Hi,
I wrote a couple of sample programs to test the I2C and SPI devices and
tought of sharing in case they may be useful to someone else.
In the attached ZIP file I have included:
I2CSCAN.AS - I2C Bus Scanner, similar to Linux's i2cdetect shows the
address of the connected devices.
LCD.C - Simple demo to write text to a 16x2 characters LCD with PCF8574.
Prints a message and the current date and time (CP/M 3, not sure what
prints with CP/M 2).
PN532.C - Simple demo to read the tag id from a PN532 NFC device, with
variants for I2C and SPI.
All sources can be compiled with the HI-TECH C compiler, I have recently
discovered there is an active GitHub repository with some updates so I'm
also testing it.
https://github.com/agn453/HI-TECH-Z80-C
The source should work with SC126 and SC137 but since I don't have these
boards I can't test them so I haven't included any executable file.
Note: the PN532 is a bit awkward to handle, I2C requires clock
stretching or big delays somewhere, I haven't figured out where to put
them exactly, I had it working initially when printing each received
byte as debug, without it I wasn't able to make it work. The SPI
interface has a glitch with the Z180 CSIO interface as it seems that it
is off-sync by one bit when receiving, bit 7 of the last received byte
is bit 0 of the next. Not a big problem in this case because the PN532
sends data as packets and the first and last bytes are always zero, the
SPI.AS code does a shift to realign the bits.
Enjoy!
Best regards,
Marco