I wrote a driver for the TI ADS1220 24-bit analog to digital converter. This chip has a separate DRDY_ (data ready) output to indicate that a conversion is finished and ready for readout via spi. But there also is the option to read drdy_ via the MISO pin, given the chip is active via CS_ (chip select). I prefer this because it saves a pin on the controller.
First question:
Can I extract the miso pin from just the spi structure?
In:
Code: Select all
class Ads1220:
def __init__(self, spi, cs, drdy=None, ain_pos=0, ain_neg=4, sps=20, ..
Currently I have
Code: Select all
miso = Pin('B14', Pin.IN) # do this before setting up spi, because the pin is redefined,
spi = SPI(2, baudrate=1000000, phase=1)
cs = Pin('B12', Pin.OUT_PP, value=1)
ads = Ads1220(spi, cs, miso)
Code: Select all
ads = Ads1220(spi, cs)
Ideally there would be a function spi.miso_value() in micropython which I could use in the driver. Did anyone program such a thing or did consider to do so?
I would try to program it but I would need some help.
Second question: I use miso.value() in the driver and it works. The value of drdy is read out this way as long as there is no spi clock starting an spi transfer. Is this a reliable option given that the pin is redefined to alternating function SPI (af=Pin.AF5_SPI2)?