SYSTIMER
|
SYSTIMER_STATUS_t | SYSTIMER_Init (SYSTIMER_t *handle) |
Initializes SYSTIMER APP. More... | |
uint32_t | SYSTIMER_CreateTimer (uint32_t period, SYSTIMER_MODE_t mode, SYSTIMER_CALLBACK_t callback, void *args) |
Creates a new software timer. This function cannot be called from an ISR. Use SYSTIMER_CreateTimerFromISR() instead. More... | |
uint32_t | SYSTIMER_CreateTimerFromISR (uint32_t period, SYSTIMER_MODE_t mode, SYSTIMER_CALLBACK_t callback, void *args) |
A version of SYSTIMER_CreateTimer() that can be called from an ISR. More... | |
SYSTIMER_STATUS_t | SYSTIMER_StartTimer (uint32_t id) |
Starts the software timer. This function cannot be called from an ISR. Use SYSTIMER_StartTimerFromISR() instead. More... | |
SYSTIMER_STATUS_t | SYSTIMER_StartTimerFromISR (uint32_t id) |
A version of SYSTIMER_StartTimer() that can be called from an ISR. More... | |
SYSTIMER_STATUS_t | SYSTIMER_StopTimer (uint32_t id) |
Stops the software timer. This function cannot be called from an ISR. Use SYSTIMER_StopTimerFromISR() instead. More... | |
SYSTIMER_STATUS_t | SYSTIMER_StopTimerFromISR (uint32_t id) |
A version of SYSTIMER_StopTimer() that can be called from an ISR. More... | |
SYSTIMER_STATUS_t | SYSTIMER_RestartTimer (uint32_t id, uint32_t microsec) |
Function to modify the time interval and restart the timer for the new time interval. This function cannot be called from an ISR. Use SYSTIMER_RestartTimerFromISR() instead. More... | |
SYSTIMER_STATUS_t | SYSTIMER_RestartTimerFromISR (uint32_t id, uint32_t microsec) |
A version of SYSTIMER_RestartTimer() that can be called from an ISR. More... | |
SYSTIMER_STATUS_t | SYSTIMER_DeleteTimer (uint32_t id) |
Deletes the software timer from the timer list. This function cannot be called from an ISR. Use SYSTIMER_DeleteTimerFromISR() instead. More... | |
SYSTIMER_STATUS_t | SYSTIMER_DeleteTimerFromISR (uint32_t id) |
A version of SYSTIMER_DeleteTimer() that can be called from an ISR. More... | |
uint32_t | SYSTIMER_GetTime (void) |
Gives the current hardware SysTick time in microsecond since start of hardware SysTick timer. More... | |
uint32_t | SYSTIMER_GetTickCount (void) |
Gives the SysTick count. More... | |
SYSTIMER_STATE_t | SYSTIMER_GetTimerState (uint32_t id) |
Gives the current state of software timer. More... | |
DAVE_APP_VERSION_t | SYSTIMER_GetAppVersion (void) |
Get SYSTIMER APP version. More... | |
void | SYSTIMER_Start (void) |
Starts the SysTick timer. More... | |
void | SYSTIMER_Stop (void) |
Stops the SysTick timer. More... | |
Detailed Description
Methods
Function Documentation
uint32_t SYSTIMER_CreateTimer | ( | uint32_t | period, |
SYSTIMER_MODE_t | mode, | ||
SYSTIMER_CALLBACK_t | callback, | ||
void * | args | ||
) |
Creates a new software timer. This function cannot be called from an ISR. Use SYSTIMER_CreateTimerFromISR() instead.
- Parameters
-
period timer period value in microseconds. Range: (SYSTIMER_TICK_PERIOD_US) to pow(2,32). mode Mode of timer(ONE_SHOT/PERIODIC). Refer SYSTIMER_MODE_t for details. callback Call back function of the timer(No Macros are allowed). args Call back function parameter.
- Returns
- uint32_t returns timer ID if timer created successfully otherwise returns 0 if timer creation failed. Range: 0 to 16, 0: Invalid timer ID, 1-16: Valid timer ID.
- Description:
- API for creating a new software timer instance. This also add created software timer to timer list.
Note :
1. This APP uses SysTick exception for controlling the timer list. Call back function registered through this function will be called in SysTick exception when the software timer is expired i.e the software timers callback is executed in the interrupt context.
- Due to time at which software timer creation asked by user will not be in synchronize with Hardware SysTick timer, the count value used during creation of software timer will not create starting/initial period same as expected value. It is decided to add one extra count(HW_TIMER_ADDITIONAL_CNT) with Software timer. Impact of this additional count(HW_TIMER_ADDITIONAL_CNT) is, first SW timer period(Initial one) is always equal to or more than expected/configured.
- Callbacks are executed in round robin manner if more than one software timers are created with same period value. Last created software is having higher priority and its associated callback is executed first.
- Avoid any call to wait, infinitive while loop, blocking calls or creating software timer in ISR because their behavior could be corrupted when called from an ISR.
- Software timers are based on 24-bit Hardware SysTick counters, so maximum counts can achieve is pow(2,24) *(1/fCPU) * 1E6, where fCPU is in hertz. Software timers are designed for times between microseconds and seconds. For longer times, application code need to ensure to take necessary action.
- Software timer period value must be equal to SysTick Interval or integer multiple of a number with SysTick interval (i.e. SysTick Interval * n, where n is integer number, n can be 1,2,3,4... but n should not be fractional or float number). And also software timer period value should not be 0 or less than Hardware SysTick Interval.
- Due to time at which software timer creation asked by user will not be in synchronize with Hardware SysTick timer, the count value used during creation of software timer will not create starting/initial period same as expected value. It is decided to add one extra count(HW_TIMER_ADDITIONAL_CNT) with Software timer. Impact of this additional count(HW_TIMER_ADDITIONAL_CNT) is, first SW timer period(Initial one) is always equal to or more than expected/configured.
- Example Usage:
Definition at line 414 of file SYSTIMER.c.
References g_timer_tbl, SYSTIMER_MODE_ONE_SHOT, SYSTIMER_MODE_PERIODIC, and SYSTIMER_STATE_STOPPED.
Referenced by SYSTIMER_CreateTimerFromISR().
uint32_t SYSTIMER_CreateTimerFromISR | ( | uint32_t | period, |
SYSTIMER_MODE_t | mode, | ||
SYSTIMER_CALLBACK_t | callback, | ||
void * | args | ||
) |
A version of SYSTIMER_CreateTimer() that can be called from an ISR.
- Parameters
-
period timer period value in microseconds. Range: (SYSTIMER_TICK_PERIOD_US) to pow(2,32). mode Mode of timer(ONE_SHOT/PERIODIC). Refer SYSTIMER_MODE_t for details. callback Call back function of the timer(No Macros are allowed). args Call back function parameter.
- Returns
- uint32_t returns timer ID if timer created successfully otherwise returns 0 if timer creation failed. Range: 0 to 16, 0: Invalid timer ID, 1-16: Valid timer ID.
Definition at line 466 of file SYSTIMER.c.
References SYSTIMER_CreateTimer().
SYSTIMER_STATUS_t SYSTIMER_DeleteTimer | ( | uint32_t | id | ) |
Deletes the software timer from the timer list. This function cannot be called from an ISR. Use SYSTIMER_DeleteTimerFromISR() instead.
- Parameters
-
id timer ID obtained from SYSTIMER_CreateTimer. Range : 1 to 16
- Returns
- SYSTIMER_STATUS_t APP status. Refer SYSTIMER_STATUS_t for details.
- Description:
- API for deleting the created software timer instance from timer list.
Note : This API must be called after software timer is created using SYSTIMER_CreateTimer API with generated ID and enable XMC_ASSERT for better understanding of API behavioral in run time.
- Example Usage:
Definition at line 630 of file SYSTIMER.c.
References g_timer_tbl, SYSTIMER_STATE_NOT_INITIALIZED, SYSTIMER_STATUS_FAILURE, SYSTIMER_STATUS_SUCCESS, and SYSTIMER_StopTimer().
Referenced by SYSTIMER_DeleteTimerFromISR().
SYSTIMER_STATUS_t SYSTIMER_DeleteTimerFromISR | ( | uint32_t | id | ) |
A version of SYSTIMER_DeleteTimer() that can be called from an ISR.
- Parameters
-
id timer ID obtained from SYSTIMER_CreateTimer. Range : 1 to 16
- Returns
- SYSTIMER_STATUS_t APP status. Refer SYSTIMER_STATUS_t for details.
Definition at line 659 of file SYSTIMER.c.
References SYSTIMER_DeleteTimer().
DAVE_APP_VERSION_t SYSTIMER_GetAppVersion | ( | void | ) |
Get SYSTIMER APP version.
- Returns
- DAVE_APP_VERSION_t APP version information (major, minor and patch number).
- Description:
- The function can be used to check application software compatibility with a specific version of the APP.
Definition at line 356 of file SYSTIMER.c.
uint32_t SYSTIMER_GetTickCount | ( | void | ) |
Gives the SysTick count.
- Returns
- uint32_t returns SysTick count. Range: 0 to pow(2,32).
- Description:
- API to get hardware SysTick counts since start of hardware SysTick timer.
- Example Usage:
Definition at line 684 of file SYSTIMER.c.
uint32_t SYSTIMER_GetTime | ( | void | ) |
Gives the current hardware SysTick time in microsecond since start of hardware SysTick timer.
- Returns
- uint32_t returns current SysTick time in microsecond. Range: (SYSTIMER_TICK_PERIOD_US) to pow(2,32).
- Description:
- API to get current hardware SysTick time in microsecond since start of hardware SysTick timer.
- Example Usage:
Definition at line 676 of file SYSTIMER.c.
SYSTIMER_STATE_t SYSTIMER_GetTimerState | ( | uint32_t | id | ) |
Gives the current state of software timer.
- Parameters
-
id timer ID obtained from SYSTIMER_CreateTimer. Range : 1 to 16
- Returns
- SYSTIMER_STATE_t Software timer state. Refer SYSTIMER_STATE_t for details.
- Description:
- API to get current software timer state.
- Example Usage:
Definition at line 692 of file SYSTIMER.c.
References g_timer_tbl.
SYSTIMER_STATUS_t SYSTIMER_Init | ( | SYSTIMER_t * | handle | ) |
Initializes SYSTIMER APP.
- Parameters
-
handle Pointer pointing to SYSTIMER APP data structure. Refer SYSTIMER_t for details.
- Returns
- SYSTIMER_STATUS_t APP status. Refer SYSTIMER_STATUS_t for details.
- Description:
- Initializes the SysTick counter as per the SysTick interval specified by the user and start the SysTick counter. It also initializes global variables.
- Example Usage:
- #include <DAVE.h> //Declarations from DAVE Code Generation (includes SFR declaration)int main(void){SYSTIMER_STATUS_t init_status;if (init_status == SYSTIMER_STATUS_SUCCESS){// Add application code herewhile(1){}}else{XMC_DEBUG("main: Application initialization failed");while(1){}}return (1);}
Definition at line 370 of file SYSTIMER.c.
References SYSTIMER::init_status, SYSTIMER_STATUS_FAILURE, and SYSTIMER_STATUS_SUCCESS.
SYSTIMER_STATUS_t SYSTIMER_RestartTimer | ( | uint32_t | id, |
uint32_t | microsec | ||
) |
Function to modify the time interval and restart the timer for the new time interval. This function cannot be called from an ISR. Use SYSTIMER_RestartTimerFromISR() instead.
- Parameters
-
id ID of already created system timer. Range : 1 to 16 microsec new time interval. Range: (SYSTIMER_TICK_PERIOD_US) to pow(2,32).
- Returns
- SYSTIMER_STATUS_t APP status. Refer SYSTIMER_STATUS_t for details.
- Description:
- API for restarting the created software timer instance with new time interval.
Note : This API must be called after software timer is created using SYSTIMER_CreateTimer API with generated ID and enable XMC_ASSERT for better understanding of API behavioral in run time.
- Example Usage:
- Demonstrate SYSTIMER_RestartTimer API
Definition at line 575 of file SYSTIMER.c.
References g_timer_tbl, SYSTIMER_StartTimer(), SYSTIMER_STATE_NOT_INITIALIZED, SYSTIMER_STATE_STOPPED, SYSTIMER_STATUS_FAILURE, SYSTIMER_STATUS_SUCCESS, and SYSTIMER_StopTimer().
SYSTIMER_STATUS_t SYSTIMER_RestartTimerFromISR | ( | uint32_t | id, |
uint32_t | microsec | ||
) |
A version of SYSTIMER_RestartTimer() that can be called from an ISR.
- Parameters
-
id ID of already created system timer. Range : 1 to 16 microsec new time interval. Range: (SYSTIMER_TICK_PERIOD_US) to pow(2,32).
- Returns
- SYSTIMER_STATUS_t APP status. Refer SYSTIMER_STATUS_t for details.
Definition at line 613 of file SYSTIMER.c.
References SYSTIMER_RestartTimerFromISR().
Referenced by SYSTIMER_RestartTimerFromISR().
void SYSTIMER_Start | ( | void | ) |
Starts the SysTick timer.
- Parameters
-
None.
- Description:
- Starts the SysTick timer.
Definition at line 162 of file SYSTIMER.c.
SYSTIMER_STATUS_t SYSTIMER_StartTimer | ( | uint32_t | id | ) |
Starts the software timer. This function cannot be called from an ISR. Use SYSTIMER_StartTimerFromISR() instead.
- Parameters
-
id timer ID obtained from SYSTIMER_CreateTimer. Range : 1 to 16
- Returns
- SYSTIMER_STATUS_t APP status. Refer SYSTIMER_STATUS_t for details.
- Description:
- API for starting a software timer instance.
Note : This API must be called after software timer is created using SYSTIMER_CreateTimer API with generated ID and enable XMC_ASSERT for better understanding of API behavioral in run time.
- Example Usage:
Definition at line 488 of file SYSTIMER.c.
References g_timer_tbl, SYSTIMER_STATE_RUNNING, SYSTIMER_STATE_STOPPED, SYSTIMER_STATUS_FAILURE, and SYSTIMER_STATUS_SUCCESS.
Referenced by SYSTIMER_RestartTimer(), and SYSTIMER_StartTimerFromISR().
SYSTIMER_STATUS_t SYSTIMER_StartTimerFromISR | ( | uint32_t | id | ) |
A version of SYSTIMER_StartTimer() that can be called from an ISR.
- Parameters
-
id timer ID obtained from SYSTIMER_CreateTimer. Range : 1 to 16
- Returns
- SYSTIMER_STATUS_t APP status. Refer SYSTIMER_STATUS_t for details.
Definition at line 513 of file SYSTIMER.c.
References SYSTIMER_StartTimer().
void SYSTIMER_Stop | ( | void | ) |
Stops the SysTick timer.
- Parameters
-
None.
- Description:
- Stops the SysTick timer therefore no software timer will time out.
Definition at line 167 of file SYSTIMER.c.
SYSTIMER_STATUS_t SYSTIMER_StopTimer | ( | uint32_t | id | ) |
Stops the software timer. This function cannot be called from an ISR. Use SYSTIMER_StopTimerFromISR() instead.
- Parameters
-
id timer ID obtained from SYSTIMER_CreateTimer. Range : 1 to 16
- Returns
- SYSTIMER_STATUS_t APP status. Refer SYSTIMER_STATUS_t for details.
- Description:
- API to stop created software timer instance.
Note : This API must be called after software timer is created using SYSTIMER_CreateTimer API with generated ID and enable XMC_ASSERT for better understanding of API behavioral in run time.
- Example Usage:
Definition at line 530 of file SYSTIMER.c.
References g_timer_tbl, SYSTIMER_STATE_NOT_INITIALIZED, SYSTIMER_STATE_RUNNING, SYSTIMER_STATE_STOPPED, SYSTIMER_STATUS_FAILURE, and SYSTIMER_STATUS_SUCCESS.
Referenced by SYSTIMER_DeleteTimer(), SYSTIMER_RestartTimer(), and SYSTIMER_StopTimerFromISR().
SYSTIMER_STATUS_t SYSTIMER_StopTimerFromISR | ( | uint32_t | id | ) |
A version of SYSTIMER_StopTimer() that can be called from an ISR.
- Parameters
-
id timer ID obtained from SYSTIMER_CreateTimer. Range : 1 to 16
- Returns
- SYSTIMER_STATUS_t APP status. Refer SYSTIMER_STATUS_t for details.
Definition at line 558 of file SYSTIMER.c.
References SYSTIMER_StopTimer().