diff options
| author | sakumisu <[email protected]> | 2022-06-15 21:04:33 +0800 |
|---|---|---|
| committer | sakumisu <[email protected]> | 2022-06-15 21:05:23 +0800 |
| commit | 9c5db7d4df52ea10f23b9fb62fb104326238c101 (patch) | |
| tree | 1b25b4b23b1473fdbc47490a6400259a5546f4db | |
| parent | 5904bbd914c0a220749087a6cfdb01e955bd2b70 (diff) | |
copy data from misalign addr to align32 addr when use dma with dcache
| -rw-r--r-- | class/cdc/usbd_cdc.c | 2 | ||||
| -rw-r--r-- | core/usbd_core.c | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/class/cdc/usbd_cdc.c b/class/cdc/usbd_cdc.c index dfeea6b5..b7b4441a 100644 --- a/class/cdc/usbd_cdc.c +++ b/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 */ diff --git a/core/usbd_core.c b/core/usbd_core.c index dca22910..10dbe57b 100644 --- a/core/usbd_core.c +++ b/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); } |
