diff --git a/cpu/atmega_common/periph/gpio.c b/cpu/atmega_common/periph/gpio.c index b59a1f703e..28e050d69f 100644 --- a/cpu/atmega_common/periph/gpio.c +++ b/cpu/atmega_common/periph/gpio.c @@ -154,7 +154,7 @@ int gpio_init(gpio_t pin, gpio_mode_t mode) return 0; } -int gpio_read(gpio_t pin) +bool gpio_read(gpio_t pin) { return (_SFR_MEM8(atmega_pin_addr(pin)) & (1 << atmega_pin_num(pin))); } diff --git a/cpu/atxmega/periph/gpio.c b/cpu/atxmega/periph/gpio.c index 8f67990e05..dd6914ec07 100644 --- a/cpu/atxmega/periph/gpio.c +++ b/cpu/atxmega/periph/gpio.c @@ -252,7 +252,7 @@ void gpio_irq_disable(gpio_t pin) } } -int gpio_read(gpio_t pin) +bool gpio_read(gpio_t pin) { PORT_t *port = _port_addr(pin); uint8_t pin_mask = _pin_mask(pin); diff --git a/cpu/cc2538/periph/gpio.c b/cpu/cc2538/periph/gpio.c index 861810d4f9..82bf84e416 100644 --- a/cpu/cc2538/periph/gpio.c +++ b/cpu/cc2538/periph/gpio.c @@ -122,7 +122,7 @@ int gpio_init(gpio_t pin, gpio_mode_t mode) return 0; } -int gpio_read(gpio_t pin) +bool gpio_read(gpio_t pin) { return (int)(gpio(pin)->DATA & _pin_mask(pin)); } diff --git a/cpu/cc26xx_cc13xx/periph/gpio.c b/cpu/cc26xx_cc13xx/periph/gpio.c index 82847bb194..17ad877d20 100644 --- a/cpu/cc26xx_cc13xx/periph/gpio.c +++ b/cpu/cc26xx_cc13xx/periph/gpio.c @@ -56,7 +56,7 @@ int gpio_init(gpio_t pin, gpio_mode_t mode) return 0; } -int gpio_read(gpio_t pin) +bool gpio_read(gpio_t pin) { if (GPIO->DOE & (1 << pin)) { return (GPIO->DOUT >> pin) & 1; diff --git a/cpu/efm32/periph/gpio.c b/cpu/efm32/periph/gpio.c index 589c7adf3e..0d37f1c8ae 100644 --- a/cpu/efm32/periph/gpio.c +++ b/cpu/efm32/periph/gpio.c @@ -73,7 +73,7 @@ int gpio_init(gpio_t pin, gpio_mode_t mode) return 0; } -int gpio_read(gpio_t pin) +bool gpio_read(gpio_t pin) { return GPIO_PinInGet(_port_num(pin), _pin_num(pin)); } diff --git a/cpu/esp32/periph/gpio.c b/cpu/esp32/periph/gpio.c index 9050f011f1..137a7402a1 100644 --- a/cpu/esp32/periph/gpio.c +++ b/cpu/esp32/periph/gpio.c @@ -338,7 +338,7 @@ static gpio_hal_context_t _gpio_hal_ctx = { */ static BITFIELD(_output, GPIO_PIN_NUMOF); -int gpio_read(gpio_t pin) +bool gpio_read(gpio_t pin) { assert(pin < GPIO_PIN_NUMOF); @@ -394,7 +394,7 @@ void gpio_toggle(gpio_t pin) #else /* IS_USED(MODULE_ESP_IDF_GPIO_HAL) */ -int gpio_read(gpio_t pin) +bool gpio_read(gpio_t pin) { assert(pin < GPIO_PIN_NUMOF); diff --git a/cpu/esp8266/periph/gpio.c b/cpu/esp8266/periph/gpio.c index d94f3ab8d7..414516e693 100644 --- a/cpu/esp8266/periph/gpio.c +++ b/cpu/esp8266/periph/gpio.c @@ -237,7 +237,7 @@ void gpio_irq_disable (gpio_t pin) } #endif /* MODULE_PERIPH_GPIO_IRQ */ -int gpio_read (gpio_t pin) +bool gpio_read (gpio_t pin) { CHECK_PARAM_RET(pin < GPIO_PIN_NUMOF, -1); diff --git a/cpu/fe310/periph/gpio.c b/cpu/fe310/periph/gpio.c index c923b8e3e1..c7db92d517 100644 --- a/cpu/fe310/periph/gpio.c +++ b/cpu/fe310/periph/gpio.c @@ -90,7 +90,7 @@ int gpio_init(gpio_t pin, gpio_mode_t mode) return 0; } -int gpio_read(gpio_t pin) +bool gpio_read(gpio_t pin) { return (GPIO_REG(GPIO_INPUT_VAL) & (1 << pin)) ? 1 : 0; } diff --git a/cpu/gd32v/periph/gpio.c b/cpu/gd32v/periph/gpio.c index f15ed83669..7fbfcbde4d 100644 --- a/cpu/gd32v/periph/gpio.c +++ b/cpu/gd32v/periph/gpio.c @@ -160,7 +160,7 @@ void gpio_init_analog(gpio_t pin) *pin_reg &= ~(0xfl << (4 * (pin_num - ((pin_num >= 8) * 8)))); } -int gpio_read(gpio_t pin) +bool gpio_read(gpio_t pin) { GPIO_Type *port = _port(pin); unsigned pin_num = _pin_num(pin); diff --git a/cpu/kinetis/periph/gpio.c b/cpu/kinetis/periph/gpio.c index df62aa6f89..ff918b6250 100644 --- a/cpu/kinetis/periph/gpio.c +++ b/cpu/kinetis/periph/gpio.c @@ -247,7 +247,7 @@ void gpio_init_port(gpio_t pin, uint32_t pcr) #endif /* KINETIS_HAVE_PCR */ } -int gpio_read(gpio_t pin) +bool gpio_read(gpio_t pin) { if (gpio(pin)->PDDR & (1 << pin_num(pin))) { return (gpio(pin)->PDOR & (1 << pin_num(pin))) ? 1 : 0; diff --git a/cpu/lm4f120/periph/gpio.c b/cpu/lm4f120/periph/gpio.c index 7d158616a7..a03a97eb0a 100644 --- a/cpu/lm4f120/periph/gpio.c +++ b/cpu/lm4f120/periph/gpio.c @@ -119,7 +119,7 @@ int gpio_init(gpio_t pin, gpio_mode_t mode) return 0; } -int gpio_read(gpio_t pin) +bool gpio_read(gpio_t pin) { const uint8_t port_num = _port_num(pin); const uint32_t port_addr = _port_base[port_num]; diff --git a/cpu/lpc1768/periph/gpio.c b/cpu/lpc1768/periph/gpio.c index 75b3217c50..668673f222 100644 --- a/cpu/lpc1768/periph/gpio.c +++ b/cpu/lpc1768/periph/gpio.c @@ -92,7 +92,7 @@ int gpio_init(gpio_t pin, gpio_mode_t mode) return 0; } -int gpio_read(gpio_t pin) +bool gpio_read(gpio_t pin) { LPC_GPIO_TypeDef *base = _base(pin); diff --git a/cpu/lpc23xx/periph/gpio.c b/cpu/lpc23xx/periph/gpio.c index 88033646c9..131ecd46ca 100644 --- a/cpu/lpc23xx/periph/gpio.c +++ b/cpu/lpc23xx/periph/gpio.c @@ -99,7 +99,7 @@ int gpio_init_mux(unsigned pin, unsigned mux) return 0; } -int gpio_read(gpio_t pin) +bool gpio_read(gpio_t pin) { unsigned _pin = pin & 31; unsigned port = pin >> 5; diff --git a/cpu/msp430/periph/gpio.c b/cpu/msp430/periph/gpio.c index af1ea5ec8c..402493d7c9 100644 --- a/cpu/msp430/periph/gpio.c +++ b/cpu/msp430/periph/gpio.c @@ -112,7 +112,7 @@ void gpio_periph_mode(gpio_t pin, bool enable) } } -int gpio_read(gpio_t pin) +bool gpio_read(gpio_t pin) { msp430_port_t *port = _port(pin); if (port->DIR & _pin_mask(pin)) { diff --git a/cpu/native/periph/gpio_linux.c b/cpu/native/periph/gpio_linux.c index a554628d97..2b32790e99 100644 --- a/cpu/native/periph/gpio_linux.c +++ b/cpu/native/periph/gpio_linux.c @@ -167,7 +167,7 @@ int gpio_init(gpio_t pin, gpio_mode_t mode) return 0; } -int gpio_read(gpio_t pin) +bool gpio_read(gpio_t pin) { struct gpiohandle_data data; diff --git a/cpu/native/periph/gpio_mock.c b/cpu/native/periph/gpio_mock.c index a335f2ddec..3094be3144 100644 --- a/cpu/native/periph/gpio_mock.c +++ b/cpu/native/periph/gpio_mock.c @@ -66,7 +66,7 @@ __attribute__((weak)) void gpio_irq_disable(gpio_t pin) (void) pin; } -__attribute__((weak)) int gpio_read(gpio_t pin) { +__attribute__((weak)) bool gpio_read(gpio_t pin) { if (pin) { return pin->value; } diff --git a/cpu/nrf5x_common/periph/gpio.c b/cpu/nrf5x_common/periph/gpio.c index 2ede21d588..7f58963f3c 100644 --- a/cpu/nrf5x_common/periph/gpio.c +++ b/cpu/nrf5x_common/periph/gpio.c @@ -126,7 +126,7 @@ int gpio_init(gpio_t pin, gpio_mode_t mode) return 0; } -int gpio_read(gpio_t pin) +bool gpio_read(gpio_t pin) { if (port(pin)->DIR & (1 << pin_num(pin))) { return (port(pin)->OUT & (1 << pin_num(pin))) ? 1 : 0; diff --git a/cpu/qn908x/periph/gpio.c b/cpu/qn908x/periph/gpio.c index 761eefbf37..6258f325ce 100644 --- a/cpu/qn908x/periph/gpio.c +++ b/cpu/qn908x/periph/gpio.c @@ -182,7 +182,7 @@ void gpio_irq_disable(gpio_t pin) #endif /* defined(MODULE_PERIPH_GPIO_IRQ) */ -int gpio_read(gpio_t pin) +bool gpio_read(gpio_t pin) { return ((GPIO_T_ADDR(pin)->DATA) >> GPIO_T_PIN(pin)) & 1u; } diff --git a/cpu/rpx0xx/periph/gpio.c b/cpu/rpx0xx/periph/gpio.c index f8ec327404..859947e120 100644 --- a/cpu/rpx0xx/periph/gpio.c +++ b/cpu/rpx0xx/periph/gpio.c @@ -106,7 +106,7 @@ int gpio_init(gpio_t pin, gpio_mode_t mode) return 0; } -int gpio_read(gpio_t pin) +bool gpio_read(gpio_t pin) { if (SIO->GPIO_OE & (1LU << pin)) { /* pin is output: */ diff --git a/cpu/sam0_common/periph/gpio.c b/cpu/sam0_common/periph/gpio.c index 5fd7ed2057..50129c130d 100644 --- a/cpu/sam0_common/periph/gpio.c +++ b/cpu/sam0_common/periph/gpio.c @@ -195,7 +195,7 @@ int gpio_init(gpio_t pin, gpio_mode_t mode) return 0; } -int gpio_read(gpio_t pin) +bool gpio_read(gpio_t pin) { PortGroup *port; int mask = _pin_mask(pin); diff --git a/cpu/sam3/periph/gpio.c b/cpu/sam3/periph/gpio.c index 4edee67e3d..6253814094 100644 --- a/cpu/sam3/periph/gpio.c +++ b/cpu/sam3/periph/gpio.c @@ -244,7 +244,7 @@ void gpio_irq_disable(gpio_t pin) NVIC_DisableIRQ((1 << (_port_num(pin) + PIOA_IRQn))); } -int gpio_read(gpio_t pin) +bool gpio_read(gpio_t pin) { Pio *port = _port(pin); int pin_num = _pin_num(pin); diff --git a/cpu/stm32/periph/gpio_all.c b/cpu/stm32/periph/gpio_all.c index f7403b463f..526deccbb6 100644 --- a/cpu/stm32/periph/gpio_all.c +++ b/cpu/stm32/periph/gpio_all.c @@ -203,7 +203,7 @@ void gpio_irq_disable(gpio_t pin) EXTI_REG_IMR &= ~(1 << _pin_num(pin)); } -int gpio_read(gpio_t pin) +bool gpio_read(gpio_t pin) { return (_port(pin)->IDR & (1 << _pin_num(pin))); } diff --git a/cpu/stm32/periph/gpio_f1.c b/cpu/stm32/periph/gpio_f1.c index 18359fa137..0896765057 100644 --- a/cpu/stm32/periph/gpio_f1.c +++ b/cpu/stm32/periph/gpio_f1.c @@ -145,7 +145,7 @@ void gpio_init_analog(gpio_t pin) *(uint32_t *)(&_port(pin)->CRL + (pin_num >= 8)) &= ~(0xfl << (4 * (pin_num - ((pin_num >= 8) * 8)))); } -int gpio_read(gpio_t pin) +bool gpio_read(gpio_t pin) { GPIO_TypeDef *port = _port(pin); int pin_num = _pin_num(pin); diff --git a/drivers/include/periph/gpio.h b/drivers/include/periph/gpio.h index 8a07104984..57861880d4 100644 --- a/drivers/include/periph/gpio.h +++ b/drivers/include/periph/gpio.h @@ -227,10 +227,10 @@ void gpio_irq_disable(gpio_t pin); * * @param[in] pin the pin to read * - * @return 0 when pin is LOW - * @return >0 for HIGH + * @retval false pin is LOW + * @retval true pin is HIGH */ -int gpio_read(gpio_t pin); +bool gpio_read(gpio_t pin); /** * @brief Set the given pin to HIGH