-
-
Notifications
You must be signed in to change notification settings - Fork 134
Commit df98331
Add a new 'OUTPUT_OPENDRAIN' pinmode for platforms.
Not every MCU offers open drain pins, but some do. This change
means that they'll no longer have to play games to implement an
API-compatible pinMode() function that offers open drain.
Fixes #155
If you're reading this commit message because you need to add another
pin mode to this enum, the hacky trivial workaround is to do something
like this in your core:
```
// This typedef is used to extend the PinMode typedef enum
// in the ArduinoAPI, since they don't have contants
typedef enum {
INPUT_ANALOG = 99 , // We assume that the Arduino core will never have 99 PinModes
OUTPUT_OPEN_DRAIN // It'd be cleaner to be able to count the size of that enum
} PinModeExtension;
```
Because PinMode is an enum and not a proper type, the compiler will
let the user pass either a PinMode or a PinModeExtension to your
pinMode() function, even though the signature is
`void pinMode(pin_size_t ulPin, PinMode ulMode)`1 parent 6a524ad commit df98331
1 file changed
+5
-4
lines changedOriginal file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
16 | 16 |
| |
17 | 17 |
| |
18 | 18 |
| |
19 | - | ||
20 | - | ||
21 | - | ||
22 | - | ||
19 | + | ||
20 | + | ||
21 | + | ||
22 | + | ||
23 | + | ||
23 | 24 |
| |
24 | 25 |
| |
25 | 26 |
| |
|
0 commit comments