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