Skip to content

Commit c8d35c9

Browse files
committed
Update USBD library to match USBFS API & support HID
1 parent d60d0fd commit c8d35c9

5 files changed

Lines changed: 890 additions & 567 deletions

File tree

examples_usb/USBD/usbd_cdc_tty/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ TARGET:=usbd_cdc_tty
44
TARGET_MCU:=CH32V208
55
TARGET_MCU_PACKAGE:=CH32V208WBU6
66

7+
ADDITIONAL_C_FILES += ../../../extralibs/usbd.c
78
include ../../../ch32fun/ch32fun.mk
89

910
flash : cv_flash

examples_usb/USBD/usbd_cdc_tty/usb_config.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
#include "funconfig.h"
55
#include "ch32fun.h"
66

7-
#define FUSB_CONFIG_EPS 4 // Include EP0 in this count
8-
#define FUSB_EP1_MODE 1 // TX (IN)
9-
#define FUSB_EP2_MODE -1 // RX (OUT)
10-
#define FUSB_EP3_MODE 1 // TX (IN)
7+
#define FUSB_BUFFERS_NUMBER 4 // Number of EP buffers (one for EP0, one per each IN/OUT, two for double)
8+
#define FUSB_EP1_MODE USBD_EP_MODE_TX // IN
9+
#define FUSB_EP2_MODE USBD_EP_MODE_RX // OUT
10+
#define FUSB_EP3_MODE USBD_EP_MODE_TX // IN
1111
#define FUSB_USER_HANDLERS 1
1212

1313
#include "usb_defines.h"

examples_usb/USBD/usbd_cdc_tty/usbd_cdc_tty.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,9 @@ void blink(int n) {
1616
}
1717
}
1818

19-
// this is hacky, it implements the USBFS sender called in ch32fun.c
20-
// we do it like this for now, because the USBFS peripheral is preferred
21-
// over the USBD interface implemented here
22-
int USBFS_SendEndpointNEW( int endp, uint8_t* data, int len, int copy) {
23-
return USBD_SendEndpoint(endp, data, len);
24-
}
25-
2619
// this callback is mandatory when FUNCONF_USE_USBPRINTF is defined,
2720
// can be empty though
28-
void handle_usbd_input(int numbytes, uint8_t *data) {
21+
void HandleUSBInput(int numbytes, uint8_t *data) {
2922
if(numbytes == 1) {
3023
switch(data[0]) {
3124
case '1':

0 commit comments

Comments
 (0)