Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update tinyusb to improve fsdev driver for ch32v203 #443

Merged
merged 6 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/arduino/Adafruit_TinyUSB_API.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ void TinyUSB_Device_FlushCDC(void) {
!defined(ARDUINO_ARCH_ESP32)

// #define USE_SEGGER_RTT
#ifndef SERIAL_TUSB_DEBUG
#define SERIAL_TUSB_DEBUG Serial1
#endif

#ifdef USE_SEGGER_RTT
#include "SEGGER_RTT/RTT/SEGGER_RTT.h"
Expand Down
25 changes: 16 additions & 9 deletions src/arduino/ports/ch32/Adafruit_TinyUSB_ch32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,14 @@ void TinyUSB_Port_InitDevice(uint8_t rhport) {
switch (SystemCoreClock) {
#if defined(CH32V20x) || defined(CH32V30x)
case 48000000:
usb_div = 0;
break; // div1
usb_div = 0; // div1
break;
case 96000000:
usb_div = 1;
break; // div2
usb_div = 1; // div2
break;
case 144000000:
usb_div = 2;
break; // div3
usb_div = 2; // div3
break;
#elif defined(CH32V10x)
case 48000000:
usb_div = RCC_USBCLKSource_PLLCLK_Div1;
Expand Down Expand Up @@ -167,14 +167,21 @@ void TinyUSB_Port_InitDevice(uint8_t rhport) {
}

void TinyUSB_Port_EnterDFU(void) {
// Reset to Bootloader
// enterSerialDfu();
// Reset to Boot ROM
// Serial1.println("Reset to Boot ROM");
//__disable_irq();
// tud_deinit(0);
//
// // define function pointer to BOOT ROM address
// void (*bootloader_entry)(void) = (void (*)(void))0x1FFF8000;
// bootloader_entry();
// while(1) {}
}

uint8_t TinyUSB_Port_GetSerialNumber(uint8_t serial_id[16]) {
volatile uint32_t *ch32_uuid = ((volatile uint32_t *)0x1FFFF7E8UL);
uint32_t *serial_32 = (uint32_t *)serial_id;
serial_32[0] = ch32_uuid[0]; // TODO maybe __builtin_bswap32()
serial_32[0] = ch32_uuid[0];
serial_32[1] = ch32_uuid[1];
serial_32[2] = ch32_uuid[2];

Expand Down
6 changes: 4 additions & 2 deletions src/arduino/ports/ch32/tusb_config_ch32.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ extern "C" {
#define CFG_TUSB_DEBUG 0
#endif

// #define SERIAL_TUSB_DEBUG Serial2

// For selectively disable device log (when > CFG_TUSB_DEBUG)
// #define CFG_TUD_LOG_LEVEL 3
// #define CFG_TUH_LOG_LEVEL 3
Expand Down Expand Up @@ -97,11 +99,11 @@ extern "C" {
#endif

#ifndef CFG_TUD_VIDEO
#define CFG_TUD_VIDEO 1 // number of video control interfaces
#define CFG_TUD_VIDEO 0 // number of video control interfaces
#endif

#ifndef CFG_TUD_VIDEO_STREAMING
#define CFG_TUD_VIDEO_STREAMING 1 // number of video streaming interfaces
#define CFG_TUD_VIDEO_STREAMING 0 // number of video streaming interfaces
#endif

// video streaming endpoint buffer size
Expand Down
5 changes: 3 additions & 2 deletions src/arduino/webusb/Adafruit_USBD_WebUSB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,9 @@ uint8_t const *tud_descriptor_bos_cb(void) { return desc_bos; }
// Driver response accordingly to the request and the transfer stage
// (setup/data/ack) return false to stall control endpoint (e.g unsupported
// request)
bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage,
tusb_control_request_t const *request) {
TU_ATTR_WEAK bool
tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage,
tusb_control_request_t const *request) {
if (!_webusb_dev) {
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/class/audio/audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ typedef enum
AUDIO_DATA_FORMAT_TYPE_I_IEEE_FLOAT = (uint32_t) (1 << 2),
AUDIO_DATA_FORMAT_TYPE_I_ALAW = (uint32_t) (1 << 3),
AUDIO_DATA_FORMAT_TYPE_I_MULAW = (uint32_t) (1 << 4),
AUDIO_DATA_FORMAT_TYPE_I_RAW_DATA = 0x80000000,
AUDIO_DATA_FORMAT_TYPE_I_RAW_DATA = 0x80000000u,
} audio_data_format_type_I_t;

/// All remaining definitions are taken from the descriptor descriptions in the UAC2 main specification
Expand Down Expand Up @@ -640,7 +640,7 @@ typedef enum
AUDIO_CHANNEL_CONFIG_BOTTOM_CENTER = 0x01000000,
AUDIO_CHANNEL_CONFIG_BACK_LEFT_OF_CENTER = 0x02000000,
AUDIO_CHANNEL_CONFIG_BACK_RIGHT_OF_CENTER = 0x04000000,
AUDIO_CHANNEL_CONFIG_RAW_DATA = 0x80000000,
AUDIO_CHANNEL_CONFIG_RAW_DATA = 0x80000000u,
} audio_channel_config_t;

/// AUDIO Channel Cluster Descriptor (4.1)
Expand Down
Loading
Loading