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