fixed build configurations for main project and moved all MLA framework source to the common_src directory

This commit is contained in:
2019-08-10 15:26:31 -04:00
parent a759e427fb
commit 3807ed2588
12 changed files with 25 additions and 21 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,329 @@
// DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright 2015 Microchip Technology Inc. (www.microchip.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
To request to license the code under the MLA license (www.microchip.com/mla_license),
please contact mla_licensing@microchip.com
*******************************************************************************/
//DOM-IGNORE-END
/*******************************************************************************
USB Device Human Interface Device (HID) Layer
Company:
Microchip Technology Inc.
File Name:
usb_device_hid.c
Summary:
USB Device Human Interface Device (HID) Layer interface API.
Description:
USB Device Human Interface Device (HID) Layer interface API.
*******************************************************************************/
// *****************************************************************************
// *****************************************************************************
// Section: Included Files
// *****************************************************************************
// *****************************************************************************
#include "usb_config.h"
#include "usb.h"
#include "usb_device_hid.h"
#if defined(__XC8)
#define PACKED
#define ALIGNED
#else
#define PACKED __attribute__((packed))
#define ALIGNED __attribute__((aligned))
#endif
// *****************************************************************************
// *****************************************************************************
// Section: File Scope or Global Constants
// *****************************************************************************
// *****************************************************************************
// *****************************************************************************
// *****************************************************************************
// Section: File Scope Data Types
// *****************************************************************************
// *****************************************************************************
typedef struct PACKED
{
unsigned :8;
unsigned :8;
uint8_t reportId;
uint8_t duration;
} USB_SETUP_SET_IDLE_RATE;
typedef struct PACKED
{
unsigned :8;
unsigned :8;
uint8_t protocol;
} USB_SETUP_SET_PROTOCOL;
// *****************************************************************************
// *****************************************************************************
// Section: Variables
// *****************************************************************************
// *****************************************************************************
static uint8_t idle_rate;
static uint8_t active_protocol; // [0] Boot Protocol [1] Report Protocol
extern const struct{uint8_t report[HID_RPT01_SIZE];}hid_rpt01;
// *****************************************************************************
// *****************************************************************************
// Section: Prototypes
// *****************************************************************************
// *****************************************************************************
#if defined USER_GET_REPORT_HANDLER
void USER_GET_REPORT_HANDLER(void);
#endif
#if defined USER_SET_REPORT_HANDLER
extern void USER_SET_REPORT_HANDLER(void);
#endif
// *****************************************************************************
// *****************************************************************************
// Section: Macros or Functions
// *****************************************************************************
// *****************************************************************************
//To implement a set idle rate callback function in the application,
//Make sure "#define USB_DEVICE_HID_IDLE_RATE_CALLBACK(reportID, newIdleRate) USBHIDCBSetIdleRateHandler(reportID, newIdleRate)"
//is placed in your usb_config.h file, and then in your application .c file,
//add the void USBHIDCBSetIdleRateHandler(reportID, newIdleRate) function
//implementation that saves the new idle rate and report ID info, so that it
//gets used later when sending subsequent HID input report packets to the host.
#ifndef USB_DEVICE_HID_IDLE_RATE_CALLBACK
#define USB_DEVICE_HID_IDLE_RATE_CALLBACK(reportId, idleRate)
#else
extern void USB_DEVICE_HID_IDLE_RATE_CALLBACK(uint8_t reportId, uint8_t idleRate);
#endif
/********************************************************************
Function:
void USBCheckHIDRequest(void)
Summary:
This routine handles HID specific request that happen on EP0.
This function should be called from the USBCBCheckOtherReq() call back
function whenever implementing a HID device.
Description:
This routine handles HID specific request that happen on EP0. These
include, but are not limited to, requests for the HID report
descriptors. This function should be called from the
USBCBCheckOtherReq() call back function whenever using an HID device.
Typical Usage:
<code>
void USBCBCheckOtherReq(void)
{
//Since the stack didn't handle the request I need to check
// my class drivers to see if it is for them
USBCheckHIDRequest();
}
</code>
PreCondition:
None
Parameters:
None
Return Values:
None
Remarks:
None
*******************************************************************/
void USBCheckHIDRequest(void)
{
if(SetupPkt.Recipient != USB_SETUP_RECIPIENT_INTERFACE_BITFIELD) return;
if(SetupPkt.bIntfID != HID_INTF_ID) return;
/*
* There are two standard requests that hid.c may support.
* 1. GET_DSC(DSC_HID,DSC_RPT,DSC_PHY);
* 2. SET_DSC(DSC_HID,DSC_RPT,DSC_PHY);
*/
if(SetupPkt.bRequest == USB_REQUEST_GET_DESCRIPTOR)
{
switch(SetupPkt.bDescriptorType)
{
case DSC_HID: //HID Descriptor
if(USBActiveConfiguration == 1)
{
USBEP0SendROMPtr(
(const uint8_t*)&configDescriptor1 + 18, //18 is a magic number. It is the offset from start of the configuration descriptor to the start of the HID descriptor.
sizeof(USB_HID_DSC)+3,
USB_EP0_INCLUDE_ZERO);
}
break;
case DSC_RPT: //Report Descriptor
//if(USBActiveConfiguration == 1)
{
USBEP0SendROMPtr(
(const uint8_t*)&hid_rpt01,
HID_RPT01_SIZE, //See usbcfg.h
USB_EP0_INCLUDE_ZERO);
}
break;
case DSC_PHY: //Physical Descriptor
//Note: The below placeholder code is commented out. HID Physical Descriptors are optional and are not used
//in many types of HID applications. If an application does not have a physical descriptor,
//then the device should return STALL in response to this request (stack will do this automatically
//if no-one claims ownership of the control transfer).
//If an application does implement a physical descriptor, then make sure to declare
//hid_phy01 (rom structure containing the descriptor data), and hid_phy01 (the size of the descriptors in uint8_ts),
//and then uncomment the below code.
//if(USBActiveConfiguration == 1)
//{
// USBEP0SendROMPtr((const uint8_t*)&hid_phy01, sizeof(hid_phy01), USB_EP0_INCLUDE_ZERO);
//}
break;
}//end switch(SetupPkt.bDescriptorType)
}//end if(SetupPkt.bRequest == GET_DSC)
if(SetupPkt.RequestType != USB_SETUP_TYPE_CLASS_BITFIELD)
{
return;
}
switch(SetupPkt.bRequest)
{
case GET_REPORT:
#if defined USER_GET_REPORT_HANDLER
USER_GET_REPORT_HANDLER();
#endif
break;
case SET_REPORT:
#if defined USER_SET_REPORT_HANDLER
USER_SET_REPORT_HANDLER();
#endif
break;
case GET_IDLE:
USBEP0SendRAMPtr(
(uint8_t*)&idle_rate,
1,
USB_EP0_INCLUDE_ZERO);
break;
case SET_IDLE:
USBEP0Transmit(USB_EP0_NO_DATA);
idle_rate = SetupPkt.W_Value.byte.HB;
USB_DEVICE_HID_IDLE_RATE_CALLBACK(SetupPkt.W_Value.byte.LB, idle_rate);
break;
case GET_PROTOCOL:
USBEP0SendRAMPtr(
(uint8_t*)&active_protocol,
1,
USB_EP0_NO_OPTIONS);
break;
case SET_PROTOCOL:
USBEP0Transmit(USB_EP0_NO_DATA);
active_protocol = SetupPkt.W_Value.byte.LB;
break;
}//end switch(SetupPkt.bRequest)
}//end USBCheckHIDRequest
/********************************************************************
Function:
USB_HANDLE HIDTxPacket(uint8_t ep, uint8_t* data, uint16_t len)
Summary:
Sends the specified data out the specified endpoint
Description:
This function sends the specified data out the specified
endpoint and returns a handle to the transfer information.
Typical Usage:
<code>
//make sure that the last transfer isn't busy by checking the handle
if(!HIDTxHandleBusy(USBInHandle))
{
//Send the data contained in the ToSendDataBuffer[] array out on
// endpoint HID_EP
USBInHandle = HIDTxPacket(HID_EP,(uint8_t*)&ToSendDataBuffer[0],sizeof(ToSendDataBuffer));
}
</code>
PreCondition:
None
Parameters:
uint8_t ep - the endpoint you want to send the data out of
uint8_t* data - pointer to the data that you wish to send
uint16_t len - the length of the data that you wish to send
Return Values:
USB_HANDLE - a handle for the transfer. This information
should be kept to track the status of the transfer
Remarks:
None
*******************************************************************/
// Implemented as a macro. See usb_function_hid.h
/********************************************************************
Function:
USB_HANDLE HIDRxPacket(uint8_t ep, uint8_t* data, uint16_t len)
Summary:
Receives the specified data out the specified endpoint
Description:
Receives the specified data out the specified endpoint.
Typical Usage:
<code>
//Read 64-uint8_ts from endpoint HID_EP, into the ReceivedDataBuffer array.
// Make sure to save the return handle so that we can check it later
// to determine when the transfer is complete.
USBOutHandle = HIDRxPacket(HID_EP,(uint8_t*)&ReceivedDataBuffer,64);
</code>
PreCondition:
None
Parameters:
uint8_t ep - the endpoint you want to receive the data into
uint8_t* data - pointer to where the data will go when it arrives
uint16_t len - the length of the data that you wish to receive
Return Values:
USB_HANDLE - a handle for the transfer. This information
should be kept to track the status of the transfer
Remarks:
None
*******************************************************************/
// Implemented as a macro. See usb_function_hid.h
/*******************************************************************************
End of File
*/

View File

@@ -0,0 +1,424 @@
// DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright 2015 Microchip Technology Inc. (www.microchip.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
To request to license the code under the MLA license (www.microchip.com/mla_license),
please contact mla_licensing@microchip.com
*******************************************************************************/
//DOM-IGNORE-END
#include "usb_config.h"
/* Short Packet States - Used by Control Transfer Read - CTRL_TRF_TX */
#define SHORT_PKT_NOT_USED 0
#define SHORT_PKT_PENDING 1
#define SHORT_PKT_SENT 2
/* Control Transfer States */
#define WAIT_SETUP 0
#define CTRL_TRF_TX 1
#define CTRL_TRF_RX 2
typedef union
{
struct
{
unsigned char ping_pong_state :1;
unsigned char transfer_terminated :1;
} bits;
uint8_t Val;
} EP_STATUS;
#if (USB_PING_PONG_MODE == USB_PING_PONG__NO_PING_PONG)
#define USB_NEXT_EP0_OUT_PING_PONG 0x0000 // Used in USB Device Mode only
#define USB_NEXT_EP0_IN_PING_PONG 0x0000 // Used in USB Device Mode only
#define USB_NEXT_PING_PONG 0x0000 // Used in USB Device Mode only
#define EP0_OUT_EVEN 0 // Used in USB Device Mode only
#define EP0_OUT_ODD 0 // Used in USB Device Mode only
#define EP0_IN_EVEN 1 // Used in USB Device Mode only
#define EP0_IN_ODD 1 // Used in USB Device Mode only
#define EP1_OUT_EVEN 2 // Used in USB Device Mode only
#define EP1_OUT_ODD 2 // Used in USB Device Mode only
#define EP1_IN_EVEN 3 // Used in USB Device Mode only
#define EP1_IN_ODD 3 // Used in USB Device Mode only
#define EP2_OUT_EVEN 4 // Used in USB Device Mode only
#define EP2_OUT_ODD 4 // Used in USB Device Mode only
#define EP2_IN_EVEN 5 // Used in USB Device Mode only
#define EP2_IN_ODD 5 // Used in USB Device Mode only
#define EP3_OUT_EVEN 6 // Used in USB Device Mode only
#define EP3_OUT_ODD 6 // Used in USB Device Mode only
#define EP3_IN_EVEN 7 // Used in USB Device Mode only
#define EP3_IN_ODD 7 // Used in USB Device Mode only
#define EP4_OUT_EVEN 8 // Used in USB Device Mode only
#define EP4_OUT_ODD 8 // Used in USB Device Mode only
#define EP4_IN_EVEN 9 // Used in USB Device Mode only
#define EP4_IN_ODD 9 // Used in USB Device Mode only
#define EP5_OUT_EVEN 10 // Used in USB Device Mode only
#define EP5_OUT_ODD 10 // Used in USB Device Mode only
#define EP5_IN_EVEN 11 // Used in USB Device Mode only
#define EP5_IN_ODD 11 // Used in USB Device Mode only
#define EP6_OUT_EVEN 12 // Used in USB Device Mode only
#define EP6_OUT_ODD 12 // Used in USB Device Mode only
#define EP6_IN_EVEN 13 // Used in USB Device Mode only
#define EP6_IN_ODD 13 // Used in USB Device Mode only
#define EP7_OUT_EVEN 14 // Used in USB Device Mode only
#define EP7_OUT_ODD 14 // Used in USB Device Mode only
#define EP7_IN_EVEN 15 // Used in USB Device Mode only
#define EP7_IN_ODD 15 // Used in USB Device Mode only
#define EP8_OUT_EVEN 16 // Used in USB Device Mode only
#define EP8_OUT_ODD 16 // Used in USB Device Mode only
#define EP8_IN_EVEN 17 // Used in USB Device Mode only
#define EP8_IN_ODD 17 // Used in USB Device Mode only
#define EP9_OUT_EVEN 18 // Used in USB Device Mode only
#define EP9_OUT_ODD 18 // Used in USB Device Mode only
#define EP9_IN_EVEN 19 // Used in USB Device Mode only
#define EP9_IN_ODD 19 // Used in USB Device Mode only
#define EP10_OUT_EVEN 20 // Used in USB Device Mode only
#define EP10_OUT_ODD 20 // Used in USB Device Mode only
#define EP10_IN_EVEN 21 // Used in USB Device Mode only
#define EP10_IN_ODD 21 // Used in USB Device Mode only
#define EP11_OUT_EVEN 22 // Used in USB Device Mode only
#define EP11_OUT_ODD 22 // Used in USB Device Mode only
#define EP11_IN_EVEN 23 // Used in USB Device Mode only
#define EP11_IN_ODD 23 // Used in USB Device Mode only
#define EP12_OUT_EVEN 24 // Used in USB Device Mode only
#define EP12_OUT_ODD 24 // Used in USB Device Mode only
#define EP12_IN_EVEN 25 // Used in USB Device Mode only
#define EP12_IN_ODD 25 // Used in USB Device Mode only
#define EP13_OUT_EVEN 26 // Used in USB Device Mode only
#define EP13_OUT_ODD 26 // Used in USB Device Mode only
#define EP13_IN_EVEN 27 // Used in USB Device Mode only
#define EP13_IN_ODD 27 // Used in USB Device Mode only
#define EP14_OUT_EVEN 28 // Used in USB Device Mode only
#define EP14_OUT_ODD 28 // Used in USB Device Mode only
#define EP14_IN_EVEN 29 // Used in USB Device Mode only
#define EP14_IN_ODD 29 // Used in USB Device Mode only
#define EP15_OUT_EVEN 30 // Used in USB Device Mode only
#define EP15_OUT_ODD 30 // Used in USB Device Mode only
#define EP15_IN_EVEN 31 // Used in USB Device Mode only
#define EP15_IN_ODD 31 // Used in USB Device Mode only
#define EP(ep,dir,pp) (2*ep+dir) // Used in USB Device Mode only
#define BD(ep,dir,pp) ((8 * ep) + (4 * dir)) // Used in USB Device Mode only
#elif (USB_PING_PONG_MODE == USB_PING_PONG__EP0_OUT_ONLY)
#define USB_NEXT_EP0_OUT_PING_PONG 0x0004
#define USB_NEXT_EP0_IN_PING_PONG 0x0000
#define USB_NEXT_PING_PONG 0x0000
#define EP0_OUT_EVEN 0
#define EP0_OUT_ODD 1
#define EP0_IN_EVEN 2
#define EP0_IN_ODD 2
#define EP1_OUT_EVEN 3
#define EP1_OUT_ODD 3
#define EP1_IN_EVEN 4
#define EP1_IN_ODD 4
#define EP2_OUT_EVEN 5
#define EP2_OUT_ODD 5
#define EP2_IN_EVEN 6
#define EP2_IN_ODD 6
#define EP3_OUT_EVEN 7
#define EP3_OUT_ODD 7
#define EP3_IN_EVEN 8
#define EP3_IN_ODD 8
#define EP4_OUT_EVEN 9
#define EP4_OUT_ODD 9
#define EP4_IN_EVEN 10
#define EP4_IN_ODD 10
#define EP5_OUT_EVEN 11
#define EP5_OUT_ODD 11
#define EP5_IN_EVEN 12
#define EP5_IN_ODD 12
#define EP6_OUT_EVEN 13
#define EP6_OUT_ODD 13
#define EP6_IN_EVEN 14
#define EP6_IN_ODD 14
#define EP7_OUT_EVEN 15
#define EP7_OUT_ODD 15
#define EP7_IN_EVEN 16
#define EP7_IN_ODD 16
#define EP8_OUT_EVEN 17
#define EP8_OUT_ODD 17
#define EP8_IN_EVEN 18
#define EP8_IN_ODD 18
#define EP9_OUT_EVEN 19
#define EP9_OUT_ODD 19
#define EP9_IN_EVEN 20
#define EP9_IN_ODD 20
#define EP10_OUT_EVEN 21
#define EP10_OUT_ODD 21
#define EP10_IN_EVEN 22
#define EP10_IN_ODD 22
#define EP11_OUT_EVEN 23
#define EP11_OUT_ODD 23
#define EP11_IN_EVEN 24
#define EP11_IN_ODD 24
#define EP12_OUT_EVEN 25
#define EP12_OUT_ODD 25
#define EP12_IN_EVEN 26
#define EP12_IN_ODD 26
#define EP13_OUT_EVEN 27
#define EP13_OUT_ODD 27
#define EP13_IN_EVEN 28
#define EP13_IN_ODD 28
#define EP14_OUT_EVEN 29
#define EP14_OUT_ODD 29
#define EP14_IN_EVEN 30
#define EP14_IN_ODD 30
#define EP15_OUT_EVEN 31
#define EP15_OUT_ODD 31
#define EP15_IN_EVEN 32
#define EP15_IN_ODD 32
#define EP(ep,dir,pp) (2u*ep+dir+(((ep==0)&&(dir==0))?pp:1))
#define BD(ep,dir,pp) (4u*((2u*ep)+dir+(((ep==0)&&(dir==0))?pp:1)))
#elif (USB_PING_PONG_MODE == USB_PING_PONG__FULL_PING_PONG)
#if defined (__18CXX) || defined(__C30__) || defined __XC16__ || defined(__XC8)
#if (defined (__dsPIC33E__) || defined (__PIC24E__))
#define USB_NEXT_EP0_OUT_PING_PONG 0x0008
#define USB_NEXT_EP0_IN_PING_PONG 0x0008
#define USB_NEXT_PING_PONG 0x0008
#else
#define USB_NEXT_EP0_OUT_PING_PONG 0x0004
#define USB_NEXT_EP0_IN_PING_PONG 0x0004
#define USB_NEXT_PING_PONG 0x0004
#endif
#elif defined(__C32__)
#define USB_NEXT_EP0_OUT_PING_PONG 0x0008
#define USB_NEXT_EP0_IN_PING_PONG 0x0008
#define USB_NEXT_PING_PONG 0x0008
#else
#error "Not defined for this compiler"
#endif
#define EP0_OUT_EVEN 0
#define EP0_OUT_ODD 1
#define EP0_IN_EVEN 2
#define EP0_IN_ODD 3
#define EP1_OUT_EVEN 4
#define EP1_OUT_ODD 5
#define EP1_IN_EVEN 6
#define EP1_IN_ODD 7
#define EP2_OUT_EVEN 8
#define EP2_OUT_ODD 9
#define EP2_IN_EVEN 10
#define EP2_IN_ODD 11
#define EP3_OUT_EVEN 12
#define EP3_OUT_ODD 13
#define EP3_IN_EVEN 14
#define EP3_IN_ODD 15
#define EP4_OUT_EVEN 16
#define EP4_OUT_ODD 17
#define EP4_IN_EVEN 18
#define EP4_IN_ODD 19
#define EP5_OUT_EVEN 20
#define EP5_OUT_ODD 21
#define EP5_IN_EVEN 22
#define EP5_IN_ODD 23
#define EP6_OUT_EVEN 24
#define EP6_OUT_ODD 25
#define EP6_IN_EVEN 26
#define EP6_IN_ODD 27
#define EP7_OUT_EVEN 28
#define EP7_OUT_ODD 29
#define EP7_IN_EVEN 30
#define EP7_IN_ODD 31
#define EP8_OUT_EVEN 32
#define EP8_OUT_ODD 33
#define EP8_IN_EVEN 34
#define EP8_IN_ODD 35
#define EP9_OUT_EVEN 36
#define EP9_OUT_ODD 37
#define EP9_IN_EVEN 38
#define EP9_IN_ODD 39
#define EP10_OUT_EVEN 40
#define EP10_OUT_ODD 41
#define EP10_IN_EVEN 42
#define EP10_IN_ODD 43
#define EP11_OUT_EVEN 44
#define EP11_OUT_ODD 45
#define EP11_IN_EVEN 46
#define EP11_IN_ODD 47
#define EP12_OUT_EVEN 48
#define EP12_OUT_ODD 49
#define EP12_IN_EVEN 50
#define EP12_IN_ODD 51
#define EP13_OUT_EVEN 52
#define EP13_OUT_ODD 53
#define EP13_IN_EVEN 54
#define EP13_IN_ODD 55
#define EP14_OUT_EVEN 56
#define EP14_OUT_ODD 57
#define EP14_IN_EVEN 58
#define EP14_IN_ODD 59
#define EP15_OUT_EVEN 60
#define EP15_OUT_ODD 61
#define EP15_IN_EVEN 62
#define EP15_IN_ODD 63
#define EP(ep,dir,pp) (4*ep+2*dir+pp)
#if defined (__18CXX) || defined(__C30__) || defined __XC16__ || (__XC8)
#if (defined(__dsPIC33E__) || defined (__PIC24E__))
#define BD(ep,dir,pp) (8*(4*ep+2*dir+pp))
#else
#define BD(ep,dir,pp) (4*(4*ep+2*dir+pp))
#endif
#elif defined(__C32__)
#define BD(ep,dir,pp) (8*(4*ep+2*dir+pp))
#else
#error "Not defined for this compiler"
#endif
#elif (USB_PING_PONG_MODE == USB_PING_PONG__ALL_BUT_EP0)
#define USB_NEXT_EP0_OUT_PING_PONG 0x0000
#define USB_NEXT_EP0_IN_PING_PONG 0x0000
#define USB_NEXT_PING_PONG 0x0004
#define EP0_OUT_EVEN 0
#define EP0_OUT_ODD 0
#define EP0_IN_EVEN 1
#define EP0_IN_ODD 1
#define EP1_OUT_EVEN 2
#define EP1_OUT_ODD 3
#define EP1_IN_EVEN 4
#define EP1_IN_ODD 5
#define EP2_OUT_EVEN 6
#define EP2_OUT_ODD 7
#define EP2_IN_EVEN 8
#define EP2_IN_ODD 9
#define EP3_OUT_EVEN 10
#define EP3_OUT_ODD 11
#define EP3_IN_EVEN 12
#define EP3_IN_ODD 13
#define EP4_OUT_EVEN 14
#define EP4_OUT_ODD 15
#define EP4_IN_EVEN 16
#define EP4_IN_ODD 17
#define EP5_OUT_EVEN 18
#define EP5_OUT_ODD 19
#define EP5_IN_EVEN 20
#define EP5_IN_ODD 21
#define EP6_OUT_EVEN 22
#define EP6_OUT_ODD 23
#define EP6_IN_EVEN 24
#define EP6_IN_ODD 25
#define EP7_OUT_EVEN 26
#define EP7_OUT_ODD 27
#define EP7_IN_EVEN 28
#define EP7_IN_ODD 29
#define EP8_OUT_EVEN 30
#define EP8_OUT_ODD 31
#define EP8_IN_EVEN 32
#define EP8_IN_ODD 33
#define EP9_OUT_EVEN 34
#define EP9_OUT_ODD 35
#define EP9_IN_EVEN 36
#define EP9_IN_ODD 37
#define EP10_OUT_EVEN 38
#define EP10_OUT_ODD 39
#define EP10_IN_EVEN 40
#define EP10_IN_ODD 41
#define EP11_OUT_EVEN 42
#define EP11_OUT_ODD 43
#define EP11_IN_EVEN 44
#define EP11_IN_ODD 45
#define EP12_OUT_EVEN 46
#define EP12_OUT_ODD 47
#define EP12_IN_EVEN 48
#define EP12_IN_ODD 49
#define EP13_OUT_EVEN 50
#define EP13_OUT_ODD 51
#define EP13_IN_EVEN 52
#define EP13_IN_ODD 53
#define EP14_OUT_EVEN 54
#define EP14_OUT_ODD 55
#define EP14_IN_EVEN 56
#define EP14_IN_ODD 57
#define EP15_OUT_EVEN 58
#define EP15_OUT_ODD 59
#define EP15_IN_EVEN 60
#define EP15_IN_ODD 61
#define EP(ep,dir,pp) (4*ep+2*dir+((ep==0)?0:(pp-2)))
#define BD(ep,dir,pp) (4*(4*ep+2*dir+((ep==0)?0:(pp-2))))
#else
#error "No ping pong mode defined."
#endif
/****** Event callback enabling/disabling macros ********************
This section of code is used to disable specific USB events that may not be
desired by the user. This can save code size and increase throughput and
decrease CPU utiliazation.
********************************************************************/
#if defined USB_DISABLE_SUSPEND_HANDLER
#define USB_SUSPEND_HANDLER(event,pointer,size)
#warning "Disabling the suspend handler is not recommended. Proper suspend handling is required to create a compliant USB device."
#else
#define USB_SUSPEND_HANDLER(event,pointer,size) USER_USB_CALLBACK_EVENT_HANDLER((USB_EVENT)event,pointer,size)
#endif
#if defined USB_DISABLE_WAKEUP_FROM_SUSPEND_HANDLER
#define USB_WAKEUP_FROM_SUSPEND_HANDLER(event,pointer,size)
#warning "Disabling the wake from suspend handler is not recommended. Proper suspend handling is required to create a compliant USB device."
#else
#define USB_WAKEUP_FROM_SUSPEND_HANDLER(event,pointer,size) USER_USB_CALLBACK_EVENT_HANDLER((USB_EVENT)event,pointer,size)
#endif
#if defined USB_DISABLE_SOF_HANDLER
#define USB_SOF_HANDLER(event,pointer,size)
#else
#define USB_SOF_HANDLER(event,pointer,size) USER_USB_CALLBACK_EVENT_HANDLER((USB_EVENT)event,pointer,size)
#endif
#if defined USB_DISABLE_TRANSFER_TERMINATED_HANDLER
#define USB_TRANSFER_TERMINATED_HANDLER(event,pointer,size)
#else
#define USB_TRANSFER_TERMINATED_HANDLER(event,pointer,size) USER_USB_CALLBACK_EVENT_HANDLER((USB_EVENT)event,pointer,size)
#endif
#if defined USB_DISABLE_ERROR_HANDLER
#define USB_ERROR_HANDLER(event,pointer,size)
#else
#define USB_ERROR_HANDLER(event,pointer,size) USER_USB_CALLBACK_EVENT_HANDLER((USB_EVENT)event,pointer,size)
#endif
#if defined USB_DISABLE_NONSTANDARD_EP0_REQUEST_HANDLER
#define USB_NONSTANDARD_EP0_REQUEST_HANDLER(event,pointer,size)
#else
#define USB_NONSTANDARD_EP0_REQUEST_HANDLER(event,pointer,size) USER_USB_CALLBACK_EVENT_HANDLER((USB_EVENT)event,pointer,size)
#endif
#if defined USB_DISABLE_SET_DESCRIPTOR_HANDLER
#define USB_SET_DESCRIPTOR_HANDLER(event,pointer,size)
#else
#define USB_SET_DESCRIPTOR_HANDLER(event,pointer,size) USER_USB_CALLBACK_EVENT_HANDLER((USB_EVENT)event,pointer,size)
#endif
#if defined USB_DISABLE_SET_CONFIGURATION_HANDLER
#define USB_SET_CONFIGURATION_HANDLER(event,pointer,size)
#else
#define USB_SET_CONFIGURATION_HANDLER(event,pointer,size) USER_USB_CALLBACK_EVENT_HANDLER((USB_EVENT)event,pointer,size)
#endif
#if defined USB_DISABLE_TRANSFER_COMPLETE_HANDLER
#define USB_TRANSFER_COMPLETE_HANDLER(event,pointer,size)
#else
#define USB_TRANSFER_COMPLETE_HANDLER(event,pointer,size) USER_USB_CALLBACK_EVENT_HANDLER((USB_EVENT)event,pointer,size)
#endif