예제 #1
0
파일: pdb.c 프로젝트: SproutOrc/CH-K-Lib
/***********************************************************************************************
 功能:PDB DAC触发初始化配置
 形参:PDB_ADC_InitStruct: PDB_ADC 初始化结构
 返回:0
 详解:专为PDB模块触发DAC模块设计的初始化函数  不许在PDB_Init后调用
************************************************************************************************/
void PDB_ADC_TriggerInit(PDB_ADC_PreTriggerInitTypeDef * PDB_ADC_InitStruct)
{
	uint16_t pt_value = 0;
	//参数检查
	assert_param(IS_PDB_TRIGGER_CH(PDB_ADC_InitStruct->PDB_ADC_TriggerSelect));
	assert_param(IS_PDB_ADC_PRE_TRIGGER_CHL(PDB_ADC_InitStruct->PDB_ADC_PreTriggerChl));
	assert_param(IS_FUNCTIONAL_STATE(PDB_ADC_InitStruct->PDB_ADC_Enable));
	assert_param(IS_FUNCTIONAL_STATE(PDB_ADC_InitStruct->PDB_ADC_BBEnable));
	
	pt_value = (1<<PDB_ADC_InitStruct->PDB_ADC_PreTriggerChl);
	//开启或者关闭模块
	if(ENABLE == PDB_ADC_InitStruct->PDB_ADC_Enable)
	{
		PDB0->CH[PDB_ADC_InitStruct->PDB_ADC_TriggerSelect].C1 |= PDB_C1_TOS(pt_value)|PDB_C1_EN(pt_value);
	}
	else
	{
		PDB0->CH[PDB_ADC_InitStruct->PDB_ADC_TriggerSelect].C1 &= ~(PDB_C1_TOS(pt_value)|PDB_C1_EN(pt_value));
	}
	//是否使能BB
	if(ENABLE == PDB_ADC_InitStruct->PDB_ADC_BBEnable)
	{
		PDB0->CH[PDB_ADC_InitStruct->PDB_ADC_TriggerSelect].C1 |= PDB_C1_BB(pt_value);
	}
	else
	{
		PDB0->CH[PDB_ADC_InitStruct->PDB_ADC_TriggerSelect].C1 &= ~PDB_C1_BB(pt_value);
	}
	//DLY
	PDB0->CH[PDB_ADC_InitStruct->PDB_ADC_TriggerSelect].DLY[PDB_ADC_InitStruct->PDB_ADC_PreTriggerChl] = 0;
}
/*FUNCTION*********************************************************************
 *
 * Function Name : PDB_HAL_SetAdcPreTriggerBackToBackEnable
 * Description   : Switch to enable pre-trigger's back to back mode.
 *
 *END*************************************************************************/
void PDB_HAL_SetAdcPreTriggerBackToBackEnable(PDB_Type * base, uint32_t chn, uint32_t preChnMask, bool enable)
{
    assert(chn < PDB_C1_COUNT);
    
    uint32_t c1 = PDB_RD_C1(base, chn);
    if (enable)
    {
        c1 |= PDB_C1_BB(preChnMask);
    }
    else
    {
        c1 &= ~PDB_C1_BB(preChnMask);
    }
    PDB_WR_C1(base, chn, c1);
}
예제 #3
0
파일: pdb.c 프로젝트: guzhaoyuan/smartCar
void PDB_SetBackToBackMode(uint32_t adcInstance, uint32_t adcMux, bool status)
{
    (status)?
    (PDB0->CH[adcInstance].C1 |= PDB_C1_BB(1<<adcMux)):
    (PDB0->CH[adcInstance].C1 &= ~PDB_C1_BB(1<<adcMux));
}