Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdf98331

Browse files
committed
Add a new 'OUTPUT_OPENDRAIN' pinmode for platforms.
Not every MCU offers open drain pins, but some do. This changemeans that they'll no longer have to play games to implement anAPI-compatible pinMode() function that offers open drain.Fixes#155If you're reading this commit message because you need to add anotherpin mode to this enum, the hacky trivial workaround is to do somethinglike this in your core:```// This typedef is used to extend the PinMode typedef enum// in the ArduinoAPI, since they don't have contantstypedef 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 willlet the user pass either a PinMode or a PinModeExtension to yourpinMode() function, even though the signature is`void pinMode(pin_size_t ulPin, PinMode ulMode)`
1 parent6a524ad commitdf98331

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

‎api/Common.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ typedef enum {
1616
} PinStatus;
1717

1818
typedefenum {
19-
INPUT =0x0,
20-
OUTPUT =0x1,
21-
INPUT_PULLUP =0x2,
22-
INPUT_PULLDOWN =0x3,
19+
INPUT =0x0,
20+
OUTPUT =0x1,
21+
INPUT_PULLUP =0x2,
22+
INPUT_PULLDOWN =0x3,
23+
OUTPUT_OPENDRAIN =0x4,
2324
} PinMode;
2425

2526
typedefenum {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp