X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/910bca557cbdc34dbc8db9df91d00103ffd73c88..7d65c54eef193f4f6f4391ea9fc62ea8c14a73b2:/LUFA/Drivers/Board/AVR8/USBKEY/Dataflash.h
diff --git a/LUFA/Drivers/Board/AVR8/USBKEY/Dataflash.h b/LUFA/Drivers/Board/AVR8/USBKEY/Dataflash.h
index e54f0d838..32f7ff905 100644
--- a/LUFA/Drivers/Board/AVR8/USBKEY/Dataflash.h
+++ b/LUFA/Drivers/Board/AVR8/USBKEY/Dataflash.h
@@ -1,13 +1,13 @@
 /*
              LUFA Library
-     Copyright (C) Dean Camera, 2011.
+     Copyright (C) Dean Camera, 2012.
 
   dean [at] fourwalledcubicle [dot] com
            www.lufa-lib.org
 */
 
 /*
-  Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com)
+  Copyright 2012  Dean Camera (dean [at] fourwalledcubicle [dot] com)
 
   Permission to use, copy, modify, distribute, and sell this
   software and its documentation for any purpose is hereby granted
@@ -42,6 +42,12 @@
  *
  *  Board specific Dataflash driver header for the Atmel USBKEY board.
  *
+ *  
+ *    | Name | Info | Select Pin | SPI Port | 
|---|
+ *    | DATAFLASH_CHIP1 | AT45DB642D (8MB) | PORTE.0 | SPI0 | 
+ *    | DATAFLASH_CHIP2 | AT45DB642D (8MB) | PORTE.1 | SPI0 | 
+ *  
+ *
  *  @{
  */
 
@@ -49,7 +55,9 @@
 #define __DATAFLASH_USBKEY_H__
 
 	/* Includes: */
-		#include "../../Misc/AT45DB642D.h"
+		#include "../../../../Common/Common.h"
+		#include "../../../Misc/AT45DB642D.h"
+		#include "../../../Peripheral/SPI.h"
 
 	/* Preprocessor Checks: */
 		#if !defined(__INCLUDE_FROM_DATAFLASH_H)
@@ -85,7 +93,7 @@
 			#define DATAFLASH_PAGES                      8192
 
 		/* Inline Functions: */
-			/** Initialises the dataflash driver so that commands and data may be sent to an attached dataflash IC.
+			/** Initializes the dataflash driver so that commands and data may be sent to an attached dataflash IC.
 			 *  The microcontroller's SPI driver MUST be initialized before any of the dataflash commands are used.
 			 */
 			static inline void Dataflash_Init(void)
@@ -94,6 +102,38 @@
 				DATAFLASH_CHIPCS_PORT |= DATAFLASH_CHIPCS_MASK;
 			}
 
+			/** Sends a byte to the currently selected dataflash IC, and returns a byte from the dataflash.
+			 *
+			 *  \param[in] Byte  Byte of data to send to the dataflash
+			 *
+			 *  \return Last response byte from the dataflash
+			 */
+			static inline uint8_t Dataflash_TransferByte(const uint8_t Byte) ATTR_ALWAYS_INLINE;
+			static inline uint8_t Dataflash_TransferByte(const uint8_t Byte)
+			{
+				return SPI_TransferByte(Byte);
+			}
+
+			/** Sends a byte to the currently selected dataflash IC, and ignores the next byte from the dataflash.
+			 *
+			 *  \param[in] Byte  Byte of data to send to the dataflash
+			 */
+			static inline void Dataflash_SendByte(const uint8_t Byte) ATTR_ALWAYS_INLINE;
+			static inline void Dataflash_SendByte(const uint8_t Byte)
+			{
+				SPI_SendByte(Byte);
+			}
+
+			/** Sends a dummy byte to the currently selected dataflash IC, and returns the next byte from the dataflash.
+			 *
+			 *  \return Last response byte from the dataflash
+			 */
+			static inline uint8_t Dataflash_ReceiveByte(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
+			static inline uint8_t Dataflash_ReceiveByte(void)
+			{
+				return SPI_ReceiveByte();
+			}
+
 			/** Determines the currently selected dataflash chip.
 			 *
 			 *  \return Mask of the currently selected Dataflash chip, either \ref DATAFLASH_NO_CHIP if no chip is selected
@@ -130,7 +170,7 @@
 			 *  are deselected.
 			 *
 			 *  \param[in] PageAddress  Address of the page to manipulate, ranging from
-			 *                          ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1).
+			 *                          0 to ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1).
 			 */
 			static inline void Dataflash_SelectChipFromPage(const uint16_t PageAddress)
 			{
@@ -168,7 +208,7 @@
 			}
 
 			/** Sends a set of page and buffer address bytes to the currently selected dataflash IC, for use with
-			 *  dataflash commands which require a complete 24-byte address.
+			 *  dataflash commands which require a complete 24-bit address.
 			 *
 			 *  \param[in] PageAddress  Page address within the selected dataflash IC
 			 *  \param[in] BufferByte   Address within the dataflash's buffer