fsl_dmamux.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. /*
  2. * Copyright (c) 2015, Freescale Semiconductor, Inc.
  3. * Copyright 2016-2017 NXP
  4. *
  5. * Redistribution and use in source and binary forms, with or without modification,
  6. * are permitted provided that the following conditions are met:
  7. *
  8. * o Redistributions of source code must retain the above copyright notice, this list
  9. * of conditions and the following disclaimer.
  10. *
  11. * o Redistributions in binary form must reproduce the above copyright notice, this
  12. * list of conditions and the following disclaimer in the documentation and/or
  13. * other materials provided with the distribution.
  14. *
  15. * o Neither the name of the copyright holder nor the names of its
  16. * contributors may be used to endorse or promote products derived from this
  17. * software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  20. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  21. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  22. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
  23. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  24. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  25. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  26. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  28. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. */
  30. #ifndef _FSL_DMAMUX_H_
  31. #define _FSL_DMAMUX_H_
  32. #include "fsl_common.h"
  33. /*!
  34. * @addtogroup dmamux
  35. * @{
  36. */
  37. /*******************************************************************************
  38. * Definitions
  39. ******************************************************************************/
  40. /*! @name Driver version */
  41. /*@{*/
  42. /*! @brief DMAMUX driver version 2.0.2. */
  43. #define FSL_DMAMUX_DRIVER_VERSION (MAKE_VERSION(2, 0, 2))
  44. /*@}*/
  45. /*******************************************************************************
  46. * API
  47. ******************************************************************************/
  48. #if defined(__cplusplus)
  49. extern "C" {
  50. #endif /* __cplusplus */
  51. /*!
  52. * @name DMAMUX Initialization and de-initialization
  53. * @{
  54. */
  55. /*!
  56. * @brief Initializes the DMAMUX peripheral.
  57. *
  58. * This function ungates the DMAMUX clock.
  59. *
  60. * @param base DMAMUX peripheral base address.
  61. *
  62. */
  63. void DMAMUX_Init(DMAMUX_Type *base);
  64. /*!
  65. * @brief Deinitializes the DMAMUX peripheral.
  66. *
  67. * This function gates the DMAMUX clock.
  68. *
  69. * @param base DMAMUX peripheral base address.
  70. */
  71. void DMAMUX_Deinit(DMAMUX_Type *base);
  72. /* @} */
  73. /*!
  74. * @name DMAMUX Channel Operation
  75. * @{
  76. */
  77. /*!
  78. * @brief Enables the DMAMUX channel.
  79. *
  80. * This function enables the DMAMUX channel.
  81. *
  82. * @param base DMAMUX peripheral base address.
  83. * @param channel DMAMUX channel number.
  84. */
  85. static inline void DMAMUX_EnableChannel(DMAMUX_Type *base, uint32_t channel)
  86. {
  87. assert(channel < FSL_FEATURE_DMAMUX_MODULE_CHANNEL);
  88. base->CHCFG[channel] |= DMAMUX_CHCFG_ENBL_MASK;
  89. }
  90. /*!
  91. * @brief Disables the DMAMUX channel.
  92. *
  93. * This function disables the DMAMUX channel.
  94. *
  95. * @note The user must disable the DMAMUX channel before configuring it.
  96. * @param base DMAMUX peripheral base address.
  97. * @param channel DMAMUX channel number.
  98. */
  99. static inline void DMAMUX_DisableChannel(DMAMUX_Type *base, uint32_t channel)
  100. {
  101. assert(channel < FSL_FEATURE_DMAMUX_MODULE_CHANNEL);
  102. base->CHCFG[channel] &= ~DMAMUX_CHCFG_ENBL_MASK;
  103. }
  104. /*!
  105. * @brief Configures the DMAMUX channel source.
  106. *
  107. * @param base DMAMUX peripheral base address.
  108. * @param channel DMAMUX channel number.
  109. * @param source Channel source, which is used to trigger the DMA transfer.
  110. */
  111. static inline void DMAMUX_SetSource(DMAMUX_Type *base, uint32_t channel, uint32_t source)
  112. {
  113. assert(channel < FSL_FEATURE_DMAMUX_MODULE_CHANNEL);
  114. base->CHCFG[channel] = ((base->CHCFG[channel] & ~DMAMUX_CHCFG_SOURCE_MASK) | DMAMUX_CHCFG_SOURCE(source));
  115. }
  116. #if defined(FSL_FEATURE_DMAMUX_HAS_TRIG) && FSL_FEATURE_DMAMUX_HAS_TRIG > 0U
  117. /*!
  118. * @brief Enables the DMAMUX period trigger.
  119. *
  120. * This function enables the DMAMUX period trigger feature.
  121. *
  122. * @param base DMAMUX peripheral base address.
  123. * @param channel DMAMUX channel number.
  124. */
  125. static inline void DMAMUX_EnablePeriodTrigger(DMAMUX_Type *base, uint32_t channel)
  126. {
  127. assert(channel < FSL_FEATURE_DMAMUX_MODULE_CHANNEL);
  128. base->CHCFG[channel] |= DMAMUX_CHCFG_TRIG_MASK;
  129. }
  130. /*!
  131. * @brief Disables the DMAMUX period trigger.
  132. *
  133. * This function disables the DMAMUX period trigger.
  134. *
  135. * @param base DMAMUX peripheral base address.
  136. * @param channel DMAMUX channel number.
  137. */
  138. static inline void DMAMUX_DisablePeriodTrigger(DMAMUX_Type *base, uint32_t channel)
  139. {
  140. assert(channel < FSL_FEATURE_DMAMUX_MODULE_CHANNEL);
  141. base->CHCFG[channel] &= ~DMAMUX_CHCFG_TRIG_MASK;
  142. }
  143. #endif /* FSL_FEATURE_DMAMUX_HAS_TRIG */
  144. #if (defined(FSL_FEATURE_DMAMUX_HAS_A_ON) && FSL_FEATURE_DMAMUX_HAS_A_ON)
  145. /*!
  146. * @brief Enables the DMA channel to be always ON.
  147. *
  148. * This function enables the DMAMUX channel always ON feature.
  149. *
  150. * @param base DMAMUX peripheral base address.
  151. * @param channel DMAMUX channel number.
  152. * @param enable Switcher of the always ON feature. "true" means enabled, "false" means disabled.
  153. */
  154. static inline void DMAMUX_EnableAlwaysOn(DMAMUX_Type *base, uint32_t channel, bool enable)
  155. {
  156. assert(channel < FSL_FEATURE_DMAMUX_MODULE_CHANNEL);
  157. if (enable)
  158. {
  159. base->CHCFG[channel] |= DMAMUX_CHCFG_A_ON_MASK;
  160. }
  161. else
  162. {
  163. base->CHCFG[channel] &= ~DMAMUX_CHCFG_A_ON_MASK;
  164. }
  165. }
  166. #endif /* FSL_FEATURE_DMAMUX_HAS_A_ON */
  167. /* @} */
  168. #if defined(__cplusplus)
  169. }
  170. #endif /* __cplusplus */
  171. /* @} */
  172. #endif /* _FSL_DMAMUX_H_ */