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

Overview

The section describes the programming interface of the TPM HAL driver.

Data Structures

struct  tpm_pwm_param_t
 TPM driver PWM parameter. More...
 

Enumerations

enum  tpm_clock_mode_t
 TPM clock source selection for TPM_SC[CMOD]. More...
 
enum  tpm_counting_mode_t
 TPM counting mode, up or down.
 
enum  tpm_clock_ps_t
 TPM prescaler factor selection for clock source.
 
enum  tpm_trigger_source_t {
  kTpmTrigSel0 = 0,
  kTpmTrigSel1,
  kTpmTrigSel2,
  kTpmTrigSel3,
  kTpmTrigSel4,
  kTpmTrigSel5,
  kTpmTrigSel6,
  kTpmTrigSel7,
  kTpmTrigSel8,
  kTpmTrigSel9,
  kTpmTrigSel10,
  kTpmTrigSel11,
  kTpmTrigSel12,
  kTpmTrigSel13,
  kTpmTrigSel14,
  kTpmTrigSel15
}
 TPM trigger sources, please refer to the chip reference manual for available options. More...
 
enum  tpm_pwm_mode_t {
  kTpmEdgeAlignedPWM = 0,
  kTpmCenterAlignedPWM
}
 TPM operation mode. More...
 
enum  tpm_pwm_edge_mode_t {
  kTpmHighTrue = 0,
  kTpmLowTrue
}
 TPM PWM output pulse mode, high-true or low-true on match up. More...
 
enum  tpm_input_capture_mode_t
 TPM input capture modes.
 
enum  tpm_output_compare_mode_t
 TPM output compare modes.
 
enum  tpm_status_t {
  kStatusTpmSuccess = 0x00U,
  kStatusTpmFail = 0x01U
}
 Error codes for TPM driver. More...
 

Functions

void TPM_HAL_Reset (TPM_Type *base, uint32_t instance)
 Resets the TPM registers. More...
 
void TPM_HAL_EnablePwmMode (TPM_Type *base, tpm_pwm_param_t *config, uint8_t channel)
 Enables the TPM PWM output mode. More...
 
void TPM_HAL_DisableChn (TPM_Type *base, uint8_t channel)
 Disables the TPM channel. More...
 
void TPM_HAL_SetClockMode (TPM_Type *base, tpm_clock_mode_t mode)
 Sets the TPM clock mode. More...
 
static tpm_clock_mode_t TPM_HAL_GetClockMode (TPM_Type *base)
 get TPM clock mode. More...
 
static void TPM_HAL_SetClockDiv (TPM_Type *base, tpm_clock_ps_t ps)
 Sets the TPM clock divider. More...
 
static tpm_clock_ps_t TPM_HAL_GetClockDiv (TPM_Type *base)
 Gets the TPM clock divider. More...
 
static void TPM_HAL_EnableTimerOverflowInt (TPM_Type *base)
 Enables the TPM peripheral timer overflow interrupt. More...
 
static void TPM_HAL_DisableTimerOverflowInt (TPM_Type *base)
 Disables the TPM peripheral timer overflow interrupt. More...
 
static bool TPM_HAL_IsOverflowIntEnabled (TPM_Type *base)
 Reads the bit that controls TPM timer overflow interrupt enablement. More...
 
static bool TPM_HAL_GetTimerOverflowStatus (TPM_Type *base)
 Returns the TPM peripheral timer overflow interrupt flag. More...
 
static void TPM_HAL_ClearTimerOverflowFlag (TPM_Type *base)
 Clears the TPM timer overflow interrupt flag. More...
 
static void TPM_HAL_SetCpwms (TPM_Type *base, uint8_t mode)
 set TPM center-aligned PWM select. More...
 
static bool TPM_HAL_GetCpwms (TPM_Type *base)
 Gets the TPM center-aligned PWM selection value. More...
 
static void TPM_HAL_ClearCounter (TPM_Type *base)
 Clears the TPM peripheral current counter value. More...
 
static uint16_t TPM_HAL_GetCounterVal (TPM_Type *base)
 Returns the TPM peripheral current counter value. More...
 
static void TPM_HAL_SetMod (TPM_Type *base, uint16_t val)
 Sets the TPM peripheral timer modulo value. More...
 
static uint16_t TPM_HAL_GetMod (TPM_Type *base)
 Returns the TPM peripheral counter modulo value. More...
 
static void TPM_HAL_SetChnMsnbaElsnbaVal (TPM_Type *base, uint8_t channel, uint8_t value)
 Sets the TPM peripheral timer channel mode and edge level,. More...
 
static uint8_t TPM_HAL_GetChnMsnbaVal (TPM_Type *base, uint8_t channel)
 Gets the TPM peripheral timer channel mode. More...
 
static uint8_t TPM_HAL_GetChnElsnbaVal (TPM_Type *base, uint8_t channel)
 Gets the TPM peripheral timer channel edge level. More...
 
static void TPM_HAL_EnableChnInt (TPM_Type *base, uint8_t channel)
 Enables the TPM peripheral timer channel(n) interrupt. More...
 
static void TPM_HAL_DisableChnInt (TPM_Type *base, uint8_t channel)
 Disables the TPM peripheral timer channel(n) interrupt. More...
 
static bool TPM_HAL_IsChnIntEnabled (TPM_Type *base, uint8_t channel)
 Gets the TPM peripheral timer channel(n) interrupt enabled or not. More...
 
static bool TPM_HAL_GetChnStatus (TPM_Type *base, uint8_t channel)
 Returns whether any event for TPM peripheral timer channel has occurred. More...
 
static void TPM_HAL_ClearChnInt (TPM_Type *base, uint8_t channel)
 Returns whether any event for the TPM peripheral timer channel has occurred. More...
 
static void TPM_HAL_SetChnCountVal (TPM_Type *base, uint8_t channel, uint16_t val)
 Sets the TPM peripheral timer channel counter value. More...
 
static uint16_t TPM_HAL_GetChnCountVal (TPM_Type *base, uint8_t channel)
 Gets the TPM peripheral timer channel counter value. More...
 
static uint32_t TPM_HAL_GetStatusRegVal (TPM_Type *base)
 Gets the TPM peripheral timer channel event status. More...
 
static void TPM_HAL_ClearStatusReg (TPM_Type *base, uint16_t tpm_status)
 Clears the TPM peripheral timer clear status register value,. More...
 
static void TPM_HAL_SetTriggerSrc (TPM_Type *base, tpm_trigger_source_t trigger_num)
 Sets the TPM peripheral timer trigger. More...
 
static void TPM_HAL_SetTriggerMode (TPM_Type *base, bool enable)
 Sets the TPM peripheral timer running on trigger or not. More...
 
static void TPM_HAL_SetReloadOnTriggerMode (TPM_Type *base, bool enable)
 Enables the TPM timer counter reload on selected trigger or not. More...
 
static void TPM_HAL_SetStopOnOverflowMode (TPM_Type *base, bool enable)
 Enables the TPM timer counter stop on selected trigger or not. More...
 
static void TPM_HAL_EnableGlobalTimeBase (TPM_Type *base, bool enable)
 Enables the TPM timer global time base. More...
 
static void TPM_HAL_SetDbgMode (TPM_Type *base, bool enable)
 Sets BDM mode. More...
 
static void TPM_HAL_SetWaitMode (TPM_Type *base, bool enable)
 Sets the WAIT mode behavior. More...
 

Variables

const uint32_t g_tpmChannelCount [TPM_INSTANCE_COUNT]
 Table of number of channels for each TPM instance.
 

Data Structure Documentation

struct tpm_pwm_param_t

Data Fields

tpm_pwm_mode_t mode
 TPM PWM operation mode.
 
tpm_pwm_edge_mode_t edgeMode
 PWM output mode.
 
uint32_t uFrequencyHZ
 PWM period in Hz.
 
uint32_t uDutyCyclePercent
 PWM pulse width, value should be between 0 to 100 0=inactive signal(0% duty cycle)... More...
 

Field Documentation

uint32_t tpm_pwm_param_t::uDutyCyclePercent

100=active signal (100% duty cycle).

Enumeration Type Documentation

Enumerator
kTpmTrigSel0 

TPM trigger source 0.

kTpmTrigSel1 

TPM trigger source 1.

kTpmTrigSel2 

TPM trigger source 2.

kTpmTrigSel3 

TPM trigger source 3.

kTpmTrigSel4 

TPM trigger source 4.

kTpmTrigSel5 

TPM trigger source 5.

kTpmTrigSel6 

TPM trigger source 6.

kTpmTrigSel7 

TPM trigger source 7.

kTpmTrigSel8 

TPM trigger source 8.

kTpmTrigSel9 

TPM trigger source 8.

kTpmTrigSel10 

TPM trigger source 10.

kTpmTrigSel11 

TPM trigger source 11.

kTpmTrigSel12 

TPM trigger source 12.

kTpmTrigSel13 

TPM trigger source 13.

kTpmTrigSel14 

TPM trigger source 14.

kTpmTrigSel15 

TPM trigger source 15.

Enumerator
kTpmEdgeAlignedPWM 

Edge aligned mode.

kTpmCenterAlignedPWM 

Center aligned mode.

Enumerator
kTpmHighTrue 

Clear output on match, set output on reload.

kTpmLowTrue 

Set output on match, clear output on reload.

Enumerator
kStatusTpmSuccess 

TPM success status.

kStatusTpmFail 

TPM error status.

Function Documentation

void TPM_HAL_Reset ( TPM_Type *  base,
uint32_t  instance 
)
Parameters
baseTPM module base address pointer
instanceThe TPM peripheral instance number.
void TPM_HAL_EnablePwmMode ( TPM_Type *  base,
tpm_pwm_param_t config,
uint8_t  channel 
)
Parameters
baseTPM module base address pointer
configPWM configuration parameter
channelThe TPM channel number.
void TPM_HAL_DisableChn ( TPM_Type *  base,
uint8_t  channel 
)
Parameters
baseTPM module base address pointer
channelThe TPM channel number.
void TPM_HAL_SetClockMode ( TPM_Type *  base,
tpm_clock_mode_t  mode 
)

When disabling the TPM counter, the function waits till it receives an acknowledge from the TPM clock domain.

Parameters
baseTPM module base address pointer
modeThe TPM counter clock mode (source).
static tpm_clock_mode_t TPM_HAL_GetClockMode ( TPM_Type *  base)
inlinestatic
Parameters
baseTPM module base address pointer
Returns
The TPM counter clock mode (source).
static void TPM_HAL_SetClockDiv ( TPM_Type *  base,
tpm_clock_ps_t  ps 
)
inlinestatic
Parameters
baseTPM module base address pointer
psThe TPM peripheral clock prescale divider
static tpm_clock_ps_t TPM_HAL_GetClockDiv ( TPM_Type *  base)
inlinestatic
Parameters
baseTPM module base address pointer
Returns
The TPM peripheral clock prescale divider.
static void TPM_HAL_EnableTimerOverflowInt ( TPM_Type *  base)
inlinestatic
Parameters
baseTPM module base address pointer
static void TPM_HAL_DisableTimerOverflowInt ( TPM_Type *  base)
inlinestatic
Parameters
baseTPM module base address pointer
static bool TPM_HAL_IsOverflowIntEnabled ( TPM_Type *  base)
inlinestatic
Parameters
baseTPM module base address pointer
Returns
true if overflow interrupt is enabled, false if not
static bool TPM_HAL_GetTimerOverflowStatus ( TPM_Type *  base)
inlinestatic
Parameters
baseTPM module base address pointer
Returns
true if overflow, false if not
static void TPM_HAL_ClearTimerOverflowFlag ( TPM_Type *  base)
inlinestatic
Parameters
baseTPM module base address pointer
static void TPM_HAL_SetCpwms ( TPM_Type *  base,
uint8_t  mode 
)
inlinestatic
Parameters
baseTPM module base address pointer
mode1 : upcounting mode 0:up_down counting mode.
static bool TPM_HAL_GetCpwms ( TPM_Type *  base)
inlinestatic
Parameters
baseTPM module base address pointer
Returns
Whether the TPM center-aligned PWM is selected or not.
static void TPM_HAL_ClearCounter ( TPM_Type *  base)
inlinestatic
Parameters
baseTPM module base address pointer
static uint16_t TPM_HAL_GetCounterVal ( TPM_Type *  base)
inlinestatic
Parameters
baseTPM module base address pointer
Returns
current TPM timer counter value
static void TPM_HAL_SetMod ( TPM_Type *  base,
uint16_t  val 
)
inlinestatic
Parameters
baseTPM module base address pointer
valThe value to be set to the timer modulo
static uint16_t TPM_HAL_GetMod ( TPM_Type *  base)
inlinestatic
Parameters
baseTPM module base address pointer
Returns
TPM timer modula value
static void TPM_HAL_SetChnMsnbaElsnbaVal ( TPM_Type *  base,
uint8_t  channel,
uint8_t  value 
)
inlinestatic

TPM channel operate mode, MSnB, and ELSnBA should be set at the same time.

Parameters
baseThe TPM base address
channelThe TPM peripheral channel number
valueThe value to set for MSnBA and ELSnBA
static uint8_t TPM_HAL_GetChnMsnbaVal ( TPM_Type *  base,
uint8_t  channel 
)
inlinestatic
Parameters
baseTPM module base address pointer
channelThe TPM peripheral channel number
Returns
The MSnB:MSnA mode value, will be 00,01, 10, 11
static uint8_t TPM_HAL_GetChnElsnbaVal ( TPM_Type *  base,
uint8_t  channel 
)
inlinestatic
Parameters
baseTPM module base address pointer
channelThe TPM peripheral channel number
Returns
The ELSnB:ELSnA mode value, will be 00,01, 10, 11
static void TPM_HAL_EnableChnInt ( TPM_Type *  base,
uint8_t  channel 
)
inlinestatic
Parameters
baseTPM module base address pointer
channelThe TPM peripheral channel number
static void TPM_HAL_DisableChnInt ( TPM_Type *  base,
uint8_t  channel 
)
inlinestatic
Parameters
baseTPM module base address pointer
channelThe TPM peripheral channel number
static bool TPM_HAL_IsChnIntEnabled ( TPM_Type *  base,
uint8_t  channel 
)
inlinestatic
Parameters
baseTPM module base address pointer
channelThe TPM peripheral channel number
Returns
Whether the TPM peripheral timer channel(n) interrupt is enabled or not.
static bool TPM_HAL_GetChnStatus ( TPM_Type *  base,
uint8_t  channel 
)
inlinestatic
Parameters
baseTPM module base address pointer
channelThe TPM peripheral channel number.
Returns
true if event occurred, false otherwise
static void TPM_HAL_ClearChnInt ( TPM_Type *  base,
uint8_t  channel 
)
inlinestatic
Parameters
baseTPM module base address pointer
channelThe TPM peripheral channel number.
static void TPM_HAL_SetChnCountVal ( TPM_Type *  base,
uint8_t  channel,
uint16_t  val 
)
inlinestatic
Parameters
baseTPM module base address pointer
channelThe TPM peripheral channel number.
valcounter value to be set
static uint16_t TPM_HAL_GetChnCountVal ( TPM_Type *  base,
uint8_t  channel 
)
inlinestatic
Parameters
baseTPM module base address pointer
channelThe TPM peripheral channel number.
Returns
The TPM timer channel counter value.
static uint32_t TPM_HAL_GetStatusRegVal ( TPM_Type *  base)
inlinestatic
Parameters
baseTPM module base address pointer
Returns
The TPM timer channel event status.
static void TPM_HAL_ClearStatusReg ( TPM_Type *  base,
uint16_t  tpm_status 
)
inlinestatic
Parameters
baseTPM module base address pointer
tpm_statusTPM channel or overflow flag to clear
static void TPM_HAL_SetTriggerSrc ( TPM_Type *  base,
tpm_trigger_source_t  trigger_num 
)
inlinestatic
Parameters
baseTPM module base address pointer
trigger_num0-15
static void TPM_HAL_SetTriggerMode ( TPM_Type *  base,
bool  enable 
)
inlinestatic
Parameters
baseTPM module base address pointer
enabletrue to enable, 1 to enable
static void TPM_HAL_SetReloadOnTriggerMode ( TPM_Type *  base,
bool  enable 
)
inlinestatic
Parameters
baseTPM module base address pointer
enabletrue to enable, false to disable.
static void TPM_HAL_SetStopOnOverflowMode ( TPM_Type *  base,
bool  enable 
)
inlinestatic
Parameters
baseTPM module base address pointer
enabletrue to enable, false to disable.
static void TPM_HAL_EnableGlobalTimeBase ( TPM_Type *  base,
bool  enable 
)
inlinestatic
Parameters
baseTPM module base address pointer
enabletrue to enable, false to disable.
static void TPM_HAL_SetDbgMode ( TPM_Type *  base,
bool  enable 
)
inlinestatic
Parameters
baseTPM module base address pointer
enablefalse pause, true continue work
static void TPM_HAL_SetWaitMode ( TPM_Type *  base,
bool  enable 
)
inlinestatic
Parameters
baseTPM module base address pointer
enable0 continue running, 1 stop running