oresat / oresat-firmware

OreSat firmware based on ChibiOS for M0 and M4 microcontrollers
GNU General Public License v3.0
36 stars 13 forks source link

Convert CO_driver error handling to error_cb based implementation #27

Open heliochronix opened 4 years ago

heliochronix commented 4 years ago

Implement the CO_CANerr_cb() method of setting and clearing CAN error status flags in CANopenNode. This method will replace the cyclic call of CO_CANmodule_process() in the CO NMT processing thread (aka the main thread) which basically checks the status of CAN all the time manually.

The challenge is we need to either ensure the callback triggers when errors are cleared, or have some other way of indicating that errors have cleared so we can unset the CO error flags. I'm not sure if the interrupt for CAN errors triggers on any change of state or only when an error occurs. If it's the latter, then the error callback will not trigger when things clear, and so the CANopen code will always think we are in an error state.