WE310F5  39.00.000
M2MB OS TMR

This section describes the M2MB APIs to perform OS timer operations. More...

#define M2MB_OS_TMR_INVALID   0
 
#define M2MB_OS_TMR_INVALID_ATTR   0
 
#define M2MB_OS_TMR_ONESHOT   0x01
 
#define M2MB_OS_TMR_PERIODIC_TMR   0x02
 
#define M2MB_OS_TMR_NO_AUTO_START   0x04
 
#define M2MB_OS_TMR_AUTO_START   0x08
 
#define M2MB_OS_TMR_OBJ_SIZE_BYTES   128
 
enum  M2MB_OS_TIME_UNIT_T {
  M2MB_OS_TIME_TICK,
  M2MB_OS_TIME_MSEC,
  M2MB_OS_TIME_NONE = 0x7FFFFFF
}
 Timer unit enumeration. More...
 
enum  M2MB_OS_TMR_SEL_CMD_E {
  M2MB_OS_TMR_SEL_CMD_CREATE_ATTR,
  M2MB_OS_TMR_SEL_CMD_DEL_ATTR,
  M2MB_OS_TMR_SEL_CMD_NAME,
  M2MB_OS_TMR_SEL_CMD_USRNAME,
  M2MB_OS_TMR_SEL_CMD_CB_FUNC,
  M2MB_OS_TMR_SEL_CMD_ARG_CB,
  M2MB_OS_TMR_SEL_CMD_TICKS_PERIOD,
  M2MB_OS_TMR_SEL_CMD_TICKS2ELAPSE,
  M2MB_OS_TMR_SEL_CMD_PERIODIC,
  M2MB_OS_TMR_SEL_CMD_DURATION,
  M2MB_OS_TMR_SEL_CMD_RELOAD,
  M2MB_OS_TMR_SEL_CMD_AUTOSTART,
  M2MB_OS_TMR_SEL_CMD_STATE,
  M2MB_OS_TMR_SEL_CMD_OPTION,
  M2MB_OS_TMR_SEL_CMD_EVENT_HANDLE,
  M2MB_OS_TMR_SEL_CMD_EVENT_MASK,
  M2MB_OS_TMR_SEL_CMD_END
}
 Timer attribute enumeration. More...
 
typedef UINT32 M2MB_OS_TIME_T
 OS Time type declaration. More...
 
typedef HANDLE M2MB_OS_TMR_HANDLE
 OS timer handle declaration. More...
 
typedef HANDLE M2MB_OS_TMR_ATTR_HANDLE
 OS timer attribute handle declaration. More...
 
typedef struct M2MB_OS_TMR_EVENT_INFO M2MB_OS_TMR_EVENT_INFO_T
 Timer event information structure. More...
 
typedef VOID(* M2MB_OS_TMR_CB_T) (VOID *)
 OS timer callback declaration. More...
 
typedef void(* USR_TMR_CB) (M2MB_OS_TMR_HANDLE handle, void *arg)
 
typedef struct M2MB_OS_TMR_CB_INFO M2MB_OS_TMR_CB_INFO_T
 Timer callback information structure. More...
 
typedef struct M2MB_OS_TMR_NOTIFY_INFO M2MB_OS_TMR_NOTIFY_INFO_T
 Timer notify information structure. More...
 
M2MB_OS_RESULT_E m2mb_os_tmr_init (M2MB_OS_TMR_HANDLE *pTmrHandle, M2MB_OS_TMR_ATTR_HANDLE *pTmrAttr)
 Application timer Creation. More...
 
M2MB_OS_RESULT_E m2mb_os_tmr_deinit (M2MB_OS_TMR_HANDLE tmrHandle)
 Timer deinit => deletion. More...
 
M2MB_OS_RESULT_E m2mb_os_tmr_start (M2MB_OS_TMR_HANDLE tmrHandle)
 Start application timer. More...
 
M2MB_OS_RESULT_E m2mb_os_tmr_change (M2MB_OS_TMR_HANDLE tmrHandle, UINT32 initial_ticks, UINT32 reschedule_ticks)
 Change application timer. More...
 
M2MB_OS_RESULT_E m2mb_os_tmr_stop (M2MB_OS_TMR_HANDLE tmrHandle)
 Stop an application timer. More...
 
M2MB_OS_RESULT_E m2mb_os_tmr_setAttrItem (M2MB_OS_TMR_ATTR_HANDLE *pTmrAttrHandle, UINT8 nCmds,...)
 Set specific attribute for timer creation. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
M2MB_OS_TIME_T m2mb_os_tmr_get_ticks (VOID)
 Gets the current timer ticks. More...
 

Detailed Description

This section describes the M2MB APIs to perform OS timer operations.

Macro Definition Documentation

◆ M2MB_OS_TMR_AUTO_START

#define M2MB_OS_TMR_AUTO_START   0x08

Default, auto activate.

Definition at line 57 of file m2mb_os_tmr.h.

◆ M2MB_OS_TMR_INVALID

#define M2MB_OS_TMR_INVALID   0

Invalid Timer

Definition at line 50 of file m2mb_os_tmr.h.

◆ M2MB_OS_TMR_INVALID_ATTR

#define M2MB_OS_TMR_INVALID_ATTR   0

Invalid Timer Attribute

Definition at line 51 of file m2mb_os_tmr.h.

◆ M2MB_OS_TMR_NO_AUTO_START

#define M2MB_OS_TMR_NO_AUTO_START   0x04

No auto activate.

Definition at line 56 of file m2mb_os_tmr.h.

◆ M2MB_OS_TMR_OBJ_SIZE_BYTES

#define M2MB_OS_TMR_OBJ_SIZE_BYTES   128

object size is 40 bytes.

Definition at line 59 of file m2mb_os_tmr.h.

◆ M2MB_OS_TMR_ONESHOT

#define M2MB_OS_TMR_ONESHOT   0x01

Single shot timer

Definition at line 53 of file m2mb_os_tmr.h.

◆ M2MB_OS_TMR_PERIODIC_TMR

#define M2MB_OS_TMR_PERIODIC_TMR   0x02

Periodic timer

Definition at line 54 of file m2mb_os_tmr.h.

Typedef Documentation

◆ M2MB_OS_TIME_T

OS Time type declaration.

Declaration of OS time.

Definition at line 69 of file m2mb_os_tmr.h.

◆ 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.

◆ 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.

◆ M2MB_OS_TMR_CB_T

typedef VOID(* M2MB_OS_TMR_CB_T) (VOID *)

OS timer callback declaration.

Callback declaration of OS timer.

Definition at line 156 of file m2mb_os_tmr.h.

◆ 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.

◆ M2MB_OS_TMR_HANDLE

OS timer handle declaration.

Declaration of timer handle.

Definition at line 78 of file m2mb_os_tmr.h.

◆ M2MB_OS_TMR_NOTIFY_INFO_T

Timer notify information structure.

This structure contains the notification information of the timer module in case of expiry.

◆ USR_TMR_CB

typedef void(* USR_TMR_CB) (M2MB_OS_TMR_HANDLE handle, void *arg)

Definition at line 157 of file m2mb_os_tmr.h.

Enumeration Type Documentation

◆ 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.

◆ M2MB_OS_TMR_SEL_CMD_E

Timer attribute enumeration.

This enumeration specifies list of attirbute actions that are supported by Timer module.

Enumerator
M2MB_OS_TMR_SEL_CMD_CREATE_ATTR 

To create attribute

M2MB_OS_TMR_SEL_CMD_DEL_ATTR 

To delete attribute

M2MB_OS_TMR_SEL_CMD_NAME 

Command name

M2MB_OS_TMR_SEL_CMD_USRNAME 

User name for timer

M2MB_OS_TMR_SEL_CMD_CB_FUNC 

the callback for timer elapsed

M2MB_OS_TMR_SEL_CMD_ARG_CB 

argument to be passed to callback

M2MB_OS_TMR_SEL_CMD_TICKS_PERIOD 

argument to be passed to callback

M2MB_OS_TMR_SEL_CMD_TICKS2ELAPSE 

period of elapsing in ticks

M2MB_OS_TMR_SEL_CMD_PERIODIC 

define if it is periodic or not

M2MB_OS_TMR_SEL_CMD_DURATION 

not need to call m2mb_os_tmr_start

M2MB_OS_TMR_SEL_CMD_RELOAD 

period of elapsing in ticks

M2MB_OS_TMR_SEL_CMD_AUTOSTART 

auto start

M2MB_OS_TMR_SEL_CMD_STATE 

command state

M2MB_OS_TMR_SEL_CMD_OPTION 

command option

M2MB_OS_TMR_SEL_CMD_EVENT_HANDLE 

Event handle

M2MB_OS_TMR_SEL_CMD_EVENT_MASK 

Event mask

M2MB_OS_TMR_SEL_CMD_END 

Definition at line 110 of file m2mb_os_tmr.h.

Function Documentation

◆ m2mb_os_tmr_change()

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.

Parameters
[in]tmrHandleHandle of timer
[in]initial_ticksSpecifies the initial number of ticks for timer expiration. Legal values range from 1 through 0xFFFFFFFF.
[in]reschedule_ticksSpecifies 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.
Returns
M2MB_OS_SUCCESS in case of success
M2MB_OS_TIMER_ERROR Invalid timer handle. M2MB_OS_ACTIVATE_ERROR Timer was already started M2MB_OS_CALLER_ERROR Invalid caller of this service.
Note

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_tmr_convert_ticks_to_time()

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.

Parameters
[in]ticksinput number of system ticks to convert
[in]time_unitUnit of time
Returns
Time in the requested unit if convertion is successful. 0xFFFFFFFF in case of failure.
Note

Example m2mb_os_tmr_convert_ticks_to_time( 100, M2MB_OS_TIME_MSEC );

int main()
{
return M2MB_OK;
else
return M2MB_ERROR;
}

◆ m2mb_os_tmr_convert_time_to_ticks()

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.

Parameters
[in]timeinput time to convert
[in]unit_of_timeUnit of time
Returns
System tick count if convertion is successful. 0xFFFFFFFF in case of failure.
Note

Example m2mb_os_tmr_convert_time_to_ticks( 100, M2MB_OS_TIME_MSEC );

int main()
{
return M2MB_OK;
else
return M2MB_ERROR;
}

◆ m2mb_os_tmr_deinit()

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.

Parameters
[in]tmrHandleHandle of the timer
Returns
M2MB_OS_SUCCESS in case of success (others in case of error : see m2mb_os_types.h)
M2MB_OS_TIMER_ERROR Invalid timer handle M2MB_OS_INVALID_ARG Invalid arguments M2MB_OS_CALLER_ERROR Invalid caller of this service.
Note
It is the application's responsibility to prevent the use of a deleted timer. Allowed From tasks Preemption Possible No

Example

◆ m2mb_os_tmr_get_ticks()

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.

Returns
Ticks accumulated since the RTOS was started on success. 0xFFFFFFFF in case of failure.
Note

Example m2mb_os_tmr_get_ticks( );

int main()
{
if( m2mb_os_tmr_get_ticks( ) != 0xFFFFFFFF )
return M2MB_OK;
else
return M2MB_ERROR;
}

◆ m2mb_os_tmr_getItem()

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

Parameters
[in]tmrHandleHandle of timer
[in]selCmdSelect parameter to be set (see M2MB_OS_TMR_SEL_CMD_E)
[out]pOutPointer Output parameter got: its meaning depends on selCmd used. See examples as a general pointer, it is set to MEM_W
[in]pInPointer to VOID, general Parameter to be specified, if any, to get right output See examples If the parameter is not needed, use NULL
Returns
M2MB_OS_SUCCESS in case of success (others in case of error : see m2mb_os_types.h)
M2MB_OS_TIMER_ERROR Invalid timer handle M2MB_OS_INVALID_ARG Invalid arguments
Note
Not all the M2MB_OS_TMR_SEL_CMD_E are always available. Of course M2MB_OS_TMR_SEL_CMD_CREATE_ATTR is not right for this function M2MB_OS_TMR_SEL_CMD_NAME, M2MB_OS_TMR_SEL_CMD_USRNAME, M2MB_OS_TMR_SEL_CMD_CB_FUNC, M2MB_OS_TMR_SEL_CMD_ARG_CB, M2MB_OS_TMR_SEL_CMD_TICK_DURATION, M2MB_OS_TMR_SEL_CMD_PERIODIC, M2MB_OS_TMR_SEL_CMD_STATE are ok Allowed From Initialization, tasks, timers, and ISRs

Example

CHAR MyTmrName[10];
CHAR *pTmrName;
MEM_W currTickDuration;
exit(error_creating attribute timer);
//set th inherit
m2mb_os_tmr_setAttrItem( &tmrAttrHandle, 1 M2MB_OS_TMR_SEL_CMD_TICK_DURATION, 100 );
// ...
//create
m2mb_os_tmr_init( &tmrHandle, &tmrAttrHandle );
//
m2mb_os_tmr_getItem( tmrHandle, M2MB_OS_TMR_SEL_CMD_TICK_DURATION, &currTickDuration, NULL );
//copy only the first 10 chars to MyTaskName array of chars
// or simply get the pointer of name, with NULL

◆ m2mb_os_tmr_init()

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

Parameters
[out]pTmrHandlePointer to timer handle
[in]pTmrAttrPointer to timer attribute handle
Returns
M2MB_OS_SUCCESS in case of success (others in case of error : see m2mb_os_types.h )
M2MB_OS_TICK_ERROR Invalid value (a zero) supplied for a period in ticks in attribute M2MB_OS_TIMER_ERROR Invalid application timer handle: either the handle is invalid or the timer is already created M2MB_OS_INVALID_ARG invalid arguments M2MB_OS_CALLER_ERROR Invalid caller of this service.
Note
After successful timer creation, timer attribute will be deleted, their resources free and pointed by pTmrAttrHandle set to M2MB_OS_TMR_INVALID_ATTR In case of an error return, it is application's responsibility to release resources of attributes by calling m2mb_os_tmr_setAttrItem( &tmrAttrHandle, 1, M2MB_OS_TMR_SEL_CMD_DEL_ATTR, NULL ); Allowed From Initialization and tasks Preemption Possible No

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

VOID timerCb(VOID *ctx)
{
MEM_W currDuration;
//here in this case ctx is address of M2MB_OS_TMR_HANDLE tmrHandle, so it is a (M2MB_OS_TMR_HANDLE *)
handle = *((M2MB_OS_TMR_HANDLE *)ctx);
m2mb_os_tmr_getItem( handle, M2MB_OS_TMR_SEL_CMD_TICK_DURATION, &currDuration, NULL );
//changing duration
currDuration += 100;
if ( currDuration > 600 )
currDuration = 10;
//update duration: here use m2mb_os_tmr_setItem since tmr already created
m2mb_os_tmr_setItem( handle, M2MB_OS_TMR_SEL_CMD_TICK_DURATION, (VOID*)currDuration );
//restart timer with new value of ticks: if new value is not provided, it will
// restart with previous ones
}
exit(error_creating attribute timer);
osRes = m2mb_os_tmr_setAttrItem( &tmrAttrHandle,
//set arg as handle of timer for example
),
);
if ( osRes != M2MB_OS_SUCCESS )
exit( error setting or creating tmrAttrHandle)
if ( m2mb_os_tmr_init( &tmrHandle, &tmrAttrHandle ) != M2MB_OS_SUCCESS )
{
//in case of error remember to manually remove attribute and release resources
}
m2mb_os_tmr_start(tmrHandle);

◆ m2mb_os_tmr_setAttrItem()

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

Parameters
[in]pTmrAttrHandlePointer to timer attribute
[in]nCmdsNumber 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
Returns
M2MB_OS_SUCCESS in case of success (others in case of error : see m2mb_os_types.h)
M2MB_OS_SUCCESS Successful timer operation. M2MB_OS_TIMER_ERROR Invalid timer handle M2MB_OS_INVALID_ARG Invalid pTmrAttr or pIn for set operation
Note
The attribute set are useful for timer creation. Once created, use instead m2mb_os_tmr_setItem() to set only available timer properties It is under application responsibility the right use of m2mb_os_sem_setAttrItem. For instance, multi creation of attrHandle without free of previous resources ( M2MB_OS_TMR_SEL_CMD_CREATE_ATTR without M2MB_OS_TMR_SEL_CMD_DEL_ATTR in case no m2mb_os_tmr_init is used in the between ) will waste memory. Allowed From Initialization, tasks, timers, and ISRs

Example See m2mb_os_tmr_init for complete example of usage

// this is the callback for timer
VOID tmr_cb(VOID *argv)
{
M2MB_OS_TASK handle = (M2MB_OS_TASK)(argv);
m2mb_os_tmr_stop(tmrHandle);
}
VOID entry( VOID *arg )
{
// for example it is an entry of already created task
M2MB_OS_TASK handle = m2mb_os_taskGetId();
handle = m2mb_os_taskGetId();
exit(error_creating attribute timer);
// insert 1 cmd for call
osRes = m2mb_os_tmr_setAttrItem( &tmrAttrHandle, 1, M2MB_OS_TMR_SEL_CMD_NAME, "mytmr");
osRes = m2mb_os_tmr_setAttrItem( &tmrAttrHandle, 1, M2MB_OS_TMR_SEL_CMD_USRNAME, "myUsrtmr");
osRes = m2mb_os_tmr_setAttrItem( &tmrAttrHandle, 1, M2MB_OS_TMR_SEL_CMD_CB_FUNC, &tmr_cb );
osRes = m2mb_os_tmr_setAttrItem( &tmrAttrHandle, 1, M2MB_OS_TMR_SEL_CMD_ARG_CB, handle );
// or use for example CMDS_ARGS(...) macro
// osRes = m2mb_os_tmr_setAttrItem( &tmrAttrHandle,
// CMDS_ARGS
// (
// M2MB_OS_TMR_SEL_CMD_CREATE_ATTR, NULL,
// M2MB_OS_TMR_SEL_CMD_NAME, "mytmr",
// M2MB_OS_TMR_SEL_CMD_USRNAME, "myUsrtmr",
// M2MB_OS_TMR_SEL_CMD_CB_FUNC, &tmr_cb,
// //use handle of the tsak as arg for callback
// M2MB_OS_TMR_SEL_CMD_ARG_CB, handle,
// M2MB_OS_TMR_SEL_CMD_TICKS_PERIOD, M2MB_OS_MS2TICKS(4000),
// )
// );
if( osRes != M2MB_OS_SUCCESS )
exit(error creating or setting attribute timer);
if ( m2mb_os_tmr_init( &tmrHandle, &tmrAttrHandle ) != M2MB_OS_SUCCESS )
{
//in case of error remember to manually remove attribute and release resources
}
while(1)
{
osRes = m2mb_os_tmr_start( tmrHandle );
//suspend the task till timer expire
printf( "\r\n task [ 0x%x ] suspended ", handle );
printf( "\r\n task [ 0x%x ] resumed by timer ", handle );
}
}

◆ m2mb_os_tmr_setItem()

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

Parameters
[in]tmrHandleHandle of timer
[in]selCmdSelect parameter to be set (see M2MB_OS_TMR_SEL_CMD_E)
[in]pInPointer 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
Returns
M2MB_OS_SUCCESS in case of success (others in case of error : see m2mb_os_types.h)
M2MB_OS_TIMER_ERROR Invalid timer handle M2MB_OS_INVALID_ARG Invalid arguments
Note
Not all the M2MB_OS_TMR_SEL_CMD_E are always available. Of course M2MB_OS_TMR_SEL_CMD_CREATE_ATTR is not right for this function M2MB_OS_TMR_SEL_CMD_NAME, M2MB_OS_TMR_SEL_CMD_USRNAME, M2MB_OS_TMR_SEL_CMD_CB_FUNC M2MB_OS_TMR_SEL_CMD_ARG_CB, M2MB_OS_TMR_SEL_CMD_TICK_DURATION, M2MB_OS_TMR_SEL_CMD_PERIODIC are ok It is the application’s responsibility to set the values in right context, for example the change of callback or periodicity should better be done inside expiration callback, or by stopping involved timer first

Example Usage of the function inside expiration callback

VOID timerCb(VOID *ctx)
{
MEM_W currDuration;
handle = *((M2MB_OS_TMR_HANDLE*)ctx);
m2mb_os_tmr_getItem( handle, M2MB_OS_TMR_SEL_CMD_TICK_DURATION, &currDuration, NULL );
currDuration += 100;
if ( currDuration > 600 )
currDuration = 10;
//update duration through m2mb_os_tmr_setItem use
m2mb_os_tmr_setItem( handle, M2MB_OS_TMR_SEL_CMD_TICK_DURATION, (VOID*)currDuration );
//restart timer with new value of ticks: if new value is not provided, it will
// restart with previous ones
}

◆ m2mb_os_tmr_start()

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.

Parameters
[in]tmrHandleHandle of timer
Returns
M2MB_OS_SUCCESS in case of success
M2MB_OS_TIMER_ERROR Invalid timer handle. M2MB_OS_ACTIVATE_ERROR Timer was already started M2MB_OS_CALLER_ERROR Invalid caller of this service.
Note

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_tmr_stop()

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

Parameters
[in]tmrHandleHandle of timer
Returns
M2MB_OS_SUCCESS in case of success (others in case of error : see m2mb_os_types.h)
M2MB_OS_TIMER_ERROR Invalid timer handle
Note
Allowed From Initialization, tasks, timers, and ISRs Preemption Possible No

Example For a complete example of use, see m2mb_os_tmr_init section