This file manages the USB host mouse HID task.
Definition in file host_mouse_hid_task.h.
#include "conf_usb.h"
#include "usb_host_task.h"
Go to the source code of this file.
Defines | |
#define | DEVICE_TO_HOST 0x01 |
#define | DIR_LOCAL_IN_NAME "IN" |
#define | DIR_LOCAL_OUT_NAME "OUT" |
#define | DIR_USB_IN_NAME "IN" |
#define | DIR_USB_OUT_NAME "OUT" |
#define | FULL_SYNC (DEVICE_TO_HOST | HOST_TO_DEVICE) |
#define | HOST_TO_DEVICE 0x02 |
#define | Is_host_mouse_hid_configured() (mouse_hid_connected && !Is_host_suspended()) |
#define | LED_HOST_MOUSE_B0 LED_MONO0_GREEN |
#define | LED_HOST_MOUSE_B1 LED_MONO1_GREEN |
#define | LED_HOST_MOUSE_B2 LED_MONO2_GREEN |
#define | LED_HOST_MOUSE_B3 LED_MONO3_GREEN |
Functions | |
void | host_mouse_hid_task (void) |
This function manages the host mouse HID task. | |
void | host_mouse_hid_task_init (void) |
This function initializes the host mouse HID task. | |
void | host_sof_action (void) |
host_sof_action | |
Variables | |
volatile Bool | ms_connected |
#define DEVICE_TO_HOST 0x01 |
Definition at line 71 of file host_mouse_hid_task.h.
#define DIR_LOCAL_IN_NAME "IN" |
Definition at line 76 of file host_mouse_hid_task.h.
#define DIR_LOCAL_OUT_NAME "OUT" |
Definition at line 75 of file host_mouse_hid_task.h.
#define DIR_USB_IN_NAME "IN" |
Definition at line 79 of file host_mouse_hid_task.h.
#define DIR_USB_OUT_NAME "OUT" |
Definition at line 78 of file host_mouse_hid_task.h.
#define FULL_SYNC (DEVICE_TO_HOST | HOST_TO_DEVICE) |
Definition at line 73 of file host_mouse_hid_task.h.
#define HOST_TO_DEVICE 0x02 |
Definition at line 72 of file host_mouse_hid_task.h.
#define Is_host_mouse_hid_configured | ( | ) | (mouse_hid_connected && !Is_host_suspended()) |
#define LED_HOST_MOUSE_B0 LED_MONO0_GREEN |
Definition at line 81 of file host_mouse_hid_task.h.
Referenced by disp_led_mouse(), and host_mouse_hid_task().
#define LED_HOST_MOUSE_B1 LED_MONO1_GREEN |
Definition at line 82 of file host_mouse_hid_task.h.
Referenced by disp_led_mouse(), and host_mouse_hid_task().
#define LED_HOST_MOUSE_B2 LED_MONO2_GREEN |
Definition at line 83 of file host_mouse_hid_task.h.
Referenced by disp_led_mouse(), and host_mouse_hid_task().
#define LED_HOST_MOUSE_B3 LED_MONO3_GREEN |
Definition at line 84 of file host_mouse_hid_task.h.
Referenced by disp_led_mouse(), and host_mouse_hid_task().
void host_mouse_hid_task | ( | void | ) |
This function manages the host mouse HID task.
Definition at line 122 of file host_mouse_hid_task.c.
References configTSK_USB_HHID_MOUSE_PERIOD, disp_ascii_mouse(), disp_led_mouse(), HID_IDLE_DURATION_INDEFINITE, HID_REPORT_DESCRIPTOR, HID_REPORT_ID_ALL, host_hid_get_report(), host_hid_set_idle(), Is_host_mouse_hid_configured, LED_HOST_MOUSE_B0, LED_HOST_MOUSE_B1, LED_HOST_MOUSE_B2, LED_HOST_MOUSE_B3, mouse_b0, mouse_b1, mouse_b2, mouse_hid_connected, mouse_hid_new_device_connected, mouse_x, MOUSE_X_MAX, MOUSE_X_MIN, mouse_y, MOUSE_Y_MAX, MOUSE_Y_MIN, new_x, new_y, pipe_mouse_in, and usb_report.
Referenced by host_mouse_hid_task_init(), and main().
00124 { 00125 U8 i; 00126 00127 #ifdef FREERTOS_USED 00128 portTickType xLastWakeTime; 00129 00130 xLastWakeTime = xTaskGetTickCount(); 00131 while (TRUE) 00132 { 00133 vTaskDelayUntil(&xLastWakeTime, configTSK_USB_HHID_MOUSE_PERIOD); 00134 00135 #endif // FREERTOS_USED 00136 // First, check the host controller is in full operating mode with the 00137 // B-device attached and enumerated 00138 if (Is_host_ready()) 00139 { 00140 // New device connection (executed only once after device connection) 00141 if (mouse_hid_new_device_connected) 00142 { 00143 mouse_hid_new_device_connected = FALSE; 00144 00145 // For all supported interfaces 00146 for (i = 0; i < Get_nb_supported_interface(); i++) 00147 { 00148 if(Get_class(i)==HID_CLASS && Get_protocol(i)==MOUSE_PROTOCOL) 00149 { 00150 host_hid_set_idle(HID_IDLE_DURATION_INDEFINITE, HID_REPORT_ID_ALL, i); 00151 host_hid_get_report(HID_REPORT_DESCRIPTOR, 0, i); 00152 pipe_mouse_in = Get_ep_pipe(i, 0); 00153 Host_enable_continuous_in_mode(pipe_mouse_in); 00154 Host_unfreeze_pipe(pipe_mouse_in); 00155 mouse_hid_connected=TRUE; 00156 break; 00157 } 00158 } 00159 } 00160 00161 if( Is_host_mouse_hid_configured() ) 00162 { 00163 if((Is_host_in_received(pipe_mouse_in)) && (Is_host_stall(pipe_mouse_in)==FALSE) ) 00164 { 00165 Host_reset_pipe_fifo_access(pipe_mouse_in); 00166 usb_report[0]= 00167 usb_report[1]= 00168 usb_report[2]= 00169 usb_report[3]=0; 00170 host_read_p_rxpacket(pipe_mouse_in, (void*)usb_report, 4, NULL); 00171 Host_ack_in_received(pipe_mouse_in); 00172 Host_free_in(pipe_mouse_in); 00173 new_x = usb_report[1]; 00174 new_y = usb_report[2]; 00175 mouse_x += new_x; 00176 mouse_y += new_y; 00177 if( mouse_x<MOUSE_X_MIN ) mouse_x=MOUSE_X_MIN; 00178 else if( mouse_x>MOUSE_X_MAX ) mouse_x=MOUSE_X_MAX; 00179 if( mouse_y<MOUSE_Y_MIN ) mouse_y=MOUSE_Y_MIN; 00180 else if( mouse_y>MOUSE_Y_MAX ) mouse_y=MOUSE_Y_MAX; 00181 mouse_b0=usb_report[0] & 1; 00182 mouse_b1=usb_report[0] & 2; 00183 mouse_b2=usb_report[0] & 4; 00184 disp_led_mouse(); 00185 disp_ascii_mouse(); 00186 } 00187 if(Is_host_nak_received(pipe_mouse_in)) 00188 { 00189 Host_ack_nak_received(pipe_mouse_in); 00190 LED_Off(LED_HOST_MOUSE_B0 ); 00191 LED_Off(LED_HOST_MOUSE_B1 ); 00192 LED_Off(LED_HOST_MOUSE_B2 ); 00193 LED_Off(LED_HOST_MOUSE_B3 ); 00194 } 00195 } 00196 } 00197 00198 00199 #ifdef FREERTOS_USED 00200 } 00201 #endif 00202 }
void host_mouse_hid_task_init | ( | void | ) |
This function initializes the host mouse HID task.
Definition at line 99 of file host_mouse_hid_task.c.
References configTSK_USB_HHID_MOUSE_NAME, configTSK_USB_HHID_MOUSE_PRIORITY, configTSK_USB_HHID_MOUSE_STACK_SIZE, host_mouse_hid_task(), mouse_hid_connected, mouse_hid_new_device_connected, and sof_cnt.
Referenced by main().
00100 { 00101 sof_cnt = 0; 00102 mouse_hid_new_device_connected = FALSE; 00103 mouse_hid_connected = FALSE; 00104 00105 #ifdef FREERTOS_USED 00106 xTaskCreate(host_mouse_hid_task, 00107 configTSK_USB_HHID_MOUSE_NAME, 00108 configTSK_USB_HHID_MOUSE_STACK_SIZE, 00109 NULL, 00110 configTSK_USB_HHID_MOUSE_PRIORITY, 00111 NULL); 00112 #endif // FREERTOS_USED 00113 }
volatile Bool ms_connected |
Definition at line 85 of file host_keyboard_hid_task.c.
Referenced by host_keyboard_hid_task(), and host_keyboard_hid_task_init().