feat(driver_twai): add api to get onchip hardware timing limit

This commit is contained in:
wanckl
2026-08-18 16:50:19 +08:00
parent 124edb2243
commit 21c1c30db5
8 changed files with 111 additions and 39 deletions
@@ -132,6 +132,20 @@ bool twai_hal_init(twai_hal_context_t *hal_ctx, const twai_hal_config_t *config)
*/
void twai_hal_deinit(twai_hal_context_t *hal_ctx);
/**
* @brief Get the hardware-dependent timing limits const
*
* @param t_const Pointer to timing limits const structure
*/
void twai_hal_get_timing_limits(twai_timing_limits_t *t_const);
/**
* @brief Get the hardware-dependent timing limits const for FD data timing
*
* @param t_const_fd Pointer to timing limits const structure for FD data
*/
void twai_hal_get_timing_limits_fd(twai_timing_limits_t *t_const_fd);
/**
* @brief Configure the TWAI peripheral for legacy driver (deprecated)
*
@@ -74,6 +74,24 @@ typedef struct {
uint8_t ssp_offset; /**< Secondary sample point offset refet to Sync seg, in quanta time, set 0 to disable ssp */
} twai_timing_advanced_config_t;
/**
* @brief TWAI hardware-dependent timing limits const
*
* Used for calculating and checking bit-timing parameters
*/
typedef struct {
uint32_t brp_min; /**< Bit-rate prescaler minimum value */
uint32_t brp_max; /**< Bit-rate prescaler maximum value */
uint32_t brp_inc; /**< Bit-rate prescaler increment step */
uint32_t prop_min; /**< Propagation segment minimum value */
uint32_t prop_max; /**< Propagation segment maximum value */
uint32_t tseg1_min; /**< Time segment 1 (phase_seg1) minimum value */
uint32_t tseg1_max; /**< Time segment 1 (phase_seg1) maximum value */
uint32_t tseg2_min; /**< Time segment 2 (phase_seg2) minimum value */
uint32_t tseg2_max; /**< Time segment 2 (phase_seg2) maximum value */
uint32_t sjw_max; /**< Synchronisation jump width maximum value */
} twai_timing_limits_t;
/**
* @brief Configuration for TWAI mask filter
*/