for demostration purposes only - SD card should not be read in the k-rate or s-rate cycles, they should load in a separate thread Mark Harris BSD table2h.axh 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288 1048576 2097152 4194304 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
chibios/ext/fatfs/src/ff.h fatfs polyIndex][0]; { int i; for(i=0;i0) && !ntrig) { // NOTE: demo only, // do not call f_open/read/close in k-rate code, could cause buffer overrun // if an error occurs the buffer is in an unknown state, could cause severe audio glitch char* filename = &c[0]; ntrig=1; FIL FileObject; FRESULT err; UINT bytes_read; LogTextMessage("Reading %s",filename); err = f_open(&FileObject, filename, FA_READ | FA_OPEN_EXISTING); if (err != FR_OK) { report_fatfs_error(err,filename); return;} int rem_sz = sizeof(*array)*LENGTH; int offset = 0; while (rem_sz>0) { if (rem_sz>sizeof(fbuff)) { err = f_read(&FileObject, fbuff, sizeof(fbuff),&bytes_read); if (bytes_read == 0) break; memcpy((char *)(&array[0]) + offset,(char *)fbuff,bytes_read); rem_sz -= bytes_read; offset += bytes_read; } else { err = f_read(&FileObject, fbuff, rem_sz,&bytes_read); memcpy((char *)(&array[0]) + offset,(char *)fbuff,bytes_read); rem_sz = 0; } } if (err != FR_OK) { report_fatfs_error(err,filename); return;}; err = f_close(&FileObject); if (err != FR_OK) { report_fatfs_error(err,filename); return;}; } else if (!(inlet_trig>0)) ntrig=0; if (inlet_index != pval){ pval = inlet_index; int i = inlet_index; int i0 = i/10; c[offset+2] = '0'+i-10*i0; i = i0; i0 = i/10; c[offset+1] = '0'+i-10*i0; i = i0; i0 = i/10; c[offset+0] = '0'+i-10*i0; }]]>