aboutsummaryrefslogtreecommitdiffstats
path: root/LUFA/Drivers/Board/USBKEY/Dataflash.h
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2009-03-17 04:43:34 +0000
committerDean Camera <dean@fourwalledcubicle.com>2009-03-17 04:43:34 +0000
commitd770d98bca4af54b10316d03979bfcdb71ce623d (patch)
tree899ba4118bcc9389fb3199b6f67a975dbcf2edb9 /LUFA/Drivers/Board/USBKEY/Dataflash.h
parente611b250c170c9e830f8212ca5d49e505e3f4af1 (diff)
downloadlufa-d770d98bca4af54b10316d03979bfcdb71ce623d.tar.gz
lufa-d770d98bca4af54b10316d03979bfcdb71ce623d.tar.bz2
lufa-d770d98bca4af54b10316d03979bfcdb71ce623d.zip
Board Dataflash driver now allows for dataflash ICs which use different shifts for setting the current page/byte address (thanks to Kenneth Clubb).
Diffstat (limited to 'LUFA/Drivers/Board/USBKEY/Dataflash.h')
-rw-r--r--LUFA/Drivers/Board/USBKEY/Dataflash.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/LUFA/Drivers/Board/USBKEY/Dataflash.h b/LUFA/Drivers/Board/USBKEY/Dataflash.h
index 848ae32d8..2b3956f04 100644
--- a/LUFA/Drivers/Board/USBKEY/Dataflash.h
+++ b/LUFA/Drivers/Board/USBKEY/Dataflash.h
@@ -74,5 +74,43 @@
/** Total number of pages inside each of the board's dataflash ICs. */
#define DATAFLASH_PAGES 8192
+
+ /* Inline Functions: */
+ /** Selects a dataflash IC from the given page number, which should range from 0 to
+ * ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1). For boards containing only one
+ * dataflash IC, this will select DATAFLASH_CHIP1. If the given page number is outside
+ * the total number of pages contained in the boards dataflash ICs, all dataflash ICs
+ * are deselected.
+ *
+ * \param PageAddress Address of the page to manipulate, ranging from
+ * ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1).
+ */
+ static inline void Dataflash_SelectChipFromPage(const uint16_t PageAddress)
+ {
+ Dataflash_DeselectChip();
+
+ if (PageAddress >= (DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS))
+ return;
+
+ if (PageAddress & 0x01)
+ Dataflash_SelectChip(DATAFLASH_CHIP2);
+ else
+ Dataflash_SelectChip(DATAFLASH_CHIP1);
+ }
+
+ /** 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.
+ *
+ * \param PageAddress Page address within the selected dataflash IC
+ * \param BufferByte Address within the dataflash's buffer
+ */
+ static inline void Dataflash_SendAddressBytes(uint16_t PageAddress, const uint16_t BufferByte)
+ {
+ PageAddress >>= 1;
+
+ Dataflash_SendByte(PageAddress >> 5);
+ Dataflash_SendByte((PageAddress << 3) | (BufferByte >> 8));
+ Dataflash_SendByte(BufferByte);
+ }
#endif