|
37 | 37 | #define SPI_OUT_PACKET_LOSS_FRAME_SIZE (6) |
38 | 38 | #define SPI_OUT_TRANS_ITVL_MIN_US (30) |
39 | 39 | #define SPI_OUT_UL_LOG_STR_BUF_SIZE (100) |
| 40 | +#define SPI_OUT_MALLOC(size) heap_caps_malloc(size, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT) |
40 | 41 |
|
41 | 42 | #if SPI_OUT_TS_SYNC_ENABLED |
42 | 43 | #define SPI_OUT_TS_SYNC_TIMEOUT (1000 * 1000) |
@@ -233,13 +234,13 @@ static void spi_out_le_audio_log_deinit(void); |
233 | 234 | static int spi_out_init_trans(spi_out_trans_cb_t **trans_cb, uint16_t buf_size) |
234 | 235 | { |
235 | 236 | // Memory allocations |
236 | | - *trans_cb = (spi_out_trans_cb_t *)malloc(sizeof(spi_out_trans_cb_t)); |
| 237 | + *trans_cb = (spi_out_trans_cb_t *)SPI_OUT_MALLOC(sizeof(spi_out_trans_cb_t)); |
237 | 238 | if (!(*trans_cb)) { |
238 | 239 | return -1; |
239 | 240 | } |
240 | 241 | memset(*trans_cb, 0, sizeof(spi_out_trans_cb_t)); |
241 | 242 |
|
242 | | - uint8_t *buf = (uint8_t *)spi_bus_dma_memory_alloc(SPI_OUT_BUS, (size_t)buf_size, 0); |
| 243 | + uint8_t *buf = (uint8_t *)SPI_OUT_MALLOC((size_t)buf_size); |
243 | 244 | if (!buf) { |
244 | 245 | free(*trans_cb); |
245 | 246 | *trans_cb = NULL; |
@@ -311,7 +312,7 @@ IRAM_ATTR static inline void spi_out_append_trans(spi_out_trans_cb_t *trans_cb) |
311 | 312 | static int spi_out_log_cb_init(spi_out_log_cb_t **log_cb, uint16_t buf_size, uint8_t type) |
312 | 313 | { |
313 | 314 | // Initialize log control block |
314 | | - *log_cb = (spi_out_log_cb_t *)malloc(sizeof(spi_out_log_cb_t)); |
| 315 | + *log_cb = (spi_out_log_cb_t *)SPI_OUT_MALLOC(sizeof(spi_out_log_cb_t)); |
315 | 316 | if (!(*log_cb)) { |
316 | 317 | ESP_LOGE(BLE_LOG_TAG, "Failed to initialize log control block!"); |
317 | 318 | return -1; |
@@ -427,7 +428,7 @@ IRAM_ATTR static bool spi_out_log_cb_write(spi_out_log_cb_t *log_cb, const uint8 |
427 | 428 |
|
428 | 429 | memcpy(buf, (const uint8_t *)&head, SPI_OUT_FRAME_HEAD_LEN); |
429 | 430 | memcpy(buf + SPI_OUT_FRAME_HEAD_LEN, addr, len); |
430 | | - if (len_append) { |
| 431 | + if (len_append && addr_append) { |
431 | 432 | memcpy(buf + SPI_OUT_FRAME_HEAD_LEN + len, addr_append, len_append); |
432 | 433 | } |
433 | 434 | memcpy(buf + SPI_OUT_FRAME_HEAD_LEN + total_length, &checksum, SPI_OUT_FRAME_TAIL_LEN); |
@@ -520,7 +521,7 @@ static int spi_out_ul_log_init(void) |
520 | 521 | } |
521 | 522 |
|
522 | 523 | // Initialize string buffer |
523 | | - ul_log_str_buf = (uint8_t *)malloc(SPI_OUT_UL_LOG_STR_BUF_SIZE); |
| 524 | + ul_log_str_buf = (uint8_t *)SPI_OUT_MALLOC(SPI_OUT_UL_LOG_STR_BUF_SIZE); |
524 | 525 | if (!ul_log_str_buf) { |
525 | 526 | ESP_LOGE(BLE_LOG_TAG, "Failed to initialize string buffer for upper layer task log!"); |
526 | 527 | goto str_buf_init_failed; |
|
0 commit comments