unsigned char CS1237_Read_Config(void)
{
unsigned char i = 0;
unsigned char dat = 0;
unsigned char count_i = 0;
unsigned char Configvalue=0xac;
ADC_SCKL;
ADC_DOUT_IN; //配置IO为输入
while((PIND&ADC_DOUT) == 1)
{//
delay_nus(500);
count_i++;
if(count_i > 150)
{
ADC_SCKH;
ADC_DOUT_OUT;
ADC_DOUTH;
return;
}
}//
for(i=0;i<27;i++)// 1 - 29
{
One_CLK();
}
ADC_DOUT_OUT; //设置为输出
One_CLK();
One_CLK();
for(i=0;i<7;i++)
{
if(Configvalue&0x07)
ADC_DOUTH;
else
ADC_DOUTL;
Configvalue = Configvalue <<1;
One_CLK();
}
//ADC_SCKH;delay_nus(1);ADC_DOUTH;ADC_SCKL;delay_nus(1);//30
//ADC_SCKH;delay_nus(1);ADC_DOUTL;ADC_SCKL;delay_nus(1);//31
//ADC_SCKH;delay_nus(1);ADC_DOUTH;ADC_SCKL;delay_nus(1);//32
//ADC_SCKH;delay_nus(1);ADC_DOUTL;ADC_SCKL;delay_nus(1);//33
//ADC_SCKH;delay_nus(1);ADC_DOUTH;ADC_SCKL;delay_nus(1);//34
//ADC_SCKH;delay_nus(1);ADC_DOUTH;ADC_SCKL;delay_nus(1);//35
//ADC_SCKH;delay_nus(1);ADC_DOUTL;ADC_SCKL;delay_nus(1);//36
ADC_DOUT_IN; //配置IO为输入
One_CLK();
for(i=0;i<8;i++)// 38 - 45
{
One_CLK();
dat <<= 1;
if((PIND&ADC_DOUT) == 1)
dat++;
}
One_CLK();//46
//ADC_DOUT_OUT;
//ADC_DOUTH;
return dat;
}
0