USBMSD_SD HelloWorld for FRDM-KL25Z

Dependencies:   SDFileSystem USBDevice USBMSD_SD mbed wave_player wavfile

Fork of USBMSD_SD_HelloWorld_FRDM-KL25Z by Samuel Mokrani

Committer:
cstevens
Date:
Wed May 01 10:40:52 2013 +0000
Revision:
1:82ab86e5f918
Parent:
0:44b579c983e0
sd reader

Who changed what in which revision?

UserRevisionLine numberNew contents of line
samux 0:44b579c983e0 1 #include "mbed.h"
samux 0:44b579c983e0 2 #include "USBMSD_SD.h"
cstevens 1:82ab86e5f918 3 #include "SDFileSystem.h"
cstevens 1:82ab86e5f918 4 #include "wave_player.h"
samux 0:44b579c983e0 5
cstevens 1:82ab86e5f918 6 AnalogOut DACout(PTE30);
cstevens 1:82ab86e5f918 7 wave_player waver(&DACout);
cstevens 1:82ab86e5f918 8 DigitalOut BLUE(LED1);
cstevens 1:82ab86e5f918 9
cstevens 1:82ab86e5f918 10 //USBMSD_SD sd(PTD2, PTD3, PTD1, PTD0);
cstevens 1:82ab86e5f918 11 SDFileSystem sd(PTD2,PTD3, PTD1, PTD0 ,"sd");
samux 0:44b579c983e0 12
samux 0:44b579c983e0 13 int main() {
cstevens 1:82ab86e5f918 14 BLUE=1;
cstevens 1:82ab86e5f918 15 wait(1);
cstevens 1:82ab86e5f918 16 printf("Hello World!\n");
cstevens 1:82ab86e5f918 17
cstevens 1:82ab86e5f918 18 mkdir("/sd/mydir", 0777);
cstevens 1:82ab86e5f918 19
cstevens 1:82ab86e5f918 20 FILE *fp = fopen("/sd/mydir/sdtest2.txt", "a");
cstevens 1:82ab86e5f918 21 if(fp == NULL) {
cstevens 1:82ab86e5f918 22 error("Could not open file for write\n");
cstevens 1:82ab86e5f918 23 }
cstevens 1:82ab86e5f918 24 fprintf(fp, "Hello fun SD Card World!");
cstevens 1:82ab86e5f918 25 fclose(fp);
cstevens 1:82ab86e5f918 26
cstevens 1:82ab86e5f918 27 printf("Goodbye World!\n\r");
cstevens 1:82ab86e5f918 28 int i,j;
cstevens 1:82ab86e5f918 29 for(j=0;j<6400;j++){
cstevens 1:82ab86e5f918 30 for(i=1;i<64768;i=i+12000){
cstevens 1:82ab86e5f918 31 DACout.write_u16(i);
cstevens 1:82ab86e5f918 32 wait_us(100);
cstevens 1:82ab86e5f918 33 }
cstevens 1:82ab86e5f918 34 }
cstevens 1:82ab86e5f918 35
cstevens 1:82ab86e5f918 36 FILE *wave_file;
cstevens 1:82ab86e5f918 37
cstevens 1:82ab86e5f918 38 printf("\n\n\nHello, wave world!\n\r");
cstevens 1:82ab86e5f918 39 BLUE=0;
cstevens 1:82ab86e5f918 40 wave_file=fopen("/sd/st.wav","r");
cstevens 1:82ab86e5f918 41 BLUE=1;
cstevens 1:82ab86e5f918 42 if(wave_file == NULL)
cstevens 1:82ab86e5f918 43 {printf("\n\r couldn't open st.wav\n\r");}
cstevens 1:82ab86e5f918 44 waver.set_verbosity(0);
cstevens 1:82ab86e5f918 45 waver.play(wave_file);
cstevens 1:82ab86e5f918 46 printf("\n\n\r Finished.....\n\r");
cstevens 1:82ab86e5f918 47 fclose(wave_file);
cstevens 1:82ab86e5f918 48
cstevens 1:82ab86e5f918 49
cstevens 1:82ab86e5f918 50 while(1);
samux 0:44b579c983e0 51 }