Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions drivers/include/periph/gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
* @brief Convert (port, pin) tuple to @c gpio_t value
*/
/* Default GPIO macro maps port-pin tuples to the pin value */
#define GPIO_PIN(x,y) ((gpio_t)((x & 0) | y))

Check warning on line 99 in drivers/include/periph/gpio.h

View workflow job for this annotation

GitHub Actions / static-tests

comma should be followed by whitespace
#endif

#ifndef GPIO_UNDEF
Expand All @@ -116,7 +116,7 @@
*/
#ifndef HAVE_GPIO_MODE_T
typedef enum {
GPIO_IN , /**< configure as input without pull resistor */

Check warning on line 119 in drivers/include/periph/gpio.h

View workflow job for this annotation

GitHub Actions / static-tests

comma should not be preceded by whitespace
GPIO_IN_PD, /**< configure as input with pull-down resistor */
GPIO_IN_PU, /**< configure as input with pull-up resistor */
GPIO_OUT, /**< configure as output in push-pull mode */
Expand Down Expand Up @@ -199,8 +199,8 @@
/**
* @brief Enable pin interrupt if configured as interrupt source
*
* Interrupts that would have occurred after @see gpio_irq_disable
* was called will be discarded.
* Interrupts that would have occurred after @see gpio_irq_disable
* was called will be discarded.
*
* @note You have to add the module `periph_gpio_irq` to your project to
* enable this function
Expand Down
29 changes: 29 additions & 0 deletions drivers/include/periph/gpio_ll.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@
* @warning This API is not stable yet and intended for internal use only
* as of now.
*
* # General
*
* Ports and pin numbers are not always internally defined as the same numbers
* that you would expect them to be. Therefore it is highly recommended to call
* the low level functions like gpio_ll_init() or gpio_ll_query_conf() with the
* gpio_get_port() and gpio_get_pin_num() functions instead of directly setting
* port or pin numbers. Using the helper functions will assure reliable
* operation on all platforms and GPIO banks.
*
* # Design Goals
*
* This API aims to provide low-level access to GPIOs with as little
Expand Down Expand Up @@ -821,11 +830,31 @@ static inline void gpio_ll_write(gpio_port_t port, uword_t state);

/**
* @brief Extract the `gpio_port_t` from a `gpio_t`
*
* CPU specific implementation to return the GPIO port for a given
* GPIO pin.
*
* @param[in] pin GPIO pin structure, usually defined with the GPIO_PIN macro
*
* @return GPIO port
*
*/
static inline gpio_port_t gpio_get_port(gpio_t pin);

/**
* @brief Extract the pin number from a `gpio_t`
*
* CPU specific implementation to return the internal pin number for a
* given GPIO pin.
*
* @note The actual, internal pin numbers are not always directly related to
* their name. For example on some microcontrollers as the nRF52,
* the distinction between P0 and P1 pins is made by a bit that is set
* in the pin numbers.
*
* @param[in] pin GPIO pin structure, usually defined with the GPIO_PIN macro
*
* @return Internal pin number
*/
static inline uint8_t gpio_get_pin_num(gpio_t pin);

Expand Down