Conversation
…into CCU_Review Cheese
CCU/Core/Src/stm32g4xx_it.c
Outdated
| LOGOMATIC("PRECHARGE TS ACTIVE: %d\n", state_data.BCU_PRECHARGE_SET_TS_ACTIVE); | ||
|
|
||
| LOGOMATIC("====================================\n\n"); | ||
| VCP_StateDump(&state_data); |
There was a problem hiding this comment.
You cannot do this inside of an interrupt (the ISR) it just takes too much time. Anything done in an ISR supercedes CAN interrupts (which are the lowest priority interrupt due to the risk of the bus flooding and nothing happening) and printing is slow and in an ISR it cannot be interrupted to capture a message or something, while outside of an ISR it can be interrupted just fine.
Instead, I want you to define a global volatile boolean and here I want you to set that flag high; then, on state tick, I want you to check the status of the flag and if it is high then I would like you to call the function to print all the things and set the flag low.
Something vaguely like the following perhaps
// In StateUtils.h
extern volatile bool request_print_statedata;// In StateUtils.c
volatile bool request_print_statedata;
void CheckForDebugPrint(void)
{
if (!request_print_statedata)
return;
LOGOMATIC(...)
...
LOGOMATIC(...)
request_print_statedata = false;
}| VCP_StateDump(&state_data); | |
| request_print_statedata = true; |
And then just call CheckForDebugPrint() inside of the main infinite while loop
CCU/Application/Src/StateUtils.c
Outdated
| } | ||
| } | ||
|
|
||
| void VCP_StateDump(const CCU_StateData *state_data) |
There was a problem hiding this comment.
dchansen06
left a comment
There was a problem hiding this comment.
A few code duplication problems, and a few changing 0/1 to proper false/true for boolean values
dchansen06
left a comment
There was a problem hiding this comment.
Please fill in the PR description
Problem and Scope
Description
Gotchas and Limitations
Testing
Testing Details
Larger Impact
Additional Context and Ticket