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