hal_fsmc.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. ////////////////////////////////////////////////////////////////////////////////
  2. /// @file hal_fsmc.h
  3. /// @author AE TEAM
  4. /// @brief THIS FILE CONTAINS ALL THE FUNCTIONS PROTOTYPES FOR THE SDIO
  5. /// FIRMWARE LIBRARY.
  6. ////////////////////////////////////////////////////////////////////////////////
  7. /// @attention
  8. ///
  9. /// THE EXISTING FIRMWARE IS ONLY FOR REFERENCE, WHICH IS DESIGNED TO PROVIDE
  10. /// CUSTOMERS WITH CODING INFORMATION ABOUT THEIR PRODUCTS SO THEY CAN SAVE
  11. /// TIME. THEREFORE, MINDMOTION SHALL NOT BE LIABLE FOR ANY DIRECT, INDIRECT OR
  12. /// CONSEQUENTIAL DAMAGES ABOUT ANY CLAIMS ARISING OUT OF THE CONTENT OF SUCH
  13. /// HARDWARE AND/OR THE USE OF THE CODING INFORMATION CONTAINED HEREIN IN
  14. /// CONNECTION WITH PRODUCTS MADE BY CUSTOMERS.
  15. ///
  16. /// <H2><CENTER>&COPY; COPYRIGHT MINDMOTION </CENTER></H2>
  17. ////////////////////////////////////////////////////////////////////////////////
  18. // Define to prevent recursive inclusion
  19. #ifndef __HAL_FSMC_H
  20. #define __HAL_FSMC_H
  21. // Files includes
  22. #include "types.h"
  23. #include "reg_common.h"
  24. #include "reg_fsmc.h"
  25. ////////////////////////////////////////////////////////////////////////////////
  26. /// @addtogroup MM32_Hardware_Abstract_Layer
  27. /// @{
  28. ////////////////////////////////////////////////////////////////////////////////
  29. /// @defgroup FSMC_HAL
  30. /// @brief FSMC HAL modules
  31. /// @{
  32. ////////////////////////////////////////////////////////////////////////////////
  33. /// @defgroup FSMC_Exported_Types
  34. /// @{
  35. ////////////////////////////////////////////////////////////////////////////////
  36. /// @brief FSMC_interrupts_define
  37. ////////////////////////////////////////////////////////////////////////////////
  38. // Timing parameter configuration register set selection register set0 register set1 register set2
  39. #define FSMC_TimingRegSelect_0 ((u32)0x00000000)
  40. #define FSMC_TimingRegSelect_1 ((u32)0x00000100)
  41. #define FSMC_TimingRegSelect_2 ((u32)0x00000200)
  42. // Capacity of external device
  43. #define FSMC_MemSize_None ((u32)0x00000000)
  44. #define FSMC_MemSize_64KB ((u32)0x00000001)
  45. #define FSMC_MemSize_128KB ((u32)0x00000002)
  46. #define FSMC_MemSize_256KB ((u32)0x00000002)
  47. #define FSMC_MemSize_512KB ((u32)0x00000004)
  48. #define FSMC_MemSize_1MB ((u32)0x00000005)
  49. #define FSMC_MemSize_2MB ((u32)0x00000006)
  50. #define FSMC_MemSize_4MB ((u32)0x00000007)
  51. #define FSMC_MemSize_8MB ((u32)0x00000008)
  52. #define FSMC_MemSize_16MB ((u32)0x00000009)
  53. #define FSMC_MemSize_32MB ((u32)0x0000000A)
  54. #define FSMC_MemSize_64MB ((u32)0x0000000B)
  55. #define FSMC_MemSize_128MB ((u32)0x0000000C)
  56. #define FSMC_MemSize_256MB ((u32)0x0000000D)
  57. #define FSMC_MemSize_512MB ((u32)0x0000000E)
  58. #define FSMC_MemSize_1GB ((u32)0x0000000F)
  59. #define FSMC_MemSize_2GB ((u32)0x00000010)
  60. #define FSMC_MemSize_4GB ((u32)0x00000011)
  61. // Memory data bus bit width setting
  62. typedef enum {
  63. FSMC_DataWidth_16bits = (0x0000), //16bits
  64. FSMC_DataWidth_32bits = (0x0001), //32bits
  65. FSMC_DataWidth_64bits = (0x0002), //64bits
  66. FSMC_DataWidth_128bits = (0x0003), //128bits
  67. FSMC_DataWidth_8bits = (0x0004), //8bits
  68. } FSMC_NORSRAM_DataWidth_TypeDef;
  69. typedef enum {
  70. FSMC_NORSRAM_BANK0 = 0,
  71. FSMC_NORSRAM_BANK1 = 1,
  72. FSMC_NORSRAM_BANK2 = 2,
  73. } FSMC_NORSRAM_BANK_TypeDef;
  74. typedef struct {
  75. u32 FSMC_SMReadPipe; //sm_read_pipe[1:0] The cycle of latching read data, that is, the cycle when ready_resp is pulled high
  76. u32 FSMC_ReadyMode; //Select whether the hready_resp signal comes from the FSMC IP internal or external DEVICE, only for writing and reading external DEVICE operations.
  77. //0: Internal FSMC 1: External DEVICE (ie from FSMC_NWAIT)
  78. u32 FSMC_WritePeriod; //Write cycle
  79. u32 FSMC_WriteHoldTime; //Address/data hold time during write operation
  80. u32 FSMC_AddrSetTime; //Address establishment time
  81. u32 FSMC_ReadPeriod; //Read cycle
  82. FSMC_NORSRAM_DataWidth_TypeDef FSMC_DataWidth;
  83. } FSMC_NORSRAM_Bank_InitTypeDef;
  84. typedef struct {
  85. u32 FSMC_Mode;
  86. u32 FSMC_TimingRegSelect;
  87. u32 FSMC_MemSize;
  88. u32 FSMC_MemType;
  89. u32 FSMC_AddrDataMode;
  90. } FSMC_InitTypeDef;
  91. #define FSMC_MemType_SDRAM ((u32)0x0<<5)
  92. #define FSMC_MemType_NorSRAM ((u32)0x1<<5)
  93. #define FSMC_MemType_FLASH ((u32)0x2<<5)
  94. #define FSMC_MemType_RESERVED ((u32)0x3<<5)
  95. //SYSCFG_CFGR1
  96. #define FSMC_Mode_6800 ((u32)0x40000000)
  97. #define FSMC_Mode_8080 ((u32)0x20000000)
  98. #define FSMC_Mode_NorFlash ((u32)0x00000000)
  99. #define FSMC_AddrDataMUX ((u32)0x00000000)
  100. #define FSMC_AddrDataDeMUX ((u32)0x10000000)
  101. void FSMC_NORSRAMStructInit(FSMC_InitTypeDef* init_struct);
  102. void FSMC_NORSRAM_BankStructInit(FSMC_NORSRAM_Bank_InitTypeDef* init_struct);
  103. void FSMC_NORSRAMInit(FSMC_InitTypeDef* init_struct);
  104. void FSMC_NORSRAM_Bank_Init(FSMC_NORSRAM_Bank_InitTypeDef* FSMC_Bank_InitStruct, FSMC_NORSRAM_BANK_TypeDef bank);
  105. /// @}
  106. /// @}
  107. /// @}
  108. ////////////////////////////////////////////////////////////////////////////////
  109. #endif // __HAL_FSMC_H
  110. ////////////////////////////////////////////////////////////////////////////////