int main(void) { clock_setup(); gpio_setup(); // provides time_curr_us to usbh_poll function tim6_setup(); #ifdef USART_DEBUG usart_init(USART6, 921600); #endif LOG_PRINTF("\n\n\n\n\n###################\nInit\n"); /** * device driver initialization * * Pass configuration struct where the callbacks are defined */ hid_driver_init(&hid_config); hub_driver_init(); gp_xbox_driver_init(&gp_xbox_config); midi_driver_init(&midi_config); gpio_set(GPIOD, GPIO13); /** * Pass array of supported low level drivers * In case of stm32f407, there are up to two supported OTG hosts on one chip. * Each one can be enabled or disabled in usbh_config.h - optimization for speed * * Pass array of supported device drivers */ usbh_init(lld_drivers, device_drivers); gpio_clear(GPIOD, GPIO13); LOG_PRINTF("USB init complete\n"); LOG_FLUSH(); while (1) { // set busy led gpio_set(GPIOD, GPIO14); uint32_t time_curr_us = tim6_get_time_us(); usbh_poll(time_curr_us); // clear busy led gpio_clear(GPIOD, GPIO14); LOG_FLUSH(); // approx 1ms interval between usbh_poll() delay_ms_busy_loop(1); } return 0; }
void USB_host::poll() { usbh_poll(get_time_us()); delay_ms(1); }