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

@@ -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);
}