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 #if !defined(DMAMUX_SOC_WRITEONLY) || !DMAMUX_SOC_WRITEONLY
27
28 /**
29 * @brief Enable dmamux channel
30 *
31 * @param ptr DMAMUX base address
32 * @param ch_index channel to be enabled
33 */
dmamux_enable_channel(DMAMUX_Type * ptr,uint8_t ch_index)34 static inline void dmamux_enable_channel(DMAMUX_Type *ptr, uint8_t ch_index)
35 {
36 ptr->MUXCFG[ch_index] |= DMAMUX_MUXCFG_ENABLE_MASK;
37 }
38
39 /**
40 * @brief Disable dmamux channel
41 *
42 * @param ptr DMAMUX base address
43 * @param ch_index channel to be disabled
44 */
dmamux_disable_channel(DMAMUX_Type * ptr,uint8_t ch_index)45 static inline void dmamux_disable_channel(DMAMUX_Type *ptr, uint8_t ch_index)
46 {
47 ptr->MUXCFG[ch_index] &= ~DMAMUX_MUXCFG_ENABLE_MASK;
48 }
49
50 #endif
51
52 /**
53 * @brief Config DMAMUX
54 *
55 * @param[in] ptr DMAMUX base address
56 * @param[in] ch_index channel to be configured
57 * @param[in] src DMAMUX source
58 * @param[in] enable Set true to enable the channel
59 */
dmamux_config(DMAMUX_Type * ptr,uint8_t ch_index,uint8_t src,bool enable)60 static inline void dmamux_config(DMAMUX_Type *ptr, uint8_t ch_index, uint8_t src, bool enable)
61 {
62 ptr->MUXCFG[ch_index] = DMAMUX_MUXCFG_SOURCE_SET(src)
63 | DMAMUX_MUXCFG_ENABLE_SET(enable);
64 }
65
66
67 #ifdef __cplusplus
68 }
69 #endif
70 /**
71 * @}
72 */
73
74 #endif /* HPM_DMAMUX_DRV_H */
75
76