Disable CS in dflash_cmd function and remove where is unneeded. Add comments.
authorasterix <asterix@38d2e660-2303-0410-9eaa-f027e97ec537>
Tue, 30 Oct 2007 11:31:45 +0000 (11:31 +0000)
committerasterix <asterix@38d2e660-2303-0410-9eaa-f027e97ec537>
Tue, 30 Oct 2007 11:31:45 +0000 (11:31 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@965 38d2e660-2303-0410-9eaa-f027e97ec537

drv/dataflash.c

index 2c185083658ca34428418472312d7f0b52c8acf1..67bd9ade86e56638a4dbc0cdcc5df7e35d0c4ae3 100644 (file)
@@ -183,6 +183,12 @@ static uint8_t dataflash_stat(void)
        stat = spi_sendRecv(DFO_READ_STATUS);
        stat = spi_sendRecv(0x00);
 
+       /*
+        * Note: this function could be call one more time
+        * to check register status (es. check if memory has been
+        * teminate one operation), and so we don't disable CS to
+        * allow fast reading of register status.
+        */
        return stat;
 }
 
@@ -195,6 +201,8 @@ static uint8_t dataflash_stat(void)
 static uint8_t dataflash_cmd(dataflash_t page_addr, dataflashOffset_t byte_addr, DataFlashOpcode opcode)
 {
 
+       uint8_t stat;
+
        send_cmd(page_addr, byte_addr, opcode);
 
        CS_TOGGLE();
@@ -205,7 +213,15 @@ static uint8_t dataflash_cmd(dataflash_t page_addr, dataflashOffset_t byte_addr,
         */
        while(!(dataflash_stat() & BUSY_BIT));
 
-       return (dataflash_stat());
+       stat = dataflash_stat();
+
+       /*
+        * Data flash has been terminate a sent command, and so
+        * disable CS.
+        */
+       CS_DISABLE();
+
+       return (stat);
 
 }
 
@@ -234,6 +250,7 @@ static uint8_t dataflash_read_byte(dataflash_t page_addr, dataflashOffset_t byte
 
        spi_sendRecv(0x00);         //Send 8 don't care bit.
        data = spi_sendRecv(0x00);  //Read byte.
+
        CS_DISABLE();
 
        return data;
@@ -293,8 +310,6 @@ static void dataflash_write_block(dataflashOffset_t byte_addr, DataFlashOpcode o
 static void dataflash_loadPage(dataflash_t page_addr)
 {
        dataflash_cmd(page_addr, 0x00, DFO_MOV_MEM_TO_BUFF1);
-
-       CS_DISABLE();
 }
 
 /**
@@ -306,7 +321,6 @@ void dataflash_flush(void)
        {
                dataflash_cmd(previous_page, 0x00, DFO_WRITE_BUFF1_TO_MEM_E);
 
-               CS_DISABLE();
                page_modified = false;
 
                kprintf("\n::=> Flush page:... <%ld>\n", previous_page);