copy data from misalign addr to align32 addr when use dma with dcache

This commit is contained in:
sakumisu
2022-06-15 21:04:33 +08:00
parent 5904bbd914
commit 9c5db7d4df
2 changed files with 9 additions and 1 deletions

View File

@@ -29,7 +29,7 @@ const char *parity_name[] = { "N", "O", "E", "M", "S" };
/* Device data structure */
struct cdc_acm_cfg_priv {
/* CDC ACM line coding properties. LE order */
USB_MEM_ALIGN32 struct cdc_line_coding line_coding;
struct cdc_line_coding line_coding;
/* CDC ACM line state bitmap, DTE side */
uint8_t line_state;
/* CDC ACM serial state bitmap, DCE side */

View File

@@ -1054,6 +1054,14 @@ static void usbd_ep0_setup_handler(void)
/* Send smallest of requested and offered length */
usbd_core_cfg.ep0_data_buf_residue = MIN(usbd_core_cfg.ep0_data_buf_len,
setup->wLength);
#ifdef CONFIG_USB_DCACHE_ENABLE
/* check if the data buf addr uses usbd_core_cfg.req_data */
if (((uint32_t)usbd_core_cfg.ep0_data_buf) != ((uint32_t)usbd_core_cfg.req_data)) {
/*copy data buf from misalign32 addr to align32 addr*/
memcpy(usbd_core_cfg.req_data, usbd_core_cfg.ep0_data_buf, usbd_core_cfg.ep0_data_buf_residue);
usbd_core_cfg.ep0_data_buf = usbd_core_cfg.req_data;
}
#endif
/*Send data or status to host*/
usbd_send_to_host(setup->wLength);
}