Nano100AN Series BSP  V3.02.002
The Board Support Package for Nano100AN Series
pdma.h
Go to the documentation of this file.
1 /**************************************************************************/
12 #ifndef __PDMA_H__
13 #define __PDMA_H__
14 
15 #ifdef __cplusplus
16 extern "C"
17 {
18 #endif
19 
20 
33 /*---------------------------------------------------------------------------------------------------------*/
34 /* Data Width Constant Definitions */
35 /*---------------------------------------------------------------------------------------------------------*/
36 #define PDMA_WIDTH_8 0x00080000UL
37 #define PDMA_WIDTH_16 0x00100000UL
38 #define PDMA_WIDTH_32 0x00000000UL
40 /*---------------------------------------------------------------------------------------------------------*/
41 /* Address Attribute Constant Definitions */
42 /*---------------------------------------------------------------------------------------------------------*/
43 #define PDMA_SAR_INC 0x00000000UL
44 #define PDMA_SAR_FIX 0x00000020UL
45 #define PDMA_SAR_WRA 0x00000030UL
46 #define PDMA_DAR_INC 0x00000000UL
47 #define PDMA_DAR_FIX 0x00000080UL
48 #define PDMA_DAR_WRA 0x000000C0UL
50 /*---------------------------------------------------------------------------------------------------------*/
51 /* Peripheral Transfer Mode Constant Definitions */
52 /*---------------------------------------------------------------------------------------------------------*/
53 #define PDMA_SPI0_TX 0x00000000UL
54 #define PDMA_SPI1_TX 0x00000001UL
55 #define PDMA_UART0_TX 0x00000002UL
56 #define PDMA_UART1_TX 0x00000003UL
57 #define PDMA_USB_TX 0x00000004UL
58 #define PDMA_I2S_TX 0x00000005UL
59 #define PDMA_DAC0_TX 0x00000006UL
60 #define PDMA_DAC1_TX 0x00000007UL
61 #define PDMA_SPI2_TX 0x00000008UL
62 #define PDMA_TMR0 0x00000009UL
63 #define PDMA_TMR1 0x0000000AUL
64 #define PDMA_TMR2 0x0000000BUL
65 #define PDMA_TMR3 0x0000000CUL
67 #define PDMA_SPI0_RX 0x00000010UL
68 #define PDMA_SPI1_RX 0x00000011UL
69 #define PDMA_UART0_RX 0x00000012UL
70 #define PDMA_UART1_RX 0x00000013UL
71 #define PDMA_USB_RX 0x00000014UL
72 #define PDMA_I2S_RX 0x00000015UL
73 #define PDMA_ADC 0x00000016UL
74 #define PDMA_SPI2_RX 0x00000018UL
75 #define PDMA_PWM0_CH0 0x00000019UL
76 #define PDMA_PWM0_CH2 0x0000001AUL
77 #define PDMA_PWM1_CH0 0x0000001BUL
78 #define PDMA_PWM1_CH2 0x0000001CUL
79 #define PDMA_MEM 0x0000001FUL
83  /* end of group NANO100_PDMA_EXPORTED_CONSTANTS */
84 
99 #define PDMA_GET_INT_STATUS() ((uint32_t)(PDMAGCR->GCRISR))
100 
111 #define PDMA_GET_CH_INT_STS(u32Ch) (*((__IO uint32_t *)((uint32_t)&PDMA1->ISR + (uint32_t)((u32Ch-1)*0x100))))
112 
124 #define PDMA_CLR_CH_INT_FLAG(u32Ch, u32Mask) (*((__IO uint32_t *)((uint32_t)&PDMA1->ISR + (uint32_t)((u32Ch-1)*0x100))) = (u32Mask))
125 
136 #define PDMA_IS_CH_BUSY(u32Ch) ((*((__IO uint32_t *)((uint32_t)&PDMA1->CSR +(uint32_t)((u32Ch-1)*0x100))) & PDMA_CSR_TRIG_EN_Msk)? 1 : 0)
137 
149 #define PDMA_SET_SRC_ADDR(u32Ch, u32Addr) (*((__IO uint32_t *)((uint32_t)&PDMA1->SAR + (uint32_t)((u32Ch-1)*0x100))) = (u32Addr))
150 
162 #define PDMA_SET_DST_ADDR(u32Ch, u32Addr) (*((__IO uint32_t *)((uint32_t)&PDMA1->DAR + (uint32_t)((u32Ch-1)*0x100))) = (u32Addr))
163 
175 #define PDMA_SET_TRANS_CNT(u32Ch, u32Count) { \
176  if (((uint32_t)*((__IO uint32_t *)((uint32_t)&PDMA1->CSR + (uint32_t)((u32Ch-1)*0x100))) & PDMA_CSR_APB_TWS_Msk) == PDMA_WIDTH_32) \
177  *((__IO uint32_t *)((uint32_t)&PDMA1->BCR + (uint32_t)((u32Ch-1)*0x100))) = ((u32Count) << 2); \
178  else if (((uint32_t)*((__IO uint32_t *)((uint32_t)&PDMA1->CSR + (uint32_t)((u32Ch-1)*0x100))) & PDMA_CSR_APB_TWS_Msk) == PDMA_WIDTH_8) \
179  *((__IO uint32_t *)((uint32_t)&PDMA1->BCR + (uint32_t)((u32Ch-1)*0x100))) = (u32Count); \
180  else if (((uint32_t)*((__IO uint32_t *)((uint32_t)&PDMA1->CSR + (uint32_t)((u32Ch-1)*0x100))) & PDMA_CSR_APB_TWS_Msk) == PDMA_WIDTH_16) \
181  *((__IO uint32_t *)((uint32_t)&PDMA1->BCR + (uint32_t)((u32Ch-1)*0x100))) = ((u32Count) << 1); \
182 }
183 
194 #define PDMA_STOP(u32Ch) (*((__IO uint32_t *)((uint32_t)&PDMA1->CSR + (uint32_t)((u32Ch-1)*0x100))) &= ~PDMA_CSR_PDMACEN_Msk)
195 
196 void PDMA_Open(uint32_t u32Mask);
197 void PDMA_Close(void);
198 void PDMA_SetTransferCnt(uint32_t u32Ch, uint32_t u32Width, uint32_t u32TransCount);
199 void PDMA_SetTransferAddr(uint32_t u32Ch, uint32_t u32SrcAddr, uint32_t u32SrcCtrl, uint32_t u32DstAddr, uint32_t u32DstCtrl);
200 void PDMA_SetTransferMode(uint32_t u32Ch, uint32_t u32Periphral, uint32_t u32ScatterEn, uint32_t u32DescAddr);
201 void PDMA_SetTimeOut(uint32_t u32Ch, uint32_t u32OnOff, uint32_t u32TimeOutCnt);
202 void PDMA_Trigger(uint32_t u32Ch);
203 void PDMA_EnableInt(uint32_t u32Ch, uint32_t u32Mask);
204 void PDMA_DisableInt(uint32_t u32Ch, uint32_t u32Mask);
205  /* end of group NANO100_PDMA_EXPORTED_FUNCTIONS */
207  /* end of group NANO100_PDMA_Driver */
209  /* end of group NANO100_Device_Driver */
211 
212 #ifdef __cplusplus
213 }
214 #endif
215 
216 #endif //__PDMA_H__
217 
218 /*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/
void PDMA_Trigger(uint32_t u32Ch)
Trigger PDMA.
Definition: pdma.c:187
void PDMA_DisableInt(uint32_t u32Ch, uint32_t u32Mask)
Disable Interrupt.
Definition: pdma.c:223
void PDMA_EnableInt(uint32_t u32Ch, uint32_t u32Mask)
Enable Interrupt.
Definition: pdma.c:205
void PDMA_SetTransferAddr(uint32_t u32Ch, uint32_t u32SrcAddr, uint32_t u32SrcCtrl, uint32_t u32DstAddr, uint32_t u32DstCtrl)
Set PDMA Transfer Address.
Definition: pdma.c:105
void PDMA_SetTransferMode(uint32_t u32Ch, uint32_t u32Periphral, uint32_t u32ScatterEn, uint32_t u32DescAddr)
Set PDMA Transfer Mode.
Definition: pdma.c:127
void PDMA_Open(uint32_t u32Mask)
PDMA Open.
Definition: pdma.c:38
void PDMA_SetTimeOut(uint32_t u32Ch, uint32_t u32OnOff, uint32_t u32TimeOutCnt)
Set PDMA Timeout.
Definition: pdma.c:168
void PDMA_SetTransferCnt(uint32_t u32Ch, uint32_t u32Width, uint32_t u32TransCount)
Set PDMA Transfer Count.
Definition: pdma.c:68
void PDMA_Close(void)
PDMA Close.
Definition: pdma.c:52