Skip to content

Commit feaee0a

Browse files
author
Zhou Xiao
committed
change(ble): replaced le audio log codes with template
1 parent 8b2c176 commit feaee0a

File tree

1 file changed

+36
-52
lines changed

1 file changed

+36
-52
lines changed

components/bt/common/ble_log/ble_log_spi_out.c

Lines changed: 36 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,15 @@
5454
#define SPI_OUT_LL_QUEUE_SIZE (0)
5555
#endif // SPI_OUT_LL_ENABLED
5656

57+
#if SPI_OUT_LE_AUDIO_ENABLED
58+
#define SPI_OUT_LE_AUDIO_QUEUE_SIZE (SPI_OUT_PING_PONG_BUF_CNT)
59+
#else
60+
#define SPI_OUT_LE_AUDIO_QUEUE_SIZE (0)
61+
#endif // SPI_OUT_LE_AUDIO_ENABLED
62+
5763
#define SPI_OUT_SPI_MASTER_QUEUE_SIZE (SPI_OUT_UL_QUEUE_SIZE +\
58-
SPI_OUT_LL_QUEUE_SIZE)
64+
SPI_OUT_LL_QUEUE_SIZE +\
65+
SPI_OUT_LE_AUDIO_QUEUE_SIZE)
5966

6067
// Private typedefs
6168
typedef struct {
@@ -157,11 +164,6 @@ static esp_timer_handle_t ts_sync_timer = NULL;
157164
static esp_timer_handle_t flush_timer = NULL;
158165
#endif // SPI_OUT_FLUSH_TIMER_ENABLED
159166

160-
#if SPI_OUT_LE_AUDIO_ENABLED
161-
static bool le_audio_log_inited = false;
162-
static spi_out_log_cb_t *le_audio_log_cb = NULL;
163-
#endif // SPI_OUT_LE_AUDIO_ENABLED
164-
165167
// Extern function declarations
166168
extern void esp_panic_handler_feed_wdts(void);
167169

@@ -227,11 +229,6 @@ static void esp_timer_cb_ts_sync(void);
227229
#endif // !SPI_OUT_TS_SYNC_SLEEP_SUPPORT
228230
#endif // SPI_OUT_TS_SYNC_ENABLED
229231

230-
#if SPI_OUT_LE_AUDIO_ENABLED
231-
static int spi_out_le_audio_log_init(void);
232-
static void spi_out_le_audio_log_deinit(void);
233-
#endif // SPI_OUT_LE_AUDIO_ENABLED
234-
235232
// Private templates
236233
#define IF_1(...) __VA_ARGS__
237234
#define IF_0(...)
@@ -316,6 +313,10 @@ static void spi_out_le_audio_log_deinit(void);
316313
) \
317314
} \
318315

316+
#if SPI_OUT_LE_AUDIO_ENABLED
317+
DECLARE_LOG_MODULE(le_audio, LOG_CB_TYPE_LE_AUDIO, SPI_OUT_LE_AUDIO_BUF_SIZE, 0, 0)
318+
#endif // SPI_OUT_LE_AUDIO_ENABLED
319+
319320
// Private functions
320321
static int spi_out_init_trans(spi_out_trans_cb_t **trans_cb, uint16_t buf_size)
321322
{
@@ -583,6 +584,10 @@ static void spi_out_log_flush(void)
583584
SPI_OUT_LL_PUT_EV;
584585
}
585586
#endif // SPI_OUT_LL_ENABLED
587+
588+
#if SPI_OUT_LE_AUDIO_ENABLED
589+
LOG_MODULE_FLUSH(le_audio)();
590+
#endif // SPI_OUT_LE_AUDIO_ENABLED
586591
}
587592

588593
#if SPI_OUT_FLUSH_TIMER_ENABLED
@@ -899,40 +904,6 @@ static void esp_timer_cb_ts_sync(void)
899904
#endif // !SPI_OUT_TS_SYNC_SLEEP_SUPPORT
900905
#endif // SPI_OUT_TS_SYNC_ENABLED
901906

902-
#if SPI_OUT_LE_AUDIO_ENABLED
903-
static int spi_out_le_audio_log_init(void)
904-
{
905-
if (le_audio_log_inited) {
906-
return 0;
907-
}
908-
909-
// Initialize log control blocks for controller task & ISR logs
910-
if (spi_out_log_cb_init(&le_audio_log_cb, SPI_OUT_LE_AUDIO_BUF_SIZE, LOG_CB_TYPE_LE_AUDIO) != 0) {
911-
ESP_LOGE(BLE_LOG_TAG, "Failed to initialize log control blocks for LE audio!");
912-
return -1;
913-
}
914-
915-
// Initialization done
916-
ESP_LOGI(BLE_LOG_TAG, "Succeeded to initialize log control blocks for LE Audio!");
917-
le_audio_log_inited = true;
918-
return 0;
919-
}
920-
921-
static void spi_out_le_audio_log_deinit(void)
922-
{
923-
if (!le_audio_log_inited) {
924-
return;
925-
}
926-
927-
spi_out_log_cb_deinit(&le_audio_log_cb);
928-
929-
// Deinitialization done
930-
ESP_LOGI(BLE_LOG_TAG, "Succeeded to deinitialize LE audio log!");
931-
le_audio_log_inited = false;
932-
return;
933-
}
934-
#endif // SPI_OUT_LE_AUDIO_ENABLED
935-
936907
// Public functions
937908
int ble_log_spi_out_init(void)
938909
{
@@ -988,7 +959,7 @@ int ble_log_spi_out_init(void)
988959
#endif // SPI_OUT_TS_SYNC_ENABLED
989960

990961
#if SPI_OUT_LE_AUDIO_ENABLED
991-
if (spi_out_le_audio_log_init() != 0) {
962+
if (LOG_MODULE_INIT(le_audio)() != 0) {
992963
goto le_audio_init_failed;
993964
}
994965
#endif // SPI_OUT_LE_AUDIO_ENABLED
@@ -1018,7 +989,7 @@ int ble_log_spi_out_init(void)
1018989
timer_init_failed:
1019990
#endif // SPI_OUT_FLUSH_TIMER_ENABLED
1020991
#if SPI_OUT_LE_AUDIO_ENABLED
1021-
spi_out_le_audio_log_deinit();
992+
LOG_MODULE_DEINIT(le_audio)();
1022993
le_audio_init_failed:
1023994
#endif // SPI_OUT_LE_AUDIO_ENABLED
1024995
#if SPI_OUT_TS_SYNC_ENABLED
@@ -1065,6 +1036,10 @@ void ble_log_spi_out_deinit(void)
10651036
spi_out_ts_sync_deinit();
10661037
#endif // SPI_OUT_TS_SYNC_ENABLED
10671038

1039+
#if SPI_OUT_LE_AUDIO_ENABLED
1040+
LOG_MODULE_DEINIT(le_audio)();
1041+
#endif // SPI_OUT_LE_AUDIO_ENABLED
1042+
10681043
#if SPI_OUT_LL_ENABLED
10691044
spi_out_ll_log_deinit();
10701045
#endif // SPI_OUT_LL_ENABLED
@@ -1289,6 +1264,15 @@ void ble_log_spi_out_dump_all(void)
12891264
spi_out_log_cb_dump(ul_log_cb);
12901265
esp_rom_printf("\n:UL_LOG_DUMP_END]\n\n");
12911266
}
1267+
1268+
#if SPI_OUT_LE_AUDIO_ENABLED
1269+
if (LOG_MODULE_INIT_FLAG(le_audio)) {
1270+
esp_rom_printf("[LE_AUDIO_LOG_DUMP_START:\n");
1271+
spi_out_log_cb_dump(LOG_MODULE_CB(le_audio));
1272+
esp_rom_printf("\n:LE_AUDIO_LOG_DUMP_END]\n\n");
1273+
}
1274+
#endif // SPI_OUT_LE_AUDIO_ENABLED
1275+
12921276
portEXIT_CRITICAL_SAFE(&spinlock);
12931277
}
12941278

@@ -1315,19 +1299,19 @@ void ble_log_spi_out_flush(void)
13151299
#if CONFIG_BT_BLE_LOG_SPI_OUT_LE_AUDIO_ENABLED
13161300
IRAM_ATTR void ble_log_spi_out_le_audio_write(const uint8_t *addr, uint16_t len)
13171301
{
1318-
if (!le_audio_log_inited) {
1302+
if (!LOG_MODULE_INIT_FLAG(le_audio)) {
13191303
return;
13201304
}
13211305

13221306
bool need_append;
1323-
if (spi_out_log_cb_check_trans(le_audio_log_cb, len, &need_append)) {
1324-
need_append |= spi_out_log_cb_write(le_audio_log_cb, addr, len, NULL, 0,
1307+
if (spi_out_log_cb_check_trans(LOG_MODULE_CB(le_audio), len, &need_append)) {
1308+
need_append |= spi_out_log_cb_write(LOG_MODULE_CB(le_audio), addr, len, NULL, 0,
13251309
BLE_LOG_SPI_OUT_SOURCE_LE_AUDIO, false);
13261310
}
13271311
if (need_append) {
1328-
spi_out_log_cb_append_trans(le_audio_log_cb);
1312+
spi_out_log_cb_append_trans(LOG_MODULE_CB(le_audio));
13291313
}
1330-
spi_out_log_cb_write_loss(le_audio_log_cb);
1314+
spi_out_log_cb_write_loss(LOG_MODULE_CB(le_audio));
13311315
return;
13321316
}
13331317
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_LE_AUDIO_ENABLED

0 commit comments

Comments
 (0)