summaryrefslogtreecommitdiffstats
path: root/watch-library/shared/watch
diff options
context:
space:
mode:
authorEdward Shin <contact@edwardsh.in>2023-10-15 00:36:49 -0400
committerEdward Shin <contact@edwardsh.in>2024-01-07 00:20:20 -0500
commit5b762d016841acb3cefa60f05e963711f0a3eb2b (patch)
tree8bea5eb0443df8cbe9cd2e402d2df8dfe7445b0b /watch-library/shared/watch
parent63d6bc6aa0ddf4cc1ce1918ef7650852a25e581b (diff)
downloadSensor-Watch-5b762d016841acb3cefa60f05e963711f0a3eb2b.tar.gz
Sensor-Watch-5b762d016841acb3cefa60f05e963711f0a3eb2b.tar.bz2
Sensor-Watch-5b762d016841acb3cefa60f05e963711f0a3eb2b.zip
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
Diffstat (limited to 'watch-library/shared/watch')
-rw-r--r--watch-library/shared/watch/watch.h6
-rw-r--r--watch-library/shared/watch/watch_private.h19
2 files changed, 17 insertions, 8 deletions
diff --git a/watch-library/shared/watch/watch.h b/watch-library/shared/watch/watch.h
index 790f9a16..2f697f0a 100644
--- a/watch-library/shared/watch/watch.h
+++ b/watch-library/shared/watch/watch.h
@@ -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_ */ \ No newline at end of file
+#endif /* WATCH_H_ */
diff --git a/watch-library/shared/watch/watch_private.h b/watch-library/shared/watch/watch_private.h
index 9d55bc21..8fcc5755 100644
--- a/watch-library/shared/watch/watch_private.h
+++ b/watch-library/shared/watch/watch_private.h
@@ -38,14 +38,19 @@ void _watch_enable_tcc(void);
/// Called by buzzer and LED teardown functions. You should not call this from your app.
void _watch_disable_tcc(void);
-/// Called by main.c if plugged in to USB. You should not call this from your app.
-void _watch_enable_usb(void);
+/// Enable USB task timer. Called by USB enable routine in main(). You should not call this from your app.
+void _watch_enable_tc0(void);
+
+/// Disable USB task timer. You should not call this from your app.
+void _watch_disable_tc0(void);
-// this function ends up getting called by printf to log stuff to the USB console.
-int _write(int file, char *ptr, int len);
+/// Enable CDC task timer. Called by USB enable routine in main(). You should not call this from your app.
+void _watch_enable_tc1(void);
-// i thought this would be called by gets but it doesn't? anyway it does get called by read()
-// so that's our mechanism for reading data from the USB serial console.
-int _read(int file, char *ptr, int len);
+/// Disable CDC task timer. You should not call this from your app.
+void _watch_disable_tc1(void);
+
+/// Called by main.c if plugged in to USB. You should not call this from your app.
+void _watch_enable_usb(void);
#endif