summaryrefslogtreecommitdiffstats
path: root/watch-library
diff options
context:
space:
mode:
authorJoey Castillo <joeycastillo@utexas.edu>2022-02-01 00:24:20 -0500
committerJoey Castillo <joeycastillo@utexas.edu>2022-02-01 00:24:20 -0500
commita3085cb1364cba787ede58a35f3106108604b283 (patch)
tree7b43634949f56ff9fe55c7ce853cf47b9c2cf926 /watch-library
parent658739c880ca3568c7d3774d7c76fcdc3059a01b (diff)
parent932e10529d84872a0df6d182c721614dbf7ff8d2 (diff)
downloadSensor-Watch-a3085cb1364cba787ede58a35f3106108604b283.tar.gz
Sensor-Watch-a3085cb1364cba787ede58a35f3106108604b283.tar.bz2
Sensor-Watch-a3085cb1364cba787ede58a35f3106108604b283.zip
Merge branch 'main' of github.com:joeycastillo/Sensor-Watch
Diffstat (limited to 'watch-library')
-rw-r--r--watch-library/hardware/watch/watch_rtc.c6
-rw-r--r--watch-library/shared/watch/watch_rtc.h6
-rw-r--r--watch-library/simulator/watch/watch_rtc.c8
3 files changed, 17 insertions, 3 deletions
diff --git a/watch-library/hardware/watch/watch_rtc.c b/watch-library/hardware/watch/watch_rtc.c
index 14a968c4..28360523 100644
--- a/watch-library/hardware/watch/watch_rtc.c
+++ b/watch-library/hardware/watch/watch_rtc.c
@@ -102,8 +102,12 @@ void watch_rtc_disable_periodic_callback(uint8_t frequency) {
RTC->MODE2.INTENCLR.reg = 1 << per_n;
}
+void watch_rtc_disable_matching_periodic_callbacks(uint8_t mask) {
+ RTC->MODE2.INTENCLR.reg = mask;
+}
+
void watch_rtc_disable_all_periodic_callbacks(void) {
- RTC->MODE2.INTENCLR.reg = 0xFF;
+ watch_rtc_disable_matching_periodic_callbacks(0xFF);
}
void watch_rtc_register_alarm_callback(ext_irq_cb_t callback, watch_date_time alarm_time, watch_rtc_alarm_match mask) {
diff --git a/watch-library/shared/watch/watch_rtc.h b/watch-library/shared/watch/watch_rtc.h
index 6dac63f5..183e6dd0 100644
--- a/watch-library/shared/watch/watch_rtc.h
+++ b/watch-library/shared/watch/watch_rtc.h
@@ -137,6 +137,12 @@ void watch_rtc_register_periodic_callback(ext_irq_cb_t callback, uint8_t frequen
*/
void watch_rtc_disable_periodic_callback(uint8_t frequency);
+/** @brief Disables tick callbacks for the given periods (as a bitmask).
+ * @param mask The frequencies of tick callbacks you wish to disable, in Hz.
+ * The 128 Hz callback is 0b1, the 64 Hz callback is 0b10, the 32 Hz callback is 0b100, etc.
+ */
+void watch_rtc_disable_matching_periodic_callbacks(uint8_t mask);
+
/** @brief Disables all periodic callbacks, including the once-per-second tick callback.
*/
void watch_rtc_disable_all_periodic_callbacks(void);
diff --git a/watch-library/simulator/watch/watch_rtc.c b/watch-library/simulator/watch/watch_rtc.c
index 1fe6a78b..ea8659dc 100644
--- a/watch-library/simulator/watch/watch_rtc.c
+++ b/watch-library/simulator/watch/watch_rtc.c
@@ -113,15 +113,19 @@ void watch_rtc_disable_periodic_callback(uint8_t frequency) {
}
}
-void watch_rtc_disable_all_periodic_callbacks(void) {
+void watch_rtc_disable_matching_periodic_callbacks(uint8_t mask) {
for (int i = 0; i < 8; i++) {
- if (tick_callbacks[i] != -1) {
+ if (tick_callbacks[i] != -1 && (mask & (1 << (7 - i))) != 0) {
emscripten_clear_interval(tick_callbacks[i]);
tick_callbacks[i] = -1;
}
}
}
+void watch_rtc_disable_all_periodic_callbacks(void) {
+ watch_rtc_disable_matching_periodic_callbacks(0xFF);
+}
+
static void watch_invoke_alarm_interval_callback(void *userData) {
if (alarm_callback) alarm_callback();
}