drivers: can: m_can variant for STM32H7
* New m_can driver variant for STM32H7, as it uses the complete m_can register set. * Fix definitions for CAN_MCAN_RXF0S_F0FL, CAN_MCAN_TXEFC_EFSA_POS. Signed-off-by: Jeremy Wood <jeremy@bcdevices.com>
This commit is contained in:
parent
03135f4604
commit
1caa7f6cb9
7 changed files with 365 additions and 22 deletions
|
@ -297,10 +297,14 @@ int can_mcan_init(const struct device *dev, const struct can_mcan_config *cfg,
|
|||
(can->crel & CAN_MCAN_CREL_DAY) >> CAN_MCAN_CREL_DAY_POS);
|
||||
|
||||
#ifndef CONFIG_CAN_STM32FD
|
||||
uint32_t mrba = 0;
|
||||
#ifdef CONFIG_CAN_STM32H7
|
||||
mrba = (uint32_t)msg_ram;
|
||||
#endif
|
||||
#ifdef CONFIG_CAN_MCUX_MCAN
|
||||
uint32_t mrba = (uint32_t)msg_ram & CAN_MCAN_MRBA_BA_MSK;
|
||||
|
||||
mrba = (uint32_t)msg_ram & CAN_MCAN_MRBA_BA_MSK;
|
||||
can->mrba = mrba;
|
||||
#endif
|
||||
can->sidfc = (((uint32_t)msg_ram->std_filt - mrba) & CAN_MCAN_SIDFC_FLSSA_MSK) |
|
||||
(ARRAY_SIZE(msg_ram->std_filt) << CAN_MCAN_SIDFC_LSS_POS);
|
||||
can->xidfc = (((uint32_t)msg_ram->ext_filt - mrba) & CAN_MCAN_XIDFC_FLESA_MSK) |
|
||||
|
@ -312,24 +316,8 @@ int can_mcan_init(const struct device *dev, const struct can_mcan_config *cfg,
|
|||
can->rxbc = (((uint32_t)msg_ram->rx_buffer - mrba) & CAN_MCAN_RXBC_RBSA);
|
||||
can->txefc = (((uint32_t)msg_ram->tx_event_fifo - mrba) & CAN_MCAN_TXEFC_EFSA_MSK) |
|
||||
(ARRAY_SIZE(msg_ram->tx_event_fifo) << CAN_MCAN_TXEFC_EFS_POS);
|
||||
can->txbc = (((uint32_t)msg_ram->tx_buffer - mrba) & CAN_MCAN_TXBC_TBSA_MSK) |
|
||||
(ARRAY_SIZE(msg_ram->tx_buffer) << CAN_MCAN_TXBC_TFQS_POS);
|
||||
#else /* CONFIG_CAN_MCUX_MCAN */
|
||||
can->sidfc = ((uint32_t)msg_ram->std_filt & CAN_MCAN_SIDFC_FLSSA_MSK) |
|
||||
(ARRAY_SIZE(msg_ram->std_filt) << CAN_MCAN_SIDFC_LSS_POS);
|
||||
can->xidfc = ((uint32_t)msg_ram->ext_filt & CAN_MCAN_XIDFC_FLESA_MSK) |
|
||||
(ARRAY_SIZE(msg_ram->ext_filt) << CAN_MCAN_XIDFC_LSS_POS);
|
||||
can->rxf0c = ((uint32_t)msg_ram->rx_fifo0 & CAN_MCAN_RXF0C_F0SA) |
|
||||
(ARRAY_SIZE(msg_ram->rx_fifo0) << CAN_MCAN_RXF0C_F0S_POS);
|
||||
can->rxf1c = ((uint32_t)msg_ram->rx_fifo1 & CAN_MCAN_RXF1C_F1SA) |
|
||||
(ARRAY_SIZE(msg_ram->rx_fifo1) << CAN_MCAN_RXF1C_F1S_POS);
|
||||
can->rxbc = ((uint32_t)msg_ram->rx_buffer & CAN_MCAN_RXBC_RBSA);
|
||||
can->txefc = ((uint32_t)msg_ram->tx_event_fifo & CAN_MCAN_TXEFC_EFSA_MSK) |
|
||||
(ARRAY_SIZE(msg_ram->tx_event_fifo) <<
|
||||
CAN_MCAN_TXEFC_EFS_POS);
|
||||
can->txbc = ((uint32_t)msg_ram->tx_buffer & CAN_MCAN_TXBC_TBSA) |
|
||||
(ARRAY_SIZE(msg_ram->tx_buffer) << CAN_MCAN_TXBC_TFQS_POS);
|
||||
#endif /* !CONFIG_CAN_MCUX_MCAN */
|
||||
can->txbc = (((uint32_t)msg_ram->tx_buffer - mrba) & CAN_MCAN_TXBC_TBSA) |
|
||||
(ARRAY_SIZE(msg_ram->tx_buffer) << CAN_MCAN_TXBC_TFQS_POS);
|
||||
|
||||
if (sizeof(msg_ram->tx_buffer[0].data) <= 24) {
|
||||
can->txesc = (sizeof(msg_ram->tx_buffer[0].data) - 8) / 4;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue