forked from espressif/esp-idf
feat(ble): provided dynamic spi enable/disable api
(cherry picked from commit 3568f19fef
)
Co-authored-by: Zhou Xiao <zhouxiao@espressif.com>
This commit is contained in:
@ -91,6 +91,7 @@ enum {
|
|||||||
|
|
||||||
// Private variables
|
// Private variables
|
||||||
static bool spi_out_inited = false;
|
static bool spi_out_inited = false;
|
||||||
|
static bool spi_out_enabled = false;
|
||||||
static spi_device_handle_t spi_handle = NULL;
|
static spi_device_handle_t spi_handle = NULL;
|
||||||
static uint32_t last_tx_done_ts = 0;
|
static uint32_t last_tx_done_ts = 0;
|
||||||
|
|
||||||
@ -239,6 +240,13 @@ IRAM_ATTR static inline int spi_out_append_trans(spi_out_trans_cb_t *trans_cb)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Note: To support dump log when disabled
|
||||||
|
if (!spi_out_enabled) {
|
||||||
|
trans_cb->length = 0;
|
||||||
|
trans_cb->flag = TRANS_CB_FLAG_AVAILABLE;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// CRITICAL: Length unit conversion from bytes to bits
|
// CRITICAL: Length unit conversion from bytes to bits
|
||||||
trans_cb->trans.length = trans_cb->length * 8;
|
trans_cb->trans.length = trans_cb->length * 8;
|
||||||
trans_cb->trans.rxlength = 0;
|
trans_cb->trans.rxlength = 0;
|
||||||
@ -740,6 +748,7 @@ int ble_log_spi_out_init(void)
|
|||||||
// Initialization done
|
// Initialization done
|
||||||
ESP_LOGI(BLE_LOG_TAG, "Succeeded to initialize BLE log SPI output interface!");
|
ESP_LOGI(BLE_LOG_TAG, "Succeeded to initialize BLE log SPI output interface!");
|
||||||
spi_out_inited = true;
|
spi_out_inited = true;
|
||||||
|
spi_out_enabled = true;
|
||||||
|
|
||||||
#if SPI_OUT_FLUSH_TIMER_ENABLED
|
#if SPI_OUT_FLUSH_TIMER_ENABLED
|
||||||
// Start flushout timer
|
// Start flushout timer
|
||||||
@ -796,6 +805,7 @@ void ble_log_spi_out_deinit(void)
|
|||||||
|
|
||||||
// Reset init flag
|
// Reset init flag
|
||||||
spi_out_inited = false;
|
spi_out_inited = false;
|
||||||
|
spi_out_enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SPI_OUT_TS_SYNC_ENABLED
|
#if SPI_OUT_TS_SYNC_ENABLED
|
||||||
@ -1050,4 +1060,15 @@ void ble_log_spi_out_dump_all(void)
|
|||||||
portEXIT_CRITICAL_SAFE(&spinlock);
|
portEXIT_CRITICAL_SAFE(&spinlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ble_log_spi_out_enable(bool enable)
|
||||||
|
{
|
||||||
|
spi_out_enabled = enable;
|
||||||
|
|
||||||
|
if (!enable) {
|
||||||
|
#if CONFIG_BT_BLE_LOG_SPI_OUT_TS_SYNC_ENABLED
|
||||||
|
ble_log_spi_out_ts_sync_stop();
|
||||||
|
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_TS_SYNC_ENABLED
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||||
|
@ -55,5 +55,6 @@ int ble_log_spi_out_printf(uint8_t source, const char *format, ...);
|
|||||||
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, ...);
|
||||||
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);
|
||||||
void ble_log_spi_out_dump_all(void);
|
void ble_log_spi_out_dump_all(void);
|
||||||
|
void ble_log_spi_out_enable(bool enable);
|
||||||
|
|
||||||
#endif // __BT_SPI_OUT_H__
|
#endif // __BT_SPI_OUT_H__
|
||||||
|
Reference in New Issue
Block a user