diff options
Diffstat (limited to 'ao-tools/lib')
-rw-r--r-- | ao-tools/lib/cc-telemetry.c | 30 | ||||
-rw-r--r-- | ao-tools/lib/cc-telemetry.h | 12 | ||||
-rw-r--r-- | ao-tools/lib/cc-usb.c | 7 | ||||
-rw-r--r-- | ao-tools/lib/cc-usb.h | 2 | ||||
-rw-r--r-- | ao-tools/lib/ccdbg-flash.c | 5 |
5 files changed, 47 insertions, 9 deletions
diff --git a/ao-tools/lib/cc-telemetry.c b/ao-tools/lib/cc-telemetry.c index 99da2680..88da7f03 100644 --- a/ao-tools/lib/cc-telemetry.c +++ b/ao-tools/lib/cc-telemetry.c @@ -60,3 +60,33 @@ cc_telemetry_parse(const char *input_line, union ao_telemetry_all *telemetry) memcpy(telemetry, hex+1, 34); return TRUE; } + +uint8_t +cc_telemetry_cksum(const union ao_telemetry_all *telemetry) +{ + const uint8_t *x = (const uint8_t *) telemetry; + int i; + uint8_t sum = 0x5a; + for (i = 0; i < 34; i++) + sum += x[i]; + return sum; +} + +void +cc_telemetry_unparse(const union ao_telemetry_all *telemetry, char output_line[CC_TELEMETRY_BUFSIZE]) +{ + uint8_t hex[36]; + int i; + int p; + + hex[0] = 34; + memcpy(hex+1, telemetry, 34); + hex[35] = cc_telemetry_cksum(telemetry); + strcpy(output_line, "TELEM "); + p = strlen(output_line); + for (i = 0; i < 36; i++) { + sprintf(output_line + p, "%02x", hex[i]); + p += 2; + } +} + diff --git a/ao-tools/lib/cc-telemetry.h b/ao-tools/lib/cc-telemetry.h index e849cd3b..9a5be49f 100644 --- a/ao-tools/lib/cc-telemetry.h +++ b/ao-tools/lib/cc-telemetry.h @@ -237,7 +237,19 @@ union ao_telemetry_all { struct ao_telemetry_baro baro; }; +#define CC_TELEMETRY_HEADER "TELEM" + +/* "TELEM " 1 byte length 32 data bytes 1 rssi 1 status 1 checksum 1 null */ + +#define CC_TELEMETRY_BUFSIZE (6 + (1 + 32 + 3) * 2 + 1) + int cc_telemetry_parse(const char *input_line, union ao_telemetry_all *telemetry); +uint8_t +cc_telemetry_cksum(const union ao_telemetry_all *telemetry); + +void +cc_telemetry_unparse(const union ao_telemetry_all *telemetry, char output_line[CC_TELEMETRY_BUFSIZE]); + #endif diff --git a/ao-tools/lib/cc-usb.c b/ao-tools/lib/cc-usb.c index 1580c6d9..9f07e662 100644 --- a/ao-tools/lib/cc-usb.c +++ b/ao-tools/lib/cc-usb.c @@ -375,11 +375,12 @@ cc_usb_reset(struct cc_usb *cc) } void -cc_usb_open_remote(struct cc_usb *cc, int channel) +cc_usb_open_remote(struct cc_usb *cc, int freq, char *call) { if (!cc->remote) { - printf ("channel %d\n", channel); - cc_usb_printf(cc, "\nc r %d\np\nE 0\n", channel); + fprintf (stderr, "freq %dkHz\n", freq); + fprintf (stderr, "call %s\n", call); + cc_usb_printf(cc, "\nc F %d\nc c %s\np\nE 0\n", freq, call); do { cc->in_count = cc->in_pos = 0; _cc_usb_sync(cc, 100); diff --git a/ao-tools/lib/cc-usb.h b/ao-tools/lib/cc-usb.h index d3539281..e90e1195 100644 --- a/ao-tools/lib/cc-usb.h +++ b/ao-tools/lib/cc-usb.h @@ -63,7 +63,7 @@ void cc_usb_printf(struct cc_usb *cc, char *format, ...); void -cc_usb_open_remote(struct cc_usb *cc, int channel); +cc_usb_open_remote(struct cc_usb *cc, int freq, char *call); void cc_usb_close_remote(struct cc_usb *cc); diff --git a/ao-tools/lib/ccdbg-flash.c b/ao-tools/lib/ccdbg-flash.c index 3e672985..1b46870b 100644 --- a/ao-tools/lib/ccdbg-flash.c +++ b/ao-tools/lib/ccdbg-flash.c @@ -240,7 +240,6 @@ ccdbg_flash_lock(struct ccdbg *dbg, uint8_t lock) uint8_t ccdbg_flash_hex_image(struct ccdbg *dbg, struct hex_image *image) { - uint16_t offset; uint16_t flash_prog; uint16_t flash_len; uint8_t fwt; @@ -249,7 +248,6 @@ ccdbg_flash_hex_image(struct ccdbg *dbg, struct hex_image *image) uint16_t flash_words; uint8_t flash_words_high, flash_words_low; uint16_t ram_addr; - uint16_t pc; uint8_t status; uint16_t remain, this_time, start; uint8_t verify[0x400]; @@ -284,8 +282,6 @@ ccdbg_flash_hex_image(struct ccdbg *dbg, struct hex_image *image) if (this_time > 0x400) this_time = 0x400; - offset = ram_addr - (image->address + start); - ccdbg_debug(CC_DEBUG_FLASH, "Upload %d bytes at 0x%04x\n", this_time, ram_addr); ccdbg_write_memory(dbg, ram_addr, image->data + start, this_time); #if 0 @@ -319,7 +315,6 @@ ccdbg_flash_hex_image(struct ccdbg *dbg, struct hex_image *image) ccdbg_write_uint8(dbg, flash_prog + FLASH_WORDS_LOW, flash_words_low); ccdbg_set_pc(dbg, flash_prog); - pc = ccdbg_get_pc(dbg); ccdbg_debug(CC_DEBUG_FLASH, "Flashing %d bytes at 0x%04x\n", this_time, flash_addr); status = ccdbg_resume(dbg); |