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 "ctrl_access.h"
00044 #include "uhi_msc_mem.h"
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 static void ui_disable_asynchronous_interrupt(void);
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 static void ui_disable_asynchronous_interrupt(void)
00065 {
00066 }
00067
00068
00069
00070
00071
00072
00073
00074 void ui_init(void)
00075 {
00076
00077 LED_Configure(LED_YELLOW0);
00078 #if 2 == LED_NUM
00079 LED_Configure(LED_YELLOW1);
00080 #endif
00081 }
00082
00083 void ui_usb_mode_change(bool b_host_mode)
00084 {
00085 UNUSED(b_host_mode);
00086 ui_init();
00087 }
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097 static USBH_enum_status_t ui_enum_status = UHC_ENUM_DISCONNECT;
00098
00099 static uint16_t ui_device_speed_blink;
00100
00101 static bool ui_test_result;
00102
00103 static int8_t ui_x, ui_y, ui_scroll;
00104
00105
00106 void ui_usb_vbus_change(bool b_vbus_present)
00107 {
00108 b_vbus_present = b_vbus_present;
00109 }
00110
00111 void ui_usb_vbus_error(void)
00112 {
00113 }
00114
00115 void ui_usb_connection_event(USBH_device_t *dev, bool b_present)
00116 {
00117 UNUSED(dev);
00118
00119 if (b_present)
00120 LED_Set(LED_YELLOW0);
00121 else {
00122 LED_Clear(LED_YELLOW0);
00123 ui_enum_status = UHC_ENUM_DISCONNECT;
00124 }
00125 }
00126
00127 void ui_usb_enum_event(USBH_device_t *dev, USBH_enum_status_t status)
00128 {
00129 UNUSED(dev);
00130 ui_enum_status = status;
00131
00132 switch (dev->speed) {
00133 case UHD_SPEED_HIGH:
00134 ui_device_speed_blink = 250;
00135 break;
00136
00137 case UHD_SPEED_FULL:
00138 ui_device_speed_blink = 500;
00139 break;
00140
00141 case UHD_SPEED_LOW:
00142 default:
00143 ui_device_speed_blink = 1000;
00144 break;
00145 }
00146
00147 }
00148 void ui_uhi_hid_mouse_change(USBH_device_t *dev, bool b_plug)
00149 {
00150 UNUSED(dev);
00151 UNUSED(b_plug);
00152 }
00153
00154 void ui_uhi_msc_change(USBH_device_t *dev, bool b_plug)
00155 {
00156 UNUSED(dev);
00157 UNUSED(b_plug);
00158 }
00159
00160 void ui_usb_wakeup_event(void)
00161 {
00162 ui_disable_asynchronous_interrupt();
00163 }
00164
00165 void ui_usb_sof_event(void)
00166 {
00167 static uint16_t counter_sof = 0;
00168
00169 if (ui_enum_status == UHC_ENUM_SUCCESS) {
00170
00171 if (++counter_sof > ui_device_speed_blink) {
00172 counter_sof = 0;
00173 LED_Toggle(LED_YELLOW0);
00174 }
00175
00176
00177 if (!ui_x && !ui_y && !ui_scroll) {
00178 #if 2 == LED_NUM
00179 LED_Clear(LED_YELLOW1);
00180 #endif
00181 } else {
00182 ui_x = ui_y = ui_scroll = 0;
00183 #if 2 == LED_NUM
00184 LED_Set(LED_YELLOW1);
00185 #endif
00186 }
00187 }
00188 }
00189
00190 static void ui_uhi_hid_mouse_btn(bool b_state)
00191 {
00192 static uint8_t nb_down = 0;
00193
00194 if (b_state)
00195 nb_down++;
00196 else
00197 nb_down--;
00198 }
00199
00200 void ui_test_flag_reset(void)
00201 {
00202 LED_Clear(LED_YELLOW0);
00203 }
00204
00205 void ui_test_finish(bool b_success)
00206 {
00207 ui_test_result = b_success;
00208
00209 if (ui_test_result) {
00210 #if 2 == LED_NUM
00211 LED_Set(LED_YELLOW1);
00212 #endif
00213 }
00214 }
00215
00216
00217
00218
00219
00220 void ui_uhi_hid_mouse_btn_left(bool b_state)
00221 {
00222 TRACE_INFO_WP("\r\t\t\t\tLeft Button clicked ");
00223 ui_uhi_hid_mouse_btn(b_state);
00224 }
00225
00226 void ui_uhi_hid_mouse_btn_right(bool b_state)
00227 {
00228 TRACE_INFO_WP("\r\t\t\t\tRight Button clicked ");
00229 ui_uhi_hid_mouse_btn(b_state);
00230 }
00231
00232 void ui_uhi_hid_mouse_btn_middle(bool b_state)
00233 {
00234 ui_uhi_hid_mouse_btn(b_state);
00235 }
00236
00237 void ui_uhi_hid_mouse_move(int8_t x, int8_t y, int8_t scroll)
00238 {
00239 ui_x = x;
00240 ui_y = y;
00241 TRACE_INFO_WP("\r Mouse at X:%d, Y:%d ", ui_x, ui_y);
00242 ui_scroll = scroll;
00243 }
00244
00245
00246
00247
00248 void ui_start_read(void)
00249 {
00250 #if 2 == LED_NUM
00251 LED_Set(LED_YELLOW1);
00252 #endif
00253 }
00254
00255 void ui_stop_read(void)
00256 {
00257 #if 2 == LED_NUM
00258 LED_Clear(LED_YELLOW1);
00259 #endif
00260 }
00261
00262 void ui_start_write(void)
00263 {
00264 #if 2 == LED_NUM
00265 LED_Set(LED_YELLOW1);
00266 #endif
00267 }
00268
00269 void ui_stop_write(void)
00270 {
00271 #if 2 == LED_NUM
00272 LED_Clear(LED_YELLOW1);
00273 #endif
00274 }
00275
00276