host_mouse_task.c File Reference

#include "config.h"
#include "conf_usb.h"
#include "host_mouse_task.h"
#include "modules/usb/host_chap9/usb_host_task.h"
#include "modules/usb/host_chap9/usb_host_enum.h"
#include "lib_mcu/usb/usb_drv.h"

Include dependency graph for host_mouse_task.c:

Go to the source code of this file.

Defines

#define LOG_STR_CODE(str)

Functions

void host_mouse_task_init (void)
 This function initializes the Host USB mouse application.
void host_mouse_task (void)

Variables

U8 mouse_connected = 0
U8 pipe_mouse_in


Detailed Description

This file manages the USB Host mouse control application.

Author:
Atmel Corporation: http://www.atmel.com
Support and FAQ: http://support.atmel.no/

Definition in file host_mouse_task.c.


Define Documentation

#define LOG_STR_CODE ( str   ) 

Definition at line 53 of file host_mouse_task.c.

Referenced by host_mouse_task(), usb_general_interrupt(), and usb_host_task().


Function Documentation

void host_mouse_task_init ( void   ) 

This function initializes the Host USB mouse application.

Parameters:
none 
Returns:
none

Definition at line 73 of file host_mouse_task.c.

References Leds_init.

00074 {
00075    Leds_init();
00076 }

void host_mouse_task ( void   ) 

This function manages the HOST mouse application

Parameters:
none 
Returns:
none

Definition at line 83 of file host_mouse_task.c.

References FALSE, Get_class, Get_ep_addr, Get_nb_supported_interface, Get_protocol, HID_CLASS, HID_PROTOCOL_MOUSE, Host_ack_in_received, Host_ack_nak_received, Host_continuous_in_mode, host_get_hid_repport_descriptor, host_get_hwd_pipe_nb(), host_hid_set_idle, Host_read_byte, Host_select_pipe, Host_send_in, Host_unfreeze_pipe, i, Is_device_disconnection_event, Is_host_in_received, Is_host_nak_received, Is_host_ready, Is_host_stall, Is_new_device_connection_event, Led0_off, Led0_on, Led1_off, Led1_on, Led2_off, Led2_on, Led3_off, Led3_on, Leds_off, LOG_STR_CODE, mouse_connected, and PIPE_MOUSE_IN.

00084 {
00085 U8 i;
00086 S8 new_x,new_y;
00087 
00088    //Test HID device connection
00089    if(Is_host_ready())
00090    {
00091       if(Is_new_device_connection_event())   //Device connection
00092       {
00093             mouse_connected=0;
00094             for(i=0;i<Get_nb_supported_interface();i++)
00095             {
00096                if(Get_class(i)==HID_CLASS && Get_protocol(i)==HID_PROTOCOL_MOUSE)
00097                {
00098                   mouse_connected=1;
00099                   host_hid_set_idle();
00100                   host_get_hid_repport_descriptor();                  
00101                   LOG_STR_CODE(log_mouse_connect);
00102                   PIPE_MOUSE_IN=host_get_hwd_pipe_nb(Get_ep_addr(i,0));
00103                   Host_select_pipe(PIPE_MOUSE_IN);
00104                   Host_continuous_in_mode();
00105                   Host_unfreeze_pipe();
00106                   break;
00107                }
00108             }
00109       }
00110       if(mouse_connected)
00111       {
00112          Host_select_pipe(PIPE_MOUSE_IN);
00113          if(Is_host_in_received())
00114          {
00115             if(Is_host_stall()==FALSE)
00116             {
00117                i=Host_read_byte();
00118                new_x=(S8)Host_read_byte();
00119                new_y=(S8)Host_read_byte();
00120 
00121                if(new_x==0)
00122                { Led0_off(); Led1_off();}
00123                else if(new_x>0)
00124                {Led0_on(); Led1_off();}
00125                else
00126                { Led0_off(); Led1_on();}
00127 
00128                if(new_y==0)
00129                { Led2_off(); Led3_off();}
00130                else if(new_y>0)
00131                { Led2_on(); Led3_off();}
00132                else
00133                { Led2_off(); Led3_on();}
00134             }
00135             Host_ack_in_received(); Host_send_in();
00136          }
00137          if(Is_host_nak_received())
00138          {
00139             Host_ack_nak_received();
00140             Led0_off(); Led1_off();
00141             Led2_off(); Led3_off();
00142          }
00143 
00144       }
00145    }
00146    //Device disconnection...
00147    if(Is_device_disconnection_event())
00148    {
00149       Leds_off();
00150       mouse_connected=0;
00151    }
00152 }

Here is the call graph for this function:


Variable Documentation

U8 mouse_connected = 0

Definition at line 63 of file host_mouse_task.c.

Referenced by host_mouse_task().


Generated on Fri Oct 31 16:09:22 2008 for ATMEL by  doxygen 1.5.3