#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 146 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_disable_vbus_interrupt, Usb_enable_vbus_interrupt, Usb_select_endpoint, usb_task(), and Usb_write_byte.
00147 { 00148 if(Is_usb_vbus_low()) 00149 { 00150 // Before power down the USB Stack must be call to manage the VBus low state 00151 usb_task(); 00152 Usb_enable_vbus_interrupt(); // To exit of power down mode when VBus is plugged 00153 Setup_power_down_mode(); 00154 Sleep_instruction(); 00155 Usb_disable_vbus_interrupt(); 00156 } 00157 00158 if(!Is_device_enumerated()) 00159 return; // Device not ready 00160 00161 #if (USB_LOW_SPEED_DEVICE==DISABLE) 00162 // The SOF is used to schedule the task at the same frequency that Endpoint Interrupt frequency 00163 // This check allow to win a CPU time 00164 if(g_u8_cpt_sof<NB_IDLE_POLLING_SOF) 00165 return; // Wait a delay 00166 g_u8_cpt_sof=0; 00167 #endif 00168 00169 if(!g_b_send_report) 00170 { 00171 // No report sending on going then check mouse event to eventualy fill a new report 00172 if(is_mouse_event()) 00173 { 00174 // Enable sending of report 00175 g_b_send_report = TRUE; 00176 } 00177 } 00178 00179 if((!g_b_send_report)&&(!g_b_send_ack_report)) 00180 return; // No report and ack to send 00181 00182 //** A report or ack must be send 00183 Usb_select_endpoint(EP_MOUSE_IN); 00184 if(!Is_usb_write_enabled()) 00185 return; // Endpoint no free 00186 00187 Led0_on(); 00188 if( g_b_send_report ) 00189 { 00190 g_b_send_report = FALSE; 00191 // Send an ack after a "clic" report only 00192 g_b_send_ack_report = (0!=g_hid_mouse_report[0]); 00193 } 00194 else 00195 { 00196 Hid_mouse_report_reset(); // Reset report to have a ack report 00197 g_b_send_ack_report = FALSE; 00198 } 00199 // Send report 00200 Usb_write_byte(g_hid_mouse_report[0]); 00201 Usb_write_byte(g_hid_mouse_report[1]); 00202 Usb_write_byte(g_hid_mouse_report[2]); 00203 Usb_write_byte(g_hid_mouse_report[3]); 00204 Usb_ack_in_ready(); 00205 Led0_off(); 00206 }
1.5.3