libftdi: Infrastructure to test for target voltage present.
This commit is contained in:
parent
aff624b6e0
commit
c78066255d
@ -123,6 +123,8 @@ cable_desc_t cable_desc[] = {
|
|||||||
.mpsse_swd_write.set_data_low = PIN5,
|
.mpsse_swd_write.set_data_low = PIN5,
|
||||||
.mpsse_swd_write.clr_data_low = PIN6,
|
.mpsse_swd_write.clr_data_low = PIN6,
|
||||||
.jtag.set_data_low = PIN6,
|
.jtag.set_data_low = PIN6,
|
||||||
|
.target_voltage_cmd = GET_BITS_HIGH,
|
||||||
|
.target_voltage_pin = ~PIN2,
|
||||||
.name = "ftdiswd"
|
.name = "ftdiswd"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -519,5 +521,20 @@ void libftdi_jtagtap_tdi_tdo_seq(
|
|||||||
|
|
||||||
const char *libftdi_target_voltage(void)
|
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";
|
return "not supported";
|
||||||
}
|
}
|
||||||
|
@ -88,6 +88,10 @@ typedef struct cable_desc_s {
|
|||||||
pin_settings_t mpsse_swd_write;
|
pin_settings_t mpsse_swd_write;
|
||||||
/* dbus data for jtag.*/
|
/* dbus data for jtag.*/
|
||||||
pin_settings_t 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.*/
|
/* USB readable description of the device.*/
|
||||||
char *description;
|
char *description;
|
||||||
/* Command line argument to -c option to select this device.*/
|
/* Command line argument to -c option to select this device.*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user