Skip to content

Commit

Permalink
drivers/periph/gpio: make gpio_write() take a bool
Browse files Browse the repository at this point in the history
  • Loading branch information
benpicco committed Oct 22, 2024
1 parent 33b1cac commit 4627f66
Show file tree
Hide file tree
Showing 24 changed files with 28 additions and 27 deletions.
2 changes: 1 addition & 1 deletion cpu/atmega_common/periph/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ void gpio_toggle(gpio_t pin)
}
}

void gpio_write(gpio_t pin, int value)
void gpio_write(gpio_t pin, bool value)
{
if (value) {
gpio_set(pin);
Expand Down
2 changes: 1 addition & 1 deletion cpu/atxmega/periph/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ void gpio_toggle(gpio_t pin)
}
}

void gpio_write(gpio_t pin, int value)
void gpio_write(gpio_t pin, bool value)
{
DEBUG("gpio_write pin = 0x%04x, value = 0x%02x \n", pin, value);

Expand Down
2 changes: 1 addition & 1 deletion cpu/cc2538/periph/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ void gpio_toggle(gpio_t pin)
gpio(pin)->DATA ^= _pin_mask(pin);
}

void gpio_write(gpio_t pin, int value)
void gpio_write(gpio_t pin, bool value)
{
if (value) {
gpio(pin)->DATA |= _pin_mask(pin);
Expand Down
2 changes: 1 addition & 1 deletion cpu/cc26xx_cc13xx/periph/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void gpio_toggle(gpio_t pin)
GPIO->DOUTTGL = (1 << pin);
}

void gpio_write(gpio_t pin, int value)
void gpio_write(gpio_t pin, bool value)
{
if (value) {
GPIO->DOUTSET = (1 << pin);
Expand Down
2 changes: 1 addition & 1 deletion cpu/efm32/periph/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void gpio_toggle(gpio_t pin)
GPIO_PinOutToggle(_port_num(pin), _pin_num(pin));
}

void gpio_write(gpio_t pin, int value)
void gpio_write(gpio_t pin, bool value)
{
if (value) {
GPIO_PinOutSet(_port_num(pin), _pin_num(pin));
Expand Down
4 changes: 2 additions & 2 deletions cpu/esp32/periph/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ int gpio_read(gpio_t pin)
return value;
}

void gpio_write(gpio_t pin, int value)
void gpio_write(gpio_t pin, bool value)
{
DEBUG("%s gpio=%u val=%d\n", __func__, pin, value);
assert(pin < GPIO_PIN_NUMOF);
Expand Down Expand Up @@ -412,7 +412,7 @@ int gpio_read(gpio_t pin)
return value;
}

void gpio_write(gpio_t pin, int value)
void gpio_write(gpio_t pin, bool value)
{
DEBUG("%s gpio=%u val=%d\n", __func__, pin, value);
assert(pin < GPIO_PIN_NUMOF);
Expand Down
2 changes: 1 addition & 1 deletion cpu/esp8266/periph/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ int gpio_read (gpio_t pin)
return (GPIO.IN & BIT(pin)) ? 1 : 0;
}

void gpio_write (gpio_t pin, int value)
void gpio_write (gpio_t pin, bool value)
{
DEBUG("%s: %d %d\n", __func__, pin, value);

Expand Down
2 changes: 1 addition & 1 deletion cpu/fe310/periph/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void gpio_toggle(gpio_t pin)
__ATOMIC_RELAXED);
}

void gpio_write(gpio_t pin, int value)
void gpio_write(gpio_t pin, bool value)
{
if (value) {
_set_pin_reg(GPIO_OUTPUT_VAL, pin);
Expand Down
2 changes: 1 addition & 1 deletion cpu/gd32v/periph/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ void gpio_toggle(gpio_t pin)
}
}

void gpio_write(gpio_t pin, int value)
void gpio_write(gpio_t pin, bool value)
{
if (value) {
gpio_set(pin);
Expand Down
2 changes: 1 addition & 1 deletion cpu/kinetis/periph/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ void gpio_toggle(gpio_t pin)
gpio(pin)->PTOR = (1 << pin_num(pin));
}

void gpio_write(gpio_t pin, int value)
void gpio_write(gpio_t pin, bool value)
{
if (value) {
gpio(pin)->PSOR = (1 << pin_num(pin));
Expand Down
2 changes: 1 addition & 1 deletion cpu/lm4f120/periph/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ void gpio_toggle(gpio_t pin)
}
}

void gpio_write(gpio_t pin, int value)
void gpio_write(gpio_t pin, bool value)
{
if (value) {
gpio_set(pin);
Expand Down
2 changes: 1 addition & 1 deletion cpu/lpc1768/periph/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void gpio_toggle(gpio_t pin)
base->FIOPIN ^= (1 << _pin(pin));
}

void gpio_write(gpio_t pin, int value)
void gpio_write(gpio_t pin, bool value)
{
LPC_GPIO_TypeDef *base = _base(pin);

Expand Down
6 changes: 3 additions & 3 deletions cpu/lpc23xx/periph/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,13 @@ void gpio_toggle(gpio_t dev)
}
}

void gpio_write(gpio_t dev, int value)
void gpio_write(gpio_t pin, bool value)
{
if (value) {
gpio_set(dev);
gpio_set(pin);
}
else {
gpio_clear(dev);
gpio_clear(pin);
}
}

Expand Down
2 changes: 1 addition & 1 deletion cpu/msp430/periph/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void gpio_toggle(gpio_t pin)
_port(pin)->OD ^= _pin_mask(pin);
}

void gpio_write(gpio_t pin, int value)
void gpio_write(gpio_t pin, bool value)
{
if (value) {
_port(pin)->OD |= _pin_mask(pin);
Expand Down
2 changes: 1 addition & 1 deletion cpu/native/periph/gpio_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ void gpio_toggle(gpio_t pin)
_set(pin, !gpio_read(pin));
}

void gpio_write(gpio_t pin, int value)
void gpio_write(gpio_t pin, bool value)
{
_set(pin, value);
}
Expand Down
2 changes: 1 addition & 1 deletion cpu/native/periph/gpio_mock.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ __attribute__((weak)) void gpio_toggle(gpio_t pin) {
}
}

__attribute__((weak)) void gpio_write(gpio_t pin, int value) {
__attribute__((weak)) void gpio_write(gpio_t pin, bool value) {
if (pin) {
pin->value = value;
}
Expand Down
2 changes: 1 addition & 1 deletion cpu/nrf5x_common/periph/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ void gpio_toggle(gpio_t pin)
port(pin)->OUT ^= (1 << pin_num(pin));
}

void gpio_write(gpio_t pin, int value)
void gpio_write(gpio_t pin, bool value)
{
if (value) {
port(pin)->OUTSET = (1 << pin_num(pin));
Expand Down
2 changes: 1 addition & 1 deletion cpu/qn908x/periph/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ void gpio_toggle(gpio_t pin)
base->OUTENSET = out_clr & dataout;
}

void gpio_write(gpio_t pin, int value)
void gpio_write(gpio_t pin, bool value)
{
if (value) {
gpio_set(pin);
Expand Down
2 changes: 1 addition & 1 deletion cpu/rpx0xx/periph/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ void gpio_toggle(gpio_t pin)
SIO->GPIO_OUT_XOR = 1LU << pin;
}

void gpio_write(gpio_t pin, int value)
void gpio_write(gpio_t pin, bool value)
{
if (value) {
gpio_set(pin);
Expand Down
2 changes: 1 addition & 1 deletion cpu/sam0_common/periph/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ void gpio_toggle(gpio_t pin)
_port_iobus(pin)->OUTTGL.reg = _pin_mask(pin);
}

void gpio_write(gpio_t pin, int value)
void gpio_write(gpio_t pin, bool value)
{
if (value) {
_port_iobus(pin)->OUTSET.reg = _pin_mask(pin);
Expand Down
2 changes: 1 addition & 1 deletion cpu/sam3/periph/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ void gpio_toggle(gpio_t pin)
}
}

void gpio_write(gpio_t pin, int value)
void gpio_write(gpio_t pin, bool value)
{
if (value) {
_port(pin)->PIO_SODR = (1 << _pin_num(pin));
Expand Down
2 changes: 1 addition & 1 deletion cpu/stm32/periph/gpio_all.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ void gpio_toggle(gpio_t pin)
}
}

void gpio_write(gpio_t pin, int value)
void gpio_write(gpio_t pin, bool value)
{
if (value) {
gpio_set(pin);
Expand Down
2 changes: 1 addition & 1 deletion cpu/stm32/periph/gpio_f1.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ void gpio_toggle(gpio_t pin)
}
}

void gpio_write(gpio_t pin, int value)
void gpio_write(gpio_t pin, bool value)
{
if (value) {
_port(pin)->BSRR = (1 << _pin_num(pin));
Expand Down
3 changes: 2 additions & 1 deletion drivers/include/periph/gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
#define PERIPH_GPIO_H

#include <limits.h>
#include <stdbool.h>

#include "periph_cpu.h"
#include "periph_conf.h"
Expand Down Expand Up @@ -258,7 +259,7 @@ void gpio_toggle(gpio_t pin);
* @param[in] pin the pin to set
* @param[in] value value to set the pin to, 0 for LOW, HIGH otherwise
*/
void gpio_write(gpio_t pin, int value);
void gpio_write(gpio_t pin, bool value);

/**
* @brief Test if a GPIO pin is equal to another GPIO pin
Expand Down

0 comments on commit 4627f66

Please sign in to comment.