#include "config.h"#include "conf_usb.h"#include "device_mouse_task.h"#include "usb_descriptors.h"#include "lib_mcu/usb/usb_drv.h"#include "lib_mcu/adc/adc_drv.h"#include "modules/usb/device_chap9/usb_standard_request.h"
Go to the source code of this file.
Defines | |
| #define | Hid_mouse_report_up() (g_hid_mouse_report[2]-=MOUSE_SPEED) |
| #define | Hid_mouse_report_down() (g_hid_mouse_report[2]+=MOUSE_SPEED) |
| #define | Hid_mouse_report_left() (g_hid_mouse_report[1]-=MOUSE_SPEED) |
| #define | Hid_mouse_report_right() (g_hid_mouse_report[1]+=MOUSE_SPEED) |
| #define | Hid_mouse_report_scroll_up() (g_hid_mouse_report[3]+=MOUSE_SPEED) |
| #define | Hid_mouse_report_scroll_down() (g_hid_mouse_report[3]-=MOUSE_SPEED) |
| #define | Hid_mouse_report_click_left() (g_hid_mouse_report[0] |= 0x01) |
| #define | Hid_mouse_report_click_right() (g_hid_mouse_report[0] |= 0x02) |
| #define | Hid_mouse_report_click_middle() (g_hid_mouse_report[0] |= 0x04) |
| #define | Hid_mouse_report_reset() (g_hid_mouse_report[0]=0,g_hid_mouse_report[1]=0,g_hid_mouse_report[2]=0,g_hid_mouse_report[3]=0) |
| #define | Is_mouse_left_event() Is_joy_left() |
| #define | Is_mouse_right_event() Is_joy_right() |
| #define | Is_mouse_up_event() Is_joy_up() |
| #define | Is_mouse_down_event() Is_joy_down() |
| #define | SCROLL_STEP 10 |
| #define | Is_mouse_scroll_up_event() ((g_u16_pos_scroll+SCROLL_STEP) < Get_adc_pot_val()) |
| #define | Is_mouse_scroll_down_event() ((g_u16_pos_scroll-SCROLL_STEP) > Get_adc_pot_val()) |
| #define | Is_mouse_click_left_event() Is_btn_left() |
| #define | Is_mouse_click_middle_event() FALSE |
| #define | Is_mouse_click_right_event() Is_btn_middle() |
Functions | |
| bit | is_device_mouse_event (void) |
| This function checks the board interface and fill the HID mouse report. | |
| void | device_mouse_task_init (void) |
| This function initializes the hardware/software resources required for mouse task. | |
| void | device_mouse_task (void) |
| This function has no effect, but is called by scheduler. | |
| void | device_mouse_task_by_IT (void) |
| Task which links mouse events with the USB HID mouse device. | |
| void | sof_action () |
| This function increments the SOF counter each times. | |
Variables | |
| Bool | g_b_send_report |
| Used to flag a report ready to send. | |
| Bool | g_b_send_ack_report |
| Used to flag a ack report ready to send. | |
| U8 | g_hid_mouse_report [4] |
| Used to store the HID mouse report. | |
| U16 | g_u16_pos_scroll |
| Used to store the HID mouse report. | |
| volatile U8 | g_u8_cpt_sof = 0 |
| Used to count the number of SOF and create a timer counter. | |
| volatile U16 | g_u16_cpt2_sof = 0 |
Definition in file device_mouse_task.c.
| bit is_device_mouse_event | ( | void | ) |
This function checks the board interface and fill the HID mouse report.
FALSE if not event
Definition at line 201 of file device_mouse_task.c.
References FALSE, g_hid_mouse_report, g_u16_pos_scroll, Hid_mouse_report_click_left, Hid_mouse_report_click_middle, Hid_mouse_report_click_right, Hid_mouse_report_down, Hid_mouse_report_left, Hid_mouse_report_reset, Hid_mouse_report_right, Hid_mouse_report_scroll_down, Hid_mouse_report_scroll_up, Hid_mouse_report_up, Is_mouse_click_left_event, Is_mouse_click_middle_event, Is_mouse_click_right_event, Is_mouse_down_event, Is_mouse_left_event, Is_mouse_right_event, Is_mouse_scroll_down_event, Is_mouse_scroll_up_event, Is_mouse_up_event, SCROLL_STEP, and TRUE.
Referenced by device_mouse_task_by_IT().
00202 { 00203 Hid_mouse_report_reset(); 00204 00205 // Check Click events 00206 if(Is_mouse_click_left_event()) { 00207 Hid_mouse_report_click_left(); 00208 } 00209 if(Is_mouse_click_middle_event()) { 00210 Hid_mouse_report_click_middle(); 00211 } 00212 if(Is_mouse_click_right_event()) { 00213 Hid_mouse_report_click_right(); 00214 } 00215 00216 // Check Mouve events 00217 if (Is_mouse_left_event()) { 00218 Hid_mouse_report_left(); 00219 } 00220 if (Is_mouse_right_event()) { 00221 Hid_mouse_report_right(); 00222 } 00223 if (Is_mouse_up_event()) { 00224 Hid_mouse_report_up(); 00225 } 00226 if (Is_mouse_down_event()) { 00227 Hid_mouse_report_down(); 00228 } 00229 00230 if (Is_mouse_scroll_up_event()) { 00231 g_u16_pos_scroll+=SCROLL_STEP; 00232 Hid_mouse_report_scroll_up(); 00233 } 00234 if (Is_mouse_scroll_down_event()) { 00235 g_u16_pos_scroll-=SCROLL_STEP; 00236 Hid_mouse_report_scroll_down(); 00237 } 00238 00239 // Check report 00240 if((0==g_hid_mouse_report[0]) 00241 && (0==g_hid_mouse_report[1]) 00242 && (0==g_hid_mouse_report[2]) 00243 && (0==g_hid_mouse_report[3])) 00244 { 00245 return FALSE; // No event 00246 } 00247 return TRUE; // Event(s) occurs 00248 }
| void device_mouse_task_init | ( | void | ) |
This function initializes the hardware/software resources required for mouse task.
Definition at line 118 of file device_mouse_task.c.
00119 { 00120 // Init SOF 00121 Usb_enable_sof_interrupt(); 00122 00123 // Init interface board 00124 Joy_init(); 00125 Leds_init(); 00126 Hwb_button_init(); 00127 init_adc(); 00128 g_u16_pos_scroll=Get_adc_pot_val(); 00129 00130 // Send a ack report at startup 00131 g_b_send_report = FALSE; 00132 g_b_send_ack_report = TRUE; 00133 }
| void device_mouse_task | ( | void | ) |
This function has no effect, but is called by scheduler.
It is replaced by mouse_task_by_IT() that is interrupt handled
Definition at line 138 of file device_mouse_task.c.
00139 { 00140 if(Is_usb_id_device()) 00141 { 00142 Usb_enable_sof_interrupt(); // In case of interrupt disabled when USB ID pin change 00143 } 00144 }
| void device_mouse_task_by_IT | ( | void | ) |
Task which links mouse events with the USB HID mouse device.
//! This task is interrupt handled : the function is called periodically from the ISR of Start of Frame reception //! That makes possible moving the mouse while the mass storage is used (file copy for example) //!
Definition at line 153 of file device_mouse_task.c.
References EP_MOUSE_IN, FALSE, g_b_send_ack_report, g_b_send_report, g_hid_mouse_report, Hid_mouse_report_reset, Is_device_enumerated, is_device_mouse_event(), Is_usb_write_enabled, TRUE, Usb_ack_in_ready, Usb_select_endpoint, and Usb_write_byte.
Referenced by sof_action().
00154 { 00155 if(!Is_device_enumerated()) 00156 return; // Device not ready 00157 00158 if(!g_b_send_report) 00159 { 00160 // No report sending on going then check mouse event to eventualy fill a new report 00161 if(is_device_mouse_event()) 00162 { 00163 // Enable sending of report 00164 g_b_send_report = TRUE; 00165 } 00166 } 00167 00168 if((!g_b_send_report)&&(!g_b_send_ack_report)) 00169 return; // No report and ack to send 00170 00171 //** A report or ack must be send 00172 Usb_select_endpoint(EP_MOUSE_IN); 00173 if(!Is_usb_write_enabled()) 00174 return; // Endpoint no free 00175 00176 if( g_b_send_report ) 00177 { 00178 g_b_send_report = FALSE; 00179 // Send an ack after a "clic" report only 00180 g_b_send_ack_report = (0!=g_hid_mouse_report[0]); 00181 } 00182 else 00183 { 00184 Hid_mouse_report_reset(); // Reset report to have a ack report 00185 g_b_send_ack_report = FALSE; 00186 } 00187 // Send report 00188 Usb_write_byte(g_hid_mouse_report[0]); 00189 Usb_write_byte(g_hid_mouse_report[1]); 00190 Usb_write_byte(g_hid_mouse_report[2]); 00191 Usb_write_byte(g_hid_mouse_report[3]); 00192 Usb_ack_in_ready(); 00193 }
Used to flag a report ready to send.
Definition at line 104 of file device_mouse_task.c.
Referenced by device_mouse_task_by_IT(), and device_mouse_task_init().
Used to flag a ack report ready to send.
Definition at line 106 of file device_mouse_task.c.
Referenced by device_mouse_task_by_IT(), and device_mouse_task_init().
Used to store the HID mouse report.
Definition at line 108 of file device_mouse_task.c.
Referenced by device_mouse_task_by_IT(), and is_device_mouse_event().
Used to store the HID mouse report.
Definition at line 110 of file device_mouse_task.c.
Referenced by device_mouse_task_init(), and is_device_mouse_event().
| volatile U8 g_u8_cpt_sof = 0 |
Used to count the number of SOF and create a timer counter.
Definition at line 112 of file device_mouse_task.c.
Referenced by sof_action().
| volatile U16 g_u16_cpt2_sof = 0 |
Definition at line 113 of file device_mouse_task.c.
Referenced by hid_report_in(), and sof_action().
1.5.3