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)
257257 const struct can_mcan_config * cfg = dev -> config ;
258258 struct can_mcan_data * data = dev -> data ;
259259 struct can_mcan_reg * can = cfg -> can ;
260+ can_tx_callback_t tx_cb ;
261+ uint32_t tx_idx ;
260262 int ret ;
261263
262264 if (!data -> started ) {
263265 return - EALREADY ;
264266 }
265267
268+ /* CAN transmissions are automatically stopped when entering init mode */
266269 ret = can_enter_init_mode (can , K_MSEC (CAN_INIT_TIMEOUT ));
267270 if (ret != 0 ) {
268271 LOG_ERR ("Failed to enter init mode" );
@@ -281,6 +284,16 @@ int can_mcan_stop(const struct device *dev)
281284
282285 data -> started = false;
283286
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+
284297 return 0 ;
285298}
286299
@@ -554,6 +567,7 @@ static void can_mcan_tc_event_handler(const struct device *dev)
554567 k_sem_give (& data -> tx_sem );
555568
556569 tx_cb = data -> tx_fin_cb [tx_idx ];
570+ data -> tx_fin_cb [tx_idx ] = NULL ;
557571 tx_cb (dev , 0 , data -> tx_fin_cb_arg [tx_idx ]);
558572 }
559573}
You can’t perform that action at this time.
0 commit comments