Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
6 years, 7 months ago.
USBHost on application board mbed-os
Hi. I am trying to write a CSV file to a USB flash stick. I'm using the application board:
https://os.mbed.com/cookbook/mbed-application-board
With mbed-os I cannot find any examples to work on. Anyone who have experienced the same difficulties ?
Any help is much appreciated.
Regards Mustafa Kazaale
1 Answer
6 years, 7 months ago.
Hi there,
The following code utilizes the LocalFileSystem library (make sure to import the "mbed-os" library into your project with the following URL: https://github.com/armmbed/mbed-os):
#include "mbed.h" LocalFileSystem local("local"); DigitalOut led(LED1); AnalogIn pot1(p19); int main() { FILE *fp = fopen("/local/test.csv","w"); printf("Create file handle for test.csv\r\n"); printf("Writing to file\r\n"); for (int i = 0; i < 100; i++) { float val = pot1.read(); fprintf(fp,"%.2f\n", val); } fclose(fp); printf("Close the handle\r\n"); led=1; }
For USBHost I would take a look at this program: https://os.mbed.com/users/vinit/code/SD-to-Flash-Data-Transfer/file/5838d8c4432a/main.cpp/
Please let me know if you have any questions!
- Jenny, team Mbed
If this solved your question, please make sure to click the "Thanks" link below!