#include "config.h"#include "conf_usb.h"#include "mouse_task.h"#include "usb_descriptors.h"#include "lib_mcu/usb/usb_drv.h"#include "lib_mcu/adc/adc_drv.h"#include "lib_mcu/wdt/wdt_drv.h"#include "lib_mcu/power/power_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_mouse_event (void) |
| This function checks the board interface and fill the HID mouse report. | |
| 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 () |
| This function increments the SOF counter each times. | |
| void | suspend_action (void) |
| This function enables switches interruptions and enters the CPU in power down mode. | |
| __interrupt void | switch_event_int () |
| This function exits the CPU of the power down mode and disables switches interruptions. | |
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 |
| Used to count the number of SOF and create a timer counter. | |
Definition in file mouse_task.c.
| bit is_mouse_event | ( | void | ) |
This function checks the board interface and fill the HID mouse report.
FALSE if not event
Definition at line 207 of file 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 mouse_task().
00208 { 00209 Hid_mouse_report_reset(); 00210 00211 // Check Click events 00212 if(Is_mouse_click_left_event()) { 00213 Hid_mouse_report_click_left(); 00214 } 00215 if(Is_mouse_click_middle_event()) { 00216 Hid_mouse_report_click_middle(); 00217 } 00218 if(Is_mouse_click_right_event()) { 00219 Hid_mouse_report_click_right(); 00220 } 00221 00222 // Check Mouve events 00223 if (Is_mouse_left_event()) { 00224 Hid_mouse_report_left(); 00225 } 00226 if (Is_mouse_right_event()) { 00227 Hid_mouse_report_right(); 00228 } 00229 if (Is_mouse_up_event()) { 00230 Hid_mouse_report_up(); 00231 } 00232 if (Is_mouse_down_event()) { 00233 Hid_mouse_report_down(); 00234 } 00235 #if (TARGET_BOARD==STK525) 00236 if (Is_mouse_scroll_up_event()) { 00237 g_u16_pos_scroll+=SCROLL_STEP; 00238 Hid_mouse_report_scroll_up(); 00239 } 00240 if (Is_mouse_scroll_down_event()) { 00241 g_u16_pos_scroll-=SCROLL_STEP; 00242 Hid_mouse_report_scroll_down(); 00243 } 00244 #endif 00245 00246 // Check report 00247 if((0==g_hid_mouse_report[0]) 00248 && (0==g_hid_mouse_report[1]) 00249 && (0==g_hid_mouse_report[2]) 00250 && (0==g_hid_mouse_report[3])) 00251 { 00252 return FALSE; // No event 00253 } 00254 return TRUE; // Event(s) occurs 00255 }
| void mouse_task | ( | void | ) |
Task which links mouse events with the USB HID mouse device.
Definition at line 143 of file mouse_task.c.
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 }
| __interrupt void switch_event_int | ( | ) |
This function exits the CPU of the power down mode and disables switches interruptions.
//! This function is executed when a switche interruption is received //!
Definition at line 303 of file mouse_task.c.
References Switches_disable_it, and usb_generate_remote_wakeup().
00305 { 00306 Switches_disable_it(); 00307 usb_generate_remote_wakeup(); 00308 }
Used to flag a report ready to send.
Definition at line 103 of file mouse_task.c.
Referenced by mouse_task(), and mouse_task_init().
Used to flag a ack report ready to send.
Definition at line 105 of file mouse_task.c.
Referenced by mouse_task(), and mouse_task_init().
Used to store the HID mouse report.
Definition at line 107 of file mouse_task.c.
Referenced by is_mouse_event(), and mouse_task().
Used to store the HID mouse report.
Definition at line 110 of file mouse_task.c.
Referenced by is_mouse_event(), and mouse_task_init().
| volatile U8 g_u8_cpt_sof |
Used to count the number of SOF and create a timer counter.
Definition at line 113 of file mouse_task.c.
Referenced by mouse_task(), mouse_task_init(), and sof_action().
1.5.3