Sensor Watch 0.0.2
A board replacement for the classic Casio F-91W wristwatch, powered by a Microchip SAM L22 microcontroller.
|
This section covers functions related to the various sleep modes available to the watch, including Sleep, Deep Sleep, and BACKUP mode. More...
Functions | |
void | watch_register_extwake_callback (uint8_t pin, ext_irq_cb_t callback, bool level) |
Registers a callback on one of the RTC's external wake pins, which can wake the device from Sleep, Deep Sleep and BACKUP modes (but see warning re: BACKUP mode). | |
void | watch_disable_extwake_interrupt (uint8_t pin) |
Unregisters the RTC interrupt on one of the EXTWAKE pins. This will prevent a value change on one of these pins from waking the device. | |
void | watch_store_backup_data (uint32_t data, uint8_t reg) |
Stores data in one of the RTC's backup registers, which retain their data in BACKUP mode. | |
uint32_t | watch_get_backup_data (uint8_t reg) |
Gets 32 bits of data from the RTC's BACKUP register. | |
void | watch_enter_sleep_mode (void) |
enters Sleep Mode by disabling all pins and peripherals except the RTC and the LCD. | |
void | watch_enter_deep_sleep_mode (void) |
enters Deep Sleep Mode by disabling all pins and peripherals except the RTC. | |
void | watch_enter_backup_mode (void) |
Enters the SAM L22's lowest-power mode, BACKUP. | |
This section covers functions related to the various sleep modes available to the watch, including Sleep, Deep Sleep, and BACKUP mode.
These terms changed meaning a bit over the course of development; if you are coming to this documentation after having worked with an earlier version of the library, these definitions should clarify the terminology. Terms in all caps are modes of the SAM L22; terms in Title Case are specific implementations in this library.
app_loop
function returns false, the device will remain in ACTIVE mode and call your app_loop
function again.app_loop
function returns true, the watch enters STANDBY mode until the next tick or other interrupt. This mode uses much less power than ACTIVE mode.watch_enter_sleep_mode
. It consumes an order of magnitude less power than STANDBY mode.watch_enter_deep_sleep_mode
.watch_enter_backup_mode
. void watch_disable_extwake_interrupt | ( | uint8_t | pin | ) |
Unregisters the RTC interrupt on one of the EXTWAKE pins. This will prevent a value change on one of these pins from waking the device.
pin | Either pin BTN_ALARM, A2, or A4. If the pin is BTN_ALARM, this function DOES NOT disable the internal pull down on that pin. |
void watch_enter_backup_mode | ( | void | ) |
Enters the SAM L22's lowest-power mode, BACKUP.
This function does some housekeeping before entering BACKUP mode. It first disables all pins and peripherals except for the RTC, and disables the tick interrupt (since that would wake us up from BACKUP mode). Once again, if you wish to wake from the A2 or the A4 interrupt, you must first configure this by calling watch_register_extwake_callback.
void watch_enter_deep_sleep_mode | ( | void | ) |
enters Deep Sleep Mode by disabling all pins and peripherals except the RTC.
Short of BACKUP mode, this is the lowest power mode you can enter while retaining your application state (and the ability to wake with the alarm button). Just note that the display will be completely off, so you should document to the user of your application that they will need to press the alarm button to wake the device, or use a sensor board with support for an external wake pin.
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 4µA at room temperature.
void watch_enter_sleep_mode | ( | void | ) |
enters Sleep Mode by disabling all pins and peripherals except the RTC and the LCD.
This sleep mode is not the lowest power mode available, but it has the benefit of allowing you to display a message to the user while asleep. You can also set an alarm interrupt to wake at a configfurable interval (every minute, hour or day) to update the display. You can wake from this mode by pressing the ALARM button, if you registered an extwake callback on the ALARM button. Also note that when your app wakes from this sleep mode, your app_setup method will be called again, since this function will have disabled things you set up there.
Note that to wake from either the ALARM button, the A2 interrupt or the A4 interrupt, you must first configure this by calling watch_register_extwake_callback.
Power consumption depends on temperature, but as a rough estimate, this mode will consume:
uint32_t watch_get_backup_data | ( | uint8_t | reg | ) |
Gets 32 bits of data from the RTC's BACKUP register.
reg | A register from 0-7. |
void watch_register_extwake_callback | ( | uint8_t | pin, |
ext_irq_cb_t | callback, | ||
bool | level | ||
) |
Registers a callback on one of the RTC's external wake pins, which can wake the device from Sleep, Deep Sleep and BACKUP modes (but see warning re: BACKUP mode).
pin | Either pin BTN_ALARM, A2, or A4. These are the three external wake pins. If the pin is BTN_ALARM, this function also enables an internal pull down on that pin. |
callback | The callback to be called if this pin triggers outside of BACKUP mode. If this is NULL, no callback will be called even in normal modes, but the interrupt will still be enabled so that it can wake the device. |
level | The level you wish to scan for: true for rising, false for falling. Note that you cannot scan for both rising and falling edges like you can with the external interrupt pins; with the external wake interrupt, you can only get one or the other. |
void watch_store_backup_data | ( | uint32_t | data, |
uint8_t | reg | ||
) |
Stores data in one of the RTC's backup registers, which retain their data in BACKUP mode.
data | An unsigned 32 bit integer with the data you wish to store. |
reg | A register from 0-7. |