mbed library sources. Supersedes mbed-src.

Dependents:   Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more

Embed: (wiki syntax)

« Back to documentation index

DigitalOut Class Reference

DigitalOut Class Reference
[Drivers]

A digital output, used for setting the state of a pin. More...

#include <DigitalOut.h>

Public Member Functions

 DigitalOut (PinName pin)
 Create a DigitalOut connected to the specified pin.
 DigitalOut (PinName pin, int value)
 Create a DigitalOut 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)
int is_connected ()
 Return the output setting, represented as 0 or 1 (int)
DigitalOutoperator= (int value)
 A shorthand for write()
DigitalOutoperator= (DigitalOut &rhs)
 A shorthand for write() using the assignment operator which copies the state from the DigitalOut argument.
 operator int ()
 A shorthand for read()
 DigitalOut (PinName pin)
 Create a DigitalOut connected to the specified pin.
 DigitalOut (PinName pin, int value)
 Create a DigitalOut 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)
int is_connected ()
 Return the output setting, represented as 0 or 1 (int)
DigitalOutoperator= (int value)
 A shorthand for write()
DigitalOutoperator= (DigitalOut &rhs)
 A shorthand for write() using the assignment operator which copies the state from the DigitalOut argument.
 operator int ()
 A shorthand for read()

Detailed Description

A digital output, used for setting the state of a pin.

Note:
Synchronization level: Interrupt safe

Example:

 // Toggle a LED
 #include "mbed.h"

 DigitalOut led(LED1);

 int main() {
     while(1) {
         led = !led;
         wait(0.2);
     }
 }

Definition at line 47 of file cmsis/BUILD/mbed/drivers/DigitalOut.h.


Constructor & Destructor Documentation

DigitalOut ( PinName  pin )

Create a DigitalOut connected to the specified pin.

Parameters:
pinDigitalOut pin to connect to

Definition at line 54 of file cmsis/BUILD/mbed/drivers/DigitalOut.h.

DigitalOut ( PinName  pin,
int  value 
)

Create a DigitalOut connected to the specified pin.

Parameters:
pinDigitalOut pin to connect to
valuethe initial pin value

Definition at line 65 of file cmsis/BUILD/mbed/drivers/DigitalOut.h.

DigitalOut ( PinName  pin )

Create a DigitalOut connected to the specified pin.

Parameters:
pinDigitalOut pin to connect to

Definition at line 54 of file drivers/DigitalOut.h.

DigitalOut ( PinName  pin,
int  value 
)

Create a DigitalOut connected to the specified pin.

Parameters:
pinDigitalOut pin to connect to
valuethe initial pin value

Definition at line 65 of file drivers/DigitalOut.h.


Member Function Documentation

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 100 of file cmsis/BUILD/mbed/drivers/DigitalOut.h.

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 100 of file drivers/DigitalOut.h.

operator int (  )

A shorthand for read()

See also:
DigitalOut::read()
      DigitalIn  button(BUTTON1);
      DigitalOut led(LED1);
      led = button;   // Equivalent to led.write(button.read())

Definition at line 141 of file cmsis/BUILD/mbed/drivers/DigitalOut.h.

operator int (  )

A shorthand for read()

See also:
DigitalOut::read()
      DigitalIn  button(BUTTON1);
      DigitalOut led(LED1);
      led = button;   // Equivalent to led.write(button.read())

Definition at line 141 of file drivers/DigitalOut.h.

DigitalOut& operator= ( int  value )

A shorthand for write()

See also:
DigitalOut::write()
      DigitalIn  button(BUTTON1);
      DigitalOut led(LED1);
      led = button;   // Equivalent to led.write(button.read())

Definition at line 114 of file cmsis/BUILD/mbed/drivers/DigitalOut.h.

DigitalOut& operator= ( DigitalOut rhs )

A shorthand for write() using the assignment operator which copies the state from the DigitalOut argument.

See also:
DigitalOut::write()

Definition at line 125 of file cmsis/BUILD/mbed/drivers/DigitalOut.h.

DigitalOut& operator= ( int  value )

A shorthand for write()

See also:
DigitalOut::write()
      DigitalIn  button(BUTTON1);
      DigitalOut led(LED1);
      led = button;   // Equivalent to led.write(button.read())

Definition at line 114 of file drivers/DigitalOut.h.

DigitalOut& operator= ( DigitalOut rhs )

A shorthand for write() using the assignment operator which copies the state from the DigitalOut argument.

See also:
DigitalOut::write()

Definition at line 125 of file drivers/DigitalOut.h.

int read ( void   )

Return the output setting, represented as 0 or 1 (int)

Returns:
an integer representing the output setting of the pin, 0 for logical 0, 1 for logical 1

Definition at line 88 of file drivers/DigitalOut.h.

int read (  )

Return the output setting, represented as 0 or 1 (int)

Returns:
an integer representing the output setting of the pin, 0 for logical 0, 1 for logical 1

Definition at line 88 of file cmsis/BUILD/mbed/drivers/DigitalOut.h.

void write ( int  value )

Set the output, specified as 0 or 1 (int)

Parameters:
valueAn integer specifying the pin output value, 0 for logical 0, 1 (or any other non-zero value) for logical 1

Definition at line 76 of file drivers/DigitalOut.h.

void write ( int  value )

Set the output, specified as 0 or 1 (int)

Parameters:
valueAn integer specifying the pin output value, 0 for logical 0, 1 (or any other non-zero value) for logical 1

Definition at line 76 of file cmsis/BUILD/mbed/drivers/DigitalOut.h.