Skip to content

Commit

Permalink
Fix dead lock with pin above NUM_DIGITAL_PINS (stm32duino#2629)
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

Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
Co-authored-by: Frederic Pillon <frederic.pillon@st.com>
  • Loading branch information
VitorBoss and fpistm authored Jan 14, 2025
1 parent cfe4962 commit d8a8b20
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions cores/arduino/wiring_digital.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,25 @@ 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);

return (p == NC) ? 0 : 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 d8a8b20

Please sign in to comment.