I'm working on a driver for a sensor which uses a proprietary one-wire interface. To get data out of the device, we do the following:
1) switch the pin to output
2) 1 us low
3) 1 us high
4) Switch the pin to input
5) wait 8 us for the signal to settle
6) read the pin value
.. and this loops for the number of bits we need to read.
I have been working on a design using PPI. The issue I'm running into is that the pin needs to switch between input and output. Originally I had planned to use a 3-state buffer external to the chip and use the PPI+Timer CC to control that. However, we have ben told that we can overcome this by using 2 pins: one configured as input and one as output. This is the exact answer we received from Nordic (Håkon):
"Not with a single GPIO. You can achieve this functionality by using two GPIOs that are both connected to the DIRECT LINK pin. You can then turn on or off the PPI channel associated with a GPIO via the PPI task (nrf_ppi_task_t).
The input pin must be connected to the disable task of it's own PPI channel as well as the enable task of the output pins PPI channel (forked PPI event). "
I've been going thorugh the documentation and tried some examples and have a hard time figuring out how this would work. The docs state:
“When Event mode is selected in CONFIG.MODE, the pin specified by CONFIG.PSEL will be configured as
an input, overriding the DIR setting in GPIO. Similarly, when Task mode is selected in CONFIG.MODE, the
pin specified by CONFIG.PSEL will be configured as an output overriding the DIR setting and OUT value
in GPIO.”
That seemed encouraging, and for a while I was under the impression the PPI can use the PPI Group Tasks (enable/Disable, NRF_PPI->CHG, NRF_PPI->TASKS_CHG[0].DIS) to switch between input (default GPIO config) and output (GPIOTE config).
However, I have not been successful and am wondering if this is possible at all. Am I missing something?
Thanks,
Dirk