diff options
Diffstat (limited to 'watch-library')
26 files changed, 80 insertions, 13 deletions
diff --git a/watch-library/hal/include/hal_calendar.h b/watch-library/hal/include/hal_calendar.h new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/watch-library/hal/include/hal_calendar.h diff --git a/watch-library/hal/src/hal_calendar.c b/watch-library/hal/src/hal_calendar.c new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/watch-library/hal/src/hal_calendar.c diff --git a/watch-library/watch/watch.c b/watch-library/watch/watch.c index 6196b1f3..de7160c5 100644 --- a/watch-library/watch/watch.c +++ b/watch-library/watch/watch.c @@ -24,18 +24,6 @@ #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. diff --git a/watch-library/watch/watch_adc.c b/watch-library/watch/watch_adc.c index 490a49b1..90980a88 100644 --- a/watch-library/watch/watch_adc.c +++ b/watch-library/watch/watch_adc.c @@ -22,6 +22,8 @@ * SOFTWARE. */ +#include "watch_adc.h" + void _watch_sync_adc() { while (ADC->SYNCBUSY.reg); } diff --git a/watch-library/watch/watch_adc.h b/watch-library/watch/watch_adc.h index b49f1301..c9b6ad2a 100644 --- a/watch-library/watch/watch_adc.h +++ b/watch-library/watch/watch_adc.h @@ -21,8 +21,12 @@ * 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 diff --git a/watch-library/watch/watch_app.h b/watch-library/watch/watch_app.h index fd7ea706..00a6a610 100644 --- a/watch-library/watch/watch_app.h +++ b/watch-library/watch/watch_app.h @@ -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 diff --git a/watch-library/watch/watch_buzzer.c b/watch-library/watch/watch_buzzer.c index 9cb37393..007a44ca 100644 --- a/watch-library/watch/watch_buzzer.c +++ b/watch-library/watch/watch_buzzer.c @@ -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(); diff --git a/watch-library/watch/watch_buzzer.h b/watch-library/watch/watch_buzzer.h index 995e059a..e15657be 100644 --- a/watch-library/watch/watch_buzzer.h +++ b/watch-library/watch/watch_buzzer.h @@ -21,8 +21,12 @@ * 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 diff --git a/watch-library/watch/watch_deepsleep.c b/watch-library/watch/watch_deepsleep.c index 4294b660..c83254e4 100644 --- a/watch-library/watch/watch_deepsleep.c +++ b/watch-library/watch/watch_deepsleep.c @@ -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. diff --git a/watch-library/watch/watch_deepsleep.h b/watch-library/watch/watch_deepsleep.h index dc8724d9..3dc428d0 100644 --- a/watch-library/watch/watch_deepsleep.h +++ b/watch-library/watch/watch_deepsleep.h @@ -21,8 +21,12 @@ * 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 diff --git a/watch-library/watch/watch_extint.c b/watch-library/watch/watch_extint.c index f2bad949..dcaa0d80 100644 --- a/watch-library/watch/watch_extint.c +++ b/watch-library/watch/watch_extint.c @@ -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)); diff --git a/watch-library/watch/watch_extint.h b/watch-library/watch/watch_extint.h index 9c810534..758fe8bc 100644 --- a/watch-library/watch/watch_extint.h +++ b/watch-library/watch/watch_extint.h @@ -21,8 +21,11 @@ * 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 diff --git a/watch-library/watch/watch_gpio.c b/watch-library/watch/watch_gpio.c index a9bc139d..b37d009f 100644 --- a/watch-library/watch/watch_gpio.c +++ b/watch-library/watch/watch_gpio.c @@ -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); diff --git a/watch-library/watch/watch_gpio.h b/watch-library/watch/watch_gpio.h index 640686e0..fc43642c 100644 --- a/watch-library/watch/watch_gpio.h +++ b/watch-library/watch/watch_gpio.h @@ -21,8 +21,12 @@ * 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 diff --git a/watch-library/watch/watch_i2c.c b/watch-library/watch/watch_i2c.c index 385d9d08..d2cf474b 100644 --- a/watch-library/watch/watch_i2c.c +++ b/watch-library/watch/watch_i2c.c @@ -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(); diff --git a/watch-library/watch/watch_i2c.h b/watch-library/watch/watch_i2c.h index 7ac05c13..65df49b4 100644 --- a/watch-library/watch/watch_i2c.h +++ b/watch-library/watch/watch_i2c.h @@ -21,8 +21,12 @@ * 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 diff --git a/watch-library/watch/watch_led.c b/watch-library/watch/watch_led.c index 7b189452..1348c977 100644 --- a/watch-library/watch/watch_led.c +++ b/watch-library/watch/watch_led.c @@ -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(); diff --git a/watch-library/watch/watch_led.h b/watch-library/watch/watch_led.h index 0927e716..2b9dead0 100644 --- a/watch-library/watch/watch_led.h +++ b/watch-library/watch/watch_led.h @@ -21,8 +21,12 @@ * 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 diff --git a/watch-library/watch/watch_private.c b/watch-library/watch/watch_private.c index dc70f4cb..270208dc 100644 --- a/watch-library/watch/watch_private.c +++ b/watch-library/watch/watch_private.c @@ -22,6 +22,7 @@ * SOFTWARE. */ +#include "watch_private.h" #include "tusb.h" void _watch_init() { diff --git a/watch-library/watch/watch_private.h b/watch-library/watch/watch_private.h index abee085a..8045e438 100644 --- a/watch-library/watch/watch_private.h +++ b/watch-library/watch/watch_private.h @@ -21,10 +21,17 @@ * 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 diff --git a/watch-library/watch/watch_rtc.c b/watch-library/watch/watch_rtc.c index 43cff478..0974c796 100644 --- a/watch-library/watch/watch_rtc.c +++ b/watch-library/watch/watch_rtc.c @@ -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; diff --git a/watch-library/watch/watch_rtc.h b/watch-library/watch/watch_rtc.h index a2248758..71f555ab 100644 --- a/watch-library/watch/watch_rtc.h +++ b/watch-library/watch/watch_rtc.h @@ -21,8 +21,11 @@ * 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 diff --git a/watch-library/watch/watch_slcd.c b/watch-library/watch/watch_slcd.c index 7210713a..ba9d12b2 100644 --- a/watch-library/watch/watch_slcd.c +++ b/watch-library/watch/watch_slcd.c @@ -22,6 +22,8 @@ * SOFTWARE. */ +#include "watch_slcd.h" + ////////////////////////////////////////////////////////////////////////////////////////// // Segmented Display diff --git a/watch-library/watch/watch_slcd.h b/watch-library/watch/watch_slcd.h index efef99ac..4f5a617c 100644 --- a/watch-library/watch/watch_slcd.h +++ b/watch-library/watch/watch_slcd.h @@ -21,8 +21,12 @@ * 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 diff --git a/watch-library/watch/watch_uart.c b/watch-library/watch/watch_uart.c index 3d97803d..d35533d0 100644 --- a/watch-library/watch/watch_uart.c +++ b/watch-library/watch/watch_uart.c @@ -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) { diff --git a/watch-library/watch/watch_uart.h b/watch-library/watch/watch_uart.h index 3c4f7aef..3e98bd35 100644 --- a/watch-library/watch/watch_uart.h +++ b/watch-library/watch/watch_uart.h @@ -21,8 +21,12 @@ * 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 |