For more details and example usage, see Clock
◆ ClockP_OBJECT_SIZE_MAX
#define ClockP_OBJECT_SIZE_MAX (104u) |
Max size of clock object across no-RTOS and all OS's.
◆ ClockP_FxnCallback
Callback that is called when the clock expires.
- Parameters
-
obj | [in] Clock object associated with this callback |
args | [in] user specific argument pointer that was passed via ClockP_Params |
◆ ClockP_init()
void ClockP_init |
( |
void |
| ) |
|
Initialize the clock module.
The API is called during system init to setup a timer to run at a periodic time internval of 'n' micro seconds.
'n' can be configued by the user via SysConfig, default value for 'n' is typically 1000 us
Using this single timer, the clock API can be used to start multiple 'clock's in units of clock ticks.
◆ ClockP_Params_init()
Set default values to ClockP_Params.
Strongly recommended to be called before seting values in ClockP_Params
- Parameters
-
params | [out] parameter structure to set to default |
◆ ClockP_construct()
◆ ClockP_destruct()
Cleanup, delete, destruct a clock object.
- Parameters
-
◆ ClockP_start()
Start the clock, if not already started.
If clock is already started, then this restarts it with updated timeout and period, if any.
- Parameters
-
◆ ClockP_stop()
Stop the clock, if not already stopped. No effect if clock is already stopped.
- Parameters
-
◆ ClockP_isActive()
Check if clock is active i.e not expired.
For clock setup in periodic mode, clock will always be active after it is started and before it is stopped.
For clock setup in one-shot mode , clock will be active after it is started and will be inactive after clock expires or it is stopped.
- Parameters
-
- Returns
- 0: clock is not-active or expired,
1: clock is active or not expired
◆ ClockP_setTimeout()
Set clock timeout value, takes effect for next clock start.
- Parameters
-
obj | [in] object |
timeout | [in] clock expiry period of first clock execution, in units of clock ticks |
◆ ClockP_getTimeout()
Get current remaining time in units of ticks.
- Parameters
-
- Returns
- clock expiry period of next clock execution, in units of clock ticks
◆ ClockP_getTicks()
uint32_t ClockP_getTicks |
( |
void |
| ) |
|
Get current clock ticks.
- Returns
- number of clock ticks that have elasped since ClockP_init()
◆ ClockP_usecToTicks()
uint32_t ClockP_usecToTicks |
( |
uint64_t |
usecs | ) |
|
Convert usecs to clock ticks.
- Parameters
-
usecs | [in] time in micro seconds |
- Returns
- nearest integer clock ticks
◆ ClockP_ticksToUsec()
uint64_t ClockP_ticksToUsec |
( |
uint32_t |
ticks | ) |
|
Convert clock ticks to usecs.
- Parameters
-
ticks | [in] number of clocks ticks |
- Returns
- nearest integer micro seconds
◆ ClockP_getTimeUsec()
uint64_t ClockP_getTimeUsec |
( |
void |
| ) |
|
Get current time in units of usecs.
- Note
- This API shouldn't be called from an ISR with priority higher than that of Tick Interrupt. This is because Tick interrupt won't be able
to preempt the current ISR and ClockP_getTimeUsec may return incorrect value.
◆ ClockP_usleep()
void ClockP_usleep |
( |
uint32_t |
usec | ) |
|
Sleep for user specified usecs.
- Parameters
-
usec | [in] Time to sleep in units of usecs |
- Note
- Actual sleep will be in the range of
usec - ClockP_ticksToUsec(1)
to usec
. If you need to guarantee atleast minimum sleep of usec
, you need to sleep for usec + ClockP_ticksToUsec(1)
.
◆ ClockP_sleep()
void ClockP_sleep |
( |
uint32_t |
sec | ) |
|
Sleep for user specified seconds.
- Note
- Actual sleep will be in the range of
sec - ClockP_ticksToUsec(1)
to sec
. If you need to guarantee atleast minimum sleep of sec
, you need to sleep for sec + ClockP_ticksToUsec(1)
.
- Parameters
-
sec | [in] Time to sleep in units of secs |