Renamed main folder to firmware

This commit is contained in:
Christina Quast
2015-04-07 18:24:06 +02:00
parent f5cd7efede
commit 5a67c0fef3
326 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,70 @@
/* ----------------------------------------------------------------------------
* 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
*
* This file implements functions for USB AUDIO class feature unit requests.
*/
/** \addtogroup usb_audio
*@{
*/
/*----------------------------------------------------------------------------
* Headers
*----------------------------------------------------------------------------*/
#include "AUDRequests.h"
/*----------------------------------------------------------------------------
* Exported functions
*----------------------------------------------------------------------------*/
/**
* Returns the control selector value indicating the target of a Feature Unit
* request.
* \param request Pointer to a USBGenericRequest instance.
* \sa usb_audio_ctrl_sel USB Audio Control selector values
*/
uint8_t AUDFeatureUnitRequest_GetControl(const USBGenericRequest *request)
{
return ((USBGenericRequest_GetValue(request) >> 8) & 0xFF);
}
/**
* Returns the channel number of a Feature unit which should be altered by the
* given request.
* \param request Pointer to a USBGenericRequest instance.
*/
uint8_t AUDFeatureUnitRequest_GetChannel(const USBGenericRequest *request)
{
return (USBGenericRequest_GetValue(request) & 0xFF);
}
/**@}*/

View File

@@ -0,0 +1,67 @@
/* ----------------------------------------------------------------------------
* 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
*
* This file implements functions for USB AUDIO class requests.
*/
/** \addtogroup usb_audio
*@{
*/
/*----------------------------------------------------------------------------
* Headers
*----------------------------------------------------------------------------*/
#include "AUDRequests.h"
/*----------------------------------------------------------------------------
* Exported functions
*----------------------------------------------------------------------------*/
/**
* Returns the ID of the unit or terminal targetted by an USB audio request.
* \param request Pointer to a USBGenericRequest instance.
*/
uint8_t AUDGenericRequest_GetEntity(const USBGenericRequest *request)
{
return ((USBGenericRequest_GetIndex(request) >> 8) & 0xFF);
}
/**
* Returns the ID of the interface targetted by an USB audio request.
* \param request Pointer to a USBGenericRequest instance.
*/
uint8_t AUDGenericRequest_GetInterface(const USBGenericRequest *request)
{
return (USBGenericRequest_GetIndex(request) & 0xFF);
}
/**@}*/

View File

@@ -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;
}
/**@}*/

View File

@@ -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;
}
}
/**@}*/

View File

@@ -0,0 +1,310 @@
/* ----------------------------------------------------------------------------
* 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)
{
return endpoint->wMaxPacketSize;
}
/**
* 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;
}
}
/**@}*/

View File

@@ -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;
}
/**@}*/

View File

@@ -0,0 +1,73 @@
/* ----------------------------------------------------------------------------
* 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: HIDIdleRequest implementation
About: Purpose
Implementation of the HIDIdleRequest methods.
*/
/**\addtogroup usb_hid
*@{
*/
/*------------------------------------------------------------------------------
* Headers
*------------------------------------------------------------------------------*/
#include "HIDRequests.h"
/*------------------------------------------------------------------------------
* Exported functions
*------------------------------------------------------------------------------*/
/**
* Indicates the ID of the report targetted by a SET_IDLE or GET_IDLE
* request. This value should be 0 if report IDs are not used.
* \param request Pointer to a USBGenericRequest instance.
* \return Requested report ID.
*/
uint8_t HIDIdleRequest_GetReportId(const USBGenericRequest *request)
{
return (USBGenericRequest_GetValue(request) & 0xFF);
}
/**
* Retrieves the Idle rate (in milliseconds) indicated by a SET_IDLE
* request.
* \param request Pointer to a USBGenericRequest instance.
* \return New idle rate for the report.
*/
uint8_t HIDIdleRequest_GetIdleRate(const USBGenericRequest *request)
{
return ((USBGenericRequest_GetValue(request) >> 8) & 0xFF);
}
/**@}*/

View File

@@ -0,0 +1,61 @@
/* ----------------------------------------------------------------------------
* 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: HIDKeypad implementation
About: Purpose
Implementation of HID keypad usage page methods.
*/
/**\addtogroup usb_hid
*@{
*/
/*------------------------------------------------------------------------------
* Headers
*------------------------------------------------------------------------------*/
#include "HIDUsages.h"
/*------------------------------------------------------------------------------
* Exported functions
*------------------------------------------------------------------------------*/
/**
* Indicates if the given key code is associated with a modified key.
* \param key Key code.
* \return 1 if the key code represents a modifier key; otherwise 0.
*/
uint8_t HIDKeypad_IsModifierKey(uint8_t key)
{
return ((key >= HIDKeypad_LEFTCONTROL) && (key <= HIDKeypad_RIGHTGUI));
}
/**@}*/

View File

@@ -0,0 +1,73 @@
/* ----------------------------------------------------------------------------
* 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: HIDReportRequest implementation
About: Purpose
Implementation of the HIDReportRequest methods.
*/
/**\addtogroup usb_hid
*@{
*/
/*------------------------------------------------------------------------------
* Headers
*------------------------------------------------------------------------------*/
#include "HIDRequests.h"
/*------------------------------------------------------------------------------
* Exported functions
*------------------------------------------------------------------------------*/
/**
* Indicates the type of report targetted by a SET_REPORT or GET_REPORT
* request.
* \param request Pointer to a USBGenericRequest instance.
* \return Requested report type (see "HID Report Types").
*/
uint8_t HIDReportRequest_GetReportType(const USBGenericRequest *request)
{
return ((USBGenericRequest_GetValue(request) >> 8) & 0xFF);
}
/**
* Indicates the ID of the report targetted by a SET_REPORT or GET_REPORT
* request. This value should be 0 if report IDs are not used.
* \param request Pointer to a USBGenericRequest instance.
* \return Requested report ID.
*/
uint8_t HIDReportRequest_GetReportId(const USBGenericRequest *request)
{
return (USBGenericRequest_GetValue(request) & 0xFF);
}
/**@}*/