OpenOCD
swo.c File Reference

Serial Wire Output (SWO) functions. More...

Include dependency graph for swo.c:

Go to the source code of this file.

Functions

JAYLINK_API int jaylink_swo_get_speeds (struct jaylink_device_handle *devh, enum jaylink_swo_mode mode, struct jaylink_swo_speed *speed)
 Retrieve SWO speeds. More...
 
JAYLINK_API int jaylink_swo_read (struct jaylink_device_handle *devh, uint8_t *buffer, uint32_t *length)
 Read SWO trace data. More...
 
JAYLINK_API int jaylink_swo_start (struct jaylink_device_handle *devh, enum jaylink_swo_mode mode, uint32_t baudrate, uint32_t size)
 Start SWO capture. More...
 
JAYLINK_API int jaylink_swo_stop (struct jaylink_device_handle *devh)
 Stop SWO capture. More...
 

Detailed Description

Serial Wire Output (SWO) functions.

Definition in file swo.c.

Function Documentation

◆ jaylink_swo_get_speeds()

JAYLINK_API int jaylink_swo_get_speeds ( struct jaylink_device_handle devh,
enum jaylink_swo_mode  mode,
struct jaylink_swo_speed speed 
)

Retrieve SWO speeds.

The speeds are calculated as follows:

speeds = freq / n with n >= min_div and n <= max_div, where n is an integer

Assuming, for example, a base frequency freq of 4500 kHz, a minimum divider min_div of 1 and a maximum divider max_div of 8 then the highest possible SWO speed is 4500 kHz / 1 = 4500 kHz. The next highest speed is 2250 kHz for a divider of 2, and so on. Accordingly, the lowest possible speed is 4500 kHz / 8 = 562.5 kHz.

Note
This function must be used only if the device has the JAYLINK_DEV_CAP_SWO capability.
Parameters
[in,out]devhDevice handle.
[in]modeCapture mode to retrieve speeds for.
[out]speedSpeed information on success, and undefined on failure.
Return values
JAYLINK_OKSuccess.
JAYLINK_ERR_ARGInvalid arguments.
JAYLINK_ERR_TIMEOUTA timeout occurred.
JAYLINK_ERR_PROTOProtocol violation.
JAYLINK_ERR_IOInput/output error.
JAYLINK_ERR_DEVUnspecified device error.
JAYLINK_ERROther error conditions.
Since
0.1.0

Definition at line 345 of file swo.c.

References buffer_get_u32(), buffer_set_u32(), jaylink_device::ctx, jaylink_device_handle::dev, jaylink_swo_speed::freq, JAYLINK_ERR_ARG, JAYLINK_ERR_DEV, JAYLINK_ERR_PROTO, JAYLINK_OK, jaylink_strerror(), JAYLINK_SWO_MODE_UART, length, log_err(), jaylink_swo_speed::max_div, jaylink_swo_speed::max_prescaler, jaylink_swo_speed::min_div, jaylink_swo_speed::min_prescaler, transport_read(), transport_start_read(), transport_start_write_read(), and transport_write().

Referenced by config_trace().

◆ jaylink_swo_read()

JAYLINK_API int jaylink_swo_read ( struct jaylink_device_handle devh,
uint8_t *  buffer,
uint32_t *  length 
)

Read SWO trace data.

Note
This function must be used only if the device has the JAYLINK_DEV_CAP_SWO capability.
Parameters
[in,out]devhDevice handle.
[out]bufferBuffer to store trace data on success. Its content is undefined on failure.
[in,out]lengthMaximum number of bytes to read. On success, the value gets updated with the actual number of bytes read. The value is undefined on failure.
Return values
JAYLINK_OKSuccess.
JAYLINK_ERR_ARGInvalid arguments.
JAYLINK_ERR_TIMEOUTA timeout occurred.
JAYLINK_ERR_PROTOProtocol violation.
JAYLINK_ERR_IOInput/output error.
JAYLINK_ERR_DEVUnspecified device error.
JAYLINK_ERROther error conditions.
See also
jaylink_swo_start()
Since
0.1.0

Definition at line 230 of file swo.c.

References buffer_get_u32(), buffer_set_u32(), jaylink_device::ctx, jaylink_device_handle::dev, JAYLINK_ERR_ARG, JAYLINK_ERR_DEV, JAYLINK_ERR_PROTO, JAYLINK_OK, jaylink_strerror(), log_err(), transport_read(), transport_start_read(), transport_start_write_read(), and transport_write().

Referenced by poll_trace().

◆ jaylink_swo_start()

JAYLINK_API int jaylink_swo_start ( struct jaylink_device_handle devh,
enum jaylink_swo_mode  mode,
uint32_t  baudrate,
uint32_t  size 
)

Start SWO capture.

Note
This function must be used only if the device has the JAYLINK_DEV_CAP_SWO capability.
Parameters
[in,out]devhDevice handle.
[in]modeMode to capture data with.
[in]baudrateBaudrate to capture data in bit per second.
[in]sizeDevice internal buffer size in bytes to use for capturing.
Return values
JAYLINK_OKSuccess.
JAYLINK_ERR_ARGInvalid arguments.
JAYLINK_ERR_TIMEOUTA timeout occurred.
JAYLINK_ERR_IOInput/output error.
JAYLINK_ERR_DEVUnspecified device error.
JAYLINK_ERROther error conditions.
See also
jaylink_swo_get_speeds()
jaylink_get_free_memory()
Since
0.1.0

Definition at line 71 of file swo.c.

References buffer_get_u32(), buffer_set_u32(), jaylink_device::ctx, jaylink_device_handle::dev, JAYLINK_ERR_ARG, JAYLINK_ERR_DEV, JAYLINK_OK, jaylink_strerror(), JAYLINK_SWO_MODE_UART, log_err(), transport_read(), transport_start_write_read(), and transport_write().

Referenced by config_trace().

◆ jaylink_swo_stop()

JAYLINK_API int jaylink_swo_stop ( struct jaylink_device_handle devh)

Stop SWO capture.

Note
This function must be used only if the device has the JAYLINK_DEV_CAP_SWO capability.
Parameters
[in,out]devhDevice handle.
Return values
JAYLINK_OKSuccess.
JAYLINK_ERR_ARGInvalid arguments.
JAYLINK_ERR_TIMEOUTA timeout occurred.
JAYLINK_ERR_IOInput/output error.
JAYLINK_ERR_DEVUnspecified device error.
JAYLINK_ERROther error conditions.
See also
jaylink_swo_start()
Since
0.1.0

Definition at line 156 of file swo.c.

References buffer_get_u32(), jaylink_device::ctx, jaylink_device_handle::dev, JAYLINK_ERR_ARG, JAYLINK_ERR_DEV, JAYLINK_OK, jaylink_strerror(), log_err(), transport_read(), transport_start_write_read(), and transport_write().

Referenced by config_trace(), and jlink_quit().