#include <stdint.h>
#include <stdbool.h>
#include "sys.h"
#include "stack_common.h"
#include "system_task_manager.h"
Data Structures | |
struct | _SwTimer |
Macros | |
#define | ADD_TIME(a, b) ((a) + (b)) |
Adds two time values. More... | |
#define | MS_TO_US(m) ((m) * (1000)) |
#define | SUB_TIME(a, b) ((a) - (b)) |
Subtracts two time values. More... | |
#define | SW_TIMESTAMP_INVALID (UINT64_MAX) |
#define | SW_TIMESTAMP_MAX (UINT64_MAX) |
#define | SWTIMER_HWTIME_MASK (0xFFFF) |
#define | SWTIMER_INVALID (0xFF) |
#define | SWTIMER_INVALID_TIMEOUT (0xFFFFFFFF) |
#define | SWTIMER_MAX_TIMEOUT (0x7FFFFFFF) |
#define | SWTIMER_MIN_TIMEOUT (0xff) |
#define | SWTIMER_SYSTIME_SHIFTMASK (16) |
#define | US_TO_MS(u) ((u) / (1000)) |
Typedefs | |
typedef enum _SwTimeoutType | SwTimeoutType_t |
typedef struct _SwTimer | SwTimer_t |
typedef void(* | SwTimerCallbackFunc_t )(void *) |
typedef uint64_t | SwTimestamp_t |
Enumerations | |
enum | _SwTimeoutType { SW_TIMEOUT_RELATIVE, SW_TIMEOUT_ABSOLUTE } |
Functions | |
StackRetStatus_t | SwTimerCreate (uint8_t *timerId) |
Returns a timer id to be used before starting a timer. More... | |
uint64_t | SwTimerGetTime (void) |
Get current system time. More... | |
bool | SwTimerIsRunning (uint8_t timerid) |
Checks whether a given timer is running or not. More... | |
uint32_t | SwTimerNextExpiryDuration (void) |
Returns the duration until the next timer expiry. More... | |
void | SwTimerReadTimestamp (uint8_t index, SwTimestamp_t *timestamp) |
Returns the timestamp stored in the given timestamp index. More... | |
uint32_t | SwTimerReadValue (uint8_t timerId) |
Returns the remaining timeout for the given timerId. More... | |
void | SwTimerReset (void) |
Resets the Software Timer module. More... | |
void | SwTimerRunRemainingTime (uint32_t offset) |
Run the running timer for the given offset. More... | |
void | SwTimersExecute (void) |
Handles Queues and Callbacks for Expired Timers. More... | |
StackRetStatus_t | SwTimerStart (uint8_t timerId, uint32_t timerCount, SwTimeoutType_t timeoutType, void *timerCb, void *paramCb) |
Starts a timer. More... | |
StackRetStatus_t | SwTimerStop (uint8_t timerId) |
Stops a running timer. More... | |
SwTimestamp_t | SwTimerTimeDiff (SwTimestamp_t *earlier, SwTimestamp_t *later) |
Difference between the given timestamps. More... | |
StackRetStatus_t | SwTimerTimestampCreate (uint8_t *timestampId) |
Returns a timestamp id to be used before using it. More... | |
void | SwTimerWriteTimestamp (uint8_t index, SwTimestamp_t *timestamp) |
Stores the timestamp in the given timestamp index. More... | |
void | SystemTimerInit (void) |
Initializes the Software Timer module. More... | |
void | SystemTimerSuspend (void) |
Suspends the software timer. More... | |
void | SystemTimerSync (uint64_t timeToSync) |
Resumes the software timer by offseting it with given time. More... | |
SYSTEM_TaskStatus_t | TIMER_TaskHandler (void) |
Handler for the timer tasks. More... | |
#define ADD_TIME | ( | a, | |
b | |||
) | ((a) + (b)) |
Adds two time values.
Referenced by pal_add_time_us().
#define MS_TO_US | ( | m | ) | ((m) * (1000)) |
Referenced by cert_app_timer_callback(), cert_joindata_callback(), demoTimerCb(), DutyCycleCallback(), enddevice_cpc_execute_command(), JoinBackoffCallback(), JoinDutyCycleCallback(), LBTChannelPauseCallback(), lTimerCb(), messageSendProcess(), mote_demo_init(), processTransactionComplete(), setDutyCycleTimer(), setJoinBackOffTimer(), setJoinDutyCycleTimer(), and setLBTTimer().
#define SUB_TIME | ( | a, | |
b | |||
) | ((a) - (b)) |
Subtracts two time values.
Referenced by calculate_time_duration(), and pal_sub_time_us().
#define SW_TIMESTAMP_INVALID (UINT64_MAX) |
#define SW_TIMESTAMP_MAX (UINT64_MAX) |
#define SWTIMER_HWTIME_MASK (0xFFFF) |
#define SWTIMER_INVALID (0xFF) |
Referenced by LongTimerReset(), and LongTimerStart().
#define SWTIMER_INVALID_TIMEOUT (0xFFFFFFFF) |
Referenced by PMM_Sleep(), and validateSleepDuration().
#define SWTIMER_MAX_TIMEOUT (0x7FFFFFFF) |
Referenced by JoinDutyCycleCallback(), and setJoinDutyCycleTimer().
#define SWTIMER_MIN_TIMEOUT (0xff) |
#define SWTIMER_SYSTIME_SHIFTMASK (16) |
#define US_TO_MS | ( | u | ) | ((u) / (1000)) |
typedef enum _SwTimeoutType SwTimeoutType_t |
typedef void(* SwTimerCallbackFunc_t)(void *) |
typedef uint64_t SwTimestamp_t |
enum _SwTimeoutType |
StackRetStatus_t SwTimerCreate | ( | uint8_t * | timerId | ) |
Returns a timer id to be used before starting a timer.
[out] | timerId | Value of the id returned by the function |
Referenced by cert_app_init(), CreateAllRegSoftwareTimers(), LongTimerInit(), main(), and MSG_Init().
uint64_t SwTimerGetTime | ( | void | ) |
Get current system time.
bool SwTimerIsRunning | ( | uint8_t | timerid | ) |
Checks whether a given timer is running or not.
[in] | timerId | Timer ID to be checked for running |
Referenced by enddevice_cpc_execute_command(), LongTimerReset(), LORAREG_GetAttr_JoinDutyCycleRemainingTime(), SearchAvailableChannel1(), SearchAvailableChannel2(), setDutyCycleTimer(), setJoinBackoffCntl(), setJoinDutyCycleTimer(), and setLBTTimer().
uint32_t SwTimerNextExpiryDuration | ( | void | ) |
Returns the duration until the next timer expiry.
Referenced by PMM_Sleep().
void SwTimerReadTimestamp | ( | uint8_t | index, |
SwTimestamp_t * | timestamp | ||
) |
Returns the timestamp stored in the given timestamp index.
[in] | index | Index of the system timestamp |
[out] | *timestamp | Pointer-to-timestamp to be read from the given index |
uint32_t SwTimerReadValue | ( | uint8_t | timerId | ) |
Returns the remaining timeout for the given timerId.
[in] | timerId | Timer ID to get the remaining time |
Referenced by LORAREG_GetAttr_DutyCycleTimer(), LORAREG_GetAttr_JoinDutyCycleRemainingTime(), setDutyCycleTimer(), setJoinDutyCycleTimer(), and setLBTTimer().
void SwTimerReset | ( | void | ) |
Resets the Software Timer module.
void SwTimerRunRemainingTime | ( | uint32_t | offset | ) |
Run the running timer for the given offset.
[in] | offset | New time duration for the running timer |
void SwTimersExecute | ( | void | ) |
Handles Queues and Callbacks for Expired Timers.
StackRetStatus_t SwTimerStart | ( | uint8_t | timerId, |
uint32_t | timerCount, | ||
SwTimeoutType_t | timeoutType, | ||
void * | timerCb, | ||
void * | paramCb | ||
) |
Starts a timer.
This function starts a regular timer and installs the corresponding callback function handle the timeout event.
[in] | timerId | Timer identifier |
[in] | timerCount | Timeout in microseconds |
[in] | timeoutType | SW_TIMEOUT_RELATIVE or SW_TIMEOUT_ABSOLUTE |
[in] | timerCb | Callback handler invoked upon timer expiry |
[in] | paramCb | Argument for the callback handler |
Referenced by cert_app_timer_callback(), cert_joindata_callback(), demoTimerCb(), DutyCycleCallback(), enddevice_cpc_execute_command(), JoinBackoffCallback(), JoinDutyCycleCallback(), LBTChannelPauseCallback(), LongTimerCallback(), LongTimerStart(), lTimerCb(), messageSendProcess(), mote_demo_init(), processTransactionComplete(), setDutyCycleTimer(), setJoinBackOffTimer(), setJoinDutyCycleTimer(), and setLBTTimer().
StackRetStatus_t SwTimerStop | ( | uint8_t | timerId | ) |
Stops a running timer.
It stops a running timer with specified timerId
timer_id | Timer identifier |
Referenced by cert_handle_cert_rx_data(), demo_appdata_callback(), enddevice_cpc_execute_command(), enddevice_cpc_fresh_join(), JoinDutyCycleCallback(), LongTimerReset(), setDutyCycleTimer(), setJoinBackoffCntl(), setJoinBackOffTimer(), setJoinDutyCycleTimer(), setLBTTimer(), StopAllRegSoftwareTimers(), and SysExitFromSleep().
SwTimestamp_t SwTimerTimeDiff | ( | SwTimestamp_t * | earlier, |
SwTimestamp_t * | later | ||
) |
Difference between the given timestamps.
[in] | *earlier | Pointer-to-timestamp of known-to-be-earlier time |
[in] | *later | Pointer-to-timestamp of known-to-be-later time |
StackRetStatus_t SwTimerTimestampCreate | ( | uint8_t * | timestampId | ) |
Returns a timestamp id to be used before using it.
[out] | timestampId | Value of the id returned by the function |
void SwTimerWriteTimestamp | ( | uint8_t | index, |
SwTimestamp_t * | timestamp | ||
) |
Stores the timestamp in the given timestamp index.
[in] | index | Index of the system timestamp |
[in] | *timestamp | Pointer-to-timestamp to be stored in the given index |
void SystemTimerInit | ( | void | ) |
Initializes the Software Timer module.
void SystemTimerSuspend | ( | void | ) |
Suspends the software timer.
Referenced by PMM_Sleep().
void SystemTimerSync | ( | uint64_t | timeToSync | ) |
Resumes the software timer by offseting it with given time.
[in] | timeToSync | Amount of duration to offset from known system time |
Referenced by PMM_Wakeup().
SYSTEM_TaskStatus_t TIMER_TaskHandler | ( | void | ) |
Handler for the timer tasks.