1 / 8

Using the SD card on the Wunderboard

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

hyatt-rice
Download Presentation

Using the SD card on the Wunderboard

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Using the SD card on the Wunderboard ECE152

  2. 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

  3. 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)

  4. 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)

  5. 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

  6. 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...

  7. Coding example

  8. Things to Remember • Always double check the error codes • When in doubt, ask questions.

More Related