mbed library sources. Supersedes mbed-src.
Dependents: Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more
Diff: drivers/DigitalIn.h
- Revision:
- 187:0387e8f68319
- Parent:
- 167:e84263d55307
- Child:
- 188:bcfe06ba3d64
--- a/drivers/DigitalIn.h Fri Jun 22 16:45:37 2018 +0100 +++ b/drivers/DigitalIn.h Thu Sep 06 13:40:20 2018 +0100 @@ -55,7 +55,8 @@ * * @param pin DigitalIn pin to connect to */ - DigitalIn(PinName pin) : gpio() { + DigitalIn(PinName pin) : gpio() + { // No lock needed in the constructor gpio_init_in(&gpio, pin); } @@ -65,7 +66,8 @@ * @param pin DigitalIn pin to connect to * @param mode the initial mode of the pin */ - DigitalIn(PinName pin, PinMode mode) : gpio() { + DigitalIn(PinName pin, PinMode mode) : gpio() + { // No lock needed in the constructor gpio_init_in_ex(&gpio, pin, mode); } @@ -75,7 +77,8 @@ * An integer representing the state of the input pin, * 0 for logical 0, 1 for logical 1 */ - int read() { + int read() + { // Thread safe / atomic HAL call return gpio_read(&gpio); } @@ -84,7 +87,8 @@ * * @param pull PullUp, PullDown, PullNone, OpenDrain */ - void mode(PinMode pull) { + void mode(PinMode pull) + { core_util_critical_section_enter(); gpio_mode(&gpio, pull); core_util_critical_section_exit(); @@ -96,7 +100,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); } @@ -104,7 +109,8 @@ /** An operator shorthand for read() * \sa DigitalIn::read() */ - operator int() { + operator int() + { // Underlying read is thread safe return read(); }