Xmega Application Note | |||||
The USB task checks the income of new requests from the USB Host. When a Setup request occurs, this task will launch the processing of this setup contained in the usb_standard_request.c file. Other class specific requests are also processed in this file.
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.c.
#include "config.h"
#include "conf_usb.h"
#include "usb_device_task.h"
#include "usb_task.h"
#include "usb_drv.h"
#include "usb_descriptors.h"
#include "usb_standard_request.h"
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. | |
Variables | |
uint8_t | usb_configuration_nb |
Store the number of the USB configuration used by the USB device. | |
uint8_t | usb_connected |
Global connection status byte. |
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 }
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 }
uint8_t usb_configuration_nb |
Store the number of the USB configuration used by the USB device.
When its value is different from zero, it means the device mode is enumerated
Definition at line 85 of file usb_standard_request.c.
Referenced by usb_device_task(), usb_enum_var_init(), usb_get_configuration(), and usb_set_configuration().
uint8_t usb_connected |
Global connection status byte.
usb_connected is set to true when VBUS has been detected usb_connected is set to false otherwise
Definition at line 65 of file usb_device_task.c.
Referenced by ISR(), usb_device_task(), usb_enum_var_init(), and usb_start_device().
Generated on Mon Jan 18 09:26:12 2010 for AVR1907 Xplain USB Gateway by ![]() |