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

Overview

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

Data Structures

struct  lptmr_prescaler_user_config_t
 Define LPTMR prescaler user configure. More...
 
struct  lptmr_working_mode_user_config_t
 Define LPTMR working mode user configure. More...
 

Enumerations

enum  lptmr_pin_select_t {
  kLptmrPinSelectInput0 = 0x0U,
  kLptmrPinSelectInput1 = 0x1U,
  kLptmrPinSelectInput2 = 0x2U,
  kLptmrPinSelectInput3 = 0x3U
}
 LPTMR pin selection, used in pulse counter mode. More...
 
enum  lptmr_pin_polarity_t {
  kLptmrPinPolarityActiveHigh = 0x0U,
  kLptmrPinPolarityActiveLow = 0x1U
}
 LPTMR pin polarity, used in pulse counter mode. More...
 
enum  lptmr_timer_mode_t {
  kLptmrTimerModeTimeCounter = 0x0U,
  kLptmrTimerModePulseCounter = 0x1U
}
 LPTMR timer mode selection. More...
 
enum  lptmr_prescaler_value_t {
  kLptmrPrescalerDivide2 = 0x0U,
  kLptmrPrescalerDivide4GlitchFilter2 = 0x1U,
  kLptmrPrescalerDivide8GlitchFilter4 = 0x2U,
  kLptmrPrescalerDivide16GlitchFilter8 = 0x3U,
  kLptmrPrescalerDivide32GlitchFilter16 = 0x4U,
  kLptmrPrescalerDivide64GlitchFilter32 = 0x5U,
  kLptmrPrescalerDivide128GlitchFilter64 = 0x6U,
  kLptmrPrescalerDivide256GlitchFilter128 = 0x7U,
  kLptmrPrescalerDivide512GlitchFilter256 = 0x8U,
  kLptmrPrescalerDivide1024GlitchFilter512 = 0x9U,
  kLptmrPrescalerDivide2048GlitchFilter1024 = 0xAU,
  kLptmrPrescalerDivide4096GlitchFilter2048 = 0xBU,
  kLptmrPrescalerDivide8192GlitchFilter4096 = 0xCU,
  kLptmrPrescalerDivide16384GlitchFilter8192 = 0xDU,
  kLptmrPrescalerDivide32768GlitchFilter16384 = 0xEU,
  kLptmrPrescalerDivide65536GlitchFilter32768 = 0xFU
}
 LPTMR prescaler value. More...
 
enum  lptmr_prescaler_clock_select_t {
  kLptmrPrescalerClock0 = 0x0U,
  kLptmrPrescalerClock1 = 0x1U,
  kLptmrPrescalerClock2 = 0x2U,
  kLptmrPrescalerClock3 = 0x3U
}
 LPTMR prescaler/glitch filter clock select. More...
 
enum  lptmr_status_t {
  kStatus_LPTMR_Success = 0x0U,
  kStatus_LPTMR_NotInitlialized = 0x1U,
  kStatus_LPTMR_NullArgument = 0x2U,
  kStatus_LPTMR_InvalidPrescalerValue = 0x3U,
  kStatus_LPTMR_InvalidInTimeCounterMode = 0x4U,
  kStatus_LPTMR_InvalidInPulseCounterMode = 0x5U,
  kStatus_LPTMR_TcfNotSet = 0x6U,
  kStatus_LPTMR_TimerPeriodUsTooSmall = 0x7U,
  kStatus_LPTMR_TimerPeriodUsTooLarge = 0x8U
}
 LPTMR status return codes. More...
 

LPTMR HAL.

static void LPTMR_HAL_Enable (LPTMR_Type *base)
 Enables the LPTMR module operation. More...
 
static void LPTMR_HAL_Disable (LPTMR_Type *base)
 Disables the LPTMR module operation. More...
 
static void LPTMR_HAL_ClearIntFlag (LPTMR_Type *base)
 Clears the LPTMR interrupt flag if set. More...
 
static bool LPTMR_HAL_IsIntPending (LPTMR_Type *base)
 Returns the current LPTMR interrupt flag. More...
 
static void LPTMR_HAL_SetIntCmd (LPTMR_Type *base, bool enable)
 Enables or disables the LPTMR interrupt. More...
 
void LPTMR_HAL_SetTimerWorkingMode (LPTMR_Type *base, lptmr_working_mode_user_config_t timerMode)
 Configures the LPTMR working mode. More...
 
void LPTMR_HAL_SetPrescalerMode (LPTMR_Type *base, lptmr_prescaler_user_config_t prescaler_config)
 Sets the LPTMR prescaler mode. More...
 
static void LPTMR_HAL_SetCompareValue (LPTMR_Type *base, uint32_t compareValue)
 Sets the LPTMR compare value. More...
 
static uint32_t LPTMR_HAL_GetCompareValue (LPTMR_Type *base)
 Gets the LPTMR compare value. More...
 
uint32_t LPTMR_HAL_GetCounterValue (LPTMR_Type *base)
 Gets the LPTMR counter value. More...
 
void LPTMR_HAL_Init (LPTMR_Type *base)
 Restores the LPTMR module to reset state. More...
 

Data Structure Documentation

struct lptmr_prescaler_user_config_t

Data Fields

bool prescalerBypass
 Set this value will by pass the prescaler or glitch filter. More...
 
lptmr_prescaler_clock_select_t prescalerClockSelect
 Selects the clock to be used by the LPTMR prescaler/glitch filter. More...
 
lptmr_prescaler_value_t prescalerValue
 Configures the size of the prescaler in time counter mode or width of the glitch filter in pulse counter mode. More...
 

Field Documentation

bool lptmr_prescaler_user_config_t::prescalerBypass
lptmr_prescaler_clock_select_t lptmr_prescaler_user_config_t::prescalerClockSelect
lptmr_prescaler_value_t lptmr_prescaler_user_config_t::prescalerValue
struct lptmr_working_mode_user_config_t

Data Fields

lptmr_timer_mode_t timerModeSelect
 Selects the LPTMR working mode: Timer or Pulse Counter. More...
 
bool freeRunningEnable
 Enables or disables the LPTMR free running. More...
 
lptmr_pin_polarity_t pinPolarity
 Specifies LPTMR pulse input pin polarity. More...
 
lptmr_pin_select_t pinSelect
 Specifies LPTMR pulse input pin select. More...
 

Field Documentation

lptmr_timer_mode_t lptmr_working_mode_user_config_t::timerModeSelect
bool lptmr_working_mode_user_config_t::freeRunningEnable
lptmr_pin_polarity_t lptmr_working_mode_user_config_t::pinPolarity
lptmr_pin_select_t lptmr_working_mode_user_config_t::pinSelect

Enumeration Type Documentation

Enumerator
kLptmrPinSelectInput0 

Pulse counter input 0 is selected.

kLptmrPinSelectInput1 

Pulse counter input 1 is selected.

kLptmrPinSelectInput2 

Pulse counter input 2 is selected.

kLptmrPinSelectInput3 

Pulse counter input 3 is selected.

Enumerator
kLptmrPinPolarityActiveHigh 

Pulse Counter input source is active-high.

kLptmrPinPolarityActiveLow 

Pulse Counter input source is active-low.

Enumerator
kLptmrTimerModeTimeCounter 

Time Counter mode.

kLptmrTimerModePulseCounter 

Pulse Counter mode.

Enumerator
kLptmrPrescalerDivide2 

Prescaler divide 2, glitch filter invalid.

kLptmrPrescalerDivide4GlitchFilter2 

Prescaler divide 4, glitch filter 2.

kLptmrPrescalerDivide8GlitchFilter4 

Prescaler divide 8, glitch filter 4.

kLptmrPrescalerDivide16GlitchFilter8 

Prescaler divide 16, glitch filter 8.

kLptmrPrescalerDivide32GlitchFilter16 

Prescaler divide 32, glitch filter 16.

kLptmrPrescalerDivide64GlitchFilter32 

Prescaler divide 64, glitch filter 32.

kLptmrPrescalerDivide128GlitchFilter64 

Prescaler divide 128, glitch filter 64.

kLptmrPrescalerDivide256GlitchFilter128 

Prescaler divide 256, glitch filter 128.

kLptmrPrescalerDivide512GlitchFilter256 

Prescaler divide 512, glitch filter 256.

kLptmrPrescalerDivide1024GlitchFilter512 

Prescaler divide 1024, glitch filter 512.

kLptmrPrescalerDivide2048GlitchFilter1024 

Prescaler divide 2048 glitch filter 1024.

kLptmrPrescalerDivide4096GlitchFilter2048 

Prescaler divide 4096, glitch filter 2048.

kLptmrPrescalerDivide8192GlitchFilter4096 

Prescaler divide 8192, glitch filter 4096.

kLptmrPrescalerDivide16384GlitchFilter8192 

Prescaler divide 16384, glitch filter 8192.

kLptmrPrescalerDivide32768GlitchFilter16384 

Prescaler divide 32768, glitch filter 16384.

kLptmrPrescalerDivide65536GlitchFilter32768 

Prescaler divide 65536, glitch filter 32768.

Enumerator
kLptmrPrescalerClock0 

Prescaler/glitch filter clock 0 selected.

kLptmrPrescalerClock1 

Prescaler/glitch filter clock 1 selected.

kLptmrPrescalerClock2 

Prescaler/glitch filter clock 2 selected.

kLptmrPrescalerClock3 

Prescaler/glitch filter clock 3 selected.

Enumerator
kStatus_LPTMR_Success 

Succeed.

kStatus_LPTMR_NotInitlialized 

LPTMR is not initialized yet.

kStatus_LPTMR_NullArgument 

Argument is NULL.

kStatus_LPTMR_InvalidPrescalerValue 

Value 0 is not valid in pulse counter mode.

kStatus_LPTMR_InvalidInTimeCounterMode 

Function cannot be called in time counter mode.

kStatus_LPTMR_InvalidInPulseCounterMode 

Function cannot be called in pulse counter mode.

kStatus_LPTMR_TcfNotSet 

If LPTMR is enabled, compare register can only altered when TCF is set.

kStatus_LPTMR_TimerPeriodUsTooSmall 

Timer period time is too small for current clock source.

kStatus_LPTMR_TimerPeriodUsTooLarge 

Timer period time is too large for current clock source.

Function Documentation

static void LPTMR_HAL_Enable ( LPTMR_Type *  base)
inlinestatic
Parameters
baseThe LPTMR peripheral base address.
static void LPTMR_HAL_Disable ( LPTMR_Type *  base)
inlinestatic
Parameters
baseThe LPTMR peripheral base address.
static void LPTMR_HAL_ClearIntFlag ( LPTMR_Type *  base)
inlinestatic
Parameters
baseThe LPTMR peripheral base address.
static bool LPTMR_HAL_IsIntPending ( LPTMR_Type *  base)
inlinestatic
Parameters
baseThe LPTMR peripheral base address
Returns
State of LPTMR interrupt flag
Return values
trueAn interrupt is pending.
falseNo interrupt is pending.
static void LPTMR_HAL_SetIntCmd ( LPTMR_Type *  base,
bool  enable 
)
inlinestatic
Parameters
baseThe LPTMR peripheral base address
enablePass true to enable LPTMR interrupt
void LPTMR_HAL_SetTimerWorkingMode ( LPTMR_Type *  base,
lptmr_working_mode_user_config_t  timerMode 
)
Parameters
baseThe LPTMR peripheral base address.
timerModeSpecifies LPTMR working mode configure, see lptmr_working_mode_user_config_t
void LPTMR_HAL_SetPrescalerMode ( LPTMR_Type *  base,
lptmr_prescaler_user_config_t  prescaler_config 
)
Parameters
baseThe LPTMR peripheral base address.
prescaler_configSpecifies LPTMR prescaler configure, see lptmr_prescaler_user_config_t
static void LPTMR_HAL_SetCompareValue ( LPTMR_Type *  base,
uint32_t  compareValue 
)
inlinestatic
Parameters
baseThe LPTMR peripheral base address.
compareValueSpecifies LPTMR compare value, less than 0xFFFFU
static uint32_t LPTMR_HAL_GetCompareValue ( LPTMR_Type *  base)
inlinestatic
Parameters
baseThe LPTMR peripheral base address.
Returns
The LPTMR compare value.
uint32_t LPTMR_HAL_GetCounterValue ( LPTMR_Type *  base)
Parameters
baseThe LPTMR peripheral base address.
Returns
Current LPTMR counter value
void LPTMR_HAL_Init ( LPTMR_Type *  base)
Parameters
baseThe LPTMR peripheral base address