My logging helper method needs to put data into the output buffer (actual logging i-o works on a different thread), so I want my universal method not to care if it is invoked from a usual thread or from an interruption handler.
I was able to implement this as
Code: Select all
void lockForLogging() {
if (dbg_isr_cnt > 0) {
chSysLockFromIsr();
} else {
chSysLock();
}
}
but I do not really like to access the extern variable which is only available in case of CH_DBG_SYSTEM_STATE_CHECK.
What is the best way to implement 'isInIrqHandler' check? Do I need to add my own hook into CH_IRQ_PROLOGUE?
Does such method not exist because I am not supposed to use such a method because it is wrong or against the philosophy of Chibios?