d_dma.h
Go to the documentation of this file.
1 /*
2 MIT LICENSE
3 
4 Copyright 2014-2019 Inertial Sense, Inc. - http://inertialsense.com
5 
6 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions :
7 
8 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
9 
10 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT, IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11 */
12 
13 #ifndef _D_DMA_H_
14 #define _D_DMA_H_
15 #ifdef __cplusplus
16 extern "C" {
17 #endif // __cplusplus
18 
19 // includes
20 #include <xdmac.h>
21 
22 #define DBGPIO_START(x)
23 #define DBGPIO_END(x)
24 
25 // Memcpy then clean Data Cache to memory for before DMA starts
26 #define MEMCPY_DCACHE_CLEAN(dst, src, size) \
27 memcpy((void*)(dst), (const void*)(src), (size)); \
28 DBGPIO_START(DBG_TX_DCACHE_CLEAN_PIN); \
29 SCB_CLEAN_DCACHE_BY_ADDR_32BYTE_ALIGNED((dst), (size)); \
30 DBGPIO_END(DBG_TX_DCACHE_CLEAN_PIN);
31 
32 // Memcpy then clear Data Cache to memory for before DMA starts
33 #define MEMCPY_DCACHE_CLEAN_INVALIDATE(dst, src, size) \
34 memcpy((void*)(dst), (const void*)(src), (size)); \
35 DBGPIO_START(DBG_TX_DCACHE_CLEAN_PIN); \
36 SCB_CLEANINVALIDATE_DCACHE_BY_ADDR_32BYTE_ALIGNED((dst), (size)); \
37 DBGPIO_END(DBG_TX_DCACHE_CLEAN_PIN);
38 
39 // Ensure data cache has valid Rx data prior to memcpy
40 #define DCACHE_CLEAN_INVALIDATE_MEMCPY(dst, src, size) \
41 DBGPIO_START( DBG_RX_DCACHE_CLEAN_PIN ); \
42 SCB_CLEANINVALIDATE_DCACHE_BY_ADDR_32BYTE_ALIGNED((src), (size)); \
43 DBGPIO_END( DBG_RX_DCACHE_CLEAN_PIN ); \
44 memcpy((void*)(dst), (const void*)(src), (size));
45 
46 // defines
47 //#define ENABLE_DMA_INTERRUPTS
48 #ifdef ENABLE_DMA_INTERRUPTS
49 #define DMA_INT_ENABLE(_ch_) \
50  xdmac_enable_interrupt(XDMAC, _ch_); \
51  xdmac_channel_enable_interrupt(XDMAC, _ch_, XDMAC_CIE_BIE);
52 #define DMA_INT_DISABLE(_ch_) \
53  xdmac_disable_interrupt(XDMAC, _ch_); \
54  xdmac_channel_disable_interrupt(XDMAC, _ch_, XDMAC_CIE_BIE);
55 #else
56 #define DMA_INT_ENABLE(_ch_)
57 #define DMA_INT_DISABLE(_ch_)
58 #endif // ENABLE_DMA_INTERRUPTS
59 
60 // XDMAC channel HW Interface number for peripherals; refer to datasheet
61 #define XDMAC_PERID_SPI0_TX 1
62 #define XDMAC_PERID_SPI0_RX 2
63 #define XDMAC_PERID_SPI1_TX 3
64 #define XDMAC_PERID_SPI1_RX 4
65 #define XDMAC_PERID_USART0_TX 7
66 #define XDMAC_PERID_USART0_RX 8
67 #define XDMAC_PERID_USART1_TX 9
68 #define XDMAC_PERID_USART1_RX 10
69 #define XDMAC_PERID_USART2_TX 11
70 #define XDMAC_PERID_USART2_RX 12
71 #define XDMAC_PERID_UART0_TX 20
72 #define XDMAC_PERID_UART0_RX 21
73 #define XDMAC_PERID_UART1_TX 22
74 #define XDMAC_PERID_UART1_RX 23
75 #define XDMAC_PERID_UART2_TX 24
76 #define XDMAC_PERID_UART2_RX 25
77 #define XDMAC_PERID_UART3_TX 26
78 #define XDMAC_PERID_UART3_RX 27
79 #define XDMAC_PERID_UART4_TX 28
80 #define XDMAC_PERID_UART4_RX 29
81 
82 // cache specific
83 #define ALIGN_32B_MASK 0xffffffe0
84 #define IS_32B_ALIGNED(_addr_) !(((uint32_t)(_addr_)) & 0x0000001f)
85 #define ALIGN_32B(_bytes_) ((_bytes_) + (sizeof(uint32_t) - ((_bytes_) % sizeof(uint32_t))))
86 
87 // enums
88 enum
89 {
90  // uINS specific
112  // add more channels before this line
115 };
116 
117 // structs
118 typedef struct
119 {
120  uint32_t len : 24;
121  uint32_t sa;
122  uint32_t da;
124 
125 typedef struct
126 {
127  uint32_t chan;
131 
132 // prototypes
133 void dma_init(void);
134 
136 void dma_chan_disable(uint32_t ch);
137 int dma_chan_enable(uint32_t ch);
138 int dma_transfer_is_complete(uint32_t ch);
139 
140 #ifdef __cplusplus
141 }
142 #endif // __cplusplus
143 #endif // _D_DMA_H_
uint32_t da
Definition: d_dma.h:122
uint32_t len
Definition: d_dma.h:120
void dma_init(void)
void dma_chan_disable(uint32_t ch)
int dma_transfer_is_complete(uint32_t ch)
int dma_chan_enable(uint32_t ch)
uint32_t sa
Definition: d_dma.h:121
Structure for storing parameters for DMA view1 that can be performed by the DMA Master transfer...
int dma_configure(dma_channel_config_t *hd, lld_view1 *lld)
xdmac_channel_config_t xdmac
Definition: d_dma.h:128
uint32_t chan
Definition: d_dma.h:127
dma_transfer_info_t next
Definition: d_dma.h:129


inertial_sense_ros
Author(s):
autogenerated on Sun Feb 28 2021 03:17:57