diff options
author | Keith Packard <keithp@keithp.com> | 2009-04-20 23:33:41 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2009-04-20 23:33:41 -0700 |
commit | 43c8f7012102cdb591ace899420c10e4a78385ad (patch) | |
tree | 6ce45d0a58b1133961acd3cda3f3be21fef085b4 /ao_ee.c | |
parent | 5be13b76a2e29b84cd6d1eec065e3354b0dafce5 (diff) |
Add radio support. Build separate executables for TeleMetrum and the TI dongle
Ok, way too big a patch, but things were in rough shape.
This patch adds support for the radio, both transmit and receive.
Then, because I could no longer run the TeleMetrum code on the TI
dongle, I ended up building a separate image for the TI board, which
involved creating a mechanism for having multiple command sets and splitting
code for different functions into different files.
Diffstat (limited to 'ao_ee.c')
-rw-r--r-- | ao_ee.c | 62 |
1 files changed, 62 insertions, 0 deletions
@@ -347,6 +347,67 @@ ao_ee_read_config(uint8_t *buf, uint16_t len) __reentrant return 1; } +static void +ee_dump(void) +{ + __xdata uint8_t b; + __xdata uint16_t block; + __xdata uint8_t i; + + ao_cmd_hex(); + block = ao_cmd_lex_i; + if (ao_cmd_status != ao_cmd_success) + return; + i = 0; + do { + if ((i & 7) == 0) { + if (i) + putchar('\n'); + ao_cmd_put16((uint16_t) i); + } + putchar(' '); + ao_ee_read(((uint32_t) block << 8) | i, &b, 1); + ao_cmd_put8(b); + ++i; + } while (i != 0); + putchar('\n'); +} + +static void +ee_store(void) +{ + __xdata uint16_t block; + __xdata uint8_t i; + __xdata uint16_t len; + __xdata uint8_t b; + __xdata uint32_t addr; + + ao_cmd_hex(); + block = ao_cmd_lex_i; + ao_cmd_hex(); + i = ao_cmd_lex_i; + addr = ((uint32_t) block << 8) | i; + ao_cmd_hex(); + len = ao_cmd_lex_i; + if (ao_cmd_status != ao_cmd_success) + return; + while (len--) { + ao_cmd_hex(); + if (ao_cmd_status != ao_cmd_success) + return; + b = ao_cmd_lex_i; + ao_ee_write(addr, &b, 1); + addr++; + } + ao_ee_flush(); +} + +__code struct ao_cmds ao_ee_cmds[] = { + { 'e', ee_dump, "e <block> Dump a block of EEPROM data\n" }, + { 'w', ee_store, "w <block> <start> <len> <data> ... Write data to EEPROM\n" }, + { 0, ee_store, NULL }, +}; + /* * To initialize the chip, set up the CS line and * the SPI interface @@ -393,4 +454,5 @@ ao_ee_init(void) UxGCR_CPHA_FIRST_EDGE | UxGCR_ORDER_MSB | (17 << UxGCR_BAUD_E_SHIFT)); + ao_cmd_register(&ao_ee_cmds[0]); } |