#include "config.h"
Go to the source code of this file.
Functions | |
| void | mouse_task_init (void) |
| This function initializes the hardware/software resources required for mouse task. | |
| void | mouse_task (void) |
| Task which links mouse events with the USB HID mouse device. | |
| void | sof_action (void) |
| This function increments the SOF counter each times. | |
Definition in file mouse_task.h.
| void mouse_task | ( | void | ) |
Task which links mouse events with the USB HID mouse device.
Definition at line 143 of file mouse_task.c.
References EP_MOUSE_IN, FALSE, g_b_send_ack_report, g_b_send_report, g_hid_mouse_report, g_u8_cpt_sof, Hid_mouse_report_reset, Is_device_enumerated, is_mouse_event(), Is_usb_vbus_low, Is_usb_write_enabled, Led0_off, Led0_on, NB_IDLE_POLLING_SOF, Setup_power_down_mode, Sleep_instruction, TRUE, Usb_ack_in_ready, Usb_select_endpoint, and Usb_write_byte.
00144 { 00145 if(Is_usb_vbus_low()) 00146 { 00147 Setup_power_down_mode(); 00148 Sleep_instruction(); 00149 } 00150 00151 if(!Is_device_enumerated()) 00152 return; // Device not ready 00153 00154 #if (USB_LOW_SPEED_DEVICE==DISABLE) 00155 // The SOF is used to schedule the task at the same frequency that Endpoint Interrupt frequency 00156 // This check allow to win a CPU time 00157 if(g_u8_cpt_sof<NB_IDLE_POLLING_SOF) 00158 return; // Wait a delay 00159 g_u8_cpt_sof=0; 00160 #endif 00161 00162 if(!g_b_send_report) 00163 { 00164 // No report sending on going then check mouse event to eventualy fill a new report 00165 if(is_mouse_event()) 00166 { 00167 // Enable sending of report 00168 g_b_send_report = TRUE; 00169 } 00170 } 00171 00172 if((!g_b_send_report)&&(!g_b_send_ack_report)) 00173 return; // No report and ack to send 00174 00175 //** A report or ack must be send 00176 Usb_select_endpoint(EP_MOUSE_IN); 00177 if(!Is_usb_write_enabled()) 00178 return; // Endpoint no free 00179 00180 Led0_on(); 00181 if( g_b_send_report ) 00182 { 00183 g_b_send_report = FALSE; 00184 // Send an ack after a "clic" report only 00185 g_b_send_ack_report = (0!=g_hid_mouse_report[0]); 00186 } 00187 else 00188 { 00189 Hid_mouse_report_reset(); // Reset report to have a ack report 00190 g_b_send_ack_report = FALSE; 00191 } 00192 // Send report 00193 Usb_write_byte(g_hid_mouse_report[0]); 00194 Usb_write_byte(g_hid_mouse_report[1]); 00195 Usb_write_byte(g_hid_mouse_report[2]); 00196 Usb_write_byte(g_hid_mouse_report[3]); 00197 Usb_ack_in_ready(); 00198 Led0_off(); 00199 }
1.5.3