From 448a0efde42a258139cc8ca61fe53ff3bb4a9b94 Mon Sep 17 00:00:00 2001 From: Kristoffer Richardsson Date: Wed, 8 Aug 2018 15:46:34 +0200 Subject: [PATCH] Corrected word read access of non word aligned data. Closes #13 --- src/libdw1000.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/libdw1000.c b/src/libdw1000.c index e01485b..5db98f1 100644 --- a/src/libdw1000.c +++ b/src/libdw1000.c @@ -770,11 +770,20 @@ bool dwIsReceiveDone(dwDevice_t* dev) { } bool dwIsReceiveFailed(dwDevice_t *dev) { - return *(uint32_t*)dev->sysstatus & SYS_STATUS_ALL_RX_ERR; + bool ldeErr = getBit(dev->sysstatus, LEN_SYS_STATUS, LDEERR_BIT); + bool rxCRCErr = getBit(dev->sysstatus, LEN_SYS_STATUS, RXFCE_BIT); + bool rxHeaderErr = getBit(dev->sysstatus, LEN_SYS_STATUS, RXPHE_BIT); + bool rxDecodeErr = getBit(dev->sysstatus, LEN_SYS_STATUS, RXRFSL_BIT); + + + bool rxSfdto = getBit(dev->sysstatus, LEN_SYS_STATUS, RXSFDTO_BIT); + bool affrej = getBit(dev->sysstatus, LEN_SYS_STATUS, AFFREJ_BIT); + + return (ldeErr || rxCRCErr || rxHeaderErr || rxDecodeErr || rxSfdto || affrej); } bool dwIsReceiveTimeout(dwDevice_t* dev) { - return *(uint32_t*)dev->sysstatus & SYS_STATUS_ALL_RX_TO; + return getBit(dev->sysstatus, LEN_SYS_STATUS, RXRFTO_BIT); } bool dwIsClockProblem(dwDevice_t* dev) {