libjaylink  0.3.1
Library to access J-Link devices
Functions
swo.c File Reference

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

#include <stdint.h>
#include <stdbool.h>
#include "libjaylink.h"
#include "libjaylink-internal.h"

Functions

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

Detailed Description

Serial Wire Output (SWO) functions.

Function Documentation

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
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
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
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