![]() |
![]() |
GPTimer driver implementation for Wi-Fi F3 devices.
The GPTimer driver allows you to measure elapsed time with simple and portable APIs. It also allows for asynchronous callbacks after a certain amount of time has elapsed. In addition the driver supports APIs for both capture and compare of IO signals muxable to the four channels of each GPT peripheral instance. The channel capture functionality can be used to measure period and duty cycle of an input signal. The channel compare functionality can be used for generating PWM signals.
The GPTimer driver also handles the general purpose timer resource allocation. For each driver that requires use of a general purpose timer, it calls GPTimerWFF3_open() to occupy the specified timer, and calls GPTimerWFF3_close() to release the occupied timer resource.
The table below lists supported counter widths for each peripheral instance number on available device types. The timer counter clock is sourced from the internal prescaler stage which has the system clock as input. The prescaler can be configured to divide the input system clock, effectively extending the maximal time interval for the timer counter while reducing the timer resolution.
| Device type | GPT0 | GPT1 |
|---|---|---|
| CC35xx | 32 bits | 32 bits |
The GPTimer driver supports the following timer counter modes:
The power management framework will try to put the device into the most power efficient mode whenever possible. Please see the technical reference manual for further details on each power mode.
The GPTimer driver will set constraints on disallowed power modes when needed, removing the need for the application to handle this. The following statements are valid:
The timer clock of the GPT peripheral is dependent on the system clock.
This documentation provides some basic examples in the form of commented code fragments.
The code example below will generate an interrupt using the GPTimer every 1 ms. Note that when a count-up counter mode is used, the number of counter ticks to reach the target value equals target value + 1.
The code example below will generate an output signal of 32 kHz with a 50 % duty cycle on channel 2. With an up/down counter mode, the counter target value determines the signal period and the value must be set to half the number of the total counter ticks per signal period. With a channel action of toggle-on-compare, the channel compare value must be set to (counter target value)/2 in order to obtain a 50 % duty cycle of the output signal. The period of a 32 kHz signal equals 1250 counter ticks when the counter has a 40 MHz clock.
Opening a GPTimerWFFF3 requires four steps:
Refer to the Driver's Configuration section for driver configuration information.
#include <ti/drivers/dpl/HwiP.h>#include <ti/drivers/Power.h>#include <ti/drivers/GPIO.h>#include <ti/devices/DeviceFamily.h>#include <DeviceFamily_constructPath(inc/hw_gptimer.h)>

Go to the source code of this file.
Data Structures | |
| struct | GPTimerWFF3_ChannelProp |
| GPTimerWFF3 channel dependent properties struct. More... | |
| struct | GPTimerWFF3_Params |
| GPTimerWFF3 Parameters. More... | |
| struct | GPTimerWFF3_ChannelConf |
| GPTimerWFF3 channel dependent pin configuration struct. More... | |
| struct | GPTimerWFF3_HWAttrs |
| GPTimerWFF3 Hardware attributes. More... | |
| struct | GPTimerWFF3_Object |
| GPTimerWFF3 Object. More... | |
| struct | GPTimerWFF3_Config |
| GPTimer Global configuration. More... | |
Macros | |
| #define | NO_OF_GPT_CHANNELS 4 |
Typedefs | |
| typedef struct GPTimerWFF3_Config | GPTimerWFF3_Config |
| typedef GPTimerWFF3_Config * | GPTimerWFF3_Handle |
| typedef uint16_t | GPTimerWFF3_IntMask |
| typedef void(* | GPTimerWFF3_HwiFxn) (GPTimerWFF3_Handle handle, GPTimerWFF3_IntMask interruptMask) |
| The definition of a callback function used by the GPTimer driver. More... | |
| typedef struct GPTimerWFF3_ChannelProp | GPTimerWFF3_ChannelProp |
| GPTimerWFF3 channel dependent properties struct. More... | |
| typedef struct GPTimerWFF3_Params | GPTimerWFF3_Params |
| GPTimerWFF3 Parameters. More... | |
| typedef struct GPTimerWFF3_ChannelConf | GPTimerWFF3_ChannelConf |
| GPTimerWFF3 channel dependent pin configuration struct. More... | |
| typedef struct GPTimerWFF3_HWAttrs | GPTimerWFF3_HWAttrs |
| GPTimerWFF3 Hardware attributes. More... | |
| typedef struct GPTimerWFF3_Object | GPTimerWFF3_Object |
| GPTimerWFF3 Object. More... | |
Enumerations | |
| enum | GPTimerWFF3_ChannelNo { GPTimerWFF3_CH_NO_0 = 0, GPTimerWFF3_CH_NO_1 = 1, GPTimerWFF3_CH_NO_2 = 2, GPTimerWFF3_CH_NO_3 = 3 } |
| Definitions for supported GPTimer channel numbers. More... | |
| enum | GPTimerWFF3_ChannelDir { GPTimerWFF3_CH_DIR_NONE = 0, GPTimerWFF3_CH_DIR_INPUT = 1, GPTimerWFF3_CH_DIR_OUTPUT = 2 } |
| Definitions for supported GPTimer channel direction. More... | |
| enum | GPTimerWFF3_ChannelLevel { GPTimerWFF3_CH_LEVEL_LOW = GPTIMER_OUTCTL_CLROUT0, GPTimerWFF3_CH_LEVEL_HIGH = GPTIMER_OUTCTL_SETOUT0 } |
| Definitions for supported GPTimer channel output levels. More... | |
| enum | GPTimerWFF3_ChannelInputEdge { GPTimerWFF3_CH_EDGE_NONE = GPTIMER_C0CFG_EDGE_NONE, GPTimerWFF3_CH_EDGE_RISE = GPTIMER_C0CFG_EDGE_RISE, GPTimerWFF3_CH_EDGE_FALL = GPTIMER_C0CFG_EDGE_FALL, GPTimerWFF3_CH_EDGE_BOTH = GPTIMER_C0CFG_EDGE_BOTH } |
| Definitions for supported GPTimer channel input edge. More... | |
| enum | GPTimerWFF3_Mode { GPTimerWFF3_CTL_MODE_DIS = GPTIMER_CTL_MODE_DIS, GPTimerWFF3_CTL_MODE_UP_ONCE = GPTIMER_CTL_MODE_UP_ONCE, GPTimerWFF3_CTL_MODE_UP_PER = GPTIMER_CTL_MODE_UP_PER, GPTimerWFF3_CTL_MODE_UPDWN_PER = GPTIMER_CTL_MODE_UPDWN_PER } |
| Definitions for supported GPTimer counting modes. More... | |
| enum | GPTimerWFF3_Interrupt { GPTimerWFF3_INT_TGT = 1 << GPTIMER_RIS_TGT_S, GPTimerWFF3_INT_ZERO = 1 << GPTIMER_RIS_ZERO_S, GPTimerWFF3_INT_COUNTER_CHANGE = 1 << GPTIMER_RIS_CNTRCHNG_S, GPTimerWFF3_INT_DIR_CHANGE = 1 << GPTIMER_RIS_DIRCHNG_S, GPTimerWFF3_INT_CH0_CC = 1 << GPTIMER_RIS_C0CC_S, GPTimerWFF3_INT_CH1_CC = 1 << GPTIMER_RIS_C1CC_S, GPTimerWFF3_INT_CH2_CC = 1 << GPTIMER_RIS_C2CC_S, GPTimerWFF3_INT_CH3_CC = 1 << GPTIMER_RIS_C3CC_S } |
| Definitions for supported GPTimer interrupts. GPTimerWFF3_IntMask arguments should be a bit vector containing these definitions. More... | |
| enum | GPTimerWFF3_DebugMode { GPTimerWFF3_DEBUG_STALL_OFF = GPTIMER_EMU_HALT_DIS, GPTimerWFF3_DEBUG_STALL_IMMEDIATE = (GPTIMER_EMU_HALT_EN | GPTIMER_EMU_CTL_IMMEDIATE), GPTimerWFF3_DEBUG_STALL_ON_ZERO = (GPTIMER_EMU_HALT_EN | GPTIMER_EMU_CTL_ZERCOND) } |
| Definitions for controlling timer debug stall mode. More... | |
| enum | GPTimerWFF3_ChannelCmpDir { GPTimerWFF3_CH_COMPARE_COUNTER_DIR_BOTH = GPTIMER_CTL_CMPDIR_BOTH, GPTimerWFF3_CH_COMPARE_COUNTER_DIR_UP = GPTIMER_CTL_CMPDIR_UP, GPTimerWFF3_CH_COMPARE_COUNTER_DIR_DOWN = GPTIMER_CTL_CMPDIR_DOWN } |
| Definitions for which direction the timer counter must have in order to set channel compare interrupt status flag. More... | |
| enum | GPTimerWFF3_ChannelAction { GPTimerWFF3_CH_DISABLE = GPTIMER_C0CFG_CCACT_DIS, GPTimerWFF3_CH_TOGGLE_ON_COMPARE_PERIODIC = GPTIMER_C0CFG_CCACT_TGL_ON_CMP, GPTimerWFF3_CH_TOGGLE_ON_COMPARE_ONCE = GPTIMER_C0CFG_CCACT_TGL_ON_CMP_DIS, GPTimerWFF3_CH_SET_ON_COMPARE_PERIODIC = GPTIMER_C0CFG_CCACT_SET_ON_CMP, GPTimerWFF3_CH_SET_ON_COMPARE_ONCE = GPTIMER_C0CFG_CCACT_SET_ON_CMP_DIS, GPTimerWFF3_CH_CLEAR_ON_COMPARE_PERIODIC = GPTIMER_C0CFG_CCACT_CLR_ON_CMP, GPTimerWFF3_CH_CLEAR_ON_COMPARE_ONCE = GPTIMER_C0CFG_CCACT_CLR_ON_CMP_DIS, GPTimerWFF3_CH_SET_ON_0_TOGGLE_ON_CMP_PERIODIC = GPTIMER_C0CFG_CCACT_SET_ON_0_TGL_ON_CMP, GPTimerWFF3_CH_SET_ON_0_TOGGLE_ON_COMPARE_ONCE = GPTIMER_C0CFG_CCACT_SET_ON_0_TGL_ON_CMP_DIS, GPTimerWFF3_CH_CLR_ON_0_TOGGLE_ON_COMPARE_PERIODIC = GPTIMER_C0CFG_CCACT_CLR_ON_0_TGL_ON_CMP, GPTimerWFF3_CH_CLR_ON_0_TOGGLE_ON_COMPARE_ONCE = GPTIMER_C0CFG_CCACT_CLR_ON_0_TGL_ON_CMP_DIS, GPTimerWFF3_CH_PULSE_ON_COMPARE_PERIODIC = GPTIMER_C0CFG_CCACT_PULSE_ON_CMP, GPTimerWFF3_CH_PULSE_ON_COMPARE_ONCE = GPTIMER_C0CFG_CCACT_PULSE_ON_CMP_DIS, GPTimerWFF3_CH_SET_ON_CAPTURE_PERIODIC = GPTIMER_C0CFG_CCACT_SET_ON_CAPT, GPTimerWFF3_CH_SET_ON_CAPTURE_ONCE = GPTIMER_C0CFG_CCACT_SET_ON_CAPT_DIS, GPTimerWFF3_CH_PULSE_WIDTH_MEASURE = GPTIMER_C0CFG_CCACT_PER_PULSE_WIDTH_MEAS } |
| Definitions for supported GPTimer channel actions. More... | |
Functions | |
| void | GPTimerWFF3_Params_init (GPTimerWFF3_Params *params) |
| Function that initializes the GPTimerWFF3_Params struct to its default values. More... | |
| GPTimerWFF3_Handle | GPTimerWFF3_open (uint_least8_t index, const GPTimerWFF3_Params *params) |
| Function that opens a driver for the given GPT peripheral. Will set power dependency on timer and configure it into specified configuration. More... | |
| void | GPTimerWFF3_close (GPTimerWFF3_Handle handle) |
| Function that closes a GPTimer driver specified by the GPTimer handle. Closing GPTimer driver will release power dependency on timer and clear configuration. More... | |
| void | GPTimerWFF3_start (GPTimerWFF3_Handle handle, GPTimerWFF3_Mode mode) |
| Function that starts the timer counter of the specified GPTimer handle with current settings and specified timer counter mode. More... | |
| void | GPTimerWFF3_stop (GPTimerWFF3_Handle handle) |
| Function that stops the timer counter of the specified GPTimer driver. More... | |
| void | GPTimerWFF3_setInitialCounterTarget (GPTimerWFF3_Handle handle, uint32_t value, bool intFlagClr) |
| Function that sets the initial timer counter target on the specified GPTimer. This function must be called before the timer is started. More... | |
| void | GPTimerWFF3_setNextCounterTarget (GPTimerWFF3_Handle handle, uint32_t value, bool intFlagClr) |
| Function that sets the timer counter target for the next counter period on the specified GPTimer. The specified target value will be valid as timer counter target on the upcoming zero crossing. When counting repeatedly upwards a zero crossing is regarded as when the timer counter restarts counting from 0. This function can be called after the timer has started. Timer counter width is 32-bits. (see GPT peripheral properties). More... | |
| uint32_t | GPTimerWFF3_getCounter (GPTimerWFF3_Handle handle) |
| Function that returns the current timer counter value. More... | |
| uintptr_t | GPTimerWFF3_getArg (GPTimerWFF3_Handle handle) |
| Function to get a custom argument. More... | |
| void | GPTimerWFF3_setArg (GPTimerWFF3_Handle handle, uintptr_t arg) |
| Function to set a custom argument. More... | |
| void | GPTimerWFF3_enableInterrupt (GPTimerWFF3_Handle handle, GPTimerWFF3_IntMask intMask) |
| Enable interrupt source for the GPTimer handle. More... | |
| void | GPTimerWFF3_disableInterrupt (GPTimerWFF3_Handle handle, GPTimerWFF3_IntMask intMask) |
| Disable interrupt source for the GPTimer handle. More... | |
| void | GPTimerWFF3_setInitialChannelCompVal (GPTimerWFF3_Handle handle, GPTimerWFF3_ChannelNo chNo, uint32_t value, bool intFlagClr) |
| Function that sets the initial channel compare value on the specified GPTimer and channel. The compare value for the specified channel will be used by any compare type channel action GPTimerWFF3_ChannelAction specified by the GPTimer params. The channel number dependent interrupt status flag (GPTimerWFF3_INT_CH0_CC for channel number GPTimerWFF3_CH_NO_0) will be set when the timer counter equals the channel compare value. This function must be called prior to GPTimerWFF3_start(). Timer compare value width is 32 bits (see GPT peripheral properties). More... | |
| void | GPTimerWFF3_setNextChannelCompVal (GPTimerWFF3_Handle handle, GPTimerWFF3_ChannelNo chNo, uint32_t value, bool intFlagClr) |
| Function that sets the channel compare value on the specified GPTimer for the next cycle of the already started timer counter. The compare value for the specified channel is valid for any compare type channel action GPTimerWFF3_ChannelAction specified by the GPTimer params. The channel number dependent interrupt status flag (GPTimerWFF3_INT_CH0_CC for channel number GPTimerWFF3_CH_NO_0) will be set when the timer counter equals the channel compare value in the next and following timer counter cycles. This function can be called while the timer is active. More... | |
| void | GPTimerWFF3_setChannelOutputLevel (GPTimerWFF3_Handle handle, GPTimerWFF3_ChannelNo chNo, GPTimerWFF3_ChannelLevel level) |
| Function that manually sets the current channel output level high or low. Manual update of a channel output takes priority over automatic channel updates to the same output when occurring at the same time. The complementary channel output will be set to the complementary level of the specified level. More... | |
| uint32_t | GPTimerWFF3_getChCompareVal (GPTimerWFF3_Handle handle, GPTimerWFF3_ChannelNo chNo) |
| Function to get the channel compare value or channel-updated capture value. Dependent on the selected channel action for the specified channel, the function will return either the current channel compare value or the channel-updated capture value. The channel-updated capture value is returned if a successful channel capture event, as specified by the channel action, has occured on the specified channel. For a channel action of GPTimerWFF3_CH_PULSE_WIDTH_MEASURE, the returned value after a successful channel capture event, represents the measured period of the selected channel input signal. More... | |
| uint32_t | GPTimerWFF3_getChCaptureVal (GPTimerWFF3_Handle handle, GPTimerWFF3_ChannelNo chNo) |
| Function to get the channel compare value or channel-updated capture value. Dependent on the selected channel action for the specified channel, the function will return either the current channel compare value or the channel-updated capture value. The channel-updated capture value is returned if a successful channel capture event, as specified by the channel action, has occured on the specified channel. For a channel action of GPTimerWFF3_CH_PULSE_WIDTH_MEASURE, the returned value after a successful channel capture event, represents the measured period of the selected channel input signal. More... | |
| uint32_t | GPTimerWFF3_getNextChCompareVal (GPTimerWFF3_Handle handle, GPTimerWFF3_ChannelNo chNo) |
| Function to get the channel compare value for the next counter cycle or the channel-updated capture value. Dependent on the selected channel action for the specified channel, the function will return either the channel compare value for the next counter cycle or the channel-updated capture value. For a channel action mode of GPTimerWFF3_CH_PULSE_WIDTH_MEASURE, the returned value after a successful capture event will be the width of the low or high phase of the selected channel input signal. The phase is specified by GPTimerWFF3_ChannelInputEdge parameter for the selected channel. In order to get the channel-updated capture value for other capture channel actions than GPTimerWFF3_CH_PULSE_WIDTH_MEASURE, the function GPTimerWFF3_getChCompareVal should be used. More... | |
| uint32_t | GPTimerWFF3_getNextChCaptureVal (GPTimerWFF3_Handle handle, GPTimerWFF3_ChannelNo chNo) |
| Function to get the channel compare value for the next counter cycle or the channel-updated capture value. Dependent on the selected channel action for the specified channel, the function will return either the channel compare value for the next counter cycle or the channel-updated capture value. For a channel action mode of GPTimerWFF3_CH_PULSE_WIDTH_MEASURE, the returned value after a successful capture event will be the width of the low or high phase of the selected channel input signal. The phase is specified by GPTimerWFF3_ChannelInputEdge parameter for the selected channel. In order to get the channel-updated capture value for other capture channel actions than GPTimerWFF3_CH_PULSE_WIDTH_MEASURE, the function GPTimerWFF3_getChCompareVal() should be used. More... | |
| uint32_t | GPTimerWFF3_getCounterWidth (GPTimerWFF3_Handle handle) |
| Function to get the width of the timer counter in number of bits. More... | |
| #define NO_OF_GPT_CHANNELS 4 |
| typedef struct GPTimerWFF3_Config GPTimerWFF3_Config |
| typedef GPTimerWFF3_Config* GPTimerWFF3_Handle |
| typedef uint16_t GPTimerWFF3_IntMask |
| typedef void(* GPTimerWFF3_HwiFxn) (GPTimerWFF3_Handle handle, GPTimerWFF3_IntMask interruptMask) |
The definition of a callback function used by the GPTimer driver.
| [in] | handle | A GPTimer handle |
| [in] | interruptMask | GPTimer interrupt mask |
| typedef struct GPTimerWFF3_ChannelProp GPTimerWFF3_ChannelProp |
GPTimerWFF3 channel dependent properties struct.
GPTimer struct used by the GPTimerWFF3_Params.
| typedef struct GPTimerWFF3_Params GPTimerWFF3_Params |
GPTimerWFF3 Parameters.
GPTimer parameters are used by the GPTimerWFF3_open() call. Default values for these parameters are set using GPTimerWFF3_Params_init().
Please note that if the value of the intPhaseLate parameter is set to false while the prescalerDiv parameter value is high and either the GPTimerWFF3_INT_TGT or GPTimerWFF3_INT_ZERO interrupts are enabled, these interrupts might occur multiple times back-to-back when the interrupts are first triggered. While the counter is active, the timer will hold the state of the counter for one clock period of the timer clock before the counter gets updated. When the timer clock frequency is configured low by a high prescalerDiv parameter value, this hold time might be longer than it takes for the interrupt service routine to clear the interrupt status. This will cause a new interrupt to be immediatly generated. In order to avoid this situation, the intPhaseLate parameter value needs to be set to true. Then the interrupt will occur one timer clock cycle after the counter has reached the TARGET/ZERO value, meaning that the described hold time is reduced to 0.
| typedef struct GPTimerWFF3_ChannelConf GPTimerWFF3_ChannelConf |
GPTimerWFF3 channel dependent pin configuration struct.
GPTimer struct used by the GPTimerWFF3_HWAttrs.
| typedef struct GPTimerWFF3_HWAttrs GPTimerWFF3_HWAttrs |
GPTimerWFF3 Hardware attributes.
These fields are used by the driver to set up underlying GPTimer driver statically. A sample structure is shown below making use of channel 2 in GPTIMER1:
| typedef struct GPTimerWFF3_Object GPTimerWFF3_Object |
GPTimerWFF3 Object.
These fields are used by the driver to store and modify GPTimer configuration during run-time. The application must not edit any member variables of this structure. Appplications should also not access member variables of this structure as backwards compatibility is not guaranteed. An example structure is shown below:
| enum GPTimerWFF3_Mode |
Definitions for supported GPTimer counting modes.
Definitions for supported GPTimer interrupts. GPTimerWFF3_IntMask arguments should be a bit vector containing these definitions.
Definitions for controlling timer debug stall mode.
Definitions for which direction the timer counter must have in order to set channel compare interrupt status flag.
Definitions for supported GPTimer channel actions.
| Enumerator | |
|---|---|
| GPTimerWFF3_CH_DISABLE | Channel disabled |
| GPTimerWFF3_CH_TOGGLE_ON_COMPARE_PERIODIC | Toggle on compare repeatedly. Toggle channel output when the timer counter equals the compare value set by either GPTimerWFF3_setInitialChannelCompVal() or GPTimerWFF3_setNextChannelCompVal(). |
| GPTimerWFF3_CH_TOGGLE_ON_COMPARE_ONCE | Toggle on compare, and then disable channel. Toggle channel output when the timer counter equals the compare value set by GPTimerWFF3_setInitialChannelCompVal(). |
| GPTimerWFF3_CH_SET_ON_COMPARE_PERIODIC | Set on compare repeatedly. Set channel output when the timer counter equals the compare value set by either GPTimerWFF3_setInitialChannelCompVal() or GPTimerWFF3_setNextChannelCompVal(). |
| GPTimerWFF3_CH_SET_ON_COMPARE_ONCE | Set on compare, and then disable channel. Set channel output when the timer counter equals the compare value set by GPTimerWFF3_setInitialChannelCompVal(). |
| GPTimerWFF3_CH_CLEAR_ON_COMPARE_PERIODIC | Clear on compare repeatedly. Clear channel output when the timer counter equals the compare value set by either GPTimerWFF3_setInitialChannelCompVal() or GPTimerWFF3_setNextChannelCompVal(). |
| GPTimerWFF3_CH_CLEAR_ON_COMPARE_ONCE | Clear on compare, and then disable channel. Clear channel output when the timer counter equals the compare value set by GPTimerWFF3_setInitialChannelCompVal(). |
| GPTimerWFF3_CH_SET_ON_0_TOGGLE_ON_CMP_PERIODIC | Set on zero, toggle on compare repeatedly. Set channel output when timer counter value equals zero. Toggle channel output when the timer counter equals the compare value set by either GPTimerWFF3_setInitialChannelCompVal() or GPTimerWFF3_setNextChannelCompVal(). |
| GPTimerWFF3_CH_SET_ON_0_TOGGLE_ON_COMPARE_ONCE | Set on zero, toggle on compare, and then disable channel. Set channel output when timer counter equals zero. Toggle channel output when the timer counter equals the compare value set by GPTimerWFF3_setInitialChannelCompVal(). |
| GPTimerWFF3_CH_CLR_ON_0_TOGGLE_ON_COMPARE_PERIODIC | Clear on zero, toggle on compare repeatedly. Clear channel output when timer counter equals zero. Toggle channel output when the timer counter equals the compare value set by either GPTimerWFF3_setInitialChannelCompVal() or GPTimerWFF3_setNextChannelCompVal(). |
| GPTimerWFF3_CH_CLR_ON_0_TOGGLE_ON_COMPARE_ONCE | Clear on zero, toggle on compare, and then disable channel. Clear channel output when timer counter equals zero. Toggle channel output when the timer counter equals the compare value set by GPTimerWFF3_setInitialChannelCompVal(). |
| GPTimerWFF3_CH_PULSE_ON_COMPARE_PERIODIC | Pulse on compare repeatedly. Pulse channel output when the timer counter equals the compare value set by either GPTimerWFF3_setInitialChannelCompVal() or GPTimerWFF3_setNextChannelCompVal(). The channel output is high for two timer clock periods. |
| GPTimerWFF3_CH_PULSE_ON_COMPARE_ONCE | Pulse on compare, and then disable channel. Pulse channel output when the timer counter equals the compare value set by GPTimerWFF3_setInitialChannelCompVal(). The channel output is high for two timer clock periods. |
| GPTimerWFF3_CH_SET_ON_CAPTURE_PERIODIC | Set on capture repeatedly. The channel number dependent interrupt status flag (GPTimerWFF3_INT_CH0_CC for channel number GPTimerWFF3_CH_NO_0) will be set when the signal edge selected by the chxInputEdge element in the GPTimerWFF3_Params structure, is detected on the channel input signal. |
| GPTimerWFF3_CH_SET_ON_CAPTURE_ONCE | Set on capture, and then disable channel. The channel number dependent interrupt status flag (GPTimerWFF3_INT_CH0_CC for channel number GPTimerWFF3_CH_NO_0) will be set when the signal edge selected by the ch<x>InputEdge element in the GPTimerWFF3_Params structure, is detected on the channel input signal. |
| GPTimerWFF3_CH_PULSE_WIDTH_MEASURE | Period and pulse width measurement. Continuously capture period and pulse width of the channel input signal relative to the signal edge selected by the ch<x>InputEdge element in the GPTimerWFF3_Params structure. The channel number dependent interrupt status flag (GPTimerWFF3_INT_CH0_CC for channel number GPTimerWFF3_CH_NO_0) will be set when the signal period and pulse width have been captured. The period and pulse width are reported in numbers of counter ticks. The GPTimerWFF3_getChCompareVal() function returns the measured period and the GPTimerWFF3_getNextChCompareVal() functions returns the measured pulse width.
Signal property requirements for this channel action:
|
| void GPTimerWFF3_Params_init | ( | GPTimerWFF3_Params * | params | ) |
Function that initializes the GPTimerWFF3_Params struct to its default values.
| [in] | params | An pointer to GPTimerWFF3_Params structure for initialization |
Default values:
| Parameter | Default value |
|---|---|
| Interrupt callback fxn | NULL |
| Interrupt phase late | true |
| Prescaler division | 0 |
| Timer debug stall mode | GPTimerWFF3_DEBUG_STALL_OFF |
| Counter dir ch cmp | GPTimerWFF3_CH_COMPARE_COUNTER_DIR_BOTH |
| Channel 0 action | GPTimerWFF3_CH_DISABLE |
| Channel 0 input edge | GPTimerWFF3_CH_EDGE_NONE |
| Channel 1 action | GPTimerWFF3_CH_DISABLE |
| Channel 1 input edge | GPTimerWFF3_CH_EDGE_NONE |
| Channel 2 action | GPTimerWFF3_CH_DISABLE |
| Channel 2 input edge | GPTimerWFF3_CH_EDGE_NONE |
| Channel 3 action | GPTimerWFF3_CH_DISABLE |
| Channel 3 input edge | GPTimerWFF3_CH_EDGE_NONE |
| GPTimerWFF3_Handle GPTimerWFF3_open | ( | uint_least8_t | index, |
| const GPTimerWFF3_Params * | params | ||
| ) |
Function that opens a driver for the given GPT peripheral. Will set power dependency on timer and configure it into specified configuration.
| [in] | index | Index in the GPTimerWFF3_config table. |
| [in] | params | Pointer to a parameter block. If NULL, it will use default values. |
| void GPTimerWFF3_close | ( | GPTimerWFF3_Handle | handle | ) |
Function that closes a GPTimer driver specified by the GPTimer handle. Closing GPTimer driver will release power dependency on timer and clear configuration.
| [in] | handle | A GPTimerWFF3_Handle returned from GPTimerWFF3_open() |
| void GPTimerWFF3_start | ( | GPTimerWFF3_Handle | handle, |
| GPTimerWFF3_Mode | mode | ||
| ) |
Function that starts the timer counter of the specified GPTimer handle with current settings and specified timer counter mode.
| [in] | handle | A GPTimerWFF3_Handle returned from GPTimerWFF3_open(). |
| [in] | mode | The timer counter mode. |
| void GPTimerWFF3_stop | ( | GPTimerWFF3_Handle | handle | ) |
Function that stops the timer counter of the specified GPTimer driver.
| [in] | handle | A GPTimerWFF3_Handle returned from GPTimerWFF3_open() |
| void GPTimerWFF3_setInitialCounterTarget | ( | GPTimerWFF3_Handle | handle, |
| uint32_t | value, | ||
| bool | intFlagClr | ||
| ) |
Function that sets the initial timer counter target on the specified GPTimer. This function must be called before the timer is started.
| [in] | handle | A GPTimerWFF3_Handle returned from GPTimerWFF3_open() |
| [in] | value | Initial target value of the timer counter. Max value: GPT peripheral properties The number of counter ticks required to reach target value is value + 1. Note that if either GPTimerWFF3_CTL_MODE_UP_ONCE or GPTimerWFF3_CTL_MODE_UP_PER counter modes are used for generating a PWM signal, the signal period equals value + 1. Note that if GPTimerWFF3_CTL_MODE_UPDWN_PER counter mode is used for generating a PWM signal, the signal period equals value * 2. |
| [in] | intFlagClr | Controls if the GPTimerWFF3_INT_TGT and GPTimerWFF3_INT_ZERO interrupt status flags are cleared or not when this function is executed. |
| void GPTimerWFF3_setNextCounterTarget | ( | GPTimerWFF3_Handle | handle, |
| uint32_t | value, | ||
| bool | intFlagClr | ||
| ) |
Function that sets the timer counter target for the next counter period on the specified GPTimer. The specified target value will be valid as timer counter target on the upcoming zero crossing. When counting repeatedly upwards a zero crossing is regarded as when the timer counter restarts counting from 0. This function can be called after the timer has started. Timer counter width is 32-bits. (see GPT peripheral properties).
| [in] | handle | A GPTimerWFF3_Handle returned from GPTimerWFF3_open() |
| [in] | value | Next target value of the timer counter. Max value: GPT peripheral properties The number of counter ticks required to reach target value on the next counter period is value + 1. Note that if either GPTimerWFF3_CTL_MODE_UP_ONCE or GPTimerWFF3_CTL_MODE_UP_PER counter modes are used for generating a PWM signal, the signal period equals value + 1. Note that if GPTimerWFF3_CTL_MODE_UPDWN_PER counter mode is used for generating a PWM signal, the signal period equals value * 2. |
| [in] | intFlagClr | Controls if the GPTimerWFF3_INT_TGT and GPTimerWFF3_INT_ZERO interrupt status flags are cleared or not when this function is executed. |
| uint32_t GPTimerWFF3_getCounter | ( | GPTimerWFF3_Handle | handle | ) |
Function that returns the current timer counter value.
| [in] | handle | A GPTimerWFF3_Handle returned from GPTimerWFF3_open() |
| uintptr_t GPTimerWFF3_getArg | ( | GPTimerWFF3_Handle | handle | ) |
Function to get a custom argument.
| [in] | handle | A GPTimerWFF3_Handle returned from GPTimerWFF3_open() |
| void GPTimerWFF3_setArg | ( | GPTimerWFF3_Handle | handle, |
| uintptr_t | arg | ||
| ) |
Function to set a custom argument.
| [in] | handle | A GPTimerWFF3_Handle returned from GPTimerWFF3_open() |
| [in] | arg | Custom argument |
| void GPTimerWFF3_enableInterrupt | ( | GPTimerWFF3_Handle | handle, |
| GPTimerWFF3_IntMask | intMask | ||
| ) |
Enable interrupt source for the GPTimer handle.
| [in] | handle | A GPTimerWFF3_Handle returned from GPTimerWFF3_open() |
| [in] | intMask | A bit mask of interrupt flags to enable |
| void GPTimerWFF3_disableInterrupt | ( | GPTimerWFF3_Handle | handle, |
| GPTimerWFF3_IntMask | intMask | ||
| ) |
Disable interrupt source for the GPTimer handle.
| [in] | handle | A GPTimerWFF3_Handle returned from GPTimerWFF3_open() |
| [in] | intMask | A bit mask of interrupt flags to disable |
| void GPTimerWFF3_setInitialChannelCompVal | ( | GPTimerWFF3_Handle | handle, |
| GPTimerWFF3_ChannelNo | chNo, | ||
| uint32_t | value, | ||
| bool | intFlagClr | ||
| ) |
Function that sets the initial channel compare value on the specified GPTimer and channel. The compare value for the specified channel will be used by any compare type channel action GPTimerWFF3_ChannelAction specified by the GPTimer params. The channel number dependent interrupt status flag (GPTimerWFF3_INT_CH0_CC for channel number GPTimerWFF3_CH_NO_0) will be set when the timer counter equals the channel compare value. This function must be called prior to GPTimerWFF3_start(). Timer compare value width is 32 bits (see GPT peripheral properties).
| [in] | handle | A GPTimerWFF3_Handle returned from GPTimerWFF3_open() |
| [in] | chNo | Channel number |
| [in] | value | Channel compare value for specified channel number |
| [in] | intFlagClr | Controls if the channel number dependent compare/capture interrupt status flag is cleared or not when this function is executed. |
| void GPTimerWFF3_setNextChannelCompVal | ( | GPTimerWFF3_Handle | handle, |
| GPTimerWFF3_ChannelNo | chNo, | ||
| uint32_t | value, | ||
| bool | intFlagClr | ||
| ) |
Function that sets the channel compare value on the specified GPTimer for the next cycle of the already started timer counter. The compare value for the specified channel is valid for any compare type channel action GPTimerWFF3_ChannelAction specified by the GPTimer params. The channel number dependent interrupt status flag (GPTimerWFF3_INT_CH0_CC for channel number GPTimerWFF3_CH_NO_0) will be set when the timer counter equals the channel compare value in the next and following timer counter cycles. This function can be called while the timer is active.
| [in] | handle | A GPTimerWFF3_Handle returned from GPTimerWFF3_open() |
| [in] | chNo | Channel number |
| [in] | value | Channel compare value for specified channel number. Width value is 32 bits (see GPT peripheral properties). |
| [in] | intFlagClr | Controls if the channel number dependent compare/capture interrupt status flag is cleared or not when this function is executed. |
| void GPTimerWFF3_setChannelOutputLevel | ( | GPTimerWFF3_Handle | handle, |
| GPTimerWFF3_ChannelNo | chNo, | ||
| GPTimerWFF3_ChannelLevel | level | ||
| ) |
Function that manually sets the current channel output level high or low. Manual update of a channel output takes priority over automatic channel updates to the same output when occurring at the same time. The complementary channel output will be set to the complementary level of the specified level.
| [in] | handle | A GPTimerWFF3_Handle returned from GPTimerWFF3_open() |
| [in] | chNo | Channel number |
| [in] | level | Channel level for specified channel number |
| uint32_t GPTimerWFF3_getChCompareVal | ( | GPTimerWFF3_Handle | handle, |
| GPTimerWFF3_ChannelNo | chNo | ||
| ) |
Function to get the channel compare value or channel-updated capture value. Dependent on the selected channel action for the specified channel, the function will return either the current channel compare value or the channel-updated capture value. The channel-updated capture value is returned if a successful channel capture event, as specified by the channel action, has occured on the specified channel. For a channel action of GPTimerWFF3_CH_PULSE_WIDTH_MEASURE, the returned value after a successful channel capture event, represents the measured period of the selected channel input signal.
| [in] | handle | A GPTimerWFF3_Handle returned from GPTimerWFF3_open() |
| [in] | chNo | Channel number |
| uint32_t GPTimerWFF3_getChCaptureVal | ( | GPTimerWFF3_Handle | handle, |
| GPTimerWFF3_ChannelNo | chNo | ||
| ) |
Function to get the channel compare value or channel-updated capture value. Dependent on the selected channel action for the specified channel, the function will return either the current channel compare value or the channel-updated capture value. The channel-updated capture value is returned if a successful channel capture event, as specified by the channel action, has occured on the specified channel. For a channel action of GPTimerWFF3_CH_PULSE_WIDTH_MEASURE, the returned value after a successful channel capture event, represents the measured period of the selected channel input signal.
| [in] | handle | A GPTimerWFF3_Handle returned from GPTimerWFF3_open() |
| [in] | chNo | Channel number |
| uint32_t GPTimerWFF3_getNextChCompareVal | ( | GPTimerWFF3_Handle | handle, |
| GPTimerWFF3_ChannelNo | chNo | ||
| ) |
Function to get the channel compare value for the next counter cycle or the channel-updated capture value. Dependent on the selected channel action for the specified channel, the function will return either the channel compare value for the next counter cycle or the channel-updated capture value. For a channel action mode of GPTimerWFF3_CH_PULSE_WIDTH_MEASURE, the returned value after a successful capture event will be the width of the low or high phase of the selected channel input signal. The phase is specified by GPTimerWFF3_ChannelInputEdge parameter for the selected channel. In order to get the channel-updated capture value for other capture channel actions than GPTimerWFF3_CH_PULSE_WIDTH_MEASURE, the function GPTimerWFF3_getChCompareVal should be used.
| [in] | handle | A GPTimerWFF3_Handle returned from GPTimerWFF3_open() |
| [in] | chNo | Channel number |
| uint32_t GPTimerWFF3_getNextChCaptureVal | ( | GPTimerWFF3_Handle | handle, |
| GPTimerWFF3_ChannelNo | chNo | ||
| ) |
Function to get the channel compare value for the next counter cycle or the channel-updated capture value. Dependent on the selected channel action for the specified channel, the function will return either the channel compare value for the next counter cycle or the channel-updated capture value. For a channel action mode of GPTimerWFF3_CH_PULSE_WIDTH_MEASURE, the returned value after a successful capture event will be the width of the low or high phase of the selected channel input signal. The phase is specified by GPTimerWFF3_ChannelInputEdge parameter for the selected channel. In order to get the channel-updated capture value for other capture channel actions than GPTimerWFF3_CH_PULSE_WIDTH_MEASURE, the function GPTimerWFF3_getChCompareVal() should be used.
| [in] | handle | A GPTimerWFF3_Handle returned from GPTimerWFF3_open() |
| [in] | chNo | Channel number |
| uint32_t GPTimerWFF3_getCounterWidth | ( | GPTimerWFF3_Handle | handle | ) |
Function to get the width of the timer counter in number of bits.
| [in] | handle | A GPTimerWFF3_Handle returned from GPTimerWFF3_open() |