forked from espressif/esp-idf
Merge branch 'contrib/github_pr_15484_v5.0' into 'release/v5.0'
fix(twai): fixed twai assert fail during recover (GitHub PR) (v5.0) See merge request espressif/esp-idf!37996
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@@ -184,8 +184,10 @@ static inline void twai_handle_tx_buffer_frame(BaseType_t *task_woken, int *aler
|
|||||||
p_twai_obj->tx_msg_count--;
|
p_twai_obj->tx_msg_count--;
|
||||||
assert(p_twai_obj->tx_msg_count >= 0); //Sanity check
|
assert(p_twai_obj->tx_msg_count >= 0); //Sanity check
|
||||||
|
|
||||||
//Check if there are more frames to transmit
|
//If not bus-off, check if there are more frames to transmit
|
||||||
if (p_twai_obj->tx_msg_count > 0 && p_twai_obj->tx_queue != NULL) {
|
if (!twai_hal_check_state_flags(&twai_context, TWAI_HAL_STATE_FLAG_BUS_OFF)
|
||||||
|
&& p_twai_obj->tx_msg_count > 0
|
||||||
|
&& p_twai_obj->tx_queue != NULL) {
|
||||||
twai_hal_frame_t frame;
|
twai_hal_frame_t frame;
|
||||||
int res = xQueueReceiveFromISR(p_twai_obj->tx_queue, &frame, task_woken);
|
int res = xQueueReceiveFromISR(p_twai_obj->tx_queue, &frame, task_woken);
|
||||||
if (res == pdTRUE) {
|
if (res == pdTRUE) {
|
||||||
|
@@ -129,6 +129,7 @@ void twai_hal_stop(twai_hal_context_t *hal_ctx);
|
|||||||
*/
|
*/
|
||||||
static inline void twai_hal_start_bus_recovery(twai_hal_context_t *hal_ctx)
|
static inline void twai_hal_start_bus_recovery(twai_hal_context_t *hal_ctx)
|
||||||
{
|
{
|
||||||
|
TWAI_HAL_CLEAR_BITS(hal_ctx->state_flags, TWAI_HAL_STATE_FLAG_TX_BUFF_OCCUPIED);
|
||||||
TWAI_HAL_SET_BITS(hal_ctx->state_flags, TWAI_HAL_STATE_FLAG_RECOVERING);
|
TWAI_HAL_SET_BITS(hal_ctx->state_flags, TWAI_HAL_STATE_FLAG_RECOVERING);
|
||||||
twai_ll_exit_reset_mode(hal_ctx->dev);
|
twai_ll_exit_reset_mode(hal_ctx->dev);
|
||||||
}
|
}
|
||||||
@@ -188,7 +189,7 @@ static inline bool twai_hal_check_last_tx_successful(twai_hal_context_t *hal_ctx
|
|||||||
* @param check_flags Bit mask of flags to check
|
* @param check_flags Bit mask of flags to check
|
||||||
* @return True if one or more of the flags in check_flags are set
|
* @return True if one or more of the flags in check_flags are set
|
||||||
*/
|
*/
|
||||||
|
__attribute__((always_inline))
|
||||||
static inline bool twai_hal_check_state_flags(twai_hal_context_t *hal_ctx, uint32_t check_flags)
|
static inline bool twai_hal_check_state_flags(twai_hal_context_t *hal_ctx, uint32_t check_flags)
|
||||||
{
|
{
|
||||||
return hal_ctx->state_flags & check_flags;
|
return hal_ctx->state_flags & check_flags;
|
||||||
|
Reference in New Issue
Block a user