GPIO初始化函數(shù)
void AD7606Init(void) //AD06060初始化函數(shù)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA|RCC_AHB1Periph_GPIOB|RCC_AHB1Periph_GPIOC|\
RCC_AHB1Periph_GPIOD|RCC_AHB1Periph_GPIOE|RCC_AHB1Periph_GPIOF|\
RCC_AHB1Periph_GPIOG|RCC_AHB1Periph_GPIOH|RCC_AHB1Periph_GPIOI,ENABLE); //使能GPIOA的時鐘
/***********************8GPIO輸出配置******************************/
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;//輸出
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; //推挽輸出
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; //上拉輸出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; //高速GPIO
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
GPIO_Init(GPIOB,&GPIO_InitStructure);//PB7
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4;
GPIO_Init(GPIOI,&GPIO_InitStructure);//PI4
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1;
GPIO_Init(GPIOE,&GPIO_InitStructure);//PE0,1
/************************GPIO輸入配置*********************************/
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10|GPIO_Pin_11|GPIO_Pin_12;
GPIO_Init(GPIOC,&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4|\
GPIO_Pin_5|GPIO_Pin_6;
GPIO_Init(GPIOD,&GPIO_InitStructure);//PD0,1,2,3,4,5,6
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9|GPIO_Pin_10;
GPIO_Init(GPIOG,&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_6|GPIO_Pin_7;
GPIO_Init(GPIOI,&GPIO_InitStructure);
AD760600_RESET = 0;
AD760600_CONVST =1;
AD760600_CS = 1;
AD760600_RD_SCLK = 1;
AD7606驅(qū)動函數(shù)
/***********************AD760600驅(qū)動函數(shù)****************************/
void AD760600Reset(void)
{
AD760600_RESET = 1;
delay_us(1);
AD760600_RESET = 0;
AD760600_CONVST = 0;
delay_us(1);
AD760600_CONVST = 1;
}
void AD760600ReadOneSample(u16*Dout,u8 Channels)
{
u8 i,j;
u8 Date;
AD760600Reset();
u8 Read_Busy ;
Read_Busy = AD760600_BUSY;
while(Read_Busy == 1)
{
Read_Busy = AD760600_BUSY;
}
AD760600_CS = 0;
for(i=0;i
{
AD760600_RD_SCLK = 0;
Date = AD760600_DB0<<0|AD760600_DB1<<1|AD760600_DB2<<2|AD760600_DB3<<3|AD760600_DB4<<4|AD760600_DB5<<5|\
AD760600_DB6<<6|AD760600_DB7<<7|AD760600_DB8<<8|AD760600_DB9<<9|AD760600_DB10<<10|AD760600_DB11<<11|AD760600_DB12<<12|\
AD760600_DB13|AD760600_DB14<<14|AD760600_DB15<<15;
AD760600_RD_SCLK = 1;
delay_us(1);
Dout[i] = Date;
}
AD760600_CS = 1;
for(j=1;j<=8;j++)
{
Dout[j] = Kalman(Dout[j]);
}
}