Need help for CC2500 RF module code for Atmea 328

I need the code for CC2500 RF module to communicate with AVRcontroller.
Thanks.

#include <avr/io.h>
#include <util/delay.h>

#define SS PB2
#define MOSI PB3
#define MISO PB4
#define SCK PB5

void SPI_MasterInit(void)
{
DDRB |= (1<<MOSI) | (1<<SCK) | (1<<SS);
DDRB &= ~(1<<MISO);
PORTB |= (1<<SS);
SPCR |= (1<<SPE) | (1<<MSTR) | (1<<SPR0);
}

void SPI_MasterTransmit(char cData)
{
SPDR = cData;
while(!(SPSR & (1<<SPIF)));
}

char SPI_MasterReceive(void)
{
SPI_MasterTransmit(0xFF);
while(!(SPSR & (1<<SPIF)));
return SPDR;
}

void CC2500_Init(void)
{
// Write configuration registers
SPI_MasterTransmit(0x30);
SPI_MasterTransmit(0x0F);
SPI_MasterTransmit(0x06);
// …
}

int main(void)
{
SPI_MasterInit();
CC2500_Init();

while(1)
{
    // Send data
    SPI_MasterTransmit(0x01);
    _delay_ms(10);

    // Receive data
    char data = SPI_MasterReceive();
    // Process received data...
}

}

Please modify the code to meet your needs. It is just starter code.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.