Просмотр исходного кода

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

sakumisu 3 лет назад
Родитель
Сommit
9c5db7d4df
2 измененных файлов с 9 добавлено и 1 удалено
  1. 1 1
      class/cdc/usbd_cdc.c
  2. 8 0
      core/usbd_core.c

+ 1 - 1
class/cdc/usbd_cdc.c

@@ -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 */

+ 8 - 0
core/usbd_core.c

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