| M480 BSP V3.05.001 The Board Support Package for M480 Series

dac.c
Go to the documentation of this file.
1 /**************************************************************************/
9 #include "NuMicro.h"
10
46 void DAC_Open(DAC_T *dac,
47 uint32_t u32Ch,
48 uint32_t u32TrgSrc)
49 {
50 dac->CTL &= ~(DAC_CTL_ETRGSEL_Msk | DAC_CTL_TRGSEL_Msk | DAC_CTL_TRGEN_Msk);
51 dac->CTL |= (u32TrgSrc | DAC_CTL_DACEN_Msk);
52 }
53
61 void DAC_Close(DAC_T *dac, uint32_t u32Ch)
62 {
63 dac->CTL &= (~DAC_CTL_DACEN_Msk);
64 }
65
74 uint32_t DAC_SetDelayTime(DAC_T *dac, uint32_t u32Delay)
75 {
76
77 dac->TCTL = ((CLK_GetPCLK1Freq() * u32Delay / 1000000UL) & 0x3FFUL);
78
79 return ((dac->TCTL) * 1000000UL / CLK_GetPCLK1Freq());
80 }
81
82
83 /* end of group DAC_EXPORTED_FUNCTIONS */
85 /* end of group DAC_Driver */
87 /* end of group Standard_Driver */
89
90 /*** (C) COPYRIGHT 2016 Nuvoton Technology Corp. ***/
DAC_CTL_DACEN_Msk
#define DAC_CTL_DACEN_Msk
Definition: dac_reg.h:288
DAC_CTL_ETRGSEL_Msk
#define DAC_CTL_ETRGSEL_Msk
Definition: dac_reg.h:312
DAC_CTL_TRGSEL_Msk
#define DAC_CTL_TRGSEL_Msk
Definition: dac_reg.h:303
DAC_Open
void DAC_Open(DAC_T *dac, uint32_t u32Ch, uint32_t u32TrgSrc)
This function make DAC module be ready to convert.
Definition: dac.c:46
NuMicro.h
NuMicro peripheral access layer header file.
DAC_Close
void DAC_Close(DAC_T *dac, uint32_t u32Ch)
Disable DAC analog power.
Definition: dac.c:61
DAC_T
Definition: dac_reg.h:26
CLK_GetPCLK1Freq
uint32_t CLK_GetPCLK1Freq(void)
Get PCLK1 frequency.
Definition: clk.c:204
DAC_CTL_TRGEN_Msk
#define DAC_CTL_TRGEN_Msk
Definition: dac_reg.h:300
DAC_T::TCTL
__IO uint32_t TCTL
Definition: dac_reg.h:278
DAC_T::CTL
__IO uint32_t CTL
Definition: dac_reg.h:273
DAC_SetDelayTime
uint32_t DAC_SetDelayTime(DAC_T *dac, uint32_t u32Delay)
Set delay time for DAC to become stable.
Definition: dac.c:74