spi.c
来自「AVR下的ICC所有函数库代码」· C语言 代码 · 共 43 行
C
43 行
#include <io8515.h> // change to the appropriate header file
#include "spi.h"
/* spi_init function should be generated using the AppBuilder
*/
/*
** SpiWriteByte() writes a byte to the SPI and waits until
** it has been transmitted. This function doesn't
** return any value back.
*/
void SpiWriteByte(unsigned char byte)
{
SPDR = byte;
while (!(SPSR & 0x80));
byte = SPDR;
}
/*
** SpiReadByte() first writes a byte (a dummy, since
** that byte is to generate clock signals to "poll" home
** the byte from the slave. The function returns the
** received byte.
*/
unsigned char SpiReadByte(void)
{
SPDR = 0x00;
while (!(SPSR & 0x80));
return SPDR;
}
/*
** SpiReadDataReg() reads the last byte in the SPI register
** without any clock signals generated. Could be used
** as reading the last byte received.
*/
unsigned char SpiReadDataReg(void)
{
return SPDR;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?