fix missing prototype warnings
This commit is contained in:
@@ -25,7 +25,7 @@
|
||||
#include "lis2dh.h"
|
||||
#include "watch.h"
|
||||
|
||||
bool lis2dh_begin() {
|
||||
bool lis2dh_begin(void) {
|
||||
if (lis2dh_get_device_id() != LIS2DH_WHO_AM_I_VAL) {
|
||||
return false;
|
||||
}
|
||||
@@ -40,16 +40,16 @@ bool lis2dh_begin() {
|
||||
return true;
|
||||
}
|
||||
|
||||
uint8_t lis2dh_get_device_id() {
|
||||
uint8_t lis2dh_get_device_id(void) {
|
||||
return watch_i2c_read8(LIS2DH_ADDRESS, LIS2DH_REG_WHO_AM_I);
|
||||
}
|
||||
|
||||
bool lis2dh_have_new_data() {
|
||||
bool lis2dh_have_new_data(void) {
|
||||
uint8_t retval = watch_i2c_read8(LIS2DH_ADDRESS, LIS2DH_REG_STATUS);
|
||||
return !!retval; // return true if any bit is set
|
||||
}
|
||||
|
||||
lis2dh_reading lis2dh_get_raw_reading() {
|
||||
lis2dh_reading lis2dh_get_raw_reading(void) {
|
||||
uint8_t buffer[6];
|
||||
uint8_t reg = LIS2DH_REG_OUT_X_L | 0x80; // set high bit for consecutive reads
|
||||
lis2dh_reading retval;
|
||||
@@ -97,7 +97,7 @@ void lis2dh_set_range(lis2dh_range_t range) {
|
||||
watch_i2c_write8(LIS2DH_ADDRESS, LIS2DH_REG_CTRL4, val | bits);
|
||||
}
|
||||
|
||||
lis2dh_range_t lis2dh_get_range() {
|
||||
lis2dh_range_t lis2dh_get_range(void) {
|
||||
uint8_t retval = watch_i2c_read8(LIS2DH_ADDRESS, LIS2DH_REG_CTRL4) & 0x30;
|
||||
retval >>= 4;
|
||||
return (lis2dh_range_t)retval;
|
||||
@@ -111,7 +111,7 @@ void lis2dh_set_data_rate(lis2dh_data_rate_t dataRate) {
|
||||
watch_i2c_write8(LIS2DH_ADDRESS, LIS2DH_REG_CTRL1, val | bits);
|
||||
}
|
||||
|
||||
lis2dh_data_rate_t lis2dh_get_data_rate() {
|
||||
lis2dh_data_rate_t lis2dh_get_data_rate(void) {
|
||||
return watch_i2c_read8(LIS2DH_ADDRESS, LIS2DH_REG_CTRL1) >> 4;
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ void lis2dh_configure_aoi_int1(lis2dh_interrupt_configuration configuration, uin
|
||||
watch_i2c_write8(LIS2DH_ADDRESS, LIS2DH_REG_CTRL5, val | latch ? LIS2DH_CTRL5_VAL_LIR_INT1 : 0);
|
||||
}
|
||||
|
||||
lis2dh_interrupt_state lis2dh_get_int1_state() {
|
||||
lis2dh_interrupt_state lis2dh_get_int1_state(void) {
|
||||
return (lis2dh_interrupt_state) watch_i2c_read8(LIS2DH_ADDRESS, LIS2DH_REG_INT1_SRC);
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ void lis2dh_configure_aoi_int2(lis2dh_interrupt_configuration configuration, uin
|
||||
watch_i2c_write8(LIS2DH_ADDRESS, LIS2DH_REG_CTRL5, val | latch ? LIS2DH_CTRL5_VAL_LIR_INT2 : 0);
|
||||
}
|
||||
|
||||
lis2dh_interrupt_state lis2dh_get_int2_state() {
|
||||
lis2dh_interrupt_state lis2dh_get_int2_state(void) {
|
||||
return (lis2dh_interrupt_state) watch_i2c_read8(LIS2DH_ADDRESS, LIS2DH_REG_INT2_SRC);
|
||||
}
|
||||
|
||||
|
||||
@@ -84,31 +84,31 @@ typedef enum {
|
||||
LIS2DH_INTERRUPT_STATE_X_LOW = 0b00000001, // X down
|
||||
} lis2dh_interrupt_state;
|
||||
|
||||
bool lis2dh_begin();
|
||||
bool lis2dh_begin(void);
|
||||
|
||||
uint8_t lis2dh_get_device_id();
|
||||
uint8_t lis2dh_get_device_id(void);
|
||||
|
||||
bool lis2dh_have_new_data();
|
||||
bool lis2dh_have_new_data(void);
|
||||
|
||||
lis2dh_reading lis2dh_get_raw_reading();
|
||||
lis2dh_reading lis2dh_get_raw_reading(void);
|
||||
|
||||
lis2dh_acceleration_measurement lis2dh_get_acceleration_measurement(lis2dh_reading *out_reading);
|
||||
|
||||
void lis2dh_set_range(lis2dh_range_t range);
|
||||
|
||||
lis2dh_range_t lis2dh_get_range();
|
||||
lis2dh_range_t lis2dh_get_range(void);
|
||||
|
||||
void lis2dh_set_data_rate(lis2dh_data_rate_t dataRate);
|
||||
|
||||
lis2dh_data_rate_t lis2dh_get_data_rate();
|
||||
lis2dh_data_rate_t lis2dh_get_data_rate(void);
|
||||
|
||||
void lis2dh_configure_aoi_int1(lis2dh_interrupt_configuration configuration, uint8_t threshold, uint8_t duration, bool latch);
|
||||
|
||||
lis2dh_interrupt_state lis2dh_get_int1_state();
|
||||
lis2dh_interrupt_state lis2dh_get_int1_state(void);
|
||||
|
||||
void lis2dh_configure_aoi_int2(lis2dh_interrupt_configuration configuration, uint8_t threshold, uint8_t duration, bool latch);
|
||||
|
||||
lis2dh_interrupt_state lis2dh_get_int2_state();
|
||||
lis2dh_interrupt_state lis2dh_get_int2_state(void);
|
||||
|
||||
// Assumes SA0 is high; if low, its 0x18
|
||||
#define LIS2DH_ADDRESS (0x19)
|
||||
|
||||
@@ -39,11 +39,6 @@
|
||||
*/
|
||||
#define DRIVER_VERSION 0x00000001u
|
||||
|
||||
uint32_t io_get_version(void)
|
||||
{
|
||||
return DRIVER_VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief I/O write interface
|
||||
*/
|
||||
|
||||
@@ -58,4 +58,6 @@ static inline bool _is_in_isr(void)
|
||||
|
||||
#endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
|
||||
|
||||
void Default_Handler(void);
|
||||
|
||||
#endif /* _HPL_CORE_PORT_H_INCLUDED */
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
*/
|
||||
|
||||
#include <hpl_gclk_config.h>
|
||||
#include <hpl_gclk_base.h>
|
||||
#include <hpl_init.h>
|
||||
#include <utils_assert.h>
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
|
||||
#include <compiler.h>
|
||||
#include <hpl_mclk_config.h>
|
||||
#include <hpl_init.h>
|
||||
|
||||
/**
|
||||
* \brief Initialize master clock generator
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
|
||||
#include <hpl_time_measure.h>
|
||||
#include <hpl_systick_config.h>
|
||||
#include <hpl_delay.h>
|
||||
|
||||
/**
|
||||
* \brief Initialize system time module
|
||||
|
||||
@@ -50,6 +50,7 @@ void delay_driver_init(void);
|
||||
|
||||
void EXTERNAL_IRQ_0_init(void);
|
||||
|
||||
void SEGMENT_LCD_0_PORT_init(void);
|
||||
void SEGMENT_LCD_0_init(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -35,6 +35,6 @@ void SYSTEM_Handler(void) {
|
||||
}
|
||||
}
|
||||
|
||||
bool watch_is_battery_low() {
|
||||
bool watch_is_battery_low(void) {
|
||||
return battery_is_low;
|
||||
}
|
||||
|
||||
@@ -71,6 +71,6 @@
|
||||
* the battery voltage has fallen to 2.5 volts, it will have probably less than 10% of its capacity remaining, and
|
||||
* you can expect the voltage to drop relatively quickly as the battery dies.
|
||||
*/
|
||||
bool watch_is_battery_low();
|
||||
bool watch_is_battery_low(void);
|
||||
|
||||
#endif /* WATCH_H_ */
|
||||
@@ -24,11 +24,11 @@
|
||||
|
||||
#include "watch_adc.h"
|
||||
|
||||
void _watch_sync_adc() {
|
||||
static void _watch_sync_adc(void) {
|
||||
while (ADC->SYNCBUSY.reg);
|
||||
}
|
||||
|
||||
uint16_t _watch_get_analog_value(uint16_t channel) {
|
||||
static uint16_t _watch_get_analog_value(uint16_t channel) {
|
||||
if (ADC->INPUTCTRL.bit.MUXPOS != channel) {
|
||||
ADC->INPUTCTRL.bit.MUXPOS = channel;
|
||||
_watch_sync_adc();
|
||||
@@ -40,7 +40,7 @@ uint16_t _watch_get_analog_value(uint16_t channel) {
|
||||
return ADC->RESULT.reg;
|
||||
}
|
||||
|
||||
void watch_enable_adc() {
|
||||
void watch_enable_adc(void) {
|
||||
MCLK->APBCMASK.reg |= MCLK_APBCMASK_ADC;
|
||||
GCLK->PCHCTRL[ADC_GCLK_ID].reg = GCLK_PCHCTRL_GEN_GCLK0 | GCLK_PCHCTRL_CHEN;
|
||||
|
||||
@@ -151,7 +151,7 @@ void watch_set_analog_reference_voltage(watch_adc_reference_voltage reference) {
|
||||
_watch_get_analog_value(ADC_INPUTCTRL_MUXPOS_SCALEDCOREVCC);
|
||||
}
|
||||
|
||||
uint16_t watch_get_vcc_voltage() {
|
||||
uint16_t watch_get_vcc_voltage(void) {
|
||||
// stash the previous reference so we can restore it when we're done.
|
||||
uint8_t oldref = ADC->REFCTRL.bit.REFSEL;
|
||||
|
||||
@@ -171,7 +171,7 @@ inline void watch_disable_analog_input(const uint8_t pin) {
|
||||
gpio_set_pin_function(pin, GPIO_PIN_FUNCTION_OFF);
|
||||
}
|
||||
|
||||
inline void watch_disable_adc() {
|
||||
inline void watch_disable_adc(void) {
|
||||
ADC->CTRLA.bit.ENABLE = 0;
|
||||
_watch_sync_adc();
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
/** @brief Enables the ADC peripheral. You must call this before attempting to read a value
|
||||
* from an analog pin.
|
||||
*/
|
||||
void watch_enable_adc();
|
||||
void watch_enable_adc(void);
|
||||
|
||||
/** @brief Configures the selected pin for analog input.
|
||||
* @param pin One of pins A0-A4.
|
||||
@@ -139,7 +139,7 @@ void watch_set_analog_reference_voltage(watch_adc_reference_voltage reference);
|
||||
* @note This function depends on INTREF being 1.024V. If you have changed it by poking at the supply
|
||||
* controller's VREF.SEL bits, this function will return inaccurate values.
|
||||
*/
|
||||
uint16_t watch_get_vcc_voltage();
|
||||
uint16_t watch_get_vcc_voltage(void);
|
||||
|
||||
/** @brief Disables the analog circuitry on the selected pin.
|
||||
* @param pin One of pins A0-A4.
|
||||
@@ -151,7 +151,7 @@ void watch_disable_analog_input(const uint8_t pin);
|
||||
* have the default settings of 16 samples and 1 measurement cycle; if you customized these
|
||||
* parameters, you will need to set them up again.
|
||||
**/
|
||||
void watch_disable_adc();
|
||||
void watch_disable_adc(void);
|
||||
|
||||
/// @}
|
||||
#endif
|
||||
|
||||
@@ -55,13 +55,13 @@
|
||||
* anything else. Use it to set up any internal data structures or application state required by your app,
|
||||
* but don't configure any peripherals just yet.
|
||||
*/
|
||||
void app_init();
|
||||
void app_init(void);
|
||||
|
||||
/** @brief A function you will implement to wake from BACKUP mode, which wipes the system's RAM, and with it, your
|
||||
* application's state. You may have chosen to store some important application state in the RTC's backup
|
||||
* registers prior to entering this mode. You may restore that state here.
|
||||
*/
|
||||
void app_wake_from_backup();
|
||||
void app_wake_from_backup(void);
|
||||
|
||||
/** @brief A function you will implement to set up your application. The app_setup function is like setup() in Arduino.
|
||||
* It is called once when the program begins. You should set pin modes and enable any peripherals you want to
|
||||
@@ -71,7 +71,7 @@ void app_wake_from_backup();
|
||||
* @note If your app enters the ultra-low power BACKUP sleep mode, this function will be called again when it wakes
|
||||
* from that deep sleep state. In this state, the RTC will still be configured with the correct date and time.
|
||||
*/
|
||||
void app_setup();
|
||||
void app_setup(void);
|
||||
|
||||
/** @brief A function you will implement to serve as the app's main run loop. This method will be called repeatedly,
|
||||
or if you enter STANDBY mode, as soon as the device wakes from sleep.
|
||||
@@ -86,7 +86,7 @@ void app_setup();
|
||||
* so e.g. the I2C controller, if configured, will sleep in STANDBY. But you can use it again as soon as your
|
||||
* app wakes up.
|
||||
*/
|
||||
bool app_loop();
|
||||
bool app_loop(void);
|
||||
|
||||
/** @brief A function you will implement to prepare to enter STANDBY mode. The app_prepare_for_standby function is
|
||||
* called after your app_loop function returns true, and just before the watch enters STANDBY mode. In this
|
||||
@@ -98,11 +98,11 @@ bool app_loop();
|
||||
* buzzer that could damage it if left in this state. If your app_loop does not prevent sleep during these
|
||||
* activities, you should make sure to disable these outputs in app_prepare_for_standby.
|
||||
*/
|
||||
void app_prepare_for_standby();
|
||||
void app_prepare_for_standby(void);
|
||||
|
||||
/** @brief A method you will implement to configure the app after waking from STANDBY mode.
|
||||
*/
|
||||
void app_wake_from_standby();
|
||||
void app_wake_from_standby(void);
|
||||
|
||||
/// @}
|
||||
#endif
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
#include "watch_buzzer.h"
|
||||
|
||||
inline void watch_enable_buzzer() {
|
||||
inline void watch_enable_buzzer(void) {
|
||||
if (!hri_tcc_get_CTRLA_reg(TCC0, TCC_CTRLA_ENABLE)) {
|
||||
_watch_enable_tcc();
|
||||
}
|
||||
@@ -33,16 +33,16 @@ inline void watch_set_buzzer_period(uint32_t period) {
|
||||
hri_tcc_write_PERBUF_reg(TCC0, period);
|
||||
}
|
||||
|
||||
void watch_disable_buzzer() {
|
||||
void watch_disable_buzzer(void) {
|
||||
_watch_disable_tcc();
|
||||
}
|
||||
|
||||
inline void watch_set_buzzer_on() {
|
||||
inline void watch_set_buzzer_on(void) {
|
||||
gpio_set_pin_direction(BUZZER, GPIO_DIRECTION_OUT);
|
||||
gpio_set_pin_function(BUZZER, WATCH_BUZZER_TCC_PINMUX);
|
||||
}
|
||||
|
||||
inline void watch_set_buzzer_off() {
|
||||
inline void watch_set_buzzer_off(void) {
|
||||
gpio_set_pin_direction(BUZZER, GPIO_DIRECTION_OFF);
|
||||
gpio_set_pin_function(BUZZER, GPIO_PIN_FUNCTION_OFF);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
/// @{
|
||||
/** @brief Enables the TCC peripheral, which drives the buzzer.
|
||||
*/
|
||||
void watch_enable_buzzer();
|
||||
void watch_enable_buzzer(void);
|
||||
|
||||
/** @brief Sets the period of the buzzer.
|
||||
* @param period The period of a single cycle for the TCC peripheral. You can determine the period for
|
||||
@@ -45,17 +45,17 @@ void watch_set_buzzer_period(uint32_t period);
|
||||
* @note If you are using PWM to set custom LED colors, this method will also disable the LED PWM driver,
|
||||
* since the buzzer and LED both make use of the same peripheral to drive their PWM behavior.
|
||||
*/
|
||||
void watch_disable_buzzer();
|
||||
void watch_disable_buzzer(void);
|
||||
|
||||
/** @brief Turns the buzzer output on. It will emit a continuous sound at the given frequency.
|
||||
* @note The TCC peripheral that drives the buzzer does not run in standby mode; if you wish for buzzer
|
||||
* output to continue, you should prevent your app from going to sleep.
|
||||
*/
|
||||
void watch_set_buzzer_on();
|
||||
void watch_set_buzzer_on(void);
|
||||
|
||||
/** @brief Turns the buzzer output off.
|
||||
*/
|
||||
void watch_set_buzzer_off();
|
||||
void watch_set_buzzer_off(void);
|
||||
|
||||
/// @brief 87 notes for use with watch_buzzer_play_note
|
||||
typedef enum BuzzerNote {
|
||||
|
||||
@@ -126,7 +126,7 @@ uint32_t watch_get_backup_data(uint8_t reg) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void _watch_disable_all_pins_except_rtc() {
|
||||
static void _watch_disable_all_pins_except_rtc(void) {
|
||||
uint32_t config = RTC->MODE0.TAMPCTRL.reg;
|
||||
uint32_t portb_pins_to_disable = 0xFFFFFFFF;
|
||||
|
||||
@@ -141,7 +141,7 @@ void _watch_disable_all_pins_except_rtc() {
|
||||
gpio_set_port_direction(1, portb_pins_to_disable, GPIO_DIRECTION_OFF);
|
||||
}
|
||||
|
||||
void _watch_disable_all_peripherals_except_slcd() {
|
||||
static void _watch_disable_all_peripherals_except_slcd(void) {
|
||||
_watch_disable_tcc();
|
||||
watch_disable_adc();
|
||||
watch_disable_external_interrupts();
|
||||
@@ -151,7 +151,7 @@ void _watch_disable_all_peripherals_except_slcd() {
|
||||
MCLK->APBCMASK.reg &= ~MCLK_APBCMASK_SERCOM3;
|
||||
}
|
||||
|
||||
void watch_enter_sleep_mode() {
|
||||
void watch_enter_sleep_mode(void) {
|
||||
// disable all other peripherals
|
||||
_watch_disable_all_peripherals_except_slcd();
|
||||
|
||||
@@ -177,7 +177,7 @@ void watch_enter_sleep_mode() {
|
||||
app_wake_from_standby();
|
||||
}
|
||||
|
||||
void watch_enter_deep_sleep_mode() {
|
||||
void watch_enter_deep_sleep_mode(void) {
|
||||
// identical to sleep mode except we disable the LCD first.
|
||||
slcd_sync_deinit(&SEGMENT_LCD_0);
|
||||
hri_mclk_clear_APBCMASK_SLCD_bit(SLCD);
|
||||
@@ -185,7 +185,7 @@ void watch_enter_deep_sleep_mode() {
|
||||
watch_enter_sleep_mode();
|
||||
}
|
||||
|
||||
void watch_enter_backup_mode() {
|
||||
void watch_enter_backup_mode(void) {
|
||||
watch_rtc_disable_all_periodic_callbacks();
|
||||
_watch_disable_all_peripherals_except_slcd();
|
||||
slcd_sync_deinit(&SEGMENT_LCD_0);
|
||||
@@ -203,7 +203,7 @@ void watch_enter_shallow_sleep(bool display_on) {
|
||||
}
|
||||
|
||||
// deprecated
|
||||
void watch_enter_deep_sleep() {
|
||||
void watch_enter_deep_sleep(void) {
|
||||
watch_register_extwake_callback(BTN_ALARM, NULL, true);
|
||||
watch_enter_backup_mode();
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ uint32_t watch_get_backup_data(uint8_t reg);
|
||||
* You can estimate the power consumption of this mode to be on the order of 30 microwatts
|
||||
* (about 10 µA at 3 V).
|
||||
*/
|
||||
void watch_enter_sleep_mode();
|
||||
void watch_enter_sleep_mode(void);
|
||||
|
||||
/** @brief enters Deep Sleep Mode by disabling all pins and peripherals except the RTC.
|
||||
* @details Short of BACKUP mode, this is the lowest power mode you can enter while retaining your
|
||||
@@ -131,7 +131,7 @@ void watch_enter_sleep_mode();
|
||||
* All notes from watch_enter_sleep_mode apply here, except for power consumption. You can estimate
|
||||
* the power consumption of this mode to be on the order of 12 microwatts (about 4µA at 3 V).
|
||||
*/
|
||||
void watch_enter_deep_sleep_mode();
|
||||
void watch_enter_deep_sleep_mode(void);
|
||||
|
||||
/** @brief Enters the SAM L22's lowest-power mode, BACKUP.
|
||||
* @details This function does some housekeeping before entering BACKUP mode. It first disables all pins
|
||||
@@ -148,12 +148,12 @@ void watch_enter_deep_sleep_mode();
|
||||
* this function unless you have a device on the nine-pin connector with an external interrupt
|
||||
* on pin A2 or A4 (i.e. an accelerometer with an interrupt pin).
|
||||
*/
|
||||
void watch_enter_backup_mode();
|
||||
void watch_enter_backup_mode(void);
|
||||
|
||||
__attribute__((deprecated("Use watch_enter_sleep_mode or watch_enter_deep_sleep_mode instead")))
|
||||
void watch_enter_shallow_sleep(bool display_on);
|
||||
|
||||
__attribute__((deprecated("Use watch_enter_backup_mode instead")))
|
||||
void watch_enter_deep_sleep();
|
||||
void watch_enter_deep_sleep(void);
|
||||
/// @}
|
||||
#endif
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
#include "watch_extint.h"
|
||||
|
||||
void watch_enable_external_interrupts() {
|
||||
void watch_enable_external_interrupts(void) {
|
||||
// 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));
|
||||
// Enable AHB clock for the EIC
|
||||
@@ -33,7 +33,7 @@ void watch_enable_external_interrupts() {
|
||||
ext_irq_init();
|
||||
}
|
||||
|
||||
void watch_disable_external_interrupts() {
|
||||
void watch_disable_external_interrupts(void) {
|
||||
ext_irq_deinit();
|
||||
hri_mclk_clear_APBAMASK_EIC_bit(MCLK);
|
||||
}
|
||||
@@ -106,6 +106,6 @@ inline void watch_register_button_callback(const uint8_t pin, ext_irq_cb_t callb
|
||||
watch_register_interrupt_callback(pin, callback, INTERRUPT_TRIGGER_RISING);
|
||||
}
|
||||
|
||||
inline void watch_enable_buttons() {
|
||||
inline void watch_enable_buttons(void) {
|
||||
watch_enable_external_interrupts();
|
||||
}
|
||||
|
||||
@@ -49,10 +49,10 @@ typedef enum watch_interrupt_trigger {
|
||||
} watch_interrupt_trigger;
|
||||
|
||||
/// @brief Enables the external interrupt controller.
|
||||
void watch_enable_external_interrupts();
|
||||
void watch_enable_external_interrupts(void);
|
||||
|
||||
/// @brief Disables the external interrupt controller.
|
||||
void watch_disable_external_interrupts();
|
||||
void watch_disable_external_interrupts(void);
|
||||
|
||||
/** @brief Configures an external interrupt callback on one of the external interrupt pins.
|
||||
* @details You can set one interrupt callback per pin, and you can monitor for a rising condition,
|
||||
@@ -80,6 +80,6 @@ __attribute__((deprecated("Use watch_register_interrupt_callback or watch_regist
|
||||
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();
|
||||
void watch_enable_buttons(void);
|
||||
/// @}
|
||||
#endif
|
||||
|
||||
@@ -26,13 +26,13 @@
|
||||
|
||||
struct io_descriptor *I2C_0_io;
|
||||
|
||||
void watch_enable_i2c() {
|
||||
void watch_enable_i2c(void) {
|
||||
I2C_0_init();
|
||||
i2c_m_sync_get_io_descriptor(&I2C_0, &I2C_0_io);
|
||||
i2c_m_sync_enable(&I2C_0);
|
||||
}
|
||||
|
||||
void watch_disable_i2c() {
|
||||
void watch_disable_i2c(void) {
|
||||
i2c_m_sync_disable(&I2C_0);
|
||||
hri_mclk_clear_APBCMASK_SERCOM1_bit(MCLK);
|
||||
}
|
||||
|
||||
@@ -35,11 +35,11 @@
|
||||
/// @{
|
||||
/** @brief Enables the I2C peripheral. Call this before attempting to interface with I2C devices.
|
||||
*/
|
||||
void watch_enable_i2c();
|
||||
void watch_enable_i2c(void);
|
||||
|
||||
/** @brief Disables the I2C peripheral.
|
||||
*/
|
||||
void watch_disable_i2c();
|
||||
void watch_disable_i2c(void);
|
||||
|
||||
/** @brief Sends a series of values to a device on the I2C bus.
|
||||
* @param addr The address of the device you wish to talk to.
|
||||
|
||||
@@ -24,13 +24,13 @@
|
||||
|
||||
#include "watch_led.h"
|
||||
|
||||
void watch_enable_leds() {
|
||||
void watch_enable_leds(void) {
|
||||
if (!hri_tcc_get_CTRLA_reg(TCC0, TCC_CTRLA_ENABLE)) {
|
||||
_watch_enable_tcc();
|
||||
}
|
||||
}
|
||||
|
||||
void watch_disable_leds() {
|
||||
void watch_disable_leds(void) {
|
||||
_watch_disable_tcc();
|
||||
}
|
||||
|
||||
@@ -52,18 +52,18 @@ void watch_set_led_color(uint8_t red, uint8_t green) {
|
||||
}
|
||||
}
|
||||
|
||||
void watch_set_led_red() {
|
||||
void watch_set_led_red(void) {
|
||||
watch_set_led_color(255, 0);
|
||||
}
|
||||
|
||||
void watch_set_led_green() {
|
||||
void watch_set_led_green(void) {
|
||||
watch_set_led_color(0, 255);
|
||||
}
|
||||
|
||||
void watch_set_led_yellow() {
|
||||
void watch_set_led_yellow(void) {
|
||||
watch_set_led_color(255, 255);
|
||||
}
|
||||
|
||||
void watch_set_led_off() {
|
||||
void watch_set_led_off(void) {
|
||||
watch_set_led_color(0, 0);
|
||||
}
|
||||
|
||||
@@ -46,13 +46,13 @@
|
||||
* your app is asleep. If, however, you set a custom color using watch_set_led_color, the color will
|
||||
* not display correctly in STANDBY mode. You will need to keep your app running while the LED is on.
|
||||
*/
|
||||
void watch_enable_leds();
|
||||
void watch_enable_leds(void);
|
||||
|
||||
/** @brief Disables the LEDs.
|
||||
* @note This method will also disable the buzzer, since the buzzer and LED both make use of the same
|
||||
* peripheral to drive their PWM behavior.
|
||||
*/
|
||||
void watch_disable_leds();
|
||||
void watch_disable_leds(void);
|
||||
|
||||
/** @brief Sets the LED to a custom color by modulating each output's duty cycle.
|
||||
* @param red The red value from 0-255.
|
||||
@@ -66,23 +66,23 @@ void watch_set_led_color(uint8_t red, uint8_t green);
|
||||
/** @brief Sets the red LED to full brightness, and turns the green LED off.
|
||||
* @details Of the two LED's in the RG bi-color LED, the red LED is the less power-efficient one (~4.5 mA).
|
||||
*/
|
||||
void watch_set_led_red();
|
||||
void watch_set_led_red(void);
|
||||
|
||||
/** @brief Sets the green LED to full brightness, and turns the red LED off.
|
||||
* @details Of the two LED's in the RG bi-color LED, the green LED is the more power-efficient one (~0.44 mA).
|
||||
* @note If your watch has a red/blue LED, this method will set the LED to blue.
|
||||
*/
|
||||
void watch_set_led_green();
|
||||
void watch_set_led_green(void);
|
||||
|
||||
/** @brief Sets both red and green LEDs to full brightness.
|
||||
* @details The total current draw between the two LED's in this mode will be ~5 mA, which is more than the
|
||||
* watch draws in any other mode. Take care not to drain the battery.
|
||||
* @note If your watch has a red/blue LED, this method will set the LED to pink.
|
||||
*/
|
||||
void watch_set_led_yellow();
|
||||
void watch_set_led_yellow(void);
|
||||
|
||||
/** @brief Turns both the red and the green LEDs off. */
|
||||
void watch_set_led_off();
|
||||
void watch_set_led_off(void);
|
||||
|
||||
__attribute__((deprecated("Use watch_enable_leds instead")))
|
||||
void watch_enable_led(bool unused);
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "watch_private.h"
|
||||
#include "tusb.h"
|
||||
|
||||
void _watch_init() {
|
||||
void _watch_init(void) {
|
||||
// disable the LED pin (it may have been enabled by the bootloader)
|
||||
watch_disable_digital_output(RED);
|
||||
|
||||
@@ -65,7 +65,7 @@ void _watch_init() {
|
||||
a4_callback = NULL;
|
||||
}
|
||||
|
||||
void _watch_enable_tcc() {
|
||||
void _watch_enable_tcc(void) {
|
||||
// clock TCC0 with the main clock (8 MHz) and enable the peripheral clock.
|
||||
hri_gclk_write_PCHCTRL_reg(GCLK, TCC0_GCLK_ID, GCLK_PCHCTRL_GEN_GCLK0_Val | GCLK_PCHCTRL_CHEN);
|
||||
hri_mclk_set_APBCMASK_TCC0_bit(MCLK);
|
||||
@@ -111,7 +111,7 @@ void _watch_enable_tcc() {
|
||||
gpio_set_pin_function(GREEN, WATCH_GREEN_TCC_PINMUX);
|
||||
}
|
||||
|
||||
void _watch_disable_tcc() {
|
||||
void _watch_disable_tcc(void) {
|
||||
// disable all PWM pins
|
||||
gpio_set_pin_direction(BUZZER, GPIO_DIRECTION_OFF);
|
||||
gpio_set_pin_function(BUZZER, GPIO_PIN_FUNCTION_OFF);
|
||||
@@ -125,7 +125,7 @@ void _watch_disable_tcc() {
|
||||
hri_mclk_clear_APBCMASK_TCC0_bit(MCLK);
|
||||
}
|
||||
|
||||
void _watch_enable_usb() {
|
||||
void _watch_enable_usb(void) {
|
||||
// disable USB, just in case.
|
||||
hri_usb_clear_CTRLA_ENABLE_bit(USB);
|
||||
|
||||
@@ -209,7 +209,7 @@ int _write(int file, char *ptr, int len) {
|
||||
}
|
||||
|
||||
// this method could be overridden to read stuff from the USB console? but no need rn.
|
||||
int _read() {
|
||||
int _read(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,17 +27,24 @@
|
||||
#include "watch.h"
|
||||
|
||||
/// Called by main.c while setting up the app. You should not call this from your app.
|
||||
void _watch_init();
|
||||
void _watch_init(void);
|
||||
|
||||
/// Initializes the real-time clock peripheral.
|
||||
void _watch_rtc_init();
|
||||
void _watch_rtc_init(void);
|
||||
|
||||
/// Called by buzzer and LED setup functions. You should not call this from your app.
|
||||
void _watch_enable_tcc();
|
||||
void _watch_enable_tcc(void);
|
||||
|
||||
/// Called by buzzer and LED teardown functions. You should not call this from your app.
|
||||
void _watch_disable_tcc();
|
||||
void _watch_disable_tcc(void);
|
||||
|
||||
/// Called by main.c if plugged in to USB. You should not call this from your app.
|
||||
void _watch_enable_usb();
|
||||
void _watch_enable_usb(void);
|
||||
|
||||
// this function ends up getting called by printf to log stuff to the USB console.
|
||||
int _write(int file, char *ptr, int len);
|
||||
|
||||
// this method could be overridden to read stuff from the USB console? but no need rn.
|
||||
int _read(void);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -30,15 +30,15 @@ ext_irq_cb_t btn_alarm_callback;
|
||||
ext_irq_cb_t a2_callback;
|
||||
ext_irq_cb_t a4_callback;
|
||||
|
||||
bool _watch_rtc_is_enabled() {
|
||||
bool _watch_rtc_is_enabled(void) {
|
||||
return RTC->MODE2.CTRLA.bit.ENABLE;
|
||||
}
|
||||
|
||||
void _sync_rtc() {
|
||||
static void _sync_rtc(void) {
|
||||
while (RTC->MODE2.SYNCBUSY.reg);
|
||||
}
|
||||
|
||||
void _watch_rtc_init() {
|
||||
void _watch_rtc_init(void) {
|
||||
MCLK->APBAMASK.reg |= MCLK_APBAMASK_RTC;
|
||||
|
||||
if (_watch_rtc_is_enabled()) return; // don't reset the RTC if it's already set up.
|
||||
@@ -61,7 +61,7 @@ void watch_rtc_set_date_time(watch_date_time date_time) {
|
||||
_sync_rtc();
|
||||
}
|
||||
|
||||
watch_date_time watch_rtc_get_date_time() {
|
||||
watch_date_time watch_rtc_get_date_time(void) {
|
||||
watch_date_time retval;
|
||||
|
||||
_sync_rtc();
|
||||
@@ -74,7 +74,7 @@ void watch_rtc_register_tick_callback(ext_irq_cb_t callback) {
|
||||
watch_rtc_register_periodic_callback(callback, 1);
|
||||
}
|
||||
|
||||
void watch_rtc_disable_tick_callback() {
|
||||
void watch_rtc_disable_tick_callback(void) {
|
||||
watch_rtc_disable_periodic_callback(1);
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ void watch_rtc_disable_periodic_callback(uint8_t frequency) {
|
||||
RTC->MODE2.INTENCLR.reg = 1 << per_n;
|
||||
}
|
||||
|
||||
void watch_rtc_disable_all_periodic_callbacks() {
|
||||
void watch_rtc_disable_all_periodic_callbacks(void) {
|
||||
RTC->MODE2.INTENCLR.reg = 0xFF;
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ void watch_rtc_register_alarm_callback(ext_irq_cb_t callback, watch_date_time al
|
||||
RTC->MODE2.INTENSET.reg = RTC_MODE2_INTENSET_ALARM0;
|
||||
}
|
||||
|
||||
void watch_rtc_disable_alarm_callback() {
|
||||
void watch_rtc_disable_alarm_callback(void) {
|
||||
RTC->MODE2.INTENCLR.reg = RTC_MODE2_INTENCLR_ALARM0;
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ typedef enum watch_rtc_alarm_match {
|
||||
/** @brief Called by main.c to check if the RTC is enabled.
|
||||
* You may call this function, but outside of app_init, it should always return true.
|
||||
*/
|
||||
bool _watch_rtc_is_enabled();
|
||||
bool _watch_rtc_is_enabled(void);
|
||||
|
||||
/** @brief Sets the date and time.
|
||||
* @param date_time The date and time you wish to set, with a year value from 0-63 representing 2020-2083.
|
||||
@@ -79,7 +79,7 @@ void watch_rtc_set_date_time(watch_date_time date_time);
|
||||
* @return A watch_date_time with the current date and time, with a year value from 0-63 representing 2020-2083.
|
||||
* @see watch_rtc_set_date_time for notes about how the year is stored.
|
||||
*/
|
||||
watch_date_time watch_rtc_get_date_time();
|
||||
watch_date_time watch_rtc_get_date_time(void);
|
||||
|
||||
/** @brief Registers an alarm callback that will be called when the RTC time matches the target time, as masked
|
||||
* by the provided mask.
|
||||
@@ -100,7 +100,7 @@ void watch_rtc_register_alarm_callback(ext_irq_cb_t callback, watch_date_time al
|
||||
|
||||
/** @brief Disables the alarm callback.
|
||||
*/
|
||||
void watch_rtc_disable_alarm_callback();
|
||||
void watch_rtc_disable_alarm_callback(void);
|
||||
|
||||
/** @brief Registers a "tick" callback that will be called once per second.
|
||||
* @param callback The function you wish to have called when the clock ticks. If you pass in NULL, the tick
|
||||
@@ -113,7 +113,7 @@ void watch_rtc_register_tick_callback(ext_irq_cb_t callback);
|
||||
|
||||
/** @brief Disables the tick callback for the given period.
|
||||
*/
|
||||
void watch_rtc_disable_tick_callback();
|
||||
void watch_rtc_disable_tick_callback(void);
|
||||
|
||||
/** @brief Registers a callback that will be called at a configurable period.
|
||||
* @param callback The function you wish to have called at the specified period. If you pass in NULL, the periodic
|
||||
@@ -139,7 +139,7 @@ void watch_rtc_disable_periodic_callback(uint8_t frequency);
|
||||
|
||||
/** @brief Disables all periodic callbacks, including the once-per-second tick callback.
|
||||
*/
|
||||
void watch_rtc_disable_all_periodic_callbacks();
|
||||
void watch_rtc_disable_all_periodic_callbacks(void);
|
||||
|
||||
/** @brief Sets the system date and time.
|
||||
* @param date_time A struct representing the date and time you wish to set.
|
||||
|
||||
@@ -150,11 +150,11 @@ static const uint32_t IndicatorSegments[6] = {
|
||||
SLCD_SEGID(1, 10), // WATCH_INDICATOR_LAP
|
||||
};
|
||||
|
||||
void _sync_slcd() {
|
||||
static void _sync_slcd(void) {
|
||||
while (SLCD->SYNCBUSY.reg);
|
||||
}
|
||||
|
||||
void watch_enable_display() {
|
||||
void watch_enable_display(void) {
|
||||
SEGMENT_LCD_0_init();
|
||||
slcd_sync_enable(&SEGMENT_LCD_0);
|
||||
}
|
||||
@@ -167,13 +167,13 @@ inline void watch_clear_pixel(uint8_t com, uint8_t seg) {
|
||||
slcd_sync_seg_off(&SEGMENT_LCD_0, SLCD_SEGID(com, seg));
|
||||
}
|
||||
|
||||
void watch_clear_display() {
|
||||
void watch_clear_display(void) {
|
||||
SLCD->SDATAL0.reg = 0;
|
||||
SLCD->SDATAL1.reg = 0;
|
||||
SLCD->SDATAL2.reg = 0;
|
||||
}
|
||||
|
||||
void watch_display_character(uint8_t character, uint8_t position) {
|
||||
static void watch_display_character(uint8_t character, uint8_t position) {
|
||||
// special cases for positions 4 and 6
|
||||
if (position == 4 || position == 6) {
|
||||
if (character == '7') character = '&'; // "lowercase" 7
|
||||
@@ -245,11 +245,11 @@ void watch_display_string(char *string, uint8_t position) {
|
||||
// printf("________\n %c%c %c%c\n%c%c %c%c %c%c\n--------\n", (position > 0) ? ' ' : string[0], (position > 1) ? ' ' : string[1 - position], (position > 2) ? ' ' : string[2 - position], (position > 3) ? ' ' : string[3 - position], (position > 4) ? ' ' : string[4 - position], (position > 5) ? ' ' : string[5 - position], (position > 6) ? ' ' : string[6 - position], (position > 7) ? ' ' : string[7 - position], (position > 8) ? ' ' : string[8 - position], (position > 9) ? ' ' : string[9 - position]);
|
||||
}
|
||||
|
||||
inline void watch_set_colon() {
|
||||
inline void watch_set_colon(void) {
|
||||
slcd_sync_seg_on(&SEGMENT_LCD_0, SLCD_SEGID(1, 16));
|
||||
}
|
||||
|
||||
inline void watch_clear_colon() {
|
||||
inline void watch_clear_colon(void) {
|
||||
slcd_sync_seg_off(&SEGMENT_LCD_0, SLCD_SEGID(1, 16));
|
||||
}
|
||||
|
||||
@@ -261,7 +261,7 @@ inline void watch_clear_indicator(WatchIndicatorSegment indicator) {
|
||||
slcd_sync_seg_off(&SEGMENT_LCD_0, IndicatorSegments[indicator]);
|
||||
}
|
||||
|
||||
void watch_clear_all_indicators() {
|
||||
void watch_clear_all_indicators(void) {
|
||||
slcd_sync_seg_off(&SEGMENT_LCD_0, SLCD_SEGID(2, 17));
|
||||
slcd_sync_seg_off(&SEGMENT_LCD_0, SLCD_SEGID(2, 16));
|
||||
slcd_sync_seg_off(&SEGMENT_LCD_0, SLCD_SEGID(0, 17));
|
||||
@@ -296,7 +296,7 @@ void watch_start_character_blink(char character, uint32_t duration) {
|
||||
_sync_slcd();
|
||||
}
|
||||
|
||||
void watch_stop_blink() {
|
||||
void watch_stop_blink(void) {
|
||||
SLCD->CTRLD.bit.FC0EN = 0;
|
||||
SLCD->CTRLD.bit.BLINK = 0;
|
||||
}
|
||||
@@ -307,11 +307,11 @@ void watch_start_tick_animation(uint32_t duration) {
|
||||
slcd_sync_start_animation(&SEGMENT_LCD_0, segs, 1, duration);
|
||||
}
|
||||
|
||||
bool watch_tick_animation_is_running() {
|
||||
bool watch_tick_animation_is_running(void) {
|
||||
return hri_slcd_get_CTRLD_CSREN_bit(SLCD);
|
||||
}
|
||||
|
||||
void watch_stop_tick_animation() {
|
||||
void watch_stop_tick_animation(void) {
|
||||
const uint32_t segs[] = { SLCD_SEGID(0, 2)};
|
||||
slcd_sync_stop_animation(&SEGMENT_LCD_0, segs, 1);
|
||||
watch_display_character(' ', 8);
|
||||
|
||||
@@ -53,7 +53,7 @@ typedef enum WatchIndicatorSegment {
|
||||
/** @brief Enables the Segment LCD display.
|
||||
* Call this before attempting to set pixels or display strings.
|
||||
*/
|
||||
void watch_enable_display();
|
||||
void watch_enable_display(void);
|
||||
|
||||
/** @brief Sets a pixel. Use this to manually set a pixel with a given common and segment number.
|
||||
* See <a href="segmap.html">segmap.html</a>.
|
||||
@@ -71,7 +71,7 @@ void watch_clear_pixel(uint8_t com, uint8_t seg);
|
||||
|
||||
/** @brief Clears all segments of the display, including incicators and the colon.
|
||||
*/
|
||||
void watch_clear_display();
|
||||
void watch_clear_display(void);
|
||||
|
||||
/** @brief Displays a string at the given position, starting from the top left. There are ten digits.
|
||||
A space in any position will clear that digit.
|
||||
@@ -86,11 +86,11 @@ void watch_display_string(char *string, uint8_t position);
|
||||
|
||||
/** @brief Turns the colon segment on.
|
||||
*/
|
||||
void watch_set_colon();
|
||||
void watch_set_colon(void);
|
||||
|
||||
/** @brief Turns the colon segment off.
|
||||
*/
|
||||
void watch_clear_colon();
|
||||
void watch_clear_colon(void);
|
||||
|
||||
/** @brief Sets an indicator on the LCD. Use this to turn on one of the indicator segments.
|
||||
* @param indicator One of the indicator segments from the enum. @see WatchIndicatorSegment
|
||||
@@ -105,7 +105,7 @@ void watch_clear_indicator(WatchIndicatorSegment indicator);
|
||||
/** @brief Clears all indicator segments.
|
||||
* @see WatchIndicatorSegment
|
||||
*/
|
||||
void watch_clear_all_indicators();
|
||||
void watch_clear_all_indicators(void);
|
||||
|
||||
/** @brief Blinks a single character in position 7. Does not affect other positions.
|
||||
* @details Six of the seven segments in position 7 (and only position 7) are capable of autonomous
|
||||
@@ -124,7 +124,7 @@ void watch_start_character_blink(char character, uint32_t duration);
|
||||
/** @brief Stops and clears all blinking segments.
|
||||
* @details This will stop all blinking in position 7, and clear all segments in that digit.
|
||||
*/
|
||||
void watch_stop_blink();
|
||||
void watch_stop_blink(void);
|
||||
|
||||
/** @brief Begins a two-segment "tick-tock" animation in position 8.
|
||||
* @details Six of the seven segments in position 8 (and only position 8) are capable of autonomous
|
||||
@@ -141,11 +141,11 @@ void watch_start_tick_animation(uint32_t duration);
|
||||
/** @brief Checks if the tick animation is currently running.
|
||||
* @return true if the animation is running; false otherwise.
|
||||
*/
|
||||
bool watch_tick_animation_is_running();
|
||||
bool watch_tick_animation_is_running(void);
|
||||
|
||||
/** @brief Stops the tick/tock animation and clears all animating segments.
|
||||
* @details This will stop the animation and clear all segments in position 8.
|
||||
*/
|
||||
void watch_stop_tick_animation();
|
||||
void watch_stop_tick_animation(void);
|
||||
/// @}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user