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
00044
00045 #define RESUME_PMC_FSTT (PMC_FSMR_FSTT14)
00046 #define RESUME_PIN (GPIO_PUSH_BUTTON_2)
00047 #define RESUME_PIO (PIN_PUSHBUTTON_2_PIO)
00048 #define RESUME_PIO_ID (PIN_PUSHBUTTON_2_ID)
00049 #define RESUME_PIO_MASK (PIN_PUSHBUTTON_2_MASK)
00050 #define RESUME_PIO_ATTR (PIN_PUSHBUTTON_2_ATTR)
00051
00052
00053
00054
00055
00056
00057
00058
00059 static void ui_enable_asynchronous_interrupt(void);
00060 static void ui_disable_asynchronous_interrupt(void);
00061
00062
00063
00064
00065
00066 static void ui_wakeup_handler(uint32_t id, uint32_t mask)
00067 {
00068
00069 }
00070
00071
00072
00073
00074 static void ui_enable_asynchronous_interrupt(void)
00075 {
00076
00077 }
00078
00079
00080
00081
00082 static void ui_disable_asynchronous_interrupt(void)
00083 {
00084
00085 }
00086
00087
00088
00089
00090
00091
00092
00093 void ui_init(void)
00094 {
00095
00096 LED_Configure( LED_YELLOW0 ) ;
00097 LED_Configure( LED_YELLOW1 ) ;
00098 }
00099
00100 void ui_usb_mode_change(bool b_host_mode)
00101 {
00102 (void)b_host_mode;
00103 ui_init();
00104 }
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114 static USBH_enum_status_t ui_enum_status = UHC_ENUM_DISCONNECT;
00115
00116 static uint16_t ui_device_speed_blink;
00117
00118 static int8_t ui_x, ui_y, ui_scroll;
00119
00120 void ui_usb_vbus_change(bool b_vbus_present)
00121 {
00122
00123 }
00124
00125 void ui_usb_vbus_error(void)
00126 {
00127 }
00128
00129 void ui_usb_connection_event(USBH_device_t *pDev, bool b_present)
00130 {
00131 (void)pDev;
00132 if (b_present) {
00133 LED_Set(LED_YELLOW0);
00134 } else {
00135 LED_Clear(LED_YELLOW0);
00136 ui_enum_status = UHC_ENUM_DISCONNECT;
00137 }
00138 }
00139
00140 void ui_usb_enum_event(USBH_device_t *pDev, USBH_enum_status_t status)
00141 {
00142 (void)pDev;
00143 ui_enum_status = status;
00144 if (ui_enum_status == UHC_ENUM_SUCCESS) {
00145 ui_x = 0, ui_y = 0, ui_scroll = 0;
00146 switch (pDev->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 }
00161 }
00162
00163 void ui_usb_wakeup_event(void)
00164 {
00165 ui_disable_asynchronous_interrupt();
00166 }
00167
00168 void ui_usb_sof_event(void)
00169 {
00170 bool b_btn_state;
00171 static bool btn_suspend_and_remotewakeup = false;
00172 static uint16_t counter_sof = 0;
00173
00174 if (ui_enum_status == UHC_ENUM_SUCCESS) {
00175
00176 if (++counter_sof > ui_device_speed_blink) {
00177 counter_sof = 0;
00178 LED_Toggle(LED_YELLOW0);
00179 }
00180
00181
00182
00183
00184 b_btn_state = true ;
00185 if (b_btn_state != btn_suspend_and_remotewakeup) {
00186
00187 btn_suspend_and_remotewakeup = b_btn_state;
00188 if (b_btn_state) {
00189
00190 ui_enable_asynchronous_interrupt();
00191 USBH_suspend(true);
00192 return;
00193 }
00194 }
00195
00196
00197 if (!ui_x && !ui_y && !ui_scroll) {
00198 LED_Clear(LED_YELLOW1);
00199 } else {
00200 ui_x = ui_y = ui_scroll = 0;
00201 LED_Set(LED_YELLOW1);
00202 }
00203 }
00204 }
00205
00206 static void ui_uhi_hid_mouse_btn(bool b_state)
00207 {
00208 static uint8_t nb_down = 0;
00209 if (b_state) {
00210 nb_down++;
00211 } else {
00212 nb_down--;
00213 }
00214
00215 if (nb_down) {
00216
00217 } else {
00218
00219 }
00220 }
00221
00222 void ui_uhi_hid_mouse_btn_left(bool b_state)
00223 {
00224 TRACE_INFO_WP("\r\t\t\t\tLeft Button clicked ");
00225 ui_uhi_hid_mouse_btn(b_state);
00226 }
00227
00228 void ui_uhi_hid_mouse_btn_right(bool b_state)
00229 {
00230 TRACE_INFO_WP("\r\t\t\t\tRight Button clicked ");
00231 ui_uhi_hid_mouse_btn(b_state);
00232 }
00233
00234 void ui_uhi_hid_mouse_btn_middle(bool b_state)
00235 {
00236 ui_uhi_hid_mouse_btn(b_state);
00237 }
00238
00239 void ui_uhi_hid_mouse_move(int8_t x, int8_t y, int8_t scroll)
00240 {
00241 ui_x = x;
00242 ui_y = y;
00243 TRACE_INFO_WP("\r Mouse at X:%d, Y:%d ", ui_x, ui_y);
00244 ui_scroll = scroll;
00245 }
00246
00247
00248