vs1011e lib attempt

Dependencies:   SDFileSystem mbed

main.cpp

Committer:
ecardenas8
Date:
2016-12-10
Revision:
0:8a46c5988d62

File content as of revision 0:8a46c5988d62:

#include "mbed.h"
#include "SDFileSystem.h"

DigitalOut led1(LED1);
DigitalOut led2(LED2);
DigitalOut led3(LED3);
DigitalOut led4(LED4);

DigitalIn Dreq(p26);
DigitalOut XDCS(p25);
DigitalOut reset(p23);
DigitalOut XCS(p22);

SPI mp3Board(p11, p12, p13);
SDFileSystem sd(p5, p6, p7, p8, "sd"); //SD card

int killLoop = 1;
int mp3Chunk;
int fileSize;

long getFileSize(FILE *fp) {
    fseek(fp, 0, SEEK_END);
    int size = ftell(fp);
    fseek(fp, 0, SEEK_SET);
    
    return size;
}

int main() {
    led1=0;
    led2=0;
    led3=0;
    led4=0;
    
    
    XCS=1;
    XCS=0; //pull xcs low to begin sci write. Sets mode to vs1002, 
    mp3Board.write(0x02); //0x02 is the write opcode
    mp3Board.write(0x00); //0x00 is the address of the sci mode register
    mp3Board.write(0x0A); //0x0A (11 in dec) is the SM_SDINEW bit
    XCS=1; //pulled high to end write sequence
    
    led1=1;
    
    FILE *mp3_file;
    //printf("\n\n\nHello, wave world!\n");
    mp3_file=fopen("/sd/Putties.mp3","rb");
    
    XDCS = 1;
    XDCS = 0;
    
    
    /*
    fseek(mp3_file, 0, SEEK_END);
    fileSize=ftell(mp3_file);
    fseek(mp3_file, 0, SEEK_SET);
    */
    
    fileSize=getFileSize(mp3_file);
    
    led2=1;
    
    fread(&mp3Chunk, 1, 100, mp3_file);
    led3=1;
    mp3Board.write(mp3Chunk);
    
        
    
    fclose(mp3_file);
    XDCS=1;
    
    led4=1;
    
}