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

GPIO Driver for STM32F4/F7 Devices. More...

#include "common/phal_F4_F7/phal_F4_F7.h"

Go to the source code of this file.

Classes

struct  GPIOInitConfig_t
 Configuration entry for GPIO initilization. More...
 

Macros

#define GPIO_INIT_INPUT(gpio_bank, pin_num, input_pull_sel)
 Create GPIO Init struct to intilize a GPIO pin for input.
 
#define GPIO_INIT_OUTPUT(gpio_bank, pin_num, ospeed_sel)
 Create GPIO Init struct to intilize a GPIO pin for output.
 
#define GPIO_INIT_OUTPUT_OPEN_DRAIN(gpio_bank, pin_num, ospeed_sel)
 
#define GPIO_INIT_ANALOG(gpio_bank, pin_num)
 Create GPIO Init struct to intilize a GPIO pin for analog.
 
#define GPIO_INIT_AF(gpio_bank, pin_num, alt_func_num, ospeed_sel, otype_sel, input_pull_sel)
 Create GPIO Init struct to intilize a GPIO pin for alternate function.
 
#define GPIO_INIT_SDIO_CLK   GPIO_INIT_AF(GPIOC, 12, 12, GPIO_OUTPUT_ULTRA_SPEED, GPIO_OUTPUT_PUSH_PULL, GPIO_INPUT_PULL_UP)
 
#define GPIO_INIT_SDIO_CMD   GPIO_INIT_AF(GPIOD, 2, 12, GPIO_OUTPUT_ULTRA_SPEED, GPIO_OUTPUT_PUSH_PULL, GPIO_INPUT_PULL_UP)
 
#define GPIO_INIT_SDIO_DT0   GPIO_INIT_AF(GPIOC, 8, 12, GPIO_OUTPUT_ULTRA_SPEED, GPIO_OUTPUT_PUSH_PULL, GPIO_INPUT_PULL_UP)
 
#define GPIO_INIT_SDIO_DT1   GPIO_INIT_AF(GPIOC, 9, 12, GPIO_OUTPUT_ULTRA_SPEED, GPIO_OUTPUT_PUSH_PULL, GPIO_INPUT_PULL_UP)
 
#define GPIO_INIT_SDIO_DT2   GPIO_INIT_AF(GPIOC, 10, 12, GPIO_OUTPUT_ULTRA_SPEED, GPIO_OUTPUT_PUSH_PULL, GPIO_INPUT_PULL_UP)
 
#define GPIO_INIT_SDIO_DT3   GPIO_INIT_AF(GPIOC, 11, 12, GPIO_OUTPUT_ULTRA_SPEED, GPIO_OUTPUT_PUSH_PULL, GPIO_INPUT_PULL_UP)
 
#define GPIO_INIT_MCO1_PA8   GPIO_INIT_AF(GPIOA, 8, 0, GPIO_OUTPUT_ULTRA_SPEED, GPIO_OUTPUT_PUSH_PULL, GPIO_INPUT_OPEN_DRAIN)
 

Enumerations

enum  GPIOPinType_t { GPIO_TYPE_INPUT = 0b00 , GPIO_TYPE_OUTPUT = 0b01 , GPIO_TYPE_AF = 0b10 , GPIO_TYPE_ANALOG = 0b11 }
 Configuration type for GPIO Pin.
 
enum  GPIOOutputSpeed_t { GPIO_OUTPUT_LOW_SPEED = 0b00 , GPIO_OUTPUT_MED_SPEED = 0b01 , GPIO_OUTPUT_HIGH_SPEED = 0b10 , GPIO_OUTPUT_ULTRA_SPEED = 0b11 }
 Slew rate control for output pins.
 
enum  GPIOOutputPull_t { GPIO_OUTPUT_PUSH_PULL = 0b0 , GPIO_OUTPUT_OPEN_DRAIN = 0b1 }
 Output drive mode selection.
 
enum  GPIOInputPull_t { GPIO_INPUT_OPEN_DRAIN = 0b00 , GPIO_INPUT_PULL_UP = 0b01 , GPIO_INPUT_PULL_DOWN = 0b10 }
 Enable internal pullup/down resistors.
 

Functions

bool PHAL_initGPIO (GPIOInitConfig_t config[], uint8_t config_len)
 Initilize the GPIO perpheral given a list of configuration fields for all of the GPIO pins. Will also enable the GPIO RCC clock.
 

Detailed Description

GPIO Driver for STM32F4/F7 Devices.

Author
Adam Busch (busch.nosp@m.8@pu.nosp@m.rdue..nosp@m.edu)
Version
0.1
Date
2021-09-20

Macro Definition Documentation

◆ GPIO_INIT_AF

#define GPIO_INIT_AF ( gpio_bank,
pin_num,
alt_func_num,
ospeed_sel,
otype_sel,
input_pull_sel )
Value:
{ \
.bank = gpio_bank, .pin = pin_num, .type = GPIO_TYPE_AF, .config = {.af_num = alt_func_num, \
.ospeed = ospeed_sel, \
.otype = otype_sel, \
.pull = input_pull_sel } \
}

Create GPIO Init struct to intilize a GPIO pin for alternate function.

Parameters
gpio_bankGPIO_TypeDef* reference to the GPIO bank for the pin
pin_numPin number from GPIO bank to configure
alt_func_numAlternate function selection
ospeed_selPin output speed selection
otype_selPin output type selection
input_pull_selInput pullup/pulldown/high-z selection

◆ GPIO_INIT_ANALOG

#define GPIO_INIT_ANALOG ( gpio_bank,
pin_num )
Value:
{ \
.bank = gpio_bank, \
.pin = pin_num, \
.type = GPIO_TYPE_ANALOG}

Create GPIO Init struct to intilize a GPIO pin for analog.

Parameters
gpio_bankGPIO_TypeDef* reference to the GPIO bank for the pin
pin_numPin number from GPIO bank to configure

◆ GPIO_INIT_INPUT

#define GPIO_INIT_INPUT ( gpio_bank,
pin_num,
input_pull_sel )
Value:
{ \
.bank = gpio_bank, .pin = pin_num, .type = GPIO_TYPE_INPUT, .config = {.pull = input_pull_sel } \
}

Create GPIO Init struct to intilize a GPIO pin for input.

Parameters
gpio_bankGPIO_TypeDef* reference to the GPIO bank for the pin
pin_numPin number from GPIO bank to configure
input_pull_selInput pullup/pulldown/high-z selection

◆ GPIO_INIT_OUTPUT

#define GPIO_INIT_OUTPUT ( gpio_bank,
pin_num,
ospeed_sel )
Value:
{ \
.bank = gpio_bank, .pin = pin_num, .type = GPIO_TYPE_OUTPUT, .config = {.ospeed = ospeed_sel, \
.otype = GPIO_OUTPUT_PUSH_PULL } \
}

Create GPIO Init struct to intilize a GPIO pin for output.

Parameters
gpio_bankGPIO_TypeDef* reference to the GPIO bank for the pin
pin_numPin number from GPIO bank to configure
ospeed_selPin output speed selection

◆ GPIO_INIT_OUTPUT_OPEN_DRAIN

#define GPIO_INIT_OUTPUT_OPEN_DRAIN ( gpio_bank,
pin_num,
ospeed_sel )
Value:
{ \
.bank = gpio_bank, .pin = pin_num, .type = GPIO_TYPE_OUTPUT, .config = {.ospeed = ospeed_sel, \
.otype = GPIO_OUTPUT_OPEN_DRAIN } \
}

Function Documentation

◆ PHAL_initGPIO()

bool PHAL_initGPIO ( GPIOInitConfig_t config[],
uint8_t config_len )

Initilize the GPIO perpheral given a list of configuration fields for all of the GPIO pins. Will also enable the GPIO RCC clock.

Parameters
configA list of GPIOs to config
config_lenNumber of GPIOs in the config list
Returns
true All GPIOs were a valid configuration format
false Some of the GPIOs had an invalid configuration format