00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #include "board.h"
00042 #include "ui.h"
00043 #include "conf_usb_host.h"
00044
00045
00046
00047
00048
00049 void ui_init(void)
00050 {
00051
00052 LED_Configure( LED_YELLOW0 ) ;
00053 LED_Configure( LED_YELLOW1 ) ;
00054 }
00055
00056 void ui_usb_mode_change(bool b_host_mode)
00057 {
00058 (void)b_host_mode;
00059 ui_init();
00060 }
00061
00062
00063
00064
00065
00066
00067
00068
00069 static USBH_enum_status_t ui_enum_status=UHC_ENUM_DISCONNECT;
00070
00071 static uint16_t ui_device_speed_blink;
00072
00073 void ui_usb_vbus_change(bool b_vbus_present)
00074 {
00075 if (b_vbus_present) {
00076
00077 } else {
00078
00079 }
00080 }
00081
00082 void ui_usb_vbus_error(void)
00083 {
00084 }
00085
00086 void ui_usb_connection_event(USBH_device_t *dev, bool b_present)
00087 {
00088 UNUSED(dev);
00089 if (b_present) {
00090 LED_Set(LED_YELLOW0);
00091 } else {
00092 LED_Clear(LED_YELLOW0);
00093 ui_enum_status = UHC_ENUM_DISCONNECT;
00094 }
00095 }
00096
00097 void ui_usb_enum_event(USBH_device_t *dev, USBH_enum_status_t status)
00098 {
00099 ui_enum_status = status;
00100 switch (dev->speed) {
00101 case UHD_SPEED_HIGH:
00102 ui_device_speed_blink = 250;
00103 break;
00104 case UHD_SPEED_FULL:
00105 ui_device_speed_blink = 500;
00106 break;
00107 case UHD_SPEED_LOW:
00108 default:
00109 ui_device_speed_blink = 1000;
00110 break;
00111 }
00112 if (ui_enum_status == UHC_ENUM_SUCCESS) {
00113
00114
00115 CDCLineCoding cfg = {
00116 .dwDTERate = (115200),
00117 .bCharFormat = CDCLineCoding_ONESTOPBIT,
00118 .bParityType = CDCLineCoding_NOPARITY,
00119 .bDataBits = 8,
00120 };
00121 TRACE_INFO("USART OPEN");
00122 uart_open();
00123 uart_config(&cfg);
00124 uhi_cdc_open(0, &cfg);
00125 }
00126 }
00127
00128 void ui_usb_wakeup_event(void)
00129 {
00130 }
00131
00132 void ui_usb_sof_event(void)
00133 {
00134 static uint16_t counter_sof = 0;
00135
00136 if (ui_enum_status == UHC_ENUM_SUCCESS) {
00137
00138 if (++counter_sof > ui_device_speed_blink) {
00139 counter_sof = 0;
00140 LED_Toggle(LED_YELLOW0);
00141 }
00142 }
00143 }
00144
00145 void ui_com_rx_start(void)
00146 {
00147 LED_Set(LED_YELLOW1);
00148 }
00149
00150 void ui_com_rx_stop(void)
00151 {
00152 LED_Clear(LED_YELLOW1);
00153 }
00154
00155 void ui_com_tx_start(void)
00156 {
00157 LED_Set(LED_YELLOW1);
00158 }
00159
00160 void ui_com_tx_stop(void)
00161 {
00162 LED_Clear(LED_YELLOW1);
00163 }
00164
00165 void ui_com_error(void)
00166 {
00167 }
00168
00169 void ui_com_overflow(void)
00170 {
00171 }
00172
00173
00174
00175