forked from MoonbaseOtago/CCLoad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ccloadview.h
207 lines (186 loc) · 6.79 KB
/
ccloadview.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
/***************************************************************************
* Copyright (C) %{CURRENT_YEAR} by %{AUTHOR} <%{EMAIL}> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
***************************************************************************/
#ifndef CCLOADVIEW_H
#define CCLOADVIEW_H
#include <QWidget>
#include <QSettings>
#include "ttylock.h"
#include "mythread.h"
#include "ui_ccloadview_base.h"
class QPainter;
class KUrl;
/**
* This is the main view class for ccload. Most of the non-menu,
* non-toolbar, and non-statusbar (e.g., non frame) GUI code should go
* here.
*
* @short Main view
* @author %{AUTHOR} <%{EMAIL}>
* @version %{VERSION}
*/
#include "mythread.h"
class MyThread;
//class ccloadView : public QWidget, public Ui::Form
class ccloadView : public QWidget
{
Q_OBJECT
public:
/**
* Default constructor
*/
ccloadView(QWidget *parent);
/**
* Destructor
*/
virtual ~ccloadView();
int port;
Ui::Form form;
void setIdleTimer();
private:
static const unsigned char SEL_FLASH_INFO = 0x01;
static const unsigned char CHIP_ERASE_DONE = 0x80;
static const unsigned char PCON_IDLE = 0x40;
static const unsigned char CPU_HALTED = 0x20;
static const unsigned char POWER_MODE_0 = 0x10;
static const unsigned char HALT_STATUS = 0x08;
static const unsigned char DEBUG_LOCKED = 0x04;
static const unsigned char OSCILATOR_STABLE = 0x02;
static const unsigned char STACK_OVERFLOW = 0x01;
// Chip Name, FlashSize, FlashPageSize, FlashWordSize
static char *ChipDescriptors[];
bool waiting;
bool chipDefined;
bool inDebugMode;
long FLASH_SIZE;
int FLASH_PAGE_SIZE;
int FLASH_WORD_SIZE;
MyThread *thread;
int maddr;
unsigned char image[256*1024];
int app_mstart;
int app_msize;
unsigned char app_image[0x10000];
private:
QString prepareCommand(QString cmd);
QString sendCommand(QString command, QString msg);
bool parseOK(QString response);
QString getTokenREAD(QString response);
QString getToken(QString token, QString response);
bool getDataByte(int index, QString data, unsigned char &value);
bool getDataByte(int index, QString data);
bool isPageEmpty(unsigned char *buffer);
void loadChipModel(QString items);
void addRoutine(unsigned char *routine, int &rlen, unsigned char in0);
void addRoutine(unsigned char *routine, int &rlen, unsigned char in0, unsigned char in1);
void addRoutine(unsigned char *routine, int &rlen, unsigned char in0, unsigned char in1, unsigned char in2);
bool parseHexByte(QString s, QLineEdit *textBox, unsigned char &value, unsigned char def, bool canEmpty, bool valid);
void setStatusLED(int state, QCheckBox *led);
void setStatusLabels(int status);
void setConfigLabels(int config);
void setConnected();
void setDisconnected();
void btnMACwrite_Click_set();
bool DEBUG_INIT();
bool DEBUG_INIT(bool soft);
void set_REGISTER(QLabel *, int v);
bool READ_REGISTERS();
bool READ_STATUS();
bool READ_STATUS(unsigned char &status);
bool RESET(bool state);
bool LED(bool state);
bool FLASHDC(bool state);
bool FLASHDD(bool state);
bool FLASHRST(bool state);
bool READ_CONFIG();
bool dbg_ReadConfig(unsigned char &config);
bool WRITE_CONFIG(unsigned char config);
bool GET_CHIP_ID();
bool GET_CHIP_ID(unsigned char &id, unsigned char &revision);
bool HALT();
bool RESUME(bool run);
bool STEP();
bool MASS_ERASE_FLASH();
bool CHIP_ERASE();
bool DEBUG_INSTR(unsigned char in0);
bool DEBUG_INSTR(unsigned char in0, unsigned char *data);
bool DEBUG_INSTR(unsigned char in0, unsigned char in1, unsigned char *data);
bool DEBUG_INSTR(unsigned char in0, unsigned char in1);
bool DEBUG_INSTR(unsigned char in0, unsigned char in1, unsigned char in2, unsigned char *data);
bool DEBUG_INSTR(unsigned char in0, unsigned char in1, unsigned char in2);
bool dbg_DebugInstr(unsigned char *cmds, int len, unsigned char *data);
bool CLOCK_INIT();
bool WRITE_XDATA_MEMORY(int address, unsigned char *buffer, int length);
bool READ_XDATA_MEMORY(int address, int length, unsigned char *buffer, int &outlen);
bool READ_CODE_MEMORY(int address, unsigned char bank, int length, unsigned char *buffer, int &outlen);
bool SET_PC(int address);
bool GET_PC(int &address);
bool WRITE_PAGE_FLASH(long iPageAddress, unsigned char *buffer, int length, bool erasePage);
bool READ_FLASH_PAGE(long iPageAddress, int length, unsigned char *code, int &clen);
bool Connect();
bool set_INSTR(QLabel *lp, unsigned char in0);
bool set_INSTR(QLabel *lp, unsigned char in0, unsigned char in1);
bool set_INSTR(QLabel *lp, unsigned char in0, unsigned char in1, unsigned char in2);
bool CLIENT(bool state);
ttylock *lock;
bool prod;
QSettings *settings;
bool startPCvalid;
int startPC;
bool connected;
void consoleDisplay(QString &s);
signals:
void startupclick();
private slots:
void btnFlashDD_Click();
void btnFlashDC_Click();
void btnFlashRST_Click();
void btnConnect_Click();
void cbChipModel_SelectedIndexChanged(int);
void btnSelectFile_Click();
void btnSelectFile_App_Click();
void btnWrite_Click();
void btnLock_Click();
void btnWrite_App_Click();
void btnWrite_All_Click();
void btnDebug_Click();
void btnProduction_Click();
void btnRead_Click();
void btnRead_App_Click();
void btnGetStatus_Click();
void btnFlashCC_Click();
void btnRun_Click();
void btnStep_Click();
void btnHalt_Click();
void btnSelectLoad_Click();
void btnSelectLoad_App_Click();
void btnAuto_Click();
void btnVerify_Click();
void btnVerify_App_Click();
void btnErasePage_Click();
void btnErasePage_App_Click();
void btnErase_Click();
void btnReadLocation_Click();
void btnSetPC_Click();
void btnMACwrite_Click();
void btnMACautoInc_Click();
void btnMAClow_Click();
void btnMAChi_Click();
void idle();
};
#endif // ccloadVIEW_H