void ui_usb_enum_event(uhc_device_t *dev, uhc_enum_status_t status) { ui_enum_status = status; switch (dev->speed) { case UHD_SPEED_HIGH: ui_device_speed_blink = 250; break; case UHD_SPEED_FULL: ui_device_speed_blink = 500; break; case UHD_SPEED_LOW: default: ui_device_speed_blink = 1000; break; } if (ui_enum_status == UHC_ENUM_SUCCESS) { // USB Device CDC connected // Open and configure UART and USB CDC ports usb_cdc_line_coding_t cfg = { .dwDTERate = CPU_TO_LE32(115200), .bCharFormat = CDC_STOP_BITS_1, .bParityType = CDC_PAR_NONE, .bDataBits = 8, }; uart_open(); uart_config(&cfg); uhi_cdc_open(0, &cfg); } }
void ui_usb_enum_event(USBH_device_t *dev, USBH_enum_status_t status) { ui_enum_status = status; switch (dev->speed) { case UHD_SPEED_HIGH: ui_device_speed_blink = 250; break; case UHD_SPEED_FULL: ui_device_speed_blink = 500; break; case UHD_SPEED_LOW: default: ui_device_speed_blink = 1000; break; } if (ui_enum_status == UHC_ENUM_SUCCESS) { /* USB Device CDC connected Open and configure UART and USB CDC ports */ CDCLineCoding cfg = { .dwDTERate = (115200), .bCharFormat = CDCLineCoding_ONESTOPBIT, .bParityType = CDCLineCoding_NOPARITY, .bDataBits = 8, }; TRACE_INFO("USART OPEN"); uart_open(); uart_config(&cfg); uhi_cdc_open(0, &cfg); } }
void ui_usb_enum_event(uhc_device_t *dev, uhc_enum_status_t status) { ui_enum_status = status; if (ui_enum_status == UHC_ENUM_SUCCESS) { switch (dev->speed) { case UHD_SPEED_HIGH: ui_device_speed_blink = 250; break; case UHD_SPEED_FULL: ui_device_speed_blink = 500; break; case UHD_SPEED_LOW: default: ui_device_speed_blink = 1000; break; } /* USB Device CDC connected Open and configure UART and USB CDC ports */ usb_cdc_line_coding_t cfg = { .dwDTERate = CPU_TO_LE32(19200), .bCharFormat = CDC_STOP_BITS_1, .bParityType = CDC_PAR_NONE, .bDataBits = 8, }; uart_open(); uart_config(&cfg); uhi_cdc_open(0, &cfg); } } void ui_usb_wakeup_event(void) { #ifdef USB_HOST_LPM_SUPPORT ui_disable_asynchronous_interrupt(); #endif } void ui_usb_sof_event(void) { #ifdef USB_HOST_LPM_SUPPORT bool b_btn_state; static bool btn_suspend_and_remotewakeup = false; #endif static uint16_t counter_sof = 0; if (ui_enum_status == UHC_ENUM_SUCCESS) { /* Display device enumerated and in active mode */ if (++counter_sof > ui_device_speed_blink) { counter_sof = 0; if (!ui_data_transfer) { LED_Toggle(LED_0_PIN); } } #ifdef USB_HOST_LPM_SUPPORT /* Scan button to enter in suspend mode and remote wakeup */ b_btn_state = !port_pin_get_input_level(BUTTON_0_PIN); if (b_btn_state != btn_suspend_and_remotewakeup) { /* Button have changed */ btn_suspend_and_remotewakeup = b_btn_state; if (b_btn_state) { /* Button has been pressed */ ui_enable_asynchronous_interrupt(); LED_Off(LED_0_PIN); uhc_suspend_lpm(true, HIRD_800_US); return; } } #endif // #ifdef USB_HOST_LPM_SUPPORT } }