USB Improvements

* Introduce shell module for basic serial shell with argument parsing
* Introduce shell_cmd_list module for basic compile-time command
  registration
* Harden USB handling to hang less and drop fewer inputs
  - Service tud_task() with periodic TC0 timer interrupt
  - Service cdc_task() with periodic TC1 timer interrupt
  - Handle shell servicing in main app loop
  - Add a circular buffering layer for reads/writes
* Change newline prints to also send carriage return
* Refactor filesystem commands for shell subsystem
* Introduce new shell commands:
  - 'help' command
  - 'flash' command to reset into bootloader
  - 'stress' command to stress CDC writes

Testing:
* Shell validated on Sensor Watch Blue w/ Linux host
* Shell validated in emscripten emulator
* Tuned by spamming inputs during `stress` cmd until stack didn't crash
This commit is contained in:
Edward Shin
2023-10-15 00:36:49 -04:00
parent 63d6bc6aa0
commit 5b762d0168
15 changed files with 820 additions and 160 deletions

View File

@@ -88,6 +88,10 @@ bool watch_is_usb_enabled(void);
*/
void watch_reset_to_bootloader(void);
/** @brief Call periodically from app main loop to service CDC RX/TX.
*/
void cdc_task(void);
/** @brief Reads up to len bytes from the USB serial.
* @param file ignored, you can pass in 0
* @param ptr pointer to a buffer of at least len bytes
@@ -96,4 +100,4 @@ void watch_reset_to_bootloader(void);
*/
int read(int file, char *ptr, int len);
#endif /* WATCH_H_ */
#endif /* WATCH_H_ */