OpenOCD
jtag/drivers/libjaylink/libjaylink/target.c File Reference

Target related functions. More...

Include dependency graph for jtag/drivers/libjaylink/libjaylink/target.c:

Go to the source code of this file.

Functions

JAYLINK_API int jaylink_clear_reset (struct jaylink_device_handle *devh)
 Clear the target reset signal. More...
 
JAYLINK_API int jaylink_get_available_interfaces (struct jaylink_device_handle *devh, uint32_t *ifaces)
 Retrieve the available target interfaces. More...
 
JAYLINK_API int jaylink_get_selected_interface (struct jaylink_device_handle *devh, enum jaylink_target_interface *iface)
 Retrieve the selected target interface. More...
 
JAYLINK_API int jaylink_get_speeds (struct jaylink_device_handle *devh, struct jaylink_speed *speed)
 Retrieve target interface speeds. More...
 
JAYLINK_API int jaylink_select_interface (struct jaylink_device_handle *devh, enum jaylink_target_interface iface, enum jaylink_target_interface *prev_iface)
 Select the target interface. More...
 
JAYLINK_API int jaylink_set_reset (struct jaylink_device_handle *devh)
 Set the target reset signal. More...
 
JAYLINK_API int jaylink_set_speed (struct jaylink_device_handle *devh, uint16_t speed)
 Set the target interface speed. More...
 
JAYLINK_API int jaylink_set_target_power (struct jaylink_device_handle *devh, bool enable)
 Set the target power supply. More...
 

Detailed Description

Target related functions.

Definition in file jtag/drivers/libjaylink/libjaylink/target.c.

Function Documentation

◆ jaylink_clear_reset()

JAYLINK_API int jaylink_clear_reset ( struct jaylink_device_handle devh)

Clear the target reset signal.

Parameters
[in,out]devhDevice handle.
Return values
JAYLINK_OKSuccess.
JAYLINK_ERR_ARGInvalid arguments.
JAYLINK_ERR_TIMEOUTA timeout occurred.
JAYLINK_ERR_IOInput/output error.
JAYLINK_ERROther error conditions.
Since
0.1.0

Definition at line 406 of file jtag/drivers/libjaylink/libjaylink/target.c.

References jaylink_device::ctx, jaylink_device_handle::dev, JAYLINK_ERR_ARG, JAYLINK_OK, jaylink_strerror(), log_err(), transport_start_write(), and transport_write().

Referenced by jlink_reset().

◆ jaylink_get_available_interfaces()

JAYLINK_API int jaylink_get_available_interfaces ( struct jaylink_device_handle devh,
uint32_t *  ifaces 
)

Retrieve the available target interfaces.

The target interfaces are stored in a 32-bit bit field where each individual bit represents a target interface. A set bit indicates an available target interface. See jaylink_target_interface for a description of the target interfaces and their bit positions.

Note
This function must only be used if the device has the JAYLINK_DEV_CAP_SELECT_TIF capability.
Parameters
[in,out]devhDevice handle.
[out]ifacesTarget interfaces on success, and undefined on failure.
Return values
JAYLINK_OKSuccess.
JAYLINK_ERR_ARGInvalid arguments.
JAYLINK_ERR_TIMEOUTA timeout occurred.
JAYLINK_ERR_IOInput/output error.
JAYLINK_ERROther error conditions.
See also
jaylink_select_interface()
Since
0.1.0

Definition at line 283 of file jtag/drivers/libjaylink/libjaylink/target.c.

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

Referenced by select_interface().

◆ jaylink_get_selected_interface()

JAYLINK_API int jaylink_get_selected_interface ( struct jaylink_device_handle devh,
enum jaylink_target_interface iface 
)

Retrieve the selected target interface.

Note
This function must only be used if the device has the JAYLINK_DEV_CAP_SELECT_TIF capability.
Warning
This function may return a value for iface which is not covered by jaylink_target_interface.
Parameters
[in,out]devhDevice handle.
[out]ifaceSelected target interface on success, and undefined on failure.
Return values
JAYLINK_OKSuccess.
JAYLINK_ERR_ARGInvalid arguments.
JAYLINK_ERR_TIMEOUTA timeout occurred.
JAYLINK_ERR_IOInput/output error.
JAYLINK_ERROther error conditions.
See also
jaylink_select_interface()
Since
0.1.0

Definition at line 349 of file jtag/drivers/libjaylink/libjaylink/target.c.

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

◆ jaylink_get_speeds()

JAYLINK_API int jaylink_get_speeds ( struct jaylink_device_handle devh,
struct jaylink_speed speed 
)

Retrieve target interface speeds.

The speeds are applicable for the currently selected target interface only and calculated as follows:

speeds = freq / n with n >= div, where n is an integer

Assuming, for example, a base frequency freq of 4 MHz and a minimum divider div of 4 then the highest possible target interface speed is 4 MHz / 4 = 1 MHz. The next highest speed is 800 kHz for a divider of 5, and so on.

Note
This function must only be used if the device has the JAYLINK_DEV_CAP_GET_SPEEDS capability.
Parameters
[in,out]devhDevice handle.
[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_ERROther error conditions.
See also
jaylink_select_interface()
Since
0.1.0

Definition at line 128 of file jtag/drivers/libjaylink/libjaylink/target.c.

References buffer_get_u16(), buffer_get_u32(), jaylink_device::ctx, jaylink_device_handle::dev, jaylink_speed::div, jaylink_speed::freq, JAYLINK_ERR_ARG, JAYLINK_ERR_PROTO, JAYLINK_OK, jaylink_strerror(), log_err(), transport_read(), transport_start_write_read(), and transport_write().

Referenced by jlink_speed().

◆ jaylink_select_interface()

JAYLINK_API int jaylink_select_interface ( struct jaylink_device_handle devh,
enum jaylink_target_interface  iface,
enum jaylink_target_interface prev_iface 
)

Select the target interface.

Note
This function must only be used if the device has the JAYLINK_DEV_CAP_SELECT_TIF capability.
Warning
This function may return a value for prev_iface which is not covered by jaylink_target_interface.
Parameters
[in,out]devhDevice handle.
[in]ifaceTarget interface to select.
[out]prev_ifacePreviously selected target interface on success, and undefined on failure. Can be NULL.
Return values
JAYLINK_OKSuccess.
JAYLINK_ERR_ARGInvalid arguments.
JAYLINK_ERR_TIMEOUTA timeout occurred.
JAYLINK_ERR_IOInput/output error.
JAYLINK_ERROther error conditions.
See also
jaylink_get_available_interfaces()
Since
0.1.0

Definition at line 203 of file jtag/drivers/libjaylink/libjaylink/target.c.

References buffer_get_u32(), jaylink_device::ctx, jaylink_device_handle::dev, iface, JAYLINK_ERR_ARG, JAYLINK_OK, jaylink_strerror(), JAYLINK_TIF_2W_JTAG_PIC32, JAYLINK_TIF_BDM3, JAYLINK_TIF_FINE, JAYLINK_TIF_JTAG, JAYLINK_TIF_SWD, log_err(), transport_read(), transport_start_write_read(), and transport_write().

Referenced by select_interface().

◆ jaylink_set_reset()

JAYLINK_API int jaylink_set_reset ( struct jaylink_device_handle devh)

Set the target reset signal.

Parameters
[in,out]devhDevice handle.
Return values
JAYLINK_OKSuccess.
JAYLINK_ERR_ARGInvalid arguments.
JAYLINK_ERR_TIMEOUTA timeout occurred.
JAYLINK_ERR_IOInput/output error.
JAYLINK_ERROther error conditions.
Since
0.1.0

Definition at line 450 of file jtag/drivers/libjaylink/libjaylink/target.c.

References jaylink_device::ctx, jaylink_device_handle::dev, JAYLINK_ERR_ARG, JAYLINK_OK, jaylink_strerror(), log_err(), transport_start_write(), and transport_write().

Referenced by jlink_reset().

◆ jaylink_set_speed()

JAYLINK_API int jaylink_set_speed ( struct jaylink_device_handle devh,
uint16_t  speed 
)

Set the target interface speed.

Parameters
[in,out]devhDevice handle.
[in]speedSpeed in kHz or JAYLINK_SPEED_ADAPTIVE_CLOCKING for adaptive clocking. Speed of 0 kHz is not allowed and adaptive clocking must only be used if the device has the JAYLINK_DEV_CAP_ADAPTIVE_CLOCKING capability.
Return values
JAYLINK_OKSuccess.
JAYLINK_ERR_ARGInvalid arguments.
JAYLINK_ERR_TIMEOUTA timeout occurred.
JAYLINK_ERR_IOInput/output error.
JAYLINK_ERROther error conditions.
See also
jaylink_get_speeds()
Since
0.1.0

Definition at line 63 of file jtag/drivers/libjaylink/libjaylink/target.c.

References buffer_set_u16(), jaylink_device::ctx, jaylink_device_handle::dev, JAYLINK_ERR_ARG, JAYLINK_OK, jaylink_strerror(), log_err(), transport_start_write(), and transport_write().

Referenced by jlink_speed().

◆ jaylink_set_target_power()

JAYLINK_API int jaylink_set_target_power ( struct jaylink_device_handle devh,
bool  enable 
)

Set the target power supply.

If enabled, the target is supplied with 5 V from pin 19 of the 20-pin JTAG / SWD connector.

Note
This function must only be used if the device has the JAYLINK_DEV_CAP_SET_TARGET_POWER capability.
Parameters
[in,out]devhDevice handle.
[in]enableDetermines whether to enable or disable the target power supply.
Return values
JAYLINK_OKSuccess.
JAYLINK_ERR_ARGInvalid arguments.
JAYLINK_ERR_TIMEOUTA timeout occurred.
JAYLINK_ERR_IOInput/output error.
JAYLINK_ERROther error conditions.
Since
0.1.0

Definition at line 502 of file jtag/drivers/libjaylink/libjaylink/target.c.

References jaylink_device::ctx, jaylink_device_handle::dev, JAYLINK_ERR_ARG, JAYLINK_OK, jaylink_strerror(), log_err(), transport_start_write(), and transport_write().

Referenced by COMMAND_HANDLER().