OpenOCD
mpsse.c File Reference
Include dependency graph for mpsse.c:

Go to the source code of this file.

Data Structures

struct  mpsse_ctx
 
struct  transfer_result
 

Macros

#define BITMODE_MPSSE   0x02
 
#define DEBUG_PRINT_BUF(buf, len)
 
#define FTDI_DEVICE_IN_REQTYPE   (0x80 | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE)
 
#define FTDI_DEVICE_OUT_REQTYPE   (LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE)
 
#define LIBUSB_CALL
 
#define SIO_GET_LATENCY_TIMER_REQUEST   0x0A
 
#define SIO_RESET_PURGE_RX   1
 
#define SIO_RESET_PURGE_TX   2
 
#define SIO_RESET_REQUEST   0x00
 
#define SIO_RESET_SIO   0
 
#define SIO_SET_BITMODE_REQUEST   0x0B
 
#define SIO_SET_LATENCY_TIMER_REQUEST   0x09
 

Functions

static unsigned buffer_add_read (struct mpsse_ctx *ctx, uint8_t *in, unsigned in_offset, unsigned bit_count, unsigned offset)
 
static unsigned buffer_read_space (struct mpsse_ctx *ctx)
 
static unsigned buffer_write (struct mpsse_ctx *ctx, const uint8_t *out, unsigned out_offset, unsigned bit_count)
 
static void buffer_write_byte (struct mpsse_ctx *ctx, uint8_t data)
 
static unsigned buffer_write_space (struct mpsse_ctx *ctx)
 
static bool device_location_equal (struct libusb_device *device, const char *location)
 
void mpsse_clock_data (struct mpsse_ctx *ctx, const uint8_t *out, unsigned out_offset, uint8_t *in, unsigned in_offset, unsigned length, uint8_t mode)
 
void mpsse_clock_data_in (struct mpsse_ctx *ctx, uint8_t *in, unsigned in_offset, unsigned length, uint8_t mode)
 
void mpsse_clock_data_out (struct mpsse_ctx *ctx, const uint8_t *out, unsigned out_offset, unsigned length, uint8_t mode)
 
void mpsse_clock_tms_cs (struct mpsse_ctx *ctx, const uint8_t *out, unsigned out_offset, uint8_t *in, unsigned in_offset, unsigned length, bool tdi, uint8_t mode)
 
void mpsse_clock_tms_cs_out (struct mpsse_ctx *ctx, const uint8_t *out, unsigned out_offset, unsigned length, bool tdi, uint8_t mode)
 
void mpsse_close (struct mpsse_ctx *ctx)
 
int mpsse_divide_by_5_config (struct mpsse_ctx *ctx, bool enable)
 
int mpsse_flush (struct mpsse_ctx *ctx)
 
bool mpsse_is_high_speed (struct mpsse_ctx *ctx)
 
void mpsse_loopback_config (struct mpsse_ctx *ctx, bool enable)
 
struct mpsse_ctxmpsse_open (const uint16_t *vid, const uint16_t *pid, const char *description, const char *serial, const char *location, int channel)
 
void mpsse_purge (struct mpsse_ctx *ctx)
 
void mpsse_read_data_bits_high_byte (struct mpsse_ctx *ctx, uint8_t *data)
 
void mpsse_read_data_bits_low_byte (struct mpsse_ctx *ctx, uint8_t *data)
 
int mpsse_rtck_config (struct mpsse_ctx *ctx, bool enable)
 
void mpsse_set_data_bits_high_byte (struct mpsse_ctx *ctx, uint8_t data, uint8_t dir)
 
void mpsse_set_data_bits_low_byte (struct mpsse_ctx *ctx, uint8_t data, uint8_t dir)
 
void mpsse_set_divisor (struct mpsse_ctx *ctx, uint16_t divisor)
 
int mpsse_set_frequency (struct mpsse_ctx *ctx, int frequency)
 
static bool open_matching_device (struct mpsse_ctx *ctx, const uint16_t *vid, const uint16_t *pid, const char *product, const char *serial, const char *location)
 
static LIBUSB_CALL void read_cb (struct libusb_transfer *transfer)
 
static void single_byte_boolean_helper (struct mpsse_ctx *ctx, bool var, uint8_t val_if_true, uint8_t val_if_false)
 
static bool string_descriptor_equal (struct libusb_device_handle *device, uint8_t str_index, const char *string)
 
static LIBUSB_CALL void write_cb (struct libusb_transfer *transfer)
 

Macro Definition Documentation

◆ BITMODE_MPSSE

#define BITMODE_MPSSE   0x02

Definition at line 43 of file mpsse.c.

◆ DEBUG_PRINT_BUF

#define DEBUG_PRINT_BUF (   buf,
  len 
)
Value:
do { \
char buf_string[32 * 3 + 1]; \
int buf_string_pos = 0; \
for (int i = 0; i < len; i++) { \
buf_string_pos += sprintf(buf_string + buf_string_pos, " %02x", buf[i]); \
if (i % 32 == 32 - 1) { \
LOG_DEBUG_IO("%s", buf_string); \
buf_string_pos = 0; \
} \
} \
if (buf_string_pos > 0) \
LOG_DEBUG_IO("%s", buf_string);\
} \
} while (0)
#define LOG_LEVEL_IS(FOO)
Definition: log.h:99
@ LOG_LVL_DEBUG_IO
Definition: log.h:48

Definition at line 23 of file mpsse.c.

◆ FTDI_DEVICE_IN_REQTYPE

#define FTDI_DEVICE_IN_REQTYPE   (0x80 | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE)

Definition at line 41 of file mpsse.c.

◆ FTDI_DEVICE_OUT_REQTYPE

#define FTDI_DEVICE_OUT_REQTYPE   (LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE)

Definition at line 40 of file mpsse.c.

◆ LIBUSB_CALL

#define LIBUSB_CALL

Definition at line 20 of file mpsse.c.

◆ SIO_GET_LATENCY_TIMER_REQUEST

#define SIO_GET_LATENCY_TIMER_REQUEST   0x0A

Definition at line 47 of file mpsse.c.

◆ SIO_RESET_PURGE_RX

#define SIO_RESET_PURGE_RX   1

Definition at line 51 of file mpsse.c.

◆ SIO_RESET_PURGE_TX

#define SIO_RESET_PURGE_TX   2

Definition at line 52 of file mpsse.c.

◆ SIO_RESET_REQUEST

#define SIO_RESET_REQUEST   0x00

Definition at line 45 of file mpsse.c.

◆ SIO_RESET_SIO

#define SIO_RESET_SIO   0

Definition at line 50 of file mpsse.c.

◆ SIO_SET_BITMODE_REQUEST

#define SIO_SET_BITMODE_REQUEST   0x0B

Definition at line 48 of file mpsse.c.

◆ SIO_SET_LATENCY_TIMER_REQUEST

#define SIO_SET_LATENCY_TIMER_REQUEST   0x09

Definition at line 46 of file mpsse.c.

Function Documentation

◆ buffer_add_read()

static unsigned buffer_add_read ( struct mpsse_ctx ctx,
uint8_t *  in,
unsigned  in_offset,
unsigned  bit_count,
unsigned  offset 
)
static

◆ buffer_read_space()

static unsigned buffer_read_space ( struct mpsse_ctx ctx)
static

◆ buffer_write()

static unsigned buffer_write ( struct mpsse_ctx ctx,
const uint8_t *  out,
unsigned  out_offset,
unsigned  bit_count 
)
static

◆ buffer_write_byte()

◆ buffer_write_space()

◆ device_location_equal()

static bool device_location_equal ( struct libusb_device *  device,
const char *  location 
)
static

Definition at line 92 of file mpsse.c.

References device, LOG_DEBUG, LOG_ERROR, and NULL.

Referenced by open_matching_device().

◆ mpsse_clock_data()

void mpsse_clock_data ( struct mpsse_ctx ctx,
const uint8_t *  out,
unsigned  out_offset,
uint8_t *  in,
unsigned  in_offset,
unsigned  length,
uint8_t  mode 
)

◆ mpsse_clock_data_in()

void mpsse_clock_data_in ( struct mpsse_ctx ctx,
uint8_t *  in,
unsigned  in_offset,
unsigned  length,
uint8_t  mode 
)

Definition at line 477 of file mpsse.c.

References length, mode, and mpsse_clock_data().

Referenced by ftdi_swd_queue_cmd().

◆ mpsse_clock_data_out()

void mpsse_clock_data_out ( struct mpsse_ctx ctx,
const uint8_t *  out,
unsigned  out_offset,
unsigned  length,
uint8_t  mode 
)

Definition at line 471 of file mpsse.c.

References length, mode, and mpsse_clock_data().

Referenced by ftdi_swd_queue_cmd(), and ftdi_swd_run_queue().

◆ mpsse_clock_tms_cs()

void mpsse_clock_tms_cs ( struct mpsse_ctx ctx,
const uint8_t *  out,
unsigned  out_offset,
uint8_t *  in,
unsigned  in_offset,
unsigned  length,
bool  tdi,
uint8_t  mode 
)

◆ mpsse_clock_tms_cs_out()

void mpsse_clock_tms_cs_out ( struct mpsse_ctx ctx,
const uint8_t *  out,
unsigned  out_offset,
unsigned  length,
bool  tdi,
uint8_t  mode 
)

◆ mpsse_close()

◆ mpsse_divide_by_5_config()

int mpsse_divide_by_5_config ( struct mpsse_ctx ctx,
bool  enable 
)

Definition at line 714 of file mpsse.c.

References ERROR_FAIL, ERROR_OK, LOG_DEBUG, mpsse_is_high_speed(), and single_byte_boolean_helper().

Referenced by mpsse_set_frequency().

◆ mpsse_flush()

◆ mpsse_is_high_speed()

bool mpsse_is_high_speed ( struct mpsse_ctx ctx)

Definition at line 404 of file mpsse.c.

References mpsse_ctx::type, and TYPE_FT2232C.

Referenced by ftdi_khz(), mpsse_divide_by_5_config(), and mpsse_rtck_config().

◆ mpsse_loopback_config()

void mpsse_loopback_config ( struct mpsse_ctx ctx,
bool  enable 
)

Definition at line 691 of file mpsse.c.

References LOG_DEBUG, and single_byte_boolean_helper().

Referenced by ftdi_initialize().

◆ mpsse_open()

◆ mpsse_purge()

◆ mpsse_read_data_bits_high_byte()

void mpsse_read_data_bits_high_byte ( struct mpsse_ctx ctx,
uint8_t *  data 
)

◆ mpsse_read_data_bits_low_byte()

void mpsse_read_data_bits_low_byte ( struct mpsse_ctx ctx,
uint8_t *  data 
)

◆ mpsse_rtck_config()

int mpsse_rtck_config ( struct mpsse_ctx ctx,
bool  enable 
)

Definition at line 725 of file mpsse.c.

References ERROR_FAIL, ERROR_OK, LOG_DEBUG, mpsse_is_high_speed(), and single_byte_boolean_helper().

Referenced by mpsse_set_frequency().

◆ mpsse_set_data_bits_high_byte()

void mpsse_set_data_bits_high_byte ( struct mpsse_ctx ctx,
uint8_t  data,
uint8_t  dir 
)

◆ mpsse_set_data_bits_low_byte()

void mpsse_set_data_bits_low_byte ( struct mpsse_ctx ctx,
uint8_t  data,
uint8_t  dir 
)

◆ mpsse_set_divisor()

void mpsse_set_divisor ( struct mpsse_ctx ctx,
uint16_t  divisor 
)

◆ mpsse_set_frequency()

int mpsse_set_frequency ( struct mpsse_ctx ctx,
int  frequency 
)

◆ open_matching_device()

static bool open_matching_device ( struct mpsse_ctx ctx,
const uint16_t *  vid,
const uint16_t *  pid,
const char *  product,
const char *  serial,
const char *  location 
)
static

◆ read_cb()

◆ single_byte_boolean_helper()

static void single_byte_boolean_helper ( struct mpsse_ctx ctx,
bool  var,
uint8_t  val_if_true,
uint8_t  val_if_false 
)
static

◆ string_descriptor_equal()

static bool string_descriptor_equal ( struct libusb_device_handle *  device,
uint8_t  str_index,
const char *  string 
)
static

Definition at line 78 of file mpsse.c.

References device, and LOG_ERROR.

Referenced by open_matching_device().

◆ write_cb()

static LIBUSB_CALL void write_cb ( struct libusb_transfer *  transfer)
static