小弟菜蔬,对代码理解不到位还希望各位大佬帮忙解释下
for(u32DataCount=0; u32DataCount<TEST_COUNT; u32DataCount++) {
g_au32SourceData[u32DataCount] = 0x00550000 + u32DataCount;
g_au32DestinationData[u32DataCount] = 0;
}
printf("Before starting the data transfer, make sure the slave device is ready. Press any key to start the transfer.\n");
getchar();
printf("\n");
SPI_EnableInt(SPI0, SPI_IE_MASK);
NVIC_EnableIRQ(SPI_IRQn);
for(i=0; i<TEST_COUNT; i++) {
g_u8Done = 0;
SPI_WRITE_TX(SPI0, g_au32SourceData[i]);
SPI_TRIGGER(SPI0);
while(!g_u8Done);
g_au32DestinationData[i] = SPI_READ_RX(SPI0);
}
printf("Received data:\n");
for(u32DataCount=0; u32DataCount<TEST_COUNT; u32DataCount++) {
printf("%d:\t0x%08X\n", u32DataCount, g_au32DestinationData[u32DataCount]);
}
printf("The data transfer was done.\n");
我的源代码
void Lcd_WrCmdByte(uint8_t iCmd)
{
GPIO_ResetBits(GPIOB,LCD_DC);
GPIO_ResetBits(GPIOB,LCD_CS);
SpiW4_SendByte(iCmd);
GPIO_SetBits(GPIOB,LCD_CS);
GPIO_SetBits(GPIOB,LCD_DC);
}
//*****************************************************************
void Lcd_WrDataByte(uint8_t iData)
{
GPIO_SetBits(GPIOB,LCD_DC);
GPIO_ResetBits(GPIOB,LCD_CS);
SpiW4_SendByte(iData);
GPIO_SetBits(GPIOB,LCD_CS);
GPIO_SetBits(GPIOB,LCD_DC);
}
void SpiW4_SendByte(uint8_t iData)
{
uint8_t i=0,Data_temp=iData;
for(i=0;i<8;i++)
{
GPIO_ResetBits(GPIOB,LCD_SCL);
SpiW4_Delay(5);
if(Data_temp&0x80)
{
GPIO_SetBits(GPIOB,LCD_SDA);
}
else
{
GPIO_ResetBits(GPIOB,LCD_SDA);
}
GPIO_SetBits(GPIOB,LCD_SCL);
Data_temp<<=1;
}
}
这个可以实现移植吗?求详解 |