diff --git a/libs/core/pinsDigital.cpp b/libs/core/pinsDigital.cpp index 91403bcd4..339baf7cb 100644 --- a/libs/core/pinsDigital.cpp +++ b/libs/core/pinsDigital.cpp @@ -101,6 +101,19 @@ void onEvent(DigitalInOutPin pin, PinEvent event, Action body) { } } +/** + * Measure pin capacitance. + */ +//% +int readCapacitance(DigitalInOutPin pin) { + // on STM32F4 this requires 2M pulldown + // other chips to be tested + pin->setDigitalValue(1); + pin->getDigitalValue(PullMode::None); + sleep_us(50); + return pin->getAnalogValue(); +} + /** * Return the duration of a pulse in microseconds * @param name the pin which measures the pulse