You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
2.3KB

  1. /***************************************************************************
  2. * Copyright (C) 10/2010 by Olaf Rempel *
  3. * razzor@kopf-tisch.de *
  4. * *
  5. * This program is free software; you can redistribute it and/or modify *
  6. * it under the terms of the GNU General Public License as published by *
  7. * the Free Software Foundation; version 2 of the License, *
  8. * *
  9. * This program is distributed in the hope that it will be useful, *
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  12. * GNU General Public License for more details. *
  13. * *
  14. * You should have received a copy of the GNU General Public License *
  15. * along with this program; if not, write to the *
  16. * Free Software Foundation, Inc., *
  17. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
  18. ***************************************************************************/
  19. #include <stdio.h>
  20. #include <stdlib.h>
  21. #include <unistd.h>
  22. #include <string.h>
  23. #include <stdint.h>
  24. #include "chipinfo_avr.h"
  25. #define ARRAY_SIZE(x) (sizeof(x) / sizeof(*x))
  26. struct chipinfo
  27. {
  28. uint8_t sig[3];
  29. const char name[16];
  30. };
  31. static struct chipinfo chips[] =
  32. {
  33. { { 0x1E, 0x93, 0x07 }, "AVR Mega 8" },
  34. { { 0x1E, 0x93, 0x0A }, "AVR Mega 88" },
  35. { { 0x1E, 0x94, 0x06 }, "AVR Mega 168" },
  36. { { 0x1E, 0x95, 0x02 }, "AVR Mega 32" },
  37. };
  38. /* *************************************************************************
  39. * chipinfo_get_avr_name
  40. * ************************************************************************* */
  41. const char * chipinfo_get_avr_name(const uint8_t *sig)
  42. {
  43. int i;
  44. for (i = 0; i < ARRAY_SIZE(chips); i++)
  45. {
  46. struct chipinfo *chip = &chips[i];
  47. if (chip->sig[0] == sig[0] && chip->sig[1] == sig[1] && chip->sig[2] == sig[2])
  48. {
  49. return chip->name;
  50. }
  51. }
  52. return "unknown";
  53. } /* chipinfo_get_avr_name */