APM:Libraries
Classes | Macros | Typedefs | Enumerations | Functions | Variables
gpio_hal.h File Reference
#include "hal_types.h"
#include "exti.h"
Include dependency graph for gpio_hal.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  gpio_dev
 

Macros

#define Bit_RESET   0
 
#define Bit_SET   1
 

Typedefs

typedef enum gpio_pin_mode gpio_pin_mode
 GPIO Pin modes. More...
 
typedef struct gpio_dev gpio_dev
 

Enumerations

enum  gpio_pin_mode {
  GPIO_INPUT_FLOATING, GPIO_OUTPUT_PP, GPIO_AF_OUTPUT_PP, GPIO_INPUT_ANALOG,
  GPIO_INPUT_PD, GPIO_INPUT_PU, GPIO_OUTPUT_OD, GPIO_OUTPUT_OD_PU,
  GPIO_AF_OUTPUT_OD, GPIO_AF_OUTPUT_OD_PU, GPIO_PIN_MODE_LAST
}
 GPIO Pin modes. More...
 
enum  GPIOSpeed_t { GPIO_speed_2MHz = 0x00, GPIO_speed_25MHz = 0x01, GPIO_speed_50MHz = 0x02, GPIO_speed_100MHz = 0x03 }
 

Functions

void gpio_init (const gpio_dev *const dev)
 
void gpio_init_all (void)
 
void gpio_set_mode (const gpio_dev *const dev, uint8_t pin, gpio_pin_mode mode)
 
static void gpio_set_af_mode (const gpio_dev *const dev, uint8_t pin, uint8_t mode)
 
static INLINE void gpio_write_bit (const gpio_dev *const dev, uint8_t pin, uint8_t val)
 
static INLINE uint8_t gpio_read_bit (const gpio_dev *const dev, uint8_t pin)
 
static void gpio_toggle_bit (const gpio_dev *const dev, uint8_t pin)
 
static afio_exti_port gpio_exti_port (const gpio_dev *const dev)
 
static void gpio_set_speed (const gpio_dev *const dev, uint8_t pin, GPIOSpeed_t gpio_speed)
 
static void afio_exti_select (afio_exti_port gpio_port, afio_exti_num pin)
 

Variables

const gpio_dev gpioa
 
const gpio_dev *const _GPIOA
 
const gpio_dev gpiob
 
const gpio_dev *const _GPIOB
 
const gpio_dev gpioc
 
const gpio_dev *const _GPIOC
 
const gpio_dev gpiod
 
const gpio_dev *const _GPIOD
 
const gpio_dev gpioe
 
const gpio_dev *const _GPIOE
 
const gpio_dev gpiof
 
const gpio_dev *const _GPIOF
 
const gpio_dev gpiog
 
const gpio_dev *const _GPIOG
 

Macro Definition Documentation

◆ Bit_RESET

#define Bit_RESET   0

Definition at line 39 of file gpio_hal.h.

Referenced by gpio_read_bit().

◆ Bit_SET

#define Bit_SET   1

Definition at line 40 of file gpio_hal.h.

Referenced by gpio_read_bit().

Typedef Documentation

◆ gpio_dev

typedef struct gpio_dev gpio_dev

GPIO device type

◆ gpio_pin_mode

GPIO Pin modes.

These only allow for 50MHZ max output speeds; if you want slower, use direct register access.

Enumeration Type Documentation

◆ gpio_pin_mode

GPIO Pin modes.

These only allow for 50MHZ max output speeds; if you want slower, use direct register access.

Enumerator
GPIO_INPUT_FLOATING 

Input floating.

GPIO_OUTPUT_PP 

Output push-pull.

GPIO_AF_OUTPUT_PP 

Alternate function output push-pull.

GPIO_INPUT_ANALOG 

Analog input.

GPIO_INPUT_PD 

Input pull-down.

GPIO_INPUT_PU 

Input pull-up.

GPIO_OUTPUT_OD 

Output open-drain.

GPIO_OUTPUT_OD_PU 

Output open-drain with pullUp

GPIO_AF_OUTPUT_OD 

Alternate function output open drain.

GPIO_AF_OUTPUT_OD_PU 

Alternate function output open drain with pullup

GPIO_PIN_MODE_LAST 

Definition at line 23 of file gpio_hal.h.

◆ GPIOSpeed_t

Enumerator
GPIO_speed_2MHz 

Low speed

GPIO_speed_25MHz 

Medium speed

GPIO_speed_50MHz 

Fast speed

GPIO_speed_100MHz 

High speed on 30 pF (80 MHz Output max speed on 15 pF)

Definition at line 42 of file gpio_hal.h.

Function Documentation

◆ afio_exti_select()

static void afio_exti_select ( afio_exti_port  gpio_port,
afio_exti_num  pin 
)
inlinestatic

Definition at line 168 of file gpio_hal.h.

Referenced by exti_attach_interrupt(), and exti_attach_interrupt_pri().

Here is the caller graph for this function:

◆ gpio_exti_port()

static afio_exti_port gpio_exti_port ( const gpio_dev *const  dev)
inlinestatic

Definition at line 153 of file gpio_hal.h.

Referenced by F4Light::GPIO::_attach_interrupt().

Here is the caller graph for this function:

◆ gpio_init()

void gpio_init ( const gpio_dev *const  dev)

Initialize a GPIO device.

◆ gpio_init_all()

void gpio_init_all ( void  )

Initialize and reset all available GPIO devices.

Definition at line 90 of file gpio_hal.c.

Referenced by F4Light::GPIO::init().

Here is the caller graph for this function:

◆ gpio_read_bit()

static INLINE uint8_t gpio_read_bit ( const gpio_dev *const  dev,
uint8_t  pin 
)
static

Definition at line 130 of file gpio_hal.h.

Referenced by F4Light::DigitalSource::_read(), F4Light::GPIO::_read(), i2c_bus_reset(), is_usb_connected(), and F4Light::GPIO::usb_connected().

Here is the caller graph for this function:

◆ gpio_set_af_mode()

static void gpio_set_af_mode ( const gpio_dev *const  dev,
uint8_t  pin,
uint8_t  mode 
)
inlinestatic

Set the alternate function mode of a GPIO pin.

Parameters
devGPIO device.
pinPin on the device whose mode to set, 0–15.
modealternate function mode to set the pin to.
See also
gpio_pin_mode

Definition at line 102 of file gpio_hal.h.

Referenced by F4Light::GPIO::_pinMode(), F4Light::UARTDriver::begin(), i2c_lowLevel_init(), pwmInitializeInput(), spi_gpio_master_cfg(), and usb_periphcfg().

Here is the caller graph for this function:

◆ gpio_set_mode()

void gpio_set_mode ( const gpio_dev *const  dev,
uint8_t  pin,
gpio_pin_mode  mode 
)

Set the mode of a GPIO pin.

Definition at line 125 of file gpio_hal.c.

Referenced by F4Light::GPIO::_pinMode(), F4Light::UARTDriver::begin(), boardInit(), i2c_master_release_bus(), F4Light::SPIDevice::init(), Soft_I2C::init_hw(), F4Light::DigitalSource::mode(), pwmInitializeInput(), F4Light::AnalogSource::setup_read(), spi_gpio_master_cfg(), spi_gpio_slave_cfg(), F4Light::AnalogSource::stop_read(), usb_close(), usb_periphcfg(), and usb_setParams().

Here is the caller graph for this function:

◆ gpio_set_speed()

static void gpio_set_speed ( const gpio_dev *const  dev,
uint8_t  pin,
GPIOSpeed_t  gpio_speed 
)
inlinestatic

Definition at line 161 of file gpio_hal.h.

Referenced by F4Light::GPIO::_pinMode(), F4Light::GPIO::_setSpeed(), F4Light::SPIDevice::init(), Soft_I2C::init_hw(), F4Light::DigitalSource::mode(), and spi_gpio_master_cfg().

Here is the caller graph for this function:

◆ gpio_toggle_bit()

static void gpio_toggle_bit ( const gpio_dev *const  dev,
uint8_t  pin 
)
inlinestatic

Definition at line 145 of file gpio_hal.h.

Referenced by F4Light::GPIO::_toggle(), and F4Light::DigitalSource::toggle().

Here is the caller graph for this function:

◆ gpio_write_bit()

static INLINE void gpio_write_bit ( const gpio_dev *const  dev,
uint8_t  pin,
uint8_t  val 
)
static

Definition at line 115 of file gpio_hal.h.

Referenced by __attribute__(), F4Light::DigitalSource::_write(), F4Light::GPIO::_write(), boardInit(), i2c_bus_reset(), i2c_master_release_bus(), F4Light::SPIDevice::init(), F4Light::AnalogSource::setup_read(), and F4Light::AnalogSource::stop_read().

Here is the caller graph for this function:

Variable Documentation

◆ _GPIOA

const gpio_dev* const _GPIOA

GPIO port A device.

Definition at line 23 of file gpio_hal.c.

Referenced by usb_periphcfg().

◆ _GPIOB

const gpio_dev* const _GPIOB

GPIO port B device.

Definition at line 31 of file gpio_hal.c.

◆ _GPIOC

const gpio_dev* const _GPIOC

GPIO port C device.

Definition at line 39 of file gpio_hal.c.

◆ _GPIOD

const gpio_dev* const _GPIOD

GPIO port D device.

Definition at line 47 of file gpio_hal.c.

◆ _GPIOE

const gpio_dev* const _GPIOE

GPIO port E device.

Definition at line 55 of file gpio_hal.c.

◆ _GPIOF

const gpio_dev* const _GPIOF

GPIO port F device.

Definition at line 63 of file gpio_hal.c.

◆ _GPIOG

const gpio_dev* const _GPIOG

GPIO port G device.

Definition at line 71 of file gpio_hal.c.

◆ gpioa

const gpio_dev gpioa

Definition at line 17 of file gpio_hal.c.

◆ gpiob

const gpio_dev gpiob

Definition at line 25 of file gpio_hal.c.

◆ gpioc

const gpio_dev gpioc

Definition at line 33 of file gpio_hal.c.

◆ gpiod

const gpio_dev gpiod

Definition at line 41 of file gpio_hal.c.

◆ gpioe

const gpio_dev gpioe

Definition at line 49 of file gpio_hal.c.

◆ gpiof

const gpio_dev gpiof

Definition at line 57 of file gpio_hal.c.

◆ gpiog

const gpio_dev gpiog

Definition at line 65 of file gpio_hal.c.