OpenOCD
mpsse.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 /**************************************************************************
4  * Copyright (C) 2012 by Andreas Fritiofson *
5  * andreas.fritiofson@gmail.com *
6  ***************************************************************************/
7 
8 #ifndef OPENOCD_JTAG_DRIVERS_MPSSE_H
9 #define OPENOCD_JTAG_DRIVERS_MPSSE_H
10 
11 #include <stdbool.h>
12 #include "helper/binarybuffer.h"
13 
14 /* Mode flags */
15 #define POS_EDGE_OUT 0x00
16 #define NEG_EDGE_OUT 0x01
17 #define POS_EDGE_IN 0x00
18 #define NEG_EDGE_IN 0x04
19 #define MSB_FIRST 0x00
20 #define LSB_FIRST 0x08
21 
34 };
35 
36 struct mpsse_ctx;
37 
38 /* Device handling */
39 struct mpsse_ctx *mpsse_open(const uint16_t *vid, const uint16_t *pid, const char *description,
40  const char *serial, const char *location, int channel);
41 void mpsse_close(struct mpsse_ctx *ctx);
42 bool mpsse_is_high_speed(struct mpsse_ctx *ctx);
43 
44 /* Command queuing. These correspond to the MPSSE commands with the same names, but no need to care
45  * about bit/byte transfer or data length limitation. Read data is guaranteed to be available only
46  * after the following mpsse_flush(). */
47 void mpsse_clock_data_out(struct mpsse_ctx *ctx, const uint8_t *out, unsigned int out_offset,
48  unsigned int length, uint8_t mode);
49 void mpsse_clock_data_in(struct mpsse_ctx *ctx, uint8_t *in, unsigned int in_offset, unsigned int length,
50  uint8_t mode);
51 void mpsse_clock_data(struct mpsse_ctx *ctx, const uint8_t *out, unsigned int out_offset, uint8_t *in,
52  unsigned int in_offset, unsigned int length, uint8_t mode);
53 void mpsse_clock_tms_cs_out(struct mpsse_ctx *ctx, const uint8_t *out, unsigned int out_offset,
54  unsigned int length, bool tdi, uint8_t mode);
55 void mpsse_clock_tms_cs(struct mpsse_ctx *ctx, const uint8_t *out, unsigned int out_offset, uint8_t *in,
56  unsigned int in_offset, unsigned int length, bool tdi, uint8_t mode);
57 void mpsse_set_data_bits_low_byte(struct mpsse_ctx *ctx, uint8_t data, uint8_t dir);
58 void mpsse_set_data_bits_high_byte(struct mpsse_ctx *ctx, uint8_t data, uint8_t dir);
59 void mpsse_read_data_bits_low_byte(struct mpsse_ctx *ctx, uint8_t *data);
60 void mpsse_read_data_bits_high_byte(struct mpsse_ctx *ctx, uint8_t *data);
61 void mpsse_loopback_config(struct mpsse_ctx *ctx, bool enable);
62 void mpsse_set_divisor(struct mpsse_ctx *ctx, uint16_t divisor);
63 int mpsse_divide_by_5_config(struct mpsse_ctx *ctx, bool enable);
64 int mpsse_rtck_config(struct mpsse_ctx *ctx, bool enable);
65 
66 /* Helper to set frequency in Hertz. Returns actual realizable frequency or negative error.
67  * Frequency 0 means RTCK. */
68 int mpsse_set_frequency(struct mpsse_ctx *ctx, int frequency);
69 
70 /* Queue handling */
71 int mpsse_flush(struct mpsse_ctx *ctx);
72 void mpsse_purge(struct mpsse_ctx *ctx);
73 
74 #endif /* OPENOCD_JTAG_DRIVERS_MPSSE_H */
char * serial
Definition: adapter.c:43
const char * description
Definition: arm_adi_v5.c:1010
enum arm_mode mode
Definition: armv4_5.c:277
Support functions to access arbitrary bits in a byte array.
uint8_t length
Definition: esp_usb_jtag.c:1
ftdi_chip_type
Definition: mpsse.h:22
@ TYPE_FT232HP
Definition: mpsse.h:32
@ TYPE_FT233HP
Definition: mpsse.h:31
@ TYPE_FT2232C
Definition: mpsse.h:23
@ TYPE_FT2232H
Definition: mpsse.h:24
@ TYPE_FT4232HP
Definition: mpsse.h:30
@ TYPE_FT232H
Definition: mpsse.h:26
@ TYPE_FT4232H
Definition: mpsse.h:25
@ TYPE_FT4233HP
Definition: mpsse.h:28
@ TYPE_FT2233HP
Definition: mpsse.h:27
@ TYPE_FT4232HA
Definition: mpsse.h:33
@ TYPE_FT2232HP
Definition: mpsse.h:29
int mpsse_flush(struct mpsse_ctx *ctx)
Definition: mpsse.c:848
void mpsse_read_data_bits_high_byte(struct mpsse_ctx *ctx, uint8_t *data)
Definition: mpsse.c:676
void mpsse_set_data_bits_high_byte(struct mpsse_ctx *ctx, uint8_t data, uint8_t dir)
Definition: mpsse.c:643
void mpsse_set_divisor(struct mpsse_ctx *ctx, uint16_t divisor)
Definition: mpsse.c:712
int mpsse_set_frequency(struct mpsse_ctx *ctx, int frequency)
Definition: mpsse.c:751
void mpsse_read_data_bits_low_byte(struct mpsse_ctx *ctx, uint8_t *data)
Definition: mpsse.c:660
void mpsse_clock_tms_cs_out(struct mpsse_ctx *ctx, const uint8_t *out, unsigned int out_offset, unsigned int length, bool tdi, uint8_t mode)
Definition: mpsse.c:569
void mpsse_purge(struct mpsse_ctx *ctx)
Definition: mpsse.c:424
void mpsse_clock_data(struct mpsse_ctx *ctx, const uint8_t *out, unsigned int out_offset, uint8_t *in, unsigned int in_offset, unsigned int length, uint8_t mode)
Definition: mpsse.c:498
void mpsse_clock_data_out(struct mpsse_ctx *ctx, const uint8_t *out, unsigned int out_offset, unsigned int length, uint8_t mode)
Definition: mpsse.c:486
struct mpsse_ctx * mpsse_open(const uint16_t *vid, const uint16_t *pid, const char *description, const char *serial, const char *location, int channel)
void mpsse_clock_tms_cs(struct mpsse_ctx *ctx, const uint8_t *out, unsigned int out_offset, uint8_t *in, unsigned int in_offset, unsigned int length, bool tdi, uint8_t mode)
Definition: mpsse.c:575
bool mpsse_is_high_speed(struct mpsse_ctx *ctx)
Definition: mpsse.c:419
void mpsse_close(struct mpsse_ctx *ctx)
Definition: mpsse.c:405
void mpsse_clock_data_in(struct mpsse_ctx *ctx, uint8_t *in, unsigned int in_offset, unsigned int length, uint8_t mode)
Definition: mpsse.c:492
void mpsse_loopback_config(struct mpsse_ctx *ctx, bool enable)
Definition: mpsse.c:706
void mpsse_set_data_bits_low_byte(struct mpsse_ctx *ctx, uint8_t data, uint8_t dir)
Definition: mpsse.c:626
int mpsse_divide_by_5_config(struct mpsse_ctx *ctx, bool enable)
Definition: mpsse.c:729
int mpsse_rtck_config(struct mpsse_ctx *ctx, bool enable)
Definition: mpsse.c:740