|
19 | 19 | #ifndef PERIPH_CPU_GPIO_LL_H |
20 | 20 | #define PERIPH_CPU_GPIO_LL_H |
21 | 21 |
|
| 22 | +#include <stdalign.h> |
22 | 23 | #include <stdint.h> |
23 | 24 | #include "periph_cpu.h" |
24 | 25 |
|
@@ -88,8 +89,84 @@ typedef enum { |
88 | 89 | GPIO_TRIGGER_LEVEL_LOW = GPIO_TRIGGER_LEVEL | GPIO_TRIGGER_EDGE_FALLING, |
89 | 90 | } gpio_irq_trig_t; |
90 | 91 |
|
| 92 | +#define HAVE_GPIO_STATE_T |
| 93 | +typedef enum { |
| 94 | + GPIO_OUTPUT_PUSH_PULL, |
| 95 | + GPIO_OUTPUT_OPEN_DRAIN, |
| 96 | + GPIO_OUTPUT_OPEN_SOURCE, |
| 97 | + GPIO_INPUT, |
| 98 | + GPIO_USED_BY_PERIPHERAL, |
| 99 | + GPIO_DISCONNECT, |
| 100 | +} gpio_state_t; |
| 101 | + |
| 102 | +#define HAVE_GPIO_PULL_T |
| 103 | +typedef enum { |
| 104 | + GPIO_FLOATING, |
| 105 | + GPIO_PULL_UP, |
| 106 | + GPIO_PULL_DOWN, |
| 107 | + GPIO_PULL_KEEP, |
| 108 | +} gpio_pull_t; |
| 109 | + |
| 110 | +#define HAVE_GPIO_CONF_T |
| 111 | +typedef union gpio_conf_stm32 gpio_conf_t; |
| 112 | + |
91 | 113 | #endif /* ndef Doxygen */ |
92 | 114 |
|
| 115 | +/** |
| 116 | + * @brief GPIO pin configuration for STM32 MCUs. |
| 117 | + * @ingroup drivers_periph_gpio_ll |
| 118 | + */ |
| 119 | +union gpio_conf_stm32 { |
| 120 | + uint16_t bits; /**< the raw bits */ |
| 121 | + struct { |
| 122 | + /** |
| 123 | + * @brief State of the pin |
| 124 | + */ |
| 125 | + gpio_state_t state : 3; |
| 126 | + /** |
| 127 | + * @brief Pull resistor configuration |
| 128 | + */ |
| 129 | + gpio_pull_t pull : 2; |
| 130 | + /** |
| 131 | + * @brief Configure the slew rate of outputs |
| 132 | + * |
| 133 | + * @warning If the requested slew rate is not available, the closest fit |
| 134 | + * supported will be configured instead. |
| 135 | + * |
| 136 | + * This value is ignored *unless* @ref gpio_conf_stm32::state is |
| 137 | + * configured to @ref GPIO_OUTPUT_PUSH_PULL or @ref GPIO_OUTPUT_OPEN_DRAIN. |
| 138 | + */ |
| 139 | + gpio_slew_t slew_rate : 2; |
| 140 | + /** |
| 141 | + * @brief Whether to disable the input Schmitt trigger |
| 142 | + * |
| 143 | + * @details This could be called `schmitt_trigger` with inverse |
| 144 | + * meaning, but the API contract says that additional |
| 145 | + * members in the structure should have a sane |
| 146 | + * default when zero. |
| 147 | + * |
| 148 | + * This value is ignored *unless* @ref gpio_conf_stm32::state is |
| 149 | + * configured to @ref GPIO_INPUT. |
| 150 | + */ |
| 151 | + bool schmitt_trigger_disabled : 1; |
| 152 | + /** |
| 153 | + * @brief Initial value of the output |
| 154 | + * |
| 155 | + * Ignored if @ref gpio_conf_stm32::state is set to @ref GPIO_INPUT or |
| 156 | + * @ref GPIO_DISCONNECT. If the pin was previously in a high impedance |
| 157 | + * state, it is guaranteed to directly transition to the given initial |
| 158 | + * value. |
| 159 | + * |
| 160 | + * @ref gpio_ll_query_conf will write the current value of the specified |
| 161 | + * pin here, which is read from the input register when the state is |
| 162 | + * @ref GPIO_INPUT, otherwise the state from the output register is |
| 163 | + * consulted. |
| 164 | + */ |
| 165 | + bool initial_value : 1; |
| 166 | + uint8_t : 7; /*< padding */ |
| 167 | + }; |
| 168 | +}; |
| 169 | + |
93 | 170 | #ifdef __cplusplus |
94 | 171 | } |
95 | 172 | #endif |
|
0 commit comments