1 /******************************************************************************
2 * @file rsi_rom_udma_wrapper.h
3 *******************************************************************************
4 * # License
5 * <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
6 *******************************************************************************
7 *
8 * SPDX-License-Identifier: Zlib
9 *
10 * The licensor of this software is Silicon Laboratories Inc.
11 *
12 * This software is provided 'as-is', without any express or implied
13 * warranty. In no event will the authors be held liable for any damages
14 * arising from the use of this software.
15 *
16 * Permission is granted to anyone to use this software for any purpose,
17 * including commercial applications, and to alter it and redistribute it
18 * freely, subject to the following restrictions:
19 *
20 * 1. The origin of this software must not be misrepresented; you must not
21 * claim that you wrote the original software. If you use this software
22 * in a product, an acknowledgment in the product documentation would be
23 * appreciated but is not required.
24 * 2. Altered source versions must be plainly marked as such, and must not be
25 * misrepresented as being the original software.
26 * 3. This notice may not be removed or altered from any source distribution.
27 *
28 ******************************************************************************/
29
30 #ifndef __RSI_ROM_UDMA_WRAPPER_H__
31 #define __RSI_ROM_UDMA_WRAPPER_H__
32
33 /**
34 * \ingroup RSI_SPECIFIC_DRIVERS
35 * \defgroup RSI_UDMA_DRIVER UDMA WRAPPER
36 * @{
37 *
38 */
39 #include "rsi_ccp_user_config.h"
40 #include "rsi_packing.h"
41 #include "rsi_udma_wrapper.h"
42 #include "UDMA.h"
43 #if defined(A11_ROM)
44 #include "rsi_rom_table_si91x.h"
45 #endif
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49
UDMAx_Initialize(const UDMA_RESOURCES * udma,RSI_UDMA_DESC_T * UDMA_Table,RSI_UDMA_HANDLE_T udmaHandle,uint32_t * mem)50 STATIC INLINE RSI_UDMA_HANDLE_T UDMAx_Initialize(const UDMA_RESOURCES *udma,
51 RSI_UDMA_DESC_T *UDMA_Table,
52 RSI_UDMA_HANDLE_T udmaHandle,
53 uint32_t *mem)
54 {
55 #if defined(UDMA_ROMDRIVER_PRESENT) && defined(A11_ROM)
56 return udmaHandle = ROMAPI_UDMA_WRAPPER_API->uDMAx_Initialize(udma, UDMA_Table, udmaHandle, mem);
57 #else
58 return udmaHandle = uDMAx_Initialize(udma, UDMA_Table, udmaHandle, mem);
59 #endif
60 }
61
UDMAx_Uninitialize(const UDMA_RESOURCES * udma)62 STATIC INLINE int32_t UDMAx_Uninitialize(const UDMA_RESOURCES *udma)
63 {
64 #if defined(UDMA_ROMDRIVER_PRESENT) && defined(A11_ROM)
65 return ROMAPI_UDMA_WRAPPER_API->uDMAx_Uninitialize(udma);
66 #else
67 return uDMAx_Uninitialize(udma);
68 #endif
69 }
70
UDMAx_ChannelConfigure(const UDMA_RESOURCES * udma,uint8_t ch,uint32_t src_addr,uint32_t dest_addr,uint32_t size,RSI_UDMA_CHA_CONFIG_DATA_T control,const RSI_UDMA_CHA_CFG_T * config,UDMA_SignalEvent_t cb_event,UDMA_Channel_Info * chnl_info,RSI_UDMA_HANDLE_T udmaHandle)71 STATIC INLINE int32_t UDMAx_ChannelConfigure(const UDMA_RESOURCES *udma,
72 uint8_t ch,
73 uint32_t src_addr,
74 uint32_t dest_addr,
75 uint32_t size,
76 RSI_UDMA_CHA_CONFIG_DATA_T control,
77 const RSI_UDMA_CHA_CFG_T *config,
78 UDMA_SignalEvent_t cb_event,
79 UDMA_Channel_Info *chnl_info,
80 RSI_UDMA_HANDLE_T udmaHandle)
81 {
82 if (control.transferType == UDMA_SOFTWARE_TRIGG) {
83 udma->desc->vsUDMAChaConfigData1.transferType = UDMA_SOFTWARE_TRIGG;
84 }
85 if ((control.totalNumOfDMATrans + 1UL) > size) {
86 control.totalNumOfDMATrans = (unsigned int)((size - 1) & 0x03FF);
87 }
88
89 #if defined(UDMA_ROMDRIVER_PRESENT) && defined(A11_ROM)
90 return ROMAPI_UDMA_WRAPPER_API
91 ->uDMAx_ChannelConfigure(udma, ch, src_addr, dest_addr, size, control, config, cb_event, chnl_info, udmaHandle);
92 #else
93 return uDMAx_ChannelConfigure(udma, ch, src_addr, dest_addr, size, control, config, cb_event, chnl_info, udmaHandle);
94 #endif
95 }
96
UDMAx_ChannelEnable(uint8_t ch,const UDMA_RESOURCES * udma,RSI_UDMA_HANDLE_T udmaHandle)97 STATIC INLINE int32_t UDMAx_ChannelEnable(uint8_t ch, const UDMA_RESOURCES *udma, RSI_UDMA_HANDLE_T udmaHandle)
98 {
99 #if defined(UDMA_ROMDRIVER_PRESENT) && defined(A11_ROM)
100
101 return ROMAPI_UDMA_WRAPPER_API->uDMAx_ChannelEnable(ch, udma, udmaHandle);
102 #else
103 return uDMAx_ChannelEnable(ch, udma, udmaHandle);
104 #endif
105 }
106
UDMAx_DMAEnable(const UDMA_RESOURCES * udma,RSI_UDMA_HANDLE_T udmaHandle)107 STATIC INLINE int32_t UDMAx_DMAEnable(const UDMA_RESOURCES *udma, RSI_UDMA_HANDLE_T udmaHandle)
108 {
109 #if defined(UDMA_ROMDRIVER_PRESENT) && defined(A11_ROM)
110 return ROMAPI_UDMA_WRAPPER_API->uDMAx_DMAEnable(udma, udmaHandle);
111 #else
112 return uDMAx_DMAEnable(udma, udmaHandle);
113 #endif
114 }
115
UDMAx_ChannelDisable(uint8_t ch,const UDMA_RESOURCES * udma,RSI_UDMA_HANDLE_T udmaHandle)116 STATIC INLINE int32_t UDMAx_ChannelDisable(uint8_t ch, const UDMA_RESOURCES *udma, RSI_UDMA_HANDLE_T udmaHandle)
117 {
118 #if defined(UDMA_ROMDRIVER_PRESENT) && defined(A11_ROM)
119 return ROMAPI_UDMA_WRAPPER_API->uDMAx_ChannelDisable(ch, udma, udmaHandle);
120 #else
121 return uDMAx_ChannelDisable(ch, udma, udmaHandle);
122 #endif
123 }
124
UDMAx_ChannelGetCount(uint8_t ch,RSI_UDMA_CHA_CONFIG_DATA_T control,RSI_UDMA_CHA_CFG_T config,const UDMA_RESOURCES * udma,RSI_UDMA_HANDLE_T udmaHandle)125 STATIC INLINE uint32_t UDMAx_ChannelGetCount(uint8_t ch,
126 RSI_UDMA_CHA_CONFIG_DATA_T control,
127 RSI_UDMA_CHA_CFG_T config,
128 const UDMA_RESOURCES *udma,
129 RSI_UDMA_HANDLE_T udmaHandle)
130 {
131 #if defined(UDMA_ROMDRIVER_PRESENT) && defined(A11_ROM)
132 return ROMAPI_UDMA_WRAPPER_API->uDMAx_ChannelGetCount(ch, control, config, udma, udmaHandle);
133 #else
134 return uDMAx_ChannelGetCount(ch, control, config, udma, udmaHandle);
135 #endif
136 }
UDMAx_IRQHandler(UDMA_RESOURCES * udma,RSI_UDMA_DESC_T * UDMA_Table,UDMA_Channel_Info * chnl_info)137 STATIC INLINE void UDMAx_IRQHandler(UDMA_RESOURCES *udma, RSI_UDMA_DESC_T *UDMA_Table, UDMA_Channel_Info *chnl_info)
138 {
139 #if defined(UDMA_ROMDRIVER_PRESENT) && defined(A11_ROM)
140 ROMAPI_UDMA_WRAPPER_API->uDMAx_IRQHandler(udma, UDMA_Table, chnl_info);
141 #else
142 uDMAx_IRQHandler(udma, UDMA_Table, chnl_info);
143 #endif
144 }
145
146 #ifdef __cplusplus
147 }
148 #endif
149
150 #endif /* __RSI_ROM_UDMA_WRAPPER_H__*/
151