diff --git a/bsp/src/OPLAYER/bsp.c b/bsp/src/OPLAYER/bsp.c --- a/bsp/src/OPLAYER/bsp.c +++ b/bsp/src/OPLAYER/bsp.c @@ -199,15 +199,15 @@ int bsp_FSMC_init() void bsp_spi_init() { - gpio_t VSSPI_DBxList[]={VS1053SCK,VS1053MOSI,VS1053MISO}; - for(int i=0;i<3;i++) - { - gpio_t SPI_DBx = gpioopen(VSSPI_DBxList[i]); - SPI_DBx |= gpiohighspeed | gpioaf | gpiopushpulltype | gpionopulltype; - gpiosetconfig(&SPI_DBx); - GPIO_PinAFConfig(GPIOGETPORT(SPI_DBx), (uint8_t)(SPI_DBx & 0xF), GPIO_AF_SPI1); - } - spiopenandconfig(VS1053SPI,spi8bits|spimaster|spimsbfirst,2*1000*1000,VS1053MOSI,VS1053MISO,VS1053SCK,-1); +// gpio_t VSSPI_DBxList[]={VS1053SCK,VS1053MOSI,VS1053MISO}; +// for(int i=0;i<3;i++) +// { +// gpio_t SPI_DBx = gpioopen(VSSPI_DBxList[i]); +// SPI_DBx |= gpiohighspeed | gpioaf | gpiopushpulltype | gpionopulltype; +// gpiosetconfig(&SPI_DBx); +// GPIO_PinAFConfig(GPIOGETPORT(SPI_DBx), (uint8_t)(SPI_DBx & 0xF), GPIO_AF_SPI1); +// } +// spiopenandconfig(VS1053SPI,spi8bits|spimaster|spimsbfirst,2*1000*1000,VS1053MOSI,VS1053MISO,VS1053SCK,-1); gpio_t SDSPI_DBxList[]={SDCARD2SCK,SDCARD2MOSI,SDCARD2MISO}; for(int i=0;i<3;i++) @@ -235,13 +235,13 @@ void bsp_Audio_init() void bsp_SD_init() { - sdcardDev sdcard2; - blkdevice sdcard2blkdev; - dikpartition sdcard2Part1; - sdcardspimake(&sdcard2,(UHANDLE)SDCARD2SPI,spigetnc,spiputnc,spisetspeed,spigetspeed); - sdcardspimakeblkdev(&sdcard2blkdev,&sdcard2,bspsdcardselect,bsppowersdcard,bspsdcardpresent,bspsdcardwriteprotected); - sdcard2blkdev.initialize(&sdcard2blkdev); - mbropen(&sdcard2blkdev,&sdcard2Part1,1); +// sdcardDev sdcard2; +// blkdevice sdcard2blkdev; +// dikpartition sdcard2Part1; +// sdcardspimake(&sdcard2,(UHANDLE)SDCARD2SPI,spigetnc,spiputnc,spisetspeed,spigetspeed); +// sdcardspimakeblkdev(&sdcard2blkdev,&sdcard2,bspsdcardselect,bsppowersdcard,bspsdcardpresent,bspsdcardwriteprotected); +// sdcard2blkdev.initialize(&sdcard2blkdev); +// mbropen(&sdcard2blkdev,&sdcard2Part1,1); } void vs1052setXCS(char val) diff --git a/examples/SOLAR_PSU_HELLO/main.c b/examples/SOLAR_PSU_HELLO/main.c --- a/examples/SOLAR_PSU_HELLO/main.c +++ b/examples/SOLAR_PSU_HELLO/main.c @@ -7,6 +7,13 @@ #include #include #include +#include +#include +#include +#include +#include +#include + extern streamdevice* __opnfiles__[]; @@ -30,13 +37,60 @@ void randBoxesDemo() int main() { + while(!bspsdcardpresent()); + delay_100us(5000); + printf("About to initialize SDCARD"); + sdcardDev sdcard2; + blkdevice sdcard2blkdev; + dikpartition sdcard2Part1; + FAT32fs partoche; + sdcardspimake(&sdcard2,(UHANDLE)SDCARD2SPI,spigetnc,spiputnc,spisetspeed,spigetspeed); + sdcardspimakeblkdev(&sdcard2blkdev,&sdcard2,bspsdcardselect,bsppowersdcard,bspsdcardpresent,bspsdcardwriteprotected); + sdcard2blkdev.initialize(&sdcard2blkdev); + mbropen(&sdcard2blkdev,&sdcard2Part1,1); + if(FATnoErr==fat32open(&partoche,&sdcard2Part1)) + { + printf("FAT32 partition opened\n"); + char test[]=" \n"; + ucdirent root,folder; + fat32mkdirent(&partoche,&root); + fat32getrootfirstent(&root); + fat32getVolName(&partoche,test); + printf("Vol Name=%s\n",test); + fat32getdirentname(&root,test); + printf("%s\n",test); + while (DIRENT_EndOfDir!=fat32nextdirent(&root)) + { + if(test[0]=='m') + { + printf("enter music folder\n"); + fat32enterdirent(&root,&folder); + while (DIRENT_EndOfDir!=fat32nextdirent(&folder)) + { + printf("%s\n",test); + } + } + fat32getdirentname(&root,test); + printf("%s\n",test); + } + if(test[0]=='m') + { + printf("enter music folder\n"); + fat32enterdirent(&root,&folder); + while (DIRENT_EndOfDir!=fat32nextdirent(&folder)) + { + printf("%s\n",test); + } + } + } while(1) { -// printf("Audio Codec reg0=0x%x\n",vs10XXcmdread(&audioCodec0,0)); + // printf("Audio Codec reg0=0x%x\n",vs10XXcmdread(&audioCodec0,0)); // printf("hello "); // bsp_lcd0_write_reg(1,0x1234); // delay_100us(10000); - // randBoxesDemo(); + // randBoxesDemo(); + gpioset(LED1); delay_100us(10000); gpioclr(LED1); diff --git a/lib/src/common/FILE_SYSTEM/MBR/mbr.c b/lib/src/common/FILE_SYSTEM/MBR/mbr.c --- a/lib/src/common/FILE_SYSTEM/MBR/mbr.c +++ b/lib/src/common/FILE_SYSTEM/MBR/mbr.c @@ -32,6 +32,7 @@ int mbropen(blkdevice* phy,dikpartition* if(phy->read(phy,mbr,0,1)!=RES_OK) { printf("can't read MBR!\n"); + printf("%x %x %x %x %x %x %x %x\n",mbr[0],mbr[1],mbr[2],mbr[3],mbr[4],mbr[5],mbr[6],mbr[7]); return MBRReadErr; } if(((mbr[510]) == (char)0x55) && ((mbr[511]) == (char)0xAA)) diff --git a/lib/src/common/FILE_SYSTEM/SDCARD/sdcard.c b/lib/src/common/FILE_SYSTEM/SDCARD/sdcard.c --- a/lib/src/common/FILE_SYSTEM/SDCARD/sdcard.c +++ b/lib/src/common/FILE_SYSTEM/SDCARD/sdcard.c @@ -64,7 +64,7 @@ int sdcardwait_ready (sdcardDev* sdcard) unsigned int tmr; volatile unsigned int i=0; - for (tmr = 1000; tmr>0; tmr--) { /* Wait for ready in timeout of 500ms */ + for (tmr = 500; tmr>0; tmr--) { /* Wait for ready in timeout of 500ms */ sdcard->rcvr_mmc(sdcard->phy,&d, 1); if (d == 0xFF) break; delay_100us(10); @@ -78,10 +78,10 @@ int sdcardrcvr_datablock (sdcardDev* sdc char d[2]; unsigned int tmr; volatile unsigned int i=0; - for (tmr = 50000; tmr; tmr--) { /* Wait for data packet in timeout of 100ms */ + for (tmr = 100; tmr; tmr--) { /* Wait for data packet in timeout of 100ms */ sdcard->rcvr_mmc(sdcard->phy,d, 1); if (d[0] != 0xFF) break; - for(i=0;i<64;i++); + delay_100us(10); } if (d[0] != 0xFE) return 0; /* If not valid data token, return with error */ @@ -139,14 +139,17 @@ char sdcardsend_cmd (blkdeviceptr _this, buf[5] = n; ((sdcardDev*)_this->phy)->xmit_mmc(((sdcardDev*)_this->phy)->phy,buf, 6); /* Receive command response */ - if (cmd == CMD12) {((sdcardDev*)_this->phy)->rcvr_mmc(((sdcardDev*)_this->phy)->phy,&d, 1);} /* Skip a stuff byte when stop reading */ - n = 10; /* Wait for a valid response in timeout of 10 attempts */ + if (cmd == CMD12) + { + ((sdcardDev*)_this->phy)->rcvr_mmc(((sdcardDev*)_this->phy)->phy,&d, 1); + } /* Skip a stuff byte when stop reading */ + n = 100; /* Wait for a valid response in timeout of 100 attempts */ do { ((sdcardDev*)_this->phy)->rcvr_mmc(((sdcardDev*)_this->phy)->phy,&d, 1); + delay_100us(10); //libucprintf("resp=%d\n\r",d); - } - while ((d & 0x80) && --n); + }while ((d & 0x80) && --n); return d; /* Return with the response value */ } @@ -206,13 +209,17 @@ DSTATUS sdcarddisk_initialize (blkdevice printf("SDCARD in Idle mode\n"); Timer1 = 1000; /* Initialization timeout = 1 sec */ if (sdcardsend_cmd(_this,CMD8, 0x1AA) == 1) { /* SDv2? */ + printf("SDCARD V2\n"); ((sdcardDev*)_this->phy)->rcvr_mmc(((sdcardDev*)_this->phy)->phy,ocr, 4); //for (n = 0; n < 4; n++) ocr[n] = xchg_spi(0xFF); /* Get 32 bit return value of R7 resp */ if (ocr[2] == 0x01 && ocr[3] == 0xAA) { /* Is the card supports vcc of 2.7-3.6V? */ + printf("The card supports vcc of 2.7-3.6V\n"); while (Timer1 && sdcardsend_cmd(_this,ACMD41, 1UL << 30)) ; /* Wait for end of initialization with ACMD41(HCS) */ if (Timer1 && sdcardsend_cmd(_this,CMD58, 0) == 0) { /* Check CCS bit in the OCR */ //for (n = 0; n < 4; n++) ocr[n] = xchg_spi(0xFF); - ((sdcardDev*)_this->phy)->rcvr_mmc(((sdcardDev*)_this->phy)->phy,ocr, 4); + printf("Check CCS bit in the OCR:\n"); + ((sdcardDev*)_this->phy)->rcvr_mmc(((sdcardDev*)_this->phy)->phy,ocr, 4); + printf("OCR[0]=0x%X\n",ocr[0]); ty = (ocr[0] & 0x40) ? CT_SD2 | CT_BLOCK : CT_SD2; /* Card id SDv2 */ } } @@ -228,6 +235,7 @@ DSTATUS sdcarddisk_initialize (blkdevice } } ((sdcardDev*)_this->phy)->CardType = ty; /* Card type */ + printf("CardType=0x%X\n",ty); if (ty) { /* OK */ ((sdcardDev*)_this->phy)->Stat &= ~STA_NOINIT; /* Clear STA_NOINIT flag */ @@ -247,7 +255,7 @@ DSTATUS sdcarddisk_initialize (blkdevice break; } } - if(speed>(50*1000*1000)) + if((speed>(50*1000*1000)) || (speed >= getCpuFreq())) { break; } @@ -257,6 +265,7 @@ DSTATUS sdcarddisk_initialize (blkdevice speed-=1000000; ((sdcardDev*)_this->phy)->setspeed(((sdcardDev*)_this->phy)->phy,speed); } + printf("SDCARD speed = %dMHz\n",speed/1000000); } else { /* Failed */ //power_off(); diff --git a/lib/src/common/GRAPHIC/GUI/Widgets/Terminal/Terminal.c b/lib/src/common/GRAPHIC/GUI/Widgets/Terminal/Terminal.c --- a/lib/src/common/GRAPHIC/GUI/Widgets/Terminal/Terminal.c +++ b/lib/src/common/GRAPHIC/GUI/Widgets/Terminal/Terminal.c @@ -46,8 +46,8 @@ int terminal_init(terminal_t* terminal,L terminal->font=font; terminal->line = 0; terminal->column = 0; - terminal->horizontalSpace=-2; - terminal->verticalSpace=2; + terminal->horizontalSpace=0; + terminal->verticalSpace=0; int charw=terminal->font->Width + terminal->horizontalSpace; int charh=terminal->font->Height + terminal->verticalSpace; terminal->textColor=0xFFFF;