//模拟SPI
unsigned char SPIPutChar(unsigned char data) { unsigned char x = 0,temp=0,i; for(i=0;i<8;i++) { x= data&0x80; GPIOPinWrite(CTL_PORT,CLK,0x00); // CLK输出低电平 if(x==0x80) { GPIOPinWrite(CTL_PORT,SI,0xFF); // SI输出高电平 } else { GPIOPinWrite(CTL_PORT,SI,0x00); // SI输出低电平 } GPIOPinWrite(CTL_PORT,CLK,0xFF); // CLK输出高电平 temp<<= 1; // delay(2); GPIOPinWrite(CTL_PORT,CLK,0x00); // CLK输出高电平 // delay(2); if(GPIOPinRead(CTL_PORT,SO)) { temp=temp&0x01; } else { temp=temp&0x00; } data<<=1; } return(temp); }
MP3.rar
(1.21 MB, 下载次数: 119)
|