S32 SDK

Detailed Description

General Purpose Input/Output Hardware Abstraction Layer.

This HAL provides low-level access to all hardware features of the GPIO module.

This module provides methods for basic operations on the pins of the GPIO modules: configure data direction, read data, write, set and toggle pins.

The methods operate on the entire port (all 32 pins) so bit masks must be used to access individual bits. Some methods only act on the bits that have value '1' (leaving bits with value '0' unchanged), but others will affect all the pins, in this case a Read-Modify-Write operation is needed to keep the previous configuration.

This module assumes that the clocking and PORT configuration have been set up correctly. To see how to configure these modules, please refer to the Clock Manager (PCC HAL) and PORT modules.

In the following documentation the terms 'Set' and 'Clear' are used to refer to values of pins:

Writing a port means configuring each of its pins with the bit value corresponding to the pin's position.

The Set, Clear and Toggle methods operate only on pins with corresponding bits set to '1' in the bit mask. These methods do not require a Read-Modify-Write operation, as they will leave pins corresponding to bits with value '0' unchanged.

To use a pin as a GPIO pin, it needs to be configured as GPIO and, optionally, have pull up/down, drive strength etc. configured. This needs to be done using the PCC and PORT modules. The example below shows how to configure and use Pin 7 of Port C.

GPIO

General GPIO functions.

static void GPIO_HAL_WritePin (GPIO_Type *const baseAddr, const uint32_t pinNumber, const uint32_t pinValue)
 Write a pin of a port with a given value. More...
 
static void GPIO_HAL_WritePins (GPIO_Type *const baseAddr, const uint32_t pins)
 Write all pins of a port. More...
 
static uint32_t GPIO_HAL_GetPinsOutput (const GPIO_Type *const baseAddr)
 Get the current output from a port. More...
 
static void GPIO_HAL_SetPins (GPIO_Type *const baseAddr, const uint32_t pins)
 Write pins with 'Set' value. More...
 
static void GPIO_HAL_ClearPins (GPIO_Type *const baseAddr, const uint32_t pins)
 Write pins to 'Clear' value. More...
 
static void GPIO_HAL_TogglePins (GPIO_Type *const baseAddr, const uint32_t pins)
 Toggle pins value. More...
 
static uint32_t GPIO_HAL_ReadPins (const GPIO_Type *const baseAddr)
 Read input pins. More...
 
static uint32_t GPIO_HAL_GetPinsDirection (const GPIO_Type *const baseAddr)
 Get the pins directions configuration for a port. More...
 
static void GPIO_HAL_SetPinDirection (GPIO_Type *const baseAddr, const uint32_t pinNumber, const uint32_t pinDirection)
 Configure the direction for a certain pin from a port. More...
 
static void GPIO_HAL_SetPinsDirection (GPIO_Type *const baseAddr, const uint32_t pins)
 Set the pins directions configuration for a port. More...
 
static void GPIO_HAL_SetPortInputDisable (GPIO_Type *const baseAddr, const uint32_t pins)
 Set the pins input disable state for a port. More...
 
static uint32_t GPIO_HAL_GetPortInputDisable (const GPIO_Type *const baseAddr)
 Get the pins input disable state for a port. More...
 

Function Documentation

static void GPIO_HAL_ClearPins ( GPIO_Type *const  baseAddr,
const uint32_t  pins 
)
inlinestatic

Write pins to 'Clear' value.

This function configures output pins listed in parameter pins (bits that are '1') to have a 'cleared' value (LOW). Pins corresponding to '0' will be unaffected.

Parameters
baseAddrGPIO base pointer (PTA, PTB, PTC, etc.)
pinspin mask of bits to be cleared. Each bit represents one pin (LSB is pin 0, MSB is pin 31). For each bit:
  • 0: corresponding pin is unaffected
  • 1: corresponding pin is cleared (set to LOW) Implements : GPIO_HAL_ClearPins_Activity

Definition at line 145 of file gpio_hal.h.

static uint32_t GPIO_HAL_GetPinsDirection ( const GPIO_Type *const  baseAddr)
inlinestatic

Get the pins directions configuration for a port.

This function returns the current pins directions for a port. Pins corresponding to bits with value of '1' are configured as output and pins corresponding to bits with value of '0' are configured as input.

Parameters
baseAddrGPIO base pointer (PTA, PTB, PTC, etc.)
Returns
GPIO directions. Each bit represents one pin (LSB is pin 0, MSB is pin 31). For each bit:
  • 0: corresponding pin is set to input
  • 1: corresponding pin is set to output Implements : GPIO_HAL_GetPinsDirection_Activity

Definition at line 200 of file gpio_hal.h.

static uint32_t GPIO_HAL_GetPinsOutput ( const GPIO_Type *const  baseAddr)
inlinestatic

Get the current output from a port.

This function returns the current output that is written to a port. Only pins that are configured as output will have meaningful values.

Parameters
baseAddrGPIO base pointer (PTA, PTB, PTC, etc.)
Returns
GPIO outputs. Each bit represents one pin (LSB is pin 0, MSB is pin 31). For each bit:
  • 0: corresponding pin is set to LOW
  • 1: corresponding pin is set to HIGH Implements : GPIO_HAL_GetPinsOutput_Activity

Definition at line 107 of file gpio_hal.h.

static uint32_t GPIO_HAL_GetPortInputDisable ( const GPIO_Type *const  baseAddr)
inlinestatic

Get the pins input disable state for a port.

This function returns the current pins input state for a port. Pins corresponding to bits with value of '1' are not configured as input and pins corresponding to bits with value of '0' are configured as input.

Parameters
baseAddrGPIO base pointer (PTA, PTB, PTC, etc.)
Returns
GPIO input state. Each bit represents one pin (LSB is pin 0, MSB is pin 31). For each bit:
  • 0: corresponding pin is set to input
  • 1: corresponding pin is not set to input Implements : GPIO_HAL_GetPortInputDisable_Activity

Definition at line 282 of file gpio_hal.h.

static uint32_t GPIO_HAL_ReadPins ( const GPIO_Type *const  baseAddr)
inlinestatic

Read input pins.

This function returns the current input values from a port. Only pins configured as input will have meaningful values.

Parameters
baseAddrGPIO base pointer (PTA, PTB, PTC, etc.)
Returns
GPIO inputs. Each bit represents one pin (LSB is pin 0, MSB is pin 31). For each bit:
  • 0: corresponding pin is read as LOW
  • 1: corresponding pin is read as HIGH Implements : GPIO_HAL_ReadPins_Activity

Definition at line 181 of file gpio_hal.h.

static void GPIO_HAL_SetPinDirection ( GPIO_Type *const  baseAddr,
const uint32_t  pinNumber,
const uint32_t  pinDirection 
)
inlinestatic

Configure the direction for a certain pin from a port.

This function configures the direction for the given pin, with the given value('1' for pin to be configured as output and '0' for pin to be configured as input)

Parameters
baseAddrGPIO base pointer (PTA, PTB, PTC, etc.)
pinNumberthe pin number for which to configure the direction
pinDirectionthe pin direction:
  • 0: corresponding pin is set to input
  • 1: corresponding pin is set to output Implements : GPIO_HAL_SetPinDirection_Activity

Definition at line 219 of file gpio_hal.h.

static void GPIO_HAL_SetPins ( GPIO_Type *const  baseAddr,
const uint32_t  pins 
)
inlinestatic

Write pins with 'Set' value.

This function configures output pins listed in parameter pins (bits that are '1') to have a value of 'set' (HIGH). Pins corresponding to '0' will be unaffected.

Parameters
baseAddrGPIO base pointer (PTA, PTB, PTC, etc.)
pinspin mask of bits to be set. Each bit represents one pin (LSB is pin 0, MSB is pin 31). For each bit:
  • 0: corresponding pin is unaffected
  • 1: corresponding pin is set to HIGH Implements : GPIO_HAL_SetPins_Activity

Definition at line 126 of file gpio_hal.h.

static void GPIO_HAL_SetPinsDirection ( GPIO_Type *const  baseAddr,
const uint32_t  pins 
)
inlinestatic

Set the pins directions configuration for a port.

This function sets the direction configuration for all pins in a port. Pins corresponding to bits with value of '1' will be configured as output and pins corresponding to bits with value of '0' will be configured as input.

Parameters
baseAddrGPIO base pointer (PTA, PTB, PTC, etc.)
pinspin mask where each bit represents one pin (LSB is pin 0, MSB is pin 31). For each bit:
  • 0: corresponding pin is set to input
  • 1: corresponding pin is set to output Implements : GPIO_HAL_SetPinsDirection_Activity

Definition at line 243 of file gpio_hal.h.

static void GPIO_HAL_SetPortInputDisable ( GPIO_Type *const  baseAddr,
const uint32_t  pins 
)
inlinestatic

Set the pins input disable state for a port.

This function sets the pins input state for a port. Pins corresponding to bits with value of '1' will not be configured as input and pins corresponding to bits with value of '0' will be configured as input.

Parameters
baseAddrGPIO base pointer (PTA, PTB, PTC, etc.)
pinspin mask where each bit represents one pin (LSB is pin 0, MSB is pin 31). For each bit:
  • 0: corresponding pin is set to input
  • 1: corresponding pin is not set to input Implements : GPIO_HAL_SetPortInputDisable_Activity

Definition at line 263 of file gpio_hal.h.

static void GPIO_HAL_TogglePins ( GPIO_Type *const  baseAddr,
const uint32_t  pins 
)
inlinestatic

Toggle pins value.

This function toggles output pins listed in parameter pins (bits that are '1'). Pins corresponding to '0' will be unaffected.

Parameters
baseAddrGPIO base pointer (PTA, PTB, PTC, etc.)
pinspin mask of bits to be toggled. Each bit represents one pin (LSB is pin 0, MSB is pin 31). For each bit:
  • 0: corresponding pin is unaffected
  • 1: corresponding pin is toggled Implements : GPIO_HAL_TogglePins_Activity

Definition at line 163 of file gpio_hal.h.

static void GPIO_HAL_WritePin ( GPIO_Type *const  baseAddr,
const uint32_t  pinNumber,
const uint32_t  pinValue 
)
inlinestatic

Write a pin of a port with a given value.

This function writes the given pin from a port, with the given value ('0' represents LOW, '1' represents HIGH).

Parameters
baseAddrGPIO base pointer (PTA, PTB, PTC, etc.)
pinNumberpin number to be written
pinValuepin value to be written
  • 0: corresponding pin is set to LOW
  • 1: corresponding pin is set to HIGH Implements : GPIO_HAL_WritePin_Activity

Definition at line 68 of file gpio_hal.h.

static void GPIO_HAL_WritePins ( GPIO_Type *const  baseAddr,
const uint32_t  pins 
)
inlinestatic

Write all pins of a port.

This function writes all pins configured as output with the values given in the parameter pins. '0' represents LOW, '1' represents HIGH.

Parameters
baseAddrGPIO base pointer (PTA, PTB, PTC, etc.)
pinspin mask to be written
  • 0: corresponding pin is set to LOW
  • 1: corresponding pin is set to HIGH Implements : GPIO_HAL_WritePins_Activity

Definition at line 89 of file gpio_hal.h.