ATMEL: host_mouse_task.c File Reference

- Main Page
- Modules
- Data Structures
- Files
- Related Pages

# 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.

- Compiler: IAR EWAVR and GNU GCC for AVR
- Supported devices: AT90USB1287, AT90USB1286, AT90USB647, AT90USB646

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 56 of file host_mouse_task.c.

## Function Documentation

void host_mouse_task_init | ( | void |  | ) |

This function initializes the Host USB mouse application.

Parameters:

  | none |

Returns:
  none

Definition at line 76 of file host_mouse_task.c.

References Leds_init.

    00077 {
    00078    Leds_init();
    00079 }

void host_mouse_task | ( | void |  | ) |

This function manages the HOST mouse application

Parameters:

  | none |

Returns:
  none

Definition at line 86 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.

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

Here is the call graph for this function:

## Variable Documentation

U8 mouse_connected = 0

Definition at line 66 of file host_mouse_task.c.

Referenced by host_mouse_task().