Преглед на файлове

Always create writable files

main
PaulStoffregen преди 9 години
родител
ревизия
5ff9d93334
променени са 3 файла, в които са добавени 9 реда и са изтрити 5 реда
  1. +0
    -3
      SerialFlash.h
  2. +8
    -1
      SerialFlashDirectory.cpp
  3. +1
    -1
      examples/TestHardware/TestHardware.ino

+ 0
- 3
SerialFlash.h Целия файл

@@ -20,9 +20,6 @@ public:

static SerialFlashFile open(const char *filename);
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) {
return create(filename, length, blockSize());
}

+ 8
- 1
SerialFlashDirectory.cpp Целия файл

@@ -195,14 +195,21 @@ bool SerialFlashChip::create(const char *filename, uint32_t length, uint32_t ali
straddr += string_length(straddr);
straddr = (straddr + 3) & 0x0003FFFC;
}
// for files aligned to pages or sectors, adjust addr & len
if (align > 0) {
// for files aligned to sectors, adjust addr & len
address += align - 1;
address /= align;
address *= align;
length += align - 1;
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...
len = strlen(filename);

+ 1
- 1
examples/TestHardware/TestHardware.ino Целия файл

@@ -58,7 +58,7 @@ void setup() {
file.close();
} else {
Serial.println(" create file");
SerialFlash.createWritable("soundfile.wav", 3081000);
SerialFlash.createErasable("soundfile.wav", 3081000);
}

Serial.println("wavetable1 test");

Loading…
Отказ
Запис