Firmware: added load and save commands (#10)

Change-Id: I2455e6f6dc5d0ecdca8cb5408f6336b1008ed4a9
This commit is contained in:
David Banks 2019-11-13 17:06:07 +00:00
parent 1bf2358b55
commit c43251576c
2 changed files with 60 additions and 2 deletions

View File

@ -60,6 +60,8 @@ char *cmdStrings[] = {
"wri",
#endif
"test",
"load",
"save",
"srec",
"special",
"reset",
@ -106,6 +108,8 @@ void (*cmdFuncs[])(char *params) = {
doCmdWriteIO,
#endif
doCmdTest,
doCmdLoad,
doCmdSave,
doCmdSRec,
doCmdSpecial,
doCmdReset,
@ -639,6 +643,10 @@ void shiftBreakpointRegister(addr_t addr, addr_t mask, modes_t mode, trigger_t t
* Host Memory/IO Access helpers
********************************************************/
void log_send_file() {
logstr("Send file now...\n");
}
void log_char(uint8_t c) {
if (c < 32 || c > 126) {
c = '.';
@ -1364,6 +1372,55 @@ void doCmdWriteIO(char *params) {
#endif
void doCmdSave(char *params) {
long i;
addr_t start;
addr_t end;
data_t data;
params = parsehex4(params, &start);
params = parsehex4(params, &end);
logstr("Press any key to start transmission (and again at end)\n");
Serial_RxByte0();
loadAddr(start);
for (i = start; i <= end; i++) {
data = readMemByteInc();
Serial_TxByte0(data);
}
Serial_RxByte0();
}
void doCmdLoad(char *params) {
addr_t start;
addr_t addr;
data_t data;
uint16_t timeout;
params = parsehex4(params, &start);
addr = start;
log_send_file();
do {
data = Serial_RxByte0();
loadData(data);
loadAddr(addr++);
writeMemByte();
// Wait for next byte to appear, or a 1 second timeout
timeout = 1000;
while (timeout > 0 && !Serial_ByteRecieved0()) {
Delay_us(1000);
timeout--;
}
} while (timeout > 0);
logstr("Wrote ");
loghex4(start);
logstr(" to ");
loghex4(addr - 1);
logc('\n');
}
void doCmdTest(char *params) {
addr_t start;
addr_t end;
@ -1419,8 +1476,7 @@ void doCmdSRec(char *params) {
addr_t addrlo = 0xFFFF;
addr_t addrhi = 0x0000;
logstr("Send file now...\n");
log_send_file();
// Special case reading the first record, with no timeout
c = Serial_RxByte0();

View File

@ -61,6 +61,7 @@ void doCmdHistory(char *params);
#endif
void doCmdIO(char *params);
void doCmdList(char *params);
void doCmdLoad(char *params);
void doCmdMem(char *params);
void doCmdNext(char *params);
void doCmdReadIO(char *params);
@ -69,6 +70,7 @@ void doCmdRegs(char *params);
void doCmdReset(char *params);
void doCmdStep(char *params);
void doCmdTest(char *params);
void doCmdSave(char *params);
void doCmdSRec(char *params);
void doCmdSpecial(char *params);
void doCmdTrace(char *params);