fsl_xbara.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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_XBARA_H_
  9. #define _FSL_XBARA_H_
  10. #include "fsl_common.h"
  11. /*!
  12. * @addtogroup xbara
  13. * @{
  14. */
  15. /*******************************************************************************
  16. * Definitions
  17. ******************************************************************************/
  18. #define FSL_XBARA_DRIVER_VERSION (MAKE_VERSION(2, 0, 5))
  19. /* Macros for entire XBARA_SELx register. */
  20. #define XBARA_SELx(base, output) (((volatile uint16_t *)(&((base)->SEL0)))[(uint32_t)(output) / 2UL])
  21. /* Set the XBARA_SELx_SELx field to a new value. */
  22. #define XBARA_WR_SELx_SELx(base, input, output) XBARA_SetSignalsConnection((base), (input), (output))
  23. /*!
  24. * @brief XBARA active edge for detection
  25. */
  26. typedef enum _xbara_active_edge
  27. {
  28. kXBARA_EdgeNone = 0U, /*!< Edge detection status bit never asserts. */
  29. kXBARA_EdgeRising = 1U, /*!< Edge detection status bit asserts on rising edges. */
  30. kXBARA_EdgeFalling = 2U, /*!< Edge detection status bit asserts on falling edges. */
  31. kXBARA_EdgeRisingAndFalling = 3U /*!< Edge detection status bit asserts on rising and falling edges. */
  32. } xbara_active_edge_t;
  33. /*!
  34. * @brief Defines the XBARA DMA and interrupt configurations.
  35. */
  36. typedef enum _xbar_request
  37. {
  38. kXBARA_RequestDisable = 0U, /*!< Interrupt and DMA are disabled. */
  39. kXBARA_RequestDMAEnable = 1U, /*!< DMA enabled, interrupt disabled. */
  40. kXBARA_RequestInterruptEnalbe = 2U /*!< Interrupt enabled, DMA disabled. */
  41. } xbara_request_t;
  42. /*!
  43. * @brief XBARA status flags.
  44. *
  45. * This provides constants for the XBARA status flags for use in the XBARA functions.
  46. */
  47. typedef enum _xbara_status_flag_t
  48. {
  49. kXBARA_EdgeDetectionOut0 =
  50. (XBARA_CTRL0_STS0_MASK), /*!< XBAR_OUT0 active edge interrupt flag, sets when active edge detected. */
  51. kXBARA_EdgeDetectionOut1 =
  52. (XBARA_CTRL0_STS1_MASK), /*!< XBAR_OUT1 active edge interrupt flag, sets when active edge detected. */
  53. kXBARA_EdgeDetectionOut2 =
  54. (XBARA_CTRL1_STS2_MASK << 16U), /*!< XBAR_OUT2 active edge interrupt flag, sets when active edge detected. */
  55. kXBARA_EdgeDetectionOut3 =
  56. (XBARA_CTRL1_STS3_MASK << 16U), /*!< XBAR_OUT3 active edge interrupt flag, sets when active edge detected. */
  57. } xbara_status_flag_t;
  58. /*!
  59. * @brief Defines the configuration structure of the XBARA control register.
  60. *
  61. * This structure keeps the configuration of XBARA control register for one output.
  62. * Control registers are available only for a few outputs. Not every XBARA module has
  63. * control registers.
  64. */
  65. typedef struct XBARAControlConfig
  66. {
  67. xbara_active_edge_t activeEdge; /*!< Active edge to be detected. */
  68. xbara_request_t requestType; /*!< Selects DMA/Interrupt request. */
  69. } xbara_control_config_t;
  70. /*******************************************************************************
  71. * API
  72. ******************************************************************************/
  73. #if defined(__cplusplus)
  74. extern "C" {
  75. #endif /* __cplusplus */
  76. /*!
  77. * @name XBARA functional Operation.
  78. * @{
  79. */
  80. /*!
  81. * @brief Initializes the XBARA module.
  82. *
  83. * This function un-gates the XBARA clock.
  84. *
  85. * @param base XBARA peripheral address.
  86. */
  87. void XBARA_Init(XBARA_Type *base);
  88. /*!
  89. * @brief Shuts down the XBARA module.
  90. *
  91. * This function disables XBARA clock.
  92. *
  93. * @param base XBARA peripheral address.
  94. */
  95. void XBARA_Deinit(XBARA_Type *base);
  96. /*!
  97. * @brief Sets a connection between the selected XBARA_IN[*] input and the XBARA_OUT[*] output signal.
  98. *
  99. * This function connects the XBARA input to the selected XBARA output.
  100. * If more than one XBARA module is available, only the inputs and outputs from the same module
  101. * can be connected.
  102. *
  103. * Example:
  104. @code
  105. XBARA_SetSignalsConnection(XBARA, kXBARA_InputPIT_TRG0, kXBARA_OutputDMAMUX18);
  106. @endcode
  107. *
  108. * @param base XBARA peripheral address.
  109. * @param input XBARA input signal.
  110. * @param output XBARA output signal.
  111. */
  112. void XBARA_SetSignalsConnection(XBARA_Type *base, xbar_input_signal_t input, xbar_output_signal_t output);
  113. /*!
  114. * @brief Gets the active edge detection status.
  115. *
  116. * This function gets the active edge detect status of all XBARA_OUTs. If the
  117. * active edge occurs, the return value is asserted. When the interrupt or the DMA
  118. * functionality is enabled for the XBARA_OUTx, this field is 1 when the interrupt
  119. * or DMA request is asserted and 0 when the interrupt or DMA request has been
  120. * cleared.
  121. *
  122. * @param base XBARA peripheral address.
  123. * @return the mask of these status flag bits.
  124. */
  125. uint32_t XBARA_GetStatusFlags(XBARA_Type *base);
  126. /*!
  127. * @brief Clears the edge detection status flags of relative mask.
  128. *
  129. * @param base XBARA peripheral address.
  130. * @param mask the status flags to clear.
  131. */
  132. void XBARA_ClearStatusFlags(XBARA_Type *base, uint32_t mask);
  133. /*!
  134. * @brief Configures the XBARA control register.
  135. *
  136. * This function configures an XBARA control register. The active edge detection
  137. * and the DMA/IRQ function on the corresponding XBARA output can be set.
  138. *
  139. * Example:
  140. @code
  141. xbara_control_config_t userConfig;
  142. userConfig.activeEdge = kXBARA_EdgeRising;
  143. userConfig.requestType = kXBARA_RequestInterruptEnalbe;
  144. XBARA_SetOutputSignalConfig(XBARA, kXBARA_OutputDMAMUX18, &userConfig);
  145. @endcode
  146. *
  147. * @param base XBARA peripheral address.
  148. * @param output XBARA output number.
  149. * @param controlConfig Pointer to structure that keeps configuration of control register.
  150. */
  151. void XBARA_SetOutputSignalConfig(XBARA_Type *base,
  152. xbar_output_signal_t output,
  153. const xbara_control_config_t *controlConfig);
  154. #if defined(__cplusplus)
  155. }
  156. #endif /* __cplusplus */
  157. /*! @}*/
  158. /*!* @} */
  159. #endif /* _FSL_XBARA_H_ */