?? spi.c
字號:
// ------------- Functions for simulating Serial Peripheral Interface ----------
// Send a byte to the SPI device
void spi_sendbyte(uint8 dByte)
{
uint8 i;
for (i = 0; i < 8; i++)
{
SPI_SCL = 0;
SPI_SDA = (dByte<<i) & 0x80;
SPI_SCL = 1; // Transfer a bit at rising edge of SPI_SCL
}
}
// Read a byte from the SPI device
uint8 spi_readbyte(void)
{
uint8 i;
uint8 Result;
for (i = 0; i < 8; i++)
{
SPI_SCL = 0;
Result <<= 1;
SPI_SCL = 1;
if (SPI_SDA == 1)
Result |= 0x01;
}
return Result;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -