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

Overview

This section describes the programming interface of the GPIO HAL driver.

Files

file  fsl_gpio_hal.h
 GPIO hardware driver configuration.
 

Enumerations

enum  gpio_pin_direction_t {
  kGpioDigitalInput = 0U,
  kGpioDigitalOutput = 1U
}
 GPIO direction definition. More...
 

Configuration

void GPIO_HAL_SetPinDir (GPIO_Type *base, uint32_t pin, gpio_pin_direction_t direction)
 Sets the individual GPIO pin to general input or output. More...
 
static void GPIO_HAL_SetPortDir (GPIO_Type *base, uint32_t pinDirectionMap)
 Sets the GPIO port pins to general input or output. More...
 

Status

static gpio_pin_direction_t GPIO_HAL_GetPinDir (GPIO_Type *base, uint32_t pin)
 Gets the current direction of the individual GPIO pin. More...
 
static uint32_t GPIO_HAL_GetPortDir (GPIO_Type *base)
 Gets the GPIO port pins direction. More...
 

Output Operation

void GPIO_HAL_WritePinOutput (GPIO_Type *base, uint32_t pin, uint32_t output)
 Sets the output level of the individual GPIO pin to logic 1 or 0. More...
 
static uint32_t GPIO_HAL_ReadPinOutput (GPIO_Type *base, uint32_t pin)
 Reads the current pin output. More...
 
static void GPIO_HAL_SetPinOutput (GPIO_Type *base, uint32_t pin)
 Sets the output level of the individual GPIO pin to logic 1. More...
 
static void GPIO_HAL_ClearPinOutput (GPIO_Type *base, uint32_t pin)
 Clears the output level of the individual GPIO pin to logic 0. More...
 
static void GPIO_HAL_TogglePinOutput (GPIO_Type *base, uint32_t pin)
 Reverses the current output logic of the individual GPIO pin. More...
 
static void GPIO_HAL_WritePortOutput (GPIO_Type *base, uint32_t portOutput)
 Sets the output of the GPIO port pins to a specific logic value. More...
 
static uint32_t GPIO_HAL_ReadPortOutput (GPIO_Type *base)
 Reads out all pin output status of the current port. More...
 
static void GPIO_HAL_SetPortOutput (GPIO_Type *base, uint32_t portOutput)
 Sets the output level of the GPIO port pins to logic 1. More...
 
static void GPIO_HAL_ClearPortOutput (GPIO_Type *base, uint32_t portOutput)
 Clears the output level of the GPIO port pins to logic 0. More...
 
static void GPIO_HAL_TogglePortOutput (GPIO_Type *base, uint32_t portOutput)
 Reverses the current output logic of the GPIO port pins. More...
 

Input Operation

static uint32_t GPIO_HAL_ReadPinInput (GPIO_Type *base, uint32_t pin)
 Reads the current input value of the individual GPIO pin. More...
 
static uint32_t GPIO_HAL_ReadPortInput (GPIO_Type *base)
 Reads the current input value of a specific GPIO port. More...
 

Enumeration Type Documentation

Enumerator
kGpioDigitalInput 

Set current pin as digital input.

kGpioDigitalOutput 

Set current pin as digital output.

Function Documentation

void GPIO_HAL_SetPinDir ( GPIO_Type *  base,
uint32_t  pin,
gpio_pin_direction_t  direction 
)
Parameters
baseGPIO base pointer(PTA, PTB, PTC, etc.)
pinGPIO port pin number
directionGPIO directions
  • kGpioDigitalInput: set to input
  • kGpioDigitalOutput: set to output
static void GPIO_HAL_SetPortDir ( GPIO_Type *  base,
uint32_t  pinDirectionMap 
)
inlinestatic

This function operates all 32 port pins.

Parameters
baseGPIO base pointer (PTA, PTB, PTC, etc.)
pinDirectionMapGPIO directions bit map
  • 0: set to input
  • 1: set to output
  • LSB: pin 0
  • MSB: pin 31
static gpio_pin_direction_t GPIO_HAL_GetPinDir ( GPIO_Type *  base,
uint32_t  pin 
)
inlinestatic
Parameters
baseGPIO base pointer(PTA, PTB, PTC, etc.)
pinGPIO port pin number
Returns
GPIO directions
  • kGpioDigitalInput: corresponding pin is set to input.
  • kGpioDigitalOutput: corresponding pin is set to output.
static uint32_t GPIO_HAL_GetPortDir ( GPIO_Type *  base)
inlinestatic

This function gets all 32-pin directions as a 32-bit integer.

Parameters
baseGPIO base pointer (PTA, PTB, PTC, etc.)
Returns
GPIO directions. Each bit represents one pin. For each bit:
  • 0: corresponding pin is set to input
  • 1: corresponding pin is set to output
  • LSB: pin 0
  • MSB: pin 31
void GPIO_HAL_WritePinOutput ( GPIO_Type *  base,
uint32_t  pin,
uint32_t  output 
)
Parameters
baseGPIO base pointer(PTA, PTB, PTC, etc.)
pinGPIO port pin number
outputpin output logic level
static uint32_t GPIO_HAL_ReadPinOutput ( GPIO_Type *  base,
uint32_t  pin 
)
inlinestatic
Parameters
baseGPIO base pointer (PTA, PTB, PTC, etc.)
pinGPIO port pin number
Returns
current pin output status. 0 - Low logic, 1 - High logic
static void GPIO_HAL_SetPinOutput ( GPIO_Type *  base,
uint32_t  pin 
)
inlinestatic
Parameters
baseGPIO base pointer(PTA, PTB, PTC, etc.)
pinGPIO port pin number
static void GPIO_HAL_ClearPinOutput ( GPIO_Type *  base,
uint32_t  pin 
)
inlinestatic
Parameters
baseGPIO base pointer(PTA, PTB, PTC, etc.)
pinGPIO port pin number
static void GPIO_HAL_TogglePinOutput ( GPIO_Type *  base,
uint32_t  pin 
)
inlinestatic
Parameters
baseGPIO base pointer(PTA, PTB, PTC, etc.)
pinGPIO port pin number
static void GPIO_HAL_WritePortOutput ( GPIO_Type *  base,
uint32_t  portOutput 
)
inlinestatic

This function operates all 32 port pins.

Parameters
baseGPIO base pointer (PTA, PTB, PTC, etc.)
portOutputdata to configure the GPIO output. Each bit represents one pin. For each bit:
  • 0: set logic level 0 to pin
  • 1: set logic level 1 to pin
  • LSB: pin 0
  • MSB: pin 31
static uint32_t GPIO_HAL_ReadPortOutput ( GPIO_Type *  base)
inlinestatic

This function operates all 32 port pins.

Parameters
baseGPIO base pointer (PTA, PTB, PTC, etc.)
Returns
current port output status. Each bit represents one pin. For each bit:
  • 0: corresponding pin is outputting logic level 0
  • 1: corresponding pin is outputting logic level 1
  • LSB: pin 0
  • MSB: pin 31
static void GPIO_HAL_SetPortOutput ( GPIO_Type *  base,
uint32_t  portOutput 
)
inlinestatic

This function operates all 32 port pins.

Parameters
baseGPIO base pointer(PTA, PTB, PTC, etc.)
portOutputGPIO output port pin mask. Each bit represents one pin. For each bit:
  • 0: pin output will not be changed.
  • 1: pin output will be set to logic level 1
  • LSB: pin 0
  • MSB: pin 31
static void GPIO_HAL_ClearPortOutput ( GPIO_Type *  base,
uint32_t  portOutput 
)
inlinestatic

This function operates all 32 port pins.

Parameters
baseGPIO base pointer(PTA, PTB, PTC, etc.)
portOutputmask of GPIO output pins. Each bit represents one pin. For each bit:
  • 0: pin output will not be changed.
  • 1: pin output will be set to logic level 0
  • LSB: pin 0
  • MSB: pin 31
static void GPIO_HAL_TogglePortOutput ( GPIO_Type *  base,
uint32_t  portOutput 
)
inlinestatic

This function operates all 32 port pins.

Parameters
baseGPIO base pointer(PTA, PTB, PTC, etc.)
portOutputmask of GPIO output pins. Each bit represents one pin. For each bit:
  • 0: pin output will not be changed.
  • 1: pin output logic level will be reversed.
  • LSB: pin 0
  • MSB: pin 31
static uint32_t GPIO_HAL_ReadPinInput ( GPIO_Type *  base,
uint32_t  pin 
)
inlinestatic
Parameters
baseGPIO base pointer(PTA, PTB, PTC, etc.)
pinGPIO port pin number
Returns
GPIO port input value
  • 0: Pin logic level is 0, or is not configured for use by digital function.
  • 1: Pin logic level is 1
static uint32_t GPIO_HAL_ReadPortInput ( GPIO_Type *  base)
inlinestatic

This function gets all 32-pin input as a 32-bit integer.

Parameters
baseGPIO base pointer(PTA, PTB, PTC, etc.)
Returns
GPIO port input data. Each bit represents one pin. For each bit:
  • 0: Pin logic level is 0, or is not configured for use by digital function.
  • 1: Pin logic level is 1.
  • LSB: pin 0
  • MSB: pin 31