This is a library to keep track of sensor and radio timers. Manages alarms for sensors and radio transmissions. This library is used by the sensor_scheduling library to schedule sensor readings and radio transmissions.
More...
#include <zephyr/drivers/counter.h>
#include <zephyr/device.h>
Go to the source code of this file.
|
#define | MINUTES_TO_SECONDS(minutes) (minutes * 60) |
|
|
int | sensor_timer_init (const struct device *dev) |
| Initialize the chosen sensor timer instance and create a top value callback to increment the total overflown seconds. This also starts the timer.
|
|
int | sensor_timer_start (const struct device *dev) |
| Start the chosen sensor timer instance.
|
|
int | sensor_timer_get_current_seconds (const struct device *dev) |
| Get the current seconds the timer was started. This value resets every time the timer is reset or top value is reached.
|
|
int | sensor_timer_get_total_seconds (const struct device *dev) |
| Get the total seconds the timer has been running. This value is reset when the timer is reset.
|
|
int | sensor_timer_stop (const struct device *dev) |
| Stop the chosen sensor timer instance. Timer will remain at the current value.
|
|
int | sensor_timer_reset (const struct device *dev) |
| Reset the chosen sensor timer instance. This also resets the total seconds to 0.
|
|
int | sensor_timer_set_alarm (const struct device *dev, sensor_timer_alarm_cfg_t *sensor_timer_alarm_cfg) |
| Set the alarm for the chosen sensor timer instance, also setting the top value of the timer to the chosen alarm value. When the alarm is triggered, the callback function will be called and the timer will be reset. In alarm callback, the is_alarm_set needs to be set to 0 manually.
|
|
int | sensor_timer_cancel_alarm (const struct device *dev, uint8_t channel) |
| Cancel the alarm for the chosen channel of the sensor timer instance.
|
|
This is a library to keep track of sensor and radio timers. Manages alarms for sensors and radio transmissions. This library is used by the sensor_scheduling library to schedule sensor readings and radio transmissions.
- Author
- Tyler Garcia
- Version
- 0.1
- Date
- 2025-05-09
- Copyright
- Copyright (c) 2025
◆ sensor_timer_cancel_alarm()
int sensor_timer_cancel_alarm |
( |
const struct device * |
dev, |
|
|
uint8_t |
channel |
|
) |
| |
Cancel the alarm for the chosen channel of the sensor timer instance.
- Parameters
-
dev | The timer device to cancel the alarm for. |
channel | The channel to cancel the alarm for. |
- Returns
- 0 on success, negative error code on failure.
◆ sensor_timer_get_current_seconds()
int sensor_timer_get_current_seconds |
( |
const struct device * |
dev | ) |
|
Get the current seconds the timer was started. This value resets every time the timer is reset or top value is reached.
- Parameters
-
dev | The timer device to get the seconds from. |
- Returns
- The seconds elapsed since the timer was started, or negative error code on failure.
◆ sensor_timer_get_total_seconds()
int sensor_timer_get_total_seconds |
( |
const struct device * |
dev | ) |
|
Get the total seconds the timer has been running. This value is reset when the timer is reset.
- Parameters
-
dev | The timer device to get the total seconds from. |
- Returns
- The total seconds the timer has been running, or negative error code on failure.
◆ sensor_timer_init()
int sensor_timer_init |
( |
const struct device * |
dev | ) |
|
Initialize the chosen sensor timer instance and create a top value callback to increment the total overflown seconds. This also starts the timer.
- Parameters
-
dev | The timer device to initialize. |
- Returns
- 0 on success, negative error code on failure.
◆ sensor_timer_reset()
int sensor_timer_reset |
( |
const struct device * |
dev | ) |
|
Reset the chosen sensor timer instance. This also resets the total seconds to 0.
- Parameters
-
dev | The timer device to reset. |
- Returns
- 0 on success, negative error code on failure.
◆ sensor_timer_set_alarm()
Set the alarm for the chosen sensor timer instance, also setting the top value of the timer to the chosen alarm value. When the alarm is triggered, the callback function will be called and the timer will be reset. In alarm callback, the is_alarm_set needs to be set to 0 manually.
- Parameters
-
dev | The timer device to set the alarm for. |
sensor_timer_alarm_cfg | The alarm configuration to set. |
- Returns
- 0 on success, negative error code on failure.
◆ sensor_timer_start()
int sensor_timer_start |
( |
const struct device * |
dev | ) |
|
Start the chosen sensor timer instance.
- Parameters
-
dev | The timer device to start. |
- Returns
- 0 on success, negative error code on failure.
◆ sensor_timer_stop()
int sensor_timer_stop |
( |
const struct device * |
dev | ) |
|
Stop the chosen sensor timer instance. Timer will remain at the current value.
- Parameters
-
dev | The timer device to stop. |
- Returns
- 0 on success, negative error code on failure.