Skip to content

Commit

Permalink
udpate tinyusb to hathach/tinyusb@c60934e
Browse files Browse the repository at this point in the history
  • Loading branch information
hathach committed Jul 31, 2024
1 parent 51a9de8 commit 889a5d6
Show file tree
Hide file tree
Showing 29 changed files with 1,030 additions and 1,604 deletions.
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
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
120 changes: 66 additions & 54 deletions src/class/audio/audio_device.c

Large diffs are not rendered by default.

Loading

0 comments on commit 889a5d6

Please sign in to comment.