Skip to content

Commit

Permalink
Refactor writePin to work with statements (#16738)
Browse files Browse the repository at this point in the history
  • Loading branch information
KarlK90 authored Mar 27, 2022
1 parent 03f9b8d commit 119abc4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion platforms/chibios/gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@ typedef ioline_t pin_t;

#define writePinHigh(pin) palSetLine(pin)
#define writePinLow(pin) palClearLine(pin)
#define writePin(pin, level) ((level) ? (writePinHigh(pin)) : (writePinLow(pin)))
#define writePin(pin, level) \
do { \
if (level) { \
writePinHigh(pin); \
} else { \
writePinLow(pin); \
} \
} while (0)

#define readPin(pin) palReadLine(pin)

Expand Down

0 comments on commit 119abc4

Please sign in to comment.