mirror of
https://github.com/hoglet67/AtomBusMon.git
synced 2024-06-13 00:29:30 +00:00
Extend TimerMode command with prescale and reset address
Change-Id: Ia958ea97175469b642b4a70579f080dd0ff148cc
This commit is contained in:
parent
c0275ff059
commit
ca40fe81b3
|
@ -164,6 +164,7 @@ static const char ARGS13[] PROGMEM = "<start> <end> <to>";
|
||||||
static const char ARGS14[] PROGMEM = "[ <value> ]";
|
static const char ARGS14[] PROGMEM = "[ <value> ]";
|
||||||
static const char ARGS15[] PROGMEM = "[ <command> ]";
|
static const char ARGS15[] PROGMEM = "[ <command> ]";
|
||||||
static const char ARGS16[] PROGMEM = "<op1> [ <op2> [ <op3> ] ]";
|
static const char ARGS16[] PROGMEM = "<op1> [ <op2> [ <op3> ] ]";
|
||||||
|
static const char ARGS17[] PROGMEM = "[ <source> [ <prescale> [ <reset address> ] ] ]";
|
||||||
|
|
||||||
static const char * const argsStrings[] PROGMEM = {
|
static const char * const argsStrings[] PROGMEM = {
|
||||||
ARGS00,
|
ARGS00,
|
||||||
|
@ -182,7 +183,8 @@ static const char * const argsStrings[] PROGMEM = {
|
||||||
ARGS13,
|
ARGS13,
|
||||||
ARGS14,
|
ARGS14,
|
||||||
ARGS15,
|
ARGS15,
|
||||||
ARGS16
|
ARGS16,
|
||||||
|
ARGS17,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Must be kept in step with cmdStrings (just above)
|
// Must be kept in step with cmdStrings (just above)
|
||||||
|
@ -236,7 +238,7 @@ static const uint8_t helpMeta[] PROGMEM = {
|
||||||
#endif
|
#endif
|
||||||
7, 0, // clear
|
7, 0, // clear
|
||||||
36, 5, // trigger
|
36, 5, // trigger
|
||||||
34, 14, // timer
|
34, 17, // timermode
|
||||||
0, 0
|
0, 0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -630,6 +632,9 @@ uint8_t special = 0x00;
|
||||||
|
|
||||||
// Current timer mode setting
|
// Current timer mode setting
|
||||||
uint8_t timer_mode = 0x00;
|
uint8_t timer_mode = 0x00;
|
||||||
|
uint8_t timer_prescale = 0x01;
|
||||||
|
addr_t timer_resetaddr = 0xffff;
|
||||||
|
unsigned long timer_offset = 0;
|
||||||
|
|
||||||
/********************************************************
|
/********************************************************
|
||||||
* User Command Processor
|
* User Command Processor
|
||||||
|
@ -983,8 +988,9 @@ void genericRead(char *params, data_t (*readFunc)()) {
|
||||||
* Logging Helpers
|
* Logging Helpers
|
||||||
********************************************************/
|
********************************************************/
|
||||||
|
|
||||||
void logCycleCount(int offsetLow, int offsetHigh) {
|
void logCycleCount(int offsetLow, int offsetHigh, uint8_t clear) {
|
||||||
unsigned long count = (((unsigned long) hwRead8(offsetHigh)) << 16) | hwRead16(offsetLow);
|
unsigned long original_count = (((unsigned long) hwRead8(offsetHigh)) << 16) | hwRead16(offsetLow);
|
||||||
|
unsigned long count = ((original_count - timer_offset) & 0xFFFFFF) / timer_prescale;
|
||||||
char buffer[16];
|
char buffer[16];
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
// count is 24 bits so a maximum of 16777215
|
// count is 24 bits so a maximum of 16777215
|
||||||
|
@ -1002,6 +1008,11 @@ void logCycleCount(int offsetLow, int offsetHigh) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logs(" : ");
|
logs(" : ");
|
||||||
|
// Deal with clearing the counter
|
||||||
|
if (clear) {
|
||||||
|
logs("\n00.000000 : ");
|
||||||
|
timer_offset = original_count;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void logMode(modes_t mode) {
|
void logMode(modes_t mode) {
|
||||||
|
@ -1038,6 +1049,8 @@ uint8_t logDetails() {
|
||||||
|
|
||||||
// Process the dropped counter
|
// Process the dropped counter
|
||||||
uint8_t dropped = mode >> 4;
|
uint8_t dropped = mode >> 4;
|
||||||
|
// Whether to clear timer
|
||||||
|
uint8_t clear = i_addr == timer_resetaddr;
|
||||||
if (dropped) {
|
if (dropped) {
|
||||||
logstr(" : ");
|
logstr(" : ");
|
||||||
if (dropped == 15) {
|
if (dropped == 15) {
|
||||||
|
@ -1056,7 +1069,7 @@ uint8_t logDetails() {
|
||||||
|
|
||||||
// Update the serial console
|
// Update the serial console
|
||||||
if (mode & W_MASK) {
|
if (mode & W_MASK) {
|
||||||
logCycleCount(OFFSET_BW_CNTL, OFFSET_BW_CNTH);
|
logCycleCount(OFFSET_BW_CNTL, OFFSET_BW_CNTH, clear);
|
||||||
}
|
}
|
||||||
logMode(mode);
|
logMode(mode);
|
||||||
logstr(" hit at ");
|
logstr(" hit at ");
|
||||||
|
@ -1072,7 +1085,7 @@ uint8_t logDetails() {
|
||||||
logc('\n');
|
logc('\n');
|
||||||
if (mode & B_RDWR_MASK) {
|
if (mode & B_RDWR_MASK) {
|
||||||
// It's only safe to do this for brkpts, as it makes memory accesses
|
// It's only safe to do this for brkpts, as it makes memory accesses
|
||||||
logCycleCount(OFFSET_BW_CNTL, OFFSET_BW_CNTH);
|
logCycleCount(OFFSET_BW_CNTL, OFFSET_BW_CNTH, clear);
|
||||||
disMem(i_addr);
|
disMem(i_addr);
|
||||||
}
|
}
|
||||||
return watch;
|
return watch;
|
||||||
|
@ -1084,7 +1097,7 @@ void logAddr() {
|
||||||
Delay_us(100);
|
Delay_us(100);
|
||||||
memAddr = hwRead16(OFFSET_IAL);
|
memAddr = hwRead16(OFFSET_IAL);
|
||||||
// Update the serial console
|
// Update the serial console
|
||||||
logCycleCount(OFFSET_CNTL, OFFSET_CNTH);
|
logCycleCount(OFFSET_CNTL, OFFSET_CNTH, memAddr == timer_resetaddr);
|
||||||
nextAddr = disMem(memAddr);
|
nextAddr = disMem(memAddr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2029,13 +2042,29 @@ void doCmdSpecial(char *params) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void doCmdTimerMode(char *params) {
|
void doCmdTimerMode(char *params) {
|
||||||
uint8_t tmp = 0xff;
|
uint8_t mode = 0xff;
|
||||||
parsehex2(params, &tmp);
|
uint8_t prescale = 0xff;
|
||||||
if (tmp <= NUM_TIMERS) {
|
addr_t addr = 0xffff;
|
||||||
timer_mode = tmp;
|
|
||||||
|
params = parsehex2(params, &mode);
|
||||||
|
params = parsehex2(params, &prescale);
|
||||||
|
params = parsehex4(params, &addr);
|
||||||
|
if (mode <= NUM_TIMERS) {
|
||||||
|
timer_mode = mode;
|
||||||
hwCmd(CMD_TIMER_MODE, timer_mode);
|
hwCmd(CMD_TIMER_MODE, timer_mode);
|
||||||
}
|
}
|
||||||
|
if (prescale < 0xff) {
|
||||||
|
timer_prescale = prescale;
|
||||||
|
}
|
||||||
|
if (addr < 0xffff) {
|
||||||
|
timer_resetaddr = addr;
|
||||||
|
}
|
||||||
|
logstr("mode: ");
|
||||||
logpgmstr(timerStrings[timer_mode]);
|
logpgmstr(timerStrings[timer_mode]);
|
||||||
|
logstr("; prescale=");
|
||||||
|
loghex4(timer_prescale);
|
||||||
|
logstr("; reset address=");
|
||||||
|
loghex4(timer_resetaddr);
|
||||||
logstr("\n");
|
logstr("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user