| Kinetis SDK API Reference Manual 1.0.0-beta Freescale Semiconductor, Inc.

- Introduction
- Related Pages
- API Usage

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
PIT HAL driver
Periodic Interrup Timer (PIT)

The section describes the programming interface of the PIT HAL driver. More...

## Initialization
static void | pit_hal_enable (void)
| Enables the PIT module. More...
static void | pit_hal_disable (void)
| Disables the PIT module. More...
static void | pit_hal_configure_timer_run_in_debug (bool timerRun)
| Configures the timers to continue running or stop in debug mode. More...

## Timer Start and Stop
static void | pit_hal_timer_start (uint32_t timer)
| Starts the timer counting. More...
static void | pit_hal_timer_stop (uint32_t timer)
| Stops the timer from counting. More...
static bool | pit_hal_is_timer_started (uint32_t timer)
| Checks to see whether the current timer is started or not. More...

## Timer Period
static void | pit_hal_set_timer_period_count (uint32_t timer, uint32_t count)
| Sets the timer period in units of count. More...
static uint32_t | pit_hal_read_timer_period_count (uint32_t timer)
| Returns the current timer period in units of count. More...
static uint32_t | pit_hal_read_timer_count (uint32_t timer)
| Reads the current timer counting value. More...

## Interrupt
static void | pit_hal_configure_interrupt (uint32_t timer, bool enable)
| Enables or disables the timer interrupt. More...
static bool | pit_hal_is_interrupt_enabled (uint32_t timer)
| Checks whether the timer interrupt is enabled or not. More...
static void | pit_hal_clear_interrupt_flag (uint32_t timer)
| Clears the timer interrupt flag. More...
static bool | pit_hal_is_timeout_occurred (uint32_t timer)
| Reads the current timer timeout flag. More...

### PIT HAL Driver

# Overview

PIT hal driver is a set of APIs to access and configure PIT hardware registers.

## Function Documentation

static void pit_hal_enable | ( | void |  | ) |
| inline static

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.

static void pit_hal_disable | ( | void |  | ) |
| inline static

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

static void pit_hal_configure_timer_run_in_debug | ( | bool | timerRun | ) |
| inline static

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

  timerRun | Timers run or stop in debug mode. true: Timers continue to run in debug mode. false: Timers stop in debug mode.

static void pit_hal_timer_start | ( | uint32_t | timer | ) |
| inline static

After calling this function, timers load the start value as specified by the function pit_hal_set_timer_period_count(uint32_t timer, 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

  timer | Timer channel number

static void pit_hal_timer_stop | ( | uint32_t | timer | ) |
| inline static

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

Parameters

  timer | Timer channel number

static bool pit_hal_is_timer_started | ( | uint32_t | timer | ) |
| inline static

Parameters

  timer | Timer channel number

Returns
  Current timer running status -true: Current timer is running. -false: Current timer has stopped.

static void pit_hal_set_timer_period_count | ( | uint32_t | timer,
|  | uint32_t | count
| ) |  |
| inline static

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

  timer | Timer channel number
  count | Timer period in units of count

static uint32_t pit_hal_read_timer_period_count | ( | uint32_t | timer | ) |
| inline static

Parameters

  timer | Timer channel number

Returns
  Timer period in units of count

static uint32_t pit_hal_read_timer_count | ( | uint32_t | timer | ) |
| inline static

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

Parameters

  timer | Timer channel number

Returns
  Current timer counting value

static void pit_hal_configure_interrupt | ( | uint32_t | timer,
|  | bool | enable
| ) |  |
| inline static

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

Parameters

  timer | Timer channel number
  enable | Enable or disable interrupt. true: Generate interrupt when timer counts to 0. false: No interrupt is generated.

static bool pit_hal_is_interrupt_enabled | ( | uint32_t | timer | ) |
| inline static

Parameters

  timer | Timer channel number

Returns
  Status of enabled or disabled interrupt
  - true: Interrupt is enabled.
  - false: Interrupt is disabled.

static void pit_hal_clear_interrupt_flag | ( | uint32_t | timer | ) |
| inline static

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

Parameters

  timer | Timer channel number

static bool pit_hal_is_timeout_occurred | ( | uint32_t | timer | ) |
| inline static

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

Parameters

  timer | Timer channel number

Returns
  Current status of the timeout flag
  - true: Timeout has occurred.
  - false: Timeout has not yet occurred.