222.jpg
图片上有文字描述
[code]void Bus_Init(void)
{
//-----------SPI-------------
SPI_InitTypeDef SPI_InitStructure;
RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2,ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1,ENABLE);
//------------------------------SPI1------------------------------
DISABLE_TP(); //必须先禁能,才能改变MODE
SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex; //两线全双工
SPI_InitStructure.SPI_Mode = SPI_Mode_Master; //主
SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b; //8bit
SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low;
SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge; //数据捕获于第1个时钟沿
SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;
SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_64;
SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
SPI_InitStructure.SPI_CRCPolynomial = 7;
SPI_Init(SPI1,&SPI_InitStructure);
ENABLE_TP();
SPI_Cmd(SPI1,ENABLE);
//------------------------------SPI2------------------------------
DISABLE_MRF(); //必须先禁能,才能改变MODE
SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex; //两线全双工
SPI_InitStructure.SPI_Mode = SPI_Mode_Master; //主
SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b; //8bit
SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low; //时钟悬空为低
SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge; //数据捕获于第1个时钟沿
SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;
SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_64;//主频64分步
SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; ////高位在前
SPI_InitStructure.SPI_CRCPolynomial = 7;
SPI_Init(SPI2,&SPI_InitStructure);
ENABLE_MRF();
SPI_Cmd(SPI2,ENABLE);
//--------------I2C--------------
//I2C_Configuration();
// delay_ms(1);
//------------FSMC--------------
LCD_FSMCConfig();
LCD_Init();
//-----------TOUCH-------------
//Read_Ads7843();
/*if(Get_Adjdata()==0)
{
LCD_Clear(WHITE);
LCD_BL_ON();
Touch_Adjust();
}
*/
//------------USB---------------
RCC_USBCLKConfig(RCC_USBCLKSource_PLLCLK_1Div5);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USB, ENABLE);
USB_Init();
}[/code]