USBMSD_SD HelloWorld for FRDM-KL25Z
Dependencies: SDFileSystem USBDevice USBMSD_SD mbed wave_player wavfile
Fork of USBMSD_SD_HelloWorld_FRDM-KL25Z by
Diff: main.cpp
- Revision:
- 1:82ab86e5f918
- Parent:
- 0:44b579c983e0
--- a/main.cpp Fri Mar 01 13:29:13 2013 +0000 +++ b/main.cpp Wed May 01 10:40:52 2013 +0000 @@ -1,8 +1,51 @@ #include "mbed.h" #include "USBMSD_SD.h" +#include "SDFileSystem.h" +#include "wave_player.h" -USBMSD_SD sd(PTD2, PTD3, PTD1, PTD0); +AnalogOut DACout(PTE30); +wave_player waver(&DACout); +DigitalOut BLUE(LED1); + +//USBMSD_SD sd(PTD2, PTD3, PTD1, PTD0); + SDFileSystem sd(PTD2,PTD3, PTD1, PTD0 ,"sd"); int main() { - while(1); +BLUE=1; +wait(1); +printf("Hello World!\n"); + + mkdir("/sd/mydir", 0777); + + FILE *fp = fopen("/sd/mydir/sdtest2.txt", "a"); + if(fp == NULL) { + error("Could not open file for write\n"); + } + fprintf(fp, "Hello fun SD Card World!"); + fclose(fp); + + printf("Goodbye World!\n\r"); + int i,j; + for(j=0;j<6400;j++){ + for(i=1;i<64768;i=i+12000){ + DACout.write_u16(i); + wait_us(100); + } + } + + FILE *wave_file; + + printf("\n\n\nHello, wave world!\n\r"); + BLUE=0; + wave_file=fopen("/sd/st.wav","r"); + BLUE=1; + if(wave_file == NULL) + {printf("\n\r couldn't open st.wav\n\r");} + waver.set_verbosity(0); + waver.play(wave_file); + printf("\n\n\r Finished.....\n\r"); + fclose(wave_file); + + +while(1); } \ No newline at end of file