From 6cb04b4f01dd8a4fd7da4b49d03afe3bbecb8a92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?SZIGETI=20J=C3=A1nos?= Date: Wed, 29 Jan 2025 19:12:44 +0100 Subject: [PATCH] [ISSUE-27]: DHT22 RMT RX RAM address calculation fixed. --- modules/dht22.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/dht22.c b/modules/dht22.c index 375b342..e8c6b16 100644 --- a/modules/dht22.c +++ b/modules/dht22.c @@ -82,11 +82,12 @@ static void _rxstart(void *pvParam) { static void _rxready(void *pvParam) { SDht22Descriptor *psParam = (SDht22Descriptor*)pvParam; - - RegAddr prData = rmt_ram_addr(psParam->eChannel, 1, 0); - uint32_t u32RecvSize = gpsRMT->asStatus[psParam->eChannel].u9RxIdx; - uint32_t u32DataOfs = u32RecvSize - (DHT22_DATA_LEN * 8) - 1; - bool bLowEnd = (prData[u32RecvSize - 1] & RMT_ENTRYMAX) == 0; + // Note, here we use _absolute_ RMT RAM addresses. + // This works fine since the received data fits into a single RMT RAM block. + RegAddr prData = rmt_ram_block(RMT_CH0); + uint32_t u32RecvEnd = gpsRMT->asStatus[psParam->eChannel].u9RxIdx; + uint32_t u32DataOfs = u32RecvEnd - (DHT22_DATA_LEN * 8) - 1; + bool bLowEnd = (prData[u32RecvEnd - 1] & RMT_ENTRYMAX) == 0; uint8_t u8Shr = bLowEnd ? 0 : 16; memset(&psParam->sData, 0, sizeof (psParam->sData));