📄 device.dir
字号:
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2008, 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:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* 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.
* ----------------------------------------------------------------------------
*/
//------------------------------------------------------------------------------
/// \dir
/// !!!Purpose
///
/// This directory provides definitions, structs and functions for USB %device
/// applications with Atmel AT91 microcontrollers and USB %device framework.
///
/// You can develop your own USB %device products based on the class-specific
/// driver code provided, or just take them as a refference.
///
/// !!!Contents
/// There are two groups for the implement:
/// -# The hardware interface driver for USB peripheral on AT91
/// microcontrollers (UDP or UDPHS), this is a part of the "AT91 USB
/// framework".
/// - "core": hardware interface driver for AT91 USB peripheral
/// -# The %device class driver to class-specific %device.
/// - "audio-speaker"
/// - "ccid"
/// - "cdc-serial"
/// - "hid-keyboard"
/// - "massstorage"
///
/// For more information about what a particular group contains, please refer to
/// its documentation page.
///
/// \note
/// Depending on the project, not all the subdirectories will be available
/// (i.e. the #ccid# directory will not be in projects without USB CCID
/// function).
//------------------------------------------------------------------------------
/**
\page "USBD API"
See "USBD API Structures" and "USBD API Methods".\n
!!!USBD API Structures
Several specific structures are used by the USBD API to perform various
operations, such as invoking callbacks or accessing the USBD controller.
There are two %main structures:
- USBDDriver:
It is the %main structure of the USB API. It should be instanciated
in class-specific USB %device driver or user application.
- USBDDriverDescriptors:
It is a list of all descriptors used by a USB %device driver. It
should be instanciated in class-specific USB %device driver or
user application and passed to USBD by USBDDriver_Initialize.
!!!USBD API Methods
The USB API provides serveral methods to perform the following operations:
- Changing the %device state
- USBD_Init
- USBD_Connect, USBD_Disconnect
- USBD_SetAddress
- USBD_SetConfiguration
- USBD_GetState
- "USB Device State Diagram"
- Handling events coming from the USB controller
- USBD_InterruptHandler
- Modifying the behavior of an endpoint
- USBD_ConfigureEndpoint
- USBD_Stall
- USBD_Halt
- USBD_Unhalt
- USBD_IsHalted
- Transferring data
- USBD_Write
- USBD_Read
- USBD_IsoWrite
- Special functions
- USBD_RemoteWakeUp
See "USBD API Methods" for detailed informations.
*/
/**
\page "USBD API Structures"
!!!USBD API Structures
Several specific structures are used by the USBD API to perform various
operations, such as invoking callbacks or accessing the USBD controller.
There are two %main structures:
- USBDDriver:
It is the %main structure of the USB API. It should be instanciated
in class-specific USB %device driver or user application.
- USBDDriverDescriptors:
It is a list of all descriptors used by a USB %device driver. It
should be instanciated in class-specific USB %device driver or
user application and passed to USBD by USBDDriver_Initialize.
*/
/**
\page "USBD API Methods"
!!!USB API methods
The USB API provides serveral methods to perform the following operations:
- Changing the %device state
- USBD_Init
- USBD_Connect, USBD_Disconnect
- USBD_SetAddress
- USBD_SetConfiguration
- USBD_GetState
- "USB Device State Diagram"
- Handling events coming from the USB controller
- USBD_InterruptHandler
- Modifying the behavior of an endpoint
- USBD_ConfigureEndpoint
- USBD_Stall
- USBD_Halt
- USBD_Unhalt
- USBD_IsHalted
- Transferring data
- USBD_Write
- USBD_Read
- USBD_IsoWrite
- Special functions
- USBD_RemoteWakeUp
!!!Controlling the Device State
Chapter 9 of the USB specification 2.0 describes the various states a %device
can be in. Most of the methods of this API are used to change between those
states.
!!USBD_Init
USBD_Init is the first method to call in a user application. Technically, it
must occur just before entering the Attached state. It performs the following
actions:
- USB Device driver and endpoint state initialization
- D+ pull-up configuration and disabling
- UDP hardware initialization (Peripheral and clock init)
A USB %device uses a pull-up on the D+ line to signal its connection to the
host. Depending on the USB controller present on the chip, either an
internal or external pull-up is used. In both cases, its configuration is
performed directly by this method. Please refer to the documentation of a
particular controller for more information about the D+ pull-up.
The ini callback has to perform several mandatory operations at this point.
You can find the default operations in USBDCallbacks_Initialized.
!!USBD_Connect, USBD_Disconnect
These two methods control the state of the D+ upll-up. This makes it possible
to connect of disconnect the %device by software when needed. USBD_Connect
changes the %device state from Powered to Default, while USBD_Disconnect
changes from either Default, Address or Configured to Powered.
!!USBD_SetAddress
USBD_SetAddress extracts the information from the last received
SETUP packet to either change the %device state from Default to
Address or from Address to Default. The difference is made
depending on the value of the wValue field of the request.
This method must only be called right after the SET_ADDRESS
request is received.
!!USBD_SetConfiguration
This function operates in a way similar to USBD_SetAddress. When the SETUP
packet containing a SET_CONFIGURATION request is received,
USBD_SetConfiguration should be called to extract the new configuration
value to adopt. If the wValue field of the request is non-zero, then the
%device must adopt the new configuration and enter the Configuration state;
otherwise, it returns (or stays) in the Address state.
!!USBD_GetState
As its name implies, USBD_GetState simply returns the current state of the USB
driver. See state definitions on "USB %device states".
- USBD_STATE_SUSPENDED
- USBD_STATE_ATTACHED
- USBD_STATE_POWERED
- USBD_STATE_DEFAULT
- USBD_STATE_ADDRESS
- USBD_STATE_CONFIGURED
!!Device State Diagram
See "USB Device State Diagram"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -