Hello everyone, I need advice. On my latest board, I have an expansion area which includes the SPI pins: CS, CLK, MOSI, and MISO. All of the lines are shared besides CS of course. MISO has a 10K pull-up resistor. Standard stuff.
In my System Monitor program, I want to have a way to interface an SPI device through these expansion pins. Right now I have a 25LC640A EEPROM and an "SPI MicroSD Card Adapter" (here
https://duckduckgo.com/?t=ffab&q=spi+mi ... ter&ia=web) connected using SPI protocols, but they share a common base code of enable/disable/read-byte/write-byte.
What should I do through my System Monitor to be able to interface general SPI devices? Some ideas I've tried:
1) Enable/Disable function, Write Byte function, Read Byte function, with the exact byte to be written or location of read byte as an argument. Pros: Basic, easy, probably universal. Cons: Lots of overhead, lots of wasted time. Example from my monitor (note, mine is not exactly like this, but you get the idea):
Code:
FF>SPI ; to write byte FF
0000<SPI ; to read byte into address 0000
2) Read and/or Write from list of bytes/addresses, having the values in memory instead of hand-typed by user. Pros: You can get a lot more done quickly. Cons: Sometimes reading and writing switch out every other byte, so this isn't as helpful. Example:
Code:
0000.007F>SPI ; to write list of bytes from 0000 to 007F
0080.00FF<SPI ; to read list of bytes from 0080 to 00FF
3) Command + Byte structure. This would end up being like a psuedo-code that can be manipulated for advanced instructions. Pros: You can do a lot more when pre-programmed. Cons: Super complicated to the user. Example:
Code:
0000.001F SPI ; send commands + bytes
Memory would look like:
0000: 01 02 AA 02 55 03 80 00 00
01 = enable
02 AA = write byte AA
02 55 = write byte 55
03 80 00 = read byte into location 0080
00 = disable
I just don't know of a good way to interface general SPI devices. I haven't used anything really outside of what I have already mentioned. I want this to be general enough that I could make it work with most SPI devices without actually needing special assembly code. I want it to be easy to use but also useful.
Thoughts? I don't care about notation and all that, I want to know what you think the functionality should be like. Write a byte at a time? Write a string of bytes? Write commands + bytes? Or something else, please! Any suggestions and advice is greatly appreciated. Thank you all!
Chad