rp2040: Fix boundary check for max gpio pin

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2022-11-17 14:38:41 -05:00
parent d17ef95a3c
commit b9a378c1ca
1 changed files with 2 additions and 2 deletions

View File

@ -48,7 +48,7 @@ mask_to_pin(uint32_t mask)
struct gpio_out struct gpio_out
gpio_out_setup(uint8_t pin, uint8_t val) gpio_out_setup(uint8_t pin, uint8_t val)
{ {
if (pin > 30) if (pin >= 30)
goto fail; goto fail;
struct gpio_out g = { .bit=1<<pin }; struct gpio_out g = { .bit=1<<pin };
gpio_out_reset(g, val); gpio_out_reset(g, val);
@ -93,7 +93,7 @@ gpio_out_write(struct gpio_out g, uint8_t val)
struct gpio_in struct gpio_in
gpio_in_setup(uint8_t pin, int8_t pull_up) gpio_in_setup(uint8_t pin, int8_t pull_up)
{ {
if (pin > 30) if (pin >= 30)
goto fail; goto fail;
struct gpio_in g = { .bit=1<<pin }; struct gpio_in g = { .bit=1<<pin };
gpio_in_reset(g, pull_up); gpio_in_reset(g, pull_up);