main.c
182 lines
| 5.4 KiB
| text/x-c
|
CLexer
|
r18 | #include <stdio.h> | ||
#include <fat32.h> | ||||
#include <gpio.h> | ||||
#include <uart.h> | ||||
#include <stm32f4xx.h> | ||||
|
r21 | #include <bsp.h> | ||
|
r42 | #include <core.h> | ||
r60 | #include <VS10XX.h> | |||
#include <bsp.h> | ||||
r61 | #include <spi.h> | |||
#include <sdcard.h> | ||||
#include <sdcard-spi.h> | ||||
#include <fat32.h> | ||||
#include <ucdirent.h> | ||||
#include <string.h> | ||||
r62 | #include <terminal.h> | |||
r61 | ||||
|
r18 | |||
extern streamdevice* __opnfiles__[]; | ||||
r62 | char buffer[512]; | |||
|
r18 | |||
r60 | void randBoxesDemo() | |||
{ | ||||
int16_t x,y,w,h,t,r; | ||||
x=rand()%240; | ||||
y=rand()%320; | ||||
w=rand()%(240-x); | ||||
if(x>y) | ||||
r=(rand()%(y))%(320-y); | ||||
else | ||||
r=(rand()%(x))%(240-x); | ||||
h=rand()%(320-y); | ||||
t=rand()%(10); | ||||
ili9328paintFilRect(&lcd0,x,y,w,h,rand(),t,rand()); | ||||
//ili9328paintFilCirc(&lcd0,x,y,r,rand(),t,rand()); | ||||
//delay_100us(10); | ||||
//for(volatile int i=0;i<(1024*2);i++); | ||||
} | ||||
r62 | void tryToplay1() | |||
{ | ||||
extern FAT32fs sdcard2FAT32part1; | ||||
extern volatile vs10XXDev audioCodec0; | ||||
ucdirent root; | ||||
char direntName[]=" \n"; | ||||
uint32_t fileLba,nextLba; | ||||
int i=0; | ||||
spisetspeed(audioCodec0.SPIdev,2000000); | ||||
if(DIRENT_noErr==fat32mkdirent(&sdcard2FAT32part1,&root)) | ||||
{ | ||||
if(DIRENT_noErr==fat32getrootfirstent(&root)) | ||||
{ | ||||
do{ | ||||
fat32getdirentname(&root,direntName); | ||||
printf("%s\n",direntName); | ||||
nextLba=fat32getdirentlba(&root); | ||||
printf("Streaming File\n"); | ||||
do | ||||
{ | ||||
fileLba = nextLba; | ||||
if(sdcard2FAT32part1.part->phy->read(sdcard2FAT32part1.part->phy,buffer,fileLba,1)==RES_OK) | ||||
{ | ||||
for(i=0;i<512;i+=32) | ||||
{ | ||||
vs10XXstream32bytes(&audioCodec0,buffer+i); | ||||
} | ||||
} | ||||
}while ((fat32nextsectorlba(&sdcard2FAT32part1,fileLba,&nextLba)==DIRENT_noErr) && (!gpiogetval(BP3))); | ||||
//vs10XXsoftReset(&audioCodec0); | ||||
while (gpiogetval(BP3))delay_100us(1000); | ||||
printf("looking for next file\n"); | ||||
}while (DIRENT_noErr==fat32nextdirent(&root)); | ||||
} | ||||
} | ||||
if(DIRENT_noErr==fat32mkdirent(&sdcard2FAT32part2,&root)) | ||||
{ | ||||
if(DIRENT_noErr==fat32getrootfirstent(&root)) | ||||
{ | ||||
fat32getdirentname(&root,direntName); | ||||
printf("%s\n",direntName); | ||||
nextLba=fat32getdirentlba(&root); | ||||
printf("Streaming File\n"); | ||||
do | ||||
{ | ||||
fileLba = nextLba; | ||||
if(sdcard2FAT32part2.part->phy->read(sdcard2FAT32part2.part->phy,buffer,fileLba,1)==RES_OK) | ||||
{ | ||||
for(i=0;i<512;i+=32) | ||||
{ | ||||
vs10XXstream32bytes(&audioCodec0,buffer+i); | ||||
} | ||||
} | ||||
}while ((fat32nextsectorlba(&sdcard2FAT32part2,fileLba,&nextLba)==DIRENT_noErr) && (!gpiogetval(BP3))); | ||||
while (gpiogetval(BP3))delay_100us(1000); | ||||
} | ||||
} | ||||
if(DIRENT_noErr==fat32mkdirent(&sdcard2FAT32part3,&root)) | ||||
{ | ||||
if(DIRENT_noErr==fat32getrootfirstent(&root)) | ||||
{ | ||||
fat32getdirentname(&root,direntName); | ||||
printf("%s\n",direntName); | ||||
nextLba=fat32getdirentlba(&root); | ||||
printf("Streaming File\n"); | ||||
do | ||||
{ | ||||
fileLba = nextLba; | ||||
if(sdcard2FAT32part3.part->phy->read(sdcard2FAT32part3.part->phy,buffer,fileLba,1)==RES_OK) | ||||
{ | ||||
for(i=0;i<512;i+=32) | ||||
{ | ||||
vs10XXstream32bytes(&audioCodec0,buffer+i); | ||||
} | ||||
} | ||||
}while ((fat32nextsectorlba(&sdcard2FAT32part3,fileLba,&nextLba)==DIRENT_noErr) && (!gpiogetval(BP3))); | ||||
while (gpiogetval(BP3))delay_100us(1000); | ||||
} | ||||
} | ||||
if(DIRENT_noErr==fat32mkdirent(&sdcard2FAT32part4,&root)) | ||||
{ | ||||
if(DIRENT_noErr==fat32getrootfirstent(&root)) | ||||
{ | ||||
fat32getdirentname(&root,direntName); | ||||
printf("%s\n",direntName); | ||||
nextLba=fat32getdirentlba(&root); | ||||
printf("Streaming File\n"); | ||||
do | ||||
{ | ||||
fileLba = nextLba; | ||||
if(sdcard2FAT32part4.part->phy->read(sdcard2FAT32part4.part->phy,buffer,fileLba,1)==RES_OK) | ||||
{ | ||||
for(i=0;i<512;i+=32) | ||||
{ | ||||
vs10XXstream32bytes(&audioCodec0,buffer+i); | ||||
} | ||||
} | ||||
}while ((fat32nextsectorlba(&sdcard2FAT32part4,fileLba,&nextLba)==DIRENT_noErr) && (!gpiogetval(BP3))); | ||||
while (gpiogetval(BP3))delay_100us(1000); | ||||
} | ||||
} | ||||
} | ||||
void tryToplay2() | ||||
{ | ||||
extern blkdevice sdcard2blkdev; | ||||
int i=0,l=0; | ||||
spisetspeed(audioCodec0.SPIdev,4000000); | ||||
printf("Streaming File\n"); | ||||
//printf("New LBA=0x%X\n",nextLba); | ||||
while(sdcard2blkdev.read(&sdcard2blkdev,buffer,l++,1)==RES_OK) | ||||
{ | ||||
for(i=0;i<512;i+=32) | ||||
{ | ||||
vs10XXstream32bytes(&audioCodec0,buffer+i); | ||||
} | ||||
} | ||||
} | ||||
r60 | ||||
|
r18 | int main() | ||
{ | ||||
r62 | extern terminal_t terminal0; | |||
extern volatile vs10XXDev audioCodec0; | ||||
printf("Volume=0x%x\n",vs10XXcmdread(&audioCodec0,VSVOL)); | ||||
vs10XXcmdwrite(&audioCodec0,VSCLOCKF,0x2000); | ||||
vs10XXcmdwrite(&audioCodec0,VSVOL,0x2222); | ||||
printf("VSCLOCKF=0x%x\n",vs10XXcmdread(&audioCodec0,VSCLOCKF)); | ||||
printf("VSMODE=0x%x\n",vs10XXcmdread(&audioCodec0,VSMODE)); | ||||
terminal_clear(&terminal0); | ||||
// tryToplay2(); | ||||
tryToplay1(); | ||||
|
r18 | return 0; | ||
} | ||||