1.1.4.12 1.6.13.13 1.7.14.13 1.10.11.13 1.11.11.13 1.12.11.13 1.13.10.13 1.14.10.13 1.15.10.13 1.16.8.13 1.17.8.13 1.18.9.13 1.19.8.13 1.20.8.13 1.21.9.13 1.22.13.13 1.23.12.13 1.24.9.13 GPIO_PinRead Function
C
bool GPIO_PinRead(GPIO_PIN pin)
uint8_t GPIO_PinRead(GPIO_PIN pin)
Summary
Read the selected pin value.
Description
This function reads the selected pin value. it reads the value regardless of pin configuration, whether uniquely as an input, or driven by the GPIO Controller, or driven by 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 |
---|---|
pin | One of the IO pins from the enum GPIO_PIN |
Returns
For API returning bool:
- True - Pin state is HIGH level (1).
- False - Pin state is LOW level (0).
For API returning uint8_t:
1 - Pin state is HIGH level
0 - Pin state is LOW level
Example
bool value; value = GPIO_PinRead(GPIO_PIN_RB3);
uint8_t value; value = GPIO_PinRead(GPIO_PIN_GPIO012); if (value) { //Pin is set } else { //Pin is cleared }
Remarks
To read the latched value on this pin, GPIO_PinLatchRead API should be used.