updates
Dependencies: BLE_API mbed-dev-bin nRF51822
Fork of microbit-dal-eddystone by
Revision 36:6837feb07da4, committed 2016-07-13
- Comitter:
- LancasterUniversity
- Date:
- Wed Jul 13 12:18:15 2016 +0100
- Parent:
- 35:8ce23bc1af38
- Child:
- 37:b624ae5e94a5
- Commit message:
- Synchronized with git rev 4e71d613
Author: James Devine
microbit-dal: Added setPull to MicroBitPin
This new member function allows the configuration of the pull currently
applied to the MicroBitPin instance. This member function only has
affect when the MicroBitPin instance is in a digital input mode.
Changed in this revision
inc/drivers/MicroBitPin.h | Show annotated file Show diff for this revision Revisions of this file |
source/drivers/MicroBitPin.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/inc/drivers/MicroBitPin.h Wed Jul 13 12:18:14 2016 +0100 +++ b/inc/drivers/MicroBitPin.h Wed Jul 13 12:18:15 2016 +0100 @@ -342,6 +342,16 @@ int getAnalogPeriod(); /** + * Configures the pull of this pin. + * + * @param pull one of the mbed pull configurations: PullUp, PullDown, PullNone, OpenDrain + * + * @return MICROBIT_NOT_SUPPORTED if the current pin configuration is anything other + * than a digital input, otherwise MICROBIT_OK. + */ + int setPull(PinMode pull); + + /** * Configures the events generated by this MicroBitPin instance. * * MICROBIT_PIN_EVENT_ON_EDGE - Configures this pin to a digital input, and generates events whenever a rise/fall is detected on this pin. (MICROBIT_PIN_EVT_RISE, MICROBIT_PIN_EVT_FALL)
--- a/source/drivers/MicroBitPin.cpp Wed Jul 13 12:18:14 2016 +0100 +++ b/source/drivers/MicroBitPin.cpp Wed Jul 13 12:18:15 2016 +0100 @@ -442,6 +442,31 @@ } /** + * Configures the pull of this pin. + * + * @param pull one of the mbed pull configurations: PullUp, PullDown, PullNone, OpenDrain + * + * @return MICROBIT_NOT_SUPPORTED if the current pin configuration is anything other + * than a digital input, otherwise MICROBIT_OK. + */ +int MicroBitPin::setPull(PinMode pull) +{ + if ((status & IO_STATUS_DIGITAL_IN)) + { + ((DigitalIn *)pin)->mode(pull); + return MICROBIT_OK; + } + + if((status & IO_STATUS_EVENT_ON_EDGE) || (status & IO_STATUS_EVENT_PULSE_ON_EDGE)) + { + ((TimedInterruptIn *)pin)->mode(pull); + return MICROBIT_OK; + } + + return MICROBIT_NOT_SUPPORTED; +} + +/** * This member function manages the calculation of the timestamp of a pulse detected * on a pin whilst in IO_STATUS_EVENT_PULSE_ON_EDGE or IO_STATUS_EVENT_ON_EDGE modes. *