Xmega Application Note


usb_device_task.h File Reference


Detailed Description

This file contains the function declarations for USB device task.

Application note:
AVR1907: Xplain Evaluation Board
Documentation
For comprehensive code documentation, supported compilers, compiler settings and supported devices see readme.html
Author:
Atmel Corporation: http://www.atmel.com
Support email: avr@atmel.com
Revision
3122
Date
2010-01-13 13:26:22 +0100 (on, 13 jan 2010)

Copyright (c) 2010, Atmel Corporation All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. The name of ATMEL may not be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition in file usb_device_task.h.

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void usb_device_task (void)
 Entry point of the USB device mamagement.
void usb_device_task_init (void)
 This function initializes the USB device controller and system interrupt.
void usb_start_device (void)
 This function initializes the USB device controller.


Function Documentation

void usb_device_task ( void   ) 

Entry point of the USB device mamagement.

This function is the entry point of the USB management. Each USB event is checked here in order to launch the appropriate action. If a Setup request occurs on the Default Control Endpoint, the usb_process_request() function is call in the usb_standard_request.c file

Definition at line 120 of file usb_device_task.c.

References EP_CONTROL, EVT_USB_POWERED, EVT_USB_RESET, Is_usb_event, Is_usb_receive_setup, Is_usb_vbus_high, Usb_ack_event, Usb_attach, usb_configuration_nb, usb_connected, Usb_enable_reset_interrupt, usb_process_request(), Usb_reset_endpoint, Usb_select_endpoint, Usb_send_event, and Usb_vbus_on_action.

Referenced by usb_task().

00121 {
00122         if (Is_usb_vbus_high()&& usb_connected==false)
00123         {
00124                 usb_connected = true;
00125                 Usb_vbus_on_action();
00126                 Usb_send_event(EVT_USB_POWERED);
00127                 Usb_enable_reset_interrupt();
00128                 Usb_attach();
00129         }
00130         
00131         if(Is_usb_event(EVT_USB_RESET))
00132         {
00133                 Usb_ack_event(EVT_USB_RESET);
00134                 Usb_reset_endpoint(0);
00135                 usb_configuration_nb=0;
00136         }
00137         
00138         Usb_select_endpoint(EP_CONTROL);
00139         if (Is_usb_receive_setup())
00140         {
00141                 usb_process_request();
00142         }
00143 }

Here is the call graph for this function:

void usb_device_task_init ( void   ) 

This function initializes the USB device controller and system interrupt.

This function enables the USB controller and init the USB interrupts. The aim is to allow the USB connection detection in order to send the appropriate USB event to the operating mode manager.

Definition at line 81 of file usb_device_task.c.

References Usb_disable, Usb_enable, Usb_enable_vbus_interrupt, and Usb_select_device.

Referenced by usb_task_init().

00082 {
00083         sei();
00084         Usb_disable();
00085         Usb_enable();
00086         Usb_select_device();
00087         Usb_enable_vbus_interrupt();
00088         sei();
00089         
00090 }

void usb_start_device ( void   ) 

This function initializes the USB device controller.

This function enables the USB controller and init the USB interrupts. The aim is to allow the USB connection detection in order to send the appropriate USB event to the operating mode manager. Start device function is executed once VBUS connection has been detected either by the VBUS change interrupt either by the VBUS high level

Definition at line 100 of file usb_device_task.c.

References Start_PLL, Usb_attach, usb_connected, Usb_enable_reset_interrupt, Usb_enable_suspend_interrupt, usb_init_device(), Usb_unfreeze_clock, and Wait_pll_ready.

Referenced by ISR().

00101 {
00102         Start_PLL();
00103         Wait_pll_ready();
00104         Usb_unfreeze_clock();
00105         Usb_enable_suspend_interrupt();
00106         Usb_enable_reset_interrupt();
00107         usb_init_device();               /* Configure the USB controller EP0 */
00108         Usb_attach();
00109         usb_connected = false;
00110 }

Here is the call graph for this function:

@DOC_TITLE@
Generated on Mon Jan 18 09:26:12 2010 for AVR1907 Xplain USB Gateway by doxygen 1.5.5