![]() |
WE310F5
39.00.000
|
This section describes the M2MB APIs to perform OS timer operations. More...
This section describes the M2MB APIs to perform OS timer operations.
#define M2MB_OS_TMR_AUTO_START 0x08 |
Default, auto activate.
Definition at line 57 of file m2mb_os_tmr.h.
#define M2MB_OS_TMR_INVALID 0 |
Invalid Timer
Definition at line 50 of file m2mb_os_tmr.h.
#define M2MB_OS_TMR_INVALID_ATTR 0 |
Invalid Timer Attribute
Definition at line 51 of file m2mb_os_tmr.h.
#define M2MB_OS_TMR_NO_AUTO_START 0x04 |
No auto activate.
Definition at line 56 of file m2mb_os_tmr.h.
#define M2MB_OS_TMR_OBJ_SIZE_BYTES 128 |
object size is 40 bytes.
Definition at line 59 of file m2mb_os_tmr.h.
#define M2MB_OS_TMR_ONESHOT 0x01 |
Single shot timer
Definition at line 53 of file m2mb_os_tmr.h.
#define M2MB_OS_TMR_PERIODIC_TMR 0x02 |
Periodic timer
Definition at line 54 of file m2mb_os_tmr.h.
typedef UINT32 M2MB_OS_TIME_T |
typedef HANDLE M2MB_OS_TMR_ATTR_HANDLE |
OS timer attribute handle declaration.
Declaration of timer attribute handle.
Definition at line 87 of file m2mb_os_tmr.h.
typedef struct M2MB_OS_TMR_CB_INFO M2MB_OS_TMR_CB_INFO_T |
Timer callback information structure.
This structure contains the event information of the timer module. This is used if the timer is created using event option.
OS timer callback declaration.
Callback declaration of OS timer.
Definition at line 156 of file m2mb_os_tmr.h.
typedef struct M2MB_OS_TMR_EVENT_INFO M2MB_OS_TMR_EVENT_INFO_T |
Timer event information structure.
This structure contains the event information of the timer module. This is used to create the timer with event as the expiry handling option.
typedef HANDLE M2MB_OS_TMR_HANDLE |
OS timer handle declaration.
Declaration of timer handle.
Definition at line 78 of file m2mb_os_tmr.h.
typedef struct M2MB_OS_TMR_NOTIFY_INFO M2MB_OS_TMR_NOTIFY_INFO_T |
Timer notify information structure.
This structure contains the notification information of the timer module in case of expiry.
typedef void(* USR_TMR_CB) (M2MB_OS_TMR_HANDLE handle, void *arg) |
Definition at line 157 of file m2mb_os_tmr.h.
enum M2MB_OS_TIME_UNIT_T |
Timer unit enumeration.
This enumeration specifies list of units of time are supported by Timer module.
Enumerator | |
---|---|
M2MB_OS_TIME_TICK | Return time in ticks. |
M2MB_OS_TIME_MSEC | Return time in milliseconds. |
M2MB_OS_TIME_NONE | Identifier to use if no particular return type is needed |
Definition at line 96 of file m2mb_os_tmr.h.
Timer attribute enumeration.
This enumeration specifies list of attirbute actions that are supported by Timer module.
Definition at line 110 of file m2mb_os_tmr.h.
M2MB_OS_RESULT_E m2mb_os_tmr_change | ( | M2MB_OS_TMR_HANDLE | tmrHandle, |
UINT32 | initial_ticks, | ||
UINT32 | reschedule_ticks | ||
) |
Change application timer.
This service changes the expiration characteristics of the specified application timer. The timer must be deactivated prior to calling this service.
[in] | tmrHandle | Handle of timer |
[in] | initial_ticks | Specifies the initial number of ticks for timer expiration. Legal values range from 1 through 0xFFFFFFFF. |
[in] | reschedule_ticks | Specifies the number of ticks for all timer expirations after the first. A zero for this parameter makes the timer a one-shot timer. Otherwise, for periodic timers, legal values range from 1 through 0xFFFFFFFF. |
Allowed From Initialization, tasks, timers, and ISRs Preemption Possible No
Example For a complete example of use, see m2mb_os_tmr_init section
M2MB_OS_TIME_T m2mb_os_tmr_convert_ticks_to_time | ( | M2MB_OS_TIME_T | ticks, |
M2MB_OS_TIME_UNIT_T | time_unit | ||
) |
Convertion ticks to time.
This service converts given number of system ticks to time.
[in] | ticks | input number of system ticks to convert |
[in] | time_unit | Unit of time |
Example m2mb_os_tmr_convert_ticks_to_time( 100, M2MB_OS_TIME_MSEC );
M2MB_OS_TIME_T m2mb_os_tmr_convert_time_to_ticks | ( | M2MB_OS_TIME_T | time, |
M2MB_OS_TIME_UNIT_T | unit_of_time | ||
) |
Convertion time to ticks.
This service converts given time to system ticks.
[in] | time | input time to convert |
[in] | unit_of_time | Unit of time |
Example m2mb_os_tmr_convert_time_to_ticks( 100, M2MB_OS_TIME_MSEC );
M2MB_OS_RESULT_E m2mb_os_tmr_deinit | ( | M2MB_OS_TMR_HANDLE | tmrHandle | ) |
Timer deinit => deletion.
This service deletes the specified OS timer. The resources will be released and handle set to M2MB_OS_TMR_INVALID It is the application's responsibility to prevent the use of a deleted timer.
[in] | tmrHandle | Handle of the timer |
Example
M2MB_OS_TIME_T m2mb_os_tmr_get_ticks | ( | VOID | ) |
Gets the current timer ticks.
This service gives the RTOS timer ticks. The ticks are accumulated since the RTOS was started.
Example m2mb_os_tmr_get_ticks( );
M2MB_OS_RESULT_E m2mb_os_tmr_getItem | ( | M2MB_OS_TMR_HANDLE | tmrHandle, |
M2MB_OS_TMR_SEL_CMD_E | selCmd, | ||
MEM_W * | pOut, | ||
VOID * | pIn | ||
) |
Get specific properties of the timer.
This service retrieves values for a specified parameter of the specified timer Selecting cmd, a parameter to be retrieved can be set To be used when the timer is already created: Right usage is under application responsibility
[in] | tmrHandle | Handle of timer |
[in] | selCmd | Select parameter to be set (see M2MB_OS_TMR_SEL_CMD_E) |
[out] | pOut | Pointer Output parameter got: its meaning depends on selCmd used. See examples as a general pointer, it is set to MEM_W |
[in] | pIn | Pointer to VOID, general Parameter to be specified, if any, to get right output See examples If the parameter is not needed, use NULL |
Example
M2MB_OS_RESULT_E m2mb_os_tmr_init | ( | M2MB_OS_TMR_HANDLE * | pTmrHandle, |
M2MB_OS_TMR_ATTR_HANDLE * | pTmrAttr | ||
) |
Application timer Creation.
This service creates an application timer with the specified Timer attributes
[out] | pTmrHandle | Pointer to timer handle |
[in] | pTmrAttr | Pointer to timer attribute handle |
Example Complete use of Timer with its callback; callback stop the timer and restarts it with different period. Arg for callback is a context as pointer to timer handle, so in the callback the related timer can be managed
M2MB_OS_RESULT_E m2mb_os_tmr_setAttrItem | ( | M2MB_OS_TMR_ATTR_HANDLE * | pTmrAttrHandle, |
UINT8 | nCmds, | ||
... | |||
) |
Set specific attribute for timer creation.
This service set the attribute (or create it) to be used for timer creation
[in] | pTmrAttrHandle | Pointer to timer attribute |
[in] | nCmds | Number of commands to be issued at once |
[in] | ... | Variable inputs, N cmds (see M2MB_OS_TMR_SEL_CMD_E) followed by N arguments for their respective issued commands. CMDS(...) and CMDS_ARGS(...) macro can be used to better insert cmd and parameters and to better control right insertion |
Example See m2mb_os_tmr_init for complete example of usage
M2MB_OS_RESULT_E m2mb_os_tmr_setItem | ( | M2MB_OS_TMR_HANDLE | tmrHandle, |
M2MB_OS_TMR_SEL_CMD_E | selCmd, | ||
VOID * | pIn | ||
) |
Set specific properties of the timer.
This service sets values for a specified parameter of the specified timer if available Selecting cmd, a parameter to be set can be selected To be used when the timer is already created: its right usage is under application responsibility
[in] | tmrHandle | Handle of timer |
[in] | selCmd | Select parameter to be set (see M2MB_OS_TMR_SEL_CMD_E) |
[in] | pIn | Pointer to value to be set. If a simple value, can be easily casted to (VOID*) For example, int value -3 has to be passed, use (VOID*)-3 NULL if no value is needed |
Example Usage of the function inside expiration callback
M2MB_OS_RESULT_E m2mb_os_tmr_start | ( | M2MB_OS_TMR_HANDLE | tmrHandle | ) |
Start application timer.
This service starts the specified application timer. The expiration routines of timers that expire at the same time are executed in the order they were activated.
[in] | tmrHandle | Handle of timer |
Allowed From Initialization, tasks, timers, and ISRs Preemption Possible No
Example For a complete example of use, see m2mb_os_tmr_init section
M2MB_OS_RESULT_E m2mb_os_tmr_stop | ( | M2MB_OS_TMR_HANDLE | tmrHandle | ) |
Stop an application timer.
This service stops the specified application timer. If the timer is already stopped, this service has no effect
[in] | tmrHandle | Handle of timer |
Example For a complete example of use, see m2mb_os_tmr_init section