From 6a226e3e3ca654e0c9d43ae4a8add794381dcce3 Mon Sep 17 00:00:00 2001 From: sakumisu <1203593632@qq.com> Date: Thu, 12 Jun 2025 21:35:51 +0800 Subject: [PATCH] refactor(port/ch32): classify ch32 port Signed-off-by: sakumisu <1203593632@qq.com> --- README.md | 2 +- README_zh.md | 2 +- port/ch32/README.md | 13 ++++++++++++- port/ch32/{ => ch32fs}/usb_ch32_usbfs_reg.h | 0 port/ch32/{ => ch32fs}/usb_dc_usbfs.c | 4 ++-- port/ch32/{ => ch32hs}/usb_ch32_usbhs_reg.h | 0 port/ch32/{ => ch32hs}/usb_dc_usbhs.c | 0 .../usb_ch585_usbhs_dc.c} | 4 ++-- .../usb_ch585_usbhs_reg.h} | 5 +++++ port/ch32/{ => ch58x}/usb_ch58x_dc_usbfs.c | 0 port/ch32/{ => ch58x}/usb_ch58x_usbfs_reg.h | 0 11 files changed, 23 insertions(+), 7 deletions(-) rename port/ch32/{ => ch32fs}/usb_ch32_usbfs_reg.h (100%) rename port/ch32/{ => ch32fs}/usb_dc_usbfs.c (99%) rename port/ch32/{ => ch32hs}/usb_ch32_usbhs_reg.h (100%) rename port/ch32/{ => ch32hs}/usb_dc_usbhs.c (100%) rename port/ch32/{ch585_usbhs_dc.c => ch58x/usb_ch585_usbhs_dc.c} (99%) rename port/ch32/{ch585_usbhs_reg.h => ch58x/usb_ch585_usbhs_reg.h} (99%) rename port/ch32/{ => ch58x}/usb_ch58x_dc_usbfs.c (100%) rename port/ch32/{ => ch58x}/usb_ch58x_usbfs_reg.h (100%) diff --git a/README.md b/README.md index 8d434602..fcb6f13c 100644 --- a/README.md +++ b/README.md @@ -204,7 +204,7 @@ TODO |AllwinnerTech | F1C100S/F1C200S | musb |[cherryusb_rtt_f1c100s](https://github.com/CherryUSB/cherryusb_rtt_f1c100s)|<= latest | the same with musb | |Bekencorp | bk7256/bk7258 | musb |[bk_idk](https://github.com/CherryUSB/bk_idk)| v0.7.0 | the same with musb | |Sophgo | cv18xx | dwc2 |[cvi_alios_open](https://github.com/CherryUSB/cvi_alios_open)| v0.7.0 | TBD | -|WCH | CH32V307/ch58x | ch32_usbfs/ch32_usbhs/ch58x |[wch_repo](https://github.com/CherryUSB/cherryusb_wch)|<= v0.10.2 | TBD | +|WCH | CH32V307/ch58x | ch32_usbfs/ch32_usbhs/ch58x |[wch_repo](https://github.com/CherryUSB/cherryusb_wch)|<= v0.10.2/>=v1.5.0 | TBD | ## Package Support diff --git a/README_zh.md b/README_zh.md index 2c12ce55..c0ff9133 100644 --- a/README_zh.md +++ b/README_zh.md @@ -204,7 +204,7 @@ TODO |AllwinnerTech | F1C100S/F1C200S | musb |[cherryusb_rtt_f1c100s](https://github.com/CherryUSB/cherryusb_rtt_f1c100s)|<= latest | the same with musb | |Bekencorp | bk7256/bk7258 | musb |[bk_idk](https://github.com/CherryUSB/bk_idk)| v0.7.0 | the same with musb | |Sophgo | cv18xx | dwc2 |[cvi_alios_open](https://github.com/CherryUSB/cvi_alios_open)| v0.7.0 | TBD | -|WCH | CH32V307/ch58x | ch32_usbfs/ch32_usbhs/ch58x |[wch_repo](https://github.com/CherryUSB/cherryusb_wch)|<= v0.10.2 | TBD | +|WCH | CH32V307/ch58x | ch32_usbfs/ch32_usbhs/ch58x |[wch_repo](https://github.com/CherryUSB/cherryusb_wch)|<= v0.10.2/>=v1.5.0 | TBD | ## 软件包支持 diff --git a/port/ch32/README.md b/port/ch32/README.md index a625d04c..68a1ab76 100644 --- a/port/ch32/README.md +++ b/port/ch32/README.md @@ -2,4 +2,15 @@ ## Support Chip List -- CH32V30x +## CH32FS + +- CH32V30X/CH32V20X/CH32V10X/CH32X035 + +## CH32HS + +- CH32V30X + +## CH58X + +- CH57X/CH58X(usbfs) +- CH585(usbhs) diff --git a/port/ch32/usb_ch32_usbfs_reg.h b/port/ch32/ch32fs/usb_ch32_usbfs_reg.h similarity index 100% rename from port/ch32/usb_ch32_usbfs_reg.h rename to port/ch32/ch32fs/usb_ch32_usbfs_reg.h diff --git a/port/ch32/usb_dc_usbfs.c b/port/ch32/ch32fs/usb_dc_usbfs.c similarity index 99% rename from port/ch32/usb_dc_usbfs.c rename to port/ch32/ch32fs/usb_dc_usbfs.c index 65f5ca8c..8047d42d 100644 --- a/port/ch32/usb_dc_usbfs.c +++ b/port/ch32/ch32fs/usb_dc_usbfs.c @@ -404,8 +404,8 @@ void USBD_IRQHandler(uint8_t busid) } } -void OTG_FS_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast"))); -void OTG_FS_IRQHandler(void) +void USBFS_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast"))); +void USBFS_IRQHandler(void) { extern void USBD_IRQHandler(uint8_t busid); USBD_IRQHandler(0); diff --git a/port/ch32/usb_ch32_usbhs_reg.h b/port/ch32/ch32hs/usb_ch32_usbhs_reg.h similarity index 100% rename from port/ch32/usb_ch32_usbhs_reg.h rename to port/ch32/ch32hs/usb_ch32_usbhs_reg.h diff --git a/port/ch32/usb_dc_usbhs.c b/port/ch32/ch32hs/usb_dc_usbhs.c similarity index 100% rename from port/ch32/usb_dc_usbhs.c rename to port/ch32/ch32hs/usb_dc_usbhs.c diff --git a/port/ch32/ch585_usbhs_dc.c b/port/ch32/ch58x/usb_ch585_usbhs_dc.c similarity index 99% rename from port/ch32/ch585_usbhs_dc.c rename to port/ch32/ch58x/usb_ch585_usbhs_dc.c index e066ffb9..2e6724c2 100644 --- a/port/ch32/ch585_usbhs_dc.c +++ b/port/ch32/ch58x/usb_ch585_usbhs_dc.c @@ -1,5 +1,5 @@ #include "usbd_core.h" -#include "ch585_usbhs_reg.h" +#include "usb_ch585_usbhs_reg.h" /** * @brief Related register macro @@ -507,7 +507,7 @@ void USBD_IRQHandler(uint8_t busid) R8_U2EP0_RX_CTRL = USBHS_UEP_R_RES_ACK; CH585_USBHS_DEV->INT_FG = USBHS_UDIF_BUS_RST; } else if (intflag & USBHS_UDIF_SUSPEND) { - if (CH585_USBHS_DEV->MIS_ST & 0x04) { + if (CH585_USBHS_DEV->MIS_ST & USBHS_UDMS_SUSPEND) { /* Suspend */ } else { /* Wake up */ diff --git a/port/ch32/ch585_usbhs_reg.h b/port/ch32/ch58x/usb_ch585_usbhs_reg.h similarity index 99% rename from port/ch32/ch585_usbhs_reg.h rename to port/ch32/ch58x/usb_ch585_usbhs_reg.h index 29ed6db0..cfec7f75 100644 --- a/port/ch32/ch585_usbhs_reg.h +++ b/port/ch32/ch58x/usb_ch585_usbhs_reg.h @@ -1,3 +1,8 @@ +/* + * Copyright (c) 2024, sakumisu + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once /**********************************/ diff --git a/port/ch32/usb_ch58x_dc_usbfs.c b/port/ch32/ch58x/usb_ch58x_dc_usbfs.c similarity index 100% rename from port/ch32/usb_ch58x_dc_usbfs.c rename to port/ch32/ch58x/usb_ch58x_dc_usbfs.c diff --git a/port/ch32/usb_ch58x_usbfs_reg.h b/port/ch32/ch58x/usb_ch58x_usbfs_reg.h similarity index 100% rename from port/ch32/usb_ch58x_usbfs_reg.h rename to port/ch32/ch58x/usb_ch58x_usbfs_reg.h