diff --git a/fw/main.c b/fw/main.c index bbc70fc..8275f2b 100644 --- a/fw/main.c +++ b/fw/main.c @@ -1,8 +1,11 @@ #include +#include #include #include #include +#define PIN_LED PA4 +uint8_t pin = 0; // this callback is mandatory when FUNCONF_USE_USBPRINTF is defined, // can be empty though @@ -25,12 +28,19 @@ __attribute__((noreturn)) int main(void) { SystemInit(); funGpioInitAll(); + funPinMode(PIN_LED, GPIO_CFGLR_OUT_10Mhz_PP); USBFSSetup(); + Delay_Ms(500); unsigned int count = 0; - while (1) { + + for (uint32_t x = 0; true ; x++) { poll_input(); // usb - printf("[%d]: Hello From CH32X035\n", count++); - Delay_Ms(100); + if ((x % 100) == 0) { + printf("[%d]: Hello From CH32X035\n", count++); + funDigitalWrite(PIN_LED, pin); + pin = !pin; + } + Delay_Ms(1); } } diff --git a/fw/usb_config.h b/fw/usb_config.h index f13ce6d..16f9fe9 100644 --- a/fw/usb_config.h +++ b/fw/usb_config.h @@ -7,16 +7,16 @@ // Endpoint numbers, at least one (EP0) #define FUSB_CONFIG_EPS 4 // Endpoint configuration for CDC TTY -#define FUSB_EP1_MODE USBFS_EP_TX // TX (IN), CDC Interrupt Endpoint -#define FUSB_EP2_MODE USBFS_EP_RX // RX (OUT), CDC Data OUT -#define FUSB_EP3_MODE USBFS_EP_TX // TX (IN), CDC Data IN +#define FUSB_EP1_MODE 1 // TX (IN), CDC Interrupt Endpoint +#define FUSB_EP2_MODE -1 // RX (OUT), CDC Data OUT +#define FUSB_EP3_MODE 1 // TX (IN), CDC Data IN // Other hardware configuration #define FUSB_SUPPORTS_SLEEP 0 #define FUSB_HID_INTERFACES 0 #define FUSB_CURSED_TURBO_DMA 0 // Hacky, but seems fine, shaves 2.5us off filling 64-byte buffers. #define FUSB_HID_USER_REPORTS 0 #define FUSB_IO_PROFILE 0 -//#define FUSB_USE_HPE FUNCONF_ENABLE_HPE +#define FUSB_USE_HPE FUNCONF_ENABLE_HPE #define FUSB_USER_HANDLERS 1 #define FUSB_USE_DMA7_COPY 0 #define FUSB_VDD_5V 0 // 3.3V