Dataflash.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. /*
  2. LUFA Library
  3. Copyright (C) Dean Camera, 2018.
  4. dean [at] fourwalledcubicle [dot] com
  5. www.lufa-lib.org
  6. */
  7. /*
  8. Copyright 2018 Dean Camera (dean [at] fourwalledcubicle [dot] com)
  9. Permission to use, copy, modify, distribute, and sell this
  10. software and its documentation for any purpose is hereby granted
  11. without fee, provided that the above copyright notice appear in
  12. all copies and that both that the copyright notice and this
  13. permission notice and warranty disclaimer appear in supporting
  14. documentation, and that the name of the author not be used in
  15. advertising or publicity pertaining to distribution of the
  16. software without specific, written prior permission.
  17. The author disclaims all warranties with regard to this
  18. software, including all implied warranties of merchantability
  19. and fitness. In no event shall the author be liable for any
  20. special, indirect or consequential damages or any damages
  21. whatsoever resulting from loss of use, data or profits, whether
  22. in an action of contract, negligence or other tortious action,
  23. arising out of or in connection with the use or performance of
  24. this software.
  25. */
  26. /** \file
  27. * \brief LUFA Custom Board Dataflash Hardware Driver (Template)
  28. *
  29. * This is a stub driver header file, for implementing custom board
  30. * layout hardware with compatible LUFA board specific drivers. If
  31. * the library is configured to use the BOARD_USER board mode, this
  32. * driver file should be completed and copied into the "/Board/" folder
  33. * inside the application's folder.
  34. *
  35. * This stub is for the board-specific component of the LUFA Dataflash
  36. * driver.
  37. */
  38. #ifndef __DATAFLASH_USER_H__
  39. #define __DATAFLASH_USER_H__
  40. /* Includes: */
  41. // TODO: Add any required includes here
  42. /* Preprocessor Checks: */
  43. #if !defined(__INCLUDE_FROM_DATAFLASH_H)
  44. #error Do not include this file directly. Include LUFA/Drivers/Board/Dataflash.h instead.
  45. #endif
  46. #define BOARD_DUMMY_DATAFLASH_IMPLEMENTATION
  47. /* Private Interface - For use in library only: */
  48. #if !defined(__DOXYGEN__)
  49. /* Macros: */
  50. #define DATAFLASH_CHIPCS_MASK 0
  51. #define DATAFLASH_CHIPCS_DDR 0
  52. #define DATAFLASH_CHIPCS_PORT 0
  53. #endif
  54. /* Public Interface - May be used in end-application: */
  55. /* Macros: */
  56. /** Constant indicating the total number of dataflash ICs mounted on the selected board. */
  57. #define DATAFLASH_TOTALCHIPS 1
  58. /** Mask for no dataflash chip selected. */
  59. #define DATAFLASH_NO_CHIP 0
  60. /** Mask for the first dataflash chip selected. */
  61. #define DATAFLASH_CHIP1 0
  62. /** Mask for the second dataflash chip selected. */
  63. #define DATAFLASH_CHIP2 0
  64. /** Internal main memory page size for the board's dataflash ICs. */
  65. #define DATAFLASH_PAGE_SIZE 0
  66. /** Total number of pages inside each of the board's dataflash ICs. */
  67. #define DATAFLASH_PAGES 0
  68. /* Inline Functions: */
  69. /** Initializes the dataflash driver so that commands and data may be sent to an attached dataflash IC.
  70. * The microcontroller's SPI driver MUST be initialized before any of the dataflash commands are used.
  71. */
  72. static inline void Dataflash_Init(void)
  73. {
  74. }
  75. /** Sends a byte to the currently selected dataflash IC, and returns a byte from the dataflash.
  76. *
  77. * \param[in] Byte Byte of data to send to the dataflash
  78. *
  79. * \return Last response byte from the dataflash
  80. */
  81. static inline uint8_t Dataflash_TransferByte(const uint8_t Byte) ATTR_ALWAYS_INLINE;
  82. static inline uint8_t Dataflash_TransferByte(const uint8_t Byte)
  83. {
  84. return 0;
  85. }
  86. /** Sends a byte to the currently selected dataflash IC, and ignores the next byte from the dataflash.
  87. *
  88. * \param[in] Byte Byte of data to send to the dataflash
  89. */
  90. static inline void Dataflash_SendByte(const uint8_t Byte) ATTR_ALWAYS_INLINE;
  91. static inline void Dataflash_SendByte(const uint8_t Byte)
  92. {
  93. }
  94. /** Sends a dummy byte to the currently selected dataflash IC, and returns the next byte from the dataflash.
  95. *
  96. * \return Last response byte from the dataflash
  97. */
  98. static inline uint8_t Dataflash_ReceiveByte(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
  99. static inline uint8_t Dataflash_ReceiveByte(void)
  100. {
  101. return 0;
  102. }
  103. /** Determines the currently selected dataflash chip.
  104. *
  105. * \return Mask of the currently selected Dataflash chip, either \ref DATAFLASH_NO_CHIP if no chip is selected
  106. * or a DATAFLASH_CHIPn mask (where n is the chip number).
  107. */
  108. static inline uint8_t Dataflash_GetSelectedChip(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
  109. static inline uint8_t Dataflash_GetSelectedChip(void)
  110. {
  111. return 0;
  112. }
  113. /** Selects the given dataflash chip.
  114. *
  115. * \param[in] ChipMask Mask of the Dataflash IC to select, in the form of a \c DATAFLASH_CHIPn mask (where n is
  116. * the chip number).
  117. */
  118. static inline void Dataflash_SelectChip(const uint8_t ChipMask) ATTR_ALWAYS_INLINE;
  119. static inline void Dataflash_SelectChip(const uint8_t ChipMask)
  120. {
  121. }
  122. /** Deselects the current dataflash chip, so that no dataflash is selected. */
  123. static inline void Dataflash_DeselectChip(void) ATTR_ALWAYS_INLINE;
  124. static inline void Dataflash_DeselectChip(void)
  125. {
  126. }
  127. /** Selects a dataflash IC from the given page number, which should range from 0 to
  128. * ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1). For boards containing only one
  129. * dataflash IC, this will select DATAFLASH_CHIP1. If the given page number is outside
  130. * the total number of pages contained in the boards dataflash ICs, all dataflash ICs
  131. * are deselected.
  132. *
  133. * \param[in] PageAddress Address of the page to manipulate, ranging from
  134. * 0 to ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1).
  135. */
  136. static inline void Dataflash_SelectChipFromPage(const uint16_t PageAddress)
  137. {
  138. }
  139. /** Toggles the select line of the currently selected dataflash IC, so that it is ready to receive
  140. * a new command.
  141. */
  142. static inline void Dataflash_ToggleSelectedChipCS(void)
  143. {
  144. }
  145. /** Spin-loops while the currently selected dataflash is busy executing a command, such as a main
  146. * memory page program or main memory to buffer transfer.
  147. */
  148. static inline void Dataflash_WaitWhileBusy(void)
  149. {
  150. }
  151. /** Sends a set of page and buffer address bytes to the currently selected dataflash IC, for use with
  152. * dataflash commands which require a complete 24-bit address.
  153. *
  154. * \param[in] PageAddress Page address within the selected dataflash IC
  155. * \param[in] BufferByte Address within the dataflash's buffer
  156. */
  157. static inline void Dataflash_SendAddressBytes(uint16_t PageAddress, const uint16_t BufferByte)
  158. {
  159. }
  160. #endif