Skip to content

Commit

Permalink
Use TOTAL_GPIO_COUNT instead of magic number 30
Browse files Browse the repository at this point in the history
  • Loading branch information
dhalbert committed Jan 25, 2021
1 parent 0fa5aa3 commit fdca0c8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ports/raspberrypi/common-hal/microcontroller/Pin.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ bool speaker_enable_in_use;
STATIC uint32_t never_reset_pins;

void reset_all_pins(void) {
for (size_t i = 0; i < 30; i++) {
for (size_t i = 0; i < TOTAL_GPIO_COUNT; i++) {
if ((never_reset_pins & (1 << i)) != 0) {
continue;
}
Expand All @@ -55,15 +55,15 @@ void reset_all_pins(void) {
}

void never_reset_pin_number(uint8_t pin_number) {
if (pin_number >= 32) {
if (pin_number >= TOTAL_GPIO_COUNT) {
return;
}

never_reset_pins |= 1 << pin_number;
}

void reset_pin_number(uint8_t pin_number) {
if (pin_number >= 32) {
if (pin_number >= TOTAL_GPIO_COUNT) {
return;
}

Expand Down Expand Up @@ -134,7 +134,7 @@ void claim_pin(const mcu_pin_obj_t* pin) {
}

bool pin_number_is_free(uint8_t pin_number) {
if (pin_number >= 30) {
if (pin_number >= TOTAL_GPIO_COUNT) {
return false;
}

Expand Down

0 comments on commit fdca0c8

Please sign in to comment.