Add additional debug info to version command and add CPU cycle counter to cc instruction's output
This commit is contained in:
parent
8a62ed2ea7
commit
d4d654e8dd
@ -33,4 +33,6 @@ void stm_unique_id_get(uint32_t *high, uint32_t *mid, uint32_t *low);
|
||||
|
||||
void stm_dev_rev_id_get(uint32_t *device_id, uint32_t *revision_id);
|
||||
|
||||
void stm_cpuid_get(uint8_t *implementer, uint8_t *variant, uint16_t *part_no, uint8_t *rev);
|
||||
|
||||
#endif /* __UNIQUE_ID_H__ */
|
||||
|
@ -43,3 +43,23 @@ void stm_dev_rev_id_get(uint32_t *device_id, uint32_t *revision_id)
|
||||
if (revision_id)
|
||||
*revision_id = (DBGMCU->IDCODE & DBGMCU_IDCODE_REV_ID) >> 16;
|
||||
}
|
||||
|
||||
void stm_cpuid_get(uint8_t *implementer, uint8_t *variant, uint16_t *part_no, uint8_t *rev)
|
||||
{
|
||||
uint32_t cpuid;
|
||||
|
||||
cpuid = SCB->CPUID;
|
||||
|
||||
if (implementer) {
|
||||
*implementer = (uint8_t)((cpuid >> 24) & 0xFFU);
|
||||
}
|
||||
if (variant) {
|
||||
*variant = (uint8_t)((cpuid >> 20) & 0x0FU);
|
||||
}
|
||||
if (part_no) {
|
||||
*part_no = (uint16_t)((cpuid >> 4) & 0x0FFFU);
|
||||
}
|
||||
if (rev) {
|
||||
*rev = (uint8_t)(cpuid & 0x0FU);
|
||||
}
|
||||
}
|
||||
|
@ -70,6 +70,10 @@ static shellmatta_retCode_t shell_cmd_ver(const shellmatta_handle_t handle,
|
||||
uint32_t high_id;
|
||||
uint32_t stm_rev_id;
|
||||
uint32_t stm_dev_id;
|
||||
uint8_t core_rev;
|
||||
uint8_t core_implementer;
|
||||
uint8_t core_variant;
|
||||
uint16_t core_part_no;
|
||||
const char *hw_rev_str;
|
||||
enum hw_revision pcb_rev;
|
||||
|
||||
@ -77,7 +81,7 @@ static shellmatta_retCode_t shell_cmd_ver(const shellmatta_handle_t handle,
|
||||
stm_dev_rev_id_get(&stm_dev_id, &stm_rev_id);
|
||||
|
||||
shellmatta_printf(handle, "Reflow Oven Controller Firmware " xstr(GIT_VER) "\r\n"
|
||||
"Compiled: " __DATE__ " at " __TIME__ "\r\n");
|
||||
"Compiled: " __DATE__ " at " __TIME__ "\r\n");
|
||||
shellmatta_printf(handle, "Serial: %08X-%08X-%08X\r\n", high_id, mid_id, low_id);
|
||||
|
||||
pcb_rev = get_pcb_hardware_version();
|
||||
@ -100,6 +104,12 @@ static shellmatta_retCode_t shell_cmd_ver(const shellmatta_handle_t handle,
|
||||
shellmatta_printf(handle, "STM Device ID: 0x%04X\r\n", stm_dev_id);
|
||||
shellmatta_printf(handle, "STM Revision ID: 0x%04X\r\n", stm_rev_id);
|
||||
|
||||
stm_cpuid_get(&core_implementer, &core_variant, &core_part_no, &core_rev);
|
||||
shellmatta_printf(handle, "CPU Implementer: 0x%02X\r\n", (unsigned int)core_implementer);
|
||||
shellmatta_printf(handle, "CPU Variant: 0x%02X\r\n", (unsigned int)core_variant);
|
||||
shellmatta_printf(handle, "CPU Part No.: 0x%04X\r\n", (unsigned int)core_part_no);
|
||||
shellmatta_printf(handle, "CPU Revision: 0x%02X\r\n", (unsigned int)core_rev);
|
||||
|
||||
return SHELLMATTA_OK;
|
||||
}
|
||||
|
||||
@ -849,6 +859,7 @@ shellmatta_retCode_t shell_cmd_execute(const shellmatta_handle_t handle, const c
|
||||
shellmatta_retCode_t shell_cmd_cycle_count(const shellmatta_handle_t handle, const char *args, uint32_t len)
|
||||
{
|
||||
uint64_t counter;
|
||||
uint32_t core_cycle_count;
|
||||
(void)args;
|
||||
(void)len;
|
||||
char option;
|
||||
@ -856,8 +867,10 @@ shellmatta_retCode_t shell_cmd_cycle_count(const shellmatta_handle_t handle, con
|
||||
uint32_t arg_len;
|
||||
int opt_stat;
|
||||
bool clear = false;
|
||||
bool hex = false;
|
||||
const shellmatta_opt_long_t options[] = {
|
||||
{"clear", 'c', SHELLMATTA_OPT_ARG_NONE},
|
||||
{"hex", 'h', SHELLMATTA_OPT_ARG_NONE},
|
||||
{NULL, '\0', SHELLMATTA_OPT_ARG_NONE},
|
||||
};
|
||||
|
||||
@ -869,6 +882,8 @@ shellmatta_retCode_t shell_cmd_cycle_count(const shellmatta_handle_t handle, con
|
||||
case 'c':
|
||||
clear = true;
|
||||
break;
|
||||
case 'h':
|
||||
hex = true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -876,10 +891,18 @@ shellmatta_retCode_t shell_cmd_cycle_count(const shellmatta_handle_t handle, con
|
||||
|
||||
|
||||
counter = main_cycle_counter_get();
|
||||
shellmatta_printf(handle, "%"PRIu64"\r\n", counter);
|
||||
if (clear)
|
||||
core_cycle_count = DWT->CYCCNT;
|
||||
if (hex) {
|
||||
shellmatta_printf(handle, "Main loop: 0x%016"PRIX64"\r\n", counter);
|
||||
shellmatta_printf(handle, "CPU cycles: 0x%08"PRIX32"\r\n", core_cycle_count);
|
||||
} else {
|
||||
shellmatta_printf(handle, "Main loop: %"PRIu64"\r\n", counter);
|
||||
shellmatta_printf(handle, "CPU cycles: %"PRIu32"\r\n", core_cycle_count);
|
||||
}
|
||||
if (clear) {
|
||||
main_cycle_counter_init();
|
||||
|
||||
DWT->CYCCNT = 0UL;
|
||||
}
|
||||
return SHELLMATTA_OK;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user