Skip to content

Usb post initialization function and tinyusb fixes #128

New issue

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

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

Already on GitHub? # to your account

Merged
merged 7 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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: 1 addition & 1 deletion boards.txt
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ muxto.build.fpu=
muxto.build.float-abi=

muxto.build.board=MUXTO
muxto.build.defines=-DF_CPU=48000000 -DFIRST_BULK_PIPE=4
muxto.build.defines=-DF_CPU=48000000 -DFIRST_BULK_PIPE=4 -DNO_ISOCRONOUS_PIPE=1 -DNUMBER_OF_PIPES=8
muxto.vid.0=0x2341
muxto.pid.0=0x006C
muxto.vid.1=0x2341
Expand Down
4 changes: 4 additions & 0 deletions cores/arduino/usb/USB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ extern "C" {
}

__attribute__((weak)) void configure_usb_mux() {}
/* specific variant USB initialization should define this functiona in variant.cpp */
__attribute__((weak)) void usb_post_initialization() {}

void __USBStart() {
USBIrqCfg_t usb_irq_cfg;
Expand Down Expand Up @@ -361,6 +363,8 @@ void __USBStart() {
/* init device port*/
tud_init(BOARD_TUD_RHPORT);

usb_post_initialization();

#ifdef VUSB_LDO_ENABLE
((R_USB_FS0_Type*)R_USB_FS0_BASE)->USBMC_b.VDCEN = 1;
#endif
Expand Down
2 changes: 1 addition & 1 deletion extras/tinyusb
5 changes: 5 additions & 0 deletions variants/MINIMA/variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ int32_t getPinIndex(bsp_io_port_pin_t p) {

#include "FspTimer.h"

void usb_post_initialization() {
((R_USB_FS0_Type*)R_USB_FS0_BASE)->USBMC_b.VDCEN = 1;
}


void initVariant() {
// bootloader configures LED_BUILTIN as PWM output, deconfigure it to avoid spurious signals
pinMode(LED_BUILTIN, OUTPUT);
Expand Down
5 changes: 5 additions & 0 deletions variants/MUXTO/variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ static const ioport_cfg_t bsp_pin_cfg = {
};
static ioport_instance_ctrl_t ioport_ctrl;

void usb_post_initialization() {
((R_USB_FS0_Type*)R_USB_FS0_BASE)->USBMC_b.VDCEN = 1;
((R_USB_FS0_Type*)R_USB_FS0_BASE)->SYSCFG_b.DPRPU = 1;
}

void initVariant() {
//R_IOPORT_Open(&ioport_ctrl, &bsp_pin_cfg);
//R_IOPORT_PinCfg(NULL, BSP_IO_PORT_09_PIN_14, (uint32_t) (IOPORT_CFG_PERIPHERAL_PIN | IOPORT_PERIPHERAL_USB_FS));
Expand Down
4 changes: 4 additions & 0 deletions variants/UNOWIFIR4/variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ void configure_usb_mux() {

__attribute__((weak)) void __maybe_start_usb() {}

void usb_post_initialization() {
((R_USB_FS0_Type*)R_USB_FS0_BASE)->USBMC_b.VDCEN = 1;
}

void initVariant() {
__maybe_start_usb();
// bootloader configures LED_BUILTIN as PWM output, deconfigure it to avoid spurious signals
Expand Down