Merge branch 'chronos'

This commit is contained in:
Daniel Beer 2010-04-13 20:46:25 +12:00
commit 437456dda1
1 changed files with 73 additions and 23 deletions

94
fet.c
View File

@ -610,7 +610,7 @@ static int do_erase(void)
return -1;
}
if (xfer(C_ERASE, NULL, 0, 3, FET_ERASE_ALL, 0x1000, 0x100) < 0) {
if (xfer(C_ERASE, NULL, 0, 3, FET_ERASE_MAIN, 0x8000, 2) < 0) {
fprintf(stderr, "fet: erase command failed\n");
return -1;
}
@ -777,6 +777,74 @@ const static struct device fet_device = {
.writemem = fet_writemem
};
static const u_int8_t rf2500_29_magic[] = {
0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00, 0x10,
0xff, 0x10, 0x40, 0x00, 0x00, 0x02, 0xff, 0x05,
0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00,
0x01, 0x00, 0xd7, 0x60, 0x00, 0x00, 0x00, 0x00,
0x08, 0x07, 0x10, 0x0e, 0xc4, 0x09, 0x70, 0x17,
0x58, 0x1b, 0x01, 0x00, 0x03, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x33, 0x0f, 0x1f, 0x0f,
0xff, 0xff
};
static const u_int8_t chronos_2b_magic[] = {
0x00, 0x10, 0xff, 0x17, 0x00, 0x02, 0x01, 0x00,
0x04, 0x00, 0x40, 0x00, 0x0a, 0x91, 0x8e, 0x00,
0x00, 0xb0, 0x28, 0x29, 0x2a, 0x2b, 0x80, 0xd8,
0xa8, 0x60, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00
};
static const u_int8_t chronos_29_magic[] = {
0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00, 0x18,
0xff, 0x19, 0x80, 0x00, 0x00, 0x1c, 0xff, 0x2b,
0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x02, 0x00,
0x02, 0x00, 0x07, 0x24, 0x00, 0x00, 0x00, 0x00,
0x08, 0x07, 0x10, 0x0e, 0xc4, 0x09, 0x70, 0x17,
0x58, 0x1b, 0x01, 0x00, 0x03, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff
};
static int do_magic(void)
{
if (fet_version >= 30001000) {
printf("Sending Chronos init messages...\n");
if (xfer(0x2b, chronos_2b_magic,
sizeof(chronos_2b_magic), 0) < 0) {
fprintf(stderr, "fet: command 0x2b failed\n");
return -1;
}
if (xfer(0x29, chronos_29_magic,
sizeof(chronos_29_magic), 3, 0x77, 0x6f, 0x4a) < 0) {
fprintf(stderr, "fet: command 0x29 failed\n");
return -1;
}
} else if (fet_version >= 30000000) {
printf("Sending RF2500 init messages...\n");
if (xfer(0x29, rf2500_29_magic,
sizeof(rf2500_29_magic), 3, 0, 0x39, 0x31) < 0) {
fprintf(stderr, "fet: command 0x29 failed\n");
return -1;
}
}
return 0;
}
const struct device *fet_open(const struct fet_transport *tr,
int proto_flags, int vcc_mv)
{
@ -821,29 +889,11 @@ const struct device *fet_open(const struct fet_transport *tr,
return NULL;
}
/* Who knows what this is. Without it, register reads don't work.
* This is RF2500-specific.
*/
if (fet_is_rf2500) {
static const u_int8_t data[] = {
0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00, 0x10,
0xff, 0x10, 0x40, 0x00, 0x00, 0x02, 0xff, 0x05,
0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00,
0x01, 0x00, 0xd7, 0x60, 0x00, 0x00, 0x00, 0x00,
0x08, 0x07, 0x10, 0x0e, 0xc4, 0x09, 0x70, 0x17,
0x58, 0x1b, 0x01, 0x00, 0x03, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x33, 0x0f, 0x1f, 0x0f,
0xff, 0xff
};
if (xfer(0x29, data, sizeof(data), 4, 0, 0x39, 0x31,
sizeof(data)) < 0) {
fprintf(stderr, "fet: command 0x29 failed\n");
/* Send the magic required by RF2500 and Chronos FETs */
if (do_magic() < 0) {
fprintf(stderr, "fet: init magic failed\n");
return NULL;
}
}
return &fet_device;
}