Skip to content

Commit 0061a40

Browse files
authored
Merge pull request adafruit#443 from adafruit/update-tinyusb-fsdev
update tinyusb to improve fsdev driver for ch32v203
2 parents 51a9de8 + 9aaf9b5 commit 0061a40

31 files changed

+1417
-1825
lines changed

src/arduino/Adafruit_TinyUSB_API.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ void TinyUSB_Device_FlushCDC(void) {
6363
!defined(ARDUINO_ARCH_ESP32)
6464

6565
// #define USE_SEGGER_RTT
66+
#ifndef SERIAL_TUSB_DEBUG
6667
#define SERIAL_TUSB_DEBUG Serial1
68+
#endif
6769

6870
#ifdef USE_SEGGER_RTT
6971
#include "SEGGER_RTT/RTT/SEGGER_RTT.h"

src/arduino/ports/ch32/Adafruit_TinyUSB_ch32.cpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,14 @@ void TinyUSB_Port_InitDevice(uint8_t rhport) {
118118
switch (SystemCoreClock) {
119119
#if defined(CH32V20x) || defined(CH32V30x)
120120
case 48000000:
121-
usb_div = 0;
122-
break; // div1
121+
usb_div = 0; // div1
122+
break;
123123
case 96000000:
124-
usb_div = 1;
125-
break; // div2
124+
usb_div = 1; // div2
125+
break;
126126
case 144000000:
127-
usb_div = 2;
128-
break; // div3
127+
usb_div = 2; // div3
128+
break;
129129
#elif defined(CH32V10x)
130130
case 48000000:
131131
usb_div = RCC_USBCLKSource_PLLCLK_Div1;
@@ -167,14 +167,21 @@ void TinyUSB_Port_InitDevice(uint8_t rhport) {
167167
}
168168

169169
void TinyUSB_Port_EnterDFU(void) {
170-
// Reset to Bootloader
171-
// enterSerialDfu();
170+
// Reset to Boot ROM
171+
// Serial1.println("Reset to Boot ROM");
172+
//__disable_irq();
173+
// tud_deinit(0);
174+
//
175+
// // define function pointer to BOOT ROM address
176+
// void (*bootloader_entry)(void) = (void (*)(void))0x1FFF8000;
177+
// bootloader_entry();
178+
// while(1) {}
172179
}
173180

174181
uint8_t TinyUSB_Port_GetSerialNumber(uint8_t serial_id[16]) {
175182
volatile uint32_t *ch32_uuid = ((volatile uint32_t *)0x1FFFF7E8UL);
176183
uint32_t *serial_32 = (uint32_t *)serial_id;
177-
serial_32[0] = ch32_uuid[0]; // TODO maybe __builtin_bswap32()
184+
serial_32[0] = ch32_uuid[0];
178185
serial_32[1] = ch32_uuid[1];
179186
serial_32[2] = ch32_uuid[2];
180187

src/arduino/ports/ch32/tusb_config_ch32.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ extern "C" {
4747
#define CFG_TUSB_DEBUG 0
4848
#endif
4949

50+
// #define SERIAL_TUSB_DEBUG Serial2
51+
5052
// For selectively disable device log (when > CFG_TUSB_DEBUG)
5153
// #define CFG_TUD_LOG_LEVEL 3
5254
// #define CFG_TUH_LOG_LEVEL 3
@@ -97,11 +99,11 @@ extern "C" {
9799
#endif
98100

99101
#ifndef CFG_TUD_VIDEO
100-
#define CFG_TUD_VIDEO 1 // number of video control interfaces
102+
#define CFG_TUD_VIDEO 0 // number of video control interfaces
101103
#endif
102104

103105
#ifndef CFG_TUD_VIDEO_STREAMING
104-
#define CFG_TUD_VIDEO_STREAMING 1 // number of video streaming interfaces
106+
#define CFG_TUD_VIDEO_STREAMING 0 // number of video streaming interfaces
105107
#endif
106108

107109
// video streaming endpoint buffer size

src/arduino/webusb/Adafruit_USBD_WebUSB.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,9 @@ uint8_t const *tud_descriptor_bos_cb(void) { return desc_bos; }
251251
// Driver response accordingly to the request and the transfer stage
252252
// (setup/data/ack) return false to stall control endpoint (e.g unsupported
253253
// request)
254-
bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage,
255-
tusb_control_request_t const *request) {
254+
TU_ATTR_WEAK bool
255+
tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage,
256+
tusb_control_request_t const *request) {
256257
if (!_webusb_dev) {
257258
return false;
258259
}

src/class/audio/audio.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ typedef enum
489489
AUDIO_DATA_FORMAT_TYPE_I_IEEE_FLOAT = (uint32_t) (1 << 2),
490490
AUDIO_DATA_FORMAT_TYPE_I_ALAW = (uint32_t) (1 << 3),
491491
AUDIO_DATA_FORMAT_TYPE_I_MULAW = (uint32_t) (1 << 4),
492-
AUDIO_DATA_FORMAT_TYPE_I_RAW_DATA = 0x80000000,
492+
AUDIO_DATA_FORMAT_TYPE_I_RAW_DATA = 0x80000000u,
493493
} audio_data_format_type_I_t;
494494

495495
/// All remaining definitions are taken from the descriptor descriptions in the UAC2 main specification
@@ -640,7 +640,7 @@ typedef enum
640640
AUDIO_CHANNEL_CONFIG_BOTTOM_CENTER = 0x01000000,
641641
AUDIO_CHANNEL_CONFIG_BACK_LEFT_OF_CENTER = 0x02000000,
642642
AUDIO_CHANNEL_CONFIG_BACK_RIGHT_OF_CENTER = 0x04000000,
643-
AUDIO_CHANNEL_CONFIG_RAW_DATA = 0x80000000,
643+
AUDIO_CHANNEL_CONFIG_RAW_DATA = 0x80000000u,
644644
} audio_channel_config_t;
645645

646646
/// AUDIO Channel Cluster Descriptor (4.1)

0 commit comments

Comments
 (0)