lattice: use color

This commit is contained in:
Gwenhael Goavec-Merou 2019-11-20 07:51:48 +01:00
parent 04624f028d
commit 7fb114f172
1 changed files with 28 additions and 27 deletions

View File

@ -27,6 +27,7 @@
#include "ftdijtag.hpp" #include "ftdijtag.hpp"
#include "lattice.hpp" #include "lattice.hpp"
#include "progressBar.hpp" #include "progressBar.hpp"
#include "display.hpp"
using namespace std; using namespace std;
@ -136,42 +137,42 @@ void Lattice::program(unsigned int offset)
wr_rd(0x1C, tx_buf, 26, NULL, 0); wr_rd(0x1C, tx_buf, 26, NULL, 0);
/* ISC Enable 0xC6 */ /* ISC Enable 0xC6 */
cout << "Enable configuration: " << flush; printInfo("Enable configuration: ", false);
if (!EnableISC(0x00)) { if (!EnableISC(0x00)) {
cerr << "FAIL" << endl; printError("FAIL");// << endl;
displayReadReg(readStatusReg()); displayReadReg(readStatusReg());
return; return;
} else { } else {
cout << "DONE" << endl; printSuccess("DONE");
} }
/* ISC ERASE */ /* ISC ERASE */
cout << "SRAM erase: " << flush; printInfo("SRAM erase: ", false);
if (flashErase(0x01) == false) { if (flashErase(0x01) == false) {
cerr << "FAIL" << endl; printError("FAIL");
displayReadReg(readStatusReg()); displayReadReg(readStatusReg());
return; return;
} else { } else {
cout << "DONE" << endl; printSuccess("DONE");
} }
/* bypass */ /* bypass */
wr_rd(0xff, NULL, 0, NULL, 0); wr_rd(0xff, NULL, 0, NULL, 0);
/* ISC Enable 0xC6 followed by 0x08 */ /* ISC Enable 0xC6 followed by 0x08 */
cout << "Enable configuration: " << flush; printInfo("Enable configuration: ", false);
if (!EnableISC(0x08)) { if (!EnableISC(0x08)) {
cerr << "FAIL" << endl; printError("FAIL");
displayReadReg(readStatusReg()); displayReadReg(readStatusReg());
return; return;
} else { } else {
cout << "DONE" << endl; printSuccess("DONE");
} }
/* ISC ERASE */ /* ISC ERASE */
cout << "Flash erase: " << flush; printInfo("Flash erase: ", false);
if (flashErase(0x0e) == false) { if (flashErase(0x0e) == false) {
cerr << "FAIL" << endl; printError("FAIL");
return; return;
} else { } else {
cout << "DONE" << endl; printSuccess("DONE");
} }
/* LSC_INIT_ADDRESS */ /* LSC_INIT_ADDRESS */
@ -192,46 +193,46 @@ void Lattice::program(unsigned int offset)
_jtag->set_state(FtdiJtag::RUN_TEST_IDLE); _jtag->set_state(FtdiJtag::RUN_TEST_IDLE);
_jtag->toggleClk(1000); _jtag->toggleClk(1000);
/* write feature row */ /* write feature row */
cout << "Program features Row: " << flush; printInfo("Program features Row: ", false);
if (writeFeaturesRow(_jed.featuresRow(), true) == false) { if (writeFeaturesRow(_jed.featuresRow(), true) == false) {
cerr << "FAIL" << endl; printError("FAIL");
return; return;
} else { } else {
cout << "DONE" << endl; printSuccess("DONE");
} }
/* write feabits */ /* write feabits */
cout << "Program feabitss: " << flush; printInfo("Program feabitss: ", false);
if (writeFeabits(_jed.feabits(), true) == false) { if (writeFeabits(_jed.feabits(), true) == false) {
cerr << "FAIL" << endl; printError("FAIL");
return; return;
} else { } else {
cout << "DONE" << endl; printSuccess("DONE");
} }
/* ISC program done 0x5E */ /* ISC program done 0x5E */
cout << "Write program Done: " << flush; printInfo("Write program Done: ", false);
if (writeProgramDone() == false) { if (writeProgramDone() == false) {
cerr << "FAIL" << endl; printError("FAIL");
return; return;
} else { } else {
cout << "DONE" << endl; printSuccess("DONE");
} }
/* bypass */ /* bypass */
wr_rd(0xff, NULL, 0, NULL, 0); wr_rd(0xff, NULL, 0, NULL, 0);
/* disable configuration mode */ /* disable configuration mode */
cout << "Disable configuration: " << flush; printInfo("Disable configuration: ", false);
if (!DisableISC()) { if (!DisableISC()) {
cerr << "FAIL" << endl; printError("FAIL");
return; return;
} else { } else {
cout << "DONE" << endl; printSuccess("DONE");
} }
/* ISC REFRESH 0x26 */ /* ISC REFRESH 0x26 */
cout << "Refresh: " << flush; printInfo("Refresh: ", false);
if (loadConfiguration() == false) { if (loadConfiguration() == false) {
cerr << "FAIL" << endl; printError("FAIL");
return; return;
} else { } else {
cout << "DONE" << endl; printSuccess("DONE");
} }
/* bypass */ /* bypass */
wr_rd(0xff, NULL, 0, NULL, 0); wr_rd(0xff, NULL, 0, NULL, 0);