rework board structure to add an optional pin mapping for bitbang mode

This commit is contained in:
Gwenhael Goavec-Merou 2020-03-07 11:00:29 +01:00
parent 706219016e
commit 84298839ea
3 changed files with 48 additions and 13 deletions

View File

@ -3,16 +3,49 @@
#include <map>
static std::map <std::string, std::string > board_list = {
{"arty", "digilent"},
{"colorlight", ""},
{"cyc1000", "ft2232"},
{"de0nano", "usbblaster"},
{"ecp5_evn", "ft2232"},
{"machXO3SK", "ft2232"},
{"littleBee", "ft2232"},
{"spartanEdgeAccelBoard", ""},
{"tangnano", "ft2232"}
#include "cable.hpp"
/* AN_232R-01_Bit_Bang_Mode_Available_For_FT232R_and_Ft245R */
enum {
FT232RL_TXD = 0,
FT232RL_RXD = 1,
FT232RL_RTS = 2,
FT232RL_CTS = 3,
FT232RL_DTR = 4,
FT232RL_DSR = 5,
FT232RL_DCD = 6,
FT232RL_RI = 7
};
/*!
* \brief for bitbang mode this structure provide offset for each JTAG signals
*/
typedef struct {
uint8_t tms_pin; /*! TMS pin offset */
uint8_t tck_pin; /*! TCK pin offset */
uint8_t tdi_pin; /*! TDI pin offset */
uint8_t tdo_pin; /*! TDO pin offset */
} jtag_pins_conf_t;
/*!
* \brief a board has a target cable and optionnally a pin configuration
* (bitbang mode)
*/
typedef struct {
std::string cable_name; /*! provide name of one entry in cable_list */
jtag_pins_conf_t pins_config; /*! for bitbang, provide struct with pins offset */
} target_cable_t;
static std::map <std::string, target_cable_t> board_list = {
{"arty", {"digilent", {}}},
{"colorlight", {"", {}}},
{"cyc1000", {"ft2232", {}}},
{"de0nano", {"usbblaster", {}}},
{"ecp5_evn", {"ft2232", {}}},
{"machXO3SK", {"ft2232", {}}},
{"littleBee", {"ft2232", {}}},
{"spartanEdgeAccelBoard", {"",{}}},
{"tangnano", {"ft2232", {}}}
};
#endif

View File

@ -23,7 +23,8 @@ static std::map <std::string, cable_t> cable_list = {
{"digilent", {MODE_FTDI_SERIAL, {0x0403, 0x6010, INTERFACE_A, 0xe8, 0xeb, 0x00, 0x60}}},
{"digilent_hs2", {MODE_FTDI_SERIAL, {0x0403, 0x6014, INTERFACE_A, 0xe8, 0xeb, 0x00, 0x60}}},
{"digilent_hs3", {MODE_FTDI_SERIAL, {0x0403, 0x6014, INTERFACE_A, 0x88, 0x8B, 0x20, 0x30}}},
{"ft2232", {MODE_FTDI_SERIAL, {0x0403, 0x6010, INTERFACE_A, 0x08, 0x0B, 0x08, 0x0B}}}
{"ft2232", {MODE_FTDI_SERIAL, {0x0403, 0x6010, INTERFACE_A, 0x08, 0x0B, 0x08, 0x0B}}},
{"ft232RL", {MODE_FTDI_BITBANG, {0x0403, 0x6001, INTERFACE_A, 0x08, 0x0B, 0x08, 0x0B}}}
};
#endif

View File

@ -100,7 +100,7 @@ int main(int argc, char **argv)
/* if a board name is specified try to use this to determine cable */
if (args.board[0] != '-' && board_list.find(args.board) != board_list.end()) {
auto t = cable_list.find(board_list[args.board]);
auto t = cable_list.find(board_list[args.board].cable_name);
if (t == cable_list.end()) {
args.cable = "-";
cout << "Board " << args.board << " has not default cable" << endl;
@ -282,7 +282,8 @@ void displaySupported(const struct arguments &args)
printSuccess(t.str());
for (auto b = board_list.begin(); b != board_list.end(); b++) {
stringstream ss;
ss << setw(15) << left << (*b).first << " " << (*b).second;
target_cable_t c = (*b).second;
ss << setw(15) << left << (*b).first << " " << c.cable_name;
printInfo(ss.str());
}
cout << endl;