summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSadeep Madurange <sadeep@asciimx.com>2025-01-19 13:23:36 +0800
committerSadeep Madurange <sadeep@asciimx.com>2025-01-19 13:23:36 +0800
commiteeb5ad7b9e009b034114635a98294ac01f847f1f (patch)
tree9a48173cb00b0cd879f5d74226cfe264817335ec
parent60de3d7c7bf6394e214ee78bc0c89398715e2b87 (diff)
downloadsmart-home-eeb5ad7b9e009b034114635a98294ac01f847f1f.tar.gz
Switch to standby mode after tx is complete.
-rw-r--r--rf_test/radio.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/rf_test/radio.c b/rf_test/radio.c
index 9db0f05..143a67c 100644
--- a/rf_test/radio.c
+++ b/rf_test/radio.c
@@ -22,6 +22,7 @@
#define RF69_REG_TESTPA1 0x5A
#define RF69_REG_TESTPA2 0x5C
#define RF69_REG_IRQFLAGS1 0x27
+#define RF69_REG_IRQFLAGS2 0x28
#define RF69_PALEVEL_PA1 0x40
#define RF69_PALEVEL_PA2 0x20
@@ -112,6 +113,7 @@ void radio_send(const char *data, uint8_t n)
set_mode(RF69_OPMODE_STDBY);
cli();
+
SPI_PORT &= ~(1 << SPI_SS);
SPDR = 0x00 | 0x80;
@@ -125,8 +127,13 @@ void radio_send(const char *data, uint8_t n)
}
SPI_PORT |= (1 << SPI_SS);
+
sei();
set_mode(RF69_OPMODE_TX);
+
+ while (!(read_reg(RF69_REG_IRQFLAGS2) & 0x08))
+ ;
+ set_mode(RF69_OPMODE_STDBY);
}
uint8_t radio_recv(char *buf, uint8_t n)