2014-12-26 11:36:32 +01:00
|
|
|
/***************************************************************************
|
|
|
|
* Copyright (C) 10/2010 by Olaf Rempel *
|
|
|
|
* razzor@kopf-tisch.de *
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; version 2 of the License, *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program; if not, write to the *
|
|
|
|
* Free Software Foundation, Inc., *
|
|
|
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
|
|
|
***************************************************************************/
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#include "chipinfo_avr.h"
|
|
|
|
|
|
|
|
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(*x))
|
|
|
|
|
2020-01-17 23:26:41 +01:00
|
|
|
static avr_chipinfo_t chips[] =
|
2017-03-07 20:09:48 +01:00
|
|
|
{
|
2020-01-17 23:26:41 +01:00
|
|
|
{ { 0x1E, 0x93, 0x07 }, "ATmega8", 0x2000, 0x200 },
|
|
|
|
{ { 0x1E, 0x93, 0x0A }, "ATmega88", 0x2000, 0x200 },
|
2020-10-17 21:30:44 +02:00
|
|
|
{ { 0x1E, 0x93, 0x0B }, "ATtiny85", 0x2000, 0x200 },
|
2020-01-17 23:26:41 +01:00
|
|
|
{ { 0x1E, 0x94, 0x06 }, "ATmega168", 0x4000, 0x200 },
|
|
|
|
{ { 0x1E, 0x95, 0x02 }, "ATmega32", 0x8000, 0x400 },
|
|
|
|
{ { 0x1E, 0x95, 0x0F }, "ATmega328p", 0x8000, 0x400 },
|
2014-12-26 11:36:32 +01:00
|
|
|
};
|
|
|
|
|
2017-03-07 20:09:48 +01:00
|
|
|
/* *************************************************************************
|
2020-01-17 23:26:41 +01:00
|
|
|
* chipinfo_get_by_signature
|
2017-03-07 20:09:48 +01:00
|
|
|
* ************************************************************************* */
|
2020-01-17 23:26:41 +01:00
|
|
|
const avr_chipinfo_t * chipinfo_get_by_signature(const uint8_t *sig)
|
2014-12-26 11:36:32 +01:00
|
|
|
{
|
2019-08-11 11:16:26 +02:00
|
|
|
unsigned int i;
|
2017-03-07 20:09:48 +01:00
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(chips); i++)
|
|
|
|
{
|
2020-01-17 23:26:41 +01:00
|
|
|
avr_chipinfo_t *chip = &chips[i];
|
|
|
|
|
|
|
|
if ((chip->sig[0] == sig[0]) &&
|
|
|
|
(chip->sig[1] == sig[1]) &&
|
|
|
|
(chip->sig[2] == sig[2])
|
|
|
|
)
|
2017-03-07 20:09:48 +01:00
|
|
|
{
|
2020-01-17 23:26:41 +01:00
|
|
|
return chip;
|
2017-03-07 20:09:48 +01:00
|
|
|
}
|
2014-12-26 11:36:32 +01:00
|
|
|
}
|
|
|
|
|
2020-01-17 23:26:41 +01:00
|
|
|
return NULL;
|
|
|
|
} /* chipinfo_get_by_signature */
|
|
|
|
|
|
|
|
|
|
|
|
/* *************************************************************************
|
|
|
|
* chipinfo_get_avr_name
|
|
|
|
* ************************************************************************* */
|
|
|
|
const char * chipinfo_get_avr_name(const uint8_t *sig)
|
|
|
|
{
|
|
|
|
const avr_chipinfo_t * p_chipinfo;
|
|
|
|
|
|
|
|
p_chipinfo = chipinfo_get_by_signature(sig);
|
|
|
|
|
|
|
|
return (p_chipinfo != NULL) ? p_chipinfo->name : "unknown";
|
2017-03-07 20:09:48 +01:00
|
|
|
} /* chipinfo_get_avr_name */
|