Skip to content

Commit

Permalink
Fix dead lock with pin above NUM_DIGITAL_PINS
Browse files Browse the repository at this point in the history
Penalty for the check should be a single instruction for pin numbers below NUM_DIGITAL_PINS, 9 for pin numbers between PNUM_ANALOG_BASE and NUM_ANALOG_INTERNAL_FIRST.

Tests done on a Black F407VE board
  • Loading branch information
VitorBoss committed Jan 13, 2025
1 parent cfe4962 commit b06ba1d
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions cores/arduino/wiring_digital.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,28 @@ void pinMode(uint32_t ulPin, uint32_t ulMode)

void digitalWrite(uint32_t ulPin, uint32_t ulVal)
{
digitalWriteFast(digitalPinToPinName(ulPin), ulVal);
PinName p = digitalPinToPinName(ulPin);
if (p != NC) {
digitalWriteFast(p, ulVal);
}
}

int digitalRead(uint32_t ulPin)
{
return digitalReadFast(digitalPinToPinName(ulPin));
PinName p = digitalPinToPinName(ulPin);

if (p == NC) {
return 0;
}
return digitalReadFast(p);
}

void digitalToggle(uint32_t ulPin)
{
digitalToggleFast(digitalPinToPinName(ulPin));
PinName p = digitalPinToPinName(ulPin);
if (p != NC) {
digitalToggleFast(digitalPinToPinName(ulPin));
}
}

#ifdef __cplusplus
Expand Down

0 comments on commit b06ba1d

Please sign in to comment.