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 PORT HAL driver, 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 to the instance number (HW_PORTA, HW_PORTB, HW_PORTC, and so on.).

Files

file  fsl_port_hal.h
 The port features such as digital filter, pull, and so on are valid when they are available in one of the pins.
 

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,
  kPortIntLogicZero = 0x8U,
  kPortIntRisingEdge = 0x9U,
  kPortIntFallingEdge = 0xAU,
  kPortIntEitherEdge = 0xBU,
  kPortIntLogicOne = 0xCU
}
 Digital filter clock source selection. More...
 

Configuration

static void PORT_HAL_SetMuxMode (PORT_Type *base, uint32_t pin, port_mux_t mux)
 Configures the pin muxing. More...
 
void PORT_HAL_SetLowGlobalPinCtrl (PORT_Type *base, uint16_t lowPinSelect, uint16_t config)
 Configures the low half of the pin control register for the same settings. More...
 
void PORT_HAL_SetHighGlobalPinCtrl (PORT_Type *base, uint16_t highPinSelect, uint16_t config)
 Configures the high half of the pin control register for the same settings. More...
 

Interrupt

static void PORT_HAL_SetPinIntMode (PORT_Type *base, uint32_t pin, port_interrupt_config_t intConfig)
 Configures the port pin interrupt/DMA request. More...
 
static port_interrupt_config_t PORT_HAL_GetPinIntMode (PORT_Type *base, uint32_t pin)
 Gets the current port pin interrupt/DMA request configuration. More...
 
static bool PORT_HAL_IsPinIntPending (PORT_Type *base, uint32_t pin)
 Reads the individual pin-interrupt status flag. More...
 
static void PORT_HAL_ClearPinIntFlag (PORT_Type *base, uint32_t pin)
 Clears the individual pin-interrupt status flag. More...
 
static uint32_t PORT_HAL_GetPortIntFlag (PORT_Type *base)
 Reads the entire port interrupt status flag. More...
 
static void PORT_HAL_ClearPortIntFlag (PORT_Type *base)
 Clears the entire port interrupt status flag. More...
 

Enumeration Type Documentation

Enumerator
kPortPullDown 

Internal pull-down resistor is enabled.

kPortPullUp 

Internal pull-up resistor is enabled.

Enumerator
kPortFastSlewRate 

Fast slew rate is configured.

kPortSlowSlewRate 

Slow slew rate is configured.

Enumerator
kPortLowDriveStrength 

Low drive strength is configured.

kPortHighDriveStrength 

High drive strength is configured.

enum port_mux_t
Enumerator
kPortPinDisabled 

Corresponding pin is disabled, but is used as an analog pin.

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.

Configures the interrupt generation condition.

Enumerator
kPortIntDisabled 

Interrupt/DMA request is disabled.

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_SetMuxMode ( PORT_Type *  base,
uint32_t  pin,
port_mux_t  mux 
)
inlinestatic
Parameters
baseport base pointer
pinport pin number
muxpin muxing slot selection
  • kPortPinDisabled: Pin disabled.
  • kPortMuxAsGpio : Set as GPIO.
  • others : chip-specific.
void PORT_HAL_SetLowGlobalPinCtrl ( PORT_Type *  base,
uint16_t  lowPinSelect,
uint16_t  config 
)

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

Parameters
baseport base pointer
lowPinSelectupdate 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.
configvalue is written to a low half port control register bits[15:0].
void PORT_HAL_SetHighGlobalPinCtrl ( PORT_Type *  base,
uint16_t  highPinSelect,
uint16_t  config 
)

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

Parameters
baseport base pointer
highPinSelectupdate 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.
configvalue is written to a high half port control register bits[15:0].
static void PORT_HAL_SetPinIntMode ( PORT_Type *  base,
uint32_t  pin,
port_interrupt_config_t  intConfig 
)
inlinestatic
Parameters
baseport base pointer.
pinport pin number
intConfiginterrupt configuration
  • kPortIntDisabled : Interrupt/DMA request 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.
static port_interrupt_config_t PORT_HAL_GetPinIntMode ( PORT_Type *  base,
uint32_t  pin 
)
inlinestatic
Parameters
baseport base pointer
pinport pin number
Returns
interrupt configuration
  • kPortIntDisabled : Interrupt/DMA request 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.
static bool PORT_HAL_IsPinIntPending ( PORT_Type *  base,
uint32_t  pin 
)
inlinestatic

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
baseport base pointer
pinport pin number
Returns
current pin interrupt status flag
  • 0: interrupt is not detected.
  • 1: interrupt is detected.
static void PORT_HAL_ClearPinIntFlag ( PORT_Type *  base,
uint32_t  pin 
)
inlinestatic
Parameters
baseport base pointer
pinport pin number
static uint32_t PORT_HAL_GetPortIntFlag ( PORT_Type *  base)
inlinestatic
Parameters
baseport base pointer
Returns
all 32 pin interrupt status flags. For specific bit:
  • 0: interrupt is not detected.
  • 1: interrupt is detected.
static void PORT_HAL_ClearPortIntFlag ( PORT_Type *  base)
inlinestatic
Parameters
baseport base pointer