mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
sys/arduino: add assertion to gpio handling
Not all boards that provide a Arduino pin layout break out all GPIOs. A good example are Adafruit `feather-m0` boards. GPIOs that are not broken out have to be defined as `GPIO_UNDEF` to preserve the Arduino pin layout. However, GPIO functions lead to a complete system lock on `feather-m0` boards if a pin is used that is defined as `GPIO_UNDEF`. Therefore, at least an assert should blow up in this case.
This commit is contained in:
parent
3053b87a5e
commit
ede5f9ebab
@ -32,6 +32,7 @@ extern "C" {
|
|||||||
|
|
||||||
void pinMode(int pin, int mode)
|
void pinMode(int pin, int mode)
|
||||||
{
|
{
|
||||||
|
assert(gpio_is_valid(arduino_pinmap[pin]));
|
||||||
gpio_mode_t m = GPIO_OUT;
|
gpio_mode_t m = GPIO_OUT;
|
||||||
|
|
||||||
if (mode == INPUT) {
|
if (mode == INPUT) {
|
||||||
@ -46,11 +47,13 @@ void pinMode(int pin, int mode)
|
|||||||
|
|
||||||
void digitalWrite(int pin, int state)
|
void digitalWrite(int pin, int state)
|
||||||
{
|
{
|
||||||
|
assert(gpio_is_valid(arduino_pinmap[pin]));
|
||||||
gpio_write(arduino_pinmap[pin], state);
|
gpio_write(arduino_pinmap[pin], state);
|
||||||
}
|
}
|
||||||
|
|
||||||
int digitalRead(int pin)
|
int digitalRead(int pin)
|
||||||
{
|
{
|
||||||
|
assert(gpio_is_valid(arduino_pinmap[pin]));
|
||||||
if (gpio_read(arduino_pinmap[pin])) {
|
if (gpio_read(arduino_pinmap[pin])) {
|
||||||
return HIGH;
|
return HIGH;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user