Functions

# mouse_task.h File Reference

This file contains the function declarations. More...

`#include "config.h"`
Include dependency graph for mouse_task.h:
This graph shows which files directly or indirectly include this file:

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.
void | update_osc_cal_task (void)
| This function update the OSCCAL value each 30s.

## Detailed Description

This file contains the function declarations.

- Compiler: IAR EWAVR and GNU GCC for AVR
- Supported devices: ATmega32U4

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

Definition in file mouse_task.h.

## Function Documentation

void mouse_task_init | ( | void | ) |

This function initializes the hardware/software resources required for mouse task.

Definition at line 115 of file mouse_task.c.

References FALSE, g_b_send_ack_report, g_b_send_report, g_int_cpt_cal_update, g_u8_cpt_sof, Led6_off, Led7_on, Leds_init, Switches_init, TRUE, and Usb_enable_sof_interrupt.

    {
       // Init SOF
       g_u8_cpt_sof=0;
       Usb_enable_sof_interrupt();

       // Init interface board
       Switches_init();
       Leds_init();
       Led7_on();
       Led6_off();

       // Send a ack report at startup
       g_b_send_report      = FALSE;
       g_b_send_ack_report  = TRUE;

       // Init the internal OSC calibration counter
       g_int_cpt_cal_update = 0;
    }

void mouse_task | ( | void | ) |

Task which links mouse events with the USB HID mouse device.

Definition at line 138 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, Led6_off, Led6_on, NB_IDLE_POLLING_SOF, TRUE, Usb_ack_in_ready, Usb_select_endpoint, and Usb_write_byte.

    {
       if(!Is_device_enumerated())
          return;  // Device not ready

    #if (USB_LOW_SPEED_DEVICE==DISABLE)
       // The SOF is used to schedule the task at the same frequency that Endpoint Interrupt frequency
       // This check allow to win a CPU time
       if(g_u8_cpt_sof<NB_IDLE_POLLING_SOF)
          return;  // Wait a delay
       g_u8_cpt_sof=0;
    #endif

       if(!g_b_send_report)
       {
          // No report sending on going then check mouse event to eventualy fill a new report
          if(is_mouse_event())
          {
             // Enable sending of report
             g_b_send_report      = TRUE;
          }
       }

       if((!g_b_send_report)&&(!g_b_send_ack_report))
          return;  // No report and ack to send

       //** A report or ack must be send
       Usb_select_endpoint(EP_MOUSE_IN);
       if(!Is_usb_write_enabled())
          return;  // Endpoint no free

       Led6_on();
       if( g_b_send_report )
       {
          g_b_send_report      = FALSE;
          // Send an ack after a "clic" report only
          g_b_send_ack_report = (0!=g_hid_mouse_report[0]);
       }
       else
       {
          Hid_mouse_report_reset();     // Reset report to have a ack report
          g_b_send_ack_report  = FALSE;
       }
       // Send report
       Usb_write_byte(g_hid_mouse_report[0]);
       Usb_write_byte(g_hid_mouse_report[1]);
       Usb_write_byte(g_hid_mouse_report[2]);
       Usb_write_byte(g_hid_mouse_report[3]);
       Usb_ack_in_ready();
       Led6_off();
    }

Here is the call graph for this function:

void update_osc_cal_task | ( | void | ) |

This function update the OSCCAL value each 30s.

    //! The calibration of the internal OSC each 30s
    //!

Definition at line 261 of file mouse_task.c.

References calibrate_inter_osc(), g_int_cpt_cal_update, and vcc_5.

    {
      g_int_cpt_cal_update++;
      if(g_int_cpt_cal_update > 3000)
     {
       g_int_cpt_cal_update = 0;
       calibrate_inter_osc(vcc_5);
     }
    }

Here is the call graph for this function: