summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--rf_test/Recv.Makefile2
-rw-r--r--rf_test/Send.Makefile2
-rw-r--r--rf_test/send.c25
-rw-r--r--rf_test/serial.c2
-rw-r--r--rf_test/serial.h1
5 files changed, 17 insertions, 15 deletions
diff --git a/rf_test/Recv.Makefile b/rf_test/Recv.Makefile
index 26cb45a..1c6733b 100644
--- a/rf_test/Recv.Makefile
+++ b/rf_test/Recv.Makefile
@@ -9,7 +9,7 @@ CFLAGS = -std=gnu99
CFLAGS += -Os
CFLAGS += -Wall
CFLAGS += -mmcu=$(MCU)
-CFLAGS += -DF_BAUD=115200
+CFLAGS += -DBAUD=115200
CFLAGS += -DF_CPU=16000000UL
CFLAGS += -ffunction-sections -fdata-sections
diff --git a/rf_test/Send.Makefile b/rf_test/Send.Makefile
index 3fa9329..6e171b1 100644
--- a/rf_test/Send.Makefile
+++ b/rf_test/Send.Makefile
@@ -9,7 +9,7 @@ CFLAGS = -std=gnu99
CFLAGS += -Os
CFLAGS += -Wall
CFLAGS += -mmcu=$(MCU)
-CFLAGS += -DF_BAUD=115200
+CFLAGS += -DBAUD=115200
CFLAGS += -DF_CPU=16000000UL
CFLAGS += -ffunction-sections -fdata-sections
diff --git a/rf_test/send.c b/rf_test/send.c
index e8535e3..8e54859 100644
--- a/rf_test/send.c
+++ b/rf_test/send.c
@@ -1,3 +1,5 @@
+#include <stdlib.h>
+
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
@@ -50,33 +52,32 @@ static inline void write_reg(uint8_t reg, uint8_t val)
SPI_PORT |= (1 << SPI_SS);
}
-static inline void set_mode(uint8_t mode)
-{
- write_reg(0x01, mode);
- while (!read_reg(0x27))
- ;
-}
-
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);
-
- set_mode(STDBY | LISTEN_ON);
+
+ write_reg(0x01, STDBY);
}
int main(void)
{
+ uint8_t val;
+ char buf[100];
+
serial_init();
- _delay_ms(5000);
+ _delay_ms(3000);
serial_write_line("Initializing radio");
radio_init();
serial_write_line("Initialized radio");
- for (;;)
- ;
+ for (;;) {
+ val = read_reg(0x01);
+ serial_write_line(itoa(val, buf, 16));
+ _delay_ms(2000);
+ }
return 0;
}
diff --git a/rf_test/serial.c b/rf_test/serial.c
index 0b9aecf..a7dbb93 100644
--- a/rf_test/serial.c
+++ b/rf_test/serial.c
@@ -16,7 +16,7 @@ void serial_init(void)
UCSR0C = (1 << UCSZ01) | (1 << UCSZ00);
}
-static void serial_write(unsigned char data)
+void serial_write(unsigned char data)
{
while (!(UCSR0A & (1 << UDRE0)))
;
diff --git a/rf_test/serial.h b/rf_test/serial.h
index 6128623..96fdcab 100644
--- a/rf_test/serial.h
+++ b/rf_test/serial.h
@@ -2,6 +2,7 @@
#define SA_SERIAL_H
void serial_init(void);
+void serial_write(unsigned char data);
void serial_write_line(const char *s);
#endif /* SA_SERIAL_H */