Actions

EmSys

Tm4clib-gptm-functions

From EdWiki

Revision as of 05:48, 27 December 2018 by Jshankar (Talk | contribs) (gptm_get_value())

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

GPTM API Functions

gptm_enable()

Enables the timer(s).

Prototype:
void gptm_enable(uint32_t ui32Base, uint32_t ui32Timer)
Parameters:
ui32Base is the base address of the timer module.
ui32Timer specifies the timer(s) to enable; must be one of TIMER_A, TIMER_B, or TIMER_BOTH.
Description:
This function enables operation of the timer module. The timer must be configured before it is enabled.
Returns: None.

gptm_disable()

Disables the timer(s).
Prototype:
void gptm_disable(uint32_t ui32Base, uint32_t ui32Timer)
Parameters:
ui32Base is the base address of the timer module.
ui32Timer specifies the timer(s) to disable; must be one of TIMER_A, TIMER_B, or TIMER_BOTH.
Description:
This function disables operation of the timer module.
Returns: None.

gptm_rtc_enable()

Enables RTC counting.
Prototype:
void gptm_rtc_enable(uint32_t ui32Base)
Parameters:
ui32Base is the base address of the timer module.
Description:
This function causes the timer to start counting when in RTC mode. If not configured for RTC mode, this function does nothing.
Returns: None.

gptm_rtc_disable()

Disables RTC counting.
Prototype:
void gptm_rtc_disable(uint32_t ui32Base)
Parameters:
ui32Base is the base address of the timer module.
Description:
This function causes the timer to stop counting when in RTC mode.
Returns: None.

gptm_get_prescale()

Gets the timer prescale value.

Prototype:
uint32_t gptm_get_prescale(uint32_t ui32Base, uint32_t ui32Timer)
Parameters:
ui32Base is the base address of the timer module.
ui32Timer specifies the timer; must be one of TIMER_A or TIMER_B.
Description:
This function gets the value of the input clock prescaler. The prescaler is only operational when in half-width mode and is used to extend the range of the half-width timer modes. The prescaler provides the least significant bits when counting down in periodic and one-shot modes; in all other modes, the prescaler provides the most significant bits.
Note:
The availability of the prescaler varies with the Tiva part and timer mode in use. Please consult the datasheet for the part you are using to determine whether this support is available.
Returns: The value of the timer prescaler.

gptm_get_prescale_match()

Gets the timer prescale match value.
Prototype:
uint32_t gptm_get_prescale_match(uint32_t ui32Base, uint32_t ui32Timer)
Parameters:
ui32Base is the base address of the timer module.
ui32Timer specifies the timer; must be one of TIMER_A or TIMER_B.
Description:
This function gets the value of the input clock prescaler match value. When in a half-width mode that uses the counter match and prescaler, the prescale match effectively extends the range of the match. The prescaler provides the least significant bits when counting down in periodic and one-shot modes; in all other modes, the prescaler provides the most significant bits.
Note:
The availability of the prescaler match varies with the Tiva part and timer mode in use. Please consult the datasheet for the part you are using to determine whether this support is available.
Returns: The value of the timer prescale match.

gptm_get_load64()

Gets the timer load value.

Prototype:
uint32_t gptm_get_load(uint32_t ui32Base, uint32_t ui32Timer)
Parameters:
ui32Base is the base address of the timer module.
ui32Timer specifies the timer; must be one of TIMER_Aor TIMER_B. Only TIMER_A should be used when the timer is configured for full-width operation.
Description:
This function gets the currently programmed interval load value for the specified timer.
Note:
This function can be used for both full- and half-width modes of 16/32-bit timers and for half-width modes of 32/64-bit timers. Use gptm_get_load64() for full-width modes of 32/64-bit timers.
Returns: Returns the load value for the timer.

gptm_get_value()

Gets the current timer value.

Prototype:
uint32_t gptm_get_value(uint32_t ui32Base, uint32_t ui32Timer)
Parameters:
ui32Base is the base address of the timer module.
ui32Timer specifies the timer; must be one of TIMER_A or TIMER_B. Only TIMER_A should be used when the timer is configured for full-width operation.
Description:
This function reads the current value of the specified timer.
Note:
This function can be used for both full- and half-width modes of 16/32-bit timers and for half-width modes of 32/64-bit timers. Use gptm_get_value64() for full-width modes of 32/64-bit timers.
Returns: Returns the current value of the timer.

gptm_get_match()

Gets the timer match value.

Prototype:
uint32_t gptm_get_match(uint32_t ui32Base, uint32_t ui32Timer)
Parameters:
ui32Base is the base address of the timer module.
ui32Timer specifies the timer; must be one of TIMER_A or TIMER_B. Only TIMER_A should be used when the timer is configured for full-width operation.
Description:
This function gets the match value for the specified timer.
Note:
This function can be used for both full- and half-width modes of 16/32-bit timers and for half-width modes of 32/64-bit timers. Use gptm_get_match64() for full-width modes of 32/64-bit timers.
Returns: Returns the match value for the timer.

gptm_enable_int()

Enables individual timer interrupt sources.

Prototype:
void gptm_enable_int(uint32_t ui32Base, uint32_t ui32IntFlags)
Parameters:
ui32Base is the base address of the timer module.
ui32IntFlags is the bit mask of the interrupt sources to be enabled.
Description:
This function enables the indicated timer interrupt sources. Only the sources that are enabled can be reflected to the processor interrupt; disabled sources have no effect on the processor. The ui32IntFlags parameter must be the logical OR of any combination of the following:
TIMER_TIMB_DMA - Timer B uDMA complete
TIMER_TIMA_DMA - Timer A uDMA complete
TIMER_CAPB_EVENT - Capture B event interrupt
TIMER_CAPB_MATCH - Capture B match interrupt
TIMER_TIMB_TIMEOUT - Timer B timeout interrupt
TIMER_RTC_MATCH - RTC interrupt mask
TIMER_CAPA_EVENT - Capture A event interrupt
TIMER_CAPA_MATCH - Capture A match interrupt
TIMER_TIMA_TIMEOUT - Timer A timeout interrupt
Returns: None.

gptm_disable_int()

Disables individual timer interrupt sources.

Prototype:
void gptm_disable_int(uint32_t ui32Base, uint32_t ui32IntFlags)
Parameters:
ui32Base is the base address of the timer module.
ui32IntFlags is the bit mask of the interrupt sources to be disabled.
Description:
This function disables the indicated timer interrupt sources. Only the sources that are enabled can be reflected to the processor interrupt; disabled sources have no effect on the processor. The ui32IntFlags parameter has the same definition as the ui32IntFlags parameter to gptm_enable_int().
Returns: None.

gptm_int_status()

Gets the current interrupt status.

Prototype:
uint32_t gptm_int_status(uint32_t ui32Base, bool bMasked)
Parameters: ui32Base is the base address of the timer module.
bMasked is false if the raw interrupt status is required and true if the masked interrupt status is required.
Description:
This function returns the interrupt status for the timer module. Either the raw interrupt status or the status of interrupts that are allowed to reflect to the processor can be returned.
Returns: The current interrupt status, enumerated as a bit field of values described in gptm_enable_int().

gptm_clear_int()

Clears timer interrupt sources.

Prototype:
void gptm_clear_int(uint32_t ui32Base, uint32_t ui32IntFlags)
Parameters:
ui32Base is the base address of the timer module.
ui32IntFlags is a bit mask of the interrupt sources to be cleared.
Description:
The specified timer interrupt sources are cleared, so that they no longer assert. This function must be called in the interrupt handler to keep the interrupt from being triggered again immediately upon exit. The ui32IntFlags parameter has the same definition as the ui32IntFlags parameter to gptm_enable_int().
Note:
Because there is a write buffer in the Cortex-M processor, it may take several clock cycles before the interrupt source is actually cleared. Therefore, it is recommended that the interrupt source be cleared early in the interrupt handler (as opposed to the very last action) to avoid returning from the interrupt handler before the interrupt source is actually cleared. Failure to do so may result in the interrupt handler being immediately reentered (because the interrupt controller still sees the interrupt source asserted).
Returns: None.

gptm_synchronize()

Synchronizes the counters in a set of timers.

Prototype:
void gptm_synchronize(uint32_t ui32Base, uint32_t ui32Timers)
Parameters:
ui32Base is the base address of the timer module. This parameter must be the base address of Timer0 (in other words, TIMER0_BASE).
ui32Timers is the set of timers to synchronize.
Description:
This function synchronizes the counters in a specified set of timers. When a timer is running in halfwidth mode, each half can be included or excluded in the synchronization event. When a timer is running in full-width mode, only the A timer can be synchronized (specifying the B timer has no effect).
The ui32Timers parameter is the logical OR of any of the following defines:
TIMER_0A_SYNC
TIMER_0B_SYNC
TIMER_1A_SYNC
TIMER_1B_SYNC
TIMER_2A_SYNC
TIMER_2B_SYNC
TIMER_3A_SYNC
TIMER_3B_SYNC
TIMER_4A_SYNC
TIMER_4B_SYNC
TIMER_5A_SYNC
TIMER_5B_SYNC
WTIMER_0A_SYNC
WTIMER_0B_SYNC
WTIMER_1A_SYNC
WTIMER_1B_SYNC
WTIMER_2A_SYNC
WTIMER_2B_SYNC
WTIMER_3A_SYNC
WTIMER_3B_SYNC
WTIMER_4A_SYNC
WTIMER_4B_SYNC
WTIMER_5A_SYNC
WTIMER_5B_SYNC
Note:
This functionality is not available on all parts.
Returns: None.

gptm_set_adc_event()

Enables the events that can cause an ADC trigger event.

Prototype:
void gptm_set_adc_event(uint32_t ui32Base, uint32_t ui32ADCEvent)
Parameters:
ui32Base is the base address of the timer module.
ui32ADCEvent is a bit mask of the events that can cause an ADC trigger event.
Description:
This function enables the timer events that can cause an ADC trigger event. The ADC trigger events are specified in the ui32ADCEvent parameter by passing in the logical OR of any of the following values:
TIMER_ADC_MODEMATCH_B - Enables the mode match ADC trigger for timer B.
TIMER_ADC_CAPEVENT_B - Enables the capture event ADC trigger for timer B.
TIMER_ADC_CAPMATCH_B - Enables the capture match ADC trigger for timer B.
TIMER_ADC_TIMEOUT_B - Enables the timeout ADC trigger for timer B.
TIMER_ADC_MODEMATCH_A - Enables the mode match ADC trigger for timer A.
TIMER_ADC_RTC_A - Enables the RTC ADC trigger for timer A.
TIMER_ADC_CAPEVENT_A - Enables the capture event ADC trigger for timer A.
TIMER_ADC_CAPMATCH_A - Enables the capture match ADC trigger for timer A.
TIMER_ADC_TIMEOUT_A - Enables the timeout ADC trigger for timer A.
Note:
The ability to specify ADC event triggers varies with the Tiva part in use. Please consult the data sheet for the part you are using to determine whether this support is available.
Returns: None.

gptm_get_adc_event()

Returns the events that can cause an ADC trigger event.

Prototype:
uint32_t gptm_get_adc_event(uint32_t ui32Base)
Parameters:
ui32Base is the base address of the timer module.c Description:
This function returns the timer events that can cause an ADC trigger event. The ADC trigger events are the logical OR of any of the following values:
TIMER_ADC_MODEMATCH_B - Enables the mode match ADC trigger for timer B.
TIMER_ADC_CAPEVENT_B - Enables the capture event ADC trigger for timer B.
TIMER_ADC_CAPMATCH_B - Enables the capture match ADC trigger for timer B.
TIMER_ADC_TIMEOUT_B - Enables the timeout ADC trigger for timer B.
TIMER_ADC_MODEMATCH_A - Enables the mode match ADC trigger for timer A.
TIMER_ADC_RTC_A - Enables the RTC ADC trigger for timer A.
TIMER_ADC_CAPEVENT_A - Enables the capture event ADC trigger for timer A.
TIMER_ADC_CAPMATCH_A - Enables the capture match ADC trigger for timer A.
TIMER_ADC_TIMEOUT_A - Enables the timeout ADC trigger for timer A.
Note:
The ability to specify ADC event triggers varies with the Tiva part in use. Please consult the data sheet for the part you are using to determine whether this support is available.
Returns: The timer events that trigger the ADC.

gptm_configure()

Configures the timer(s).

Prototype:
void gptm_configure(uint32_t ui32Base, uint32_t ui32Config);
Parameters:
ui32Base is the base address of the timer module.
ui32Config is the configuration for the timer.
Description:
This function configures the operating mode of the timer(s). The timer module is disabled before being configured and is left in the disabled state. The timer can be configured to be a single full-width timer by using the TIMER_CFG_∗ values or a pair of half-width timers using the TIMER_CFG_A_∗ and TIMER_CFG_B_∗ values passed in the ui32Config parameter. The configuration is specified in ui32Config as one of the following values:
TIMER_CFG_ONE_SHOT - Full-width one-shot timer
TIMER_CFG_ONE_SHOT_UP - Full-width one-shot timer that counts up instead of down (not available on all parts)
TIMER_CFG_PERIODIC - Full-width periodic timer
TIMER_CFG_PERIODIC_UP - Full-width periodic timer that counts up instead of down (not available on all parts)
TIMER_CFG_RTC - Full-width real time clock timer
TIMER_CFG_SPLIT_PAIR - Two half-width timers When configured for a pair of half-width timers, each timer is separately configured. The first timer is configured by setting ui32Config to the result of a logical OR operation between one of the following values and ui32Config:
TIMER_CFG_A_ONE_SHOT - Half-width one-shot timer
TIMER_CFG_A_ONE_SHOT_UP - Half-width one-shot timer that counts up instead of down (not available on all parts)
TIMER_CFG_A_PERIODIC - Half-width periodic timer
TIMER_CFG_A_PERIODIC_UP - Half-width periodic timer that counts up instead of down (not available on all parts)
TIMER_CFG_A_CAP_COUNT - Half-width edge count capture
TIMER_CFG_A_CAP_COUNT_UP - Half-width edge count capture that counts up instead of down (not available on all parts)
TIMER_CFG_A_CAP_TIME - Half-width edge time capture
TIMER_CFG_A_CAP_TIME_UP - Half-width edge time capture that counts up instead of down (not available on all parts)
TIMER_CFG_A_PWM - Half-width PWM output Some Tiva devices also allow configuring an action when the timers reach their timeout. Please consult the data sheet for the part you are using to determine whether configuring actions on timers is available. One of the following can be combined with the TIMER_CFG_∗ values to enable an action on timer A:
TIMER_CFG_A_ACT_TOINTD - masks the timeout interrupt of timer A.
TIMER_CFG_A_ACT_NONE|TIMER_CFG_A_ACT_NONE - no additional action on timeout of timer A.
TIMER_CFG_A_ACT_TOGGLE - toggle CCP on timeout of timer A.
TIMER_CFG_A_ACT_SETTO - set CCP on timeout of timer A.
TIMER_CFG_A_ACT_CLRTO - clear CCP on timeout of timer A.
TIMER_CFG_A_ACT_SETTOGTO - set CCP immediately and then toggle it on timeout of timer A.
TIMER_CFG_A_ACT_CLRTOGTO - clear CCP immediately and then toggle it on timeout of timer A.
TIMER_CFG_A_ACT_SETCLRTO - set CCP immediately and then clear it on timeout of timer [[EmSys:Tm4clib-gptm-defines#A.
TIMER_CFG_A_ACT_CLRSETTO - clear CCP immediately and then set it on timeout of timer A.
One of the following can be combined with the TIMER_CFG_∗ values to enable an action on timer B:
TIMER_CFG_B_ACT_TOINTD - masks the timeout interrupt of timer B.
TIMER_CFG_B_ACT_NONE - no additional action on timeout of timer B.
TIMER_CFG_B_ACT_TOGGLE - toggle CCP on timeout of timer B.
TIMER_CFG_B_ACT_SETTO - set CCP on timeout of timer B.
TIMER_CFG_B_ACT_CLRTO - clear CCP on timeout of timer B.
TIMER_CFG_B_ACT_SETTOGTO - set CCP immediately and then toggle it on timeout of timer B.
TIMER_CFG_B_ACT_CLRTOGTO - clear CCP immediately and then toggle it on timeout of timer B.
TIMER_CFG_B_ACT_SETCLRTO - set CCP immediately and then clear it on timeout of timer B.
TIMER_CFG_B_ACT_CLRSETTO - clear CCP immediately and then set it on timeout of timer B.
Similarly, the second timer is configured by setting ui32Config to the result of a logical OR operation between one of the corresponding TIMER_CFG_B_∗ values and ui32Config.
Returns: None.

gptm_control_level()

Controls the output level.

Prototype:
void gptm_control_level(uint32_t ui32Base, uint32_t ui32Timer, bool bInvert);
Parameters:
ui32Base is the base address of the timer module.
ui32Timer specifies the timer(s) to adjust; must be one of TIMER_A, TIMER_B, or TIMER_BOTH.
bInvert specifies the output level.
Description:
This function configures the PWM output level for the specified timer. If the bInvert parameter is true, then the timer’s output is made active low; otherwise, it is made active high.
Returns: None.

gptm_set_prescale()

Sets the timer prescale value.

Prototype:
void gptm_set_prescale(uint32_t ui32Base, uint32_t ui32Timer, uint32_t ui32Value);
Parameters:
ui32Base is the base address of the timer module.
ui32Timer specifies the timer(s) to adjust; must be one of TIMER_A, TIMER_B, or TIMER_BOTH.
ui32Value is the timer prescale value which must be between 0 and 255 (inclusive) for 16/32-bit timers and between 0 and 65535 (inclusive) for 32/64-bit timers.
Description:
This function configures the value of the input clock prescaler. The prescaler is only operational when in half-width mode and is used to extend the range of the half-width timer modes. The prescaler provides the least significant bits when counting down in periodic and one-shot modes; in all other modes, the prescaler provides the most significant bits.
Note:
The availability of the prescaler varies with the Tiva part and timer mode in use. Please consult the datasheet for the part you are using to determine whether this support is available.
Returns: None.

gptm_set_prescale_match()

Sets the timer prescale match value.

Prototype:
void gptm_set_prescale_match(uint32_t ui32Base, uint32_t ui32Timer, uint32_t ui32Value);
Parameters:
ui32Base is the base address of the timer module.
ui32Timer specifies the timer(s) to adjust; must be one of TIMER_A, TIMER_B, or TIMER_BOTH.
ui32Value is the timer prescale match value which must be between 0 and 255 (inclusive) for 16/32-bit timers and between 0 and 65535 (inclusive) for 32/64-bit timers.
Description:
This function configures the value of the input clock prescaler match value. When in a half-width mode that uses the counter match and the prescaler, the prescale match effectively extends the range of the match. The prescaler provides the least significant bits when counting down in periodic and one-shot modes; in all other modes, the prescaler provides the most significant bits. Note:
The availability of the prescaler match varies with the Tiva part and timer mode in use. Please consult the datasheet for the part you are using to determine whether this support is available.
Returns: None.

gptm_set_load()

Sets the timer load value.

Prototype:
void gptm_set_load(uint32_t ui32Base, uint32_t ui32Timer, uint32_t ui32Value);
Parameters:
ui32Base is the base address of the timer module.
ui32Timer specifies the timer(s) to adjust; must be one of TIMER_A, TIMER_B, or TIMER_BOTH. Only TIMER_A should be used when the timer is configured for full-width operation.
ui32Value is the load value.
Description:
This function configures the timer load value; if the timer is running then the value is immediately loaded into the timer.
Note:
This function can be used for both full- and half-width modes of 16/32-bit timers and for half-width modes of 32/64-bit timers. Use gptm_set_load64() for full-width modes of 32/64-bit timers.
Returns: None.

gptm_set_load64()

Sets the timer load value for a 64-bit timer.

Prototype:
void gptm_set64_load(uint32_t ui32Base, uint64_t ui64Value);
Parameters:
ui32Base is the base address of the timer module.
ui64Value is the load value.
Description:
This function configures the timer load value for a 64-bit timer; if the timer is running, then the value is immediately loaded into the timer. Returns: None.

gptm_get_load64()

Gets the timer load value for a 64-bit timer.

Prototype:
uint64_t gptm_get_load64(uint32_t ui32Base)
Parameters:
ui32Base is the base address of the timer module.
Description:
This function gets the currently programmed interval load value for the specified 64-bit timer.
Returns: Returns the load value for the timer.

gptm_get_value64()

Gets the current 64-bit timer value.

Prototype:
uint64_t gptm_get_value64(uint32_t ui32Base);
Parameters:
ui32Base is the base address of the timer module.
Description:
This function reads the current value of the specified timer.
Returns: Returns the current value of the timer.

gptm_set_match()

Sets the timer match value.

Prototype:
void gptm_set_match(uint32_t ui32Base, uint32_t ui32Timer, uint32_t ui32Value);
Parameters:
ui32Base is the base address of the timer module.
ui32Timer specifies the timer(s) to adjust; must be one of TIMER_A, TIMER_B, or TIMER_BOTH. Only TIMER_A should be used when the timer is configured for full-width operation.
ui32Value is the match value.
Description:
This function configures the match value for a timer. This value is used in capture count mode to determine when to interrupt the processor and in PWM mode to determine the duty cycle of the output signal. On some Tiva devices, match interrupts can also be generated in periodic and one-shot modes.
Note:
This function can be used for both full- and half-width modes of 16/32-bit timers and for half-width modes of 32/64-bit timers. Use gptm_set_match64() for full-width modes of 32/64-bit timers.
Returns: None.

gptm_set_match64()

Sets the timer match value for a 64-bit timer.

Prototype:
void gptm_set_match64(uint32_t ui32Base, uint64_t ui64Value);
Parameters:
ui32Base is the base address of the timer module.
ui64Value is the match value.
Description:
This function configures the match value for a timer. This value is used in capture count mode to determine when to interrupt the processor and in PWM mode to determine the duty cycle of the output signal.
Returns: None.

gptm_get_match64()

Gets the timer match value for a 64-bit timer.

Prototype:
)O uint64_t gptm_get_match64(uint32_t ui32Base);
Parameters:
ui32Base is the base address of the timer module.
Description:
This function gets the match value for the specified timer.
Returns: Returns the match value for the timer.

gptm_update_mode()

This function configures the update of timer load and match settings.

Prototype:
void gptm_update_mode(uint32_t ui32Base, uint32_t ui32Timer, uint32_t ui32Config);
Parameters:
ui32Base is the base address of the timer module.
ui32Timer specifies the timer(s); must be one of TIMER_A, TIMER_B, or TIMER_BOTH. ui32Config is a combination of the updates methods for the timers specified in the ui32Timer parameter.
Description:
This function configures how the timer updates the timer load and match values for the timers. The ui32Timer values can be TIMER_A, TIMER_B, or TIMER_BOTH to apply the settings in ui32Config to either timer or both timers. If the timer is not split then the TIMER_A should be used.
The ui32Config values affects when the gptm_set_load() and gptm_set_load64() values take effect.
TIMER_UP_LOAD_IMMEDIATE is the default mode that causes the gptm_set_load() or gptm_set_load64() to update the timer counter immediately.
TIMER_UP_LOAD_TIMEOUT causes the gptm_set_load() or gptm_set_load64() to update the timer when it counts down to zero.
Similarly the ui32Config value affects when the gptm_set_match() and gptm_set_match64() values take effect.
TIMER_UP_MATCH_IMMEDIATE is the default mode that causes the gptm_set_match() or gptm_set_match64() to update the timer match value immediately.
TIMER_UP_MATCH_TIMEOUT causes the gptm_set_match() or gptm_set_match64() to update the timer match value when it counts down to zero.
Note:
These settings have no effect if the timer is not in count down mode and are mostly useful when operating in PWM mode to allow for synchronous update of timer match and load values.
Returns: None.

gptm_control_stall()

Controls the stall handling.

Prototype:
void gptm_control_stall(uint32_t ui32Base, uint32_t ui32Timer, bool bStall);
Parameters:
ui32Base is the base address of the timer module.
ui32Timer specifies the timer(s) to be adjusted; must be one of TIMER_A, TIMER_B, or TIMER_BOTH.
bStall specifies the response to a stall signal.
Description:
This function controls the stall response for the specified timer. If the bStall parameter is true, then the timer stops counting if the processor enters debug mode; otherwise the timer keeps running while in debug mode.
Returns: None.