Tuesday, May 14, 2013
CP23S17 programming - passing spi channel object by reference to a function
On second thought, it is more neat and tidy to pass the spi channel object to the spi write function, instead of the spi channel's function.
So the spi write function is newly defined like this:
def SpiWrite(spiChannel, spiWriteList):
spiChannel.xfer2(spiWriteList)
and called like this:
SpiWrite(spiEeprom, [EePromCommandWriteLatchEnable])
# *** SPI write/read functions ***
def SpiWrite(spiChannel, spiWriteList):
spiChannel.xfer2(spiWriteList)
def Test25Lc256():
...
spiEeprom = spidev.SpiDev()
spiEeprom.open(0, 0)
...
EepromCommandWriteLatchDisable = 0x04
...
SpiWrite(spiEeprom, [EePromCommandWriteLatchEnable])
...
.END
No comments:
Post a Comment