blob: 3bd6dc9662de9bf48b31d55369460833863bcebc [file] [log] [blame]
Kévin Redonc94e0fc2019-03-07 19:15:29 +01001/**
2 * \file
3 *
4 * \brief Memory with DMA functionality declaration.
5 *
6 * Copyright (c) 2016-2018 Microchip Technology Inc. and its subsidiaries.
7 *
8 * \asf_license_start
9 *
10 * \page License
11 *
12 * Subject to your compliance with these terms, you may use Microchip
13 * software and any derivatives exclusively with Microchip products.
14 * It is your responsibility to comply with third party license terms applicable
15 * to your use of third party software (including open source software) that
16 * may accompany Microchip software.
17 *
18 * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,
19 * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
20 * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
21 * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
22 * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
23 * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
24 * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
25 * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT
26 * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
27 * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
28 * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
29 *
30 * \asf_license_stop
31 *
32 */
33
34#ifndef DMA_MEMORY_H_INCLUDED
35#define DMA_MEMORY_H_INCLUDED
36
37#include <hpl_dma.h>
38
39#ifdef __cplusplus
40extern "C" {
41#endif
42
43/**
44 * \addtogroup dma_memory
45 *
46 * \section dma_rev Revision History
47 * - v0.0.0.1 Initial Commit
48 *
49 *@{
50 */
51
52/**
53 * \brief Memory with DMA descriptor
54 *
55 * The Memory with DMA descriptor forward declaration.
56 */
57struct dma_memory_descriptor;
58
59/**
60 * \brief memory with dma callback type
61 */
62typedef void (*dma_memory_cb_t)(void);
63
64/**
65 * \brief Memory with DMA callback types
66 */
67enum dma_memory_callback_type { DMA_MEMORY_COMPLETE_CB, DMA_MEMORY_ERROR_CB };
68
69/**
70 * \brief Memory with DMA callbacks
71 */
72struct dma_memory_callbacks {
73 dma_memory_cb_t complete;
74 dma_memory_cb_t error;
75};
76
77/**
78 * \brief Memory with DMA descriptor
79 */
80struct dma_memory_descriptor {
81 struct _dma_resource * resource;
82 struct dma_memory_callbacks memory_cb;
83};
84
85/**
86 * \brief Initialize Memory with DMA
87 *
88 * \return Initialization status.
89 */
90int32_t dma_memory_init(void);
91
92/**
93 * \brief Register Memory with DMA callback
94 *
95 * \param[in] type Callback type
96 * \param[in] cb A callback function, passing NULL de-registers callback
97 *
98 * \return The status of callback assignment.
99 * \retval ERR_INVALID_ARG Passed parameters were invalid
100 * \retval ERR_NONE A callback is registered successfully
101 */
102int32_t dma_memory_register_callback(const enum dma_memory_callback_type type, dma_memory_cb_t cb);
103
104/**
105 * \brief dma memory copy
106 *
107 * \param[in] dst The pointer to destination address for transfer
108 * \param[in] src The pointer to source address for transfer
109 * \param[in] size The transfer size
110 *
111 * \return the status of operation`
112 */
113int32_t dma_memcpy(void *dst, void *src, uint32_t size);
114
115/**
116 * \brief dma memory set
117 *
118 * \param[in] dst The pointer to address to fill
119 * \param[in] ch The value to be filled
120 * \param[in] size Number of bytes to set to the value
121 *
122 * \return the status of operation
123 */
124int32_t dma_memset(void *dst, int32_t ch, uint32_t size);
125
126/**@}*/
127
128#ifdef __cplusplus
129}
130#endif
131
132#endif /* DMA_MEMORY_H_INCLUDED */