Skip to content

Commit 63f2d4c

Browse files
Martinhoff-makerjhedberg
authored andcommitted
simplicity_sdk: Import HAL files from Simplicity SDK
Origin: Simplicity SDK License: Zlib URL: https://github.com/SiliconLabs/simplicity_sdk Commit: 8627f8482564dc6d94b56512740a39d6f409a0eb Version: 2024.12.0 Purpose: Import dmadrv in order to simplify the use of other hal driver. It has be done escpecially for future sl_* driver. Signed-off-by: Martin Hoff <[email protected]>
1 parent 788fff9 commit 63f2d4c

File tree

5 files changed

+2211
-0
lines changed

5 files changed

+2211
-0
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/***************************************************************************//**
2+
* @file
3+
* @brief Energy Aware drivers error code definitions.
4+
*******************************************************************************
5+
* # License
6+
* <b>Copyright 2018 Silicon Laboratories Inc. www.silabs.com</b>
7+
*******************************************************************************
8+
*
9+
* SPDX-License-Identifier: Zlib
10+
*
11+
* The licensor of this software is Silicon Laboratories Inc.
12+
*
13+
* This software is provided 'as-is', without any express or implied
14+
* warranty. In no event will the authors be held liable for any damages
15+
* arising from the use of this software.
16+
*
17+
* Permission is granted to anyone to use this software for any purpose,
18+
* including commercial applications, and to alter it and redistribute it
19+
* freely, subject to the following restrictions:
20+
*
21+
* 1. The origin of this software must not be misrepresented; you must not
22+
* claim that you wrote the original software. If you use this software
23+
* in a product, an acknowledgment in the product documentation would be
24+
* appreciated but is not required.
25+
* 2. Altered source versions must be plainly marked as such, and must not be
26+
* misrepresented as being the original software.
27+
* 3. This notice may not be removed or altered from any source distribution.
28+
*
29+
******************************************************************************/
30+
#ifndef __SILICON_LABS_ECODE_H__
31+
#define __SILICON_LABS_ECODE_H__
32+
33+
#include <stdint.h>
34+
35+
/***************************************************************************//**
36+
* @addtogroup ecode ECODE - Error Codes
37+
* @details ECODE is set of error and status codes related to DMA, RTC, SPI,
38+
* NVM, USTIMER, UARTDRV, EZRADIO, TEMP, and NVM3 drivers. These error and
39+
* status codes are used by the above listed drivers to update the layer
40+
* (using the driver) about an error or status.
41+
*
42+
* @{
43+
******************************************************************************/
44+
45+
/***************************************************************************//**
46+
* @brief Typedef for API function error code return values.
47+
*
48+
* @details
49+
* Bit 24-31: Component, for example emdrv @n
50+
* Bit 16-23: Module, for example @ref uartdrv or @ref spidrv @n
51+
* Bit 0-15: Error code
52+
******************************************************************************/
53+
typedef uint32_t Ecode_t;
54+
55+
#define ECODE_EMDRV_BASE (0xF0000000U) ///< Base value for all EMDRV errorcodes.
56+
57+
#define ECODE_OK (0U) ///< Generic success return value.
58+
59+
#define ECODE_EMDRV_SPIDRV_BASE (ECODE_EMDRV_BASE | 0x00002000U) ///< Base value for SPIDRV error codes.
60+
#define ECODE_EMDRV_NVM_BASE (ECODE_EMDRV_BASE | 0x00003000U) ///< Base value for NVM error codes.
61+
#define ECODE_EMDRV_USTIMER_BASE (ECODE_EMDRV_BASE | 0x00004000U) ///< Base value for USTIMER error codes.
62+
#define ECODE_EMDRV_UARTDRV_BASE (ECODE_EMDRV_BASE | 0x00007000U) ///< Base value for UARTDRV error codes.
63+
#define ECODE_EMDRV_DMADRV_BASE (ECODE_EMDRV_BASE | 0x00008000U) ///< Base value for DMADRV error codes.
64+
#define ECODE_EMDRV_EZRADIODRV_BASE (ECODE_EMDRV_BASE | 0x00009000U) ///< Base value for EZRADIODRV error codes.
65+
#define ECODE_EMDRV_TEMPDRV_BASE (ECODE_EMDRV_BASE | 0x0000D000U) ///< Base value for TEMPDRV error codes.
66+
#define ECODE_EMDRV_NVM3_BASE (ECODE_EMDRV_BASE | 0x0000E000U) ///< Base value for NVM3 error codes.
67+
68+
/** @} (end addtogroup ecode) */
69+
70+
#endif // __SILICON_LABS_ECODE_H__
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#ifndef DMADRV_CONFIG_H
2+
#define DMADRV_CONFIG_H
3+
4+
// <<< Use Configuration Wizard in Context Menu >>>
5+
6+
// <o EMDRV_DMADRV_DMA_IRQ_PRIORITY> DMA interrupt priority <0-15>
7+
// <i> Priority of the DMA interrupt. Smaller number equals higher priority.
8+
// <i> Default: 8
9+
#define EMDRV_DMADRV_DMA_IRQ_PRIORITY 8
10+
11+
// <o EMDRV_DMADRV_DMA_CH_COUNT> Number of available channels <1-8>
12+
// <i> Number of DMA channels supported by the driver. A lower channel count
13+
// <i> will reduce RAM memory footprint. The default is to support all channels
14+
// <i> on the device.
15+
// <i> Default: 8
16+
#define EMDRV_DMADRV_DMA_CH_COUNT 8
17+
18+
// <o EMDRV_DMADRV_DMA_CH_PRIORITY> Number of fixed priority channels
19+
// <i> This will configure channels [0, CH_PRIORITY - 1] as fixed priority,
20+
// <i> and channels [CH_PRIORITY, CH_COUNT] as round-robin.
21+
// <i> Default: 0
22+
#define EMDRV_DMADRV_DMA_CH_PRIORITY 0
23+
24+
// <<< end of configuration section >>>
25+
26+
#endif // DMADRV_CONFIG_H
Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
/***************************************************************************//**
2+
* @file
3+
* @brief DMADRV API definition.
4+
*******************************************************************************
5+
* # License
6+
* <b>Copyright 2018 Silicon Laboratories Inc. www.silabs.com</b>
7+
*******************************************************************************
8+
*
9+
* SPDX-License-Identifier: Zlib
10+
*
11+
* The licensor of this software is Silicon Laboratories Inc.
12+
*
13+
* This software is provided 'as-is', without any express or implied
14+
* warranty. In no event will the authors be held liable for any damages
15+
* arising from the use of this software.
16+
*
17+
* Permission is granted to anyone to use this software for any purpose,
18+
* including commercial applications, and to alter it and redistribute it
19+
* freely, subject to the following restrictions:
20+
*
21+
* 1. The origin of this software must not be misrepresented; you must not
22+
* claim that you wrote the original software. If you use this software
23+
* in a product, an acknowledgment in the product documentation would be
24+
* appreciated but is not required.
25+
* 2. Altered source versions must be plainly marked as such, and must not be
26+
* misrepresented as being the original software.
27+
* 3. This notice may not be removed or altered from any source distribution.
28+
*
29+
******************************************************************************/
30+
31+
#ifndef __SILICON_LABS_DMADRV_H__
32+
#define __SILICON_LABS_DMADRV_H__
33+
34+
#include "em_device.h"
35+
36+
#include "ecode.h"
37+
38+
#include "dmadrv_signals.h"
39+
40+
#if defined(LDMA_PRESENT) && (LDMA_COUNT == 1)
41+
#if (_SILICON_LABS_32B_SERIES > 2)
42+
#define EMDRV_DMADRV_LDMA_S3
43+
#else
44+
#define EMDRV_DMADRV_DMA_PRESENT
45+
#define EMDRV_DMADRV_LDMA
46+
#endif
47+
#else
48+
#error "No valid DMA engine defined."
49+
#endif
50+
51+
#include "dmadrv_config.h"
52+
#include "sl_code_classification.h"
53+
54+
#ifdef __cplusplus
55+
extern "C" {
56+
#endif
57+
58+
/***************************************************************************//**
59+
* @addtogroup dmadrv
60+
* @{
61+
******************************************************************************/
62+
63+
/***************************************************************************//**
64+
* @addtogroup dmadrv_error_codes Error Codes
65+
* @{
66+
******************************************************************************/
67+
68+
#define ECODE_EMDRV_DMADRV_OK (ECODE_OK) ///< A successful return value.
69+
#define ECODE_EMDRV_DMADRV_PARAM_ERROR (ECODE_EMDRV_DMADRV_BASE | 0x00000001) ///< An illegal input parameter.
70+
#define ECODE_EMDRV_DMADRV_NOT_INITIALIZED (ECODE_EMDRV_DMADRV_BASE | 0x00000002) ///< DMA is not initialized.
71+
#define ECODE_EMDRV_DMADRV_ALREADY_INITIALIZED (ECODE_EMDRV_DMADRV_BASE | 0x00000003) ///< DMA has already been initialized.
72+
#define ECODE_EMDRV_DMADRV_CHANNELS_EXHAUSTED (ECODE_EMDRV_DMADRV_BASE | 0x00000004) ///< No DMA channels available.
73+
#define ECODE_EMDRV_DMADRV_IN_USE (ECODE_EMDRV_DMADRV_BASE | 0x00000005) ///< DMA is in use.
74+
#define ECODE_EMDRV_DMADRV_ALREADY_FREED (ECODE_EMDRV_DMADRV_BASE | 0x00000006) ///< A DMA channel was free.
75+
#define ECODE_EMDRV_DMADRV_CH_NOT_ALLOCATED (ECODE_EMDRV_DMADRV_BASE | 0x00000007) ///< A channel is not reserved.
76+
77+
/** @} (end addtogroup error codes) */
78+
/***************************************************************************//**
79+
* @brief
80+
* DMADRV transfer completion callback function.
81+
*
82+
* @details
83+
* The callback function is called when a transfer is complete.
84+
*
85+
* @param[in] channel
86+
* The DMA channel number.
87+
*
88+
* @param[in] sequenceNo
89+
* The number of times the callback was called. Useful on long chains of
90+
* linked transfers or on endless ping-pong type transfers.
91+
*
92+
* @param[in] userParam
93+
* Optional user parameter supplied on DMA invocation.
94+
*
95+
* @return
96+
* When doing ping-pong transfers, return true to continue or false to
97+
* stop transfers.
98+
******************************************************************************/
99+
typedef bool (*DMADRV_Callback_t)(unsigned int channel,
100+
unsigned int sequenceNo,
101+
void *userParam);
102+
103+
Ecode_t DMADRV_AllocateChannel(unsigned int *channelId,
104+
void *capabilities);
105+
Ecode_t DMADRV_DeInit(void);
106+
Ecode_t DMADRV_FreeChannel(unsigned int channelId);
107+
Ecode_t DMADRV_Init(void);
108+
109+
Ecode_t DMADRV_MemoryPeripheral(unsigned int channelId,
110+
DMADRV_PeripheralSignal_t peripheralSignal,
111+
void *dst,
112+
void *src,
113+
bool srcInc,
114+
int len,
115+
DMADRV_DataSize_t size,
116+
DMADRV_Callback_t callback,
117+
void *cbUserParam);
118+
Ecode_t DMADRV_PeripheralMemory(unsigned int channelId,
119+
DMADRV_PeripheralSignal_t peripheralSignal,
120+
void *dst,
121+
void *src,
122+
bool dstInc,
123+
int len,
124+
DMADRV_DataSize_t size,
125+
DMADRV_Callback_t callback,
126+
void *cbUserParam);
127+
Ecode_t DMADRV_MemoryPeripheralPingPong(unsigned int channelId,
128+
DMADRV_PeripheralSignal_t peripheralSignal,
129+
void *dst,
130+
void *src0,
131+
void *src1,
132+
bool srcInc,
133+
int len,
134+
DMADRV_DataSize_t size,
135+
DMADRV_Callback_t callback,
136+
void *cbUserParam);
137+
Ecode_t DMADRV_PeripheralMemoryPingPong(unsigned int channelId,
138+
DMADRV_PeripheralSignal_t peripheralSignal,
139+
void *dst0,
140+
void *dst1,
141+
void *src,
142+
bool dstInc,
143+
int len,
144+
DMADRV_DataSize_t size,
145+
DMADRV_Callback_t callback,
146+
void *cbUserParam);
147+
148+
#if defined(EMDRV_DMADRV_LDMA)
149+
Ecode_t DMADRV_LdmaStartTransfer(int channelId,
150+
LDMA_TransferCfg_t *transfer,
151+
LDMA_Descriptor_t *descriptor,
152+
DMADRV_Callback_t callback,
153+
void *cbUserParam);
154+
#elif defined(EMDRV_DMADRV_LDMA_S3)
155+
Ecode_t DMADRV_LdmaStartTransfer(int channelId,
156+
sl_hal_ldma_transfer_config_t *transfer,
157+
sl_hal_ldma_descriptor_t *descriptor,
158+
DMADRV_Callback_t callback,
159+
void *cbUserParam);
160+
#endif
161+
162+
Ecode_t DMADRV_PauseTransfer(unsigned int channelId);
163+
Ecode_t DMADRV_ResumeTransfer(unsigned int channelId);
164+
SL_CODE_CLASSIFY(SL_CODE_COMPONENT_DMADRV, SL_CODE_CLASS_TIME_CRITICAL)
165+
Ecode_t DMADRV_StopTransfer(unsigned int channelId);
166+
SL_CODE_CLASSIFY(SL_CODE_COMPONENT_DMADRV, SL_CODE_CLASS_TIME_CRITICAL)
167+
Ecode_t DMADRV_TransferActive(unsigned int channelId,
168+
bool *active);
169+
SL_CODE_CLASSIFY(SL_CODE_COMPONENT_DMADRV, SL_CODE_CLASS_TIME_CRITICAL)
170+
Ecode_t DMADRV_TransferCompletePending(unsigned int channelId,
171+
bool *pending);
172+
SL_CODE_CLASSIFY(SL_CODE_COMPONENT_DMADRV, SL_CODE_CLASS_TIME_CRITICAL)
173+
Ecode_t DMADRV_TransferDone(unsigned int channelId,
174+
bool *done);
175+
SL_CODE_CLASSIFY(SL_CODE_COMPONENT_DMADRV, SL_CODE_CLASS_TIME_CRITICAL)
176+
Ecode_t DMADRV_TransferRemainingCount(unsigned int channelId,
177+
int *remaining);
178+
179+
/** @} (end addtogroup dmadrv) */
180+
181+
#ifdef __cplusplus
182+
}
183+
#endif
184+
185+
#endif /* __SILICON_LABS_DMADRV_H__ */

0 commit comments

Comments
 (0)