mbed library sources. Supersedes mbed-src.
Dependents: Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more
Diff: drivers/DigitalOut.h
- Revision:
- 187:0387e8f68319
- Parent:
- 167:e84263d55307
- Child:
- 188:bcfe06ba3d64
--- a/drivers/DigitalOut.h Fri Jun 22 16:45:37 2018 +0100 +++ b/drivers/DigitalOut.h Thu Sep 06 13:40:20 2018 +0100 @@ -50,7 +50,8 @@ * * @param pin DigitalOut pin to connect to */ - DigitalOut(PinName pin) : gpio() { + DigitalOut(PinName pin) : gpio() + { // No lock needed in the constructor gpio_init_out(&gpio, pin); } @@ -60,7 +61,8 @@ * @param pin DigitalOut pin to connect to * @param value the initial pin value */ - DigitalOut(PinName pin, int value) : gpio() { + DigitalOut(PinName pin, int value) : gpio() + { // No lock needed in the constructor gpio_init_out_ex(&gpio, pin, value); } @@ -70,7 +72,8 @@ * @param value An integer specifying the pin output value, * 0 for logical 0, 1 (or any other non-zero value) for logical 1 */ - void write(int value) { + void write(int value) + { // Thread safe / atomic HAL call gpio_write(&gpio, value); } @@ -81,7 +84,8 @@ * an integer representing the output setting of the pin, * 0 for logical 0, 1 for logical 1 */ - int read() { + int read() + { // Thread safe / atomic HAL call return gpio_read(&gpio); } @@ -92,7 +96,8 @@ * Non zero value if pin is connected to uc GPIO * 0 if gpio object was initialized with NC */ - int is_connected() { + int is_connected() + { // Thread safe / atomic HAL call return gpio_is_connected(&gpio); } @@ -100,7 +105,8 @@ /** A shorthand for write() * \sa DigitalOut::write() */ - DigitalOut& operator= (int value) { + DigitalOut &operator= (int value) + { // Underlying write is thread safe write(value); return *this; @@ -109,7 +115,8 @@ /** A shorthand for write() * \sa DigitalOut::write() */ - DigitalOut& operator= (DigitalOut& rhs) { + DigitalOut &operator= (DigitalOut &rhs) + { core_util_critical_section_enter(); write(rhs.read()); core_util_critical_section_exit(); @@ -119,7 +126,8 @@ /** A shorthand for read() * \sa DigitalOut::read() */ - operator int() { + operator int() + { // Underlying call is thread safe return read(); }