usbBlaster: cleanup

This commit is contained in:
Gwenhael Goavec-Merou 2023-07-30 08:51:30 +02:00
parent 75d98d12e9
commit 2f8056cba5
2 changed files with 10 additions and 14 deletions

View File

@ -9,13 +9,13 @@
#include <iostream> #include <iostream>
#include <map> #include <map>
#include <vector>
#include <string> #include <string>
#include <vector>
#include "display.hpp" #include "display.hpp"
#include "usbBlaster.hpp"
#include "ftdipp_mpsse.hpp" #include "ftdipp_mpsse.hpp"
#include "fx2_ll.hpp" #include "fx2_ll.hpp"
#include "usbBlaster.hpp"
using namespace std; using namespace std;
@ -39,7 +39,7 @@ using namespace std;
UsbBlaster::UsbBlaster(const cable_t &cable, const std::string &firmware_path, UsbBlaster::UsbBlaster(const cable_t &cable, const std::string &firmware_path,
int8_t verbose): int8_t verbose):
_verbose(verbose>1), _nb_bit(0), _verbose(verbose > 1), _nb_bit(0),
_curr_tms(0), _buffer_size(64) _curr_tms(0), _buffer_size(64)
{ {
if (cable.pid == 0x6001) if (cable.pid == 0x6001)
@ -211,7 +211,7 @@ int UsbBlaster::writeTDI(uint8_t *tx, uint8_t *rx, uint32_t len, bool end)
int num_read = _nb_bit; int num_read = _nb_bit;
if (writeBit((rx)? rx_ptr:NULL, num_read/2) < 0) if (writeBit((rx)? rx_ptr:NULL, num_read/2) < 0)
return -EXIT_FAILURE; return -EXIT_FAILURE;
if (rx) // realign bits if (rx) // realign bits
*rx_ptr >>= (8 - nb_bit); *rx_ptr >>= (8 - nb_bit);
} }
@ -223,7 +223,7 @@ int UsbBlaster::writeTDI(uint8_t *tx, uint8_t *rx, uint32_t len, bool end)
mask |= _tdi_pin; mask |= _tdi_pin;
_in_buf[_nb_bit++] = mask; _in_buf[_nb_bit++] = mask;
_in_buf[_nb_bit++] = mask | mode | _tck_pin; _in_buf[_nb_bit++] = mask | mode | _tck_pin;
uint8_t tmp; uint8_t tmp = 0;
if (writeBit((rx)? &tmp:NULL, 1) < 0) if (writeBit((rx)? &tmp:NULL, 1) < 0)
return -EXIT_FAILURE; return -EXIT_FAILURE;
if (rx) if (rx)

View File

@ -3,17 +3,17 @@
* Copyright (C) 2020 Gwenhael Goavec-Merou <gwenhael.goavec-merou@trabucayre.com> * Copyright (C) 2020 Gwenhael Goavec-Merou <gwenhael.goavec-merou@trabucayre.com>
*/ */
#ifndef USBBLASTER_H #ifndef SRC_USBBLASTER_HPP_
#define USBBLASTER_H #define SRC_USBBLASTER_HPP_
#include <ftdi.h> #include <ftdi.h>
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <vector> #include <vector>
#include "cable.hpp" #include "cable.hpp"
#include "jtagInterface.hpp"
#include "ftdipp_mpsse.hpp" #include "ftdipp_mpsse.hpp"
#include "fx2_ll.hpp" #include "fx2_ll.hpp"
#include "jtagInterface.hpp"
/*! /*!
* \file UsbBlaster.hpp * \file UsbBlaster.hpp
@ -111,11 +111,7 @@ class UsbBlasterI: public UsbBlaster_ll {
int write(uint8_t *wr_buf, int wr_len, int write(uint8_t *wr_buf, int wr_len,
uint8_t *rd_buf, int rd_len) override; uint8_t *rd_buf, int rd_len) override;
private: private:
/* struct ftdi_context *_ftdi; /*!< ftdi_context */
* \brief init and configure FT245
*/
void init_internal();
struct ftdi_context *_ftdi; /*!< ftid_context */
}; };
/*! /*!
@ -136,4 +132,4 @@ class UsbBlasterII: public UsbBlaster_ll {
private: private:
FX2_ll *fx2; FX2_ll *fx2;
}; };
#endif #endif // SRC_USBBLASTER_HPP_