我需要一些帮助来尝试读取rc5222 rfid标签,在atmel studio中进行c编程。
#ifndef F_CPU
#define F_CPU 16000000UL //16 Mhz clock speed
#endif
#include <avr/io.h>
#include <util/delay.h>
void spi_init_master(void)
{
DDRB = (1 << 5) | (1 << 3); //mosi,sck output
// Enable SPI, Set as Master
// Prescaler: Fosc/16, Enable Interrupts
SPCR = (1 << SPIE) | (1 << SPE) | (1 << MSTR) | (1 << SPR0);
}
unsigned char spi_transceiver(unsigned char dataout)
{
unsigned char datain;
//LOAD DATA in the buffer
SPDR = dataout;
//wait until transmission complete
while (!((SPSR)&(1 << SPIF)))
//return received data
datain = SPDR;
return datain;
}
我试图初始化SPI传输数据,然后我不知道如何为rfid读取那些char数组。任何帮助都超过了赞赏。