diff --git a/src/platforms/hosted/ftdi_bmp.c b/src/platforms/hosted/ftdi_bmp.c index 6f4ce74..70b3f13 100644 --- a/src/platforms/hosted/ftdi_bmp.c +++ b/src/platforms/hosted/ftdi_bmp.c @@ -123,6 +123,8 @@ cable_desc_t cable_desc[] = { .mpsse_swd_write.set_data_low = PIN5, .mpsse_swd_write.clr_data_low = PIN6, .jtag.set_data_low = PIN6, + .target_voltage_cmd = GET_BITS_HIGH, + .target_voltage_pin = ~PIN2, .name = "ftdiswd" }, { @@ -519,5 +521,20 @@ void libftdi_jtagtap_tdi_tdo_seq( const char *libftdi_target_voltage(void) { + uint8_t pin = active_cable->target_voltage_pin; + if (active_cable->target_voltage_cmd && pin) { + libftdi_buffer_write(&active_cable->target_voltage_cmd, 1); + uint8_t data[1]; + libftdi_buffer_read(data, 1); + bool res = false; + if (((pin < 0x7f) || (pin == PIN7))) + res = data[0] & pin; + else + res = !(data[0] & ~pin); + if (res) + return "Present"; + else + return "Absent"; + } return "not supported"; } diff --git a/src/platforms/hosted/ftdi_bmp.h b/src/platforms/hosted/ftdi_bmp.h index 9ed634e..584b706 100644 --- a/src/platforms/hosted/ftdi_bmp.h +++ b/src/platforms/hosted/ftdi_bmp.h @@ -88,6 +88,10 @@ typedef struct cable_desc_s { pin_settings_t mpsse_swd_write; /* dbus data for jtag.*/ pin_settings_t jtag; + /* Command to read port to check target voltage.*/ + uint8_t target_voltage_cmd; + /* Pin to check target voltage.*/ + uint8_t target_voltage_pin; /* USB readable description of the device.*/ char *description; /* Command line argument to -c option to select this device.*/