static SerialFlashFile open(const char *filename); | static SerialFlashFile open(const char *filename); | ||||
static bool create(const char *filename, uint32_t length, uint32_t align = 0); | static bool create(const char *filename, uint32_t length, uint32_t align = 0); | ||||
static bool createWritable(const char *filename, uint32_t length) { | |||||
return create(filename, length, 256); | |||||
} | |||||
static bool createErasable(const char *filename, uint32_t length) { | static bool createErasable(const char *filename, uint32_t length) { | ||||
return create(filename, length, blockSize()); | return create(filename, length, blockSize()); | ||||
} | } |
straddr += string_length(straddr); | straddr += string_length(straddr); | ||||
straddr = (straddr + 3) & 0x0003FFFC; | straddr = (straddr + 3) & 0x0003FFFC; | ||||
} | } | ||||
// for files aligned to pages or sectors, adjust addr & len | |||||
if (align > 0) { | if (align > 0) { | ||||
// for files aligned to sectors, adjust addr & len | |||||
address += align - 1; | address += align - 1; | ||||
address /= align; | address /= align; | ||||
address *= align; | address *= align; | ||||
length += align - 1; | length += align - 1; | ||||
length /= align; | length /= align; | ||||
length *= align; | length *= align; | ||||
} else { | |||||
// always align every file to a page boundary | |||||
// for predictable write latency and to guarantee | |||||
// write suspend for reading another file can't | |||||
// conflict on the same page (2 files never share | |||||
// a write page). | |||||
address = (address + 255) & 0xFFFFFF00; | |||||
} | } | ||||
// last check, if enough space exists... | // last check, if enough space exists... | ||||
len = strlen(filename); | len = strlen(filename); |
file.close(); | file.close(); | ||||
} else { | } else { | ||||
Serial.println(" create file"); | Serial.println(" create file"); | ||||
SerialFlash.createWritable("soundfile.wav", 3081000); | |||||
SerialFlash.createErasable("soundfile.wav", 3081000); | |||||
} | } | ||||
Serial.println("wavetable1 test"); | Serial.println("wavetable1 test"); |