From 86729451cd20c1805955d9e50f03d98b3f4e20ef Mon Sep 17 00:00:00 2001
From: asterix <asterix@38d2e660-2303-0410-9eaa-f027e97ec537>
Date: Fri, 26 Oct 2007 17:14:45 +0000
Subject: [PATCH] Remove unneeded function. Use CS_TOGGLE macro. Write kfile
 function interface prototype.

git-svn-id: https://src.develer.com/svnoss/bertos/trunk@951 38d2e660-2303-0410-9eaa-f027e97ec537
---
 drv/dflash.c | 42 ++++++++++++++----------------------------
 1 file changed, 14 insertions(+), 28 deletions(-)

diff --git a/drv/dflash.c b/drv/dflash.c
index 815d9570..7dda5db0 100644
--- a/drv/dflash.c
+++ b/drv/dflash.c
@@ -61,11 +61,14 @@ static void send_cmd(dflashAddr_t page_addr, dflashAddr_t byte_addr, DFlashOpcod
 	/*
 	 * Make sure to toggle CS signal in order,
 	 * and reset dflash command decoder.
-	 * \{
+	 *
+	 * Note:
+	 * #define CS_TOGGLE() \
+	 * 		CS_DISABLE(); \
+	 * 		CS_ENABLE(); \
 	 */
-	CS_DISABLE();
-	CS_ENABLE();
-	/* \} */
+	CS_TOGGLE();
+
 
 	/*
 	 * To send one command to data flash memory, we send 4 byte.
@@ -174,9 +177,7 @@ static uint8_t dflash_stat(void)
 	 * and reset dflash command decoder.
 	 * \{
 	 */
-	CS_DISABLE();
-	CS_ENABLE();
-	/* \} */
+	CS_TOGGLE();
 
 	stat = spi_sendRecv(DFO_READ_STATUS);
 	stat = spi_sendRecv(0x00);
@@ -241,8 +242,8 @@ static uint8_t dflash_read_byte(dflashAddr_t page_addr, dflashAddr_t byte_addr,
 }
 
 /**
- * Read \param len bytes from main data flash memory or buffer data
- * flash memory, and put it in \param *block.
+ * Read \a len bytes from main data flash memory or buffer data
+ * flash memory, and put it in \a *block.
  */
 static void dflash_read_block(dflashAddr_t page_addr, dflashAddr_t byte_addr, DFlashOpcode opcode, uint8_t *block, dflashSize_t len)
 {
@@ -269,24 +270,9 @@ static void dflash_read_block(dflashAddr_t page_addr, dflashAddr_t byte_addr, DF
 
 }
 
-/**
- * Write one byte in buffer buffer data flash memory.
- *
- * \note Isn't possible to write byte directly in main memory data
- * flash. To perform write in main memory you must before write in buffer
- * data flash memory, an then send command to write page in main memory.
- */
-static void dflash_write_byte(dflashAddr_t byte_addr, DFlashOpcode opcode, uint8_t data)
-{
-	send_cmd(0x00, byte_addr, opcode);
-
-	spi_sendRecv(data); //Write data byte.
-
-	CS_DISABLE();
-}
 
 /**
- * Write \param len bytes in buffer buffer data flash memory.
+ * Write \a len bytes in buffer buffer data flash memory.
  *
  * \note Isn't possible to write bytes directly in main memory data
  * flash. To perform write in main memory you must before write in buffer
@@ -295,7 +281,6 @@ static void dflash_write_byte(dflashAddr_t byte_addr, DFlashOpcode opcode, uint8
 static void dflash_write_block(dflashAddr_t byte_addr, DFlashOpcode opcode, uint8_t *block, dflashSize_t len)
 {
 
-
 	send_cmd(0x00, byte_addr, opcode);
 
 	spi_write(block, len); //Write len bytes.
@@ -304,6 +289,8 @@ static void dflash_write_block(dflashAddr_t byte_addr, DFlashOpcode opcode, uint
 
 }
 
+/* Kfile interface section */
+
 /**
  * Open data flash file \a fd
  * \a name and \a mode are unused, cause flash memory is
@@ -336,7 +323,6 @@ static size_t dflash_read(struct _KFile *fd, void *buf, size_t size)
 {
 }
 
-//TODO: deve ritornare un bool?
 /**
  * Init data flash memory interface.
  */
@@ -350,5 +336,5 @@ void dflash_init(struct _KFile *fd)
 	fd->seek = dflash_seek;
 
 	// Init data flash memory and micro pin.
-	dflash_pin_init();
+	ASSERT(dflash_pin_init());
 }
\ No newline at end of file
-- 
2.34.1