Sandro
Well-known member
Hi all! In my audio application, I need to open many audio files (stored in the external flash chip on the Audio Adaptor) in the "same time".
Each activity with an audio file starts with:
SerialFlash.open looks for file attributes (address, length, offset, dirindex), if file_name exist, on flash chip, reading on its "file-index" than copies these values into rawfile:
This process takes on average about 50us, due to the read time of the flash: a relatively long time, considering the available time (about 2900us) that I reserve for completing the update() process.
So, instead of using SerialFlash.open, my idea is:
1) read all files attributes on flash chip (address, length, offset, dirindex) at setup() time and save these data in a RAM repository:
2) compile rawfile data.
The first part is very easy to do, since there are existing methods in SerialFlashFile class; the second is less trivial because rawfile is (rightly) protected; these assignments are not immediately possible :
I've tried in to write a class that inherits from SerialFlashFile, but I cannot find a way to open the lock. Of course, I don't want to modify anything SerialFlash library; I would only create a minimum overlay for my purpose.
Thanks in advance for any idea!
Each activity with an audio file starts with:
Code:
SerialFlashFile rawfile;
rawfile = SerialFlash.open(file_name);
SerialFlash.open looks for file attributes (address, length, offset, dirindex), if file_name exist, on flash chip, reading on its "file-index" than copies these values into rawfile:
Code:
rawfile.address = buf[0];
rawfile.length = buf[1];
rawfile.offset = 0;
rawfile.dirindex = index + i;
This process takes on average about 50us, due to the read time of the flash: a relatively long time, considering the available time (about 2900us) that I reserve for completing the update() process.
So, instead of using SerialFlash.open, my idea is:
1) read all files attributes on flash chip (address, length, offset, dirindex) at setup() time and save these data in a RAM repository:
Code:
#define n_files 500
struct flashfile_data
{
uint32_t address;
uint32_t length;
uint16_t dirindex;
} rawfiledata[n_files];
2) compile rawfile data.
The first part is very easy to do, since there are existing methods in SerialFlashFile class; the second is less trivial because rawfile is (rightly) protected; these assignments are not immediately possible :
Code:
rawfile.address = rawfiledata[i].address;
rawfile.length = rawfiledata[i].length;
rawfile.offset = 0;
rawfile.dirindex = rawfiledata[i].dirindex;
I've tried in to write a class that inherits from SerialFlashFile, but I cannot find a way to open the lock. Of course, I don't want to modify anything SerialFlash library; I would only create a minimum overlay for my purpose.
Thanks in advance for any idea!
Last edited: