|
1 | 1 | /* |
2 | | - * SPDX-FileCopyrightText: 2017-2024 Espressif Systems (Shanghai) CO LTD |
| 2 | + * SPDX-FileCopyrightText: 2017-2025 Espressif Systems (Shanghai) CO LTD |
3 | 3 | * |
4 | 4 | * SPDX-License-Identifier: Apache-2.0 OR MIT |
5 | 5 | */ |
@@ -80,31 +80,30 @@ ESP_SYSTEM_INIT_FN(esp_apptrace_init, SECONDARY, ESP_SYSTEM_INIT_ALL_CORES, 115) |
80 | 80 | return esp_apptrace_init(); |
81 | 81 | } |
82 | 82 |
|
83 | | -void esp_apptrace_down_buffer_config(uint8_t *buf, uint32_t size) |
| 83 | +esp_err_t esp_apptrace_down_buffer_config(esp_apptrace_dest_t dest, uint8_t *buf, uint32_t size) |
84 | 84 | { |
85 | 85 | esp_apptrace_channel_t *ch; |
86 | 86 |
|
| 87 | + if (dest >= ESP_APPTRACE_DEST_MAX) { |
| 88 | + return ESP_ERR_INVALID_ARG; |
| 89 | + } |
| 90 | + if (buf == NULL || size == 0) { |
| 91 | + return ESP_ERR_INVALID_ARG; |
| 92 | + } |
87 | 93 | if (!s_inited) { |
88 | | - return; |
89 | | - } |
90 | | - // currently down buffer is supported for JTAG interface only |
91 | | - // TODO: one more argument should be added to this function to specify HW interface: JTAG, UART0 etc |
92 | | - ch = &s_trace_channels[ESP_APPTRACE_DEST_JTAG]; |
93 | | - if (ch->hw != NULL) { |
94 | | - if (ch->hw->down_buffer_config != NULL) { |
95 | | - ch->hw->down_buffer_config(ch->hw_data, buf, size); |
96 | | - } |
97 | | - } else { |
98 | | - ESP_APPTRACE_LOGD("Trace destination for JTAG not supported!"); |
| 94 | + return ESP_ERR_INVALID_STATE; |
99 | 95 | } |
100 | | - ch = &s_trace_channels[ESP_APPTRACE_DEST_UART]; |
101 | | - if (ch->hw != NULL) { |
102 | | - if (ch->hw->down_buffer_config != NULL) { |
103 | | - ch->hw->down_buffer_config(ch->hw_data, buf, size); |
104 | | - } |
105 | | - } else { |
106 | | - ESP_APPTRACE_LOGD("Trace destination for UART not supported!"); |
| 96 | + |
| 97 | + ch = &s_trace_channels[dest]; |
| 98 | + if (ch->hw == NULL) { |
| 99 | + ESP_APPTRACE_LOGE("Trace destination %d not supported!", dest); |
| 100 | + return ESP_FAIL; |
| 101 | + } |
| 102 | + if (ch->hw->down_buffer_config != NULL) { |
| 103 | + ch->hw->down_buffer_config(ch->hw_data, buf, size); |
107 | 104 | } |
| 105 | + |
| 106 | + return ESP_OK; |
108 | 107 | } |
109 | 108 |
|
110 | 109 | uint8_t *esp_apptrace_down_buffer_get(esp_apptrace_dest_t dest, uint32_t *size, uint32_t user_tmo) |
|
0 commit comments