Core kernel code:
Allow the stats formatting functions to be built in without stdio.h being included inside tasks.c. Kernel port code: - Slight change to the Cortex-A GIC-less port to move all non portable code to the application level. SAMA5D4 demo project: - Update the Atmel provided library to V1.1. - Create a DDR build configuration. - Ensure interrupts are all edge sensitive. - Update the regtest code to use all 32 flop registers.pull/4/head
parent
e3263bb9b3
commit
ca22607d14
@ -1,2 +1,2 @@
|
||||
[MainWindow]
|
||||
WindowPlacement=_ 68 69 855 818 3
|
||||
WindowPlacement=_ 90 4 1190 900 3
|
||||
|
@ -0,0 +1,558 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* SAM Software Package License
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2011, 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
/** \file
|
||||
* \addtogroup usbd_cdc
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Headers
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
#include "board.h"
|
||||
#include "include/USBD_Config.h"
|
||||
#include "CDCDSerialDriver.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/** \addtogroup usbd_cdc_serial_device_ids CDC Serial Device IDs
|
||||
* @{
|
||||
* This page lists the IDs used in the CDC Serial Device Descriptor.
|
||||
*
|
||||
* \section IDs
|
||||
* - CDCDSerialDriverDescriptors_PRODUCTID
|
||||
* - CDCDSerialDriverDescriptors_VENDORID
|
||||
* - CDCDSerialDriverDescriptors_RELEASE
|
||||
*/
|
||||
|
||||
/** Device product ID. */
|
||||
#define CDCDSerialDriverDescriptors_PRODUCTID 0x6119
|
||||
/** Device vendor ID (Atmel). */
|
||||
#define CDCDSerialDriverDescriptors_VENDORID 0x03EB
|
||||
/** Device release number. */
|
||||
#define CDCDSerialDriverDescriptors_RELEASE 0x0100
|
||||
/** @}*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Macros
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/** Returns the minimum between two values. */
|
||||
#define MIN(a, b) ((a < b) ? a : b)
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Exported variables
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/** Standard USB device descriptor for the CDC serial driver */
|
||||
const USBDeviceDescriptor deviceDescriptor = {
|
||||
|
||||
sizeof(USBDeviceDescriptor),
|
||||
USBGenericDescriptor_DEVICE,
|
||||
USBDeviceDescriptor_USB2_00,
|
||||
CDCDeviceDescriptor_CLASS,
|
||||
CDCDeviceDescriptor_SUBCLASS,
|
||||
CDCDeviceDescriptor_PROTOCOL,
|
||||
CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0),
|
||||
CDCDSerialDriverDescriptors_VENDORID,
|
||||
CDCDSerialDriverDescriptors_PRODUCTID,
|
||||
CDCDSerialDriverDescriptors_RELEASE,
|
||||
0, /* No string descriptor for manufacturer */
|
||||
1, /* Index of product string descriptor is #1 */
|
||||
0, /* No string descriptor for serial number */
|
||||
1 /* Device has 1 possible configuration */
|
||||
};
|
||||
|
||||
/** Standard USB configuration descriptor for the CDC serial driver */
|
||||
const CDCDSerialDriverConfigurationDescriptors configurationDescriptorsFS = {
|
||||
|
||||
/* Standard configuration descriptor */
|
||||
{
|
||||
sizeof(USBConfigurationDescriptor),
|
||||
USBGenericDescriptor_CONFIGURATION,
|
||||
sizeof(CDCDSerialDriverConfigurationDescriptors),
|
||||
2, /* There are two interfaces in this configuration */
|
||||
1, /* This is configuration #1 */
|
||||
0, /* No string descriptor for this configuration */
|
||||
USBD_BMATTRIBUTES,
|
||||
USBConfigurationDescriptor_POWER(100)
|
||||
},
|
||||
/* Communication class interface standard descriptor */
|
||||
{
|
||||
sizeof(USBInterfaceDescriptor),
|
||||
USBGenericDescriptor_INTERFACE,
|
||||
0, /* This is interface #0 */
|
||||
0, /* This is alternate setting #0 for this interface */
|
||||
1, /* This interface uses 1 endpoint */
|
||||
CDCCommunicationInterfaceDescriptor_CLASS,
|
||||
CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL,
|
||||
CDCCommunicationInterfaceDescriptor_NOPROTOCOL,
|
||||
0 /* No string descriptor for this interface */
|
||||
},
|
||||
/* Class-specific header functional descriptor */
|
||||
{
|
||||
sizeof(CDCHeaderDescriptor),
|
||||
CDCGenericDescriptor_INTERFACE,
|
||||
CDCGenericDescriptor_HEADER,
|
||||
CDCGenericDescriptor_CDC1_10
|
||||
},
|
||||
/* Class-specific call management functional descriptor */
|
||||
{
|
||||
sizeof(CDCCallManagementDescriptor),
|
||||
CDCGenericDescriptor_INTERFACE,
|
||||
CDCGenericDescriptor_CALLMANAGEMENT,
|
||||
CDCCallManagementDescriptor_SELFCALLMANAGEMENT,
|
||||
0 /* No associated data interface */
|
||||
},
|
||||
/* Class-specific abstract control management functional descriptor */
|
||||
{
|
||||
sizeof(CDCAbstractControlManagementDescriptor),
|
||||
CDCGenericDescriptor_INTERFACE,
|
||||
CDCGenericDescriptor_ABSTRACTCONTROLMANAGEMENT,
|
||||
CDCAbstractControlManagementDescriptor_LINE
|
||||
},
|
||||
/* Class-specific union functional descriptor with one slave interface */
|
||||
{
|
||||
sizeof(CDCUnionDescriptor),
|
||||
CDCGenericDescriptor_INTERFACE,
|
||||
CDCGenericDescriptor_UNION,
|
||||
0, /* Number of master interface is #0 */
|
||||
1 /* First slave interface is #1 */
|
||||
},
|
||||
/* Notification endpoint standard descriptor */
|
||||
{
|
||||
sizeof(USBEndpointDescriptor),
|
||||
USBGenericDescriptor_ENDPOINT,
|
||||
USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN,
|
||||
CDCDSerialDriverDescriptors_NOTIFICATION),
|
||||
USBEndpointDescriptor_INTERRUPT,
|
||||
MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDSerialDriverDescriptors_NOTIFICATION),
|
||||
USBEndpointDescriptor_MAXINTERRUPTSIZE_FS),
|
||||
10 /* Endpoint is polled every 10ms */
|
||||
},
|
||||
/* Data class interface standard descriptor */
|
||||
{
|
||||
sizeof(USBInterfaceDescriptor),
|
||||
USBGenericDescriptor_INTERFACE,
|
||||
1, /* This is interface #1 */
|
||||
0, /* This is alternate setting #0 for this interface */
|
||||
2, /* This interface uses 2 endpoints */
|
||||
CDCDataInterfaceDescriptor_CLASS,
|
||||
CDCDataInterfaceDescriptor_SUBCLASS,
|
||||
CDCDataInterfaceDescriptor_NOPROTOCOL,
|
||||
0 /* No string descriptor for this interface */
|
||||
},
|
||||
/* Bulk-OUT endpoint standard descriptor */
|
||||
{
|
||||
sizeof(USBEndpointDescriptor),
|
||||
USBGenericDescriptor_ENDPOINT,
|
||||
USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT,
|
||||
CDCDSerialDriverDescriptors_DATAOUT),
|
||||
USBEndpointDescriptor_BULK,
|
||||
MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDSerialDriverDescriptors_DATAOUT),
|
||||
USBEndpointDescriptor_MAXBULKSIZE_FS),
|
||||
0 /* Must be 0 for full-speed bulk endpoints */
|
||||
},
|
||||
/* Bulk-IN endpoint descriptor */
|
||||
{
|
||||
sizeof(USBEndpointDescriptor),
|
||||
USBGenericDescriptor_ENDPOINT,
|
||||
USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN,
|
||||
CDCDSerialDriverDescriptors_DATAIN),
|
||||
USBEndpointDescriptor_BULK,
|
||||
MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDSerialDriverDescriptors_DATAIN),
|
||||
USBEndpointDescriptor_MAXBULKSIZE_FS),
|
||||
0 /* Must be 0 for full-speed bulk endpoints */
|
||||
}
|
||||
};
|
||||
|
||||
/** Other-speed configuration descriptor (when in full-speed). */
|
||||
const CDCDSerialDriverConfigurationDescriptors otherSpeedDescriptorsFS = {
|
||||
|
||||
/* Standard configuration descriptor */
|
||||
{
|
||||
sizeof(USBConfigurationDescriptor),
|
||||
USBGenericDescriptor_OTHERSPEEDCONFIGURATION,
|
||||
sizeof(CDCDSerialDriverConfigurationDescriptors),
|
||||
2, /* There are two interfaces in this configuration */
|
||||
1, /* This is configuration #1 */
|
||||
0, /* No string descriptor for this configuration */
|
||||
BOARD_USB_BMATTRIBUTES,
|
||||
USBConfigurationDescriptor_POWER(100)
|
||||
},
|
||||
/* Communication class interface standard descriptor */
|
||||
{
|
||||
sizeof(USBInterfaceDescriptor),
|
||||
USBGenericDescriptor_INTERFACE,
|
||||
0, /* This is interface #0 */
|
||||
0, /* This is alternate setting #0 for this interface */
|
||||
1, /* This interface uses 1 endpoint */
|
||||
CDCCommunicationInterfaceDescriptor_CLASS,
|
||||
CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL,
|
||||
CDCCommunicationInterfaceDescriptor_NOPROTOCOL,
|
||||
0 /* No string descriptor for this interface */
|
||||
},
|
||||
/* Class-specific header functional descriptor */
|
||||
{
|
||||
sizeof(CDCHeaderDescriptor),
|
||||
CDCGenericDescriptor_INTERFACE,
|
||||
CDCGenericDescriptor_HEADER,
|
||||
CDCGenericDescriptor_CDC1_10
|
||||
},
|
||||
/* Class-specific call management functional descriptor */
|
||||
{
|
||||
sizeof(CDCCallManagementDescriptor),
|
||||
CDCGenericDescriptor_INTERFACE,
|
||||
CDCGenericDescriptor_CALLMANAGEMENT,
|
||||
CDCCallManagementDescriptor_SELFCALLMANAGEMENT,
|
||||
0 /* No associated data interface */
|
||||
},
|
||||
/* Class-specific abstract control management functional descriptor */
|
||||
{
|
||||
sizeof(CDCAbstractControlManagementDescriptor),
|
||||
CDCGenericDescriptor_INTERFACE,
|
||||
CDCGenericDescriptor_ABSTRACTCONTROLMANAGEMENT,
|
||||
CDCAbstractControlManagementDescriptor_LINE
|
||||
},
|
||||
/* Class-specific union functional descriptor with one slave interface */
|
||||
{
|
||||
sizeof(CDCUnionDescriptor),
|
||||
CDCGenericDescriptor_INTERFACE,
|
||||
CDCGenericDescriptor_UNION,
|
||||
0, /* Number of master interface is #0 */
|
||||
1 /* First slave interface is #1 */
|
||||
},
|
||||
/* Notification endpoint standard descriptor */
|
||||
{
|
||||
sizeof(USBEndpointDescriptor),
|
||||
USBGenericDescriptor_ENDPOINT,
|
||||
USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN,
|
||||
CDCDSerialDriverDescriptors_NOTIFICATION),
|
||||
USBEndpointDescriptor_INTERRUPT,
|
||||
MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDSerialDriverDescriptors_NOTIFICATION),
|
||||
USBEndpointDescriptor_MAXINTERRUPTSIZE_FS),
|
||||
8 /* Endpoint is polled every 16ms */
|
||||
},
|
||||
/* Data class interface standard descriptor */
|
||||
{
|
||||
sizeof(USBInterfaceDescriptor),
|
||||
USBGenericDescriptor_INTERFACE,
|
||||
1, /* This is interface #1 */
|
||||
0, /* This is alternate setting #0 for this interface */
|
||||
2, /* This interface uses 2 endpoints */
|
||||
CDCDataInterfaceDescriptor_CLASS,
|
||||
CDCDataInterfaceDescriptor_SUBCLASS,
|
||||
CDCDataInterfaceDescriptor_NOPROTOCOL,
|
||||
0 /* No string descriptor for this interface */
|
||||
},
|
||||
/* Bulk-OUT endpoint standard descriptor */
|
||||
{
|
||||
sizeof(USBEndpointDescriptor),
|
||||
USBGenericDescriptor_ENDPOINT,
|
||||
USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT,
|
||||
CDCDSerialDriverDescriptors_DATAOUT),
|
||||
USBEndpointDescriptor_BULK,
|
||||
MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDSerialDriverDescriptors_DATAOUT),
|
||||
USBEndpointDescriptor_MAXBULKSIZE_HS),
|
||||
0 /* Must be 0 for full-speed bulk endpoints */
|
||||
},
|
||||
/* Bulk-IN endpoint descriptor */
|
||||
{
|
||||
sizeof(USBEndpointDescriptor),
|
||||
USBGenericDescriptor_ENDPOINT,
|
||||
USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN,
|
||||
CDCDSerialDriverDescriptors_DATAIN),
|
||||
USBEndpointDescriptor_BULK,
|
||||
MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDSerialDriverDescriptors_DATAIN),
|
||||
USBEndpointDescriptor_MAXBULKSIZE_HS),
|
||||
0 /* Must be 0 for full-speed bulk endpoints */
|
||||
}
|
||||
};
|
||||
|
||||
/** Configuration descriptor (when in high-speed). */
|
||||
const CDCDSerialDriverConfigurationDescriptors configurationDescriptorsHS = {
|
||||
|
||||
/* Standard configuration descriptor */
|
||||
{
|
||||
sizeof(USBConfigurationDescriptor),
|
||||
USBGenericDescriptor_CONFIGURATION,
|
||||
sizeof(CDCDSerialDriverConfigurationDescriptors),
|
||||
2, /* There are two interfaces in this configuration */
|
||||
1, /* This is configuration #1 */
|
||||
0, /* No string descriptor for this configuration */
|
||||
BOARD_USB_BMATTRIBUTES,
|
||||
USBConfigurationDescriptor_POWER(100)
|
||||
},
|
||||
/* Communication class interface standard descriptor */
|
||||
{
|
||||
sizeof(USBInterfaceDescriptor),
|
||||
USBGenericDescriptor_INTERFACE,
|
||||
0, /* This is interface #0 */
|
||||
0, /* This is alternate setting #0 for this interface */
|
||||
1, /* This interface uses 1 endpoint */
|
||||
CDCCommunicationInterfaceDescriptor_CLASS,
|
||||
CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL,
|
||||
CDCCommunicationInterfaceDescriptor_NOPROTOCOL,
|
||||
0 /* No string descriptor for this interface */
|
||||
},
|
||||
/* Class-specific header functional descriptor */
|
||||
{
|
||||
sizeof(CDCHeaderDescriptor),
|
||||
CDCGenericDescriptor_INTERFACE,
|
||||
CDCGenericDescriptor_HEADER,
|
||||
CDCGenericDescriptor_CDC1_10
|
||||
},
|
||||
/* Class-specific call management functional descriptor */
|
||||
{
|
||||
sizeof(CDCCallManagementDescriptor),
|
||||
CDCGenericDescriptor_INTERFACE,
|
||||
CDCGenericDescriptor_CALLMANAGEMENT,
|
||||
CDCCallManagementDescriptor_SELFCALLMANAGEMENT,
|
||||
0 /* No associated data interface */
|
||||
},
|
||||
/* Class-specific abstract control management functional descriptor */
|
||||
{
|
||||
sizeof(CDCAbstractControlManagementDescriptor),
|
||||
CDCGenericDescriptor_INTERFACE,
|
||||
CDCGenericDescriptor_ABSTRACTCONTROLMANAGEMENT,
|
||||
CDCAbstractControlManagementDescriptor_LINE
|
||||
},
|
||||
/* Class-specific union functional descriptor with one slave interface */
|
||||
{
|
||||
sizeof(CDCUnionDescriptor),
|
||||
CDCGenericDescriptor_INTERFACE,
|
||||
CDCGenericDescriptor_UNION,
|
||||
0, /* Number of master interface is #0 */
|
||||
1 /* First slave interface is #1 */
|
||||
},
|
||||
/* Notification endpoint standard descriptor */
|
||||
{
|
||||
sizeof(USBEndpointDescriptor),
|
||||
USBGenericDescriptor_ENDPOINT,
|
||||
USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN,
|
||||
CDCDSerialDriverDescriptors_NOTIFICATION),
|
||||
USBEndpointDescriptor_INTERRUPT,
|
||||
MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDSerialDriverDescriptors_NOTIFICATION),
|
||||
USBEndpointDescriptor_MAXINTERRUPTSIZE_FS),
|
||||
8 /* Endpoint is polled every 16ms */
|
||||
},
|
||||
/* Data class interface standard descriptor */
|
||||
{
|
||||
sizeof(USBInterfaceDescriptor),
|
||||
USBGenericDescriptor_INTERFACE,
|
||||
1, /* This is interface #1 */
|
||||
0, /* This is alternate setting #0 for this interface */
|
||||
2, /* This interface uses 2 endpoints */
|
||||
CDCDataInterfaceDescriptor_CLASS,
|
||||
CDCDataInterfaceDescriptor_SUBCLASS,
|
||||
CDCDataInterfaceDescriptor_NOPROTOCOL,
|
||||
0 /* No string descriptor for this interface */
|
||||
},
|
||||
/* Bulk-OUT endpoint standard descriptor */
|
||||
{
|
||||
sizeof(USBEndpointDescriptor),
|
||||
USBGenericDescriptor_ENDPOINT,
|
||||
USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT,
|
||||
CDCDSerialDriverDescriptors_DATAOUT),
|
||||
USBEndpointDescriptor_BULK,
|
||||
MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDSerialDriverDescriptors_DATAOUT),
|
||||
USBEndpointDescriptor_MAXBULKSIZE_HS),
|
||||
0 /* Must be 0 for full-speed bulk endpoints */
|
||||
},
|
||||
/* Bulk-IN endpoint descriptor */
|
||||
{
|
||||
sizeof(USBEndpointDescriptor),
|
||||
USBGenericDescriptor_ENDPOINT,
|
||||
USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN,
|
||||
CDCDSerialDriverDescriptors_DATAIN),
|
||||
USBEndpointDescriptor_BULK,
|
||||
MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDSerialDriverDescriptors_DATAIN),
|
||||
USBEndpointDescriptor_MAXBULKSIZE_HS),
|
||||
0 /* Must be 0 for full-speed bulk endpoints */
|
||||
}
|
||||
};
|
||||
|
||||
/** Other-speed configuration descriptor (when in high-speed). */
|
||||
const CDCDSerialDriverConfigurationDescriptors otherSpeedDescriptorsHS = {
|
||||
|
||||
/* Standard configuration descriptor */
|
||||
{
|
||||
sizeof(USBConfigurationDescriptor),
|
||||
USBGenericDescriptor_OTHERSPEEDCONFIGURATION,
|
||||
sizeof(CDCDSerialDriverConfigurationDescriptors),
|
||||
2, /* There are two interfaces in this configuration */
|
||||
1, /* This is configuration #1 */
|
||||
0, /* No string descriptor for this configuration */
|
||||
BOARD_USB_BMATTRIBUTES,
|
||||
USBConfigurationDescriptor_POWER(100)
|
||||
},
|
||||
/* Communication class interface standard descriptor */
|
||||
{
|
||||
sizeof(USBInterfaceDescriptor),
|
||||
USBGenericDescriptor_INTERFACE,
|
||||
0, /* This is interface #0 */
|
||||
0, /* This is alternate setting #0 for this interface */
|
||||
1, /* This interface uses 1 endpoint */
|
||||
CDCCommunicationInterfaceDescriptor_CLASS,
|
||||
CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL,
|
||||
CDCCommunicationInterfaceDescriptor_NOPROTOCOL,
|
||||
0 /* No string descriptor for this interface */
|
||||
},
|
||||
/* Class-specific header functional descriptor */
|
||||
{
|
||||
sizeof(CDCHeaderDescriptor),
|
||||
CDCGenericDescriptor_INTERFACE,
|
||||
CDCGenericDescriptor_HEADER,
|
||||
CDCGenericDescriptor_CDC1_10
|
||||
},
|
||||
/* Class-specific call management functional descriptor */
|
||||
{
|
||||
sizeof(CDCCallManagementDescriptor),
|
||||
CDCGenericDescriptor_INTERFACE,
|
||||
CDCGenericDescriptor_CALLMANAGEMENT,
|
||||
CDCCallManagementDescriptor_SELFCALLMANAGEMENT,
|
||||
0 /* No associated data interface */
|
||||
},
|
||||
/* Class-specific abstract control management functional descriptor */
|
||||
{
|
||||
sizeof(CDCAbstractControlManagementDescriptor),
|
||||
CDCGenericDescriptor_INTERFACE,
|
||||
CDCGenericDescriptor_ABSTRACTCONTROLMANAGEMENT,
|
||||
CDCAbstractControlManagementDescriptor_LINE
|
||||
},
|
||||
/* Class-specific union functional descriptor with one slave interface */
|
||||
{
|
||||
sizeof(CDCUnionDescriptor),
|
||||
CDCGenericDescriptor_INTERFACE,
|
||||
CDCGenericDescriptor_UNION,
|
||||
0, /* Number of master interface is #0 */
|
||||
1 /* First slave interface is #1 */
|
||||
},
|
||||
/* Notification endpoint standard descriptor */
|
||||
{
|
||||
sizeof(USBEndpointDescriptor),
|
||||
USBGenericDescriptor_ENDPOINT,
|
||||
USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN,
|
||||
CDCDSerialDriverDescriptors_NOTIFICATION),
|
||||
USBEndpointDescriptor_INTERRUPT,
|
||||
MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDSerialDriverDescriptors_NOTIFICATION),
|
||||
USBEndpointDescriptor_MAXINTERRUPTSIZE_FS),
|
||||
10 /* Endpoint is polled every 10ms */
|
||||
},
|
||||
/* Data class interface standard descriptor */
|
||||
{
|
||||
sizeof(USBInterfaceDescriptor),
|
||||
USBGenericDescriptor_INTERFACE,
|
||||
1, /* This is interface #1 */
|
||||
0, /* This is alternate setting #0 for this interface */
|
||||
2, /* This interface uses 2 endpoints */
|
||||
CDCDataInterfaceDescriptor_CLASS,
|
||||
CDCDataInterfaceDescriptor_SUBCLASS,
|
||||
CDCDataInterfaceDescriptor_NOPROTOCOL,
|
||||
0 /* No string descriptor for this interface */
|
||||
},
|
||||
/* Bulk-OUT endpoint standard descriptor */
|
||||
{
|
||||
sizeof(USBEndpointDescriptor),
|
||||
USBGenericDescriptor_ENDPOINT,
|
||||
USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT,
|
||||
CDCDSerialDriverDescriptors_DATAOUT),
|
||||
USBEndpointDescriptor_BULK,
|
||||
MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDSerialDriverDescriptors_DATAOUT),
|
||||
USBEndpointDescriptor_MAXBULKSIZE_FS),
|
||||
0 /* Must be 0 for full-speed bulk endpoints */
|
||||
},
|
||||
/* Bulk-IN endpoint descriptor */
|
||||
{
|
||||
sizeof(USBEndpointDescriptor),
|
||||
USBGenericDescriptor_ENDPOINT,
|
||||
USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN,
|
||||
CDCDSerialDriverDescriptors_DATAIN),
|
||||
USBEndpointDescriptor_BULK,
|
||||
MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDSerialDriverDescriptors_DATAIN),
|
||||
USBEndpointDescriptor_MAXBULKSIZE_FS),
|
||||
0 /* Must be 0 for full-speed bulk endpoints */
|
||||
}
|
||||
};
|
||||
|
||||
/** Language ID string descriptor */
|
||||
const unsigned char languageIdStringDescriptor[] = {
|
||||
|
||||
USBStringDescriptor_LENGTH(1),
|
||||
USBGenericDescriptor_STRING,
|
||||
USBStringDescriptor_ENGLISH_US
|
||||
};
|
||||
|
||||
/** Product string descriptor */
|
||||
const unsigned char productStringDescriptor[] = {
|
||||
|
||||
USBStringDescriptor_LENGTH(13),
|
||||
USBGenericDescriptor_STRING,
|
||||
USBStringDescriptor_UNICODE('A'),
|
||||
USBStringDescriptor_UNICODE('T'),
|
||||
USBStringDescriptor_UNICODE('9'),
|
||||
USBStringDescriptor_UNICODE('1'),
|
||||
USBStringDescriptor_UNICODE('U'),
|
||||
USBStringDescriptor_UNICODE('S'),
|
||||
USBStringDescriptor_UNICODE('B'),
|
||||
USBStringDescriptor_UNICODE('S'),
|
||||
USBStringDescriptor_UNICODE('e'),
|
||||
USBStringDescriptor_UNICODE('r'),
|
||||
USBStringDescriptor_UNICODE('i'),
|
||||
USBStringDescriptor_UNICODE('a'),
|
||||
USBStringDescriptor_UNICODE('l')
|
||||
};
|
||||
|
||||
/** List of string descriptors used by the device */
|
||||
const unsigned char *stringDescriptors[] = {
|
||||
|
||||
languageIdStringDescriptor,
|
||||
productStringDescriptor,
|
||||
};
|
||||
|
||||
/** List of standard descriptors for the serial driver. */
|
||||
WEAK const USBDDriverDescriptors cdcdSerialDriverDescriptors = {
|
||||
|
||||
&deviceDescriptor,
|
||||
(USBConfigurationDescriptor *) &(configurationDescriptorsFS),
|
||||
0, /* No full-speed device qualifier descriptor */
|
||||
(USBConfigurationDescriptor *) &(otherSpeedDescriptorsFS),
|
||||
0, /* No high-speed device descriptor (uses FS one) */
|
||||
(USBConfigurationDescriptor *) &(configurationDescriptorsHS),
|
||||
0, /* No high-speed device qualifier descriptor */
|
||||
(USBConfigurationDescriptor *) &(otherSpeedDescriptorsHS),
|
||||
stringDescriptors,
|
||||
2 /* 2 string descriptors in list */
|
||||
};
|
||||
|
||||
/**@}*/
|
@ -0,0 +1,71 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** \file
|
||||
Implementation of the CDCLineCoding class.
|
||||
*/
|
||||
/** \addtogroup usb_cdc
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <CDCRequests.h>
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Initializes the bitrate, number of stop bits, parity checking and
|
||||
* number of data bits of a CDCLineCoding object.
|
||||
* \param lineCoding Pointer to a CDCLineCoding instance.
|
||||
* \param bitrate Bitrate of the virtual COM connection.
|
||||
* \param stopbits Number of stop bits
|
||||
* (\ref usb_cdc_stop CDC LineCoding StopBits).
|
||||
* \param parity Parity check type
|
||||
* (\ref usb_cdc_parity CDC LineCoding ParityChecking).
|
||||
* \param databits Number of data bits.
|
||||
*/
|
||||
void CDCLineCoding_Initialize(CDCLineCoding *lineCoding,
|
||||
uint32_t bitrate,
|
||||
uint8_t stopbits,
|
||||
uint8_t parity,
|
||||
uint8_t databits)
|
||||
{
|
||||
lineCoding->dwDTERate = bitrate;
|
||||
lineCoding->bCharFormat = stopbits;
|
||||
lineCoding->bParityType = parity;
|
||||
lineCoding->bDataBits = databits;
|
||||
}
|
||||
|
||||
/**@}*/
|
||||
|
@ -0,0 +1,87 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Implementation of the CDCSetControlLineStateRequest class.
|
||||
*/
|
||||
|
||||
/** \addtogroup usb_cdc
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <CDCRequests.h>
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Notifies if the given request indicates that the DTE signal is present.
|
||||
* \param request Pointer to a USBGenericRequest instance.
|
||||
* \return 1 if the DTE signal is present, otherwise 0.
|
||||
*/
|
||||
uint8_t CDCSetControlLineStateRequest_IsDtePresent(
|
||||
const USBGenericRequest *request)
|
||||
{
|
||||
if ((USBGenericRequest_GetValue(request) & 0x0001) != 0) {
|
||||
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifies if the given request indicates that the device carrier should
|
||||
* be activated.
|
||||
* \param request Pointer to a USBGenericRequest instance.
|
||||
* \return 1 is the device should activate its carrier, 0 otherwise.
|
||||
*/
|
||||
uint8_t CDCSetControlLineStateRequest_ActivateCarrier(
|
||||
const USBGenericRequest *request)
|
||||
{
|
||||
if ((USBGenericRequest_GetValue(request) & 0x0002) != 0) {
|
||||
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**@}*/
|
||||
|
@ -0,0 +1,319 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* 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:
|
||||
*
|
||||
* - 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Implements for USB descriptor methods described by the USB specification.
|
||||
*/
|
||||
|
||||
/** \addtogroup usb_descriptor
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Headers
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
#include "USBDescriptors.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Returns the length of a descriptor.
|
||||
* \param descriptor Pointer to a USBGenericDescriptor instance.
|
||||
* \return Length of descriptor in bytes.
|
||||
*/
|
||||
uint32_t USBGenericDescriptor_GetLength(
|
||||
const USBGenericDescriptor *descriptor)
|
||||
{
|
||||
return descriptor->bLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of a descriptor.
|
||||
* \param descriptor Pointer to a USBGenericDescriptor instance.
|
||||
* \return Type of descriptor.
|
||||
*/
|
||||
uint8_t USBGenericDescriptor_GetType(
|
||||
const USBGenericDescriptor *descriptor)
|
||||
{
|
||||
return descriptor->bDescriptorType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a pointer to the descriptor right after the given one, when
|
||||
* parsing a Configuration descriptor.
|
||||
* \param descriptor - Pointer to a USBGenericDescriptor instance.
|
||||
* \return Pointer to the next descriptor.
|
||||
*/
|
||||
USBGenericDescriptor *USBGenericDescriptor_GetNextDescriptor(
|
||||
const USBGenericDescriptor *descriptor)
|
||||
{
|
||||
return (USBGenericDescriptor *)
|
||||
(((char *) descriptor) + USBGenericDescriptor_GetLength(descriptor));
|
||||
}
|
||||
|
||||
/** Parses the given descriptor list via costomized function.
|
||||
* \param descriptor Pointer to the start of the whole descriptors list.
|
||||
* \param totalLength Total size of descriptors in bytes.
|
||||
* \param parseFunction Function to parse each descriptor scanned.
|
||||
* Return 0 to continue parsing.
|
||||
* \param parseArg Argument passed to parse function.
|
||||
* \return Pointer to USBGenericDescriptor instance for next descriptor.
|
||||
*/
|
||||
USBGenericDescriptor *USBGenericDescriptor_Parse(
|
||||
const USBGenericDescriptor *descriptor,
|
||||
uint32_t totalLength,
|
||||
USBDescriptorParseFunction parseFunction,
|
||||
void *parseArg)
|
||||
{
|
||||
int32_t size = totalLength;
|
||||
|
||||
if (size == 0)
|
||||
return 0;
|
||||
|
||||
/* Start parsing descriptors */
|
||||
while (1) {
|
||||
|
||||
uint32_t parseRC = 0;
|
||||
|
||||
/* Parse current descriptor */
|
||||
if (parseFunction) {
|
||||
|
||||
parseRC = parseFunction((void*)descriptor, parseArg);
|
||||
}
|
||||
|
||||
/* Get next descriptor */
|
||||
size -= USBGenericDescriptor_GetLength(descriptor);
|
||||
descriptor = USBGenericDescriptor_GetNextDescriptor(descriptor);
|
||||
|
||||
if (size) {
|
||||
if (parseRC != 0) {
|
||||
|
||||
return (USBGenericDescriptor *)descriptor;
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
/* No descriptors remaining */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of an endpoint given its descriptor.
|
||||
* \param endpoint Pointer to a USBEndpointDescriptor instance.
|
||||
* \return Endpoint number.
|
||||
*/
|
||||
uint8_t USBEndpointDescriptor_GetNumber(
|
||||
const USBEndpointDescriptor *endpoint)
|
||||
{
|
||||
return endpoint->bEndpointAddress & 0xF;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the direction of an endpoint given its descriptor.
|
||||
* \param endpoint Pointer to a USBEndpointDescriptor instance.
|
||||
* \return Endpoint direction (see \ref usb_ep_dir).
|
||||
*/
|
||||
uint8_t USBEndpointDescriptor_GetDirection(
|
||||
const USBEndpointDescriptor *endpoint)
|
||||
{
|
||||
if ((endpoint->bEndpointAddress & 0x80) != 0) {
|
||||
|
||||
return USBEndpointDescriptor_IN;
|
||||
}
|
||||
else {
|
||||
|
||||
return USBEndpointDescriptor_OUT;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of an endpoint given its descriptor.
|
||||
* \param endpoint Pointer to a USBEndpointDescriptor instance.
|
||||
* \return Endpoint type (see \ref usb_ep_type).
|
||||
*/
|
||||
uint8_t USBEndpointDescriptor_GetType(
|
||||
const USBEndpointDescriptor *endpoint)
|
||||
{
|
||||
return endpoint->bmAttributes & 0x3;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum size of a packet (in bytes) on an endpoint given
|
||||
* its descriptor.
|
||||
* \param endpoint - Pointer to a USBEndpointDescriptor instance.
|
||||
* \return Maximum packet size of endpoint.
|
||||
*/
|
||||
uint16_t USBEndpointDescriptor_GetMaxPacketSize(
|
||||
const USBEndpointDescriptor *endpoint)
|
||||
{
|
||||
uint16_t usTemp;
|
||||
uint8_t *pc1, *pc2;
|
||||
|
||||
/* Note this is an unaligned access hence it is performed as two byte
|
||||
accesses. */
|
||||
pc1 = ( uint8_t * ) &( endpoint->wMaxPacketSize );
|
||||
pc2 = pc1 + 1;
|
||||
usTemp = ( ( *pc2 ) << 8 ) | *pc1;
|
||||
|
||||
return usTemp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the polling interval on an endpoint given its descriptor.
|
||||
* \param endpoint - Pointer to a USBEndpointDescriptor instance.
|
||||
* \return Polling interval of endpoint.
|
||||
*/
|
||||
uint8_t USBEndpointDescriptor_GetInterval(
|
||||
const USBEndpointDescriptor *endpoint)
|
||||
{
|
||||
return endpoint->bInterval;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** Returns the total length of a configuration, i.e. including the
|
||||
* descriptors following it.
|
||||
* \param configuration Pointer to a USBConfigurationDescriptor instance.
|
||||
* \return Total length (in bytes) of the configuration.
|
||||
*/
|
||||
uint32_t USBConfigurationDescriptor_GetTotalLength(
|
||||
const USBConfigurationDescriptor *configuration)
|
||||
{
|
||||
return configuration->wTotalLength;
|
||||
}
|
||||
|
||||
/** Returns the number of interfaces in a configuration.
|
||||
* \param configuration Pointer to a USBConfigurationDescriptor instance.
|
||||
* \return Number of interfaces in configuration.
|
||||
*/
|
||||
unsigned char USBConfigurationDescriptor_GetNumInterfaces(
|
||||
const USBConfigurationDescriptor *configuration)
|
||||
{
|
||||
return configuration->bNumInterfaces;
|
||||
}
|
||||
|
||||
/** Indicates if the device is self-powered when in a given configuration.
|
||||
* \param configuration Pointer to a USBConfigurationDescriptor instance.
|
||||
* \return 1 if the device is self-powered when in the given configuration;
|
||||
* otherwise 0.
|
||||
*/
|
||||
unsigned char USBConfigurationDescriptor_IsSelfPowered(
|
||||
const USBConfigurationDescriptor *configuration)
|
||||
{
|
||||
if ((configuration->bmAttributes & (1 << 6)) != 0) {
|
||||
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/** Parses the given Configuration descriptor (followed by relevant
|
||||
* interface, endpoint and class-specific descriptors) into three arrays.
|
||||
* *Each array must have its size equal or greater to the number of
|
||||
* descriptors it stores plus one*. A null-value is inserted after the last
|
||||
* descriptor of each type to indicate the array end.
|
||||
*
|
||||
* Note that if the pointer to an array is null (0), nothing is stored in
|
||||
* it.
|
||||
* \param configuration Pointer to the start of the whole Configuration
|
||||
* descriptor.
|
||||
* \param interfaces Pointer to the Interface descriptor array.
|
||||
* \param endpoints Pointer to the Endpoint descriptor array.
|
||||
* \param others Pointer to the class-specific descriptor array.
|
||||
*/
|
||||
void USBConfigurationDescriptor_Parse(
|
||||
const USBConfigurationDescriptor *configuration,
|
||||
USBInterfaceDescriptor **interfaces,
|
||||
USBEndpointDescriptor **endpoints,
|
||||
USBGenericDescriptor **others)
|
||||
{
|
||||
/* Get size of configuration to parse */
|
||||
int size = USBConfigurationDescriptor_GetTotalLength(configuration);
|
||||
size -= sizeof(USBConfigurationDescriptor);
|
||||
|
||||
/* Start parsing descriptors */
|
||||
USBGenericDescriptor *descriptor = (USBGenericDescriptor *) configuration;
|
||||
while (size > 0) {
|
||||
|
||||
/* Get next descriptor */
|
||||
descriptor = USBGenericDescriptor_GetNextDescriptor(descriptor);
|
||||
size -= USBGenericDescriptor_GetLength(descriptor);
|
||||
|
||||
/* Store descriptor in correponding array */
|
||||
if (USBGenericDescriptor_GetType(descriptor)
|
||||
== USBGenericDescriptor_INTERFACE) {
|
||||
|
||||
if (interfaces) {
|
||||
|
||||
*interfaces = (USBInterfaceDescriptor *) descriptor;
|
||||
interfaces++;
|
||||
}
|
||||
}
|
||||
else if (USBGenericDescriptor_GetType(descriptor)
|
||||
== USBGenericDescriptor_ENDPOINT) {
|
||||
|
||||
if (endpoints) {
|
||||
|
||||
*endpoints = (USBEndpointDescriptor *) descriptor;
|
||||
endpoints++;
|
||||
}
|
||||
}
|
||||
else if (others) {
|
||||
|
||||
*others = descriptor;
|
||||
others++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Null-terminate arrays */
|
||||
if (interfaces) {
|
||||
|
||||
*interfaces = 0;
|
||||
}
|
||||
if (endpoints) {
|
||||
|
||||
*endpoints = 0;
|
||||
}
|
||||
if (others) {
|
||||
|
||||
*others = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**@}*/
|
||||
|
@ -0,0 +1,244 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* 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:
|
||||
*
|
||||
* - 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \section Purpose
|
||||
*
|
||||
* Implements for USB requests described by the USB specification.
|
||||
*/
|
||||
|
||||
/** \addtogroup usb_request
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Headers
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
#include <USBRequests.h>
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Returns the type of the given request.
|
||||
* \param request Pointer to a USBGenericRequest instance.
|
||||
* \return "USB Request Types"
|
||||
*/
|
||||
extern uint8_t USBGenericRequest_GetType(const USBGenericRequest *request)
|
||||
{
|
||||
return ((request->bmRequestType >> 5) & 0x3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the request code of the given request.
|
||||
* \param request Pointer to a USBGenericRequest instance.
|
||||
* \return Request code.
|
||||
* \sa "USB Request Codes"
|
||||
*/
|
||||
uint8_t USBGenericRequest_GetRequest(const USBGenericRequest *request)
|
||||
{
|
||||
return request->bRequest;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the wValue field of the given request.
|
||||
* \param request - Pointer to a USBGenericRequest instance.
|
||||
* \return Request value.
|
||||
*/
|
||||
uint16_t USBGenericRequest_GetValue(const USBGenericRequest *request)
|
||||
{
|
||||
return request->wValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the wIndex field of the given request.
|
||||
* \param request Pointer to a USBGenericRequest instance.
|
||||
* \return Request index;
|
||||
*/
|
||||
uint16_t USBGenericRequest_GetIndex(const USBGenericRequest *request)
|
||||
{
|
||||
return request->wIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the expected length of the data phase following a request.
|
||||
* \param request Pointer to a USBGenericRequest instance.
|
||||
* \return Length of data phase.
|
||||
*/
|
||||
uint16_t USBGenericRequest_GetLength(const USBGenericRequest *request)
|
||||
{
|
||||
return request->wLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the endpoint number targetted by a given request.
|
||||
* \param request Pointer to a USBGenericRequest instance.
|
||||
* \return Endpoint number.
|
||||
*/
|
||||
uint8_t USBGenericRequest_GetEndpointNumber(
|
||||
const USBGenericRequest *request)
|
||||
{
|
||||
return USBGenericRequest_GetIndex(request) & 0xF;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the intended recipient of a given request.
|
||||
* \param request Pointer to a USBGenericRequest instance.
|
||||
* \return Request recipient.
|
||||
* \sa "USB Request Recipients"
|
||||
*/
|
||||
uint8_t USBGenericRequest_GetRecipient(const USBGenericRequest *request)
|
||||
{
|
||||
/* Recipient is in bits [0..4] of the bmRequestType field */
|
||||
return request->bmRequestType & 0xF;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the direction of the data transfer following the given request.
|
||||
* \param request Pointer to a USBGenericRequest instance.
|
||||
* \return Transfer direction.
|
||||
* \sa "USB Request Directions"
|
||||
*/
|
||||
uint8_t USBGenericRequest_GetDirection(const USBGenericRequest *request)
|
||||
{
|
||||
/* Transfer direction is located in bit D7 of the bmRequestType field */
|
||||
if ((request->bmRequestType & 0x80) != 0) {
|
||||
|
||||
return USBGenericRequest_IN;
|
||||
}
|
||||
else {
|
||||
|
||||
return USBGenericRequest_OUT;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the type of the descriptor requested by the host given the
|
||||
* corresponding GET_DESCRIPTOR request.
|
||||
* \param request Pointer to a USBGenericDescriptor instance.
|
||||
* \return Type of the requested descriptor.
|
||||
*/
|
||||
uint8_t USBGetDescriptorRequest_GetDescriptorType(
|
||||
const USBGenericRequest *request)
|
||||
{
|
||||
/* Requested descriptor type is in the high-byte of the wValue field */
|
||||
return (USBGenericRequest_GetValue(request) >> 8) & 0xFF;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the index of the requested descriptor, given the corresponding
|
||||
* GET_DESCRIPTOR request.
|
||||
* \param request Pointer to a USBGenericDescriptor instance.
|
||||
* \return Index of the requested descriptor.
|
||||
*/
|
||||
uint8_t USBGetDescriptorRequest_GetDescriptorIndex(
|
||||
const USBGenericRequest *request)
|
||||
{
|
||||
/* Requested descriptor index if in the low byte of the wValue field */
|
||||
return USBGenericRequest_GetValue(request) & 0xFF;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the address that the device must take in response to a
|
||||
* SET_ADDRESS request.
|
||||
* \param request Pointer to a USBGenericRequest instance.
|
||||
* \return New device address.
|
||||
*/
|
||||
uint8_t USBSetAddressRequest_GetAddress(const USBGenericRequest *request)
|
||||
{
|
||||
return USBGenericRequest_GetValue(request) & 0x7F;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of the configuration that should be set in response
|
||||
* to the given SET_CONFIGURATION request.
|
||||
* \param request Pointer to a USBGenericRequest instance.
|
||||
* \return Number of the requested configuration.
|
||||
*/
|
||||
uint8_t USBSetConfigurationRequest_GetConfiguration(
|
||||
const USBGenericRequest *request)
|
||||
{
|
||||
return USBGenericRequest_GetValue(request);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Indicates which interface is targetted by a GET_INTERFACE or
|
||||
* SET_INTERFACE request.
|
||||
* \param request Pointer to a USBGenericRequest instance.
|
||||
* \return Interface number.
|
||||
*/
|
||||
uint8_t USBInterfaceRequest_GetInterface(const USBGenericRequest *request)
|
||||
{
|
||||
return (USBGenericRequest_GetIndex(request) & 0xFF);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates the new alternate setting that the interface targetted by a
|
||||
* SET_INTERFACE request should use.
|
||||
* \param request Pointer to a USBGenericRequest instance.
|
||||
* \return New active setting for the interface.
|
||||
*/
|
||||
uint8_t USBInterfaceRequest_GetAlternateSetting(
|
||||
const USBGenericRequest *request)
|
||||
{
|
||||
return (USBGenericRequest_GetValue(request) & 0xFF);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the feature selector of a given CLEAR_FEATURE or SET_FEATURE
|
||||
* request.
|
||||
* \param request Pointer to a USBGenericRequest instance.
|
||||
* \return Feature selector.
|
||||
*/
|
||||
uint8_t USBFeatureRequest_GetFeatureSelector(
|
||||
const USBGenericRequest *request)
|
||||
{
|
||||
return USBGenericRequest_GetValue(request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates the test that the device must undertake following a
|
||||
* SET_FEATURE request.
|
||||
* \param request Pointer to a USBGenericRequest instance.
|
||||
* \return Test selector.
|
||||
*/
|
||||
uint8_t USBFeatureRequest_GetTestSelector(
|
||||
const USBGenericRequest *request)
|
||||
{
|
||||
return (USBGenericRequest_GetIndex(request) >> 8) & 0xFF;
|
||||
}
|
||||
|
||||
/**@}*/
|
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
Binary file not shown.
After Width: | Height: | Size: 8.6 KiB |
@ -0,0 +1,228 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**\file
|
||||
* Implementation of a single CDC serial port function for USB device.
|
||||
*/
|
||||
|
||||
/** \addtogroup usbd_cdc
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Headers
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
#include "CDCDSerial.h"
|
||||
|
||||
#include <USBLib_Trace.h>
|
||||
#include <USBDDriver.h>
|
||||
#include <USBD_HAL.h>
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Types
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Internal variables
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/** Serial Port instance list */
|
||||
static CDCDSerialPort cdcdSerial;
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Internal functions
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* USB CDC Serial Port Event Handler.
|
||||
* \param event Event code.
|
||||
* \param param Event parameter.
|
||||
*/
|
||||
static uint32_t CDCDSerial_EventHandler(uint32_t event,
|
||||
uint32_t param)
|
||||
{
|
||||
switch (event) {
|
||||
case CDCDSerialPortEvent_SETCONTROLLINESTATE:
|
||||
{
|
||||
if (CDCDSerial_ControlLineStateChanged != NULL) {
|
||||
CDCDSerial_ControlLineStateChanged(
|
||||
(param & CDCControlLineState_DTR) > 0,
|
||||
(param & CDCControlLineState_RTS) > 0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CDCDSerialPortEvent_SETLINECODING:
|
||||
{
|
||||
if (NULL != CDCDSerial_LineCodingIsToChange) {
|
||||
event = CDCDSerial_LineCodingIsToChange(
|
||||
(CDCLineCoding*)param);
|
||||
if (event != USBRC_SUCCESS)
|
||||
return event;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return USBRC_SUCCESS;
|
||||
}
|
||||
|
||||
return USBRC_SUCCESS;
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Initializes the USB Device CDC serial driver & USBD Driver.
|
||||
* \param pUsbd Pointer to USBDDriver instance.
|
||||
* \param bInterfaceNb Interface number for the function.
|
||||
*/
|
||||
void CDCDSerial_Initialize(
|
||||
USBDDriver *pUsbd, uint8_t bInterfaceNb)
|
||||
{
|
||||
CDCDSerialPort *pCdcd = &cdcdSerial;
|
||||
|
||||
TRACE_INFO("CDCDSerial_Initialize\n\r");
|
||||
|
||||
/* Initialize serial port function */
|
||||
CDCDSerialPort_Initialize(
|
||||
pCdcd, pUsbd,
|
||||
(CDCDSerialPortEventHandler)CDCDSerial_EventHandler,
|
||||
0,
|
||||
bInterfaceNb, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked whenever the device is changed by the
|
||||
* host.
|
||||
* \pDescriptors Pointer to the descriptors for function configure.
|
||||
* \wLength Length of descriptors in number of bytes.
|
||||
*/
|
||||
void CDCDSerial_ConfigureFunction(USBGenericDescriptor *pDescriptors,
|
||||
uint16_t wLength)
|
||||
{
|
||||
CDCDSerialPort *pCdcd = &cdcdSerial;
|
||||
CDCDSerialPort_ParseInterfaces(pCdcd,
|
||||
(USBGenericDescriptor*)pDescriptors,
|
||||
wLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles CDC-specific SETUP requests. Should be called from a
|
||||
* re-implementation of USBDCallbacks_RequestReceived() method.
|
||||
* \param request Pointer to a USBGenericRequest instance.
|
||||
*/
|
||||
uint32_t CDCDSerial_RequestHandler(const USBGenericRequest *request)
|
||||
{
|
||||
CDCDSerialPort * pCdcd = &cdcdSerial;
|
||||
|
||||
TRACE_INFO_WP("Cdcf ");
|
||||
return CDCDSerialPort_RequestHandler(pCdcd, request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Receives data from the host through the virtual COM port created by
|
||||
* the CDC device serial driver. This function behaves like USBD_Read.
|
||||
* \param data Pointer to the data buffer to put received data.
|
||||
* \param size Size of the data buffer in bytes.
|
||||
* \param callback Optional callback function to invoke when the transfer
|
||||
* finishes.
|
||||
* \param argument Optional argument to the callback function.
|
||||
* \return USBD_STATUS_SUCCESS if the read operation has been started normally;
|
||||
* otherwise, the corresponding error code.
|
||||
*/
|
||||
uint32_t CDCDSerial_Read(void *data,
|
||||
uint32_t size,
|
||||
TransferCallback callback,
|
||||
void *argument)
|
||||
{
|
||||
CDCDSerialPort * pCdcd = &cdcdSerial;
|
||||
return CDCDSerialPort_Read(pCdcd, data, size, callback, argument);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a data buffer through the virtual COM port created by the CDC
|
||||
* device serial driver. This function behaves exactly like USBD_Write.
|
||||
* \param data Pointer to the data buffer to send.
|
||||
* \param size Size of the data buffer in bytes.
|
||||
* \param callback Optional callback function to invoke when the transfer
|
||||
* finishes.
|
||||
* \param argument Optional argument to the callback function.
|
||||
* \return USBD_STATUS_SUCCESS if the read operation has been started normally;
|
||||
* otherwise, the corresponding error code.
|
||||
*/
|
||||
uint32_t CDCDSerial_Write(void *data,
|
||||
uint32_t size,
|
||||
TransferCallback callback,
|
||||
void *argument)
|
||||
{
|
||||
CDCDSerialPort * pCdcd = &cdcdSerial;
|
||||
return CDCDSerialPort_Write(pCdcd, data, size, callback, argument);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current control line state of the RS-232 line.
|
||||
*/
|
||||
uint8_t CDCDSerial_GetControlLineState(void)
|
||||
{
|
||||
CDCDSerialPort * pCdcd = &cdcdSerial;
|
||||
return CDCDSerialPort_GetControlLineState(pCdcd);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy current line coding settings to pointered space.
|
||||
* \param pLineCoding Pointer to CDCLineCoding instance.
|
||||
*/
|
||||
void CDCDSerial_GetLineCoding(CDCLineCoding* pLineCoding)
|
||||
{
|
||||
CDCDSerialPort * pCdcd = &cdcdSerial;
|
||||
CDCDSerialPort_GetLineCoding(pCdcd, pLineCoding);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current status of the RS-232 line.
|
||||
*/
|
||||
uint16_t CDCDSerial_GetSerialState(void)
|
||||
{
|
||||
CDCDSerialPort * pCdcd = &cdcdSerial;
|
||||
return CDCDSerialPort_GetSerialState(pCdcd);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current serial state of the device to the given value.
|
||||
* \param serialState New device state.
|
||||
*/
|
||||
void CDCDSerial_SetSerialState(uint16_t serialState)
|
||||
{
|
||||
CDCDSerialPort * pCdcd = &cdcdSerial;
|
||||
CDCDSerialPort_SetSerialState(pCdcd, serialState);
|
||||
}
|
||||
|
||||
/**@}*/
|
@ -0,0 +1,116 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**\file
|
||||
* Title: CDCDSerialDriver implementation
|
||||
*
|
||||
* About: Purpose
|
||||
* Implementation of the CDCDSerialDriver class methods.
|
||||
*/
|
||||
|
||||
/** \addtogroup usbd_cdc
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Headers
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
#include "CDCDSerialDriver.h"
|
||||
|
||||
#include <USBLib_Trace.h>
|
||||
#include <USBDDriver.h>
|
||||
#include <USBD_HAL.h>
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Types
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Internal variables
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Internal functions
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Initializes the USB Device CDC serial driver & USBD Driver.
|
||||
* \param pDescriptors Pointer to Descriptors list for CDC Serial Device.
|
||||
*/
|
||||
void CDCDSerialDriver_Initialize(const USBDDriverDescriptors *pDescriptors)
|
||||
{
|
||||
USBDDriver *pUsbd = USBD_GetDriver();
|
||||
|
||||
/* Initialize the standard driver */
|
||||
USBDDriver_Initialize(pUsbd,
|
||||
pDescriptors,
|
||||
0); /* Multiple settings for interfaces not supported */
|
||||
|
||||
CDCDSerial_Initialize(pUsbd, CDCDSerialDriver_CC_INTERFACE);
|
||||
|
||||
/* Initialize the USB driver */
|
||||
USBD_Init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked whenever the active configuration of device is changed by the
|
||||
* host.
|
||||
* \param cfgnum Configuration number.
|
||||
*/
|
||||
void CDCDSerialDriver_ConfigurationChangedHandler(uint8_t cfgnum)
|
||||
{
|
||||
USBDDriver *pUsbd = USBD_GetDriver();
|
||||
USBConfigurationDescriptor *pDesc;
|
||||
if (cfgnum) {
|
||||
pDesc = USBDDriver_GetCfgDescriptors(pUsbd, cfgnum);
|
||||
CDCDSerial_ConfigureFunction((USBGenericDescriptor *)pDesc,
|
||||
pDesc->wTotalLength);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles CDC-specific SETUP requests. Should be called from a
|
||||
* re-implementation of USBDCallbacks_RequestReceived() method.
|
||||
* \param request Pointer to a USBGenericRequest instance.
|
||||
*/
|
||||
void CDCDSerialDriver_RequestHandler(const USBGenericRequest *request)
|
||||
{
|
||||
USBDDriver *pUsbd = USBD_GetDriver();
|
||||
TRACE_INFO_WP("NewReq ");
|
||||
if (CDCDSerial_RequestHandler(request))
|
||||
USBDDriver_RequestHandler(pUsbd, request);
|
||||
}
|
||||
|
||||
/**@}*/
|
||||
|
@ -0,0 +1,458 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**\file
|
||||
* Implementation of the CDCDSerialPort class methods.
|
||||
*/
|
||||
|
||||
/** \addtogroup usbd_cdc
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Headers
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
#include <CDCDSerialPort.h>
|
||||
#include <CDCDescriptors.h>
|
||||
#include <USBLib_Trace.h>
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Types
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/** Parse data extention for descriptor parsing */
|
||||
typedef struct _CDCDParseData {
|
||||
/** Pointer to CDCDSerialPort instance */
|
||||
CDCDSerialPort * pCdcd;
|
||||
/** Pointer to found interface descriptor */
|
||||
USBInterfaceDescriptor * pIfDesc;
|
||||
|
||||
} CDCDParseData;
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Internal variables
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/** Line coding values */
|
||||
static CDCLineCoding lineCoding;
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Internal functions
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Parse descriptors: Interface, Bulk IN/OUT, Interrupt IN.
|
||||
* \param desc Pointer to descriptor list.
|
||||
* \param arg Argument, pointer to AUDDParseData instance.
|
||||
*/
|
||||
static uint32_t _Interfaces_Parse(USBGenericDescriptor *pDesc,
|
||||
CDCDParseData * pArg)
|
||||
{
|
||||
CDCDSerialPort *pCdcd = pArg->pCdcd;
|
||||
|
||||
/* Not a valid descriptor */
|
||||
if (pDesc->bLength == 0)
|
||||
return USBRC_PARAM_ERR;
|
||||
|
||||
/* Find interface descriptor */
|
||||
if (pDesc->bDescriptorType == USBGenericDescriptor_INTERFACE) {
|
||||
USBInterfaceDescriptor *pIf = (USBInterfaceDescriptor*)pDesc;
|
||||
|
||||
/* Obtain interface from descriptor */
|
||||
if (pCdcd->bInterfaceNdx == 0xFF) {
|
||||
/* First interface is communication */
|
||||
if (pIf->bInterfaceClass ==
|
||||
CDCCommunicationInterfaceDescriptor_CLASS) {
|
||||
pCdcd->bInterfaceNdx = pIf->bInterfaceNumber;
|
||||
pCdcd->bNumInterface = 2;
|
||||
}
|
||||
/* Only data interface */
|
||||
else if(pIf->bInterfaceClass == CDCDataInterfaceDescriptor_CLASS) {
|
||||
pCdcd->bInterfaceNdx = pIf->bInterfaceNumber;
|
||||
pCdcd->bNumInterface = 1;
|
||||
}
|
||||
pArg->pIfDesc = pIf;
|
||||
}
|
||||
else if (pCdcd->bInterfaceNdx <= pIf->bInterfaceNumber
|
||||
&& pCdcd->bInterfaceNdx + pCdcd->bNumInterface
|
||||
> pIf->bInterfaceNumber) {
|
||||
pArg->pIfDesc = pIf;
|
||||
}
|
||||
}
|
||||
|
||||
/* Parse valid interfaces */
|
||||
if (pArg->pIfDesc == 0)
|
||||
return 0;
|
||||
|
||||
/* Find endpoint descriptors */
|
||||
if (pDesc->bDescriptorType == USBGenericDescriptor_ENDPOINT) {
|
||||
USBEndpointDescriptor *pEp = (USBEndpointDescriptor*)pDesc;
|
||||
switch(pEp->bmAttributes & 0x3) {
|
||||
case USBEndpointDescriptor_INTERRUPT:
|
||||
if (pEp->bEndpointAddress & 0x80)
|
||||
pCdcd->bIntInPIPE = pEp->bEndpointAddress & 0x7F;
|
||||
break;
|
||||
case USBEndpointDescriptor_BULK:
|
||||
if (pEp->bEndpointAddress & 0x80)
|
||||
pCdcd->bBulkInPIPE = pEp->bEndpointAddress & 0x7F;
|
||||
else
|
||||
pCdcd->bBulkOutPIPE = pEp->bEndpointAddress;
|
||||
}
|
||||
}
|
||||
|
||||
if ( pCdcd->bInterfaceNdx != 0xFF
|
||||
&& pCdcd->bBulkInPIPE != 0
|
||||
&& pCdcd->bBulkOutPIPE != 0)
|
||||
return USBRC_FINISHED;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback function which should be invoked after the data of a
|
||||
* SetLineCoding request has been retrieved. Sends a zero-length packet
|
||||
* to the host for acknowledging the request.
|
||||
* \param pCdcd Pointer to CDCDSerialPort instance.
|
||||
*/
|
||||
static void _SetLineCodingCallback(CDCDSerialPort * pCdcd)
|
||||
{
|
||||
uint32_t exec = 1;
|
||||
if (pCdcd->fEventHandler) {
|
||||
uint32_t rc = pCdcd->fEventHandler(
|
||||
CDCDSerialPortEvent_SETLINECODING,
|
||||
(uint32_t)(&lineCoding),
|
||||
pCdcd->pArg);
|
||||
if (rc == USBD_STATUS_SUCCESS) {
|
||||
pCdcd->lineCoding.dwDTERate = lineCoding.dwDTERate;
|
||||
pCdcd->lineCoding.bCharFormat = lineCoding.bCharFormat;
|
||||
pCdcd->lineCoding.bParityType = lineCoding.bParityType;
|
||||
pCdcd->lineCoding.bDataBits = lineCoding.bDataBits;
|
||||
}
|
||||
else
|
||||
exec = 0;
|
||||
}
|
||||
if (exec) USBD_Write(0, 0, 0, 0, 0);
|
||||
else USBD_Stall(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Receives new line coding information from the USB host.
|
||||
* \param pCdcd Pointer to CDCDSerialPort instance.
|
||||
*/
|
||||
static void _SetLineCoding(CDCDSerialPort * pCdcd)
|
||||
{
|
||||
TRACE_INFO_WP("sLineCoding ");
|
||||
|
||||
USBD_Read(0,
|
||||
(void *) & (lineCoding),
|
||||
sizeof(CDCLineCoding),
|
||||
(TransferCallback)_SetLineCodingCallback,
|
||||
(void*)pCdcd);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the current line coding information to the host through Control
|
||||
* endpoint 0.
|
||||
* \param pCdcd Pointer to CDCDSerialPort instance.
|
||||
*/
|
||||
static void _GetLineCoding(CDCDSerialPort * pCdcd)
|
||||
{
|
||||
TRACE_INFO_WP("gLineCoding ");
|
||||
|
||||
USBD_Write(0,
|
||||
(void *) &(pCdcd->lineCoding),
|
||||
sizeof(CDCLineCoding),
|
||||
0,
|
||||
0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the state of the serial driver according to the information
|
||||
* sent by the host via a SetControlLineState request, and acknowledges
|
||||
* the request with a zero-length packet.
|
||||
* \param pCdcd Pointer to CDCDSerialPort instance.
|
||||
* \param request Pointer to a USBGenericRequest instance.
|
||||
*/
|
||||
static void _SetControlLineState(
|
||||
CDCDSerialPort * pCdcd,
|
||||
const USBGenericRequest *request)
|
||||
{
|
||||
#if (TRACE_LEVEL >= TRACE_LEVEL_INFO)
|
||||
uint8_t DTR, RTS;
|
||||
|
||||
DTR = ((request->wValue & CDCControlLineState_DTR) > 0);
|
||||
RTS = ((request->wValue & CDCControlLineState_RTS) > 0);
|
||||
TRACE_INFO_WP("sControlLineState(%d, %d) ", DTR, RTS);
|
||||
#endif
|
||||
|
||||
pCdcd->bControlLineState = (uint8_t)request->wValue;
|
||||
USBD_Write(0, 0, 0, 0, 0);
|
||||
|
||||
if (pCdcd->fEventHandler)
|
||||
pCdcd->fEventHandler(CDCDSerialPortEvent_SETCONTROLLINESTATE,
|
||||
|
||||
(uint32_t)pCdcd->bControlLineState,
|
||||
pCdcd->pArg);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Initializes the USB Device CDC serial port function.
|
||||
* \param pCdcd Pointer to CDCDSerialPort instance.
|
||||
* \param pUsbd Pointer to USBDDriver instance.
|
||||
* \param fEventHandler Pointer to event handler function.
|
||||
* \param firstInterface First interface index for the function
|
||||
* (0xFF to parse from descriptors).
|
||||
* \param numInterface Number of interfaces for the function.
|
||||
*/
|
||||
void CDCDSerialPort_Initialize(CDCDSerialPort * pCdcd,
|
||||
USBDDriver * pUsbd,
|
||||
CDCDSerialPortEventHandler fEventHandler,
|
||||
void * pArg,
|
||||
uint8_t firstInterface,uint8_t numInterface)
|
||||
{
|
||||
TRACE_INFO("CDCDSerialPort_Initialize\n\r");
|
||||
|
||||
/* Initialize event handler */
|
||||
pCdcd->fEventHandler = fEventHandler;
|
||||
pCdcd->pArg = pArg;
|
||||
|
||||
/* Initialize USB Device Driver interface */
|
||||
pCdcd->pUsbd = pUsbd;
|
||||
pCdcd->bInterfaceNdx = firstInterface;
|
||||
pCdcd->bNumInterface = numInterface;
|
||||
pCdcd->bIntInPIPE = 0;
|
||||
pCdcd->bBulkInPIPE = 0;
|
||||
pCdcd->bBulkOutPIPE = 0;
|
||||
|
||||
/* Initialize Abstract Control Model attributes */
|
||||
pCdcd->bControlLineState = 0;
|
||||
pCdcd->wSerialState = 0;
|
||||
CDCLineCoding_Initialize(&(pCdcd->lineCoding),
|
||||
115200,
|
||||
CDCLineCoding_ONESTOPBIT,
|
||||
CDCLineCoding_NOPARITY,
|
||||
8);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse CDC Serial Port information for CDCDSerialPort instance.
|
||||
* Accepted interfaces:
|
||||
* - Communication Interface + Data Interface
|
||||
* - Data Interface ONLY
|
||||
* \param pCdcd Pointer to CDCDSerialPort instance.
|
||||
* \param pDescriptors Pointer to descriptor list.
|
||||
* \param dwLength Descriptor list size in bytes.
|
||||
*/
|
||||
USBGenericDescriptor *CDCDSerialPort_ParseInterfaces(
|
||||
CDCDSerialPort *pCdcd,
|
||||
USBGenericDescriptor *pDescriptors,
|
||||
uint32_t dwLength)
|
||||
{
|
||||
CDCDParseData parseData;
|
||||
|
||||
parseData.pCdcd = pCdcd;
|
||||
parseData.pIfDesc = 0;
|
||||
|
||||
return USBGenericDescriptor_Parse(
|
||||
pDescriptors, dwLength,
|
||||
(USBDescriptorParseFunction)_Interfaces_Parse,
|
||||
&parseData);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handles CDC-specific SETUP requests. Should be called from a
|
||||
* re-implementation of USBDCallbacks_RequestReceived() method.
|
||||
* \param pCdcd Pointer to CDCDSerialPort instance.
|
||||
* \param request Pointer to a USBGenericRequest instance.
|
||||
* \return USBRC_SUCCESS if request handled, otherwise error.
|
||||
*/
|
||||
uint32_t CDCDSerialPort_RequestHandler(
|
||||
CDCDSerialPort *pCdcd,
|
||||
const USBGenericRequest *request)
|
||||
{
|
||||
if (USBGenericRequest_GetType(request) != USBGenericRequest_CLASS)
|
||||
return USBRC_PARAM_ERR;
|
||||
|
||||
TRACE_INFO_WP("Cdcs ");
|
||||
|
||||
/* Validate interface */
|
||||
if (request->wIndex >= pCdcd->bInterfaceNdx &&
|
||||
request->wIndex < pCdcd->bInterfaceNdx + pCdcd->bNumInterface) {
|
||||
}
|
||||
else {
|
||||
return USBRC_PARAM_ERR;
|
||||
}
|
||||
|
||||
/* Handle the request */
|
||||
switch (USBGenericRequest_GetRequest(request)) {
|
||||
|
||||
case CDCGenericRequest_SETLINECODING:
|
||||
|
||||
_SetLineCoding(pCdcd);
|
||||
break;
|
||||
|
||||
case CDCGenericRequest_GETLINECODING:
|
||||
|
||||
_GetLineCoding(pCdcd);
|
||||
break;
|
||||
|
||||
case CDCGenericRequest_SETCONTROLLINESTATE:
|
||||
|
||||
_SetControlLineState(pCdcd, request);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
return USBRC_PARAM_ERR;
|
||||
}
|
||||
|
||||
return USBRC_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Receives data from the host through the virtual COM port created by
|
||||
* the CDC device serial driver. This function behaves like USBD_Read.
|
||||
* \param pCdcd Pointer to CDCDSerialPort instance.
|
||||
* \param pData Pointer to the data buffer to put received data.
|
||||
* \param dwSize Size of the data buffer in bytes.
|
||||
* \param fCallback Optional callback function to invoke when the transfer
|
||||
* finishes.
|
||||
* \param pArg Optional argument to the callback function.
|
||||
* \return USBD_STATUS_SUCCESS if the read operation has been started normally;
|
||||
* otherwise, the corresponding error code.
|
||||
*/
|
||||
uint32_t CDCDSerialPort_Read(const CDCDSerialPort * pCdcd,
|
||||
void * pData,uint32_t dwSize,
|
||||
TransferCallback fCallback,void * pArg)
|
||||
{
|
||||
if (pCdcd->bBulkOutPIPE == 0)
|
||||
return USBRC_PARAM_ERR;
|
||||
|
||||
return USBD_Read(pCdcd->bBulkOutPIPE,
|
||||
pData, dwSize,
|
||||
fCallback, pArg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a data buffer through the virtual COM port created by the CDC
|
||||
* device serial driver. This function behaves exactly like USBD_Write.
|
||||
* \param pCdcd Pointer to CDCDSerialPort instance.
|
||||
* \param pData Pointer to the data buffer to send.
|
||||
* \param dwSize Size of the data buffer in bytes.
|
||||
* \param fCallback Optional callback function to invoke when the transfer
|
||||
* finishes.
|
||||
* \param pArg Optional argument to the callback function.
|
||||
* \return USBD_STATUS_SUCCESS if the read operation has been started normally;
|
||||
* otherwise, the corresponding error code.
|
||||
*/
|
||||
uint32_t CDCDSerialPort_Write(const CDCDSerialPort * pCdcd,
|
||||
void * pData, uint32_t dwSize,
|
||||
TransferCallback fCallback, void * pArg)
|
||||
{
|
||||
if (pCdcd->bBulkInPIPE == 0)
|
||||
return USBRC_PARAM_ERR;
|
||||
|
||||
return USBD_Write(pCdcd->bBulkInPIPE,
|
||||
pData, dwSize,
|
||||
fCallback, pArg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current control line state of the RS-232 line.
|
||||
* \param pCdcd Pointer to CDCDSerialPort instance.
|
||||
*/
|
||||
uint8_t CDCDSerialPort_GetControlLineState(const CDCDSerialPort * pCdcd)
|
||||
{
|
||||
return pCdcd->bControlLineState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy current line coding settings to pointered space.
|
||||
* \param pCdcd Pointer to CDCDSerialPort instance.
|
||||
* \param pLineCoding Pointer to CDCLineCoding instance.
|
||||
*/
|
||||
void CDCDSerialPort_GetLineCoding(const CDCDSerialPort * pCdcd,
|
||||
CDCLineCoding* pLineCoding)
|
||||
{
|
||||
if (pLineCoding) {
|
||||
pLineCoding->dwDTERate = pCdcd->lineCoding.dwDTERate;
|
||||
pLineCoding->bCharFormat = pCdcd->lineCoding.bCharFormat;
|
||||
pLineCoding->bParityType = pCdcd->lineCoding.bParityType;
|
||||
pLineCoding->bDataBits = pCdcd->lineCoding.bDataBits;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current status of the RS-232 line.
|
||||
* \param pCdcd Pointer to CDCDSerialPort instance.
|
||||
*/
|
||||
uint16_t CDCDSerialPort_GetSerialState(const CDCDSerialPort * pCdcd)
|
||||
{
|
||||
return pCdcd->wSerialState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current serial state of the device to the given value.
|
||||
* \param pCdcd Pointer to CDCDSerialPort instance.
|
||||
* \param wSerialState New device state.
|
||||
*/
|
||||
void CDCDSerialPort_SetSerialState(CDCDSerialPort * pCdcd,
|
||||
uint16_t wSerialState)
|
||||
{
|
||||
if (pCdcd->bIntInPIPE == 0)
|
||||
return;
|
||||
|
||||
/* If new state is different from previous one, send a notification to the
|
||||
host */
|
||||
if (pCdcd->wSerialState != wSerialState) {
|
||||
|
||||
pCdcd->wSerialState = wSerialState;
|
||||
USBD_Write(pCdcd->bIntInPIPE,
|
||||
&(pCdcd->wSerialState),
|
||||
2,
|
||||
0,
|
||||
0);
|
||||
|
||||
/* Reset one-time flags */
|
||||
pCdcd->wSerialState &= ~(CDCSerialState_OVERRUN
|
||||
| CDCSerialState_PARITY
|
||||
| CDCSerialState_FRAMING
|
||||
| CDCSerialState_RINGSIGNAL
|
||||
| CDCSerialState_BREAK);
|
||||
}
|
||||
}
|
||||
|
||||
/**@}*/
|
||||
|
@ -0,0 +1,70 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* 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:
|
||||
*
|
||||
* - 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Headers
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/* These headers were introduced in C99
|
||||
by working group ISO/IEC JTC1/SC22/WG14. */
|
||||
#include <stdint.h>
|
||||
|
||||
#include "CDCDSerial.h"
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Default callback functions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Invoked when the CDC LineCoding is requested to changed
|
||||
* \param port Port number.
|
||||
* \param pLineCoding Pointer to new LineCoding settings.
|
||||
* \return USBRC_SUCCESS if ready to receive the line coding.
|
||||
*/
|
||||
extern WEAK uint8_t CDCDSerial_LineCodingIsToChange(
|
||||
CDCLineCoding * pLineCoding)
|
||||
{
|
||||
/* Accept any of linecoding settings */
|
||||
pLineCoding = pLineCoding;
|
||||
return USBRC_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked when the CDC ControlLineState is changed
|
||||
* \param port Port number.
|
||||
* \param DTR New DTR value.
|
||||
* \param RTS New RTS value.
|
||||
*/
|
||||
extern WEAK void CDCDSerial_ControlLineStateChanged(uint8_t DTR,
|
||||
uint8_t RTS)
|
||||
{
|
||||
/* Do nothing */
|
||||
DTR = DTR; RTS = RTS;
|
||||
}
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 28 KiB |
Binary file not shown.
After Width: | Height: | Size: 9.9 KiB |
@ -0,0 +1,45 @@
|
||||
; $Id: 6119.inf,v 1.1.2.1 2006/12/05 08:33:25 danielru Exp $
|
||||
|
||||
[Version] ; Version section
|
||||
Signature="$Chicago$" ; All Windows versions
|
||||
Class=Ports ; This is a serial port driver
|
||||
ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318} ; Associated GUID
|
||||
Provider=%ATMEL% ; Driver is provided by ATMEL
|
||||
DriverVer=09/12/2006,1.1.1.5 ; Driver version 1.1.1.5 published on 23 February 2007
|
||||
|
||||
[DestinationDirs] ; DestinationDirs section
|
||||
DefaultDestDir=12 ; Default install directory is \drivers or \IOSubSys
|
||||
|
||||
[Manufacturer] ; Manufacturer section
|
||||
%ATMEL%=AtmelMfg ; Only one manufacturer (ATMEL), models section is named
|
||||
; AtmelMfg
|
||||
|
||||
[AtmelMfg] ; Models section corresponding to ATMEL
|
||||
%USBtoSerialConverter%=USBtoSer.Install,USB\VID_03EB&PID_6119 ; Identifies a device with ATMEL Vendor ID (03EBh) and
|
||||
; Product ID equal to 6119h. Corresponding Install section
|
||||
; is named USBtoSer.Install
|
||||
|
||||
[USBtoSer.Install] ; Install section
|
||||
include=mdmcpq.inf
|
||||
CopyFiles=FakeModemCopyFileSection
|
||||
AddReg=USBtoSer.AddReg ; Registry keys to add are listed in USBtoSer.AddReg
|
||||
|
||||
[USBtoSer.AddReg] ; AddReg section
|
||||
HKR,,DevLoader,,*ntkern ;
|
||||
HKR,,NTMPDriver,,usbser.sys
|
||||
HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider"
|
||||
|
||||
[USBtoSer.Install.Services] ; Services section
|
||||
AddService=usbser,0x00000002,USBtoSer.AddService ; Assign usbser as the PnP driver for the device
|
||||
|
||||
[USBtoSer.AddService] ; Service install section
|
||||
DisplayName=%USBSer% ; Name of the serial driver
|
||||
ServiceType=1 ; Service kernel driver
|
||||
StartType=3 ; Driver is started by the PnP manager
|
||||
ErrorControl=1 ; Warn about errors
|
||||
ServiceBinary=%12%\usbser.sys ; Driver filename
|
||||
|
||||
[Strings] ; Strings section
|
||||
ATMEL="ATMEL Corp." ; String value for the ATMEL symbol
|
||||
USBtoSerialConverter="AT91 USB to Serial Converter" ; String value for the USBtoSerialConverter symbol
|
||||
USBSer="USB Serial Driver" ; String value for the USBSer symbol
|
@ -0,0 +1,550 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* \section Purpose
|
||||
*
|
||||
* Implementation of USB device functions on a UDP controller.
|
||||
*
|
||||
* See \ref usbd_api "USBD API Methods".
|
||||
*/
|
||||
|
||||
/** \addtogroup usbd_interface
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Headers
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "USBD.h"
|
||||
#include "USBD_HAL.h"
|
||||
|
||||
#include <USBLib_Trace.h>
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Internal variables
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/** Device current state. */
|
||||
static uint8_t deviceState;
|
||||
/** Indicates the previous device state */
|
||||
static uint8_t previousDeviceState;
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Internal Functions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* USBD: Event handlers
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Handle the USB suspend event, should be invoked whenever
|
||||
* HW reports a suspend signal.
|
||||
*/
|
||||
void USBD_SuspendHandler(void)
|
||||
{
|
||||
/* Don't do anything if the device is already suspended */
|
||||
if (deviceState != USBD_STATE_SUSPENDED) {
|
||||
|
||||
/* Switch to the Suspended state */
|
||||
previousDeviceState = deviceState;
|
||||
deviceState = USBD_STATE_SUSPENDED;
|
||||
|
||||
/* Suspend HW interface */
|
||||
USBD_HAL_Suspend();
|
||||
|
||||
/* Invoke the User Suspended callback (Suspend System?) */
|
||||
if (NULL != USBDCallbacks_Suspended)
|
||||
USBDCallbacks_Suspended();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the USB resume event, should be invoked whenever
|
||||
* HW reports a resume signal.
|
||||
*/
|
||||
void USBD_ResumeHandler(void)
|
||||
{
|
||||
/* Don't do anything if the device was not suspended */
|
||||
if (deviceState == USBD_STATE_SUSPENDED) {
|
||||
/* Active the device */
|
||||
USBD_HAL_Activate();
|
||||
deviceState = previousDeviceState;
|
||||
if (deviceState >= USBD_STATE_DEFAULT) {
|
||||
/* Invoke the Resume callback */
|
||||
if (NULL != USBDCallbacks_Resumed)
|
||||
USBDCallbacks_Resumed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the USB reset event, should be invoked whenever
|
||||
* HW found USB reset signal on bus, which usually is called
|
||||
* "end of bus reset" status.
|
||||
*/
|
||||
void USBD_ResetHandler()
|
||||
{
|
||||
/* The device enters the Default state */
|
||||
deviceState = USBD_STATE_DEFAULT;
|
||||
/* Active the USB HW */
|
||||
USBD_HAL_Activate();
|
||||
/* Only EP0 enabled */
|
||||
USBD_HAL_ResetEPs(0xFFFFFFFF, USBD_STATUS_RESET, 0);
|
||||
USBD_ConfigureEndpoint(0);
|
||||
/* Invoke the Reset callback */
|
||||
if (NULL != USBDCallbacks_Reset)
|
||||
USBDCallbacks_Reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the USB setup package received, should be invoked
|
||||
* when an endpoint got a setup package as request.
|
||||
* \param bEndpoint Endpoint number.
|
||||
* \param pRequest Pointer to content of request.
|
||||
*/
|
||||
void USBD_RequestHandler(uint8_t bEndpoint,
|
||||
const USBGenericRequest* pRequest)
|
||||
{
|
||||
if (bEndpoint != 0) {
|
||||
TRACE_WARNING("EP%d request not supported, default EP only",
|
||||
bEndpoint);
|
||||
}
|
||||
else if (NULL != USBDCallbacks_RequestReceived) {
|
||||
USBDCallbacks_RequestReceived(pRequest);
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* USBD: Library interface
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Configures an endpoint according to its Endpoint Descriptor.
|
||||
* \param pDescriptor Pointer to an Endpoint descriptor.
|
||||
*/
|
||||
void USBD_ConfigureEndpoint(const USBEndpointDescriptor *pDescriptor)
|
||||
{
|
||||
USBD_HAL_ConfigureEP(pDescriptor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends data through a USB endpoint. Sets up the transfer descriptor,
|
||||
* writes one or two data payloads (depending on the number of FIFO bank
|
||||
* for the endpoint) and then starts the actual transfer. The operation is
|
||||
* complete when all the data has been sent.
|
||||
*
|
||||
* *If the size of the buffer is greater than the size of the endpoint
|
||||
* (or twice the size if the endpoint has two FIFO banks), then the buffer
|
||||
* must be kept allocated until the transfer is finished*. This means that
|
||||
* it is not possible to declare it on the stack (i.e. as a local variable
|
||||
* of a function which returns after starting a transfer).
|
||||
*
|
||||
* \param bEndpoint Endpoint number.
|
||||
* \param pData Pointer to a buffer with the data to send.
|
||||
* \param dLength Size of the data buffer.
|
||||
* \param fCallback Optional callback function to invoke when the transfer is
|
||||
* complete.
|
||||
* \param pArgument Optional argument to the callback function.
|
||||
* \return USBD_STATUS_SUCCESS if the transfer has been started;
|
||||
* otherwise, the corresponding error status code.
|
||||
*/
|
||||
uint8_t USBD_Write( uint8_t bEndpoint,
|
||||
const void *pData,
|
||||
uint32_t dLength,
|
||||
TransferCallback fCallback,
|
||||
void *pArgument )
|
||||
{
|
||||
USBD_HAL_SetTransferCallback(bEndpoint, fCallback, pArgument);
|
||||
return USBD_HAL_Write(bEndpoint, pData, dLength);
|
||||
}
|
||||
#if 0
|
||||
/**
|
||||
* Sends data frames through a USB endpoint. Sets up the transfer descriptor
|
||||
* list, writes one or two data payloads (depending on the number of FIFO bank
|
||||
* for the endpoint) and then starts the actual transfer. The operation is
|
||||
* complete when all the data has been sent.
|
||||
*
|
||||
* *If the size of the frame is greater than the size of the endpoint
|
||||
* (or twice the size if the endpoint has two FIFO banks), then the buffer
|
||||
* must be kept allocated until the frame is finished*. This means that
|
||||
* it is not possible to declare it on the stack (i.e. as a local variable
|
||||
* of a function which returns after starting a transfer).
|
||||
*
|
||||
* \param bEndpoint Endpoint number.
|
||||
* \param pMbl Pointer to a frame (USBDTransferBuffer) list that describes
|
||||
* the buffer list to send.
|
||||
* \param wListSize Size of the frame list.
|
||||
* \param bCircList Circle the list.
|
||||
* \param wStartNdx For circled list only, the first buffer index to transfer.
|
||||
* \param fCallback Optional callback function to invoke when the transfer is
|
||||
* complete.
|
||||
* \param pArgument Optional argument to the callback function.
|
||||
* \return USBD_STATUS_SUCCESS if the transfer has been started;
|
||||
* otherwise, the corresponding error status code.
|
||||
* \see USBDTransferBuffer, MblTransferCallback, USBD_MblReuse
|
||||
*/
|
||||
uint8_t USBD_MblWrite( uint8_t bEndpoint,
|
||||
void *pMbl,
|
||||
uint16_t wListSize,
|
||||
uint8_t bCircList,
|
||||
uint16_t wStartNdx,
|
||||
MblTransferCallback fCallback,
|
||||
void *pArgument )
|
||||
{
|
||||
Endpoint *pEndpoint = &(endpoints[bEndpoint]);
|
||||
MblTransfer *pTransfer = (MblTransfer*)&(pEndpoint->transfer);
|
||||
uint16_t i;
|
||||
|
||||
/* EP0 is not suitable for Mbl */
|
||||
|
||||
if (bEndpoint == 0) {
|
||||
|
||||
return USBD_STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
/* Check that the endpoint is in Idle state */
|
||||
|
||||
if (pEndpoint->state != UDP_ENDPOINT_IDLE) {
|
||||
|
||||
return USBD_STATUS_LOCKED;
|
||||
}
|
||||
pEndpoint->state = UDP_ENDPOINT_SENDINGM;
|
||||
|
||||
TRACE_DEBUG_WP("WriteM%d(0x%x,%d) ", bEndpoint, pMbl, wListSize);
|
||||
|
||||
/* Start from first if not circled list */
|
||||
|
||||
if (!bCircList) wStartNdx = 0;
|
||||
|
||||
/* Setup the transfer descriptor */
|
||||
|
||||
pTransfer->pMbl = (USBDTransferBuffer*)pMbl;
|
||||
pTransfer->listSize = wListSize;
|
||||
pTransfer->fCallback = fCallback;
|
||||
pTransfer->pArgument = pArgument;
|
||||
pTransfer->currBuffer = wStartNdx;
|
||||
pTransfer->freedBuffer = 0;
|
||||
pTransfer->pLastLoaded = &(((USBDTransferBuffer*)pMbl)[wStartNdx]);
|
||||
pTransfer->circList = bCircList;
|
||||
pTransfer->allUsed = 0;
|
||||
|
||||
/* Clear all buffer */
|
||||
|
||||
for (i = 0; i < wListSize; i ++) {
|
||||
|
||||
pTransfer->pMbl[i].transferred = 0;
|
||||
pTransfer->pMbl[i].buffered = 0;
|
||||
pTransfer->pMbl[i].remaining = pTransfer->pMbl[i].size;
|
||||
}
|
||||
|
||||
/* Send the first packet */
|
||||
|
||||
while((UDP->UDP_CSR[bEndpoint]&UDP_CSR_TXPKTRDY)==UDP_CSR_TXPKTRDY);
|
||||
UDP_MblWriteFifo(bEndpoint);
|
||||
SET_CSR(bEndpoint, UDP_CSR_TXPKTRDY);
|
||||
|
||||
/* If double buffering is enabled and there is data remaining, */
|
||||
|
||||
/* prepare another packet */
|
||||
|
||||
if ((CHIP_USB_ENDPOINTS_BANKS(bEndpoint) > 1)
|
||||
&& (pTransfer->pMbl[pTransfer->currBuffer].remaining > 0)) {
|
||||
|
||||
UDP_MblWriteFifo(bEndpoint);
|
||||
}
|
||||
|
||||
/* Enable interrupt on endpoint */
|
||||
|
||||
UDP->UDP_IER = 1 << bEndpoint;
|
||||
|
||||
return USBD_STATUS_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
/**
|
||||
* Reads incoming data on an USB endpoint This methods sets the transfer
|
||||
* descriptor and activate the endpoint interrupt. The actual transfer is
|
||||
* then carried out by the endpoint interrupt handler. The Read operation
|
||||
* finishes either when the buffer is full, or a short packet (inferior to
|
||||
* endpoint maximum size) is received.
|
||||
*
|
||||
* *The buffer must be kept allocated until the transfer is finished*.
|
||||
* \param bEndpoint Endpoint number.
|
||||
* \param pData Pointer to a data buffer.
|
||||
* \param dLength Size of the data buffer in bytes.
|
||||
* \param fCallback Optional end-of-transfer callback function.
|
||||
* \param pArgument Optional argument to the callback function.
|
||||
* \return USBD_STATUS_SUCCESS if the read operation has been started;
|
||||
* otherwise, the corresponding error code.
|
||||
*/
|
||||
uint8_t USBD_Read(uint8_t bEndpoint,
|
||||
void *pData,
|
||||
uint32_t dLength,
|
||||
TransferCallback fCallback,
|
||||
void *pArgument)
|
||||
{
|
||||
USBD_HAL_SetTransferCallback(bEndpoint, fCallback, pArgument);
|
||||
return USBD_HAL_Read(bEndpoint, pData, dLength);
|
||||
}
|
||||
#if 0
|
||||
/**
|
||||
* Reuse first used/released buffer with new buffer address and size to be used
|
||||
* in transfer again. Only valid when frame list is ringed. Can be used for
|
||||
* both read & write.
|
||||
* \param bEndpoint Endpoint number.
|
||||
* \param pNewBuffer Pointer to new buffer with data to send (0 to keep last).
|
||||
* \param wNewSize Size of the data buffer
|
||||
*/
|
||||
uint8_t USBD_MblReuse( uint8_t bEndpoint,
|
||||
uint8_t *pNewBuffer,
|
||||
uint16_t wNewSize )
|
||||
{
|
||||
Endpoint *pEndpoint = &(endpoints[bEndpoint]);
|
||||
MblTransfer *pTransfer = (MblTransfer*)&(pEndpoint->transfer);
|
||||
USBDTransferBuffer *pBi = &(pTransfer->pMbl[pTransfer->freedBuffer]);
|
||||
|
||||
TRACE_DEBUG_WP("MblReuse(%d), st%x, circ%d\n\r",
|
||||
bEndpoint, pEndpoint->state, pTransfer->circList);
|
||||
|
||||
/* Only for Multi-buffer-circle list */
|
||||
|
||||
if (bEndpoint != 0
|
||||
&& (pEndpoint->state == UDP_ENDPOINT_RECEIVINGM
|
||||
|| pEndpoint->state == UDP_ENDPOINT_SENDINGM)
|
||||
&& pTransfer->circList) {
|
||||
}
|
||||
else {
|
||||
|
||||
return USBD_STATUS_WRONG_STATE;
|
||||
}
|
||||
|
||||
/* Check if there is freed buffer */
|
||||
|
||||
if (pTransfer->freedBuffer == pTransfer->currBuffer
|
||||
&& !pTransfer->allUsed) {
|
||||
|
||||
return USBD_STATUS_LOCKED;
|
||||
}
|
||||
|
||||
/* Update transfer information */
|
||||
|
||||
if ((++ pTransfer->freedBuffer) == pTransfer->listSize)
|
||||
pTransfer->freedBuffer = 0;
|
||||
if (pNewBuffer) {
|
||||
pBi->pBuffer = pNewBuffer;
|
||||
pBi->size = wNewSize;
|
||||
}
|
||||
pBi->buffered = 0;
|
||||
pBi->transferred = 0;
|
||||
pBi->remaining = pBi->size;
|
||||
|
||||
/* At least one buffer is not processed */
|
||||
|
||||
pTransfer->allUsed = 0;
|
||||
return USBD_STATUS_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
/**
|
||||
* Sets the HALT feature on the given endpoint (if not already in this state).
|
||||
* \param bEndpoint Endpoint number.
|
||||
*/
|
||||
void USBD_Halt(uint8_t bEndpoint)
|
||||
{
|
||||
USBD_HAL_Halt(bEndpoint, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the Halt feature on the given endpoint.
|
||||
* \param bEndpoint Index of endpoint
|
||||
*/
|
||||
void USBD_Unhalt(uint8_t bEndpoint)
|
||||
{
|
||||
USBD_HAL_Halt(bEndpoint, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current Halt status of an endpoint.
|
||||
* \param bEndpoint Index of endpoint
|
||||
* \return 1 if the endpoint is currently halted; otherwise 0
|
||||
*/
|
||||
uint8_t USBD_IsHalted(uint8_t bEndpoint)
|
||||
{
|
||||
return USBD_HAL_Halt(bEndpoint, 0xFF);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if the device is running in high or full-speed. Always returns 0
|
||||
* since UDP does not support high-speed mode.
|
||||
*/
|
||||
uint8_t USBD_IsHighSpeed(void)
|
||||
{
|
||||
return USBD_HAL_IsHighSpeed();
|
||||
}
|
||||
|
||||
/**
|
||||
* Causes the given endpoint to acknowledge the next packet it receives
|
||||
* with a STALL handshake.
|
||||
* \param bEndpoint Endpoint number.
|
||||
* \return USBD_STATUS_SUCCESS or USBD_STATUS_LOCKED.
|
||||
*/
|
||||
uint8_t USBD_Stall(uint8_t bEndpoint)
|
||||
|
||||
{
|
||||
return USBD_HAL_Stall(bEndpoint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the device address to the given value.
|
||||
* \param address New device address.
|
||||
*/
|
||||
void USBD_SetAddress(uint8_t address)
|
||||
{
|
||||
TRACE_INFO_WP("SetAddr(%d) ", address);
|
||||
|
||||
USBD_HAL_SetAddress(address);
|
||||
if (address == 0) deviceState = USBD_STATE_DEFAULT;
|
||||
else deviceState = USBD_STATE_ADDRESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current device configuration.
|
||||
* \param cfgnum - Configuration number to set.
|
||||
*/
|
||||
void USBD_SetConfiguration(uint8_t cfgnum)
|
||||
{
|
||||
TRACE_INFO_WP("SetCfg(%d) ", cfgnum);
|
||||
|
||||
USBD_HAL_SetConfiguration(cfgnum);
|
||||
|
||||
if (cfgnum != 0) {
|
||||
deviceState = USBD_STATE_CONFIGURED;
|
||||
}
|
||||
else {
|
||||
deviceState = USBD_STATE_ADDRESS;
|
||||
/* Reset all endpoints but Control 0 */
|
||||
USBD_HAL_ResetEPs(0xFFFFFFFE, USBD_STATUS_RESET, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* USBD: Library API
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Starts a remote wake-up procedure.
|
||||
*/
|
||||
void USBD_RemoteWakeUp(void)
|
||||
{
|
||||
/* Device is NOT suspended */
|
||||
if (deviceState != USBD_STATE_SUSPENDED) {
|
||||
|
||||
TRACE_INFO("USBD_RemoteWakeUp: Device is not suspended\n\r");
|
||||
return;
|
||||
}
|
||||
USBD_HAL_Activate();
|
||||
USBD_HAL_RemoteWakeUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Connects the pull-up on the D+ line of the USB.
|
||||
*/
|
||||
void USBD_Connect(void)
|
||||
{
|
||||
USBD_HAL_Connect();
|
||||
}
|
||||
|
||||
/**
|
||||
* Disconnects the pull-up from the D+ line of the USB.
|
||||
*/
|
||||
void USBD_Disconnect(void)
|
||||
{
|
||||
USBD_HAL_Disconnect();
|
||||
|
||||
/* Device returns to the Powered state */
|
||||
|
||||
if (deviceState > USBD_STATE_POWERED) {
|
||||
|
||||
deviceState = USBD_STATE_POWERED;
|
||||
}
|
||||
|
||||
if (previousDeviceState > USBD_STATE_POWERED) {
|
||||
|
||||
previousDeviceState = USBD_STATE_POWERED;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the USB driver.
|
||||
*/
|
||||
void USBD_Init(void)
|
||||
{
|
||||
TRACE_INFO_WP("USBD_Init\n\r");
|
||||
|
||||
/* HW Layer Initialize */
|
||||
USBD_HAL_Init();
|
||||
|
||||
/* Device is in the Attached state */
|
||||
deviceState = USBD_STATE_SUSPENDED;
|
||||
previousDeviceState = USBD_STATE_POWERED;
|
||||
|
||||
/* Upper Layer Initialize */
|
||||
if (NULL != USBDCallbacks_Initialized)
|
||||
USBDCallbacks_Initialized();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current state of the USB device.
|
||||
* \return Device current state.
|
||||
*/
|
||||
uint8_t USBD_GetState(void)
|
||||
{
|
||||
return deviceState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Certification test for High Speed device.
|
||||
* \param bIndex Test to be done
|
||||
*/
|
||||
void USBD_Test(uint8_t bIndex)
|
||||
{
|
||||
USBD_HAL_Test(bIndex);
|
||||
}
|
||||
|
||||
/**@}*/
|
@ -0,0 +1,89 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* Definitions of callbacks used by the USBD API to notify the user
|
||||
* application of incoming events. These functions are declared as 'weak',
|
||||
* so they can be re-implemented elsewhere in the application in a
|
||||
* transparent way.
|
||||
*
|
||||
* \addtogroup usbd_interface
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Headers
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
#include "USBD.h"
|
||||
#include "USBDDriver.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Exported function
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Invoked after the USB driver has been initialized. By default, do nothing.
|
||||
*/
|
||||
WEAK void USBDCallbacks_Initialized(void)
|
||||
{
|
||||
/* Does nothing */
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked when the USB driver is reset. Does nothing by default.
|
||||
*/
|
||||
WEAK void USBDCallbacks_Reset(void)
|
||||
{
|
||||
/* Does nothing*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked when the USB device gets suspended. By default, do nothing.
|
||||
*/
|
||||
WEAK void USBDCallbacks_Suspended(void) {}
|
||||
|
||||
/**
|
||||
* Invoked when the USB device leaves the Suspended state. By default,
|
||||
* Do nothing.
|
||||
*/
|
||||
WEAK void USBDCallbacks_Resumed(void) {}
|
||||
|
||||
/**
|
||||
* USBDCallbacks_RequestReceived - Invoked when a new SETUP request is
|
||||
* received. Does nothing by default.
|
||||
* \param request Pointer to the request to handle.
|
||||
*/
|
||||
WEAK void USBDCallbacks_RequestReceived(const USBGenericRequest *request)
|
||||
{
|
||||
/* Does basic enumeration */
|
||||
USBDDriver_RequestHandler(USBD_GetDriver(), request);
|
||||
}
|
||||
|
||||
/**@}*/
|
@ -0,0 +1,84 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* \section Purpose
|
||||
*
|
||||
* Definition of several callbacks which are triggered by the USB software
|
||||
* driver after receiving specific requests.
|
||||
*
|
||||
* \section Usage
|
||||
*
|
||||
* -# Re-implement the USBDDriverCallbacks_ConfigurationChanged
|
||||
* callback to know when the hosts changes the active configuration of
|
||||
* the device.
|
||||
* -# Re-implement the USBDDriverCallbacks_InterfaceSettingChanged
|
||||
* callback to get notified whenever the active setting of an interface
|
||||
* is changed by the host.
|
||||
*
|
||||
* \addtogroup usbd_interface
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Headers
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
#include "USBDDriver.h"
|
||||
#include <USBLib_Trace.h>
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Global functions
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Indicates that the current configuration of the device has changed.
|
||||
* \param cfgnum New device configuration index.
|
||||
*/
|
||||
WEAK void USBDDriverCallbacks_ConfigurationChanged(uint8_t cfgnum)
|
||||
{
|
||||
cfgnum = cfgnum;
|
||||
TRACE_INFO_WP("cfgChanged%d ", cfgnum);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifies of a change in the currently active setting of an interface.
|
||||
* \param interface Number of the interface whose setting has changed.
|
||||
* \param setting New interface setting.
|
||||
*/
|
||||
WEAK void USBDDriverCallbacks_InterfaceSettingChanged(
|
||||
uint8_t interface,
|
||||
uint8_t setting)
|
||||
{
|
||||
interface = interface; setting = setting;
|
||||
TRACE_INFO_WP("ifSettingChanged%d.%d ", interface, setting);
|
||||
}
|
||||
|
||||
/**@}*/
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,307 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* 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:
|
||||
*
|
||||
* - 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \section Purpose
|
||||
*
|
||||
* Definitions and methods for USB composite device implement.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CDCAUDDDRIVER_H
|
||||
#define CDCAUDDDRIVER_H
|
||||
/** \addtogroup usbd_composite_cdcaud
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Headers
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <USBRequests.h>
|
||||
#include <CDCDescriptors.h>
|
||||
#include <AUDDescriptors.h>
|
||||
#include "USBD.h"
|
||||
#include <USBDDriver.h>
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/** \addtogroup usbd_cdc_aud_desc USB CDC(Serial) + AUD(Speaker) Definitions
|
||||
* @{
|
||||
*/
|
||||
/** Number of interfaces of the device (5, can be 4 if no mic support */
|
||||
#define CDCAUDDDriverDescriptors_MaxNumInterfaces 5
|
||||
/** Number of the CDC interface. */
|
||||
#define CDCAUDDDriverDescriptors_CDC_INTERFACE 0
|
||||
/** Number of the Audio interface. */
|
||||
#define CDCAUDDDriverDescriptors_AUD_INTERFACE 2
|
||||
/** Number of Audio function channels (M,L,R) */
|
||||
#define AUDD_NumChannels 3
|
||||
/** @}*/
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Types
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma pack(1)
|
||||
#if defined ( __CC_ARM ) /* Keil ¦ÌVision 4 */
|
||||
#elif defined ( __ICCARM__ ) /* IAR Ewarm */
|
||||
#define __attribute__(...)
|
||||
#define __packed__ packed
|
||||
#elif defined ( __GNUC__ ) /* GCC CS3 */
|
||||
#define __packed__ aligned(1)
|
||||
#endif
|
||||
|
||||
/** Audio header descriptor with 1 interface */
|
||||
typedef struct _AUDHeaderDescriptor1{
|
||||
|
||||
/** Header descriptor.*/
|
||||
AUDHeaderDescriptor header;
|
||||
/** Id of the first grouped interface.*/
|
||||
uint8_t bInterface0;
|
||||
|
||||
} __attribute__ ((__packed__)) AUDHeaderDescriptor1;
|
||||
|
||||
/** Audio header descriptor with 2 interface */
|
||||
typedef struct _AUDHeaderDescriptor2 {
|
||||
|
||||
/** Header descriptor. */
|
||||
AUDHeaderDescriptor header;
|
||||
/** Id of the first grouped interface - Speaker. */
|
||||
uint8_t bInterface0;
|
||||
/** Id of the second grouped interface - Speakerphone. */
|
||||
uint8_t bInterface1;
|
||||
|
||||
} __attribute__ ((__packed__)) AUDHeaderDescriptor2; /* GCC */
|
||||
|
||||
/**
|
||||
* Feature unit descriptor with 3 channel controls (master, right, left).
|
||||
*/
|
||||
typedef struct _AUDFeatureUnitDescriptor3{
|
||||
|
||||
/** Feature unit descriptor.*/
|
||||
AUDFeatureUnitDescriptor feature;
|
||||
/** Available controls for each channel.*/
|
||||
uint8_t bmaControls[AUDD_NumChannels];
|
||||
/** Index of a string descriptor for the feature unit.*/
|
||||
uint8_t iFeature;
|
||||
|
||||
} __attribute__ ((__packed__)) AUDFeatureUnitDescriptor3;
|
||||
|
||||
/**
|
||||
* List of descriptors for detailling the audio control interface of a
|
||||
* device using a USB audio speaker function.
|
||||
*/
|
||||
typedef struct _AUDDSpeakerAcDescriptors{
|
||||
|
||||
/** Header descriptor (with one slave interface).*/
|
||||
AUDHeaderDescriptor1 header;
|
||||
/** Input terminal descriptor.*/
|
||||
AUDInputTerminalDescriptor input;
|
||||
/** Output terminal descriptor.*/
|
||||
AUDOutputTerminalDescriptor output;
|
||||
/** Feature unit descriptor.*/
|
||||
AUDFeatureUnitDescriptor3 feature;
|
||||
|
||||
} __attribute__ ((__packed__)) AUDDSpeakerAcDescriptors;
|
||||
|
||||
/**
|
||||
* List of descriptors for detailling the audio control interface of a
|
||||
* device using a USB Audio Speakerphoneer function.
|
||||
*/
|
||||
typedef struct _AUDDSpeakerPhoneAcDescriptors {
|
||||
|
||||
/** Header descriptor (with one slave interface). */
|
||||
AUDHeaderDescriptor2 header;
|
||||
/** Input terminal descriptor. */
|
||||
AUDInputTerminalDescriptor inputSpeakerPhone;
|
||||
/** Output terminal descriptor. */
|
||||
AUDOutputTerminalDescriptor outputSpeakerPhone;
|
||||
/** Feature unit descriptor - SpeakerPhone. */
|
||||
AUDFeatureUnitDescriptor3 featureSpeakerPhone;
|
||||
/** Input terminal descriptor. */
|
||||
AUDInputTerminalDescriptor inputRec;
|
||||
/** Output terminal descriptor. */
|
||||
AUDOutputTerminalDescriptor outputRec;
|
||||
/** Feature unit descriptor - SpeakerPhonephone. */
|
||||
AUDFeatureUnitDescriptor3 featureRec;
|
||||
|
||||
} __attribute__ ((__packed__)) AUDDSpeakerPhoneAcDescriptors;
|
||||
|
||||
/**
|
||||
* Format type I descriptor with one discrete sampling frequency.
|
||||
*/
|
||||
typedef struct _AUDFormatTypeOneDescriptor1{
|
||||
|
||||
/** Format type I descriptor.*/
|
||||
AUDFormatTypeOneDescriptor formatType;
|
||||
/** Sampling frequency in Hz.*/
|
||||
uint8_t tSamFreq[3];
|
||||
|
||||
} __attribute__ ((__packed__)) AUDFormatTypeOneDescriptor1;
|
||||
|
||||
/**
|
||||
* Configuration descriptor list for a device implementing
|
||||
* CDC(Serial) + Audio(Speaker) composite driver.
|
||||
*/
|
||||
typedef struct _CdcAudspkdDriverConfigurationDescriptors {
|
||||
|
||||
/** Standard configuration descriptor. */
|
||||
USBConfigurationDescriptor configuration;
|
||||
|
||||
/* --- CDC 0 */
|
||||
/** IAD 0 */
|
||||
USBInterfaceAssociationDescriptor cdcIAD0;
|
||||
/** Communication interface descriptor */
|
||||
USBInterfaceDescriptor cdcCommunication0;
|
||||
/** CDC header functional descriptor. */
|
||||
CDCHeaderDescriptor cdcHeader0;
|
||||
/** CDC call management functional descriptor. */
|
||||
CDCCallManagementDescriptor cdcCallManagement0;
|
||||
/** CDC abstract control management functional descriptor. */
|
||||
CDCAbstractControlManagementDescriptor cdcAbstractControlManagement0;
|
||||
/** CDC union functional descriptor (with one slave interface). */
|
||||
CDCUnionDescriptor cdcUnion0;
|
||||
/** Notification endpoint descriptor. */
|
||||
USBEndpointDescriptor cdcNotification0;
|
||||
/** Data interface descriptor. */
|
||||
USBInterfaceDescriptor cdcData0;
|
||||
/** Data OUT endpoint descriptor. */
|
||||
USBEndpointDescriptor cdcDataOut0;
|
||||
/** Data IN endpoint descriptor. */
|
||||
USBEndpointDescriptor cdcDataIn0;
|
||||
|
||||
/* --- AUDIO (AC) */
|
||||
/** IAD 1*/
|
||||
USBInterfaceAssociationDescriptor audIAD;
|
||||
/** Audio control interface.*/
|
||||
USBInterfaceDescriptor audInterface;
|
||||
/** Descriptors for the audio control interface.*/
|
||||
AUDDSpeakerAcDescriptors audControl;
|
||||
/* -- AUDIO out (AS) */
|
||||
/** Streaming out interface descriptor (with no endpoint, required).*/
|
||||
USBInterfaceDescriptor audStreamingOutNoIsochronous;
|
||||
/** Streaming out interface descriptor.*/
|
||||
USBInterfaceDescriptor audStreamingOut;
|
||||
/** Audio class descriptor for the streaming out interface.*/
|
||||
AUDStreamingInterfaceDescriptor audStreamingOutClass;
|
||||
/** Stream format descriptor.*/
|
||||
AUDFormatTypeOneDescriptor1 audStreamingOutFormatType;
|
||||
/** Streaming out endpoint descriptor.*/
|
||||
AUDEndpointDescriptor audStreamingOutEndpoint;
|
||||
/** Audio class descriptor for the streaming out endpoint.*/
|
||||
AUDDataEndpointDescriptor audStreamingOutDataEndpoint;
|
||||
|
||||
} __attribute__ ((__packed__)) CdcAudspkdDriverConfigurationDescriptors;
|
||||
|
||||
/**
|
||||
* Configuration descriptor list for a device implementing
|
||||
* CDC(Serial) + Audio(SpeakerPhone) composite driver.
|
||||
*/
|
||||
typedef struct _CdcAuddDriverConfigurationDescriptors {
|
||||
|
||||
/** Standard configuration descriptor. */
|
||||
USBConfigurationDescriptor configuration;
|
||||
|
||||
/* --- CDC 0 */
|
||||
/** IAD 0 */
|
||||
USBInterfaceAssociationDescriptor cdcIAD0;
|
||||
/** Communication interface descriptor */
|
||||
USBInterfaceDescriptor cdcCommunication0;
|
||||
/** CDC header functional descriptor. */
|
||||
CDCHeaderDescriptor cdcHeader0;
|
||||
/** CDC call management functional descriptor. */
|
||||
CDCCallManagementDescriptor cdcCallManagement0;
|
||||
/** CDC abstract control management functional descriptor. */
|
||||
CDCAbstractControlManagementDescriptor cdcAbstractControlManagement0;
|
||||
/** CDC union functional descriptor (with one slave interface). */
|
||||
CDCUnionDescriptor cdcUnion0;
|
||||
/** Notification endpoint descriptor. */
|
||||
USBEndpointDescriptor cdcNotification0;
|
||||
/** Data interface descriptor. */
|
||||
USBInterfaceDescriptor cdcData0;
|
||||
/** Data OUT endpoint descriptor. */
|
||||
USBEndpointDescriptor cdcDataOut0;
|
||||
/** Data IN endpoint descriptor. */
|
||||
USBEndpointDescriptor cdcDataIn0;
|
||||
|
||||
/* --- AUDIO (AC) */
|
||||
/** IAD 1*/
|
||||
USBInterfaceAssociationDescriptor audIAD;
|
||||
/** Audio control interface.*/
|
||||
USBInterfaceDescriptor audInterface;
|
||||
/** Descriptors for the audio control interface.*/
|
||||
AUDDSpeakerPhoneAcDescriptors audControl;
|
||||
/* -- AUDIO out (AS) */
|
||||
/** Streaming out interface descriptor (with no endpoint, required).*/
|
||||
USBInterfaceDescriptor audStreamingOutNoIsochronous;
|
||||
/** Streaming out interface descriptor.*/
|
||||
USBInterfaceDescriptor audStreamingOut;
|
||||
/** Audio class descriptor for the streaming out interface.*/
|
||||
AUDStreamingInterfaceDescriptor audStreamingOutClass;
|
||||
/** Stream format descriptor.*/
|
||||
AUDFormatTypeOneDescriptor1 audStreamingOutFormatType;
|
||||
/** Streaming out endpoint descriptor.*/
|
||||
AUDEndpointDescriptor audStreamingOutEndpoint;
|
||||
/** Audio class descriptor for the streaming out endpoint.*/
|
||||
AUDDataEndpointDescriptor audStreamingOutDataEndpoint;
|
||||
/*- AUDIO IN */
|
||||
/** Streaming in interface descriptor (with no endpoint, required). */
|
||||
USBInterfaceDescriptor streamingInNoIsochronous;
|
||||
/** Streaming in interface descriptor. */
|
||||
USBInterfaceDescriptor streamingIn;
|
||||
/** Audio class descriptor for the streaming in interface. */
|
||||
AUDStreamingInterfaceDescriptor streamingInClass;
|
||||
/** Stream format descriptor. */
|
||||
AUDFormatTypeOneDescriptor1 streamingInFormatType;
|
||||
/** Streaming in endpoint descriptor. */
|
||||
AUDEndpointDescriptor streamingInEndpoint;
|
||||
/** Audio class descriptor for the streaming in endpoint. */
|
||||
AUDDataEndpointDescriptor streamingInDataEndpoint;
|
||||
|
||||
} __attribute__ ((__packed__)) CdcAuddDriverConfigurationDescriptors;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
extern void CDCAUDDDriver_Initialize(const USBDDriverDescriptors * pDescriptors);
|
||||
extern void CDCAUDDDriver_ConfigurationChangedHandler(uint8_t cfgnum);
|
||||
extern void CDCAUDDDriver_InterfaceSettingChangedHandler(
|
||||
uint8_t interface, uint8_t setting);
|
||||
extern void CDCAUDDDriver_RequestHandler(const USBGenericRequest *request);
|
||||
|
||||
/**@}*/
|
||||
#endif //#ifndef CDCHIDDDRIVER_H
|
||||
|
@ -0,0 +1,106 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* Single CDC Serial Port Function for USB device & composite driver.
|
||||
*/
|
||||
|
||||
#ifndef CDCDSERIAL_H
|
||||
#define CDCDSERIAL_H
|
||||
|
||||
/** \addtogroup usbd_cdc
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Headers
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/* These headers were introduced in C99
|
||||
by working group ISO/IEC JTC1/SC22/WG14. */
|
||||
#include <stdint.h>
|
||||
|
||||
#include <USBRequests.h>
|
||||
|
||||
#include <USBDDriver.h>
|
||||
#include <CDCDSerialPort.h>
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Types
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
extern void CDCDSerial_Initialize(
|
||||
USBDDriver * pUsbd, uint8_t bInterfaceNb);
|
||||
|
||||
extern uint32_t CDCDSerial_RequestHandler(
|
||||
const USBGenericRequest *request);
|
||||
|
||||
extern void CDCDSerial_ConfigureFunction(
|
||||
USBGenericDescriptor * pDescriptors, uint16_t wLength);
|
||||
|
||||
extern uint32_t CDCDSerial_Write(
|
||||
void *data,
|
||||
uint32_t size,
|
||||
TransferCallback callback,
|
||||
void *argument);
|
||||
|
||||
extern uint32_t CDCDSerial_Read(
|
||||
void *data,
|
||||
uint32_t size,
|
||||
TransferCallback callback,
|
||||
void *argument);
|
||||
|
||||
extern void CDCDSerial_GetLineCoding(CDCLineCoding * pLineCoding);
|
||||
|
||||
extern uint8_t CDCDSerial_GetControlLineState(void);
|
||||
|
||||
extern uint16_t CDCDSerial_GetSerialState(void);
|
||||
|
||||
extern void CDCDSerial_SetSerialState(uint16_t serialState);
|
||||
|
||||
extern uint8_t CDCDSerial_LineCodingIsToChange(
|
||||
CDCLineCoding * pLineCoding);
|
||||
|
||||
extern void CDCDSerial_ControlLineStateChanged(
|
||||
uint8_t DTR,uint8_t RTS);
|
||||
|
||||
/**@}*/
|
||||
|
||||
#endif /*#ifndef CDCSERIAL_H*/
|
||||
|
@ -0,0 +1,249 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \section Purpose
|
||||
*
|
||||
* Definition of a class for implementing a USB device CDC serial driver.
|
||||
*
|
||||
* \section Usage
|
||||
*
|
||||
* -# Re-implement the USBDCallbacks_RequestReceived method to pass
|
||||
* received requests to CDCDSerialDriver_RequestHandler. *This is
|
||||
* automatically done unless the NOAUTOCALLBACK symbol is defined*.
|
||||
* -# Initialize the CDC serial and USB drivers using
|
||||
* CDCDSerialDriver_Initialize.
|
||||
* -# Logically connect the device to the host using USBD_Connect.
|
||||
* -# Send serial data to the USB host using CDCDSerialDriver_Write.
|
||||
* -# Receive serial data from the USB host using CDCDSerialDriver_Read.
|
||||
*/
|
||||
|
||||
#ifndef CDCDSERIALDRIVER_H
|
||||
#define CDCDSERIALDRIVER_H
|
||||
|
||||
/** \addtogroup usbd_cdc
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Headers
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/* These headers were introduced in C99
|
||||
by working group ISO/IEC JTC1/SC22/WG14. */
|
||||
#include <stdint.h>
|
||||
|
||||
#include <USBRequests.h>
|
||||
#include <CDCRequests.h>
|
||||
#include <CDCDescriptors.h>
|
||||
#include <CDCNotifications.h>
|
||||
|
||||
#include <CDCDSerial.h>
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/** \addtogroup usbd_cdc_if USB Device CDC Serial Interface IDs
|
||||
* @{
|
||||
*/
|
||||
/** Communication Class Interface ID */
|
||||
#define CDCDSerialDriver_CC_INTERFACE 0
|
||||
/** Data Class Interface ID */
|
||||
#define CDCDSerialDriver_DC_INTERFACE 1
|
||||
/** @}*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Types
|
||||
*------------------------------------------------------------------------------*/
|
||||
#pragma pack(1)
|
||||
#if defined ( __CC_ARM ) /* Keil ¦ÌVision 4 */
|
||||
#elif defined ( __ICCARM__ ) /* IAR Ewarm */
|
||||
#define __attribute__(...)
|
||||
#define __packed__ packed
|
||||
#elif defined ( __GNUC__ ) /* GCC CS3 */
|
||||
#define __packed__ aligned(1)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \typedef CDCDSerialDriverConfigurationDescriptors
|
||||
* \brief Configuration descriptor list for a device implementing a
|
||||
* CDC serial driver.
|
||||
*/
|
||||
typedef struct _CDCDSerialDriverConfigurationDescriptors {
|
||||
|
||||
/** Standard configuration descriptor. */
|
||||
USBConfigurationDescriptor configuration;
|
||||
/** Communication interface descriptor. */
|
||||
USBInterfaceDescriptor communication;
|
||||
/** CDC header functional descriptor. */
|
||||
CDCHeaderDescriptor header;
|
||||
/** CDC call management functional descriptor. */
|
||||
CDCCallManagementDescriptor callManagement;
|
||||
/** CDC abstract control management functional descriptor. */
|
||||
CDCAbstractControlManagementDescriptor abstractControlManagement;
|
||||
/** CDC union functional descriptor (with one slave interface). */
|
||||
CDCUnionDescriptor union1;
|
||||
/** Notification endpoint descriptor. */
|
||||
USBEndpointDescriptor notification;
|
||||
/** Data interface descriptor. */
|
||||
USBInterfaceDescriptor data;
|
||||
/** Data OUT endpoint descriptor. */
|
||||
USBEndpointDescriptor dataOut;
|
||||
/** Data IN endpoint descriptor. */
|
||||
USBEndpointDescriptor dataIn;
|
||||
|
||||
} __attribute__ ((__packed__)) CDCDSerialDriverConfigurationDescriptors;
|
||||
|
||||
/**
|
||||
* \typedef CDCDSerialDriverConfigurationDescriptorsOTG
|
||||
* \brief Configuration descriptor list for a device implementing a
|
||||
* CDC serial OTG driver.
|
||||
*/
|
||||
typedef struct _CDCDSerialDriverConfigurationDescriptorsOTG {
|
||||
|
||||
/** Standard configuration descriptor. */
|
||||
USBConfigurationDescriptor configuration;
|
||||
/* OTG descriptor */
|
||||
USBOtgDescriptor otgDescriptor;
|
||||
/** Communication interface descriptor. */
|
||||
USBInterfaceDescriptor communication;
|
||||
/** CDC header functional descriptor. */
|
||||
CDCHeaderDescriptor header;
|
||||
/** CDC call management functional descriptor. */
|
||||
CDCCallManagementDescriptor callManagement;
|
||||
/** CDC abstract control management functional descriptor. */
|
||||
CDCAbstractControlManagementDescriptor abstractControlManagement;
|
||||
/** CDC union functional descriptor (with one slave interface). */
|
||||
CDCUnionDescriptor union1;
|
||||
/** Notification endpoint descriptor. */
|
||||
USBEndpointDescriptor notification;
|
||||
/** Data interface descriptor. */
|
||||
USBInterfaceDescriptor data;
|
||||
/** Data OUT endpoint descriptor. */
|
||||
USBEndpointDescriptor dataOut;
|
||||
/** Data IN endpoint descriptor. */
|
||||
USBEndpointDescriptor dataIn;
|
||||
|
||||
} __attribute__ ((__packed__)) CDCDSerialDriverConfigurationDescriptorsOTG;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
extern void CDCDSerialDriver_Initialize(
|
||||
const USBDDriverDescriptors *pDescriptors);
|
||||
|
||||
extern void CDCDSerialDriver_ConfigurationChangedHandler(uint8_t cfgnum);
|
||||
|
||||
extern void CDCDSerialDriver_RequestHandler(
|
||||
const USBGenericRequest *request);
|
||||
|
||||
/**
|
||||
* Sends a data buffer through the virtual COM port created by the CDC
|
||||
* device serial driver. This function behaves exactly like USBD_Write.
|
||||
* \param data Pointer to the data buffer to send.
|
||||
* \param size Size of the data buffer in bytes.
|
||||
* \param callback Optional callback function to invoke when the transfer
|
||||
* finishes.
|
||||
* \param argument Optional argument to the callback function.
|
||||
* \return USBD_STATUS_SUCCESS if the read operation has been started normally;
|
||||
* otherwise, the corresponding error code.
|
||||
*/
|
||||
static inline uint32_t CDCDSerialDriver_Write(
|
||||
void *data,
|
||||
uint32_t size,
|
||||
TransferCallback callback,
|
||||
void *argument)
|
||||
{
|
||||
return CDCDSerial_Write(data, size, callback, argument);
|
||||
}
|
||||
|
||||
/**
|
||||
* Receives data from the host through the virtual COM port created by
|
||||
* the CDC device serial driver. This function behaves like USBD_Read.
|
||||
* \param data Pointer to the data buffer to put received data.
|
||||
* \param size Size of the data buffer in bytes.
|
||||
* \param callback Optional callback function to invoke when the transfer
|
||||
* finishes.
|
||||
* \param argument Optional argument to the callback function.
|
||||
* \return USBD_STATUS_SUCCESS if the read operation has been started normally;
|
||||
* otherwise, the corresponding error code.
|
||||
*/
|
||||
static inline uint32_t CDCDSerialDriver_Read(
|
||||
void *data,
|
||||
uint32_t size,
|
||||
TransferCallback callback,
|
||||
void *argument)
|
||||
{
|
||||
return CDCDSerial_Read(data, size, callback, argument);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy current line coding settings to pointered space.
|
||||
* \param pLineCoding Pointer to CDCLineCoding instance.
|
||||
*/
|
||||
static inline void CDCDSerialDriver_GetLineCoding(CDCLineCoding * pLineCoding)
|
||||
{
|
||||
CDCDSerial_GetLineCoding(pLineCoding);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current control line state of the RS-232 line.
|
||||
*/
|
||||
static inline uint8_t CDCDSerialDriver_GetControlLineState(void)
|
||||
{
|
||||
return CDCDSerial_GetControlLineState();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current status of the RS-232 line.
|
||||
*/
|
||||
static inline uint16_t CDCDSerialDriver_GetSerialState(void)
|
||||
{
|
||||
return CDCDSerial_GetSerialState();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current serial state of the device to the given value.
|
||||
* \param serialState New device state.
|
||||
*/
|
||||
static inline void CDCDSerialDriver_SetSerialState(uint16_t serialState)
|
||||
{
|
||||
CDCDSerial_SetSerialState(serialState);
|
||||
}
|
||||
|
||||
/**@}*/
|
||||
|
||||
#endif /*#ifndef CDCSERIALDRIVER_H*/
|
||||
|
@ -0,0 +1,167 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* 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:
|
||||
*
|
||||
* - 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* Definition of a class for implementing a USB device
|
||||
* CDC serial port function.
|
||||
*/
|
||||
|
||||
#ifndef _CDCDSERIALPORT_H_
|
||||
#define _CDCDSERIALPORT_H_
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Headers
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/* These headers were introduced in C99
|
||||
by working group ISO/IEC JTC1/SC22/WG14. */
|
||||
#include <stdint.h>
|
||||
|
||||
#include <USBRequests.h>
|
||||
#include <CDCRequests.h>
|
||||
#include <CDCNotifications.h>
|
||||
#include "USBD.h"
|
||||
#include <USBDDriver.h>
|
||||
/** \addtogroup usbd_cdc
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Defines
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/** \addtogroup usbd_cdc_serial_desc USB Device Serial Port Descriptor Values
|
||||
* @{
|
||||
*/
|
||||
/** Default CDC interrupt endpoints max packat size (8). */
|
||||
#define CDCDSerialPort_INTERRUPT_MAXPACKETSIZE 8
|
||||
/** Default CDC interrupt endpoint polling rate of High Speed (16ms). */
|
||||
#define CDCDSerialPort_INTERRUPT_INTERVAL_HS 8
|
||||
/** Default CDC interrupt endpoint polling rate of Full Speed (16ms). */
|
||||
#define CDCDSerialPort_INTERRUPT_INTERVAL_FS 16
|
||||
/** Default CDC bulk endpoints max packat size (512, for HS actually). */
|
||||
#define CDCDSerialPort_BULK_MAXPACKETSIZE_HS 512
|
||||
/** Default CDC bulk endpoints max packat size (64, for FS actually). */
|
||||
#define CDCDSerialPort_BULK_MAXPACKETSIZE_FS 64
|
||||
/** @}*/
|
||||
|
||||
/** \addtogroup usbd_cdc_serial_events USB Device Serial Port Events
|
||||
* @{
|
||||
*/
|
||||
/** SetControlLineState event, value is changed */
|
||||
#define CDCDSerialPortEvent_SETCONTROLLINESTATE 0
|
||||
/** SetLineCoding event, value is to changed according to return value */
|
||||
#define CDCDSerialPortEvent_SETLINECODING 1
|
||||
/** @}*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Types
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/** Callback function for serial port events */
|
||||
typedef uint32_t (*CDCDSerialPortEventHandler)(uint32_t dwEvent,
|
||||
uint32_t dwParam,
|
||||
void * pArguments);
|
||||
|
||||
/**
|
||||
* Struct for USB CDC virtual COM serial port function.
|
||||
*/
|
||||
typedef struct _CDCDSerialPort {
|
||||
/** USB Driver for the %device */
|
||||
USBDDriver *pUsbd;
|
||||
/** Callback for serial port events */
|
||||
CDCDSerialPortEventHandler fEventHandler;
|
||||
/** Callback arguments */
|
||||
void *pArg;
|
||||
/** USB starting interface index */
|
||||
uint8_t bInterfaceNdx;
|
||||
/** USB number of interfaces */
|
||||
uint8_t bNumInterface;
|
||||
/** USB interrupt IN endpoint address */
|
||||
uint8_t bIntInPIPE;
|
||||
/** USB bulk IN endpoint address */
|
||||
uint8_t bBulkInPIPE;
|
||||
/** USB bulk OUT endpoint address */
|
||||
uint8_t bBulkOutPIPE;
|
||||
|
||||
/** Serial port ControlLineState */
|
||||
uint8_t bControlLineState;
|
||||
/** Serial port SerialState */
|
||||
uint16_t wSerialState;
|
||||
/** Serial port linecoding */
|
||||
CDCLineCoding lineCoding;
|
||||
|
||||
uint8_t bReserved;
|
||||
} CDCDSerialPort;
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Functions
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
extern void CDCDSerialPort_Initialize(CDCDSerialPort *pCdcd,
|
||||
USBDDriver *pUsbd,
|
||||
CDCDSerialPortEventHandler fCallback,
|
||||
void *pArg,
|
||||
uint8_t firstInterface,
|
||||
uint8_t numInterface);
|
||||
|
||||
extern USBGenericDescriptor * CDCDSerialPort_ParseInterfaces(
|
||||
CDCDSerialPort * pCdcd,
|
||||
USBGenericDescriptor * pDescriptors, uint32_t dwLength);
|
||||
|
||||
extern uint32_t CDCDSerialPort_RequestHandler(
|
||||
CDCDSerialPort *pCdcd,
|
||||
const USBGenericRequest *pRequest);
|
||||
|
||||
extern uint32_t CDCDSerialPort_Write(
|
||||
const CDCDSerialPort *pCdcd,
|
||||
void *pData, uint32_t dwSize,
|
||||
TransferCallback fCallback, void* pArg);
|
||||
|
||||
extern uint32_t CDCDSerialPort_Read(
|
||||
const CDCDSerialPort *pCdcd,
|
||||
void *pData, uint32_t dwSize,
|
||||
TransferCallback fCallback, void* pArg);
|
||||
|
||||
extern uint16_t CDCDSerialPort_GetSerialState(
|
||||
const CDCDSerialPort *pCdcd);
|
||||
|
||||
extern void CDCDSerialPort_SetSerialState(
|
||||
CDCDSerialPort *pCdcd,
|
||||
uint16_t wSerialState);
|
||||
|
||||
extern uint8_t CDCDSerialPort_GetControlLineState(
|
||||
const CDCDSerialPort * pCdcd);
|
||||
|
||||
extern void CDCDSerialPort_GetLineCoding(
|
||||
const CDCDSerialPort * pCdcd,
|
||||
CDCLineCoding * pLineCoding);
|
||||
|
||||
/**@}*/
|
||||
#endif /* #ifndef _CDCDSERIALPORT_H_ */
|
@ -0,0 +1,275 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* 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:
|
||||
*
|
||||
* - 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Definitions and classes for USB CDC class descriptors.
|
||||
*/
|
||||
|
||||
#ifndef _CDCDESCRIPTORS_H_
|
||||
#define _CDCDESCRIPTORS_H_
|
||||
/** \addtogroup usb_cdc
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Includes
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/** \addtogroup usb_cdc_ver USB CDC Specification Release Numbers
|
||||
* @{
|
||||
* This section list the CDC Spec. Release Numbers.
|
||||
* - \ref CDCGenericDescriptor_CDC1_10
|
||||
*/
|
||||
|
||||
/** Identify CDC specification version 1.10. */
|
||||
#define CDCGenericDescriptor_CDC1_10 0x0110
|
||||
/** @}*/
|
||||
|
||||
/** \addtogroup usb_cdc_desc_type CDC Descriptro Types
|
||||
* @{
|
||||
* This section lists CDC descriptor types.
|
||||
* - \ref CDCGenericDescriptor_INTERFACE
|
||||
* - \ref CDCGenericDescriptor_ENDPOINT
|
||||
*/
|
||||
/**Indicates that a CDC descriptor applies to an interface. */
|
||||
#define CDCGenericDescriptor_INTERFACE 0x24
|
||||
/** Indicates that a CDC descriptor applies to an endpoint. */
|
||||
#define CDCGenericDescriptor_ENDPOINT 0x25
|
||||
/** @}*/
|
||||
|
||||
/** \addtogroup usb_cdc_desc_subtype CDC Descriptor Subtypes
|
||||
* @{
|
||||
* This section lists CDC descriptor sub types
|
||||
* - \ref CDCGenericDescriptor_HEADER
|
||||
* - \ref CDCGenericDescriptor_CALLMANAGEMENT
|
||||
* - \ref CDCGenericDescriptor_ABSTRACTCONTROLMANAGEMENT
|
||||
* - \ref CDCGenericDescriptor_UNION
|
||||
*/
|
||||
|
||||
/** Header functional descriptor subtype. */
|
||||
#define CDCGenericDescriptor_HEADER 0x00
|
||||
/** Call management functional descriptor subtype. */
|
||||
#define CDCGenericDescriptor_CALLMANAGEMENT 0x01
|
||||
/** Abstract control management descriptor subtype. */
|
||||
#define CDCGenericDescriptor_ABSTRACTCONTROLMANAGEMENT 0x02
|
||||
/** Union descriptor subtype. */
|
||||
#define CDCGenericDescriptor_UNION 0x06
|
||||
/** @}*/
|
||||
|
||||
/** \addtogroup usb_cdc_descriptor USB CDC Device Descriptor Values
|
||||
* @{
|
||||
* This section lists the values for CDC Device Descriptor.
|
||||
* - \ref CDCDeviceDescriptor_CLASS
|
||||
* - \ref CDCDeviceDescriptor_SUBCLASS
|
||||
* - \ref CDCDeviceDescriptor_PROTOCOL
|
||||
*/
|
||||
/** Device class code when using the CDC class. */
|
||||
#define CDCDeviceDescriptor_CLASS 0x02
|
||||
/** Device subclass code when using the CDC class. */
|
||||
#define CDCDeviceDescriptor_SUBCLASS 0x00
|
||||
/** Device protocol code when using the CDC class. */
|
||||
#define CDCDeviceDescriptor_PROTOCOL 0x00
|
||||
/** @}*/
|
||||
|
||||
/** \addtogroup usb_cdc_if_desc USB CDC Communication Interface Descriptor
|
||||
* @{
|
||||
* This section lists the values for CDC Communication Interface Descriptor.
|
||||
* - \ref CDCCommunicationInterfaceDescriptor_CLASS
|
||||
* - \ref CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL
|
||||
* - \ref CDCCommunicationInterfaceDescriptor_NOPROTOCOL
|
||||
*/
|
||||
/** Interface class code for a CDC communication class interface. */
|
||||
#define CDCCommunicationInterfaceDescriptor_CLASS 0x02
|
||||
/** Interface subclass code for an Abstract Control Model interface descriptor.
|
||||
*/
|
||||
#define CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL 0x02
|
||||
/** Interface protocol code when a CDC communication interface does not
|
||||
implemenent any particular protocol. */
|
||||
#define CDCCommunicationInterfaceDescriptor_NOPROTOCOL 0x00
|
||||
/** @}*/
|
||||
|
||||
/** \addtogroup usb_cdc_data_if USB CDC Data Interface Values
|
||||
* @{
|
||||
* This section lists the values for CDC Data Interface Descriptor.
|
||||
* - \ref CDCDataInterfaceDescriptor_CLASS
|
||||
* - \ref CDCDataInterfaceDescriptor_SUBCLASS
|
||||
* - \ref CDCDataInterfaceDescriptor_NOPROTOCOL
|
||||
*/
|
||||
|
||||
/** Interface class code for a data class interface. */
|
||||
#define CDCDataInterfaceDescriptor_CLASS 0x0A
|
||||
/** Interface subclass code for a data class interface. */
|
||||
#define CDCDataInterfaceDescriptor_SUBCLASS 0x00
|
||||
/** Protocol code for a data class interface which does not implement any
|
||||
particular protocol. */
|
||||
#define CDCDataInterfaceDescriptor_NOPROTOCOL 0x00
|
||||
/** @}*/
|
||||
|
||||
/** \addtogroup usb_cdc_cb_man_desc USB CDC CallManagement Capabilities
|
||||
* @{
|
||||
* This section lists CDC CallManagement Capabilities.
|
||||
* - \ref CDCCallManagementDescriptor_SELFCALLMANAGEMENT
|
||||
* - \ref CDCCallManagementDescriptor_DATACALLMANAGEMENT
|
||||
*/
|
||||
/** Device handles call management itself. */
|
||||
#define CDCCallManagementDescriptor_SELFCALLMANAGEMENT (1 << 0)
|
||||
/** Device can exchange call management information over a Data class interface.
|
||||
*/
|
||||
#define CDCCallManagementDescriptor_DATACALLMANAGEMENT (1 << 1)
|
||||
/** @}*/
|
||||
|
||||
/** \addtogroup usb_cdc_acm USB CDC ACM Capabilities
|
||||
* @{
|
||||
*
|
||||
* This section lists the capabilities of the CDC ACM.
|
||||
* - \ref CDCAbstractControlManagementDescriptor_COMMFEATURE
|
||||
* - \ref CDCAbstractControlManagementDescriptor_LINE
|
||||
* - \ref CDCAbstractControlManagementDescriptor_SENDBREAK
|
||||
* - \ref CDCAbstractControlManagementDescriptor_NETWORKCONNECTION
|
||||
*/
|
||||
|
||||
/** Device supports the request combination of SetCommFeature, ClearCommFeature
|
||||
and GetCommFeature. */
|
||||
#define CDCAbstractControlManagementDescriptor_COMMFEATURE (1 << 0)
|
||||
/** Device supports the request combination of SetLineCoding, GetLineCoding and
|
||||
SetControlLineState. */
|
||||
#define CDCAbstractControlManagementDescriptor_LINE (1 << 1)
|
||||
/** Device supports the SendBreak request. */
|
||||
#define CDCAbstractControlManagementDescriptor_SENDBREAK (1 << 2)
|
||||
/** Device supports the NetworkConnection notification. */
|
||||
#define CDCAbstractControlManagementDescriptor_NETWORKCONNECTION (1 << 3)
|
||||
/** @}*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Types
|
||||
*----------------------------------------------------------------------------*/
|
||||
#pragma pack(1)
|
||||
#if defined ( __CC_ARM ) /* Keil ¦ÌVision 4 */
|
||||
#elif defined ( __ICCARM__ ) /* IAR Ewarm */
|
||||
#define __attribute__(...)
|
||||
#define __packed__ packed
|
||||
#elif defined ( __GNUC__ ) /* GCC CS3 */
|
||||
#define __packed__ aligned(1)
|
||||
#endif
|
||||
/**
|
||||
* \typedef CDCHeaderDescriptor
|
||||
* \brief Marks the beginning of the concatenated set of functional descriptors
|
||||
* for the interface.
|
||||
*/
|
||||
typedef struct _CDCHeaderDescriptor {
|
||||
|
||||
/** Size of this descriptor in bytes. */
|
||||
uint8_t bFunctionLength;
|
||||
/** Descriptor type . */
|
||||
uint8_t bDescriptorType;
|
||||
/** Descriptor sub-type . */
|
||||
uint8_t bDescriptorSubtype;
|
||||
/** USB CDC specification release number. */
|
||||
uint16_t bcdCDC;
|
||||
|
||||
} __attribute__ ((__packed__)) CDCHeaderDescriptor; /* GCC */
|
||||
|
||||
/**
|
||||
* \typedef CDCUnionDescriptor
|
||||
* \brief Describes the relationship between a group of interfaces that can
|
||||
* be considered to form a functional unit.
|
||||
*/
|
||||
typedef struct _CDCUnionDescriptor {
|
||||
|
||||
/** Size of the descriptor in bytes. */
|
||||
uint8_t bFunctionLength;
|
||||
/** Descriptor type . */
|
||||
uint8_t bDescriptorType;
|
||||
/** Descriptor subtype . */
|
||||
uint8_t bDescriptorSubtype;
|
||||
/** Number of the master interface for this union. */
|
||||
uint8_t bMasterInterface;
|
||||
/** Number of the first slave interface for this union. */
|
||||
uint8_t bSlaveInterface0;
|
||||
|
||||
} __attribute__ ((__packed__)) CDCUnionDescriptor; /* GCC */
|
||||
|
||||
/**
|
||||
* \typedef CDCCallManagementDescriptor
|
||||
* \brief Describes the processing of calls for the communication class
|
||||
* interface.
|
||||
*/
|
||||
typedef struct _CDCCallManagementDescriptor {
|
||||
|
||||
/** Size of this descriptor in bytes. */
|
||||
uint8_t bFunctionLength;
|
||||
/** Descriptor type . */
|
||||
uint8_t bDescriptorType;
|
||||
/** Descriptor sub-type . */
|
||||
uint8_t bDescriptorSubtype;
|
||||
/** Configuration capabilities
|
||||
\sa usb_cdc_cb_man_desc CDC CallManagement Capabilities. */
|
||||
uint8_t bmCapabilities;
|
||||
/** Interface number of the data class interface used for call management
|
||||
(optional). */
|
||||
uint8_t bDataInterface;
|
||||
|
||||
} __attribute__ ((__packed__)) CDCCallManagementDescriptor; /* GCC */
|
||||
|
||||
/**
|
||||
* \typedef CDCAbstractControlManagementDescriptor
|
||||
* \brief Describes the command supported by the communication interface class
|
||||
* with the Abstract Control Model subclass code.
|
||||
*/
|
||||
typedef struct _CDCAbstractControlManagementDescriptor {
|
||||
|
||||
/** Size of this descriptor in bytes. */
|
||||
uint8_t bFunctionLength;
|
||||
/** Descriptor type . */
|
||||
uint8_t bDescriptorType;
|
||||
/** Descriptor subtype . */
|
||||
uint8_t bDescriptorSubtype;
|
||||
/** Configuration capabilities.
|
||||
\sa usb_cdc_acm CDC ACM Capabilities. */
|
||||
uint8_t bmCapabilities;
|
||||
|
||||
} __attribute__ ((__packed__)) CDCAbstractControlManagementDescriptor; /* GCC */
|
||||
|
||||
#pragma pack()
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/**@}*/
|
||||
#endif /* #ifndef _CDCDESCRIPTORS_H_ */
|
||||
|
@ -0,0 +1,152 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \section Purpose
|
||||
*
|
||||
* Definitions and methods for USB composite device implement.
|
||||
*
|
||||
* \section Usage
|
||||
*
|
||||
* -# Initialize USB function specified driver ( for MSD currently )
|
||||
* - MSDDFunctionDriver_Initialize()
|
||||
*
|
||||
* -# Initialize USB composite driver and USB driver
|
||||
* - CDCHIDDDriver_Initialize()
|
||||
*
|
||||
* -# Handle and dispach USB requests
|
||||
* - CDCHIDDDriver_RequestHandler()
|
||||
*
|
||||
* -# Try starting a remote wake-up sequence
|
||||
* - CDCHIDDDriver_RemoteWakeUp()
|
||||
*/
|
||||
|
||||
#ifndef CDCHIDDDRIVER_H
|
||||
#define CDCHIDDDRIVER_H
|
||||
/** \addtogroup usbd_composite_cdchid
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Headers
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <USBRequests.h>
|
||||
#include <CDCDescriptors.h>
|
||||
#include <HIDDescriptors.h>
|
||||
#include "USBD.h"
|
||||
#include <USBDDriver.h>
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/** \addtogroup usbd_cdc_hid_desc USB CDC(Serial) + HID(Kbd) Descriptors define
|
||||
* @{
|
||||
*/
|
||||
/** Number of interfaces of the device */
|
||||
#define CDCHIDDDriverDescriptors_NUMINTERFACE 3
|
||||
/** Number of the CDC interface. */
|
||||
#define CDCHIDDDriverDescriptors_CDC_INTERFACE 0
|
||||
/** Number of the HID interface. */
|
||||
#define CDCHIDDDriverDescriptors_HID_INTERFACE 2
|
||||
/** @}*/
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Types
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma pack(1)
|
||||
#if defined ( __CC_ARM ) /* Keil ¦ÌVision 4 */
|
||||
#elif defined ( __ICCARM__ ) /* IAR Ewarm */
|
||||
#define __attribute__(...)
|
||||
#define __packed__ packed
|
||||
#elif defined ( __GNUC__ ) /* GCC CS3 */
|
||||
#define __packed__ aligned(1)
|
||||
#endif
|
||||
/**
|
||||
* \typedef CdcHidDriverConfigurationDescriptors
|
||||
* \brief Configuration descriptor list for a device implementing a
|
||||
* composite driver.
|
||||
*/
|
||||
typedef struct _CdcHidDriverConfigurationDescriptors {
|
||||
|
||||
/** Standard configuration descriptor. */
|
||||
USBConfigurationDescriptor configuration;
|
||||
|
||||
/* --- CDC 0 */
|
||||
/** IAD 0 */
|
||||
USBInterfaceAssociationDescriptor cdcIAD0;
|
||||
/** Communication interface descriptor */
|
||||
USBInterfaceDescriptor cdcCommunication0;
|
||||
/** CDC header functional descriptor. */
|
||||
CDCHeaderDescriptor cdcHeader0;
|
||||
/** CDC call management functional descriptor. */
|
||||
CDCCallManagementDescriptor cdcCallManagement0;
|
||||
/** CDC abstract control management functional descriptor. */
|
||||
CDCAbstractControlManagementDescriptor cdcAbstractControlManagement0;
|
||||
/** CDC union functional descriptor (with one slave interface). */
|
||||
CDCUnionDescriptor cdcUnion0;
|
||||
/** Notification endpoint descriptor. */
|
||||
USBEndpointDescriptor cdcNotification0;
|
||||
/** Data interface descriptor. */
|
||||
USBInterfaceDescriptor cdcData0;
|
||||
/** Data OUT endpoint descriptor. */
|
||||
USBEndpointDescriptor cdcDataOut0;
|
||||
/** Data IN endpoint descriptor. */
|
||||
USBEndpointDescriptor cdcDataIn0;
|
||||
|
||||
/* --- HID */
|
||||
USBInterfaceDescriptor hidInterface;
|
||||
HIDDescriptor1 hid;
|
||||
USBEndpointDescriptor hidInterruptIn;
|
||||
USBEndpointDescriptor hidInterruptOut;
|
||||
|
||||
} __attribute__ ((__packed__)) CdcHidDriverConfigurationDescriptors;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/* -CDCHID */
|
||||
extern void CDCHIDDDriver_Initialize(
|
||||
const USBDDriverDescriptors * pDescriptors);
|
||||
|
||||
extern void CDCHIDDDriver_ConfigurationChangedHandler(uint8_t cfgnum);
|
||||
|
||||
extern void CDCHIDDDriver_RequestHandler(const USBGenericRequest *request);
|
||||
|
||||
extern void CDCHIDDDriver_RemoteWakeUp(void);
|
||||
|
||||
/**@}*/
|
||||
#endif //#ifndef CDCHIDDDRIVER_H
|
||||
|
@ -0,0 +1,155 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \section Purpose
|
||||
*
|
||||
* Definitions and methods for USB CDCMSD device implement.
|
||||
*
|
||||
* \section Usage
|
||||
*
|
||||
* -# Initialize USB function specified driver ( for MSD currently )
|
||||
* - MSDDFunctionDriver_Initialize
|
||||
*
|
||||
* -# Initialize USB CDCMSD driver and USB driver
|
||||
* - CDCMSDDDriver_Initialize
|
||||
*
|
||||
* -# Handle and dispach USB requests
|
||||
* - CDCMSDDDriver_RequestHandler
|
||||
*
|
||||
* -# Try starting a remote wake-up sequence
|
||||
* - CDCMSDDDriver_RemoteWakeUp
|
||||
*/
|
||||
|
||||
#ifndef CDCMSDDDRIVER_H
|
||||
#define CDCMSDDDRIVER_H
|
||||
/** \addtogroup usbd_composite_cdcmsd
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Headers
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <USBRequests.h>
|
||||
#include <CDCDescriptors.h>
|
||||
#include <MSDescriptors.h>
|
||||
#include <MSDLun.h>
|
||||
#include "USBD.h"
|
||||
#include <USBDDriver.h>
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Consts
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/** \addtogroup usbd_cdc_msd_desc USB CDC(Serial) + MS Descriptors define
|
||||
* @{
|
||||
*/
|
||||
/** Number of interfaces of the device */
|
||||
#define CDCMSDDriverDescriptors_NUMINTERFACE 3
|
||||
/** Number of the CDC interface. */
|
||||
#define CDCMSDDriverDescriptors_CDC_INTERFACE 0
|
||||
/** Number of the HID interface. */
|
||||
#define CDCMSDDriverDescriptors_MSD_INTERFACE 2
|
||||
/** @}*/
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Types
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma pack(1)
|
||||
#if defined ( __CC_ARM ) /* Keil ¦ÌVision 4 */
|
||||
#elif defined ( __ICCARM__ ) /* IAR Ewarm */
|
||||
#define __attribute__(...)
|
||||
#define __packed__ packed
|
||||
#elif defined ( __GNUC__ ) /* GCC CS3 */
|
||||
#define __packed__ aligned(1)
|
||||
#endif
|
||||
/**
|
||||
* \typedef CDCMSDDriverConfigurationDescriptors
|
||||
* \brief Configuration descriptor list for a device implementing
|
||||
* a CDCMSD driver.
|
||||
*/
|
||||
typedef struct _CDCMSDDriverConfigurationDescriptors {
|
||||
|
||||
/** Standard configuration descriptor. */
|
||||
USBConfigurationDescriptor configuration;
|
||||
|
||||
/* --- CDC 0 */
|
||||
/** IAD 0 */
|
||||
USBInterfaceAssociationDescriptor cdcIAD0;
|
||||
/** Communication interface descriptor */
|
||||
USBInterfaceDescriptor cdcCommunication0;
|
||||
/** CDC header functional descriptor. */
|
||||
CDCHeaderDescriptor cdcHeader0;
|
||||
/** CDC call management functional descriptor. */
|
||||
CDCCallManagementDescriptor cdcCallManagement0;
|
||||
/** CDC abstract control management functional descriptor. */
|
||||
CDCAbstractControlManagementDescriptor cdcAbstractControlManagement0;
|
||||
/** CDC union functional descriptor (with one slave interface). */
|
||||
CDCUnionDescriptor cdcUnion0;
|
||||
/** Notification endpoint descriptor. */
|
||||
USBEndpointDescriptor cdcNotification0;
|
||||
/** Data interface descriptor. */
|
||||
USBInterfaceDescriptor cdcData0;
|
||||
/** Data OUT endpoint descriptor. */
|
||||
USBEndpointDescriptor cdcDataOut0;
|
||||
/** Data IN endpoint descriptor. */
|
||||
USBEndpointDescriptor cdcDataIn0;
|
||||
|
||||
/* --- MSD */
|
||||
/** Mass storage interface descriptor. */
|
||||
USBInterfaceDescriptor msdInterface;
|
||||
/** Bulk-out endpoint descriptor. */
|
||||
USBEndpointDescriptor msdBulkOut;
|
||||
/** Bulk-in endpoint descriptor. */
|
||||
USBEndpointDescriptor msdBulkIn;
|
||||
|
||||
} __attribute__ ((__packed__)) CDCMSDDriverConfigurationDescriptors;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/* -CDCMSD */
|
||||
extern void CDCMSDDriver_Initialize(
|
||||
const USBDDriverDescriptors *pDescriptors,
|
||||
MSDLun *pLuns, unsigned char numLuns);
|
||||
|
||||
extern void CDCMSDDriver_ConfigurationChangedHandler(unsigned char cfgnum);
|
||||
|
||||
extern void CDCMSDDriver_RequestHandler(const USBGenericRequest *request);
|
||||
|
||||
/**@}*/
|
||||
#endif /* #ifndef CDCMSDDDRIVER_H */
|
||||
|
@ -0,0 +1,111 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* 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:
|
||||
*
|
||||
* - 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* Definitions and methods for USB CDC Notifications.
|
||||
*/
|
||||
|
||||
#ifndef _CDCNOTIFICATIONS_H_
|
||||
#define _CDCNOTIFICATIONS_H_
|
||||
/** \addtogroup usb_cdc
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Includes
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/** \addtogroup cdc_serial_states CDC SerialState bits
|
||||
* @{
|
||||
* This page lists the bit map for CDC Serial States.
|
||||
*
|
||||
* - \ref CDCSerialState_RXDRIVER
|
||||
* - \ref CDCSerialState_TXCARRIER
|
||||
* - \ref CDCSerialState_BREAK
|
||||
* - \ref CDCSerialState_RINGSIGNAL
|
||||
* - \ref CDCSerialState_FRAMING
|
||||
* - \ref CDCSerialState_PARITY
|
||||
* - \ref CDCSerialState_OVERRUN
|
||||
*/
|
||||
|
||||
/** Indicates the receiver carrier signal is present */
|
||||
#define CDCSerialState_RXDRIVER (1 << 0)
|
||||
/** Indicates the transmission carrier signal is present */
|
||||
#define CDCSerialState_TXCARRIER (1 << 1)
|
||||
/** Indicates a break has been detected */
|
||||
#define CDCSerialState_BREAK (1 << 2)
|
||||
/** Indicates a ring signal has been detected */
|
||||
#define CDCSerialState_RINGSIGNAL (1 << 3)
|
||||
/** Indicates a framing error has occured */
|
||||
#define CDCSerialState_FRAMING (1 << 4)
|
||||
/** Indicates a parity error has occured */
|
||||
#define CDCSerialState_PARITY (1 << 5)
|
||||
/** Indicates a data overrun error has occured */
|
||||
#define CDCSerialState_OVERRUN (1 << 6)
|
||||
/** @}*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Types
|
||||
*----------------------------------------------------------------------------*/
|
||||
#pragma pack(1)
|
||||
#if defined ( __CC_ARM ) /* Keil ¦ÌVision 4 */
|
||||
#elif defined ( __ICCARM__ ) /* IAR Ewarm */
|
||||
#define __attribute__(...)
|
||||
#define __packed__ packed
|
||||
#elif defined ( __GNUC__ ) /* GCC CS3 */
|
||||
#define __packed__ aligned(1)
|
||||
#endif
|
||||
/** USB CDC SerialState struct (bitmap) */
|
||||
typedef struct _CDCSerialState {
|
||||
uint16_t bRxCarrier:1, /**< State of receive carrier detection (V2.4 signal
|
||||
109 and RS-232 signal DCD) */
|
||||
bTxCarrier:1, /**< State of transmission carrier */
|
||||
bBreak:1, /**< State of break detection */
|
||||
bRingSignal:1, /**< State of ring signal */
|
||||
bFraming:1, /**< Framing error */
|
||||
bParity:1, /**< Parity error */
|
||||
bOverRun:1, /**< Received data discarded due to overrun error */
|
||||
reserved:9; /**< Reserved */
|
||||
} __attribute__ ((__packed__)) CDCSerialState;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/**@}*/
|
||||
#endif /* #ifndef _CDCNOTIFICATIONS_H_ */
|
||||
|
@ -0,0 +1,183 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* 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:
|
||||
*
|
||||
* - 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Definitions and classes for USB CDC class requests
|
||||
* (mostly for ACM).
|
||||
*
|
||||
* \section CDCLineCoding
|
||||
*
|
||||
* -# Initialize a CDCLineCoding instance using CDCLineCoding_Initialize.
|
||||
* -# Send a CDCLineCoding object to the host in response to a GetLineCoding
|
||||
* request.
|
||||
* -# Receive a CDCLineCoding object from the host after a SetLineCoding
|
||||
* request.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _CDCREQUESTS_H_
|
||||
#define _CDCREQUESTS_H_
|
||||
/** \addtogroup usb_cdc
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Includes
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <USBRequests.h>
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/** \addtogroup usb_cdc_request USB CDC Request Codes
|
||||
* @{
|
||||
* This section lists USB CDC Request Codes.
|
||||
* - \ref CDCGenericRequest_SETLINECODING
|
||||
* - \ref CDCGenericRequest_GETLINECODING
|
||||
* - \ref CDCGenericRequest_SETCONTROLLINESTATE
|
||||
*/
|
||||
|
||||
/** SetLineCoding request code. */
|
||||
#define CDCGenericRequest_SETLINECODING 0x20
|
||||
/** GetLineCoding request code. */
|
||||
#define CDCGenericRequest_GETLINECODING 0x21
|
||||
/** SetControlLineState request code. */
|
||||
#define CDCGenericRequest_SETCONTROLLINESTATE 0x22
|
||||
/** @}*/
|
||||
|
||||
/** \addtogroup usb_cdc_ctrl_line_state USB CDC ControlLineState bitmap
|
||||
* @{
|
||||
* This section lists CDC ControlLineState bitmap.
|
||||
* - \ref CDCControlLineState_DTR, CDCControlLineState_DTE_PRESENT
|
||||
* - \ref CDCControlLineState_RTS, CDCControlLineState_CARRIER_ON
|
||||
*/
|
||||
/** Indicates to DCE if DTE is present or not. */
|
||||
#define CDCControlLineState_DTE_PRESENT (1 << 0)
|
||||
/** RS232 signal DTR: Data Terminal Ready. */
|
||||
#define CDCControlLineState_DTR (1 << 0)
|
||||
/** Carrier control for half duplex modems. */
|
||||
#define CDCControlLineState_CARRIER_ON (1 << 1)
|
||||
/** RS232 signal RTS: Request to send. */
|
||||
#define CDCControlLineState_RTS (1 << 1)
|
||||
/** @}*/
|
||||
|
||||
/** \addtogroup usb_cdc_stop USB CDC LineCoding StopBits
|
||||
* @{
|
||||
* This section lists Stop Bits for CDC Line Coding.
|
||||
* - \ref CDCLineCoding_ONESTOPBIT
|
||||
* - \ref CDCLineCoding_ONE5STOPBIT
|
||||
* - \ref CDCLineCoding_TWOSTOPBITS
|
||||
*/
|
||||
/** The transmission protocol uses one stop bit. */
|
||||
#define CDCLineCoding_ONESTOPBIT 0
|
||||
/** The transmission protocol uses 1.5 stop bit. */
|
||||
#define CDCLineCoding_ONE5STOPBIT 1
|
||||
/** The transmissin protocol uses two stop bits. */
|
||||
#define CDCLineCoding_TWOSTOPBITS 2
|
||||
/** @}*/
|
||||
|
||||
/** \addtogroup usb_cdc_parity USB CDC LineCoding ParityCheckings
|
||||
* @{
|
||||
* This section lists Parity checkings for CDC Line Coding.
|
||||
* - \ref CDCLineCoding_NOPARITY
|
||||
* - \ref CDCLineCoding_ODDPARITY
|
||||
* - \ref CDCLineCoding_EVENPARITY
|
||||
* - \ref CDCLineCoding_MARKPARITY
|
||||
* - \ref CDCLineCoding_SPACEPARITY
|
||||
*/
|
||||
/** No parity checking. */
|
||||
#define CDCLineCoding_NOPARITY 0
|
||||
/** Odd parity checking. */
|
||||
#define CDCLineCoding_ODDPARITY 1
|
||||
/** Even parity checking. */
|
||||
#define CDCLineCoding_EVENPARITY 2
|
||||
/** Mark parity checking. */
|
||||
#define CDCLineCoding_MARKPARITY 3
|
||||
/** Space parity checking. */
|
||||
#define CDCLineCoding_SPACEPARITY 4
|
||||
/** @}*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Types
|
||||
*----------------------------------------------------------------------------*/
|
||||
#pragma pack(1)
|
||||
#if defined ( __CC_ARM ) /* Keil ¦ÌVision 4 */
|
||||
#elif defined ( __ICCARM__ ) /* IAR Ewarm */
|
||||
#define __attribute__(...)
|
||||
#define __packed__ packed
|
||||
#elif defined ( __GNUC__ ) /* GCC CS3 */
|
||||
#define __packed__ aligned(1)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \typedef CDCLineCoding
|
||||
* \brief Format of the data returned when a GetLineCoding request is received.
|
||||
*/
|
||||
typedef struct _CDCLineCoding {
|
||||
|
||||
/** Data terminal rate in bits per second. */
|
||||
uint32_t dwDTERate;
|
||||
/** Number of stop bits.
|
||||
\sa usb_cdc_stop CDC LineCoding StopBits. */
|
||||
uint8_t bCharFormat;
|
||||
/** Type of parity checking used.
|
||||
\sa usb_cdc_parity CDC LineCoding ParityCheckings. */
|
||||
uint8_t bParityType;
|
||||
/** Number of data bits (5, 6, 7, 8 or 16). */
|
||||
uint8_t bDataBits;
|
||||
|
||||
} __attribute__ ((__packed__)) CDCLineCoding; /* GCC */
|
||||
|
||||
#pragma pack()
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
extern uint8_t CDCSetControlLineStateRequest_IsDtePresent(
|
||||
const USBGenericRequest *request);
|
||||
|
||||
extern uint8_t CDCSetControlLineStateRequest_ActivateCarrier(
|
||||
const USBGenericRequest *request);
|
||||
|
||||
extern void CDCLineCoding_Initialize(CDCLineCoding *lineCoding,
|
||||
uint32_t bitrate,
|
||||
uint8_t stopbits,
|
||||
uint8_t parity,
|
||||
uint8_t databits);
|
||||
|
||||
|
||||
/**@}*/
|
||||
#endif /* #define _CDCREQUESTS_H_ */
|
||||
|
@ -0,0 +1,157 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \section Purpose
|
||||
*
|
||||
* Definitions and methods for USB composite device implement.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef DUALCDCDDRIVER_H
|
||||
#define DUALCDCDDRIVER_H
|
||||
/** \addtogroup usbd_composite_cdccdc
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Headers
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <USBRequests.h>
|
||||
#include <CDCDescriptors.h>
|
||||
|
||||
#include "USBD.h"
|
||||
#include <CDCDSerialPort.h>
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Defines
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/** \addtogroup usbd_composite_cdccdc_desc
|
||||
* The driver uses these interface numbers in configuration descriptor.
|
||||
* @{
|
||||
*/
|
||||
/** Number of interfaces of the device */
|
||||
#define DUALCDCDDriverDescriptors_NUMINTERFACE 4
|
||||
/** Number of the CDC0 interface. */
|
||||
#define DUALCDCDDriverDescriptors_INTERFACENUM0 0
|
||||
/** Number of the CDC1 interface. */
|
||||
#define DUALCDCDDriverDescriptors_INTERFACENUM1 2
|
||||
/** @}*/
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Types
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma pack(1)
|
||||
#if defined ( __CC_ARM ) /* Keil ¦ÌVision 4 */
|
||||
#elif defined ( __ICCARM__ ) /* IAR Ewarm */
|
||||
#define __attribute__(...)
|
||||
#define __packed__ packed
|
||||
#elif defined ( __GNUC__ ) /* GCC CS3 */
|
||||
#define __packed__ aligned(1)
|
||||
#endif
|
||||
/**
|
||||
* \typedef DualCdcDriverConfigurationDescriptors
|
||||
* \brief Configuration descriptor list for a device implementing a
|
||||
* dual CDC serial composite driver.
|
||||
*/
|
||||
typedef struct _DualCdcDriverConfigurationDescriptors {
|
||||
|
||||
/** Standard configuration descriptor. */
|
||||
USBConfigurationDescriptor configuration;
|
||||
|
||||
/* --- CDC 0 */
|
||||
/** IAD 0 */
|
||||
USBInterfaceAssociationDescriptor cdcIAD0;
|
||||
/** Communication interface descriptor */
|
||||
USBInterfaceDescriptor cdcCommunication0;
|
||||
/** CDC header functional descriptor. */
|
||||
CDCHeaderDescriptor cdcHeader0;
|
||||
/** CDC call management functional descriptor. */
|
||||
CDCCallManagementDescriptor cdcCallManagement0;
|
||||
/** CDC abstract control management functional descriptor. */
|
||||
CDCAbstractControlManagementDescriptor cdcAbstractControlManagement0;
|
||||
/** CDC union functional descriptor (with one slave interface). */
|
||||
CDCUnionDescriptor cdcUnion0;
|
||||
/** Notification endpoint descriptor. */
|
||||
USBEndpointDescriptor cdcNotification0;
|
||||
/** Data interface descriptor. */
|
||||
USBInterfaceDescriptor cdcData0;
|
||||
/** Data OUT endpoint descriptor. */
|
||||
USBEndpointDescriptor cdcDataOut0;
|
||||
/** Data IN endpoint descriptor. */
|
||||
USBEndpointDescriptor cdcDataIn0;
|
||||
|
||||
/* --- CDC 1 */
|
||||
/** IAD 1 */
|
||||
USBInterfaceAssociationDescriptor cdcIAD1;
|
||||
/** Communication interface descriptor */
|
||||
USBInterfaceDescriptor cdcCommunication1;
|
||||
/** CDC header functional descriptor. */
|
||||
CDCHeaderDescriptor cdcHeader1;
|
||||
/** CDC call management functional descriptor. */
|
||||
CDCCallManagementDescriptor cdcCallManagement1;
|
||||
/** CDC abstract control management functional descriptor. */
|
||||
CDCAbstractControlManagementDescriptor cdcAbstractControlManagement1;
|
||||
/** CDC union functional descriptor (with one slave interface). */
|
||||
CDCUnionDescriptor cdcUnion1;
|
||||
/** Notification endpoint descriptor. */
|
||||
USBEndpointDescriptor cdcNotification1;
|
||||
/** Data interface descriptor. */
|
||||
USBInterfaceDescriptor cdcData1;
|
||||
/** Data OUT endpoint descriptor. */
|
||||
USBEndpointDescriptor cdcDataOut1;
|
||||
/** Data IN endpoint descriptor. */
|
||||
USBEndpointDescriptor cdcDataIn1;
|
||||
|
||||
} __attribute__ ((__packed__)) DualCdcDriverConfigurationDescriptors;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/* -DUALCDC */
|
||||
extern void DUALCDCDDriver_Initialize(
|
||||
const USBDDriverDescriptors* pDescriptors);
|
||||
|
||||
extern void DUALCDCDDriver_ConfigurationChangeHandler(uint8_t cfgnum);
|
||||
|
||||
extern void DUALCDCDDriver_RequestHandler(const USBGenericRequest *request);
|
||||
|
||||
extern CDCDSerialPort* DUALCDCDDriver_GetSerialPort(uint32_t port);
|
||||
|
||||
/**@}*/
|
||||
#endif /* #ifndef DUALCDCDDRIVER_H */
|
||||
|
@ -0,0 +1,678 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \section Purpose
|
||||
*
|
||||
* SCSI definitions.
|
||||
*
|
||||
* \section Usage
|
||||
*
|
||||
* -# After command block received, Access and decode the SCSI command block
|
||||
* with SBCCommand structure.
|
||||
*/
|
||||
|
||||
#ifndef SBC_H
|
||||
#define SBC_H
|
||||
|
||||
/** \addtogroup usbd_msd
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/** \addtogroup usbd_sbc_operation_codes SBC Operation Codes
|
||||
* @{
|
||||
* This page lists operation codes of commands described in the SBC-3
|
||||
* standard.
|
||||
*
|
||||
* \note That most commands are actually defined in other standards,
|
||||
* like SPC-4. Optional commands are not included here.
|
||||
*
|
||||
* \see sbc3r07.pdf - Section 5.1 - Table 12
|
||||
* \see spc4r06.pdf
|
||||
* \see SBCCommand
|
||||
*
|
||||
* \section Codes
|
||||
* - SBC_INQUIRY
|
||||
* - SBC_READ_10
|
||||
* - SBC_READ_CAPACITY_10
|
||||
* - SBC_REQUEST_SENSE
|
||||
* - SBC_TEST_UNIT_READY
|
||||
* - SBC_WRITE_10
|
||||
*
|
||||
* \section Optional Codes but required by Windows
|
||||
* - SBC_PREVENT_ALLOW_MEDIUM_REMOVAL
|
||||
* - SBC_MODE_SENSE_6
|
||||
* - SBC_VERIFY_10
|
||||
* - SBC_READ_FORMAT_CAPACITIES
|
||||
*/
|
||||
|
||||
/** Request information regarding parameters of the target and Logical Unit. */
|
||||
#define SBC_INQUIRY 0x12
|
||||
/** Request the transfer data to the host. */
|
||||
#define SBC_READ_10 0x28
|
||||
/** Request capacities of the currently installed medium. */
|
||||
#define SBC_READ_CAPACITY_10 0x25
|
||||
/** Request that the device server transfer sense data. */
|
||||
#define SBC_REQUEST_SENSE 0x03
|
||||
/** Check if the LUN is ready */
|
||||
#define SBC_TEST_UNIT_READY 0x00
|
||||
/** Request that the device write the data transferred by the host. */
|
||||
#define SBC_WRITE_10 0x2A
|
||||
|
||||
/** Request that the target enable or disable the removal of the medium in */
|
||||
/** the Logical Unit. */
|
||||
#define SBC_PREVENT_ALLOW_MEDIUM_REMOVAL 0x1E
|
||||
/** Report parameters. */
|
||||
#define SBC_MODE_SENSE_6 0x1A
|
||||
/** Request that the %device verify the data on the medium. */
|
||||
#define SBC_VERIFY_10 0x2F
|
||||
/** Request a list of the possible capacities that can be formatted on medium */
|
||||
#define SBC_READ_FORMAT_CAPACITIES 0x23
|
||||
/** @}*/
|
||||
|
||||
/** \addtogroup usbd_sbc_periph_quali SBC Periph. Qualifiers
|
||||
* @{
|
||||
* This page lists the peripheral qualifier values specified in the INQUIRY
|
||||
* data
|
||||
* \see spc4r06.pdf - Section 6.4.2 - Table 83
|
||||
* \see SBCInquiryData
|
||||
*
|
||||
* \section Qualifiers
|
||||
* - SBC_PERIPHERAL_DEVICE_CONNECTED
|
||||
* - SBC_PERIPHERAL_DEVICE_NOT_CONNECTED
|
||||
* - SBC_PERIPHERAL_DEVICE_NOT_SUPPORTED
|
||||
*/
|
||||
|
||||
#define SBC_PERIPHERAL_DEVICE_CONNECTED 0x00
|
||||
#define SBC_PERIPHERAL_DEVICE_NOT_CONNECTED 0x01
|
||||
#define SBC_PERIPHERAL_DEVICE_NOT_SUPPORTED 0x03
|
||||
/** @}*/
|
||||
|
||||
/** \addtogroup usbd_sbc_periph_types SBC Periph. Types
|
||||
* @{
|
||||
* This page lists peripheral device types specified in the INQUIRY data
|
||||
* \see spc4r06.pdf - Section 6.4.2 - Table 84
|
||||
* \see SBCInquiryData
|
||||
*
|
||||
* \section Types
|
||||
* - SBC_DIRECT_ACCESS_BLOCK_DEVICE
|
||||
* - SBC_SEQUENTIAL_ACCESS_DEVICE
|
||||
* - SBC_PRINTER_DEVICE
|
||||
* - SBC_PROCESSOR_DEVICE
|
||||
* - SBC_WRITE_ONCE_DEVICE
|
||||
* - SBC_CD_DVD_DEVICE
|
||||
* - SBC_SCANNER_DEVICE
|
||||
* - SBC_OPTICAL_MEMORY_DEVICE
|
||||
* - SBC_MEDIA_CHANGER_DEVICE
|
||||
* - SBC_COMMUNICATION_DEVICE
|
||||
* - SBC_STORAGE_ARRAY_CONTROLLER_DEVICE
|
||||
* - SBC_ENCLOSURE_SERVICES_DEVICE
|
||||
* - SBC_SIMPLIFIED_DIRECT_ACCESS_DEVICE
|
||||
* - SBC_OPTICAL_CARD_READER_WRITER_DEVICE
|
||||
* - SBC_BRIDGE_CONTROLLER_COMMANDS
|
||||
* - SBC_OBJECT_BASED_STORAGE_DEVICE
|
||||
*/
|
||||
|
||||
#define SBC_DIRECT_ACCESS_BLOCK_DEVICE 0x00
|
||||
#define SBC_SEQUENTIAL_ACCESS_DEVICE 0x01
|
||||
#define SBC_PRINTER_DEVICE 0x02
|
||||
#define SBC_PROCESSOR_DEVICE 0x03
|
||||
#define SBC_WRITE_ONCE_DEVICE 0x04
|
||||
#define SBC_CD_DVD_DEVICE 0x05
|
||||
#define SBC_SCANNER_DEVICE 0x06
|
||||
#define SBC_OPTICAL_MEMORY_DEVICE 0x07
|
||||
#define SBC_MEDIA_CHANGER_DEVICE 0x08
|
||||
#define SBC_COMMUNICATION_DEVICE 0x09
|
||||
#define SBC_STORAGE_ARRAY_CONTROLLER_DEVICE 0x0C
|
||||
#define SBC_ENCLOSURE_SERVICES_DEVICE 0x0D
|
||||
#define SBC_SIMPLIFIED_DIRECT_ACCESS_DEVICE 0x0E
|
||||
#define SBC_OPTICAL_CARD_READER_WRITER_DEVICE 0x0F
|
||||
#define SBC_BRIDGE_CONTROLLER_COMMANDS 0x10
|
||||
#define SBC_OBJECT_BASED_STORAGE_DEVICE 0x11
|
||||
/** @}*/
|
||||
|
||||
/*------------------------------------------------------------------------------ */
|
||||
/** \brief Version value for the SBC-3 specification */
|
||||
/** \see spc4r06.pdf - Section 6.4.2 - Table 85 */
|
||||
#define SBC_SPC_VERSION_4 0x06
|
||||
/*------------------------------------------------------------------------------ */
|
||||
|
||||
/*------------------------------------------------------------------------------ */
|
||||
/** \brief Values for the TPGS field returned in INQUIRY data */
|
||||
/** \see spc4r06.pdf - Section 6.4.2 - Table 86 */
|
||||
#define SBC_TPGS_NONE 0x0
|
||||
#define SBC_TPGS_ASYMMETRIC 0x1
|
||||
#define SBC_TPGS_SYMMETRIC 0x2
|
||||
#define SBC_TPGS_BOTH 0x3
|
||||
/*------------------------------------------------------------------------------ */
|
||||
|
||||
/*------------------------------------------------------------------------------ */
|
||||
/** \brief Version descriptor value for the SBC-3 specification */
|
||||
/** \see spc4r06.pdf - Section 6.4.2 - Table 87 */
|
||||
#define SBC_VERSION_DESCRIPTOR_SBC_3 0x04C0
|
||||
/*------------------------------------------------------------------------------ */
|
||||
|
||||
/** \addtogroup usbd_sbc_secse_codes SBC Sense Response Codes
|
||||
* @{
|
||||
* This page lists sense data response codes returned in REQUEST SENSE data
|
||||
* \see spc4r06.pdf - Section 4.5.1 - Table 12
|
||||
*
|
||||
* \section Codes
|
||||
* - SBC_SENSE_DATA_FIXED_CURRENT
|
||||
* - SBC_SENSE_DATA_FIXED_DEFERRED
|
||||
* - SBC_SENSE_DATA_DESCRIPTOR_CURRENT
|
||||
* - SBC_SENSE_DATA_DESCRIPTOR_DEFERRED
|
||||
*/
|
||||
|
||||
#define SBC_SENSE_DATA_FIXED_CURRENT 0x70
|
||||
#define SBC_SENSE_DATA_FIXED_DEFERRED 0x71
|
||||
#define SBC_SENSE_DATA_DESCRIPTOR_CURRENT 0x72
|
||||
#define SBC_SENSE_DATA_DESCRIPTOR_DEFERRED 0x73
|
||||
/** @}*/
|
||||
|
||||
/** \addtogroup usbd_sbc_sense_keys SBC Sense Keys
|
||||
* @{
|
||||
* This page lists sense key values returned in the REQUEST SENSE data
|
||||
* \see spc4r06.pdf - Section 4.5.6 - Table 27
|
||||
*
|
||||
* \section Keys
|
||||
* - SBC_SENSE_KEY_NO_SENSE
|
||||
* - SBC_SENSE_KEY_RECOVERED_ERROR
|
||||
* - SBC_SENSE_KEY_NOT_READY
|
||||
* - SBC_SENSE_KEY_MEDIUM_ERROR
|
||||
* - SBC_SENSE_KEY_HARDWARE_ERROR
|
||||
* - SBC_SENSE_KEY_ILLEGAL_REQUEST
|
||||
* - SBC_SENSE_KEY_UNIT_ATTENTION
|
||||
* - SBC_SENSE_KEY_DATA_PROTECT
|
||||
* - SBC_SENSE_KEY_BLANK_CHECK
|
||||
* - SBC_SENSE_KEY_VENDOR_SPECIFIC
|
||||
* - SBC_SENSE_KEY_COPY_ABORTED
|
||||
* - SBC_SENSE_KEY_ABORTED_COMMAND
|
||||
* - SBC_SENSE_KEY_VOLUME_OVERFLOW
|
||||
* - SBC_SENSE_KEY_MISCOMPARE
|
||||
*/
|
||||
|
||||
/** No specific sense key. Successful command. */
|
||||
#define SBC_SENSE_KEY_NO_SENSE 0x00
|
||||
/** Command completed succesfully with some recovery action by the %device. */
|
||||
#define SBC_SENSE_KEY_RECOVERED_ERROR 0x01
|
||||
/** The device can not be accessed. */
|
||||
#define SBC_SENSE_KEY_NOT_READY 0x02
|
||||
/** Command terminated with a error condition that was probably caused by a */
|
||||
/** flaw in the medium or an error in the recorded data. */
|
||||
#define SBC_SENSE_KEY_MEDIUM_ERROR 0x03
|
||||
/** Hardware failure while performing the command or during a self test. */
|
||||
#define SBC_SENSE_KEY_HARDWARE_ERROR 0x04
|
||||
/** Illegal parameter found in the command or additional parameters. */
|
||||
#define SBC_SENSE_KEY_ILLEGAL_REQUEST 0x05
|
||||
/** Removable medium may have been changed or the %device has been reset. */
|
||||
#define SBC_SENSE_KEY_UNIT_ATTENTION 0x06
|
||||
/** Write on a block that is protected. */
|
||||
#define SBC_SENSE_KEY_DATA_PROTECT 0x07
|
||||
/** Indicates that a write-once device or a sequential-access device */
|
||||
/** encountered blank medium or format-defined end-of-data indication while */
|
||||
/** reading or a write-once device encountered a non-blank medium while writing. */
|
||||
#define SBC_SENSE_KEY_BLANK_CHECK 0x08
|
||||
/** Reporting vendor specific conditions. */
|
||||
#define SBC_SENSE_KEY_VENDOR_SPECIFIC 0x09
|
||||
/** EXTENDED COPY command was aborted. */
|
||||
#define SBC_SENSE_KEY_COPY_ABORTED 0x0A
|
||||
/** Device aborted the command. */
|
||||
#define SBC_SENSE_KEY_ABORTED_COMMAND 0x0B
|
||||
/** A buffered peripheral device is overflow. */
|
||||
#define SBC_SENSE_KEY_VOLUME_OVERFLOW 0x0D
|
||||
/** The source data did not match the data read from the medium. */
|
||||
#define SBC_SENSE_KEY_MISCOMPARE 0x0E
|
||||
/** @}*/
|
||||
|
||||
/** \addtogroup usbd_sbc_sense_additionals SBC Sense Additionals
|
||||
* @{
|
||||
* This page lists additional sense code values returned in REQUEST SENSE data
|
||||
* \see spc4r06.pdf - Section 4.5.6 - Table 28
|
||||
*
|
||||
* \section Additional Codes
|
||||
* - SBC_ASC_LOGICAL_UNIT_NOT_READY
|
||||
* - SBC_ASC_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE
|
||||
* - SBC_ASC_INVALID_FIELD_IN_CDB
|
||||
* - SBC_ASC_WRITE_PROTECTED
|
||||
* - SBC_ASC_FORMAT_CORRUPTED
|
||||
* - SBC_ASC_INVALID_COMMAND_OPERATION_CODE
|
||||
* - SBC_ASC_TOO_MUCH_WRITE_DATA
|
||||
* - SBC_ASC_NOT_READY_TO_READY_CHANGE
|
||||
* - SBC_ASC_MEDIUM_NOT_PRESENT
|
||||
*/
|
||||
|
||||
#define SBC_ASC_LOGICAL_UNIT_NOT_READY 0x04
|
||||
#define SBC_ASC_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE 0x21
|
||||
#define SBC_ASC_INVALID_FIELD_IN_CDB 0x24
|
||||
#define SBC_ASC_WRITE_PROTECTED 0x27
|
||||
#define SBC_ASC_FORMAT_CORRUPTED 0x31
|
||||
#define SBC_ASC_INVALID_COMMAND_OPERATION_CODE 0x20
|
||||
#define SBC_ASC_TOO_MUCH_WRITE_DATA 0x26
|
||||
#define SBC_ASC_NOT_READY_TO_READY_CHANGE 0x28
|
||||
#define SBC_ASC_MEDIUM_NOT_PRESENT 0x3A
|
||||
/** @}*/
|
||||
|
||||
/*------------------------------------------------------------------------------ */
|
||||
/** \brief MEDIUM TYPE field value for direct-access block devices */
|
||||
/** \see sbc3r06.pdf - Section 6.3.1 */
|
||||
#define SBC_MEDIUM_TYPE_DIRECT_ACCESS_BLOCK_DEVICE 0x00
|
||||
/*------------------------------------------------------------------------------ */
|
||||
|
||||
/*------------------------------------------------------------------------------ */
|
||||
/** \brief MRIE field values */
|
||||
/** \see sbc3r06.pdf - Section 7.4.11 - Table 286 */
|
||||
#define SBC_MRIE_NO_REPORTING 0x00
|
||||
#define SBC_MRIE_ASYNCHRONOUS 0x01
|
||||
#define SBC_MRIE_GENERATE_UNIT_ATTENTION 0x02
|
||||
#define SBC_MRIE_COND_GENERATE_RECOVERED_ERROR 0x03
|
||||
#define SBC_MRIE_UNCOND_GENERATE_RECOVERED_ERROR 0x04
|
||||
#define SBC_MRIE_GENERATE_NO_SENSE 0x05
|
||||
#define SBC_MRIE_ON_REQUEST 0x06
|
||||
/*------------------------------------------------------------------------------ */
|
||||
|
||||
/*------------------------------------------------------------------------------ */
|
||||
/** \brief Supported mode pages */
|
||||
/** \see sbc3r06.pdf - Section 6.3.1 - Table 115 */
|
||||
#define SBC_PAGE_READ_WRITE_ERROR_RECOVERY 0x01
|
||||
#define SBC_PAGE_INFORMATIONAL_EXCEPTIONS_CONTROL 0x1C
|
||||
#define SBC_PAGE_RETURN_ALL 0x3F
|
||||
#define SBC_PAGE_VENDOR_SPECIFIC 0x00
|
||||
/*------------------------------------------------------------------------------ */
|
||||
|
||||
/** \addtogroup usbd_msd_endian_macros MSD Endian Macros
|
||||
* @{
|
||||
* This page lists the macros for endianness conversion.
|
||||
*
|
||||
* \section Macros
|
||||
* - WORDB
|
||||
* - DWORDB
|
||||
* - STORE_DWORDB
|
||||
* - STORE_WORDB
|
||||
*/
|
||||
|
||||
/** \brief Converts a byte array to a word value using the big endian format */
|
||||
#define WORDB(bytes) ((unsigned short) ((bytes[0] << 8) | bytes[1]))
|
||||
|
||||
/** \brief Converts a byte array to a dword value using the big endian format */
|
||||
#define DWORDB(bytes) ((unsigned int) ((bytes[0] << 24) | (bytes[1] << 16) \
|
||||
| (bytes[2] << 8) | bytes[3]))
|
||||
|
||||
/** \brief Stores a dword value in a byte array, in big endian format */
|
||||
#define STORE_DWORDB(dword, bytes) \
|
||||
bytes[0] = (unsigned char) (((dword) >> 24) & 0xFF); \
|
||||
bytes[1] = (unsigned char) (((dword) >> 16) & 0xFF); \
|
||||
bytes[2] = (unsigned char) (((dword) >> 8) & 0xFF); \
|
||||
bytes[3] = (unsigned char) ((dword) & 0xFF);
|
||||
|
||||
/** \brief Stores a word value in a byte array, in big endian format */
|
||||
#define STORE_WORDB(word, bytes) \
|
||||
bytes[0] = (unsigned char) (((word) >> 8) & 0xFF); \
|
||||
bytes[1] = (unsigned char) ((word) & 0xFF);
|
||||
/** @}*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Structures
|
||||
*------------------------------------------------------------------------------*/
|
||||
#pragma pack(1)
|
||||
#if defined ( __CC_ARM ) /* Keil ¦ÌVision 4 */
|
||||
#elif defined ( __ICCARM__ ) /* IAR Ewarm */
|
||||
#define __attribute__(...)
|
||||
#define __packed__ packed
|
||||
#elif defined ( __GNUC__ ) /* GCC CS3 */
|
||||
#define __packed__ aligned(1)
|
||||
#endif
|
||||
/**
|
||||
* \typedef SBCInquiry
|
||||
* \brief Structure for the INQUIRY command
|
||||
* \see spc4r06.pdf - Section 6.4.1 - Table 81
|
||||
*/
|
||||
typedef struct _SBCInquiry {
|
||||
|
||||
unsigned char bOperationCode; /*!< 0x12 : SBC_INQUIRY */
|
||||
unsigned char isEVPD:1, /*!< Type of requested data */
|
||||
bReserved1:7; /*!< Reserved bits */
|
||||
unsigned char bPageCode; /*!< Specifies the VPD to return */
|
||||
unsigned char pAllocationLength[2]; /*!< Size of host buffer */
|
||||
unsigned char bControl; /*!< 0x00 */
|
||||
|
||||
} __attribute__ ((__packed__)) SBCInquiry; /* GCC */
|
||||
|
||||
/**
|
||||
* \typedef SBCInquiryData
|
||||
* \brief Standard INQUIRY data format returned by the device
|
||||
* \see spc4r06.pdf - Section 6.4.2 - Table 82
|
||||
*/
|
||||
typedef struct _SBCInquiryData {
|
||||
|
||||
unsigned char bPeripheralDeviceType:5, /*!< Peripheral device type */
|
||||
bPeripheralQualifier :3; /*!< Peripheral qualifier */
|
||||
unsigned char bReserved1:7, /*!< Reserved bits */
|
||||
isRMB :1; /*!< Is media removable ? */
|
||||
unsigned char bVersion; /*!< SPC version used */
|
||||
unsigned char bResponseDataFormat:4, /*!< Must be 0x2 */
|
||||
isHIGHSUP :1, /*!< Hierarchical addressing used ? */
|
||||
isNORMACA :1, /*!< ACA attribute supported ? */
|
||||
bObsolete1 :2; /*!< Obsolete bits */
|
||||
unsigned char bAdditionalLength; /*!< Length of remaining INQUIRY data */
|
||||
unsigned char isSCCS :1, /*!< Embedded SCC ? */
|
||||
isACC :1, /*!< Access control coordinator ? */
|
||||
bTPGS :2, /*!< Target port support group */
|
||||
is3PC :1, /*!< Third-party copy supported ? */
|
||||
bReserved2:2, /*!< Reserved bits */
|
||||
isProtect :1; /*!< Protection info supported ? */
|
||||
unsigned char bObsolete2:1, /*!< Obsolete bit */
|
||||
isEncServ :1, /*!< Embedded enclosure service comp? */
|
||||
isVS :1, /*!< ??? */
|
||||
isMultiP :1, /*!< Multi-port device ? */
|
||||
bObsolete3:3, /*!< Obsolete bits */
|
||||
bUnused1 :1; /*!< Unused feature */
|
||||
unsigned char bUnused2:6, /*!< Unused features */
|
||||
isCmdQue:1, /*!< Task management model supported ? */
|
||||
isVS2 :1; /*!< ??? */
|
||||
unsigned char pVendorID[8]; /*!< T10 vendor identification */
|
||||
unsigned char pProductID[16]; /*!< Vendor-defined product ID */
|
||||
unsigned char pProductRevisionLevel[4];/*!< Vendor-defined product revision */
|
||||
unsigned char pVendorSpecific[20]; /*!< Vendor-specific data */
|
||||
unsigned char bUnused3; /*!< Unused features */
|
||||
unsigned char bReserved3; /*!< Reserved bits */
|
||||
unsigned short pVersionDescriptors[8]; /*!< Standards the device complies to */
|
||||
unsigned char pReserved4[22]; /*!< Reserved bytes */
|
||||
|
||||
} __attribute__ ((__packed__)) SBCInquiryData; /* GCC */
|
||||
|
||||
/**
|
||||
* \typedef SBCRead10
|
||||
* \brief Data structure for the READ (10) command
|
||||
* \see sbc3r07.pdf - Section 5.7 - Table 34
|
||||
*/
|
||||
typedef struct _SBCRead10 {
|
||||
|
||||
unsigned char bOperationCode; /*!< 0x28 : SBC_READ_10 */
|
||||
unsigned char bObsolete1:1, /*!< Obsolete bit */
|
||||
isFUA_NV:1, /*!< Cache control bit */
|
||||
bReserved1:1, /*!< Reserved bit */
|
||||
isFUA:1, /*!< Cache control bit */
|
||||
isDPO:1, /*!< Cache control bit */
|
||||
bRdProtect:3; /*!< Protection information to send */
|
||||
unsigned char pLogicalBlockAddress[4]; /*!< Index of first block to read */
|
||||
unsigned char bGroupNumber:5, /*!< Information grouping */
|
||||
bReserved2:3; /*!< Reserved bits */
|
||||
unsigned char pTransferLength[2]; /*!< Number of blocks to transmit */
|
||||
unsigned char bControl; /*!< 0x00 */
|
||||
|
||||
} __attribute__ ((__packed__)) SBCRead10; /* GCC */
|
||||
|
||||
/**
|
||||
* \typedef SBCReadCapacity10
|
||||
* \brief Structure for the READ CAPACITY (10) command
|
||||
* \see sbc3r07.pdf - Section 5.11.1 - Table 40
|
||||
*/
|
||||
typedef struct _SBCReadCapacity10 {
|
||||
|
||||
unsigned char bOperationCode; /*!< 0x25 : RBC_READ_CAPACITY */
|
||||
unsigned char bObsolete1:1, /*!< Obsolete bit */
|
||||
bReserved1:7; /*!< Reserved bits */
|
||||
unsigned char pLogicalBlockAddress[4]; /*!< Block to evaluate if PMI is set */
|
||||
unsigned char pReserved2[2]; /*!< Reserved bytes */
|
||||
unsigned char isPMI:1, /*!< Partial medium indicator bit */
|
||||
bReserved3:7; /*!< Reserved bits */
|
||||
unsigned char bControl; /*!< 0x00 */
|
||||
|
||||
} SBCReadCapacity10;
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* \brief Data returned by the device after a READ CAPACITY (10) command
|
||||
* \see sbc3r07.pdf - Section 5.11.2 - Table 41
|
||||
*------------------------------------------------------------------------------*/
|
||||
typedef struct {
|
||||
|
||||
unsigned char pLogicalBlockAddress[4]; /*!< Address of last logical block */
|
||||
unsigned char pLogicalBlockLength[4]; /*!< Length of each logical block */
|
||||
|
||||
} SBCReadCapacity10Data;
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* \brief Structure for the REQUEST SENSE command
|
||||
* \see spc4r06.pdf - Section 6.26 - Table 170
|
||||
*------------------------------------------------------------------------------*/
|
||||
typedef struct {
|
||||
|
||||
unsigned char bOperationCode; /*!< 0x03 : SBC_REQUEST_SENSE */
|
||||
unsigned char isDesc :1, /*!< Type of information expected */
|
||||
bReserved1:7; /*!< Reserved bits */
|
||||
unsigned char pReserved2[2]; /*!< Reserved bytes */
|
||||
unsigned char bAllocationLength; /*!< Size of host buffer */
|
||||
unsigned char bControl; /*!< 0x00 */
|
||||
|
||||
} SBCRequestSense;
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* \brief Fixed format sense data returned after a REQUEST SENSE command has
|
||||
* been received with a DESC bit cleared.
|
||||
* \see spc4r06.pdf - Section 4.5.3 - Table 26
|
||||
*------------------------------------------------------------------------------*/
|
||||
typedef struct {
|
||||
|
||||
unsigned char bResponseCode:7, /*!< Sense data format */
|
||||
isValid :1; /*!< Information field is standard */
|
||||
unsigned char bObsolete1; /*!< Obsolete byte */
|
||||
unsigned char bSenseKey :4, /*!< Generic error information */
|
||||
bReserved1:1, /*!< Reserved bit */
|
||||
isILI :1, /*!< SSC */
|
||||
isEOM :1, /*!< SSC */
|
||||
isFilemark:1; /*!< SSC */
|
||||
unsigned char pInformation[4]; /*!< Command-specific */
|
||||
unsigned char bAdditionalSenseLength; /*!< sizeof(SBCRequestSense_data)-8 */
|
||||
unsigned char pCommandSpecificInformation[4]; /*!< Command-specific */
|
||||
unsigned char bAdditionalSenseCode; /*!< Additional error information */
|
||||
unsigned char bAdditionalSenseCodeQualifier; /*!< Further error information */
|
||||
unsigned char bFieldReplaceableUnitCode; /*!< Specific component code */
|
||||
unsigned char bSenseKeySpecific:7, /*!< Additional exception info */
|
||||
isSKSV :1; /*!< Is sense key specific valid? */
|
||||
unsigned char pSenseKeySpecific[2]; /*!< Additional exception info */
|
||||
|
||||
} SBCRequestSenseData;
|
||||
|
||||
/**
|
||||
* \brief SBCTestUnitReady
|
||||
* Data structure for the TEST UNIT READY command
|
||||
* \see spc4r06.pdf - Section 6.34 - Table 192
|
||||
*/
|
||||
typedef struct _SBCTestUnitReady {
|
||||
|
||||
unsigned char bOperationCode; /*!< 0x00 : SBC_TEST_UNIT_READY */
|
||||
unsigned char pReserved1[4]; /*!< Reserved bits */
|
||||
unsigned char bControl; /*!< 0x00 */
|
||||
|
||||
} __attribute__ ((__packed__)) SBCTestUnitReady; /* GCC */
|
||||
|
||||
/**
|
||||
* \typedef SBCWrite10
|
||||
* \brief Structure for the WRITE (10) command
|
||||
* \see sbc3r07.pdf - Section 5.26 - Table 70
|
||||
*/
|
||||
typedef struct _SBCWrite10 {
|
||||
|
||||
unsigned char bOperationCode; /*!< 0x2A : SBC_WRITE_10 */
|
||||
unsigned char bObsolete1:1, /*!< Obsolete bit */
|
||||
isFUA_NV:1, /*!< Cache control bit */
|
||||
bReserved1:1, /*!< Reserved bit */
|
||||
isFUA:1, /*!< Cache control bit */
|
||||
isDPO:1, /*!< Cache control bit */
|
||||
bWrProtect:3; /*!< Protection information to send */
|
||||
unsigned char pLogicalBlockAddress[4]; /*!< First block to write */
|
||||
unsigned char bGroupNumber:5, /*!< Information grouping */
|
||||
bReserved2:3; /*!< Reserved bits */
|
||||
unsigned char pTransferLength[2]; /*!< Number of blocks to write */
|
||||
unsigned char bControl; /*!< 0x00 */
|
||||
|
||||
} SBCWrite10;
|
||||
|
||||
/**
|
||||
* \typedef SBCMediumRemoval
|
||||
* \brief Structure for the PREVENT/ALLOW MEDIUM REMOVAL command
|
||||
* \see sbc3r07.pdf - Section 5.5 - Table 30
|
||||
*/
|
||||
typedef struct _SBCMediumRemoval {
|
||||
|
||||
unsigned char bOperationCode; /*!< 0x1E : SBC_PREVENT_ALLOW_MEDIUM_REMOVAL */
|
||||
unsigned char pReserved1[3]; /*!< Reserved bytes */
|
||||
unsigned char bPrevent:2, /*!< Accept/prohibit removal */
|
||||
bReserved2:6; /*!< Reserved bits */
|
||||
unsigned char bControl; /*!< 0x00 */
|
||||
|
||||
} __attribute__ ((__packed__)) SBCMediumRemoval; /* GCC */
|
||||
|
||||
/**
|
||||
* \typedef SBCModeSense6
|
||||
* \brief Structure for the MODE SENSE (6) command
|
||||
* \see spc4r06 - Section 6.9.1 - Table 98
|
||||
*/
|
||||
typedef struct _SBCModeSense6 {
|
||||
|
||||
unsigned char bOperationCode; /*!< 0x1A : SBC_MODE_SENSE_6 */
|
||||
unsigned char bReserved1:3, /*!< Reserved bits */
|
||||
isDBD:1, /*!< Disable block descriptors bit */
|
||||
bReserved2:4; /*!< Reserved bits */
|
||||
unsigned char bPageCode:6, /*!< Mode page to return */
|
||||
bPC:2; /*!< Type of parameter values to return */
|
||||
unsigned char bSubpageCode; /*!< Mode subpage to return */
|
||||
unsigned char bAllocationLength; /*!< Host buffer allocated size */
|
||||
unsigned char bControl; /*!< 0x00 */
|
||||
|
||||
} __attribute__ ((__packed__)) SBCModeSense6; /* GCC */
|
||||
|
||||
/**
|
||||
* \typedef SBCModeParameterHeader6
|
||||
* \brief Header for the data returned after a MODE SENSE (6) command
|
||||
* \see spc4r06.pdf - Section 7.4.3 - Table 268
|
||||
*/
|
||||
typedef struct _SBCModeParameterHeader6 {
|
||||
|
||||
unsigned char bModeDataLength; /*!< Length of mode data to follow */
|
||||
unsigned char bMediumType; /*!< Type of medium (SBC_MEDIUM_TYPE_DIRECT_ACCESS_BLOCK_DEVICE) */
|
||||
unsigned char bReserved1:4, /*!< Reserved bits */
|
||||
isDPOFUA:1, /*!< DPO/FUA bits supported ? */
|
||||
bReserved2:2, /*!< Reserved bits */
|
||||
isWP:1; /*!< Is medium write-protected ? */
|
||||
unsigned char bBlockDescriptorLength; /*!< Length of all block descriptors */
|
||||
|
||||
} __attribute__ ((__packed__)) SBCModeParameterHeader6; /* GCC */
|
||||
|
||||
/**
|
||||
* \typedef SBCInformationalExceptionsControl
|
||||
* \brief Informational exceptions control mode page
|
||||
* \see spc4r06.pdf - Section 7.4.11 - Table 285
|
||||
*/
|
||||
typedef struct _SBCInformationalExceptionsControl {
|
||||
|
||||
unsigned char bPageCode:6, /*!< 0x1C : SBC_PAGE_INFORMATIONAL_EXCEPTIONS_CONTROL */
|
||||
isSPF:1, /*!< Page or subpage data format */
|
||||
isPS:1; /*!< Parameters saveable ? */
|
||||
unsigned char bPageLength; /*!< Length of page data (0x0A) */
|
||||
unsigned char isLogErr:1, /*!< Should informational exceptions be logged ? */
|
||||
isEBackErr:1, /*!< Enable background error bit */
|
||||
isTest:1, /*!< Create a device test failure ? */
|
||||
isDExcpt:1, /*!< Disable exception control bit */
|
||||
isEWasc:1, /*!< Report warnings ? */
|
||||
isEBF:1, /*!< Enable background function bit */
|
||||
bReserved1:1, /*!< Reserved bit */
|
||||
isPerf:1; /*!< Delay acceptable when treating exceptions ? */
|
||||
unsigned char bMRIE:4, /*!< Method of reporting informational exceptions */
|
||||
bReserved2:4; /*!< Reserved bits */
|
||||
unsigned char pIntervalTimer[4]; /*!< Error reporting period */
|
||||
unsigned char pReportCount[4]; /*!< Maximum number of time a report can be issued */
|
||||
|
||||
} __attribute__ ((__packed__)) SBCInformationalExceptionsControl; /* GCC */
|
||||
|
||||
/**
|
||||
* \typedef SBCReadWriteErrorRecovery
|
||||
* \brief Read/write error recovery mode page
|
||||
* \see sbc3r07.pdf - Section 6.3.5 - Table 122
|
||||
*/
|
||||
typedef struct _SBCReadWriteErrorRecovery {
|
||||
|
||||
unsigned char bPageCode:6, /*!< 0x01 : SBC_PAGE_READ_WRITE_ERROR_RECOVERY */
|
||||
isSPF:1, /*!< Page or subpage data format */
|
||||
isPS:1; /*!< Parameters saveable ? */
|
||||
unsigned char bPageLength; /*!< Length of page data (0x0A) */
|
||||
unsigned char isDCR:1, /*!< Disable correction bit */
|
||||
isDTE:1, /*!< Data terminate on error bit */
|
||||
isPER:1, /*!< Post error bit */
|
||||
isEER:1, /*!< Enable early recovery bit */
|
||||
isRC:1, /*!< Read continuous bit */
|
||||
isTB:1, /*!< Transfer block bit */
|
||||
isARRE:1, /*!< Automatic read reallocation enabled bit */
|
||||
isAWRE:1; /*!< Automatic write reallocation enabled bit */
|
||||
unsigned char bReadRetryCount; /*!< Number of retries when reading */
|
||||
unsigned char pObsolete1[3]; /*!< Obsolete bytes */
|
||||
unsigned char bReserved1; /*!< Reserved byte */
|
||||
unsigned char bWriteRetryCount; /*!< Number of retries when writing */
|
||||
unsigned char bReserved2; /*!< Reserved byte */
|
||||
unsigned char pRecoveryTimeLimit[2]; /*!< Maximum time duration for error recovery */
|
||||
|
||||
} __attribute__ ((__packed__)) SBCReadWriteErrorRecovery; /* GCC */
|
||||
|
||||
/**
|
||||
* \typedef SBCCommand
|
||||
* \brief Generic structure for holding information about SBC commands
|
||||
* \see SBCInquiry
|
||||
* \see SBCRead10
|
||||
* \see SBCReadCapacity10
|
||||
* \see SBCRequestSense
|
||||
* \see SBCTestUnitReady
|
||||
* \see SBCWrite10
|
||||
* \see SBCMediumRemoval
|
||||
* \see SBCModeSense6
|
||||
*/
|
||||
typedef union _SBCCommand {
|
||||
|
||||
unsigned char bOperationCode; /*!< Operation code of the command */
|
||||
SBCInquiry inquiry; /*!< INQUIRY command */
|
||||
SBCRead10 read10; /*!< READ (10) command */
|
||||
SBCReadCapacity10 readCapacity10; /*!< READ CAPACITY (10) command */
|
||||
SBCRequestSense requestSense; /*!< REQUEST SENSE command */
|
||||
SBCTestUnitReady testUnitReady; /*!< TEST UNIT READY command */
|
||||
SBCWrite10 write10; /*!< WRITE (10) command */
|
||||
SBCMediumRemoval mediumRemoval; /*!< PREVENT/ALLOW MEDIUM REMOVAL command */
|
||||
SBCModeSense6 modeSense6; /*!< MODE SENSE (6) command */
|
||||
|
||||
} SBCCommand;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
/**@}*/
|
||||
|
||||
#endif /*#ifndef SBC_H */
|
||||
|
@ -0,0 +1,118 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \section Purpose
|
||||
*
|
||||
* SCSI commands implementation.
|
||||
*
|
||||
* section Usage
|
||||
*
|
||||
* -# After a CBW is received from host, use SBC_GetCommandInformation to check
|
||||
* if the command is supported, and get the command length and type
|
||||
* information before processing it.
|
||||
* -# Then SBC_ProcessCommand can be used to handle a valid command, to
|
||||
* perform the command operations.
|
||||
* -# SBC_UpdateSenseData is used to update the sense data that will be sent
|
||||
* to host.
|
||||
*/
|
||||
|
||||
#ifndef SBCMETHODS_H
|
||||
#define SBCMETHODS_H
|
||||
|
||||
/** \addtogroup usbd_msd
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Headers
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
#include "SBC.h"
|
||||
#include "MSDLun.h"
|
||||
#include "MSDDStateMachine.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/** \addtogroup usbd_sbc_command_state SBC Command States
|
||||
* @{
|
||||
* This page lists the possible states of a SBC command.
|
||||
*
|
||||
* \section States
|
||||
* - SBC_STATE_READ
|
||||
* - SBC_STATE_WAIT_READ
|
||||
* - SBC_STATE_WRITE
|
||||
* - SBC_STATE_WAIT_WRITE
|
||||
* - SBC_STATE_NEXT_BLOCK
|
||||
*/
|
||||
|
||||
/** Start of reading bulk data */
|
||||
#define SBC_STATE_READ 0x01
|
||||
/** Waiting for the bulk data reading complete */
|
||||
#define SBC_STATE_WAIT_READ 0x02
|
||||
/** Read error state */
|
||||
#define SBC_STATE_READ_ERROR 0x03
|
||||
/** Start next read block */
|
||||
#define SBC_STATE_NEXT_READ 0x04
|
||||
/** Start writing bulk data to host */
|
||||
#define SBC_STATE_WRITE 0x05
|
||||
/** Waiting for the bulk data sending complete */
|
||||
#define SBC_STATE_WAIT_WRITE 0x06
|
||||
/** Write error state */
|
||||
#define SBC_STATE_WRITE_ERROR 0x07
|
||||
/** Start next write block */
|
||||
#define SBC_STATE_NEXT_WRITE 0x08
|
||||
/** Start next command block */
|
||||
#define SBC_STATE_NEXT_BLOCK 0x09
|
||||
/** @}*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
void SBC_UpdateSenseData(SBCRequestSenseData *requestSenseData,
|
||||
unsigned char senseKey,
|
||||
unsigned char additionalSenseCode,
|
||||
unsigned char additionalSenseCodeQualifier);
|
||||
|
||||
unsigned char SBC_GetCommandInformation(void *command,
|
||||
unsigned int *length,
|
||||
unsigned char *type,
|
||||
MSDLun *lun);
|
||||
|
||||
unsigned char SBC_ProcessCommand(MSDLun *lun,
|
||||
MSDCommandState *commandState);
|
||||
|
||||
/**@}*/
|
||||
|
||||
#endif /*#ifndef SBCMETHODS_H */
|
||||
|
||||
|
@ -0,0 +1,278 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \section Purpose
|
||||
*
|
||||
* Collection of methods for using the USB device controller on AT91
|
||||
* microcontrollers.
|
||||
*
|
||||
* \section Usage
|
||||
*
|
||||
* Please refer to the corresponding application note.
|
||||
* - \ref usbd_framework AT91 USB device framework
|
||||
* - \ref usbd_api USBD API
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef USBD_H
|
||||
#define USBD_H
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#include "USBDescriptors.h"
|
||||
#include "USBRequests.h"
|
||||
|
||||
#include "USBLib_Types.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/* Define attribute */
|
||||
#if defined ( __CC_ARM ) /* Keil ¦ÌVision 4 */
|
||||
#define WEAK __attribute__ ((weak))
|
||||
#elif defined ( __ICCARM__ ) /* IAR Ewarm 5.41+ */
|
||||
#define WEAK __weak
|
||||
#elif defined ( __GNUC__ ) /* GCC CS3 2009q3-68 */
|
||||
#define WEAK __attribute__ ((weak))
|
||||
#endif
|
||||
|
||||
/* Define NO_INIT attribute */
|
||||
#if defined ( __CC_ARM )
|
||||
#define NO_INIT
|
||||
#elif defined ( __ICCARM__ )
|
||||
#define NO_INIT __no_init
|
||||
#elif defined ( __GNUC__ )
|
||||
#define NO_INIT
|
||||
#endif
|
||||
|
||||
|
||||
/** \addtogroup usbd_interface
|
||||
*@{*/
|
||||
|
||||
/**
|
||||
* \addtogroup usbd_rc USB device API return codes
|
||||
* @{
|
||||
* This section lists the return codes for the USB device driver API
|
||||
* - \ref USBD_STATUS_SUCCESS
|
||||
* - \ref USBD_STATUS_LOCKED
|
||||
* - \ref USBD_STATUS_ABORTED
|
||||
* - \ref USBD_STATUS_RESET
|
||||
*/
|
||||
|
||||
/** Indicates the operation was successful. */
|
||||
#define USBD_STATUS_SUCCESS USBRC_SUCCESS
|
||||
/** Endpoint/device is already busy. */
|
||||
#define USBD_STATUS_LOCKED USBRC_BUSY
|
||||
/** Operation has been aborted (error or stall). */
|
||||
#define USBD_STATUS_ABORTED USBRC_ABORTED
|
||||
/** Operation has been canceled (by user). */
|
||||
#define USBD_STATUS_CANCELED USBRC_CANCELED
|
||||
/** Operation has been aborted because the device init/reset/un-configure. */
|
||||
#define USBD_STATUS_RESET USBRC_RESET
|
||||
/** Part ot operation successfully done. */
|
||||
#define USBD_STATUS_PARTIAL_DONE USBRC_PARTIAL_DONE
|
||||
/** Operation failed because parameter error */
|
||||
#define USBD_STATUS_INVALID_PARAMETER USBRC_PARAM_ERR
|
||||
/** Operation failed because in unexpected state */
|
||||
#define USBD_STATUS_WRONG_STATE USBRC_STATE_ERR
|
||||
/** Operation failed because SW not supported */
|
||||
#define USBD_STATUS_SW_NOT_SUPPORTED USBRC_SW_NOT_SUPPORTED
|
||||
/** Operation failed because HW not supported */
|
||||
#define USBD_STATUS_HW_NOT_SUPPORTED USBRC_HW_NOT_SUPPORTED
|
||||
/** @}*/
|
||||
|
||||
/** \addtogroup usbd_states USB device states
|
||||
* @{
|
||||
* This section lists the device states of the USB device driver.
|
||||
* - \ref USBD_STATE_SUSPENDED
|
||||
* - \ref USBD_STATE_ATTACHED
|
||||
* - \ref USBD_STATE_POWERED
|
||||
* - \ref USBD_STATE_DEFAULT
|
||||
* - \ref USBD_STATE_ADDRESS
|
||||
* - \ref USBD_STATE_CONFIGURED
|
||||
*/
|
||||
|
||||
/** The device is currently suspended. */
|
||||
#define USBD_STATE_SUSPENDED 0
|
||||
/** USB cable is plugged into the device. */
|
||||
#define USBD_STATE_ATTACHED 1
|
||||
/** Host is providing +5V through the USB cable. */
|
||||
#define USBD_STATE_POWERED 2
|
||||
/** Device has been reset. */
|
||||
#define USBD_STATE_DEFAULT 3
|
||||
/** The device has been given an address on the bus. */
|
||||
#define USBD_STATE_ADDRESS 4
|
||||
/** A valid configuration has been selected. */
|
||||
#define USBD_STATE_CONFIGURED 5
|
||||
/** @}*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Types
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* \brief Buffer struct used for multi-buffer-listed transfer.
|
||||
*
|
||||
* The driver can process 255 bytes of buffers or buffer list window.
|
||||
*/
|
||||
typedef struct _USBDTransferBuffer {
|
||||
/** Pointer to frame buffer */
|
||||
uint8_t * pBuffer;
|
||||
/** Size of the frame (up to 64K-1) */
|
||||
uint16_t size;
|
||||
/** Bytes transferred */
|
||||
uint16_t transferred;
|
||||
/** Bytes in FIFO */
|
||||
uint16_t buffered;
|
||||
/** Bytes remaining */
|
||||
uint16_t remaining;
|
||||
} USBDTransferBuffer;
|
||||
|
||||
#pragma pack(1)
|
||||
#if defined ( __CC_ARM ) /* Keil ¦ÌVision 4 */
|
||||
#elif defined ( __ICCARM__ ) /* IAR Ewarm 5.41+ */
|
||||
#define __attribute__(...)
|
||||
#elif defined ( __GNUC__ ) /* GCC CS3 2009q3-68 */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Struct used for USBD DMA Link List Transfer Descriptor, must be 16-bytes
|
||||
* aligned.
|
||||
*
|
||||
* (For USB, DMA transfer is linked to EPs and FIFO address is EP defined)
|
||||
*/
|
||||
typedef struct _USBDDmaDescriptor {
|
||||
/** Pointer to Next Descriptor */
|
||||
void* pNxtDesc;
|
||||
/** Pointer to data buffer address */
|
||||
void* pDataAddr;
|
||||
/** DMA Control setting register value */
|
||||
uint32_t ctrlSettings:8, /** Control settings */
|
||||
reserved:8, /** Not used */
|
||||
bufferLength:16; /** Length of buffer */
|
||||
/** Loaded to DMA register, OK to modify */
|
||||
uint32_t used;
|
||||
} __attribute__((aligned(16))) USBDDmaDescriptor;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
/**
|
||||
* Callback used by transfer functions (USBD_Read & USBD_Write) to notify
|
||||
* that a transaction is complete.
|
||||
*/
|
||||
typedef void (*TransferCallback)(void *pArg,
|
||||
uint8_t status,
|
||||
uint32_t transferred,
|
||||
uint32_t remaining);
|
||||
|
||||
/**
|
||||
* Callback used by MBL transfer functions (USBD_Read & USBD_Write) to notify
|
||||
* that a transaction is complete.
|
||||
* \param pArg Pointer to callback arguments.
|
||||
* \param status USBD status.
|
||||
*/
|
||||
typedef void (*MblTransferCallback)(void *pArg,
|
||||
uint8_t status);
|
||||
|
||||
/**@}*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
//extern void USBD_IrqHandler(void);
|
||||
|
||||
extern void USBD_Init(void);
|
||||
|
||||
extern void USBD_ConfigureSpeed(uint8_t forceFS);
|
||||
|
||||
extern void USBD_Connect(void);
|
||||
|
||||
extern void USBD_Disconnect(void);
|
||||
|
||||
extern uint8_t USBD_Write(
|
||||
uint8_t bEndpoint,
|
||||
const void *pData,
|
||||
uint32_t size,
|
||||
TransferCallback callback,
|
||||
void *pArg);
|
||||
|
||||
extern uint8_t USBD_Read(
|
||||
uint8_t bEndpoint,
|
||||
void *pData,
|
||||
uint32_t dLength,
|
||||
TransferCallback fCallback,
|
||||
void *pArg);
|
||||
|
||||
extern uint8_t USBD_Stall(uint8_t bEndpoint);
|
||||
|
||||
extern void USBD_Halt(uint8_t bEndpoint);
|
||||
|
||||
extern void USBD_Unhalt(uint8_t bEndpoint);
|
||||
|
||||
extern void USBD_ConfigureEndpoint(const USBEndpointDescriptor *pDescriptor);
|
||||
|
||||
extern uint8_t USBD_IsHalted(uint8_t bEndpoint);
|
||||
|
||||
extern void USBD_RemoteWakeUp(void);
|
||||
|
||||
extern void USBD_SetAddress(uint8_t address);
|
||||
|
||||
extern void USBD_SetConfiguration(uint8_t cfgnum);
|
||||
|
||||
extern uint8_t USBD_GetState(void);
|
||||
|
||||
extern uint8_t USBD_IsHighSpeed(void);
|
||||
|
||||
extern void USBD_Test(uint8_t bIndex);
|
||||
|
||||
extern void USBD_SuspendHandler(void);
|
||||
extern void USBD_ResumeHandler(void);
|
||||
extern void USBD_ResetHandler(void);
|
||||
extern void USBD_RequestHandler(uint8_t bEndpoint,
|
||||
const USBGenericRequest * pRequest);
|
||||
|
||||
|
||||
extern void USBDCallbacks_Initialized(void);
|
||||
extern void USBDCallbacks_Reset(void);
|
||||
extern void USBDCallbacks_Suspended(void);
|
||||
extern void USBDCallbacks_Resumed(void);
|
||||
extern void USBDCallbacks_RequestReceived(const USBGenericRequest *request);
|
||||
|
||||
#endif /*#ifndef USBD_H*/
|
||||
|
@ -0,0 +1,149 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \section Purpose
|
||||
*
|
||||
* USB Device Driver class definition.
|
||||
*
|
||||
* \section Usage
|
||||
*
|
||||
* -# Instanciate a USBDDriver object and initialize it using
|
||||
* USBDDriver_Initialize.
|
||||
* -# When a USB SETUP request is received, forward it to the standard
|
||||
* driver using USBDDriver_RequestHandler.
|
||||
* -# Check the Remote Wakeup setting via USBDDriver_IsRemoteWakeUpEnabled.
|
||||
*/
|
||||
|
||||
#ifndef USBDDRIVER_H
|
||||
#define USBDDRIVER_H
|
||||
|
||||
/** \addtogroup usbd_interface
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Headers
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/* These headers were introduced in C99 by working group
|
||||
* ISO/IEC JTC1/SC22/WG14.
|
||||
*/
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <USBRequests.h>
|
||||
#include <USBDescriptors.h>
|
||||
#include <USBLib_Types.h>
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Types
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* \typedef USBDDriverDescriptors
|
||||
* \brief List of all descriptors used by a USB device driver. Each descriptor
|
||||
* can be provided in two versions: full-speed and high-speed. Devices
|
||||
* which are not high-speed capable do not need to provided high-speed
|
||||
* descriptors and the full-speed qualifier & other speed descriptors.
|
||||
*/
|
||||
typedef struct _USBDDriverDescriptors {
|
||||
|
||||
/** Pointer to the full-speed device descriptor */
|
||||
const USBDeviceDescriptor *pFsDevice;
|
||||
/** Pointer to the full-speed configuration descriptor */
|
||||
const USBConfigurationDescriptor *pFsConfiguration;
|
||||
/** Pointer to the full-speed qualifier descriptor */
|
||||
const USBDeviceQualifierDescriptor *pFsQualifier;
|
||||
/** Pointer to the full-speed other speed configuration descriptor */
|
||||
const USBConfigurationDescriptor *pFsOtherSpeed;
|
||||
/** Pointer to the high-speed device descriptor */
|
||||
const USBDeviceDescriptor *pHsDevice;
|
||||
/** Pointer to the high-speed configuration descriptor */
|
||||
const USBConfigurationDescriptor *pHsConfiguration;
|
||||
/** Pointer to the high-speed qualifier descriptor */
|
||||
const USBDeviceQualifierDescriptor *pHsQualifier;
|
||||
/** Pointer to the high-speed other speed configuration descriptor */
|
||||
const USBConfigurationDescriptor *pHsOtherSpeed;
|
||||
/** Pointer to the list of string descriptors */
|
||||
const uint8_t **pStrings;
|
||||
/** Number of string descriptors in list */
|
||||
uint8_t numStrings;
|
||||
|
||||
} USBDDriverDescriptors;
|
||||
|
||||
/**
|
||||
* \typedef USBDDriver
|
||||
* \brief USB device driver structure, holding a list of descriptors identifying
|
||||
* the device as well as the driver current state.
|
||||
*/
|
||||
typedef struct _USBDDriver {
|
||||
|
||||
/** List of descriptors used by the device. */
|
||||
const USBDDriverDescriptors *pDescriptors;
|
||||
/** Current setting for each interface. */
|
||||
uint8_t *pInterfaces;
|
||||
/** Current configuration number (0 -> device is not configured). */
|
||||
uint8_t cfgnum;
|
||||
/** Indicates if remote wake up has been enabled by the host. */
|
||||
uint8_t isRemoteWakeUpEnabled;
|
||||
/** Features supported by OTG */
|
||||
uint8_t otg_features_supported;
|
||||
} USBDDriver;
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
extern USBDDriver *USBD_GetDriver(void);
|
||||
extern void USBDDriver_Initialize(
|
||||
USBDDriver *pDriver,
|
||||
const USBDDriverDescriptors *pDescriptors,
|
||||
uint8_t *pInterfaces);
|
||||
extern USBConfigurationDescriptor* USBDDriver_GetCfgDescriptors(
|
||||
USBDDriver * pDriver,
|
||||
uint8_t cfgNum);
|
||||
extern void USBDDriver_RequestHandler(
|
||||
USBDDriver *pDriver,
|
||||
const USBGenericRequest *pRequest);
|
||||
extern uint8_t USBDDriver_IsRemoteWakeUpEnabled(const USBDDriver *pDriver);
|
||||
extern uint8_t USBDDriver_returnOTGFeatures(const USBDDriver *pDriver);
|
||||
extern void USBDDriver_clearOTGFeatures(USBDDriver *pDriver);
|
||||
|
||||
extern void USBDDriverCallbacks_ConfigurationChanged(uint8_t cfgnum);
|
||||
extern void USBDDriverCallbacks_InterfaceSettingChanged(uint8_t interface,
|
||||
uint8_t setting);
|
||||
|
||||
/**@}*/
|
||||
|
||||
#endif /*#ifndef USBDDRIVER_H*/
|
||||
|
@ -0,0 +1,111 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef USBD_HAL_H
|
||||
#define USBD_HAL_H
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* This file defines functions for USB Device Hardware Access Level.
|
||||
*/
|
||||
|
||||
/** \addtogroup usbd_hal
|
||||
*@{*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/* Introduced in C99 by working group ISO/IEC JTC1/SC22/WG14. */
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "USBD.h"
|
||||
#include <USBDescriptors.h>
|
||||
#include <USBRequests.h>
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Consts
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Macros
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/** Get bitmap for an endpoint */
|
||||
#define bmEP(bEP) (1 << (bEP))
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Types
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Exported functoins
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
extern void USBD_HAL_Init(void);
|
||||
extern void USBD_HAL_Connect(void);
|
||||
extern void USBD_HAL_Disconnect(void);
|
||||
|
||||
extern void USBD_HAL_RemoteWakeUp(void);
|
||||
extern void USBD_HAL_SetConfiguration(uint8_t cfgnum);
|
||||
extern void USBD_HAL_SetAddress(uint8_t address);
|
||||
extern uint8_t USBD_HAL_IsHighSpeed(void);
|
||||
|
||||
extern void USBD_HAL_Suspend(void);
|
||||
extern void USBD_HAL_Activate(void);
|
||||
|
||||
extern void USBD_HAL_ResetEPs(uint32_t bmEPs,uint8_t bStatus, uint8_t bKeepCfg);
|
||||
extern void USBD_HAL_CancelIo(uint32_t bmEPs);
|
||||
extern uint8_t USBD_HAL_ConfigureEP(const USBEndpointDescriptor * pDescriptor);
|
||||
|
||||
extern uint8_t USBD_HAL_SetTransferCallback(uint8_t bEP,
|
||||
TransferCallback fCallback,
|
||||
void * pCbData);
|
||||
extern uint8_t USBD_HAL_SetupMblTransfer(uint8_t bEndpoint,
|
||||
USBDTransferBuffer * pMbList,
|
||||
uint16_t mblSize,
|
||||
uint16_t startOffset);
|
||||
extern uint8_t USBD_HAL_Write(uint8_t bEndpoint,
|
||||
const void * pData,
|
||||
uint32_t dLength);
|
||||
extern uint8_t USBD_HAL_WrWithHdr(uint8_t bEndpoint,
|
||||
const void * pHdr, uint8_t bHdrLen,
|
||||
const void * pData, uint32_t dLength);
|
||||
extern uint8_t USBD_HAL_Read(uint8_t bEndpoint,
|
||||
void * pData,
|
||||
uint32_t dLength);
|
||||
extern uint8_t USBD_HAL_Stall(uint8_t bEP);
|
||||
extern uint8_t USBD_HAL_Halt(uint8_t bEndpoint,uint8_t ctl);
|
||||
extern void USBD_HAL_Test(uint8_t bIndex);
|
||||
/**@}*/
|
||||
|
||||
#endif // #define USBD_HAL_H
|
@ -0,0 +1,549 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* 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:
|
||||
*
|
||||
* - 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \section Purpose
|
||||
*
|
||||
* Definitions and methods for USB descriptor structures described by the
|
||||
* USB specification.
|
||||
*
|
||||
* \section Usage
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _USBDESCRIPTORS_H_
|
||||
#define _USBDESCRIPTORS_H_
|
||||
/** \addtogroup usb_general
|
||||
* @{
|
||||
* \addtogroup usb_descriptor USB Descriptors
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Headers
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/* These headers were introduced in C99 by working group
|
||||
* ISO/IEC JTC1/SC22/WG14.
|
||||
*/
|
||||
#include <stdint.h>
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/*--------- Generic Descriptors --------*/
|
||||
|
||||
/** \addtogroup usb_desc_type USB Descriptor types
|
||||
* @{
|
||||
* This section lists the codes of the usb descriptor types
|
||||
* - \ref USBGenericDescriptor_DEVICE
|
||||
* - \ref USBGenericDescriptor_CONFIGURATION
|
||||
* - \ref USBGenericDescriptor_STRING
|
||||
* - \ref USBGenericDescriptor_INTERFACE
|
||||
* - \ref USBGenericDescriptor_ENDPOINT
|
||||
* - \ref USBGenericDescriptor_DEVICEQUALIFIER
|
||||
* - \ref USBGenericDescriptor_OTHERSPEEDCONFIGURATION
|
||||
* - \ref USBGenericDescriptor_INTERFACEPOWER
|
||||
* - \ref USBGenericDescriptor_OTG
|
||||
* - \ref USBGenericDescriptor_DEBUG
|
||||
* - \ref USBGenericDescriptor_INTERFACEASSOCIATION
|
||||
*/
|
||||
/** Device descriptor type. */
|
||||
#define USBGenericDescriptor_DEVICE 1
|
||||
/** Configuration descriptor type. */
|
||||
#define USBGenericDescriptor_CONFIGURATION 2
|
||||
/** String descriptor type. */
|
||||
#define USBGenericDescriptor_STRING 3
|
||||
/** Interface descriptor type. */
|
||||
#define USBGenericDescriptor_INTERFACE 4
|
||||
/** Endpoint descriptor type. */
|
||||
#define USBGenericDescriptor_ENDPOINT 5
|
||||
/** Device qualifier descriptor type. */
|
||||
#define USBGenericDescriptor_DEVICEQUALIFIER 6
|
||||
/** Other speed configuration descriptor type. */
|
||||
#define USBGenericDescriptor_OTHERSPEEDCONFIGURATION 7
|
||||
/** Interface power descriptor type. */
|
||||
#define USBGenericDescriptor_INTERFACEPOWER 8
|
||||
/** On-The-Go descriptor type. */
|
||||
#define USBGenericDescriptor_OTG 9
|
||||
/** Debug descriptor type. */
|
||||
#define USBGenericDescriptor_DEBUG 10
|
||||
/** Interface association descriptor type. */
|
||||
#define USBGenericDescriptor_INTERFACEASSOCIATION 11
|
||||
/** @}*/
|
||||
|
||||
|
||||
/*--------- Device Descriptors --------*/
|
||||
|
||||
/** \addtogroup usb_release_number USB release numbers
|
||||
* @{
|
||||
* This section lists the codes of USB release numbers.
|
||||
* - \ref USBDeviceDescriptor_USB2_00
|
||||
*/
|
||||
|
||||
/** The device supports USB 2.00. */
|
||||
#define USBDeviceDescriptor_USB2_00 0x0200
|
||||
/** @}*/
|
||||
|
||||
|
||||
/*--------- Configuration Descriptors --------*/
|
||||
|
||||
/** \addtogroup usb_attributes USB Device Attributes
|
||||
* @{
|
||||
* This section lists the codes of the usb attributes.
|
||||
* - \ref USBConfigurationDescriptor_BUSPOWERED_NORWAKEUP
|
||||
* - \ref USBConfigurationDescriptor_SELFPOWERED_NORWAKEUP
|
||||
* - \ref USBConfigurationDescriptor_BUSPOWERED_RWAKEUP
|
||||
* - \ref USBConfigurationDescriptor_SELFPOWERED_RWAKEUP
|
||||
* - \ref USBConfigurationDescriptor_POWER
|
||||
*/
|
||||
/** Device is bus-powered and not support remote wake-up. */
|
||||
#define USBConfigurationDescriptor_BUSPOWERED_NORWAKEUP 0x80
|
||||
/** Device is self-powered and not support remote wake-up. */
|
||||
#define USBConfigurationDescriptor_SELFPOWERED_NORWAKEUP 0xC0
|
||||
/** Device is bus-powered and supports remote wake-up. */
|
||||
#define USBConfigurationDescriptor_BUSPOWERED_RWAKEUP 0xA0
|
||||
/** Device is self-powered and supports remote wake-up. */
|
||||
#define USBConfigurationDescriptor_SELFPOWERED_RWAKEUP 0xE0
|
||||
/** Calculates the value of the power consumption field given the value in mA.
|
||||
* \param power The power consumption value in mA
|
||||
* \return The value that should be set to the field in descriptor
|
||||
*/
|
||||
#define USBConfigurationDescriptor_POWER(power) (power / 2)
|
||||
/** @}*/
|
||||
|
||||
|
||||
/*--------- Endpoint Descriptors --------*/
|
||||
|
||||
/** \addtogroup usb_ep_define USB Endpoint definitions
|
||||
* @{
|
||||
* This section lists definitions and macro for endpoint descriptors.
|
||||
* - \ref usb_ep_dir USB Endpoint directions
|
||||
* - \ref USBEndpointDescriptor_OUT
|
||||
* - \ref USBEndpointDescriptor_IN
|
||||
*
|
||||
* - \ref usb_ep_type USB Endpoint types
|
||||
* - \ref USBEndpointDescriptor_CONTROL
|
||||
* - \ref USBEndpointDescriptor_ISOCHRONOUS
|
||||
* - \ref USBEndpointDescriptor_BULK
|
||||
* - \ref USBEndpointDescriptor_INTERRUPT
|
||||
*
|
||||
* - \ref usb_ep_size USB Endpoint maximun sizes
|
||||
* - \ref USBEndpointDescriptor_MAXCTRLSIZE_FS
|
||||
* - \ref USBEndpointDescriptor_MAXCTRLSIZE_HS
|
||||
* - \ref USBEndpointDescriptor_MAXBULKSIZE_FS
|
||||
* - \ref USBEndpointDescriptor_MAXBULKSIZE_HS
|
||||
* - \ref USBEndpointDescriptor_MAXINTERRUPTSIZE_FS
|
||||
* - \ref USBEndpointDescriptor_MAXINTERRUPTSIZE_HS
|
||||
* - \ref USBEndpointDescriptor_MAXISOCHRONOUSSIZE_FS
|
||||
* - \ref USBEndpointDescriptor_MAXISOCHRONOUSSIZE_HS
|
||||
*
|
||||
* - \ref usb_ep_addr USB Endpoint address define
|
||||
* - \ref USBEndpointDescriptor_ADDRESS
|
||||
*/
|
||||
|
||||
/** \addtogroup usb_ep_dir USB Endpoint directions
|
||||
* @{
|
||||
* This section lists definitions of USB endpoint directions.
|
||||
* - USBEndpointDescriptor_OUT
|
||||
* - USBEndpointDescriptor_IN
|
||||
*/
|
||||
/** Endpoint receives data from the host. */
|
||||
#define USBEndpointDescriptor_OUT 0
|
||||
/** Endpoint sends data to the host. */
|
||||
#define USBEndpointDescriptor_IN 1
|
||||
/** @}*/
|
||||
|
||||
/** \addtogroup usb_ep_type USB Endpoint types
|
||||
* @{
|
||||
* This section lists definitions of USB endpoint types.
|
||||
* - \ref USBEndpointDescriptor_CONTROL
|
||||
* - \ref USBEndpointDescriptor_ISOCHRONOUS
|
||||
* - \ref USBEndpointDescriptor_BULK
|
||||
* - \ref USBEndpointDescriptor_INTERRUPT
|
||||
*/
|
||||
/** Control endpoint type. */
|
||||
#define USBEndpointDescriptor_CONTROL 0
|
||||
/** Isochronous endpoint type. */
|
||||
#define USBEndpointDescriptor_ISOCHRONOUS 1
|
||||
/** Bulk endpoint type. */
|
||||
#define USBEndpointDescriptor_BULK 2
|
||||
/** Interrupt endpoint type. */
|
||||
#define USBEndpointDescriptor_INTERRUPT 3
|
||||
/** @}*/
|
||||
|
||||
/** \addtogroup usb_ep_size USB Endpoint maximun sizes
|
||||
* @{
|
||||
* This section lists definitions of USB endpoint maximun sizes.
|
||||
* - \ref USBEndpointDescriptor_MAXCTRLSIZE_FS
|
||||
* - \ref USBEndpointDescriptor_MAXCTRLSIZE_HS
|
||||
* - \ref USBEndpointDescriptor_MAXBULKSIZE_FS
|
||||
* - \ref USBEndpointDescriptor_MAXBULKSIZE_HS
|
||||
* - \ref USBEndpointDescriptor_MAXINTERRUPTSIZE_FS
|
||||
* - \ref USBEndpointDescriptor_MAXINTERRUPTSIZE_HS
|
||||
* - \ref USBEndpointDescriptor_MAXISOCHRONOUSSIZE_FS
|
||||
* - \ref USBEndpointDescriptor_MAXISOCHRONOUSSIZE_HS
|
||||
*/
|
||||
/** Maximum size for a full-speed control endpoint. */
|
||||
#define USBEndpointDescriptor_MAXCTRLSIZE_FS 64
|
||||
/** Maximum size for a high-speed control endpoint. */
|
||||
#define USBEndpointDescriptor_MAXCTRLSIZE_HS 64
|
||||
/** Maximum size for a full-speed bulk endpoint. */
|
||||
#define USBEndpointDescriptor_MAXBULKSIZE_FS 64
|
||||
/** Maximum size for a high-speed bulk endpoint. */
|
||||
#define USBEndpointDescriptor_MAXBULKSIZE_HS 512
|
||||
/** Maximum size for a full-speed interrupt endpoint. */
|
||||
#define USBEndpointDescriptor_MAXINTERRUPTSIZE_FS 64
|
||||
/** Maximum size for a high-speed interrupt endpoint. */
|
||||
#define USBEndpointDescriptor_MAXINTERRUPTSIZE_HS 1024
|
||||
/** Maximum size for a full-speed isochronous endpoint. */
|
||||
#define USBEndpointDescriptor_MAXISOCHRONOUSSIZE_FS 1023
|
||||
/** Maximum size for a high-speed isochronous endpoint. */
|
||||
#define USBEndpointDescriptor_MAXISOCHRONOUSSIZE_HS 1024
|
||||
/** @}*/
|
||||
|
||||
/** \addtogroup usb_ep_addr USB Endpoint address define
|
||||
* @{
|
||||
* This section lists macro for USB endpoint address definition.
|
||||
* - \ref USBEndpointDescriptor_ADDRESS
|
||||
*/
|
||||
/**
|
||||
* Calculates the address of an endpoint given its number and direction
|
||||
* \param direction USB endpoint direction definition
|
||||
* \param number USB endpoint number
|
||||
* \return The value used to set the endpoint descriptor based on input number
|
||||
* and direction
|
||||
*/
|
||||
#define USBEndpointDescriptor_ADDRESS(direction, number) \
|
||||
(((direction & 0x01) << 7) | (number & 0xF))
|
||||
/** @}*/
|
||||
/** @}*/
|
||||
|
||||
|
||||
/*--------- Generic Descriptors --------*/
|
||||
|
||||
/** \addtogroup usb_string_descriptor USB String Descriptor Definitions
|
||||
* @{
|
||||
* This section lists the codes and macros for USB string descriptor definition.
|
||||
*
|
||||
* \par Language IDs
|
||||
* - USBStringDescriptor_ENGLISH_US
|
||||
*
|
||||
* \par String Descriptor Length
|
||||
* - USBStringDescriptor_LENGTH
|
||||
*
|
||||
* \par ASCII to UNICODE convertion
|
||||
* - USBStringDescriptor_UNICODE
|
||||
*/
|
||||
/** Language ID for US english. */
|
||||
#define USBStringDescriptor_ENGLISH_US 0x09, 0x04
|
||||
/**
|
||||
* Calculates the length of a string descriptor given the number of ascii
|
||||
* characters/language IDs in it.
|
||||
* \param length The ascii format string length.
|
||||
* \return The actual data length in bytes.
|
||||
*/
|
||||
#define USBStringDescriptor_LENGTH(length) ((length) * 2 + 2)
|
||||
/**
|
||||
* Converts an ascii character to its unicode representation.
|
||||
* \param ascii The ASCII character to convert
|
||||
* \return A 2-byte-array for the UNICODE based on given ASCII
|
||||
*/
|
||||
#define USBStringDescriptor_UNICODE(ascii) (ascii), 0
|
||||
/** @}*/
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Types
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Function types
|
||||
*/
|
||||
|
||||
typedef uint32_t (*USBDescriptorParseFunction)(void *descriptor, void *parseArg);
|
||||
|
||||
|
||||
/*
|
||||
* Descriptor structs types
|
||||
*/
|
||||
#pragma pack(1)
|
||||
#if defined ( __CC_ARM ) /* Keil ¦ÌVision 4 */
|
||||
#elif defined ( __ICCARM__ ) /* IAR Ewarm */
|
||||
#define __attribute__(...)
|
||||
#define __packed__ packed
|
||||
#elif defined ( __GNUC__ ) /* GCC CS3 */
|
||||
#define __packed__ aligned(1)
|
||||
#endif
|
||||
/**
|
||||
\typedef USBGenericDescriptor
|
||||
\brief Holds the few fields shared by all USB descriptors.
|
||||
*/
|
||||
typedef struct _USBGenericDescriptor {
|
||||
|
||||
/** Length of the descriptor in bytes. */
|
||||
uint8_t bLength;
|
||||
/** Descriptor type. */
|
||||
uint8_t bDescriptorType;
|
||||
|
||||
} __attribute__ ((__packed__)) USBGenericDescriptor; /* GCC */
|
||||
|
||||
/**
|
||||
* \typedef USBDeviceDescriptor
|
||||
* \brief USB standard device descriptor structure.
|
||||
*/
|
||||
typedef struct _USBDeviceDescriptor {
|
||||
|
||||
/** Size of this descriptor in bytes. */
|
||||
uint8_t bLength;
|
||||
/** Descriptor type (USBGenericDescriptor_DEVICE). */
|
||||
uint8_t bDescriptorType;
|
||||
/** USB specification release number in BCD format. */
|
||||
uint16_t bcdUSB;
|
||||
/** Device class code. */
|
||||
uint8_t bDeviceClass;
|
||||
/** Device subclass code. */
|
||||
uint8_t bDeviceSubClass;
|
||||
/** Device protocol code. */
|
||||
uint8_t bDeviceProtocol;
|
||||
/** Maximum packet size of endpoint 0 (in bytes). */
|
||||
uint8_t bMaxPacketSize0;
|
||||
/** Vendor ID. */
|
||||
uint16_t idVendor;
|
||||
/** Product ID. */
|
||||
uint16_t idProduct;
|
||||
/** Device release number in BCD format. */
|
||||
uint16_t bcdDevice;
|
||||
/** Index of the manufacturer string descriptor. */
|
||||
uint8_t iManufacturer;
|
||||
/** Index of the product string descriptor. */
|
||||
uint8_t iProduct;
|
||||
/** Index of the serial number string descriptor. */
|
||||
uint8_t iSerialNumber;
|
||||
/** Number of possible configurations for the device. */
|
||||
uint8_t bNumConfigurations;
|
||||
|
||||
} __attribute__ ((__packed__)) USBDeviceDescriptor; /* GCC */
|
||||
|
||||
/**
|
||||
* \typedef USBOtgDescriptor
|
||||
* \brief USB On-The-Go descriptor struct.
|
||||
*/
|
||||
typedef struct _USBOtgDescriptor {
|
||||
|
||||
/** Size of this descriptor in bytes. */
|
||||
uint8_t bLength;
|
||||
/** Descriptor type (USBGenericDescriptor_OTG). */
|
||||
uint8_t bDescriptorType;
|
||||
/** Attribute Fields D7?: Reserved D1: HNP support D0: SRP support */
|
||||
uint8_t bmAttributes;
|
||||
|
||||
} __attribute__ ((__packed__)) USBOtgDescriptor; /* GCC */
|
||||
|
||||
/**
|
||||
* \typedef USBDeviceQualifierDescriptor
|
||||
* \brief Alternate device descriptor indicating the capabilities of the device
|
||||
* in full-speed, if currently in high-speed; or in high-speed, if it is
|
||||
* currently in full-speed. Only relevant for devices supporting the
|
||||
* high-speed mode.
|
||||
*/
|
||||
typedef struct _USBDeviceQualifierDescriptor {
|
||||
|
||||
/** Size of the descriptor in bytes. */
|
||||
uint8_t bLength;
|
||||
/** Descriptor type (USBDESC_DEVICE_QUALIFIER or "USB device types"). */
|
||||
uint8_t bDescriptorType;
|
||||
/** USB specification release number (in BCD format). */
|
||||
uint16_t bcdUSB;
|
||||
/** Device class code. */
|
||||
uint8_t bDeviceClass;
|
||||
/** Device subclass code. */
|
||||
uint8_t bDeviceSubClass;
|
||||
/** Device protocol code. */
|
||||
uint8_t bDeviceProtocol;
|
||||
/** Maximum packet size of endpoint 0. */
|
||||
uint8_t bMaxPacketSize0;
|
||||
/** Number of possible configurations for the device. */
|
||||
uint8_t bNumConfigurations;
|
||||
/** Reserved. */
|
||||
uint8_t bReserved;
|
||||
|
||||
} __attribute__ ((__packed__)) USBDeviceQualifierDescriptor; /* GCC */
|
||||
|
||||
/**
|
||||
* \typedef USBConfigurationDescriptor
|
||||
* \brief USB standard configuration descriptor structure.
|
||||
*/
|
||||
typedef struct _USBConfigurationDescriptor {
|
||||
|
||||
/** Size of the descriptor in bytes. */
|
||||
uint8_t bLength;
|
||||
/** Descriptor type
|
||||
(USBDESC_CONFIGURATION of \ref usb_desc_type USB Descriptor types). */
|
||||
uint8_t bDescriptorType;
|
||||
/** Length of all descriptors returned along with this configuration
|
||||
descriptor. */
|
||||
uint16_t wTotalLength;
|
||||
/** Number of interfaces in this configuration. */
|
||||
uint8_t bNumInterfaces;
|
||||
/** Value for selecting this configuration. */
|
||||
uint8_t bConfigurationValue;
|
||||
/** Index of the configuration string descriptor. */
|
||||
uint8_t iConfiguration;
|
||||
/** Configuration characteristics. */
|
||||
uint8_t bmAttributes;
|
||||
/** Maximum power consumption of the device when in this configuration. */
|
||||
uint8_t bMaxPower;
|
||||
|
||||
} __attribute__ ((__packed__)) USBConfigurationDescriptor; /* GCC*/
|
||||
|
||||
/**
|
||||
* \typedef USBInterfaceAssociationDescriptor
|
||||
* \brief
|
||||
*/
|
||||
typedef struct _USBInterfaceAssociationDescriptor {
|
||||
|
||||
unsigned char bLength;
|
||||
unsigned char bDescriptorType;
|
||||
unsigned char bFirstInterface;
|
||||
unsigned char bInterfaceCount;
|
||||
unsigned char bFunctionClass;
|
||||
unsigned char bFunctionSubClass;
|
||||
unsigned char bFunctionProtocol;
|
||||
unsigned char iFunction;
|
||||
} __attribute__ ((__packed__)) USBInterfaceAssociationDescriptor; /* GCC*/
|
||||
|
||||
/**
|
||||
* \typedef USBInterfaceDescriptor
|
||||
* \brief USB standard interface descriptor structure.
|
||||
*/
|
||||
typedef struct _USBInterfaceDescriptor {
|
||||
|
||||
/** Size of the descriptor in bytes. */
|
||||
uint8_t bLength;
|
||||
/** Descriptor type (USBGenericDescriptor_INTERFACE). */
|
||||
uint8_t bDescriptorType;
|
||||
/** Number of the interface in its configuration. */
|
||||
uint8_t bInterfaceNumber;
|
||||
/** Value to select this alternate interface setting. */
|
||||
uint8_t bAlternateSetting;
|
||||
/** Number of endpoints used by the inteface (excluding endpoint 0). */
|
||||
uint8_t bNumEndpoints;
|
||||
/** Interface class code. */
|
||||
uint8_t bInterfaceClass;
|
||||
/** Interface subclass code. */
|
||||
uint8_t bInterfaceSubClass;
|
||||
/** Interface protocol code. */
|
||||
uint8_t bInterfaceProtocol;
|
||||
/** Index of the interface string descriptor. */
|
||||
uint8_t iInterface;
|
||||
|
||||
} __attribute__ ((__packed__)) USBInterfaceDescriptor; /* GCC */
|
||||
|
||||
/**
|
||||
* \typedef USBEndpointDescriptor
|
||||
* \brief USB standard endpoint descriptor structure.
|
||||
*/
|
||||
typedef struct _USBEndpointDescriptor {
|
||||
|
||||
/** Size of the descriptor in bytes. */
|
||||
uint8_t bLength;
|
||||
/** Descriptor type (\ref USBGenericDescriptor_ENDPOINT). */
|
||||
uint8_t bDescriptorType;
|
||||
/** Address and direction of the endpoint. */
|
||||
uint8_t bEndpointAddress;
|
||||
/** Endpoint type and additional characteristics
|
||||
(for isochronous endpoints). */
|
||||
uint8_t bmAttributes;
|
||||
/** Maximum packet size (in bytes) of the endpoint. */
|
||||
uint16_t wMaxPacketSize;
|
||||
/** Polling rate of the endpoint. */
|
||||
uint8_t bInterval;
|
||||
|
||||
} __attribute__ ((__packed__)) USBEndpointDescriptor; /* GCC*/
|
||||
|
||||
|
||||
#pragma pack()
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Exported Functions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
extern uint32_t USBGenericDescriptor_GetLength(
|
||||
const USBGenericDescriptor *descriptor);
|
||||
|
||||
extern uint8_t USBGenericDescriptor_GetType(
|
||||
const USBGenericDescriptor *descriptor);
|
||||
|
||||
extern USBGenericDescriptor *USBGenericDescriptor_GetNextDescriptor(
|
||||
const USBGenericDescriptor *descriptor);
|
||||
|
||||
extern USBGenericDescriptor *USBGenericDescriptor_Parse(
|
||||
const USBGenericDescriptor * descriptor,
|
||||
uint32_t totalLength,
|
||||
USBDescriptorParseFunction parseFunction,
|
||||
void * parseArg);
|
||||
|
||||
|
||||
extern uint32_t USBConfigurationDescriptor_GetTotalLength(
|
||||
const USBConfigurationDescriptor *configuration);
|
||||
|
||||
extern uint8_t USBConfigurationDescriptor_GetNumInterfaces(
|
||||
const USBConfigurationDescriptor *configuration);
|
||||
|
||||
extern uint8_t USBConfigurationDescriptor_IsSelfPowered(
|
||||
const USBConfigurationDescriptor *configuration);
|
||||
|
||||
extern void USBConfigurationDescriptor_Parse(
|
||||
const USBConfigurationDescriptor *configuration,
|
||||
USBInterfaceDescriptor **interfaces,
|
||||
USBEndpointDescriptor **endpoints,
|
||||
USBGenericDescriptor **others);
|
||||
|
||||
extern uint8_t USBEndpointDescriptor_GetNumber(
|
||||
const USBEndpointDescriptor *endpoint);
|
||||
|
||||
extern uint8_t USBEndpointDescriptor_GetDirection(
|
||||
const USBEndpointDescriptor *endpoint);
|
||||
|
||||
extern uint8_t USBEndpointDescriptor_GetType(
|
||||
const USBEndpointDescriptor *endpoint);
|
||||
|
||||
extern uint16_t USBEndpointDescriptor_GetMaxPacketSize(
|
||||
const USBEndpointDescriptor *endpoint);
|
||||
|
||||
extern uint8_t USBEndpointDescriptor_GetInterval(
|
||||
const USBEndpointDescriptor *endpoint);
|
||||
|
||||
|
||||
/** @}*/
|
||||
/**@}*/
|
||||
#endif /* #ifndef _USBDESCRIPTORS_H_ */
|
||||
|
@ -0,0 +1,209 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \par Purpose
|
||||
*
|
||||
* Standard output methods for reporting debug information, warnings and
|
||||
* errors, which can be easily be turned on/off.
|
||||
*
|
||||
* \par Usage
|
||||
* -# Initialize the debug message port in application, for stdio printf().
|
||||
* -# Uses the TRACE_DEBUG(), TRACE_INFO(), TRACE_WARNING(), TRACE_ERROR()
|
||||
* TRACE_FATAL() macros to output traces throughout the program.
|
||||
* -# Each type of trace has a level : Debug 5, Info 4, Warning 3, Error 2
|
||||
* and Fatal 1. Disable a group of traces by changing the value of
|
||||
* TRACE_LEVEL during compilation; traces with a level bigger than TRACE_LEVEL
|
||||
* are not generated. To generate no trace, use the reserved value 0.
|
||||
* -# Trace disabling can be static or dynamic. If dynamic disabling is selected
|
||||
* the trace level can be modified in runtime. If static disabling is selected
|
||||
* the disabled traces are not compiled.
|
||||
*
|
||||
* \par traceLevels Trace level description
|
||||
* -# TRACE_DEBUG (5): Traces whose only purpose is for debugging the program,
|
||||
* and which do not produce meaningful information otherwise.
|
||||
* -# TRACE_INFO (4): Informational trace about the program execution. Should
|
||||
* enable the user to see the execution flow.
|
||||
* -# TRACE_WARNING (3): Indicates that a minor error has happened. In most case
|
||||
* it can be discarded safely; it may even be expected.
|
||||
* -# TRACE_ERROR (2): Indicates an error which may not stop the program execution,
|
||||
* but which indicates there is a problem with the code.
|
||||
* -# TRACE_FATAL (1): Indicates a major error which prevents the program from going
|
||||
* any further.
|
||||
*/
|
||||
|
||||
#ifndef _USBLIB_TRACE_H
|
||||
#define _USBLIB_TRACE_H
|
||||
|
||||
/*
|
||||
* Headers
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
* Global Definitions
|
||||
*/
|
||||
|
||||
/** Softpack Version */
|
||||
#define USBLIB_VERSION "0.1"
|
||||
|
||||
#define TRACE_LEVEL_DEBUG 5
|
||||
#define TRACE_LEVEL_INFO 4
|
||||
#define TRACE_LEVEL_WARNING 3
|
||||
#define TRACE_LEVEL_ERROR 2
|
||||
#define TRACE_LEVEL_FATAL 1
|
||||
#define TRACE_LEVEL_NO_TRACE 0
|
||||
|
||||
/* By default, all traces are output except the debug one. */
|
||||
#if !defined(TRACE_LEVEL)
|
||||
#define TRACE_LEVEL TRACE_LEVEL_INFO
|
||||
#endif
|
||||
|
||||
/* By default, trace level is static (not dynamic) */
|
||||
#if !defined(DYN_TRACES)
|
||||
#define DYN_TRACES 0
|
||||
#endif
|
||||
|
||||
#if defined(NOTRACE)
|
||||
#error "Error: NOTRACE has to be not defined !"
|
||||
#endif
|
||||
|
||||
#undef NOTRACE
|
||||
#if (DYN_TRACES==0)
|
||||
#if (TRACE_LEVEL == TRACE_LEVEL_NO_TRACE)
|
||||
#define NOTRACE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------
|
||||
* Global Macros
|
||||
* ------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef DYNTRACE
|
||||
#define DYNTRACE 0
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* Outputs a formatted string using 'printf' if the log level is high
|
||||
* enough. Can be disabled by defining TRACE_LEVEL=0 during compilation.
|
||||
* \param ... Additional parameters depending on formatted string.
|
||||
*/
|
||||
#if defined(NOTRACE)
|
||||
|
||||
/* Empty macro */
|
||||
#define TRACE_DEBUG(...) { }
|
||||
#define TRACE_INFO(...) { }
|
||||
#define TRACE_WARNING(...) { }
|
||||
#define TRACE_ERROR(...) { }
|
||||
#define TRACE_FATAL(...) { while(1); }
|
||||
|
||||
#define TRACE_DEBUG_WP(...) { }
|
||||
#define TRACE_INFO_WP(...) { }
|
||||
#define TRACE_WARNING_WP(...) { }
|
||||
#define TRACE_ERROR_WP(...) { }
|
||||
#define TRACE_FATAL_WP(...) { while(1); }
|
||||
|
||||
#elif (DYN_TRACES == 1)
|
||||
|
||||
/* Trace output depends on dwTraceLevel value */
|
||||
#define TRACE_DEBUG(...) { if (dwTraceLevel >= TRACE_LEVEL_DEBUG) { printf("-D- " __VA_ARGS__); } }
|
||||
#define TRACE_INFO(...) { if (dwTraceLevel >= TRACE_LEVEL_INFO) { printf("-I- " __VA_ARGS__); } }
|
||||
#define TRACE_WARNING(...) { if (dwTraceLevel >= TRACE_LEVEL_WARNING) { printf("-W- " __VA_ARGS__); } }
|
||||
#define TRACE_ERROR(...) { if (dwTraceLevel >= TRACE_LEVEL_ERROR) { printf("-E- " __VA_ARGS__); } }
|
||||
#define TRACE_FATAL(...) { if (dwTraceLevel >= TRACE_LEVEL_FATAL) { printf("-F- " __VA_ARGS__); while(1); } }
|
||||
|
||||
#define TRACE_DEBUG_WP(...) { if (dwTraceLevel >= TRACE_LEVEL_DEBUG) { printf(__VA_ARGS__); } }
|
||||
#define TRACE_INFO_WP(...) { if (dwTraceLevel >= TRACE_LEVEL_INFO) { printf(__VA_ARGS__); } }
|
||||
#define TRACE_WARNING_WP(...) { if (dwTraceLevel >= TRACE_LEVEL_WARNING) { printf(__VA_ARGS__); } }
|
||||
#define TRACE_ERROR_WP(...) { if (dwTraceLevel >= TRACE_LEVEL_ERROR) { printf(__VA_ARGS__); } }
|
||||
#define TRACE_FATAL_WP(...) { if (dwTraceLevel >= TRACE_LEVEL_FATAL) { printf(__VA_ARGS__); while(1); } }
|
||||
|
||||
#else
|
||||
|
||||
/* Trace compilation depends on TRACE_LEVEL value */
|
||||
#if (TRACE_LEVEL >= TRACE_LEVEL_DEBUG)
|
||||
#define TRACE_DEBUG(...) { printf("-D- " __VA_ARGS__); }
|
||||
#define TRACE_DEBUG_WP(...) { printf(__VA_ARGS__); }
|
||||
#else
|
||||
#define TRACE_DEBUG(...) { }
|
||||
#define TRACE_DEBUG_WP(...) { }
|
||||
#endif
|
||||
|
||||
#if (TRACE_LEVEL >= TRACE_LEVEL_INFO)
|
||||
#define TRACE_INFO(...) { printf("-I- " __VA_ARGS__); }
|
||||
#define TRACE_INFO_WP(...) { printf(__VA_ARGS__); }
|
||||
#else
|
||||
#define TRACE_INFO(...) { }
|
||||
#define TRACE_INFO_WP(...) { }
|
||||
#endif
|
||||
|
||||
#if (TRACE_LEVEL >= TRACE_LEVEL_WARNING)
|
||||
#define TRACE_WARNING(...) { printf("-W- " __VA_ARGS__); }
|
||||
#define TRACE_WARNING_WP(...) { printf(__VA_ARGS__); }
|
||||
#else
|
||||
#define TRACE_WARNING(...) { }
|
||||
#define TRACE_WARNING_WP(...) { }
|
||||
#endif
|
||||
|
||||
#if (TRACE_LEVEL >= TRACE_LEVEL_ERROR)
|
||||
#define TRACE_ERROR(...) { printf("-E- " __VA_ARGS__); }
|
||||
#define TRACE_ERROR_WP(...) { printf(__VA_ARGS__); }
|
||||
#else
|
||||
#define TRACE_ERROR(...) { }
|
||||
#define TRACE_ERROR_WP(...) { }
|
||||
#endif
|
||||
|
||||
#if (TRACE_LEVEL >= TRACE_LEVEL_FATAL)
|
||||
#define TRACE_FATAL(...) { printf("-F- " __VA_ARGS__); while(1); }
|
||||
#define TRACE_FATAL_WP(...) { printf(__VA_ARGS__); while(1); }
|
||||
#else
|
||||
#define TRACE_FATAL(...) { while(1); }
|
||||
#define TRACE_FATAL_WP(...) { while(1); }
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* Exported variables
|
||||
*/
|
||||
/** Depending on DYN_TRACES, dwTraceLevel is a modifable runtime variable or a define */
|
||||
#if !defined(NOTRACE) && (DYN_TRACES == 1)
|
||||
extern uint32_t dwTraceLevel ;
|
||||
#endif
|
||||
|
||||
#endif /* #ifndef _USBLIB_TRACE_H */
|
||||
|
@ -0,0 +1,81 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* 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:
|
||||
*
|
||||
* - 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* Definitions for USB Lib compiling.
|
||||
*/
|
||||
|
||||
#ifndef USBLIB_TYPES_H
|
||||
#define USBLIB_TYPES_H
|
||||
/*----------------------------------------------------------------------------
|
||||
* Includes
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Defines
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/* Define WEAK attribute */
|
||||
#ifndef WEAK
|
||||
#if defined ( __CC_ARM )
|
||||
#define WEAK __attribute__ ((weak))
|
||||
#elif defined ( __ICCARM__ )
|
||||
#define WEAK __weak
|
||||
#elif defined ( __GNUC__ )
|
||||
#define WEAK __attribute__ ((weak))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/** USB status ReturnCode */
|
||||
typedef enum _USBRC {
|
||||
USBRC_OK = 0, /**< Operation was successful */
|
||||
USBRC_SUCCESS = 0, /**< Operation was successful */
|
||||
/* Bool codes */
|
||||
USBRC_FALSE = 0, /**< As boolean TRUE */
|
||||
USBRC_TRUE = 1, /**< As boolean FALSE */
|
||||
/* Error codes */
|
||||
USBRC_BUSY, /**< EP/Device is already busy */
|
||||
USBRC_ABORTED, /**< Operation aborted due to error or stall */
|
||||
USBRC_CANCELED, /**< Operation canceled by user */
|
||||
USBRC_RESET, /**< Operation aborted due to init/reset/un-configure */
|
||||
USBRC_PARTIAL_DONE,/**< Part of operation successfully done */
|
||||
USBRC_FINISHED, /**< All operation successfully done and terminate */
|
||||
|
||||
USBRC_PARAM_ERR, /**< Failed due to parameter error */
|
||||
USBRC_STATE_ERR, /**< Failed due to state error */
|
||||
USBRC_ERROR, /**< General error */
|
||||
|
||||
USBRC_SW_NOT_SUPPORTED = 0xFD, /**< Failed due to SW not supported */
|
||||
USBRC_HW_NOT_SUPPORTED = 0xFE /**< Failed due to HW not supported */
|
||||
} USBRC;
|
||||
|
||||
#endif /* #define USBLIB_TYPES_H */
|
||||
|
@ -0,0 +1,354 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* 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:
|
||||
*
|
||||
* - 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \section Purpose
|
||||
*
|
||||
* Definitions and methods for USB request structures described by the
|
||||
* USB specification.
|
||||
*
|
||||
* \section Usage
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _USBREQUESTS_H_
|
||||
#define _USBREQUESTS_H_
|
||||
/** \addtogroup usb_general
|
||||
* @{
|
||||
* \addtogroup usb_request USB Requests
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Headers
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/* These headers were introduced in C99 by working group
|
||||
* ISO/IEC JTC1/SC22/WG14.
|
||||
*/
|
||||
#include <stdint.h>
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/*----------- Generic Request ------------*/
|
||||
|
||||
/** \addtogroup usb_request_define USB Generic Request definitions
|
||||
* @{
|
||||
* This section lists the codes of USB generic request.
|
||||
*
|
||||
* - \ref usb_request_code USB Request codes
|
||||
* - \ref USBGenericRequest_GETSTATUS
|
||||
* - \ref USBGenericRequest_CLEARFEATURE
|
||||
* - \ref USBGenericRequest_SETFEATURE
|
||||
* - \ref USBGenericRequest_SETADDRESS
|
||||
* - \ref USBGenericRequest_GETDESCRIPTOR
|
||||
* - \ref USBGenericRequest_SETDESCRIPTOR
|
||||
* - \ref USBGenericRequest_GETCONFIGURATION
|
||||
* - \ref USBGenericRequest_SETCONFIGURATION
|
||||
* - \ref USBGenericRequest_GETINTERFACE
|
||||
* - \ref USBGenericRequest_SETINTERFACE
|
||||
* - \ref USBGenericRequest_SYNCHFRAME
|
||||
*
|
||||
* - \ref usb_request_recipient USB Request Recipients
|
||||
* - \ref USBGenericRequest_DEVICE
|
||||
* - \ref USBGenericRequest_INTERFACE
|
||||
* - \ref USBGenericRequest_ENDPOINT
|
||||
* - \ref USBGenericRequest_OTHER
|
||||
*
|
||||
* - \ref usb_request_type USB Request Types
|
||||
* - \ref USBGenericRequest_STANDARD
|
||||
* - \ref USBGenericRequest_CLASS
|
||||
* - \ref USBGenericRequest_VENDOR
|
||||
*
|
||||
* - \ref usb_request_dir USB Request Directions
|
||||
* - \ref USBGenericRequest_IN
|
||||
* - \ref USBGenericRequest_OUT
|
||||
*/
|
||||
|
||||
/** \addtogroup usb_request_code USB Request codes
|
||||
* @{
|
||||
* This section lists the USB generic request codes.
|
||||
* - \ref USBGenericRequest_GETSTATUS
|
||||
* - \ref USBGenericRequest_CLEARFEATURE
|
||||
* - \ref USBGenericRequest_SETFEATURE
|
||||
* - \ref USBGenericRequest_SETADDRESS
|
||||
* - \ref USBGenericRequest_GETDESCRIPTOR
|
||||
* - \ref USBGenericRequest_SETDESCRIPTOR
|
||||
* - \ref USBGenericRequest_GETCONFIGURATION
|
||||
* - \ref USBGenericRequest_SETCONFIGURATION
|
||||
* - \ref USBGenericRequest_GETINTERFACE
|
||||
* - \ref USBGenericRequest_SETINTERFACE
|
||||
* - \ref USBGenericRequest_SYNCHFRAME
|
||||
*/
|
||||
/** GET_STATUS request code. */
|
||||
#define USBGenericRequest_GETSTATUS 0
|
||||
/** CLEAR_FEATURE request code. */
|
||||
#define USBGenericRequest_CLEARFEATURE 1
|
||||
/** SET_FEATURE request code. */
|
||||
#define USBGenericRequest_SETFEATURE 3
|
||||
/** SET_ADDRESS request code. */
|
||||
#define USBGenericRequest_SETADDRESS 5
|
||||
/** GET_DESCRIPTOR request code. */
|
||||
#define USBGenericRequest_GETDESCRIPTOR 6
|
||||
/** SET_DESCRIPTOR request code. */
|
||||
#define USBGenericRequest_SETDESCRIPTOR 7
|
||||
/** GET_CONFIGURATION request code. */
|
||||
#define USBGenericRequest_GETCONFIGURATION 8
|
||||
/** SET_CONFIGURATION request code. */
|
||||
#define USBGenericRequest_SETCONFIGURATION 9
|
||||
/** GET_INTERFACE request code. */
|
||||
#define USBGenericRequest_GETINTERFACE 10
|
||||
/** SET_INTERFACE request code. */
|
||||
#define USBGenericRequest_SETINTERFACE 11
|
||||
/** SYNCH_FRAME request code. */
|
||||
#define USBGenericRequest_SYNCHFRAME 12
|
||||
/** @}*/
|
||||
|
||||
/** \addtogroup usb_request_recipient USB Request Recipients
|
||||
* @{
|
||||
* This section lists codes of USB request recipients.
|
||||
* - \ref USBGenericRequest_DEVICE
|
||||
* - \ref USBGenericRequest_INTERFACE
|
||||
* - \ref USBGenericRequest_ENDPOINT
|
||||
* - \ref USBGenericRequest_OTHER
|
||||
*/
|
||||
/** Recipient is the whole device. */
|
||||
#define USBGenericRequest_DEVICE 0
|
||||
/** Recipient is an interface. */
|
||||
#define USBGenericRequest_INTERFACE 1
|
||||
/** Recipient is an endpoint. */
|
||||
#define USBGenericRequest_ENDPOINT 2
|
||||
/** Recipient is another entity. */
|
||||
#define USBGenericRequest_OTHER 3
|
||||
/** @}*/
|
||||
|
||||
/** \addtogroup usb_request_type USB Request Types
|
||||
* @{
|
||||
* This section lists codes of USB request types.
|
||||
* - \ref USBGenericRequest_STANDARD
|
||||
* - \ref USBGenericRequest_CLASS
|
||||
* - \ref USBGenericRequest_VENDOR
|
||||
*/
|
||||
/** Request is standard. */
|
||||
#define USBGenericRequest_STANDARD 0
|
||||
/** Request is class-specific. */
|
||||
#define USBGenericRequest_CLASS 1
|
||||
/** Request is vendor-specific. */
|
||||
#define USBGenericRequest_VENDOR 2
|
||||
/** @}*/
|
||||
|
||||
/** \addtogroup usb_request_dir USB Request Directions
|
||||
* @{
|
||||
* This section lists codes of USB request directions.
|
||||
* - \ref USBGenericRequest_IN
|
||||
* - \ref USBGenericRequest_OUT
|
||||
*/
|
||||
/** Transfer occurs from device to the host. */
|
||||
#define USBGenericRequest_OUT 0
|
||||
/** Transfer occurs from the host to the device. */
|
||||
#define USBGenericRequest_IN 1
|
||||
/** @}*/
|
||||
/** @}*/
|
||||
|
||||
|
||||
/*----------- Feature Request ------------*/
|
||||
|
||||
/** \addtogroup usb_feature_def USB Feature Request Definitions
|
||||
* @{
|
||||
* This section lists codes of USB Feature Request
|
||||
*
|
||||
* - \ref usb_feature_sel USB Feature selectors
|
||||
* - \ref USBFeatureRequest_ENDPOINTHALT
|
||||
* - \ref USBFeatureRequest_DEVICEREMOTEWAKEUP
|
||||
* - \ref USBFeatureRequest_TESTMODE
|
||||
*
|
||||
* - \ref usb_test_sel USB Test mode selectors
|
||||
* - \ref USBFeatureRequest_TESTJ
|
||||
* - \ref USBFeatureRequest_TESTK
|
||||
* - \ref USBFeatureRequest_TESTSE0NAK
|
||||
* - \ref USBFeatureRequest_TESTPACKET
|
||||
* - \ref USBFeatureRequest_TESTFORCEENABLE
|
||||
* - \ref USBFeatureRequest_TESTSENDZLP
|
||||
*/
|
||||
|
||||
/** \addtogroup usb_feature_sel USB Feature selectors
|
||||
* @{
|
||||
* This section lists codes of USB feature selectors.
|
||||
* - \ref USBFeatureRequest_ENDPOINTHALT
|
||||
* - \ref USBFeatureRequest_DEVICEREMOTEWAKEUP
|
||||
* - \ref USBFeatureRequest_TESTMODE
|
||||
*/
|
||||
/** Halt feature of an endpoint. */
|
||||
#define USBFeatureRequest_ENDPOINTHALT 0
|
||||
/** Remote wake-up feature of the device. */
|
||||
#define USBFeatureRequest_DEVICEREMOTEWAKEUP 1
|
||||
/** Test mode of the device. */
|
||||
#define USBFeatureRequest_TESTMODE 2
|
||||
/** OTG set feature */
|
||||
#define USBFeatureRequest_OTG 0x0B
|
||||
/** OTG b_hnp_enable */
|
||||
#define USBFeatureRequest_OTG_B_HNP_ENABLE 3
|
||||
/** OTG a_hnp_support */
|
||||
#define USBFeatureRequest_OTG_A_HNP_SUPPORT 4
|
||||
/** OTG a_alt_hnp_support */
|
||||
#define USBFeatureRequest_OTG_A_ALT_HNP_SUPPORT 5
|
||||
/** @}*/
|
||||
|
||||
/** \addtogroup usb_test_sel USB Test mode selectors
|
||||
* @{
|
||||
* This section lists codes of USB high speed test mode selectors.
|
||||
* - \ref USBFeatureRequest_TESTJ
|
||||
* - \ref USBFeatureRequest_TESTK
|
||||
* - \ref USBFeatureRequest_TESTSE0NAK
|
||||
* - \ref USBFeatureRequest_TESTPACKET
|
||||
* - \ref USBFeatureRequest_TESTFORCEENABLE
|
||||
* - \ref USBFeatureRequest_TESTSENDZLP
|
||||
*/
|
||||
|
||||
/** Tests the high-output drive level on the D+ line. */
|
||||
#define USBFeatureRequest_TESTJ 1
|
||||
/** Tests the high-output drive level on the D- line. */
|
||||
#define USBFeatureRequest_TESTK 2
|
||||
/** Tests the output impedance, low-level output voltage and loading
|
||||
characteristics. */
|
||||
#define USBFeatureRequest_TESTSE0NAK 3
|
||||
/** Tests rise and fall times, eye patterns and jitter. */
|
||||
#define USBFeatureRequest_TESTPACKET 4
|
||||
/** Tests the hub disconnect detection. */
|
||||
#define USBFeatureRequest_TESTFORCEENABLE 5
|
||||
/** Send a ZLP in Test Mode. */
|
||||
#define USBFeatureRequest_TESTSENDZLP 6
|
||||
/** @}*/
|
||||
/** @}*/
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Types
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Function types
|
||||
*/
|
||||
|
||||
/*
|
||||
* Descriptor structs types
|
||||
*/
|
||||
#pragma pack(1)
|
||||
#if defined ( __CC_ARM ) /* Keil ¦ÌVision 4 */
|
||||
#elif defined ( __ICCARM__ ) /* IAR Ewarm 5.41+ */
|
||||
#define __attribute__(...)
|
||||
#elif defined ( __GNUC__ ) /* GCC CS3 2009q3-68 */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Generic USB SETUP request sent over Control endpoints.
|
||||
*/
|
||||
typedef struct {
|
||||
|
||||
/** Type of request
|
||||
* \sa usb_request_recipient "USB Request Recipients"
|
||||
* \sa usb_request_type "USB Request Types"
|
||||
* \sa usb_request_dir "USB Request Directions" */
|
||||
uint8_t bmRequestType:8;
|
||||
/** Request code
|
||||
* \sa usb_request_code "USB Request Codes" */
|
||||
uint8_t bRequest:8;
|
||||
/** Request-specific value parameter. */
|
||||
uint16_t wValue:16;
|
||||
/** Request-specific index parameter. */
|
||||
uint16_t wIndex:16;
|
||||
/** Expected length (in bytes) of the data phase. */
|
||||
uint16_t wLength:16;
|
||||
|
||||
} USBGenericRequest;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Exported Functions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
extern uint8_t USBGenericRequest_GetType(
|
||||
const USBGenericRequest *request);
|
||||
|
||||
extern uint8_t USBGenericRequest_GetRequest(
|
||||
const USBGenericRequest *request);
|
||||
|
||||
extern uint16_t USBGenericRequest_GetValue(
|
||||
const USBGenericRequest *request);
|
||||
|
||||
extern uint16_t USBGenericRequest_GetIndex(
|
||||
const USBGenericRequest *request);
|
||||
|
||||
extern uint16_t USBGenericRequest_GetLength(
|
||||
const USBGenericRequest *request);
|
||||
|
||||
extern uint8_t USBGenericRequest_GetEndpointNumber(
|
||||
const USBGenericRequest *request);
|
||||
|
||||
extern uint8_t USBGenericRequest_GetRecipient(
|
||||
const USBGenericRequest *request);
|
||||
|
||||
extern uint8_t USBGenericRequest_GetDirection(
|
||||
const USBGenericRequest *request);
|
||||
|
||||
|
||||
extern uint8_t USBGetDescriptorRequest_GetDescriptorType(
|
||||
const USBGenericRequest *request);
|
||||
|
||||
extern uint8_t USBGetDescriptorRequest_GetDescriptorIndex(
|
||||
const USBGenericRequest *request);
|
||||
|
||||
|
||||
extern uint8_t USBSetAddressRequest_GetAddress(
|
||||
const USBGenericRequest *request);
|
||||
|
||||
|
||||
extern uint8_t USBSetConfigurationRequest_GetConfiguration(
|
||||
const USBGenericRequest *request);
|
||||
|
||||
|
||||
extern uint8_t USBInterfaceRequest_GetInterface(
|
||||
const USBGenericRequest *request);
|
||||
|
||||
extern uint8_t USBInterfaceRequest_GetAlternateSetting(
|
||||
const USBGenericRequest *request);
|
||||
|
||||
|
||||
extern uint8_t USBFeatureRequest_GetFeatureSelector(
|
||||
const USBGenericRequest *request);
|
||||
|
||||
extern uint8_t USBFeatureRequest_GetTestSelector(
|
||||
const USBGenericRequest *request);
|
||||
|
||||
/** @}*/
|
||||
/**@}*/
|
||||
#endif /* #ifndef _USBREQUESTS_H_ */
|
||||
|
@ -0,0 +1,100 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* 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:
|
||||
*
|
||||
* - 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file usb.h
|
||||
*
|
||||
* Definition of SAM9XX5-EK usb library
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _usb_
|
||||
#define _usb_
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
#include "board.h"
|
||||
|
||||
#include "include/USBD.h"
|
||||
#include "include/USBD_HAL.h"
|
||||
|
||||
#include "include/USBDescriptors.h"
|
||||
|
||||
#include "include/USBDDriver.h"
|
||||
|
||||
#include "include/AUDDescriptors.h"
|
||||
#include "include/AUDDFunction.h"
|
||||
#include "include/AUDDSpeakerDriver.h"
|
||||
#include "include/AUDDSpeakerPhone.h"
|
||||
#include "include/AUDDSpeakerPhoneDriver.h"
|
||||
#include "include/AUDDStream.h"
|
||||
#include "include/AUDRequests.h"
|
||||
|
||||
#include "include/CDCAUDDDriver.h"
|
||||
#include "include/CDCDescriptors.h"
|
||||
#include "include/CDCDSerial.h"
|
||||
#include "include/CDCDSerialDriver.h"
|
||||
#include "include/CDCDSerialPort.h"
|
||||
#include "include/CDCHIDDDriver.h"
|
||||
#include "include/CDCMSDDriver.h"
|
||||
#include "include/CDCNotifications.h"
|
||||
#include "include/CDCRequests.h"
|
||||
|
||||
#include "include/DUALCDCDDriver.h"
|
||||
|
||||
#include "include/HIDAUDDDriver.h"
|
||||
#include "include/HIDDescriptors.h"
|
||||
#include "include/HIDDFunction.h"
|
||||
#include "include/HIDDKeyboard.h"
|
||||
#include "include/HIDDKeyboardDriver.h"
|
||||
#include "include/HIDDMouseDriver.h"
|
||||
#include "include/HIDDTransferDriver.h"
|
||||
#include "include/HIDMSDDriver.h"
|
||||
#include "include/HIDReports.h"
|
||||
#include "include/HIDRequests.h"
|
||||
#include "include/HIDUsages.h"
|
||||
|
||||
#include "include/MSD.h"
|
||||
#include "include/MSDDriver.h"
|
||||
#include "include/MSDDStateMachine.h"
|
||||
#include "include/MSDescriptors.h"
|
||||
#include "include/MSDFunction.h"
|
||||
#include "include/MSDIOFifo.h"
|
||||
#include "include/MSDLun.h"
|
||||
|
||||
#include "include/SBC.h"
|
||||
#include "include/SBCMethods.h"
|
||||
|
||||
#include "include/USBVideo.h"
|
||||
|
||||
#include "include/USBLib_Types.h"
|
||||
#include "include/USBRequests.h"
|
||||
|
||||
#endif /* #ifndef _usb_ */
|
Loading…
Reference in New Issue