TMPM4KxA Group Peripheral Driver User Manual  V1.0.4.0
txz_dma_include.h
Go to the documentation of this file.
1 
13 /*------------------------------------------------------------------------------*/
14 /* Define to prevent recursive inclusion */
15 /*------------------------------------------------------------------------------*/
16 #ifndef __DMA_INCLUDE_H
17 #define __DMA_INCLUDE_H
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 /*------------------------------------------------------------------------------*/
24 /* Includes */
25 /*------------------------------------------------------------------------------*/
26 #include "txz_driver_def.h"
27 
37 /*------------------------------------------------------------------------------*/
38 /* Macro Function */
39 /*------------------------------------------------------------------------------*/
45 /* no define */
46  /* End of group DMA_Private_macro */
50 
51 
52 /*------------------------------------------------------------------------------*/
53 /* Macro Definition */
54 /*------------------------------------------------------------------------------*/
65 #define DMA_NULL ((void *)0)
66  /* End of group DMA_NullPointer */
69 
75 #define DMA_PARAM_OK ((int32_t)1)
76 #define DMA_PARAM_NG ((int32_t)0) /* End of group DMA_ParameterResult */
80 
91 /* master_enable */
92 #define CFG_MASTER_DISABLE ((uint32_t)0x00000000)
93 #define CFG_MASTER_ENABLE ((uint32_t)0x00000001) /* End of group DMAxCfg */
97 
108 /* ctrl_base_ptr */
109 #define CTRLBASEPTR_MASK ((uint32_t)0xFFFFFC00) /* End of group DMAxCtrlBasePtr */
113 
154 /* chnl_req_mask_set */
155 #define CHNLREQMASKSET_ALL_MASK ((uint32_t)0xFFFFFFFF) /* End of group DMAxChnlReqMaskSet */
159 
200 /* chnl_enable_clr */
201 #define CHNLENABLECLR_ALL_DISABLE ((uint32_t)0xFFFFFFFF) /* End of group DMAxChnlEnableClr */
205 
216 /* err_clr */
217 #define ERRCLR_MASK_BUS ((uint32_t)0x00000001)
218 #define ERRCLR_MASK_BUS_R_NON ((uint32_t)0x00000000)
219 #define ERRCLR_MASK_BUS_R_ERR ((uint32_t)0x00000001)
220 #define ERRCLR_MASK_BUS_W_CLR ((uint32_t)0x00000001) /* End of group DMAxErrClr */
224 
242 #define CH_CFG_MASK_DST_INC ((uint32_t)0xC0000000)
243 #define CH_CFG_MASK_DST_SIZE ((uint32_t)0x30000000)
244 #define CH_CFG_MASK_SRC_INC ((uint32_t)0x0C000000)
245 #define CH_CFG_MASK_SRC_SIZE ((uint32_t)0x03000000)
246 #define CH_CFG_MASK_TRANS_NUM ((uint32_t)0x00003FF0)
247 #define CH_CFG_MASK_CYCLE_CTRL ((uint32_t)0x00000007) /* End of group ChannelCfg */
251  /* End of group DMA_Private_define */
255 
256 
257 /*------------------------------------------------------------------------------*/
258 /* Enumerated Type Definition */
259 /*------------------------------------------------------------------------------*/
265 /* no define */
266  /* End of group DMA_Private_define */
270 
271 
272 /*------------------------------------------------------------------------------*/
273 /* Structure Definition */
274 /*------------------------------------------------------------------------------*/
280 /*----------------------------------*/
284 /*----------------------------------*/
285 typedef struct
286 {
287  uint32_t srcEnd;
288  uint32_t dstEnd;
289  uint32_t control;
290  uint32_t reserved;
292  /* End of group DMA_Private_typedef */
296 
297 
298 /*------------------------------------------------------------------------------*/
299 /* Inline Functions */
300 /*------------------------------------------------------------------------------*/
305 #ifdef DEBUG
306  __STATIC_INLINE int32_t check_param_channel(uint32_t numMax, uint32_t ch);
307 #endif
308 __STATIC_INLINE uint32_t get_primary_address(uint32_t base, uint32_t ch);
309 __STATIC_INLINE uint32_t convert_transfer_num_to_reg(uint32_t num);
310 __STATIC_INLINE uint32_t convert_ch_to_reg(uint32_t ch);
311 __STATIC_INLINE uint32_t get_end_address(uint32_t start, uint32_t inc, uint32_t size, uint32_t num);
312 #ifdef DEBUG
313 /*--------------------------------------------------*/
322 /*--------------------------------------------------*/
323 __STATIC_INLINE int32_t check_param_channel(uint32_t numMax, uint32_t ch)
324 {
325  int32_t result = DMA_PARAM_NG;
326 
327  if (ch < numMax)
328  {
329  result = DMA_PARAM_OK;
330  }
331 
332  return (result);
333 }
334 #endif
335 
336 /*--------------------------------------------------*/
344 /*--------------------------------------------------*/
345 __STATIC_INLINE uint32_t get_primary_address(uint32_t base, uint32_t ch)
346 {
347  uint32_t result = base + (uint32_t)(ch * sizeof(control_data_t));
348 
349  return (result);
350 }
351 
352 /*--------------------------------------------------*/
359 /*--------------------------------------------------*/
360 __STATIC_INLINE uint32_t convert_transfer_num_to_reg(uint32_t num)
361 {
362  uint32_t result = (uint32_t)((uint32_t)(num - 1) << 4);
363 
364  return (result);
365 }
366 
367 /*--------------------------------------------------*/
374 /*--------------------------------------------------*/
375 __STATIC_INLINE uint32_t convert_ch_to_reg(uint32_t ch)
376 {
377  uint32_t result = (uint32_t)((uint32_t)1 << (uint8_t)ch);
378 
379  return (result);
380 }
381 
382 /*--------------------------------------------------*/
392 /*--------------------------------------------------*/
393 __STATIC_INLINE uint32_t get_end_address(uint32_t start, uint32_t inc, uint32_t size, uint32_t num)
394 {
395  uint32_t result = (uint32_t)(start + (uint32_t)((uint32_t)(num - 1) * inc));
396 
397  return (result);
398 }
399  /* End of group DMA_Private_functions */
403  /* End of group DMA */
407  /* End of group Periph_Driver */
411 
412 #ifdef __cplusplus
413 }
414 #endif /* __cplusplus */
415 #endif /* __DMA_INCLUDE_H */
416 
417 
__STATIC_INLINE uint32_t get_end_address(uint32_t start, uint32_t inc, uint32_t size, uint32_t num)
Get Tansfer End Address.
Definition: txz_dma_include.h:393
__STATIC_INLINE uint32_t convert_ch_to_reg(uint32_t ch)
Convert channel to register.
Definition: txz_dma_include.h:375
Control data structure definenition.
Definition: txz_dma_include.h:285
uint32_t control
Definition: txz_dma_include.h:289
__STATIC_INLINE int32_t check_param_channel(uint32_t numMax, uint32_t ch)
Check the channel no.
Definition: txz_dma_include.h:323
__STATIC_INLINE uint32_t convert_transfer_num_to_reg(uint32_t num)
Convert transfer num to register.
Definition: txz_dma_include.h:360
uint32_t srcEnd
Definition: txz_dma_include.h:287
All common macro and definition for TXZ peripheral drivers.
uint32_t dstEnd
Definition: txz_dma_include.h:288
__STATIC_INLINE uint32_t get_primary_address(uint32_t base, uint32_t ch)
Get primary start address.
Definition: txz_dma_include.h:345
uint32_t reserved
Definition: txz_dma_include.h:290