fsl_dmamux.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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_DMAMUX_H_
  35. #define _FSL_DMAMUX_H_
  36. #include "fsl_common.h"
  37. /*!
  38. * @addtogroup dmamux
  39. * @{
  40. */
  41. /*******************************************************************************
  42. * Definitions
  43. ******************************************************************************/
  44. /*! @name Driver version */
  45. /*@{*/
  46. /*! @brief DMAMUX driver version 2.0.2. */
  47. #define FSL_DMAMUX_DRIVER_VERSION (MAKE_VERSION(2, 0, 2))
  48. /*@}*/
  49. /*******************************************************************************
  50. * API
  51. ******************************************************************************/
  52. #if defined(__cplusplus)
  53. extern "C" {
  54. #endif /* __cplusplus */
  55. /*!
  56. * @name DMAMUX Initialization and de-initialization
  57. * @{
  58. */
  59. /*!
  60. * @brief Initializes the DMAMUX peripheral.
  61. *
  62. * This function ungates the DMAMUX clock.
  63. *
  64. * @param base DMAMUX peripheral base address.
  65. *
  66. */
  67. void DMAMUX_Init(DMAMUX_Type *base);
  68. /*!
  69. * @brief Deinitializes the DMAMUX peripheral.
  70. *
  71. * This function gates the DMAMUX clock.
  72. *
  73. * @param base DMAMUX peripheral base address.
  74. */
  75. void DMAMUX_Deinit(DMAMUX_Type *base);
  76. /* @} */
  77. /*!
  78. * @name DMAMUX Channel Operation
  79. * @{
  80. */
  81. /*!
  82. * @brief Enables the DMAMUX channel.
  83. *
  84. * This function enables the DMAMUX channel.
  85. *
  86. * @param base DMAMUX peripheral base address.
  87. * @param channel DMAMUX channel number.
  88. */
  89. static inline void DMAMUX_EnableChannel(DMAMUX_Type *base, uint32_t channel)
  90. {
  91. assert(channel < FSL_FEATURE_DMAMUX_MODULE_CHANNEL);
  92. base->CHCFG[channel] |= DMAMUX_CHCFG_ENBL_MASK;
  93. }
  94. /*!
  95. * @brief Disables the DMAMUX channel.
  96. *
  97. * This function disables the DMAMUX channel.
  98. *
  99. * @note The user must disable the DMAMUX channel before configuring it.
  100. * @param base DMAMUX peripheral base address.
  101. * @param channel DMAMUX channel number.
  102. */
  103. static inline void DMAMUX_DisableChannel(DMAMUX_Type *base, uint32_t channel)
  104. {
  105. assert(channel < FSL_FEATURE_DMAMUX_MODULE_CHANNEL);
  106. base->CHCFG[channel] &= ~DMAMUX_CHCFG_ENBL_MASK;
  107. }
  108. /*!
  109. * @brief Configures the DMAMUX channel source.
  110. *
  111. * @param base DMAMUX peripheral base address.
  112. * @param channel DMAMUX channel number.
  113. * @param source Channel source, which is used to trigger the DMA transfer.
  114. */
  115. static inline void DMAMUX_SetSource(DMAMUX_Type *base, uint32_t channel, uint32_t source)
  116. {
  117. assert(channel < FSL_FEATURE_DMAMUX_MODULE_CHANNEL);
  118. base->CHCFG[channel] = ((base->CHCFG[channel] & ~DMAMUX_CHCFG_SOURCE_MASK) | DMAMUX_CHCFG_SOURCE(source));
  119. }
  120. #if defined(FSL_FEATURE_DMAMUX_HAS_TRIG) && FSL_FEATURE_DMAMUX_HAS_TRIG > 0U
  121. /*!
  122. * @brief Enables the DMAMUX period trigger.
  123. *
  124. * This function enables the DMAMUX period trigger feature.
  125. *
  126. * @param base DMAMUX peripheral base address.
  127. * @param channel DMAMUX channel number.
  128. */
  129. static inline void DMAMUX_EnablePeriodTrigger(DMAMUX_Type *base, uint32_t channel)
  130. {
  131. assert(channel < FSL_FEATURE_DMAMUX_MODULE_CHANNEL);
  132. base->CHCFG[channel] |= DMAMUX_CHCFG_TRIG_MASK;
  133. }
  134. /*!
  135. * @brief Disables the DMAMUX period trigger.
  136. *
  137. * This function disables the DMAMUX period trigger.
  138. *
  139. * @param base DMAMUX peripheral base address.
  140. * @param channel DMAMUX channel number.
  141. */
  142. static inline void DMAMUX_DisablePeriodTrigger(DMAMUX_Type *base, uint32_t channel)
  143. {
  144. assert(channel < FSL_FEATURE_DMAMUX_MODULE_CHANNEL);
  145. base->CHCFG[channel] &= ~DMAMUX_CHCFG_TRIG_MASK;
  146. }
  147. #endif /* FSL_FEATURE_DMAMUX_HAS_TRIG */
  148. #if (defined(FSL_FEATURE_DMAMUX_HAS_A_ON) && FSL_FEATURE_DMAMUX_HAS_A_ON)
  149. /*!
  150. * @brief Enables the DMA channel to be always ON.
  151. *
  152. * This function enables the DMAMUX channel always ON feature.
  153. *
  154. * @param base DMAMUX peripheral base address.
  155. * @param channel DMAMUX channel number.
  156. * @param enable Switcher of the always ON feature. "true" means enabled, "false" means disabled.
  157. */
  158. static inline void DMAMUX_EnableAlwaysOn(DMAMUX_Type *base, uint32_t channel, bool enable)
  159. {
  160. assert(channel < FSL_FEATURE_DMAMUX_MODULE_CHANNEL);
  161. if (enable)
  162. {
  163. base->CHCFG[channel] |= DMAMUX_CHCFG_A_ON_MASK;
  164. }
  165. else
  166. {
  167. base->CHCFG[channel] &= ~DMAMUX_CHCFG_A_ON_MASK;
  168. }
  169. }
  170. #endif /* FSL_FEATURE_DMAMUX_HAS_A_ON */
  171. /* @} */
  172. #if defined(__cplusplus)
  173. }
  174. #endif /* __cplusplus */
  175. /* @} */
  176. #endif /* _FSL_DMAMUX_H_ */