1# Copyright (c) 2021 Nordic Semiconductor ASA
2# SPDX-License-Identifier: Apache-2.0
3
4config LOG_BACKEND_SWO
5	bool "Serial Wire Output (SWO) backend"
6	depends on HAS_SWO
7	select LOG_BACKEND_SUPPORTS_FORMAT_TIMESTAMP
8	help
9	  When enabled, backend will use SWO for logging.
10
11if LOG_BACKEND_SWO
12
13config LOG_BACKEND_SWO_REF_FREQ_HZ
14	int "SWO reference clock frequency"
15	default $(dt_node_int_prop_int,$(dt_nodelabel_path,itm),swo-ref-frequency) if $(dt_nodelabel_enabled,itm)
16	default $(dt_node_int_prop_int,/cpus/cpu@0,clock-frequency) if $(dt_node_has_prop,/cpus/cpu@0,clock-frequency)
17	default 0
18	help
19	  Set SWO reference frequency. In most cases it is equal to CPU
20	  frequency.
21
22config LOG_BACKEND_SWO_FREQ_HZ
23	int "Set SWO output frequency"
24	default 0
25	help
26	  Set SWO output frequency. Value 0 will select maximum frequency
27	  supported by the given MCU. Not all debug probes support high
28	  frequency SWO operation. In this case the frequency has to be set
29	  manually.
30
31	  SWO value defined by this option will be configured at boot. Most SWO
32	  viewer programs will configure SWO frequency when attached to the
33	  debug probe. Such configuration will persist only until the device
34	  reset. To ensure flawless operation the frequency configured here and
35	  by the SWO viewer program has to match.
36
37choice
38	prompt "SWO protocol"
39	default LOG_BACKEND_SWO_PROTOCOL_NRZ
40
41config LOG_BACKEND_SWO_PROTOCOL_NRZ
42	bool "NRZ encoding"
43	help
44	  Use UART-like NRZ encoding. This is the most common option, but requires the SWO output
45	  frequency to be known on the receiving side.
46
47config LOG_BACKEND_SWO_PROTOCOL_MANCHESTER
48	bool "Manchester encoding"
49	help
50	  Use Manchester encoding. This is less widely supported, but permits the clock to be
51	  recovered automatically on the receiving side.
52
53endchoice
54
55backend = SWO
56backend-str = swo
57source "subsys/logging/Kconfig.template.log_format_config"
58
59endif # LOG_BACKEND_SWO
60