From 99942154f70da83a1b3c3c624166a03ca5c5e886 Mon Sep 17 00:00:00 2001 From: Joey Castillo Date: Wed, 4 Aug 2021 11:54:19 -0400 Subject: break up sections --- watch-library/watch/watch.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) 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 +////////////////////////////////////////////////////////////////////////////////////////// +// 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; -- cgit v1.2.3