diff options
| -rw-r--r-- | fw/usb.c | 23 | ||||
| -rw-r--r-- | sw/usbcom/usbcom.c | 2 |
2 files changed, 16 insertions, 9 deletions
@@ -72,8 +72,10 @@ idleState(void) { static State state; uint8_t opcode; + state.next = idleState; + readLen = getsUSBUSART(readBuf, sizeof(readBuf)); - if (readLen >= 2u) { + if (readLen >= 2u) { // <opcode> <space> ... opcode = readBuf[0u]; // skip <opcode> <space> @@ -84,11 +86,8 @@ idleState(void) { case 'e': state.next = echoState; break; case 'w': state.next = writeEepromState; break; case 'r': state.next = readEepromState; break; - default: state.next = idleState; break; // invalid command + default: break; // invalid command } - } else { - // Invalid command. Must start with <opcode> <space> - state.next = idleState; } return &state; @@ -97,9 +96,11 @@ idleState(void) { // Handle "e" echo command. static State * echoState(void) { - static State state = {echoState}; + static State state; uint8_t i; + state.next = echoState; + if (readLen == 0u) { readLen = getsUSBUSART(readBuf, sizeof(readBuf)); } @@ -125,16 +126,22 @@ echoState(void) { // Handle "w" write eeprom command. static State * writeEepromState(void) { - static State state = {idleState}; + static State state; + // TODO + + state.next = idleState; return &state; } // Handle "r" read eeprom command. static State * readEepromState(void) { - static State state = {idleState}; + static State state; + // TODO + + state.next = idleState; return &state; } diff --git a/sw/usbcom/usbcom.c b/sw/usbcom/usbcom.c index a51bd6f..a374875 100644 --- a/sw/usbcom/usbcom.c +++ b/sw/usbcom/usbcom.c @@ -6,7 +6,7 @@ #include <libusb-1.0/libusb.h> -#define TIMEOUT_MS 1000 +#define TIMEOUT_MS 5000 #define BUF_SIZE 512 |