LGPTimer driver implementation for Low Power F3 devices.
The LGPTimer 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 of IO signals muxable to the three channels of each LGPT peripheral instance. The channel capture functionality can be used to measure period and dutcy cycle of an input signal. The channel compare functionality can be used for generating PWM signals.
The LGPTimer driver also handles the general purpose timer resource allocation. For each driver that requires use of a general purpose timer, it calls LGPTimerLPF3_open() to occupy the specified timer, and calls LGPTimerLPF3_close() to release the occupied timer resource.
The LGPT peripherals support different timer counter widths depending on the peripheral instance number (LGPT0, LGPT1, ..). 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 high frequency clock (CLKSVT) 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 | LGPT0 | LGPT1 | LGPT2 | LGPT3 |
---|---|---|---|---|
CC2340R2 | 16 bits | 16 bits | N.A | N.A |
CC2340R5 | 16 bits | 16 bits | 16 bits | 24 bits |
CC27X5 | 16 bits | 16 bits | 16 bits | 24 bits |
The LGPTimer 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 LGPTimer 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 LGPT peripheral is dependent on the high frequency clock (CLKSVT).
This documentation provides some basic examples in the form of commented code fragments.
The code example below will generate an interrupt using the LGPTimer 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 1500 counter ticks when the counter has a 48 MHz clock.
Opening a LGPTimerLPF3 requires four steps:
Refer to the Driver's Configuration section for driver configuration information.
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#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_lgpt.h)>
Go to the source code of this file.
Data Structures | |
struct | LGPTimerLPF3_ChannelProp |
LGPTimerLPF3 channel dependent properties struct. More... | |
struct | LGPTimerLPF3_Params |
LGPTimerLPF3 Parameters. More... | |
struct | LGPTimerLPF3_ChannelConf |
LGPTimerLPF3 channel dependent pin configuration struct. More... | |
struct | LGPTimerLPF3_HWAttrs |
LGPTimerLPF3 Hardware attributes. More... | |
struct | LGPTimerLPF3_Object |
LGPTimerLPF3 Object. More... | |
struct | LGPTimerLPF3_Config |
LGPTimer Global configuration. More... | |
Macros | |
#define | NO_OF_LGPT_CHANNELS 3 |
Typedefs | |
typedef struct LGPTimerLPF3_Config | LGPTimerLPF3_Config |
typedef LGPTimerLPF3_Config * | LGPTimerLPF3_Handle |
typedef uint16_t | LGPTimerLPF3_IntMask |
typedef void(* | LGPTimerLPF3_HwiFxn) (LGPTimerLPF3_Handle handle, LGPTimerLPF3_IntMask interruptMask) |
The definition of a callback function used by the LGPTimer driver. More... | |
typedef struct LGPTimerLPF3_ChannelProp | LGPTimerLPF3_ChannelProp |
LGPTimerLPF3 channel dependent properties struct. More... | |
typedef struct LGPTimerLPF3_Params | LGPTimerLPF3_Params |
LGPTimerLPF3 Parameters. More... | |
typedef struct LGPTimerLPF3_ChannelConf | LGPTimerLPF3_ChannelConf |
LGPTimerLPF3 channel dependent pin configuration struct. More... | |
typedef struct LGPTimerLPF3_HWAttrs | LGPTimerLPF3_HWAttrs |
LGPTimerLPF3 Hardware attributes. More... | |
typedef struct LGPTimerLPF3_Object | LGPTimerLPF3_Object |
LGPTimerLPF3 Object. More... | |
Enumerations | |
enum | LGPTimerLPF3_ChannelNo { LGPTimerLPF3_CH_NO_0 = 0, LGPTimerLPF3_CH_NO_1 = 1, LGPTimerLPF3_CH_NO_2 = 2 } |
Definitions for supported LGPTimer channel numbers. More... | |
enum | LGPTimerLPF3_ChannelDir { LGPTimerLPF3_CH_DIR_NONE = 0, LGPTimerLPF3_CH_DIR_INPUT = 1, LGPTimerLPF3_CH_DIR_OUTPUT = 2 } |
Definitions for supported LGPTimer channel direction. More... | |
enum | LGPTimerLPF3_ChannelLevel { LGPTimerLPF3_CH_LEVEL_LOW = LGPT_OUTCTL_CLROUT0, LGPTimerLPF3_CH_LEVEL_HIGH = LGPT_OUTCTL_SETOUT0 } |
Definitions for supported LGPTimer channel output levels. More... | |
enum | LGPTimerLPF3_ChannelInputEdge { LGPTimerLPF3_CH_EDGE_NONE = LGPT_C0CFG_EDGE_NONE, LGPTimerLPF3_CH_EDGE_RISE = LGPT_C0CFG_EDGE_RISE, LGPTimerLPF3_CH_EDGE_FALL = LGPT_C0CFG_EDGE_FALL, LGPTimerLPF3_CH_EDGE_BOTH = LGPT_C0CFG_EDGE_BOTH } |
Definitions for supported LGPTimer channel input edge. More... | |
enum | LGPTimerLPF3_Mode { LGPTimerLPF3_CTL_MODE_DIS = LGPT_CTL_MODE_DIS, LGPTimerLPF3_CTL_MODE_UP_ONCE = LGPT_CTL_MODE_UP_ONCE, LGPTimerLPF3_CTL_MODE_UP_PER = LGPT_CTL_MODE_UP_PER, LGPTimerLPF3_CTL_MODE_UPDWN_PER = LGPT_CTL_MODE_UPDWN_PER } |
Definitions for supported LGPTimer counting modes. More... | |
enum | LGPTimerLPF3_Interrupt { LGPTimerLPF3_INT_TGT = 1 << LGPT_RIS_TGT_S, LGPTimerLPF3_INT_ZERO = 1 << LGPT_RIS_ZERO_S, LGPTimerLPF3_INT_COUNTER_CHANGE = 1 << LGPT_RIS_CNTRCHNG_S, LGPTimerLPF3_INT_DIR_CHANGE = 1 << LGPT_RIS_DIRCHNG_S, LGPTimerLPF3_INT_CH0_CC = 1 << LGPT_RIS_C0CC_S, LGPTimerLPF3_INT_CH1_CC = 1 << LGPT_RIS_C1CC_S, LGPTimerLPF3_INT_CH2_CC = 1 << LGPT_RIS_C2CC_S } |
Definitions for supported LGPTimer interrupts. LGPTimerLPF3_IntMask arguments should be a bit vector containing these definitions. More... | |
enum | LGPTimerLPF3_DebugMode { LGPTimerLPF3_DEBUG_STALL_OFF = LGPT_EMU_HALT_DIS, LGPTimerLPF3_DEBUG_STALL_IMMEDIATE = (LGPT_EMU_HALT_EN | LGPT_EMU_CTL_IMMEDIATE), LGPTimerLPF3_DEBUG_STALL_ON_ZERO = (LGPT_EMU_HALT_EN | LGPT_EMU_CTL_ZERCOND) } |
Definitions for controlling timer debug stall mode. More... | |
enum | LGPTimerLPF3_ChannelCmpDir { LGPTimerLPF3_CH_COMPARE_COUNTER_DIR_BOTH = LGPT_CTL_CMPDIR_BOTH, LGPTimerLPF3_CH_COMPARE_COUNTER_DIR_UP = LGPT_CTL_CMPDIR_UP, LGPTimerLPF3_CH_COMPARE_COUNTER_DIR_DOWN = LGPT_CTL_CMPDIR_DOWN } |
Definitions for which direction the timer counter must have in order to set channel compare interrupt status flag. More... | |
enum | LGPTimerLPF3_ChannelAction { LGPTimerLPF3_CH_DISABLE = LGPT_C1CFG_CCACT_DIS, LGPTimerLPF3_CH_TOGGLE_ON_COMPARE_PERIODIC = LGPT_C0CFG_CCACT_TGL_ON_CMP, LGPTimerLPF3_CH_TOGGLE_ON_COMPARE_ONCE = LGPT_C0CFG_CCACT_TGL_ON_CMP_DIS, LGPTimerLPF3_CH_SET_ON_COMPARE_PERIODIC = LGPT_C0CFG_CCACT_SET_ON_CMP, LGPTimerLPF3_CH_SET_ON_COMPARE_ONCE = LGPT_C0CFG_CCACT_SET_ON_CMP_DIS, LGPTimerLPF3_CH_CLEAR_ON_COMPARE_PERIODIC = LGPT_C0CFG_CCACT_CLR_ON_CMP, LGPTimerLPF3_CH_CLEAR_ON_COMPARE_ONCE = LGPT_C0CFG_CCACT_CLR_ON_CMP_DIS, LGPTimerLPF3_CH_SET_ON_0_TOGGLE_ON_CMP_PERIODIC = LGPT_C0CFG_CCACT_SET_ON_0_TGL_ON_CMP, LGPTimerLPF3_CH_SET_ON_0_TOGGLE_ON_COMPARE_ONCE = LGPT_C0CFG_CCACT_SET_ON_0_TGL_ON_CMP_DIS, LGPTimerLPF3_CH_CLR_ON_0_TOGGLE_ON_COMPARE_PERIODIC = LGPT_C0CFG_CCACT_CLR_ON_0_TGL_ON_CMP, LGPTimerLPF3_CH_CLR_ON_0_TOGGLE_ON_COMPARE_ONCE = LGPT_C0CFG_CCACT_CLR_ON_0_TGL_ON_CMP_DIS, LGPTimerLPF3_CH_PULSE_ON_COMPARE_PERIODIC = LGPT_C0CFG_CCACT_PULSE_ON_CMP, LGPTimerLPF3_CH_PULSE_ON_COMPARE_ONCE = LGPT_C0CFG_CCACT_PULSE_ON_CMP_DIS, LGPTimerLPF3_CH_SET_ON_CAPTURE_PERIODIC = LGPT_C0CFG_CCACT_SET_ON_CAPT, LGPTimerLPF3_CH_SET_ON_CAPTURE_ONCE = LGPT_C0CFG_CCACT_SET_ON_CAPT_DIS, LGPTimerLPF3_CH_PULSE_WIDTH_MEASURE = LGPT_C0CFG_CCACT_PER_PULSE_WIDTH_MEAS } |
Definitions for supported LGPTimer channel actions. More... | |
Functions | |
void | LGPTimerLPF3_Params_init (LGPTimerLPF3_Params *params) |
Function that initializes the LGPTimerLPF3_Params struct to its default values. More... | |
LGPTimerLPF3_Handle | LGPTimerLPF3_open (uint_least8_t index, const LGPTimerLPF3_Params *params) |
Function that opens a driver for the given LGPT peripheral. Will set power dependency on timer and configure it into specified configuration. More... | |
void | LGPTimerLPF3_close (LGPTimerLPF3_Handle handle) |
Function that closes a LGPTimer driver specified by the LGPTimer handle. Closing LGPTimer driver will release power dependency on timer and clear configuration. More... | |
void | LGPTimerLPF3_start (LGPTimerLPF3_Handle handle, LGPTimerLPF3_Mode mode) |
Function that starts the timer counter of the specified LGPTimer handle with current settings and specified timer counter mode. More... | |
void | LGPTimerLPF3_stop (LGPTimerLPF3_Handle handle) |
Function that stops the timer counter of the specified LGPTimer driver. More... | |
void | LGPTimerLPF3_setInitialCounterTarget (LGPTimerLPF3_Handle handle, uint32_t value, bool intFlagClr) |
Function that sets the initial timer counter target on the specified LGPTimer. This function must be called before the timer is started. Timer counter width (16 or 24 bits) depends on selected peripheral instance. More... | |
void | LGPTimerLPF3_setNextCounterTarget (LGPTimerLPF3_Handle handle, uint32_t value, bool intFlagClr) |
Function that sets the timer counter target for the next counter period on the specified LGPTimer. 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 (16 or 24 bits) depends on selected peripheral instance. More... | |
uint32_t | LGPTimerLPF3_getCounter (LGPTimerLPF3_Handle handle) |
Function that returns the current timer counter value. More... | |
uint32_t | LGPTimerLPF3_getArg (LGPTimerLPF3_Handle handle) |
Function to get a custom argument. More... | |
void | LGPTimerLPF3_setArg (LGPTimerLPF3_Handle handle, void *arg) |
Function to set a custom argument. More... | |
void | LGPTimerLPF3_enableInterrupt (LGPTimerLPF3_Handle handle, LGPTimerLPF3_IntMask intMask) |
Enable interrupt source for the LGPTimer handle. More... | |
void | LGPTimerLPF3_disableInterrupt (LGPTimerLPF3_Handle handle, LGPTimerLPF3_IntMask intMask) |
Disable interrupt source for the LGPTimer handle. More... | |
void | LGPTimerLPF3_setInitialChannelCompVal (LGPTimerLPF3_Handle handle, LGPTimerLPF3_ChannelNo chNo, uint32_t value, bool intFlagClr) |
Function that sets the initial channel compare value on the specified LGPTimer and channel. The compare value for the specified channel will be used by any compare type channel action LGPTimerLPF3_ChannelAction specified by the LGPTimer params. The channel number dependent interrupt status flag (LGPTimerLPF3_INT_CH0_CC for channel number LGPTimerLPF3_CH_NO_0) will be set when the timer counter equals the channel compare value. This function must be called prior to LGPTimerLPF3_start(). Timer compare value width (16 or 24 bits) depends on selected peripheral instance. More... | |
void | LGPTimerLPF3_setNextChannelCompVal (LGPTimerLPF3_Handle handle, LGPTimerLPF3_ChannelNo chNo, uint32_t value, bool intFlagClr) |
Function that sets the channel compare value on the specified LGPTimer 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 LGPTimerLPF3_ChannelAction specified by the LGPTimer params. The channel number dependent interrupt status flag (LGPTimerLPF3_INT_CH0_CC for channel number LGPTimerLPF3_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 | LGPTimerLPF3_setChannelOutputLevel (LGPTimerLPF3_Handle handle, LGPTimerLPF3_ChannelNo chNo, LGPTimerLPF3_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 | LGPTimerLPF3_getChCompareVal (LGPTimerLPF3_Handle handle, LGPTimerLPF3_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 LGPTimerLPF3_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 | LGPTimerLPF3_getChCaptureVal (LGPTimerLPF3_Handle handle, LGPTimerLPF3_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 LGPTimerLPF3_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 | LGPTimerLPF3_getNextChCompareVal (LGPTimerLPF3_Handle handle, LGPTimerLPF3_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 LGPTimerLPF3_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 LGPTimerLPF3_ChannelInputEdge parameter for the selected channel. In order to get the channel-updated capture value for other capture channel actions than LGPTimerLPF3_CH_PULSE_WIDTH_MEASURE, the function LGPTimerLPF3_getChCompareVal should be used. More... | |
uint32_t | LGPTimerLPF3_getNextChCaptureVal (LGPTimerLPF3_Handle handle, LGPTimerLPF3_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 LGPTimerLPF3_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 LGPTimerLPF3_ChannelInputEdge parameter for the selected channel. In order to get the channel-updated capture value for other capture channel actions than LGPTimerLPF3_CH_PULSE_WIDTH_MEASURE, the function LGPTimerLPF3_getChCompareVal should be used. More... | |
uint32_t | LGPTimerLPF3_getCounterWidth (LGPTimerLPF3_Handle handle) |
Function to get the width of the timer counter in number of bits. More... | |
#define NO_OF_LGPT_CHANNELS 3 |
typedef struct LGPTimerLPF3_Config LGPTimerLPF3_Config |
typedef LGPTimerLPF3_Config* LGPTimerLPF3_Handle |
typedef uint16_t LGPTimerLPF3_IntMask |
typedef void(* LGPTimerLPF3_HwiFxn) (LGPTimerLPF3_Handle handle, LGPTimerLPF3_IntMask interruptMask) |
The definition of a callback function used by the LGPTimer driver.
[in] | handle | A LGPTimer handle |
[in] | interruptMask | LGPTimer interrupt mask |
typedef struct LGPTimerLPF3_ChannelProp LGPTimerLPF3_ChannelProp |
LGPTimerLPF3 channel dependent properties struct.
LGPTimer struct used by the LGPTimerLPF3_Params.
typedef struct LGPTimerLPF3_Params LGPTimerLPF3_Params |
LGPTimerLPF3 Parameters.
LGPTimer parameters are used by the LGPTimerLPF3_open() call. Default values for these parameters are set using LGPTimerLPF3_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 LGPTimerLPF3_INT_TGT or LGPTimerLPF3_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 LGPTimerLPF3_ChannelConf LGPTimerLPF3_ChannelConf |
LGPTimerLPF3 channel dependent pin configuration struct.
LGPTimer struct used by the LGPTimerLPF3_HWAttrs.
typedef struct LGPTimerLPF3_HWAttrs LGPTimerLPF3_HWAttrs |
LGPTimerLPF3 Hardware attributes.
These fields are used by the driver to set up underlying LGPTimer driver statically. A sample structure is shown below:
typedef struct LGPTimerLPF3_Object LGPTimerLPF3_Object |
LGPTimerLPF3 Object.
These fields are used by the driver to store and modify LGPTimer 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 LGPTimerLPF3_Mode |
Definitions for supported LGPTimer counting modes.
Definitions for supported LGPTimer interrupts. LGPTimerLPF3_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 LGPTimer channel actions.
Enumerator | |
---|---|
LGPTimerLPF3_CH_DISABLE | Channel disabled |
LGPTimerLPF3_CH_TOGGLE_ON_COMPARE_PERIODIC | Toggle on compare repeatedly. Toggle channel output when the timer counter equals the compare value set by either LGPTimerLPF3_setInitialChannelCompVal() or LGPTimerLPF3_setNextChannelCompVal(). |
LGPTimerLPF3_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 LGPTimerLPF3_setInitialChannelCompVal(). |
LGPTimerLPF3_CH_SET_ON_COMPARE_PERIODIC | Set on compare repeatedly. Set channel output when the timer counter equals the compare value set by either LGPTimerLPF3_setInitialChannelCompVal() or LGPTimerLPF3_setNextChannelCompVal(). |
LGPTimerLPF3_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 LGPTimerLPF3_setInitialChannelCompVal(). |
LGPTimerLPF3_CH_CLEAR_ON_COMPARE_PERIODIC | Clear on compare repeatedly. Clear channel output when the timer counter equals the compare value set by either LGPTimerLPF3_setInitialChannelCompVal() or LGPTimerLPF3_setNextChannelCompVal(). |
LGPTimerLPF3_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 LGPTimerLPF3_setInitialChannelCompVal(). |
LGPTimerLPF3_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 LGPTimerLPF3_setInitialChannelCompVal() or LGPTimerLPF3_setNextChannelCompVal(). |
LGPTimerLPF3_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 LGPTimerLPF3_setInitialChannelCompVal(). |
LGPTimerLPF3_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 LGPTimerLPF3_setInitialChannelCompVal() or LGPTimerLPF3_setNextChannelCompVal(). |
LGPTimerLPF3_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 LGPTimerLPF3_setInitialChannelCompVal(). |
LGPTimerLPF3_CH_PULSE_ON_COMPARE_PERIODIC | Pulse on compare repeatedly. Pulse channel output when the timer counter equals the compare value set by either LGPTimerLPF3_setInitialChannelCompVal() or LGPTimerLPF3_setNextChannelCompVal(). The channel output is high for two timer clock periods. |
LGPTimerLPF3_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 LGPTimerLPF3_setInitialChannelCompVal(). The channel output is high for two timer clock periods. |
LGPTimerLPF3_CH_SET_ON_CAPTURE_PERIODIC | Set on capture repeatedly. The channel number dependent interrupt status flag (LGPTimerLPF3_INT_CH0_CC for channel number LGPTimerLPF3_CH_NO_0) will be set when the signal edge selected by the ch<x>InputEdge element in the LGPTimerLPF3_Params structure, is detected on the channel input signal. |
LGPTimerLPF3_CH_SET_ON_CAPTURE_ONCE | Set on capture, and then disable channel. The channel number dependent interrupt status flag (LGPTimerLPF3_INT_CH0_CC for channel number LGPTimerLPF3_CH_NO_0) will be set when the signal edge selected by the ch<x>InputEdge element in the LGPTimerLPF3_Params structure, is detected on the channel input signal. |
LGPTimerLPF3_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 LGPTimerLPF3_Params structure. The channel number dependent interrupt status flag (LGPTimerLPF3_INT_CH0_CC for channel number LGPTimerLPF3_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 LGPTimerLPF3_getChCompareVal() function returns the measured period and the LGPTimerLPF3_getNextChCompareVal() functions returns the measured pulse width.
Signal property requirements for this channel action:
|
void LGPTimerLPF3_Params_init | ( | LGPTimerLPF3_Params * | params | ) |
Function that initializes the LGPTimerLPF3_Params struct to its default values.
[in] | params | An pointer to LGPTimerLPF3_Params structure for initialization |
Default values are: Interrupt callback fxn: NULL, Interrupt phase late : true, Prescaler division : 0, Timer debug stall mode: LGPTimerLPF3_DEBUG_STALL_OFF, Counter dir ch cmp : LGPTimerLPF3_CH_COMPARE_COUNTER_DIR_BOTH, Channel 0 action : LGPTimerLPF3_CH_DISABLE, Channel 0 input edge : LGPTimerLPF3_CH_EDGE_NONE, Channel 1 action : LGPTimerLPF3_CH_DISABLE, Channel 1 input edge : LGPTimerLPF3_CH_EDGE_NONE, Channel 2 action : LGPTimerLPF3_CH_DISABLE, Channel 2 input edge : LGPTimerLPF3_CH_EDGE_NONE
LGPTimerLPF3_Handle LGPTimerLPF3_open | ( | uint_least8_t | index, |
const LGPTimerLPF3_Params * | params | ||
) |
Function that opens a driver for the given LGPT peripheral. Will set power dependency on timer and configure it into specified configuration.
[in] | index | Index in the LGPTimerLPF3_config table. |
[in] | params | Pointer to a parameter block. If NULL, it will use default values. |
void LGPTimerLPF3_close | ( | LGPTimerLPF3_Handle | handle | ) |
Function that closes a LGPTimer driver specified by the LGPTimer handle. Closing LGPTimer driver will release power dependency on timer and clear configuration.
[in] | handle | A LGPTimerLPF3 handle returned from LGPTimerLPF3_open() |
void LGPTimerLPF3_start | ( | LGPTimerLPF3_Handle | handle, |
LGPTimerLPF3_Mode | mode | ||
) |
Function that starts the timer counter of the specified LGPTimer handle with current settings and specified timer counter mode.
[in] | handle | A LGPTimerLPF3 handle returned from LGPTimerLPF3_open(). |
[in] | mode | The timer counter mode. |
void LGPTimerLPF3_stop | ( | LGPTimerLPF3_Handle | handle | ) |
Function that stops the timer counter of the specified LGPTimer driver.
[in] | handle | A LGPTimerLPF3 handle returned from LGPTimerLPF3_open() |
void LGPTimerLPF3_setInitialCounterTarget | ( | LGPTimerLPF3_Handle | handle, |
uint32_t | value, | ||
bool | intFlagClr | ||
) |
Function that sets the initial timer counter target on the specified LGPTimer. This function must be called before the timer is started. Timer counter width (16 or 24 bits) depends on selected peripheral instance.
[in] | handle | A LGPTimerLPF3 handle returned from LGPTimerLPF3_open |
[in] | value | Initial target value of the timer counter. Max value: LGPT peripheral properties The number of counter ticks required to reach target value is value + 1. Note that if either LGPTimerLPF3_CTL_MODE_UP_ONCE or LGPTimerLPF3_CTL_MODE_UP_PER counter modes are used for generating a PWM signal, the signal period equals value + 1. Note that if LGPTimerLPF3_CTL_MODE_UPDWN_PER counter mode is used for generating a PWM signal, the signal period equals value * 2. |
[in] | intFlagClr | Controls if the LGPTimerLPF3_INT_TGT and LGPTimerLPF3_INT_ZERO interrupt status flags are cleared or not when this function is executed. |
void LGPTimerLPF3_setNextCounterTarget | ( | LGPTimerLPF3_Handle | handle, |
uint32_t | value, | ||
bool | intFlagClr | ||
) |
Function that sets the timer counter target for the next counter period on the specified LGPTimer. 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 (16 or 24 bits) depends on selected peripheral instance.
[in] | handle | A LGPTimerLPF3 handle returned from LGPTimerLPF3_open |
[in] | value | Next target value of the timer counter. Max value Max value: LGPT peripheral properties" The number of counter ticks required to reach target value on the next counter period is value + 1. Note that if either LGPTimerLPF3_CTL_MODE_UP_ONCE or LGPTimerLPF3_CTL_MODE_UP_PER counter modes are used for generating a PWM signal, the signal period equals value + 1. Note that if LGPTimerLPF3_CTL_MODE_UPDWN_PER counter mode is used for generating a PWM signal, the signal period equals value * 2. |
[in] | intFlagClr | Controls if the LGPTimerLPF3_INT_TGT and LGPTimerLPF3_INT_ZERO interrupt status flags are cleared or not when this function is executed. |
uint32_t LGPTimerLPF3_getCounter | ( | LGPTimerLPF3_Handle | handle | ) |
Function that returns the current timer counter value.
[in] | handle | A LGPTimerLPF3 handle returned from LGPTimerLPF3_open |
uint32_t LGPTimerLPF3_getArg | ( | LGPTimerLPF3_Handle | handle | ) |
Function to get a custom argument.
[in] | handle | A LGPTimerLPF3 handle returned from LGPTimerLPF3_open |
void LGPTimerLPF3_setArg | ( | LGPTimerLPF3_Handle | handle, |
void * | arg | ||
) |
Function to set a custom argument.
[in] | handle | A LGPTimerLPF3 handle returned from LGPTimerLPF3_open |
[in] | arg | Pointer to a custom argument |
void LGPTimerLPF3_enableInterrupt | ( | LGPTimerLPF3_Handle | handle, |
LGPTimerLPF3_IntMask | intMask | ||
) |
Enable interrupt source for the LGPTimer handle.
[in] | handle | A LGPTimerLPF3 handle returned from LGPTimerLPF3_open |
[in] | intMask | A bit mask of interrupt flags to enable |
void LGPTimerLPF3_disableInterrupt | ( | LGPTimerLPF3_Handle | handle, |
LGPTimerLPF3_IntMask | intMask | ||
) |
Disable interrupt source for the LGPTimer handle.
[in] | handle | A LGPTimerLPF3 handle returned from LGPTimerLPF3_open |
[in] | intMask | A bit mask of interrupt flags to disable |
void LGPTimerLPF3_setInitialChannelCompVal | ( | LGPTimerLPF3_Handle | handle, |
LGPTimerLPF3_ChannelNo | chNo, | ||
uint32_t | value, | ||
bool | intFlagClr | ||
) |
Function that sets the initial channel compare value on the specified LGPTimer and channel. The compare value for the specified channel will be used by any compare type channel action LGPTimerLPF3_ChannelAction specified by the LGPTimer params. The channel number dependent interrupt status flag (LGPTimerLPF3_INT_CH0_CC for channel number LGPTimerLPF3_CH_NO_0) will be set when the timer counter equals the channel compare value. This function must be called prior to LGPTimerLPF3_start(). Timer compare value width (16 or 24 bits) depends on selected peripheral instance.
[in] | handle | A LGPTimerLPF3 handle returned from LGPTimerLPF3_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 LGPTimerLPF3_setNextChannelCompVal | ( | LGPTimerLPF3_Handle | handle, |
LGPTimerLPF3_ChannelNo | chNo, | ||
uint32_t | value, | ||
bool | intFlagClr | ||
) |
Function that sets the channel compare value on the specified LGPTimer 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 LGPTimerLPF3_ChannelAction specified by the LGPTimer params. The channel number dependent interrupt status flag (LGPTimerLPF3_INT_CH0_CC for channel number LGPTimerLPF3_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 LGPTimerLPF3 handle returned from LGPTimerLPF3_open |
[in] | chNo | Channel number |
[in] | value | Channel compare value for specified channel number. Width (16 or 24 bits) of value depends on selected peripheral instance. |
[in] | intFlagClr | Controls if the channel number dependent compare/capture interrupt status flag is cleared or not when this function is executed. |
void LGPTimerLPF3_setChannelOutputLevel | ( | LGPTimerLPF3_Handle | handle, |
LGPTimerLPF3_ChannelNo | chNo, | ||
LGPTimerLPF3_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 LGPTimerLPF3 handle returned from LGPTimerLPF3_open |
[in] | chNo | Channel number |
[in] | level | Channel level for specified channel number |
uint32_t LGPTimerLPF3_getChCompareVal | ( | LGPTimerLPF3_Handle | handle, |
LGPTimerLPF3_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 LGPTimerLPF3_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 LGPTimerLPF3 handle returned from LGPTimerLPF3_open |
[in] | chNo | Channel number |
uint32_t LGPTimerLPF3_getChCaptureVal | ( | LGPTimerLPF3_Handle | handle, |
LGPTimerLPF3_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 LGPTimerLPF3_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 LGPTimerLPF3 handle returned from LGPTimerLPF3_open |
[in] | chNo | Channel number |
uint32_t LGPTimerLPF3_getNextChCompareVal | ( | LGPTimerLPF3_Handle | handle, |
LGPTimerLPF3_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 LGPTimerLPF3_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 LGPTimerLPF3_ChannelInputEdge parameter for the selected channel. In order to get the channel-updated capture value for other capture channel actions than LGPTimerLPF3_CH_PULSE_WIDTH_MEASURE, the function LGPTimerLPF3_getChCompareVal should be used.
[in] | handle | A LGPTimerLPF3 handle returned from LGPTimerLPF3_open |
[in] | chNo | Channel number |
uint32_t LGPTimerLPF3_getNextChCaptureVal | ( | LGPTimerLPF3_Handle | handle, |
LGPTimerLPF3_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 LGPTimerLPF3_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 LGPTimerLPF3_ChannelInputEdge parameter for the selected channel. In order to get the channel-updated capture value for other capture channel actions than LGPTimerLPF3_CH_PULSE_WIDTH_MEASURE, the function LGPTimerLPF3_getChCompareVal should be used.
[in] | handle | A LGPTimerLPF3 handle returned from LGPTimerLPF3_open |
[in] | chNo | Channel number |
uint32_t LGPTimerLPF3_getCounterWidth | ( | LGPTimerLPF3_Handle | handle | ) |
Function to get the width of the timer counter in number of bits.
[in] | handle | A LGPTimerLPF3 handle returned from LGPTimerLPF3_open |