![]() |
S32 SDK
|
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 | |
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... | |
|
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.
baseAddr | GPIO base pointer (PTA, PTB, PTC, etc.) |
pins | pin mask of bits to be cleared. Each bit represents one pin (LSB is pin 0, MSB is pin 31). For each bit:
|
Definition at line 145 of file gpio_hal.h.
|
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.
baseAddr | GPIO base pointer (PTA, PTB, PTC, etc.) |
Definition at line 200 of file gpio_hal.h.
|
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.
baseAddr | GPIO base pointer (PTA, PTB, PTC, etc.) |
Definition at line 107 of file gpio_hal.h.
|
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.
baseAddr | GPIO base pointer (PTA, PTB, PTC, etc.) |
Definition at line 282 of file gpio_hal.h.
|
inlinestatic |
Read input pins.
This function returns the current input values from a port. Only pins configured as input will have meaningful values.
baseAddr | GPIO base pointer (PTA, PTB, PTC, etc.) |
Definition at line 181 of file gpio_hal.h.
|
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)
baseAddr | GPIO base pointer (PTA, PTB, PTC, etc.) |
pinNumber | the pin number for which to configure the direction |
pinDirection | the pin direction:
|
Definition at line 219 of file gpio_hal.h.
|
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.
baseAddr | GPIO base pointer (PTA, PTB, PTC, etc.) |
pins | pin mask of bits to be set. Each bit represents one pin (LSB is pin 0, MSB is pin 31). For each bit:
|
Definition at line 126 of file gpio_hal.h.
|
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.
baseAddr | GPIO base pointer (PTA, PTB, PTC, etc.) |
pins | pin mask where each bit represents one pin (LSB is pin 0, MSB is pin 31). For each bit:
|
Definition at line 243 of file gpio_hal.h.
|
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.
baseAddr | GPIO base pointer (PTA, PTB, PTC, etc.) |
pins | pin mask where each bit represents one pin (LSB is pin 0, MSB is pin 31). For each bit:
|
Definition at line 263 of file gpio_hal.h.
|
inlinestatic |
Toggle pins value.
This function toggles output pins listed in parameter pins (bits that are '1'). Pins corresponding to '0' will be unaffected.
baseAddr | GPIO base pointer (PTA, PTB, PTC, etc.) |
pins | pin mask of bits to be toggled. Each bit represents one pin (LSB is pin 0, MSB is pin 31). For each bit:
|
Definition at line 163 of file gpio_hal.h.
|
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).
baseAddr | GPIO base pointer (PTA, PTB, PTC, etc.) |
pinNumber | pin number to be written |
pinValue | pin value to be written
|
Definition at line 68 of file gpio_hal.h.
|
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.
baseAddr | GPIO base pointer (PTA, PTB, PTC, etc.) |
pins | pin mask to be written
|
Definition at line 89 of file gpio_hal.h.