77#include "periph_cpu.h"
88#if !defined(GPIO_PORT_UNDEF) || defined(DOXYGEN)
92#define GPIO_PORT_UNDEF UINTPTR_MAX
105# define GPIO_PORT_NUMBERING_ALPHABETIC implementation_specific
121#define GPIO_PORT_0 implementation_specific
153#if !defined(HAVE_GPIO_STATE_T) || defined(DOXYGEN)
245#if !defined(HAVE_GPIO_PULL_T) || defined(DOXYGEN)
258#if !defined(HAVE_GPIO_PULL_STRENGTH_T) || defined(DOXYGEN)
285#define GPIO_PULL_NUMOF (1U + (GPIO_PULL_WEAKEST != GPIO_PULL_WEAK) \
286 + (GPIO_PULL_WEAK != GPIO_PULL_STRONG) \
287 + (GPIO_PULL_STRONG != GPIO_PULL_STRONGEST))
289#if !defined(HAVE_GPIO_DRIVE_STRENGTH_T) || defined(DOXYGEN)
314#define GPIO_DRIVE_NUMOF (1U + (GPIO_DRIVE_WEAKEST != GPIO_DRIVE_WEAK) \
315 + (GPIO_DRIVE_WEAK != GPIO_DRIVE_STRONG) \
316 + (GPIO_DRIVE_STRONG != GPIO_DRIVE_STRONGEST))
318#if !defined(HAVE_GPIO_SLEW_T) || defined(DOXYGEN)
349#define GPIO_SLEW_NUMOF (1U + (GPIO_SLEW_SLOWEST != GPIO_SLEW_SLOW) \
350 + (GPIO_SLEW_SLOW != GPIO_SLEW_FAST) \
351 + (GPIO_SLEW_FAST != GPIO_SLEW_FASTEST))
399#if !defined(HAVE_GPIO_CONF_T) && !defined(DOXYGEN)
486 .initial_value =
false,
498 .initial_value =
true,
511 .initial_value =
true,
681#if defined(DOXYGEN) || !defined(HAVE_GPIO_LL_PREPARE_WRITE_ALL_PINS)
712#if defined(DOXYGEN) || !defined(HAVE_GPIO_LL_PREPARE_WRITE)
733#if defined(DOXYGEN) || !defined(HAVE_GPIO_LL_PREPARE_SWITCH_DIR)
861#if !MODULE_PERIPH_GPIO_LL_SWITCH_DIR
877 extern void gpio_ll_switch_dir_output_used_but_feature_gpio_ll_switch_dir_is_not_provided(
void);
878 gpio_ll_switch_dir_output_used_but_feature_gpio_ll_switch_dir_is_not_provided();
886 extern void gpio_ll_switch_dir_input_used_but_feature_gpio_ll_switch_dir_is_not_provided(
void);
887 gpio_ll_switch_dir_input_used_but_feature_gpio_ll_switch_dir_is_not_provided();
899#include "gpio_ll_arch.h"
901#if !defined(DOXYGEN) && !defined(GPIO_PORT_NUMBERING_ALPHABETIC)
902# define GPIO_PORT_NUMBERING_ALPHABETIC 0
909#if defined(GPIO_PORT_0) || defined(DOXYGEN)
913# define GPIO_PORT_A GPIO_PORT_0
915#if defined(GPIO_PORT_1) || defined(DOXYGEN)
919# define GPIO_PORT_B GPIO_PORT_1
921#if defined(GPIO_PORT_2) || defined(DOXYGEN)
925# define GPIO_PORT_C GPIO_PORT_2
927#if defined(GPIO_PORT_3) || defined(DOXYGEN)
931# define GPIO_PORT_D GPIO_PORT_3
933#if defined(GPIO_PORT_4) || defined(DOXYGEN)
937# define GPIO_PORT_E GPIO_PORT_4
939#if defined(GPIO_PORT_5) || defined(DOXYGEN)
943# define GPIO_PORT_F GPIO_PORT_5
945#if defined(GPIO_PORT_6) || defined(DOXYGEN)
949# define GPIO_PORT_G GPIO_PORT_6
951#if defined(GPIO_PORT_7) || defined(DOXYGEN)
955# define GPIO_PORT_H GPIO_PORT_7
957#if defined(GPIO_PORT_8) || defined(DOXYGEN)
961# define GPIO_PORT_I GPIO_PORT_8
963#if defined(GPIO_PORT_9) || defined(DOXYGEN)
967# define GPIO_PORT_J GPIO_PORT_9
969#if defined(GPIO_PORT_10) || defined(DOXYGEN)
973# define GPIO_PORT_K GPIO_PORT_10
975#if defined(GPIO_PORT_11) || defined(DOXYGEN)
979# define GPIO_PORT_L GPIO_PORT_11
981#if defined(GPIO_PORT_12) || defined(DOXYGEN)
985# define GPIO_PORT_M GPIO_PORT_12
987#if defined(GPIO_PORT_13) || defined(DOXYGEN)
991# define GPIO_PORT_N GPIO_PORT_13
993#if defined(GPIO_PORT_14) || defined(DOXYGEN)
997# define GPIO_PORT_O GPIO_PORT_14
999#if defined(GPIO_PORT_15) || defined(DOXYGEN)
1003# define GPIO_PORT_P GPIO_PORT_15
Platform-independent access to architecture details.
POSIX.1-2008 compliant version of the assert macro.
Low-level GPIO peripheral driver interface definitions.
static const gpio_conf_t gpio_ll_in_pk
A standard configuration for a generic input pin with pull resistor to keep signal at bus level.
static uint8_t gpio_get_pin_num(gpio_t pin)
Extract the pin number from a gpio_t
static void gpio_ll_set(gpio_port_t port, uword_t mask)
Perform an reg |= mask operation on the I/O register of the port.
gpio_pull_t
Enumeration of pull resistor configurations.
gpio_pull_strength_t
Enumeration of pull resistor values.
static const gpio_conf_t gpio_ll_in_pd
A standard configuration for a generic input pin with pull down resistor.
static const gpio_conf_t gpio_ll_out
A standard configuration for a generic push-pull output pin.
gpio_state_t
Enumeration of GPIO states (direction)
gpio_port_t gpio_port(uword_t num)
Get the gpio_port_t value of the port number num.
gpio_slew_t
Enumeration of slew rate settings.
int gpio_ll_init(gpio_port_t port, uint8_t pin, gpio_conf_t conf)
Initialize the given GPIO pin as specified.
static uword_t gpio_ll_prepare_write(gpio_port_t port, uword_t mask, uword_t value)
Helper to use gpio_ll_write side-effect free.
static gpio_port_t gpio_port_pack_addr(void *addr)
Pack a pointer into a gpio_port_t.
static void gpio_ll_switch_dir_output(gpio_port_t port, uword_t pins)
Turn GPIO pins specified by pins (obtained from gpio_ll_prepare_switch_dir) to outputs.
gpio_conf_t gpio_ll_query_conf(gpio_port_t port, uint8_t pin)
Retrieve the current configuration of a GPIO pin.
void gpio_ll_print_conf_common(const gpio_conf_t conf)
INTERNAL, use gpio_ll_print_conf instead.
gpio_drive_strength_t
Enumeration of drive strength options.
static const gpio_conf_t gpio_ll_in_pu
A standard configuration for a generic input pin with pull up resistor.
static void gpio_ll_switch_dir_input(gpio_port_t port, uword_t pins)
Turn GPIO pins specified by pins (obtained from gpio_ll_prepare_switch_dir) to inputs.
static uword_t gpio_ll_read(gpio_port_t port)
Get the current input value of all GPIO pins of the given port as bitmask.
static gpio_port_t gpio_get_port(gpio_t pin)
Extract the gpio_port_t from a gpio_t
static uword_t gpio_ll_prepare_write_all_outputs(gpio_port_t port, uword_t value)
Same as gpio_ll_prepare_write(port, UWORD_MAX, value), but faster.
typedef gpio_conf_t
GPIO pin configuration.
static const gpio_conf_t gpio_ll_in
A standard configuration for a generic floating input pin.
uword_t gpio_port_num(gpio_port_t port)
Get the number of the GPIO port port refers to.
static uword_t gpio_ll_prepare_switch_dir(uword_t mask)
Prepare bitmask for use with gpio_ll_switch_dir_output and gpio_ll_switch_dir_input.
static const gpio_conf_t gpio_ll_od_pu
A standard configuration for a generic open drain output with pull up.
static void * gpio_port_unpack_addr(gpio_port_t port)
Extract a data pointer that was packed by gpio_port_pack_addr.
static bool is_gpio_port_num_valid(uint_fast8_t num)
Check if the given number is a valid argument for gpio_port.
static uword_t gpio_ll_read_output(gpio_port_t port)
Get the current output value of all GPIO pins of the given port as bitmask.
static void gpio_ll_clear(gpio_port_t port, uword_t mask)
Perform an reg &= ~mask operation on the I/O register of the port.
static void gpio_ll_toggle(gpio_port_t port, uword_t mask)
Perform an reg ^= mask operation on the I/O register of the port.
static void gpio_ll_write(gpio_port_t port, uword_t state)
Perform a masked write operation on the I/O register of the port.
static const gpio_conf_t gpio_ll_od
A standard configuration for a generic floating open drain output.
uintptr_t gpio_port_t
GPIO port type.
void gpio_ll_print_conf(const gpio_conf_t conf)
Utility function to print a given GPIO configuration to stdio.
@ GPIO_FLOATING
No pull ups nor pull downs enabled.
@ GPIO_PULL_KEEP
Keep the signal at current logic level with pull up/down resistors.
@ GPIO_PULL_DOWN
Pull down resistor enabled.
@ GPIO_PULL_UP
Pull up resistor enabled.
@ GPIO_PULL_WEAKEST
Use the weakest (highest Ohm value) resistor.
@ GPIO_PULL_WEAK
Use a weak pull resistor.
@ GPIO_PULL_STRONG
Use a strong pull resistor.
@ GPIO_PULL_STRONGEST
Use the strongest pull resistor.
@ GPIO_OUTPUT_OPEN_SOURCE
Use pin as output in open emitter configuration.
@ GPIO_USED_BY_PERIPHERAL
The GPIO pin is used by a peripheral.
@ GPIO_OUTPUT_OPEN_DRAIN
Use pin as output in open collector configuration.
@ GPIO_OUTPUT_PUSH_PULL
Use pin as output in push-pull configuration.
@ GPIO_DISCONNECT
Disconnect pin from all peripherals.
@ GPIO_INPUT
Use pin as input.
@ GPIO_SLEW_SLOWEST
let the output voltage level rise/fall as slow as possible
@ GPIO_SLEW_FAST
let the output voltage level rise/fall fast
@ GPIO_SLEW_SLOW
let the output voltage level rise/fall slowly
@ GPIO_SLEW_FASTEST
let the output voltage level rise/fall as fast as possible
@ GPIO_DRIVE_STRONG
Use a strong drive strength.
@ GPIO_DRIVE_WEAK
Use a weak drive strength.
@ GPIO_DRIVE_STRONGEST
Use the strongest drive strength.
@ GPIO_DRIVE_WEAKEST
Use the weakest drive strength.
uint16_t gpio_t
GPIO type identifier.
uint< NUM > _t uword_t
Word sized unsigned integer.
Public members of gpio_conf_t
uint8_t bits
The raw bits of the configuration.
gpio_pull_t pull
Pull resistor configuration.
bool initial_value
Initial value of the output.
gpio_state_t state
State of the pin.