Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 

244 righe
9.5 KiB

  1. /*
  2. * Copyright (c) 2015, Freescale Semiconductor, Inc.
  3. * Copyright 2016-2019 NXP
  4. * All rights reserved.
  5. *
  6. * SPDX-License-Identifier: BSD-3-Clause
  7. */
  8. #ifndef _FSL_FLEXBUS_H_
  9. #define _FSL_FLEXBUS_H_
  10. #include "fsl_common.h"
  11. /*!
  12. * @addtogroup flexbus
  13. * @{
  14. */
  15. /*******************************************************************************
  16. * Definitions
  17. ******************************************************************************/
  18. /*! @name Driver version */
  19. /*@{*/
  20. #define FSL_FLEXBUS_DRIVER_VERSION (MAKE_VERSION(2, 1, 1)) /*!< Version 2.1.1. */
  21. /*@}*/
  22. /*!
  23. * @brief Defines port size for FlexBus peripheral.
  24. */
  25. typedef enum _flexbus_port_size
  26. {
  27. kFLEXBUS_4Bytes = 0x00U, /*!< 32-bit port size */
  28. kFLEXBUS_1Byte = 0x01U, /*!< 8-bit port size */
  29. kFLEXBUS_2Bytes = 0x02U /*!< 16-bit port size */
  30. } flexbus_port_size_t;
  31. /*!
  32. * @brief Defines number of cycles to hold address and attributes for FlexBus peripheral.
  33. */
  34. typedef enum _flexbus_write_address_hold
  35. {
  36. kFLEXBUS_Hold1Cycle = 0x00U, /*!< Hold address and attributes one cycles after FB_CSn negates on writes */
  37. kFLEXBUS_Hold2Cycles = 0x01U, /*!< Hold address and attributes two cycles after FB_CSn negates on writes */
  38. kFLEXBUS_Hold3Cycles = 0x02U, /*!< Hold address and attributes three cycles after FB_CSn negates on writes */
  39. kFLEXBUS_Hold4Cycles = 0x03U /*!< Hold address and attributes four cycles after FB_CSn negates on writes */
  40. } flexbus_write_address_hold_t;
  41. /*!
  42. * @brief Defines number of cycles to hold address and attributes for FlexBus peripheral.
  43. */
  44. typedef enum _flexbus_read_address_hold
  45. {
  46. kFLEXBUS_Hold1Or0Cycles = 0x00U, /*!< Hold address and attributes 1 or 0 cycles on reads */
  47. kFLEXBUS_Hold2Or1Cycles = 0x01U, /*!< Hold address and attributes 2 or 1 cycles on reads */
  48. kFLEXBUS_Hold3Or2Cycle = 0x02U, /*!< Hold address and attributes 3 or 2 cycles on reads */
  49. kFLEXBUS_Hold4Or3Cycle = 0x03U /*!< Hold address and attributes 4 or 3 cycles on reads */
  50. } flexbus_read_address_hold_t;
  51. /*!
  52. * @brief Address setup for FlexBus peripheral.
  53. */
  54. typedef enum _flexbus_address_setup
  55. {
  56. kFLEXBUS_FirstRisingEdge = 0x00U, /*!< Assert FB_CSn on first rising clock edge after address is asserted */
  57. kFLEXBUS_SecondRisingEdge = 0x01U, /*!< Assert FB_CSn on second rising clock edge after address is asserted */
  58. kFLEXBUS_ThirdRisingEdge = 0x02U, /*!< Assert FB_CSn on third rising clock edge after address is asserted */
  59. kFLEXBUS_FourthRisingEdge = 0x03U, /*!< Assert FB_CSn on fourth rising clock edge after address is asserted */
  60. } flexbus_address_setup_t;
  61. /*!
  62. * @brief Defines byte-lane shift for FlexBus peripheral.
  63. */
  64. typedef enum _flexbus_bytelane_shift
  65. {
  66. kFLEXBUS_NotShifted = 0x00U, /*!< Not shifted. Data is left-justified on FB_AD */
  67. kFLEXBUS_Shifted = 0x01U, /*!< Shifted. Data is right justified on FB_AD */
  68. } flexbus_bytelane_shift_t;
  69. /*!
  70. * @brief Defines multiplex group1 valid signals.
  71. */
  72. typedef enum _flexbus_multiplex_group1_signal
  73. {
  74. kFLEXBUS_MultiplexGroup1_FB_ALE = 0x00U, /*!< FB_ALE */
  75. kFLEXBUS_MultiplexGroup1_FB_CS1 = 0x01U, /*!< FB_CS1 */
  76. kFLEXBUS_MultiplexGroup1_FB_TS = 0x02U, /*!< FB_TS */
  77. } flexbus_multiplex_group1_t;
  78. /*!
  79. * @brief Defines multiplex group2 valid signals.
  80. */
  81. typedef enum _flexbus_multiplex_group2_signal
  82. {
  83. kFLEXBUS_MultiplexGroup2_FB_CS4 = 0x00U, /*!< FB_CS4 */
  84. kFLEXBUS_MultiplexGroup2_FB_TSIZ0 = 0x01U, /*!< FB_TSIZ0 */
  85. kFLEXBUS_MultiplexGroup2_FB_BE_31_24 = 0x02U, /*!< FB_BE_31_24 */
  86. } flexbus_multiplex_group2_t;
  87. /*!
  88. * @brief Defines multiplex group3 valid signals.
  89. */
  90. typedef enum _flexbus_multiplex_group3_signal
  91. {
  92. kFLEXBUS_MultiplexGroup3_FB_CS5 = 0x00U, /*!< FB_CS5 */
  93. kFLEXBUS_MultiplexGroup3_FB_TSIZ1 = 0x01U, /*!< FB_TSIZ1 */
  94. kFLEXBUS_MultiplexGroup3_FB_BE_23_16 = 0x02U, /*!< FB_BE_23_16 */
  95. } flexbus_multiplex_group3_t;
  96. /*!
  97. * @brief Defines multiplex group4 valid signals.
  98. */
  99. typedef enum _flexbus_multiplex_group4_signal
  100. {
  101. kFLEXBUS_MultiplexGroup4_FB_TBST = 0x00U, /*!< FB_TBST */
  102. kFLEXBUS_MultiplexGroup4_FB_CS2 = 0x01U, /*!< FB_CS2 */
  103. kFLEXBUS_MultiplexGroup4_FB_BE_15_8 = 0x02U, /*!< FB_BE_15_8 */
  104. } flexbus_multiplex_group4_t;
  105. /*!
  106. * @brief Defines multiplex group5 valid signals.
  107. */
  108. typedef enum _flexbus_multiplex_group5_signal
  109. {
  110. kFLEXBUS_MultiplexGroup5_FB_TA = 0x00U, /*!< FB_TA */
  111. kFLEXBUS_MultiplexGroup5_FB_CS3 = 0x01U, /*!< FB_CS3 */
  112. kFLEXBUS_MultiplexGroup5_FB_BE_7_0 = 0x02U, /*!< FB_BE_7_0 */
  113. } flexbus_multiplex_group5_t;
  114. /*!
  115. * @brief Configuration structure that the user needs to set.
  116. */
  117. typedef struct _flexbus_config
  118. {
  119. uint8_t chip; /*!< Chip FlexBus for validation */
  120. uint8_t waitStates; /*!< Value of wait states */
  121. uint8_t secondaryWaitStates; /*!< Value of secondary wait states */
  122. uint32_t chipBaseAddress; /*!< Chip base address for using FlexBus */
  123. uint32_t chipBaseAddressMask; /*!< Chip base address mask */
  124. bool writeProtect; /*!< Write protected */
  125. bool burstWrite; /*!< Burst-Write enable */
  126. bool burstRead; /*!< Burst-Read enable */
  127. bool byteEnableMode; /*!< Byte-enable mode support */
  128. bool autoAcknowledge; /*!< Auto acknowledge setting */
  129. bool extendTransferAddress; /*!< Extend transfer start/extend address latch enable */
  130. bool secondaryWaitStatesEnable; /*!< Enable secondary wait states */
  131. flexbus_port_size_t portSize; /*!< Port size of transfer */
  132. flexbus_bytelane_shift_t byteLaneShift; /*!< Byte-lane shift enable */
  133. flexbus_write_address_hold_t writeAddressHold; /*!< Write address hold or deselect option */
  134. flexbus_read_address_hold_t readAddressHold; /*!< Read address hold or deselect option */
  135. flexbus_address_setup_t addressSetup; /*!< Address setup setting */
  136. flexbus_multiplex_group1_t group1MultiplexControl; /*!< FlexBus Signal Group 1 Multiplex control */
  137. flexbus_multiplex_group2_t group2MultiplexControl; /*!< FlexBus Signal Group 2 Multiplex control */
  138. flexbus_multiplex_group3_t group3MultiplexControl; /*!< FlexBus Signal Group 3 Multiplex control */
  139. flexbus_multiplex_group4_t group4MultiplexControl; /*!< FlexBus Signal Group 4 Multiplex control */
  140. flexbus_multiplex_group5_t group5MultiplexControl; /*!< FlexBus Signal Group 5 Multiplex control */
  141. } flexbus_config_t;
  142. /*******************************************************************************
  143. * API
  144. ******************************************************************************/
  145. #if defined(__cplusplus)
  146. extern "C" {
  147. #endif /* __cplusplus */
  148. /*!
  149. * @name FlexBus functional operation
  150. * @{
  151. */
  152. /*!
  153. * @brief Initializes and configures the FlexBus module.
  154. *
  155. * This function enables the clock gate for FlexBus module.
  156. * Only chip 0 is validated and set to known values. Other chips are disabled.
  157. * Note that in this function, certain parameters, depending on external memories, must
  158. * be set before using the FLEXBUS_Init() function.
  159. * This example shows how to set up the uart_state_t and the
  160. * flexbus_config_t parameters and how to call the FLEXBUS_Init function by passing
  161. * in these parameters.
  162. @code
  163. flexbus_config_t flexbusConfig;
  164. FLEXBUS_GetDefaultConfig(&flexbusConfig);
  165. flexbusConfig.waitStates = 2U;
  166. flexbusConfig.chipBaseAddress = 0x60000000U;
  167. flexbusConfig.chipBaseAddressMask = 7U;
  168. FLEXBUS_Init(FB, &flexbusConfig);
  169. @endcode
  170. *
  171. * @param base FlexBus peripheral address.
  172. * @param config Pointer to the configuration structure
  173. */
  174. void FLEXBUS_Init(FB_Type *base, const flexbus_config_t *config);
  175. /*!
  176. * @brief De-initializes a FlexBus instance.
  177. *
  178. * This function disables the clock gate of the FlexBus module clock.
  179. *
  180. * @param base FlexBus peripheral address.
  181. */
  182. void FLEXBUS_Deinit(FB_Type *base);
  183. /*!
  184. * @brief Initializes the FlexBus configuration structure.
  185. *
  186. * This function initializes the FlexBus configuration structure to default value. The default
  187. * values are.
  188. @code
  189. fbConfig->chip = 0;
  190. fbConfig->writeProtect = 0;
  191. fbConfig->burstWrite = 0;
  192. fbConfig->burstRead = 0;
  193. fbConfig->byteEnableMode = 0;
  194. fbConfig->autoAcknowledge = true;
  195. fbConfig->extendTransferAddress = 0;
  196. fbConfig->secondaryWaitStates = 0;
  197. fbConfig->byteLaneShift = kFLEXBUS_NotShifted;
  198. fbConfig->writeAddressHold = kFLEXBUS_Hold1Cycle;
  199. fbConfig->readAddressHold = kFLEXBUS_Hold1Or0Cycles;
  200. fbConfig->addressSetup = kFLEXBUS_FirstRisingEdge;
  201. fbConfig->portSize = kFLEXBUS_1Byte;
  202. fbConfig->group1MultiplexControl = kFLEXBUS_MultiplexGroup1_FB_ALE;
  203. fbConfig->group2MultiplexControl = kFLEXBUS_MultiplexGroup2_FB_CS4 ;
  204. fbConfig->group3MultiplexControl = kFLEXBUS_MultiplexGroup3_FB_CS5;
  205. fbConfig->group4MultiplexControl = kFLEXBUS_MultiplexGroup4_FB_TBST;
  206. fbConfig->group5MultiplexControl = kFLEXBUS_MultiplexGroup5_FB_TA;
  207. @endcode
  208. * @param config Pointer to the initialization structure.
  209. * @see FLEXBUS_Init
  210. */
  211. void FLEXBUS_GetDefaultConfig(flexbus_config_t *config);
  212. /*! @}*/
  213. #if defined(__cplusplus)
  214. }
  215. #endif /* __cplusplus */
  216. /*! @}*/
  217. #endif /* _FSL_FLEXBUS_H_ */