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 @@ -30,10 +30,6 @@ #include #include #include -#include -#include -#include -#include uint32_t OSC0 =8000000; uint32_t INTOSC =16000000; @@ -68,6 +64,17 @@ volatile int8_t* lcd0_DATA=(volatile int float VREF0 =(float)3.3; volatile vs10XXDev audioCodec0; +sdcardDev sdcard2; +blkdevice sdcard2blkdev; +dikpartition sdcard2Part1; +FAT32fs sdcard2FAT32part1; +dikpartition sdcard2Part2; +FAT32fs sdcard2FAT32part2; +dikpartition sdcard2Part3; +FAT32fs sdcard2FAT32part3; +dikpartition sdcard2Part4; +FAT32fs sdcard2FAT32part4; + int bsp_init() { int i=0; @@ -100,8 +107,8 @@ void bsp_GPIO_init() GPIO_init |= gpiohighspeed | gpiooutdir | gpiopushpulltype; gpiosetconfig(&GPIO_init); } - gpio_t GPIO_In_init_List[]={VS1053DREQ,SDCARD2CD}; - for(int i=0;i<2;i++) + gpio_t GPIO_In_init_List[]={VS1053DREQ,SDCARD2CD,BP3}; + for(int i=0;i<3;i++) { gpio_t GPIO_init = gpioopen(GPIO_In_init_List[i]); GPIO_init |= gpiohighspeed | gpioindir; @@ -199,15 +206,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++) @@ -231,17 +238,91 @@ void bsp_iic_init() void bsp_Audio_init() { vs10XXopen(&audioCodec0,VS1053SPI,vs1052setXCS,vs1052setRST,vs1052setXDCS,vs10XXDREQ); + if(audioCodec0.VERSION!=UNKNOWN) + { + printf("detected Audio codec "); + switch (audioCodec0.VERSION) { + case VS1001: + printf("VS1001\n"); + break; + case VS1011: + printf("VS1011\n"); + break; + case VS1002: + printf("VS1002\n"); + break; + case VS1003: + printf("VS1003\n"); + break; + case VS1053: + printf("VS1053\n"); + break; + case VS1033: + printf("VS1033\n"); + break; + case VS1103: + printf("VS1103\n"); + break; + default: + printf("Unknown device\n"); + break; + } + } } 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); + if(bspsdcardpresent()) + { + sdcardspimake(&sdcard2,(UHANDLE)SDCARD2SPI,spigetnc,spiputnc,spisetspeed,spigetspeed); + sdcardspimakeblkdev(&sdcard2blkdev,&sdcard2,bspsdcardselect,bsppowersdcard,bspsdcardpresent,bspsdcardwriteprotected); + if(sdcard2blkdev.initialize(&sdcard2blkdev)!=STA_NOINIT) + { + if(mbropen(&sdcard2blkdev,&sdcard2Part1,1)==MBRnoErr) + { + if(FATnoErr!=fat32open(&sdcard2FAT32part1,&sdcard2Part1)) + printf("Can't open fat32 partition 1\n"); + } + else + { + printf("Can't open or read MBR\n"); + } + + if(mbropen(&sdcard2blkdev,&sdcard2Part2,2)==MBRnoErr) + { + if(FATnoErr!=fat32open(&sdcard2FAT32part2,&sdcard2Part2)) + printf("Can't open fat32 partition 2\n"); + } + else + { + printf("Can't open or read MBR\n"); + } + + if(mbropen(&sdcard2blkdev,&sdcard2Part3,3)==MBRnoErr) + { + if(FATnoErr!=fat32open(&sdcard2FAT32part3,&sdcard2Part3)) + printf("Can't open fat32 partition 3\n"); + } + else + { + printf("Can't open or read MBR\n"); + } + + if(mbropen(&sdcard2blkdev,&sdcard2Part4,4)==MBRnoErr) + { + if(FATnoErr!=fat32open(&sdcard2FAT32part4,&sdcard2Part4)) + printf("Can't open fat32 partition 4\n"); + } + else + { + printf("Can't open or read MBR\n"); + } + } + else + { + printf("Can't initialize SDCARD\n"); + } + } } void vs1052setXCS(char val) @@ -251,6 +332,7 @@ void vs1052setXCS(char val) void vs1052setXDCS(char val) { + //gpiosetval(LED1,(int)val); gpiosetval(VS1053xDCS,(int)val); } @@ -285,6 +367,7 @@ char bspsdcardwriteprotected() void bspsdcardselect(char YESNO) { + // gpiosetval(LED1,(int)YESNO); if(YESNO) gpioclr(SDCARD2CS); else diff --git a/bsp/src/OPLAYER/bsp.h b/bsp/src/OPLAYER/bsp.h --- a/bsp/src/OPLAYER/bsp.h +++ b/bsp/src/OPLAYER/bsp.h @@ -28,7 +28,11 @@ #include #include #include +#include +#include +#include #include +#include #define __MAX_OPENED_FILES__ 4 #define __FS_ROOT_SIZE__ 4 @@ -37,6 +41,8 @@ #define LED1 PC15 #define LED2 PC14 +#define BP3 PA0 + #define LCD_RESET PD10 #define LCD_BACKL PE11 @@ -65,6 +71,17 @@ extern LCD_t lcd0; extern volatile vs10XXDev audioCodec0; +extern sdcardDev sdcard2; +extern blkdevice sdcard2blkdev; +extern dikpartition sdcard2Part1; +extern FAT32fs sdcard2FAT32part1; +extern dikpartition sdcard2Part2; +extern FAT32fs sdcard2FAT32part2; +extern dikpartition sdcard2Part3; +extern FAT32fs sdcard2FAT32part3; +extern dikpartition sdcard2Part4; +extern FAT32fs sdcard2FAT32part4; + extern int bsp_init(); extern void bsp_GPIO_init(); 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 @@ -13,9 +13,11 @@ #include #include #include +#include extern streamdevice* __opnfiles__[]; +char buffer[512]; void randBoxesDemo() { @@ -34,70 +36,142 @@ void randBoxesDemo() //delay_100us(10); //for(volatile int i=0;i<(1024*2);i++); } +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); + } + } +} 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("hello "); - // bsp_lcd0_write_reg(1,0x1234); - // delay_100us(10000); - // randBoxesDemo(); - - gpioset(LED1); - delay_100us(10000); - gpioclr(LED1); - delay_100us(10000); - - } - printf("hello world\n\r"); + 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(); return 0; } diff --git a/lib/src/common/AUDIO/VS10XX/VS10XX.c b/lib/src/common/AUDIO/VS10XX/VS10XX.c --- a/lib/src/common/AUDIO/VS10XX/VS10XX.c +++ b/lib/src/common/AUDIO/VS10XX/VS10XX.c @@ -22,6 +22,7 @@ #include #include #include +#include //#include void vs10XXopen(vs10XXDev *codec, spi_t dev, void (*setxCS)(char), void (*setxRST)(char), void (*setxDCS)(char), int (*getDREQ)()) @@ -36,6 +37,38 @@ void vs10XXopen(vs10XXDev *codec, spi_t codec->setxRST(0); delay_100us(2); codec->setxRST(1); + int status; + do{ + status= vs10XXcmdread(codec,VSSTATUS); + }while (status==0xc); + printf("Status=0x%x\n",status); + status = (status>>4) & 0xF; + switch (status) { + case 0: + codec->VERSION = VS1001; + break; + case 1: + codec->VERSION = VS1011; + break; + case 2: + codec->VERSION = VS1002; + break; + case 3: + codec->VERSION = VS1003; + break; + case 4: + codec->VERSION = VS1053; + break; + case 5: + codec->VERSION = VS1033; + break; + case 7: + codec->VERSION = VS1103; + break; + default: + codec->VERSION = UNKNOWN; + break; + } } void vs10XXsoftreset(vs10XXDev* dev) @@ -43,6 +76,24 @@ void vs10XXsoftreset(vs10XXDev* dev) vs10XXcmdwrite(dev,VSMODE,(1<<2)); } +void vs10XXsetCansel(vs10XXDev* dev) +{ + int mode=vs10XXcmdread(dev,VSMODE); + vs10XXcmdwrite(dev,VSMODE,mode|8); +} + +void vs10XXsoftReset(vs10XXDev* dev) +{ + int mode=vs10XXcmdread(dev,VSMODE); + vs10XXcmdwrite(dev,VSMODE,mode|4); +} + +int vs10XXcanselAccepted(vs10XXDev* dev) +{ + int mode=vs10XXcmdread(dev,VSMODE); + return ((mode & 8)!=8); +} + int vs10XXcmdread(vs10XXDev* dev,char address) { int result; @@ -68,5 +119,14 @@ void vs10XXcmdwrite(vs10XXDev* dev,char } +void vs10XXstream32bytes(vs10XXDev* dev,char* buffer) +{ + while(!dev->getDREQ()); + dev->setxCS(1); + dev->setxDCS(0); + spiputnc(dev->SPIdev,buffer,32); + dev->setxDCS(1); + +} diff --git a/lib/src/common/FILE_SYSTEM/FAT32/fat32.c b/lib/src/common/FILE_SYSTEM/FAT32/fat32.c --- a/lib/src/common/FILE_SYSTEM/FAT32/fat32.c +++ b/lib/src/common/FILE_SYSTEM/FAT32/fat32.c @@ -102,7 +102,7 @@ int fat32enterdirent(ucdirent* currenten int fat32nextdirent(ucdirent* entry) { uint32_t n=0,res=DIRENT_noErr,k,j; - k=(((signed char)entry->Currententry)+1)*32; /*Restart at last dir entry*/ + k=(0xFF&((signed char)entry->Currententry)+1)*32; /*Restart at last dir entry*/ j=entry->CurrentSec;// /*Restart at last sector*/ do { @@ -114,7 +114,7 @@ int fat32nextdirent(ucdirent* entry) if(fat32buff[DIR_Nameoff+k]==(char)0) return DIRENT_EndOfDir; /*0x00 = end of dir*/ else - if((fat32buff[DIR_Attroff + k]==ATTR_DIRECTORY)||(fat32buff[DIR_Attroff + k]==ATTR_ARCHIVE)||(fat32buff[DIR_Attroff + k]==(ATTR_READ_ONLY))) + if((fat32buff[DIR_Attroff + k]==(char)ATTR_DIRECTORY)||(fat32buff[DIR_Attroff + k]==(char)ATTR_ARCHIVE)||(fat32buff[DIR_Attroff + k]==(char)(ATTR_READ_ONLY))) { for(n=0;n<16;n++)entry->DIR_Name[n] = '\0'; for(n=0;n<11;n++)entry->DIR_Name[n] = fat32buff[n+DIR_Nameoff + k]; @@ -233,18 +233,28 @@ uint32_t fat32getdirentlba(ucdirent* ent int fat32nextsectorlba(FAT32fs* fs,uint32_t lastsector_lba,uint32_t *nextsector_lba) { - if(((lastsector_lba + 1 - fs->cluster_begin_lba) & (fs->BPB_SecPerClus-1))!=0) /*Is it the last sector of the cluster?*/ + if(((lastsector_lba + 1 - fs->cluster_begin_lba) & ((uint32_t)(fs->BPB_SecPerClus)-1))!=0) /*Is it the last sector of the cluster?*/ { *nextsector_lba = lastsector_lba+1; /*if not just increment lba*/ return DIRENT_noErr; - } + } + uint32_t clusternum=fat32sectorlbatoclusternum(fs,lastsector_lba); /*Get cluster Number from sector number*/ uint32_t fatsec=fat32clusterinfatsect(fs,clusternum); /*Get FAT sector number*/ fat32sectorreadout(fs,fatsec); int i= fat32clusterinfatoff(clusternum); *nextsector_lba=fat32Ui8_2_Ui32(fat32buff,i); - if(*nextsector_lba==0xFFFFFFF7)return DIRENT_BadSect; - if(*nextsector_lba>=0xFFFFFFF6)return DIRENT_LastSect; + if(*nextsector_lba==0xFFFFFFF7) + { + + printf("DIRENT_BadSect\n"); + return DIRENT_BadSect; + } + if((uint32_t)(*nextsector_lba)>=(uint32_t)0xFFFFFFF6) + { + printf("DIRENT_LastSect\n"); + return DIRENT_LastSect; + } *nextsector_lba = clusterlba(fs,*nextsector_lba); return DIRENT_noErr; } diff --git a/lib/src/common/FILE_SYSTEM/FAT32/fat32_STM32F4.pro b/lib/src/common/FILE_SYSTEM/FAT32/fat32_STM32F4.pro --- a/lib/src/common/FILE_SYSTEM/FAT32/fat32_STM32F4.pro +++ b/lib/src/common/FILE_SYSTEM/FAT32/fat32_STM32F4.pro @@ -15,3 +15,6 @@ UCMODEL=stm32f4 target.path = $$[QT_INSTALL_LIBS]/$$UCMODEL INSTALLS += target +HEADERS += \ + ../../../includes/fat32.h + 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 @@ -202,7 +202,7 @@ DSTATUS sdcarddisk_initialize (blkdevice return ((sdcardDev*)_this->phy)->Stat; } printf("SDCARD Detected\n"); - for (n = 10; n; n--) ((sdcardDev*)_this->phy)->xmit_mmc(((sdcardDev*)_this->phy)->phy,&dummy, 1); /* Send 80 dummy clocks */ + for (n = 100; n; n--) ((sdcardDev*)_this->phy)->xmit_mmc(((sdcardDev*)_this->phy)->phy,&dummy, 1); /* Send 80 dummy clocks */ ty = 0; if (sdcardsend_cmd(_this,CMD0, 0) == 1) { /* Put the card SPI/Idle state */ 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 @@ -134,6 +134,7 @@ int terminal_writenc(terminal_t* termina { terminal->line= (terminal->line+1) % terminal->lineCount; terminal->column = 0; + terminal_clearCurentLine(terminal); }else { if(buffer[0]=='\t') { diff --git a/lib/src/includes/VS10XX.h b/lib/src/includes/VS10XX.h --- a/lib/src/includes/VS10XX.h +++ b/lib/src/includes/VS10XX.h @@ -41,6 +41,18 @@ #define VSAICTRL2 0xE #define VSAICTRL3 0xF +typedef enum VS10XXVER_en +{ + UNKNOWN, + VS1001, + VS1011, + VS1002, + VS1003, + VS1053, + VS1033, + VS1103 +}VS10XXVER_en; + typedef struct vs10XXDev { spi_t SPIdev; @@ -48,7 +60,7 @@ typedef struct vs10XXDev void (*setxRST)(char); void (*setxDCS)(char); int (*getDREQ)(); - int a; + VS10XXVER_en VERSION; }vs10XXDev; @@ -56,10 +68,13 @@ void vs10XXopen(vs10XXDev* codec,spi_t d void vs10XXsoftreset(vs10XXDev* dev); int vs10XXcmdread(vs10XXDev* dev,char address); void vs10XXcmdwrite(vs10XXDev* dev,char address,int value); - -extern void vs10XXclearXCS(); -extern void vs10XXsetXCS(); -extern int vs10XXDREQ(); +void vs10XXstream32bytes(vs10XXDev* dev,char* buffer); +void vs10XXsetCansel(vs10XXDev* dev); +int vs10XXcanselAccepted(vs10XXDev* dev); +void vs10XXsoftReset(vs10XXDev* dev); +//extern void vs10XXclearXCS(); +//extern void vs10XXsetXCS(); +//extern int vs10XXDREQ(); #endif //VS10XX_H diff --git a/lib/src/includes/fat32.h b/lib/src/includes/fat32.h --- a/lib/src/includes/fat32.h +++ b/lib/src/includes/fat32.h @@ -116,7 +116,7 @@ typedef struct FAT32fs //#define fat32clusterinfatsect(fs,cluster_number) ((((uint32_t)(cluster_number))>>6) + fs->fat_begin_lba) #define fat32clusterinfatsect(fs,cluster_number) ((((uint32_t)(cluster_number))>>7) + fs->fat_begin_lba) -#define fat32clusterinfatoff(cluster_number) (((cluster_number)&0x3F)*4) +#define fat32clusterinfatoff(cluster_number) (((cluster_number)&0x7F)*4) /*Get cluster index in FAT Table from sector address*/ #define fat32masksectorlba(sectorlba,fs) (sectorlba & (castUI32(-1)^castUI32(fs->BPB_SecPerClus-1)))