diff options
author | Joey Castillo <jose.castillo@gmail.com> | 2021-08-04 11:54:19 -0400 |
---|---|---|
committer | Joey Castillo <jose.castillo@gmail.com> | 2021-08-04 11:54:39 -0400 |
commit | 99942154f70da83a1b3c3c624166a03ca5c5e886 (patch) | |
tree | 5ce7c962e190e0e0e3d1e32af51df0925d34f2c6 /watch-library/watch | |
parent | fc31739eb6fdf230a26930e8d42de7a26558aeae (diff) | |
download | Sensor-Watch-99942154f70da83a1b3c3c624166a03ca5c5e886.tar.gz Sensor-Watch-99942154f70da83a1b3c3c624166a03ca5c5e886.tar.bz2 Sensor-Watch-99942154f70da83a1b3c3c624166a03ca5c5e886.zip |
break up sections
Diffstat (limited to 'watch-library/watch')
-rw-r--r-- | watch-library/watch/watch.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/watch-library/watch/watch.c b/watch-library/watch/watch.c index 922aeb0a..ffb7d446 100644 --- a/watch-library/watch/watch.c +++ b/watch-library/watch/watch.c @@ -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; |