diff options
Diffstat (limited to 'rf_test/send.c')
| -rw-r--r-- | rf_test/send.c | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/rf_test/send.c b/rf_test/send.c index 8e54859..8813f7e 100644 --- a/rf_test/send.c +++ b/rf_test/send.c @@ -15,40 +15,30 @@ #define SPI_PORT PORTB #define STDBY 0x04 -#define LISTEN_ON 0x40 static inline uint8_t read_reg(uint8_t reg) { - uint8_t data; - SPI_PORT &= ~(1 << SPI_SS); - - SPDR = reg | 0x7F; + SPDR = reg & 0x7F; while (!(SPSR & (1 << SPIF))) ; - SPDR = 0; while (!(SPSR & (1 << SPIF))) ; - - data = SPDR; SPI_PORT |= (1 << SPI_SS); - return data; + return SPDR; } static inline void write_reg(uint8_t reg, uint8_t val) { SPI_PORT &= ~(1 << SPI_SS); - SPDR = reg | 0x80; while (!(SPSR & (1 << SPIF))) ; - SPDR = val; while (!(SPSR & (1 << SPIF))) ; - SPI_PORT |= (1 << SPI_SS); } @@ -57,23 +47,18 @@ static inline void radio_init(void) SPI_DDR |= (1 << SPI_SS) | (1 << SPI_SCK) | (1 << SPI_MOSI); SPI_PORT |= (1 << SPI_SS); SPCR |= (1 << SPE) | (1 << MSTR); - - write_reg(0x01, STDBY); } int main(void) { uint8_t val; - char buf[100]; + char buf[5]; serial_init(); - - _delay_ms(3000); - serial_write_line("Initializing radio"); radio_init(); - serial_write_line("Initialized radio"); for (;;) { + write_reg(0x01, 0x04); val = read_reg(0x01); serial_write_line(itoa(val, buf, 16)); _delay_ms(2000); |
