BlockoS / arduino-dataflash

Support for Atmel Dataflash for the Arduino
http://blockos.github.com/arduino-dataflash
23 stars 14 forks source link

BufferToPage should block at beginning, not end #5

Open kolosy opened 13 years ago

kolosy commented 13 years ago

The BufferToPage method currently initiates the ram -> flash transfer and blocks until completion. this should be reversed. the reason the device has two ram buffers is so that you could continuously write data to it without having the consumer wait for the flush operation.

it should be

function BufferToPage(number) while (busy) wait;

initiateTransfer(number) return

and the operations that read flash directly should wait as well. this way, if i'm writing a chunk of data that's larget than the ram buffer, i can initiate the flush, pop out, switch ram buffers and keep writing. the time necessary to flush a buffer to flash is less than the time necessary to fill a ram buffer.

kolosy commented 12 years ago

because of this change, you need to introduce checks into any function that touches the flash, including ReadMainMemoryPage and ContinuousRead. The reason is that before you couldn't have a situation where you were trying to read the flash while it was busy, but now you can.

BlockoS commented 11 years ago

I'm thinking about making DataFlash::enable call waitUntilReady before setting CS pin low.