using the sd card on the wunderboard

8
Using the SD card on the Wunderboard ECE152

Upload: hyatt-rice

Post on 01-Jan-2016

21 views

Category:

Documents


0 download

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 Presentation

TRANSCRIPT

Page 1: Using the  SD card on the Wunderboard

Using the SD card on the WunderboardECE152

Page 2: Using the  SD card on the Wunderboard

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

Page 3: Using the  SD card on the Wunderboard

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)

Page 4: Using the  SD card on the Wunderboard

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)

Page 5: Using the  SD card on the Wunderboard

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

Page 6: Using the  SD card on the Wunderboard

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

Page 7: Using the  SD card on the Wunderboard

Coding example

Page 8: Using the  SD card on the Wunderboard

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