Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
DigitalInOut Class Reference
[DigitalInOut class]
A digital input/output, used for setting or reading a bi-directional pin. More...
#include <DigitalInOut.h>
Public Member Functions | |
DigitalInOut (PinName pin) | |
Create a DigitalInOut connected to the specified pin. | |
DigitalInOut (PinName pin, PinDirection direction, PinMode mode, int value) | |
Create a DigitalInOut connected to the specified pin. | |
void | write (int value) |
Set the output, specified as 0 or 1 (int) | |
int | read () |
Return the output setting, represented as 0 or 1 (int) | |
void | output () |
Set as an output. | |
void | input () |
Set as an input. | |
void | mode (PinMode pull) |
Set the input pin mode. | |
int | is_connected () |
Return the output setting, represented as 0 or 1 (int) | |
DigitalInOut & | operator= (int value) |
A shorthand for write() | |
DigitalInOut & | operator= (DigitalInOut &rhs) |
A shorthand for write() using the assignment operator which copies the state from the DigitalInOut argument. | |
operator int () | |
A shorthand for read() |
Detailed Description
A digital input/output, used for setting or reading a bi-directional pin.
- Note:
- Synchronization level: Interrupt safe
Definition at line 35 of file DigitalInOut.h.
Constructor & Destructor Documentation
DigitalInOut | ( | PinName | pin ) |
Create a DigitalInOut connected to the specified pin.
- Parameters:
-
pin DigitalInOut pin to connect to
Definition at line 42 of file DigitalInOut.h.
DigitalInOut | ( | PinName | pin, |
PinDirection | direction, | ||
PinMode | mode, | ||
int | value | ||
) |
Create a DigitalInOut connected to the specified pin.
- Parameters:
-
pin DigitalInOut pin to connect to direction the initial direction of the pin mode the initial mode of the pin value the initial value of the pin if is an output
Definition at line 55 of file DigitalInOut.h.
Member Function Documentation
void input | ( | ) |
Set as an input.
Definition at line 31 of file DigitalInOut.cpp.
int is_connected | ( | ) |
Return the output setting, represented as 0 or 1 (int)
- Returns:
- Non zero value if pin is connected to uc GPIO 0 if gpio object was initialized with NC
Definition at line 104 of file DigitalInOut.h.
void mode | ( | PinMode | pull ) |
Set the input pin mode.
- Parameters:
-
pull PullUp, PullDown, PullNone, OpenDrain
Definition at line 38 of file DigitalInOut.cpp.
operator int | ( | ) |
A shorthand for read()
- See also:
- DigitalInOut::read()
DigitalInOut inout(PIN); DigitalOut led(LED1); inout.input(); led = inout; // Equivalent to led.write(inout.read())
Definition at line 143 of file DigitalInOut.h.
DigitalInOut& operator= | ( | int | value ) |
A shorthand for write()
- See also:
- DigitalInOut::write()
DigitalInOut inout(PIN); DigitalIn button(BUTTON1); inout.output(); inout = button; // Equivalent to inout.write(button.read())
Definition at line 120 of file DigitalInOut.h.
DigitalInOut & operator= | ( | DigitalInOut & | rhs ) |
A shorthand for write() using the assignment operator which copies the state from the DigitalInOut argument.
- See also:
- DigitalInOut::write()
Definition at line 45 of file DigitalInOut.cpp.
void output | ( | ) |
Set as an output.
Definition at line 24 of file DigitalInOut.cpp.
int read | ( | ) |
Return the output setting, represented as 0 or 1 (int)
- Returns:
- an integer representing the output setting of the pin if it is an output, or read the input if set as an input
Definition at line 78 of file DigitalInOut.h.
void write | ( | int | value ) |
Set the output, specified as 0 or 1 (int)
- Parameters:
-
value An integer specifying the pin output value, 0 for logical 0, 1 (or any other non-zero value) for logical 1
Definition at line 66 of file DigitalInOut.h.
Generated on Tue Jul 12 2022 13:55:42 by
