diff --git a/avr/usbload/dump.c b/avr/usbload/dump.c index d13d689..b9ab93d 100644 --- a/avr/usbload/dump.c +++ b/avr/usbload/dump.c @@ -26,6 +26,7 @@ #include "info.h" #include "uart.h" #include "sram.h" +#include "dump.h" extern FILE uart_stdout; diff --git a/avr/usbload/shell.c b/avr/usbload/shell.c index 962478d..b941d26 100644 --- a/avr/usbload/shell.c +++ b/avr/usbload/shell.c @@ -17,28 +17,34 @@ * * ===================================================================================== */ - #include - #include - #include - #include +#include +#include +#include +#include +#include +#include +#include +#include - #include "pwm.h" - #include "debug.h" - #include "info.h" - #include "sram.h" - - #define RECEIVE_BUF_LEN 40 - - uint8_t recv_buf[RECEIVE_BUF_LEN]; - volatile uint8_t recv_counter = 0; - volatile uint8_t cr = 0; - - - static char *token_ptr; - static char *get_token(void) - { - char *p = token_ptr; +#include "pwm.h" +#include "debug.h" +#include "info.h" +#include "sram.h" +#include "util.h" +#include "uart.h" + +#define RECEIVE_BUF_LEN 40 + +uint8_t recv_buf[RECEIVE_BUF_LEN]; +volatile uint8_t recv_counter = 0; +volatile uint8_t cr = 0; + +uint8_t *token_ptr; + +uint8_t *get_token(void) +{ + uint8_t *p = token_ptr; while (*p == ' ') p++; if (*p == '\0') @@ -52,83 +58,78 @@ } } while (*token_ptr != '\0'); return p; - } +} - static int get_dec(int *decval) - { - const char *t; +uint8_t get_dec(uint32_t *decval) +{ + const uint8_t *t; t = get_token(); if (t != NULL) { - int x = Util_sscandec(t); + int x = util_sscandec(t); if (x < 0) - return FALSE; + return 0; *decval = x; - return TRUE; + return 1; } - return FALSE; + return 0; } - static int parse_hex(const char *s, UWORD *hexval) - { - int x = Util_sscanhex(s); - #ifdef MONITOR_HINTS - int y = find_label_value(s); - if (y >= 0) { - if (x < 0 || x > 0xffff || x == y) { - *hexval = (UWORD) y; - return TRUE; - } - /* s can be a hex number or a label name */ - printf("%s is ambiguous. Use 0%X or %X instead.\n", s, x, y); - return FALSE; - } - #endif - if (x < 0 || x > 0xffff) - return FALSE; - *hexval = (UWORD) x; - return TRUE; +uint8_t parse_hex(const uint8_t *s, uint32_t *hexval) +{ + uint32_t x = util_sscanhex(s); + if (x > 0xffffff) + return 0; + *hexval = (uint32_t) x; + return 1; } - static int get_hex(UWORD *hexval) - { - const char *t; +uint8_t get_hex(uint32_t *hexval) +{ + const uint8_t *t; t = get_token(); if (t != NULL) return parse_hex(t, hexval); - return FALSE; + return 0; } - static int get_hex2(UWORD *hexval1, UWORD *hexval2) - { +uint8_t get_hex_arg2(uint32_t *hexval1, uint32_t *hexval2) +{ return get_hex(hexval1) && get_hex(hexval2); - } +} - static int get_hex3(UWORD *hexval1, UWORD *hexval2, UWORD *hexval3) - { +uint8_t get_hex_arg3(uint32_t *hexval1, uint32_t *hexval2, uint32_t *hexval3) +{ return get_hex(hexval1) && get_hex(hexval2) && get_hex(hexval3); +} + +static uint8_t get_int32(uint32_t *val) + { + if (!get_hex(val)){ + printf("Invalid argument!\n"); + return 0; + } else { + return 1; + } } - static void get_uword(UWORD *val) + static uint8_t get_int8(uint8_t *val) { - if (!get_hex(val)) + uint32_t ret; + if (!get_hex(&ret) ||ret > 0xff){ printf("Invalid argument!\n"); - } - - static void get_ubyte(UBYTE *val) - { - UWORD uword; - if (!get_hex(&uword) || uword > 0xff) - printf("Invalid argument!\n"); - else - *val = (UBYTE) uword; + return 0; + }else{ + *val = (uint8_t)ret; + return 1; + } } static int get_bool(void) { - const char *t; + const uint8_t *t; t = get_token(); if (t != NULL) { - int result = Util_sscanbool(t); + int result = util_sscanbool(t); if (result >= 0) return result; } @@ -170,3 +171,32 @@ ISR(USART0_RX_vect) // Interrupt for UART Byte received } UCSR0B |= (1< currentDocument - avr/usbload/util.c + avr/usbload/shell.c documents @@ -21,19 +21,109 @@ 271 metaData + avr/usbload/crc.c + + caret + + column + 0 + line + 59 + + firstVisibleColumn + 0 + firstVisibleLine + 15 + + avr/usbload/debug.c + + caret + + column + 0 + line + 26 + + columnSelection + + firstVisibleColumn + 0 + firstVisibleLine + 0 + selectFrom + + column + 0 + line + 25 + + selectTo + + column + 0 + line + 26 + + + avr/usbload/dump.c + + caret + + column + 12 + line + 67 + + columnSelection + + firstVisibleColumn + 0 + firstVisibleLine + 35 + selectFrom + + column + 5 + line + 67 + + selectTo + + column + 16 + line + 67 + + avr/usbload/main.c caret column - 42 + 0 line - 252 + 28 + columnSelection + firstVisibleColumn 0 firstVisibleLine - 247 + 0 + selectFrom + + column + 0 + line + 22 + + selectTo + + column + 0 + line + 28 + avr/usbload/rle.h @@ -65,35 +155,33 @@ 0 + avr/usbload/shared_memory.h + + caret + + column + 45 + line + 24 + + firstVisibleColumn + 0 + firstVisibleLine + 0 + avr/usbload/shell.c caret column - 0 + 41 line - 74 + 177 - columnSelection - firstVisibleColumn 0 firstVisibleLine - 80 - selectFrom - - column - 0 - line - 73 - - selectTo - - column - 0 - line - 74 - + 154 avr/usbload/shell.h @@ -102,28 +190,12 @@ column 0 line - 0 + 23 - columnSelection - firstVisibleColumn 0 firstVisibleLine 0 - selectFrom - - column - 0 - line - 19 - - selectTo - - column - 0 - line - 0 - avr/usbload/sram.c @@ -188,14 +260,14 @@ caret column - 15 + 1 line - 46 + 25 firstVisibleColumn 0 firstVisibleLine - 14 + 0 avr/usbload/util.h @@ -261,12 +333,16 @@ avr/usbload/sram.c avr/usbload/main.c avr/usbload/shell.c + avr/usbload/crc.c + avr/usbload/dump.c + avr/usbload/debug.c avr/usbload/uart.c avr/usbload/util.c avr/usbload/util.h avr/usbload/usb_bulk.h avr/usbload/rle.h avr/usbload/shell.h + avr/usbload/shared_memory.h showFileHierarchyDrawer