fsl_xbara.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. /*
  2. * The Clear BSD License
  3. * Copyright (c) 2015, Freescale Semiconductor, Inc.
  4. * Copyright 2016-2017 NXP
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without modification,
  8. * are permitted (subject to the limitations in the disclaimer below) provided
  9. * that the following conditions are met:
  10. *
  11. * o Redistributions of source code must retain the above copyright notice, this list
  12. * of conditions and the following disclaimer.
  13. *
  14. * o Redistributions in binary form must reproduce the above copyright notice, this
  15. * list of conditions and the following disclaimer in the documentation and/or
  16. * other materials provided with the distribution.
  17. *
  18. * o Neither the name of the copyright holder nor the names of its
  19. * contributors may be used to endorse or promote products derived from this
  20. * software without specific prior written permission.
  21. *
  22. * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE.
  23. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  24. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  25. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  26. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
  27. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  28. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  29. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  30. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  31. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  32. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  33. */
  34. #ifndef _FSL_XBARA_H_
  35. #define _FSL_XBARA_H_
  36. #include "fsl_common.h"
  37. /*!
  38. * @addtogroup xbara
  39. * @{
  40. */
  41. /*******************************************************************************
  42. * Definitions
  43. ******************************************************************************/
  44. #define FSL_XBARA_DRIVER_VERSION (MAKE_VERSION(2, 0, 3)) /*!< Version 2.0.3. */
  45. /* Macros for entire XBARA_SELx register. */
  46. #define XBARA_SELx(base, output) (*(volatile uint16_t *)((uintptr_t) & (base->SEL0) + ((output) / 2U) * 2U))
  47. /* Set the XBARA_SELx_SELx field to a new value. */
  48. #define XBARA_WR_SELx_SELx(base, input, output) \
  49. (XBARA_SELx((base), (output)) = \
  50. ((XBARA_SELx((base), (output)) & ~(0xFFU << (XBARA_SEL0_SEL1_SHIFT * ((output) % 2U)))) | \
  51. ((input) << (XBARA_SEL0_SEL1_SHIFT * ((output) % 2U)))))
  52. /*!
  53. * @brief XBARA active edge for detection
  54. */
  55. typedef enum _xbara_active_edge
  56. {
  57. kXBARA_EdgeNone = 0U, /*!< Edge detection status bit never asserts. */
  58. kXBARA_EdgeRising = 1U, /*!< Edge detection status bit asserts on rising edges. */
  59. kXBARA_EdgeFalling = 2U, /*!< Edge detection status bit asserts on falling edges. */
  60. kXBARA_EdgeRisingAndFalling = 3U /*!< Edge detection status bit asserts on rising and falling edges. */
  61. } xbara_active_edge_t;
  62. /*!
  63. * @brief Defines the XBARA DMA and interrupt configurations.
  64. */
  65. typedef enum _xbar_request
  66. {
  67. kXBARA_RequestDisable = 0U, /*!< Interrupt and DMA are disabled. */
  68. kXBARA_RequestDMAEnable = 1U, /*!< DMA enabled, interrupt disabled. */
  69. kXBARA_RequestInterruptEnalbe = 2U /*!< Interrupt enabled, DMA disabled. */
  70. } xbara_request_t;
  71. /*!
  72. * @brief XBARA status flags.
  73. *
  74. * This provides constants for the XBARA status flags for use in the XBARA functions.
  75. */
  76. typedef enum _xbara_status_flag_t
  77. {
  78. kXBARA_EdgeDetectionOut0 =
  79. (XBARA_CTRL0_STS0_MASK), /*!< XBAR_OUT0 active edge interrupt flag, sets when active edge detected. */
  80. kXBARA_EdgeDetectionOut1 =
  81. (XBARA_CTRL0_STS1_MASK), /*!< XBAR_OUT1 active edge interrupt flag, sets when active edge detected. */
  82. kXBARA_EdgeDetectionOut2 =
  83. (XBARA_CTRL1_STS2_MASK << 16U), /*!< XBAR_OUT2 active edge interrupt flag, sets when active edge detected. */
  84. kXBARA_EdgeDetectionOut3 =
  85. (XBARA_CTRL1_STS3_MASK << 16U), /*!< XBAR_OUT3 active edge interrupt flag, sets when active edge detected. */
  86. } xbara_status_flag_t;
  87. /*!
  88. * @brief Defines the configuration structure of the XBARA control register.
  89. *
  90. * This structure keeps the configuration of XBARA control register for one output.
  91. * Control registers are available only for a few outputs. Not every XBARA module has
  92. * control registers.
  93. */
  94. typedef struct XBARAControlConfig
  95. {
  96. xbara_active_edge_t activeEdge; /*!< Active edge to be detected. */
  97. xbara_request_t requestType; /*!< Selects DMA/Interrupt request. */
  98. } xbara_control_config_t;
  99. /*******************************************************************************
  100. * API
  101. ******************************************************************************/
  102. #if defined(__cplusplus)
  103. extern "C" {
  104. #endif /* __cplusplus */
  105. /*!
  106. * @name XBARA functional Operation.
  107. * @{
  108. */
  109. /*!
  110. * @brief Initializes the XBARA module.
  111. *
  112. * This function un-gates the XBARA clock.
  113. *
  114. * @param base XBARA peripheral address.
  115. */
  116. void XBARA_Init(XBARA_Type *base);
  117. /*!
  118. * @brief Shuts down the XBARA module.
  119. *
  120. * This function disables XBARA clock.
  121. *
  122. * @param base XBARA peripheral address.
  123. */
  124. void XBARA_Deinit(XBARA_Type *base);
  125. /*!
  126. * @brief Sets a connection between the selected XBARA_IN[*] input and the XBARA_OUT[*] output signal.
  127. *
  128. * This function connects the XBARA input to the selected XBARA output.
  129. * If more than one XBARA module is available, only the inputs and outputs from the same module
  130. * can be connected.
  131. *
  132. * Example:
  133. @code
  134. XBARA_SetSignalsConnection(XBARA, kXBARA_InputPIT_TRG0, kXBARA_OutputDMAMUX18);
  135. @endcode
  136. *
  137. * @param base XBARA peripheral address.
  138. * @param input XBARA input signal.
  139. * @param output XBARA output signal.
  140. */
  141. void XBARA_SetSignalsConnection(XBARA_Type *base, xbar_input_signal_t input, xbar_output_signal_t output);
  142. /*!
  143. * @brief Gets the active edge detection status.
  144. *
  145. * This function gets the active edge detect status of all XBARA_OUTs. If the
  146. * active edge occurs, the return value is asserted. When the interrupt or the DMA
  147. * functionality is enabled for the XBARA_OUTx, this field is 1 when the interrupt
  148. * or DMA request is asserted and 0 when the interrupt or DMA request has been
  149. * cleared.
  150. *
  151. * @param base XBARA peripheral address.
  152. * @return the mask of these status flag bits.
  153. */
  154. uint32_t XBARA_GetStatusFlags(XBARA_Type *base);
  155. /*!
  156. * @brief Clears the edge detection status flags of relative mask.
  157. *
  158. * @param base XBARA peripheral address.
  159. * @param mask the status flags to clear.
  160. */
  161. void XBARA_ClearStatusFlags(XBARA_Type *base, uint32_t mask);
  162. /*!
  163. * @brief Configures the XBARA control register.
  164. *
  165. * This function configures an XBARA control register. The active edge detection
  166. * and the DMA/IRQ function on the corresponding XBARA output can be set.
  167. *
  168. * Example:
  169. @code
  170. xbara_control_config_t userConfig;
  171. userConfig.activeEdge = kXBARA_EdgeRising;
  172. userConfig.requestType = kXBARA_RequestInterruptEnalbe;
  173. XBARA_SetOutputSignalConfig(XBARA, kXBARA_OutputDMAMUX18, &userConfig);
  174. @endcode
  175. *
  176. * @param base XBARA peripheral address.
  177. * @param output XBARA output number.
  178. * @param controlConfig Pointer to structure that keeps configuration of control register.
  179. */
  180. void XBARA_SetOutputSignalConfig(XBARA_Type *base,
  181. xbar_output_signal_t output,
  182. const xbara_control_config_t *controlConfig);
  183. #if defined(__cplusplus)
  184. }
  185. #endif /* __cplusplus */
  186. /*! @}*/
  187. /*!* @} */
  188. #endif /* _FSL_XBARA_H_ */