📄 drvadc.c
字号:
ADC->ADCMPR[0].CMPEN = 1;
return E_SUCCESS;
}
/*---------------------------------------------------------------------------------------------------------*/
/* Function: DrvADC_DisableADCCmp0 */
/* */
/* Parameters: */
/* None. */
/* */
/* Returns: */
/* None. */
/* */
/* Description: */
/* Disable the ADC result monitor 0. */
/*---------------------------------------------------------------------------------------------------------*/
void DrvADC_DisableADCCmp0(void)
{
ADC->ADCMPR[0].CMPEN = 0;
}
/*---------------------------------------------------------------------------------------------------------*/
/* Function: DrvADC_EnableADCCmp1 */
/* */
/* Parameters: */
/* u8CmpChannelNum [in]: Specify the channel number that want to compare. */
/* CmpCondition [in]: Specify the compare condition. */
/* LESS_THAN for the condition of "less than the compare data"; */
/* GREATER_OR_EQUAL for the condition of "greater or equal to the compare data." */
/* u16CmpData [in]: Specify the compare data. */
/* u8CmpMatchCount [in]: Specify the compare match count. */
/* */
/* Returns: */
/* E_DRVADC_ARGUMENT: one of the input arguments is out of the range. */
/* E_SUCCESS: the compare function is enabled. */
/* */
/* Description: */
/* Enable the ADC result monitor 1 and configure the necessary settings. */
/*---------------------------------------------------------------------------------------------------------*/
int32_t DrvADC_EnableADCCmp1(uint8_t u8CmpChannelNum, E_ADC_CMP_CONDITION CmpCondition, uint16_t u16CmpData, uint8_t u8CmpMatchCount)
{
if(u8CmpChannelNum>7)
return E_DRVADC_ARGUMENT;
if(u16CmpData>0x0FFF)
return E_DRVADC_ARGUMENT;
if(u8CmpMatchCount>0x0F)
return E_DRVADC_ARGUMENT;
ADC->ADCMPR[1].CMPCH = u8CmpChannelNum;
ADC->ADCMPR[1].CMPCOND = CmpCondition;
ADC->ADCMPR[1].CMPD = u16CmpData;
ADC->ADCMPR[1].CMPMATCNT = u8CmpMatchCount;
ADC->ADCMPR[1].CMPEN = 1;
return E_SUCCESS;
}
/*---------------------------------------------------------------------------------------------------------*/
/* Function: DrvADC_DisableADCCmp1 */
/* */
/* Parameters: */
/* None. */
/* */
/* Returns: */
/* None. */
/* */
/* Description: */
/* Disable the ADC result monitor 1. */
/*---------------------------------------------------------------------------------------------------------*/
void DrvADC_DisableADCCmp1(void)
{
ADC->ADCMPR[1].CMPEN = 0;
}
/*---------------------------------------------------------------------------------------------------------*/
/* Function: DrvADC_EnableSelfCalibration */
/* */
/* Parameters: */
/* None. */
/* */
/* Returns: */
/* None. */
/* */
/* Description: */
/* Enable the self calibration function. */
/*---------------------------------------------------------------------------------------------------------*/
void DrvADC_EnableSelfCalibration(void)
{
ADC->ADCALR.CALEN = 1;
}
/*---------------------------------------------------------------------------------------------------------*/
/* Function: DrvADC_IsCalibrationDone */
/* */
/* Parameters: */
/* None. */
/* */
/* Returns: */
/* TRUE: the self calibration action is finished. */
/* FALSE: the self calibration action is in progress. */
/* */
/* Description: */
/* Check whether the self calibration action is finished or not. */
/*---------------------------------------------------------------------------------------------------------*/
uint32_t DrvADC_IsCalibrationDone(void)
{
if(ADC->ADCALR.CALDONE == 1)
return TRUE;
else
return FALSE;
}
/*---------------------------------------------------------------------------------------------------------*/
/* Function: DrvADC_DisableSelfCalibration */
/* */
/* Parameters: */
/* None. */
/* */
/* Returns: */
/* None. */
/* */
/* Description: */
/* Disable the self calibration function. */
/*---------------------------------------------------------------------------------------------------------*/
void DrvADC_DisableSelfCalibration(void)
{
ADC->ADCALR.CALEN = 0;
}
/*---------------------------------------------------------------------------------------------------------*/
/* Function: DrvADC_DiffModeOutputFormat */
/* */
/* Parameters: */
/* OutputFormat [in]: Specify the output format. */
/* UNSIGNED_OUTPUT: unsigned format. */
/* TWOS_COMPLEMENT: 2's complement. */
/* */
/* Returns: */
/* None. */
/* */
/* Description: */
/* Select the output format of differential input mode. */
/*---------------------------------------------------------------------------------------------------------*/
void DrvADC_DiffModeOutputFormat (E_ADC_DIFF_MODE_OUTPUT_FORMAT OutputFormat)
{
ADC->ADCR.DMOF = OutputFormat;
}
/*---------------------------------------------------------------------------------------------------------*/
/* Function: DrvADC_GetVersion */
/* */
/* Parameters: */
/* None. */
/* */
/* Returns: */
/* Version number. */
/* */
/* Description: */
/* Get the version number of NUC100 ADC driver. */
/*---------------------------------------------------------------------------------------------------------*/
uint32_t DrvADC_GetVersion (void)
{
return DRVADC_VERSION_NUM;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -