diff --git a/components/ieee802154/driver/esp_ieee802154_ack.c b/components/ieee802154/driver/esp_ieee802154_ack.c index 2c96bdf99b..1a94a58b22 100644 --- a/components/ieee802154/driver/esp_ieee802154_ack.c +++ b/components/ieee802154/driver/esp_ieee802154_ack.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -17,9 +17,11 @@ static ieee802154_pending_table_t ieee802154_pending_table; -#define BIT_SET(mask, pos) ((mask) |= (1UL << (pos))) -#define BIT_CLR(mask, pos) ((mask) &= ~(1UL << (pos))) -#define BIT_IST(mask, pos) ((mask) & (1UL << (pos))) +#define GET_MASK_ITEM_FROM_TABLE(mask, pos) (mask[(pos + 1) / IEEE802154_PENDING_TABLE_MASK_BITS]) + +#define BIT_SET(mask, pos) (GET_MASK_ITEM_FROM_TABLE(mask, pos) |= (1UL << (pos % IEEE802154_PENDING_TABLE_MASK_BITS))) +#define BIT_CLR(mask, pos) (GET_MASK_ITEM_FROM_TABLE(mask, pos) &= ~(1UL << (pos % IEEE802154_PENDING_TABLE_MASK_BITS))) +#define BIT_IST(mask, pos) (GET_MASK_ITEM_FROM_TABLE(mask, pos) & (1UL << (pos % IEEE802154_PENDING_TABLE_MASK_BITS))) static IRAM_ATTR bool ieee802154_addr_in_pending_table(const uint8_t *addr, bool is_short) { @@ -114,9 +116,9 @@ void ieee802154_reset_pending_table(bool is_short) { // Consider this function may be called in ISR, only clear the mask bits for finishing the process quickly. if (is_short) { - ieee802154_pending_table.short_addr_mask = 0; + memset(ieee802154_pending_table.short_addr_mask, 0, IEEE802154_PENDING_TABLE_MASK_SIZE); } else { - ieee802154_pending_table.ext_addr_mask = 0; + memset(ieee802154_pending_table.ext_addr_mask, 0, IEEE802154_PENDING_TABLE_MASK_SIZE); } } diff --git a/components/ieee802154/private_include/esp_ieee802154_ack.h b/components/ieee802154/private_include/esp_ieee802154_ack.h index 1b44f608b5..793600b91d 100644 --- a/components/ieee802154/private_include/esp_ieee802154_ack.h +++ b/components/ieee802154/private_include/esp_ieee802154_ack.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -8,6 +8,7 @@ #include #include +#include "sdkconfig.h" #include "esp_err.h" #include "esp_ieee802154_frame.h" @@ -18,11 +19,14 @@ extern "C" { /** * @brief The radio pending table, which is utilized to determine whether the received frame should be responded to with pending bit enabled. */ + +#define IEEE802154_PENDING_TABLE_MASK_BITS (8) +#define IEEE802154_PENDING_TABLE_MASK_SIZE ((CONFIG_IEEE802154_PENDING_TABLE_SIZE + 1) / IEEE802154_PENDING_TABLE_MASK_BITS) typedef struct { uint8_t short_addr[CONFIG_IEEE802154_PENDING_TABLE_SIZE][IEEE802154_FRAME_SHORT_ADDR_SIZE]; /*!< Short address table */ uint8_t ext_addr[CONFIG_IEEE802154_PENDING_TABLE_SIZE][IEEE802154_FRAME_EXT_ADDR_SIZE]; /*!< Extend address table */ - uint32_t short_addr_mask; /*!< The mask which the index of short address table is used */ - uint32_t ext_addr_mask; /*!< The mask which the index of extended address table is used */ + uint8_t short_addr_mask[IEEE802154_PENDING_TABLE_MASK_SIZE]; /*!< The mask which the index of short address table is used */ + uint8_t ext_addr_mask[IEEE802154_PENDING_TABLE_MASK_SIZE]; /*!< The mask which the index of extended address table is used */ } ieee802154_pending_table_t; /**