Skip to content

Commit

Permalink
Fix BOFF Error.
Browse files Browse the repository at this point in the history
  • Loading branch information
HamedJafarzadeh committed Sep 13, 2022
1 parent db3bf3d commit 06fc084
Show file tree
Hide file tree
Showing 2 changed files with 514 additions and 2,045 deletions.
7 changes: 7 additions & 0 deletions CANopenNode_STM32/CO_driver_STM32.c
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,9 @@ CO_CANmodule_process(CO_CANmodule_t *CANmodule) {

if(err & FDCAN_PSR_BO){
status |= CO_CAN_ERRTX_BUS_OFF;
// Ask for recovery from the controller
((FDCAN_HandleTypeDef*)((CANopenNodeSTM32 *)CANmodule->CANptr)->CANHandle)->Instance->CCCR = ((FDCAN_HandleTypeDef*)((CANopenNodeSTM32 *)CANmodule->CANptr)->CANHandle)->Instance->CCCR & (~FDCAN_CCCR_INIT);

} else {
/* recalculate CANerrorStatus, first clear some flags */
status &= 0xFFFF ^ (CO_CAN_ERRTX_BUS_OFF |
Expand Down Expand Up @@ -525,6 +528,10 @@ CO_CANmodule_process(CO_CANmodule_t *CANmodule) {

if(err & CAN_ESR_BOFF){
status |= CO_CAN_ERRTX_BUS_OFF;
// TODO : Ask for recovery from the controller - For now
// CANx->MCR |= CAN_MCR_ABOM;
// In initialization can be used

} else {
/* recalculate CANerrorStatus, first clear some flags */
status &= 0xFFFF ^ (CO_CAN_ERRTX_BUS_OFF |
Expand Down
Loading

0 comments on commit 06fc084

Please sign in to comment.