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 #if 2 == LED_NUM
00054 LED_Configure(LED_YELLOW1);
00055 #endif
00056 }
00057
00058 void ui_usb_mode_change(bool b_host_mode)
00059 {
00060 (void)b_host_mode;
00061 ui_init();
00062 }
00063
00064
00065
00066
00067
00068
00069
00070
00071 static USBH_enum_status_t ui_enum_status = UHC_ENUM_DISCONNECT;
00072
00073 static uint16_t ui_device_speed_blink;
00074
00075 void ui_usb_vbus_change(bool b_vbus_present)
00076 {
00077 if (b_vbus_present) {
00078
00079 } else {
00080
00081 }
00082 }
00083
00084 void ui_usb_vbus_error(void)
00085 {
00086 }
00087
00088 void ui_usb_connection_event(USBH_device_t *dev, bool b_present)
00089 {
00090 UNUSED(dev);
00091
00092 if (b_present)
00093 LED_Set(LED_YELLOW0);
00094 else {
00095 LED_Clear(LED_YELLOW0);
00096 ui_enum_status = UHC_ENUM_DISCONNECT;
00097 }
00098 }
00099
00100 void ui_usb_enum_event(USBH_device_t *dev, USBH_enum_status_t status)
00101 {
00102 ui_enum_status = status;
00103
00104 switch (dev->speed) {
00105 case UHD_SPEED_HIGH:
00106 ui_device_speed_blink = 250;
00107 break;
00108
00109 case UHD_SPEED_FULL:
00110 ui_device_speed_blink = 500;
00111 break;
00112
00113 case UHD_SPEED_LOW:
00114 default:
00115 ui_device_speed_blink = 1000;
00116 break;
00117 }
00118
00119 if (ui_enum_status == UHC_ENUM_SUCCESS) {
00120
00121
00122 CDCLineCoding cfg = {
00123 .dwDTERate = (115200),
00124 .bCharFormat = CDCLineCoding_ONESTOPBIT,
00125 .bParityType = CDCLineCoding_NOPARITY,
00126 .bDataBits = 8,
00127 };
00128 TRACE_INFO("USART OPEN");
00129 uart_open();
00130 uart_config(&cfg);
00131 uhi_cdc_open(0, &cfg);
00132 }
00133 }
00134
00135 void ui_usb_wakeup_event(void)
00136 {
00137 }
00138
00139 void ui_usb_sof_event(void)
00140 {
00141 static uint16_t counter_sof = 0;
00142
00143 if (ui_enum_status == UHC_ENUM_SUCCESS) {
00144
00145 if (++counter_sof > ui_device_speed_blink) {
00146 counter_sof = 0;
00147 LED_Toggle(LED_YELLOW0);
00148 }
00149 }
00150 }
00151
00152 void ui_com_rx_start(void)
00153 {
00154 #if 2 == LED_NUM
00155 LED_Set(LED_YELLOW1);
00156 #endif
00157 }
00158
00159 void ui_com_rx_stop(void)
00160 {
00161 #if 2 == LED_NUM
00162 LED_Clear(LED_YELLOW1);
00163 #endif
00164 }
00165
00166 void ui_com_tx_start(void)
00167 {
00168 #if 2 == LED_NUM
00169 LED_Set(LED_YELLOW1);
00170 #endif
00171 }
00172
00173 void ui_com_tx_stop(void)
00174 {
00175 #if 2 == LED_NUM
00176 LED_Clear(LED_YELLOW1);
00177 #endif
00178 }
00179
00180 void ui_com_error(void)
00181 {
00182 }
00183
00184 void ui_com_overflow(void)
00185 {
00186 }
00187
00188
00189
00190