lancaster-university / codal-microbit-v2

CODAL target for the micro:bit v2.x series of devices
MIT License
41 stars 50 forks source link

A way to configure a pin on open drain mode #412

Closed microbit-carlos closed 1 month ago

microbit-carlos commented 4 months ago

Would it be possible to add a way in CODAL to configure a pin in open drain mode?

This is something required for implementing 1-wire protocols on top level languages like MicroPython.

microbit-carlos commented 3 months ago

@dpgeorge Looks like the nRF way to set up open drain is to call drive mode to 6, with CODAL via uBit.io.P0.setDriveMode(6): https://github.com/lancaster-university/codal-nrf52/blob/0643733703b4f8f788af81a996f40d1f1a1527bc/inc/NRF52Pin.h#L423-L438

Drive mode from the datasheet, where S0D1 means setting the pin low works as normal and setting it high does nothing :

image

Could also set it into "high drive mode" H0D1, to pull more current.