hpm_dmamux_drv.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Copyright (c) 2021-2022 HPMicro
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. *
  6. */
  7. #ifndef HPM_DMAMUX_DRV_H
  8. #define HPM_DMAMUX_DRV_H
  9. #include "hpm_common.h"
  10. #include "hpm_dmamux_regs.h"
  11. /**
  12. *
  13. * @brief DMAMUX driver APIs
  14. * @defgroup dmamux_interface DMAMUX driver APIs
  15. * @{
  16. */
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. #if !defined(DMAMUX_SOC_WRITEONLY) || !DMAMUX_SOC_WRITEONLY
  21. /**
  22. * @brief Enable dmamux channel
  23. *
  24. * @param ptr DMAMUX base address
  25. * @param ch_index channel to be enabled
  26. */
  27. static inline void dmamux_enable_channel(DMAMUX_Type *ptr, uint8_t ch_index)
  28. {
  29. ptr->MUXCFG[ch_index] |= DMAMUX_MUXCFG_ENABLE_MASK;
  30. }
  31. /**
  32. * @brief Disable dmamux channel
  33. *
  34. * @param ptr DMAMUX base address
  35. * @param ch_index channel to be disabled
  36. */
  37. static inline void dmamux_disable_channel(DMAMUX_Type *ptr, uint8_t ch_index)
  38. {
  39. ptr->MUXCFG[ch_index] &= ~DMAMUX_MUXCFG_ENABLE_MASK;
  40. }
  41. #endif
  42. /**
  43. * @brief Config DMAMUX
  44. *
  45. * @param[in] ptr DMAMUX base address
  46. * @param[in] ch_index channel to be configured
  47. * @param[in] src DMAMUX source
  48. * @param[in] enable Set true to enable the channel
  49. */
  50. static inline void dmamux_config(DMAMUX_Type *ptr, uint8_t ch_index, uint8_t src, bool enable)
  51. {
  52. ptr->MUXCFG[ch_index] = DMAMUX_MUXCFG_SOURCE_SET(src)
  53. | DMAMUX_MUXCFG_ENABLE_SET(enable);
  54. }
  55. #ifdef __cplusplus
  56. }
  57. #endif
  58. /**
  59. * @}
  60. */
  61. #endif /* HPM_DMAMUX_DRV_H */