#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_init | ( | void | ) |
This function initializes the hardware/software resources required for mouse task.
Definition at line 114 of file mouse_task.c.
References FALSE, g_b_send_ack_report, g_b_send_report, g_u8_cpt_sof, Led6_off, Led7_on, Leds_init, Switches_init, TRUE, and Usb_enable_sof_interrupt.
00115 { 00116 // Init SOF 00117 g_u8_cpt_sof=0; 00118 Usb_enable_sof_interrupt(); 00119 00120 // Init interface board 00121 Switches_init(); 00122 Leds_init(); 00123 Led7_on(); 00124 Led6_off(); 00125 00126 // Send a ack report at startup 00127 g_b_send_report = FALSE; 00128 g_b_send_ack_report = TRUE; 00129 }
| void mouse_task | ( | void | ) |
Task which links mouse events with the USB HID mouse device.
Definition at line 134 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_write_enabled, Led6_off, Led6_on, NB_IDLE_POLLING_SOF, TRUE, Usb_ack_in_ready, Usb_select_endpoint, and Usb_write_byte.
00135 { 00136 if(!Is_device_enumerated()) 00137 return; // Device not ready 00138 00139 #if (USB_LOW_SPEED_DEVICE==DISABLE) 00140 // The SOF is used to schedule the task at the same frequency that Endpoint Interrupt frequency 00141 // This check allow to win a CPU time 00142 if(g_u8_cpt_sof<NB_IDLE_POLLING_SOF) 00143 return; // Wait a delay 00144 g_u8_cpt_sof=0; 00145 #endif 00146 00147 if(!g_b_send_report) 00148 { 00149 // No report sending on going then check mouse event to eventualy fill a new report 00150 if(is_mouse_event()) 00151 { 00152 // Enable sending of report 00153 g_b_send_report = TRUE; 00154 } 00155 } 00156 00157 if((!g_b_send_report)&&(!g_b_send_ack_report)) 00158 return; // No report and ack to send 00159 00160 //** A report or ack must be send 00161 Usb_select_endpoint(EP_MOUSE_IN); 00162 if(!Is_usb_write_enabled()) 00163 return; // Endpoint no free 00164 00165 Led6_on(); 00166 if( g_b_send_report ) 00167 { 00168 g_b_send_report = FALSE; 00169 // Send an ack after a "clic" report only 00170 g_b_send_ack_report = (0!=g_hid_mouse_report[0]); 00171 } 00172 else 00173 { 00174 Hid_mouse_report_reset(); // Reset report to have a ack report 00175 g_b_send_ack_report = FALSE; 00176 } 00177 // Send report 00178 Usb_write_byte(g_hid_mouse_report[0]); 00179 Usb_write_byte(g_hid_mouse_report[1]); 00180 Usb_write_byte(g_hid_mouse_report[2]); 00181 Usb_write_byte(g_hid_mouse_report[3]); 00182 Usb_ack_in_ready(); 00183 Led6_off(); 00184 }
1.5.3