libsi24: small fixes for recv mode
authorRobin Krens <robin@robinkrens.nl>
Sun, 22 Jan 2023 15:03:11 +0000 (16:03 +0100)
committerRobin Krens <robin@robinkrens.nl>
Sun, 22 Jan 2023 15:05:13 +0000 (16:05 +0100)
libsi24.c

index 7427301..d435b5f 100644 (file)
--- a/libsi24.c
+++ b/libsi24.c
@@ -90,11 +90,15 @@ static int _config(si24_t * si)
                ret += _reg_write(si, SI24_REG_DYNPD, &dyn, 1);
                feature_reg |= (1 << EN_DPL);
                ret += _reg_write(si, SI24_REG_FEATURE, &feature_reg, 1);
-               setup_retr_reg = ARD(params->timeout) | ARC(params->retries);
-               ret += _reg_write(si, SI24_REG_SETUP_RETR, &setup_retr_reg, 1);
+               if (params->mode == SEND_MODE) {
+                       setup_retr_reg = ARD(params->timeout) | ARC(params->retries);
+                       ret += _reg_write(si, SI24_REG_SETUP_RETR, &setup_retr_reg, 1);
+               }
        } else {
-               feature_reg |= (1 << EN_DYN_ACK);
-               ret += _reg_write(si, SI24_REG_FEATURE, &feature_reg, 1);
+               if (params->mode == SEND_MODE) {
+                       feature_reg |= (1 << EN_DYN_ACK);
+                       ret += _reg_write(si, SI24_REG_FEATURE, &feature_reg, 1);
+               }
        }
 
        uint8_t aw;
@@ -290,7 +294,7 @@ int main(void)
        };
 
        const si24_opts_t opts = {
-               .mode = SEND_MODE,
+               .mode = RECV_MODE,
                .enable_ack = 1,
                .non_blocking = 0,
                .enable_crc = 1,