]> git.earman.xyz Git - sensor-watch.git/commitdiff
overdue refactor: compile all watch modules separately
authorJoey Castillo <jose.castillo@gmail.com>
Tue, 28 Sep 2021 17:42:08 +0000 (13:42 -0400)
committerJoey Castillo <jose.castillo@gmail.com>
Tue, 28 Sep 2021 18:42:56 +0000 (14:42 -0400)
27 files changed:
make.mk
watch-library/hal/include/hal_calendar.h [new file with mode: 0644]
watch-library/hal/src/hal_calendar.c [new file with mode: 0644]
watch-library/watch/watch.c
watch-library/watch/watch_adc.c
watch-library/watch/watch_adc.h
watch-library/watch/watch_app.h
watch-library/watch/watch_buzzer.c
watch-library/watch/watch_buzzer.h
watch-library/watch/watch_deepsleep.c
watch-library/watch/watch_deepsleep.h
watch-library/watch/watch_extint.c
watch-library/watch/watch_extint.h
watch-library/watch/watch_gpio.c
watch-library/watch/watch_gpio.h
watch-library/watch/watch_i2c.c
watch-library/watch/watch_i2c.h
watch-library/watch/watch_led.c
watch-library/watch/watch_led.h
watch-library/watch/watch_private.c
watch-library/watch/watch_private.h
watch-library/watch/watch_rtc.c
watch-library/watch/watch_rtc.h
watch-library/watch/watch_slcd.c
watch-library/watch/watch_slcd.h
watch-library/watch/watch_uart.c
watch-library/watch/watch_uart.h

diff --git a/make.mk b/make.mk
index ae32f2dacffd10a9a4dc92e5fa0f6df545a3ac5d..299d9d31a220741604061a5138273fd7003911c5 100644 (file)
--- a/make.mk
+++ b/make.mk
@@ -71,6 +71,17 @@ SRCS += \
   $(TOP)/watch-library/main.c \
   $(TOP)/watch-library/startup_saml22.c \
   $(TOP)/watch-library/hw/driver_init.c \
+  $(TOP)/watch-library/watch/watch_rtc.c \
+  $(TOP)/watch-library/watch/watch_slcd.c \
+  $(TOP)/watch-library/watch/watch_extint.c \
+  $(TOP)/watch-library/watch/watch_led.c \
+  $(TOP)/watch-library/watch/watch_buzzer.c \
+  $(TOP)/watch-library/watch/watch_adc.c \
+  $(TOP)/watch-library/watch/watch_gpio.c \
+  $(TOP)/watch-library/watch/watch_i2c.c \
+  $(TOP)/watch-library/watch/watch_uart.c \
+  $(TOP)/watch-library/watch/watch_deepsleep.c \
+  $(TOP)/watch-library/watch/watch_private.c \
   $(TOP)/watch-library/watch/watch.c \
   $(TOP)/watch-library/hal/src/hal_atomic.c \
   $(TOP)/watch-library/hal/src/hal_delay.c \
diff --git a/watch-library/hal/include/hal_calendar.h b/watch-library/hal/include/hal_calendar.h
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/watch-library/hal/src/hal_calendar.c b/watch-library/hal/src/hal_calendar.c
new file mode 100644 (file)
index 0000000..e69de29
index 6196b1f3d88df7a815fe2ade3cf9dbd7f04f7eda..de7160c5b41b96f47bb15150942337c56f62f953 100644 (file)
 
 #include "watch.h"
 
-#include "watch_rtc.c"
-#include "watch_slcd.c"
-#include "watch_extint.c"
-#include "watch_led.c"
-#include "watch_buzzer.c"
-#include "watch_adc.c"
-#include "watch_gpio.c"
-#include "watch_i2c.c"
-#include "watch_uart.c"
-#include "watch_deepsleep.c"
-#include "watch_private.c"
-
 bool battery_is_low = false;
 
 // receives interrupts from MCLK, OSC32KCTRL, OSCCTRL, PAC, PM, SUPC and TAL, whatever that is.
index 490a49b115b757c80686dd944771ddccde4d9a35..90980a88eccd5f0fabdfc39e06f9524e57e55c52 100644 (file)
@@ -22,6 +22,8 @@
  * SOFTWARE.
  */
 
+#include "watch_adc.h"
+
 void _watch_sync_adc() {
     while (ADC->SYNCBUSY.reg);
 }
index b49f1301e15875ea1d087df13fd1d0640fad1b09..c9b6ad2a7f339a0f0f84391a5052ea8c7a596f3a 100644 (file)
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
  */
+#ifndef _WATCH_ADC_H_INCLUDED
+#define _WATCH_ADC_H_INCLUDED
 ////< @file watch_adc.h
 
+#include "watch.h"
+
 /** @addtogroup adc Analog Input
   * @brief This section covers functions related to the SAM L22's analog-to-digital converter,
   *        as well as configuring and reading values from the five analog-capable pins on the
@@ -103,3 +107,4 @@ void watch_disable_analog_input(const uint8_t pin);
 void watch_disable_adc();
 
 /// @}
+#endif
index fd7ea706f6f94d9a70eb2eb13d9e42bddf0822a7..00a6a610aac5439b550408a9fa366c767dbc0466 100644 (file)
@@ -21,6 +21,8 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
  */
+#ifndef _WATCH_APP_H_INCLUDED
+#define _WATCH_APP_H_INCLUDED
 ////< @file watch_app.h
 
 /** @addtogroup app Application Framework
@@ -103,3 +105,4 @@ void app_prepare_for_sleep();
 void app_wake_from_sleep();
 
 /// @}
+#endif
index 9cb37393378c71a747ceeccaccf1e007239cfa68..007a44cab0affb357f39e562f0d717089af2542f 100644 (file)
@@ -22,6 +22,8 @@
  * SOFTWARE.
  */
 
+#include "watch_buzzer.h"
+
  inline void watch_enable_buzzer() {
     if (!hri_tcc_get_CTRLA_reg(TCC0, TCC_CTRLA_ENABLE)) {
         _watch_enable_tcc();
index 995e059ab28b70597a6777ba75f1312b0807f68d..e15657becfad2c6ab62b4df02f941ac6f6920ad3 100644 (file)
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
  */
+#ifndef _WATCH_BUZZER_H_INCLUDED
+#define _WATCH_BUZZER_H_INCLUDED
 ////< @file watch_buzzer.h
 
+#include "watch.h"
+
 /** @addtogroup buzzer Buzzer
   * @brief This section covers functions related to the piezo buzzer embedded in the F-91W's back plate.
   */
@@ -157,3 +161,4 @@ void watch_buzzer_play_note(BuzzerNote note, uint16_t duration_ms);
 extern const uint16_t NotePeriods[108];
 
 /// @}
+#endif
index 4294b6605b26aab3fc7f89f4542779f4283393cc..c83254e43b56aedb1e2795e48d3c82a8a7f097e7 100644 (file)
@@ -22,6 +22,8 @@
  * SOFTWARE.
  */
 
+#include "watch_extint.h"
+
 // this warning only appears when you `make BOARD=OSO-SWAT-A1-02`. it's annoying,
 // but i'd rather have it warn us at build-time than fail silently at run-time.
 // besides, no one but me really has any of these boards anyway.
index dc8724d9a6fd7d84c9707c93344a1b8b6684f5c5..3dc428d051ed7ce7d0de5db880065cc09bf7501a 100644 (file)
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
  */
+#ifndef _WATCH_DEEPSLEEP_H_INCLUDED
+#define _WATCH_DEEPSLEEP_H_INCLUDED
 ////< @file watch_deepsleep.h
 
+#include "watch.h"
+
 // These are declared in watch_rtc.c.
 extern ext_irq_cb_t btn_alarm_callback;
 extern ext_irq_cb_t a2_callback;
@@ -115,3 +119,4 @@ void watch_enter_shallow_sleep(char *message);
   */
 void watch_enter_deep_sleep();
 /// @}
+#endif
index f2bad949af38d98d50cb32b1fa05e7c1485109ef..dcaa0d80673d6fdc95916c2a931f705aa19eb3ae 100644 (file)
@@ -22,6 +22,8 @@
  * SOFTWARE.
  */
 
+#include "watch_extint.h"
+
 void watch_enable_external_interrupts() {
     // Configure EIC to use GCLK3 (the 32.768 kHz crystal)
     hri_gclk_write_PCHCTRL_reg(GCLK, EIC_GCLK_ID, GCLK_PCHCTRL_GEN_GCLK3_Val | (1 << GCLK_PCHCTRL_CHEN_Pos));
index 9c810534280b791d0f0391893a1da45c10866e0d..758fe8bca3520eea2c040420f28c99c861402c93 100644 (file)
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
  */
+#ifndef _WATCH_EXTINT_H_INCLUDED
+#define _WATCH_EXTINT_H_INCLUDED
 ////< @file watch_extint.h
 
+#include "watch.h"
 #include "hal_ext_irq.h"
 
 /** @addtogroup buttons Buttons & External Interrupts
@@ -78,3 +81,4 @@ void watch_register_button_callback(const uint8_t pin, ext_irq_cb_t callback);
 __attribute__((deprecated("Use watch_enable_external_interrupts instead")))
 void watch_enable_buttons();
 /// @}
+#endif
index a9bc139d566376c827003bdc3c78210bdec4985f..b37d009f17cab40dde9a108a4bedd10bc6df2080 100644 (file)
@@ -22,6 +22,8 @@
  * SOFTWARE.
  */
 
+#include "watch_gpio.h"
+
  void watch_enable_digital_input(const uint8_t pin) {
     gpio_set_pin_direction(pin, GPIO_DIRECTION_IN);
     gpio_set_pin_function(pin, GPIO_PIN_FUNCTION_OFF);
index 640686e0861b51d04b24d683af89fdec084b1837..fc43642c4a43e6f0c2c69a5c3229c90e96a4a737 100644 (file)
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
  */
+#ifndef _WATCH_GPIO_H_INCLUDED
+#define _WATCH_GPIO_H_INCLUDED
 ////< @file watch_gpio.h
 
+#include "watch.h"
+
 /** @addtogroup gpio Digital Input and Output
   * @brief This section covers functions related to general-purpose input and output signals.
   */
@@ -69,3 +73,4 @@ void watch_disable_digital_output(const uint8_t pin);
   */
 void watch_set_pin_level(const uint8_t pin, const bool level);
 /// @}
+#endif
index 385d9d089d3029e571dce9593237107276af1041..d2cf474b9ccf1c24e2fa2366400ad0de25128a87 100644 (file)
@@ -22,7 +22,9 @@
  * SOFTWARE.
  */
 
- struct io_descriptor *I2C_0_io;
+#include "watch_i2c.h"
+
+struct io_descriptor *I2C_0_io;
 
 void watch_enable_i2c() {
     I2C_0_init();
index 7ac05c139528b697b4fe3cccbda27bfbed512f82..65df49b4b65fa3ac522001af55129e70c8db250d 100644 (file)
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
  */
+#ifndef _WATCH_I2C_H_INCLUDED
+#define _WATCH_I2C_H_INCLUDED
 ////< @file watch_i2c.h
 
+#include "watch.h"
+
 /** @addtogroup i2c I2C Controller Driver
   * @brief This section covers functions related to the SAM L22's built-I2C driver, including
   *        configuring the I2C bus, putting values directly on the bus and reading data from
@@ -99,3 +103,4 @@ uint32_t watch_i2c_read24(int16_t addr, uint8_t reg);
   */
 uint32_t watch_i2c_read32(int16_t addr, uint8_t reg);
 /// @}
+#endif
index 7b1894529511da4f75af20ac15925ea8384819b1..1348c977231aab1d6e5f63ab9fcc8ab32c670517 100644 (file)
@@ -22,6 +22,8 @@
  * SOFTWARE.
  */
 
+#include "watch_led.h"
+
 void watch_enable_leds() {
     if (!hri_tcc_get_CTRLA_reg(TCC0, TCC_CTRLA_ENABLE)) {
         _watch_enable_tcc();
index 0927e716afaac378828b7106410e8f131911c11b..2b9dead0ef5637fe8d323a3e6aa4eaccefe0e39d 100644 (file)
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
  */
+#ifndef _WATCH_LED_H_INCLUDED
+#define _WATCH_LED_H_INCLUDED
 ////< @file watch_led.h
 
+#include "watch.h"
+
 /** @addtogroup led LED Control
   * @brief This section covers functions related to the bi-color red/green LED mounted behind the LCD.
   * @details The SAM L22 is an exceedingly power efficient chip, whereas the LED's are relatively power-
@@ -86,3 +90,4 @@ void watch_enable_led(bool unused);
 __attribute__((deprecated("Use watch_disable_leds instead")))
 void watch_disable_led(bool unused);
 /// @}
+#endif
index dc70f4cb02dff568cb1a08769eba52924dfdbbb0..270208dc4d1c6f78ac98261b8c5ad2fa6a9d4cfe 100644 (file)
@@ -22,6 +22,7 @@
  * SOFTWARE.
  */
 
+#include "watch_private.h"
 #include "tusb.h"
 
 void _watch_init() {
index abee085aa956fc3d95854e02b6bc1b5eddf0395c..8045e438f83c7045a228a855832c3f9551b99cd6 100644 (file)
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
  */
+#ifndef _WATCH_PRIVATE_H_INCLUDED
+#define _WATCH_PRIVATE_H_INCLUDED
+
+#include "watch.h"
 
 /// Called by main.c while setting up the app. You should not call this from your app.
 void _watch_init();
 
+/// Initializes the real-time clock peripheral.
+void _watch_rtc_init();
+
 /// Called by buzzer and LED setup functions. You should not call this from your app.
 void _watch_enable_tcc();
 
@@ -33,3 +40,4 @@ void _watch_disable_tcc();
 
 /// Called by main.c if plugged in to USB. You should not call this from your app.
 void _watch_enable_usb();
+#endif
index 43cff478aecc2e942b8e5401e8defeb21960441d..0974c7966ea0e41d744434d36650661e9e79fff3 100644 (file)
@@ -22,6 +22,8 @@
  * SOFTWARE.
  */
 
+#include "watch_rtc.h"
+
 ext_irq_cb_t tick_callback;
 ext_irq_cb_t alarm_callback;
 ext_irq_cb_t btn_alarm_callback;
index a2248758215becfa8d239a64b026bb3af8e2cb2c..71f555abd7d81f4d41c3204fbe2876627704f679 100644 (file)
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
  */
+#ifndef _WATCH_RTC_H_INCLUDED
+#define _WATCH_RTC_H_INCLUDED
 ////< @file watch_rtc.h
 
+#include "watch.h"
 #include "hpl_calendar.h"
 
 /** @addtogroup rtc Real-Time Clock
@@ -122,3 +125,4 @@ __attribute__((deprecated("Use the watch_rtc_get_date_time function instead")))
 void watch_get_date_time(struct calendar_date_time *date_time);
 
 /// @}
+#endif
index 7210713a9de3fbf3c4cff1ea90d2c116ece3d444..ba9d12b25e6f04ffcacca6a89a771968c7b52fef 100644 (file)
@@ -22,6 +22,8 @@
  * SOFTWARE.
  */
 
+#include "watch_slcd.h"
+
  //////////////////////////////////////////////////////////////////////////////////////////
 // Segmented Display
 
index efef99acfaf175c04b2a285f8e4ddac71e071d77..4f5a617c072a7806351c26e583210e2f8c7f2060 100644 (file)
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
  */
+#ifndef _WATCH_SLCD_H_INCLUDED
+#define _WATCH_SLCD_H_INCLUDED
 ////< @file watch_slcd.h
 
+#include "watch.h"
+
 /** @addtogroup slcd Segment LCD Display
   * @brief This section covers functions related to the Segment LCD display driver, which is responsible
   *        for displaying strings of characters and indicators on the main watch display.
@@ -100,3 +104,4 @@ void watch_clear_indicator(WatchIndicatorSegment indicator);
 void watch_clear_all_indicators();
 
 /// @}
+#endif
index 3d97803d77e826e00f2da4d4760b9f4a72f77c70..d35533d066b2e3806f207516e2880f18605db789 100644 (file)
@@ -50,6 +50,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include "watch_uart.h"
 #include "peripheral_clk_config.h"
 
 void watch_enable_debug_uart(uint32_t baud) {
index 3c4f7aef82a673ba7a86d7d5b2b97e5047f94572..3e98bd35478ef0c2ab52562712383ac2cfa1718e 100644 (file)
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
  */
+#ifndef _WATCH_UART_H_INCLUDED
+#define _WATCH_UART_H_INCLUDED
 ////< @file watch_uart.h
 
+#include "watch.h"
+
 /** @addtogroup debug Debug UART
   * @brief This section covers functions related to the debug UART, available on
   *        pin D1 of the 9-pin connector.
@@ -51,3 +55,4 @@ void watch_debug_putc(char c);
 __attribute__((deprecated("Use printf to log debug messages over USB.")))
 void watch_debug_puts(char *s);
 /// @}
+#endif