In my continuing effort to avoid completing features, I've added another distraction: SD card storage. My real plan is to have SPI available for all kinds of peripherals (displays and network adapters come to mind), but I already had an SD breakout board and it seemed like the logical place to start.
This time I ignored all concerns for speed and efficient code and wrote the SPI and SD libraries in C. It's still bit-banging SPI through the 6522. I'm able to initialize the card and read arbitrary sectors of data. There's currently no filesystem support other than some simple parsing of the FAT metadata in the first sector. I'll need to decide how much deeper into the FAT implementation I want to go. It would be nice to have file I/O, but worst case I can treat the SD card like a big serial EEPROM and read in raw data.
><(((°> run Setting up the SD card... Sending SD init command... SD card ready! Reading block: 0 Block read complete: 0 Disk Info: OEM: MSDOS5.0 Bytes per sector: 512 Sectors per cluster: 16 Reserved sectors: 2304 Sectors per FAT: 0 Number of sectors: 30840 Filesystem type: Reading block: 0
As always, the code is available on Github: https://github.com/crmaykish/herring-6502/tree/main/firmware
Look for the spi.h and sd.h files.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.