Dec. 13, 2014 | Project | Licensed as Apache 2.0 | 2355 views
ALFAT is designed to help user in accessing file system on USB / SD with high speed. However, if you just started to work on ALFAT with SPI, you may have some confuses. Reading the manual is always a good way. So this section only provide some basic thing that help you get easier when reading the manual.
There are few more advance things you have to be done if you want to get the speed more than 1MB/s, like using write file with DMA, check busy pin, active pin (1.0.8 and earlier), flush pin (2.0), etc.... To keep it simple, this section only talk about SPI Write Frame and SPI Read Frame. Understand these 2 thing enough to start ALFAT in SPI, with some basic communication, without busy pin.
Few important thing:
- SPI Write frame, SPI Read frame are different with Write/Read commands. SPI Write/Read Frame to bring your commands to ALFAT or read ALFAT's respond, while Write/Read commands are used to Write/Read data to/from a file.
- In SPI Write Frame, firstly always send 2 bytes of header, and check the ALFAT's status at the second byte when you received. This status is also status of busy pin, but as I said, we ignore busy pin in this section. If this status is low, you have to stop the transaction. You can re-send the transaction later but what I mean is, should not continue sending the 3rd or raw data. ALFAT will ignore them at all.
- In SPI Read Frame, always send 3 bytes and check how many bytes available on ALFAT by combine the 2nd and 3rd bytes returned from ALFAT. We call this value is payload. If the payload is zero, same as SPI Write Frame above, you should stop the transaction and re-start later. If the payload is larger than zero, even smaller than your input value, you have to continue the transaction with new size is payload.
It can be described as below:
payload < your_size? payload :your_size;
The payload returned from ALFAT should be never bigger than your size.
This example is only for reference. You have to implement your SPI drive that depends on your hardware.
I just tried in my understanding about ALFAT, but anyway, hope this help.
Comments or questions? Discuss on the forum.