Renamed main folder to firmware
@@ -0,0 +1,235 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* 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 */
|
||||
|
||||
/** \addtogroup usbd_aud_fun
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Headers
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
#include <USBLib_Trace.h>
|
||||
|
||||
#include <AUDDFunction.h>
|
||||
#include <AUDDSpeakerPhone.h>
|
||||
|
||||
#include <AUDRequests.h>
|
||||
|
||||
#include <USBD.h>
|
||||
#include <USBD_HAL.h>
|
||||
#include <USBDDriver.h>
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Internal types
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* \brief Audio speaker driver struct.
|
||||
*/
|
||||
typedef struct _AUDDFunction {
|
||||
/** Speaker & Phone function */
|
||||
AUDDSpeakerPhone drv;
|
||||
/** Stream instance for speaker */
|
||||
AUDDStream speaker;
|
||||
/** Stream instance for microphone */
|
||||
AUDDStream mic;
|
||||
} AUDDFunction;
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Internal variables
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/** Global USB audio function driver instance. */
|
||||
static AUDDFunction auddFunction;
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Internal functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Callback triggerred after the mute or volume status of the channel has been
|
||||
* changed.
|
||||
* \param ec Event code.
|
||||
* \param channel Channel number.
|
||||
* \param pArg Pointer to AUDDStream instance.
|
||||
*/
|
||||
static void AUDDFunction_EventCallback(uint32_t ec,
|
||||
uint8_t channel,
|
||||
AUDDStream *pArg)
|
||||
{
|
||||
AUDDFunction *pAudf = &auddFunction;
|
||||
uint8_t mic = ((uint32_t)pArg == (uint32_t)(&pAudf->mic));
|
||||
if (ec == AUDD_EC_MuteChanged) {
|
||||
if (AUDDFunction_MuteChanged)
|
||||
AUDDFunction_MuteChanged(mic, channel, pArg->bmMute);
|
||||
}
|
||||
else if (ec == AUDD_EC_VolumeChanged) {
|
||||
/* Not supported now */
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Initializes an USB audio speaker device driver, as well as the underlying
|
||||
* USB controller.
|
||||
*/
|
||||
void AUDDFunction_Initialize(USBDDriver *pUsbd, uint8_t bInterface)
|
||||
{
|
||||
AUDDFunction *pAudf = &auddFunction;
|
||||
AUDDSpeakerPhone *pDrv = &pAudf->drv;
|
||||
AUDDStream *pSpk = &pAudf->speaker;
|
||||
AUDDStream *pMic = &pAudf->mic;
|
||||
|
||||
/* 0: Speaker */
|
||||
AUDDSpeakerPhone_InitializeStream(
|
||||
pSpk, AUDDFunction_MaxNumSpeakerChannels, 0,
|
||||
(AUDDStreamEventCallback)AUDDFunction_EventCallback,
|
||||
(void*)pSpk);
|
||||
/* 1: Mic */
|
||||
AUDDSpeakerPhone_InitializeStream(
|
||||
pMic, AUDDFunction_MaxNumMicrophoneChannels, 0,
|
||||
(AUDDStreamEventCallback)AUDDFunction_EventCallback,
|
||||
(void*)pMic);
|
||||
/* Audio Driver initialize */
|
||||
AUDDSpeakerPhone_Initialize(pDrv, pUsbd, pSpk, pMic);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure function with expected descriptors and start functionality.
|
||||
* Usually invoked when device is configured.
|
||||
* \pDescriptors Pointer to the descriptors for function configure.
|
||||
* \wLength Length of descriptors in number of bytes.
|
||||
*/
|
||||
void AUDDFunction_Configure(USBGenericDescriptor *pDescriptors,
|
||||
uint16_t wLength)
|
||||
{
|
||||
AUDDFunction *pAudf = &auddFunction;
|
||||
AUDDSpeakerPhone *pDrv = &pAudf->drv;
|
||||
AUDDSpeakerPhone_ParseInterfaces(pDrv, pDescriptors, wLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked whenever the active setting of an interface is changed by the
|
||||
* host. Changes the status of the third LED accordingly.
|
||||
* \param interface Interface number.
|
||||
* \param setting Newly active setting.
|
||||
*/
|
||||
void AUDDFunction_InterfaceSettingChangedHandler(uint8_t interface,
|
||||
uint8_t setting)
|
||||
{
|
||||
AUDDFunction *pAudf = &auddFunction;
|
||||
AUDDSpeakerPhone *pDrv = &pAudf->drv;
|
||||
if (setting == 0) AUDDSpeakerPhone_CloseStream(pDrv, interface);
|
||||
if (AUDDFunction_StreamSettingChanged) {
|
||||
uint8_t mic = (interface == pDrv->pMicrophone->bAsInterface);
|
||||
AUDDFunction_StreamSettingChanged(mic, setting);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles AUDIO-specific USB requests sent by the host
|
||||
* \param request Pointer to a USBGenericRequest instance.
|
||||
* \return USBRC_SUCCESS if request is handled.
|
||||
*/
|
||||
uint32_t AUDDFunction_RequestHandler(
|
||||
const USBGenericRequest *request)
|
||||
{
|
||||
AUDDFunction *pAudf = &auddFunction;
|
||||
AUDDSpeakerPhone *pDrv = &pAudf->drv;
|
||||
return AUDDSpeakerPhone_RequestHandler(pDrv, request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads incoming audio data sent by the USB host into the provided buffer.
|
||||
* When the transfer is complete, an optional callback function is invoked.
|
||||
* \param buffer Pointer to the data storage buffer.
|
||||
* \param length Size of the buffer in bytes.
|
||||
* \param callback Optional callback function.
|
||||
* \param argument Optional argument to the callback function.
|
||||
* \return <USBD_STATUS_SUCCESS> if the transfer is started successfully;
|
||||
* otherwise an error code.
|
||||
*/
|
||||
uint8_t AUDDFunction_Read(void *buffer,
|
||||
uint32_t length,
|
||||
TransferCallback callback,
|
||||
void *argument)
|
||||
{
|
||||
AUDDFunction *pAudf = &auddFunction;
|
||||
AUDDSpeakerPhone *pDrv = &pAudf->drv;
|
||||
return AUDDSpeakerPhone_Read(pDrv, buffer, length, callback, argument);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize Frame List for sending audio data.
|
||||
*
|
||||
* \param pListInit Pointer to the allocated list for audio write.
|
||||
* \param pDmaInit Pointer to the allocated DMA descriptors for autio write
|
||||
* (if DMA supported).
|
||||
* \param listSize Circular list size.
|
||||
* \param delaySize Start transfer after delaySize frames filled in.
|
||||
* \param callback Optional callback function for transfer.
|
||||
* \param argument Optional callback argument.
|
||||
* \return USBD_STATUS_SUCCESS if setup successfully; otherwise an error code.
|
||||
*/
|
||||
uint8_t AUDDFunction_SetupWrite(void * pListInit,
|
||||
void * pDmaInit,
|
||||
uint16_t listSize,
|
||||
uint16_t delaySize,
|
||||
TransferCallback callback,
|
||||
void * argument)
|
||||
{
|
||||
AUDDFunction *pAudf = &auddFunction;
|
||||
AUDDSpeakerPhone *pDrv = &pAudf->drv;
|
||||
return AUDDSpeakerPhone_SetupWrite(pDrv,
|
||||
pListInit, pDmaInit, listSize, delaySize,
|
||||
callback, argument);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add frame buffer to audio sending list.
|
||||
* \buffer Pointer to data frame to send.
|
||||
* \length Frame size in bytes.
|
||||
* \return USBD_STATUS_SUCCESS if the transfer is started successfully;
|
||||
* otherwise an error code.
|
||||
*/
|
||||
uint8_t AUDDFunction_Write(void* buffer, uint16_t length)
|
||||
{
|
||||
AUDDFunction *pAudf = &auddFunction;
|
||||
AUDDSpeakerPhone *pDrv = &pAudf->drv;
|
||||
return AUDDSpeakerPhone_Write(pDrv, buffer, length);
|
||||
}
|
||||
|
||||
/**@}*/
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** \addtogroup usbd_composite_cdcaud
|
||||
*@{
|
||||
*/
|
||||
/*---------------------------------------------------------------------------
|
||||
* Headers
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <USBLib_Trace.h>
|
||||
|
||||
#include <CDCAUDDDriver.h>
|
||||
#include <CDCDSerial.h>
|
||||
#include <AUDDFunction.h>
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Defines
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Types
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Internal variables
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/** Array for storing the current setting of each interface */
|
||||
static uint8_t bAltInterfaces[CDCAUDDDriverDescriptors_MaxNumInterfaces];
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Internal functions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Initializes the USB device composite device driver.
|
||||
*/
|
||||
void CDCAUDDDriver_Initialize(const USBDDriverDescriptors *pDescriptors)
|
||||
{
|
||||
USBDDriver *pUsbd = USBD_GetDriver();
|
||||
|
||||
/* Initialize the standard USB driver */
|
||||
USBDDriver_Initialize(pUsbd,
|
||||
pDescriptors,
|
||||
bAltInterfaces);
|
||||
|
||||
/* CDC */
|
||||
CDCDSerial_Initialize(pUsbd, CDCAUDDDriverDescriptors_CDC_INTERFACE);
|
||||
/* Audio */
|
||||
AUDDFunction_Initialize(pUsbd, CDCAUDDDriverDescriptors_AUD_INTERFACE);
|
||||
|
||||
/* Initialize the USB driver */
|
||||
USBD_Init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked whenever the configuration value of a device is changed by the host
|
||||
* \param cfgnum Configuration number.
|
||||
*/
|
||||
void CDCAUDDDriver_ConfigurationChangedHandler(uint8_t cfgnum)
|
||||
{
|
||||
USBDDriver *pUsbd = USBD_GetDriver();
|
||||
USBConfigurationDescriptor *pDesc;
|
||||
if (cfgnum > 0) {
|
||||
pDesc = USBDDriver_GetCfgDescriptors(pUsbd, cfgnum);
|
||||
/* CDC */
|
||||
CDCDSerial_ConfigureFunction((USBGenericDescriptor*)pDesc,
|
||||
pDesc->wTotalLength);
|
||||
/* AUD */
|
||||
AUDDFunction_Configure((USBGenericDescriptor*)pDesc,
|
||||
pDesc->wTotalLength);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked whenever the active setting of an interface is changed by the
|
||||
* host. Changes the status of the third LED accordingly.
|
||||
* \param interface Interface number.
|
||||
* \param setting Newly active setting.
|
||||
*/
|
||||
void CDCAUDDDriver_InterfaceSettingChangedHandler(uint8_t interface,
|
||||
uint8_t setting)
|
||||
{
|
||||
AUDDFunction_InterfaceSettingChangedHandler(interface, setting);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles composite-specific USB requests sent by the host, and forwards
|
||||
* standard ones to the USB device driver.
|
||||
* \param request Pointer to a USBGenericRequest instance.
|
||||
*/
|
||||
void CDCAUDDDriver_RequestHandler(const USBGenericRequest *request)
|
||||
{
|
||||
USBDDriver *pUsbd = USBD_GetDriver();
|
||||
|
||||
TRACE_INFO_WP("NewReq ");
|
||||
|
||||
if (CDCDSerial_RequestHandler(request) == USBRC_SUCCESS)
|
||||
return;
|
||||
|
||||
if (AUDDFunction_RequestHandler(request) == USBRC_SUCCESS)
|
||||
return;
|
||||
|
||||
USBDDriver_RequestHandler(pUsbd, request);
|
||||
}
|
||||
|
||||
/**@}*/
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** \addtogroup usbd_composite_cdchid
|
||||
*@{
|
||||
*/
|
||||
/*---------------------------------------------------------------------------
|
||||
* Headers
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <USBLib_Trace.h>
|
||||
|
||||
#include <CDCHIDDDriver.h>
|
||||
#include <CDCDSerial.h>
|
||||
#include <HIDDKeyboard.h>
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Defines
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Types
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Internal variables
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Internal functions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Initializes the USB device composite device driver.
|
||||
*/
|
||||
void CDCHIDDDriver_Initialize(const USBDDriverDescriptors *pDescriptors)
|
||||
{
|
||||
USBDDriver *pUsbd = USBD_GetDriver();
|
||||
|
||||
/* Initialize the standard USB driver */
|
||||
USBDDriver_Initialize(pUsbd,
|
||||
pDescriptors,
|
||||
0);
|
||||
|
||||
/* CDC */
|
||||
CDCDSerial_Initialize(pUsbd, CDCHIDDDriverDescriptors_CDC_INTERFACE);
|
||||
/* HID */
|
||||
HIDDKeyboard_Initialize(pUsbd, CDCHIDDDriverDescriptors_HID_INTERFACE);
|
||||
|
||||
/* Initialize the USB driver */
|
||||
USBD_Init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked whenever the configuration value of a device is changed by the host
|
||||
* \param cfgnum Configuration number.
|
||||
*/
|
||||
void CDCHIDDDriver_ConfigurationChangedHandler(uint8_t cfgnum)
|
||||
{
|
||||
USBDDriver *pUsbd = USBD_GetDriver();
|
||||
USBConfigurationDescriptor *pDesc;
|
||||
if (cfgnum > 0) {
|
||||
pDesc = USBDDriver_GetCfgDescriptors(pUsbd, cfgnum);
|
||||
/* CDC */
|
||||
CDCDSerial_ConfigureFunction((USBGenericDescriptor*)pDesc,
|
||||
pDesc->wTotalLength);
|
||||
/* HID */
|
||||
HIDDKeyboard_ConfigureFunction((USBGenericDescriptor*)pDesc,
|
||||
pDesc->wTotalLength);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles composite-specific USB requests sent by the host, and forwards
|
||||
* standard ones to the USB device driver.
|
||||
* \param request Pointer to a USBGenericRequest instance.
|
||||
*/
|
||||
void CDCHIDDDriver_RequestHandler(const USBGenericRequest *request)
|
||||
{
|
||||
USBDDriver *pUsbd = USBD_GetDriver();
|
||||
|
||||
TRACE_INFO_WP("NewReq ");
|
||||
|
||||
if (CDCDSerial_RequestHandler(request) == USBRC_SUCCESS)
|
||||
return;
|
||||
|
||||
if (HIDDKeyboard_RequestHandler(request) == USBRC_SUCCESS)
|
||||
return;
|
||||
|
||||
USBDDriver_RequestHandler(pUsbd, request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a remote wake-up sequence if the host has explicitely enabled it
|
||||
* by sending the appropriate SET_FEATURE request.
|
||||
*/
|
||||
void CDCHIDDDriver_RemoteWakeUp(void)
|
||||
{
|
||||
USBDDriver *pUsbd = USBD_GetDriver();
|
||||
|
||||
/* Remote wake-up has been enabled */
|
||||
if (USBDDriver_IsRemoteWakeUpEnabled(pUsbd)) {
|
||||
|
||||
USBD_RemoteWakeUp();
|
||||
}
|
||||
}
|
||||
|
||||
/**@}*/
|
||||
@@ -0,0 +1,128 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* 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 */
|
||||
/** \addtogroup usbd_composite_cdcmsd
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Headers
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <USBLib_Trace.h>
|
||||
|
||||
#include <CDCMSDDriver.h>
|
||||
|
||||
#include <CDCDSerial.h>
|
||||
#include <MSDFunction.h>
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Defines
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Types
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Internal variables
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Internal functions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Initializes the USB device CDCMSD device driver.
|
||||
*/
|
||||
void CDCMSDDriver_Initialize(
|
||||
const USBDDriverDescriptors *pDescriptors,
|
||||
MSDLun *pLuns, unsigned char numLuns)
|
||||
{
|
||||
USBDDriver *pUsbd = USBD_GetDriver();
|
||||
|
||||
/* Initialize the standard USB driver */
|
||||
USBDDriver_Initialize(pUsbd, pDescriptors, 0);
|
||||
|
||||
/* CDC */
|
||||
CDCDSerial_Initialize(pUsbd, CDCMSDDriverDescriptors_CDC_INTERFACE);
|
||||
|
||||
/* MSD */
|
||||
MSDFunction_Initialize(pUsbd, CDCMSDDriverDescriptors_MSD_INTERFACE,
|
||||
pLuns, numLuns);
|
||||
|
||||
/* Initialize the USB driver */
|
||||
USBD_Init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked whenever the configuration value of a device is changed by the host
|
||||
* \param cfgnum Configuration number.
|
||||
*/
|
||||
void CDCMSDDriver_ConfigurationChangedHandler(unsigned char cfgnum)
|
||||
{
|
||||
USBDDriver *pUsbd = USBD_GetDriver();
|
||||
USBConfigurationDescriptor *pDesc;
|
||||
if (cfgnum > 0) {
|
||||
pDesc = USBDDriver_GetCfgDescriptors(pUsbd, cfgnum);
|
||||
/* CDC */
|
||||
CDCDSerial_ConfigureFunction((USBGenericDescriptor*)pDesc,
|
||||
pDesc->wTotalLength);
|
||||
/* MSD */
|
||||
MSDFunction_Configure((USBGenericDescriptor*)pDesc,
|
||||
pDesc->wTotalLength);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles CDCMSD-specific USB requests sent by the host, and forwards
|
||||
* standard ones to the USB device driver.
|
||||
* \param request Pointer to a USBGenericRequest instance.
|
||||
*/
|
||||
void CDCMSDDriver_RequestHandler(const USBGenericRequest *request)
|
||||
{
|
||||
USBDDriver *pUsbd = USBD_GetDriver();
|
||||
|
||||
TRACE_INFO_WP("NewReq ");
|
||||
|
||||
if (CDCDSerial_RequestHandler(request) == USBRC_SUCCESS)
|
||||
return;
|
||||
|
||||
if (MSDFunction_RequestHandler(request) == USBRC_SUCCESS)
|
||||
return;
|
||||
|
||||
USBDDriver_RequestHandler(pUsbd, request);
|
||||
}
|
||||
|
||||
/**@}*/
|
||||
|
||||
@@ -0,0 +1,194 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* 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 */
|
||||
/** \addtogroup usbd_composite_cdccdc
|
||||
*@{
|
||||
*/
|
||||
/*---------------------------------------------------------------------------
|
||||
* Headers
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/* GENERAL */
|
||||
#include <USBLib_Trace.h>
|
||||
|
||||
/* USB */
|
||||
#include <USBD.h>
|
||||
#include <USBD_HAL.h>
|
||||
#include <USBDDriver.h>
|
||||
|
||||
/* - DUALCDC */
|
||||
#include <DUALCDCDDriver.h>
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Defines
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/** Number of CDC serial ports */
|
||||
#define NUM_PORTS 2
|
||||
|
||||
/** Interface setting spaces (4 byte aligned) */
|
||||
#define NUM_INTERFACES ((DUALCDCDDriverDescriptors_NUMINTERFACE+3)&0xFC)
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Types
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/** Dual-CDC-Serial device driver struct */
|
||||
typedef struct _DualCdcdSerialDriver {
|
||||
/** CDC Serial Port List */
|
||||
CDCDSerialPort cdcdSerialPort[NUM_PORTS];
|
||||
} DualCdcdSerialDriver;
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Internal variables
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/** Dual CDC Serial device driver instance */
|
||||
DualCdcdSerialDriver dualcdcdDriver;
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Internal functions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Initializes the USB device composite device driver.
|
||||
* \param pDescriptors Pointer to Descriptors list for CDC Serial Device.
|
||||
*/
|
||||
void DUALCDCDDriver_Initialize(const USBDDriverDescriptors *pDescriptors)
|
||||
{
|
||||
USBDDriver *pUsbd = USBD_GetDriver();
|
||||
CDCDSerialPort *pCdcd = &dualcdcdDriver.cdcdSerialPort[0];
|
||||
|
||||
TRACE_INFO("DUALCDCDDriver_Initialize\n\r");
|
||||
|
||||
pCdcd = &dualcdcdDriver.cdcdSerialPort[0];
|
||||
CDCDSerialPort_Initialize(pCdcd, pUsbd,
|
||||
0,
|
||||
0,
|
||||
DUALCDCDDriverDescriptors_INTERFACENUM0, 2);
|
||||
|
||||
pCdcd = &dualcdcdDriver.cdcdSerialPort[1];
|
||||
CDCDSerialPort_Initialize(pCdcd, pUsbd,
|
||||
0,
|
||||
0,
|
||||
DUALCDCDDriverDescriptors_INTERFACENUM1, 2);
|
||||
|
||||
/* Initialize the standard USB driver */
|
||||
USBDDriver_Initialize(pUsbd,
|
||||
pDescriptors,
|
||||
0);
|
||||
/* Initialize the USB driver */
|
||||
USBD_Init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked whenever the active configuration of device is changed by the
|
||||
* host.
|
||||
* \param cfgnum Configuration number.
|
||||
*/
|
||||
void DUALCDCDDriver_ConfigurationChangeHandler(uint8_t cfgnum)
|
||||
{
|
||||
CDCDSerialPort *pCdcd = &dualcdcdDriver.cdcdSerialPort[0];
|
||||
USBDDriver *pUsbd = pCdcd->pUsbd;
|
||||
USBConfigurationDescriptor *pDesc;
|
||||
USBGenericDescriptor *pD;
|
||||
uint32_t i, len;
|
||||
|
||||
if (cfgnum > 0) {
|
||||
|
||||
/* Parse endpoints for data & notification */
|
||||
pDesc = USBDDriver_GetCfgDescriptors(pUsbd, cfgnum);
|
||||
|
||||
pD = (USBGenericDescriptor *)pDesc;
|
||||
len = pDesc->wTotalLength;
|
||||
|
||||
for (i = 0; i < NUM_PORTS; i ++) {
|
||||
pCdcd = &dualcdcdDriver.cdcdSerialPort[i];
|
||||
pD = CDCDSerialPort_ParseInterfaces(pCdcd, pD, len);
|
||||
len = pDesc->wTotalLength - ((uint32_t)pD - (uint32_t)pDesc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handles composite-specific USB requests sent by the host, and forwards
|
||||
* standard ones to the USB device driver.
|
||||
* \param request Pointer to a USBGenericRequest instance.
|
||||
*/
|
||||
void DUALCDCDDriver_RequestHandler(const USBGenericRequest *request)
|
||||
{
|
||||
CDCDSerialPort *pCdcd = 0;
|
||||
USBDDriver *pUsbd = 0;
|
||||
uint32_t rc, i;
|
||||
|
||||
TRACE_INFO_WP("NewReq ");
|
||||
|
||||
for (i = 0; i < NUM_PORTS; i ++) {
|
||||
pCdcd = &dualcdcdDriver.cdcdSerialPort[i];
|
||||
rc = CDCDSerialPort_RequestHandler(pCdcd, request);
|
||||
if (rc == USBRC_SUCCESS)
|
||||
break;
|
||||
}
|
||||
|
||||
/* Not handled by CDC Serial */
|
||||
if (rc != USBRC_SUCCESS) {
|
||||
if (USBGenericRequest_GetType(request) == USBGenericRequest_STANDARD) {
|
||||
pUsbd = pCdcd->pUsbd;
|
||||
USBDDriver_RequestHandler(pUsbd, request);
|
||||
}
|
||||
else {
|
||||
TRACE_WARNING(
|
||||
"DUALCDCDDriver_RequestHandler: Unsupported request (%d,%d)\n\r",
|
||||
USBGenericRequest_GetType(request),
|
||||
USBGenericRequest_GetRequest(request));
|
||||
USBD_Stall(0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Return CDCDSerialPort for serial port operations.
|
||||
* \param port Port number.
|
||||
*/
|
||||
CDCDSerialPort *DUALCDCDDriver_GetSerialPort(uint32_t port)
|
||||
{
|
||||
if (port < NUM_PORTS)
|
||||
return &dualcdcdDriver.cdcdSerialPort[port];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**@}*/
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** \addtogroup usbd_composite_hidaud
|
||||
*@{
|
||||
*/
|
||||
/*---------------------------------------------------------------------------
|
||||
* Headers
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <USBLib_Trace.h>
|
||||
|
||||
#include <HIDAUDDDriver.h>
|
||||
#include <HIDDKeyboard.h>
|
||||
#include <AUDDFunction.h>
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Defines
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Types
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Internal variables
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/** Array for storing the current setting of each interface */
|
||||
static uint8_t bAltInterfaces[HIDAUDDDriverDescriptors_NUMINTERFACE];
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Internal functions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Initializes the USB device composite device driver.
|
||||
*/
|
||||
void HIDAUDDDriver_Initialize(const USBDDriverDescriptors *pDescriptors)
|
||||
{
|
||||
USBDDriver *pUsbd = USBD_GetDriver();
|
||||
|
||||
/* Initialize the standard USB driver */
|
||||
USBDDriver_Initialize(pUsbd,
|
||||
pDescriptors,
|
||||
bAltInterfaces);
|
||||
|
||||
/* HID */
|
||||
HIDDKeyboard_Initialize(pUsbd, HIDAUDDDriverDescriptors_HID_INTERFACE);
|
||||
/* Audio */
|
||||
AUDDFunction_Initialize(pUsbd, HIDAUDDDriverDescriptors_AUD_INTERFACE);
|
||||
|
||||
/* Initialize the USB driver */
|
||||
USBD_Init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked whenever the configuration value of a device is changed by the host
|
||||
* \param cfgnum Configuration number.
|
||||
*/
|
||||
void HIDAUDDDriver_ConfigurationChangedHandler(uint8_t cfgnum)
|
||||
{
|
||||
USBDDriver *pUsbd = USBD_GetDriver();
|
||||
USBConfigurationDescriptor *pDesc;
|
||||
if (cfgnum > 0) {
|
||||
pDesc = USBDDriver_GetCfgDescriptors(pUsbd, cfgnum);
|
||||
/* CDC */
|
||||
HIDDKeyboard_ConfigureFunction((USBGenericDescriptor*)pDesc,
|
||||
pDesc->wTotalLength);
|
||||
/* AUD */
|
||||
AUDDFunction_Configure((USBGenericDescriptor*)pDesc,
|
||||
pDesc->wTotalLength);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked whenever the active setting of an interface is changed by the
|
||||
* host. Changes the status of the third LED accordingly.
|
||||
* \param interface Interface number.
|
||||
* \param setting Newly active setting.
|
||||
*/
|
||||
void HIDAUDDDriver_InterfaceSettingChangedHandler(uint8_t interface,
|
||||
uint8_t setting)
|
||||
{
|
||||
AUDDFunction_InterfaceSettingChangedHandler(interface, setting);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles composite-specific USB requests sent by the host, and forwards
|
||||
* standard ones to the USB device driver.
|
||||
* \param request Pointer to a USBGenericRequest instance.
|
||||
*/
|
||||
void HIDAUDDDriver_RequestHandler(const USBGenericRequest *request)
|
||||
{
|
||||
USBDDriver *pUsbd = USBD_GetDriver();
|
||||
|
||||
TRACE_INFO_WP("NewReq ");
|
||||
|
||||
if (HIDDKeyboard_RequestHandler(request) == USBRC_SUCCESS)
|
||||
return;
|
||||
|
||||
if (AUDDFunction_RequestHandler(request) == USBRC_SUCCESS)
|
||||
return;
|
||||
|
||||
USBDDriver_RequestHandler(pUsbd, request);
|
||||
}
|
||||
|
||||
/**@}*/
|
||||
|
||||
@@ -0,0 +1,153 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* 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
|
||||
*/
|
||||
|
||||
/** \addtogroup usbd_composite_hidmsd
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Headers
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <USBLib_Trace.h>
|
||||
|
||||
#include <HIDMSDDriver.h>
|
||||
|
||||
#include <HIDDKeyboard.h>
|
||||
#include <MSDFunction.h>
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Defines
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Types
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Internal variables
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Internal functions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Initializes the USB device HIDMSD device driver.
|
||||
*/
|
||||
void HIDMSDDriver_Initialize(
|
||||
const USBDDriverDescriptors *pDescriptors,
|
||||
MSDLun *pLuns, uint8_t numLuns)
|
||||
{
|
||||
USBDDriver *pUsbd = USBD_GetDriver();
|
||||
|
||||
/* Initialize the standard USB driver */
|
||||
USBDDriver_Initialize(pUsbd,
|
||||
pDescriptors,
|
||||
0);
|
||||
|
||||
/* HID */
|
||||
HIDDKeyboard_Initialize(pUsbd, HIDMSDDriverDescriptors_HID_INTERFACE);
|
||||
|
||||
/* MSD */
|
||||
MSDFunction_Initialize(pUsbd, HIDMSDDriverDescriptors_MSD_INTERFACE,
|
||||
pLuns, numLuns);
|
||||
|
||||
/* Initialize the USB driver */
|
||||
USBD_Init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked whenever the configuration value of a device is changed by the host
|
||||
* \param cfgnum Configuration number.
|
||||
*/
|
||||
void HIDMSDDriver_ConfigurationChangedHandler(uint8_t cfgnum)
|
||||
{
|
||||
USBDDriver *pUsbd = USBD_GetDriver();
|
||||
USBConfigurationDescriptor *pDesc;
|
||||
if (cfgnum > 0) {
|
||||
pDesc = USBDDriver_GetCfgDescriptors(pUsbd, cfgnum);
|
||||
/* HID */
|
||||
HIDDKeyboard_ConfigureFunction((USBGenericDescriptor*)pDesc,
|
||||
pDesc->wTotalLength);
|
||||
/* MSD */
|
||||
MSDFunction_Configure((USBGenericDescriptor*)pDesc,
|
||||
pDesc->wTotalLength);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles HIDMSD-specific USB requests sent by the host, and forwards
|
||||
* standard ones to the USB device driver.
|
||||
* \param request Pointer to a USBGenericRequest instance.
|
||||
*/
|
||||
void HIDMSDDriver_RequestHandler(const USBGenericRequest *request)
|
||||
{
|
||||
USBDDriver *pUsbd = USBD_GetDriver();
|
||||
|
||||
TRACE_INFO_WP("NewReq ");
|
||||
|
||||
if (HIDDKeyboard_RequestHandler(request) == USBRC_SUCCESS)
|
||||
return;
|
||||
|
||||
if (MSDFunction_RequestHandler(request) == USBRC_SUCCESS)
|
||||
return;
|
||||
|
||||
USBDDriver_RequestHandler(pUsbd, request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a remote wake-up sequence if the host has explicitely enabled it
|
||||
* by sending the appropriate SET_FEATURE request.
|
||||
*/
|
||||
void HIDMSDDriver_RemoteWakeUp(void)
|
||||
{
|
||||
USBDDriver *pUsbd = USBD_GetDriver();
|
||||
|
||||
/* Remote wake-up has been enabled */
|
||||
if (USBDDriver_IsRemoteWakeUpEnabled(pUsbd)) {
|
||||
|
||||
USBD_RemoteWakeUp();
|
||||
}
|
||||
/* Remote wake-up NOT enabled */
|
||||
else {
|
||||
|
||||
TRACE_WARNING("HIDMSDDDriver_RemoteWakeUp: not enabled\n\r");
|
||||
}
|
||||
}
|
||||
/**@}*/
|
||||
|
||||
|
After Width: | Height: | Size: 49 KiB |
|
After Width: | Height: | Size: 54 KiB |
|
After Width: | Height: | Size: 47 KiB |
|
After Width: | Height: | Size: 50 KiB |
|
After Width: | Height: | Size: 64 KiB |
|
After Width: | Height: | Size: 42 KiB |
|
After Width: | Height: | Size: 41 KiB |
|
After Width: | Height: | Size: 34 KiB |
|
After Width: | Height: | Size: 58 KiB |
|
After Width: | Height: | Size: 44 KiB |
|
After Width: | Height: | Size: 38 KiB |
@@ -0,0 +1,57 @@
|
||||
; $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_6130&MI_00 ; Identifies a device with ATMEL Vendor ID (03EBh) and
|
||||
; Product ID equal to 6130h. Corresponding Install section
|
||||
; is named USBtoSer.Install ( CDCHID )
|
||||
%USBtoSerialConverter%=USBtoSer.Install,USB\VID_03EB&PID_6131&MI_00 ; Identifies a device with ATMEL Vendor ID (03EBh) and
|
||||
; Product ID equal to 6131h. Corresponding Install section
|
||||
; is named USBtoSer.Install ( CDCAUDIO )
|
||||
%USBtoSerialConverter%=USBtoSer.Install,USB\VID_03EB&PID_6132&MI_00 ; Identifies a device with ATMEL Vendor ID (03EBh) and
|
||||
; Product ID equal to 6132h. Corresponding Install section
|
||||
; is named USBtoSer.Install ( CDCMSD )
|
||||
%USBtoSerialConverter%=USBtoSer.Install,USB\VID_03EB&PID_6133&MI_00 ; Identifies a device with ATMEL Vendor ID (03EBh) and
|
||||
; Product ID equal to 6133h. Corresponding Install section
|
||||
; is named USBtoSer.Install ( CDCCDC )
|
||||
%USBtoSerialConverter%=USBtoSer.Install,USB\VID_03EB&PID_6133&MI_02 ; Identifies a device with ATMEL Vendor ID (03EBh) and
|
||||
; Product ID equal to 6133h. Corresponding Install section
|
||||
; is named USBtoSer.Install ( CDCCDC )
|
||||
|
||||
[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 Composite Serial Driver" ; String value for the USBSer symbol
|
||||