Fix return value of gpio::ReadPin
The cast to Level is incorrect, since the expression returns either 0 or a positive value if the pin is set. The value is directly assigned to the underlying uint8_t, meaning that Level::high won't match for levels greater than 0. Return a boolean and cast that to Level instead.pull/47/head
parent
1ff9b81630
commit
32e09afd4c
|
|
@ -57,7 +57,7 @@ __attribute__((always_inline)) inline void WritePin(const GPIO_pin portPin, Leve
|
|||
}
|
||||
|
||||
__attribute__((always_inline)) inline Level ReadPin(const GPIO_pin portPin) {
|
||||
return (Level)(portPin.port->PINx & (1 << portPin.pin));
|
||||
return (Level)((portPin.port->PINx & (1 << portPin.pin)) != 0);
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) inline void TogglePin(const GPIO_pin portPin) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue