at45d.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. #ifndef _DEV_AT45D_H_
  2. #define _DEV_AT45D_H_
  3. /*
  4. * Copyright (C) 2008-2009 by egnite GmbH
  5. *
  6. * All rights reserved.
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. *
  12. * 1. Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. * 2. Redistributions in binary form must reproduce the above copyright
  15. * notice, this list of conditions and the following disclaimer in the
  16. * documentation and/or other materials provided with the distribution.
  17. * 3. Neither the name of the copyright holders nor the names of
  18. * contributors may be used to endorse or promote products derived
  19. * from this software without specific prior written permission.
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  24. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  25. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  26. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  27. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  28. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  29. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  30. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  31. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  32. * SUCH DAMAGE.
  33. *
  34. * For additional information see http://www.ethernut.de/
  35. */
  36. /*!
  37. * \file dev/at45d.h
  38. * \brief AT45D DataFlash defines.
  39. *
  40. * \verbatim
  41. * $Id: at45d.h 4115 2012-04-12 21:06:13Z olereinhardt $
  42. * \endverbatim
  43. */
  44. #include <sys/types.h>
  45. #include <stdint.h>
  46. /*!
  47. * \name AT45D DataFlash Commands
  48. */
  49. /*@{*/
  50. /*! \brief Continuos read (low frequency).
  51. *
  52. * Reads a continous stream in low speed mode. Automatically switches
  53. * to the the page and wraps to the first page after the last has been
  54. * read. Note, that the data buffers are not used for this operation.
  55. */
  56. #define DFCMD_CONT_READ_LF 0x03
  57. /*! \brief Continuos read (high frequency).
  58. *
  59. * Reads a continous stream in high speed mode. Automatically switches
  60. * to the the page and wraps to the first page after the last has been
  61. * read. Note, that the data buffers are not used for this operation.
  62. */
  63. #define DFCMD_CONT_READ_HF 0x0B
  64. /*! \brief Block erase.
  65. */
  66. #define DFCMD_BLOCK_ERASE 0x50
  67. /*! \brief Sector erase.
  68. */
  69. #define DFCMD_SECTOR_ERASE 0x7C
  70. /*! \brief Page erase.
  71. */
  72. #define DFCMD_PAGE_ERASE 0x81
  73. /*! \brief Main memory page program through buffer 1.
  74. */
  75. #define DFCMD_BUF1_PROG 0x82
  76. /*! \brief Buffer 1 flash with page erase.
  77. */
  78. #define DFCMD_BUF1_FLASH 0x83
  79. /*! \brief Buffer 1 write.
  80. */
  81. #define DFCMD_BUF1_WRITE 0x84
  82. /*! \brief Main memory page program through buffer 2.
  83. */
  84. #define DFCMD_BUF2_PROG 0x85
  85. /*! \brief Buffer 2 flash with page erase.
  86. */
  87. #define DFCMD_BUF2_FLASH 0x86
  88. /*! \brief Buffer 2 write.
  89. */
  90. #define DFCMD_BUF2_WRITE 0x87
  91. /*! \brief Buffer 1 flash without page erase.
  92. */
  93. #define DFCMD_BUF1_FLASH_NE 0x88
  94. /*! \brief Buffer 2 flash without page erase.
  95. */
  96. #define DFCMD_BUF2_FLASH_NE 0x89
  97. /*! \brief Chip erase.
  98. */
  99. #define DFCMD_CHIP_ERASE 0xC7
  100. /*! \brief Buffer 1 read (low frequency).
  101. */
  102. #define DFCMD_BUF1_READ_LF 0xD1
  103. /*! \brief Read main memory page.
  104. *
  105. * Automatically wraps to the first byte of the same page after
  106. * the last byte had been read. The data buffers are left unchanged.
  107. */
  108. #define DFCMD_READ_PAGE 0xD2
  109. /*! \brief Buffer 2 read (low frequency).
  110. */
  111. #define DFCMD_BUF2_READ_LF 0xD3
  112. /*! \brief Buffer 1 read.
  113. */
  114. #define DFCMD_BUF1_READ 0xD4
  115. /*! \brief Buffer 2 read.
  116. */
  117. #define DFCMD_BUF2_READ 0xD6
  118. /*! \brief Read status register.
  119. */
  120. #define DFCMD_READ_STATUS 0xD7
  121. /*! \brief Continuos read (legacy).
  122. *
  123. * Reads a continous stream. Automatically switches to the the page
  124. * and wraps to the first page after the last has been read. Note,
  125. * that the data buffers are not used for this operation.
  126. */
  127. #define DFCMD_CONT_READ 0xE8
  128. /*@}*/
  129. /*!
  130. * \name AT45D DataFlash Status Bits
  131. */
  132. /*@{*/
  133. /*! \brief Ready (not busy) flag. */
  134. #define AT45D_STATUS_RDY 0x80
  135. /*! \brief Last compare result. */
  136. #define AT45D_STATUS_COMP 0x40
  137. /*! \brief Device type code. */
  138. #define AT45D_STATUS_DENSITY 0x3C
  139. /*! \brief Sector protection flag. */
  140. #define AT45D_STATUS_PROTECT 0x02
  141. /*! \brief Set when binary page size is configured. */
  142. #define AT45D_STATUS_PAGE_SIZE 0x01
  143. /*@}*/
  144. /*!
  145. * \brief AT45D DataFlash parameter structure type.
  146. */
  147. typedef struct _AT45D_INFO AT45D_INFO;
  148. /*!
  149. * \brief AT45D DataFlash parameter structure.
  150. */
  151. struct _AT45D_INFO {
  152. /*! \brief Least significant bit of the page parameter. */
  153. uint_fast8_t at45d_pshft;
  154. /*! \brief Total number of pages. */
  155. uint32_t at45d_pages;
  156. /*! \brief Number of bytes per page. */
  157. size_t at45d_psize;
  158. /*! \brief Type determination value. */
  159. uint_fast8_t at45d_srval;
  160. };
  161. /*!
  162. * \brief Table of known AT45D DataFlash chips.
  163. */
  164. extern AT45D_INFO at45d_info[];
  165. /*!
  166. * \brief Number of known AT45D DataFlash chips.
  167. */
  168. extern uint_fast8_t at45d_known_types;
  169. #endif