summaryrefslogtreecommitdiffstats
path: root/nRF24L01/radio.c
diff options
context:
space:
mode:
authorSadeep Madurange <sadeep@asciimx.com>2025-02-01 13:28:46 +0800
committerSadeep Madurange <sadeep@asciimx.com>2025-02-01 13:28:46 +0800
commitd84152a969653b5b887a605db0afe8acd173b184 (patch)
tree9245b0c7811e9e273d1a0957a0f955ea89a1a9af /nRF24L01/radio.c
parent426233da0802b1d02f9c30dc901f6d7307a834c8 (diff)
downloadsmart-home-d84152a969653b5b887a605db0afe8acd173b184.tar.gz
wip
Diffstat (limited to 'nRF24L01/radio.c')
-rw-r--r--nRF24L01/radio.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/nRF24L01/radio.c b/nRF24L01/radio.c
index b68b600..42035f8 100644
--- a/nRF24L01/radio.c
+++ b/nRF24L01/radio.c
@@ -58,10 +58,10 @@
#define NRF24L01_W_TX_PAYLOAD_NOACK 0xB0
#define NRF24L01_NOP 0xFF
-#define NRF24L01_EN_RX_DR_IRQ 0x3F
-#define NRF24L01_EN_TX_DS_IRQ 0x5F
-#define NRF24L01_EN_MAX_RT_IRQ 0x6F
-#define NRF24L01_CRCO_BYTE_2 0x04
+#define NRF24L01_DIS_RX_DR_IRQ 0x40
+#define NRF24L01_DIS_TX_DS_IRQ 0x20
+#define NRF24L01_DIS_MAX_RT_IRQ 0x10
+#define NRF24L01_CRCO_LEN_2 0x04
static inline uint8_t read_reg(uint8_t reg)
{
@@ -100,6 +100,11 @@ void radio_listen(void)
{
}
+static inline void write_config_reg(uint8_t val)
+{
+ write_reg(NRF24L01_REG_CONFIG, (0x7F & val));
+}
+
void radio_init(const struct radio_cfg *cfg)
{
SPI_DDR |= (1 << SPI_SS) | (1 << SPI_SCK) | (1 << SPI_MOSI);
@@ -111,7 +116,8 @@ void radio_init(const struct radio_cfg *cfg)
_delay_ms(NRF24L01_POWER_ON_RST_DELAY);
- write_reg(NRF24L01_REG_CONFIG,
- !(NRF24L01_EN_RX_DR_IRQ & NRF24L01_EN_TX_DS_IRQ & NRF24L01_EN_MAX_RT_IRQ)
- | NRF24L01_CRCO_BYTE_2);
+ write_config_reg((NRF24L01_DIS_RX_DR_IRQ
+ | NRF24L01_DIS_TX_DS_IRQ
+ | NRF24L01_DIS_MAX_RT_IRQ
+ | NRF24L01_CRCO_LEN_2));
}