final

Dependencies:   mbed FATFileSystem

Fork of KL46Z-USBHostMSD_HelloWorld by Norimasa Okamoto

main.cpp

Committer:
va009039
Date:
2014-01-21
Revision:
0:7012d3c02e58
Child:
1:88de0ef4739f

File content as of revision 0:7012d3c02e58:

// Simple USBHost MSD for FRDM-KL46Z test program
#include "mbed.h"
#include "USBHostMSD.h"

DigitalOut led1(PTD5); // green
DigitalOut led2(PTE29); // red
#define LED_OFF 1
#define LED_ON  0

int main() {
    USBHostMSD msd("usb");
    
    FILE* fp = fopen("/usb/test1.txt", "a");
    if (fp) {
        fprintf(fp, "Hello from FRDM-KL46Z\n");
        fclose(fp);
    }
    fp = fopen("/usb/test1.txt", "r");
    if (fp) {
        while(1) {
            int c = fgetc(fp);
            if (c == EOF) {
                break;
            }
            printf("%c", c);
            led2 = !led2;
        }
        fclose(fp);
    }
    led1 = LED_OFF;
    led2 = LED_OFF;
    while(1) {
        led1 = !led1;
        wait_ms(200);
    }
}