diff options
| author | jacqueline <me@jacqueline.id.au> | 2024-03-28 14:32:49 +1100 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2024-03-28 14:32:49 +1100 |
| commit | ee29c25b29eaa4fac4e897442634b69ecc8d8125 (patch) | |
| tree | 8c5f1a140463f20f104316fa3492984e191154e9 /lib/bt/porting/mem | |
| parent | 239e6d89507a24c849385f4bfa93ac4ad58e5de5 (diff) | |
| download | tangara-fw-ee29c25b29eaa4fac4e897442634b69ecc8d8125.tar.gz | |
Fork ESP-IDF's bluetooth component
i want better sbc encoding, and no cla will stop me
Diffstat (limited to 'lib/bt/porting/mem')
| -rw-r--r-- | lib/bt/porting/mem/bt_osi_mem.c | 50 | ||||
| -rw-r--r-- | lib/bt/porting/mem/bt_osi_mem.h | 21 |
2 files changed, 71 insertions, 0 deletions
diff --git a/lib/bt/porting/mem/bt_osi_mem.c b/lib/bt/porting/mem/bt_osi_mem.c new file mode 100644 index 00000000..69c656dd --- /dev/null +++ b/lib/bt/porting/mem/bt_osi_mem.c @@ -0,0 +1,50 @@ +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "esp_attr.h" +#include "esp_heap_caps.h" +#include "sdkconfig.h" + +IRAM_ATTR void *bt_osi_mem_malloc(size_t size) +{ +#ifdef CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_INTERNAL + return heap_caps_malloc(size, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT); +#elif CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_EXTERNAL + return heap_caps_malloc(size, MALLOC_CAP_SPIRAM|MALLOC_CAP_8BIT); +#elif CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_IRAM_8BIT + return heap_caps_malloc_prefer(size, 2, MALLOC_CAP_INTERNAL|MALLOC_CAP_IRAM_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT); +#else + return malloc(size); +#endif +} + +IRAM_ATTR void *bt_osi_mem_calloc(size_t n, size_t size) +{ +#ifdef CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_INTERNAL + return heap_caps_calloc(n, size, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT); +#elif CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_EXTERNAL + return heap_caps_calloc(n, size, MALLOC_CAP_SPIRAM|MALLOC_CAP_8BIT); +#elif CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_IRAM_8BIT + return heap_caps_calloc_prefer(n, size, 2, MALLOC_CAP_INTERNAL|MALLOC_CAP_IRAM_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT); +#else + return calloc(n, size); +#endif +} + +IRAM_ATTR void *bt_osi_mem_malloc_internal(size_t size) +{ + return heap_caps_malloc(size, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT|MALLOC_CAP_DMA); +} + +IRAM_ATTR void *bt_osi_mem_calloc_internal(size_t n, size_t size) +{ + return heap_caps_calloc(n, size, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT|MALLOC_CAP_DMA); +} + +IRAM_ATTR void bt_osi_mem_free(void *ptr) +{ + heap_caps_free(ptr); +} diff --git a/lib/bt/porting/mem/bt_osi_mem.h b/lib/bt/porting/mem/bt_osi_mem.h new file mode 100644 index 00000000..9ab06d0a --- /dev/null +++ b/lib/bt/porting/mem/bt_osi_mem.h @@ -0,0 +1,21 @@ +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include "sdkconfig.h" +#include "esp_attr.h" +#include "esp_heap_caps.h" + +void *bt_osi_mem_malloc(size_t size); + +void *bt_osi_mem_calloc(size_t n, size_t size); + +void *bt_osi_mem_malloc_internal(size_t size); + +void *bt_osi_mem_calloc_internal(size_t n, size_t size); + +void bt_osi_mem_free(void *ptr); |
