36#ifndef _FREERTOS_DRIVERS_ST_STM32GPIO_HXX_
37#define _FREERTOS_DRIVERS_ST_STM32GPIO_HXX_
49template <u
int32_t GPIOx, u
int16_t PIN, u
int8_t PIN_NUM>
struct Stm32GpioDefs
52 static GPIO_TypeDef *
port()
54 return (GPIO_TypeDef *)GPIOx;
64 static void set(
bool value)
69#if 0 && (defined(STM32F303xC) || defined(STM32F303xE))
77#if 0 && (defined(STM32F303xC) || defined(STM32F303xE))
107 uint8_t* mode = (uint8_t*)
port();
108 uint8_t m = mode[PIN_NUM >> 1];
109 if (PIN_NUM & 1) { m >>= 4; }
115template <
class Defs,
bool SAFE_VALUE>
struct GpioOutputPin :
public Defs
123 GPIO_InitTypeDef gpio_init = {0};
124 gpio_init.Pin = pin();
125 gpio_init.Mode = GPIO_MODE_OUTPUT_PP;
126 gpio_init.Pull = GPIO_NOPULL;
127 gpio_init.Speed = GPIO_SPEED_FREQ_LOW;
128 HAL_GPIO_Init(port(), &gpio_init);
163template <
class Defs, u
int32_t PULL_MODE>
struct GpioInputPin :
public Defs
171 GPIO_InitTypeDef gpio_init = {0};
172 gpio_init.Pin = pin();
173 gpio_init.Mode = GPIO_MODE_INPUT;
174 gpio_init.Pull = PULL_MODE;
175 gpio_init.Speed = GPIO_SPEED_FREQ_LOW;
176 HAL_GPIO_Init(port(), &gpio_init);
232#define GPIO_PIN(NAME, BaseClass, PORTNAME, NUM) \
233 typedef BaseClass<Stm32GpioDefs<(uint32_t)(GPIO ## PORTNAME ## _BASE), GPIO_PIN_ ## NUM, NUM>> NAME##_Pin
Creates an implementation of an os-independent Gpio object from a hardware-specific static Gpio struc...
OS-independent abstraction for GPIO.
Parametric GPIO output class.
static void hw_init()
Initializes the hardware pin.
static void set(bool value)
Sets the output pinm.
static void hw_set_to_safe()
Sets the output pin to a safe value.
Defines a GPIO output pin, initialized to be an output pin with high level.
Defines a GPIO output pin, initialized to be an output pin with low level.
Defines a GPIO output pin with high-current drive and low initialization level.
Static GPIO implementation for the STM32 microcontrollers.
static bool get()
Sets the output pin to a given level.
static void set(bool value)
Sets the output pin to a given level.
static constexpr const Gpio * instance()
static void toggle()
Changes the output pin level.
static GPIO_TypeDef * port()