From c8e79a926620e48830778714cfe4b2ea2453fcaf Mon Sep 17 00:00:00 2001 From: jacqueline Date: Fri, 25 Jul 2025 13:33:07 +1000 Subject: Update forked idf components --- lib/bt/esp_ble_mesh/common/include/mesh/atomic.h | 27 +++++++++++++++++++ lib/bt/esp_ble_mesh/common/include/mesh/mutex.h | 7 ++++- lib/bt/esp_ble_mesh/common/include/mesh/queue.h | 33 ++++++++++++++++++++++++ lib/bt/esp_ble_mesh/common/include/mesh/utils.h | 2 +- 4 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 lib/bt/esp_ble_mesh/common/include/mesh/queue.h (limited to 'lib/bt/esp_ble_mesh/common/include') diff --git a/lib/bt/esp_ble_mesh/common/include/mesh/atomic.h b/lib/bt/esp_ble_mesh/common/include/mesh/atomic.h index f7283436..b2849743 100644 --- a/lib/bt/esp_ble_mesh/common/include/mesh/atomic.h +++ b/lib/bt/esp_ble_mesh/common/include/mesh/atomic.h @@ -147,6 +147,33 @@ static inline bt_mesh_atomic_val_t bt_mesh_atomic_and(bt_mesh_atomic_t *target, extern bt_mesh_atomic_val_t bt_mesh_atomic_and(bt_mesh_atomic_t *target, bt_mesh_atomic_val_t value); #endif +/** + * @brief Atomic CAS operation. + * + * This compares the contents of @a *target + * with the contents of @a excepted. If equal, + * the operation is a read-modify-write operation + * that writes @a new_val into @a *target and return true. + * If they are not equal, the operation is a read + * and return false. + * + * @param target Address of atomic variable. + * @param excepted Value of excepted. + * @param new_val Write if target value is equal to expected one. + * + * @return + * - true: Target value updated. + * - false: Target value not updated. + */ +#ifdef CONFIG_ATOMIC_OPERATIONS_BUILTIN +static inline bool bt_mesh_atomic_cas(bt_mesh_atomic_t *target, bt_mesh_atomic_val_t excepted, bt_mesh_atomic_val_t new_val) +{ + return __atomic_compare_exchange_n(target, &excepted, &new_val, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); +} +#else +extern bool bt_mesh_atomic_cas(bt_mesh_atomic_t *target, bt_mesh_atomic_val_t excepted, bt_mesh_atomic_val_t new_val); +#endif + /** * @cond INTERNAL_HIDDEN */ diff --git a/lib/bt/esp_ble_mesh/common/include/mesh/mutex.h b/lib/bt/esp_ble_mesh/common/include/mesh/mutex.h index ee897500..0cc47eb0 100644 --- a/lib/bt/esp_ble_mesh/common/include/mesh/mutex.h +++ b/lib/bt/esp_ble_mesh/common/include/mesh/mutex.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2017-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -32,6 +32,11 @@ void bt_mesh_r_mutex_free(bt_mesh_mutex_t *mutex); void bt_mesh_r_mutex_lock(bt_mesh_mutex_t *mutex); void bt_mesh_r_mutex_unlock(bt_mesh_mutex_t *mutex); +void bt_mesh_c_semaphore_create(bt_mesh_mutex_t *mutex, int max, int init); +void bt_mesh_c_semaphore_free(bt_mesh_mutex_t *mutex); +void bt_mesh_c_semaphore_give(bt_mesh_mutex_t *mutex); +void bt_mesh_c_semaphore_take(bt_mesh_mutex_t *mutex, uint32_t timeout); + void bt_mesh_alarm_lock(void); void bt_mesh_alarm_unlock(void); diff --git a/lib/bt/esp_ble_mesh/common/include/mesh/queue.h b/lib/bt/esp_ble_mesh/common/include/mesh/queue.h new file mode 100644 index 00000000..021c99ba --- /dev/null +++ b/lib/bt/esp_ble_mesh/common/include/mesh/queue.h @@ -0,0 +1,33 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _BLE_MESH_QUEUE_H_ +#define _BLE_MESH_QUEUE_H_ + +#include "mesh/kernel.h" +#include "mesh/slist.h" +#include "mesh/atomic.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + QueueHandle_t handle; +#if CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC + StaticQueue_t *buffer; + uint8_t *storage; +#endif +} bt_mesh_queue_t; + +int bt_mesh_queue_init(bt_mesh_queue_t *queue, uint16_t queue_size, uint8_t item_size); +int bt_mesh_queue_deinit(bt_mesh_queue_t *queue); + +#ifdef __cplusplus +} +#endif + +#endif /* _BLE_MESH_QUEUE_H_ */ diff --git a/lib/bt/esp_ble_mesh/common/include/mesh/utils.h b/lib/bt/esp_ble_mesh/common/include/mesh/utils.h index 98243483..967fed2e 100644 --- a/lib/bt/esp_ble_mesh/common/include/mesh/utils.h +++ b/lib/bt/esp_ble_mesh/common/include/mesh/utils.h @@ -200,7 +200,7 @@ extern "C" { * { MY_PWM0 , MY_PWM1 } * * @param LEN The length of the sequence. Must be an integer literal less - * than 255. + * than 255 (ref: utils_loops.h). * @param F A macro function that accepts at least two arguments: * F(i, ...). @p F is called repeatedly in the expansion. * Its first argument @p i is the index in the sequence, and -- cgit v1.2.3