mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 11:10:54 +03:00
fix(driver_twai): remove new drivre from using legacy type defines
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2025-2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -63,26 +63,16 @@ typedef int twai_clock_source_t;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief TWAI bitrate timing config advanced mode
|
||||
* @note Setting one of `quanta_resolution_hz` and `brp` is enough, otherwise, `brp` is not used.
|
||||
* @brief TWAI bitrate timing advanced config structure
|
||||
*/
|
||||
typedef struct {
|
||||
twai_clock_source_t clk_src; /**< Optional, clock source, remain 0 to using TWAI_CLK_SRC_DEFAULT by default */
|
||||
uint32_t quanta_resolution_hz; /**< The resolution of one timing quanta, in Hz. If setting, brp will be ignored */
|
||||
uint32_t brp; /**< Bit rate pre-divider, f(clk_src) / brp = quanta_resolution_hz, f(clk_src) can be obtained using esp_clk_tree_src_get_freq_hz(clk_src,,)*/
|
||||
uint32_t brp; /**< Bitrate pre-divider, which decides the quanta time */
|
||||
uint8_t prop_seg; /**< Prop_seg length, in quanta time */
|
||||
uint8_t tseg_1; /**< Seg_1 length, in quanta time */
|
||||
uint8_t tseg_2; /**< Seg_2 length, in quanta time */
|
||||
uint8_t sjw; /**< Sync jump width, in quanta time */
|
||||
uint8_t ssp_offset; /**< Secondary sample point offset refet to Sync seg, in quanta time, set 0 to disable ssp */
|
||||
bool triple_sampling; /**< Deprecated, in favor of `ssp_offset` */
|
||||
} twai_timing_config_t;
|
||||
|
||||
/**
|
||||
* @brief TWAI bitrate timing config advanced mode for esp_driver_twai
|
||||
* @note `quanta_resolution_hz` is not supported in this driver
|
||||
*/
|
||||
typedef twai_timing_config_t twai_timing_advanced_config_t;
|
||||
} twai_timing_advanced_config_t;
|
||||
|
||||
/**
|
||||
* @brief Configuration for TWAI mask filter
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -84,6 +84,32 @@ extern "C" {
|
||||
#define TWAI_FILTER_CONFIG_ACCEPT_ALL() {.acceptance_code = 0, .acceptance_mask = 0xFFFFFFFF, .single_filter = true}
|
||||
/** @endcond */
|
||||
|
||||
/**
|
||||
* @brief TWAI group clock source
|
||||
* @note User should select the clock source based on the power and resolution requirement
|
||||
*/
|
||||
#if SOC_TWAI_SUPPORTED
|
||||
typedef soc_periph_twai_clk_src_t twai_clock_source_t;
|
||||
#else
|
||||
typedef int twai_clock_source_t;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief TWAI bitrate timing config advanced mode
|
||||
* @note Setting one of `quanta_resolution_hz` and `brp` is enough, otherwise, `brp` is not used.
|
||||
*/
|
||||
typedef struct {
|
||||
twai_clock_source_t clk_src; /**< Optional, clock source, remain 0 to using TWAI_CLK_SRC_DEFAULT by default */
|
||||
uint32_t quanta_resolution_hz; /**< The resolution of one timing quanta, in Hz. If setting, brp will be ignored */
|
||||
uint32_t brp; /**< Bit rate pre-divider, f(clk_src) / brp = quanta_resolution_hz, f(clk_src) can be obtained using esp_clk_tree_src_get_freq_hz(clk_src,,)*/
|
||||
uint8_t prop_seg; /**< Prop_seg length, in quanta time */
|
||||
uint8_t tseg_1; /**< Seg_1 length, in quanta time */
|
||||
uint8_t tseg_2; /**< Seg_2 length, in quanta time */
|
||||
uint8_t sjw; /**< Sync jump width, in quanta time */
|
||||
uint8_t ssp_offset; /**< Secondary sample point offset refet to Sync seg, in quanta time, set 0 to disable ssp */
|
||||
bool triple_sampling; /**< Deprecated, in favor of `ssp_offset` */
|
||||
} twai_timing_config_t;
|
||||
|
||||
/**
|
||||
* @brief TWAI Controller operating modes
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2025-2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -98,15 +98,8 @@ bool twai_hal_check_brp_validation(twai_hal_context_t *hal_ctx, uint32_t brp)
|
||||
|
||||
void twai_hal_configure_timing(twai_hal_context_t *hal_ctx, const twai_timing_advanced_config_t *t_config)
|
||||
{
|
||||
uint32_t brp = t_config->brp;
|
||||
// both quanta_resolution_hz and brp can affect the baud rate
|
||||
// but a non-zero quanta_resolution_hz takes higher priority
|
||||
if (t_config->quanta_resolution_hz) {
|
||||
brp = hal_ctx->clock_source_hz / t_config->quanta_resolution_hz;
|
||||
}
|
||||
//Configure bus timing
|
||||
twai_ll_set_bus_timing(hal_ctx->dev, brp, t_config->sjw, t_config->tseg_1 + t_config->prop_seg, t_config->tseg_2, !!t_config->ssp_offset);
|
||||
twai_ll_set_clkout(hal_ctx->dev, brp);
|
||||
twai_ll_set_bus_timing(hal_ctx->dev, t_config->brp, t_config->sjw, t_config->tseg_1 + t_config->prop_seg, t_config->tseg_2, !!t_config->ssp_offset);
|
||||
twai_ll_set_clkout(hal_ctx->dev, t_config->brp);
|
||||
}
|
||||
|
||||
void twai_hal_configure_mask_filter(twai_hal_context_t *hal_ctx, uint8_t filter_id, const twai_mask_filter_config_t *f_config)
|
||||
|
||||
@@ -48,7 +48,7 @@ bool twai_hal_check_brp_validation(twai_hal_context_t *hal_ctx, uint32_t brp)
|
||||
return twaifd_ll_check_brp_validation(brp);
|
||||
}
|
||||
|
||||
void twai_hal_configure_timing(twai_hal_context_t *hal_ctx, const twai_timing_config_t *t_config)
|
||||
void twai_hal_configure_timing(twai_hal_context_t *hal_ctx, const twai_timing_advanced_config_t *t_config)
|
||||
{
|
||||
twaifd_ll_set_nominal_bitrate(hal_ctx->dev, t_config);
|
||||
if (t_config->ssp_offset) {
|
||||
@@ -57,7 +57,7 @@ void twai_hal_configure_timing(twai_hal_context_t *hal_ctx, const twai_timing_co
|
||||
}
|
||||
}
|
||||
|
||||
void twai_hal_configure_timing_fd(twai_hal_context_t *hal_ctx, const twai_timing_config_t *t_config_fd)
|
||||
void twai_hal_configure_timing_fd(twai_hal_context_t *hal_ctx, const twai_timing_advanced_config_t *t_config_fd)
|
||||
{
|
||||
twaifd_ll_set_fd_bitrate(hal_ctx->dev, t_config_fd);
|
||||
if (t_config_fd->ssp_offset) {
|
||||
|
||||
Reference in New Issue
Block a user