diff options
| author | sakumisu <[email protected]> | 2025-10-11 20:29:54 +0800 |
|---|---|---|
| committer | sakumisu <[email protected]> | 2025-10-27 17:40:42 +0800 |
| commit | ed344579ff2da523e65d26c271d8d5cce764b8e4 (patch) | |
| tree | 6038c3a403093e65e9d68e0eccf6d9f7be8a0e03 | |
| parent | c3b01eed2588caaf2294095be5d22ddef879d583 (diff) | |
update(port/hpmicro): add dcache support for device
Signed-off-by: sakumisu <[email protected]>
| -rw-r--r-- | port/hpmicro/usb_dc_hpm.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/port/hpmicro/usb_dc_hpm.c b/port/hpmicro/usb_dc_hpm.c index 09896549..beb84826 100644 --- a/port/hpmicro/usb_dc_hpm.c +++ b/port/hpmicro/usb_dc_hpm.c @@ -240,10 +240,15 @@ int usbd_ep_start_write(uint8_t busid, const uint8_t ep, const uint8_t *data, ui return -2; } +#ifdef CONFIG_USB_DCACHE_ENABLE + USB_ASSERT_MSG(!((uintptr_t)data % CONFIG_USB_ALIGN_SIZE), "data is not aligned %d", CONFIG_USB_ALIGN_SIZE); +#endif + g_hpm_udc[busid].in_ep[ep_idx].xfer_buf = (uint8_t *)data; g_hpm_udc[busid].in_ep[ep_idx].xfer_len = data_len; g_hpm_udc[busid].in_ep[ep_idx].actual_xfer_len = 0; + usb_dcache_clean((uintptr_t)data, USB_ALIGN_UP(data_len, CONFIG_USB_ALIGN_SIZE)); usb_device_edpt_xfer(handle, ep, (uint8_t *)data, data_len); return 0; @@ -261,10 +266,15 @@ int usbd_ep_start_read(uint8_t busid, const uint8_t ep, uint8_t *data, uint32_t return -2; } +#ifdef CONFIG_USB_DCACHE_ENABLE + USB_ASSERT_MSG(!((uintptr_t)data % CONFIG_USB_ALIGN_SIZE), "data is not aligned %d", CONFIG_USB_ALIGN_SIZE); +#endif + g_hpm_udc[busid].out_ep[ep_idx].xfer_buf = (uint8_t *)data; g_hpm_udc[busid].out_ep[ep_idx].xfer_len = data_len; g_hpm_udc[busid].out_ep[ep_idx].actual_xfer_len = 0; + usb_dcache_invalidate((uintptr_t)data, USB_ALIGN_UP(data_len, CONFIG_USB_ALIGN_SIZE)); usb_device_edpt_xfer(handle, ep, data, data_len); return 0; @@ -362,6 +372,7 @@ void USBD_IRQHandler(uint8_t busid) if (ep_addr & 0x80) { usbd_event_ep_in_complete_handler(busid, ep_addr, transfer_len); } else { + usb_dcache_invalidate((uintptr_t)g_hpm_udc[busid].out_ep[ep_idx].xfer_buf, USB_ALIGN_UP(transfer_len, CONFIG_USB_ALIGN_SIZE)); usbd_event_ep_out_complete_handler(busid, ep_addr, transfer_len); } } |
