File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -116,7 +116,7 @@ bool R7FA6M5_CAN::begin(CanBitRate const /* can_bitrate */)
116
116
int const max_index = g_pin_cfg_size / sizeof (g_pin_cfg[0 ]);
117
117
auto [cfg_init_ok, cfg_channel] = cfg_pins (max_index, _can_tx_pin, _can_rx_pin);
118
118
init_ok &= cfg_init_ok;
119
- _canfd_cfg.channel = cfg_channel;
119
+ _canfd_cfg.channel = cfg_channel;
120
120
121
121
/* Configure the interrupts.
122
122
*/
@@ -127,6 +127,19 @@ bool R7FA6M5_CAN::begin(CanBitRate const /* can_bitrate */)
127
127
};
128
128
init_ok &= IRQManager::getInstance ().addPeripheral (IRQ_CANFD, &irq_req);
129
129
130
+ /* There is only one global error channel shared between both CAN0 and CAN1
131
+ * peripheral. If you are using e2Studio the error channel is configured via
132
+ * a project-wide define, however this is an issue for as as we do not know
133
+ * if both CAN instances are actually going to be used by the end-user. It may
134
+ * happen that only CAN1.begin() is called, if in this scenario CAN0 is configured
135
+ * as the source of the global error channel a hard-fault occurs as soon as
136
+ * an error occurs (this is a design-issue with the FSP layer). The line below
137
+ * ensures that there's always a valid error channel and that no hard-fault
138
+ * can occur.
139
+ */
140
+ _canfd_extended_cfg.global_err_channel = cfg_channel;
141
+
142
+ /* Initialize the peripheral's FSP driver. */
130
143
if (R_CANFD_Open (&_canfd_ctrl, &_canfd_cfg) != FSP_SUCCESS)
131
144
init_ok = false ;
132
145
You can’t perform that action at this time.
0 commit comments