@@ -21,21 +21,6 @@ LOG_MODULE_REGISTER(can_mcan, CONFIG_CAN_LOG_LEVEL);
2121#define CAN_INIT_TIMEOUT (100)
2222#define CAN_DIV_CEIL (val , div ) (((val) + (div) - 1) / (div))
2323
24- static void memcpy32_volatile (volatile void * dst_ , const volatile void * src_ ,
25- size_t len )
26- {
27- volatile uint32_t * dst = dst_ ;
28- const volatile uint32_t * src = src_ ;
29-
30- __ASSERT (len % 4 == 0 , "len must be a multiple of 4!" );
31- len /= sizeof (uint32_t );
32-
33- while (len -- ) {
34- * dst = * src ;
35- ++ dst ;
36- ++ src ;
37- }
38- }
3924
4025static void memset32_volatile (volatile void * dst_ , uint32_t val , size_t len )
4126{
@@ -625,7 +610,8 @@ static void can_mcan_get_message(const struct device *dev,
625610
626611 sys_cache_data_invd_range ((void * )& fifo [get_idx ].hdr ,
627612 sizeof (struct can_mcan_rx_fifo_hdr ));
628- memcpy32_volatile (& hdr , & fifo [get_idx ].hdr ,
613+
614+ io32_memcpy (& hdr , & fifo [get_idx ].hdr ,
629615 sizeof (struct can_mcan_rx_fifo_hdr ));
630616
631617 frame .dlc = hdr .dlc ;
@@ -670,7 +656,8 @@ static void can_mcan_get_message(const struct device *dev,
670656 /* Data needs to be written in 32 bit blocks! */
671657 sys_cache_data_invd_range ((void * )fifo [get_idx ].data_32 ,
672658 ROUND_UP (data_length , sizeof (uint32_t )));
673- memcpy32_volatile (frame .data_32 , fifo [get_idx ].data_32 ,
659+
660+ io32_memcpy (frame .data_32 , fifo [get_idx ].data_32 ,
674661 ROUND_UP (data_length , sizeof (uint32_t )));
675662
676663 if ((frame .flags & CAN_FRAME_IDE ) != 0 ) {
@@ -892,8 +879,9 @@ int can_mcan_send(const struct device *dev,
892879 tx_hdr .std_id = frame -> id & CAN_STD_ID_MASK ;
893880 }
894881
895- memcpy32_volatile (& msg_ram -> tx_buffer [put_idx ].hdr , & tx_hdr , sizeof (tx_hdr ));
896- memcpy32_volatile (msg_ram -> tx_buffer [put_idx ].data_32 , frame -> data_32 ,
882+ BUILD_ASSERT (sizeof (msg_ram -> tx_buffer [put_idx ].hdr ) == sizeof (tx_hdr ));
883+ io32_memcpy (& msg_ram -> tx_buffer [put_idx ].hdr , & tx_hdr , sizeof (tx_hdr ));
884+ io32_memcpy (msg_ram -> tx_buffer [put_idx ].data_32 , frame -> data_32 ,
897885 ROUND_UP (data_length , 4 ));
898886 sys_cache_data_flush_range ((void * )& msg_ram -> tx_buffer [put_idx ].hdr , sizeof (tx_hdr ));
899887 sys_cache_data_flush_range ((void * )& msg_ram -> tx_buffer [put_idx ].data_32 ,
@@ -966,7 +954,8 @@ int can_mcan_add_rx_filter_std(const struct device *dev,
966954 filter_element .sfce = filter_id & 0x01 ? CAN_MCAN_FCE_FIFO1 :
967955 CAN_MCAN_FCE_FIFO0 ;
968956
969- memcpy32_volatile (& msg_ram -> std_filt [filter_id ], & filter_element ,
957+ BUILD_ASSERT (sizeof (msg_ram -> std_filt [0 ]) == sizeof (filter_element ));
958+ io32_memcpy (& msg_ram -> std_filt [filter_id ], & filter_element ,
970959 sizeof (struct can_mcan_std_filter ));
971960 sys_cache_data_flush_range ((void * )& msg_ram -> std_filt [filter_id ],
972961 sizeof (struct can_mcan_std_filter ));
@@ -1030,7 +1019,7 @@ static int can_mcan_add_rx_filter_ext(const struct device *dev,
10301019 filter_element .efce = filter_id & 0x01 ? CAN_MCAN_FCE_FIFO1 :
10311020 CAN_MCAN_FCE_FIFO0 ;
10321021
1033- memcpy32_volatile (& msg_ram -> ext_filt [filter_id ], & filter_element ,
1022+ io32_memcpy (& msg_ram -> ext_filt [filter_id ], & filter_element ,
10341023 sizeof (struct can_mcan_ext_filter ));
10351024 sys_cache_data_flush_range ((void * )& msg_ram -> ext_filt [filter_id ],
10361025 sizeof (struct can_mcan_ext_filter ));
0 commit comments