PER Firmware
Loading...
Searching...
No Matches
gpio.c File Reference

G4 GPIO public API implementation. More...

Include dependency graph for gpio.c:

Functions

bool PHAL_GPIO_init (PHAL_GPIO_InitConfig_t config[], size_t config_len)
 Initialize a set of GPIO pins from a configuration table.
 
bool PHAL_GPIO_read (const GPIO_TypeDef *bank, uint8_t pin)
 Read the current input state of a pin.
 
void PHAL_GPIO_write (GPIO_TypeDef *bank, uint8_t pin, bool value)
 Drive an output pin high or low.
 
void PHAL_GPIO_toggle (GPIO_TypeDef *bank, uint8_t pin)
 Flip an output pin's current state.
 

Detailed Description

G4 GPIO public API implementation.

Author
Millan Kumar (kumar.nosp@m.798@.nosp@m.purdu.nosp@m.e.ed.nosp@m.u)

Function Documentation

◆ PHAL_GPIO_init()

bool PHAL_GPIO_init ( PHAL_GPIO_InitConfig_t config[],
size_t config_len )

Initialize a set of GPIO pins from a configuration table.

Enables each pin's port clock, then configures mode, speed, drive type, pull, and alternate function per entry as applicable to that entry's PHAL_GPIO_PinType_t

Register fields that don't apply to a given type (ex: pull for an output pin) are left untouched.

When encountering an unknown bank, pin outside 0-15, or unrecognized type, stops and returns false. Already configured pins remain configured.

Parameters
configArray of pin configurations
config_lenNumber of entries in config
Returns
true if every entry was valid (bank, pin #, type) and configured; false otherwise
Here is the call graph for this function:
Here is the caller graph for this function:

◆ PHAL_GPIO_read()

bool PHAL_GPIO_read ( const GPIO_TypeDef * bank,
uint8_t pin )

Read the current input state of a pin.

Parameters
bankGPIO port
pinPin number, 0-15
Returns
true if the pin currently reads high
Here is the call graph for this function:

◆ PHAL_GPIO_toggle()

void PHAL_GPIO_toggle ( GPIO_TypeDef * bank,
uint8_t pin )

Flip an output pin's current state.

Parameters
bankGPIO port
pinPin number, 0-15
Here is the call graph for this function:

◆ PHAL_GPIO_write()

void PHAL_GPIO_write ( GPIO_TypeDef * bank,
uint8_t pin,
bool value )

Drive an output pin high or low.

Safe to call from an ISR concurrently with other threads/etc touching other pins on the same port

Parameters
bankGPIO port
pinPin number, 0-15
valuetrue to drive high, false to drive low
Here is the call graph for this function: