Selaa lähdekoodia

Bugfix blockSize (Spansion chip, model with 256K sector size)

The Spansion cards can have 64Kb or 256Kb depending on the model's
number. The device id[4] must be checked to determine the sector
architecture.
main
Helen Fornazier 8 vuotta sitten
vanhempi
commit
f481f1faec
3 muutettua tiedostoa jossa 10 lisäystä ja 6 poistoa
  1. +8
    -4
      SerialFlashChip.cpp
  2. +1
    -1
      examples/CopyFromSerial/CopyFromSerial.ino
  3. +1
    -1
      examples/EraseEverything/EraseEverything.ino

+ 8
- 4
SerialFlashChip.cpp Näytä tiedosto

@@ -215,7 +215,7 @@ void SerialFlashChip::write(uint32_t addr, const void *buf, uint32_t len)
void SerialFlashChip::eraseAll()
{
if (busy) wait();
uint8_t id[3];
uint8_t id[5];
readID(id);
//Serial.printf("ID: %02X %02X %02X\n", id[0], id[1], id[2]);
if (id[0] == 0x20 && id[2] >= 0x20 && id[2] <= 0x22) {
@@ -332,7 +332,7 @@ bool SerialFlashChip::ready()

bool SerialFlashChip::begin(uint8_t pin)
{
uint8_t id[3];
uint8_t id[5];
uint8_t f;
uint32_t size;

@@ -369,8 +369,8 @@ bool SerialFlashChip::begin(uint8_t pin)
if (id[0] == ID0_SPANSION) {
// Spansion has separate suspend commands
f |= FLAG_DIFF_SUSPEND;
if (size >= 67108864) {
// Spansion chips >= 512 mbit use 256K sectors
if (!id[4]) {
// Spansion chips with id[4] == 0 use 256K sectors
f |= FLAG_256K_BLOCKS;
}
}
@@ -411,6 +411,10 @@ void SerialFlashChip::readID(uint8_t *buf)
buf[0] = SPI.transfer(0); // manufacturer ID
buf[1] = SPI.transfer(0); // memory type
buf[2] = SPI.transfer(0); // capacity
if (buf[0] == ID0_SPANSION) {
buf[3] = SPI.transfer(0); // ID-CFI
buf[4] = SPI.transfer(0); // sector size
}
CSRELEASE();
SPI.endTransaction();
//Serial.printf("ID: %02X %02X %02X\n", buf[0], buf[1], buf[2]);

+ 1
- 1
examples/CopyFromSerial/CopyFromSerial.ino Näytä tiedosto

@@ -96,7 +96,7 @@ void setup(){
SerialFlash.begin(CSPIN);

//We start by formatting the flash...
uint8_t id[3];
uint8_t id[5];
SerialFlash.readID(id);
SerialFlash.eraseAll();

+ 1
- 1
examples/EraseEverything/EraseEverything.ino Näytä tiedosto

@@ -23,7 +23,7 @@ void setup() {
delay(100);

SerialFlash.begin(FlashChipSelect);
unsigned char id[3];
unsigned char id[5];
SerialFlash.readID(id);
unsigned long size = SerialFlash.capacity(id);


Loading…
Peruuta
Tallenna