X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/f01a05415c03b0dd61297849ece2cfcce7f8d3e8..5b5b73ce582d2afa40218e44b45a97ec6c6ce9cf:/LUFA/Drivers/Board/AVR8/XPLAIN/Dataflash.h diff --git a/LUFA/Drivers/Board/AVR8/XPLAIN/Dataflash.h b/LUFA/Drivers/Board/AVR8/XPLAIN/Dataflash.h index 7ecefba5a..9647cc1a3 100644 --- a/LUFA/Drivers/Board/AVR8/XPLAIN/Dataflash.h +++ b/LUFA/Drivers/Board/AVR8/XPLAIN/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 @@ -29,7 +29,7 @@ */ /** \file - * \brief Board specific Dataflash driver header for the Atmel XPLAIN. + * \brief Board specific Dataflash driver header for the original Atmel XPLAIN. * \copydetails Group_Dataflash_XPLAIN * * \note This file should not be included directly. It is automatically included as needed by the dataflash driver @@ -37,11 +37,32 @@ */ /** \ingroup Group_Dataflash + * \defgroup Group_Dataflash_XPLAIN_REV1 XPLAIN_REV1 + * \brief Board specific Dataflash driver header for the original Atmel XPLAIN, revision 1. + * + * See \ref Group_Dataflash_XPLAIN for more details. + */ + +/** \ingroup Group_Dataflash * \defgroup Group_Dataflash_XPLAIN XPLAIN - * \brief Board specific Dataflash driver header for the Atmel XPLAIN. + * \brief Board specific Dataflash driver header for the original Atmel XPLAIN. + * + * \note For the first revision XPLAIN board, compile with BOARD = BOARD_XPLAIN_REV1. * * Board specific Dataflash driver header for the Atmel XPLAIN. * + * Revision 1 Boards: + * + * + * + *
NameInfoSelect PinSPI Port
DATAFLASH_CHIP1AT45DB041D (512KB)PORTB.5SPI0
+ * + * Other Board Revisions: + * + * + * + *
NameInfoSelect PinSPI Port
DATAFLASH_CHIP1AT45DB642D (8MB)PORTB.5SPI0
+ * * @{ */ @@ -50,7 +71,9 @@ /* Includes: */ #include "../../../../Common/Common.h" + #include "../../../Misc/AT45DB642D.h" + #include "../../../Peripheral/SPI.h" /* Preprocessor Checks: */ #if !defined(__INCLUDE_FROM_DATAFLASH_H) @@ -76,16 +99,16 @@ /** Mask for the first dataflash chip selected. */ #define DATAFLASH_CHIP1 0 - #if (BOARD == BOARD_XPLAIN_REV1) - #define DATAFLASH_PAGE_SIZE 256 - - #define DATAFLASH_PAGES 2048 - #else + #if ((BOARD != BOARD_XPLAIN_REV1) || defined(__DOXYGEN__)) /** Internal main memory page size for the board's dataflash ICs. */ #define DATAFLASH_PAGE_SIZE 1024 /** Total number of pages inside each of the board's dataflash ICs. */ #define DATAFLASH_PAGES 8192 + #else + #define DATAFLASH_PAGE_SIZE 256 + + #define DATAFLASH_PAGES 2048 #endif /* Inline Functions: */ @@ -98,6 +121,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 @@ -134,7 +189,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) { @@ -169,7 +224,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