[][src]Struct jaylink::JayLink

pub struct JayLink { /* fields omitted */ }

A handle to a J-Link USB device.

This is the main interface type of this library. There are multiple ways of obtaining an instance of it:

  • JayLink::open_by_serial: Either opens the only J-Link device connected to the computer, or opens a specific one by its serial number. Recommended for applications that interact with one J-Link device only (ie. most of them).
  • JayLink::open_usb: Opens a specific J-Link device according to the given UsbDeviceInfo. Also see scan_usb.

Implementations

impl JayLink[src]

pub fn open_by_serial(serial: Option<&str>) -> Result<Self>[src]

Opens an attached J-Link device by its serial number.

If serial is None, this will open the only attached J-Link device, and return an error of type MultipleDevicesFound when more than one is attached. This is usually the desired behavior of robust applications.

pub fn open_usb(usb_device: UsbDeviceInfo) -> Result<Self>[src]

Opens a specific J-Link USB device.

pub fn manufacturer_string(&self) -> &str[src]

Returns the manufacturer string stored in the device descriptor.

pub fn product_string(&self) -> &str[src]

Returns the product string stored in the device descriptor.

pub fn serial_string(&self) -> &str[src]

Returns the serial number string stored in the device descriptor.

This serial number string can be passed to JayLink::open_by_serial to open a specific J-Link device.

pub fn read_firmware_version(&self) -> Result<String>[src]

Reads the firmware version string from the device.

pub fn read_hardware_version(&self) -> Result<HardwareVersion>[src]

Reads the hardware version from the device.

This requires the GET_HW_VERSION capability.

pub fn read_speeds(&self) -> Result<Speeds>[src]

Read the probe's CPU speed information.

This requires the SPEED_INFO capability.

pub fn read_max_mem_block(&self) -> Result<u32>[src]

Reads the maximum mem block size in Bytes.

This requires the GET_MAX_BLOCK_SIZE capability.

pub fn read_capabilities(&self) -> Result<Capabilities>[src]

Reads the advertised capabilities from the device.

pub fn set_tms(&mut self, tms: bool) -> Result<()>[src]

Changes the state of the TMS / SWDIO pin (pin 7).

The pin will be set to the level of VTref if tms is true, and to GND if it is false.

Note: On some hardware, detaching VTref might not affect the internal reading, so the old level might still be used afterwards.

pub fn set_tdi(&mut self, tdi: bool) -> Result<()>[src]

Changes the state of the TDI / TX pin (pin 5).

The pin will be set to the level of VTref if tdi is true, and to GND if it is false.

Note: On some hardware, detaching VTref might not affect the internal reading, so the old level might still be used afterwards.

pub fn set_trst(&mut self, trst: bool) -> Result<()>[src]

Changes the state of the (n)TRST pin (pin 3).

The pin will be set to the level of VTref if trst is true, and to GND if it is false.

Note: On some hardware, detaching VTref might not affect the internal reading, so the old level might still be used afterwards.

Note: Some embedded J-Link probes may not expose this pin or may not allow controlling it using this function.

pub fn set_reset(&mut self, reset: bool) -> Result<()>[src]

Changes the state of the RESET pin (pin 15).

RESET is an open-collector / open-drain output. If reset is true, the output will float. If reset is false, the output will be pulled to ground.

Note: Some embedded J-Link probes may not expose this pin or may not allow controlling it using this function.

pub fn reset_trst(&mut self) -> Result<()>[src]

Resets the target's JTAG TAP controller by temporarily asserting (n)TRST (Pin 3).

pub fn reset_target(&mut self) -> Result<()>[src]

Resets the target by temporarily asserting the RESET pin (pin 15).

pub fn read_current_interface(&self) -> Result<Interface>[src]

Reads the currently selected target interface.

This requires the SELECT_IF capability.

Note: There is no guarantee that the returned interface is actually supported (ie. it might not be in the list returned by read_available_interfaces). In particular, some embedded J-Link probes start up with JTAG selected, but only support SWD.

pub fn read_available_interfaces(
    &self
) -> Result<impl Iterator<Item = Interface>>
[src]

Reads the list of available target interfaces that can be selected.

This requires the SELECT_IF capability.

pub fn select_interface(&mut self, intf: Interface) -> Result<()>[src]

Selects the interface to use for talking to the target MCU.

This requires the SELECT_IF capability.

pub fn set_speed(&mut self, speed: CommunicationSpeed) -> Result<()>[src]

Sets the target communication speed.

If speed is set to CommunicationSpeed::ADAPTIVE, then the ADAPTIVE_CLOCKING capability is required.

pub fn read_target_voltage(&self) -> Result<u16>[src]

Reads the target voltage measured on the VTref pin, in millivolts.

pub fn set_kickstart_power(&mut self, enable: bool) -> Result<()>[src]

Enable or disable the 5V Power supply on pin 19.

This requires the SET_KS_POWER capability.

Note: The startup state of the power supply can be configured in non-volatile memory.

Note: Some embedded J-Links may not provide this feature or do not have the 5V supply routed to a pin.

Note: The 5V supply is protected against overcurrent. Check the device manual for more information on this.

pub fn jtag_io<'a, M, D>(&'a mut self, tms: M, tdi: D) -> Result<BitIter<'a>> where
    M: IntoIterator<Item = bool>,
    D: IntoIterator<Item = bool>, 
[src]

Performs a JTAG I/O operation.

This will shift out data on TMS (pin 7) and TDI (pin 5), while reading data shifted into TDO (pin 13).

The data received on TDO is returned to the caller as an iterator yielding bools.

The probe will be put into JTAG interface mode, if JTAG isn't selected already.

Parameters

  • tms: TMS bits to transmit.
  • tdi: TDI bits to transmit.

Panics

This method will panic if tms and tdi have different lengths. It will also panic if any of them contains more then 65535 bits of data, which is the maximum amount that can be transferred in one operation.

pub fn swd_io<'a, D, S>(&'a mut self, dir: D, swdio: S) -> Result<BitIter<'a>> where
    D: IntoIterator<Item = bool>,
    S: IntoIterator<Item = bool>, 
[src]

Performs an SWD I/O operation.

This will put the probe in SWD mode if it isn't already in that mode.

This requires the SELECT_IF capability.

Parameters

  • dir: Transfer directions of the swdio bits (false = 0 = Input, true = 1 = Output).
  • swdio: SWD data bits.

If dir is true, the corresponding bit in swdio will be written to the target; if it is false, the bit in swdio is ignored and a bit is read from the target instead.

Return Value

An iterator over the SWDIO bits is returned. Bits that were sent to the target (where dir = true) are undefined, and bits that were read from the target (dir = false) will have whatever value the target sent.

Trait Implementations

impl Debug for JayLink[src]

Auto Trait Implementations

impl !RefUnwindSafe for JayLink

impl Send for JayLink

impl !Sync for JayLink

impl Unpin for JayLink

impl UnwindSafe for JayLink

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.