From 85ad13334694bf39b4457259adf8e94f7ea48e1d Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Sat, 21 Mar 2020 08:20:51 +0000 Subject: [PATCH] CANFD fixes. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@13466 27425a3e-05d8-49a3-a47f-9c15f0e5edd8 --- os/hal/ports/STM32/LLD/FDCANv1/hal_can_lld.c | 4 ++++ os/hal/ports/STM32/LLD/FDCANv1/hal_can_lld.h | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/os/hal/ports/STM32/LLD/FDCANv1/hal_can_lld.c b/os/hal/ports/STM32/LLD/FDCANv1/hal_can_lld.c index 2c75d928a..7d51dc868 100644 --- a/os/hal/ports/STM32/LLD/FDCANv1/hal_can_lld.c +++ b/os/hal/ports/STM32/LLD/FDCANv1/hal_can_lld.c @@ -279,6 +279,7 @@ bool can_lld_start(CANDriver *canp) { canp->fdcan->CCCR |= FDCAN_CCCR_CCE; /* Setting up operation mode except driver-controlled bits.*/ + canp->fdcan->NBTP = canp->config->NBTP; canp->fdcan->DBTP = canp->config->DBTP; canp->fdcan->CCCR = canp->config->CCCR & ~(FDCAN_CCCR_CSR | FDCAN_CCCR_CSA | FDCAN_CCCR_CCE | FDCAN_CCCR_INIT); @@ -387,6 +388,9 @@ void can_lld_transmit(CANDriver *canp, for (unsigned i = 0U; i < dlc_to_bytes[ctfp->DLC]; i += 4U) { *tx_address++ = ctfp->data32[i / 4U]; } + + /* Starting transmission.*/ + canp->fdcan->TXBAR = (uint32_t)1 << (uint32_t)mailbox; } /** diff --git a/os/hal/ports/STM32/LLD/FDCANv1/hal_can_lld.h b/os/hal/ports/STM32/LLD/FDCANv1/hal_can_lld.h index eb02c344e..3f7c10a1b 100644 --- a/os/hal/ports/STM32/LLD/FDCANv1/hal_can_lld.h +++ b/os/hal/ports/STM32/LLD/FDCANv1/hal_can_lld.h @@ -304,6 +304,10 @@ typedef struct { * @brief Driver configuration structure. */ typedef struct { + /** + * @brief Nominal bit timing and prescaler register. + */ + uint32_t NBTP; /** * @brief Data bit timing and prescaler register. */