DigitalOut¶
-
class
DigitalOut¶ Public Functions
-
DigitalOut(PinName pin, PullType pull = PullType::PullNone, PinMode mode = PinMode::PushPull, PinSpeed speed = PinSpeed::Low, bool inverted = false)¶ Configures GPIO pin for digital in.
- Parameters
pin: Pin def external to boardpull: Pin pull typemode: Output mode (push-pull or open-drain)speed: GPIO frequencyinverted: Inverts output value of pin
-
void
DeInit()¶ Deinitializes the GPIO pin as a digital output.
-
void
Write(bool state)¶ Change output state of pin.
- Parameters
state: Set output value of pin (0 or 1) In open-drain 0 is high-z, 1 is drive low
-
void
Toggle()¶ Toggle pin output.
-
bool
Read()¶ Read current value of pin.
- Return
true (high) or false (low)
-
void
operator=(bool rhs)¶ Assignment operator overload to set pin value.
- Parameters
rhs:
-
operator bool()¶ Boolean operator overload to set pin value.
- Return
true
- Return
false
-
Example Usage:¶
DigitalOut myLed(PIN_E5, PullNone, PushPull);
while(1)
{
myLed.Toggle()
Delay(100);
}
Note
Make sure that you have initialized the GPIO peripheral clock for your GPIO port before initializing the pin as an output.