hpm_dmamux_drv.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. /**
  21. * @brief Enable dmamux channel
  22. *
  23. * @param ptr DMAMUX base address
  24. * @param ch_index channel to be enabled
  25. */
  26. static inline void dmamux_enable_channel(DMAMUX_Type *ptr, uint8_t ch_index)
  27. {
  28. ptr->MUXCFG[ch_index] |= DMAMUX_MUXCFG_ENABLE_MASK;
  29. }
  30. /**
  31. * @brief Disable dmamux channel
  32. *
  33. * @param ptr DMAMUX base address
  34. * @param ch_index channel to be disabled
  35. */
  36. static inline void dmamux_disable_channel(DMAMUX_Type *ptr, uint8_t ch_index)
  37. {
  38. ptr->MUXCFG[ch_index] &= ~DMAMUX_MUXCFG_ENABLE_MASK;
  39. }
  40. /**
  41. * @brief Config DMAMUX
  42. *
  43. * @param[in] ptr DMAMUX base address
  44. * @param[in] ch_index channel to be configured
  45. * @param[in] src DMAMUX source
  46. * @param[in] enable Set true to enable the channel
  47. */
  48. static inline void dmamux_config(DMAMUX_Type *ptr, uint8_t ch_index, uint8_t src, bool enable)
  49. {
  50. ptr->MUXCFG[ch_index] = DMAMUX_MUXCFG_SOURCE_SET(src)
  51. | DMAMUX_MUXCFG_ENABLE_SET(enable);
  52. }
  53. #ifdef __cplusplus
  54. }
  55. #endif
  56. /**
  57. * @}
  58. */
  59. #endif /* HPM_DMAMUX_DRV_H */