gh_sflash.h 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. /*!
  2. *******************************************************************************
  3. **
  4. ** \file gh_sflash.h
  5. **
  6. ** \brief Serial Flash Interface.
  7. **
  8. ** Copyright: 2012 - 2016 (C) GoKe Microelectronics
  9. **
  10. ** \attention THIS SAMPLE CODE IS PROVIDED AS IS. GOKE MICROELECTRONICS
  11. ** ACCEPTS NO RESPONSIBILITY OR LIABILITY FOR ANY ERRORS OR
  12. ** OMMISSIONS.
  13. **
  14. ** \note Do not modify this file as it is generated automatically.
  15. **
  16. ******************************************************************************/
  17. #ifndef _GH_SFLASH_H
  18. #define _GH_SFLASH_H
  19. #ifdef __LINUX__
  20. #include "reg4linux.h"
  21. #else
  22. #define FIO_ADDRESS(block,address) (address)
  23. #define FIO_MOFFSET(block,moffset) (moffset)
  24. #endif
  25. #ifndef __LINUX__
  26. #include "gtypes.h" /* global type definitions */
  27. #include "gh_lib_cfg.h" /* configuration */
  28. #endif
  29. #define GH_SFLASH_ENABLE_DEBUG_PRINT 0
  30. #ifdef __LINUX__
  31. #define GH_SFLASH_DEBUG_PRINT_FUNCTION printk
  32. #else
  33. #define GH_SFLASH_DEBUG_PRINT_FUNCTION printf
  34. #endif
  35. #ifndef __LINUX__
  36. #if GH_SFLASH_ENABLE_DEBUG_PRINT
  37. #include <stdio.h>
  38. #endif
  39. #endif
  40. /*----------------------------------------------------------------------------*/
  41. /* registers */
  42. /*----------------------------------------------------------------------------*/
  43. #define REG_SFLASH_DATA FIO_ADDRESS(SFLASH,0x90016000) /* read/write */
  44. #define REG_SFLASH_COMMAND FIO_ADDRESS(SFLASH,0x90016004) /* read/write */
  45. #define REG_SFLASH_CE FIO_ADDRESS(SFLASH,0x90016008) /* read/write */
  46. #define REG_SFLASH_SPEED FIO_ADDRESS(SFLASH,0x9001600C) /* read/write */
  47. /*----------------------------------------------------------------------------*/
  48. /* bit group structures */
  49. /*----------------------------------------------------------------------------*/
  50. typedef union { /* SFLASH_Command */
  51. U32 all;
  52. struct {
  53. U32 code : 8;
  54. U32 sendcmd : 1;
  55. U32 adrnum : 3;
  56. U32 dummynum : 3;
  57. U32 rwn : 2;
  58. U32 cmdmode : 2;
  59. U32 adrmode : 2;
  60. U32 datamode : 2;
  61. U32 datanum : 5;
  62. U32 holdtime : 2;
  63. U32 : 2;
  64. } bitc;
  65. } GH_SFLASH_COMMAND_S;
  66. typedef union { /* SFLASH_CE */
  67. U32 all;
  68. struct {
  69. U32 ce : 1;
  70. U32 wp : 1;
  71. U32 hold : 1;
  72. U32 cemode : 1;
  73. U32 wpmode : 1;
  74. U32 holdmode : 1;
  75. U32 chselect : 1;
  76. U32 : 25;
  77. } bitc;
  78. } GH_SFLASH_CE_S;
  79. typedef union { /* SFLASH_Speed */
  80. U32 all;
  81. struct {
  82. U32 sf_sclk_sel : 3;
  83. U32 : 29;
  84. } bitc;
  85. } GH_SFLASH_SPEED_S;
  86. /*----------------------------------------------------------------------------*/
  87. /* mirror variables */
  88. /*----------------------------------------------------------------------------*/
  89. #ifdef __cplusplus
  90. extern "C" {
  91. #endif
  92. /*----------------------------------------------------------------------------*/
  93. /* register SFLASH_Data (read/write) */
  94. /*----------------------------------------------------------------------------*/
  95. /*! \brief Writes the register 'SFLASH_Data'. */
  96. void GH_SFLASH_set_Data(U32 data);
  97. /*! \brief Reads the register 'SFLASH_Data'. */
  98. U32 GH_SFLASH_get_Data(void);
  99. /*----------------------------------------------------------------------------*/
  100. /* register SFLASH_Command (read/write) */
  101. /*----------------------------------------------------------------------------*/
  102. /*! \brief Writes the register 'SFLASH_Command'. */
  103. void GH_SFLASH_set_Command(U32 data);
  104. /*! \brief Reads the register 'SFLASH_Command'. */
  105. U32 GH_SFLASH_get_Command(void);
  106. /*! \brief Writes the bit group 'CODE' of register 'SFLASH_Command'. */
  107. void GH_SFLASH_set_Command_CODE(U8 data);
  108. /*! \brief Reads the bit group 'CODE' of register 'SFLASH_Command'. */
  109. U8 GH_SFLASH_get_Command_CODE(void);
  110. /*! \brief Writes the bit group 'SENDCMD' of register 'SFLASH_Command'. */
  111. void GH_SFLASH_set_Command_SENDCMD(U8 data);
  112. /*! \brief Reads the bit group 'SENDCMD' of register 'SFLASH_Command'. */
  113. U8 GH_SFLASH_get_Command_SENDCMD(void);
  114. /*! \brief Writes the bit group 'ADRNUM' of register 'SFLASH_Command'. */
  115. void GH_SFLASH_set_Command_ADRNUM(U8 data);
  116. /*! \brief Reads the bit group 'ADRNUM' of register 'SFLASH_Command'. */
  117. U8 GH_SFLASH_get_Command_ADRNUM(void);
  118. /*! \brief Writes the bit group 'DUMMYNUM' of register 'SFLASH_Command'. */
  119. void GH_SFLASH_set_Command_DUMMYNUM(U8 data);
  120. /*! \brief Reads the bit group 'DUMMYNUM' of register 'SFLASH_Command'. */
  121. U8 GH_SFLASH_get_Command_DUMMYNUM(void);
  122. /*! \brief Writes the bit group 'RWN' of register 'SFLASH_Command'. */
  123. void GH_SFLASH_set_Command_RWN(U8 data);
  124. /*! \brief Reads the bit group 'RWN' of register 'SFLASH_Command'. */
  125. U8 GH_SFLASH_get_Command_RWN(void);
  126. /*! \brief Writes the bit group 'CMDMODE' of register 'SFLASH_Command'. */
  127. void GH_SFLASH_set_Command_CMDMODE(U8 data);
  128. /*! \brief Reads the bit group 'CMDMODE' of register 'SFLASH_Command'. */
  129. U8 GH_SFLASH_get_Command_CMDMODE(void);
  130. /*! \brief Writes the bit group 'ADRMODE' of register 'SFLASH_Command'. */
  131. void GH_SFLASH_set_Command_ADRMODE(U8 data);
  132. /*! \brief Reads the bit group 'ADRMODE' of register 'SFLASH_Command'. */
  133. U8 GH_SFLASH_get_Command_ADRMODE(void);
  134. /*! \brief Writes the bit group 'DATAMODE' of register 'SFLASH_Command'. */
  135. void GH_SFLASH_set_Command_DATAMODE(U8 data);
  136. /*! \brief Reads the bit group 'DATAMODE' of register 'SFLASH_Command'. */
  137. U8 GH_SFLASH_get_Command_DATAMODE(void);
  138. /*! \brief Writes the bit group 'DATANUM' of register 'SFLASH_Command'. */
  139. void GH_SFLASH_set_Command_DATANUM(U8 data);
  140. /*! \brief Reads the bit group 'DATANUM' of register 'SFLASH_Command'. */
  141. U8 GH_SFLASH_get_Command_DATANUM(void);
  142. /*! \brief Writes the bit group 'HOLDTIME' of register 'SFLASH_Command'. */
  143. void GH_SFLASH_set_Command_HOLDTIME(U8 data);
  144. /*! \brief Reads the bit group 'HOLDTIME' of register 'SFLASH_Command'. */
  145. U8 GH_SFLASH_get_Command_HOLDTIME(void);
  146. /*----------------------------------------------------------------------------*/
  147. /* register SFLASH_CE (read/write) */
  148. /*----------------------------------------------------------------------------*/
  149. /*! \brief Writes the register 'SFLASH_CE'. */
  150. void GH_SFLASH_set_CE(U32 data);
  151. /*! \brief Reads the register 'SFLASH_CE'. */
  152. U32 GH_SFLASH_get_CE(void);
  153. /*! \brief Writes the bit group 'CE' of register 'SFLASH_CE'. */
  154. void GH_SFLASH_set_CE_CE(U8 data);
  155. /*! \brief Reads the bit group 'CE' of register 'SFLASH_CE'. */
  156. U8 GH_SFLASH_get_CE_CE(void);
  157. /*! \brief Writes the bit group 'WP' of register 'SFLASH_CE'. */
  158. void GH_SFLASH_set_CE_WP(U8 data);
  159. /*! \brief Reads the bit group 'WP' of register 'SFLASH_CE'. */
  160. U8 GH_SFLASH_get_CE_WP(void);
  161. /*! \brief Writes the bit group 'HOLD' of register 'SFLASH_CE'. */
  162. void GH_SFLASH_set_CE_HOLD(U8 data);
  163. /*! \brief Reads the bit group 'HOLD' of register 'SFLASH_CE'. */
  164. U8 GH_SFLASH_get_CE_HOLD(void);
  165. /*! \brief Writes the bit group 'CEMODE' of register 'SFLASH_CE'. */
  166. void GH_SFLASH_set_CE_CEMODE(U8 data);
  167. /*! \brief Reads the bit group 'CEMODE' of register 'SFLASH_CE'. */
  168. U8 GH_SFLASH_get_CE_CEMODE(void);
  169. /*! \brief Writes the bit group 'WPMODE' of register 'SFLASH_CE'. */
  170. void GH_SFLASH_set_CE_WPMODE(U8 data);
  171. /*! \brief Reads the bit group 'WPMODE' of register 'SFLASH_CE'. */
  172. U8 GH_SFLASH_get_CE_WPMODE(void);
  173. /*! \brief Writes the bit group 'HOLDMODE' of register 'SFLASH_CE'. */
  174. void GH_SFLASH_set_CE_HOLDMODE(U8 data);
  175. /*! \brief Reads the bit group 'HOLDMODE' of register 'SFLASH_CE'. */
  176. U8 GH_SFLASH_get_CE_HOLDMODE(void);
  177. /*! \brief Writes the bit group 'CHSELECT' of register 'SFLASH_CE'. */
  178. void GH_SFLASH_set_CE_CHSELECT(U8 data);
  179. /*! \brief Reads the bit group 'CHSELECT' of register 'SFLASH_CE'. */
  180. U8 GH_SFLASH_get_CE_CHSELECT(void);
  181. /*----------------------------------------------------------------------------*/
  182. /* register SFLASH_Speed (read/write) */
  183. /*----------------------------------------------------------------------------*/
  184. /*! \brief Writes the register 'SFLASH_Speed'. */
  185. void GH_SFLASH_set_Speed(U32 data);
  186. /*! \brief Reads the register 'SFLASH_Speed'. */
  187. U32 GH_SFLASH_get_Speed(void);
  188. /*! \brief Writes the bit group 'SF_SCLK_SEL' of register 'SFLASH_Speed'. */
  189. void GH_SFLASH_set_Speed_SF_SCLK_SEL(U8 data);
  190. /*! \brief Reads the bit group 'SF_SCLK_SEL' of register 'SFLASH_Speed'. */
  191. U8 GH_SFLASH_get_Speed_SF_SCLK_SEL(void);
  192. /*----------------------------------------------------------------------------*/
  193. /* init function */
  194. /*----------------------------------------------------------------------------*/
  195. /*! \brief Initialises the registers and mirror variables. */
  196. void GH_SFLASH_init(void);
  197. #ifdef SRC_INLINE
  198. #define SRC_INC 1
  199. #include "gh_sflash.c"
  200. #undef SRC_INC
  201. #endif
  202. #ifdef __cplusplus
  203. }
  204. #endif
  205. #endif /* _GH_SFLASH_H */
  206. /*----------------------------------------------------------------------------*/
  207. /* end of file */
  208. /*----------------------------------------------------------------------------*/