main.c
230 lines
| 5.5 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> | |||
r63 | #include <ili9328.h> | |||
r61 | ||||
|
r18 | |||
extern streamdevice* __opnfiles__[]; | ||||
r63 | extern void test_Block_Move(LCD_t* LCD,int x,int y,int w,int h,int color); | |||
|
r66 | extern void test_all_colors(LCD_t* LCD); | ||
extern void test_small_lines(LCD_t* LCD); | ||||
r67 | extern void test_lines(LCD_t* LCD); | |||
extern void test_address(LCD_t* LCD); | ||||
r71 | extern void test_TC(); | |||
|
r66 | void test_uniform_rw(LCD_t* LCD); | ||
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 | ||||
r63 | void randTextDemo() | |||
{ | ||||
int16_t x,y,w,h,t,r; | ||||
char buf[2]; | ||||
buf[1]='\0'; | ||||
x=rand()%240; | ||||
y=rand()%320; | ||||
if(x>y) | ||||
r=(rand()%(y))%(320-y); | ||||
else | ||||
r=(rand()%(x))%(240-x); | ||||
h=rand()%(320-y); | ||||
buf[0]=rand()%(255); | ||||
//ili9328paintFilRect(&lcd0,x,y,w,h,rand(),t,rand()); | ||||
ili9328paintText(&lcd0,buf,x,y,&ComicSansMS_18,rand()); | ||||
//ili9328paintFilCirc(&lcd0,x,y,r,rand(),t,rand()); | ||||
delay_100us(5000); | ||||
//for(volatile int i=0;i<(1024*2);i++); | ||||
r62 | } | |||
r63 | ||||
r62 | 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 | ||||
r63 | void playFile(ucdirent* file,FAT32fs* part) | |||
{ | ||||
extern volatile vs10XXDev audioCodec0; | ||||
r68 | char direntName[]=" \n"; | |||
r63 | uint32_t fileLba,nextLba; | |||
int i=0; | ||||
fat32getdirentname(file,direntName); | ||||
r65 | //gpioset(LCD_BACKL); | |||
printf("%s\n",direntName); | ||||
r63 | nextLba=fat32getdirentlba(file); | |||
//printf("Streaming File\n"); | ||||
r65 | //gpioclr(LCD_BACKL); | |||
r63 | do | |||
{ | ||||
fileLba = nextLba; | ||||
if(sdcard2FAT32part1.part->phy->read(part->part->phy,buffer,fileLba,1)==RES_OK) | ||||
{ | ||||
for(i=0;i<512;i+=32) | ||||
{ | ||||
vs10XXstream32bytes(&audioCodec0,buffer+i); | ||||
} | ||||
} | ||||
}while ((fat32nextsectorlba(part,fileLba,&nextLba)==DIRENT_noErr) && (!gpiogetval(BP3))); | ||||
vs10XXsoftReset(&audioCodec0); | ||||
while (gpiogetval(BP3))delay_100us(1000); | ||||
} | ||||
void playAllparts() | ||||
{ | ||||
extern FAT32fs sdcard2FAT32part1,sdcard2FAT32part2,sdcard2FAT32part3,sdcard2FAT32part4; | ||||
ucdirent root; | ||||
if(DIRENT_noErr==fat32mkdirent(&sdcard2FAT32part1,&root)) | ||||
{ | ||||
printf("Reading on SDCARD2 part1\n"); | ||||
if(DIRENT_noErr==fat32getrootfirstent(&root)) | ||||
{ | ||||
do{ | ||||
playFile(&root,&sdcard2FAT32part1); | ||||
}while (DIRENT_noErr==fat32nextdirent(&root)); | ||||
} | ||||
} | ||||
gpioset(LED2); | ||||
if(DIRENT_noErr==fat32mkdirent(&sdcard2FAT32part2,&root)) | ||||
{ | ||||
printf("Reading on SDCARD2 part2\n"); | ||||
if(DIRENT_noErr==fat32getrootfirstent(&root)) | ||||
{ | ||||
do{ | ||||
playFile(&root,&sdcard2FAT32part2); | ||||
}while (DIRENT_noErr==fat32nextdirent(&root)); | ||||
} | ||||
} | ||||
} | ||||
r71 | int main1() | |||
|
r18 | { | ||
|
r64 | delay_100us(30000); | ||
r63 | int i=0; | |||
int color=0; | ||||
r67 | // test_all_colors(&lcd0); | |||
// test_small_lines(&lcd0); | ||||
// test_uniform_rw(&lcd0); | ||||
|
r66 | |||
printf("LCD ID REG = 0x%X\n\r",lcd0.interface->readreg(ILI9328_REGISTER_DRIVERCODEREAD)); | ||||
r67 | printf("LCD ENTRY MODE REG = 0x%X\n\r",lcd0.interface->readreg(ILI9328_REGISTER_ENTRYMODE)); | |||
uint16_t test[16]; | ||||
for(int i=0;i<16;i++) | ||||
{ | ||||
test[i]=0xF00F; | ||||
} | ||||
lcd0.paint(&lcd0,test,10,100,4,4); | ||||
lcd0.getPix(&lcd0,test,10,100,4,4); | ||||
for(int i=0;i<16;i++) | ||||
{ | ||||
printf("@%d=0x%X\n",i,test[i]); | ||||
} | ||||
// test_lines(&lcd0); | ||||
r71 | test_TC(); | |||
r67 | while(1)test_address(&lcd0); | |||
r63 | for(i=0;i<240;i++) | |||
{ | ||||
if(i>(240/3)) | ||||
{ | ||||
color= (i<<5) + 0x1F; | ||||
} | ||||
else | ||||
{ | ||||
color = i; | ||||
} | ||||
if(i>(2*240/3)) | ||||
{ | ||||
color= (i<<10) + 0x3FF; | ||||
} | ||||
lcd0.paintFilRect(&lcd0,i,0,1,100,0,0,color); | ||||
} | ||||
while(1)printf("test "); | ||||
// for(i=0;i<240;i++) | ||||
// { | ||||
// if(i>(240/3)) | ||||
// { | ||||
// color= (i<<5) + 0x1F; | ||||
// } | ||||
// else | ||||
// { | ||||
// color = i; | ||||
// } | ||||
// if(i>(2*240/3)) | ||||
// { | ||||
// color= (i<<10) + 0x3FF; | ||||
// } | ||||
// lcd0.paintFilRect(&lcd0,i,220,1,100,0,0,color); | ||||
// } | ||||
for(i=0;i<240;i++) | ||||
{ | ||||
ili9328setFrame(&lcd0,i,0,1,100); | ||||
lcd0.interface->readGRAM(buffer,100); | ||||
lcd0.paint(&lcd0,buffer,i,200,1,100); | ||||
} | ||||
while(1); | ||||
} | ||||
r68 | int main() | |||
r63 | { | |||
r62 | extern terminal_t terminal0; | |||
extern volatile vs10XXDev audioCodec0; | ||||
printf("Volume=0x%x\n",vs10XXcmdread(&audioCodec0,VSVOL)); | ||||
vs10XXcmdwrite(&audioCodec0,VSCLOCKF,0x2000); | ||||
r63 | delay_100us(1000); | |||
r71 | //vs10XXcmdwrite(&audioCodec0,VSVOL,0x2020); | |||
r62 | printf("VSCLOCKF=0x%x\n",vs10XXcmdread(&audioCodec0,VSCLOCKF)); | |||
printf("VSMODE=0x%x\n",vs10XXcmdread(&audioCodec0,VSMODE)); | ||||
r63 | //terminal_clear(&terminal0); | |||
r65 | // gpioclr(LCD_BACKL); | |||
r63 | playAllparts(); | |||
|
r18 | return 0; | ||
} | ||||