2019-09-26 18:29:20 +02:00
|
|
|
#ifndef _FTDIPP_MPSSE_H
|
|
|
|
|
#define _FTDIPP_MPSSE_H
|
|
|
|
|
#include <ftdi.h>
|
2019-11-19 09:00:56 +01:00
|
|
|
#include <string>
|
2019-09-26 18:29:20 +02:00
|
|
|
|
|
|
|
|
class FTDIpp_MPSSE {
|
|
|
|
|
public:
|
2019-11-21 08:36:16 +01:00
|
|
|
FTDIpp_MPSSE(const std::string &dev, unsigned char interface,
|
|
|
|
|
uint32_t clkHZ, bool verbose = false);
|
|
|
|
|
FTDIpp_MPSSE(int vid, int pid, unsigned char interface,
|
|
|
|
|
uint32_t clkHZ, bool verbose = false);
|
2019-09-26 18:29:20 +02:00
|
|
|
~FTDIpp_MPSSE();
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
int vid;
|
|
|
|
|
int pid;
|
2020-03-07 07:19:20 +01:00
|
|
|
int interface;
|
2019-09-26 18:29:20 +02:00
|
|
|
int bit_low_val;
|
|
|
|
|
int bit_low_dir;
|
|
|
|
|
int bit_high_val;
|
|
|
|
|
int bit_high_dir;
|
|
|
|
|
} mpsse_bit_config;
|
|
|
|
|
|
2020-03-06 08:24:49 +01:00
|
|
|
int init(unsigned char latency, unsigned char bitmask_mode, unsigned char mode,
|
|
|
|
|
mpsse_bit_config &bit_conf);
|
2019-09-26 18:29:20 +02:00
|
|
|
int setClkFreq(uint32_t clkHZ);
|
|
|
|
|
int setClkFreq(uint32_t clkHZ, char use_divide_by_5);
|
|
|
|
|
|
2019-09-28 15:38:57 +02:00
|
|
|
int vid() {return _vid;}
|
|
|
|
|
int pid() {return _pid;}
|
2019-09-26 18:29:20 +02:00
|
|
|
|
|
|
|
|
protected:
|
2019-11-19 09:00:56 +01:00
|
|
|
void open_device(unsigned int baudrate);
|
2019-09-26 18:29:20 +02:00
|
|
|
void ftdi_usb_close_internal();
|
|
|
|
|
int close_device();
|
|
|
|
|
int mpsse_write();
|
|
|
|
|
int mpsse_read(unsigned char *rx_buff, int len);
|
|
|
|
|
int mpsse_store(unsigned char c);
|
|
|
|
|
int mpsse_store(unsigned char *c, int len);
|
|
|
|
|
int mpsse_get_buffer_size() {return _buffer_size;}
|
2019-11-19 09:00:56 +01:00
|
|
|
unsigned int udevstufftoint(const char *udevstring, int base);
|
|
|
|
|
bool search_with_dev(const std::string &device);
|
2019-11-21 08:36:16 +01:00
|
|
|
bool _verbose;
|
2019-09-26 18:29:20 +02:00
|
|
|
private:
|
|
|
|
|
int _vid;
|
|
|
|
|
int _pid;
|
2019-11-19 09:00:56 +01:00
|
|
|
int _bus;
|
|
|
|
|
int _addr;
|
|
|
|
|
char _product[64];
|
2019-09-26 18:29:20 +02:00
|
|
|
unsigned char _interface;
|
|
|
|
|
int _clkHZ;
|
2020-03-06 08:24:49 +01:00
|
|
|
protected:
|
|
|
|
|
struct ftdi_context *_ftdi;
|
2019-09-26 18:29:20 +02:00
|
|
|
int _buffer_size;
|
2020-03-06 08:24:49 +01:00
|
|
|
private:
|
2019-09-26 18:29:20 +02:00
|
|
|
int _num;
|
|
|
|
|
unsigned char *_buffer;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|