drivers/periph/gpio: add comparison functions
The expandable GPIO API requires the comparison of structured GPIO types. This means that inline functions must be used instead of direct comparisons. For the migration process, drivers and other modules must first be changed so that they use the inline comparison functions.
This commit is contained in:
parent
f264b049aa
commit
147b79169c
@ -43,6 +43,11 @@
|
|||||||
* definitions in `RIOT/boards/ * /include/periph_conf.h` will define the selected
|
* definitions in `RIOT/boards/ * /include/periph_conf.h` will define the selected
|
||||||
* GPIO pin.
|
* GPIO pin.
|
||||||
*
|
*
|
||||||
|
* @warning The scalar GPIO pin type `gpio_t` is deprecated and will be
|
||||||
|
* replaced by a structured GPIO pin type in a future GPIO API. Therefore,
|
||||||
|
* don't use the direct comparison of GPIO pins anymore. Instead, use the
|
||||||
|
* inline comparison functions @ref gpio_is_equal and @ref gpio_is_valid.
|
||||||
|
*
|
||||||
* # (Low-) Power Implications
|
* # (Low-) Power Implications
|
||||||
*
|
*
|
||||||
* On almost all platforms, we can only control the peripheral power state of
|
* On almost all platforms, we can only control the peripheral power state of
|
||||||
@ -253,6 +258,27 @@ void gpio_toggle(gpio_t pin);
|
|||||||
*/
|
*/
|
||||||
void gpio_write(gpio_t pin, int value);
|
void gpio_write(gpio_t pin, int value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Test if a GPIO pin is equal to another GPIO pin
|
||||||
|
*
|
||||||
|
* @param[in] gpio1 First GPIO pin to check
|
||||||
|
* @param[in] gpio2 Second GPIO pin to check
|
||||||
|
*/
|
||||||
|
static inline int gpio_is_equal(gpio_t gpio1, gpio_t gpio2)
|
||||||
|
{
|
||||||
|
return (gpio1 == gpio2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Test if a GPIO pin is a valid pin and not declared as undefined.
|
||||||
|
*
|
||||||
|
* @param[in] gpio GPIO pin to check
|
||||||
|
*/
|
||||||
|
static inline int gpio_is_valid(gpio_t gpio)
|
||||||
|
{
|
||||||
|
return (gpio != GPIO_UNDEF);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user