TMPM4KxA Group Peripheral Driver User Manual  V1.0.4.0
txz_dma.h
Go to the documentation of this file.
1 
13 /*------------------------------------------------------------------------------*/
14 /* Define to prevent recursive inclusion */
15 /*------------------------------------------------------------------------------*/
16 #ifndef __DMA_H
17 #define __DMA_H
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 /*------------------------------------------------------------------------------*/
24 /* Includes */
25 /*------------------------------------------------------------------------------*/
26 #include "txz_driver_def.h"
27 
38 /*------------------------------------------------------------------------------*/
39 /* Macro Function */
40 /*------------------------------------------------------------------------------*/
46 /* no define */
47  /* End of group DMA_Exported_macro */
51 
52 
53 /*------------------------------------------------------------------------------*/
54 /* Macro Definition */
55 /*------------------------------------------------------------------------------*/
66 #define DMA_CH_NUM ((uint32_t)32) /* End of group DMA_ChannelNum */
70 
76 #define DMA_DST_INC_1BYTE ((uint32_t)0x00000000)
77 #define DMA_DST_INC_2BYTE ((uint32_t)0x40000000)
78 #define DMA_DST_INC_4BYTE ((uint32_t)0x80000000)
79 #define DMA_DST_INC_NON ((uint32_t)0xC0000000) /* End of group DMA_DestinationInc */
83 
89 #define DMA_DST_SIZE_1BYTE ((uint32_t)0x00000000)
90 #define DMA_DST_SIZE_2BYTE ((uint32_t)0x10000000)
91 #define DMA_DST_SIZE_4BYTE ((uint32_t)0x20000000) /* End of group DMA_DestinationSize */
95 
101 #define DMA_SRC_INC_1BYTE ((uint32_t)0x00000000)
102 #define DMA_SRC_INC_2BYTE ((uint32_t)0x04000000)
103 #define DMA_SRC_INC_4BYTE ((uint32_t)0x08000000)
104 #define DMA_SRC_INC_NON ((uint32_t)0x0C000000) /* End of group DMA_SourceInc */
108 
114 #define DMA_SRC_SIZE_1BYTE ((uint32_t)0x00000000)
115 #define DMA_SRC_SIZE_2BYTE ((uint32_t)0x01000000)
116 #define DMA_SRC_SIZE_4BYTE ((uint32_t)0x02000000) /* End of group DMA_SourceSize */
120 
126 #define DMA_ARBITRATION_1 ((uint32_t)0x00000000)
127 #define DMA_ARBITRATION_2 ((uint32_t)0x00004000)
128 #define DMA_ARBITRATION_4 ((uint32_t)0x00008000)
129 #define DMA_ARBITRATION_8 ((uint32_t)0x0000C000)
130 #define DMA_ARBITRATION_16 ((uint32_t)0x00010000)
131 #define DMA_ARBITRATION_32 ((uint32_t)0x00014000)
132 #define DMA_ARBITRATION_64 ((uint32_t)0x00018000)
133 #define DMA_ARBITRATION_128 ((uint32_t)0x0001C000)
134 #define DMA_ARBITRATION_256 ((uint32_t)0x00020000)
135 #define DMA_ARBITRATION_512 ((uint32_t)0x00024000)
136 #define DMA_ARBITRATION_NON ((uint32_t)0x0003C000) /* End of group DMA_Arbitration */
140 
147 #define DMA_TRANS_NUM_RANGE_MIN ((uint32_t)0x00000001)
148 #define DMA_TRANS_NUM_RANGE_MAX ((uint32_t)0x00000400) /* End of group DMA_TransferNumRange */
152 
158 #define DMA_BURST_UNUSE ((uint32_t)0x00000000)
159 #define DMA_BURST_USE ((uint32_t)0x00000008) /* End of group DMA_Burst */
163 
169 #define DMA_CYCLE_MODE_DISABLE ((uint32_t)0x00000000)
170 #define DMA_CYCLE_MODE_BASE ((uint32_t)0x00000001)
171 #define DMA_CYCLE_MODE_CNT_BASE ((uint32_t)0x00000002)
172 #define DMA_CYCLE_MODE_REPEAT ((uint32_t)0x00000003)
173 #define DMA_CYCLE_MODE_CNT_CHAIN_1 ((uint32_t)0x00000004)
174 #define DMA_CYCLE_MODE_CNT_CHAIN_2 ((uint32_t)0x00000005)
175 #define DMA_CYCLE_MODE_CHAIN_1 ((uint32_t)0x00000006)
176 #define DMA_CYCLE_MODE_CHAIN_2 ((uint32_t)0x00000007) /* End of group DMA_CycleControl */
180 
186 #define DMA_PRIORITY_NORMAL ((uint32_t)0x00000000)
187 #define DMA_PRIORITY_HIGH ((uint32_t)0x00000001) /* End of group DMA_Priority */
191  /* End of group DMA_Exported_define */
195 
196 
197 /*------------------------------------------------------------------------------*/
198 /* Enumerated Type Definition */
199 /*------------------------------------------------------------------------------*/
205 /* no define */
206  /* End of group DMA_Exported_define */
210 
211 
212 /*------------------------------------------------------------------------------*/
213 /* Structure Definition */
214 /*------------------------------------------------------------------------------*/
220 /*----------------------------------*/
234 /*----------------------------------*/
235 typedef struct
236 {
237  uint32_t baseAdd;
239 
240 /*----------------------------------*/
245 /*----------------------------------*/
246 typedef struct
247 {
248  uint32_t dstInc;
250  uint32_t dstSize;
252  uint32_t srcInc;
254  uint32_t srcSize;
256  uint32_t arbitNum;
258  uint32_t burst;
260 } dma_ch_cfg_t;
261 
262 /*----------------------------------*/
266 /*----------------------------------*/
267 typedef struct
268 {
269  void (*handler)(uint32_t id, TXZ_Result result);
270  uint32_t id;
271  uint32_t priority;
276 
277 /*----------------------------------*/
282 /*----------------------------------*/
283 typedef struct
284 {
285  uint32_t source;
286  uint32_t destination;
287  uint32_t num;
289 } dma_cfg_t;
290 
291 /*----------------------------------*/
295 /*----------------------------------*/
296 typedef struct dma_handle
297 {
298  TSB_DMA_TypeDef *p_instance;
300  dma_ch_setting_t ch[DMA_CH_NUM];
301 } dma_t;
302  /* End of group DMA_Exported_typedef */
306 
307 /*------------------------------------------------------------------------------*/
308 /* Functions */
309 /*------------------------------------------------------------------------------*/
314 TXZ_Result dma_init(dma_t *p_obj);
315 TXZ_Result dma_deinit(dma_t *p_obj);
316 TXZ_Result dma_get_error(dma_t *p_obj, uint32_t *p_err);
317 TXZ_Result dma_clear_error(dma_t *p_obj);
318 void dma_error_irq_handler(dma_t *p_obj);
319 void dma_irq_handler(dma_t *p_obj, uint32_t ch);
320 TXZ_Result dma_ch_init(dma_t *p_obj, uint32_t ch);
321 TXZ_Result dma_ch_deinit(dma_t *p_obj, uint32_t ch);
322 TXZ_Result dma_startIt(dma_t *p_obj, uint32_t ch, dma_cfg_t *p_cfg);
323 TXZ_Result dma_stopIt(dma_t *p_obj, uint32_t ch); /* End of group DMA_Exported_functions */
327  /* End of group DMA */
331  /* End of group Periph_Driver */
335 
336 #ifdef __cplusplus
337 }
338 #endif /* __cplusplus */
339 #endif /* __DMA_H */
340 
341 
uint32_t arbitNum
Definition: txz_dma.h:256
void dma_error_irq_handler(dma_t *p_obj)
Error IRQ handler.
Definition: txz_dma.c:566
Initial setting structure definenition.
Definition: txz_dma.h:235
uint32_t burst
Definition: txz_dma.h:258
TXZ_Result dma_deinit(dma_t *p_obj)
Release the DMA object.
Definition: txz_dma.c:486
uint32_t dstSize
Definition: txz_dma.h:250
uint32_t dstInc
Definition: txz_dma.h:248
void dma_irq_handler(dma_t *p_obj, uint32_t ch)
IRQ handler.
Definition: txz_dma.c:523
TXZ_Result dma_get_error(dma_t *p_obj, uint32_t *p_err)
Get Error.
Definition: txz_dma.c:609
TSB_DMA_TypeDef * p_instance
Definition: txz_dma.h:298
uint32_t destination
Definition: txz_dma.h:286
dma_ch_setting_t ch[DMA_CH_NUM]
Definition: txz_dma.h:300
Channel configration structure definenition.
Definition: txz_dma.h:283
All common macro and definition for TXZ peripheral drivers.
DMA handle structure definenition.
Definition: txz_dma.h:296
uint32_t baseAdd
Definition: txz_dma.h:237
TXZ_Result dma_ch_init(dma_t *p_obj, uint32_t ch)
Initialize the DMA channel object.
Definition: txz_dma.c:676
TXZ_Result dma_startIt(dma_t *p_obj, uint32_t ch, dma_cfg_t *p_cfg)
Start DMA mode.
Definition: txz_dma.c:779
uint32_t priority
Definition: txz_dma.h:271
uint32_t srcSize
Definition: txz_dma.h:254
TXZ_Result dma_ch_deinit(dma_t *p_obj, uint32_t ch)
Release the DMA channel object.
Definition: txz_dma.c:732
uint32_t num
Definition: txz_dma.h:287
TXZ_Result dma_clear_error(dma_t *p_obj)
Clear Error.
Definition: txz_dma.c:641
uint32_t id
Definition: txz_dma.h:270
Channel setting structure definenition.
Definition: txz_dma.h:267
dma_initial_setting_t init
Definition: txz_dma.h:299
uint32_t source
Definition: txz_dma.h:285
uint32_t srcInc
Definition: txz_dma.h:252
struct dma_handle dma_t
DMA handle structure definenition.
TXZ_Result dma_init(dma_t *p_obj)
Initialize the DMA object.
Definition: txz_dma.c:449
TXZ_Result dma_stopIt(dma_t *p_obj, uint32_t ch)
Stop DMA mode.
Definition: txz_dma.c:943
Channel config setting structure definenition.
Definition: txz_dma.h:246
dma_ch_cfg_t cfg
Definition: txz_dma.h:273