Hilscher netX microcontroller driver
V0.0.5.0
Documentation of the netX driver package
|
Timer peripheral module driver. More...
Data Structures | |
union | DRV_TIM_DEVICE_U |
Union of the possible timer device pointers. More... | |
struct | DRV_TIM_CONFIGURATION_T |
Timer base Configuration Structure definition. More... | |
struct | DRV_TIM_HANDLE_T |
Timer Base Handle Structure definition. More... | |
Macros | |
#define | DRV_TIM_CLOCK_RATE SystemCoreClock |
#define | DRV_HANDLE_CHECK(handle) |
Functions | |
void | DRV_TIM_GPIOTIM0_Callback (void) |
This is the callback of the GPIOTIM 0 IRQ. More... | |
void | DRV_TIM_GPIOTIM1_Callback (void) |
This is the callback of the GPIOTIM 1 IRQ. More... | |
void | DRV_TIM_GPIOTIM2_Callback (void) |
This is the callback of the GPIOTIM 2 IRQ. More... | |
void | DRV_TIM_TIMER0_Callback (void) |
This is the callback of the TIMER 0 IRQ. More... | |
void | DRV_TIM_TIMER1_Callback (void) |
This is the callback of the TIMER 1 IRQ. More... | |
void | DRV_TIM_TIMER2_Callback (void) |
This is the callback of the TIMER 2 IRQ. More... | |
void | DRV_TIM_SYSTIME_COMPARE_Callback (void) |
This is the callback of the SYSTIME COMPARE IRQ. More... | |
void | DRV_TIM_ARMSYSTICK_Callback (void) |
This is the callback of the SYSTEM TICK IRQ. More... | |
DRV_STATUS_E | DRV_TIM_Init (DRV_TIM_HANDLE_T *const ptTim) |
DRV_STATUS_E | DRV_TIM_DeInit (DRV_TIM_HANDLE_T *const ptTim) |
DRV_STATUS_E | DRV_TIM_Start (DRV_TIM_HANDLE_T *const ptTim) |
DRV_STATUS_E | DRV_TIM_Stop (DRV_TIM_HANDLE_T *const ptTim) |
DRV_STATUS_E | DRV_TIM_Pause (DRV_TIM_HANDLE_T *const ptTim) |
DRV_STATUS_E | DRV_TIM_Wait (DRV_TIM_HANDLE_T *const ptTim, uint32_t ulTickCnt) |
DRV_STATUS_E | DRV_TIM_IRQAttach (DRV_TIM_HANDLE_T *const ptTim, DRV_CALLBACK_F pfnUserClb, void *pvUser) |
DRV_STATUS_E | DRV_TIM_GetState (DRV_TIM_HANDLE_T *const ptTim, DRV_TIM_STATE_E *const peState) |
DRV_STATUS_E | DRV_TIM_GetValue (DRV_TIM_HANDLE_T *const ptTim, uint32_t *const ptSoftwareValue, uint32_t *const ptHardwareValue) |
DRV_STATUS_E | DRV_TIM_SetPreload (DRV_TIM_HANDLE_T *const ptTim, DRV_TIM_PRELOAD_VALUE_E const tCounterValue) |
void | GPIOTIM0_IRQHandler (void) |
This function handles interrupts requests. More... | |
void | GPIOTIM1_IRQHandler (void) |
This function handles interrupts requests. More... | |
void | GPIOTIM2_IRQHandler (void) |
This function handles interrupts requests. More... | |
void | TIM0_IRQHandler (void) |
This function handles interrupts requests. More... | |
void | TIM1_IRQHandler (void) |
This function handles interrupts requests. More... | |
void | TIM2_IRQHandler (void) |
This function handles interrupts requests. More... | |
void | SYSTIME_IRQHandler (void) |
This function handles interrupts requests. More... | |
void | SysTick_Handler (void) |
This function handles interrupts requests. More... | |
DRV_STATUS_E | DRV_TIM_HANDLE_T::DRV_TIM_Init (DRV_TIM_HANDLE_T *const ptTim) |
Initializes the TIM Base peripheral. More... | |
DRV_STATUS_E | DRV_TIM_HANDLE_T::DRV_TIM_DeInit (DRV_TIM_HANDLE_T *const ptTim) |
DeInitializes the TIM Base peripheral. More... | |
DRV_STATUS_E | DRV_TIM_HANDLE_T::DRV_TIM_Start (DRV_TIM_HANDLE_T *const ptTim) |
Starts the TIM generation. More... | |
DRV_STATUS_E | DRV_TIM_HANDLE_T::DRV_TIM_Stop (DRV_TIM_HANDLE_T *const ptTim) |
Stops the TIM generation. More... | |
DRV_STATUS_E | DRV_TIM_HANDLE_T::DRV_TIM_Pause (DRV_TIM_HANDLE_T *const ptTim) |
Pauses the TIM generation. More... | |
DRV_STATUS_E | DRV_TIM_HANDLE_T::DRV_TIM_Wait (DRV_TIM_HANDLE_T *const ptTim, uint32_t ulTickCnt) |
Waits at least until uSkipCnt events have occurred. More... | |
DRV_STATUS_E | DRV_TIM_HANDLE_T::DRV_TIM_ChannelSetThreshold (DRV_TIM_HANDLE_T *const ptTim, DRV_DIO_ID_T ulChannelID, uint32_t ulTC) |
This function sets the threshold used for the specified channel. More... | |
DRV_STATUS_E | DRV_TIM_HANDLE_T::DRV_TIM_ChannelGetCapture (DRV_TIM_HANDLE_T *const ptTim, DRV_DIO_ID_T ulChannelID, uint32_t *const ulValue) |
This function gets the captured value of the specified channel. More... | |
DRV_STATUS_E | DRV_TIM_HANDLE_T::DRV_TIM_IRQAttach (DRV_TIM_HANDLE_T *const ptTim, DRV_CALLBACK_F pfnUserClb, void *pvUser) |
Attaches a given callback to the counter. More... | |
DRV_STATUS_E | DRV_TIM_HANDLE_T::DRV_TIM_GetState (DRV_TIM_HANDLE_T *const ptTim, DRV_TIM_STATE_E *const peState) |
Stores the state of the given counter. More... | |
__STATIC_FORCEINLINE void | DRV_TIM_HANDLE_T::DRV_TIM_LatchSytimes (void) |
This function latches all system time counters. More... | |
DRV_STATUS_E | DRV_TIM_HANDLE_T::DRV_TIM_GetValue (DRV_TIM_HANDLE_T *const ptTim, uint32_t *const ptSoftwareValue, uint32_t *const ptHardwareValue) |
Stores the current counter value. More... | |
DRV_STATUS_E | DRV_TIM_HANDLE_T::DRV_TIM_SetPreload (DRV_TIM_HANDLE_T *const ptTim, DRV_TIM_PRELOAD_VALUE_E tCounterValue) |
Sets a new preload value. More... | |
Variables | |
static IRQn_Type const | aulIRQnTable [DRV_TIM_IRQ_COUNT] = DRV_TIM_IRQ_LIST |
Table of the IRQ vector numbers. More... | |
static DRV_CALLBACK_F | s_apTIMCallbackTable [DRV_TIM_IRQ_COUNT] = { 0 } |
Used for mapping the handle to an interrupt. More... | |
static void * | s_apTIMCallbackHandleTable [DRV_TIM_IRQ_COUNT] = { 0 } |
static DRV_TIM_HANDLE_T * | s_apTIMCallbackDriverHandleTable [DRV_TIM_IRQ_COUNT] = { 0 } |
static volatile uint32_t | s_apTIMIrqCntr [DRV_TIM_IRQ_COUNT] = { 0 } |
Timer peripheral module driver.
#define DRV_HANDLE_CHECK | ( | handle | ) |
Define for checking the consistency of the handle or static representation of the driver.
Definition at line 84 of file netx_drv_tim.c.
#define DRV_TIM_CLOCK_RATE SystemCoreClock |
The Clock rate of the chip.
Definition at line 208 of file netx_drv_tim.h.
anonymous enum |
Those are the defines associated with the irq list enumeration. This should probably be moved to the csp.
Enumerator | |
---|---|
DRV_TIM_IRQ_GPIOTIM0 | |
DRV_TIM_IRQ_GPIOTIM1 | |
DRV_TIM_IRQ_GPIOTIM2 | |
DRV_TIM_IRQ_TIMER0 | |
DRV_TIM_IRQ_TIMER1 | |
DRV_TIM_IRQ_TIMER2 | |
DRV_TIM_IRQ_SYSTIME_COMPARE | |
DRV_TIM_IRQ_SYSTICK |
Definition at line 39 of file netx_drv_tim.c.
Enumeration of the available counting modes.
They decide in which way the counter reloads and how events are generated.
Definition at line 149 of file netx_drv_tim.h.
Enumeration of the external event mode.
It defines if the timer uses external events and in which way they will be used
Definition at line 108 of file netx_drv_tim.h.
Enumeration defines the kind of external event signal.
The external event mode will be triggerd by the following condition. The condition can be inverted by inversion of channel with the digital input output driver.
Enumerator | |
---|---|
DRV_TIM_EXTERNAL_EVENT_MODE_HIGH_LEVEL |
External event is triggered by high level. |
DRV_TIM_EXTERNAL_EVENT_MODE_RISING_EDGE |
External event is triggered by rising edge. |
Definition at line 122 of file netx_drv_tim.h.
Time structure of the timer driver.
This structure contains the tick count based on the system clock that runs with 100Mhz.
Definition at line 61 of file netx_drv_tim.h.
enum DRV_TIM_STATE_E |
Enumeration of the timer State.
Definition at line 93 of file netx_drv_tim.h.
enum DRV_TIM_SYMMETRIC_E |
Enumeration of the counting symmetries available.
Defines in which way the counter counts. From low to high or from low to high/2 and back to low.
Enumerator | |
---|---|
DRV_TIM_SYMMETRIC_SAWTOOTH |
asymmetric mode |
DRV_TIM_SYMMETRIC_TRIANGLE |
symmetric mode |
Definition at line 162 of file netx_drv_tim.h.
The time base that is used for the timer.
This time base will be used for the timer. This is necessary because system timers might be stopped for debugging and also if the counter will be used in the DRV_TIM_COUNTING_MODE_COMPARE mode.
Definition at line 134 of file netx_drv_tim.h.
__WEAK void DRV_TIM_ARMSYSTICK_Callback | ( | void | ) |
This is the callback of the SYSTEM TICK IRQ.
It is called from the Interrupt service routine. And calls the function attached to the interrupt by DRV_TIM_IRQAttach() , if there is one. Because the implementation has the attribute weak it is possible to implement the callback inside the application context. EOI-handling and source clearing not necessary.
Definition at line 1533 of file netx_drv_tim.c.
DRV_STATUS_E DRV_TIM_ChannelGetCapture | ( | DRV_TIM_HANDLE_T *const | ptTim, |
DRV_DIO_ID_T | ulChannelID, | ||
uint32_t *const | ulValue | ||
) |
This function gets the captured value of the specified channel.
This function sets the threshold capture of a digital input output channel. It is used if the specified channel is in Blink, PWM, PWM2 or capture mode.
[in,out] | ptTim | pointer to a DRV_TIM_HANDLE_T structure. |
[in] | ulChannelID | The id of the channel to be configured |
[in] | ulValue | The counter used as reference |
Definition at line 973 of file netx_drv_tim.c.
DRV_STATUS_E DRV_TIM_ChannelSetThreshold | ( | DRV_TIM_HANDLE_T *const | ptTim, |
DRV_DIO_ID_T | ulChannelID, | ||
uint32_t | ulTC | ||
) |
This function sets the threshold used for the specified channel.
This function sets the threshold of a digital input output channel.
The PWM is set if the counter is greater or equal the threshold, so it defines the low time if the channel is not inverted. In triangle, both values are divided by 2 so that the low time is the same as in sawtooth.
[in,out] | ptTim | pointer to a DRV_TIM_HANDLE_T structure. |
[in] | ulChannelID | The id of the channel to be configured |
[in] | ulTC | The counter used as reference |
Definition at line 933 of file netx_drv_tim.c.
DRV_STATUS_E DRV_TIM_DeInit | ( | DRV_TIM_HANDLE_T *const | ptTim | ) |
DeInitializes the TIM Base peripheral.
Definition at line 267 of file netx_drv_tim.c.
DRV_STATUS_E DRV_TIM_DeInit | ( | DRV_TIM_HANDLE_T *const | ptTim | ) |
[in,out] | ptTim | pointer to a DRV_TIM_HANDLE_T structure. |
Definition at line 267 of file netx_drv_tim.c.
DRV_STATUS_E DRV_TIM_GetState | ( | DRV_TIM_HANDLE_T *const | ptTim, |
DRV_TIM_STATE_E *const | peState | ||
) |
Stores the state of the given counter.
Definition at line 1091 of file netx_drv_tim.c.
DRV_STATUS_E DRV_TIM_GetState | ( | DRV_TIM_HANDLE_T *const | ptTim, |
DRV_TIM_STATE_E *const | peState | ||
) |
[in,out] | ptTim | pointer to a DRV_TIM_HANDLE_T structure. |
[out] | peState | pointer to a DRV_TIM_STATE_E enumeration that will be modified with the current state. |
Definition at line 1091 of file netx_drv_tim.c.
DRV_STATUS_E DRV_TIM_GetValue | ( | DRV_TIM_HANDLE_T *const | ptTim, |
uint32_t *const | ptSoftwareValue, | ||
uint32_t *const | ptHardwareValue | ||
) |
Stores the current counter value.
Definition at line 1142 of file netx_drv_tim.c.
DRV_STATUS_E DRV_TIM_GetValue | ( | DRV_TIM_HANDLE_T *const | ptTim, |
uint32_t *const | ptSoftwareValue, | ||
uint32_t *const | ptHardwareValue | ||
) |
This function stores the current counter values in the given pointer position. A software event is triggered if the hardware counter overflows by reaching its border. Keep in mind, that a counter iterates and a timer decrements.
If the hardware counters border/preload is set to e.g. 1ms it will overflow each ms and the software counter is incremented.
The software counter is iterated by the interrupt handlers and works only in the interrupt operation mode.
The systimes have to be latched before read. The software counter value contains the seconds and the hardware counter value contains the nano seconds of the systime counter.
[in,out] | ptTim | pointer to a DRV_TIM_HANDLE_T structure. |
[out] | ptSoftwareValue | pointer to a uint32_t where the current software counter value is written to. |
[out] | ptHardwareValue | pointer to a uint32_t where the current hardware counter value is written to. |
Definition at line 1142 of file netx_drv_tim.c.
__WEAK void DRV_TIM_GPIOTIM0_Callback | ( | void | ) |
This is the callback of the GPIOTIM 0 IRQ.
It is called from the Interrupt service routine. And calls the function attached to the interrupt by DRV_TIM_IRQAttach() , if there is one. Because the implementation has the attribute weak it is possible to implement the callback inside the application context. EOI-handling and source clearing not necessary.
Definition at line 1354 of file netx_drv_tim.c.
__WEAK void DRV_TIM_GPIOTIM1_Callback | ( | void | ) |
This is the callback of the GPIOTIM 1 IRQ.
It is called from the Interrupt service routine. And calls the function attached to the interrupt by DRV_TIM_IRQAttach() , if there is one. Because the implementation has the attribute weak it is possible to implement the callback inside the application context. EOI-handling and source clearing not necessary.
Definition at line 1381 of file netx_drv_tim.c.
__WEAK void DRV_TIM_GPIOTIM2_Callback | ( | void | ) |
This is the callback of the GPIOTIM 2 IRQ.
It is called from the Interrupt service routine. And calls the function attached to the interrupt by DRV_TIM_IRQAttach() , if there is one. Because the implementation has the attribute weak it is possible to implement the callback inside the application context. EOI-handling and source clearing not necessary.
Definition at line 1407 of file netx_drv_tim.c.
DRV_STATUS_E DRV_TIM_Init | ( | DRV_TIM_HANDLE_T *const | ptTim | ) |
The device specified in the handle will be initialized and configured after the given attributes. If the interrupt or dma method is chosen, the nvic and dmac is also configured.
[in,out] | ptTim | pointer to a DRV_TIM_HANDLE_T structure. |
Definition at line 107 of file netx_drv_tim.c.
DRV_STATUS_E DRV_TIM_Init | ( | DRV_TIM_HANDLE_T *const | ptTim | ) |
Initializes the TIM Base peripheral.
Definition at line 107 of file netx_drv_tim.c.
DRV_STATUS_E DRV_TIM_IRQAttach | ( | DRV_TIM_HANDLE_T *const | ptTim, |
DRV_CALLBACK_F | pfnUserClb, | ||
void * | pvUser | ||
) |
Attaches a given callback to the counter.
Definition at line 1016 of file netx_drv_tim.c.
DRV_STATUS_E DRV_TIM_IRQAttach | ( | DRV_TIM_HANDLE_T *const | ptTim, |
DRV_CALLBACK_F | pfnUserClb, | ||
void * | pvUser | ||
) |
This method will attach a user given callback with the user given pointer to the interrupt of the given timer device context object.
[in,out] | ptTim | pointer to a DRV_TIM_HANDLE_T structure. |
[in] | pfnUserClb | The callback to be called. |
[in] | pvUser | The handle given as second function parameter. |
Definition at line 1016 of file netx_drv_tim.c.
__STATIC_FORCEINLINE void DRV_TIM_LatchSytimes | ( | void | ) |
This function latches all system time counters.
All systimes have to be read once, after that, they return the actual value. A latch does not expire.
Definition at line 276 of file netx_drv_tim.h.
DRV_STATUS_E DRV_TIM_Pause | ( | DRV_TIM_HANDLE_T *const | ptTim | ) |
Pauses the TIM generation.
Definition at line 619 of file netx_drv_tim.c.
DRV_STATUS_E DRV_TIM_Pause | ( | DRV_TIM_HANDLE_T *const | ptTim | ) |
[in,out] | ptTim | pointer to a DRV_TIM_HANDLE_T structure. |
Definition at line 619 of file netx_drv_tim.c.
DRV_STATUS_E DRV_TIM_SetPreload | ( | DRV_TIM_HANDLE_T *const | ptTim, |
DRV_TIM_PRELOAD_VALUE_E | tCounterValue | ||
) |
Sets a new preload value.
Definition at line 1281 of file netx_drv_tim.c.
DRV_STATUS_E DRV_TIM_SetPreload | ( | DRV_TIM_HANDLE_T *const | ptTim, |
DRV_TIM_PRELOAD_VALUE_E const | tCounterValue | ||
) |
[in,out] | ptTim | pointer to a DRV_TIM_HANDLE_T structure. |
[in] | tCounterValue | contains the value set as new preload. |
Definition at line 1281 of file netx_drv_tim.c.
DRV_STATUS_E DRV_TIM_Start | ( | DRV_TIM_HANDLE_T *const | ptTim | ) |
Starts the TIM generation.
Definition at line 338 of file netx_drv_tim.c.
DRV_STATUS_E DRV_TIM_Start | ( | DRV_TIM_HANDLE_T *const | ptTim | ) |
The timer is started in non blocking mode.
[in,out] | ptTim | pointer to a DRV_TIM_HANDLE_T structure. |
Definition at line 338 of file netx_drv_tim.c.
DRV_STATUS_E DRV_TIM_Stop | ( | DRV_TIM_HANDLE_T *const | ptTim | ) |
Stops the TIM generation.
Definition at line 477 of file netx_drv_tim.c.
DRV_STATUS_E DRV_TIM_Stop | ( | DRV_TIM_HANDLE_T *const | ptTim | ) |
The timer is stopped in blocking mode. After the function has finished the timer is inactive, no interrupts will occur anymore and the dma has also stopped.
[in,out] | ptTim | pointer to a DRV_TIM_HANDLE_T structure. |
Definition at line 477 of file netx_drv_tim.c.
__WEAK void DRV_TIM_SYSTIME_COMPARE_Callback | ( | void | ) |
This is the callback of the SYSTIME COMPARE IRQ.
It is called from the Interrupt service routine. And calls the function attached to the interrupt by DRV_TIM_IRQAttach() , if there is one. Because the implementation has the attribute weak it is possible to implement the callback inside the application context. EOI-handling and source clearing not necessary.
Definition at line 1508 of file netx_drv_tim.c.
__WEAK void DRV_TIM_TIMER0_Callback | ( | void | ) |
This is the callback of the TIMER 0 IRQ.
It is called from the Interrupt service routine. And calls the function attached to the interrupt by DRV_TIM_IRQAttach() , if there is one. Because the implementation has the attribute weak it is possible to implement the callback inside the application context. EOI-handling and source clearing not necessary.
Definition at line 1433 of file netx_drv_tim.c.
__WEAK void DRV_TIM_TIMER1_Callback | ( | void | ) |
This is the callback of the TIMER 1 IRQ.
It is called from the Interrupt service routine. And calls the function attached to the interrupt by DRV_TIM_IRQAttach() , if there is one. Because the implementation has the attribute weak it is possible to implement the callback inside the application context. EOI-handling and source clearing not necessary.
Definition at line 1458 of file netx_drv_tim.c.
__WEAK void DRV_TIM_TIMER2_Callback | ( | void | ) |
This is the callback of the TIMER 2 IRQ.
It is called from the Interrupt service routine. And calls the function attached to the interrupt by DRV_TIM_IRQAttach() , if there is one. Because the implementation has the attribute weak it is possible to implement the callback inside the application context. EOI-handling and source clearing not necessary.
Definition at line 1483 of file netx_drv_tim.c.
DRV_STATUS_E DRV_TIM_Wait | ( | DRV_TIM_HANDLE_T *const | ptTim, |
uint32_t | ulTickCnt | ||
) |
Waits at least until uSkipCnt events have occurred.
Definition at line 747 of file netx_drv_tim.c.
DRV_STATUS_E DRV_TIM_Wait | ( | DRV_TIM_HANDLE_T *const | ptTim, |
uint32_t | ulTickCnt | ||
) |
If the value uSkipCnt is 0, the function will wait until the next event has occurred. If the value is at least 1 the function will wait until the given ammount of events have occurred. With a timer of 1ms and a ulSkipCnt of 100 the function will wait for 100ms + 1ms (first event) + runtime > 100.5ms
[in,out] | ptTim | pointer to a DRV_TIM_HANDLE_T structure. |
[in] | ulTickCnt | Count of events to skip. |
Definition at line 747 of file netx_drv_tim.c.
void GPIOTIM0_IRQHandler | ( | void | ) |
This function handles interrupts requests.
Definition at line 1341 of file netx_drv_tim.c.
void GPIOTIM1_IRQHandler | ( | void | ) |
This function handles interrupts requests.
Definition at line 1368 of file netx_drv_tim.c.
void GPIOTIM2_IRQHandler | ( | void | ) |
This function handles interrupts requests.
Definition at line 1394 of file netx_drv_tim.c.
void SysTick_Handler | ( | void | ) |
This function handles interrupts requests.
Definition at line 1521 of file netx_drv_tim.c.
void SYSTIME_IRQHandler | ( | void | ) |
This function handles interrupts requests.
Definition at line 1495 of file netx_drv_tim.c.
void TIM0_IRQHandler | ( | void | ) |
This function handles interrupts requests.
Definition at line 1420 of file netx_drv_tim.c.
void TIM1_IRQHandler | ( | void | ) |
This function handles interrupts requests.
Definition at line 1445 of file netx_drv_tim.c.
void TIM2_IRQHandler | ( | void | ) |
This function handles interrupts requests.
Definition at line 1470 of file netx_drv_tim.c.
|
static |
Table of the IRQ vector numbers.
Used to identify the interrupt channels by the device id.
Definition at line 56 of file netx_drv_tim.c.
|
static |
Interrupt driver handler context pointers.
Definition at line 73 of file netx_drv_tim.c.
|
static |
Interrupt attached handler context pointers.
Definition at line 68 of file netx_drv_tim.c.
|
static |
Used for mapping the handle to an interrupt.
Threadsafe and reentrant because its is only written in normal context an used in interrupt context of the specific interrupt.
Definition at line 63 of file netx_drv_tim.c.
|
static |
Interrupt counter.
Definition at line 78 of file netx_drv_tim.c.