]> git.earman.xyz Git - sensor-watch.git/commitdiff
clean up location of some private functions
authorjoeycastillo <joeycastillo@utexas.edu>
Wed, 18 Sep 2024 21:05:10 +0000 (17:05 -0400)
committerjoeycastillo <joeycastillo@utexas.edu>
Wed, 18 Sep 2024 21:05:10 +0000 (17:05 -0400)
watch-library/hardware/watch/watch.c
watch-library/hardware/watch/watch_private.c
watch-library/shared/watch/watch.h
watch-library/shared/watch/watch_private.h

index c7a5b2377de83fd5d3a6f0541d55349746027d67..e7fdbbd749d49c7b2b46404f4650910ebc4824f3 100644 (file)
@@ -25,7 +25,7 @@
 #include "watch.h"
 
 // receives interrupts from MCLK, OSC32KCTRL, OSCCTRL, PAC, PM, SUPC and TAL, whatever that is.
-void SYSTEM_Handler(void) {
+void irq_handler_system(void) {
     if (SUPC->INTFLAG.bit.BOD33DET) {
         // Our system voltage has dipped below 2.6V!
         // Set the voltage regulator to work at low system voltage before we hit 2.5 V
@@ -37,13 +37,3 @@ void SYSTEM_Handler(void) {
         SUPC->INTFLAG.reg &= ~SUPC_INTFLAG_BOD33DET;
     }
 }
-
-bool watch_is_usb_enabled(void) {
-    return USB->DEVICE.CTRLA.bit.ENABLE;
-}
-
-void watch_reset_to_bootloader(void) {
-    volatile uint32_t *dbl_tap_ptr = ((volatile uint32_t *)(HSRAM_ADDR + HSRAM_SIZE - 4));
-    *dbl_tap_ptr = 0xf01669ef; // from the UF2 bootloaer: uf2.h line 255
-    NVIC_SystemReset();
-}
index 57fa31c730f0eb53ac089e7ee4734218b6423332..d13c216951332a557bb4245e302368f94757d3e5 100644 (file)
@@ -414,3 +414,9 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
 
     return _desc_str;
 }
+
+void watch_reset_to_bootloader(void) {
+    volatile uint32_t *dbl_tap_ptr = ((volatile uint32_t *)(HSRAM_ADDR + HSRAM_SIZE - 4));
+    *dbl_tap_ptr = 0xf01669ef; // from the UF2 bootloaer: uf2.h line 255
+    NVIC_SystemReset();
+}
index 92504913f04b79427834c3d04f57266810220652..64f0830e7b546613c8cf1c402fa654fcf15b02dd 100644 (file)
@@ -23,8 +23,8 @@
  */
 /// @file watch.h
 
-#ifndef WATCH_H_
-#define WATCH_H_
+#pragma once
+
 #include <stdint.h>
 #include <stdbool.h>
 #include "pins.h"
@@ -73,11 +73,13 @@ typedef void (*watch_cb_t)(void);
 // #include "watch_storage.h"
 // #include "watch_deepsleep.h"
 
-// #include "watch_private.h"
-
-/** @brief Returns true if USB is enabled.
-  */
-bool watch_is_usb_enabled(void);
+/** @brief Interrupt handler for the SYSTEM interrupt, which handles MCLK,
+ *         OSC32KCTRL, OSCCTRL, PAC, PM and SUPC.
+ *  @details We use this to detect when the system voltage has dipped below
+ *           2.6V, which means it's time to disable the voltage regulator's
+ *           high-efficiency mode, which only works down to 2.5V.
+ */
+void irq_handler_system(void);
 
 /** @brief Resets in the UF2 bootloader mode
   */
@@ -96,7 +98,6 @@ void cdc_task(void);
 int read(int file, char *ptr, int len);
 
 /** @brief Disables the TRNG twice in order to work around silicon erratum 1.16.1.
+ *  FIXME: find a better place for this, a couple of watch faces need it.
  */
-void watch_disable_TRNG();
-
-#endif /* WATCH_H_ */
+void watch_disable_TRNG(void);
index b833107c9a2cf849a0e50f1771e901cf928c1760..57da4fa1f1b3633666589f1762ddc55359c85b55 100644 (file)
@@ -29,9 +29,6 @@
 /// Called by main.c while setting up the app. You should not call this from your app.
 void _watch_init(void);
 
-/// Initializes the real-time clock peripheral.
-void _watch_rtc_init(void);
-
 /// Called by buzzer and LED teardown functions. You should not call this from your app.
 void _watch_disable_tcc(void);
 
@@ -50,4 +47,7 @@ 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);
 
+/// Initializes the real-time clock peripheral. Implemented in watch_rtc.c
+void _watch_rtc_init(void);
+
 #endif