using the sd card on the wunderboard
DESCRIPTION
Using the SD card on the Wunderboard. ECE152. Overview. What is a file system? How can I open files? How do I read and write from files? What about 'error codes'? Coding example. What is a file system?. Memory is just a long list of locations File systems organize memory - PowerPoint PPT PresentationTRANSCRIPT
Using the SD card on the WunderboardECE152
Overview What is a file system? How can I open files? How do I read and write from files? What about 'error codes'? Coding example
What is a file system? Memory is just a long list of locations File systems organize memory File systems are created based on the
memory
uint8_t initializeFAT(FATFS* fs)
How can I open files? Files are opened for reading or writing Files can be created, overwritten, or
appended to
f_open(&log, "/log.txt", FA_WRITE | FA_CREATE_ALWAYS)
How do I write to files? You write data as bytes When writing, tell the function how many bytes
f_write (FIL*, const void*, UINT, UINT*)
FIL - File 'handle' const void* - data to be written UINT - number of bytes to write UINT* - number of bytes written
What about 'error codes'?switch (err) { case ERR_FMOUNT: sendStringUART("ERROR: Could not mount SD\r\n"); break; case ERR_NODISK: sendStringUART("ERROR: No SDC/MMC present\r\n"); break; case ERR_NOINIT: sendStringUART("ERROR: Unable to initialize FAT.\r\n"); break;
...etc...
Coding example
Things to Remember Always double check the error codes When in doubt, ask questions.