Skip to content

Commit 69f892f

Browse files
committed
drivers/gpio_ll: Add doc about gpio_get_port and gpio_get_pin_num
1 parent d144e51 commit 69f892f

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

drivers/include/periph/gpio_ll.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@
1717
* @warning This API is not stable yet and intended for internal use only
1818
* as of now.
1919
*
20+
* # General
21+
*
22+
* Ports and pin numbers are not always internally defined as the same numbers
23+
* that you would expect them to be. Therefore it is highly recommended to call
24+
* the low level functions like gpio_ll_init or gpio_ll_query_conf with the
25+
* gpio_get_port and gpio_get_pin_num functions instead of directly setting
26+
* port or pin numbers. Using the helper functions will assure reliable
27+
* operation on all platforms and GPIO banks.
28+
*
2029
* # Design Goals
2130
*
2231
* This API aims to provide low-level access to GPIOs with as little
@@ -821,11 +830,31 @@ static inline void gpio_ll_write(gpio_port_t port, uword_t state);
821830

822831
/**
823832
* @brief Extract the `gpio_port_t` from a `gpio_t`
833+
*
834+
* CPU specific implementation to return the GPIO port for a given
835+
* GPIO pin.
836+
*
837+
* @param[in] pin GPIO pin structure, usually defined with the GPIO_PIN macro
838+
*
839+
* @return GPIO port
840+
*
824841
*/
825842
static inline gpio_port_t gpio_get_port(gpio_t pin);
826843

827844
/**
828845
* @brief Extract the pin number from a `gpio_t`
846+
*
847+
* CPU specific implementation to return the internal pin number for a
848+
* given GPIO pin.
849+
*
850+
* @note The actual, internal pin numbers are not always directly related to
851+
* their name. For example on some microcontrollers as the nRF52,
852+
* the distinction between P0 and P1 pins is made by a bit that is set
853+
* in the pin numbers.
854+
*
855+
* @param[in] pin GPIO pin structure, usually defined with the GPIO_PIN macro
856+
*
857+
* @return Internal pin number
829858
*/
830859
static inline uint8_t gpio_get_pin_num(gpio_t pin);
831860

0 commit comments

Comments
 (0)