Skip to content

Commit

Permalink
Reported Volker Kuhlmann block erase.
Browse files Browse the repository at this point in the history
  • Loading branch information
BlockoS committed Sep 25, 2011
1 parent 1088e71 commit c264fb8
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions DataFlash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,9 +474,10 @@ void DataFlash::pageToBuffer(uint16_t page, uint8_t bufferNum)
SPI.transfer(bufferNum ? DATAFLASH_TRANSFER_PAGE_TO_BUFFER_2 :
DATAFLASH_TRANSFER_PAGE_TO_BUFFER_1);

/* Output the 3 bytes adress.
* The only constant between all dataflashes is number of trailing don't
* care bits. It's equal to the number of page bits. */
/* Output the 3 bytes adress.
* For all DataFlashes 011D to 642D the number of trailing don't care bits
* is equal to the number of page bits plus 3 (a block consists of 8 (1<<3)
* pages), and always larger than 8 so the third byte is always 0. */
SPI.transfer(pageToHiU8(page));
SPI.transfer(pageToLoU8(page));
SPI.transfer(0);
Expand Down Expand Up @@ -523,12 +524,14 @@ void DataFlash::blockErase(uint16_t block)
/* Send opcode */
SPI.transfer(DATAFLASH_BLOCK_ERASE);

/* Output the 3 bytes adress.
* The only constant between all dataflashes is number of trailing don't care bits.
* It's equal to the number of page bits plus 3 (a block consist of 8 (1<<3) pages. */
uint8_t dontCare = m_bufferSize + 3;
SPI.transfer((uint8_t)(block >> (16 - dontCare)));
SPI.transfer((uint8_t)(block << (dontCare - 8)));
/* Output the 3 bytes adress.
* For all DataFlashes 011D to 642D the number of trailing don't care bits
* is equal to the number of page bits plus 3 (a block consists of 8 (1<<3)
* pages), and always larger than 8 so the third byte is always 0. */
uint8_t rightShift = m_bufferSize + 3 - 8;
block >>= rightShift;
SPI.transfer(highByte(block));
SPI.transfer(lowByte(block));
SPI.transfer(0x00);

/* Start block erase.
Expand Down

0 comments on commit c264fb8

Please sign in to comment.