I try to use tinyusb as host with the P4. I don't use the espressif host lib because it do not support hub with different speed class device (it's not possible to connect an usb keyboard LS ans usbkey FS through a FS Hub)
So my question : is someone know where I can find an example of tinyusb host with esp32 please ? I tried to run stock tinyusb exemple but I didn't managed to complie.
I added espressif/tinyusb: ^0.18.0~2 to my idf_components.yml but i didn't find the bsp code for my target. In the exemple provided, it failed at the first line : #include "bsp/board_api.h" because the build system didn't find it.
Code: Select all
#include "bsp/board_api.h"
#include "tusb.h"
//--------------------------------------------------------------------+
// MACRO CONSTANT TYPEDEF PROTOTYPES
//--------------------------------------------------------------------+
void led_blinking_task(void);
extern void cdc_app_task(void);
extern void hid_app_task(void);
/*------------- MAIN -------------*/
int main(void) {
board_init();
printf("TinyUSB Host CDC MSC HID Example\r\n");
// init host stack on configured roothub port
tusb_rhport_init_t host_init = {
.role = TUSB_ROLE_HOST,
.speed = TUSB_SPEED_AUTO
};
tusb_init(BOARD_TUH_RHPORT, &host_init);
if (board_init_after_tusb) {
board_init_after_tusb();
}
#if CFG_TUH_ENABLED && CFG_TUH_MAX3421
// FeatherWing MAX3421E use MAX3421E's GPIO0 for VBUS enable
enum { IOPINS1_ADDR = 20u << 3, /* 0xA0 */ };
tuh_max3421_reg_write(BOARD_TUH_RHPORT, IOPINS1_ADDR, 0x01, false);
#endif
while (1) {
// tinyusb host task
tuh_task();
led_blinking_task();
cdc_app_task();
hid_app_task();
}
}
//--------------------------------------------------------------------+
// TinyUSB Callbacks
//--------------------------------------------------------------------+
void tuh_mount_cb(uint8_t dev_addr) {
// application set-up
printf("A device with address %u is mounted\r\n", dev_addr);
}
void tuh_umount_cb(uint8_t dev_addr) {
// application tear-down
printf("A device with address %u is unmounted \r\n", dev_addr);
}
//--------------------------------------------------------------------+
// Blinking Task
//--------------------------------------------------------------------+
void led_blinking_task(void) {
const uint32_t interval_ms = 1000;
static uint32_t start_ms = 0;
static bool led_state = false;
// Blink every interval ms
if (board_millis() - start_ms < interval_ms) {
return;// not enough time
}
start_ms += interval_ms;
board_led_write(led_state);
led_state = 1 - led_state; // toggle
}
Best regards,