ISF  2.1
Intelligent Sensing Framework for Kinetis with Processor Expert
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Pit_driver

Data Structures

struct  PitUserConfig
 PIT timer configuration structure. More...
 

Typedefs

typedef struct PitUserConfig pit_user_config_t
 PIT timer configuration structure. More...
 
typedef void(* pit_isr_callback_t )(void)
 PIT ISR callback function typedef. More...
 

Functions

void pit_init_module (bool isRunInDebug)
 Initialize PIT module. More...
 
void pit_init_channel (uint32_t timer, const pit_user_config_t *config)
 Initialize PIT channel. More...
 
void pit_shutdown (void)
 Disable PIT module and gate control. More...
 
void pit_timer_start (uint32_t timer)
 Start timer counting. More...
 
void pit_timer_stop (uint32_t timer)
 Stop timer counting. More...
 
void pit_set_timer_period_us (uint32_t timer, uint32_t us)
 Set timer period in microsecond units. More...
 
uint32_t pit_read_timer_us (uint32_t timer)
 Read current timer value in microsecond units. More...
 
void pit_init (bool bEnableirq, uint32 usec)
 Complete initialization of the PIT timer. More...
 
void pit_register_isr_callback_function (uint32_t timer, pit_isr_callback_t function)
 Register pit isr callback function. More...
 

Detailed Description

Typedef Documentation

typedef void(* pit_isr_callback_t)(void)

PIT ISR callback function typedef.

Definition at line 45 of file fsl_pit_driver.h.

PIT timer configuration structure.

Define structure PitConfig and use pit_init_channel() to make necessary initializations. You may also use remaining functions for PIT configuration.

Note
the timer chain feature is not valid in all devices, please check fsl_pit_features.h for accurate setting. If it's not valid, the value set here will be bypassed inside function pit_init_channel().

Function Documentation

void pit_init ( bool  bEnableirq,
uint32  usec 
)

Complete initialization of the PIT timer.

Definition at line 201 of file fsl_pit_driver.c.

References FALSE, ISF_BM_PIT_INSTANCE, PitUserConfig::isInterruptEnabled, pit_hal_clear_interrupt_flag(), pit_init_channel(), pit_init_module(), pit_set_timer_period_us(), and pit_timer_stop().

Referenced by bm_timer_init().

Here is the call graph for this function:

Here is the caller graph for this function:

void pit_init_channel ( uint32_t  timer,
const pit_user_config_t config 
)

Initialize PIT channel.

This function initialize PIT timers by channel. Pass in timer number and its config structure. Timers do not start counting by default after calling this function. Function pit_timer_start must be called to start timer counting. Call pit_set_timer_period_us to re-set the period.

Here is an example demonstrating how to define a PIT channel config structure:

1 pit_user_config_t pitTestInit = {
2  .isInterruptEnabled = true,
3  // Only takes effect when chain feature is available.
4  // Otherwise, pass in arbitrary value(true/false).
5  .isTimerChained = false,
6  // In unit of microseconds.
7  .periodUs = 1000,
8 };
Parameters
timerTimer channel number.
configPIT channel configuration structure.

Definition at line 69 of file fsl_pit_driver.c.

References TU_instance_PEx_t::fnTULDDInit, PitUserConfig::isInterruptEnabled, PitUserConfig::periodUs, pit_hal_configure_interrupt(), pit_set_timer_period_us(), and TU_instance_tbl.

Referenced by bm_start(), bm_timer_init(), and pit_init().

Here is the call graph for this function:

Here is the caller graph for this function:

void pit_init_module ( bool  isRunInDebug)

Initialize PIT module.

This function must be called before calling all the other PIT driver functions. This function un-gates the PIT clock and enables the PIT module. The isRunInDebug passed into function will affect all timer channels.

Parameters
isRunInDebugTimers run or stop in debug mode.
  • true: Timers continue to run in debug mode.
  • false: Timers stop in debug mode.

Definition at line 46 of file fsl_pit_driver.c.

References BM_PIT_SOURCE_CLK, pit_hal_configure_timer_run_in_debug(), pit_hal_enable(), and pitSourceClock.

Referenced by bm_start(), bm_timer_init(), and pit_init().

Here is the call graph for this function:

Here is the caller graph for this function:

uint32_t pit_read_timer_us ( uint32_t  timer)

Read current timer value in microsecond units.

This function returns an absolute time stamp in microsecond units. One common use of this function is to measure the running time of a part of code. Call this function at both the beginning and end of code; the time difference between these two time stamps is the running time (Make sure the running time will not exceed the timer period). The time stamp returned is up-counting.

Parameters
timerTimer channel number.
Returns
Current timer value in microseconds.

Definition at line 150 of file fsl_pit_driver.c.

References pit_hal_read_timer_count(), and pitSourceClock.

Here is the call graph for this function:

void pit_register_isr_callback_function ( uint32_t  timer,
pit_isr_callback_t  function 
)

Register pit isr callback function.

System default ISR interfaces are already defined in fsl_pit_irq.c. Users can either edit these ISRs or use this function to register a callback function. The default ISR runs the callback function if there is one installed.

Parameters
timerTimer channel number.
functionPointer to pit isr callback function.

Definition at line 160 of file fsl_pit_irq.c.

References pit_isr_callback_table.

void pit_set_timer_period_us ( uint32_t  timer,
uint32_t  us 
)

Set timer period in microsecond units.

The period range depends on the frequency of PIT source clock. If the required period is out of range, use the lifetime timer, if applicable.

Parameters
timerTimer channel number.
usTimer period in microseconds.

Definition at line 131 of file fsl_pit_driver.c.

References BM_PIT_SCALER, and pit_hal_set_timer_period_count().

Referenced by bm_start(), bm_timer_init(), isr_bm_callback_tmr(), pit_init(), and pit_init_channel().

Here is the call graph for this function:

Here is the caller graph for this function:

void pit_shutdown ( void  )

Disable PIT module and gate control.

This function disables all PIT interrupts and PIT clock. It then gates the PIT clock control. pit_init_module must be called if you want to use PIT again.

Definition at line 90 of file fsl_pit_driver.c.

References pit_hal_disable().

Here is the call graph for this function:

void pit_timer_start ( uint32_t  timer)

Start timer counting.

After calling this function, timers load period value, count down to 0 and then load the respective start value again. Each time a timer reaches 0, it generates a trigger pulse and sets the timeout interrupt flag.

Parameters
timerTimer channel number.

Definition at line 105 of file fsl_pit_driver.c.

References pit_hal_timer_start().

Referenced by bm_start().

Here is the call graph for this function:

Here is the caller graph for this function:

void pit_timer_stop ( uint32_t  timer)

Stop timer counting.

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

Parameters
timerTimer channel number.

Definition at line 118 of file fsl_pit_driver.c.

References pit_hal_timer_stop().

Referenced by bm_powerdown(), bm_start(), bm_timer_init(), and pit_init().

Here is the call graph for this function:

Here is the caller graph for this function: