mirror of https://github.com/ARMmbed/mbed-os.git
USBHOST : test mass storage
parent
14153dcbc3
commit
72dae26774
|
@ -0,0 +1,44 @@
|
||||||
|
#include "mbed.h"
|
||||||
|
#include "USBHostMSD.h"
|
||||||
|
DigitalOut led(LED1);
|
||||||
|
void msd_task(void const *) {
|
||||||
|
printf("init msd\n");
|
||||||
|
USBHostMSD msd("usb");
|
||||||
|
int i = 0;
|
||||||
|
printf("wait for usb memory stick insertion\n");
|
||||||
|
while(1) {
|
||||||
|
|
||||||
|
// try to connect a MSD device
|
||||||
|
while(!msd.connect()) {
|
||||||
|
Thread::wait(500);
|
||||||
|
}
|
||||||
|
|
||||||
|
// in a loop, append a file
|
||||||
|
// if the device is disconnected, we try to connect it again
|
||||||
|
|
||||||
|
// append a file
|
||||||
|
FILE * fp = fopen("/usb/test1.txt", "a");
|
||||||
|
|
||||||
|
if (fp != NULL) {
|
||||||
|
fprintf(fp, "Hello fun SD Card World: %d!\r\n", i++);
|
||||||
|
printf("Goodbye World!\r\n");
|
||||||
|
fclose(fp);
|
||||||
|
} else {
|
||||||
|
printf("FILE == NULL\r\n");
|
||||||
|
}
|
||||||
|
Thread::wait(500);
|
||||||
|
printf("again\n");
|
||||||
|
// if device disconnected, try to connect again
|
||||||
|
while (msd.connected()) {
|
||||||
|
Thread::wait(500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
Thread msdTask(msd_task, NULL, osPriorityNormal, 1024 * 4);
|
||||||
|
while(1) {
|
||||||
|
led=!led;
|
||||||
|
Thread::wait(500);
|
||||||
|
}
|
||||||
|
}
|
|
@ -978,6 +978,7 @@ TESTS = [
|
||||||
},
|
},
|
||||||
|
|
||||||
# USB Tests
|
# USB Tests
|
||||||
|
# USB device test list
|
||||||
{
|
{
|
||||||
"id": "USB_1", "description": "Mouse",
|
"id": "USB_1", "description": "Mouse",
|
||||||
"source_dir": join(TEST_DIR, "usb", "device", "basic"),
|
"source_dir": join(TEST_DIR, "usb", "device", "basic"),
|
||||||
|
@ -1018,6 +1019,12 @@ TESTS = [
|
||||||
"source_dir": join(TEST_DIR, "usb", "device", "audio_cb"),
|
"source_dir": join(TEST_DIR, "usb", "device", "audio_cb"),
|
||||||
"dependencies": [MBED_LIBRARIES, USB_LIBRARIES],
|
"dependencies": [MBED_LIBRARIES, USB_LIBRARIES],
|
||||||
},
|
},
|
||||||
|
# USB host test list
|
||||||
|
{
|
||||||
|
"id": "USB_10", "description": "MSD",
|
||||||
|
"source_dir": join(TEST_DIR, "usb", "host", "mass_storage"),
|
||||||
|
"dependencies": [MBED_LIBRARIES, USB_HOST_LIBRARIES, FAT_FS, RTOS],
|
||||||
|
},
|
||||||
|
|
||||||
# CMSIS DSP
|
# CMSIS DSP
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue