mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-30 10:47:19 +02:00
change(ble): bugs fixed on spi ble log
* removed spi master in iram select for flash only firmware * fixed memory issue in transaction init function * fixed memory issue in transaction deinit function
This commit is contained in:
@ -9,7 +9,6 @@ config BT_ALARM_MAX_NUM
|
|||||||
config BT_BLE_LOG_SPI_OUT_ENABLED
|
config BT_BLE_LOG_SPI_OUT_ENABLED
|
||||||
bool "Output ble logs to SPI bus (Experimental)"
|
bool "Output ble logs to SPI bus (Experimental)"
|
||||||
default n
|
default n
|
||||||
select SPI_MASTER_IN_IRAM
|
|
||||||
help
|
help
|
||||||
Output ble logs to SPI bus
|
Output ble logs to SPI bus
|
||||||
|
|
||||||
|
@ -140,14 +140,16 @@ static int spi_out_init_trans(spi_out_trans_cb_t **trans_cb, uint16_t buf_size)
|
|||||||
if (!(*trans_cb)) {
|
if (!(*trans_cb)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
memset(*trans_cb, 0, sizeof(spi_out_trans_cb_t));
|
||||||
|
|
||||||
uint8_t *buf = (uint8_t *)heap_caps_malloc(buf_size, MALLOC_CAP_DMA);
|
uint8_t *buf = (uint8_t *)heap_caps_malloc(buf_size, MALLOC_CAP_DMA);
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
free(*trans_cb);
|
free(*trans_cb);
|
||||||
|
*trans_cb = NULL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialization
|
// Initialization
|
||||||
memset(*trans_cb, 0, sizeof(spi_out_trans_cb_t));
|
|
||||||
(*trans_cb)->buf_size = buf_size;
|
(*trans_cb)->buf_size = buf_size;
|
||||||
(*trans_cb)->trans.tx_buffer = buf;
|
(*trans_cb)->trans.tx_buffer = buf;
|
||||||
return 0;
|
return 0;
|
||||||
@ -158,8 +160,13 @@ static void spi_out_deinit_trans(spi_out_trans_cb_t **trans_cb)
|
|||||||
if (!(*trans_cb)) {
|
if (!(*trans_cb)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if ((*trans_cb)->trans.tx_buffer) {
|
||||||
|
// Do not free buffer until recycled
|
||||||
|
while ((*trans_cb)->flag == SPI_OUT_TRANS_CB_FLAG_IN_QUEUE) {}
|
||||||
|
free((uint8_t *)(*trans_cb)->trans.tx_buffer);
|
||||||
|
(*trans_cb)->trans.tx_buffer = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
free((uint8_t *)(*trans_cb)->trans.tx_buffer);
|
|
||||||
free(*trans_cb);
|
free(*trans_cb);
|
||||||
*trans_cb = NULL;
|
*trans_cb = NULL;
|
||||||
return;
|
return;
|
||||||
@ -174,7 +181,7 @@ IRAM_ATTR static void spi_out_tx_done_cb(spi_transaction_t *ret_trans)
|
|||||||
|
|
||||||
IRAM_ATTR static inline int spi_out_append_trans(spi_out_trans_cb_t *trans_cb)
|
IRAM_ATTR static inline int spi_out_append_trans(spi_out_trans_cb_t *trans_cb)
|
||||||
{
|
{
|
||||||
if (trans_cb->flag != SPI_OUT_TRANS_CB_FLAG_NEED_QUEUE) {
|
if (trans_cb->flag != SPI_OUT_TRANS_CB_FLAG_NEED_QUEUE || !trans_cb->length) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,6 +192,8 @@ IRAM_ATTR static inline int spi_out_append_trans(spi_out_trans_cb_t *trans_cb)
|
|||||||
trans_cb->flag = SPI_OUT_TRANS_CB_FLAG_IN_QUEUE;
|
trans_cb->flag = SPI_OUT_TRANS_CB_FLAG_IN_QUEUE;
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
|
trans_cb->length = 0;
|
||||||
|
trans_cb->flag = SPI_OUT_TRANS_CB_FLAG_AVAILABLE;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -224,6 +233,7 @@ static void spi_out_log_cb_deinit(spi_out_log_cb_t **log_cb)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(*log_cb);
|
free(*log_cb);
|
||||||
|
*log_cb = NULL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -578,7 +588,7 @@ static void spi_out_ts_sync_deinit(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CRITICAL: This function is called in ESP Timer task
|
// CRITICAL: This function is called in ESP Timer task
|
||||||
IRAM_ATTR static void esp_timer_cb_ts_sync(void)
|
static void esp_timer_cb_ts_sync(void)
|
||||||
{
|
{
|
||||||
// Initialize variables
|
// Initialize variables
|
||||||
uint32_t lc_ts = 0;
|
uint32_t lc_ts = 0;
|
||||||
@ -627,7 +637,9 @@ int ble_log_spi_out_init(void)
|
|||||||
.quadwp_io_num = -1,
|
.quadwp_io_num = -1,
|
||||||
.quadhd_io_num = -1,
|
.quadhd_io_num = -1,
|
||||||
.max_transfer_sz = SPI_OUT_MAX_TRANSFER_SIZE,
|
.max_transfer_sz = SPI_OUT_MAX_TRANSFER_SIZE,
|
||||||
|
#if CONFIG_SPI_MASTER_ISR_IN_IRAM
|
||||||
.intr_flags = ESP_INTR_FLAG_IRAM
|
.intr_flags = ESP_INTR_FLAG_IRAM
|
||||||
|
#endif // CONFIG_SPI_MASTER_ISR_IN_IRAM
|
||||||
};
|
};
|
||||||
spi_device_interface_config_t dev_config = {
|
spi_device_interface_config_t dev_config = {
|
||||||
.clock_speed_hz = SPI_MASTER_FREQ_20M,
|
.clock_speed_hz = SPI_MASTER_FREQ_20M,
|
||||||
@ -782,7 +794,7 @@ IRAM_ATTR void ble_log_spi_out_ll_log_ev_proc(void)
|
|||||||
}
|
}
|
||||||
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_LL_ENABLED
|
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_LL_ENABLED
|
||||||
|
|
||||||
IRAM_ATTR int ble_log_spi_out_write(uint8_t source, const uint8_t *addr, uint16_t len)
|
int ble_log_spi_out_write(uint8_t source, const uint8_t *addr, uint16_t len)
|
||||||
{
|
{
|
||||||
if (!ul_log_inited) {
|
if (!ul_log_inited) {
|
||||||
return -1;
|
return -1;
|
||||||
@ -798,7 +810,7 @@ IRAM_ATTR int ble_log_spi_out_write(uint8_t source, const uint8_t *addr, uint16_
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
IRAM_ATTR int ble_log_spi_out_printf(uint8_t source, const char *format, ...)
|
int ble_log_spi_out_printf(uint8_t source, const char *format, ...)
|
||||||
{
|
{
|
||||||
if (!ul_log_inited) {
|
if (!ul_log_inited) {
|
||||||
return -1;
|
return -1;
|
||||||
@ -845,7 +857,7 @@ IRAM_ATTR int ble_log_spi_out_printf(uint8_t source, const char *format, ...)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
IRAM_ATTR int ble_log_spi_out_printf_enh(uint8_t source, uint8_t level, const char *tag, const char *format, ...)
|
int ble_log_spi_out_printf_enh(uint8_t source, uint8_t level, const char *tag, const char *format, ...)
|
||||||
{
|
{
|
||||||
if (!ul_log_inited) {
|
if (!ul_log_inited) {
|
||||||
return -1;
|
return -1;
|
||||||
@ -897,7 +909,7 @@ IRAM_ATTR int ble_log_spi_out_printf_enh(uint8_t source, uint8_t level, const ch
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
IRAM_ATTR int ble_log_spi_out_write_with_ts(uint8_t source, const uint8_t *addr, uint16_t len)
|
int ble_log_spi_out_write_with_ts(uint8_t source, const uint8_t *addr, uint16_t len)
|
||||||
{
|
{
|
||||||
if (!ul_log_inited) {
|
if (!ul_log_inited) {
|
||||||
return -1;
|
return -1;
|
||||||
|
Reference in New Issue
Block a user