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

📄 spi._c

📁 AVR系列单片机ATMEGA64开发的LED显示屏程序 内容包括ATMEGA64大部分资源的初始化程序
💻 _C
字号:
#include <iom64v.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;
}
main()
{
SpiReadDataReg();
while(1);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -