diff options
33 files changed, 158 insertions, 737 deletions
@@ -3,7 +3,7 @@ BUILD = ./build BIN = watch ifndef BOARD -override BOARD = OSO-SWAT-A1-04 +override BOARD = OSO-SWAT-A1-05 endif ############################################################################## diff --git a/movement/lib/TOTP-MCU/sha1.c b/movement/lib/TOTP-MCU/sha1.c index 21a24fa5..3dc02190 100644 --- a/movement/lib/TOTP-MCU/sha1.c +++ b/movement/lib/TOTP-MCU/sha1.c @@ -84,7 +84,7 @@ static void addUncounted(uint8_t data) { }
}
-void write(uint8_t data) {
+static void __write(uint8_t data) {
++byteCount;
addUncounted(data);
@@ -93,7 +93,7 @@ void write(uint8_t data) { void writeArray(uint8_t *buffer, uint8_t size){
while (size--) {
- write(*buffer++);
+ __write(*buffer++);
}
}
@@ -144,7 +144,7 @@ void initHmac(const uint8_t* key, uint8_t keyLength) { if (keyLength > BLOCK_LENGTH) {
// Hash long keys
init();
- for (;keyLength--;) write(*key++);
+ for (;keyLength--;) __write(*key++);
memcpy(keyBuffer,result(),HASH_LENGTH);
} else {
// Block length keys are used as is
@@ -153,7 +153,7 @@ void initHmac(const uint8_t* key, uint8_t keyLength) { // Start inner hash
init();
for (i=0; i<BLOCK_LENGTH; i++) {
- write(keyBuffer[i] ^ HMAC_IPAD);
+ __write(keyBuffer[i] ^ HMAC_IPAD);
}
}
@@ -163,7 +163,7 @@ uint8_t* resultHmac(void) { memcpy(innerHash,result(),HASH_LENGTH);
// Calculate outer hash
init();
- for (i=0; i<BLOCK_LENGTH; i++) write(keyBuffer[i] ^ HMAC_OPAD);
- for (i=0; i<HASH_LENGTH; i++) write(innerHash[i]);
+ for (i=0; i<BLOCK_LENGTH; i++) __write(keyBuffer[i] ^ HMAC_OPAD);
+ for (i=0; i<HASH_LENGTH; i++) __write(innerHash[i]);
return result();
}
diff --git a/movement/lib/TOTP-MCU/sha1.h b/movement/lib/TOTP-MCU/sha1.h index 2db8fdf8..bd689c34 100644 --- a/movement/lib/TOTP-MCU/sha1.h +++ b/movement/lib/TOTP-MCU/sha1.h @@ -10,7 +10,6 @@ void init(void); void initHmac(const uint8_t* secret, uint8_t secretLength);
uint8_t* result(void);
uint8_t* resultHmac(void);
-void write(uint8_t);
void writeArray(uint8_t *buffer, uint8_t size);
#endif // SHA1_H
diff --git a/movement/make/Makefile b/movement/make/Makefile index 2516cc44..3bed1963 100755 --- a/movement/make/Makefile +++ b/movement/make/Makefile @@ -44,7 +44,7 @@ SRCS += \ ../watch_faces/sensor/thermistor_testing_face.c \ ../watch_faces/demo/character_set_face.c \ ../watch_faces/demo/voltage_face.c \ - ../watch_faces/demo/lis2dh_logging_face.c \ + ../watch_faces/demo/lis2dw_logging_face.c \ ../watch_faces/demo/demo_face.c \ ../watch_faces/demo/hello_there_face.c \ ../watch_faces/complication/pulsometer_face.c \ diff --git a/movement/movement_faces.h b/movement/movement_faces.h index d068a7f9..e279683e 100644 --- a/movement/movement_faces.h +++ b/movement/movement_faces.h @@ -39,7 +39,7 @@ #include "voltage_face.h" #include "stopwatch_face.h" #include "totp_face.h" -#include "lis2dh_logging_face.h" +#include "lis2dw_logging_face.h" #include "demo_face.h" #include "hello_there_face.h" #include "sunrise_sunset_face.h" diff --git a/movement/watch_faces/clock/simple_clock_face.c b/movement/watch_faces/clock/simple_clock_face.c index ac9e2a1f..23f36672 100644 --- a/movement/watch_faces/clock/simple_clock_face.c +++ b/movement/watch_faces/clock/simple_clock_face.c @@ -82,11 +82,11 @@ bool simple_clock_face_loop(movement_event_t event, movement_settings_t *setting // ...and set the LAP indicator if low. if (state->battery_low) watch_set_indicator(WATCH_INDICATOR_LAP); - if (date_time.reg >> 6 == previous_date_time >> 6 && event.event_type != EVENT_LOW_ENERGY_UPDATE) { + if ((date_time.reg >> 6) == (previous_date_time >> 6) && event.event_type != EVENT_LOW_ENERGY_UPDATE) { // everything before seconds is the same, don't waste cycles setting those segments. pos = 8; sprintf(buf, "%02d", date_time.unit.second); - } else if (date_time.reg >> 12 == previous_date_time >> 12 && event.event_type != EVENT_LOW_ENERGY_UPDATE) { + } else if ((date_time.reg >> 12) == (previous_date_time >> 12) && event.event_type != EVENT_LOW_ENERGY_UPDATE) { // everything before minutes is the same. pos = 6; sprintf(buf, "%02d%02d", date_time.unit.minute, date_time.unit.second); diff --git a/movement/watch_faces/clock/world_clock_face.c b/movement/watch_faces/clock/world_clock_face.c index f0f7e954..4004bab2 100644 --- a/movement/watch_faces/clock/world_clock_face.c +++ b/movement/watch_faces/clock/world_clock_face.c @@ -44,14 +44,11 @@ void world_clock_face_setup(movement_settings_t *settings, uint8_t watch_face_in } void world_clock_face_activate(movement_settings_t *settings, void *context) { + (void) settings; world_clock_state_t *state = (world_clock_state_t *)context; state->current_screen = 0; - state->previous_date_time = 0xFFFFFFFF; if (watch_tick_animation_is_running()) watch_stop_tick_animation(); - if (settings->bit.clock_mode_24h) watch_set_indicator(WATCH_INDICATOR_24H); - - watch_set_colon(); } static bool world_clock_face_do_display_mode(movement_event_t event, movement_settings_t *settings, world_clock_state_t *state) { @@ -63,6 +60,10 @@ static bool world_clock_face_do_display_mode(movement_event_t event, movement_se watch_date_time date_time; switch (event.event_type) { case EVENT_ACTIVATE: + if (settings->bit.clock_mode_24h) watch_set_indicator(WATCH_INDICATOR_24H); + watch_set_colon(); + state->previous_date_time = 0xFFFFFFFF; + // fall through case EVENT_TICK: case EVENT_LOW_ENERGY_UPDATE: date_time = watch_rtc_get_date_time(); @@ -71,11 +72,11 @@ static bool world_clock_face_do_display_mode(movement_event_t event, movement_se previous_date_time = state->previous_date_time; state->previous_date_time = date_time.reg; - if (date_time.reg >> 6 == previous_date_time >> 6 && event.event_type != EVENT_LOW_ENERGY_UPDATE) { + if ((date_time.reg >> 6) == (previous_date_time >> 6) && event.event_type != EVENT_LOW_ENERGY_UPDATE) { // everything before seconds is the same, don't waste cycles setting those segments. pos = 8; sprintf(buf, "%02d", date_time.unit.second); - } else if (date_time.reg >> 12 == previous_date_time >> 12 && event.event_type != EVENT_LOW_ENERGY_UPDATE) { + } else if ((date_time.reg >> 12) == (previous_date_time >> 12) && event.event_type != EVENT_LOW_ENERGY_UPDATE) { // everything before minutes is the same. pos = 6; sprintf(buf, "%02d%02d", date_time.unit.minute, date_time.unit.second); @@ -140,9 +141,9 @@ static bool _world_clock_face_do_settings_mode(movement_event_t event, movement_ if (state->current_screen > 3) { movement_request_tick_frequency(1); state->current_screen = 0; - state->previous_date_time = 0xFFFFFFFF; if (state->backup_register) watch_store_backup_data(state->settings.reg, state->backup_register); - world_clock_face_do_display_mode(event, settings, state); + event.event_type = EVENT_ACTIVATE; + return world_clock_face_do_display_mode(event, settings, state); } break; case EVENT_ALARM_BUTTON_DOWN: diff --git a/movement/watch_faces/demo/lis2dh_logging_face.c b/movement/watch_faces/demo/lis2dw_logging_face.c index 31d1cad7..0e63e41e 100644 --- a/movement/watch_faces/demo/lis2dh_logging_face.c +++ b/movement/watch_faces/demo/lis2dw_logging_face.c @@ -24,8 +24,8 @@ #include <stdlib.h> #include <string.h> -#include "lis2dh_logging_face.h" -#include "lis2dh.h" +#include "lis2dw_logging_face.h" +#include "lis2dw.h" #include "watch.h" // This watch face is just for testing; if we want to build accelerometer support, it will likely have to be part of Movement itself. @@ -36,14 +36,14 @@ // Pressing the alarm button enters the log mode, where the main display shows the number of interrupts detected in each of the last // 24 hours (the hour is shown in the top right digit and AM/PM indicator, if the clock is set to 12 hour mode) -static void _lis2dh_logging_face_update_display(movement_settings_t *settings, lis2dh_logger_state_t *logger_state, lis2dh_interrupt_state interrupt_state) { +static void _lis2dw_logging_face_update_display(movement_settings_t *settings, lis2dw_logger_state_t *logger_state, lis2dw_wakeup_source wakeup_source) { char buf[14]; char time_indication_character; int8_t pos; watch_date_time date_time; if (logger_state->log_ticks) { - pos = (logger_state->data_points - 1 - logger_state->display_index) % LIS2DH_LOGGING_NUM_DATA_POINTS; + pos = (logger_state->data_points - 1 - logger_state->display_index) % LIS2DW_LOGGING_NUM_DATA_POINTS; if (pos < 0) { watch_clear_colon(); sprintf(buf, "NO data "); @@ -80,9 +80,9 @@ static void _lis2dh_logging_face_update_display(movement_settings_t *settings, l if ((59 - date_time.unit.second) < 10) time_indication_character = '0' + (59 - date_time.unit.second); else time_indication_character = (date_time.unit.second % 2) ? 'i' : '_'; sprintf(buf, "%c%c%c%c%2d%2d%2d", - (interrupt_state & LIS2DH_INTERRUPT_STATE_Y_HIGH) ? 'Y' : ' ', - (interrupt_state & LIS2DH_INTERRUPT_STATE_X_HIGH) ? 'X' : ' ', - (interrupt_state & LIS2DH_INTERRUPT_STATE_Z_HIGH) ? 'Z' : ' ', + (wakeup_source & LIS2DW_WAKEUP_SRC_WAKEUP_Y) ? 'Y' : ' ', + (wakeup_source & LIS2DW_WAKEUP_SRC_WAKEUP_X) ? 'X' : ' ', + (wakeup_source & LIS2DW_WAKEUP_SRC_WAKEUP_Z) ? 'Z' : ' ', time_indication_character, logger_state->interrupts[0], logger_state->interrupts[1], @@ -91,7 +91,7 @@ static void _lis2dh_logging_face_update_display(movement_settings_t *settings, l watch_display_string(buf, 0); } -static void _lis2dh_logging_face_log_data(lis2dh_logger_state_t *logger_state) { +static void _lis2dw_logging_face_log_data(lis2dw_logger_state_t *logger_state) { watch_date_time date_time = watch_rtc_get_date_time(); // we get this call 15 minutes late; i.e. at 6:15 we're logging events for 6:00. // so: if we're at the top of the hour, roll the hour back too (7:00 task logs data for 6:45) @@ -100,7 +100,7 @@ static void _lis2dh_logging_face_log_data(lis2dh_logger_state_t *logger_state) { // // then roll the minute back. date_time.unit.minute = (date_time.unit.minute + 45) % 60; - size_t pos = logger_state->data_points % LIS2DH_LOGGING_NUM_DATA_POINTS; + size_t pos = logger_state->data_points % LIS2DW_LOGGING_NUM_DATA_POINTS; logger_state->data[pos].timestamp.reg = date_time.reg; logger_state->data[pos].x_interrupts = logger_state->x_interrupts_this_hour; logger_state->data[pos].y_interrupts = logger_state->y_interrupts_this_hour; @@ -111,28 +111,25 @@ static void _lis2dh_logging_face_log_data(lis2dh_logger_state_t *logger_state) { logger_state->z_interrupts_this_hour = 0; } -void lis2dh_logging_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) { +void lis2dw_logging_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) { (void) settings; (void) watch_face_index; if (*context_ptr == NULL) { - *context_ptr = malloc(sizeof(lis2dh_logger_state_t)); - memset(*context_ptr, 0, sizeof(lis2dh_logger_state_t)); - gpio_set_pin_direction(A0, GPIO_DIRECTION_OUT); - gpio_set_pin_function(A0, GPIO_PIN_FUNCTION_OFF); - gpio_set_pin_level(A0, true); + *context_ptr = malloc(sizeof(lis2dw_logger_state_t)); + memset(*context_ptr, 0, sizeof(lis2dw_logger_state_t)); watch_enable_i2c(); - lis2dh_begin(); - lis2dh_set_data_rate(LIS2DH_DATA_RATE_10_HZ); - lis2dh_configure_aoi_int1( - LIS2DH_INTERRUPT_CONFIGURATION_OR | - LIS2DH_INTERRUPT_CONFIGURATION_X_HIGH_ENABLE | - LIS2DH_INTERRUPT_CONFIGURATION_Y_HIGH_ENABLE | - LIS2DH_INTERRUPT_CONFIGURATION_Z_HIGH_ENABLE, 96, 0, true); + lis2dw_begin(); + lis2dw_set_low_power_mode(LIS2DW_LP_MODE_2); // lowest power 14-bit mode, 25 Hz is 3.5 µA @ 1.8V w/ low noise, 3µA without + lis2dw_set_low_noise_mode(true); // consumes a little more power + lis2dw_set_range(LIS2DW_CTRL6_VAL_RANGE_4G); + lis2dw_set_data_rate(LIS2DW_DATA_RATE_25_HZ); // is this enough for training? + // threshold is 1/64th of full scale, so for a FS of ±4G this is 1.25G + lis2dw_configure_wakeup_int1(10, true, false); } } -void lis2dh_logging_face_activate(movement_settings_t *settings, void *context) { - lis2dh_logger_state_t *logger_state = (lis2dh_logger_state_t *)context; +void lis2dw_logging_face_activate(movement_settings_t *settings, void *context) { + lis2dw_logger_state_t *logger_state = (lis2dw_logger_state_t *)context; // force two settings: never enter low energy mode, and always snap back to screen 0. // this assumes the accelerometer face is first in the watch_faces list. settings->bit.le_interval = 0; @@ -140,12 +137,13 @@ void lis2dh_logging_face_activate(movement_settings_t *settings, void *context) logger_state->display_index = 0; logger_state->log_ticks = 0; - watch_enable_digital_input(A1); + watch_enable_digital_input(A0); } -bool lis2dh_logging_face_loop(movement_event_t event, movement_settings_t *settings, void *context) { - lis2dh_logger_state_t *logger_state = (lis2dh_logger_state_t *)context; - lis2dh_interrupt_state interrupt_state = 0; +bool lis2dw_logging_face_loop(movement_event_t event, movement_settings_t *settings, void *context) { + lis2dw_logger_state_t *logger_state = (lis2dw_logger_state_t *)context; + lis2dw_wakeup_source wakeup_source = 0; + lis2dw_interrupt_source interrupt_source = 0; switch (event.event_type) { case EVENT_MODE_BUTTON_UP: @@ -157,13 +155,13 @@ bool lis2dh_logging_face_loop(movement_event_t event, movement_settings_t *setti case EVENT_LIGHT_BUTTON_DOWN: logger_state->axis_index = (logger_state->axis_index + 1) % 4; logger_state->log_ticks = 255; - _lis2dh_logging_face_update_display(settings, logger_state, interrupt_state); + _lis2dw_logging_face_update_display(settings, logger_state, wakeup_source); break; case EVENT_ALARM_BUTTON_UP: - if (logger_state->log_ticks) logger_state->display_index = (logger_state->display_index + 1) % LIS2DH_LOGGING_NUM_DATA_POINTS; + if (logger_state->log_ticks) logger_state->display_index = (logger_state->display_index + 1) % LIS2DW_LOGGING_NUM_DATA_POINTS; logger_state->log_ticks = 255; logger_state->axis_index = 0; - _lis2dh_logging_face_update_display(settings, logger_state, interrupt_state); + _lis2dw_logging_face_update_display(settings, logger_state, wakeup_source); break; case EVENT_ACTIVATE: case EVENT_TICK: @@ -172,20 +170,21 @@ bool lis2dh_logging_face_loop(movement_event_t event, movement_settings_t *setti } else { logger_state->display_index = 0; } - if (watch_get_pin_level(A1)) { + interrupt_source = lis2dw_get_interrupt_source(); + if (interrupt_source) { watch_set_indicator(WATCH_INDICATOR_SIGNAL); - interrupt_state = lis2dh_get_int1_state(); + wakeup_source = lis2dw_get_wakeup_source(); logger_state->interrupts[0]++; - if (interrupt_state & LIS2DH_INTERRUPT_STATE_X_HIGH) logger_state->x_interrupts_this_hour++; - if (interrupt_state & LIS2DH_INTERRUPT_STATE_Y_HIGH) logger_state->y_interrupts_this_hour++; - if (interrupt_state & LIS2DH_INTERRUPT_STATE_Z_HIGH) logger_state->z_interrupts_this_hour++; + if (wakeup_source & LIS2DW_WAKEUP_SRC_WAKEUP_X) logger_state->x_interrupts_this_hour++; + if (wakeup_source & LIS2DW_WAKEUP_SRC_WAKEUP_Y) logger_state->y_interrupts_this_hour++; + if (wakeup_source & LIS2DW_WAKEUP_SRC_WAKEUP_Z) logger_state->z_interrupts_this_hour++; } else { watch_clear_indicator(WATCH_INDICATOR_SIGNAL); } - _lis2dh_logging_face_update_display(settings, logger_state, interrupt_state); + _lis2dw_logging_face_update_display(settings, logger_state, wakeup_source); break; case EVENT_BACKGROUND_TASK: - _lis2dh_logging_face_log_data(logger_state); + _lis2dw_logging_face_log_data(logger_state); break; default: break; @@ -194,15 +193,15 @@ bool lis2dh_logging_face_loop(movement_event_t event, movement_settings_t *setti return true; } -void lis2dh_logging_face_resign(movement_settings_t *settings, void *context) { +void lis2dw_logging_face_resign(movement_settings_t *settings, void *context) { (void) settings; (void) context; - watch_disable_digital_input(A1); + watch_disable_digital_input(A0); } -bool lis2dh_logging_face_wants_background_task(movement_settings_t *settings, void *context) { +bool lis2dw_logging_face_wants_background_task(movement_settings_t *settings, void *context) { (void) settings; - lis2dh_logger_state_t *logger_state = (lis2dh_logger_state_t *)context; + lis2dw_logger_state_t *logger_state = (lis2dw_logger_state_t *)context; watch_date_time date_time = watch_rtc_get_date_time(); // this is kind of an abuse of the API, but, let's use the 1 minute tick to shift all our data over. diff --git a/movement/watch_faces/demo/lis2dh_logging_face.h b/movement/watch_faces/demo/lis2dw_logging_face.h index 49366542..f6ea85e7 100644 --- a/movement/watch_faces/demo/lis2dh_logging_face.h +++ b/movement/watch_faces/demo/lis2dw_logging_face.h @@ -22,20 +22,20 @@ * SOFTWARE. */ -#ifndef LIS2DH_LOGGING_FACE_H_ -#define LIS2DH_LOGGING_FACE_H_ +#ifndef LIS2DW_LOGGING_FACE_H_ +#define LIS2DW_LOGGING_FACE_H_ #include "movement.h" #include "watch.h" -#define LIS2DH_LOGGING_NUM_DATA_POINTS (96) +#define LIS2DW_LOGGING_NUM_DATA_POINTS (96) typedef struct { watch_date_time timestamp; uint32_t x_interrupts; uint32_t y_interrupts; uint32_t z_interrupts; -} lis2dh_logger_data_point_t; +} lis2dw_logger_data_point_t; typedef struct { uint8_t display_index; // the index we are displaying on screen @@ -46,21 +46,21 @@ typedef struct { uint32_t x_interrupts_this_hour; // the number of interrupts we have logged in the last hour uint32_t y_interrupts_this_hour; // the number of interrupts we have logged in the last hour uint32_t z_interrupts_this_hour; // the number of interrupts we have logged in the last hour - lis2dh_logger_data_point_t data[LIS2DH_LOGGING_NUM_DATA_POINTS]; -} lis2dh_logger_state_t; + lis2dw_logger_data_point_t data[LIS2DW_LOGGING_NUM_DATA_POINTS]; +} lis2dw_logger_state_t; -void lis2dh_logging_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr); -void lis2dh_logging_face_activate(movement_settings_t *settings, void *context); -bool lis2dh_logging_face_loop(movement_event_t event, movement_settings_t *settings, void *context); -void lis2dh_logging_face_resign(movement_settings_t *settings, void *context); -bool lis2dh_logging_face_wants_background_task(movement_settings_t *settings, void *context); +void lis2dw_logging_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr); +void lis2dw_logging_face_activate(movement_settings_t *settings, void *context); +bool lis2dw_logging_face_loop(movement_event_t event, movement_settings_t *settings, void *context); +void lis2dw_logging_face_resign(movement_settings_t *settings, void *context); +bool lis2dw_logging_face_wants_background_task(movement_settings_t *settings, void *context); -#define lis2dh_logging_face ((const watch_face_t){ \ - lis2dh_logging_face_setup, \ - lis2dh_logging_face_activate, \ - lis2dh_logging_face_loop, \ - lis2dh_logging_face_resign, \ - lis2dh_logging_face_wants_background_task, \ +#define lis2dw_logging_face ((const watch_face_t){ \ + lis2dw_logging_face_setup, \ + lis2dw_logging_face_activate, \ + lis2dw_logging_face_loop, \ + lis2dw_logging_face_resign, \ + lis2dw_logging_face_wants_background_task, \ }) -#endif // LIS2DH_LOGGING_FACE_H_ +#endif // LIS2DW_LOGGING_FACE_H_ @@ -4,6 +4,8 @@ OBJS = $(addprefix $(BUILD)/, $(notdir %/$(subst .c,.o, $(SRCS)))) SUBMODULES = tinyusb +COBRA = cobra -f + ifndef EMSCRIPTEN all: directory $(SUBMODULES) $(BUILD)/$(BIN).elf $(BUILD)/$(BIN).hex $(BUILD)/$(BIN).bin $(BUILD)/$(BIN).uf2 size else @@ -54,4 +56,7 @@ clean: @echo clean @-rm -rf $(BUILD) +analyze: + @$(COBRA) basic $(INCLUDES) $(DEFINES) $(SRCS) + -include $(wildcard $(BUILD)/*.d) diff --git a/watch-library/hardware/watch/watch_adc.c b/watch-library/hardware/watch/watch_adc.c index c8c4d65a..476f0cbb 100644 --- a/watch-library/hardware/watch/watch_adc.c +++ b/watch-library/hardware/watch/watch_adc.c @@ -36,7 +36,7 @@ static uint16_t _watch_get_analog_value(uint16_t channel) { } ADC->SWTRIG.bit.START = 1; - while (!ADC->INTFLAG.bit.RESRDY); + while (!ADC->INTFLAG.bit.RESRDY); // wait for "result ready" flag return ADC->RESULT.reg; } diff --git a/watch-library/hardware/watch/watch_deepsleep.c b/watch-library/hardware/watch/watch_deepsleep.c index e3f654f2..ae2ad31d 100644 --- a/watch-library/hardware/watch/watch_deepsleep.c +++ b/watch-library/hardware/watch/watch_deepsleep.c @@ -69,7 +69,7 @@ void watch_register_extwake_callback(uint8_t pin, ext_irq_cb_t callback, bool le // disable the RTC RTC->MODE2.CTRLA.bit.ENABLE = 0; - while (RTC->MODE2.SYNCBUSY.bit.ENABLE); + while (RTC->MODE2.SYNCBUSY.bit.ENABLE); // wait for RTC to be disabled // update the configuration RTC->MODE2.TAMPCTRL.reg = config; @@ -192,15 +192,3 @@ void watch_enter_backup_mode(void) { // go into backup sleep mode (5). when we exit, the reset controller will take over. sleep(5); } - -// deprecated -void watch_enter_shallow_sleep(bool display_on) { - if (display_on) watch_enter_sleep_mode(); - else watch_enter_deep_sleep_mode(); -} - -// deprecated -void watch_enter_deep_sleep(void) { - watch_register_extwake_callback(BTN_ALARM, NULL, true); - watch_enter_backup_mode(); -} diff --git a/watch-library/hardware/watch/watch_extint.c b/watch-library/hardware/watch/watch_extint.c index 5924b646..13e8eaa3 100644 --- a/watch-library/hardware/watch/watch_extint.c +++ b/watch-library/hardware/watch/watch_extint.c @@ -101,11 +101,3 @@ void watch_register_interrupt_callback(const uint8_t pin, ext_irq_cb_t callback, ext_irq_register(pin, callback); } - -inline void watch_register_button_callback(const uint8_t pin, ext_irq_cb_t callback) { - watch_register_interrupt_callback(pin, callback, INTERRUPT_TRIGGER_RISING); -} - -inline void watch_enable_buttons(void) { - watch_enable_external_interrupts(); -} diff --git a/watch-library/hardware/watch/watch_led.c b/watch-library/hardware/watch/watch_led.c index 52174b54..5e2d8ecf 100644 --- a/watch-library/hardware/watch/watch_led.c +++ b/watch-library/hardware/watch/watch_led.c @@ -34,16 +34,6 @@ void watch_disable_leds(void) { _watch_disable_tcc(); } -void watch_enable_led(bool unused) { - (void)unused; - watch_enable_leds(); -} - -void watch_disable_led(bool unused) { - (void)unused; - watch_disable_leds(); -} - void watch_set_led_color(uint8_t red, uint8_t green) { if (hri_tcc_get_CTRLA_reg(TCC0, TCC_CTRLA_ENABLE)) { uint32_t period = hri_tcc_get_PER_reg(TCC0, TCC_PER_MASK); diff --git a/watch-library/hardware/watch/watch_private.c b/watch-library/hardware/watch/watch_private.c index 241ff40a..e4a03926 100644 --- a/watch-library/hardware/watch/watch_private.c +++ b/watch-library/hardware/watch/watch_private.c @@ -35,7 +35,7 @@ void _watch_init(void) { // Use switching regulator for lower power consumption. SUPC->VREG.bit.SEL = 1; - while(!SUPC->STATUS.bit.VREGRDY); + while(!SUPC->STATUS.bit.VREGRDY); // wait for voltage regulator to become ready // check the battery voltage... watch_enable_adc(); @@ -63,7 +63,7 @@ void _watch_init(void) { SUPC->BOD33.bit.LEVEL = 34; // Detect brownout at 2.6V (1.445V + level * 34mV) SUPC->BOD33.bit.ACTION = 0x2; // Generate an interrupt when BOD33 is triggered SUPC->BOD33.bit.HYST = 0; // Disable hysteresis - while(!SUPC->STATUS.bit.B33SRDY); + while(!SUPC->STATUS.bit.B33SRDY); // wait for BOD33 to sync // Enable interrupt on BOD33 detect SUPC->INTENSET.bit.BOD33DET = 1; @@ -198,7 +198,7 @@ void _watch_enable_usb(void) { // assign DFLL to GCLK1 GCLK->GENCTRL[1].reg = GCLK_GENCTRL_SRC(GCLK_GENCTRL_SRC_DFLL48M) | GCLK_GENCTRL_DIV(1) | GCLK_GENCTRL_GENEN;// | GCLK_GENCTRL_OE; - while (GCLK->SYNCBUSY.bit.GENCTRL1); + while (GCLK->SYNCBUSY.bit.GENCTRL1); // wait for generator control 1 to sync // assign GCLK1 to USB hri_gclk_write_PCHCTRL_reg(GCLK, USB_GCLK_ID, GCLK_PCHCTRL_GEN_GCLK1_Val | GCLK_PCHCTRL_CHEN); @@ -260,15 +260,6 @@ int _read(void) { return 0; } -// Alternate function that outputs to the debug UART. useful for debugging USB issues. -// int _write(int file, char *ptr, int len) { -// (void)file; -// int pos = 0; -// while(pos < len) watch_debug_putc(ptr[pos++]); - -// return 0; -// } - void USB_Handler(void) { tud_int_handler(0); } diff --git a/watch-library/hardware/watch/watch_rtc.c b/watch-library/hardware/watch/watch_rtc.c index 28360523..8382e571 100644 --- a/watch-library/hardware/watch/watch_rtc.c +++ b/watch-library/hardware/watch/watch_rtc.c @@ -160,40 +160,3 @@ void RTC_Handler(void) { RTC->MODE2.INTFLAG.reg = RTC_MODE2_INTFLAG_ALARM0; } } - -/////////////////////// -// Deprecated functions - -void watch_set_date_time(struct calendar_date_time date_time) { - RTC_MODE2_CLOCK_Type val; - - val.bit.SECOND = date_time.time.sec; - val.bit.MINUTE = date_time.time.min; - val.bit.HOUR = date_time.time.hour; - val.bit.DAY = date_time.date.day; - val.bit.MONTH = date_time.date.month; - val.bit.YEAR = (uint8_t)(date_time.date.year - WATCH_RTC_REFERENCE_YEAR); - - RTC->MODE2.CLOCK.reg = val.reg; - - _sync_rtc(); -} - -void watch_get_date_time(struct calendar_date_time *date_time) { - _sync_rtc(); - RTC_MODE2_CLOCK_Type val = RTC->MODE2.CLOCK; - - date_time->time.sec = val.bit.SECOND; - date_time->time.min = val.bit.MINUTE; - date_time->time.hour = val.bit.HOUR; - date_time->date.day = val.bit.DAY; - date_time->date.month = val.bit.MONTH; - date_time->date.year = val.bit.YEAR + WATCH_RTC_REFERENCE_YEAR; -} - -void watch_register_tick_callback(ext_irq_cb_t callback) { - tick_callbacks[7] = callback; - NVIC_ClearPendingIRQ(RTC_IRQn); - NVIC_EnableIRQ(RTC_IRQn); - RTC->MODE2.INTENSET.reg = RTC_MODE2_INTENSET_PER7; -} diff --git a/watch-library/hardware/watch/watch_uart.c b/watch-library/hardware/watch/watch_uart.c index c8e0600d..3aee7e3d 100644 --- a/watch-library/hardware/watch/watch_uart.c +++ b/watch-library/hardware/watch/watch_uart.c @@ -116,70 +116,3 @@ char watch_uart_getc(void) { io_read(uart_io, &retval, 1); return retval; } - -// Begin deprecated functions - - /* - * UART methods are Copyright (c) 2014-2017, Alex Taradov <alex@taradov.com> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "peripheral_clk_config.h" - -void watch_enable_debug_uart(uint32_t baud) { - uint64_t br = (uint64_t)65536 * ((CONF_CPU_FREQUENCY * 4) - 16 * baud) / (CONF_CPU_FREQUENCY * 4); - - gpio_set_pin_direction(A2, GPIO_DIRECTION_OUT); - gpio_set_pin_function(A2, PINMUX_PB02C_SERCOM3_PAD0); - - MCLK->APBCMASK.reg |= MCLK_APBCMASK_SERCOM3; - - GCLK->PCHCTRL[SERCOM3_GCLK_ID_CORE].reg = GCLK_PCHCTRL_GEN(0) | GCLK_PCHCTRL_CHEN; - while (0 == (GCLK->PCHCTRL[SERCOM3_GCLK_ID_CORE].reg & GCLK_PCHCTRL_CHEN)); - - SERCOM3->USART.CTRLA.reg = - SERCOM_USART_CTRLA_DORD | SERCOM_USART_CTRLA_MODE(1/*USART_INT_CLK*/) | - SERCOM_USART_CTRLA_RXPO(1/*PAD1*/) | SERCOM_USART_CTRLA_TXPO(0/*PAD0*/); - - SERCOM3->USART.CTRLB.reg = SERCOM_USART_CTRLB_RXEN | SERCOM_USART_CTRLB_TXEN | - SERCOM_USART_CTRLB_CHSIZE(0/*8 bits*/); - - SERCOM3->USART.BAUD.reg = (uint16_t)br; - - SERCOM3->USART.CTRLA.reg |= SERCOM_USART_CTRLA_ENABLE; -} - -void watch_debug_putc(char c) { - while (!(SERCOM3->USART.INTFLAG.reg & SERCOM_USART_INTFLAG_DRE)); - SERCOM3->USART.DATA.reg = c; -} - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -void watch_debug_puts(char *s) { - while (*s) watch_debug_putc(*s++); -} -#pragma GCC diagnostic pop diff --git a/watch-library/shared/driver/lis2dh.c b/watch-library/shared/driver/lis2dh.c deleted file mode 100644 index 20702bf5..00000000 --- a/watch-library/shared/driver/lis2dh.c +++ /dev/null @@ -1,143 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2021 Joey Castillo - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "lis2dh.h" -#include "watch.h" - -bool lis2dh_begin(void) { - if (lis2dh_get_device_id() != LIS2DH_WHO_AM_I_VAL) { - return false; - } - // Enable all axes, start at lowest possible data rate - watch_i2c_write8(LIS2DH_ADDRESS, LIS2DH_REG_CTRL1, LIS2DH_CTRL1_VAL_XEN | - LIS2DH_CTRL1_VAL_YEN | - LIS2DH_CTRL1_VAL_ZEN | - LIS2DH_CTRL1_VAL_ODR_1HZ); - // Set range to ±2G and enable block data update (output registers not updated until MSB and LSB have been read) - watch_i2c_write8(LIS2DH_ADDRESS, LIS2DH_REG_CTRL4, LIS2DH_CTRL4_VAL_BDU | LIS2DH_RANGE_2_G); - - return true; -} - -uint8_t lis2dh_get_device_id(void) { - return watch_i2c_read8(LIS2DH_ADDRESS, LIS2DH_REG_WHO_AM_I); -} - -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(void) { - uint8_t buffer[6]; - uint8_t reg = LIS2DH_REG_OUT_X_L | 0x80; // set high bit for consecutive reads - lis2dh_reading retval; - - watch_i2c_send(LIS2DH_ADDRESS, ®, 1); - watch_i2c_receive(LIS2DH_ADDRESS, (uint8_t *)&buffer, 6); - - retval.x = buffer[0]; - retval.x |= ((uint16_t)buffer[1]) << 8; - retval.y = buffer[2]; - retval.y |= ((uint16_t)buffer[3]) << 8; - retval.z = buffer[4]; - retval.z |= ((uint16_t)buffer[5]) << 8; - - return retval; -} - - lis2dh_acceleration_measurement lis2dh_get_acceleration_measurement(lis2dh_reading *out_reading) { - lis2dh_reading reading = lis2dh_get_raw_reading(); - uint8_t range = lis2dh_get_range(); - if (out_reading != NULL) *out_reading = reading; - - // this bit is cribbed from Adafruit's LIS3DH driver; from their notes, the magic number below - // converts from 16-bit lsb to 10-bit and divides by 1k to convert from milli-gs. - // final value is raw_lsb => 10-bit lsb -> milli-gs -> gs - uint8_t lsb_value = 1; - if (range == LIS2DH_RANGE_2_G) lsb_value = 4; - if (range == LIS2DH_RANGE_4_G) lsb_value = 8; - if (range == LIS2DH_RANGE_8_G) lsb_value = 16; - if (range == LIS2DH_RANGE_16_G) lsb_value = 48; - - lis2dh_acceleration_measurement retval; - - retval.x = lsb_value * ((float)reading.x / 64000.0); - retval.y = lsb_value * ((float)reading.y / 64000.0); - retval.z = lsb_value * ((float)reading.z / 64000.0); - - return retval; -} - -void lis2dh_set_range(lis2dh_range_t range) { - uint8_t val = watch_i2c_read8(LIS2DH_ADDRESS, LIS2DH_REG_CTRL4) & 0xCF; - uint8_t bits = range << 4; - - watch_i2c_write8(LIS2DH_ADDRESS, LIS2DH_REG_CTRL4, val | bits); -} - -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; -} - - -void lis2dh_set_data_rate(lis2dh_data_rate_t dataRate) { - uint8_t val = watch_i2c_read8(LIS2DH_ADDRESS, LIS2DH_REG_CTRL1) & 0x0F; - uint8_t bits = dataRate << 4; - - watch_i2c_write8(LIS2DH_ADDRESS, LIS2DH_REG_CTRL1, val | bits); -} - -lis2dh_data_rate_t lis2dh_get_data_rate(void) { - return watch_i2c_read8(LIS2DH_ADDRESS, LIS2DH_REG_CTRL1) >> 4; -} - -void lis2dh_configure_aoi_int1(lis2dh_interrupt_configuration configuration, uint8_t threshold, uint8_t duration, bool latch) { - watch_i2c_write8(LIS2DH_ADDRESS, LIS2DH_REG_CTRL3, LIS2DH_CTRL3_VAL_I1_AOI1); - watch_i2c_write8(LIS2DH_ADDRESS, LIS2DH_REG_INT1_CFG, configuration); - watch_i2c_write8(LIS2DH_ADDRESS, LIS2DH_REG_INT1_THS, threshold); - watch_i2c_write8(LIS2DH_ADDRESS, LIS2DH_REG_INT1_DUR, duration); - uint8_t val = watch_i2c_read8(LIS2DH_ADDRESS, LIS2DH_REG_CTRL5) & 0xF7; - watch_i2c_write8(LIS2DH_ADDRESS, LIS2DH_REG_CTRL5, val | latch ? LIS2DH_CTRL5_VAL_LIR_INT1 : 0); -} - -lis2dh_interrupt_state lis2dh_get_int1_state(void) { - return (lis2dh_interrupt_state) watch_i2c_read8(LIS2DH_ADDRESS, LIS2DH_REG_INT1_SRC); -} - -void lis2dh_configure_aoi_int2(lis2dh_interrupt_configuration configuration, uint8_t threshold, uint8_t duration, bool latch) { - watch_i2c_write8(LIS2DH_ADDRESS, LIS2DH_REG_CTRL6, LIS2DH_CTRL6_VAL_I2_INT2); - watch_i2c_write8(LIS2DH_ADDRESS, LIS2DH_REG_INT2_CFG, configuration); - watch_i2c_write8(LIS2DH_ADDRESS, LIS2DH_REG_INT2_THS, threshold); - watch_i2c_write8(LIS2DH_ADDRESS, LIS2DH_REG_INT2_DUR, duration); - uint8_t val = watch_i2c_read8(LIS2DH_ADDRESS, LIS2DH_REG_CTRL5) & 0xFD; - watch_i2c_write8(LIS2DH_ADDRESS, LIS2DH_REG_CTRL5, val | latch ? LIS2DH_CTRL5_VAL_LIR_INT2 : 0); -} - -lis2dh_interrupt_state lis2dh_get_int2_state(void) { - return (lis2dh_interrupt_state) watch_i2c_read8(LIS2DH_ADDRESS, LIS2DH_REG_INT2_SRC); -} - diff --git a/watch-library/shared/driver/lis2dh.h b/watch-library/shared/driver/lis2dh.h deleted file mode 100644 index 68831519..00000000 --- a/watch-library/shared/driver/lis2dh.h +++ /dev/null @@ -1,222 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2021 Joey Castillo - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef LIS2DH_H -#define LIS2DH_H - -#include <stdbool.h> -#include <stdint.h> - -typedef struct { - int16_t x; - int16_t y; - int16_t z; -} lis2dh_reading; - -typedef struct { - float x; - float y; - float z; -} lis2dh_acceleration_measurement; - -typedef enum { - LIS2DH_RANGE_16_G = 0b11, // +/- 16g - LIS2DH_RANGE_8_G = 0b10, // +/- 8g - LIS2DH_RANGE_4_G = 0b01, // +/- 4g - LIS2DH_RANGE_2_G = 0b00 // +/- 2g (default value) -} lis2dh_range_t; - -typedef enum { - LIS2DH_DATA_RATE_POWERDOWN = 0, - LIS2DH_DATA_RATE_1_HZ = 0b0001, - LIS2DH_DATA_RATE_10_HZ = 0b0010, - LIS2DH_DATA_RATE_25_HZ = 0b0011, - LIS2DH_DATA_RATE_50_HZ = 0b0100, - LIS2DH_DATA_RATE_100_HZ = 0b0101, - LIS2DH_DATA_RATE_200_HZ = 0b0110, - LIS2DH_DATA_RATE_400_HZ = 0b0111, - LIS2DH_DATA_RATE_LP1620HZ = 0b1000, - LIS2DH_DATA_RATE_LP5376HZ = 0b1001, - -} lis2dh_data_rate_t; - -typedef enum { - LIS2DH_INTERRUPT_CONFIGURATION_OR = 0b00000000, - LIS2DH_INTERRUPT_CONFIGURATION_AND = 0b10000000, - LIS2DH_INTERRUPT_CONFIGURATION_6D_MOVEMENT = 0b01000000, - LIS2DH_INTERRUPT_CONFIGURATION_6D_POSITION = 0b11000000, // in 6D mode, these have an alternate meaning: - LIS2DH_INTERRUPT_CONFIGURATION_Z_HIGH_ENABLE = 0b00100000, // Z up enable - LIS2DH_INTERRUPT_CONFIGURATION_Z_LOW_ENABLE = 0b00010000, // Z down enable - LIS2DH_INTERRUPT_CONFIGURATION_Y_HIGH_ENABLE = 0b00001000, // Y up enable - LIS2DH_INTERRUPT_CONFIGURATION_Y_LOW_ENABLE = 0b00000100, // Y down enable - LIS2DH_INTERRUPT_CONFIGURATION_X_HIGH_ENABLE = 0b00000010, // X up enable - LIS2DH_INTERRUPT_CONFIGURATION_X_LOW_ENABLE = 0b00000001, // X down enable -} lis2dh_interrupt_configuration; - -typedef enum { - LIS2DH_INTERRUPT_STATE_ACTIVE = 0b01000000, - LIS2DH_INTERRUPT_STATE_Z_HIGH = 0b00100000, // Z up - LIS2DH_INTERRUPT_STATE_Z_LOW = 0b00010000, // Z down - LIS2DH_INTERRUPT_STATE_Y_HIGH = 0b00001000, // Y up - LIS2DH_INTERRUPT_STATE_Y_LOW = 0b00000100, // Y down - LIS2DH_INTERRUPT_STATE_X_HIGH = 0b00000010, // X up - LIS2DH_INTERRUPT_STATE_X_LOW = 0b00000001, // X down -} lis2dh_interrupt_state; - -bool lis2dh_begin(void); - -uint8_t lis2dh_get_device_id(void); - -bool lis2dh_have_new_data(void); - -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(void); - -void lis2dh_set_data_rate(lis2dh_data_rate_t dataRate); - -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(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(void); - -// Assumes SA0 is high; if low, its 0x18 -#define LIS2DH_ADDRESS (0x19) - -#define LIS2DH_REG_STATUS_AUX 0x07 ///< Auxiliary status register -#define LIS2DH_REG_STATUS_AUX_TDA (1 << 2) ///< Temperature data available -#define LIS2DH_REG_STATUS_AUX_TOR (1 << 6) ///< Temperature data overrun - -#define LIS2DH_REG_OUT_TEMP_L 0x0C ///< Temperature data low bit -#define LIS2DH_REG_OUT_TEMP_H 0x0D ///< Temperature data high bit - -#define LIS2DH_REG_INT_COUNTER 0x0E - -#define LIS2DH_REG_WHO_AM_I 0x0F ///< Device identification, will read 0x33 -#define LIS2DH_WHO_AM_I_VAL 0x33 ///< Expected value of the WHO_AM_I register - -#define LIS2DH_REG_TEMP_CFG 0x1F ///< Temperature configuration; 0 to disable, 0xC0 to enable. -#define LIS2DH_TEMP_CFG_VAL_ENABLE 0xC0 ///< Value for LIS2DH_REG_TEMP_CFG that enables temperature sensing. -#define LIS2DH_TEMP_CFG_VAL_DISABLE 0x00 ///< Value for LIS2DH_REG_TEMP_CFG that disables temperature sensing. - -#define LIS2DH_REG_CTRL1 0x20 ///< CTRL_REG1 in the data sheet. -#define LIS2DH_CTRL1_VAL_XEN 0b00000001 ///< Enable X-axis -#define LIS2DH_CTRL1_VAL_YEN 0b00000010 ///< Enable Y-axis -#define LIS2DH_CTRL1_VAL_ZEN 0b00000100 ///< Enable Z-axis -#define LIS2DH_CTRL1_VAL_LPEN 0b00001000 ///< Enable low power mode -#define LIS2DH_CTRL1_VAL_ODR_POWERDOWN 0 ///< Power down -#define LIS2DH_CTRL1_VAL_ODR_1HZ (LIS2DH_DATA_RATE_1_HZ << 4) -#define LIS2DH_CTRL1_VAL_ODR_10HZ (LIS2DH_DATA_RATE_10_HZ << 4) -#define LIS2DH_CTRL1_VAL_ODR_25HZ (LIS2DH_DATA_RATE_25_HZ << 4) -#define LIS2DH_CTRL1_VAL_ODR_50HZ (LIS2DH_DATA_RATE_50_HZ << 4) -#define LIS2DH_CTRL1_VAL_ODR_100HZ (LIS2DH_DATA_RATE_100_HZ << 4) -#define LIS2DH_CTRL1_VAL_ODR_200HZ (LIS2DH_DATA_RATE_200_HZ << 4) -#define LIS2DH_CTRL1_VAL_ODR_400HZ (LIS2DH_DATA_RATE_400_HZ << 4) -#define LIS2DH_CTRL1_VAL_ODR_LP1620HZ (LIS2DH_DATA_RATE_LP1620HZ << 4) -#define LIS2DH_CTRL1_VAL_ODR_LP5376HZ (LIS2DH_DATA_RATE_LP5376HZ << 4) - -#define LIS2DH_REG_CTRL2 0x21 - -#define LIS2DH_REG_CTRL3 0x22 -#define LIS2DH_CTRL3_VAL_I1_CLICK 0b10000000 -#define LIS2DH_CTRL3_VAL_I1_AOI1 0b01000000 -#define LIS2DH_CTRL3_VAL_I1_AOI2 0b00100000 -#define LIS2DH_CTRL3_VAL_I1_DRDY1 0b00010000 -#define LIS2DH_CTRL3_VAL_I1_DRDY2 0b00001000 -#define LIS2DH_CTRL3_VAL_I1_WTM 0b00000100 -#define LIS2DH_CTRL3_VAL_I1_OVERRUN 0b00000010 - -#define LIS2DH_REG_CTRL4 0x23 -#define LIS2DH_CTRL4_VAL_BDU 0b10000000 -#define LIS2DH_CTRL4_VAL_BLE 0b01000000 -#define LIS2DH_CTRL4_VAL_RANGE_2G (LIS2DH_RANGE_2_G << 4) -#define LIS2DH_CTRL4_VAL_RANGE_4G (LIS2DH_RANGE_4_G << 4) -#define LIS2DH_CTRL4_VAL_RANGE_8G (LIS2DH_RANGE_8_G << 4) -#define LIS2DH_CTRL4_VAL_RANGE_16G (LIS2DH_RANGE_16_G << 4) -#define LIS2DH_CTRL4_VAL_HR 0b00001000 -#define LIS2DH_CTRL4_VAL_ST0 0b00000000 -#define LIS2DH_CTRL4_VAL_ST1 0b00000000 - -#define LIS2DH_REG_CTRL5 0x24 -#define LIS2DH_CTRL5_VAL_BOOT 0b10000000 -#define LIS2DH_CTRL5_VAL_FIFO_EN 0b01000000 -#define LIS2DH_CTRL5_VAL_LIR_INT1 0b00001000 -#define LIS2DH_CTRL5_VAL_D4D_INT1 0b00000100 -#define LIS2DH_CTRL5_VAL_LIR_INT2 0b00000010 -#define LIS2DH_CTRL5_VAL_D4D_INT2 0b00000001 - -#define LIS2DH_REG_CTRL6 0x25 -#define LIS2DH_CTRL6_VAL_I2_CLICK 0b10000000 -#define LIS2DH_CTRL6_VAL_I2_INT1 0b01000000 -#define LIS2DH_CTRL6_VAL_I2_INT2 0b00100000 -#define LIS2DH_CTRL6_VAL_BOOT_I2 0b00010000 -#define LIS2DH_CTRL6_VAL_P2_ACT 0b00001000 -#define LIS2DH_CTRL6_VAL_H_L_ACTIVE 0b00000000 - -#define LIS2DH_REG_REFERENCE 0x26 - -#define LIS2DH_REG_STATUS 0x27 -#define LIS2DH_STATUS_VAL_ZYXOR 0b10000000 -#define LIS2DH_STATUS_VAL_ZOR 0b01000000 -#define LIS2DH_STATUS_VAL_YOR 0b00100000 -#define LIS2DH_STATUS_VAL_XOR 0b00010000 -#define LIS2DH_STATUS_VAL_ZYXDA 0b00001000 -#define LIS2DH_STATUS_VAL_ZDA 0b00000100 -#define LIS2DH_STATUS_VAL_YDA 0b00000010 -#define LIS2DH_STATUS_VAL_XDA 0b00000001 - -#define LIS2DH_REG_OUT_X_L 0x28 -#define LIS2DH_REG_OUT_X_H 0x29 -#define LIS2DH_REG_OUT_Y_L 0x2A -#define LIS2DH_REG_OUT_Y_H 0x2B -#define LIS2DH_REG_OUT_Z_L 0x2C -#define LIS2DH_REG_OUT_Z_H 0x2D - -#define LIS2DH_REG_FIFO_CTRL 0x2E -#define LIS2DH_REG_FIFO_SRC 0x2F -#define LIS2DH_REG_INT1_CFG 0x30 -#define LIS2DH_REG_INT1_SRC 0x31 -#define LIS2DH_REG_INT1_THS 0x32 -#define LIS2DH_REG_INT1_DUR 0x33 -#define LIS2DH_REG_INT2_CFG 0x34 -#define LIS2DH_REG_INT2_SRC 0x35 -#define LIS2DH_REG_INT2_THS 0x36 -#define LIS2DH_REG_INT2_DUR 0x37 -#define LIS2DH_REG_CLICK_CFG 0x38 -#define LIS2DH_REG_CLICK_SRC 0x39 -#define LIS2DH_REG_CLICK_THS 0x3A -#define LIS2DH_REG_TIME_LIMIT 0x3B -#define LIS2DH_REG_TIME_LATENCY 0x3C -#define LIS2DH_REG_TIME_WINDOW 0x3D - -#endif // LIS2DH_H diff --git a/watch-library/shared/driver/lis2dw.c b/watch-library/shared/driver/lis2dw.c index fce266b3..4d60fcff 100644 --- a/watch-library/shared/driver/lis2dw.c +++ b/watch-library/shared/driver/lis2dw.c @@ -164,3 +164,32 @@ void lis2dw_clear_fifo(void) { watch_i2c_write8(LIS2DW_ADDRESS, LIS2DW_REG_FIFO_CTRL, LIS2DW_FIFO_CTRL_MODE_OFF); watch_i2c_write8(LIS2DW_ADDRESS, LIS2DW_REG_FIFO_CTRL, LIS2DW_FIFO_CTRL_MODE_COLLECT_AND_STOP | LIS2DW_FIFO_CTRL_FTH); } + +void lis2dw_configure_wakeup_int1(uint8_t threshold, bool latch, bool active_state) { + uint8_t configuration; + + // enable wakeup interrupt on INT1 pin + configuration = watch_i2c_read8(LIS2DW_ADDRESS, LIS2DW_REG_CTRL4_INT1); + watch_i2c_write8(LIS2DW_ADDRESS, LIS2DW_REG_CTRL4_INT1, configuration | LIS2DW_CTRL4_INT1_WU); + + // set threshold + watch_i2c_write8(LIS2DW_ADDRESS, LIS2DW_REG_WAKE_UP_THS, threshold | LIS2DW_WAKE_UP_THS_VAL_SLEEP_ON); + watch_i2c_write8(LIS2DW_ADDRESS, LIS2DW_REG_INT1_DUR, 0b01111111); + + configuration = watch_i2c_read8(LIS2DW_ADDRESS, LIS2DW_REG_CTRL3) & ~(LIS2DW_CTRL3_VAL_LIR); + if (!active_state) configuration |= LIS2DW_CTRL3_VAL_H_L_ACTIVE; + if (latch) configuration |= LIS2DW_CTRL3_VAL_LIR; + watch_i2c_write8(LIS2DW_ADDRESS, LIS2DW_REG_CTRL3, configuration); + + // enable interrupts + configuration = watch_i2c_read8(LIS2DW_ADDRESS, LIS2DW_REG_CTRL7); + watch_i2c_write8(LIS2DW_ADDRESS, LIS2DW_REG_CTRL7, configuration | LIS2DW_CTRL7_VAL_INTERRUPTS_ENABLE); +} + +lis2dw_wakeup_source lis2dw_get_wakeup_source() { + return (lis2dw_wakeup_source) watch_i2c_read8(LIS2DW_ADDRESS, LIS2DW_REG_WAKE_UP_SRC); +} + +lis2dw_interrupt_source lis2dw_get_interrupt_source(void) { + return (lis2dw_interrupt_source) watch_i2c_read8(LIS2DW_ADDRESS, LIS2DW_REG_ALL_INT_SRC); +} diff --git a/watch-library/shared/driver/lis2dw.h b/watch-library/shared/driver/lis2dw.h index 41611172..f9373e04 100644 --- a/watch-library/shared/driver/lis2dw.h +++ b/watch-library/shared/driver/lis2dw.h @@ -94,6 +94,24 @@ typedef enum { LIS2DW_RANGE_2_G = 0b00 // +/- 2g (default value) } lis2dw_range_t; +typedef enum { + LIS2DW_INTERRUPT_SRC_SLEEP_CHANGE = 0b00100000, + LIS2DW_INTERRUPT_SRC_6D = 0b00010000, + LIS2DW_INTERRUPT_SRC_DOUBLE_TAP = 0b00001000, + LIS2DW_INTERRUPT_SRC_SINGLE_TAP = 0b00000100, + LIS2DW_INTERRUPT_SRC_WU = 0b00000010, + LIS2DW_INTERRUPT_SRC_FF = 0b00000001 +} lis2dw_interrupt_source; + +typedef enum { + LIS2DW_WAKEUP_SRC_FREEFALL = 0b00100000, + LIS2DW_WAKEUP_SRC_SLEEP_STATE = 0b00010000, + LIS2DW_WAKEUP_SRC_WAKEUP = 0b00001000, + LIS2DW_WAKEUP_SRC_WAKEUP_X = 0b00000100, + LIS2DW_WAKEUP_SRC_WAKEUP_Y = 0b00000010, + LIS2DW_WAKEUP_SRC_WAKEUP_Z = 0b00000001 +} lis2dw_wakeup_source; + // Assumes SA0 is high; if low, its 0x18 #define LIS2DW_ADDRESS (0x19) @@ -130,15 +148,15 @@ typedef enum { #define LIS2DW_CTRL2_VAL_IF_ADD_INC 0b00000100 #define LIS2DW_REG_CTRL3 0x22 -#define LIS2DW_CTRL4_VAL_SELF_TEST_POS 0b10000000 -#define LIS2DW_CTRL4_VAL_SELF_TEST_NEG 0b01000000 +#define LIS2DW_CTRL3_VAL_SELF_TEST_POS 0b10000000 +#define LIS2DW_CTRL3_VAL_SELF_TEST_NEG 0b01000000 #define LIS2DW_CTRL3_VAL_PP_OD 0b00100000 #define LIS2DW_CTRL3_VAL_LIR 0b00010000 #define LIS2DW_CTRL3_VAL_H_L_ACTIVE 0b00001000 #define LIS2DW_CTRL3_VAL_SLP_MODE_SEL 0b00000010 #define LIS2DW_CTRL3_VAL_SLP_MODE_1 0b00000001 -#define LIS2DW_REG_CTRL4 0x23 +#define LIS2DW_REG_CTRL4_INT1 0x23 #define LIS2DW_CTRL4_INT1_6D 0b10000000 #define LIS2DW_CTRL4_INT1_SINGLE_TAP 0b01000000 #define LIS2DW_CTRL4_INT1_WU 0b00100000 @@ -148,7 +166,7 @@ typedef enum { #define LIS2DW_CTRL4_INT1_FTH 0b00000010 #define LIS2DW_CTRL4_INT1_DRDY 0b00000001 -#define LIS2DW_REG_CTRL5 0x24 +#define LIS2DW_REG_CTRL5_INT2 0x24 #define LIS2DW_CTRL5_INT2_SLEEP_STATE 0b10000000 #define LIS2DW_CTRL5_INT2_SLEEP_CHG 0b01000000 #define LIS2DW_CTRL5_INT2_BOOT 0b00100000 @@ -206,7 +224,11 @@ typedef enum { #define LIS2DW_REG_TAP_THS_Y 0x31 #define LIS2DW_REG_TAP_THS_Z 0x32 #define LIS2DW_REG_INT1_DUR 0x33 + #define LIS2DW_REG_WAKE_UP_THS 0x34 +#define LIS2DW_WAKE_UP_THS_VAL_TAP_EVENT_ENABLED 0b10000000 +#define LIS2DW_WAKE_UP_THS_VAL_SLEEP_ON 0b01000000 + #define LIS2DW_REG_WAKE_UP_DUR 0x35 #define LIS2DW_REG_FREE_FALL 0x36 #define LIS2DW_REG_STATUS_DUP 0x37 @@ -293,4 +315,10 @@ bool lis2dw_read_fifo(lis2dw_fifo_t *fifo_data); void lis2dw_clear_fifo(void); +void lis2dw_configure_wakeup_int1(uint8_t threshold, bool latch, bool active_state); + +lis2dw_interrupt_source lis2dw_get_interrupt_source(void); + +lis2dw_wakeup_source lis2dw_get_wakeup_source(void); + #endif // LIS2DW_H diff --git a/watch-library/shared/watch/watch_deepsleep.h b/watch-library/shared/watch/watch_deepsleep.h index f3ba7091..75a0a3d0 100644 --- a/watch-library/shared/watch/watch_deepsleep.h +++ b/watch-library/shared/watch/watch_deepsleep.h @@ -151,10 +151,5 @@ void watch_enter_deep_sleep_mode(void); */ 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); /// @} #endif diff --git a/watch-library/shared/watch/watch_extint.h b/watch-library/shared/watch/watch_extint.h index 452461b3..84194e9a 100644 --- a/watch-library/shared/watch/watch_extint.h +++ b/watch-library/shared/watch/watch_extint.h @@ -76,10 +76,5 @@ void watch_disable_external_interrupts(void); */ void watch_register_interrupt_callback(const uint8_t pin, ext_irq_cb_t callback, watch_interrupt_trigger trigger); -__attribute__((deprecated("Use watch_register_interrupt_callback or watch_register_extwake_callback instead"))) -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); /// @} #endif diff --git a/watch-library/shared/watch/watch_led.h b/watch-library/shared/watch/watch_led.h index 9e9f5640..7e2dea2e 100644 --- a/watch-library/shared/watch/watch_led.h +++ b/watch-library/shared/watch/watch_led.h @@ -84,10 +84,5 @@ void watch_set_led_yellow(void); /** @brief Turns both the red and the green LEDs off. */ void watch_set_led_off(void); -__attribute__((deprecated("Use watch_enable_leds instead"))) -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/shared/watch/watch_private_display.c b/watch-library/shared/watch/watch_private_display.c index 1454a3b6..474e5ffd 100644 --- a/watch-library/shared/watch/watch_private_display.c +++ b/watch-library/shared/watch/watch_private_display.c @@ -53,14 +53,14 @@ void watch_display_character(uint8_t character, uint8_t position) { } if (position == 1) { if (character == 'a') character = 'A'; // A needs to be uppercase - if (character == 'o') character = 'O'; // O needs to be uppercase - if (character == 'i') character = 'l'; // I needs to be uppercase (use an l, it looks the same) - if (character == 'n') character = 'N'; // N needs to be uppercase - if (character == 'r') character = 'R'; // R needs to be uppercase - if (character == 'd') character = 'D'; // D needs to be uppercase - if (character == 'v' || character == 'V' || character == 'u') character = 'U'; // side segments shared, make uppercase - if (character == 'b') character = 'B'; // B needs to be uppercase - if (character == 'c') character = 'C'; // C needs to be uppercase + else if (character == 'o') character = 'O'; // O needs to be uppercase + else if (character == 'i') character = 'l'; // I needs to be uppercase (use an l, it looks the same) + else if (character == 'n') character = 'N'; // N needs to be uppercase + else if (character == 'r') character = 'R'; // R needs to be uppercase + else if (character == 'd') character = 'D'; // D needs to be uppercase + else if (character == 'v' || character == 'V' || character == 'u') character = 'U'; // side segments shared, make uppercase + else if (character == 'b') character = 'B'; // B needs to be uppercase + else if (character == 'c') character = 'C'; // C needs to be uppercase } else { if (character == 'R') character = 'r'; // R needs to be lowercase almost everywhere } diff --git a/watch-library/shared/watch/watch_rtc.h b/watch-library/shared/watch/watch_rtc.h index 183e6dd0..6609e6b6 100644 --- a/watch-library/shared/watch/watch_rtc.h +++ b/watch-library/shared/watch/watch_rtc.h @@ -147,24 +147,5 @@ void watch_rtc_disable_matching_periodic_callbacks(uint8_t mask); */ 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. - */ -__attribute__((deprecated("Use watch_rtc_set_date_time function instead"))) -void watch_set_date_time(struct calendar_date_time date_time); - -/** @brief Returns the system date and time in the provided struct. - * @param date_time A pointer to a calendar_date_time struct. It will have with the correct date and time on return. - */ -__attribute__((deprecated("Use the watch_rtc_get_date_time function instead"))) -void watch_get_date_time(struct calendar_date_time *date_time); - -/** @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 - * interrupt will still be enabled, but no callback function will be called. - */ -__attribute__((deprecated("Use the watch_rtc_register_tick_callback function instead"))) -void watch_register_tick_callback(ext_irq_cb_t callback); - /// @} #endif diff --git a/watch-library/shared/watch/watch_uart.h b/watch-library/shared/watch/watch_uart.h index 79fcd53a..3d7ee778 100644 --- a/watch-library/shared/watch/watch_uart.h +++ b/watch-library/shared/watch/watch_uart.h @@ -52,24 +52,5 @@ void watch_uart_puts(char *s); */ char watch_uart_getc(void); -// Begin deprecated functions: - -/** @brief Initializes the debug UART. - * @param baud The baud rate - */ -__attribute__((deprecated("Use watch_enable_uart to enable the UART."))) -void watch_enable_debug_uart(uint32_t baud); - -/** @brief Outputs a single character on the debug UART. - * @param c The character you wish to output. - */ -__attribute__((deprecated("Use watch_uart_puts to print to the UART, or printf to log debug messages over USB."))) -void watch_debug_putc(char c); - -/** @brief Outputs a string on the debug UART. - * @param s A null-terminated string. - */ -__attribute__((deprecated("Use watch_uart_puts to print to the UART, or printf to log debug messages over USB."))) -void watch_debug_puts(char *s); /// @} #endif diff --git a/watch-library/simulator/watch/watch_deepsleep.c b/watch-library/simulator/watch/watch_deepsleep.c index a12cf2a6..5add05e8 100644 --- a/watch-library/simulator/watch/watch_deepsleep.c +++ b/watch-library/simulator/watch/watch_deepsleep.c @@ -86,15 +86,3 @@ void watch_enter_backup_mode(void) { // go into backup sleep mode (5). when we exit, the reset controller will take over. // sleep(5); } - -// deprecated -void watch_enter_shallow_sleep(bool display_on) { - if (display_on) watch_enter_sleep_mode(); - else watch_enter_deep_sleep_mode(); -} - -// deprecated -void watch_enter_deep_sleep(void) { - watch_register_extwake_callback(BTN_ALARM, NULL, true); - watch_enter_backup_mode(); -} diff --git a/watch-library/simulator/watch/watch_extint.c b/watch-library/simulator/watch/watch_extint.c index 03abe42c..cbba4c3d 100644 --- a/watch-library/simulator/watch/watch_extint.c +++ b/watch-library/simulator/watch/watch_extint.c @@ -181,11 +181,3 @@ void watch_register_interrupt_callback(const uint8_t pin, ext_irq_cb_t callback, external_interrupt_alarm_trigger = trigger; } } - -void watch_register_button_callback(const uint8_t pin, ext_irq_cb_t callback) { - watch_register_interrupt_callback(pin, callback, INTERRUPT_TRIGGER_RISING); -} - -void watch_enable_buttons(void) { - watch_enable_external_interrupts(); -} diff --git a/watch-library/simulator/watch/watch_led.c b/watch-library/simulator/watch/watch_led.c index 173f1b08..068da8bd 100644 --- a/watch-library/simulator/watch/watch_led.c +++ b/watch-library/simulator/watch/watch_led.c @@ -30,16 +30,6 @@ void watch_enable_leds(void) {} void watch_disable_leds(void) {} -void watch_enable_led(bool unused) { - (void)unused; - watch_enable_leds(); -} - -void watch_disable_led(bool unused) { - (void)unused; - watch_disable_leds(); -} - void watch_set_led_color(uint8_t red, uint8_t green) { EM_ASM({ document.getElementById('light').style.opacity = $1 / 255; diff --git a/watch-library/simulator/watch/watch_private.c b/watch-library/simulator/watch/watch_private.c index b852893b..4ddc2182 100644 --- a/watch-library/simulator/watch/watch_private.c +++ b/watch-library/simulator/watch/watch_private.c @@ -67,12 +67,3 @@ int _write(int file, char *ptr, int len) { int _read(void) { return 0; } - -// Alternate function that outputs to the debug UART. useful for debugging USB issues. -// int _write(int file, char *ptr, int len) { -// (void)file; -// int pos = 0; -// while(pos < len) watch_debug_putc(ptr[pos++]); - -// return 0; -// } diff --git a/watch-library/simulator/watch/watch_rtc.c b/watch-library/simulator/watch/watch_rtc.c index ea8659dc..107ae56c 100644 --- a/watch-library/simulator/watch/watch_rtc.c +++ b/watch-library/simulator/watch/watch_rtc.c @@ -197,32 +197,3 @@ void watch_rtc_disable_alarm_callback(void) { alarm_interval_id = -1; } } - -/////////////////////// -// Deprecated functions - -void watch_set_date_time(struct calendar_date_time date_time) { - watch_date_time val; - val.unit.second = date_time.time.sec; - val.unit.minute = date_time.time.min; - val.unit.hour = date_time.time.hour; - val.unit.day = date_time.date.day; - val.unit.month = date_time.date.month; - val.unit.year = date_time.date.year - WATCH_RTC_REFERENCE_YEAR; - watch_rtc_set_date_time(val); -} - -void watch_get_date_time(struct calendar_date_time *date_time) { - if (date_time == NULL) return; - watch_date_time val = watch_rtc_get_date_time(); - date_time->time.sec = val.unit.second; - date_time->time.min = val.unit.minute; - date_time->time.hour = val.unit.hour; - date_time->date.day = val.unit.day; - date_time->date.month = val.unit.month; - date_time->date.year = val.unit.year + WATCH_RTC_REFERENCE_YEAR; -} - -void watch_register_tick_callback(ext_irq_cb_t callback) { - watch_rtc_register_tick_callback(callback); -} diff --git a/watch-library/simulator/watch/watch_uart.c b/watch-library/simulator/watch/watch_uart.c index 7043383c..80c6a812 100644 --- a/watch-library/simulator/watch/watch_uart.c +++ b/watch-library/simulator/watch/watch_uart.c @@ -45,14 +45,3 @@ char watch_uart_getc(void) { } return 0; } - -void watch_enable_debug_uart(uint32_t baud) {} - -void watch_debug_putc(char c) {} - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -void watch_debug_puts(char *s) { - while (*s) watch_debug_putc(*s++); -} -#pragma GCC diagnostic pop |