| Nano100BN Series BSP V3.03.002 The Board Support Package for Nano100BN Series

dac.h
Go to the documentation of this file.
1 /**************************************************************************/
12 #ifndef __DAC_H__
13 #define __DAC_H__
14
15 #ifdef __cplusplus
16 extern "C"
17 {
18 #endif
19
20
33 #define DAC_WRITE_DAT_TRIGGER (0UL << DAC_CTL_DACLSEL_Pos)
34 #define DAC_PDMA_TRIGGER (1UL << DAC_CTL_DACLSEL_Pos)
35 #define DAC_TIMER0_TRIGGER (2UL << DAC_CTL_DACLSEL_Pos)
36 #define DAC_TIMER1_TRIGGER (3UL << DAC_CTL_DACLSEL_Pos)
37 #define DAC_TIMER2_TRIGGER (4UL << DAC_CTL_DACLSEL_Pos)
38 #define DAC_TIMER3_TRIGGER (5UL << DAC_CTL_DACLSEL_Pos)
39
40 #define DAC_REFSEL_POWER (0UL << DAC_COMCTL_REFSEL_Pos)
41 #define DAC_REFSEL_INT_VREF (1UL << DAC_COMCTL_REFSEL_Pos)
42 #define DAC_REFSEL_VREF (2UL << DAC_COMCTL_REFSEL_Pos)
43
44 /* end of group NANO100_DAC_EXPORTED_CONSTANTS */
45
46
47
60 #define DAC_WRITE_DATA(dac, u32Ch, u32Data) do {\
61 if(u32Ch) {\
62 DAC->DATA1 = u32Data;\
63 } else {\
64 DAC->DATA0 = u32Data;\
65 }\
66 }while(0)
67
68
75 #define DAC_ENABLE_GROUP_MODE(dac) (DAC->COMCTL |= DAC_COMCTL_DAC01GRP_Msk)
76
83 #define DAC_DISABLE_GROUP_MODE(dac) (DAC->COMCTL &= ~DAC_COMCTL_DAC01GRP_Msk)
84
95 #define DAC_IS_BUSY(dac, u32Ch) (inp32(DAC_BASE + 0x8 + 0x10 * (u32Ch)) & DAC_STS_BUSY_Msk ? 1 : 0)
96
97
107 #define DAC_GET_INT_FLAG(dac, u32Ch) (inp32(DAC_BASE + 0x8 + 0x10 * (u32Ch)) & DAC_STS_DACIFG_Msk ? 1 : 0)
108
116 #define DAC_CLR_INT_FLAG(dac, u32Ch) do {\
117 if(u32Ch)\
118 DAC->STS1 = DAC_STS_DACIFG_Msk;\
119 else\
120 DAC->STS0 = DAC_STS_DACIFG_Msk;\
121 }while(0)
122
123
134 #define DAC_SET_REF_VOLTAGE(dac, u32Ref) (DAC->COMCTL = ((DAC->COMCTL) & ~DAC_COMCTL_REFSEL_Msk) | u32Ref)
135
143 #define DAC_ENABLE_INT(dac, u32Ch) do {\
144 if(u32Ch)\
145 DAC->CTL1 |= DAC_CTL_DACIE_Msk;\
146 else\
147 DAC->CTL0 |= DAC_CTL_DACIE_Msk;\
148 }while(0)
149
157 #define DAC_DISABLE_INT(dac, u32Ch) do {\
158 if(u32Ch)\
159 DAC->CTL1 &= ~DAC_CTL_DACIE_Msk;\
160 else\
161 DAC->CTL0 &= ~DAC_CTL_DACIE_Msk;\
162 }while(0)
163
164 void DAC_Open(DAC_T *dac, uint32_t u32Ch, uint32_t u32TrgSrc);
165 void DAC_Close(DAC_T *dac, uint32_t u32Ch);
166 int DAC_SetDelayTime(DAC_T *dac, uint32_t u32Delay);
167 /* end of group NANO100_DAC_EXPORTED_FUNCTIONS */
169 /* end of group NANO100_DAC_Driver */
171 /* end of group NANO100_Device_Driver */
173
174 #ifdef __cplusplus
175 }
176 #endif
177
178 #endif //__DAC_H__
179
180 /*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/
DAC_Open
void DAC_Open(DAC_T *dac, uint32_t u32Ch, uint32_t u32TrgSrc)
This function make a DAC channel ready to convert.
Definition: dac.c:40
DAC_T
Definition: Nano100Series.h:1477
DAC_SetDelayTime
int DAC_SetDelayTime(DAC_T *dac, uint32_t u32Delay)
Set delay time for DAC to become stable.
Definition: dac.c:94
DAC_Close
void DAC_Close(DAC_T *dac, uint32_t u32Ch)
Disable DAC analog power.
Definition: dac.c:67