1.11.11.2 GPIO_PortRead Function

C

uint32_t GPIO_PortRead(GPIO_PORT port)

Summary

Read all the I/O lines of the selected port port.

Description

This function reads the live data values on all the I/O lines of the selected port. Bit values returned in each position indicate corresponding pin state.

  • 1 - Pin state is HIGH level (1).

  • 0 - Pin state is LOW level (0)

This function reads the value regardless of pin configuration, whether it is set as as an input, driven by the GPIO Controller, or driven by a peripheral.

Precondition

Reading the I/O line levels requires the clock of the GPIO Controller to be enabled, otherwise this API reads the levels present on the I/O line at the time the clock was enabled.

Parameters

Param Description
port One of the IO ports from the enum GPIO_PORT

Returns

Returns the read value of all the I/O lines of the selected port port.

Example

uint32_t value;
value = GPIO_PortRead(GPIO_PORT_C);

Remarks

If the port has less than 32-bits, unimplemented pins will read as low (0). Implemented pins are Right aligned in the 32-bit return value.