14. Wake-Up Timer Command¶
Sets the wake-up timer prescaler and multiplier, which determine the wake-up period.
Register Fields¶
Bits |
Name |
Meaning |
API |
|---|---|---|---|
12:8 |
|
Timer prescaler R |
|
7:0 |
|
Timer multiplier M |
The command setter directly configures the prescaler and multiplier. The
Helper Functions provide a period-based alternative.
Both setters and the reset function update staged configuration without
communicating with the radio. Use rfm12_apply_to_radio() to write
the staged settings.
The datasheet gives the wake-up period as
T_wake-up = 1.03 * M * 2^R + 0.5 milliseconds.
Timer enable is controlled separately by rfm12_set_wakeup_timer_enable()
in the Power Management Command.
Note
The prescaler field supports values from 0 through 31, but the datasheet
recommends 0 through 29 for future compatibility. The special command
encoding 0xFE00 (R = 30, M = 0) is used for software reset;
use rfm12_software_reset() for that operation.
For continual timer operation, the datasheet requires clearing and then
setting the Power Management Command’s ew bit at the end of each cycle.
Because the enable setter is staged, apply the cleared setting before
staging and applying the enabled setting.
Command Functions¶
rfm12_set_wakeup_timer()¶
-
RFM12_result_t rfm12_set_wakeup_timer(RFM12_t *dev, RFM12_wakeup_prescaler_t prescaler, RFM12_wakeup_multiplier_t multiplier)¶
Stage the raw wake-up timer prescaler and multiplier fields.
This function configures the timer period. It does not enable the timer or communicate with the radio.
- Parameters:
dev – RFM12 radio instance.
prescaler – Timer prescaler R, a five-bit value from 0 through 31; the datasheet recommends 0 through 29.
multiplier – Timer multiplier M, an eight-bit value from 0 through 255.
- Returns:
RFM12_OKon success, or an appropriateRFM12_result_terror.
rfm12_reset_wakeup_timer()¶
-
RFM12_result_t rfm12_reset_wakeup_timer(RFM12_t *dev)¶
Reset the staged Wake-Up Timer Command values to their defaults.
This function does not communicate with the radio. The changed settings are written to the radio by
rfm12_apply_to_radio().- Parameters:
dev – RFM12 radio instance.
- Returns:
RFM12_OKon success, or an appropriateRFM12_result_terror.
Helper Functions¶
The period helper selects the closest representable timer period from a
request in milliseconds. Like the raw command setter, it stages the
prescaler and multiplier for a later rfm12_apply_to_radio().
It performs no immediate SPI transfer.
rfm12_set_wakeup_period_ms()¶
-
RFM12_result_t rfm12_set_wakeup_period_ms(RFM12_t *dev, uint32_t wakeup_ms)¶
Stage the closest representation of the requested wake-up period.
The period is represented by the timer’s prescaler and multiplier, so the resulting period may differ from the requested value. Timer enable remains a separate Power Management Command setting.
- Parameters:
dev – RFM12 radio instance.
wakeup_ms – Requested wake-up period in milliseconds.
- Returns:
RFM12_OKon success, or an appropriateRFM12_result_terror.