Browse Source

Always create writable files

main
PaulStoffregen 9 years ago
parent
commit
5ff9d93334
3 changed files with 9 additions and 5 deletions
  1. +0
    -3
      SerialFlash.h
  2. +8
    -1
      SerialFlashDirectory.cpp
  3. +1
    -1
      examples/TestHardware/TestHardware.ino

+ 0
- 3
SerialFlash.h View File



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());
} }

+ 8
- 1
SerialFlashDirectory.cpp View File

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);

+ 1
- 1
examples/TestHardware/TestHardware.ino View File

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");

Loading…
Cancel
Save