##// END OF EJS Templates
Fat32 library partially working, can read a file.
jeandet -
r62:25c982b9ed94 dev_alexis
parent child
Show More
@@ -30,10 +30,6
30 30 #include <i2c.h>
31 31 #include <core.h>
32 32 #include <terminal.h>
33 #include <sdcard-spi.h>
34 #include <sdcard.h>
35 #include <mbr.h>
36 #include <VS10XX.h>
37 33
38 34 uint32_t OSC0 =8000000;
39 35 uint32_t INTOSC =16000000;
@@ -68,6 +64,17 volatile int8_t* lcd0_DATA=(volatile int
68 64 float VREF0 =(float)3.3;
69 65 volatile vs10XXDev audioCodec0;
70 66
67 sdcardDev sdcard2;
68 blkdevice sdcard2blkdev;
69 dikpartition sdcard2Part1;
70 FAT32fs sdcard2FAT32part1;
71 dikpartition sdcard2Part2;
72 FAT32fs sdcard2FAT32part2;
73 dikpartition sdcard2Part3;
74 FAT32fs sdcard2FAT32part3;
75 dikpartition sdcard2Part4;
76 FAT32fs sdcard2FAT32part4;
77
71 78 int bsp_init()
72 79 {
73 80 int i=0;
@@ -100,8 +107,8 void bsp_GPIO_init()
100 107 GPIO_init |= gpiohighspeed | gpiooutdir | gpiopushpulltype;
101 108 gpiosetconfig(&GPIO_init);
102 109 }
103 gpio_t GPIO_In_init_List[]={VS1053DREQ,SDCARD2CD};
104 for(int i=0;i<2;i++)
110 gpio_t GPIO_In_init_List[]={VS1053DREQ,SDCARD2CD,BP3};
111 for(int i=0;i<3;i++)
105 112 {
106 113 gpio_t GPIO_init = gpioopen(GPIO_In_init_List[i]);
107 114 GPIO_init |= gpiohighspeed | gpioindir;
@@ -199,15 +206,15 int bsp_FSMC_init()
199 206
200 207 void bsp_spi_init()
201 208 {
202 // gpio_t VSSPI_DBxList[]={VS1053SCK,VS1053MOSI,VS1053MISO};
203 // for(int i=0;i<3;i++)
204 // {
205 // gpio_t SPI_DBx = gpioopen(VSSPI_DBxList[i]);
206 // SPI_DBx |= gpiohighspeed | gpioaf | gpiopushpulltype | gpionopulltype;
207 // gpiosetconfig(&SPI_DBx);
208 // GPIO_PinAFConfig(GPIOGETPORT(SPI_DBx), (uint8_t)(SPI_DBx & 0xF), GPIO_AF_SPI1);
209 // }
210 // spiopenandconfig(VS1053SPI,spi8bits|spimaster|spimsbfirst,2*1000*1000,VS1053MOSI,VS1053MISO,VS1053SCK,-1);
209 gpio_t VSSPI_DBxList[]={VS1053SCK,VS1053MOSI,VS1053MISO};
210 for(int i=0;i<3;i++)
211 {
212 gpio_t SPI_DBx = gpioopen(VSSPI_DBxList[i]);
213 SPI_DBx |= gpiohighspeed | gpioaf | gpiopushpulltype | gpionopulltype;
214 gpiosetconfig(&SPI_DBx);
215 GPIO_PinAFConfig(GPIOGETPORT(SPI_DBx), (uint8_t)(SPI_DBx & 0xF), GPIO_AF_SPI1);
216 }
217 spiopenandconfig(VS1053SPI,spi8bits|spimaster|spimsbfirst,2*1000*1000,VS1053MOSI,VS1053MISO,VS1053SCK,-1);
211 218
212 219 gpio_t SDSPI_DBxList[]={SDCARD2SCK,SDCARD2MOSI,SDCARD2MISO};
213 220 for(int i=0;i<3;i++)
@@ -231,17 +238,91 void bsp_iic_init()
231 238 void bsp_Audio_init()
232 239 {
233 240 vs10XXopen(&audioCodec0,VS1053SPI,vs1052setXCS,vs1052setRST,vs1052setXDCS,vs10XXDREQ);
241 if(audioCodec0.VERSION!=UNKNOWN)
242 {
243 printf("detected Audio codec ");
244 switch (audioCodec0.VERSION) {
245 case VS1001:
246 printf("VS1001\n");
247 break;
248 case VS1011:
249 printf("VS1011\n");
250 break;
251 case VS1002:
252 printf("VS1002\n");
253 break;
254 case VS1003:
255 printf("VS1003\n");
256 break;
257 case VS1053:
258 printf("VS1053\n");
259 break;
260 case VS1033:
261 printf("VS1033\n");
262 break;
263 case VS1103:
264 printf("VS1103\n");
265 break;
266 default:
267 printf("Unknown device\n");
268 break;
269 }
270 }
234 271 }
235 272
236 273 void bsp_SD_init()
237 274 {
238 // sdcardDev sdcard2;
239 // blkdevice sdcard2blkdev;
240 // dikpartition sdcard2Part1;
241 // sdcardspimake(&sdcard2,(UHANDLE)SDCARD2SPI,spigetnc,spiputnc,spisetspeed,spigetspeed);
242 // sdcardspimakeblkdev(&sdcard2blkdev,&sdcard2,bspsdcardselect,bsppowersdcard,bspsdcardpresent,bspsdcardwriteprotected);
243 // sdcard2blkdev.initialize(&sdcard2blkdev);
244 // mbropen(&sdcard2blkdev,&sdcard2Part1,1);
275 if(bspsdcardpresent())
276 {
277 sdcardspimake(&sdcard2,(UHANDLE)SDCARD2SPI,spigetnc,spiputnc,spisetspeed,spigetspeed);
278 sdcardspimakeblkdev(&sdcard2blkdev,&sdcard2,bspsdcardselect,bsppowersdcard,bspsdcardpresent,bspsdcardwriteprotected);
279 if(sdcard2blkdev.initialize(&sdcard2blkdev)!=STA_NOINIT)
280 {
281 if(mbropen(&sdcard2blkdev,&sdcard2Part1,1)==MBRnoErr)
282 {
283 if(FATnoErr!=fat32open(&sdcard2FAT32part1,&sdcard2Part1))
284 printf("Can't open fat32 partition 1\n");
285 }
286 else
287 {
288 printf("Can't open or read MBR\n");
289 }
290
291 if(mbropen(&sdcard2blkdev,&sdcard2Part2,2)==MBRnoErr)
292 {
293 if(FATnoErr!=fat32open(&sdcard2FAT32part2,&sdcard2Part2))
294 printf("Can't open fat32 partition 2\n");
295 }
296 else
297 {
298 printf("Can't open or read MBR\n");
299 }
300
301 if(mbropen(&sdcard2blkdev,&sdcard2Part3,3)==MBRnoErr)
302 {
303 if(FATnoErr!=fat32open(&sdcard2FAT32part3,&sdcard2Part3))
304 printf("Can't open fat32 partition 3\n");
305 }
306 else
307 {
308 printf("Can't open or read MBR\n");
309 }
310
311 if(mbropen(&sdcard2blkdev,&sdcard2Part4,4)==MBRnoErr)
312 {
313 if(FATnoErr!=fat32open(&sdcard2FAT32part4,&sdcard2Part4))
314 printf("Can't open fat32 partition 4\n");
315 }
316 else
317 {
318 printf("Can't open or read MBR\n");
319 }
320 }
321 else
322 {
323 printf("Can't initialize SDCARD\n");
324 }
325 }
245 326 }
246 327
247 328 void vs1052setXCS(char val)
@@ -251,6 +332,7 void vs1052setXCS(char val)
251 332
252 333 void vs1052setXDCS(char val)
253 334 {
335 //gpiosetval(LED1,(int)val);
254 336 gpiosetval(VS1053xDCS,(int)val);
255 337 }
256 338
@@ -285,6 +367,7 char bspsdcardwriteprotected()
285 367
286 368 void bspsdcardselect(char YESNO)
287 369 {
370 // gpiosetval(LED1,(int)YESNO);
288 371 if(YESNO)
289 372 gpioclr(SDCARD2CS);
290 373 else
@@ -28,7 +28,11
28 28 #include <spi.h>
29 29 #include <ili9328.h>
30 30 #include <genericLCD_Controler.h>
31 #include <sdcard-spi.h>
32 #include <sdcard.h>
33 #include <mbr.h>
31 34 #include <VS10XX.h>
35 #include <fat32.h>
32 36
33 37 #define __MAX_OPENED_FILES__ 4
34 38 #define __FS_ROOT_SIZE__ 4
@@ -37,6 +41,8
37 41 #define LED1 PC15
38 42 #define LED2 PC14
39 43
44 #define BP3 PA0
45
40 46 #define LCD_RESET PD10
41 47 #define LCD_BACKL PE11
42 48
@@ -65,6 +71,17 extern LCD_t lcd0;
65 71
66 72 extern volatile vs10XXDev audioCodec0;
67 73
74 extern sdcardDev sdcard2;
75 extern blkdevice sdcard2blkdev;
76 extern dikpartition sdcard2Part1;
77 extern FAT32fs sdcard2FAT32part1;
78 extern dikpartition sdcard2Part2;
79 extern FAT32fs sdcard2FAT32part2;
80 extern dikpartition sdcard2Part3;
81 extern FAT32fs sdcard2FAT32part3;
82 extern dikpartition sdcard2Part4;
83 extern FAT32fs sdcard2FAT32part4;
84
68 85 extern int bsp_init();
69 86
70 87 extern void bsp_GPIO_init();
@@ -13,9 +13,11
13 13 #include <fat32.h>
14 14 #include <ucdirent.h>
15 15 #include <string.h>
16 #include <terminal.h>
16 17
17 18
18 19 extern streamdevice* __opnfiles__[];
20 char buffer[512];
19 21
20 22 void randBoxesDemo()
21 23 {
@@ -34,70 +36,142 void randBoxesDemo()
34 36 //delay_100us(10);
35 37 //for(volatile int i=0;i<(1024*2);i++);
36 38 }
39 void tryToplay1()
40 {
41
42 extern FAT32fs sdcard2FAT32part1;
43 extern volatile vs10XXDev audioCodec0;
44 ucdirent root;
45 char direntName[]=" \n";
46 uint32_t fileLba,nextLba;
47 int i=0;
48 spisetspeed(audioCodec0.SPIdev,2000000);
49 if(DIRENT_noErr==fat32mkdirent(&sdcard2FAT32part1,&root))
50 {
51 if(DIRENT_noErr==fat32getrootfirstent(&root))
52 {
53 do{
54 fat32getdirentname(&root,direntName);
55 printf("%s\n",direntName);
56 nextLba=fat32getdirentlba(&root);
57 printf("Streaming File\n");
58 do
59 {
60 fileLba = nextLba;
61 if(sdcard2FAT32part1.part->phy->read(sdcard2FAT32part1.part->phy,buffer,fileLba,1)==RES_OK)
62 {
63 for(i=0;i<512;i+=32)
64 {
65 vs10XXstream32bytes(&audioCodec0,buffer+i);
66 }
67 }
68 }while ((fat32nextsectorlba(&sdcard2FAT32part1,fileLba,&nextLba)==DIRENT_noErr) && (!gpiogetval(BP3)));
69 //vs10XXsoftReset(&audioCodec0);
70 while (gpiogetval(BP3))delay_100us(1000);
71 printf("looking for next file\n");
72 }while (DIRENT_noErr==fat32nextdirent(&root));
73 }
74 }
75 if(DIRENT_noErr==fat32mkdirent(&sdcard2FAT32part2,&root))
76 {
77 if(DIRENT_noErr==fat32getrootfirstent(&root))
78 {
79 fat32getdirentname(&root,direntName);
80 printf("%s\n",direntName);
81 nextLba=fat32getdirentlba(&root);
82 printf("Streaming File\n");
83 do
84 {
85 fileLba = nextLba;
86 if(sdcard2FAT32part2.part->phy->read(sdcard2FAT32part2.part->phy,buffer,fileLba,1)==RES_OK)
87 {
88 for(i=0;i<512;i+=32)
89 {
90 vs10XXstream32bytes(&audioCodec0,buffer+i);
91 }
92 }
93 }while ((fat32nextsectorlba(&sdcard2FAT32part2,fileLba,&nextLba)==DIRENT_noErr) && (!gpiogetval(BP3)));
94 while (gpiogetval(BP3))delay_100us(1000);
95 }
96 }
97 if(DIRENT_noErr==fat32mkdirent(&sdcard2FAT32part3,&root))
98 {
99 if(DIRENT_noErr==fat32getrootfirstent(&root))
100 {
101 fat32getdirentname(&root,direntName);
102 printf("%s\n",direntName);
103 nextLba=fat32getdirentlba(&root);
104 printf("Streaming File\n");
105 do
106 {
107 fileLba = nextLba;
108 if(sdcard2FAT32part3.part->phy->read(sdcard2FAT32part3.part->phy,buffer,fileLba,1)==RES_OK)
109 {
110 for(i=0;i<512;i+=32)
111 {
112 vs10XXstream32bytes(&audioCodec0,buffer+i);
113 }
114 }
115 }while ((fat32nextsectorlba(&sdcard2FAT32part3,fileLba,&nextLba)==DIRENT_noErr) && (!gpiogetval(BP3)));
116 while (gpiogetval(BP3))delay_100us(1000);
117 }
118 }
119 if(DIRENT_noErr==fat32mkdirent(&sdcard2FAT32part4,&root))
120 {
121 if(DIRENT_noErr==fat32getrootfirstent(&root))
122 {
123 fat32getdirentname(&root,direntName);
124 printf("%s\n",direntName);
125 nextLba=fat32getdirentlba(&root);
126 printf("Streaming File\n");
127 do
128 {
129 fileLba = nextLba;
130 if(sdcard2FAT32part4.part->phy->read(sdcard2FAT32part4.part->phy,buffer,fileLba,1)==RES_OK)
131 {
132 for(i=0;i<512;i+=32)
133 {
134 vs10XXstream32bytes(&audioCodec0,buffer+i);
135 }
136 }
137 }while ((fat32nextsectorlba(&sdcard2FAT32part4,fileLba,&nextLba)==DIRENT_noErr) && (!gpiogetval(BP3)));
138 while (gpiogetval(BP3))delay_100us(1000);
139 }
140 }
141 }
142 void tryToplay2()
143 {
144
145 extern blkdevice sdcard2blkdev;
146 int i=0,l=0;
147
148 spisetspeed(audioCodec0.SPIdev,4000000);
149 printf("Streaming File\n");
150
151 //printf("New LBA=0x%X\n",nextLba);
152
153 while(sdcard2blkdev.read(&sdcard2blkdev,buffer,l++,1)==RES_OK)
154 {
155
156 for(i=0;i<512;i+=32)
157 {
158 vs10XXstream32bytes(&audioCodec0,buffer+i);
159 }
160 }
161 }
37 162
38 163 int main()
39 164 {
40 while(!bspsdcardpresent());
41 delay_100us(5000);
42 printf("About to initialize SDCARD");
43 sdcardDev sdcard2;
44 blkdevice sdcard2blkdev;
45 dikpartition sdcard2Part1;
46 FAT32fs partoche;
47 sdcardspimake(&sdcard2,(UHANDLE)SDCARD2SPI,spigetnc,spiputnc,spisetspeed,spigetspeed);
48 sdcardspimakeblkdev(&sdcard2blkdev,&sdcard2,bspsdcardselect,bsppowersdcard,bspsdcardpresent,bspsdcardwriteprotected);
49 sdcard2blkdev.initialize(&sdcard2blkdev);
50 mbropen(&sdcard2blkdev,&sdcard2Part1,1);
51 if(FATnoErr==fat32open(&partoche,&sdcard2Part1))
52 {
53 printf("FAT32 partition opened\n");
54 char test[]=" \n";
55 ucdirent root,folder;
56 fat32mkdirent(&partoche,&root);
57 fat32getrootfirstent(&root);
58 fat32getVolName(&partoche,test);
59 printf("Vol Name=%s\n",test);
60 fat32getdirentname(&root,test);
61 printf("%s\n",test);
62 while (DIRENT_EndOfDir!=fat32nextdirent(&root))
63 {
64 if(test[0]=='m')
65 {
66 printf("enter music folder\n");
67 fat32enterdirent(&root,&folder);
68 while (DIRENT_EndOfDir!=fat32nextdirent(&folder))
69 {
70 printf("%s\n",test);
71 }
72 }
73 fat32getdirentname(&root,test);
74 printf("%s\n",test);
75 }
76 if(test[0]=='m')
77 {
78 printf("enter music folder\n");
79 fat32enterdirent(&root,&folder);
80 while (DIRENT_EndOfDir!=fat32nextdirent(&folder))
81 {
82 printf("%s\n",test);
83 }
84 }
85 }
86 while(1)
87 {
88 // printf("Audio Codec reg0=0x%x\n",vs10XXcmdread(&audioCodec0,0));
89 // printf("hello ");
90 // bsp_lcd0_write_reg(1,0x1234);
91 // delay_100us(10000);
92 // randBoxesDemo();
93
94 gpioset(LED1);
95 delay_100us(10000);
96 gpioclr(LED1);
97 delay_100us(10000);
98
99 }
100 printf("hello world\n\r");
165 extern terminal_t terminal0;
166 extern volatile vs10XXDev audioCodec0;
167 printf("Volume=0x%x\n",vs10XXcmdread(&audioCodec0,VSVOL));
168 vs10XXcmdwrite(&audioCodec0,VSCLOCKF,0x2000);
169 vs10XXcmdwrite(&audioCodec0,VSVOL,0x2222);
170 printf("VSCLOCKF=0x%x\n",vs10XXcmdread(&audioCodec0,VSCLOCKF));
171 printf("VSMODE=0x%x\n",vs10XXcmdread(&audioCodec0,VSMODE));
172 terminal_clear(&terminal0);
173 // tryToplay2();
174 tryToplay1();
101 175 return 0;
102 176 }
103 177
@@ -22,6 +22,7
22 22 #include <spi.h>
23 23 #include <VS10XX.h>
24 24 #include <core.h>
25 #include <stdio.h>
25 26 //#include <bsp.h>
26 27
27 28 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
36 37 codec->setxRST(0);
37 38 delay_100us(2);
38 39 codec->setxRST(1);
40 int status;
41 do{
42 status= vs10XXcmdread(codec,VSSTATUS);
43 }while (status==0xc);
44 printf("Status=0x%x\n",status);
45 status = (status>>4) & 0xF;
46 switch (status) {
47 case 0:
48 codec->VERSION = VS1001;
49 break;
50 case 1:
51 codec->VERSION = VS1011;
52 break;
53 case 2:
54 codec->VERSION = VS1002;
55 break;
56 case 3:
57 codec->VERSION = VS1003;
58 break;
59 case 4:
60 codec->VERSION = VS1053;
61 break;
62 case 5:
63 codec->VERSION = VS1033;
64 break;
65 case 7:
66 codec->VERSION = VS1103;
67 break;
68 default:
69 codec->VERSION = UNKNOWN;
70 break;
71 }
39 72 }
40 73
41 74 void vs10XXsoftreset(vs10XXDev* dev)
@@ -43,6 +76,24 void vs10XXsoftreset(vs10XXDev* dev)
43 76 vs10XXcmdwrite(dev,VSMODE,(1<<2));
44 77 }
45 78
79 void vs10XXsetCansel(vs10XXDev* dev)
80 {
81 int mode=vs10XXcmdread(dev,VSMODE);
82 vs10XXcmdwrite(dev,VSMODE,mode|8);
83 }
84
85 void vs10XXsoftReset(vs10XXDev* dev)
86 {
87 int mode=vs10XXcmdread(dev,VSMODE);
88 vs10XXcmdwrite(dev,VSMODE,mode|4);
89 }
90
91 int vs10XXcanselAccepted(vs10XXDev* dev)
92 {
93 int mode=vs10XXcmdread(dev,VSMODE);
94 return ((mode & 8)!=8);
95 }
96
46 97 int vs10XXcmdread(vs10XXDev* dev,char address)
47 98 {
48 99 int result;
@@ -68,5 +119,14 void vs10XXcmdwrite(vs10XXDev* dev,char
68 119 }
69 120
70 121
122 void vs10XXstream32bytes(vs10XXDev* dev,char* buffer)
123 {
124 while(!dev->getDREQ());
125 dev->setxCS(1);
126 dev->setxDCS(0);
127 spiputnc(dev->SPIdev,buffer,32);
128 dev->setxDCS(1);
129
130 }
71 131
72 132
@@ -102,7 +102,7 int fat32enterdirent(ucdirent* currenten
102 102 int fat32nextdirent(ucdirent* entry)
103 103 {
104 104 uint32_t n=0,res=DIRENT_noErr,k,j;
105 k=(((signed char)entry->Currententry)+1)*32; /*Restart at last dir entry*/
105 k=(0xFF&((signed char)entry->Currententry)+1)*32; /*Restart at last dir entry*/
106 106 j=entry->CurrentSec;// /*Restart at last sector*/
107 107 do
108 108 {
@@ -114,7 +114,7 int fat32nextdirent(ucdirent* entry)
114 114 if(fat32buff[DIR_Nameoff+k]==(char)0)
115 115 return DIRENT_EndOfDir; /*0x00 = end of dir*/
116 116 else
117 if((fat32buff[DIR_Attroff + k]==ATTR_DIRECTORY)||(fat32buff[DIR_Attroff + k]==ATTR_ARCHIVE)||(fat32buff[DIR_Attroff + k]==(ATTR_READ_ONLY)))
117 if((fat32buff[DIR_Attroff + k]==(char)ATTR_DIRECTORY)||(fat32buff[DIR_Attroff + k]==(char)ATTR_ARCHIVE)||(fat32buff[DIR_Attroff + k]==(char)(ATTR_READ_ONLY)))
118 118 {
119 119 for(n=0;n<16;n++)entry->DIR_Name[n] = '\0';
120 120 for(n=0;n<11;n++)entry->DIR_Name[n] = fat32buff[n+DIR_Nameoff + k];
@@ -233,18 +233,28 uint32_t fat32getdirentlba(ucdirent* ent
233 233 int fat32nextsectorlba(FAT32fs* fs,uint32_t lastsector_lba,uint32_t *nextsector_lba)
234 234 {
235 235
236 if(((lastsector_lba + 1 - fs->cluster_begin_lba) & (fs->BPB_SecPerClus-1))!=0) /*Is it the last sector of the cluster?*/
236 if(((lastsector_lba + 1 - fs->cluster_begin_lba) & ((uint32_t)(fs->BPB_SecPerClus)-1))!=0) /*Is it the last sector of the cluster?*/
237 237 {
238 238 *nextsector_lba = lastsector_lba+1; /*if not just increment lba*/
239 239 return DIRENT_noErr;
240 }
240 }
241
241 242 uint32_t clusternum=fat32sectorlbatoclusternum(fs,lastsector_lba); /*Get cluster Number from sector number*/
242 243 uint32_t fatsec=fat32clusterinfatsect(fs,clusternum); /*Get FAT sector number*/
243 244 fat32sectorreadout(fs,fatsec);
244 245 int i= fat32clusterinfatoff(clusternum);
245 246 *nextsector_lba=fat32Ui8_2_Ui32(fat32buff,i);
246 if(*nextsector_lba==0xFFFFFFF7)return DIRENT_BadSect;
247 if(*nextsector_lba>=0xFFFFFFF6)return DIRENT_LastSect;
247 if(*nextsector_lba==0xFFFFFFF7)
248 {
249
250 printf("DIRENT_BadSect\n");
251 return DIRENT_BadSect;
252 }
253 if((uint32_t)(*nextsector_lba)>=(uint32_t)0xFFFFFFF6)
254 {
255 printf("DIRENT_LastSect\n");
256 return DIRENT_LastSect;
257 }
248 258 *nextsector_lba = clusterlba(fs,*nextsector_lba);
249 259 return DIRENT_noErr;
250 260 }
@@ -15,3 +15,6 UCMODEL=stm32f4
15 15 target.path = $$[QT_INSTALL_LIBS]/$$UCMODEL
16 16 INSTALLS += target
17 17
18 HEADERS += \
19 ../../../includes/fat32.h
20
@@ -202,7 +202,7 DSTATUS sdcarddisk_initialize (blkdevice
202 202 return ((sdcardDev*)_this->phy)->Stat;
203 203 }
204 204 printf("SDCARD Detected\n");
205 for (n = 10; n; n--) ((sdcardDev*)_this->phy)->xmit_mmc(((sdcardDev*)_this->phy)->phy,&dummy, 1); /* Send 80 dummy clocks */
205 for (n = 100; n; n--) ((sdcardDev*)_this->phy)->xmit_mmc(((sdcardDev*)_this->phy)->phy,&dummy, 1); /* Send 80 dummy clocks */
206 206
207 207 ty = 0;
208 208 if (sdcardsend_cmd(_this,CMD0, 0) == 1) { /* Put the card SPI/Idle state */
@@ -134,6 +134,7 int terminal_writenc(terminal_t* termina
134 134 {
135 135 terminal->line= (terminal->line+1) % terminal->lineCount;
136 136 terminal->column = 0;
137 terminal_clearCurentLine(terminal);
137 138 }else {
138 139 if(buffer[0]=='\t')
139 140 {
@@ -41,6 +41,18
41 41 #define VSAICTRL2 0xE
42 42 #define VSAICTRL3 0xF
43 43
44 typedef enum VS10XXVER_en
45 {
46 UNKNOWN,
47 VS1001,
48 VS1011,
49 VS1002,
50 VS1003,
51 VS1053,
52 VS1033,
53 VS1103
54 }VS10XXVER_en;
55
44 56 typedef struct vs10XXDev
45 57 {
46 58 spi_t SPIdev;
@@ -48,7 +60,7 typedef struct vs10XXDev
48 60 void (*setxRST)(char);
49 61 void (*setxDCS)(char);
50 62 int (*getDREQ)();
51 int a;
63 VS10XXVER_en VERSION;
52 64 }vs10XXDev;
53 65
54 66
@@ -56,10 +68,13 void vs10XXopen(vs10XXDev* codec,spi_t d
56 68 void vs10XXsoftreset(vs10XXDev* dev);
57 69 int vs10XXcmdread(vs10XXDev* dev,char address);
58 70 void vs10XXcmdwrite(vs10XXDev* dev,char address,int value);
59
60 extern void vs10XXclearXCS();
61 extern void vs10XXsetXCS();
62 extern int vs10XXDREQ();
71 void vs10XXstream32bytes(vs10XXDev* dev,char* buffer);
72 void vs10XXsetCansel(vs10XXDev* dev);
73 int vs10XXcanselAccepted(vs10XXDev* dev);
74 void vs10XXsoftReset(vs10XXDev* dev);
75 //extern void vs10XXclearXCS();
76 //extern void vs10XXsetXCS();
77 //extern int vs10XXDREQ();
63 78
64 79 #endif //VS10XX_H
65 80
@@ -116,7 +116,7 typedef struct FAT32fs
116 116
117 117 //#define fat32clusterinfatsect(fs,cluster_number) ((((uint32_t)(cluster_number))>>6) + fs->fat_begin_lba)
118 118 #define fat32clusterinfatsect(fs,cluster_number) ((((uint32_t)(cluster_number))>>7) + fs->fat_begin_lba)
119 #define fat32clusterinfatoff(cluster_number) (((cluster_number)&0x3F)*4)
119 #define fat32clusterinfatoff(cluster_number) (((cluster_number)&0x7F)*4)
120 120
121 121 /*Get cluster index in FAT Table from sector address*/
122 122 #define fat32masksectorlba(sectorlba,fs) (sectorlba & (castUI32(-1)^castUI32(fs->BPB_SecPerClus-1)))
General Comments 0
You need to be logged in to leave comments. Login now