| 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 | Enumerator
GPIO HAL driver
General Purpose Input/Output (GPIO)

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

## Enumerations
enum | gpio_pin_direction_t { kGpioDigitalInput = 0, kGpioDigitalOutput = 1 }
| GPIO direction definition. More...

## Configuration
void | gpio_hal_set_pin_direction (uint32_t instance, uint32_t pin, gpio_pin_direction_t direction)
| Sets the individual GPIO pin to general input or output. More...
static void | gpio_hal_set_port_direction (uint32_t instance, uint32_t direction)
| Sets the GPIO port pins to general input or output. More...

## Status
static uint32_t | gpio_hal_get_pin_direction (uint32_t instance, uint32_t pin)
| Gets the current direction of the individual GPIO pin. More...
static uint32_t | gpio_hal_get_port_direction (uint32_t instance)
| Gets the GPIO port pins direction. More...

## Output Operation
void | gpio_hal_write_pin_output (uint32_t instance, 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_read_pin_output (uint32_t instance, uint32_t pin)
| Reads the current pin output. More...
static void | gpio_hal_set_pin_output (uint32_t instance, uint32_t pin)
| Sets the output level of the individual GPIO pin to logic 1. More...
static void | gpio_hal_clear_pin_output (uint32_t instance, uint32_t pin)
| Clears the output level of the individual GPIO pin to logic 0. More...
static void | gpio_hal_toggle_pin_output (uint32_t instance, uint32_t pin)
| Reverses the current output logic of the individual GPIO pin. More...
static void | gpio_hal_write_port_output (uint32_t instance, uint32_t portOutput)
| Sets the output of the GPIO port to a specific logic value. More...
static uint32_t | gpio_hal_read_port_output (uint32_t instance)
| Reads out all pin output status of the current port. More...

## Input Operation
static uint32_t | gpio_hal_read_pin_input (uint32_t instance, uint32_t pin)
| Reads the current input value of the individual GPIO pin. More...
static uint32_t | gpio_hal_read_port_input (uint32_t instance)
| Reads the current input value of a specific GPIO port. More...

### GPIO HAL Driver

# Overview

The GPIO HAL driver is designed to access GPIO hardware registers. It provides sets of APIs for users to configure and control GPIO ports/pins.

## Enumeration Type Documentation

enum gpio_pin_direction_t

Enumerator
kGpioDigitalInput | Set current pin as digital input.
kGpioDigitalOutput | Set current pin as digital output.

## Function Documentation

void gpio_hal_set_pin_direction | ( | uint32_t | instance,
|  | uint32_t | pin,
|  | gpio_pin_direction_t | direction
| ) |  |

Parameters

  instance | GPIO instance number(HW_GPIOA, HW_GPIOB, HW_GPIOC, etc.)
  pin | GPIO port pin number
  direction | GPIO directions kGpioDigitalInput: set to input kGpioDigitalOutput: set to output

static void gpio_hal_set_port_direction | ( | uint32_t | instance,
|  | uint32_t | direction
| ) |  |
| inline static

This function operates all 32 port pins.

Parameters

  instance | GPIO instance number (HW_GPIOA, HW_GPIOB, HW_GPIOC, etc.)
  direction | GPIO directions 0: set to input 1: set to output LSB: pin 0 MSB: pin 31

static uint32_t gpio_hal_get_pin_direction | ( | uint32_t | instance,
|  | uint32_t | pin
| ) |  |
| inline static

Parameters

  instance | GPIO instance number(HW_GPIOA, HW_GPIOB, HW_GPIOC, etc.)
  pin | GPIO port pin number

Returns
  GPIO directions
  - 0: corresponding pin is set to input.
  - 1: corresponding pin is set to output.

static uint32_t gpio_hal_get_port_direction | ( | uint32_t | instance | ) |
| inline static

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

Parameters

  instance | GPIO instance number (HW_GPIOA, HW_GPIOB, HW_GPIOC, 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_write_pin_output | ( | uint32_t | instance,
|  | uint32_t | pin,
|  | uint32_t | output
| ) |  |

Parameters

  instance | GPIO instance number(HW_GPIOA, HW_GPIOB, HW_GPIOC, etc.)
  pin | GPIO port pin number
  output | pin output logic level

static uint32_t gpio_hal_read_pin_output | ( | uint32_t | instance,
|  | uint32_t | pin
| ) |  |
| inline static

Parameters

  instance | GPIO instance number (HW_GPIOA, HW_GPIOB, HW_GPIOC, etc.)
  pin | GPIO port pin number

Returns
  current pin output status. 0 - Low logic, 1 - High logic

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

Parameters

  instance | GPIO instance number(HW_GPIOA, HW_GPIOB, HW_GPIOC, etc.)
  pin | GPIO port pin number

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

Parameters

  instance | GPIO instance number(HW_GPIOA, HW_GPIOB, HW_GPIOC, etc.)
  pin | GPIO port pin number

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

Parameters

  instance | GPIO instance number(HW_GPIOA, HW_GPIOB, HW_GPIOC, etc.)
  pin | GPIO port pin number

static void gpio_hal_write_port_output | ( | uint32_t | instance,
|  | uint32_t | portOutput
| ) |  |
| inline static

This function operates all 32 port pins.

Parameters

  instance | GPIO instance number (HW_GPIOA, HW_GPIOB, HW_GPIOC, etc.)
  portOutput | data 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_read_port_output | ( | uint32_t | instance | ) |
| inline static

This function operates all 32 port pins.

Parameters

  instance | GPIO instance number (HW_GPIOA, HW_GPIOB, HW_GPIOC, 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 uint32_t gpio_hal_read_pin_input | ( | uint32_t | instance,
|  | uint32_t | pin
| ) |  |
| inline static

Parameters

  instance | GPIO instance number(HW_GPIOA, HW_GPIOB, HW_GPIOC, etc.)
  pin | GPIO 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_read_port_input | ( | uint32_t | instance | ) |
| inline static

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

Parameters

  instance | GPIO instance number(HW_GPIOA, HW_GPIOB, HW_GPIOC, 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