30#define ADC_INPUTRANGE_HIGH (1UL)
31#define ADC_INPUTRANGE_LOW (0UL)
33#define ADC_CH8_EXT (0UL)
34#define ADC_CH8_BGP (ADC_CHEN_CH8SEL_Msk)
35#define ADC_CMP0_LESS_THAN (0UL << ADC_CMP0_CMPCOND_Pos)
36#define ADC_CMP1_LESS_THAN (0UL << ADC_CMP1_CMPCOND_Pos)
37#define ADC_CMP0_GREATER_OR_EQUAL_TO (1ul << ADC_CMP0_CMPCOND_Pos)
38#define ADC_CMP1_GREATER_OR_EQUAL_TO (1ul << ADC_CMP1_CMPCOND_Pos)
39#define ADC_TRIGGER_BY_EXT_PIN (0UL << ADC_CTL_HWTRGSEL_Pos)
40#define ADC_TRIGGER_BY_PWM (ADC_CTL_HWTRGSEL_Msk)
41#define ADC_FALLING_EDGE_TRIGGER (0UL << ADC_CTL_HWTRGCOND_Pos)
42#define ADC_RISING_EDGE_TRIGGER (ADC_CTL_HWTRGCOND_Msk)
47#define ADC_ADIF_INT (ADC_STATUS_ADIF_Msk)
48#define ADC_CMP0_INT (ADC_STATUS_ADCMPIF0_Msk)
49#define ADC_CMP1_INT (ADC_STATUS_ADCMPIF1_Msk)
50#define ADC_FIFO_FULL_INT (ADC_STATUS_INTFLG_FULL_Msk)
51#define ADC_FIFO_EMPTY_INT (ADC_STATUS_INTFLG_EMPTY_Msk)
52#define ADC_FIFO_OVER_INT (ADC_STATUS_INTFLG_OVER_Msk)
53#define ADC_FIFO_HALF_INT (ADC_STATUS_INTFLG_HALF_Msk)
60#define ADC_SAMPLE_CLOCK_0 (0UL)
61#define ADC_SAMPLE_CLOCK_1 (1UL)
62#define ADC_SAMPLE_CLOCK_2 (2UL)
63#define ADC_SAMPLE_CLOCK_4 (3UL)
64#define ADC_SAMPLE_CLOCK_8 (4UL)
65#define ADC_SAMPLE_CLOCK_16 (5UL)
66#define ADC_SAMPLE_CLOCK_32 (6UL)
67#define ADC_SAMPLE_CLOCK_64 (7UL)
68#define ADC_SAMPLE_CLOCK_128 (8UL)
69#define ADC_SAMPLE_CLOCK_256 (9UL)
70#define ADC_SAMPLE_CLOCK_512 (10UL)
71#define ADC_SAMPLE_CLOCK_1024 (11UL)
77#define ADC_SEQMODE_TYPE_23SHUNT (0UL)
78#define ADC_SEQMODE_TYPE_1SHUNT (1UL)
79#define ADC_SEQMODE_MODESELECT_CH01 (0UL)
80#define ADC_SEQMODE_MODESELECT_CH12 (1UL)
81#define ADC_SEQMODE_MODESELECT_CH02 (2UL)
82#define ADC_SEQMODE_MODESELECT_ONE (3UL)
83#define ADC_SEQMODE_PWM0_RISING (0UL)
84#define ADC_SEQMODE_PWM0_CENTER (1UL)
85#define ADC_SEQMODE_PWM0_FALLING (2UL)
86#define ADC_SEQMODE_PWM0_PERIOD (3UL)
87#define ADC_SEQMODE_PWM2_RISING (4UL)
88#define ADC_SEQMODE_PWM2_CENTER (5UL)
89#define ADC_SEQMODE_PWM2_FALLING (6UL)
90#define ADC_SEQMODE_PWM2_PERIOD (7UL)
91#define ADC_SEQMODE_PWM4_RISING (8UL)
92#define ADC_SEQMODE_PWM4_CENTER (9UL)
93#define ADC_SEQMODE_PWM4_FALLING (10UL)
94#define ADC_SEQMODE_PWM4_PERIOD (11UL)
95#define ADC_SEQMODE_PWM6_RISING (12UL)
96#define ADC_SEQMODE_PWM6_CENTER (13UL)
97#define ADC_SEQMODE_PWM6_FALLING (14UL)
98#define ADC_SEQMODE_PWM6_PERIOD (15UL)
101#define ADC_COMPARATOR_0 (0)
102#define ADC_COMPARATOR_1 (1)
104#define ADC_FIFO_TRIG_LEVEL_HALF (0)
105#define ADC_FIFO_TRIG_LEVEL_FULL (1)
123 return (ADCx->DAT & ADC_DAT_RESULT_Msk);
141 return (ADCx->STATUS & IntMask)?(
true):(
false);
159 ADCx->STATUS |= IntMask;
175__STATIC_INLINE
void ADC_IntMask(ADC_T *ADCx,uint32_t IntMask,FunctionalState NewState)
177 (NewState == DISABLE)?(ADCx->STATUS |= IntMask):(ADCx->STATUS &= ~IntMask);
195 return (ADCx->STATUS & IntMask)?(
true):(
false);
213 ADCx->STATUS = ADCx->STATUS | IntMask;
224 return (ADCx->STATUS & ADC_STATUS_BUSY_Msk)?(
true):(
false);
235 return (ADCx->STATUS & ADC_STATUS_OV_Msk)?(
true):(
false);
246 return (ADCx->STATUS & ADC_STATUS_VALID_Msk)?(
true):(
false);
255 ADCx->CTL = ADCx->CTL & ~ADC_CTL_ADCEN_Msk;
264 ADCx->CTL = ADCx->CTL | ADC_CTL_ADCEN_Msk;
273 ADCx->SEQCTL = ADCx->SEQCTL & ~ADC_SEQCTL_SEQEN_Msk;
283 (NewState == ENABLE)?(ADCx->SEQCTL |= ADC_SEQCTL_TRG_SEL_Msk):(ADCx->SEQCTL &= ~ADC_SEQCTL_TRG_SEL_Msk);
313 ADCx->CTL = ADCx->CTL | ADC_CTL_SWTRG_Msk;
322 ADCx->CTL &= ~ADC_CTL_SWTRG_Msk;
332 ADCx->CTL2 |= ADC_CTL2_TESTMODE_Msk;
341 ADCx->CTL2 &= ~ADC_CTL2_TESTMODE_Msk;
351 (NewState == ENABLE)?(ADCx->CTL2 |= ADC_CTL2_DMA_EN_Msk):(ADCx->CTL2 &= ~ADC_CTL2_DMA_EN_Msk);
362 ADCx->CTL2 = (ADCx->CTL2 & ~ADC_CTL2_CLKDIV_Msk) | (Divider << ADC_CTL2_CLKDIV_Pos);
374__STATIC_INLINE
void ADC_Open(ADC_T *ADCx,uint32_t ChMask)
376 ADCx->CHEN = (ADCx->CHEN & ~ADC_CHEN_ALL_Msk) | ChMask;
387 ADCx->CTL2 = (ADCx->CTL2 & ~ADC_SEL_VREF_Msk) | (EnableHigh << ADC_SEL_VREF_Pos);
419 ADCx->EXTSMPT = (ADCx->EXTSMPT & ~ADC_EXTSMPT_EXTSMPT_Msk) | SampleTime;
430 return (ADCx->STATUS & ADC_STATUS_ONE_CH_FLAG_Msk)?(
true):(
false);
442 (NewState == ENABLE)?(ADCx->STATUS |= ADC_STATUS_ONE_CH_CLR_SEL_Msk):(ADCx->STATUS &= ~ADC_STATUS_ONE_CH_CLR_SEL_Msk);
453 (NewState == ENABLE)?(ADCx->LS_CTL |= ADC_LS_CTL_LS_EN_Msk):(ADCx->LS_CTL &= ~ADC_LS_CTL_LS_EN_Msk);
463 return ((ADCx->LS_CTL & ADC_LS_CTL_LS_DAT_Msk) >> ADC_LS_CTL_LS_DAT_Pos);
473 (NewState == ENABLE)?(ADCx->SUB_CTL |= ADC_SUB_CTL_BIAS_EN_Msk):(ADCx->SUB_CTL &= ~ADC_SUB_CTL_BIAS_EN_Msk);
484 ADCx->SUB_CTL = (ADCx->SUB_CTL & ~ADC_LS_CTL_LS_DAT_Msk) | (BiasData << ADC_LS_CTL_LS_DAT_Pos);
494 return ADCx->DATA_SUB & ADC_DAT_SUB_LEFT_BIAS_Msk;
507 ADCx->FIFO_CTL = (ADCx->FIFO_CTL & ~ADC_FIFO_CTL_HALF_OR_FULL_Msk) | ((Level << ADC_FIFO_CTL_HALF_OR_FULL_Pos)|ADC_FIFO_CTL_EN_Msk);
517 return ADCx->POP_DATA & ADC_FIFO_POP_DAT_Msk;
528 (NewState)?(ADCx->SEQCTL |= ADC_SEQCTL_ONE_CH_EN_Msk):(ADCx->SEQCTL &= ~ADC_SEQCTL_ONE_CH_EN_Msk);
539 ADCx->SEQCTL = (ADCx->SEQCTL & ~ADC_SEQCTL_ONE_CH_SEL_Msk) | (Ch << ADC_SEQCTL_ONE_CH_SEL_Pos);
647 uint32_t CmpCondition,
void ADC_DisableInt(ADC_T *ADCx, uint32_t Mask)
Disable the interrupt(s) selected by u32Mask parameter.
__STATIC_INLINE void ADC_SeqModeChSelect(ADC_T *ADCx, uint8_t Ch)
adc channel select in pwm sequential
Definition: pan_adc.h:537
__STATIC_INLINE void ADC_ClearStatusFlag(ADC_T *ADCx, uint32_t IntMask)
Clear specified interrupt flag.
Definition: pan_adc.h:157
__STATIC_INLINE uint32_t ADC_GetConversionData(ADC_T *ADCx)
Get the latest ADC conversion data.
Definition: pan_adc.h:121
__STATIC_INLINE void ADC_TestModeEnable(ADC_T *ADCx)
Enable the A/D test mode.
Definition: pan_adc.h:330
__STATIC_INLINE bool ADC_IsDataValid(ADC_T *ADCx)
Check if the ADC conversion data is valid or not.
Definition: pan_adc.h:244
__STATIC_INLINE uint32_t ADC_GetLeftBiasData(ADC_T *ADCx)
get adc data after bias & left shift
Definition: pan_adc.h:492
void ADC_DisableHWTrigger(ADC_T *ADCx)
Disable hardware trigger ADC function.
__STATIC_INLINE bool ADC_IsIntOccured(ADC_T *ADCx, uint32_t IntMask)
adjust the user-specified interrupt occured or not
Definition: pan_adc.h:193
__STATIC_INLINE void ADC_PowerDown(ADC_T *ADCx)
Power down ADC module.
Definition: pan_adc.h:253
__STATIC_INLINE bool ADC_IsOneChConvertEnd(ADC_T *ADCx)
adjust pwm sequence convert end or not in adc one channel
Definition: pan_adc.h:428
__STATIC_INLINE void ADC_SetFifoTrigLevel(ADC_T *ADCx, uint8_t Level)
set adc fifo trig level
Definition: pan_adc.h:505
__STATIC_INLINE void ADC_SequentialModeDisable(ADC_T *ADCx)
ADC sequential mode Disabled.
Definition: pan_adc.h:271
__STATIC_INLINE void ADC_TriggerDelay(ADC_T *ADCx, uint32_t Data)
Delay ADC start conversion time after PWM trigger.
Definition: pan_adc.h:395
__STATIC_INLINE void ADC_StopConvert(ADC_T *ADCx)
Stop the A/D conversion.
Definition: pan_adc.h:320
__STATIC_INLINE void ADC_Trigger2Select(ADC_T *ADCx, FunctionalState NewState)
TRG1CTL select for 1-shunt sequential mode.
Definition: pan_adc.h:281
__STATIC_INLINE void ADC_SetBiasData(ADC_T *ADCx, uint32_t BiasData)
set bias data
Definition: pan_adc.h:482
__STATIC_INLINE void ADC_LeftShiftEn(ADC_T *ADCx, FunctionalState NewState)
enable left shift function,if enable,adc data {adc_output[11:0],4'b0 }
Definition: pan_adc.h:451
void ADC_SeqModeTriggerSrc(ADC_T *ADCx, uint32_t SeqModeTriSrc)
ADC PWM Sequential Mode PWM Trigger Source and type.
__STATIC_INLINE void ADC_TestModeDisable(ADC_T *ADCx)
Disable the A/D test mode.
Definition: pan_adc.h:339
__STATIC_INLINE void ADC_SelInputRange(ADC_T *ADCx, uint32_t EnableHigh)
Select ADC range of input sample signal.
Definition: pan_adc.h:385
__STATIC_INLINE void ADC_SubtractBiasEn(ADC_T *ADCx, FunctionalState NewState)
enable subtract bias function
Definition: pan_adc.h:471
void ADC_SeqModeEnable(ADC_T *ADCx, uint32_t SeqTYPE, uint32_t ModeSel)
ADC PWM Sequential Mode Control.
__STATIC_INLINE void ADC_DisableCompare0(ADC_T *ADCx)
Disable comparator 0.
Definition: pan_adc.h:291
__STATIC_INLINE void ADC_Open(ADC_T *ADCx, uint32_t ChMask)
This API configures ADC module to be ready for convert the input from selected channel.
Definition: pan_adc.h:374
__STATIC_INLINE void ADC_SetClockDivider(ADC_T *ADCx, uint32_t Divider)
Set the A/D clock division.
Definition: pan_adc.h:360
__STATIC_INLINE void ADC_DisableCompare1(ADC_T *ADCx)
Disable comparator 1.
Definition: pan_adc.h:301
void ADC_Close(void)
Close ADC peripheral.
void ADC_EnableInt(ADC_T *ADCx, uint32_t Mask)
Enable the interrupt(s) selected by u32Mask parameter.
void ADC_CompareEnable(ADC_T *ADCx, uint32_t ChNum, uint32_t CmpCondition, uint32_t CmpData, uint32_t MatchCnt, uint32_t CmpSelect)
Configure the comparator 0 and enable it.
__STATIC_INLINE void ADC_ClearByHw(ADC_T *ADCx, FunctionalState NewState)
clear pwm sequence end flag
Definition: pan_adc.h:440
__STATIC_INLINE void ADC_SetExtraSampleTime(ADC_T *ADCx, uint32_t SampleTime)
Set ADC sample time for designated channel.
Definition: pan_adc.h:417
__STATIC_INLINE bool ADC_IsDataOverrun(ADC_T *ADCx)
Check if the ADC conversion data is over written or not.
Definition: pan_adc.h:233
__STATIC_INLINE void ADC_IntMask(ADC_T *ADCx, uint32_t IntMask, FunctionalState NewState)
Set interrupt mask,if masked,interrupt will not be happened.
Definition: pan_adc.h:175
void ADC_EnableHWTrigger(ADC_T *ADCx, uint32_t Source, uint32_t Param)
Configure the hardware trigger condition and enable hardware trigger.
__STATIC_INLINE void ADC_SeqModeOneChEn(ADC_T *ADCx, FunctionalState NewState)
pwm sequential enable in adc one channel mode
Definition: pan_adc.h:526
__STATIC_INLINE void ADC_DmaModeEnable(ADC_T *ADCx, FunctionalState NewState)
Enable the A/D dma mode.
Definition: pan_adc.h:349
void ADC_SeqOneChModeConfig(ADC_T *ADCx, uint32_t Trig, uint8_t Level, uint8_t DmaEn, uint8_t HwClrEN, uint8_t AdcCh)
set ADC PWM one channel Sequential Mode configuration.
__STATIC_INLINE bool ADC_StatusFlag(ADC_T *ADCx, uint32_t IntMask)
Get raw status flag.
Definition: pan_adc.h:139
__STATIC_INLINE uint32_t ADC_GetFifoPopData(ADC_T *ADCx)
get fifo pop data
Definition: pan_adc.h:515
__STATIC_INLINE bool ADC_IsBusy(ADC_T *ADCx)
Get the busy state of ADC.
Definition: pan_adc.h:222
__STATIC_INLINE uint32_t ADC_GetLeftShiftData(ADC_T *ADCx)
get left shift data
Definition: pan_adc.h:461
void ADC_Disable(ADC_T *ADCx)
Disable ADC Power.
__STATIC_INLINE void ADC_StartConvert(ADC_T *ADCx)
Start the A/D conversion.
Definition: pan_adc.h:311
__STATIC_INLINE void ADC_ClearIntFlag(ADC_T *ADCx, uint32_t IntMask)
This macro clear the selected interrupt status bits.
Definition: pan_adc.h:211
__STATIC_INLINE void ADC_PowerOn(ADC_T *ADCx)
Power on ADC module.
Definition: pan_adc.h:262