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.
This commit is contained in:
parent
732971e758
commit
4e71d61347
|
@ -341,6 +341,16 @@ class MicroBitPin : public MicroBitComponent
|
|||
*/
|
||||
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.
|
||||
*
|
||||
|
|
|
@ -441,6 +441,31 @@ int MicroBitPin::getAnalogPeriod()
|
|||
return getAnalogPeriodUs()/1000;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
|
|
Loading…
Reference in New Issue