Initial import of the bootloader code
[bootloader] / cli / devices.c
CommitLineData
9c66c9ff
JM
1#include <string.h>
2#include <stdint.h>
3#include "devices.h"
4
5/* list of devices we know the ID of */
6static const devid_t device_list[] = {
7 /* { devid, devmask, name, memwords, rowsize } */
8 { 0x3020, 0x3FFF, "PIC16F1454", 0x2000, 32 },
9 { 0x3024, 0x3FFF, "PIC16LF1454", 0x2000, 32 },
10 { 0x3021, 0x3FFF, "PIC16F1455", 0x2000, 32 },
11 { 0x3025, 0x3FFF, "PIC16LF1455", 0x2000, 32 },
12 { 0x3023, 0x3FFF, "PIC16F1459", 0x2000, 32 },
13 { 0x3027, 0x3FFF, "PIC16LF1459", 0x2000, 32 },
14 { 0x1480, 0x3FE0, "PIC16F1847", 0x2000, 32 },
15 { 0x14A0, 0x3FE0, "PIC16LF1847", 0x2000, 32 },
16 { 0x1B80, 0x3FE0, "PIC12F1840", 0x1000, 32 },
17 { 0x1BC0, 0x3FE0, "PIC12LF1840", 0x1000, 32 },
18 { 0, 0, NULL, 0, 0}
19};
20
21const char *devidtoname(uint16_t devid)
22{
23 const devid_t *d = device_list;
24 while (d->name != NULL) {
25 if ((devid & d->mask) == d->id)
26 return d->name;
27 d++;
28 }
29 return "Unknown";
30}
31
32const devid_t * devid_to_info(uint16_t devid)
33{
34 const devid_t *d = device_list;
35 while (d->name != NULL) {
36 if ((devid & d->mask) == d->id)
37 return d;
38 d++;
39 }
40 return NULL;
41}