Skip to content

Commit 0e4bb3d

Browse files
committed
checks NRF24 hardware faults
1 parent dd7fcfc commit 0e4bb3d

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/nrf24/nrf24.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -189,18 +189,22 @@ uint8_t nrf24_set_packetlen(FuriHalSpiBusHandle* handle, uint8_t len) {
189189
}
190190

191191
// packet_size: 0 - dyn payload (read from PL_WID), 1 - read from pipe size, >1 - override
192+
// Return STATUS reg + additional: RX_DR - new data available, 0x80 - NRF24 hardware error
192193
uint8_t nrf24_rxpacket(FuriHalSpiBusHandle* handle, uint8_t* packet, uint8_t* ret_packetsize, uint8_t packet_size) {
193194
uint8_t status = 0;
194195
uint8_t buf[33]; // 32 max payload size + 1 for command
195196

196197
status = nrf24_status(handle);
197198
if(!(status & RX_DR)) {
198-
if((nrf24_read_register(handle, REG_FIFO_STATUS) & 1) == 0) {
199+
uint8_t st = nrf24_read_register(handle, REG_FIFO_STATUS);
200+
if(st == 0xFF || st == 0) return 0x80; // hardware error
201+
if((st & 1) == 0) {
199202
FURI_LOG_D("NRF", "FIFO PKT");
200203
status |= RX_DR; // packet in FIFO buffer
201204
}
202205
}
203206
if(status & RX_DR) {
207+
if(status & 0x80) return 0x80; // hardware error
204208
if(packet_size == 1)
205209
packet_size = nrf24_get_packetlen(handle, (status >> 1) & 7);
206210
else if(packet_size == 0){

nrf24batch.c

+3
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,9 @@ bool nrf24_read_newpacket() {
504504
}
505505
//notification_message(APP->notification, &sequence_blink_white_100);
506506
found = true;
507+
} else if(st & 0x80) { // NRF24 hardware error
508+
NRF_ERROR = 1;
509+
NRF_INITED = 0;
507510
}
508511
return found;
509512
}

0 commit comments

Comments
 (0)