summaryrefslogtreecommitdiffstats
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c37
1 files changed, 20 insertions, 17 deletions
diff --git a/main.c b/main.c
index 604da00..c049728 100644
--- a/main.c
+++ b/main.c
@@ -5,15 +5,20 @@
#include "uart.h"
-#define SPI_SS PB2
-#define SPI_SCK PB5
-#define SPI_MISO PB4
-#define SPI_MOSI PB3
-#define SPI_DDR DDRB
-#define SPI_PORT PORTB
+#define SPI_SS PB2
+#define SPI_SCK PB5
+#define SPI_MISO PB4
+#define SPI_MOSI PB3
+#define SPI_DDR DDRB
+#define SPI_PORT PORTB
-#define NRF_CE PB1
-#define NRF_IRQ PD7
+#define NRF_CE PB1
+#define NRF_CE_DDR DDRB
+#define NRF_CE_PORT PORTB
+
+#define NRF_IRQ PD7
+
+#define NRF_RST_DELAY_MS 100
static inline uint8_t read_reg(uint8_t reg)
{
@@ -34,25 +39,23 @@ void radio_init(void)
SPI_PORT |= (1 << SPI_SS);
SPCR |= (1 << SPE) | (1 << MSTR);
- // CE=0 for standby-i mode
- DDRB |= (1 << NRF_CE);
- PORTB &= ~(1 << NRF_CE);
+ NRF_CE_DDR |= (1 << NRF_CE);
+ NRF_CE_PORT &= ~(1 << NRF_CE);
- _delay_ms(500);
+ _delay_ms(NRF_RST_DELAY_MS);
}
int main(void)
{
- char s[5];
+ char s[15];
+ uint8_t rv;
uart_init();
radio_init();
for (int i = 0; i < 10; i++) {
- uint8_t val = read_reg(0x00);
- sprintf(s, "%x", val);
-
- uart_write("CONFIG: ");
+ rv = read_reg(0x00);
+ sprintf(s, "config: 0x%x", rv);
uart_write_line(s);
}