Tuesday, 5 February 2013

Reading the FAT the BASIC way...

So, I've knocked together a simple SD card interface... There's a state machine which initialises the card (works with MMC, SD and SDHC), reads the partition table and then exposes a simple byte-wise interface, handling all the sector blocking stuff automatically. You simply pass in the sector and offset, assert begin_read and the card layer asserts data_ack when the data is available to be read on data_out. Then deassert begin_read and wait for data_ack to deassert before continuing.

I've just made a very simple interface from this to the CPC. Writing to &FAD0 shifts a byte into the sector address and resets the sector offset. Reading from &FAD0 asserts begin_read and returns data_ack in the top bit. Reading from &FAD1 fetches the data input and de-asserts begin_read. Simples!

I need to build a FAT layer on top of this and then I can build the DSK image layer on top of that. But for now, I just wanted to get to work on the DSK layer code, so I'm going to use the interface so far to read the file into RAM.

No comments: