Firmware SDK
twr_dma.h
1 #ifndef _TWR_DMA_H
2 #define _TWR_DMA_H
3 
4 #include <twr_common.h>
5 
9 
11 
12 typedef enum
13 {
16 
19 
22 
25 
28 
31 
34 
36 
38 
39 typedef enum
40 {
43 
46 
49 
52 
55 
58 
61 
64 
67 
70 
73 
76 
79 
82 
85 
88 
90 
92 
93 typedef enum
94 {
97 
100 
102 
104 
105 typedef enum
106 {
109 
112 
114  TWR_DMA_SIZE_4 = 2
115 
117 
119 
120 typedef enum
121 {
124 
127 
129 
131 
132 typedef enum
133 {
136 
139 
142 
144 
146 
147 typedef enum
148 {
151 
154 
157 
160 
162 
164 
165 typedef struct
166 {
169 
172 
175 
178 
180  size_t length;
181 
184 
187 
190 
193 
195 
197 
198 void twr_dma_init(void);
199 
203 
205 
210 
211 void twr_dma_set_event_handler(twr_dma_channel_t channel, void (*event_handler)(twr_dma_channel_t, twr_dma_event_t, void *), void *event_param);
212 
215 
217 
220 
222 
223 size_t twr_dma_channel_get_length(twr_dma_channel_t channel);
224 
225 
227 
228 #endif // _TWR_DMA_H
void twr_dma_channel_config(twr_dma_channel_t channel, twr_dma_channel_config_t *config)
Configure DMA channel.
Definition: twr_dma.c:95
void twr_dma_channel_run(twr_dma_channel_t channel)
Start DMA channel.
Definition: twr_dma.c:179
twr_dma_request_t
DMA requests.
Definition: twr_dma.h:40
void twr_dma_set_event_handler(twr_dma_channel_t channel, void(*event_handler)(twr_dma_channel_t, twr_dma_event_t, void *), void *event_param)
Set callback function.
Definition: twr_dma.c:173
twr_dma_event_t
DMA channel event.
Definition: twr_dma.h:133
twr_dma_size_t
DMA channel data size.
Definition: twr_dma.h:106
twr_dma_direction_t
DMA channel directions.
Definition: twr_dma.h:94
void twr_dma_init(void)
Initialize DMA.
Definition: twr_dma.c:56
twr_dma_priority_t
DMA channel priority.
Definition: twr_dma.h:148
twr_dma_channel_t
DMA channels.
Definition: twr_dma.h:13
twr_dma_mode_t
DMA channel mode.
Definition: twr_dma.h:121
void twr_dma_channel_stop(twr_dma_channel_t channel)
Stop DMA channel.
Definition: twr_dma.c:184
@ TWR_DMA_REQUEST_3
DMA request 3.
Definition: twr_dma.h:51
@ TWR_DMA_REQUEST_1
DMA request 1.
Definition: twr_dma.h:45
@ TWR_DMA_REQUEST_4
DMA request 4.
Definition: twr_dma.h:54
@ TWR_DMA_REQUEST_11
DMA request 11.
Definition: twr_dma.h:75
@ TWR_DMA_REQUEST_0
DMA request 0.
Definition: twr_dma.h:42
@ TWR_DMA_REQUEST_10
DMA request 10.
Definition: twr_dma.h:72
@ TWR_DMA_REQUEST_5
DMA request 5.
Definition: twr_dma.h:57
@ TWR_DMA_REQUEST_9
DMA request 9.
Definition: twr_dma.h:69
@ TWR_DMA_REQUEST_6
DMA request 6.
Definition: twr_dma.h:60
@ TWR_DMA_REQUEST_14
DMA request 14.
Definition: twr_dma.h:84
@ TWR_DMA_REQUEST_2
DMA request 2.
Definition: twr_dma.h:48
@ TWR_DMA_REQUEST_13
DMA request 13.
Definition: twr_dma.h:81
@ TWR_DMA_REQUEST_15
DMA request 15.
Definition: twr_dma.h:87
@ TWR_DMA_REQUEST_8
DMA request 8.
Definition: twr_dma.h:66
@ TWR_DMA_REQUEST_12
DMA request 12.
Definition: twr_dma.h:78
@ TWR_DMA_REQUEST_7
DMA request 7.
Definition: twr_dma.h:63
@ TWR_DMA_EVENT_DONE
DMA channel event done.
Definition: twr_dma.h:141
@ TWR_DMA_EVENT_HALF_DONE
DMA channel event half done.
Definition: twr_dma.h:138
@ TWR_DMA_EVENT_ERROR
DMA channel event error.
Definition: twr_dma.h:135
@ TWR_DMA_SIZE_2
DMA channel data size 2B.
Definition: twr_dma.h:111
@ TWR_DMA_SIZE_4
DMA channel data size 4B.
Definition: twr_dma.h:114
@ TWR_DMA_SIZE_1
DMA channel data size 1B.
Definition: twr_dma.h:108
@ TWR_DMA_DIRECTION_TO_PERIPHERAL
DMA channel direction from RAM to peripheral.
Definition: twr_dma.h:96
@ TWR_DMA_DIRECTION_TO_RAM
DMA channel direction from peripheral to RAM.
Definition: twr_dma.h:99
@ TWR_DMA_PRIORITY_MEDIUM
DMA channel priority is medium.
Definition: twr_dma.h:153
@ TWR_DMA_PRIORITY_VERY_HIGH
DMA channel priority is very high.
Definition: twr_dma.h:159
@ TWR_DMA_PRIORITY_HIGH
DMA channel priority is high.
Definition: twr_dma.h:156
@ TWR_DMA_PRIORITY_LOW
DMA channel priority is low.
Definition: twr_dma.h:150
@ TWR_DMA_CHANNEL_7
DMA channel 7.
Definition: twr_dma.h:33
@ TWR_DMA_CHANNEL_6
DMA channel 6.
Definition: twr_dma.h:30
@ TWR_DMA_CHANNEL_1
DMA channel 1.
Definition: twr_dma.h:15
@ TWR_DMA_CHANNEL_5
DMA channel 5, used for SPI.
Definition: twr_dma.h:27
@ TWR_DMA_CHANNEL_2
DMA channel 2.
Definition: twr_dma.h:18
@ TWR_DMA_CHANNEL_3
DMA channel 3.
Definition: twr_dma.h:21
@ TWR_DMA_CHANNEL_4
DMA channel 4.
Definition: twr_dma.h:24
@ TWR_DMA_MODE_CIRCULAR
DMA channel mode circular.
Definition: twr_dma.h:126
@ TWR_DMA_MODE_STANDARD
DMA channel mode standard.
Definition: twr_dma.h:123
DMA channel configuration.
Definition: twr_dma.h:166
twr_dma_mode_t mode
DMA channel mode.
Definition: twr_dma.h:183
twr_dma_direction_t direction
DMA channel direction.
Definition: twr_dma.h:171
twr_dma_request_t request
DMA channel request.
Definition: twr_dma.h:168
void * address_peripheral
Peripheral address.
Definition: twr_dma.h:189
twr_dma_size_t data_size_memory
DMA channel memory data size.
Definition: twr_dma.h:174
size_t length
DMA channel data length.
Definition: twr_dma.h:180
void * address_memory
RAM memory address.
Definition: twr_dma.h:186
twr_dma_size_t data_size_peripheral
DMA channel peripheral data size.
Definition: twr_dma.h:177
twr_dma_priority_t priority
DMA channel priority.
Definition: twr_dma.h:192