Skip to content

Commit a9f976f

Browse files
committed
Report correct state when GPIO has both pullup & pulldown
1 parent 543b93a commit a9f976f

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/gpio-pin.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export enum GPIOPinState {
77
Input,
88
InputPullUp,
99
InputPullDown,
10+
InputBusKeeper,
1011
}
1112

1213
export const FUNCTION_PWM = 4;
@@ -186,10 +187,15 @@ export class GPIOPin {
186187
return this.outputValue ? GPIOPinState.High : GPIOPinState.Low;
187188
} else {
188189
// TODO: check what happens when we enable both pullup/pulldown
189-
if (this.pulldownEnabled) {
190+
// ANSWER: It is valid, see: 2.19.4.1. Bus Keeper Mode, datasheet p240
191+
if (this.pulldownEnabled && this.pullupEnabled) {
192+
// Pull high when high, pull low when low:
193+
return GPIOPinState.InputBusKeeper;
194+
}
195+
else if (this.pulldownEnabled) {
190196
return GPIOPinState.InputPullDown;
191197
}
192-
if (this.pullupEnabled) {
198+
else if (this.pullupEnabled) {
193199
return GPIOPinState.InputPullUp;
194200
}
195201
return GPIOPinState.Input;

0 commit comments

Comments
 (0)