25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 

178 satır
4.4 KiB

  1. /*
  2. * Copyright (c) 2015, Freescale Semiconductor, Inc.
  3. * Copyright 2016-2017 NXP
  4. * All rights reserved.
  5. *
  6. * SPDX-License-Identifier: BSD-3-Clause
  7. */
  8. #ifndef _FSL_DMAMUX_H_
  9. #define _FSL_DMAMUX_H_
  10. #include "fsl_common.h"
  11. /*!
  12. * @addtogroup dmamux
  13. * @{
  14. */
  15. /*******************************************************************************
  16. * Definitions
  17. ******************************************************************************/
  18. /*! @name Driver version */
  19. /*@{*/
  20. /*! @brief DMAMUX driver version 2.0.4. */
  21. #define FSL_DMAMUX_DRIVER_VERSION (MAKE_VERSION(2, 0, 4))
  22. /*@}*/
  23. /*******************************************************************************
  24. * API
  25. ******************************************************************************/
  26. #if defined(__cplusplus)
  27. extern "C" {
  28. #endif /* __cplusplus */
  29. /*!
  30. * @name DMAMUX Initialization and de-initialization
  31. * @{
  32. */
  33. /*!
  34. * @brief Initializes the DMAMUX peripheral.
  35. *
  36. * This function ungates the DMAMUX clock.
  37. *
  38. * @param base DMAMUX peripheral base address.
  39. *
  40. */
  41. void DMAMUX_Init(DMAMUX_Type *base);
  42. /*!
  43. * @brief Deinitializes the DMAMUX peripheral.
  44. *
  45. * This function gates the DMAMUX clock.
  46. *
  47. * @param base DMAMUX peripheral base address.
  48. */
  49. void DMAMUX_Deinit(DMAMUX_Type *base);
  50. /* @} */
  51. /*!
  52. * @name DMAMUX Channel Operation
  53. * @{
  54. */
  55. /*!
  56. * @brief Enables the DMAMUX channel.
  57. *
  58. * This function enables the DMAMUX channel.
  59. *
  60. * @param base DMAMUX peripheral base address.
  61. * @param channel DMAMUX channel number.
  62. */
  63. static inline void DMAMUX_EnableChannel(DMAMUX_Type *base, uint32_t channel)
  64. {
  65. assert(channel < (uint32_t)FSL_FEATURE_DMAMUX_MODULE_CHANNEL);
  66. base->CHCFG[channel] |= DMAMUX_CHCFG_ENBL_MASK;
  67. }
  68. /*!
  69. * @brief Disables the DMAMUX channel.
  70. *
  71. * This function disables the DMAMUX channel.
  72. *
  73. * @note The user must disable the DMAMUX channel before configuring it.
  74. * @param base DMAMUX peripheral base address.
  75. * @param channel DMAMUX channel number.
  76. */
  77. static inline void DMAMUX_DisableChannel(DMAMUX_Type *base, uint32_t channel)
  78. {
  79. assert(channel < (uint32_t)FSL_FEATURE_DMAMUX_MODULE_CHANNEL);
  80. base->CHCFG[channel] &= ~(uint8_t)DMAMUX_CHCFG_ENBL_MASK;
  81. }
  82. /*!
  83. * @brief Configures the DMAMUX channel source.
  84. *
  85. * @param base DMAMUX peripheral base address.
  86. * @param channel DMAMUX channel number.
  87. * @param source Channel source, which is used to trigger the DMA transfer.
  88. */
  89. static inline void DMAMUX_SetSource(DMAMUX_Type *base, uint32_t channel, uint32_t source)
  90. {
  91. assert(channel < (uint32_t)FSL_FEATURE_DMAMUX_MODULE_CHANNEL);
  92. base->CHCFG[channel] = (uint8_t)((base->CHCFG[channel] & ~DMAMUX_CHCFG_SOURCE_MASK) | DMAMUX_CHCFG_SOURCE(source));
  93. }
  94. #if defined(FSL_FEATURE_DMAMUX_HAS_TRIG) && FSL_FEATURE_DMAMUX_HAS_TRIG > 0U
  95. /*!
  96. * @brief Enables the DMAMUX period trigger.
  97. *
  98. * This function enables the DMAMUX period trigger feature.
  99. *
  100. * @param base DMAMUX peripheral base address.
  101. * @param channel DMAMUX channel number.
  102. */
  103. static inline void DMAMUX_EnablePeriodTrigger(DMAMUX_Type *base, uint32_t channel)
  104. {
  105. assert(channel < (uint32_t)FSL_FEATURE_DMAMUX_MODULE_CHANNEL);
  106. base->CHCFG[channel] |= DMAMUX_CHCFG_TRIG_MASK;
  107. }
  108. /*!
  109. * @brief Disables the DMAMUX period trigger.
  110. *
  111. * This function disables the DMAMUX period trigger.
  112. *
  113. * @param base DMAMUX peripheral base address.
  114. * @param channel DMAMUX channel number.
  115. */
  116. static inline void DMAMUX_DisablePeriodTrigger(DMAMUX_Type *base, uint32_t channel)
  117. {
  118. assert(channel < (uint32_t)FSL_FEATURE_DMAMUX_MODULE_CHANNEL);
  119. base->CHCFG[channel] &= ~(uint8_t)DMAMUX_CHCFG_TRIG_MASK;
  120. }
  121. #endif /* FSL_FEATURE_DMAMUX_HAS_TRIG */
  122. #if (defined(FSL_FEATURE_DMAMUX_HAS_A_ON) && FSL_FEATURE_DMAMUX_HAS_A_ON)
  123. /*!
  124. * @brief Enables the DMA channel to be always ON.
  125. *
  126. * This function enables the DMAMUX channel always ON feature.
  127. *
  128. * @param base DMAMUX peripheral base address.
  129. * @param channel DMAMUX channel number.
  130. * @param enable Switcher of the always ON feature. "true" means enabled, "false" means disabled.
  131. */
  132. static inline void DMAMUX_EnableAlwaysOn(DMAMUX_Type *base, uint32_t channel, bool enable)
  133. {
  134. assert(channel < (uint32_t)FSL_FEATURE_DMAMUX_MODULE_CHANNEL);
  135. if (enable)
  136. {
  137. base->CHCFG[channel] |= DMAMUX_CHCFG_A_ON_MASK;
  138. }
  139. else
  140. {
  141. base->CHCFG[channel] &= ~DMAMUX_CHCFG_A_ON_MASK;
  142. }
  143. }
  144. #endif /* FSL_FEATURE_DMAMUX_HAS_A_ON */
  145. /* @} */
  146. #if defined(__cplusplus)
  147. }
  148. #endif /* __cplusplus */
  149. /* @} */
  150. #endif /* _FSL_DMAMUX_H_ */