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