File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -257,12 +257,15 @@ int can_mcan_stop(const struct device *dev)
257
257
const struct can_mcan_config * cfg = dev -> config ;
258
258
struct can_mcan_data * data = dev -> data ;
259
259
struct can_mcan_reg * can = cfg -> can ;
260
+ can_tx_callback_t tx_cb ;
261
+ uint32_t tx_idx ;
260
262
int ret ;
261
263
262
264
if (!data -> started ) {
263
265
return - EALREADY ;
264
266
}
265
267
268
+ /* CAN transmissions are automatically stopped when entering init mode */
266
269
ret = can_enter_init_mode (can , K_MSEC (CAN_INIT_TIMEOUT ));
267
270
if (ret != 0 ) {
268
271
LOG_ERR ("Failed to enter init mode" );
@@ -281,6 +284,16 @@ int can_mcan_stop(const struct device *dev)
281
284
282
285
data -> started = false;
283
286
287
+ for (tx_idx = 0 ; tx_idx < ARRAY_SIZE (data -> tx_fin_cb ); tx_idx ++ ) {
288
+ tx_cb = data -> tx_fin_cb [tx_idx ];
289
+
290
+ if (tx_cb != NULL ) {
291
+ data -> tx_fin_cb [tx_idx ] = NULL ;
292
+ tx_cb (dev , - ENETDOWN , data -> tx_fin_cb_arg [tx_idx ]);
293
+ k_sem_give (& data -> tx_sem );
294
+ }
295
+ }
296
+
284
297
return 0 ;
285
298
}
286
299
@@ -554,6 +567,7 @@ static void can_mcan_tc_event_handler(const struct device *dev)
554
567
k_sem_give (& data -> tx_sem );
555
568
556
569
tx_cb = data -> tx_fin_cb [tx_idx ];
570
+ data -> tx_fin_cb [tx_idx ] = NULL ;
557
571
tx_cb (dev , 0 , data -> tx_fin_cb_arg [tx_idx ]);
558
572
}
559
573
}
You can’t perform that action at this time.
0 commit comments