⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 spi.c

📁 笔段型TN LCM测试
💻 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 + -