| 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
Enumerations
PORT HAL driver
Port Control and Interrupts (PORT)

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

## Enumerations
enum | port_pull_t { kPortPullDown = 0U, kPortPullUp = 1U }
| Internal resistor pull feature selection. More...
enum | port_slew_rate_t { kPortFastSlewRate = 0U, kPortSlowSlewRate = 1U }
| Slew rate selection. More...
enum | port_drive_strength_t { kPortLowDriveStrength = 0U, kPortHighDriveStrength = 1U }
| Configures the drive strength. More...
enum | port_mux_t { kPortPinDisabled = 0U, kPortMuxAsGpio = 1U, kPortMuxAlt2 = 2U, kPortMuxAlt3 = 3U, kPortMuxAlt4 = 4U, kPortMuxAlt5 = 5U, kPortMuxAlt6 = 6U, kPortMuxAlt7 = 7U }
| Pin mux selection. More...
enum | port_interrupt_config_t { kPortIntDisabled = 0x0U, kPortDmaRisingEdge = 0x1U, kPortDmaFallingEdge = 0x2U, kPortDmaEitherEdge = 0x3U, kPortIntLogicZero = 0x8U, kPortIntRisingEdge = 0x9U, kPortIntFallingEdge = 0xAU, kPortIntEitherEdge = 0xBU, kPortIntLogicOne = 0xCU }
| Digital filter clock source selection. More...

## Configuration
static void | port_hal_pull_select (uint32_t instance, uint32_t pin, port_pull_t pullSelect)
| Selects the internal resistor as pull-down or pull-up. More...
static void | port_hal_configure_pull (uint32_t instance, uint32_t pin, bool isPullEnabled)
| Enables or disables the internal pull resistor. More...
static void | port_hal_configure_slew_rate (uint32_t instance, uint32_t pin, port_slew_rate_t rateSelect)
| Configures the fast/slow slew rate if the pin is used as a digital output. More...
static void | port_hal_configure_passive_filter (uint32_t instance, uint32_t pin, bool isPassiveFilterEnabled)
| Configures the passive filter if the pin is used as a digital input. More...
static void | port_hal_configure_drive_strength (uint32_t instance, uint32_t pin, port_drive_strength_t driveSelect)
| Configures the drive strength if the pin is used as a digital output. More...
static void | port_hal_mux_control (uint32_t instance, uint32_t pin, port_mux_t mux)
| Configures the pin muxing. More...
void | port_hal_global_pin_control_low (uint32_t instance, uint16_t lowPinSelect, uint16_t config)
| Configures the low half of pin control register for the same settings. More...
void | port_hal_global_pin_control_high (uint32_t instance, uint16_t highPinSelect, uint16_t config)
| Configures the high half of pin control register for the same settings. More...

## Interrupt
static void | port_hal_configure_pin_interrupt (uint32_t instance, uint32_t pin, port_interrupt_config_t intConfig)
| Configures the port pin interrupt/DMA request. More...
static port_interrupt_config_t | port_hal_get_pin_interrupt_config (uint32_t instance, uint32_t pin)
| Gets the current port pin interrupt/DMA request configuration. More...
static bool | port_hal_read_pin_interrupt_flag (uint32_t instance, uint32_t pin)
| Reads the individual pin-interrupt status flag. More...
static void | port_hal_clear_pin_interrupt_flag (uint32_t instance, uint32_t pin)
| Clears the individual pin-interrupt status flag. More...
static uint32_t | port_hal_read_port_interrupt_flag (uint32_t instance)
| Reads the entire port interrupt status flag. More...
static void | port_hal_clear_port_interrupt_flag (uint32_t instance)
| Clears the entire port interrupt status flag. More...

### PORT HAL Driver

# Overview

Port control and interrupts hardware driver configuration. Use these functions to set port control and external interrupt functions. Most functions can be configured independently for each pin in the 32-bit port and affect the pin regardless of its pin muxing state. To use these functions, pass into instance number (HW_PORTA, HW_PORTB, HW_PORTC, etc).

## Enumeration Type Documentation

enum port_pull_t

Enumerator
kPortPullDown | internal pull-down resistor is enabled.
kPortPullUp | internal pull-up resistor is enabled.

enum port_slew_rate_t

Enumerator
kPortFastSlewRate | fast slew rate is configured.
kPortSlowSlewRate | slow slew rate is configured.

enum port_drive_strength_t

Enumerator
kPortLowDriveStrength | low drive strength is configured.
kPortHighDriveStrength | high drive strength is configured.

enum port_mux_t

Enumerator
kPortPinDisabled | corresponding pin is disabled as analog.
kPortMuxAsGpio | corresponding pin is configured as GPIO.
kPortMuxAlt2 | chip-specific
kPortMuxAlt3 | chip-specific
kPortMuxAlt4 | chip-specific
kPortMuxAlt5 | chip-specific
kPortMuxAlt6 | chip-specific
kPortMuxAlt7 | chip-specific

enum port_interrupt_config_t

Configures the interrupt generation condition.

Enumerator
kPortIntDisabled | Interrupt/DMA request is disabled.
kPortDmaRisingEdge | DMA request on rising edge.
kPortDmaFallingEdge | DMA request on falling edge.
kPortDmaEitherEdge | DMA request on either edge.
kPortIntLogicZero | Interrupt when logic zero.
kPortIntRisingEdge | Interrupt on rising edge.
kPortIntFallingEdge | Interrupt on falling edge.
kPortIntEitherEdge | Interrupt on either edge.
kPortIntLogicOne | Interrupt when logic one.

## Function Documentation

static void port_hal_pull_select | ( | uint32_t | instance,
|  | uint32_t | pin,
|  | port_pull_t | pullSelect
| ) |  |
| inline static

Pull configuration is valid in all digital pin muxing modes.

Parameters

  instance | port instance number.
  pin | port pin number
  pullSelect | internal resistor pull feature selection kPortPullDown: internal pull-down resistor is enabled. kPortPullUp : internal pull-up resistor is enabled.

static void port_hal_configure_pull | ( | uint32_t | instance,
|  | uint32_t | pin,
|  | bool | isPullEnabled
| ) |  |
| inline static

Parameters

  instance | port instance number
  pin | port pin number
  isPullEnabled | internal pull resistor enable or disable true : internal pull resistor is enabled. false: internal pull resistor is disabled.

static void port_hal_configure_slew_rate | ( | uint32_t | instance,
|  | uint32_t | pin,
|  | port_slew_rate_t | rateSelect
| ) |  |
| inline static

Parameters

  instance | port instance number
  pin | port pin number
  rateSelect | slew rate selection kPortFastSlewRate: fast slew rate is configured. kPortSlowSlewRate: slow slew rate is configured.

static void port_hal_configure_passive_filter | ( | uint32_t | instance,
|  | uint32_t | pin,
|  | bool | isPassiveFilterEnabled
| ) |  |
| inline static

If enabled, a low pass filter (10 MHz to 30 MHz bandwidth) is enabled on the digital input path. Disable the Passive Input Filter when supporting high speed interfaces (> 2 MHz) on the pin.

Parameters

  instance | port instance number
  pin | port pin number
  isPassiveFilterEnabled | passive filter configuration false: passive filter is disabled. true : passive filter is enabled.

static void port_hal_configure_drive_strength | ( | uint32_t | instance,
|  | uint32_t | pin,
|  | port_drive_strength_t | driveSelect
| ) |  |
| inline static

Parameters

  instance | port instance number
  pin | port pin number
  driveSelect | drive strength selection kLowDriveStrength : low drive strength is configured. kHighDriveStrength: high drive strength is configured.

static void port_hal_mux_control | ( | uint32_t | instance,
|  | uint32_t | pin,
|  | port_mux_t | mux
| ) |  |
| inline static

Parameters

  instance | port instance number
  pin | port pin number
  mux | pin muxing slot selection kPinDisabled: Pin disabled. kMuxAsGpio : Set as GPIO. others : chip-specific.

void port_hal_global_pin_control_low | ( | uint32_t | instance,
|  | uint16_t | lowPinSelect,
|  | uint16_t | config
| ) |  |

       This function operates pin 0 -15 of one specific port.

Parameters

  instance | port instance number
  pinSelect | update corresponding pin control register or not. For a specific bit: 0: corresponding low half of pin control register won't be updated according to configuration. 1: corresponding low half of pin control register will be updated according to configuration.
  config | value is written to a low half port control register bits[15:0].

void port_hal_global_pin_control_high | ( | uint32_t | instance,
|  | uint16_t | highPinSelect,
|  | uint16_t | config
| ) |  |

       This function operates pin 16 -31 of one specific port.

Parameters

  instance | port instance number
  pinSelect | update corresponding pin control register or not. For a specific bit: 0: corresponding high half of pin control register won't be updated according to configuration. 1: corresponding high half of pin control register will be updated according to configuration.
  config | value is written to a high half port control register bits[15:0].

static void port_hal_configure_pin_interrupt | ( | uint32_t | instance,
|  | uint32_t | pin,
|  | port_interrupt_config_t | intConfig
| ) |  |
| inline static

Parameters

  instance | port instance number.
  pin | port pin number
  intConfig | interrupt configuration kIntDisabled : Interrupt/DMA request disabled. kDmaRisingEdge : DMA request on rising edge. kDmaFallingEdge: DMA request on falling edge. kDmaEitherEdge : DMA request on either edge. KIntLogicZero : Interrupt when logic zero. KIntRisingEdge : Interrupt on rising edge. KIntFallingEdge: Interrupt on falling edge. KIntEitherEdge : Interrupt on either edge. KIntLogicOne : Interrupt when logic one.

static port_interrupt_config_t port_hal_get_pin_interrupt_config | ( | uint32_t | instance,
|  | uint32_t | pin
| ) |  |
| inline static

Parameters

  instance | port instance number
  pin | port pin number

Returns
  interrupt configuration
  - kIntDisabled : Interrupt/DMA request disabled.
  - kDmaRisingEdge : DMA request on rising edge.
  - kDmaFallingEdge: DMA request on falling edge.
  - kDmaEitherEdge : DMA request on either edge.
  - KIntLogicZero : Interrupt when logic zero.
  - KIntRisingEdge : Interrupt on rising edge.
  - KIntFallingEdge: Interrupt on falling edge.
  - KIntEitherEdge : Interrupt on either edge.
  - KIntLogicOne : Interrupt when logic one.

static bool port_hal_read_pin_interrupt_flag | ( | uint32_t | instance,
|  | uint32_t | pin
| ) |  |
| inline static

If a pin is configured to generate the DMA request, the corresponding flag is cleared automatically at the completion of the requested DMA transfer. Otherwise, the flag remains set until a logic one is written to that flag. If configured for a level sensitive interrupt that remains asserted, the flag is set again immediately.

Parameters

  instance | port instance number
  pin | port pin number

Returns
  current pin interrupt status flag
  - 0: interrupt is not detected.
  - 1: interrupt is detected.

static void port_hal_clear_pin_interrupt_flag | ( | uint32_t | instance,
|  | uint32_t | pin
| ) |  |
| inline static

Parameters

  instance | port instance number
  pin | port pin number

static uint32_t port_hal_read_port_interrupt_flag | ( | uint32_t | instance | ) |
| inline static

Parameters

  instance | port instance number

Returns
  all 32 pin interrupt status flags. For specific bit:
  - 0: interrupt is not detected.
  - 1: interrupt is detected.

static void port_hal_clear_port_interrupt_flag | ( | uint32_t | instance | ) |
| inline static

Parameters

  instance | port instance number