Ameba Arduino: [RTL8195AM] SDIO - List the files in SD Card
- Ameba x 1
- SD card or MicroSD card x 1
- SD sniffer x 1 (optional)
This example list all the files under the root directory of the SD card. Open the sample code in “File” -> “Examples” -> “AmebaSdFatFs” -> “list_root_files” Compile and upload to Ameba, then press the reset button. Execution result screenshot:
First, we initialize the SdFatFs:
fs.begin();Next, use readDir() to read the file list under root directory and store the data to buffer. The first argument is the absolute path of the directory to read (that is the root directory in this example), the second argument is the buffer, and the third is the size of the buffer.
fs.readDir(fs.getRootPath(), buf, sizeof(buf));The data format in the buffer is shown in below figure. Each file name is separated by ‘\0’.
Realtek IoT/Wi-Fi MCU Solutions . All Rights Reserved.