📄 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 + -