Quickstart
Informative
The shortest path to using GPIO: initialize, then read and write a pin. Binding rules are in Port — Requirements; signatures in API Reference.
Bring the driver up
Port_Init(NULL_PTR); /* driver: UNINIT -> INIT; all pins to configured function/direction */
Write and read a pin
Address pins through the generated symbols (PORT_PIN_<...>), never raw numbers:
Port_SetPinValue(PORT_PIN_LED, PORT_PIN_VALUE_HIGH); /* drive the LED pin high */
Port_PinValueType v = Port_GetPinValue(PORT_PIN_BUTTON);
if (v == PORT_PIN_VALUE_HIGH) {
/* button pin reads high */
}
Toggle a pin
Port_PinValueType now = Port_TogglePinValue(PORT_PIN_LED); /* flips LOW<->HIGH, returns new value */
That is a complete round trip. To update several pins of a port at once, see Reading and writing pins; to react to pin edges, see Edge detection.