$(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 \
#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.
* SOFTWARE.
*/
+#include "watch_adc.h"
+
void _watch_sync_adc() {
while (ADC->SYNCBUSY.reg);
}
* 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
void watch_disable_adc();
/// @}
+#endif
* 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
void app_wake_from_sleep();
/// @}
+#endif
* SOFTWARE.
*/
+#include "watch_buzzer.h"
+
inline void watch_enable_buzzer() {
if (!hri_tcc_get_CTRLA_reg(TCC0, TCC_CTRLA_ENABLE)) {
_watch_enable_tcc();
* 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.
*/
extern const uint16_t NotePeriods[108];
/// @}
+#endif
* 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.
* 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;
*/
void watch_enter_deep_sleep();
/// @}
+#endif
* 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));
* 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
__attribute__((deprecated("Use watch_enable_external_interrupts instead")))
void watch_enable_buttons();
/// @}
+#endif
* 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);
* 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.
*/
*/
void watch_set_pin_level(const uint8_t pin, const bool level);
/// @}
+#endif
* SOFTWARE.
*/
- struct io_descriptor *I2C_0_io;
+#include "watch_i2c.h"
+
+struct io_descriptor *I2C_0_io;
void watch_enable_i2c() {
I2C_0_init();
* 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
*/
uint32_t watch_i2c_read32(int16_t addr, uint8_t reg);
/// @}
+#endif
* SOFTWARE.
*/
+#include "watch_led.h"
+
void watch_enable_leds() {
if (!hri_tcc_get_CTRLA_reg(TCC0, TCC_CTRLA_ENABLE)) {
_watch_enable_tcc();
* 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-
__attribute__((deprecated("Use watch_disable_leds instead")))
void watch_disable_led(bool unused);
/// @}
+#endif
* SOFTWARE.
*/
+#include "watch_private.h"
#include "tusb.h"
void _watch_init() {
* 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();
/// Called by main.c if plugged in to USB. You should not call this from your app.
void _watch_enable_usb();
+#endif
* SOFTWARE.
*/
+#include "watch_rtc.h"
+
ext_irq_cb_t tick_callback;
ext_irq_cb_t alarm_callback;
ext_irq_cb_t btn_alarm_callback;
* 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
void watch_get_date_time(struct calendar_date_time *date_time);
/// @}
+#endif
* SOFTWARE.
*/
+#include "watch_slcd.h"
+
//////////////////////////////////////////////////////////////////////////////////////////
// Segmented Display
* 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.
void watch_clear_all_indicators();
/// @}
+#endif
* POSSIBILITY OF SUCH DAMAGE.
*/
+#include "watch_uart.h"
#include "peripheral_clk_config.h"
void watch_enable_debug_uart(uint32_t baud) {
* 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.
__attribute__((deprecated("Use printf to log debug messages over USB.")))
void watch_debug_puts(char *s);
/// @}
+#endif