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

eadc.c
Go to the documentation of this file.
1 /**************************************************************************/
9 #include "NuMicro.h"
10
34 void EADC_Open(EADC_T *eadc, uint32_t u32InputMode)
35 {
36 eadc->CTL &= (~EADC_CTL_DIFFEN_Msk);
37
38 eadc->CTL |= (u32InputMode | EADC_CTL_ADCEN_Msk);
39 while (!(eadc->PWRM & EADC_PWRM_PWUPRDY_Msk)) {}
40 }
41
48 void EADC_Close(EADC_T *eadc)
49 {
50 eadc->CTL &= ~EADC_CTL_ADCEN_Msk;
51 }
52
87 void EADC_ConfigSampleModule(EADC_T *eadc, \
88 uint32_t u32ModuleNum, \
89 uint32_t u32TriggerSrc, \
90 uint32_t u32Channel)
91 {
92 eadc->SCTL[u32ModuleNum] &= ~(EADC_SCTL_EXTFEN_Msk | EADC_SCTL_EXTREN_Msk | EADC_SCTL_TRGSEL_Msk | EADC_SCTL_CHSEL_Msk);
93 eadc->SCTL[u32ModuleNum] |= (u32TriggerSrc | u32Channel);
94 }
95
96
111 void EADC_SetTriggerDelayTime(EADC_T *eadc, \
112 uint32_t u32ModuleNum, \
113 uint32_t u32TriggerDelayTime, \
114 uint32_t u32DelayClockDivider)
115 {
116 eadc->SCTL[u32ModuleNum] &= ~(EADC_SCTL_TRGDLYDIV_Msk | EADC_SCTL_TRGDLYCNT_Msk);
117 eadc->SCTL[u32ModuleNum] |= ((u32TriggerDelayTime << EADC_SCTL_TRGDLYCNT_Pos) | u32DelayClockDivider);
118 }
119
129 void EADC_SetExtendSampleTime(EADC_T *eadc, uint32_t u32ModuleNum, uint32_t u32ExtendSampleTime)
130 {
131 eadc->SCTL[u32ModuleNum] &= ~EADC_SCTL_EXTSMPT_Msk;
132
133 eadc->SCTL[u32ModuleNum] |= (u32ExtendSampleTime << EADC_SCTL_EXTSMPT_Pos);
134
135 }
136 /* end of group EADC_EXPORTED_FUNCTIONS */
138 /* end of group EADC_Driver */
140 /* end of group Standard_Driver */
142
143 /*** (C) COPYRIGHT 2016 Nuvoton Technology Corp. ***/
EADC_SCTL_CHSEL_Msk
#define EADC_SCTL_CHSEL_Msk
Definition: eadc_reg.h:1455
EADC_SCTL_EXTFEN_Msk
#define EADC_SCTL_EXTFEN_Msk
Definition: eadc_reg.h:1461
EADC_SetTriggerDelayTime
void EADC_SetTriggerDelayTime(EADC_T *eadc, uint32_t u32ModuleNum, uint32_t u32TriggerDelayTime, uint32_t u32DelayClockDivider)
Set trigger delay time.
Definition: eadc.c:111
EADC_SCTL_TRGDLYDIV_Msk
#define EADC_SCTL_TRGDLYDIV_Msk
Definition: eadc_reg.h:1464
NuMicro.h
NuMicro peripheral access layer header file.
EADC_Open
void EADC_Open(EADC_T *eadc, uint32_t u32InputMode)
This function make EADC_module be ready to convert.
Definition: eadc.c:34
EADC_ConfigSampleModule
void EADC_ConfigSampleModule(EADC_T *eadc, uint32_t u32ModuleNum, uint32_t u32TriggerSrc, uint32_t u32Channel)
Configure the sample control logic module.
Definition: eadc.c:87
EADC_PWRM_PWUPRDY_Msk
#define EADC_PWRM_PWUPRDY_Msk
Definition: eadc_reg.h:2337
EADC_SCTL_EXTSMPT_Msk
#define EADC_SCTL_EXTSMPT_Msk
Definition: eadc_reg.h:1479
EADC_SCTL_EXTSMPT_Pos
#define EADC_SCTL_EXTSMPT_Pos
Definition: eadc_reg.h:1478
EADC_SetExtendSampleTime
void EADC_SetExtendSampleTime(EADC_T *eadc, uint32_t u32ModuleNum, uint32_t u32ExtendSampleTime)
Set ADC extend sample time.
Definition: eadc.c:129
EADC_SCTL_EXTREN_Msk
#define EADC_SCTL_EXTREN_Msk
Definition: eadc_reg.h:1458
EADC_SCTL_TRGDLYCNT_Pos
#define EADC_SCTL_TRGDLYCNT_Pos
Definition: eadc_reg.h:1466
EADC_CTL_ADCEN_Msk
#define EADC_CTL_ADCEN_Msk
Definition: eadc_reg.h:1416
EADC_T::PWRM
__IO uint32_t PWRM
Definition: eadc_reg.h:1218
EADC_CTL_DIFFEN_Msk
#define EADC_CTL_DIFFEN_Msk
Definition: eadc_reg.h:1437
EADC_T
Definition: eadc_reg.h:26
EADC_T::CTL
__IO uint32_t CTL
Definition: eadc_reg.h:1200
EADC_SCTL_TRGDLYCNT_Msk
#define EADC_SCTL_TRGDLYCNT_Msk
Definition: eadc_reg.h:1467
EADC_Close
void EADC_Close(EADC_T *eadc)
Disable EADC_module.
Definition: eadc.c:48
EADC_T::SCTL
__IO uint32_t SCTL[19]
Definition: eadc_reg.h:1207
EADC_SCTL_TRGSEL_Msk
#define EADC_SCTL_TRGSEL_Msk
Definition: eadc_reg.h:1470