Skip to content

Commit c210269

Browse files
committed
Fix USBHost crash and enable OTG power
1 parent 197b1b8 commit c210269

File tree

5 files changed

+8
-7
lines changed

5 files changed

+8
-7
lines changed

libraries/USBHOST/src/USBHost.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ uint32_t USBHost::Init(uint8_t id, const tusbh_class_reg_t class_table[]) {
2020
if (id == USB_CORE_ID_HS) {
2121

2222
get_usb_phy()->deinit();
23+
mbed::DigitalOut otg(PJ_6, 1);
2324

2425
_hs = tusb_get_host(USB_CORE_ID_HS);
2526
HOST_PORT_POWER_ON_HS();

libraries/USBHOST/src/board_config.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ do {} while(0U)
9696
#define HOST_PORT_POWER_ON_FS() \
9797
do{}while(0)
9898

99-
//#define RTOS_INTERRUPT_ENTER core_util_critical_section_enter
100-
//#define RTOS_INTERRUPT_LEAVE core_util_critical_section_exit
99+
#define RTOS_INTERRUPT_ENTER core_util_critical_section_enter
100+
#define RTOS_INTERRUPT_LEAVE core_util_critical_section_exit
101101

102102
// init the stdio hardware
103103
void stdio_init(void);

libraries/USBHOST/src/class/host/tusbh.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -718,9 +718,9 @@ int tusbh_device_deinit(tusbh_device_t* dev)
718718
}
719719
}
720720

721-
if(dev_root(dev)->cb_device_remove){
722-
dev_root(dev)->cb_device_remove(dev);
723-
}
721+
//if(dev_root(dev)->cb_device_remove){
722+
// dev_root(dev)->cb_device_remove(dev);
723+
//}
724724

725725
for(uint8_t i=0;i<dev->interface_num;i++){
726726

libraries/USBHOST/src/class/host/tusbh_hub.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ static int hub_data_xfered(tusbh_ep_info_t* ep)
368368
TUSB_HUB_INFO("Connect\n");
369369
tusbh_device_t* child = dev->children[port-1];
370370
if(child){
371-
TUSB_HUB_INFO("aleary has a child\n");
371+
TUSB_HUB_INFO("already has a child\n");
372372
tusbh_device_deinit(child);
373373
dev->children[port-1] = 0;
374374
}

libraries/USBHOST/src/stm32_otg_init.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ void set_io_af_mode(GPIO_TypeDef* GPIO, uint8_t pin, uint8_t af)
259259
gpio_osc_init_structure.Pin = pin;
260260
gpio_osc_init_structure.Mode = GPIO_MODE_AF_PP;
261261
gpio_osc_init_structure.Pull = GPIO_NOPULL;
262-
gpio_osc_init_structure.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
262+
gpio_osc_init_structure.Speed = GPIO_SPEED_FREQ_HIGH;
263263
gpio_osc_init_structure.Alternate = af;
264264
HAL_GPIO_Init(GPIO, &gpio_osc_init_structure);
265265
#else

0 commit comments

Comments
 (0)