STM32 RTOS 0.2.3
Bare-metal preemptive RTOS for STM32F446RE
Loading...
Searching...
No Matches
gpio.h
Go to the documentation of this file.
1
16#ifndef GPIO_H
17#define GPIO_H
18
19#include "driver_status.h"
20#include "gpio_reg.h"
21
22#include <stdint.h>
23
28
29#define GPIO_AF_MAX (15U)
30
57
64
66typedef struct GpioResetValues_t
67{
68 uint32_t MODER;
69 uint32_t OSPEEDR;
70 uint32_t PUPDR;
72
84
101 uint32_t otype, uint32_t ospeed, uint32_t pupd);
102
114void gpioDeinit(GpioRegisters_t *port, GpioPin_e pin);
115
129
142 uint32_t af);
143
152
161
174
176
177#endif /* GPIO_H */
The status every fallible driver function returns.
GPIO registers for ports A to H (RM0390 section 7.4).
DriverStatus_e
Outcome of a driver call: a category for control flow, not a diagnosis.
#define DRIVER_MUST_CHECK
Make ignoring a function's result a compile error (with -Werror).
void gpioDeinit(GpioRegisters_t *port, GpioPin_e pin)
Return a pin to its power-on configuration.
Definition gpio.c:83
GpioPin_e
Pin number within a port.
Definition gpio.h:39
GpioPinState_e
Logic level of a pin.
Definition gpio.h:60
void gpioWritePin(GpioRegisters_t *port, GpioPin_e pin, GpioPinState_e level)
Drive a pin high or low with one atomic BSRR write.
Definition gpio.c:140
void gpioDeinitToReset(GpioRegisters_t *port, GpioPin_e pin, GpioResetValues_t reset)
gpioDeinit() with the reset values supplied by the caller.
Definition gpio.c:88
DRIVER_MUST_CHECK DriverStatus_e gpioSetAlternateFunction(GpioRegisters_t *port, GpioPin_e pin, uint32_t af)
Select a pin's alternate function in AFRL/AFRH.
Definition gpio.c:110
DRIVER_MUST_CHECK DriverStatus_e gpioInit(GpioRegisters_t *port, GpioPin_e pin, uint32_t mode, uint32_t otype, uint32_t ospeed, uint32_t pupd)
Configure a pin's mode, output type, speed and pull.
Definition gpio.c:30
GpioPinState_e gpioReadPin(const GpioRegisters_t *port, GpioPin_e pin)
Read a pin's input level from IDR.
Definition gpio.c:154
GpioResetValues_t gpioPortResetValues(const GpioRegisters_t *port)
Look up a port's power-on MODER, OSPEEDR and PUPDR values.
Definition gpio.c:60
void gpioTogglePin(GpioRegisters_t *port, GpioPin_e pin)
Invert a pin's output level.
Definition gpio.c:167
@ GPIO_PIN_0
Pin 0.
Definition gpio.h:40
@ GPIO_PIN_1
Pin 1.
Definition gpio.h:41
@ GPIO_PIN_6
Pin 6.
Definition gpio.h:46
@ GPIO_PIN_5
Pin 5.
Definition gpio.h:45
@ GPIO_PIN_3
Pin 3.
Definition gpio.h:43
@ GPIO_PIN_11
Pin 11.
Definition gpio.h:51
@ GPIO_PIN_8
Pin 8.
Definition gpio.h:48
@ GPIO_PIN_12
Pin 12.
Definition gpio.h:52
@ GPIO_PIN_7
Pin 7.
Definition gpio.h:47
@ GPIO_PIN_10
Pin 10.
Definition gpio.h:50
@ GPIO_PIN_9
Pin 9.
Definition gpio.h:49
@ GPIO_PIN_15
Pin 15.
Definition gpio.h:55
@ GPIO_PIN_4
Pin 4.
Definition gpio.h:44
@ GPIO_PIN_13
Pin 13.
Definition gpio.h:53
@ GPIO_PIN_14
Pin 14.
Definition gpio.h:54
@ GPIO_PIN_2
Pin 2.
Definition gpio.h:42
@ GPIO_PIN_SET
High.
Definition gpio.h:62
@ GPIO_PIN_RESET
Low.
Definition gpio.h:61
GPIO port register block.
Definition gpio_reg.h:33
Power-on values of the GPIO registers that are not zero on every port.
Definition gpio.h:67
uint32_t MODER
MODER reset value.
Definition gpio.h:68
uint32_t PUPDR
PUPDR reset value.
Definition gpio.h:70
uint32_t OSPEEDR
OSPEEDR reset value.
Definition gpio.h:69