S32 SDK

Detailed Description

Low Power Interrupt Timer module Hardware Abstraction Layer.

This HAL provides low-level access to all hardware features of the LPIT.

Data Structures

struct  lpit_module_information_t
 Hardware information of LPIT module Implements : lpit_module_information_t_Class. More...
 

Enumerations

enum  lpit_timer_modes_t { LPIT_PERIODIC_COUNTER = 0x00U, LPIT_DUAL_PERIODIC_COUNTER = 0x01U, LPIT_TRIGGER_ACCUMULATOR = 0x02U, LPIT_INPUT_CAPTURE = 0x03U }
 Mode options available for the LPIT timer Implements : lpit_timer_modes_t_Class. More...
 
enum  lpit_trigger_source_t { LPIT_TRIGGER_SOURCE_EXTERNAL = 0x00U, LPIT_TRIGGER_SOURCE_INTERNAL = 0x01U }
 Trigger source options. More...
 

Timer Initialization

void LPIT_HAL_GetModuleInformation (const LPIT_Type *base, lpit_module_information_t *moduleInfomation)
 Gets the information of LPIT module. More...
 
static void LPIT_HAL_Enable (LPIT_Type *const base)
 Enables the LPIT module. More...
 
static void LPIT_HAL_Disable (LPIT_Type *const base)
 Disables the LPIT module. More...
 
static void LPIT_HAL_Reset (LPIT_Type *const base)
 Resets the LPIT module. More...
 

Timer Start and Stop

static void LPIT_HAL_StartTimerChannels (LPIT_Type *const base, uint32_t mask)
 Starts the timer channel counting. More...
 
static void LPIT_HAL_StopTimerChannels (LPIT_Type *const base, uint32_t mask)
 Stops the timer channel from counting. More...
 
static bool LPIT_HAL_IsTimerChannelRunning (const LPIT_Type *base, uint32_t channel)
 Checks timer channel operation status. More...
 

Timer Period

static void LPIT_HAL_SetTimerPeriodByCount (LPIT_Type *const base, uint32_t channel, uint32_t count)
 Sets the timer channel period in count unit. More...
 
static uint32_t LPIT_HAL_GetTimerPeriodByCount (const LPIT_Type *base, uint32_t channel)
 Gets the timer channel period in count unit. More...
 
static uint32_t LPIT_HAL_GetCurrentTimerCount (const LPIT_Type *base, uint32_t channel)
 Gets the current timer channel counting value. More...
 

Timer Interrupt

static void LPIT_HAL_EnableInterruptTimerChannels (LPIT_Type *const base, uint32_t mask)
 Enables the interrupt generation for timer channels. More...
 
static void LPIT_HAL_DisableInterruptTimerChannels (LPIT_Type *const base, uint32_t mask)
 Disables the interrupt generation for timer channels. More...
 
static uint32_t LPIT_HAL_GetInterruptFlagTimerChannels (const LPIT_Type *base, uint32_t mask)
 Gets the interrupt flag of timer channels. More...
 
static void LPIT_HAL_ClearInterruptFlagTimerChannels (LPIT_Type *const base, uint32_t mask)
 Clears the interrupt flag of timer channels. More...
 

Timer Configuration

static void LPIT_HAL_SetTimerChannelModeCmd (LPIT_Type *const base, uint32_t channel, lpit_timer_modes_t mode)
 Sets operation mode of timer channel. More...
 
static lpit_timer_modes_t LPIT_HAL_GetTimerChannelModeCmd (const LPIT_Type *base, uint32_t channel)
 Gets current operation mode of timer channel. More...
 
static void LPIT_HAL_SetTriggerSelectCmd (LPIT_Type *const base, uint32_t channel, uint32_t triggerChannelSelect)
 Sets internal trigger source for timer channel. More...
 
static void LPIT_HAL_SetTriggerSourceCmd (LPIT_Type *const base, uint32_t channel, lpit_trigger_source_t triggerSource)
 Sets trigger source of timer channel. More...
 
static void LPIT_HAL_SetReloadOnTriggerCmd (LPIT_Type *const base, uint32_t channel, bool isReloadOnTrigger)
 Sets timer channel reload on trigger. More...
 
static void LPIT_HAL_SetStopOnInterruptCmd (LPIT_Type *const base, uint32_t channel, bool isStopOnInterrupt)
 Sets timer channel stop on interrupt. More...
 
static void LPIT_HAL_SetStartOnTriggerCmd (LPIT_Type *const base, uint32_t channel, bool isStartOnTrigger)
 Sets timer channel start on trigger. More...
 
static void LPIT_HAL_SetTimerChannelChainCmd (LPIT_Type *const base, uint32_t channel, bool isChannelChained)
 Sets timer channel chaining. More...
 
static void LPIT_HAL_SetTimerRunInDebugCmd (LPIT_Type *const base, bool isRunInDebug)
 Sets operation of LPIT in debug mode. More...
 
static void LPIT_HAL_SetTimerRunInDozeCmd (LPIT_Type *const base, bool isRunInDoze)
 Sets operation of LPIT in DOZE mode. More...
 

Enumeration Type Documentation

Mode options available for the LPIT timer Implements : lpit_timer_modes_t_Class.

Enumerator
LPIT_PERIODIC_COUNTER 

32-bit Periodic Counter

LPIT_DUAL_PERIODIC_COUNTER 

Dual 16-bit Periodic Counter

LPIT_TRIGGER_ACCUMULATOR 

32-bit Trigger Accumulator

LPIT_INPUT_CAPTURE 

32-bit Trigger Input Capture

Definition at line 60 of file lpit_hal.h.

Trigger source options.

This is used for both internal and external trigger sources. The actual trigger options available is SoC specific, user should refer to the reference manual. Implements : lpit_trigger_source_t_Class

Enumerator
LPIT_TRIGGER_SOURCE_EXTERNAL 

Use external trigger

LPIT_TRIGGER_SOURCE_INTERNAL 

Use internal trigger

Definition at line 75 of file lpit_hal.h.

Function Documentation

static void LPIT_HAL_ClearInterruptFlagTimerChannels ( LPIT_Type *const  base,
uint32_t  mask 
)
inlinestatic

Clears the interrupt flag of timer channels.

This function clears current interrupt flag of timer channels.

Parameters
[in]baseLPIT peripheral base address
[in]maskThe interrupt flag clearing mask that decides which channels will be cleared interrupt flag.
  • For example:
    • with mask = 0x01u then the interrupt flag of channel 0 only will be cleared
    • with mask = 0x02u then the interrupt flag of channel 1 only will be cleared
    • with mask = 0x03u then the interrupt flags of channel 0 and channel 1 will be cleared Implements : LPIT_HAL_ClearInterruptFlagTimerChannels_Activity

Definition at line 371 of file lpit_hal.h.

static void LPIT_HAL_Disable ( LPIT_Type *const  base)
inlinestatic

Disables the LPIT module.

This function disables functional clock of LPIT module (Note: it does not affect the system clock gating control).

Parameters
[in]baseLPIT peripheral base address Implements : LPIT_HAL_Disable_Activity

Definition at line 132 of file lpit_hal.h.

static void LPIT_HAL_DisableInterruptTimerChannels ( LPIT_Type *const  base,
uint32_t  mask 
)
inlinestatic

Disables the interrupt generation for timer channels.

This function allows disabling interrupt generation for timer channels simultaneously.

Parameters
[in]baseLPIT peripheral base address
[in]maskThe interrupt disabling mask that decides which channels will be disabled interrupt.
  • For example:
    • with mask = 0x01u then will disable interrupt for channel 0 only
    • with mask = 0x02u then will disable interrupt for channel 1 only
    • with mask = 0x03u then will disable interrupt for channel 0 and channel 1 Implements : LPIT_HAL_DisableInterruptTimerChannels_Activity

Definition at line 330 of file lpit_hal.h.

static void LPIT_HAL_Enable ( LPIT_Type *const  base)
inlinestatic

Enables the LPIT module.

This function enables the functional clock of LPIT module (Note: this function does not un-gate the system clock gating control). It should be called before setup any timer channel.

Parameters
[in]baseLPIT peripheral base address Implements : LPIT_HAL_Enable_Activity

Definition at line 118 of file lpit_hal.h.

static void LPIT_HAL_EnableInterruptTimerChannels ( LPIT_Type *const  base,
uint32_t  mask 
)
inlinestatic

Enables the interrupt generation for timer channels.

This function allows enabling interrupt generation for timer channels simultaneously.

Parameters
[in]baseLPIT peripheral base address
[in]maskThe interrupt enabling mask that decides which channels will be enabled interrupt.
  • For example:
    • with mask = 0x01u then will enable interrupt for channel 0 only
    • with mask = 0x02u then will enable interrupt for channel 1 only
    • with mask = 0x03u then will enable interrupt for channel 0 and channel 1 Implements : LPIT_HAL_EnableInterruptTimerChannels_Activity

Definition at line 310 of file lpit_hal.h.

static uint32_t LPIT_HAL_GetCurrentTimerCount ( const LPIT_Type base,
uint32_t  channel 
)
inlinestatic

Gets the current timer channel counting value.

This function returns the real-time timer channel counting value, the value in a range from 0 to timer channel period. Need to make sure the running time does not exceed the timer channel period.

Parameters
[in]baseLPIT peripheral base address
[in]channelTimer channel number
Returns
Current timer channel counting value Implements : LPIT_HAL_GetCurrentTimerCount_Activity

Definition at line 283 of file lpit_hal.h.

static uint32_t LPIT_HAL_GetInterruptFlagTimerChannels ( const LPIT_Type base,
uint32_t  mask 
)
inlinestatic

Gets the interrupt flag of timer channels.

This function gets current interrupt flag of timer channels.

Parameters
[in]baseLPIT peripheral base address
[in]maskThe interrupt flag getting mask that decides which channels will be got interrupt flag.
  • For example:
    • with mask = 0x01u then the interrupt flag of channel 0 only will be got
    • with mask = 0x02u then the interrupt flag of channel 1 only will be got
    • with mask = 0x03u then the interrupt flags of channel 0 and channel 1 will be got
Returns
The interrupt flag of timer channels. Implements : LPIT_HAL_GetInterruptFlagTimerChannels_Activity

Definition at line 351 of file lpit_hal.h.

void LPIT_HAL_GetModuleInformation ( const LPIT_Type base,
lpit_module_information_t moduleInfomation 
)

Gets the information of LPIT module.

This function gets the informations of LPIT module as: major version number, minor version number, feature number, number of external trigger inputs, number of timer channels.

Parameters
[in]baseLPIT peripheral base address
[out]moduleInfomationPointer to lpit_module_information_t structure which is used to contain LPIT information.

Definition at line 42 of file lpit_hal.c.

static lpit_timer_modes_t LPIT_HAL_GetTimerChannelModeCmd ( const LPIT_Type base,
uint32_t  channel 
)
inlinestatic

Gets current operation mode of timer channel.

This function gets current operation mode of the timer channel given as argument.

Parameters
[in]baseLPIT peripheral base address
[in]channelTimer channel number
Returns
Operation mode of timer channel that is one of lpit_timer_modes_t Implements : LPIT_HAL_GetTimerChannelModeCmd_Activity

Definition at line 418 of file lpit_hal.h.

static uint32_t LPIT_HAL_GetTimerPeriodByCount ( const LPIT_Type base,
uint32_t  channel 
)
inlinestatic

Gets the timer channel period in count unit.

This function returns current period of timer channel given as argument.

Parameters
[in]baseLPIT peripheral base address
[in]channelTimer channel number
Returns
Timer channel period in count unit Implements : LPIT_HAL_GetTimerPeriodByCount_Activity

Definition at line 265 of file lpit_hal.h.

static bool LPIT_HAL_IsTimerChannelRunning ( const LPIT_Type base,
uint32_t  channel 
)
inlinestatic

Checks timer channel operation status.

This function checks to see whether the timer channel given as argument is running.

Parameters
[in]baseLPIT peripheral base address
[in]channelTimer channel number
Returns
The timer channel operation status -True: the timer channel is running -False: the timer channel is not running Implements : LPIT_HAL_IsTimerChannelRunning_Activity

Definition at line 216 of file lpit_hal.h.

static void LPIT_HAL_Reset ( LPIT_Type *const  base)
inlinestatic

Resets the LPIT module.

This function sets all LPIT registers to reset value, except the Module Control Register.

Parameters
[in]baseLPIT peripheral base address Implements : LPIT_HAL_Reset_Activity

Definition at line 146 of file lpit_hal.h.

static void LPIT_HAL_SetReloadOnTriggerCmd ( LPIT_Type *const  base,
uint32_t  channel,
bool  isReloadOnTrigger 
)
inlinestatic

Sets timer channel reload on trigger.

This function sets the timer channel to reload/don't reload on trigger.

Parameters
[in]baseLPIT peripheral base address
[in]channelTimer channel number
[in]isReloadOnTriggerTimer channel reload on trigger
  • True : timer channel will reload on trigger
  • False : timer channel will not reload on trigger Implements : LPIT_HAL_SetReloadOnTriggerCmd_Activity

Definition at line 497 of file lpit_hal.h.

static void LPIT_HAL_SetStartOnTriggerCmd ( LPIT_Type *const  base,
uint32_t  channel,
bool  isStartOnTrigger 
)
inlinestatic

Sets timer channel start on trigger.

This function sets the timer channel to starts/don't start on trigger.

Parameters
[in]baseLPIT peripheral base address
[in]channelTimer channel number
[in]isStartOnTriggerTimer channel start on trigger
  • True : Timer channel starts to decrement when rising edge on selected trigger is detected
  • False : Timer channel starts to decrement immediately based on restart condition (controlled by Timer Stop On Interrupt bit) Implements : LPIT_HAL_SetStartOnTriggerCmd_Activity

Definition at line 538 of file lpit_hal.h.

static void LPIT_HAL_SetStopOnInterruptCmd ( LPIT_Type *const  base,
uint32_t  channel,
bool  isStopOnInterrupt 
)
inlinestatic

Sets timer channel stop on interrupt.

This function sets the timer channel to stop or don't stop after it times out.

Parameters
[in]baseLPIT peripheral base address
[in]channelTimer channel number
[in]isStopOnInterruptTimer channel stop on interrupt
  • True : Timer channel will stop after it times out
  • False : Timer channel will not stop after it times out Implements : LPIT_HAL_SetStopOnInterruptCmd_Activity

Definition at line 517 of file lpit_hal.h.

static void LPIT_HAL_SetTimerChannelChainCmd ( LPIT_Type *const  base,
uint32_t  channel,
bool  isChannelChained 
)
inlinestatic

Sets timer channel chaining.

This function sets the timer channel to be chained or not chained.

Parameters
[in]baseLPIT peripheral base address
[in]channelTimer channel number(Note: The timer channel 0 cannot be chained)
[in]isChannelChainedTimer channel chaining
  • True : Timer channel is chained. Timer channel decrements on previous channel's timeout
  • False : Timer channel is not chained. Timer channel runs independently Implements : LPIT_HAL_SetTimerChannelChainCmd_Activity

Definition at line 558 of file lpit_hal.h.

static void LPIT_HAL_SetTimerChannelModeCmd ( LPIT_Type *const  base,
uint32_t  channel,
lpit_timer_modes_t  mode 
)
inlinestatic

Sets operation mode of timer channel.

This function sets the timer channel operation mode which control how the timer channel decrements.

Parameters
[in]baseLPIT peripheral base address
[in]channelTimer channel number
[in]modeOperation mode of timer channel that is member of lpit_timer_modes_t Implements : LPIT_HAL_SetTimerChannelModeCmd_Activity

Definition at line 400 of file lpit_hal.h.

static void LPIT_HAL_SetTimerPeriodByCount ( LPIT_Type *const  base,
uint32_t  channel,
uint32_t  count 
)
inlinestatic

Sets the timer channel period in count unit.

This function sets the timer channel period in count unit. The period range depends on the frequency of the LPIT functional clock and operation mode of timer channel. If the required period is out of range, use the suitable mode if applicable. Timer channel begins counting from the value that is set by this function. The counter period of a running timer channel can be modified by first setting a new load value, the value will be loaded after the timer channel expires. To abort the current cycle and start a timer channel period with the new value, the timer channel must be disabled and enabled again.

Parameters
[in]baseLPIT peripheral base address
[in]channelTimer channel number
[in]countTimer channel period in count unit Implements : LPIT_HAL_SetTimerPeriodByCount_Activity

Definition at line 248 of file lpit_hal.h.

static void LPIT_HAL_SetTimerRunInDebugCmd ( LPIT_Type *const  base,
bool  isRunInDebug 
)
inlinestatic

Sets operation of LPIT in debug mode.

When the device enters debug mode, the timer channels may or may not be frozen, based on the configuration of this function. This is intended to aid software development, allowing the developer to halt the processor, investigate the current state of the system (for example, the timer channel values), and continue the operation.

Parameters
[in]baseLPIT peripheral base address
[in]isRunInDebugLPIT run in debug mode
  • True: LPIT continue to run when the device enters debug mode
  • False: LPIT stop when the device enters debug mode Implements : LPIT_HAL_SetTimerRunInDebugCmd_Activity

Definition at line 580 of file lpit_hal.h.

static void LPIT_HAL_SetTimerRunInDozeCmd ( LPIT_Type *const  base,
bool  isRunInDoze 
)
inlinestatic

Sets operation of LPIT in DOZE mode.

When the device enters debug mode, the timer channels may or may not be frozen, based on the configuration of this function. The LPIT must use an external or internal clock source which remains operating during DOZE modes(low power mode).

Parameters
[in]baseLPIT peripheral base address
[in]isRunInDozeLPIT run in DOZE mode
  • True: LPIT continue to run when the device enters DOZE mode
  • False: LPIT channels stop when the device enters DOZE mode Implements : LPIT_HAL_SetTimerRunInDozeCmd_Activity

Definition at line 600 of file lpit_hal.h.

static void LPIT_HAL_SetTriggerSelectCmd ( LPIT_Type *const  base,
uint32_t  channel,
uint32_t  triggerChannelSelect 
)
inlinestatic

Sets internal trigger source for timer channel.

This function selects one trigger from the set of internal triggers that is generated by other timer channels. The selected trigger is used for starting and/or reloading the timer channel.

Parameters
[in]baseLPIT peripheral base address
[in]channelTimer channel number
[in]triggerChannelSelectNumber of the channel which is selected to be trigger source Implements : LPIT_HAL_SetTriggerSelectCmd_Activity

Definition at line 459 of file lpit_hal.h.

static void LPIT_HAL_SetTriggerSourceCmd ( LPIT_Type *const  base,
uint32_t  channel,
lpit_trigger_source_t  triggerSource 
)
inlinestatic

Sets trigger source of timer channel.

This function sets trigger source of the timer channel to be internal or external trigger.

Parameters
[in]baseLPIT peripheral base address
[in]channelTimer channel number
[in]triggerSourceTrigger source of timer channel(internal or external source) Implements : LPIT_HAL_SetTriggerSourceCmd_Activity

Definition at line 477 of file lpit_hal.h.

static void LPIT_HAL_StartTimerChannels ( LPIT_Type *const  base,
uint32_t  mask 
)
inlinestatic

Starts the timer channel counting.

This function allows starting timer channels simultaneously . After calling this function, timer channels are going operate depend on mode and control bits which controls timer channel start, reload and restart.

Parameters
[in]baseLPIT peripheral base address
[in]maskTimer channels starting mask that decides which channels will be started
  • For example:
    • with mask = 0x01U then channel 0 will be started
    • with mask = 0x02U then channel 1 will be started
    • with mask = 0x03U then channel 0 and channel 1 will be started Implements : LPIT_HAL_StartTimerChannels_Activity

Definition at line 175 of file lpit_hal.h.

static void LPIT_HAL_StopTimerChannels ( LPIT_Type *const  base,
uint32_t  mask 
)
inlinestatic

Stops the timer channel from counting.

This function allows stop timer channels simultaneously from counting. Timer channels reload their periods respectively after the next time they call the LPIT_DRV_StartTimerChannels. Note that: In 32-bit Trigger Accumulator mode, the counter will load on the first trigger rising edge.

Parameters
[in]baseLPIT peripheral base address
[in]maskTimer channels stopping mask that decides which channels will be stopped
  • For example:
    • with mask = 0x01U then channel 0 will be stopped
    • with mask = 0x02U then channel 1 will be stopped
    • with mask = 0x03U then channel 0 and channel 1 will be stopped Implements : LPIT_HAL_StopTimerChannels_Activity

Definition at line 198 of file lpit_hal.h.