* Global variable for store current and previous data
* flash memory page address during operation of writing.
*/
-dataflash_t previous_page = 0;
-bool page_modified = false;
+static dataflash_t previous_page = 0;
+static bool page_modified = false;
/**
* hight part of address byte in third byte togheter low par of page
* address.
*
- * \{
*/
/*
/*
* Send page address.
- * \{
*/
spi_sendRecv((uint8_t)(page_addr >> (16 - DATAFLASH_PAGE_ADDRESS_BIT)));
spi_sendRecv((uint8_t)((page_addr << (DATAFLASH_PAGE_ADDRESS_BIT - 8)) + (byte_addr >> 8)));
- /*\}*/
/*
* Send byte page address.
*/
spi_sendRecv((uint8_t)byte_addr);
- /* \} */
}
/*
* Make sure to toggle CS signal in order,
* and reset dataflash command decoder.
- * \{
*/
CS_TOGGLE();
send_cmd(page_addr, byte_addr, opcode);
- CS_DISABLE();
- CS_ENABLE();
+ CS_TOGGLE();
/*
* We chech data flash memory state, and wait until busy-flag
{
/*
* Send 24 don't care bit.
- * \{
*/
spi_sendRecv(0x00);
spi_sendRecv(0x00);
spi_sendRecv(0x00);
- /* \} */
}
#endif
{
/*
* Send 24 don't care bit.
- * \{
*/
spi_sendRecv(0x00);
spi_sendRecv(0x00);
spi_sendRecv(0x00);
- /* \} */
+
}
spi_sendRecv(0x00); //Send 8 don't care bit.
/*
* We select from absolute address page address
* and byte address in page.
- * \{
*/
page_addr = fd->seek_pos / (dataflashAddr_t)DATAFLASH_PAGE_SIZE;
byte_addr = fd->seek_pos % (dataflashAddr_t)DATAFLASH_PAGE_SIZE;
- /* \} */
+
kprintf(" [page-<%ld>, byte-<%ld>]", page_addr, byte_addr);
/*
* We select from absolute address page address
* and byte address in page.
- * \{
*/
current_page = fd->seek_pos / (dataflashAddr_t)DATAFLASH_PAGE_SIZE;
byte_addr = fd->seek_pos % (dataflashAddr_t)DATAFLASH_PAGE_SIZE;
- /* \} */
+
size_t wr_len = MIN(size, DATAFLASH_PAGE_SIZE - byte_addr);
/*
* Write byte in current page, and set true
* page_modified flag.
- *\{
*/
dataflash_write_byte(byte_addr, DFO_WRITE_BUFF1, data);
page_modified = true;
- /* \} */
+
data += wr_len;
fd->seek_pos += wr_len;