1.7.14.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.