Kinetis SDK v.1.3 API Reference Manual  Rev. 0
Freescale Semiconductor, Inc.
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages

Overview

This section describes the programming interface of the PIT HAL driver.

Enumerations

enum  pit_status_t
 Error codes for PIT driver. More...
 

Initialization

static void PIT_HAL_Enable (PIT_Type *base)
 Enables the PIT module. More...
 
static void PIT_HAL_Disable (PIT_Type *base)
 Disables the PIT module. More...
 
static void PIT_HAL_SetTimerRunInDebugCmd (PIT_Type *base, bool timerRun)
 Configures the timers to continue running or to stop in debug mode. More...
 

Timer Start and Stop

static void PIT_HAL_StartTimer (PIT_Type *base, uint32_t channel)
 Starts the timer counting. More...
 
static void PIT_HAL_StopTimer (PIT_Type *base, uint32_t channel)
 Stops the timer from counting. More...
 
static bool PIT_HAL_IsTimerRunning (PIT_Type *base, uint32_t channel)
 Checks to see whether the current timer is started or not. More...
 

Timer Period

static void PIT_HAL_SetTimerPeriodByCount (PIT_Type *base, uint32_t channel, uint32_t count)
 Sets the timer period in units of count. More...
 
static uint32_t PIT_HAL_GetTimerPeriodByCount (PIT_Type *base, uint32_t channel)
 Returns the current timer period in units of count. More...
 
static uint32_t PIT_HAL_ReadTimerCount (PIT_Type *base, uint32_t channel)
 Reads the current timer counting value. More...
 

Interrupt

static void PIT_HAL_SetIntCmd (PIT_Type *base, uint32_t channel, bool enable)
 Enables or disables the timer interrupt. More...
 
static bool PIT_HAL_GetIntCmd (PIT_Type *base, uint32_t channel)
 Checks whether the timer interrupt is enabled or not. More...
 
static void PIT_HAL_ClearIntFlag (PIT_Type *base, uint32_t channel)
 Clears the timer interrupt flag. More...
 
static bool PIT_HAL_IsIntPending (PIT_Type *base, uint32_t channel)
 Reads the current timer timeout flag. More...
 

Enumeration Type Documentation

Function Documentation

static void PIT_HAL_Enable ( PIT_Type *  base)
inlinestatic

This function enables the PIT timer clock (Note: this function does not un-gate the system clock gating control). It should be called before any other timer related setup.

Parameters
baseBase address for current PIT instance.
static void PIT_HAL_Disable ( PIT_Type *  base)
inlinestatic

This function disables all PIT timer clocks(Note: it does not affect the SIM clock gating control).

Parameters
baseBase address for current PIT instance.
static void PIT_HAL_SetTimerRunInDebugCmd ( PIT_Type *  base,
bool  timerRun 
)
inlinestatic

In debug mode, the timers 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 values), and continue the operation.

Parameters
baseBase address for current PIT instance.
timerRunTimers run or stop in debug mode.
  • true: Timers continue to run in debug mode.
  • false: Timers stop in debug mode.
static void PIT_HAL_StartTimer ( PIT_Type *  base,
uint32_t  channel 
)
inlinestatic

After calling this function, timers load the start value as specified by the function PIT_HAL_SetTimerPeriodByCount(PIT_Type * base, uint32_t channel, uint32_t count), count down to 0, and load the respective start value again. Each time a timer reaches 0, it generates a trigger pulse and sets the time-out interrupt flag.

Parameters
baseBase address for current PIT instance.
channelTimer channel number
static void PIT_HAL_StopTimer ( PIT_Type *  base,
uint32_t  channel 
)
inlinestatic

This function stops every timer from counting. Timers reload their periods respectively after they call the PIT_HAL_StartTimer the next time.

Parameters
baseBase address for current PIT instance.
channelTimer channel number
static bool PIT_HAL_IsTimerRunning ( PIT_Type *  base,
uint32_t  channel 
)
inlinestatic
Parameters
baseBase address for current PIT instance.
channelTimer channel number
Returns
Current timer running status -true: Current timer is running. -false: Current timer has stopped.
static void PIT_HAL_SetTimerPeriodByCount ( PIT_Type *  base,
uint32_t  channel,
uint32_t  count 
)
inlinestatic

Timers begin counting from the value set by this function. The counter period of a running timer can be modified by first stopping the timer, setting a new load value, and starting the timer again. If timers are not restarted, the new value is loaded after the next trigger event.

Parameters
baseBase address for current PIT instance.
channelTimer channel number
countTimer period in units of count
static uint32_t PIT_HAL_GetTimerPeriodByCount ( PIT_Type *  base,
uint32_t  channel 
)
inlinestatic
Parameters
baseBase address for current PIT instance.
channelTimer channel number
Returns
Timer period in units of count
static uint32_t PIT_HAL_ReadTimerCount ( PIT_Type *  base,
uint32_t  channel 
)
inlinestatic

This function returns the real-time timer counting value, in a range from 0 to a timer period.

Parameters
baseBase address for current PIT instance.
channelTimer channel number
Returns
Current timer counting value
static void PIT_HAL_SetIntCmd ( PIT_Type *  base,
uint32_t  channel,
bool  enable 
)
inlinestatic

If enabled, an interrupt happens when a timeout event occurs (Note: NVIC should be called to enable pit interrupt in system level).

Parameters
baseBase address for current PIT instance.
channelTimer channel number
enableEnable or disable interrupt.
  • true: Generate interrupt when timer counts to 0.
  • false: No interrupt is generated.
static bool PIT_HAL_GetIntCmd ( PIT_Type *  base,
uint32_t  channel 
)
inlinestatic
Parameters
baseBase address for current PIT instance.
channelTimer channel number
Returns
Status of enabled or disabled interrupt
  • true: Interrupt is enabled.
  • false: Interrupt is disabled.
static void PIT_HAL_ClearIntFlag ( PIT_Type *  base,
uint32_t  channel 
)
inlinestatic

This function clears the timer interrupt flag after a timeout event occurs.

Parameters
baseBase address for current PIT instance.
channelTimer channel number
static bool PIT_HAL_IsIntPending ( PIT_Type *  base,
uint32_t  channel 
)
inlinestatic

Every time the timer counts to 0, this flag is set.

Parameters
baseBase address for current PIT instance.
channelTimer channel number
Returns
Current status of the timeout flag
  • true: Timeout has occurred.
  • false: Timeout has not yet occurred.