]> git.earman.xyz Git - sensor-watch.git/commitdiff
break up sections
authorJoey Castillo <jose.castillo@gmail.com>
Wed, 4 Aug 2021 15:54:19 +0000 (11:54 -0400)
committerJoey Castillo <jose.castillo@gmail.com>
Wed, 4 Aug 2021 15:54:39 +0000 (11:54 -0400)
watch-library/watch/watch.c

index 922aeb0acbe751c83816213ed7a439d72818be8c..ffb7d4468cb6871c8a6916566dd70bdae1dc6f1a 100644 (file)
@@ -1,6 +1,9 @@
 #include "watch.h"
 #include <stdlib.h>
 
+//////////////////////////////////////////////////////////////////////////////////////////
+// Initialization
+
 void watch_init() {
     // Use switching regulator for lower power consumption.
     SUPC->VREG.bit.SEL = 1;
@@ -13,6 +16,8 @@ void watch_init() {
     // Not sure if this belongs in every app -- is there a power impact?
     delay_driver_init();
 }
+//////////////////////////////////////////////////////////////////////////////////////////
+// Segmented Display
 
 static const uint8_t Character_Set[] =
 {
@@ -170,6 +175,9 @@ void watch_display_string(char *string, uint8_t position) {
     }
 }
 
+//////////////////////////////////////////////////////////////////////////////////////////
+// Buttons
+
 void watch_enable_buttons() {
     EXTERNAL_IRQ_0_init();
 }
@@ -178,6 +186,9 @@ void watch_register_button_callback(const uint32_t pin, ext_irq_cb_t callback) {
     ext_irq_register(pin, callback);
 }
 
+//////////////////////////////////////////////////////////////////////////////////////////
+// LED
+
 bool PWM_0_enabled = false;
 
 void watch_enable_led(bool pwm) {
@@ -250,6 +261,9 @@ void watch_set_led_off() {
     }
 }
 
+//////////////////////////////////////////////////////////////////////////////////////////
+// Real-time Clock
+
 bool watch_rtc_is_enabled() {
     return RTC->MODE0.CTRLA.bit.ENABLE;
 }
@@ -274,6 +288,9 @@ void watch_enable_tick_callback(ext_irq_cb_t callback) {
     _prescaler_register_callback(&CALENDAR_0.device, &tick_callback);
 }
 
+//////////////////////////////////////////////////////////////////////////////////////////
+// Analog Input
+
 static bool ADC_0_ENABLED = false;
 
 void watch_enable_analog(const uint8_t pin) {
@@ -296,6 +313,9 @@ void watch_enable_analog(const uint8_t pin) {
     }
 }
 
+//////////////////////////////////////////////////////////////////////////////////////////
+// Digital IO
+
 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);
@@ -326,6 +346,9 @@ void watch_set_pin_level(const uint8_t pin, const bool level) {
     gpio_set_pin_level(pin, level);
 }
 
+//////////////////////////////////////////////////////////////////////////////////////////
+// I2C
+
 struct io_descriptor *I2C_0_io;
 
 void watch_enable_i2c() {
@@ -344,6 +367,9 @@ void watch_i2c_receive(int16_t addr, uint8_t *buf, uint16_t length) {
     io_read(I2C_0_io, buf, length);
 }
 
+//////////////////////////////////////////////////////////////////////////////////////////
+// Deep Sleep
+
 void watch_store_backup_data(uint32_t data, uint8_t reg) {
     if (reg < 8) {
         RTC->MODE0.BKUP[reg].reg = data;