-- Configuration options cannot be set via USB. Must use the USB bootloader to
- load a new firmware instead.
- - SCSI ID hardcoded to 0
- - Partity checking is on
- - Unit Attention Condition is off
-
- DMA is not used for SPI transfers
+ - Potential for large performance improvement.
- Parity checking not implemented for the PSoC Datapath implementation
--- /dev/null
+/*******************************************************************************\r
+* File Name: USBFS.c\r
+* Version 2.60\r
+*\r
+* Description:\r
+* API for USBFS Component.\r
+*\r
+* Note:\r
+* Many of the functions use endpoint number. RAM arrays are sized with 9\r
+* elements so they are indexed directly by epNumber. The SIE and ARB\r
+* registers are indexed by variations of epNumber - 1.\r
+*\r
+********************************************************************************\r
+* Copyright 2008-2013, Cypress Semiconductor Corporation. All rights reserved.\r
+* You may use this file only in accordance with the license, terms, conditions,\r
+* disclaimers, and limitations in the end user license agreement accompanying\r
+* the software package with which this file was provided.\r
+*******************************************************************************/\r
+\r
+#include <CyDmac.h>\r
+#include "USBFS.h"\r
+#include "USBFS_pvt.h"\r
+#include "USBFS_hid.h"\r
+#if(USBFS_DMA1_REMOVE == 0u)\r
+ #include "USBFS_ep1_dma.h"\r
+#endif /* End USBFS_DMA1_REMOVE */\r
+#if(USBFS_DMA2_REMOVE == 0u)\r
+ #include "USBFS_ep2_dma.h"\r
+#endif /* End USBFS_DMA2_REMOVE */\r
+#if(USBFS_DMA3_REMOVE == 0u)\r
+ #include "USBFS_ep3_dma.h"\r
+#endif /* End USBFS_DMA3_REMOVE */\r
+#if(USBFS_DMA4_REMOVE == 0u)\r
+ #include "USBFS_ep4_dma.h"\r
+#endif /* End USBFS_DMA4_REMOVE */\r
+#if(USBFS_DMA5_REMOVE == 0u)\r
+ #include "USBFS_ep5_dma.h"\r
+#endif /* End USBFS_DMA5_REMOVE */\r
+#if(USBFS_DMA6_REMOVE == 0u)\r
+ #include "USBFS_ep6_dma.h"\r
+#endif /* End USBFS_DMA6_REMOVE */\r
+#if(USBFS_DMA7_REMOVE == 0u)\r
+ #include "USBFS_ep7_dma.h"\r
+#endif /* End USBFS_DMA7_REMOVE */\r
+#if(USBFS_DMA8_REMOVE == 0u)\r
+ #include "USBFS_ep8_dma.h"\r
+#endif /* End USBFS_DMA8_REMOVE */\r
+\r
+\r
+/***************************************\r
+* Global data allocation\r
+***************************************/\r
+\r
+uint8 USBFS_initVar = 0u;\r
+#if(USBFS_EP_MM != USBFS__EP_MANUAL)\r
+ uint8 USBFS_DmaChan[USBFS_MAX_EP];\r
+ uint8 USBFS_DmaTd[USBFS_MAX_EP];\r
+#endif /* End USBFS_EP_MM */\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_Start\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* This function initialize the USB SIE, arbiter and the\r
+* endpoint APIs, including setting the D+ Pullup\r
+*\r
+* Parameters:\r
+* device: Contains the device number of the desired device descriptor.\r
+* The device number can be found in the Device Descriptor Tab of\r
+* "Configure" dialog, under the settings of desired Device Descriptor,\r
+* in the "Device Number" field.\r
+* mode: The operating voltage. This determines whether the voltage regulator\r
+* is enabled for 5V operation or if pass through mode is used for 3.3V\r
+* operation. Symbolic names and their associated values are given in the\r
+* following table.\r
+* USBFS_3V_OPERATION - Disable voltage regulator and pass-thru\r
+* Vcc for pull-up\r
+* USBFS_5V_OPERATION - Enable voltage regulator and use\r
+* regulator for pull-up\r
+* USBFS_DWR_VDDD_OPERATION - Enable or Disable voltage\r
+* regulator depend on Vddd Voltage configuration in DWR.\r
+*\r
+* Return:\r
+* None.\r
+*\r
+* Global variables:\r
+* The USBFS_intiVar variable is used to indicate initial\r
+* configuration of this component. The variable is initialized to zero (0u)\r
+* and set to one (1u) the first time USBFS_Start() is called.\r
+* This allows for component Re-Start without unnecessary re-initialization\r
+* in all subsequent calls to the USBFS_Start() routine.\r
+* If re-initialization of the component is required the variable should be set\r
+* to zero before call of UART_Start() routine, or the user may call\r
+* USBFS_Init() and USBFS_InitComponent() as done\r
+* in the USBFS_Start() routine.\r
+*\r
+* Side Effects:\r
+* This function will reset all communication states to default.\r
+*\r
+* Reentrant:\r
+* No.\r
+*\r
+*******************************************************************************/\r
+void USBFS_Start(uint8 device, uint8 mode) \r
+{\r
+ /* If not Initialized then initialize all required hardware and software */\r
+ if(USBFS_initVar == 0u)\r
+ {\r
+ USBFS_Init();\r
+ USBFS_initVar = 1u;\r
+ }\r
+ USBFS_InitComponent(device, mode);\r
+}\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_Init\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* Initialize component's hardware. Usually called in USBFS_Start().\r
+*\r
+* Parameters:\r
+* None.\r
+*\r
+* Return:\r
+* None.\r
+*\r
+* Reentrant:\r
+* No.\r
+*\r
+*******************************************************************************/\r
+void USBFS_Init(void) \r
+{\r
+ uint8 enableInterrupts;\r
+ #if(USBFS_EP_MM != USBFS__EP_MANUAL)\r
+ uint16 i;\r
+ #endif /* End USBFS_EP_MM != USBFS__EP_MANUAL */\r
+\r
+ enableInterrupts = CyEnterCriticalSection();\r
+\r
+ /* Enable USB block */\r
+ USBFS_PM_ACT_CFG_REG |= USBFS_PM_ACT_EN_FSUSB;\r
+ /* Enable USB block for Standby Power Mode */\r
+ USBFS_PM_STBY_CFG_REG |= USBFS_PM_STBY_EN_FSUSB;\r
+\r
+ /* Enable core clock */\r
+ USBFS_USB_CLK_EN_REG = USBFS_USB_CLK_ENABLE;\r
+\r
+ USBFS_CR1_REG = USBFS_CR1_ENABLE_LOCK;\r
+\r
+ /* ENABLING USBIO PADS IN USB MODE FROM I/O MODE */\r
+ /* Ensure USB transmit enable is low (USB_USBIO_CR0.ten). - Manual Transmission - Disabled */\r
+ USBFS_USBIO_CR0_REG &= ((uint8)(~USBFS_USBIO_CR0_TEN));\r
+ CyDelayUs(0u); /*~50ns delay */\r
+ /* Disable the USBIO by asserting PM.USB_CR0.fsusbio_pd_n(Inverted)\r
+ * high. This will have been set low by the power manger out of reset.\r
+ * Also confirm USBIO pull-up disabled\r
+ */\r
+ USBFS_PM_USB_CR0_REG &= ((uint8)(~(USBFS_PM_USB_CR0_PD_N |\r
+ USBFS_PM_USB_CR0_PD_PULLUP_N)));\r
+\r
+ /* Select iomode to USB mode*/\r
+ USBFS_USBIO_CR1_REG &= ((uint8)(~USBFS_USBIO_CR1_IOMODE));\r
+\r
+ /* Enable the USBIO reference by setting PM.USB_CR0.fsusbio_ref_en.*/\r
+ USBFS_PM_USB_CR0_REG |= USBFS_PM_USB_CR0_REF_EN;\r
+ /* The reference will be available 1 us after the regulator is enabled */\r
+ CyDelayUs(1u);\r
+ /* OR 40us after power restored */\r
+ CyDelayUs(40u);\r
+ /* Ensure the single ended disable bits are low (PRT15.INP_DIS[7:6])(input receiver enabled). */\r
+ USBFS_DM_INP_DIS_REG &= ((uint8)(~USBFS_DM_MASK));\r
+ USBFS_DP_INP_DIS_REG &= ((uint8)(~USBFS_DP_MASK));\r
+\r
+ /* Enable USBIO */\r
+ USBFS_PM_USB_CR0_REG |= USBFS_PM_USB_CR0_PD_N;\r
+ CyDelayUs(2u);\r
+ /* Set the USBIO pull-up enable */\r
+ USBFS_PM_USB_CR0_REG |= USBFS_PM_USB_CR0_PD_PULLUP_N;\r
+\r
+ /* Write WAx */\r
+ CY_SET_REG8(USBFS_ARB_RW1_WA_PTR, 0u);\r
+ CY_SET_REG8(USBFS_ARB_RW1_WA_MSB_PTR, 0u);\r
+\r
+ #if(USBFS_EP_MM != USBFS__EP_MANUAL)\r
+ /* Init transfer descriptor. This will be used to detect the DMA state - initialized or not. */\r
+ for (i = 0u; i < USBFS_MAX_EP; i++)\r
+ {\r
+ USBFS_DmaTd[i] = DMA_INVALID_TD;\r
+ }\r
+ #endif /* End USBFS_EP_MM != USBFS__EP_MANUAL */\r
+\r
+ CyExitCriticalSection(enableInterrupts);\r
+\r
+\r
+ /* Set the bus reset Interrupt. */\r
+ (void) CyIntSetVector(USBFS_BUS_RESET_VECT_NUM, &USBFS_BUS_RESET_ISR);\r
+ CyIntSetPriority(USBFS_BUS_RESET_VECT_NUM, USBFS_BUS_RESET_PRIOR);\r
+\r
+ /* Set the SOF Interrupt. */\r
+ #if(USBFS_SOF_ISR_REMOVE == 0u)\r
+ (void) CyIntSetVector(USBFS_SOF_VECT_NUM, &USBFS_SOF_ISR);\r
+ CyIntSetPriority(USBFS_SOF_VECT_NUM, USBFS_SOF_PRIOR);\r
+ #endif /* End USBFS_SOF_ISR_REMOVE */\r
+\r
+ /* Set the Control Endpoint Interrupt. */\r
+ (void) CyIntSetVector(USBFS_EP_0_VECT_NUM, &USBFS_EP_0_ISR);\r
+ CyIntSetPriority(USBFS_EP_0_VECT_NUM, USBFS_EP_0_PRIOR);\r
+\r
+ /* Set the Data Endpoint 1 Interrupt. */\r
+ #if(USBFS_EP1_ISR_REMOVE == 0u)\r
+ (void) CyIntSetVector(USBFS_EP_1_VECT_NUM, &USBFS_EP_1_ISR);\r
+ CyIntSetPriority(USBFS_EP_1_VECT_NUM, USBFS_EP_1_PRIOR);\r
+ #endif /* End USBFS_EP1_ISR_REMOVE */\r
+\r
+ /* Set the Data Endpoint 2 Interrupt. */\r
+ #if(USBFS_EP2_ISR_REMOVE == 0u)\r
+ (void) CyIntSetVector(USBFS_EP_2_VECT_NUM, &USBFS_EP_2_ISR);\r
+ CyIntSetPriority(USBFS_EP_2_VECT_NUM, USBFS_EP_2_PRIOR);\r
+ #endif /* End USBFS_EP2_ISR_REMOVE */\r
+\r
+ /* Set the Data Endpoint 3 Interrupt. */\r
+ #if(USBFS_EP3_ISR_REMOVE == 0u)\r
+ (void) CyIntSetVector(USBFS_EP_3_VECT_NUM, &USBFS_EP_3_ISR);\r
+ CyIntSetPriority(USBFS_EP_3_VECT_NUM, USBFS_EP_3_PRIOR);\r
+ #endif /* End USBFS_EP3_ISR_REMOVE */\r
+\r
+ /* Set the Data Endpoint 4 Interrupt. */\r
+ #if(USBFS_EP4_ISR_REMOVE == 0u)\r
+ (void) CyIntSetVector(USBFS_EP_4_VECT_NUM, &USBFS_EP_4_ISR);\r
+ CyIntSetPriority(USBFS_EP_4_VECT_NUM, USBFS_EP_4_PRIOR);\r
+ #endif /* End USBFS_EP4_ISR_REMOVE */\r
+\r
+ /* Set the Data Endpoint 5 Interrupt. */\r
+ #if(USBFS_EP5_ISR_REMOVE == 0u)\r
+ (void) CyIntSetVector(USBFS_EP_5_VECT_NUM, &USBFS_EP_5_ISR);\r
+ CyIntSetPriority(USBFS_EP_5_VECT_NUM, USBFS_EP_5_PRIOR);\r
+ #endif /* End USBFS_EP5_ISR_REMOVE */\r
+\r
+ /* Set the Data Endpoint 6 Interrupt. */\r
+ #if(USBFS_EP6_ISR_REMOVE == 0u)\r
+ (void) CyIntSetVector(USBFS_EP_6_VECT_NUM, &USBFS_EP_6_ISR);\r
+ CyIntSetPriority(USBFS_EP_6_VECT_NUM, USBFS_EP_6_PRIOR);\r
+ #endif /* End USBFS_EP6_ISR_REMOVE */\r
+\r
+ /* Set the Data Endpoint 7 Interrupt. */\r
+ #if(USBFS_EP7_ISR_REMOVE == 0u)\r
+ (void) CyIntSetVector(USBFS_EP_7_VECT_NUM, &USBFS_EP_7_ISR);\r
+ CyIntSetPriority(USBFS_EP_7_VECT_NUM, USBFS_EP_7_PRIOR);\r
+ #endif /* End USBFS_EP7_ISR_REMOVE */\r
+\r
+ /* Set the Data Endpoint 8 Interrupt. */\r
+ #if(USBFS_EP8_ISR_REMOVE == 0u)\r
+ (void) CyIntSetVector(USBFS_EP_8_VECT_NUM, &USBFS_EP_8_ISR);\r
+ CyIntSetPriority(USBFS_EP_8_VECT_NUM, USBFS_EP_8_PRIOR);\r
+ #endif /* End USBFS_EP8_ISR_REMOVE */\r
+\r
+ #if((USBFS_EP_MM != USBFS__EP_MANUAL) && (USBFS_ARB_ISR_REMOVE == 0u))\r
+ /* Set the ARB Interrupt. */\r
+ (void) CyIntSetVector(USBFS_ARB_VECT_NUM, &USBFS_ARB_ISR);\r
+ CyIntSetPriority(USBFS_ARB_VECT_NUM, USBFS_ARB_PRIOR);\r
+ #endif /* End USBFS_EP_MM != USBFS__EP_MANUAL */\r
+\r
+}\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_InitComponent\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* Initialize the component, except for the HW which is done one time in\r
+* the Start function. This function pulls up D+.\r
+*\r
+* Parameters:\r
+* device: Contains the device number of the desired device descriptor.\r
+* The device number can be found in the Device Descriptor Tab of\r
+* "Configure" dialog, under the settings of desired Device Descriptor,\r
+* in the "Device Number" field.\r
+* mode: The operating voltage. This determines whether the voltage regulator\r
+* is enabled for 5V operation or if pass through mode is used for 3.3V\r
+* operation. Symbolic names and their associated values are given in the\r
+* following table.\r
+* USBFS_3V_OPERATION - Disable voltage regulator and pass-thru\r
+* Vcc for pull-up\r
+* USBFS_5V_OPERATION - Enable voltage regulator and use\r
+* regulator for pull-up\r
+* USBFS_DWR_VDDD_OPERATION - Enable or Disable voltage\r
+* regulator depend on Vddd Voltage configuration in DWR.\r
+*\r
+* Return:\r
+* None.\r
+*\r
+* Global variables:\r
+* USBFS_device: Contains the device number of the desired device\r
+* descriptor. The device number can be found in the Device Descriptor Tab\r
+* of "Configure" dialog, under the settings of desired Device Descriptor,\r
+* in the "Device Number" field.\r
+* USBFS_transferState: This variable used by the communication\r
+* functions to handle current transfer state. Initialized to\r
+* TRANS_STATE_IDLE in this API.\r
+* USBFS_configuration: Contains current configuration number\r
+* which is set by the Host using SET_CONFIGURATION request.\r
+* Initialized to zero in this API.\r
+* USBFS_deviceAddress: Contains current device address. This\r
+* variable is initialized to zero in this API. Host starts to communicate\r
+* to device with address 0 and then set it to whatever value using\r
+* SET_ADDRESS request.\r
+* USBFS_deviceStatus: initialized to 0.\r
+* This is two bit variable which contain power status in first bit\r
+* (DEVICE_STATUS_BUS_POWERED or DEVICE_STATUS_SELF_POWERED) and remote\r
+* wakeup status (DEVICE_STATUS_REMOTE_WAKEUP) in second bit.\r
+* USBFS_lastPacketSize initialized to 0;\r
+*\r
+* Reentrant:\r
+* No.\r
+*\r
+*******************************************************************************/\r
+void USBFS_InitComponent(uint8 device, uint8 mode) \r
+{\r
+ /* Initialize _hidProtocol variable to comply with\r
+ * HID 7.2.6 Set_Protocol Request:\r
+ * "When initialized, all devices default to report protocol."\r
+ */\r
+ #if defined(USBFS_ENABLE_HID_CLASS)\r
+ uint8 i;\r
+\r
+ for (i = 0u; i < USBFS_MAX_INTERFACES_NUMBER; i++)\r
+ {\r
+ USBFS_hidProtocol[i] = USBFS_PROTOCOL_REPORT;\r
+ }\r
+ #endif /* USBFS_ENABLE_HID_CLASS */\r
+\r
+ /* Enable Interrupts. */\r
+ CyIntEnable(USBFS_BUS_RESET_VECT_NUM);\r
+ CyIntEnable(USBFS_EP_0_VECT_NUM);\r
+ #if(USBFS_EP1_ISR_REMOVE == 0u)\r
+ CyIntEnable(USBFS_EP_1_VECT_NUM);\r
+ #endif /* End USBFS_EP1_ISR_REMOVE */\r
+ #if(USBFS_EP2_ISR_REMOVE == 0u)\r
+ CyIntEnable(USBFS_EP_2_VECT_NUM);\r
+ #endif /* End USBFS_EP2_ISR_REMOVE */\r
+ #if(USBFS_EP3_ISR_REMOVE == 0u)\r
+ CyIntEnable(USBFS_EP_3_VECT_NUM);\r
+ #endif /* End USBFS_EP3_ISR_REMOVE */\r
+ #if(USBFS_EP4_ISR_REMOVE == 0u)\r
+ CyIntEnable(USBFS_EP_4_VECT_NUM);\r
+ #endif /* End USBFS_EP4_ISR_REMOVE */\r
+ #if(USBFS_EP5_ISR_REMOVE == 0u)\r
+ CyIntEnable(USBFS_EP_5_VECT_NUM);\r
+ #endif /* End USBFS_EP5_ISR_REMOVE */\r
+ #if(USBFS_EP6_ISR_REMOVE == 0u)\r
+ CyIntEnable(USBFS_EP_6_VECT_NUM);\r
+ #endif /* End USBFS_EP6_ISR_REMOVE */\r
+ #if(USBFS_EP7_ISR_REMOVE == 0u)\r
+ CyIntEnable(USBFS_EP_7_VECT_NUM);\r
+ #endif /* End USBFS_EP7_ISR_REMOVE */\r
+ #if(USBFS_EP8_ISR_REMOVE == 0u)\r
+ CyIntEnable(USBFS_EP_8_VECT_NUM);\r
+ #endif /* End USBFS_EP8_ISR_REMOVE */\r
+ #if((USBFS_EP_MM != USBFS__EP_MANUAL) && (USBFS_ARB_ISR_REMOVE == 0u))\r
+ /* usb arb interrupt enable */\r
+ USBFS_ARB_INT_EN_REG = USBFS_ARB_INT_MASK;\r
+ CyIntEnable(USBFS_ARB_VECT_NUM);\r
+ #endif /* End USBFS_EP_MM != USBFS__EP_MANUAL */\r
+\r
+ /* Arbiter configuration for DMA transfers */\r
+ #if(USBFS_EP_MM != USBFS__EP_MANUAL)\r
+\r
+ #if(USBFS_EP_MM == USBFS__EP_DMAMANUAL)\r
+ USBFS_ARB_CFG_REG = USBFS_ARB_CFG_MANUAL_DMA;\r
+ #endif /* End USBFS_EP_MM == USBFS__EP_DMAMANUAL */\r
+ #if(USBFS_EP_MM == USBFS__EP_DMAAUTO)\r
+ /*Set cfg cmplt this rises DMA request when the full configuration is done */\r
+ USBFS_ARB_CFG_REG = USBFS_ARB_CFG_AUTO_DMA | USBFS_ARB_CFG_AUTO_MEM;\r
+ #endif /* End USBFS_EP_MM == USBFS__EP_DMAAUTO */\r
+ #endif /* End USBFS_EP_MM != USBFS__EP_MANUAL */\r
+\r
+ USBFS_transferState = USBFS_TRANS_STATE_IDLE;\r
+\r
+ /* USB Locking: Enabled, VRegulator: depend on mode or DWR Voltage configuration*/\r
+ switch(mode)\r
+ {\r
+ case USBFS_3V_OPERATION:\r
+ USBFS_CR1_REG = USBFS_CR1_ENABLE_LOCK;\r
+ break;\r
+ case USBFS_5V_OPERATION:\r
+ USBFS_CR1_REG = USBFS_CR1_ENABLE_LOCK | USBFS_CR1_REG_ENABLE;\r
+ break;\r
+ default: /*USBFS_DWR_VDDD_OPERATION */\r
+ #if(USBFS_VDDD_MV < USBFS_3500MV)\r
+ USBFS_CR1_REG = USBFS_CR1_ENABLE_LOCK;\r
+ #else\r
+ USBFS_CR1_REG = USBFS_CR1_ENABLE_LOCK | USBFS_CR1_REG_ENABLE;\r
+ #endif /* End USBFS_VDDD_MV < USBFS_3500MV */\r
+ break;\r
+ }\r
+\r
+ /* Record the descriptor selection */\r
+ USBFS_device = device;\r
+\r
+ /* Clear all of the component data */\r
+ USBFS_configuration = 0u;\r
+ USBFS_interfaceNumber = 0u;\r
+ USBFS_configurationChanged = 0u;\r
+ USBFS_deviceAddress = 0u;\r
+ USBFS_deviceStatus = 0u;\r
+\r
+ USBFS_lastPacketSize = 0u;\r
+\r
+ /* ACK Setup, Stall IN/OUT */\r
+ CY_SET_REG8(USBFS_EP0_CR_PTR, USBFS_MODE_STALL_IN_OUT);\r
+\r
+ /* Enable the SIE with an address 0 */\r
+ CY_SET_REG8(USBFS_CR0_PTR, USBFS_CR0_ENABLE);\r
+\r
+ /* Workaround for PSOC5LP */\r
+ CyDelayCycles(1u);\r
+\r
+ /* Finally, Enable d+ pullup and select iomode to USB mode*/\r
+ CY_SET_REG8(USBFS_USBIO_CR1_PTR, USBFS_USBIO_CR1_USBPUEN);\r
+}\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_ReInitComponent\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* This function reinitialize the component configuration and is\r
+* intend to be called from the Reset interrupt.\r
+*\r
+* Parameters:\r
+* None.\r
+*\r
+* Return:\r
+* None.\r
+*\r
+* Global variables:\r
+* USBFS_device: Contains the device number of the desired device\r
+* descriptor. The device number can be found in the Device Descriptor Tab\r
+* of "Configure" dialog, under the settings of desired Device Descriptor,\r
+* in the "Device Number" field.\r
+* USBFS_transferState: This variable used by the communication\r
+* functions to handle current transfer state. Initialized to\r
+* TRANS_STATE_IDLE in this API.\r
+* USBFS_configuration: Contains current configuration number\r
+* which is set by the Host using SET_CONFIGURATION request.\r
+* Initialized to zero in this API.\r
+* USBFS_deviceAddress: Contains current device address. This\r
+* variable is initialized to zero in this API. Host starts to communicate\r
+* to device with address 0 and then set it to whatever value using\r
+* SET_ADDRESS request.\r
+* USBFS_deviceStatus: initialized to 0.\r
+* This is two bit variable which contain power status in first bit\r
+* (DEVICE_STATUS_BUS_POWERED or DEVICE_STATUS_SELF_POWERED) and remote\r
+* wakeup status (DEVICE_STATUS_REMOTE_WAKEUP) in second bit.\r
+* USBFS_lastPacketSize initialized to 0;\r
+*\r
+* Reentrant:\r
+* No.\r
+*\r
+*******************************************************************************/\r
+void USBFS_ReInitComponent(void) \r
+{\r
+ /* Initialize _hidProtocol variable to comply with HID 7.2.6 Set_Protocol\r
+ * Request: "When initialized, all devices default to report protocol."\r
+ */\r
+ #if defined(USBFS_ENABLE_HID_CLASS)\r
+ uint8 i;\r
+\r
+ for (i = 0u; i < USBFS_MAX_INTERFACES_NUMBER; i++)\r
+ {\r
+ USBFS_hidProtocol[i] = USBFS_PROTOCOL_REPORT;\r
+ }\r
+ #endif /* USBFS_ENABLE_HID_CLASS */\r
+\r
+ USBFS_transferState = USBFS_TRANS_STATE_IDLE;\r
+\r
+ /* Clear all of the component data */\r
+ USBFS_configuration = 0u;\r
+ USBFS_interfaceNumber = 0u;\r
+ USBFS_configurationChanged = 0u;\r
+ USBFS_deviceAddress = 0u;\r
+ USBFS_deviceStatus = 0u;\r
+\r
+ USBFS_lastPacketSize = 0u;\r
+\r
+\r
+ /* ACK Setup, Stall IN/OUT */\r
+ CY_SET_REG8(USBFS_EP0_CR_PTR, USBFS_MODE_STALL_IN_OUT);\r
+\r
+ /* Enable the SIE with an address 0 */\r
+ CY_SET_REG8(USBFS_CR0_PTR, USBFS_CR0_ENABLE);\r
+\r
+}\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_Stop\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* This function shuts down the USB function including to release\r
+* the D+ Pullup and disabling the SIE.\r
+*\r
+* Parameters:\r
+* None.\r
+*\r
+* Return:\r
+* None.\r
+*\r
+* Global variables:\r
+* USBFS_configuration: Contains current configuration number\r
+* which is set by the Host using SET_CONFIGURATION request.\r
+* Initialized to zero in this API.\r
+* USBFS_deviceAddress: Contains current device address. This\r
+* variable is initialized to zero in this API. Host starts to communicate\r
+* to device with address 0 and then set it to whatever value using\r
+* SET_ADDRESS request.\r
+* USBFS_deviceStatus: initialized to 0.\r
+* This is two bit variable which contain power status in first bit\r
+* (DEVICE_STATUS_BUS_POWERED or DEVICE_STATUS_SELF_POWERED) and remote\r
+* wakeup status (DEVICE_STATUS_REMOTE_WAKEUP) in second bit.\r
+* USBFS_configurationChanged: This variable is set to one after\r
+* SET_CONFIGURATION request and cleared in this function.\r
+* USBFS_intiVar variable is set to zero\r
+*\r
+*******************************************************************************/\r
+void USBFS_Stop(void) \r
+{\r
+\r
+ #if(USBFS_EP_MM != USBFS__EP_MANUAL)\r
+ USBFS_Stop_DMA(USBFS_MAX_EP); /* Stop all DMAs */\r
+ #endif /* End USBFS_EP_MM != USBFS__EP_MANUAL */\r
+\r
+ /* Disable the SIE */\r
+ USBFS_CR0_REG &= (uint8)(~USBFS_CR0_ENABLE);\r
+ /* Disable the d+ pullup */\r
+ USBFS_USBIO_CR1_REG &= (uint8)(~USBFS_USBIO_CR1_USBPUEN);\r
+ /* Disable USB in ACT PM */\r
+ USBFS_PM_ACT_CFG_REG &= (uint8)(~USBFS_PM_ACT_EN_FSUSB);\r
+ /* Disable USB block for Standby Power Mode */\r
+ USBFS_PM_STBY_CFG_REG &= (uint8)(~USBFS_PM_STBY_EN_FSUSB);\r
+\r
+ /* Disable the reset and EP interrupts */\r
+ CyIntDisable(USBFS_BUS_RESET_VECT_NUM);\r
+ CyIntDisable(USBFS_EP_0_VECT_NUM);\r
+ #if(USBFS_EP1_ISR_REMOVE == 0u)\r
+ CyIntDisable(USBFS_EP_1_VECT_NUM);\r
+ #endif /* End USBFS_EP1_ISR_REMOVE */\r
+ #if(USBFS_EP2_ISR_REMOVE == 0u)\r
+ CyIntDisable(USBFS_EP_2_VECT_NUM);\r
+ #endif /* End USBFS_EP2_ISR_REMOVE */\r
+ #if(USBFS_EP3_ISR_REMOVE == 0u)\r
+ CyIntDisable(USBFS_EP_3_VECT_NUM);\r
+ #endif /* End USBFS_EP3_ISR_REMOVE */\r
+ #if(USBFS_EP4_ISR_REMOVE == 0u)\r
+ CyIntDisable(USBFS_EP_4_VECT_NUM);\r
+ #endif /* End USBFS_EP4_ISR_REMOVE */\r
+ #if(USBFS_EP5_ISR_REMOVE == 0u)\r
+ CyIntDisable(USBFS_EP_5_VECT_NUM);\r
+ #endif /* End USBFS_EP5_ISR_REMOVE */\r
+ #if(USBFS_EP6_ISR_REMOVE == 0u)\r
+ CyIntDisable(USBFS_EP_6_VECT_NUM);\r
+ #endif /* End USBFS_EP6_ISR_REMOVE */\r
+ #if(USBFS_EP7_ISR_REMOVE == 0u)\r
+ CyIntDisable(USBFS_EP_7_VECT_NUM);\r
+ #endif /* End USBFS_EP7_ISR_REMOVE */\r
+ #if(USBFS_EP8_ISR_REMOVE == 0u)\r
+ CyIntDisable(USBFS_EP_8_VECT_NUM);\r
+ #endif /* End USBFS_EP8_ISR_REMOVE */\r
+\r
+ /* Clear all of the component data */\r
+ USBFS_configuration = 0u;\r
+ USBFS_interfaceNumber = 0u;\r
+ USBFS_configurationChanged = 0u;\r
+ USBFS_deviceAddress = 0u;\r
+ USBFS_deviceStatus = 0u;\r
+ USBFS_initVar = 0u;\r
+\r
+}\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_CheckActivity\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* Returns the activity status of the bus. Clears the status hardware to\r
+* provide fresh activity status on the next call of this routine.\r
+*\r
+* Parameters:\r
+* None.\r
+*\r
+* Return:\r
+* 1 - If bus activity was detected since the last call to this function\r
+* 0 - If bus activity not was detected since the last call to this function\r
+*\r
+*******************************************************************************/\r
+uint8 USBFS_CheckActivity(void) \r
+{\r
+ uint8 r;\r
+\r
+ r = CY_GET_REG8(USBFS_CR1_PTR);\r
+ CY_SET_REG8(USBFS_CR1_PTR, (r & ((uint8)(~USBFS_CR1_BUS_ACTIVITY))));\r
+\r
+ return((r & USBFS_CR1_BUS_ACTIVITY) >> USBFS_CR1_BUS_ACTIVITY_SHIFT);\r
+}\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_GetConfiguration\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* Returns the current configuration setting\r
+*\r
+* Parameters:\r
+* None.\r
+*\r
+* Return:\r
+* configuration.\r
+*\r
+*******************************************************************************/\r
+uint8 USBFS_GetConfiguration(void) \r
+{\r
+ return(USBFS_configuration);\r
+}\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_IsConfigurationChanged\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* Returns the clear on read configuration state. It is usefull when PC send\r
+* double SET_CONFIGURATION request with same configuration number.\r
+*\r
+* Parameters:\r
+* None.\r
+*\r
+* Return:\r
+* Not zero value when new configuration has been changed, otherwise zero is\r
+* returned.\r
+*\r
+* Global variables:\r
+* USBFS_configurationChanged: This variable is set to one after\r
+* SET_CONFIGURATION request and cleared in this function.\r
+*\r
+*******************************************************************************/\r
+uint8 USBFS_IsConfigurationChanged(void) \r
+{\r
+ uint8 res = 0u;\r
+\r
+ if(USBFS_configurationChanged != 0u)\r
+ {\r
+ res = USBFS_configurationChanged;\r
+ USBFS_configurationChanged = 0u;\r
+ }\r
+\r
+ return(res);\r
+}\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_GetInterfaceSetting\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* Returns the alternate setting from current interface\r
+*\r
+* Parameters:\r
+* uint8 interfaceNumber, interface number\r
+*\r
+* Return:\r
+* Alternate setting.\r
+*\r
+*******************************************************************************/\r
+uint8 USBFS_GetInterfaceSetting(uint8 interfaceNumber)\r
+ \r
+{\r
+ return(USBFS_interfaceSetting[interfaceNumber]);\r
+}\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_GetEPState\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* Returned the state of the requested endpoint.\r
+*\r
+* Parameters:\r
+* epNumber: Endpoint Number\r
+*\r
+* Return:\r
+* State of the requested endpoint.\r
+*\r
+*******************************************************************************/\r
+uint8 USBFS_GetEPState(uint8 epNumber) \r
+{\r
+ return(USBFS_EP[epNumber].apiEpState);\r
+}\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_GetEPCount\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* This function supports Data Endpoints only(EP1-EP8).\r
+* Returns the transfer count for the requested endpoint. The value from\r
+* the count registers includes 2 counts for the two byte checksum of the\r
+* packet. This function subtracts the two counts.\r
+*\r
+* Parameters:\r
+* epNumber: Data Endpoint Number.\r
+* Valid values are between 1 and 8.\r
+*\r
+* Return:\r
+* Returns the current byte count from the specified endpoint or 0 for an\r
+* invalid endpoint.\r
+*\r
+*******************************************************************************/\r
+uint16 USBFS_GetEPCount(uint8 epNumber) \r
+{\r
+ uint8 ri;\r
+ uint16 result = 0u;\r
+\r
+ if((epNumber > USBFS_EP0) && (epNumber < USBFS_MAX_EP))\r
+ {\r
+ ri = ((epNumber - USBFS_EP1) << USBFS_EPX_CNTX_ADDR_SHIFT);\r
+\r
+ result = (uint8)(CY_GET_REG8((reg8 *)(USBFS_SIE_EP1_CNT0_IND + ri)) &\r
+ USBFS_EPX_CNT0_MASK);\r
+ result = (result << 8u) | CY_GET_REG8((reg8 *)(USBFS_SIE_EP1_CNT1_IND + ri));\r
+ result -= USBFS_EPX_CNTX_CRC_COUNT;\r
+ }\r
+ return(result);\r
+}\r
+\r
+\r
+#if(USBFS_EP_MM != USBFS__EP_MANUAL)\r
+\r
+\r
+ /*******************************************************************************\r
+ * Function Name: USBFS_InitEP_DMA\r
+ ********************************************************************************\r
+ *\r
+ * Summary:\r
+ * This function allocates and initializes a DMA channel to be used by the\r
+ * USBFS_LoadInEP() or USBFS_ReadOutEP() APIs for data\r
+ * transfer.\r
+ *\r
+ * Parameters:\r
+ * epNumber: Contains the data endpoint number.\r
+ * Valid values are between 1 and 8.\r
+ * *pData: Pointer to a data array that is related to the EP transfers.\r
+ *\r
+ * Return:\r
+ * None.\r
+ *\r
+ * Reentrant:\r
+ * No.\r
+ *\r
+ *******************************************************************************/\r
+ void USBFS_InitEP_DMA(uint8 epNumber, const uint8 *pData)\r
+ \r
+ {\r
+ uint16 src;\r
+ uint16 dst;\r
+ #if (CY_PSOC3) /* PSoC 3 */\r
+ src = HI16(CYDEV_SRAM_BASE);\r
+ dst = HI16(CYDEV_PERIPH_BASE);\r
+ pData = pData;\r
+ #else /* PSoC 5 */\r
+ if((USBFS_EP[epNumber].addr & USBFS_DIR_IN) != 0u )\r
+ { /* for the IN EP source is the SRAM memory buffer */\r
+ src = HI16(pData);\r
+ dst = HI16(CYDEV_PERIPH_BASE);\r
+ }\r
+ else\r
+ { /* for the OUT EP source is the SIE register */\r
+ src = HI16(CYDEV_PERIPH_BASE);\r
+ dst = HI16(pData);\r
+ }\r
+ #endif /* End C51 */\r
+ switch(epNumber)\r
+ {\r
+ case USBFS_EP1:\r
+ #if(USBFS_DMA1_REMOVE == 0u)\r
+ USBFS_DmaChan[epNumber] = USBFS_ep1_DmaInitialize(\r
+ USBFS_DMA_BYTES_PER_BURST, USBFS_DMA_REQUEST_PER_BURST, src, dst);\r
+ #endif /* End USBFS_DMA1_REMOVE */\r
+ break;\r
+ case USBFS_EP2:\r
+ #if(USBFS_DMA2_REMOVE == 0u)\r
+ USBFS_DmaChan[epNumber] = USBFS_ep2_DmaInitialize(\r
+ USBFS_DMA_BYTES_PER_BURST, USBFS_DMA_REQUEST_PER_BURST, src, dst);\r
+ #endif /* End USBFS_DMA2_REMOVE */\r
+ break;\r
+ case USBFS_EP3:\r
+ #if(USBFS_DMA3_REMOVE == 0u)\r
+ USBFS_DmaChan[epNumber] = USBFS_ep3_DmaInitialize(\r
+ USBFS_DMA_BYTES_PER_BURST, USBFS_DMA_REQUEST_PER_BURST, src, dst);\r
+ #endif /* End USBFS_DMA3_REMOVE */\r
+ break;\r
+ case USBFS_EP4:\r
+ #if(USBFS_DMA4_REMOVE == 0u)\r
+ USBFS_DmaChan[epNumber] = USBFS_ep4_DmaInitialize(\r
+ USBFS_DMA_BYTES_PER_BURST, USBFS_DMA_REQUEST_PER_BURST, src, dst);\r
+ #endif /* End USBFS_DMA4_REMOVE */\r
+ break;\r
+ case USBFS_EP5:\r
+ #if(USBFS_DMA5_REMOVE == 0u)\r
+ USBFS_DmaChan[epNumber] = USBFS_ep5_DmaInitialize(\r
+ USBFS_DMA_BYTES_PER_BURST, USBFS_DMA_REQUEST_PER_BURST, src, dst);\r
+ #endif /* End USBFS_DMA5_REMOVE */\r
+ break;\r
+ case USBFS_EP6:\r
+ #if(USBFS_DMA6_REMOVE == 0u)\r
+ USBFS_DmaChan[epNumber] = USBFS_ep6_DmaInitialize(\r
+ USBFS_DMA_BYTES_PER_BURST, USBFS_DMA_REQUEST_PER_BURST, src, dst);\r
+ #endif /* End USBFS_DMA6_REMOVE */\r
+ break;\r
+ case USBFS_EP7:\r
+ #if(USBFS_DMA7_REMOVE == 0u)\r
+ USBFS_DmaChan[epNumber] = USBFS_ep7_DmaInitialize(\r
+ USBFS_DMA_BYTES_PER_BURST, USBFS_DMA_REQUEST_PER_BURST, src, dst);\r
+ #endif /* End USBFS_DMA7_REMOVE */\r
+ break;\r
+ case USBFS_EP8:\r
+ #if(USBFS_DMA8_REMOVE == 0u)\r
+ USBFS_DmaChan[epNumber] = USBFS_ep8_DmaInitialize(\r
+ USBFS_DMA_BYTES_PER_BURST, USBFS_DMA_REQUEST_PER_BURST, src, dst);\r
+ #endif /* End USBFS_DMA8_REMOVE */\r
+ break;\r
+ default:\r
+ /* Do not support EP0 DMA transfers */\r
+ break;\r
+ }\r
+ if((epNumber > USBFS_EP0) && (epNumber < USBFS_MAX_EP))\r
+ {\r
+ USBFS_DmaTd[epNumber] = CyDmaTdAllocate();\r
+ }\r
+ }\r
+\r
+\r
+ /*******************************************************************************\r
+ * Function Name: USBFS_Stop_DMA\r
+ ********************************************************************************\r
+ *\r
+ * Summary: Stops and free DMA\r
+ *\r
+ * Parameters:\r
+ * epNumber: Contains the data endpoint number or\r
+ * USBFS_MAX_EP to stop all DMAs\r
+ *\r
+ * Return:\r
+ * None.\r
+ *\r
+ * Reentrant:\r
+ * No.\r
+ *\r
+ *******************************************************************************/\r
+ void USBFS_Stop_DMA(uint8 epNumber) \r
+ {\r
+ uint8 i;\r
+ i = (epNumber < USBFS_MAX_EP) ? epNumber : USBFS_EP1;\r
+ do\r
+ {\r
+ if(USBFS_DmaTd[i] != DMA_INVALID_TD)\r
+ {\r
+ (void) CyDmaChDisable(USBFS_DmaChan[i]);\r
+ CyDmaTdFree(USBFS_DmaTd[i]);\r
+ USBFS_DmaTd[i] = DMA_INVALID_TD;\r
+ }\r
+ i++;\r
+ }while((i < USBFS_MAX_EP) && (epNumber == USBFS_MAX_EP));\r
+ }\r
+\r
+#endif /* End USBFS_EP_MM != USBFS__EP_MANUAL */\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_LoadInEP\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* Loads and enables the specified USB data endpoint for an IN interrupt or bulk\r
+* transfer.\r
+*\r
+* Parameters:\r
+* epNumber: Contains the data endpoint number.\r
+* Valid values are between 1 and 8.\r
+* *pData: A pointer to a data array from which the data for the endpoint space\r
+* is loaded.\r
+* length: The number of bytes to transfer from the array and then send as a\r
+* result of an IN request. Valid values are between 0 and 512.\r
+*\r
+* Return:\r
+* None.\r
+*\r
+* Reentrant:\r
+* No.\r
+*\r
+*******************************************************************************/\r
+void USBFS_LoadInEP(uint8 epNumber, const uint8 pData[], uint16 length)\r
+ \r
+{\r
+ uint8 ri;\r
+ reg8 *p;\r
+ #if(USBFS_EP_MM == USBFS__EP_MANUAL)\r
+ uint16 i;\r
+ #endif /* End USBFS_EP_MM == USBFS__EP_MANUAL */\r
+\r
+ if((epNumber > USBFS_EP0) && (epNumber < USBFS_MAX_EP))\r
+ {\r
+ ri = ((epNumber - USBFS_EP1) << USBFS_EPX_CNTX_ADDR_SHIFT);\r
+ p = (reg8 *)(USBFS_ARB_RW1_DR_IND + ri);\r
+\r
+ #if(USBFS_EP_MM != USBFS__EP_DMAAUTO)\r
+ /* Limits length to available buffer space, auto MM could send packets up to 1024 bytes */\r
+ if(length > (USBFS_EPX_DATA_BUF_MAX - USBFS_EP[epNumber].buffOffset))\r
+ {\r
+ length = USBFS_EPX_DATA_BUF_MAX - USBFS_EP[epNumber].buffOffset;\r
+ }\r
+ #endif /* End USBFS_EP_MM != USBFS__EP_DMAAUTO */\r
+\r
+ /* Set the count and data toggle */\r
+ CY_SET_REG8((reg8 *)(USBFS_SIE_EP1_CNT0_IND + ri),\r
+ (length >> 8u) | (USBFS_EP[epNumber].epToggle));\r
+ CY_SET_REG8((reg8 *)(USBFS_SIE_EP1_CNT1_IND + ri), length & 0xFFu);\r
+\r
+ #if(USBFS_EP_MM == USBFS__EP_MANUAL)\r
+ if(pData != NULL)\r
+ {\r
+ /* Copy the data using the arbiter data register */\r
+ for (i = 0u; i < length; i++)\r
+ {\r
+ CY_SET_REG8(p, pData[i]);\r
+ }\r
+ }\r
+ USBFS_EP[epNumber].apiEpState = USBFS_NO_EVENT_PENDING;\r
+ /* Write the Mode register */\r
+ CY_SET_REG8((reg8 *)(USBFS_SIE_EP1_CR0_IND + ri), USBFS_EP[epNumber].epMode);\r
+ #else\r
+ /* Init DMA if it was not initialized */\r
+ if(USBFS_DmaTd[epNumber] == DMA_INVALID_TD)\r
+ {\r
+ USBFS_InitEP_DMA(epNumber, pData);\r
+ }\r
+ #endif /* End USBFS_EP_MM == USBFS__EP_MANUAL */\r
+\r
+ #if(USBFS_EP_MM == USBFS__EP_DMAMANUAL)\r
+ USBFS_EP[epNumber].apiEpState = USBFS_NO_EVENT_PENDING;\r
+ if((pData != NULL) && (length > 0u))\r
+ {\r
+ /* Enable DMA in mode2 for transferring data */\r
+ (void) CyDmaChDisable(USBFS_DmaChan[epNumber]);\r
+ (void) CyDmaTdSetConfiguration(USBFS_DmaTd[epNumber], length, CY_DMA_DISABLE_TD,\r
+ TD_TERMIN_EN | TD_INC_SRC_ADR);\r
+ (void) CyDmaTdSetAddress(USBFS_DmaTd[epNumber], LO16((uint32)pData), LO16((uint32)p));\r
+ /* Enable the DMA */\r
+ (void) CyDmaChSetInitialTd(USBFS_DmaChan[epNumber], USBFS_DmaTd[epNumber]);\r
+ (void) CyDmaChEnable(USBFS_DmaChan[epNumber], 1u);\r
+ /* Generate DMA request */\r
+ * (reg8 *)(USBFS_ARB_EP1_CFG_IND + ri) |= USBFS_ARB_EPX_CFG_DMA_REQ;\r
+ * (reg8 *)(USBFS_ARB_EP1_CFG_IND + ri) &= ((uint8)(~USBFS_ARB_EPX_CFG_DMA_REQ));\r
+ /* Mode register will be written in arb ISR after DMA transfer complete */\r
+ }\r
+ else\r
+ {\r
+ /* When zero-length packet - write the Mode register directly */\r
+ CY_SET_REG8((reg8 *)(USBFS_SIE_EP1_CR0_IND + ri), USBFS_EP[epNumber].epMode);\r
+ }\r
+ #endif /* End USBFS_EP_MM == USBFS__EP_DMAMANUAL */\r
+\r
+ #if(USBFS_EP_MM == USBFS__EP_DMAAUTO)\r
+ if(pData != NULL)\r
+ {\r
+ /* Enable DMA in mode3 for transferring data */\r
+ (void) CyDmaChDisable(USBFS_DmaChan[epNumber]);\r
+ (void) CyDmaTdSetConfiguration(USBFS_DmaTd[epNumber], length,\r
+ USBFS_DmaTd[epNumber], TD_TERMIN_EN | TD_INC_SRC_ADR);\r
+ (void) CyDmaTdSetAddress(USBFS_DmaTd[epNumber], LO16((uint32)pData), LO16((uint32)p));\r
+ /* Clear Any potential pending DMA requests before starting the DMA channel to transfer data */\r
+ (void) CyDmaClearPendingDrq(USBFS_DmaChan[epNumber]);\r
+ /* Enable the DMA */\r
+ (void) CyDmaChSetInitialTd(USBFS_DmaChan[epNumber], USBFS_DmaTd[epNumber]);\r
+ (void) CyDmaChEnable(USBFS_DmaChan[epNumber], 1u);\r
+ }\r
+ else\r
+ {\r
+ USBFS_EP[epNumber].apiEpState = USBFS_NO_EVENT_PENDING;\r
+ if(length > 0u)\r
+ {\r
+ /* Set Data ready status, This will generate DMA request */\r
+ * (reg8 *)(USBFS_ARB_EP1_CFG_IND + ri) |= USBFS_ARB_EPX_CFG_IN_DATA_RDY;\r
+ /* Mode register will be written in arb ISR(In Buffer Full) after first DMA transfer complete */\r
+ }\r
+ else\r
+ {\r
+ /* When zero-length packet - write the Mode register directly */\r
+ CY_SET_REG8((reg8 *)(USBFS_SIE_EP1_CR0_IND + ri), USBFS_EP[epNumber].epMode);\r
+ }\r
+ }\r
+ #endif /* End USBFS_EP_MM == USBFS__EP_DMAAUTO */\r
+\r
+ }\r
+}\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_ReadOutEP\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* Read data from an endpoint. The application must call\r
+* USBFS_GetEPState to see if an event is pending.\r
+*\r
+* Parameters:\r
+* epNumber: Contains the data endpoint number.\r
+* Valid values are between 1 and 8.\r
+* pData: A pointer to a data array from which the data for the endpoint space\r
+* is loaded.\r
+* length: The number of bytes to transfer from the USB Out endpoint and loads\r
+* it into data array. Valid values are between 0 and 1023. The function\r
+* moves fewer than the requested number of bytes if the host sends\r
+* fewer bytes than requested.\r
+*\r
+* Returns:\r
+* Number of bytes received, 0 for an invalid endpoint.\r
+*\r
+* Reentrant:\r
+* No.\r
+*\r
+*******************************************************************************/\r
+uint16 USBFS_ReadOutEP(uint8 epNumber, uint8 pData[], uint16 length)\r
+ \r
+{\r
+ uint8 ri;\r
+ reg8 *p;\r
+ #if(USBFS_EP_MM == USBFS__EP_MANUAL)\r
+ uint16 i;\r
+ #endif /* End USBFS_EP_MM == USBFS__EP_MANUAL */\r
+ #if(USBFS_EP_MM != USBFS__EP_DMAAUTO)\r
+ uint16 xferCount;\r
+ #endif /* End USBFS_EP_MM != USBFS__EP_DMAAUTO */\r
+\r
+ if((epNumber > USBFS_EP0) && (epNumber < USBFS_MAX_EP) && (pData != NULL))\r
+ {\r
+ ri = ((epNumber - USBFS_EP1) << USBFS_EPX_CNTX_ADDR_SHIFT);\r
+ p = (reg8 *)(USBFS_ARB_RW1_DR_IND + ri);\r
+\r
+ #if(USBFS_EP_MM != USBFS__EP_DMAAUTO)\r
+ /* Determine which is smaller the requested data or the available data */\r
+ xferCount = USBFS_GetEPCount(epNumber);\r
+ if (length > xferCount)\r
+ {\r
+ length = xferCount;\r
+ }\r
+ #endif /* End USBFS_EP_MM != USBFS__EP_DMAAUTO */\r
+\r
+ #if(USBFS_EP_MM == USBFS__EP_MANUAL)\r
+ /* Copy the data using the arbiter data register */\r
+ for (i = 0u; i < length; i++)\r
+ {\r
+ pData[i] = CY_GET_REG8(p);\r
+ }\r
+\r
+ /* (re)arming of OUT endpoint */\r
+ USBFS_EnableOutEP(epNumber);\r
+ #else\r
+ /*Init DMA if it was not initialized */\r
+ if(USBFS_DmaTd[epNumber] == DMA_INVALID_TD)\r
+ {\r
+ USBFS_InitEP_DMA(epNumber, pData);\r
+ }\r
+ #endif /* End USBFS_EP_MM == USBFS__EP_MANUAL */\r
+\r
+ #if(USBFS_EP_MM == USBFS__EP_DMAMANUAL)\r
+ /* Enable DMA in mode2 for transferring data */\r
+ (void) CyDmaChDisable(USBFS_DmaChan[epNumber]);\r
+ (void) CyDmaTdSetConfiguration(USBFS_DmaTd[epNumber], length, CY_DMA_DISABLE_TD,\r
+ TD_TERMIN_EN | TD_INC_DST_ADR);\r
+ (void) CyDmaTdSetAddress(USBFS_DmaTd[epNumber], LO16((uint32)p), LO16((uint32)pData));\r
+ /* Enable the DMA */\r
+ (void) CyDmaChSetInitialTd(USBFS_DmaChan[epNumber], USBFS_DmaTd[epNumber]);\r
+ (void) CyDmaChEnable(USBFS_DmaChan[epNumber], 1u);\r
+\r
+ /* Generate DMA request */\r
+ * (reg8 *)(USBFS_ARB_EP1_CFG_IND + ri) |= USBFS_ARB_EPX_CFG_DMA_REQ;\r
+ * (reg8 *)(USBFS_ARB_EP1_CFG_IND + ri) &= ((uint8)(~USBFS_ARB_EPX_CFG_DMA_REQ));\r
+ /* Out EP will be (re)armed in arb ISR after transfer complete */\r
+ #endif /* End USBFS_EP_MM == USBFS__EP_DMAMANUAL */\r
+\r
+ #if(USBFS_EP_MM == USBFS__EP_DMAAUTO)\r
+ /* Enable DMA in mode3 for transferring data */\r
+ (void) CyDmaChDisable(USBFS_DmaChan[epNumber]);\r
+ (void) CyDmaTdSetConfiguration(USBFS_DmaTd[epNumber], length, USBFS_DmaTd[epNumber],\r
+ TD_TERMIN_EN | TD_INC_DST_ADR);\r
+ (void) CyDmaTdSetAddress(USBFS_DmaTd[epNumber], LO16((uint32)p), LO16((uint32)pData));\r
+\r
+ /* Clear Any potential pending DMA requests before starting the DMA channel to transfer data */\r
+ (void) CyDmaClearPendingDrq(USBFS_DmaChan[epNumber]);\r
+ /* Enable the DMA */\r
+ (void) CyDmaChSetInitialTd(USBFS_DmaChan[epNumber], USBFS_DmaTd[epNumber]);\r
+ (void) CyDmaChEnable(USBFS_DmaChan[epNumber], 1u);\r
+ /* Out EP will be (re)armed in arb ISR after transfer complete */\r
+ #endif /* End USBFS_EP_MM == USBFS__EP_DMAAUTO */\r
+\r
+ }\r
+ else\r
+ {\r
+ length = 0u;\r
+ }\r
+\r
+ return(length);\r
+}\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_EnableOutEP\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* This function enables an OUT endpoint. It should not be\r
+* called for an IN endpoint.\r
+*\r
+* Parameters:\r
+* epNumber: Endpoint Number\r
+* Valid values are between 1 and 8.\r
+*\r
+* Return:\r
+* None.\r
+*\r
+* Global variables:\r
+* USBFS_EP[epNumber].apiEpState - set to NO_EVENT_PENDING\r
+*\r
+* Reentrant:\r
+* No.\r
+*\r
+*******************************************************************************/\r
+void USBFS_EnableOutEP(uint8 epNumber) \r
+{\r
+ uint8 ri;\r
+\r
+ if((epNumber > USBFS_EP0) && (epNumber < USBFS_MAX_EP))\r
+ {\r
+ ri = ((epNumber - USBFS_EP1) << USBFS_EPX_CNTX_ADDR_SHIFT);\r
+ USBFS_EP[epNumber].apiEpState = USBFS_NO_EVENT_PENDING;\r
+ /* Write the Mode register */\r
+ CY_SET_REG8((reg8 *)(USBFS_SIE_EP1_CR0_IND + ri), USBFS_EP[epNumber].epMode);\r
+ }\r
+}\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_DisableOutEP\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* This function disables an OUT endpoint. It should not be\r
+* called for an IN endpoint.\r
+*\r
+* Parameters:\r
+* epNumber: Endpoint Number\r
+* Valid values are between 1 and 8.\r
+*\r
+* Return:\r
+* None.\r
+*\r
+*******************************************************************************/\r
+void USBFS_DisableOutEP(uint8 epNumber) \r
+{\r
+ uint8 ri ;\r
+\r
+ if((epNumber > USBFS_EP0) && (epNumber < USBFS_MAX_EP))\r
+ {\r
+ ri = ((epNumber - USBFS_EP1) << USBFS_EPX_CNTX_ADDR_SHIFT);\r
+ /* Write the Mode register */\r
+ CY_SET_REG8((reg8 *)(USBFS_SIE_EP1_CR0_IND + ri), USBFS_MODE_NAK_OUT);\r
+ }\r
+}\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_Force\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* Forces the bus state\r
+*\r
+* Parameters:\r
+* bState\r
+* USBFS_FORCE_J\r
+* USBFS_FORCE_K\r
+* USBFS_FORCE_SE0\r
+* USBFS_FORCE_NONE\r
+*\r
+* Return:\r
+* None.\r
+*\r
+*******************************************************************************/\r
+void USBFS_Force(uint8 bState) \r
+{\r
+ CY_SET_REG8(USBFS_USBIO_CR0_PTR, bState);\r
+}\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_GetEPAckState\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* Returns the ACK of the CR0 Register (ACKD)\r
+*\r
+* Parameters:\r
+* epNumber: Endpoint Number\r
+* Valid values are between 1 and 8.\r
+*\r
+* Returns\r
+* 0 if nothing has been ACKD, non-=zero something has been ACKD\r
+*\r
+*******************************************************************************/\r
+uint8 USBFS_GetEPAckState(uint8 epNumber) \r
+{\r
+ uint8 ri;\r
+ uint8 cr = 0u;\r
+\r
+ if((epNumber > USBFS_EP0) && (epNumber < USBFS_MAX_EP))\r
+ {\r
+ ri = ((epNumber - USBFS_EP1) << USBFS_EPX_CNTX_ADDR_SHIFT);\r
+ cr = CY_GET_REG8((reg8 *)(USBFS_SIE_EP1_CR0_IND + ri)) & USBFS_MODE_ACKD;\r
+ }\r
+\r
+ return(cr);\r
+}\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_SetPowerStatus\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* Sets the device power status for reporting in the Get Device Status\r
+* request\r
+*\r
+* Parameters:\r
+* powerStatus: USBFS_DEVICE_STATUS_BUS_POWERED(0) - Bus Powered,\r
+* USBFS_DEVICE_STATUS_SELF_POWERED(1) - Self Powered\r
+*\r
+* Return:\r
+* None.\r
+*\r
+* Global variables:\r
+* USBFS_deviceStatus - set power status\r
+*\r
+* Reentrant:\r
+* No.\r
+*\r
+*******************************************************************************/\r
+void USBFS_SetPowerStatus(uint8 powerStatus) \r
+{\r
+ if (powerStatus != USBFS_DEVICE_STATUS_BUS_POWERED)\r
+ {\r
+ USBFS_deviceStatus |= USBFS_DEVICE_STATUS_SELF_POWERED;\r
+ }\r
+ else\r
+ {\r
+ USBFS_deviceStatus &= ((uint8)(~USBFS_DEVICE_STATUS_SELF_POWERED));\r
+ }\r
+}\r
+\r
+\r
+#if (USBFS_MON_VBUS == 1u)\r
+\r
+ /*******************************************************************************\r
+ * Function Name: USBFS_VBusPresent\r
+ ********************************************************************************\r
+ *\r
+ * Summary:\r
+ * Determines VBUS presence for Self Powered Devices.\r
+ *\r
+ * Parameters:\r
+ * None.\r
+ *\r
+ * Return:\r
+ * 1 if VBUS is present, otherwise 0.\r
+ *\r
+ *******************************************************************************/\r
+ uint8 USBFS_VBusPresent(void) \r
+ {\r
+ return((0u != (CY_GET_REG8(USBFS_VBUS_PS_PTR) & USBFS_VBUS_MASK)) ? 1u : 0u);\r
+ }\r
+\r
+#endif /* USBFS_MON_VBUS */\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_RWUEnabled\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* Returns TRUE if Remote Wake Up is enabled, otherwise FALSE\r
+*\r
+* Parameters:\r
+* None.\r
+*\r
+* Return:\r
+* TRUE - Remote Wake Up Enabled\r
+* FALSE - Remote Wake Up Disabled\r
+*\r
+* Global variables:\r
+* USBFS_deviceStatus - checked to determine remote status\r
+*\r
+*******************************************************************************/\r
+uint8 USBFS_RWUEnabled(void) \r
+{\r
+ uint8 result = USBFS_FALSE;\r
+ if((USBFS_deviceStatus & USBFS_DEVICE_STATUS_REMOTE_WAKEUP) != 0u)\r
+ {\r
+ result = USBFS_TRUE;\r
+ }\r
+\r
+ return(result);\r
+}\r
+\r
+\r
+/* [] END OF FILE */\r
--- /dev/null
+/*******************************************************************************\r
+* File Name: USBFS.h\r
+* Version 2.60\r
+*\r
+* Description:\r
+* Header File for the USFS component. Contains prototypes and constant values.\r
+*\r
+********************************************************************************\r
+* Copyright 2008-2013, Cypress Semiconductor Corporation. All rights reserved.\r
+* You may use this file only in accordance with the license, terms, conditions,\r
+* disclaimers, and limitations in the end user license agreement accompanying\r
+* the software package with which this file was provided.\r
+*******************************************************************************/\r
+\r
+#if !defined(CY_USBFS_USBFS_H)\r
+#define CY_USBFS_USBFS_H\r
+\r
+#include "cytypes.h"\r
+#include "cydevice_trm.h"\r
+#include "cyfitter.h"\r
+#include "CyLib.h"\r
+\r
+\r
+/***************************************\r
+* Conditional Compilation Parameters\r
+***************************************/\r
+\r
+/* Check to see if required defines such as CY_PSOC5LP are available */\r
+/* They are defined starting with cy_boot v3.0 */\r
+#if !defined (CY_PSOC5LP)\r
+ #error Component USBFS_v2_60 requires cy_boot v3.0 or later\r
+#endif /* (CY_PSOC5LP) */\r
+\r
+\r
+/***************************************\r
+* Memory Type Definitions\r
+***************************************/\r
+\r
+/* Renamed Type Definitions for backward compatibility.\r
+* Should not be used in new designs.\r
+*/\r
+#define USBFS_CODE CYCODE\r
+#define USBFS_FAR CYFAR\r
+#if defined(__C51__) || defined(__CX51__)\r
+ #define USBFS_DATA data\r
+ #define USBFS_XDATA xdata\r
+#else\r
+ #define USBFS_DATA\r
+ #define USBFS_XDATA\r
+#endif /* End __C51__ */\r
+#define USBFS_NULL NULL\r
+\r
+\r
+/***************************************\r
+* Enumerated Types and Parameters\r
+***************************************/\r
+\r
+#define USBFS__EP_MANUAL 0\r
+#define USBFS__EP_DMAMANUAL 1\r
+#define USBFS__EP_DMAAUTO 2\r
+\r
+#define USBFS__MA_STATIC 0\r
+#define USBFS__MA_DYNAMIC 1\r
+\r
+\r
+\r
+/***************************************\r
+* Initial Parameter Constants\r
+***************************************/\r
+\r
+#define USBFS_NUM_DEVICES (1u)\r
+#define USBFS_ENABLE_DESCRIPTOR_STRINGS \r
+#define USBFS_ENABLE_SN_STRING \r
+#define USBFS_ENABLE_STRINGS \r
+#define USBFS_DEVICE0_CONFIGURATION0_INTERFACE0_ALTERNATE0_HID_IN_BUF_SIZE (65u)\r
+#define USBFS_DEVICE0_CONFIGURATION0_INTERFACE0_ALTERNATE0_HID_NUM_IN_RPTS (1u)\r
+#define USBFS_DEVICE0_CONFIGURATION0_INTERFACE0_ALTERNATE0_HID_OUT_BUF_SIZE (65u)\r
+#define USBFS_DEVICE0_CONFIGURATION0_INTERFACE0_ALTERNATE0_HID_NUM_OUT_RPTS (1u)\r
+#define USBFS_DEVICE0_CONFIGURATION0_INTERFACE0_ALTERNATE0_HID_COUNT (1u)\r
+#define USBFS_ENABLE_HID_CLASS \r
+#define USBFS_HID_RPT_1_SIZE_LSB (0x24u)\r
+#define USBFS_HID_RPT_1_SIZE_MSB (0x00u)\r
+#define USBFS_MAX_REPORTID_NUMBER (0u)\r
+\r
+#define USBFS_MON_VBUS (0u)\r
+#define USBFS_EXTERN_VBUS (0u)\r
+#define USBFS_EXTERN_VND (0u)\r
+#define USBFS_EXTERN_CLS (0u)\r
+#define USBFS_MAX_INTERFACES_NUMBER (1u)\r
+#define USBFS_EP0_ISR_REMOVE (0u)\r
+#define USBFS_EP1_ISR_REMOVE (0u)\r
+#define USBFS_EP2_ISR_REMOVE (0u)\r
+#define USBFS_EP3_ISR_REMOVE (1u)\r
+#define USBFS_EP4_ISR_REMOVE (1u)\r
+#define USBFS_EP5_ISR_REMOVE (1u)\r
+#define USBFS_EP6_ISR_REMOVE (1u)\r
+#define USBFS_EP7_ISR_REMOVE (1u)\r
+#define USBFS_EP8_ISR_REMOVE (1u)\r
+#define USBFS_EP_MM (0u)\r
+#define USBFS_EP_MA (0u)\r
+#define USBFS_DMA1_REMOVE (1u)\r
+#define USBFS_DMA2_REMOVE (1u)\r
+#define USBFS_DMA3_REMOVE (1u)\r
+#define USBFS_DMA4_REMOVE (1u)\r
+#define USBFS_DMA5_REMOVE (1u)\r
+#define USBFS_DMA6_REMOVE (1u)\r
+#define USBFS_DMA7_REMOVE (1u)\r
+#define USBFS_DMA8_REMOVE (1u)\r
+#define USBFS_SOF_ISR_REMOVE (0u)\r
+#define USBFS_ARB_ISR_REMOVE (0u)\r
+#define USBFS_DP_ISR_REMOVE (0u)\r
+#define USBFS_ENABLE_CDC_CLASS_API (1u)\r
+#define USBFS_ENABLE_MIDI_API (1u)\r
+#define USBFS_MIDI_EXT_MODE (0u)\r
+\r
+\r
+/***************************************\r
+* Data Struct Definition\r
+***************************************/\r
+\r
+typedef struct\r
+{\r
+ uint8 attrib;\r
+ uint8 apiEpState;\r
+ uint8 hwEpState;\r
+ uint8 epToggle;\r
+ uint8 addr;\r
+ uint8 epMode;\r
+ uint16 buffOffset;\r
+ uint16 bufferSize;\r
+ uint8 interface;\r
+} T_USBFS_EP_CTL_BLOCK;\r
+\r
+typedef struct\r
+{\r
+ uint8 interface;\r
+ uint8 altSetting;\r
+ uint8 addr;\r
+ uint8 attributes;\r
+ uint16 bufferSize;\r
+ uint8 bMisc;\r
+} T_USBFS_EP_SETTINGS_BLOCK;\r
+\r
+typedef struct\r
+{\r
+ uint8 status;\r
+ uint16 length;\r
+} T_USBFS_XFER_STATUS_BLOCK;\r
+\r
+typedef struct\r
+{\r
+ uint16 count;\r
+ volatile uint8 *pData;\r
+ T_USBFS_XFER_STATUS_BLOCK *pStatusBlock;\r
+} T_USBFS_TD;\r
+\r
+\r
+typedef struct\r
+{\r
+ uint8 c;\r
+ const void *p_list;\r
+} T_USBFS_LUT;\r
+\r
+/* Resume/Suspend API Support */\r
+typedef struct\r
+{\r
+ uint8 enableState;\r
+ uint8 mode;\r
+} USBFS_BACKUP_STRUCT;\r
+\r
+\r
+/* Renamed structure fields for backward compatibility.\r
+* Should not be used in new designs.\r
+*/\r
+#define wBuffOffset buffOffset\r
+#define wBufferSize bufferSize\r
+#define bStatus status\r
+#define wLength length\r
+#define wCount count\r
+\r
+/* Renamed global variable for backward compatibility.\r
+* Should not be used in new designs.\r
+*/\r
+#define CurrentTD USBFS_currentTD\r
+\r
+\r
+/***************************************\r
+* Function Prototypes\r
+***************************************/\r
+\r
+void USBFS_Start(uint8 device, uint8 mode) ;\r
+void USBFS_Init(void) ;\r
+void USBFS_InitComponent(uint8 device, uint8 mode) ;\r
+void USBFS_Stop(void) ;\r
+uint8 USBFS_CheckActivity(void) ;\r
+uint8 USBFS_GetConfiguration(void) ;\r
+uint8 USBFS_IsConfigurationChanged(void) ;\r
+uint8 USBFS_GetInterfaceSetting(uint8 interfaceNumber)\r
+ ;\r
+uint8 USBFS_GetEPState(uint8 epNumber) ;\r
+uint16 USBFS_GetEPCount(uint8 epNumber) ;\r
+void USBFS_LoadInEP(uint8 epNumber, const uint8 pData[], uint16 length)\r
+ ;\r
+uint16 USBFS_ReadOutEP(uint8 epNumber, uint8 pData[], uint16 length)\r
+ ;\r
+void USBFS_EnableOutEP(uint8 epNumber) ;\r
+void USBFS_DisableOutEP(uint8 epNumber) ;\r
+void USBFS_Force(uint8 bState) ;\r
+uint8 USBFS_GetEPAckState(uint8 epNumber) ;\r
+void USBFS_SetPowerStatus(uint8 powerStatus) ;\r
+uint8 USBFS_RWUEnabled(void) ;\r
+void USBFS_TerminateEP(uint8 ep) ;\r
+\r
+void USBFS_Suspend(void) ;\r
+void USBFS_Resume(void) ;\r
+\r
+#if defined(USBFS_ENABLE_FWSN_STRING)\r
+ void USBFS_SerialNumString(uint8 snString[]) ;\r
+#endif /* USBFS_ENABLE_FWSN_STRING */\r
+#if (USBFS_MON_VBUS == 1u)\r
+ uint8 USBFS_VBusPresent(void) ;\r
+#endif /* End USBFS_MON_VBUS */\r
+\r
+#if defined(CYDEV_BOOTLOADER_IO_COMP) && ((CYDEV_BOOTLOADER_IO_COMP == CyBtldr_USBFS) || \\r
+ (CYDEV_BOOTLOADER_IO_COMP == CyBtldr_Custom_Interface))\r
+\r
+ void USBFS_CyBtldrCommStart(void) ;\r
+ void USBFS_CyBtldrCommStop(void) ;\r
+ void USBFS_CyBtldrCommReset(void) ;\r
+ cystatus USBFS_CyBtldrCommWrite(uint8 *pData, uint16 size, uint16 *count, uint8 timeOut) CYSMALL\r
+ ;\r
+ cystatus USBFS_CyBtldrCommRead( uint8 *pData, uint16 size, uint16 *count, uint8 timeOut) CYSMALL\r
+ ;\r
+\r
+ #define USBFS_BTLDR_SIZEOF_WRITE_BUFFER (64u) /* EP 1 OUT */\r
+ #define USBFS_BTLDR_SIZEOF_READ_BUFFER (64u) /* EP 2 IN */\r
+ #define USBFS_BTLDR_MAX_PACKET_SIZE USBFS_BTLDR_SIZEOF_WRITE_BUFFER\r
+\r
+ /* These defines active if used USBFS interface as an\r
+ * IO Component for bootloading. When Custom_Interface selected\r
+ * in Bootloder configuration as the IO Component, user must\r
+ * provide these functions\r
+ */\r
+ #if (CYDEV_BOOTLOADER_IO_COMP == CyBtldr_USBFS)\r
+ #define CyBtldrCommStart USBFS_CyBtldrCommStart\r
+ #define CyBtldrCommStop USBFS_CyBtldrCommStop\r
+ #define CyBtldrCommReset USBFS_CyBtldrCommReset\r
+ #define CyBtldrCommWrite USBFS_CyBtldrCommWrite\r
+ #define CyBtldrCommRead USBFS_CyBtldrCommRead\r
+ #endif /*End CYDEV_BOOTLOADER_IO_COMP == CyBtldr_USBFS */\r
+\r
+#endif /* End CYDEV_BOOTLOADER_IO_COMP */\r
+\r
+#if(USBFS_EP_MM != USBFS__EP_MANUAL)\r
+ void USBFS_InitEP_DMA(uint8 epNumber, const uint8 *pData)\r
+ ;\r
+ void USBFS_Stop_DMA(uint8 epNumber) ;\r
+#endif /* End USBFS_EP_MM != USBFS__EP_MANUAL) */\r
+\r
+#if defined(USBFS_ENABLE_MIDI_STREAMING) && (USBFS_ENABLE_MIDI_API != 0u)\r
+ void USBFS_MIDI_EP_Init(void) ;\r
+\r
+ #if (USBFS_MIDI_IN_BUFF_SIZE > 0)\r
+ void USBFS_MIDI_IN_Service(void) ;\r
+ uint8 USBFS_PutUsbMidiIn(uint8 ic, const uint8 midiMsg[], uint8 cable)\r
+ ;\r
+ #endif /* USBFS_MIDI_IN_BUFF_SIZE > 0 */\r
+\r
+ #if (USBFS_MIDI_OUT_BUFF_SIZE > 0)\r
+ void USBFS_MIDI_OUT_EP_Service(void) ;\r
+ #endif /* USBFS_MIDI_OUT_BUFF_SIZE > 0 */\r
+\r
+#endif /* End USBFS_ENABLE_MIDI_API != 0u */\r
+\r
+/* Renamed Functions for backward compatibility.\r
+* Should not be used in new designs.\r
+*/\r
+\r
+#define USBFS_bCheckActivity USBFS_CheckActivity\r
+#define USBFS_bGetConfiguration USBFS_GetConfiguration\r
+#define USBFS_bGetInterfaceSetting USBFS_GetInterfaceSetting\r
+#define USBFS_bGetEPState USBFS_GetEPState\r
+#define USBFS_wGetEPCount USBFS_GetEPCount\r
+#define USBFS_bGetEPAckState USBFS_GetEPAckState\r
+#define USBFS_bRWUEnabled USBFS_RWUEnabled\r
+#define USBFS_bVBusPresent USBFS_VBusPresent\r
+\r
+#define USBFS_bConfiguration USBFS_configuration\r
+#define USBFS_bInterfaceSetting USBFS_interfaceSetting\r
+#define USBFS_bDeviceAddress USBFS_deviceAddress\r
+#define USBFS_bDeviceStatus USBFS_deviceStatus\r
+#define USBFS_bDevice USBFS_device\r
+#define USBFS_bTransferState USBFS_transferState\r
+#define USBFS_bLastPacketSize USBFS_lastPacketSize\r
+\r
+#define USBFS_LoadEP USBFS_LoadInEP\r
+#define USBFS_LoadInISOCEP USBFS_LoadInEP\r
+#define USBFS_EnableOutISOCEP USBFS_EnableOutEP\r
+\r
+#define USBFS_SetVector CyIntSetVector\r
+#define USBFS_SetPriority CyIntSetPriority\r
+#define USBFS_EnableInt CyIntEnable\r
+\r
+\r
+/***************************************\r
+* API Constants\r
+***************************************/\r
+\r
+#define USBFS_EP0 (0u)\r
+#define USBFS_EP1 (1u)\r
+#define USBFS_EP2 (2u)\r
+#define USBFS_EP3 (3u)\r
+#define USBFS_EP4 (4u)\r
+#define USBFS_EP5 (5u)\r
+#define USBFS_EP6 (6u)\r
+#define USBFS_EP7 (7u)\r
+#define USBFS_EP8 (8u)\r
+#define USBFS_MAX_EP (9u)\r
+\r
+#define USBFS_TRUE (1u)\r
+#define USBFS_FALSE (0u)\r
+\r
+#define USBFS_NO_EVENT_ALLOWED (2u)\r
+#define USBFS_EVENT_PENDING (1u)\r
+#define USBFS_NO_EVENT_PENDING (0u)\r
+\r
+#define USBFS_IN_BUFFER_FULL USBFS_NO_EVENT_PENDING\r
+#define USBFS_IN_BUFFER_EMPTY USBFS_EVENT_PENDING\r
+#define USBFS_OUT_BUFFER_FULL USBFS_EVENT_PENDING\r
+#define USBFS_OUT_BUFFER_EMPTY USBFS_NO_EVENT_PENDING\r
+\r
+#define USBFS_FORCE_J (0xA0u)\r
+#define USBFS_FORCE_K (0x80u)\r
+#define USBFS_FORCE_SE0 (0xC0u)\r
+#define USBFS_FORCE_NONE (0x00u)\r
+\r
+#define USBFS_IDLE_TIMER_RUNNING (0x02u)\r
+#define USBFS_IDLE_TIMER_EXPIRED (0x01u)\r
+#define USBFS_IDLE_TIMER_INDEFINITE (0x00u)\r
+\r
+#define USBFS_DEVICE_STATUS_BUS_POWERED (0x00u)\r
+#define USBFS_DEVICE_STATUS_SELF_POWERED (0x01u)\r
+\r
+#define USBFS_3V_OPERATION (0x00u)\r
+#define USBFS_5V_OPERATION (0x01u)\r
+#define USBFS_DWR_VDDD_OPERATION (0x02u)\r
+\r
+#define USBFS_MODE_DISABLE (0x00u)\r
+#define USBFS_MODE_NAK_IN_OUT (0x01u)\r
+#define USBFS_MODE_STATUS_OUT_ONLY (0x02u)\r
+#define USBFS_MODE_STALL_IN_OUT (0x03u)\r
+#define USBFS_MODE_RESERVED_0100 (0x04u)\r
+#define USBFS_MODE_ISO_OUT (0x05u)\r
+#define USBFS_MODE_STATUS_IN_ONLY (0x06u)\r
+#define USBFS_MODE_ISO_IN (0x07u)\r
+#define USBFS_MODE_NAK_OUT (0x08u)\r
+#define USBFS_MODE_ACK_OUT (0x09u)\r
+#define USBFS_MODE_RESERVED_1010 (0x0Au)\r
+#define USBFS_MODE_ACK_OUT_STATUS_IN (0x0Bu)\r
+#define USBFS_MODE_NAK_IN (0x0Cu)\r
+#define USBFS_MODE_ACK_IN (0x0Du)\r
+#define USBFS_MODE_RESERVED_1110 (0x0Eu)\r
+#define USBFS_MODE_ACK_IN_STATUS_OUT (0x0Fu)\r
+#define USBFS_MODE_MASK (0x0Fu)\r
+#define USBFS_MODE_STALL_DATA_EP (0x80u)\r
+\r
+#define USBFS_MODE_ACKD (0x10u)\r
+#define USBFS_MODE_OUT_RCVD (0x20u)\r
+#define USBFS_MODE_IN_RCVD (0x40u)\r
+#define USBFS_MODE_SETUP_RCVD (0x80u)\r
+\r
+#define USBFS_RQST_TYPE_MASK (0x60u)\r
+#define USBFS_RQST_TYPE_STD (0x00u)\r
+#define USBFS_RQST_TYPE_CLS (0x20u)\r
+#define USBFS_RQST_TYPE_VND (0x40u)\r
+#define USBFS_RQST_DIR_MASK (0x80u)\r
+#define USBFS_RQST_DIR_D2H (0x80u)\r
+#define USBFS_RQST_DIR_H2D (0x00u)\r
+#define USBFS_RQST_RCPT_MASK (0x03u)\r
+#define USBFS_RQST_RCPT_DEV (0x00u)\r
+#define USBFS_RQST_RCPT_IFC (0x01u)\r
+#define USBFS_RQST_RCPT_EP (0x02u)\r
+#define USBFS_RQST_RCPT_OTHER (0x03u)\r
+\r
+/* USB Class Codes */\r
+#define USBFS_CLASS_DEVICE (0x00u) /* Use class code info from Interface Descriptors */\r
+#define USBFS_CLASS_AUDIO (0x01u) /* Audio device */\r
+#define USBFS_CLASS_CDC (0x02u) /* Communication device class */\r
+#define USBFS_CLASS_HID (0x03u) /* Human Interface Device */\r
+#define USBFS_CLASS_PDC (0x05u) /* Physical device class */\r
+#define USBFS_CLASS_IMAGE (0x06u) /* Still Imaging device */\r
+#define USBFS_CLASS_PRINTER (0x07u) /* Printer device */\r
+#define USBFS_CLASS_MSD (0x08u) /* Mass Storage device */\r
+#define USBFS_CLASS_HUB (0x09u) /* Full/Hi speed Hub */\r
+#define USBFS_CLASS_CDC_DATA (0x0Au) /* CDC data device */\r
+#define USBFS_CLASS_SMART_CARD (0x0Bu) /* Smart Card device */\r
+#define USBFS_CLASS_CSD (0x0Du) /* Content Security device */\r
+#define USBFS_CLASS_VIDEO (0x0Eu) /* Video device */\r
+#define USBFS_CLASS_PHD (0x0Fu) /* Personal Healthcare device */\r
+#define USBFS_CLASS_WIRELESSD (0xDCu) /* Wireless Controller */\r
+#define USBFS_CLASS_MIS (0xE0u) /* Miscellaneous */\r
+#define USBFS_CLASS_APP (0xEFu) /* Application Specific */\r
+#define USBFS_CLASS_VENDOR (0xFFu) /* Vendor specific */\r
+\r
+\r
+/* Standard Request Types (Table 9-4) */\r
+#define USBFS_GET_STATUS (0x00u)\r
+#define USBFS_CLEAR_FEATURE (0x01u)\r
+#define USBFS_SET_FEATURE (0x03u)\r
+#define USBFS_SET_ADDRESS (0x05u)\r
+#define USBFS_GET_DESCRIPTOR (0x06u)\r
+#define USBFS_SET_DESCRIPTOR (0x07u)\r
+#define USBFS_GET_CONFIGURATION (0x08u)\r
+#define USBFS_SET_CONFIGURATION (0x09u)\r
+#define USBFS_GET_INTERFACE (0x0Au)\r
+#define USBFS_SET_INTERFACE (0x0Bu)\r
+#define USBFS_SYNCH_FRAME (0x0Cu)\r
+\r
+/* Vendor Specific Request Types */\r
+/* Request for Microsoft OS String Descriptor */\r
+#define USBFS_GET_EXTENDED_CONFIG_DESCRIPTOR (0x01u)\r
+\r
+/* Descriptor Types (Table 9-5) */\r
+#define USBFS_DESCR_DEVICE (1u)\r
+#define USBFS_DESCR_CONFIG (2u)\r
+#define USBFS_DESCR_STRING (3u)\r
+#define USBFS_DESCR_INTERFACE (4u)\r
+#define USBFS_DESCR_ENDPOINT (5u)\r
+#define USBFS_DESCR_DEVICE_QUALIFIER (6u)\r
+#define USBFS_DESCR_OTHER_SPEED (7u)\r
+#define USBFS_DESCR_INTERFACE_POWER (8u)\r
+\r
+/* Device Descriptor Defines */\r
+#define USBFS_DEVICE_DESCR_LENGTH (18u)\r
+#define USBFS_DEVICE_DESCR_SN_SHIFT (16u)\r
+\r
+/* Config Descriptor Shifts and Masks */\r
+#define USBFS_CONFIG_DESCR_LENGTH (0u)\r
+#define USBFS_CONFIG_DESCR_TYPE (1u)\r
+#define USBFS_CONFIG_DESCR_TOTAL_LENGTH_LOW (2u)\r
+#define USBFS_CONFIG_DESCR_TOTAL_LENGTH_HI (3u)\r
+#define USBFS_CONFIG_DESCR_NUM_INTERFACES (4u)\r
+#define USBFS_CONFIG_DESCR_CONFIG_VALUE (5u)\r
+#define USBFS_CONFIG_DESCR_CONFIGURATION (6u)\r
+#define USBFS_CONFIG_DESCR_ATTRIB (7u)\r
+#define USBFS_CONFIG_DESCR_ATTRIB_SELF_POWERED (0x40u)\r
+#define USBFS_CONFIG_DESCR_ATTRIB_RWU_EN (0x20u)\r
+\r
+/* Feature Selectors (Table 9-6) */\r
+#define USBFS_DEVICE_REMOTE_WAKEUP (0x01u)\r
+#define USBFS_ENDPOINT_HALT (0x00u)\r
+#define USBFS_TEST_MODE (0x02u)\r
+\r
+/* USB Device Status (Figure 9-4) */\r
+#define USBFS_DEVICE_STATUS_BUS_POWERED (0x00u)\r
+#define USBFS_DEVICE_STATUS_SELF_POWERED (0x01u)\r
+#define USBFS_DEVICE_STATUS_REMOTE_WAKEUP (0x02u)\r
+\r
+/* USB Endpoint Status (Figure 9-4) */\r
+#define USBFS_ENDPOINT_STATUS_HALT (0x01u)\r
+\r
+/* USB Endpoint Directions */\r
+#define USBFS_DIR_IN (0x80u)\r
+#define USBFS_DIR_OUT (0x00u)\r
+#define USBFS_DIR_UNUSED (0x7Fu)\r
+\r
+/* USB Endpoint Attributes */\r
+#define USBFS_EP_TYPE_CTRL (0x00u)\r
+#define USBFS_EP_TYPE_ISOC (0x01u)\r
+#define USBFS_EP_TYPE_BULK (0x02u)\r
+#define USBFS_EP_TYPE_INT (0x03u)\r
+#define USBFS_EP_TYPE_MASK (0x03u)\r
+\r
+#define USBFS_EP_SYNC_TYPE_NO_SYNC (0x00u)\r
+#define USBFS_EP_SYNC_TYPE_ASYNC (0x04u)\r
+#define USBFS_EP_SYNC_TYPE_ADAPTIVE (0x08u)\r
+#define USBFS_EP_SYNC_TYPE_SYNCHRONOUS (0x0Cu)\r
+#define USBFS_EP_SYNC_TYPE_MASK (0x0Cu)\r
+\r
+#define USBFS_EP_USAGE_TYPE_DATA (0x00u)\r
+#define USBFS_EP_USAGE_TYPE_FEEDBACK (0x10u)\r
+#define USBFS_EP_USAGE_TYPE_IMPLICIT (0x20u)\r
+#define USBFS_EP_USAGE_TYPE_RESERVED (0x30u)\r
+#define USBFS_EP_USAGE_TYPE_MASK (0x30u)\r
+\r
+/* Endpoint Status defines */\r
+#define USBFS_EP_STATUS_LENGTH (0x02u)\r
+\r
+/* Endpoint Device defines */\r
+#define USBFS_DEVICE_STATUS_LENGTH (0x02u)\r
+\r
+#define USBFS_STATUS_LENGTH_MAX \\r
+ ( (USBFS_EP_STATUS_LENGTH > USBFS_DEVICE_STATUS_LENGTH) ? \\r
+ USBFS_EP_STATUS_LENGTH : USBFS_DEVICE_STATUS_LENGTH )\r
+/* Transfer Completion Notification */\r
+#define USBFS_XFER_IDLE (0x00u)\r
+#define USBFS_XFER_STATUS_ACK (0x01u)\r
+#define USBFS_XFER_PREMATURE (0x02u)\r
+#define USBFS_XFER_ERROR (0x03u)\r
+\r
+/* Driver State defines */\r
+#define USBFS_TRANS_STATE_IDLE (0x00u)\r
+#define USBFS_TRANS_STATE_CONTROL_READ (0x02u)\r
+#define USBFS_TRANS_STATE_CONTROL_WRITE (0x04u)\r
+#define USBFS_TRANS_STATE_NO_DATA_CONTROL (0x06u)\r
+\r
+/* String Descriptor defines */\r
+#define USBFS_STRING_MSOS (0xEEu)\r
+#define USBFS_MSOS_DESCRIPTOR_LENGTH (18u)\r
+#define USBFS_MSOS_CONF_DESCR_LENGTH (40u)\r
+\r
+#if(USBFS_EP_MM == USBFS__EP_DMAMANUAL)\r
+ /* DMA manual mode defines */\r
+ #define USBFS_DMA_BYTES_PER_BURST (0u)\r
+ #define USBFS_DMA_REQUEST_PER_BURST (0u)\r
+#endif /* End USBFS_EP_MM == USBFS__EP_DMAMANUAL */\r
+#if(USBFS_EP_MM == USBFS__EP_DMAAUTO)\r
+ /* DMA automatic mode defines */\r
+ #define USBFS_DMA_BYTES_PER_BURST (32u)\r
+ /* BUF_SIZE-BYTES_PER_BURST examples: 55-32 bytes 44-16 bytes 33-8 bytes 22-4 bytes 11-2 bytes */\r
+ #define USBFS_DMA_BUF_SIZE (0x55u)\r
+ #define USBFS_DMA_REQUEST_PER_BURST (1u)\r
+#endif /* End USBFS_EP_MM == USBFS__EP_DMAAUTO */\r
+\r
+/* DIE ID string descriptor defines */\r
+#if defined(USBFS_ENABLE_IDSN_STRING)\r
+ #define USBFS_IDSN_DESCR_LENGTH (0x22u)\r
+#endif /* USBFS_ENABLE_IDSN_STRING */\r
+\r
+\r
+/***************************************\r
+* External data references\r
+***************************************/\r
+\r
+extern uint8 USBFS_initVar;\r
+extern volatile uint8 USBFS_device;\r
+extern volatile uint8 USBFS_transferState;\r
+extern volatile uint8 USBFS_configuration;\r
+extern volatile uint8 USBFS_configurationChanged;\r
+extern volatile uint8 USBFS_deviceStatus;\r
+\r
+/* HID Variables */\r
+#if defined(USBFS_ENABLE_HID_CLASS)\r
+ extern volatile uint8 USBFS_hidProtocol[USBFS_MAX_INTERFACES_NUMBER];\r
+ extern volatile uint8 USBFS_hidIdleRate[USBFS_MAX_INTERFACES_NUMBER];\r
+ extern volatile uint8 USBFS_hidIdleTimer[USBFS_MAX_INTERFACES_NUMBER];\r
+#endif /* USBFS_ENABLE_HID_CLASS */\r
+\r
+\r
+/***************************************\r
+* Registers\r
+***************************************/\r
+\r
+#define USBFS_ARB_CFG_PTR ( (reg8 *) USBFS_USB__ARB_CFG)\r
+#define USBFS_ARB_CFG_REG (* (reg8 *) USBFS_USB__ARB_CFG)\r
+\r
+#define USBFS_ARB_EP1_CFG_PTR ( (reg8 *) USBFS_USB__ARB_EP1_CFG)\r
+#define USBFS_ARB_EP1_CFG_REG (* (reg8 *) USBFS_USB__ARB_EP1_CFG)\r
+#define USBFS_ARB_EP1_CFG_IND USBFS_USB__ARB_EP1_CFG\r
+#define USBFS_ARB_EP1_INT_EN_PTR ( (reg8 *) USBFS_USB__ARB_EP1_INT_EN)\r
+#define USBFS_ARB_EP1_INT_EN_REG (* (reg8 *) USBFS_USB__ARB_EP1_INT_EN)\r
+#define USBFS_ARB_EP1_INT_EN_IND USBFS_USB__ARB_EP1_INT_EN\r
+#define USBFS_ARB_EP1_SR_PTR ( (reg8 *) USBFS_USB__ARB_EP1_SR)\r
+#define USBFS_ARB_EP1_SR_REG (* (reg8 *) USBFS_USB__ARB_EP1_SR)\r
+#define USBFS_ARB_EP1_SR_IND USBFS_USB__ARB_EP1_SR\r
+\r
+#define USBFS_ARB_EP2_CFG_PTR ( (reg8 *) USBFS_USB__ARB_EP2_CFG)\r
+#define USBFS_ARB_EP2_CFG_REG (* (reg8 *) USBFS_USB__ARB_EP2_CFG)\r
+#define USBFS_ARB_EP2_INT_EN_PTR ( (reg8 *) USBFS_USB__ARB_EP2_INT_EN)\r
+#define USBFS_ARB_EP2_INT_EN_REG (* (reg8 *) USBFS_USB__ARB_EP2_INT_EN)\r
+#define USBFS_ARB_EP2_SR_PTR ( (reg8 *) USBFS_USB__ARB_EP2_SR)\r
+#define USBFS_ARB_EP2_SR_REG (* (reg8 *) USBFS_USB__ARB_EP2_SR)\r
+\r
+#define USBFS_ARB_EP3_CFG_PTR ( (reg8 *) USBFS_USB__ARB_EP3_CFG)\r
+#define USBFS_ARB_EP3_CFG_REG (* (reg8 *) USBFS_USB__ARB_EP3_CFG)\r
+#define USBFS_ARB_EP3_INT_EN_PTR ( (reg8 *) USBFS_USB__ARB_EP3_INT_EN)\r
+#define USBFS_ARB_EP3_INT_EN_REG (* (reg8 *) USBFS_USB__ARB_EP3_INT_EN)\r
+#define USBFS_ARB_EP3_SR_PTR ( (reg8 *) USBFS_USB__ARB_EP3_SR)\r
+#define USBFS_ARB_EP3_SR_REG (* (reg8 *) USBFS_USB__ARB_EP3_SR)\r
+\r
+#define USBFS_ARB_EP4_CFG_PTR ( (reg8 *) USBFS_USB__ARB_EP4_CFG)\r
+#define USBFS_ARB_EP4_CFG_REG (* (reg8 *) USBFS_USB__ARB_EP4_CFG)\r
+#define USBFS_ARB_EP4_INT_EN_PTR ( (reg8 *) USBFS_USB__ARB_EP4_INT_EN)\r
+#define USBFS_ARB_EP4_INT_EN_REG (* (reg8 *) USBFS_USB__ARB_EP4_INT_EN)\r
+#define USBFS_ARB_EP4_SR_PTR ( (reg8 *) USBFS_USB__ARB_EP4_SR)\r
+#define USBFS_ARB_EP4_SR_REG (* (reg8 *) USBFS_USB__ARB_EP4_SR)\r
+\r
+#define USBFS_ARB_EP5_CFG_PTR ( (reg8 *) USBFS_USB__ARB_EP5_CFG)\r
+#define USBFS_ARB_EP5_CFG_REG (* (reg8 *) USBFS_USB__ARB_EP5_CFG)\r
+#define USBFS_ARB_EP5_INT_EN_PTR ( (reg8 *) USBFS_USB__ARB_EP5_INT_EN)\r
+#define USBFS_ARB_EP5_INT_EN_REG (* (reg8 *) USBFS_USB__ARB_EP5_INT_EN)\r
+#define USBFS_ARB_EP5_SR_PTR ( (reg8 *) USBFS_USB__ARB_EP5_SR)\r
+#define USBFS_ARB_EP5_SR_REG (* (reg8 *) USBFS_USB__ARB_EP5_SR)\r
+\r
+#define USBFS_ARB_EP6_CFG_PTR ( (reg8 *) USBFS_USB__ARB_EP6_CFG)\r
+#define USBFS_ARB_EP6_CFG_REG (* (reg8 *) USBFS_USB__ARB_EP6_CFG)\r
+#define USBFS_ARB_EP6_INT_EN_PTR ( (reg8 *) USBFS_USB__ARB_EP6_INT_EN)\r
+#define USBFS_ARB_EP6_INT_EN_REG (* (reg8 *) USBFS_USB__ARB_EP6_INT_EN)\r
+#define USBFS_ARB_EP6_SR_PTR ( (reg8 *) USBFS_USB__ARB_EP6_SR)\r
+#define USBFS_ARB_EP6_SR_REG (* (reg8 *) USBFS_USB__ARB_EP6_SR)\r
+\r
+#define USBFS_ARB_EP7_CFG_PTR ( (reg8 *) USBFS_USB__ARB_EP7_CFG)\r
+#define USBFS_ARB_EP7_CFG_REG (* (reg8 *) USBFS_USB__ARB_EP7_CFG)\r
+#define USBFS_ARB_EP7_INT_EN_PTR ( (reg8 *) USBFS_USB__ARB_EP7_INT_EN)\r
+#define USBFS_ARB_EP7_INT_EN_REG (* (reg8 *) USBFS_USB__ARB_EP7_INT_EN)\r
+#define USBFS_ARB_EP7_SR_PTR ( (reg8 *) USBFS_USB__ARB_EP7_SR)\r
+#define USBFS_ARB_EP7_SR_REG (* (reg8 *) USBFS_USB__ARB_EP7_SR)\r
+\r
+#define USBFS_ARB_EP8_CFG_PTR ( (reg8 *) USBFS_USB__ARB_EP8_CFG)\r
+#define USBFS_ARB_EP8_CFG_REG (* (reg8 *) USBFS_USB__ARB_EP8_CFG)\r
+#define USBFS_ARB_EP8_INT_EN_PTR ( (reg8 *) USBFS_USB__ARB_EP8_INT_EN)\r
+#define USBFS_ARB_EP8_INT_EN_REG (* (reg8 *) USBFS_USB__ARB_EP8_INT_EN)\r
+#define USBFS_ARB_EP8_SR_PTR ( (reg8 *) USBFS_USB__ARB_EP8_SR)\r
+#define USBFS_ARB_EP8_SR_REG (* (reg8 *) USBFS_USB__ARB_EP8_SR)\r
+\r
+#define USBFS_ARB_INT_EN_PTR ( (reg8 *) USBFS_USB__ARB_INT_EN)\r
+#define USBFS_ARB_INT_EN_REG (* (reg8 *) USBFS_USB__ARB_INT_EN)\r
+#define USBFS_ARB_INT_SR_PTR ( (reg8 *) USBFS_USB__ARB_INT_SR)\r
+#define USBFS_ARB_INT_SR_REG (* (reg8 *) USBFS_USB__ARB_INT_SR)\r
+\r
+#define USBFS_ARB_RW1_DR_PTR ((reg8 *) USBFS_USB__ARB_RW1_DR)\r
+#define USBFS_ARB_RW1_DR_IND USBFS_USB__ARB_RW1_DR\r
+#define USBFS_ARB_RW1_RA_PTR ((reg8 *) USBFS_USB__ARB_RW1_RA)\r
+#define USBFS_ARB_RW1_RA_IND USBFS_USB__ARB_RW1_RA\r
+#define USBFS_ARB_RW1_RA_MSB_PTR ((reg8 *) USBFS_USB__ARB_RW1_RA_MSB)\r
+#define USBFS_ARB_RW1_RA_MSB_IND USBFS_USB__ARB_RW1_RA_MSB\r
+#define USBFS_ARB_RW1_WA_PTR ((reg8 *) USBFS_USB__ARB_RW1_WA)\r
+#define USBFS_ARB_RW1_WA_IND USBFS_USB__ARB_RW1_WA\r
+#define USBFS_ARB_RW1_WA_MSB_PTR ((reg8 *) USBFS_USB__ARB_RW1_WA_MSB)\r
+#define USBFS_ARB_RW1_WA_MSB_IND USBFS_USB__ARB_RW1_WA_MSB\r
+\r
+#define USBFS_ARB_RW2_DR_PTR ((reg8 *) USBFS_USB__ARB_RW2_DR)\r
+#define USBFS_ARB_RW2_RA_PTR ((reg8 *) USBFS_USB__ARB_RW2_RA)\r
+#define USBFS_ARB_RW2_RA_MSB_PTR ((reg8 *) USBFS_USB__ARB_RW2_RA_MSB)\r
+#define USBFS_ARB_RW2_WA_PTR ((reg8 *) USBFS_USB__ARB_RW2_WA)\r
+#define USBFS_ARB_RW2_WA_MSB_PTR ((reg8 *) USBFS_USB__ARB_RW2_WA_MSB)\r
+\r
+#define USBFS_ARB_RW3_DR_PTR ((reg8 *) USBFS_USB__ARB_RW3_DR)\r
+#define USBFS_ARB_RW3_RA_PTR ((reg8 *) USBFS_USB__ARB_RW3_RA)\r
+#define USBFS_ARB_RW3_RA_MSB_PTR ((reg8 *) USBFS_USB__ARB_RW3_RA_MSB)\r
+#define USBFS_ARB_RW3_WA_PTR ((reg8 *) USBFS_USB__ARB_RW3_WA)\r
+#define USBFS_ARB_RW3_WA_MSB_PTR ((reg8 *) USBFS_USB__ARB_RW3_WA_MSB)\r
+\r
+#define USBFS_ARB_RW4_DR_PTR ((reg8 *) USBFS_USB__ARB_RW4_DR)\r
+#define USBFS_ARB_RW4_RA_PTR ((reg8 *) USBFS_USB__ARB_RW4_RA)\r
+#define USBFS_ARB_RW4_RA_MSB_PTR ((reg8 *) USBFS_USB__ARB_RW4_RA_MSB)\r
+#define USBFS_ARB_RW4_WA_PTR ((reg8 *) USBFS_USB__ARB_RW4_WA)\r
+#define USBFS_ARB_RW4_WA_MSB_PTR ((reg8 *) USBFS_USB__ARB_RW4_WA_MSB)\r
+\r
+#define USBFS_ARB_RW5_DR_PTR ((reg8 *) USBFS_USB__ARB_RW5_DR)\r
+#define USBFS_ARB_RW5_RA_PTR ((reg8 *) USBFS_USB__ARB_RW5_RA)\r
+#define USBFS_ARB_RW5_RA_MSB_PTR ((reg8 *) USBFS_USB__ARB_RW5_RA_MSB)\r
+#define USBFS_ARB_RW5_WA_PTR ((reg8 *) USBFS_USB__ARB_RW5_WA)\r
+#define USBFS_ARB_RW5_WA_MSB_PTR ((reg8 *) USBFS_USB__ARB_RW5_WA_MSB)\r
+\r
+#define USBFS_ARB_RW6_DR_PTR ((reg8 *) USBFS_USB__ARB_RW6_DR)\r
+#define USBFS_ARB_RW6_RA_PTR ((reg8 *) USBFS_USB__ARB_RW6_RA)\r
+#define USBFS_ARB_RW6_RA_MSB_PTR ((reg8 *) USBFS_USB__ARB_RW6_RA_MSB)\r
+#define USBFS_ARB_RW6_WA_PTR ((reg8 *) USBFS_USB__ARB_RW6_WA)\r
+#define USBFS_ARB_RW6_WA_MSB_PTR ((reg8 *) USBFS_USB__ARB_RW6_WA_MSB)\r
+\r
+#define USBFS_ARB_RW7_DR_PTR ((reg8 *) USBFS_USB__ARB_RW7_DR)\r
+#define USBFS_ARB_RW7_RA_PTR ((reg8 *) USBFS_USB__ARB_RW7_RA)\r
+#define USBFS_ARB_RW7_RA_MSB_PTR ((reg8 *) USBFS_USB__ARB_RW7_RA_MSB)\r
+#define USBFS_ARB_RW7_WA_PTR ((reg8 *) USBFS_USB__ARB_RW7_WA)\r
+#define USBFS_ARB_RW7_WA_MSB_PTR ((reg8 *) USBFS_USB__ARB_RW7_WA_MSB)\r
+\r
+#define USBFS_ARB_RW8_DR_PTR ((reg8 *) USBFS_USB__ARB_RW8_DR)\r
+#define USBFS_ARB_RW8_RA_PTR ((reg8 *) USBFS_USB__ARB_RW8_RA)\r
+#define USBFS_ARB_RW8_RA_MSB_PTR ((reg8 *) USBFS_USB__ARB_RW8_RA_MSB)\r
+#define USBFS_ARB_RW8_WA_PTR ((reg8 *) USBFS_USB__ARB_RW8_WA)\r
+#define USBFS_ARB_RW8_WA_MSB_PTR ((reg8 *) USBFS_USB__ARB_RW8_WA_MSB)\r
+\r
+#define USBFS_BUF_SIZE_PTR ( (reg8 *) USBFS_USB__BUF_SIZE)\r
+#define USBFS_BUF_SIZE_REG (* (reg8 *) USBFS_USB__BUF_SIZE)\r
+#define USBFS_BUS_RST_CNT_PTR ( (reg8 *) USBFS_USB__BUS_RST_CNT)\r
+#define USBFS_BUS_RST_CNT_REG (* (reg8 *) USBFS_USB__BUS_RST_CNT)\r
+#define USBFS_CWA_PTR ( (reg8 *) USBFS_USB__CWA)\r
+#define USBFS_CWA_REG (* (reg8 *) USBFS_USB__CWA)\r
+#define USBFS_CWA_MSB_PTR ( (reg8 *) USBFS_USB__CWA_MSB)\r
+#define USBFS_CWA_MSB_REG (* (reg8 *) USBFS_USB__CWA_MSB)\r
+#define USBFS_CR0_PTR ( (reg8 *) USBFS_USB__CR0)\r
+#define USBFS_CR0_REG (* (reg8 *) USBFS_USB__CR0)\r
+#define USBFS_CR1_PTR ( (reg8 *) USBFS_USB__CR1)\r
+#define USBFS_CR1_REG (* (reg8 *) USBFS_USB__CR1)\r
+\r
+#define USBFS_DMA_THRES_PTR ( (reg8 *) USBFS_USB__DMA_THRES)\r
+#define USBFS_DMA_THRES_REG (* (reg8 *) USBFS_USB__DMA_THRES)\r
+#define USBFS_DMA_THRES_MSB_PTR ( (reg8 *) USBFS_USB__DMA_THRES_MSB)\r
+#define USBFS_DMA_THRES_MSB_REG (* (reg8 *) USBFS_USB__DMA_THRES_MSB)\r
+\r
+#define USBFS_EP_ACTIVE_PTR ( (reg8 *) USBFS_USB__EP_ACTIVE)\r
+#define USBFS_EP_ACTIVE_REG (* (reg8 *) USBFS_USB__EP_ACTIVE)\r
+#define USBFS_EP_TYPE_PTR ( (reg8 *) USBFS_USB__EP_TYPE)\r
+#define USBFS_EP_TYPE_REG (* (reg8 *) USBFS_USB__EP_TYPE)\r
+\r
+#define USBFS_EP0_CNT_PTR ( (reg8 *) USBFS_USB__EP0_CNT)\r
+#define USBFS_EP0_CNT_REG (* (reg8 *) USBFS_USB__EP0_CNT)\r
+#define USBFS_EP0_CR_PTR ( (reg8 *) USBFS_USB__EP0_CR)\r
+#define USBFS_EP0_CR_REG (* (reg8 *) USBFS_USB__EP0_CR)\r
+#define USBFS_EP0_DR0_PTR ( (reg8 *) USBFS_USB__EP0_DR0)\r
+#define USBFS_EP0_DR0_REG (* (reg8 *) USBFS_USB__EP0_DR0)\r
+#define USBFS_EP0_DR0_IND USBFS_USB__EP0_DR0\r
+#define USBFS_EP0_DR1_PTR ( (reg8 *) USBFS_USB__EP0_DR1)\r
+#define USBFS_EP0_DR1_REG (* (reg8 *) USBFS_USB__EP0_DR1)\r
+#define USBFS_EP0_DR2_PTR ( (reg8 *) USBFS_USB__EP0_DR2)\r
+#define USBFS_EP0_DR2_REG (* (reg8 *) USBFS_USB__EP0_DR2)\r
+#define USBFS_EP0_DR3_PTR ( (reg8 *) USBFS_USB__EP0_DR3)\r
+#define USBFS_EP0_DR3_REG (* (reg8 *) USBFS_USB__EP0_DR3)\r
+#define USBFS_EP0_DR4_PTR ( (reg8 *) USBFS_USB__EP0_DR4)\r
+#define USBFS_EP0_DR4_REG (* (reg8 *) USBFS_USB__EP0_DR4)\r
+#define USBFS_EP0_DR5_PTR ( (reg8 *) USBFS_USB__EP0_DR5)\r
+#define USBFS_EP0_DR5_REG (* (reg8 *) USBFS_USB__EP0_DR5)\r
+#define USBFS_EP0_DR6_PTR ( (reg8 *) USBFS_USB__EP0_DR6)\r
+#define USBFS_EP0_DR6_REG (* (reg8 *) USBFS_USB__EP0_DR6)\r
+#define USBFS_EP0_DR7_PTR ( (reg8 *) USBFS_USB__EP0_DR7)\r
+#define USBFS_EP0_DR7_REG (* (reg8 *) USBFS_USB__EP0_DR7)\r
+\r
+#define USBFS_OSCLK_DR0_PTR ( (reg8 *) USBFS_USB__OSCLK_DR0)\r
+#define USBFS_OSCLK_DR0_REG (* (reg8 *) USBFS_USB__OSCLK_DR0)\r
+#define USBFS_OSCLK_DR1_PTR ( (reg8 *) USBFS_USB__OSCLK_DR1)\r
+#define USBFS_OSCLK_DR1_REG (* (reg8 *) USBFS_USB__OSCLK_DR1)\r
+\r
+#define USBFS_PM_ACT_CFG_PTR ( (reg8 *) USBFS_USB__PM_ACT_CFG)\r
+#define USBFS_PM_ACT_CFG_REG (* (reg8 *) USBFS_USB__PM_ACT_CFG)\r
+#define USBFS_PM_STBY_CFG_PTR ( (reg8 *) USBFS_USB__PM_STBY_CFG)\r
+#define USBFS_PM_STBY_CFG_REG (* (reg8 *) USBFS_USB__PM_STBY_CFG)\r
+\r
+#define USBFS_SIE_EP_INT_EN_PTR ( (reg8 *) USBFS_USB__SIE_EP_INT_EN)\r
+#define USBFS_SIE_EP_INT_EN_REG (* (reg8 *) USBFS_USB__SIE_EP_INT_EN)\r
+#define USBFS_SIE_EP_INT_SR_PTR ( (reg8 *) USBFS_USB__SIE_EP_INT_SR)\r
+#define USBFS_SIE_EP_INT_SR_REG (* (reg8 *) USBFS_USB__SIE_EP_INT_SR)\r
+\r
+#define USBFS_SIE_EP1_CNT0_PTR ( (reg8 *) USBFS_USB__SIE_EP1_CNT0)\r
+#define USBFS_SIE_EP1_CNT0_REG (* (reg8 *) USBFS_USB__SIE_EP1_CNT0)\r
+#define USBFS_SIE_EP1_CNT0_IND USBFS_USB__SIE_EP1_CNT0\r
+#define USBFS_SIE_EP1_CNT1_PTR ( (reg8 *) USBFS_USB__SIE_EP1_CNT1)\r
+#define USBFS_SIE_EP1_CNT1_REG (* (reg8 *) USBFS_USB__SIE_EP1_CNT1)\r
+#define USBFS_SIE_EP1_CNT1_IND USBFS_USB__SIE_EP1_CNT1\r
+#define USBFS_SIE_EP1_CR0_PTR ( (reg8 *) USBFS_USB__SIE_EP1_CR0)\r
+#define USBFS_SIE_EP1_CR0_REG (* (reg8 *) USBFS_USB__SIE_EP1_CR0)\r
+#define USBFS_SIE_EP1_CR0_IND USBFS_USB__SIE_EP1_CR0\r
+\r
+#define USBFS_SIE_EP2_CNT0_PTR ( (reg8 *) USBFS_USB__SIE_EP2_CNT0)\r
+#define USBFS_SIE_EP2_CNT0_REG (* (reg8 *) USBFS_USB__SIE_EP2_CNT0)\r
+#define USBFS_SIE_EP2_CNT1_PTR ( (reg8 *) USBFS_USB__SIE_EP2_CNT1)\r
+#define USBFS_SIE_EP2_CNT1_REG (* (reg8 *) USBFS_USB__SIE_EP2_CNT1)\r
+#define USBFS_SIE_EP2_CR0_PTR ( (reg8 *) USBFS_USB__SIE_EP2_CR0)\r
+#define USBFS_SIE_EP2_CR0_REG (* (reg8 *) USBFS_USB__SIE_EP2_CR0)\r
+\r
+#define USBFS_SIE_EP3_CNT0_PTR ( (reg8 *) USBFS_USB__SIE_EP3_CNT0)\r
+#define USBFS_SIE_EP3_CNT0_REG (* (reg8 *) USBFS_USB__SIE_EP3_CNT0)\r
+#define USBFS_SIE_EP3_CNT1_PTR ( (reg8 *) USBFS_USB__SIE_EP3_CNT1)\r
+#define USBFS_SIE_EP3_CNT1_REG (* (reg8 *) USBFS_USB__SIE_EP3_CNT1)\r
+#define USBFS_SIE_EP3_CR0_PTR ( (reg8 *) USBFS_USB__SIE_EP3_CR0)\r
+#define USBFS_SIE_EP3_CR0_REG (* (reg8 *) USBFS_USB__SIE_EP3_CR0)\r
+\r
+#define USBFS_SIE_EP4_CNT0_PTR ( (reg8 *) USBFS_USB__SIE_EP4_CNT0)\r
+#define USBFS_SIE_EP4_CNT0_REG (* (reg8 *) USBFS_USB__SIE_EP4_CNT0)\r
+#define USBFS_SIE_EP4_CNT1_PTR ( (reg8 *) USBFS_USB__SIE_EP4_CNT1)\r
+#define USBFS_SIE_EP4_CNT1_REG (* (reg8 *) USBFS_USB__SIE_EP4_CNT1)\r
+#define USBFS_SIE_EP4_CR0_PTR ( (reg8 *) USBFS_USB__SIE_EP4_CR0)\r
+#define USBFS_SIE_EP4_CR0_REG (* (reg8 *) USBFS_USB__SIE_EP4_CR0)\r
+\r
+#define USBFS_SIE_EP5_CNT0_PTR ( (reg8 *) USBFS_USB__SIE_EP5_CNT0)\r
+#define USBFS_SIE_EP5_CNT0_REG (* (reg8 *) USBFS_USB__SIE_EP5_CNT0)\r
+#define USBFS_SIE_EP5_CNT1_PTR ( (reg8 *) USBFS_USB__SIE_EP5_CNT1)\r
+#define USBFS_SIE_EP5_CNT1_REG (* (reg8 *) USBFS_USB__SIE_EP5_CNT1)\r
+#define USBFS_SIE_EP5_CR0_PTR ( (reg8 *) USBFS_USB__SIE_EP5_CR0)\r
+#define USBFS_SIE_EP5_CR0_REG (* (reg8 *) USBFS_USB__SIE_EP5_CR0)\r
+\r
+#define USBFS_SIE_EP6_CNT0_PTR ( (reg8 *) USBFS_USB__SIE_EP6_CNT0)\r
+#define USBFS_SIE_EP6_CNT0_REG (* (reg8 *) USBFS_USB__SIE_EP6_CNT0)\r
+#define USBFS_SIE_EP6_CNT1_PTR ( (reg8 *) USBFS_USB__SIE_EP6_CNT1)\r
+#define USBFS_SIE_EP6_CNT1_REG (* (reg8 *) USBFS_USB__SIE_EP6_CNT1)\r
+#define USBFS_SIE_EP6_CR0_PTR ( (reg8 *) USBFS_USB__SIE_EP6_CR0)\r
+#define USBFS_SIE_EP6_CR0_REG (* (reg8 *) USBFS_USB__SIE_EP6_CR0)\r
+\r
+#define USBFS_SIE_EP7_CNT0_PTR ( (reg8 *) USBFS_USB__SIE_EP7_CNT0)\r
+#define USBFS_SIE_EP7_CNT0_REG (* (reg8 *) USBFS_USB__SIE_EP7_CNT0)\r
+#define USBFS_SIE_EP7_CNT1_PTR ( (reg8 *) USBFS_USB__SIE_EP7_CNT1)\r
+#define USBFS_SIE_EP7_CNT1_REG (* (reg8 *) USBFS_USB__SIE_EP7_CNT1)\r
+#define USBFS_SIE_EP7_CR0_PTR ( (reg8 *) USBFS_USB__SIE_EP7_CR0)\r
+#define USBFS_SIE_EP7_CR0_REG (* (reg8 *) USBFS_USB__SIE_EP7_CR0)\r
+\r
+#define USBFS_SIE_EP8_CNT0_PTR ( (reg8 *) USBFS_USB__SIE_EP8_CNT0)\r
+#define USBFS_SIE_EP8_CNT0_REG (* (reg8 *) USBFS_USB__SIE_EP8_CNT0)\r
+#define USBFS_SIE_EP8_CNT1_PTR ( (reg8 *) USBFS_USB__SIE_EP8_CNT1)\r
+#define USBFS_SIE_EP8_CNT1_REG (* (reg8 *) USBFS_USB__SIE_EP8_CNT1)\r
+#define USBFS_SIE_EP8_CR0_PTR ( (reg8 *) USBFS_USB__SIE_EP8_CR0)\r
+#define USBFS_SIE_EP8_CR0_REG (* (reg8 *) USBFS_USB__SIE_EP8_CR0)\r
+\r
+#define USBFS_SOF0_PTR ( (reg8 *) USBFS_USB__SOF0)\r
+#define USBFS_SOF0_REG (* (reg8 *) USBFS_USB__SOF0)\r
+#define USBFS_SOF1_PTR ( (reg8 *) USBFS_USB__SOF1)\r
+#define USBFS_SOF1_REG (* (reg8 *) USBFS_USB__SOF1)\r
+\r
+#define USBFS_USB_CLK_EN_PTR ( (reg8 *) USBFS_USB__USB_CLK_EN)\r
+#define USBFS_USB_CLK_EN_REG (* (reg8 *) USBFS_USB__USB_CLK_EN)\r
+\r
+#define USBFS_USBIO_CR0_PTR ( (reg8 *) USBFS_USB__USBIO_CR0)\r
+#define USBFS_USBIO_CR0_REG (* (reg8 *) USBFS_USB__USBIO_CR0)\r
+#define USBFS_USBIO_CR1_PTR ( (reg8 *) USBFS_USB__USBIO_CR1)\r
+#define USBFS_USBIO_CR1_REG (* (reg8 *) USBFS_USB__USBIO_CR1)\r
+#if(!CY_PSOC5LP)\r
+ #define USBFS_USBIO_CR2_PTR ( (reg8 *) USBFS_USB__USBIO_CR2)\r
+ #define USBFS_USBIO_CR2_REG (* (reg8 *) USBFS_USB__USBIO_CR2)\r
+#endif /* End CY_PSOC5LP */\r
+\r
+#define USBFS_DIE_ID CYDEV_FLSHID_CUST_TABLES_BASE\r
+\r
+#define USBFS_PM_USB_CR0_PTR ( (reg8 *) CYREG_PM_USB_CR0)\r
+#define USBFS_PM_USB_CR0_REG (* (reg8 *) CYREG_PM_USB_CR0)\r
+#define USBFS_DYN_RECONFIG_PTR ( (reg8 *) USBFS_USB__DYN_RECONFIG)\r
+#define USBFS_DYN_RECONFIG_REG (* (reg8 *) USBFS_USB__DYN_RECONFIG)\r
+\r
+#define USBFS_DM_INP_DIS_PTR ( (reg8 *) USBFS_Dm__INP_DIS)\r
+#define USBFS_DM_INP_DIS_REG (* (reg8 *) USBFS_Dm__INP_DIS)\r
+#define USBFS_DP_INP_DIS_PTR ( (reg8 *) USBFS_Dp__INP_DIS)\r
+#define USBFS_DP_INP_DIS_REG (* (reg8 *) USBFS_Dp__INP_DIS)\r
+#define USBFS_DP_INTSTAT_PTR ( (reg8 *) USBFS_Dp__INTSTAT)\r
+#define USBFS_DP_INTSTAT_REG (* (reg8 *) USBFS_Dp__INTSTAT)\r
+\r
+#if (USBFS_MON_VBUS == 1u)\r
+ #if (USBFS_EXTERN_VBUS == 0u)\r
+ #define USBFS_VBUS_DR_PTR ( (reg8 *) USBFS_VBUS__DR)\r
+ #define USBFS_VBUS_DR_REG (* (reg8 *) USBFS_VBUS__DR)\r
+ #define USBFS_VBUS_PS_PTR ( (reg8 *) USBFS_VBUS__PS)\r
+ #define USBFS_VBUS_PS_REG (* (reg8 *) USBFS_VBUS__PS)\r
+ #define USBFS_VBUS_MASK USBFS_VBUS__MASK\r
+ #else\r
+ #define USBFS_VBUS_PS_PTR ( (reg8 *) USBFS_Vbus_ps_sts_sts_reg__STATUS_REG )\r
+ #define USBFS_VBUS_MASK (0x01u)\r
+ #endif /* End USBFS_EXTERN_VBUS == 0u */\r
+#endif /* End USBFS_MON_VBUS */\r
+\r
+/* Renamed Registers for backward compatibility.\r
+* Should not be used in new designs.\r
+*/\r
+#define USBFS_ARB_CFG USBFS_ARB_CFG_PTR\r
+\r
+#define USBFS_ARB_EP1_CFG USBFS_ARB_EP1_CFG_PTR\r
+#define USBFS_ARB_EP1_INT_EN USBFS_ARB_EP1_INT_EN_PTR\r
+#define USBFS_ARB_EP1_SR USBFS_ARB_EP1_SR_PTR\r
+\r
+#define USBFS_ARB_EP2_CFG USBFS_ARB_EP2_CFG_PTR\r
+#define USBFS_ARB_EP2_INT_EN USBFS_ARB_EP2_INT_EN_PTR\r
+#define USBFS_ARB_EP2_SR USBFS_ARB_EP2_SR_PTR\r
+\r
+#define USBFS_ARB_EP3_CFG USBFS_ARB_EP3_CFG_PTR\r
+#define USBFS_ARB_EP3_INT_EN USBFS_ARB_EP3_INT_EN_PTR\r
+#define USBFS_ARB_EP3_SR USBFS_ARB_EP3_SR_PTR\r
+\r
+#define USBFS_ARB_EP4_CFG USBFS_ARB_EP4_CFG_PTR\r
+#define USBFS_ARB_EP4_INT_EN USBFS_ARB_EP4_INT_EN_PTR\r
+#define USBFS_ARB_EP4_SR USBFS_ARB_EP4_SR_PTR\r
+\r
+#define USBFS_ARB_EP5_CFG USBFS_ARB_EP5_CFG_PTR\r
+#define USBFS_ARB_EP5_INT_EN USBFS_ARB_EP5_INT_EN_PTR\r
+#define USBFS_ARB_EP5_SR USBFS_ARB_EP5_SR_PTR\r
+\r
+#define USBFS_ARB_EP6_CFG USBFS_ARB_EP6_CFG_PTR\r
+#define USBFS_ARB_EP6_INT_EN USBFS_ARB_EP6_INT_EN_PTR\r
+#define USBFS_ARB_EP6_SR USBFS_ARB_EP6_SR_PTR\r
+\r
+#define USBFS_ARB_EP7_CFG USBFS_ARB_EP7_CFG_PTR\r
+#define USBFS_ARB_EP7_INT_EN USBFS_ARB_EP7_INT_EN_PTR\r
+#define USBFS_ARB_EP7_SR USBFS_ARB_EP7_SR_PTR\r
+\r
+#define USBFS_ARB_EP8_CFG USBFS_ARB_EP8_CFG_PTR\r
+#define USBFS_ARB_EP8_INT_EN USBFS_ARB_EP8_INT_EN_PTR\r
+#define USBFS_ARB_EP8_SR USBFS_ARB_EP8_SR_PTR\r
+\r
+#define USBFS_ARB_INT_EN USBFS_ARB_INT_EN_PTR\r
+#define USBFS_ARB_INT_SR USBFS_ARB_INT_SR_PTR\r
+\r
+#define USBFS_ARB_RW1_DR USBFS_ARB_RW1_DR_PTR\r
+#define USBFS_ARB_RW1_RA USBFS_ARB_RW1_RA_PTR\r
+#define USBFS_ARB_RW1_RA_MSB USBFS_ARB_RW1_RA_MSB_PTR\r
+#define USBFS_ARB_RW1_WA USBFS_ARB_RW1_WA_PTR\r
+#define USBFS_ARB_RW1_WA_MSB USBFS_ARB_RW1_WA_MSB_PTR\r
+\r
+#define USBFS_ARB_RW2_DR USBFS_ARB_RW2_DR_PTR\r
+#define USBFS_ARB_RW2_RA USBFS_ARB_RW2_RA_PTR\r
+#define USBFS_ARB_RW2_RA_MSB USBFS_ARB_RW2_RA_MSB_PTR\r
+#define USBFS_ARB_RW2_WA USBFS_ARB_RW2_WA_PTR\r
+#define USBFS_ARB_RW2_WA_MSB USBFS_ARB_RW2_WA_MSB_PTR\r
+\r
+#define USBFS_ARB_RW3_DR USBFS_ARB_RW3_DR_PTR\r
+#define USBFS_ARB_RW3_RA USBFS_ARB_RW3_RA_PTR\r
+#define USBFS_ARB_RW3_RA_MSB USBFS_ARB_RW3_RA_MSB_PTR\r
+#define USBFS_ARB_RW3_WA USBFS_ARB_RW3_WA_PTR\r
+#define USBFS_ARB_RW3_WA_MSB USBFS_ARB_RW3_WA_MSB_PTR\r
+\r
+#define USBFS_ARB_RW4_DR USBFS_ARB_RW4_DR_PTR\r
+#define USBFS_ARB_RW4_RA USBFS_ARB_RW4_RA_PTR\r
+#define USBFS_ARB_RW4_RA_MSB USBFS_ARB_RW4_RA_MSB_PTR\r
+#define USBFS_ARB_RW4_WA USBFS_ARB_RW4_WA_PTR\r
+#define USBFS_ARB_RW4_WA_MSB USBFS_ARB_RW4_WA_MSB_PTR\r
+\r
+#define USBFS_ARB_RW5_DR USBFS_ARB_RW5_DR_PTR\r
+#define USBFS_ARB_RW5_RA USBFS_ARB_RW5_RA_PTR\r
+#define USBFS_ARB_RW5_RA_MSB USBFS_ARB_RW5_RA_MSB_PTR\r
+#define USBFS_ARB_RW5_WA USBFS_ARB_RW5_WA_PTR\r
+#define USBFS_ARB_RW5_WA_MSB USBFS_ARB_RW5_WA_MSB_PTR\r
+\r
+#define USBFS_ARB_RW6_DR USBFS_ARB_RW6_DR_PTR\r
+#define USBFS_ARB_RW6_RA USBFS_ARB_RW6_RA_PTR\r
+#define USBFS_ARB_RW6_RA_MSB USBFS_ARB_RW6_RA_MSB_PTR\r
+#define USBFS_ARB_RW6_WA USBFS_ARB_RW6_WA_PTR\r
+#define USBFS_ARB_RW6_WA_MSB USBFS_ARB_RW6_WA_MSB_PTR\r
+\r
+#define USBFS_ARB_RW7_DR USBFS_ARB_RW7_DR_PTR\r
+#define USBFS_ARB_RW7_RA USBFS_ARB_RW7_RA_PTR\r
+#define USBFS_ARB_RW7_RA_MSB USBFS_ARB_RW7_RA_MSB_PTR\r
+#define USBFS_ARB_RW7_WA USBFS_ARB_RW7_WA_PTR\r
+#define USBFS_ARB_RW7_WA_MSB USBFS_ARB_RW7_WA_MSB_PTR\r
+\r
+#define USBFS_ARB_RW8_DR USBFS_ARB_RW8_DR_PTR\r
+#define USBFS_ARB_RW8_RA USBFS_ARB_RW8_RA_PTR\r
+#define USBFS_ARB_RW8_RA_MSB USBFS_ARB_RW8_RA_MSB_PTR\r
+#define USBFS_ARB_RW8_WA USBFS_ARB_RW8_WA_PTR\r
+#define USBFS_ARB_RW8_WA_MSB USBFS_ARB_RW8_WA_MSB_PTR\r
+\r
+#define USBFS_BUF_SIZE USBFS_BUF_SIZE_PTR\r
+#define USBFS_BUS_RST_CNT USBFS_BUS_RST_CNT_PTR\r
+#define USBFS_CR0 USBFS_CR0_PTR\r
+#define USBFS_CR1 USBFS_CR1_PTR\r
+#define USBFS_CWA USBFS_CWA_PTR\r
+#define USBFS_CWA_MSB USBFS_CWA_MSB_PTR\r
+\r
+#define USBFS_DMA_THRES USBFS_DMA_THRES_PTR\r
+#define USBFS_DMA_THRES_MSB USBFS_DMA_THRES_MSB_PTR\r
+\r
+#define USBFS_EP_ACTIVE USBFS_EP_ACTIVE_PTR\r
+#define USBFS_EP_TYPE USBFS_EP_TYPE_PTR\r
+\r
+#define USBFS_EP0_CNT USBFS_EP0_CNT_PTR\r
+#define USBFS_EP0_CR USBFS_EP0_CR_PTR\r
+#define USBFS_EP0_DR0 USBFS_EP0_DR0_PTR\r
+#define USBFS_EP0_DR1 USBFS_EP0_DR1_PTR\r
+#define USBFS_EP0_DR2 USBFS_EP0_DR2_PTR\r
+#define USBFS_EP0_DR3 USBFS_EP0_DR3_PTR\r
+#define USBFS_EP0_DR4 USBFS_EP0_DR4_PTR\r
+#define USBFS_EP0_DR5 USBFS_EP0_DR5_PTR\r
+#define USBFS_EP0_DR6 USBFS_EP0_DR6_PTR\r
+#define USBFS_EP0_DR7 USBFS_EP0_DR7_PTR\r
+\r
+#define USBFS_OSCLK_DR0 USBFS_OSCLK_DR0_PTR\r
+#define USBFS_OSCLK_DR1 USBFS_OSCLK_DR1_PTR\r
+\r
+#define USBFS_PM_ACT_CFG USBFS_PM_ACT_CFG_PTR\r
+#define USBFS_PM_STBY_CFG USBFS_PM_STBY_CFG_PTR\r
+\r
+#define USBFS_SIE_EP_INT_EN USBFS_SIE_EP_INT_EN_PTR\r
+#define USBFS_SIE_EP_INT_SR USBFS_SIE_EP_INT_SR_PTR\r
+\r
+#define USBFS_SIE_EP1_CNT0 USBFS_SIE_EP1_CNT0_PTR\r
+#define USBFS_SIE_EP1_CNT1 USBFS_SIE_EP1_CNT1_PTR\r
+#define USBFS_SIE_EP1_CR0 USBFS_SIE_EP1_CR0_PTR\r
+\r
+#define USBFS_SIE_EP2_CNT0 USBFS_SIE_EP2_CNT0_PTR\r
+#define USBFS_SIE_EP2_CNT1 USBFS_SIE_EP2_CNT1_PTR\r
+#define USBFS_SIE_EP2_CR0 USBFS_SIE_EP2_CR0_PTR\r
+\r
+#define USBFS_SIE_EP3_CNT0 USBFS_SIE_EP3_CNT0_PTR\r
+#define USBFS_SIE_EP3_CNT1 USBFS_SIE_EP3_CNT1_PTR\r
+#define USBFS_SIE_EP3_CR0 USBFS_SIE_EP3_CR0_PTR\r
+\r
+#define USBFS_SIE_EP4_CNT0 USBFS_SIE_EP4_CNT0_PTR\r
+#define USBFS_SIE_EP4_CNT1 USBFS_SIE_EP4_CNT1_PTR\r
+#define USBFS_SIE_EP4_CR0 USBFS_SIE_EP4_CR0_PTR\r
+\r
+#define USBFS_SIE_EP5_CNT0 USBFS_SIE_EP5_CNT0_PTR\r
+#define USBFS_SIE_EP5_CNT1 USBFS_SIE_EP5_CNT1_PTR\r
+#define USBFS_SIE_EP5_CR0 USBFS_SIE_EP5_CR0_PTR\r
+\r
+#define USBFS_SIE_EP6_CNT0 USBFS_SIE_EP6_CNT0_PTR\r
+#define USBFS_SIE_EP6_CNT1 USBFS_SIE_EP6_CNT1_PTR\r
+#define USBFS_SIE_EP6_CR0 USBFS_SIE_EP6_CR0_PTR\r
+\r
+#define USBFS_SIE_EP7_CNT0 USBFS_SIE_EP7_CNT0_PTR\r
+#define USBFS_SIE_EP7_CNT1 USBFS_SIE_EP7_CNT1_PTR\r
+#define USBFS_SIE_EP7_CR0 USBFS_SIE_EP7_CR0_PTR\r
+\r
+#define USBFS_SIE_EP8_CNT0 USBFS_SIE_EP8_CNT0_PTR\r
+#define USBFS_SIE_EP8_CNT1 USBFS_SIE_EP8_CNT1_PTR\r
+#define USBFS_SIE_EP8_CR0 USBFS_SIE_EP8_CR0_PTR\r
+\r
+#define USBFS_SOF0 USBFS_SOF0_PTR\r
+#define USBFS_SOF1 USBFS_SOF1_PTR\r
+\r
+#define USBFS_USB_CLK_EN USBFS_USB_CLK_EN_PTR\r
+\r
+#define USBFS_USBIO_CR0 USBFS_USBIO_CR0_PTR\r
+#define USBFS_USBIO_CR1 USBFS_USBIO_CR1_PTR\r
+#define USBFS_USBIO_CR2 USBFS_USBIO_CR2_PTR\r
+\r
+#define USBFS_USB_MEM ((reg8 *) CYDEV_USB_MEM_BASE)\r
+\r
+#if(CYDEV_CHIP_DIE_EXPECT == CYDEV_CHIP_DIE_LEOPARD)\r
+ /* PSoC3 interrupt registers*/\r
+ #define USBFS_USB_ISR_PRIOR ((reg8 *) CYDEV_INTC_PRIOR0)\r
+ #define USBFS_USB_ISR_SET_EN ((reg8 *) CYDEV_INTC_SET_EN0)\r
+ #define USBFS_USB_ISR_CLR_EN ((reg8 *) CYDEV_INTC_CLR_EN0)\r
+ #define USBFS_USB_ISR_VECT ((cyisraddress *) CYDEV_INTC_VECT_MBASE)\r
+#elif(CYDEV_CHIP_DIE_EXPECT == CYDEV_CHIP_DIE_PANTHER)\r
+ /* PSoC5 interrupt registers*/\r
+ #define USBFS_USB_ISR_PRIOR ((reg8 *) CYDEV_NVIC_PRI_0)\r
+ #define USBFS_USB_ISR_SET_EN ((reg8 *) CYDEV_NVIC_SETENA0)\r
+ #define USBFS_USB_ISR_CLR_EN ((reg8 *) CYDEV_NVIC_CLRENA0)\r
+ #define USBFS_USB_ISR_VECT ((cyisraddress *) CYDEV_NVIC_VECT_OFFSET)\r
+#endif /* End CYDEV_CHIP_DIE_EXPECT */\r
+\r
+\r
+/***************************************\r
+* Interrupt vectors, masks and priorities\r
+***************************************/\r
+\r
+#define USBFS_BUS_RESET_PRIOR USBFS_bus_reset__INTC_PRIOR_NUM\r
+#define USBFS_BUS_RESET_MASK USBFS_bus_reset__INTC_MASK\r
+#define USBFS_BUS_RESET_VECT_NUM USBFS_bus_reset__INTC_NUMBER\r
+\r
+#define USBFS_SOF_PRIOR USBFS_sof_int__INTC_PRIOR_NUM\r
+#define USBFS_SOF_MASK USBFS_sof_int__INTC_MASK\r
+#define USBFS_SOF_VECT_NUM USBFS_sof_int__INTC_NUMBER\r
+\r
+#define USBFS_EP_0_PRIOR USBFS_ep_0__INTC_PRIOR_NUM\r
+#define USBFS_EP_0_MASK USBFS_ep_0__INTC_MASK\r
+#define USBFS_EP_0_VECT_NUM USBFS_ep_0__INTC_NUMBER\r
+\r
+#define USBFS_EP_1_PRIOR USBFS_ep_1__INTC_PRIOR_NUM\r
+#define USBFS_EP_1_MASK USBFS_ep_1__INTC_MASK\r
+#define USBFS_EP_1_VECT_NUM USBFS_ep_1__INTC_NUMBER\r
+\r
+#define USBFS_EP_2_PRIOR USBFS_ep_2__INTC_PRIOR_NUM\r
+#define USBFS_EP_2_MASK USBFS_ep_2__INTC_MASK\r
+#define USBFS_EP_2_VECT_NUM USBFS_ep_2__INTC_NUMBER\r
+\r
+#define USBFS_EP_3_PRIOR USBFS_ep_3__INTC_PRIOR_NUM\r
+#define USBFS_EP_3_MASK USBFS_ep_3__INTC_MASK\r
+#define USBFS_EP_3_VECT_NUM USBFS_ep_3__INTC_NUMBER\r
+\r
+#define USBFS_EP_4_PRIOR USBFS_ep_4__INTC_PRIOR_NUM\r
+#define USBFS_EP_4_MASK USBFS_ep_4__INTC_MASK\r
+#define USBFS_EP_4_VECT_NUM USBFS_ep_4__INTC_NUMBER\r
+\r
+#define USBFS_EP_5_PRIOR USBFS_ep_5__INTC_PRIOR_NUM\r
+#define USBFS_EP_5_MASK USBFS_ep_5__INTC_MASK\r
+#define USBFS_EP_5_VECT_NUM USBFS_ep_5__INTC_NUMBER\r
+\r
+#define USBFS_EP_6_PRIOR USBFS_ep_6__INTC_PRIOR_NUM\r
+#define USBFS_EP_6_MASK USBFS_ep_6__INTC_MASK\r
+#define USBFS_EP_6_VECT_NUM USBFS_ep_6__INTC_NUMBER\r
+\r
+#define USBFS_EP_7_PRIOR USBFS_ep_7__INTC_PRIOR_NUM\r
+#define USBFS_EP_7_MASK USBFS_ep_7__INTC_MASK\r
+#define USBFS_EP_7_VECT_NUM USBFS_ep_7__INTC_NUMBER\r
+\r
+#define USBFS_EP_8_PRIOR USBFS_ep_8__INTC_PRIOR_NUM\r
+#define USBFS_EP_8_MASK USBFS_ep_8__INTC_MASK\r
+#define USBFS_EP_8_VECT_NUM USBFS_ep_8__INTC_NUMBER\r
+\r
+#define USBFS_DP_INTC_PRIOR USBFS_dp_int__INTC_PRIOR_NUM\r
+#define USBFS_DP_INTC_MASK USBFS_dp_int__INTC_MASK\r
+#define USBFS_DP_INTC_VECT_NUM USBFS_dp_int__INTC_NUMBER\r
+\r
+/* ARB ISR should have higher priority from EP_X ISR, therefore it is defined to highest (0) */\r
+#define USBFS_ARB_PRIOR (0u)\r
+#define USBFS_ARB_MASK USBFS_arb_int__INTC_MASK\r
+#define USBFS_ARB_VECT_NUM USBFS_arb_int__INTC_NUMBER\r
+\r
+/***************************************\r
+ * Endpoint 0 offsets (Table 9-2)\r
+ **************************************/\r
+\r
+#define USBFS_bmRequestType USBFS_EP0_DR0_PTR\r
+#define USBFS_bRequest USBFS_EP0_DR1_PTR\r
+#define USBFS_wValue USBFS_EP0_DR2_PTR\r
+#define USBFS_wValueHi USBFS_EP0_DR3_PTR\r
+#define USBFS_wValueLo USBFS_EP0_DR2_PTR\r
+#define USBFS_wIndex USBFS_EP0_DR4_PTR\r
+#define USBFS_wIndexHi USBFS_EP0_DR5_PTR\r
+#define USBFS_wIndexLo USBFS_EP0_DR4_PTR\r
+#define USBFS_length USBFS_EP0_DR6_PTR\r
+#define USBFS_lengthHi USBFS_EP0_DR7_PTR\r
+#define USBFS_lengthLo USBFS_EP0_DR6_PTR\r
+\r
+\r
+/***************************************\r
+* Register Constants\r
+***************************************/\r
+#define USBFS_VDDD_MV CYDEV_VDDD_MV\r
+#define USBFS_3500MV (3500u)\r
+\r
+#define USBFS_CR1_REG_ENABLE (0x01u)\r
+#define USBFS_CR1_ENABLE_LOCK (0x02u)\r
+#define USBFS_CR1_BUS_ACTIVITY_SHIFT (0x02u)\r
+#define USBFS_CR1_BUS_ACTIVITY ((uint8)(0x01u << USBFS_CR1_BUS_ACTIVITY_SHIFT))\r
+#define USBFS_CR1_TRIM_MSB_EN (0x08u)\r
+\r
+#define USBFS_EP0_CNT_DATA_TOGGLE (0x80u)\r
+#define USBFS_EPX_CNT_DATA_TOGGLE (0x80u)\r
+#define USBFS_EPX_CNT0_MASK (0x0Fu)\r
+#define USBFS_EPX_CNTX_MSB_MASK (0x07u)\r
+#define USBFS_EPX_CNTX_ADDR_SHIFT (0x04u)\r
+#define USBFS_EPX_CNTX_ADDR_OFFSET (0x10u)\r
+#define USBFS_EPX_CNTX_CRC_COUNT (0x02u)\r
+#define USBFS_EPX_DATA_BUF_MAX (512u)\r
+\r
+#define USBFS_CR0_ENABLE (0x80u)\r
+\r
+/* A 100 KHz clock is used for BUS reset count. Recommended is to count 10 pulses */\r
+#define USBFS_BUS_RST_COUNT (0x0au)\r
+\r
+#define USBFS_USBIO_CR1_IOMODE (0x20u)\r
+#define USBFS_USBIO_CR1_USBPUEN (0x04u)\r
+#define USBFS_USBIO_CR1_DP0 (0x02u)\r
+#define USBFS_USBIO_CR1_DM0 (0x01u)\r
+\r
+#define USBFS_USBIO_CR0_TEN (0x80u)\r
+#define USBFS_USBIO_CR0_TSE0 (0x40u)\r
+#define USBFS_USBIO_CR0_TD (0x20u)\r
+#define USBFS_USBIO_CR0_RD (0x01u)\r
+\r
+#define USBFS_FASTCLK_IMO_CR_USBCLK_ON (0x40u)\r
+#define USBFS_FASTCLK_IMO_CR_XCLKEN (0x20u)\r
+#define USBFS_FASTCLK_IMO_CR_FX2ON (0x10u)\r
+\r
+#define USBFS_ARB_EPX_CFG_RESET (0x08u)\r
+#define USBFS_ARB_EPX_CFG_CRC_BYPASS (0x04u)\r
+#define USBFS_ARB_EPX_CFG_DMA_REQ (0x02u)\r
+#define USBFS_ARB_EPX_CFG_IN_DATA_RDY (0x01u)\r
+\r
+#define USBFS_ARB_EPX_SR_IN_BUF_FULL (0x01u)\r
+#define USBFS_ARB_EPX_SR_DMA_GNT (0x02u)\r
+#define USBFS_ARB_EPX_SR_BUF_OVER (0x04u)\r
+#define USBFS_ARB_EPX_SR_BUF_UNDER (0x08u)\r
+\r
+#define USBFS_ARB_CFG_AUTO_MEM (0x10u)\r
+#define USBFS_ARB_CFG_MANUAL_DMA (0x20u)\r
+#define USBFS_ARB_CFG_AUTO_DMA (0x40u)\r
+#define USBFS_ARB_CFG_CFG_CPM (0x80u)\r
+\r
+#if(USBFS_EP_MM == USBFS__EP_DMAAUTO)\r
+ #define USBFS_ARB_EPX_INT_MASK (0x1Du)\r
+#else\r
+ #define USBFS_ARB_EPX_INT_MASK (0x1Fu)\r
+#endif /* End USBFS_EP_MM == USBFS__EP_DMAAUTO */\r
+#define USBFS_ARB_INT_MASK (uint8)((USBFS_DMA1_REMOVE ^ 1u) | \\r
+ (uint8)((USBFS_DMA2_REMOVE ^ 1u) << 1u) | \\r
+ (uint8)((USBFS_DMA3_REMOVE ^ 1u) << 2u) | \\r
+ (uint8)((USBFS_DMA4_REMOVE ^ 1u) << 3u) | \\r
+ (uint8)((USBFS_DMA5_REMOVE ^ 1u) << 4u) | \\r
+ (uint8)((USBFS_DMA6_REMOVE ^ 1u) << 5u) | \\r
+ (uint8)((USBFS_DMA7_REMOVE ^ 1u) << 6u) | \\r
+ (uint8)((USBFS_DMA8_REMOVE ^ 1u) << 7u) )\r
+\r
+#define USBFS_SIE_EP_INT_EP1_MASK (0x01u)\r
+#define USBFS_SIE_EP_INT_EP2_MASK (0x02u)\r
+#define USBFS_SIE_EP_INT_EP3_MASK (0x04u)\r
+#define USBFS_SIE_EP_INT_EP4_MASK (0x08u)\r
+#define USBFS_SIE_EP_INT_EP5_MASK (0x10u)\r
+#define USBFS_SIE_EP_INT_EP6_MASK (0x20u)\r
+#define USBFS_SIE_EP_INT_EP7_MASK (0x40u)\r
+#define USBFS_SIE_EP_INT_EP8_MASK (0x80u)\r
+\r
+#define USBFS_PM_ACT_EN_FSUSB USBFS_USB__PM_ACT_MSK\r
+#define USBFS_PM_STBY_EN_FSUSB USBFS_USB__PM_STBY_MSK\r
+#define USBFS_PM_AVAIL_EN_FSUSBIO (0x10u)\r
+\r
+#define USBFS_PM_USB_CR0_REF_EN (0x01u)\r
+#define USBFS_PM_USB_CR0_PD_N (0x02u)\r
+#define USBFS_PM_USB_CR0_PD_PULLUP_N (0x04u)\r
+\r
+#define USBFS_USB_CLK_ENABLE (0x01u)\r
+\r
+#define USBFS_DM_MASK USBFS_Dm__0__MASK\r
+#define USBFS_DP_MASK USBFS_Dp__0__MASK\r
+\r
+#define USBFS_DYN_RECONFIG_ENABLE (0x01u)\r
+#define USBFS_DYN_RECONFIG_EP_SHIFT (0x01u)\r
+#define USBFS_DYN_RECONFIG_RDY_STS (0x10u)\r
+\r
+\r
+#endif /* End CY_USBFS_USBFS_H */\r
+\r
+\r
+/* [] END OF FILE */\r
--- /dev/null
+/*******************************************************************************\r
+* File Name: USBFS_Dm.c \r
+* Version 1.90\r
+*\r
+* Description:\r
+* This file contains API to enable firmware control of a Pins component.\r
+*\r
+* Note:\r
+*\r
+********************************************************************************\r
+* Copyright 2008-2012, Cypress Semiconductor Corporation. All rights reserved.\r
+* You may use this file only in accordance with the license, terms, conditions, \r
+* disclaimers, and limitations in the end user license agreement accompanying \r
+* the software package with which this file was provided.\r
+*******************************************************************************/\r
+\r
+#include "cytypes.h"\r
+#include "USBFS_Dm.h"\r
+\r
+/* APIs are not generated for P15[7:6] on PSoC 5 */\r
+#if !(CY_PSOC5A &&\\r
+ USBFS_Dm__PORT == 15 && ((USBFS_Dm__MASK & 0xC0) != 0))\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_Dm_Write\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* Assign a new value to the digital port's data output register. \r
+*\r
+* Parameters: \r
+* prtValue: The value to be assigned to the Digital Port. \r
+*\r
+* Return: \r
+* None\r
+* \r
+*******************************************************************************/\r
+void USBFS_Dm_Write(uint8 value) \r
+{\r
+ uint8 staticBits = (USBFS_Dm_DR & (uint8)(~USBFS_Dm_MASK));\r
+ USBFS_Dm_DR = staticBits | ((uint8)(value << USBFS_Dm_SHIFT) & USBFS_Dm_MASK);\r
+}\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_Dm_SetDriveMode\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* Change the drive mode on the pins of the port.\r
+* \r
+* Parameters: \r
+* mode: Change the pins to this drive mode.\r
+*\r
+* Return: \r
+* None\r
+*\r
+*******************************************************************************/\r
+void USBFS_Dm_SetDriveMode(uint8 mode) \r
+{\r
+ CyPins_SetPinDriveMode(USBFS_Dm_0, mode);\r
+}\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_Dm_Read\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* Read the current value on the pins of the Digital Port in right justified \r
+* form.\r
+*\r
+* Parameters: \r
+* None\r
+*\r
+* Return: \r
+* Returns the current value of the Digital Port as a right justified number\r
+* \r
+* Note:\r
+* Macro USBFS_Dm_ReadPS calls this function. \r
+* \r
+*******************************************************************************/\r
+uint8 USBFS_Dm_Read(void) \r
+{\r
+ return (USBFS_Dm_PS & USBFS_Dm_MASK) >> USBFS_Dm_SHIFT;\r
+}\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_Dm_ReadDataReg\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* Read the current value assigned to a Digital Port's data output register\r
+*\r
+* Parameters: \r
+* None \r
+*\r
+* Return: \r
+* Returns the current value assigned to the Digital Port's data output register\r
+* \r
+*******************************************************************************/\r
+uint8 USBFS_Dm_ReadDataReg(void) \r
+{\r
+ return (USBFS_Dm_DR & USBFS_Dm_MASK) >> USBFS_Dm_SHIFT;\r
+}\r
+\r
+\r
+/* If Interrupts Are Enabled for this Pins component */ \r
+#if defined(USBFS_Dm_INTSTAT) \r
+\r
+ /*******************************************************************************\r
+ * Function Name: USBFS_Dm_ClearInterrupt\r
+ ********************************************************************************\r
+ * Summary:\r
+ * Clears any active interrupts attached to port and returns the value of the \r
+ * interrupt status register.\r
+ *\r
+ * Parameters: \r
+ * None \r
+ *\r
+ * Return: \r
+ * Returns the value of the interrupt status register\r
+ * \r
+ *******************************************************************************/\r
+ uint8 USBFS_Dm_ClearInterrupt(void) \r
+ {\r
+ return (USBFS_Dm_INTSTAT & USBFS_Dm_MASK) >> USBFS_Dm_SHIFT;\r
+ }\r
+\r
+#endif /* If Interrupts Are Enabled for this Pins component */ \r
+\r
+#endif /* CY_PSOC5A... */\r
+\r
+ \r
+/* [] END OF FILE */\r
--- /dev/null
+/*******************************************************************************\r
+* File Name: USBFS_Dm.h \r
+* Version 1.90\r
+*\r
+* Description:\r
+* This file containts Control Register function prototypes and register defines\r
+*\r
+* Note:\r
+*\r
+********************************************************************************\r
+* Copyright 2008-2012, Cypress Semiconductor Corporation. All rights reserved.\r
+* You may use this file only in accordance with the license, terms, conditions, \r
+* disclaimers, and limitations in the end user license agreement accompanying \r
+* the software package with which this file was provided.\r
+*******************************************************************************/\r
+\r
+#if !defined(CY_PINS_USBFS_Dm_H) /* Pins USBFS_Dm_H */\r
+#define CY_PINS_USBFS_Dm_H\r
+\r
+#include "cytypes.h"\r
+#include "cyfitter.h"\r
+#include "cypins.h"\r
+#include "USBFS_Dm_aliases.h"\r
+\r
+/* Check to see if required defines such as CY_PSOC5A are available */\r
+/* They are defined starting with cy_boot v3.0 */\r
+#if !defined (CY_PSOC5A)\r
+ #error Component cy_pins_v1_90 requires cy_boot v3.0 or later\r
+#endif /* (CY_PSOC5A) */\r
+\r
+/* APIs are not generated for P15[7:6] */\r
+#if !(CY_PSOC5A &&\\r
+ USBFS_Dm__PORT == 15 && ((USBFS_Dm__MASK & 0xC0) != 0))\r
+\r
+\r
+/***************************************\r
+* Function Prototypes \r
+***************************************/ \r
+\r
+void USBFS_Dm_Write(uint8 value) ;\r
+void USBFS_Dm_SetDriveMode(uint8 mode) ;\r
+uint8 USBFS_Dm_ReadDataReg(void) ;\r
+uint8 USBFS_Dm_Read(void) ;\r
+uint8 USBFS_Dm_ClearInterrupt(void) ;\r
+\r
+\r
+/***************************************\r
+* API Constants \r
+***************************************/\r
+\r
+/* Drive Modes */\r
+#define USBFS_Dm_DM_ALG_HIZ PIN_DM_ALG_HIZ\r
+#define USBFS_Dm_DM_DIG_HIZ PIN_DM_DIG_HIZ\r
+#define USBFS_Dm_DM_RES_UP PIN_DM_RES_UP\r
+#define USBFS_Dm_DM_RES_DWN PIN_DM_RES_DWN\r
+#define USBFS_Dm_DM_OD_LO PIN_DM_OD_LO\r
+#define USBFS_Dm_DM_OD_HI PIN_DM_OD_HI\r
+#define USBFS_Dm_DM_STRONG PIN_DM_STRONG\r
+#define USBFS_Dm_DM_RES_UPDWN PIN_DM_RES_UPDWN\r
+\r
+/* Digital Port Constants */\r
+#define USBFS_Dm_MASK USBFS_Dm__MASK\r
+#define USBFS_Dm_SHIFT USBFS_Dm__SHIFT\r
+#define USBFS_Dm_WIDTH 1u\r
+\r
+\r
+/***************************************\r
+* Registers \r
+***************************************/\r
+\r
+/* Main Port Registers */\r
+/* Pin State */\r
+#define USBFS_Dm_PS (* (reg8 *) USBFS_Dm__PS)\r
+/* Data Register */\r
+#define USBFS_Dm_DR (* (reg8 *) USBFS_Dm__DR)\r
+/* Port Number */\r
+#define USBFS_Dm_PRT_NUM (* (reg8 *) USBFS_Dm__PRT) \r
+/* Connect to Analog Globals */ \r
+#define USBFS_Dm_AG (* (reg8 *) USBFS_Dm__AG) \r
+/* Analog MUX bux enable */\r
+#define USBFS_Dm_AMUX (* (reg8 *) USBFS_Dm__AMUX) \r
+/* Bidirectional Enable */ \r
+#define USBFS_Dm_BIE (* (reg8 *) USBFS_Dm__BIE)\r
+/* Bit-mask for Aliased Register Access */\r
+#define USBFS_Dm_BIT_MASK (* (reg8 *) USBFS_Dm__BIT_MASK)\r
+/* Bypass Enable */\r
+#define USBFS_Dm_BYP (* (reg8 *) USBFS_Dm__BYP)\r
+/* Port wide control signals */ \r
+#define USBFS_Dm_CTL (* (reg8 *) USBFS_Dm__CTL)\r
+/* Drive Modes */\r
+#define USBFS_Dm_DM0 (* (reg8 *) USBFS_Dm__DM0) \r
+#define USBFS_Dm_DM1 (* (reg8 *) USBFS_Dm__DM1)\r
+#define USBFS_Dm_DM2 (* (reg8 *) USBFS_Dm__DM2) \r
+/* Input Buffer Disable Override */\r
+#define USBFS_Dm_INP_DIS (* (reg8 *) USBFS_Dm__INP_DIS)\r
+/* LCD Common or Segment Drive */\r
+#define USBFS_Dm_LCD_COM_SEG (* (reg8 *) USBFS_Dm__LCD_COM_SEG)\r
+/* Enable Segment LCD */\r
+#define USBFS_Dm_LCD_EN (* (reg8 *) USBFS_Dm__LCD_EN)\r
+/* Slew Rate Control */\r
+#define USBFS_Dm_SLW (* (reg8 *) USBFS_Dm__SLW)\r
+\r
+/* DSI Port Registers */\r
+/* Global DSI Select Register */\r
+#define USBFS_Dm_PRTDSI__CAPS_SEL (* (reg8 *) USBFS_Dm__PRTDSI__CAPS_SEL) \r
+/* Double Sync Enable */\r
+#define USBFS_Dm_PRTDSI__DBL_SYNC_IN (* (reg8 *) USBFS_Dm__PRTDSI__DBL_SYNC_IN) \r
+/* Output Enable Select Drive Strength */\r
+#define USBFS_Dm_PRTDSI__OE_SEL0 (* (reg8 *) USBFS_Dm__PRTDSI__OE_SEL0) \r
+#define USBFS_Dm_PRTDSI__OE_SEL1 (* (reg8 *) USBFS_Dm__PRTDSI__OE_SEL1) \r
+/* Port Pin Output Select Registers */\r
+#define USBFS_Dm_PRTDSI__OUT_SEL0 (* (reg8 *) USBFS_Dm__PRTDSI__OUT_SEL0) \r
+#define USBFS_Dm_PRTDSI__OUT_SEL1 (* (reg8 *) USBFS_Dm__PRTDSI__OUT_SEL1) \r
+/* Sync Output Enable Registers */\r
+#define USBFS_Dm_PRTDSI__SYNC_OUT (* (reg8 *) USBFS_Dm__PRTDSI__SYNC_OUT) \r
+\r
+\r
+#if defined(USBFS_Dm__INTSTAT) /* Interrupt Registers */\r
+\r
+ #define USBFS_Dm_INTSTAT (* (reg8 *) USBFS_Dm__INTSTAT)\r
+ #define USBFS_Dm_SNAP (* (reg8 *) USBFS_Dm__SNAP)\r
+\r
+#endif /* Interrupt Registers */\r
+\r
+#endif /* CY_PSOC5A... */\r
+\r
+#endif /* CY_PINS_USBFS_Dm_H */\r
+\r
+\r
+/* [] END OF FILE */\r
--- /dev/null
+/*******************************************************************************\r
+* File Name: USBFS_Dm.h \r
+* Version 1.90\r
+*\r
+* Description:\r
+* This file containts Control Register function prototypes and register defines\r
+*\r
+* Note:\r
+*\r
+********************************************************************************\r
+* Copyright 2008-2012, Cypress Semiconductor Corporation. All rights reserved.\r
+* You may use this file only in accordance with the license, terms, conditions, \r
+* disclaimers, and limitations in the end user license agreement accompanying \r
+* the software package with which this file was provided.\r
+*******************************************************************************/\r
+\r
+#if !defined(CY_PINS_USBFS_Dm_ALIASES_H) /* Pins USBFS_Dm_ALIASES_H */\r
+#define CY_PINS_USBFS_Dm_ALIASES_H\r
+\r
+#include "cytypes.h"\r
+#include "cyfitter.h"\r
+\r
+\r
+\r
+/***************************************\r
+* Constants \r
+***************************************/\r
+#define USBFS_Dm_0 USBFS_Dm__0__PC\r
+\r
+#endif /* End Pins USBFS_Dm_ALIASES_H */\r
+\r
+/* [] END OF FILE */\r
--- /dev/null
+/*******************************************************************************\r
+* File Name: USBFS_Dp.c \r
+* Version 1.90\r
+*\r
+* Description:\r
+* This file contains API to enable firmware control of a Pins component.\r
+*\r
+* Note:\r
+*\r
+********************************************************************************\r
+* Copyright 2008-2012, Cypress Semiconductor Corporation. All rights reserved.\r
+* You may use this file only in accordance with the license, terms, conditions, \r
+* disclaimers, and limitations in the end user license agreement accompanying \r
+* the software package with which this file was provided.\r
+*******************************************************************************/\r
+\r
+#include "cytypes.h"\r
+#include "USBFS_Dp.h"\r
+\r
+/* APIs are not generated for P15[7:6] on PSoC 5 */\r
+#if !(CY_PSOC5A &&\\r
+ USBFS_Dp__PORT == 15 && ((USBFS_Dp__MASK & 0xC0) != 0))\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_Dp_Write\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* Assign a new value to the digital port's data output register. \r
+*\r
+* Parameters: \r
+* prtValue: The value to be assigned to the Digital Port. \r
+*\r
+* Return: \r
+* None\r
+* \r
+*******************************************************************************/\r
+void USBFS_Dp_Write(uint8 value) \r
+{\r
+ uint8 staticBits = (USBFS_Dp_DR & (uint8)(~USBFS_Dp_MASK));\r
+ USBFS_Dp_DR = staticBits | ((uint8)(value << USBFS_Dp_SHIFT) & USBFS_Dp_MASK);\r
+}\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_Dp_SetDriveMode\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* Change the drive mode on the pins of the port.\r
+* \r
+* Parameters: \r
+* mode: Change the pins to this drive mode.\r
+*\r
+* Return: \r
+* None\r
+*\r
+*******************************************************************************/\r
+void USBFS_Dp_SetDriveMode(uint8 mode) \r
+{\r
+ CyPins_SetPinDriveMode(USBFS_Dp_0, mode);\r
+}\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_Dp_Read\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* Read the current value on the pins of the Digital Port in right justified \r
+* form.\r
+*\r
+* Parameters: \r
+* None\r
+*\r
+* Return: \r
+* Returns the current value of the Digital Port as a right justified number\r
+* \r
+* Note:\r
+* Macro USBFS_Dp_ReadPS calls this function. \r
+* \r
+*******************************************************************************/\r
+uint8 USBFS_Dp_Read(void) \r
+{\r
+ return (USBFS_Dp_PS & USBFS_Dp_MASK) >> USBFS_Dp_SHIFT;\r
+}\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_Dp_ReadDataReg\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* Read the current value assigned to a Digital Port's data output register\r
+*\r
+* Parameters: \r
+* None \r
+*\r
+* Return: \r
+* Returns the current value assigned to the Digital Port's data output register\r
+* \r
+*******************************************************************************/\r
+uint8 USBFS_Dp_ReadDataReg(void) \r
+{\r
+ return (USBFS_Dp_DR & USBFS_Dp_MASK) >> USBFS_Dp_SHIFT;\r
+}\r
+\r
+\r
+/* If Interrupts Are Enabled for this Pins component */ \r
+#if defined(USBFS_Dp_INTSTAT) \r
+\r
+ /*******************************************************************************\r
+ * Function Name: USBFS_Dp_ClearInterrupt\r
+ ********************************************************************************\r
+ * Summary:\r
+ * Clears any active interrupts attached to port and returns the value of the \r
+ * interrupt status register.\r
+ *\r
+ * Parameters: \r
+ * None \r
+ *\r
+ * Return: \r
+ * Returns the value of the interrupt status register\r
+ * \r
+ *******************************************************************************/\r
+ uint8 USBFS_Dp_ClearInterrupt(void) \r
+ {\r
+ return (USBFS_Dp_INTSTAT & USBFS_Dp_MASK) >> USBFS_Dp_SHIFT;\r
+ }\r
+\r
+#endif /* If Interrupts Are Enabled for this Pins component */ \r
+\r
+#endif /* CY_PSOC5A... */\r
+\r
+ \r
+/* [] END OF FILE */\r
--- /dev/null
+/*******************************************************************************\r
+* File Name: USBFS_Dp.h \r
+* Version 1.90\r
+*\r
+* Description:\r
+* This file containts Control Register function prototypes and register defines\r
+*\r
+* Note:\r
+*\r
+********************************************************************************\r
+* Copyright 2008-2012, Cypress Semiconductor Corporation. All rights reserved.\r
+* You may use this file only in accordance with the license, terms, conditions, \r
+* disclaimers, and limitations in the end user license agreement accompanying \r
+* the software package with which this file was provided.\r
+*******************************************************************************/\r
+\r
+#if !defined(CY_PINS_USBFS_Dp_H) /* Pins USBFS_Dp_H */\r
+#define CY_PINS_USBFS_Dp_H\r
+\r
+#include "cytypes.h"\r
+#include "cyfitter.h"\r
+#include "cypins.h"\r
+#include "USBFS_Dp_aliases.h"\r
+\r
+/* Check to see if required defines such as CY_PSOC5A are available */\r
+/* They are defined starting with cy_boot v3.0 */\r
+#if !defined (CY_PSOC5A)\r
+ #error Component cy_pins_v1_90 requires cy_boot v3.0 or later\r
+#endif /* (CY_PSOC5A) */\r
+\r
+/* APIs are not generated for P15[7:6] */\r
+#if !(CY_PSOC5A &&\\r
+ USBFS_Dp__PORT == 15 && ((USBFS_Dp__MASK & 0xC0) != 0))\r
+\r
+\r
+/***************************************\r
+* Function Prototypes \r
+***************************************/ \r
+\r
+void USBFS_Dp_Write(uint8 value) ;\r
+void USBFS_Dp_SetDriveMode(uint8 mode) ;\r
+uint8 USBFS_Dp_ReadDataReg(void) ;\r
+uint8 USBFS_Dp_Read(void) ;\r
+uint8 USBFS_Dp_ClearInterrupt(void) ;\r
+\r
+\r
+/***************************************\r
+* API Constants \r
+***************************************/\r
+\r
+/* Drive Modes */\r
+#define USBFS_Dp_DM_ALG_HIZ PIN_DM_ALG_HIZ\r
+#define USBFS_Dp_DM_DIG_HIZ PIN_DM_DIG_HIZ\r
+#define USBFS_Dp_DM_RES_UP PIN_DM_RES_UP\r
+#define USBFS_Dp_DM_RES_DWN PIN_DM_RES_DWN\r
+#define USBFS_Dp_DM_OD_LO PIN_DM_OD_LO\r
+#define USBFS_Dp_DM_OD_HI PIN_DM_OD_HI\r
+#define USBFS_Dp_DM_STRONG PIN_DM_STRONG\r
+#define USBFS_Dp_DM_RES_UPDWN PIN_DM_RES_UPDWN\r
+\r
+/* Digital Port Constants */\r
+#define USBFS_Dp_MASK USBFS_Dp__MASK\r
+#define USBFS_Dp_SHIFT USBFS_Dp__SHIFT\r
+#define USBFS_Dp_WIDTH 1u\r
+\r
+\r
+/***************************************\r
+* Registers \r
+***************************************/\r
+\r
+/* Main Port Registers */\r
+/* Pin State */\r
+#define USBFS_Dp_PS (* (reg8 *) USBFS_Dp__PS)\r
+/* Data Register */\r
+#define USBFS_Dp_DR (* (reg8 *) USBFS_Dp__DR)\r
+/* Port Number */\r
+#define USBFS_Dp_PRT_NUM (* (reg8 *) USBFS_Dp__PRT) \r
+/* Connect to Analog Globals */ \r
+#define USBFS_Dp_AG (* (reg8 *) USBFS_Dp__AG) \r
+/* Analog MUX bux enable */\r
+#define USBFS_Dp_AMUX (* (reg8 *) USBFS_Dp__AMUX) \r
+/* Bidirectional Enable */ \r
+#define USBFS_Dp_BIE (* (reg8 *) USBFS_Dp__BIE)\r
+/* Bit-mask for Aliased Register Access */\r
+#define USBFS_Dp_BIT_MASK (* (reg8 *) USBFS_Dp__BIT_MASK)\r
+/* Bypass Enable */\r
+#define USBFS_Dp_BYP (* (reg8 *) USBFS_Dp__BYP)\r
+/* Port wide control signals */ \r
+#define USBFS_Dp_CTL (* (reg8 *) USBFS_Dp__CTL)\r
+/* Drive Modes */\r
+#define USBFS_Dp_DM0 (* (reg8 *) USBFS_Dp__DM0) \r
+#define USBFS_Dp_DM1 (* (reg8 *) USBFS_Dp__DM1)\r
+#define USBFS_Dp_DM2 (* (reg8 *) USBFS_Dp__DM2) \r
+/* Input Buffer Disable Override */\r
+#define USBFS_Dp_INP_DIS (* (reg8 *) USBFS_Dp__INP_DIS)\r
+/* LCD Common or Segment Drive */\r
+#define USBFS_Dp_LCD_COM_SEG (* (reg8 *) USBFS_Dp__LCD_COM_SEG)\r
+/* Enable Segment LCD */\r
+#define USBFS_Dp_LCD_EN (* (reg8 *) USBFS_Dp__LCD_EN)\r
+/* Slew Rate Control */\r
+#define USBFS_Dp_SLW (* (reg8 *) USBFS_Dp__SLW)\r
+\r
+/* DSI Port Registers */\r
+/* Global DSI Select Register */\r
+#define USBFS_Dp_PRTDSI__CAPS_SEL (* (reg8 *) USBFS_Dp__PRTDSI__CAPS_SEL) \r
+/* Double Sync Enable */\r
+#define USBFS_Dp_PRTDSI__DBL_SYNC_IN (* (reg8 *) USBFS_Dp__PRTDSI__DBL_SYNC_IN) \r
+/* Output Enable Select Drive Strength */\r
+#define USBFS_Dp_PRTDSI__OE_SEL0 (* (reg8 *) USBFS_Dp__PRTDSI__OE_SEL0) \r
+#define USBFS_Dp_PRTDSI__OE_SEL1 (* (reg8 *) USBFS_Dp__PRTDSI__OE_SEL1) \r
+/* Port Pin Output Select Registers */\r
+#define USBFS_Dp_PRTDSI__OUT_SEL0 (* (reg8 *) USBFS_Dp__PRTDSI__OUT_SEL0) \r
+#define USBFS_Dp_PRTDSI__OUT_SEL1 (* (reg8 *) USBFS_Dp__PRTDSI__OUT_SEL1) \r
+/* Sync Output Enable Registers */\r
+#define USBFS_Dp_PRTDSI__SYNC_OUT (* (reg8 *) USBFS_Dp__PRTDSI__SYNC_OUT) \r
+\r
+\r
+#if defined(USBFS_Dp__INTSTAT) /* Interrupt Registers */\r
+\r
+ #define USBFS_Dp_INTSTAT (* (reg8 *) USBFS_Dp__INTSTAT)\r
+ #define USBFS_Dp_SNAP (* (reg8 *) USBFS_Dp__SNAP)\r
+\r
+#endif /* Interrupt Registers */\r
+\r
+#endif /* CY_PSOC5A... */\r
+\r
+#endif /* CY_PINS_USBFS_Dp_H */\r
+\r
+\r
+/* [] END OF FILE */\r
--- /dev/null
+/*******************************************************************************\r
+* File Name: USBFS_Dp.h \r
+* Version 1.90\r
+*\r
+* Description:\r
+* This file containts Control Register function prototypes and register defines\r
+*\r
+* Note:\r
+*\r
+********************************************************************************\r
+* Copyright 2008-2012, Cypress Semiconductor Corporation. All rights reserved.\r
+* You may use this file only in accordance with the license, terms, conditions, \r
+* disclaimers, and limitations in the end user license agreement accompanying \r
+* the software package with which this file was provided.\r
+*******************************************************************************/\r
+\r
+#if !defined(CY_PINS_USBFS_Dp_ALIASES_H) /* Pins USBFS_Dp_ALIASES_H */\r
+#define CY_PINS_USBFS_Dp_ALIASES_H\r
+\r
+#include "cytypes.h"\r
+#include "cyfitter.h"\r
+\r
+\r
+\r
+/***************************************\r
+* Constants \r
+***************************************/\r
+#define USBFS_Dp_0 USBFS_Dp__0__PC\r
+\r
+#endif /* End Pins USBFS_Dp_ALIASES_H */\r
+\r
+/* [] END OF FILE */\r
--- /dev/null
+/*******************************************************************************\r
+* File Name: USBFS_audio.c\r
+* Version 2.60\r
+*\r
+* Description:\r
+* USB AUDIO Class request handler.\r
+*\r
+* Note:\r
+*\r
+********************************************************************************\r
+* Copyright 2008-2013, Cypress Semiconductor Corporation. All rights reserved.\r
+* You may use this file only in accordance with the license, terms, conditions,\r
+* disclaimers, and limitations in the end user license agreement accompanying\r
+* the software package with which this file was provided.\r
+*******************************************************************************/\r
+\r
+#include "USBFS.h"\r
+\r
+#if defined(USBFS_ENABLE_AUDIO_CLASS)\r
+\r
+#include "USBFS_audio.h"\r
+#include "USBFS_pvt.h"\r
+#if defined(USBFS_ENABLE_MIDI_STREAMING) \r
+ #include "USBFS_midi.h"\r
+#endif /* End USBFS_ENABLE_MIDI_STREAMING*/\r
+\r
+\r
+/***************************************\r
+* Custom Declarations\r
+***************************************/\r
+\r
+/* `#START CUSTOM_DECLARATIONS` Place your declaration here */\r
+\r
+/* `#END` */\r
+\r
+\r
+#if !defined(USER_SUPPLIED_AUDIO_HANDLER)\r
+\r
+\r
+/***************************************\r
+* AUDIO Variables\r
+***************************************/\r
+\r
+#if defined(USBFS_ENABLE_AUDIO_STREAMING)\r
+ volatile uint8 USBFS_currentSampleFrequency[USBFS_MAX_EP][USBFS_SAMPLE_FREQ_LEN];\r
+ volatile uint8 USBFS_frequencyChanged;\r
+ volatile uint8 USBFS_currentMute;\r
+ volatile uint8 USBFS_currentVolume[USBFS_VOLUME_LEN];\r
+ volatile uint8 USBFS_minimumVolume[USBFS_VOLUME_LEN] = {USBFS_VOL_MIN_LSB,\r
+ USBFS_VOL_MIN_MSB};\r
+ volatile uint8 USBFS_maximumVolume[USBFS_VOLUME_LEN] = {USBFS_VOL_MAX_LSB,\r
+ USBFS_VOL_MAX_MSB};\r
+ volatile uint8 USBFS_resolutionVolume[USBFS_VOLUME_LEN] = {USBFS_VOL_RES_LSB,\r
+ USBFS_VOL_RES_MSB};\r
+#endif /* End USBFS_ENABLE_AUDIO_STREAMING */\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_DispatchAUDIOClassRqst\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* This routine dispatches class requests\r
+*\r
+* Parameters:\r
+* None.\r
+*\r
+* Return:\r
+* requestHandled\r
+*\r
+* Global variables:\r
+* USBFS_currentSampleFrequency: Contains the current audio Sample\r
+* Frequency. It is set by the Host using SET_CUR request to the endpoint.\r
+* USBFS_frequencyChanged: This variable is used as a flag for the\r
+* user code, to be aware that Host has been sent request for changing\r
+* Sample Frequency. Sample frequency will be sent on the next OUT\r
+* transaction. It is contains endpoint address when set. The following\r
+* code is recommended for detecting new Sample Frequency in main code:\r
+* if((USBFS_frequencyChanged != 0) &&\r
+* (USBFS_transferState == USBFS_TRANS_STATE_IDLE))\r
+* {\r
+* USBFS_frequencyChanged = 0;\r
+* }\r
+* USBFS_transferState variable is checked to be sure that\r
+* transfer completes.\r
+* USBFS_currentMute: Contains mute configuration set by Host.\r
+* USBFS_currentVolume: Contains volume level set by Host.\r
+*\r
+* Reentrant:\r
+* No.\r
+*\r
+*******************************************************************************/\r
+uint8 USBFS_DispatchAUDIOClassRqst(void) \r
+{\r
+ uint8 requestHandled = USBFS_FALSE;\r
+\r
+ #if defined(USBFS_ENABLE_AUDIO_STREAMING)\r
+ uint8 epNumber;\r
+ epNumber = CY_GET_REG8(USBFS_wIndexLo) & USBFS_DIR_UNUSED;\r
+ #endif /* End USBFS_ENABLE_AUDIO_STREAMING */\r
+\r
+ if ((CY_GET_REG8(USBFS_bmRequestType) & USBFS_RQST_DIR_MASK) == USBFS_RQST_DIR_D2H)\r
+ {\r
+ /* Control Read */\r
+ if((CY_GET_REG8(USBFS_bmRequestType) & USBFS_RQST_RCPT_MASK) == \\r
+ USBFS_RQST_RCPT_EP)\r
+ {\r
+ /* Endpoint */\r
+ switch (CY_GET_REG8(USBFS_bRequest))\r
+ {\r
+ case USBFS_GET_CUR:\r
+ #if defined(USBFS_ENABLE_AUDIO_STREAMING)\r
+ if(CY_GET_REG8(USBFS_wValueHi) == USBFS_SAMPLING_FREQ_CONTROL)\r
+ {\r
+ /* Endpoint Control Selector is Sampling Frequency */\r
+ USBFS_currentTD.wCount = USBFS_SAMPLE_FREQ_LEN;\r
+ USBFS_currentTD.pData = USBFS_currentSampleFrequency[epNumber];\r
+ requestHandled = USBFS_InitControlRead();\r
+ }\r
+ #endif /* End USBFS_ENABLE_AUDIO_STREAMING */\r
+\r
+ /* `#START AUDIO_READ_REQUESTS` Place other request handler here */\r
+\r
+ /* `#END` */\r
+ break;\r
+ default:\r
+ break;\r
+ }\r
+ }\r
+ else if((CY_GET_REG8(USBFS_bmRequestType) & USBFS_RQST_RCPT_MASK) == \\r
+ USBFS_RQST_RCPT_IFC)\r
+ {\r
+ /* Interface or Entity ID */\r
+ switch (CY_GET_REG8(USBFS_bRequest))\r
+ {\r
+ case USBFS_GET_CUR:\r
+ #if defined(USBFS_ENABLE_AUDIO_STREAMING)\r
+ if(CY_GET_REG8(USBFS_wValueHi) == USBFS_MUTE_CONTROL)\r
+ {\r
+ /* `#START MUTE_CONTROL_GET_REQUEST` Place multi-channel handler here */\r
+\r
+ /* `#END` */\r
+ \r
+ /* Entity ID Control Selector is MUTE */\r
+ USBFS_currentTD.wCount = 1u;\r
+ USBFS_currentTD.pData = &USBFS_currentMute;\r
+ requestHandled = USBFS_InitControlRead();\r
+ }\r
+ else if(CY_GET_REG8(USBFS_wValueHi) == USBFS_VOLUME_CONTROL)\r
+ {\r
+ /* `#START VOLUME_CONTROL_GET_REQUEST` Place multi-channel handler here */\r
+\r
+ /* `#END` */\r
+\r
+ /* Entity ID Control Selector is VOLUME, */\r
+ USBFS_currentTD.wCount = USBFS_VOLUME_LEN;\r
+ USBFS_currentTD.pData = USBFS_currentVolume;\r
+ requestHandled = USBFS_InitControlRead();\r
+ }\r
+ else\r
+ {\r
+ /* `#START OTHER_GET_CUR_REQUESTS` Place other request handler here */\r
+\r
+ /* `#END` */\r
+ }\r
+ break;\r
+ case USBFS_GET_MIN: /* GET_MIN */\r
+ if(CY_GET_REG8(USBFS_wValueHi) == USBFS_VOLUME_CONTROL)\r
+ {\r
+ /* Entity ID Control Selector is VOLUME, */\r
+ USBFS_currentTD.wCount = USBFS_VOLUME_LEN;\r
+ USBFS_currentTD.pData = &USBFS_minimumVolume[0];\r
+ requestHandled = USBFS_InitControlRead();\r
+ }\r
+ break;\r
+ case USBFS_GET_MAX: /* GET_MAX */\r
+ if(CY_GET_REG8(USBFS_wValueHi) == USBFS_VOLUME_CONTROL)\r
+ {\r
+ /* Entity ID Control Selector is VOLUME, */\r
+ USBFS_currentTD.wCount = USBFS_VOLUME_LEN;\r
+ USBFS_currentTD.pData = &USBFS_maximumVolume[0];\r
+ requestHandled = USBFS_InitControlRead();\r
+ }\r
+ break;\r
+ case USBFS_GET_RES: /* GET_RES */\r
+ if(CY_GET_REG8(USBFS_wValueHi) == USBFS_VOLUME_CONTROL)\r
+ {\r
+ /* Entity ID Control Selector is VOLUME, */\r
+ USBFS_currentTD.wCount = USBFS_VOLUME_LEN;\r
+ USBFS_currentTD.pData = &USBFS_resolutionVolume[0];\r
+ requestHandled = USBFS_InitControlRead();\r
+ }\r
+ break;\r
+ /* The contents of the status message is reserved for future use.\r
+ * For the time being, a null packet should be returned in the data stage of the\r
+ * control transfer, and the received null packet should be ACKed.\r
+ */\r
+ case USBFS_GET_STAT:\r
+ USBFS_currentTD.wCount = 0u;\r
+ requestHandled = USBFS_InitControlWrite();\r
+\r
+ #endif /* End USBFS_ENABLE_AUDIO_STREAMING */\r
+\r
+ /* `#START AUDIO_WRITE_REQUESTS` Place other request handler here */\r
+\r
+ /* `#END` */\r
+ break;\r
+ default:\r
+ break;\r
+ }\r
+ }\r
+ else\r
+ { /* USBFS_RQST_RCPT_OTHER */\r
+ }\r
+ }\r
+ else if ((CY_GET_REG8(USBFS_bmRequestType) & USBFS_RQST_DIR_MASK) == \\r
+ USBFS_RQST_DIR_H2D)\r
+ {\r
+ /* Control Write */\r
+ if((CY_GET_REG8(USBFS_bmRequestType) & USBFS_RQST_RCPT_MASK) == \\r
+ USBFS_RQST_RCPT_EP)\r
+ {\r
+ /* Endpoint */\r
+ switch (CY_GET_REG8(USBFS_bRequest))\r
+ {\r
+ case USBFS_SET_CUR:\r
+ #if defined(USBFS_ENABLE_AUDIO_STREAMING)\r
+ if(CY_GET_REG8(USBFS_wValueHi) == USBFS_SAMPLING_FREQ_CONTROL)\r
+ {\r
+ /* Endpoint Control Selector is Sampling Frequency */\r
+ USBFS_currentTD.wCount = USBFS_SAMPLE_FREQ_LEN;\r
+ USBFS_currentTD.pData = USBFS_currentSampleFrequency[epNumber];\r
+ requestHandled = USBFS_InitControlWrite();\r
+ USBFS_frequencyChanged = epNumber;\r
+ }\r
+ #endif /* End USBFS_ENABLE_AUDIO_STREAMING */\r
+\r
+ /* `#START AUDIO_SAMPLING_FREQ_REQUESTS` Place other request handler here */\r
+\r
+ /* `#END` */\r
+ break;\r
+ default:\r
+ break;\r
+ }\r
+ }\r
+ else if((CY_GET_REG8(USBFS_bmRequestType) & USBFS_RQST_RCPT_MASK) == \\r
+ USBFS_RQST_RCPT_IFC)\r
+ {\r
+ /* Interface or Entity ID */\r
+ switch (CY_GET_REG8(USBFS_bRequest))\r
+ {\r
+ case USBFS_SET_CUR:\r
+ #if defined(USBFS_ENABLE_AUDIO_STREAMING)\r
+ if(CY_GET_REG8(USBFS_wValueHi) == USBFS_MUTE_CONTROL)\r
+ {\r
+ /* `#START MUTE_SET_REQUEST` Place multi-channel handler here */\r
+\r
+ /* `#END` */\r
+\r
+ /* Entity ID Control Selector is MUTE */\r
+ USBFS_currentTD.wCount = 1u;\r
+ USBFS_currentTD.pData = &USBFS_currentMute;\r
+ requestHandled = USBFS_InitControlWrite();\r
+ }\r
+ else if(CY_GET_REG8(USBFS_wValueHi) == USBFS_VOLUME_CONTROL)\r
+ {\r
+ /* `#START VOLUME_CONTROL_SET_REQUEST` Place multi-channel handler here */\r
+\r
+ /* `#END` */\r
+\r
+ /* Entity ID Control Selector is VOLUME */\r
+ USBFS_currentTD.wCount = USBFS_VOLUME_LEN;\r
+ USBFS_currentTD.pData = USBFS_currentVolume;\r
+ requestHandled = USBFS_InitControlWrite();\r
+ }\r
+ else\r
+ {\r
+ /* `#START OTHER_SET_CUR_REQUESTS` Place other request handler here */\r
+\r
+ /* `#END` */\r
+ }\r
+ #endif /* End USBFS_ENABLE_AUDIO_STREAMING */\r
+\r
+ /* `#START AUDIO_CONTROL_SEL_REQUESTS` Place other request handler here */\r
+\r
+ /* `#END` */\r
+ break;\r
+ default:\r
+ break;\r
+ }\r
+ }\r
+ else\r
+ { /* USBFS_RQST_RCPT_OTHER */\r
+ }\r
+ }\r
+ else\r
+ { /* requestHandled is initialized as FALSE by default */\r
+ }\r
+\r
+ return(requestHandled);\r
+}\r
+\r
+\r
+#endif /* USER_SUPPLIED_AUDIO_HANDLER */\r
+\r
+\r
+/*******************************************************************************\r
+* Additional user functions supporting AUDIO Requests\r
+********************************************************************************/\r
+\r
+/* `#START AUDIO_FUNCTIONS` Place any additional functions here */\r
+\r
+/* `#END` */\r
+\r
+#endif /* End USBFS_ENABLE_AUDIO_CLASS*/\r
+\r
+\r
+/* [] END OF FILE */\r
--- /dev/null
+/*******************************************************************************\r
+* File Name: USBFS_audio.h\r
+* Version 2.60\r
+*\r
+* Description:\r
+* Header File for the USFS component. Contains prototypes and constant values.\r
+*\r
+********************************************************************************\r
+* Copyright 2008-2013, Cypress Semiconductor Corporation. All rights reserved.\r
+* You may use this file only in accordance with the license, terms, conditions,\r
+* disclaimers, and limitations in the end user license agreement accompanying\r
+* the software package with which this file was provided.\r
+*******************************************************************************/\r
+\r
+#if !defined(CY_USBFS_USBFS_audio_H)\r
+#define CY_USBFS_USBFS_audio_H\r
+\r
+#include "cytypes.h"\r
+\r
+\r
+/***************************************\r
+* Custom Declarations\r
+***************************************/\r
+\r
+/* `#START CUSTOM_CONSTANTS` Place your declaration here */\r
+\r
+/* `#END` */\r
+\r
+\r
+/***************************************\r
+* Constants for USBFS_audio API.\r
+***************************************/\r
+\r
+/* Audio Class-Specific Request Codes (AUDIO Table A-9) */\r
+#define USBFS_REQUEST_CODE_UNDEFINED (0x00u)\r
+#define USBFS_SET_CUR (0x01u)\r
+#define USBFS_GET_CUR (0x81u)\r
+#define USBFS_SET_MIN (0x02u)\r
+#define USBFS_GET_MIN (0x82u)\r
+#define USBFS_SET_MAX (0x03u)\r
+#define USBFS_GET_MAX (0x83u)\r
+#define USBFS_SET_RES (0x04u)\r
+#define USBFS_GET_RES (0x84u)\r
+#define USBFS_SET_MEM (0x05u)\r
+#define USBFS_GET_MEM (0x85u)\r
+#define USBFS_GET_STAT (0xFFu)\r
+\r
+/* Endpoint Control Selectors (AUDIO Table A-19) */\r
+#define USBFS_EP_CONTROL_UNDEFINED (0x00u)\r
+#define USBFS_SAMPLING_FREQ_CONTROL (0x01u)\r
+#define USBFS_PITCH_CONTROL (0x02u)\r
+\r
+/* Feature Unit Control Selectors (AUDIO Table A-11) */\r
+#define USBFS_FU_CONTROL_UNDEFINED (0x00u)\r
+#define USBFS_MUTE_CONTROL (0x01u)\r
+#define USBFS_VOLUME_CONTROL (0x02u)\r
+#define USBFS_BASS_CONTROL (0x03u)\r
+#define USBFS_MID_CONTROL (0x04u)\r
+#define USBFS_TREBLE_CONTROL (0x05u)\r
+#define USBFS_GRAPHIC_EQUALIZER_CONTROL (0x06u)\r
+#define USBFS_AUTOMATIC_GAIN_CONTROL (0x07u)\r
+#define USBFS_DELAY_CONTROL (0x08u)\r
+#define USBFS_BASS_BOOST_CONTROL (0x09u)\r
+#define USBFS_LOUDNESS_CONTROL (0x0Au)\r
+\r
+#define USBFS_SAMPLE_FREQ_LEN (3u)\r
+#define USBFS_VOLUME_LEN (2u)\r
+\r
+#if !defined(USER_SUPPLIED_DEFAULT_VOLUME_VALUE)\r
+ #define USBFS_VOL_MIN_MSB (0x80u)\r
+ #define USBFS_VOL_MIN_LSB (0x01u)\r
+ #define USBFS_VOL_MAX_MSB (0x7Fu)\r
+ #define USBFS_VOL_MAX_LSB (0xFFu)\r
+ #define USBFS_VOL_RES_MSB (0x00u)\r
+ #define USBFS_VOL_RES_LSB (0x01u)\r
+#endif /* USER_SUPPLIED_DEFAULT_VOLUME_VALUE */\r
+\r
+\r
+/***************************************\r
+* External data references\r
+***************************************/\r
+\r
+extern volatile uint8 USBFS_currentSampleFrequency[USBFS_MAX_EP]\r
+ [USBFS_SAMPLE_FREQ_LEN];\r
+extern volatile uint8 USBFS_frequencyChanged;\r
+extern volatile uint8 USBFS_currentMute;\r
+extern volatile uint8 USBFS_currentVolume[USBFS_VOLUME_LEN];\r
+extern volatile uint8 USBFS_minimumVolume[USBFS_VOLUME_LEN];\r
+extern volatile uint8 USBFS_maximumVolume[USBFS_VOLUME_LEN];\r
+extern volatile uint8 USBFS_resolutionVolume[USBFS_VOLUME_LEN];\r
+\r
+#endif /* End CY_USBFS_USBFS_audio_H */\r
+\r
+\r
+/* [] END OF FILE */\r
--- /dev/null
+/*******************************************************************************\r
+* File Name: USBFS_boot.c\r
+* Version 2.60\r
+*\r
+* Description:\r
+* Boot loader API for USBFS Component.\r
+*\r
+* Note:\r
+*\r
+********************************************************************************\r
+* Copyright 2008-2013, Cypress Semiconductor Corporation. All rights reserved.\r
+* You may use this file only in accordance with the license, terms, conditions,\r
+* disclaimers, and limitations in the end user license agreement accompanying\r
+* the software package with which this file was provided.\r
+*******************************************************************************/\r
+\r
+#include "USBFS.h"\r
+\r
+#if defined(CYDEV_BOOTLOADER_IO_COMP) && ((CYDEV_BOOTLOADER_IO_COMP == CyBtldr_USBFS) || \\r
+ (CYDEV_BOOTLOADER_IO_COMP == CyBtldr_Custom_Interface))\r
+\r
+\r
+/***************************************\r
+* Bootloader defines\r
+***************************************/\r
+\r
+#define USBFS_CyBtLdrStarttimer(X, T) {USBFS_universalTime = T * 10; X = 0u;}\r
+#define USBFS_CyBtLdrChecktimer(X) ((X++ < USBFS_universalTime) ? 1u : 0u)\r
+\r
+#define USBFS_BTLDR_OUT_EP (0x01u)\r
+#define USBFS_BTLDR_IN_EP (0x02u)\r
+\r
+\r
+/***************************************\r
+* Bootloader Variables\r
+***************************************/\r
+\r
+static uint16 USBFS_universalTime;\r
+static uint8 USBFS_started = 0u;\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_CyBtldrCommStart\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* Starts the component and enables the interrupt.\r
+*\r
+* Parameters:\r
+* None.\r
+*\r
+* Return:\r
+* None.\r
+*\r
+* Side Effects:\r
+* This function starts the USB with 3V or 5V operation.\r
+*\r
+* Reentrant:\r
+* No.\r
+*\r
+*******************************************************************************/\r
+void USBFS_CyBtldrCommStart(void) \r
+{\r
+ CyGlobalIntEnable; /* Enable Global Interrupts */\r
+\r
+ /*Start USBFS Operation/device 0 and with 5V or 3V operation depend on Voltage Configuration in DWR */\r
+ USBFS_Start(0u, USBFS_DWR_VDDD_OPERATION);\r
+\r
+ /* USB component started, the correct enumeration will be checked in first Read operation */\r
+ USBFS_started = 1u;\r
+\r
+}\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_CyBtldrCommStop.\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* Disable the component and disable the interrupt.\r
+*\r
+* Parameters:\r
+* None.\r
+*\r
+* Return:\r
+* None.\r
+*\r
+*******************************************************************************/\r
+void USBFS_CyBtldrCommStop(void) \r
+{\r
+ USBFS_Stop();\r
+}\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_CyBtldrCommReset.\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* Resets the receive and transmit communication Buffers.\r
+*\r
+* Parameters:\r
+* None.\r
+*\r
+* Return:\r
+* None.\r
+*\r
+* Reentrant:\r
+* No.\r
+*\r
+*******************************************************************************/\r
+void USBFS_CyBtldrCommReset(void) \r
+{\r
+ USBFS_EnableOutEP(USBFS_BTLDR_OUT_EP); /* Enable the OUT endpoint */\r
+}\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_CyBtldrCommWrite.\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* Allows the caller to write data to the boot loader host. The function will\r
+* handle polling to allow a block of data to be completely sent to the host\r
+* device.\r
+*\r
+* Parameters:\r
+* pData: A pointer to the block of data to send to the device\r
+* size: The number of bytes to write.\r
+* count: Pointer to an unsigned short variable to write the number of\r
+* bytes actually written.\r
+* timeOut: Number of units to wait before returning because of a timeout.\r
+*\r
+* Return:\r
+* Returns the value that best describes the problem.\r
+*\r
+* Reentrant:\r
+* No.\r
+*\r
+*******************************************************************************/\r
+cystatus USBFS_CyBtldrCommWrite(uint8 *pData, uint16 size, uint16 *count, uint8 timeOut) CYSMALL\r
+ \r
+{\r
+ uint16 time;\r
+ cystatus status;\r
+\r
+ /* Enable IN transfer */\r
+ USBFS_LoadInEP(USBFS_BTLDR_IN_EP, pData, USBFS_BTLDR_SIZEOF_READ_BUFFER);\r
+\r
+ /* Start a timer to wait on. */\r
+ USBFS_CyBtLdrStarttimer(time, timeOut);\r
+\r
+ /* Wait for the master to read it. */\r
+ while((USBFS_GetEPState(USBFS_BTLDR_IN_EP) == USBFS_IN_BUFFER_FULL) && \\r
+ USBFS_CyBtLdrChecktimer(time))\r
+ {\r
+ CyDelay(1u); /* 1ms delay */\r
+ }\r
+\r
+ if (USBFS_GetEPState(USBFS_BTLDR_IN_EP) == USBFS_IN_BUFFER_FULL)\r
+ {\r
+ status = CYRET_TIMEOUT;\r
+ }\r
+ else\r
+ {\r
+ *count = size;\r
+ status = CYRET_SUCCESS;\r
+ }\r
+\r
+ return(status);\r
+}\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_CyBtldrCommRead.\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* Allows the caller to read data from the boot loader host. The function will\r
+* handle polling to allow a block of data to be completely received from the\r
+* host device.\r
+*\r
+* Parameters:\r
+* pData: A pointer to the area to store the block of data received\r
+* from the device.\r
+* size: The number of bytes to read.\r
+* count: Pointer to an unsigned short variable to write the number\r
+* of bytes actually read.\r
+* timeOut: Number of units to wait before returning because of a timeOut.\r
+* Timeout is measured in 10s of ms.\r
+*\r
+* Return:\r
+* Returns the value that best describes the problem.\r
+*\r
+* Reentrant:\r
+* No.\r
+*\r
+*******************************************************************************/\r
+cystatus USBFS_CyBtldrCommRead(uint8 *pData, uint16 size, uint16 *count, uint8 timeOut) CYSMALL\r
+ \r
+{\r
+ cystatus status;\r
+ uint16 time;\r
+\r
+ if(size > USBFS_BTLDR_SIZEOF_WRITE_BUFFER)\r
+ {\r
+ size = USBFS_BTLDR_SIZEOF_WRITE_BUFFER;\r
+ }\r
+ /* Start a timer to wait on. */\r
+ USBFS_CyBtLdrStarttimer(time, timeOut);\r
+\r
+ /* Wait on enumeration in first time */\r
+ if(USBFS_started)\r
+ {\r
+ /* Wait for Device to enumerate */\r
+ while(!USBFS_GetConfiguration() && USBFS_CyBtLdrChecktimer(time))\r
+ {\r
+ CyDelay(1u); /* 1ms delay */\r
+ }\r
+ /* Enable first OUT, if enumeration complete */\r
+ if(USBFS_GetConfiguration())\r
+ {\r
+ USBFS_IsConfigurationChanged(); /* Clear configuration changes state status */\r
+ USBFS_CyBtldrCommReset();\r
+ USBFS_started = 0u;\r
+ }\r
+ }\r
+ else /* Check for configuration changes, has been done by Host */\r
+ {\r
+ if(USBFS_IsConfigurationChanged() != 0u) /* Host could send double SET_INTERFACE request or RESET */\r
+ {\r
+ if(USBFS_GetConfiguration() != 0u) /* Init OUT endpoints when device reconfigured */\r
+ {\r
+ USBFS_CyBtldrCommReset();\r
+ }\r
+ }\r
+ }\r
+ /* Wait on next packet */\r
+ while((USBFS_GetEPState(USBFS_BTLDR_OUT_EP) != USBFS_OUT_BUFFER_FULL) && \\r
+ USBFS_CyBtLdrChecktimer(time))\r
+ {\r
+ CyDelay(1u); /* 1ms delay */\r
+ }\r
+\r
+ /* OUT EP has completed */\r
+ if (USBFS_GetEPState(USBFS_BTLDR_OUT_EP) == USBFS_OUT_BUFFER_FULL)\r
+ {\r
+ *count = USBFS_ReadOutEP(USBFS_BTLDR_OUT_EP, pData, size);\r
+ status = CYRET_SUCCESS;\r
+ }\r
+ else\r
+ {\r
+ *count = 0u;\r
+ status = CYRET_TIMEOUT;\r
+ }\r
+ return(status);\r
+}\r
+\r
+#endif /* End CYDEV_BOOTLOADER_IO_COMP == CyBtldr_USBFS */\r
+\r
+\r
+/* [] END OF FILE */\r
--- /dev/null
+/*******************************************************************************\r
+* File Name: USBFS_cdc.c\r
+* Version 2.60\r
+*\r
+* Description:\r
+* USB HID Class request handler.\r
+*\r
+* Note:\r
+*\r
+********************************************************************************\r
+* Copyright 2012-2013, Cypress Semiconductor Corporation. All rights reserved.\r
+* You may use this file only in accordance with the license, terms, conditions,\r
+* disclaimers, and limitations in the end user license agreement accompanying\r
+* the software package with which this file was provided.\r
+*******************************************************************************/\r
+\r
+#include "USBFS.h"\r
+\r
+#if defined(USBFS_ENABLE_CDC_CLASS)\r
+\r
+#include "USBFS_cdc.h"\r
+#include "USBFS_pvt.h"\r
+\r
+\r
+/***************************************\r
+* CDC Variables\r
+***************************************/\r
+\r
+volatile uint8 USBFS_lineCoding[USBFS_LINE_CODING_SIZE];\r
+volatile uint8 USBFS_lineChanged;\r
+volatile uint16 USBFS_lineControlBitmap;\r
+volatile uint8 USBFS_cdc_data_in_ep;\r
+volatile uint8 USBFS_cdc_data_out_ep;\r
+\r
+\r
+/***************************************\r
+* Static Function Prototypes\r
+***************************************/\r
+static uint16 USBFS_StrLen(const char8 string[]) ;\r
+\r
+\r
+/***************************************\r
+* Custom Declarations\r
+***************************************/\r
+\r
+/* `#START CDC_CUSTOM_DECLARATIONS` Place your declaration here */\r
+\r
+/* `#END` */\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_DispatchCDCClassRqst\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* This routine dispatches CDC class requests.\r
+*\r
+* Parameters:\r
+* None.\r
+*\r
+* Return:\r
+* requestHandled\r
+*\r
+* Global variables:\r
+* USBFS_lineCoding: Contains the current line coding structure.\r
+* It is set by the Host using SET_LINE_CODING request and returned to the\r
+* user code by the USBFS_GetDTERate(), USBFS_GetCharFormat(),\r
+* USBFS_GetParityType(), USBFS_GetDataBits() APIs.\r
+* USBFS_lineControlBitmap: Contains the current control signal\r
+* bitmap. It is set by the Host using SET_CONTROL_LINE request and returned\r
+* to the user code by the USBFS_GetLineControl() API.\r
+* USBFS_lineChanged: This variable is used as a flag for the\r
+* USBFS_IsLineChanged() API, to be aware that Host has been sent request\r
+* for changing Line Coding or Control Bitmap.\r
+*\r
+* Reentrant:\r
+* No.\r
+*\r
+*******************************************************************************/\r
+uint8 USBFS_DispatchCDCClassRqst(void) \r
+{\r
+ uint8 requestHandled = USBFS_FALSE;\r
+\r
+ if ((CY_GET_REG8(USBFS_bmRequestType) & USBFS_RQST_DIR_MASK) == USBFS_RQST_DIR_D2H)\r
+ { /* Control Read */\r
+ switch (CY_GET_REG8(USBFS_bRequest))\r
+ {\r
+ case USBFS_CDC_GET_LINE_CODING:\r
+ USBFS_currentTD.count = USBFS_LINE_CODING_SIZE;\r
+ USBFS_currentTD.pData = USBFS_lineCoding;\r
+ requestHandled = USBFS_InitControlRead();\r
+ break;\r
+\r
+ /* `#START CDC_READ_REQUESTS` Place other request handler here */\r
+\r
+ /* `#END` */\r
+\r
+ default: /* requestHandled is initialized as FALSE by default */\r
+ break;\r
+ }\r
+ }\r
+ else if ((CY_GET_REG8(USBFS_bmRequestType) & USBFS_RQST_DIR_MASK) == \\r
+ USBFS_RQST_DIR_H2D)\r
+ { /* Control Write */\r
+ switch (CY_GET_REG8(USBFS_bRequest))\r
+ {\r
+ case USBFS_CDC_SET_LINE_CODING:\r
+ USBFS_currentTD.count = USBFS_LINE_CODING_SIZE;\r
+ USBFS_currentTD.pData = USBFS_lineCoding;\r
+ USBFS_lineChanged |= USBFS_LINE_CODING_CHANGED;\r
+ requestHandled = USBFS_InitControlWrite();\r
+ break;\r
+\r
+ case USBFS_CDC_SET_CONTROL_LINE_STATE:\r
+ USBFS_lineControlBitmap = CY_GET_REG8(USBFS_wValueLo);\r
+ USBFS_lineChanged |= USBFS_LINE_CONTROL_CHANGED;\r
+ requestHandled = USBFS_InitNoDataControlTransfer();\r
+ break;\r
+\r
+ /* `#START CDC_WRITE_REQUESTS` Place other request handler here */\r
+\r
+ /* `#END` */\r
+\r
+ default: /* requestHandled is initialized as FALSE by default */\r
+ break;\r
+ }\r
+ }\r
+ else\r
+ { /* requestHandled is initialized as FALSE by default */\r
+ }\r
+\r
+ return(requestHandled);\r
+}\r
+\r
+\r
+/***************************************\r
+* Optional CDC APIs\r
+***************************************/\r
+#if (USBFS_ENABLE_CDC_CLASS_API != 0u)\r
+\r
+\r
+ /*******************************************************************************\r
+ * Function Name: USBFS_CDC_Init\r
+ ********************************************************************************\r
+ *\r
+ * Summary:\r
+ * This function initialize the CDC interface to be ready for the receive data\r
+ * from the PC.\r
+ *\r
+ * Parameters:\r
+ * None.\r
+ *\r
+ * Return:\r
+ * None.\r
+ *\r
+ * Global variables:\r
+ * USBFS_lineChanged: Initialized to zero.\r
+ * USBFS_cdc_data_out_ep: Used as an OUT endpoint number.\r
+ *\r
+ * Reentrant:\r
+ * No.\r
+ *\r
+ *******************************************************************************/\r
+ void USBFS_CDC_Init(void) \r
+ {\r
+ USBFS_lineChanged = 0u;\r
+ USBFS_EnableOutEP(USBFS_cdc_data_out_ep);\r
+ }\r
+\r
+\r
+ /*******************************************************************************\r
+ * Function Name: USBFS_PutData\r
+ ********************************************************************************\r
+ *\r
+ * Summary:\r
+ * Sends a specified number of bytes from the location specified by a\r
+ * pointer to the PC.\r
+ *\r
+ * Parameters:\r
+ * pData: pointer to the buffer containing data to be sent.\r
+ * length: Specifies the number of bytes to send from the pData\r
+ * buffer. Maximum length will be limited by the maximum packet\r
+ * size for the endpoint.\r
+ *\r
+ * Return:\r
+ * None.\r
+ *\r
+ * Global variables:\r
+ * USBFS_cdc_data_in_ep: CDC IN endpoint number used for sending\r
+ * data.\r
+ *\r
+ * Reentrant:\r
+ * No.\r
+ *\r
+ *******************************************************************************/\r
+ void USBFS_PutData(const uint8* pData, uint16 length) \r
+ {\r
+ /* Limits length to maximum packet size for the EP */\r
+ if(length > USBFS_EP[USBFS_cdc_data_in_ep].bufferSize)\r
+ {\r
+ /* Caution: Data will be lost if length is greater than Max Packet Length */\r
+ length = USBFS_EP[USBFS_cdc_data_in_ep].bufferSize;\r
+ /* Halt CPU in debug mode */\r
+ CYASSERT(0u != 0u);\r
+ }\r
+ USBFS_LoadInEP(USBFS_cdc_data_in_ep, pData, length);\r
+ }\r
+\r
+\r
+ /*******************************************************************************\r
+ * Function Name: USBFS_StrLen\r
+ ********************************************************************************\r
+ *\r
+ * Summary:\r
+ * Calculates length of a null terminated string.\r
+ *\r
+ * Parameters:\r
+ * string: pointer to the string.\r
+ *\r
+ * Return:\r
+ * Length of the string\r
+ *\r
+ *******************************************************************************/\r
+ static uint16 USBFS_StrLen(const char8 string[]) \r
+ {\r
+ uint16 len = 0u;\r
+\r
+ while (string[len] != (char8)0)\r
+ {\r
+ len++;\r
+ }\r
+\r
+ return (len);\r
+ }\r
+\r
+\r
+ /*******************************************************************************\r
+ * Function Name: USBFS_PutString\r
+ ********************************************************************************\r
+ *\r
+ * Summary:\r
+ * Sends a null terminated string to the PC.\r
+ *\r
+ * Parameters:\r
+ * string: pointer to the string to be sent to the PC\r
+ *\r
+ * Return:\r
+ * None.\r
+ *\r
+ * Global variables:\r
+ * USBFS_cdc_data_in_ep: CDC IN endpoint number used for sending\r
+ * data.\r
+ *\r
+ * Reentrant:\r
+ * No.\r
+ *\r
+ * Theory:\r
+ * This function will block if there is not enough memory to place the whole\r
+ * string, it will block until the entire string has been written to the\r
+ * transmit buffer.\r
+ *\r
+ *******************************************************************************/\r
+ void USBFS_PutString(const char8 string[]) \r
+ {\r
+ uint16 str_length;\r
+ uint16 send_length;\r
+ uint16 buf_index = 0u;\r
+\r
+ /* Get length of the null terminated string */\r
+ str_length = USBFS_StrLen(string);\r
+ do\r
+ {\r
+ /* Limits length to maximum packet size for the EP */\r
+ send_length = (str_length > USBFS_EP[USBFS_cdc_data_in_ep].bufferSize) ?\r
+ USBFS_EP[USBFS_cdc_data_in_ep].bufferSize : str_length;\r
+ /* Enable IN transfer */\r
+ USBFS_LoadInEP(USBFS_cdc_data_in_ep, (const uint8 *)&string[buf_index], send_length);\r
+ str_length -= send_length;\r
+\r
+ /* If more data are present to send */\r
+ if(str_length > 0u)\r
+ {\r
+ buf_index += send_length;\r
+ /* Wait for the Host to read it. */\r
+ while(USBFS_EP[USBFS_cdc_data_in_ep].apiEpState ==\r
+ USBFS_IN_BUFFER_FULL)\r
+ {\r
+ ;\r
+ }\r
+ }\r
+ }while(str_length > 0u);\r
+ }\r
+\r
+\r
+ /*******************************************************************************\r
+ * Function Name: USBFS_PutChar\r
+ ********************************************************************************\r
+ *\r
+ * Summary:\r
+ * Writes a single character to the PC.\r
+ *\r
+ * Parameters:\r
+ * txDataByte: Character to be sent to the PC.\r
+ *\r
+ * Return:\r
+ * None.\r
+ *\r
+ * Global variables:\r
+ * USBFS_cdc_data_in_ep: CDC IN endpoint number used for sending\r
+ * data.\r
+ *\r
+ * Reentrant:\r
+ * No.\r
+ *\r
+ *******************************************************************************/\r
+ void USBFS_PutChar(char8 txDataByte) \r
+ {\r
+ uint8 dataByte;\r
+ dataByte = (uint8)txDataByte;\r
+\r
+ USBFS_LoadInEP(USBFS_cdc_data_in_ep, &dataByte, 1u);\r
+ }\r
+\r
+\r
+ /*******************************************************************************\r
+ * Function Name: USBFS_PutCRLF\r
+ ********************************************************************************\r
+ *\r
+ * Summary:\r
+ * Sends a carriage return (0x0D) and line feed (0x0A) to the PC\r
+ *\r
+ * Parameters:\r
+ * None.\r
+ *\r
+ * Return:\r
+ * None.\r
+ *\r
+ * Global variables:\r
+ * USBFS_cdc_data_in_ep: CDC IN endpoint number used for sending\r
+ * data.\r
+ *\r
+ * Reentrant:\r
+ * No.\r
+ *\r
+ *******************************************************************************/\r
+ void USBFS_PutCRLF(void) \r
+ {\r
+ const uint8 CYCODE txData[] = {0x0Du, 0x0Au};\r
+\r
+ USBFS_LoadInEP(USBFS_cdc_data_in_ep, (const uint8 *)txData, 2u);\r
+ }\r
+\r
+\r
+ /*******************************************************************************\r
+ * Function Name: USBFS_GetCount\r
+ ********************************************************************************\r
+ *\r
+ * Summary:\r
+ * This function returns the number of bytes that were received from the PC.\r
+ *\r
+ * Parameters:\r
+ * None.\r
+ *\r
+ * Return:\r
+ * Returns the number of received bytes.\r
+ *\r
+ * Global variables:\r
+ * USBFS_cdc_data_out_ep: CDC OUT endpoint number used.\r
+ *\r
+ *******************************************************************************/\r
+ uint16 USBFS_GetCount(void) \r
+ {\r
+ uint16 bytesCount = 0u;\r
+\r
+ if (USBFS_EP[USBFS_cdc_data_out_ep].apiEpState == USBFS_OUT_BUFFER_FULL)\r
+ {\r
+ bytesCount = USBFS_GetEPCount(USBFS_cdc_data_out_ep);\r
+ }\r
+\r
+ return(bytesCount);\r
+ }\r
+\r
+\r
+ /*******************************************************************************\r
+ * Function Name: USBFS_DataIsReady\r
+ ********************************************************************************\r
+ *\r
+ * Summary:\r
+ * Returns a nonzero value if the component received data or received\r
+ * zero-length packet. The GetAll() or GetData() API should be called to read\r
+ * data from the buffer and re-init OUT endpoint even when zero-length packet\r
+ * received.\r
+ *\r
+ * Parameters:\r
+ * None.\r
+ *\r
+ * Return:\r
+ * If the OUT packet received this function returns a nonzero value.\r
+ * Otherwise zero is returned.\r
+ *\r
+ * Global variables:\r
+ * USBFS_cdc_data_out_ep: CDC OUT endpoint number used.\r
+ *\r
+ *******************************************************************************/\r
+ uint8 USBFS_DataIsReady(void) \r
+ {\r
+ return(USBFS_EP[USBFS_cdc_data_out_ep].apiEpState);\r
+ }\r
+\r
+\r
+ /*******************************************************************************\r
+ * Function Name: USBFS_CDCIsReady\r
+ ********************************************************************************\r
+ *\r
+ * Summary:\r
+ * Returns a nonzero value if the component is ready to send more data to the\r
+ * PC. Otherwise returns zero. Should be called before sending new data to\r
+ * ensure the previous data has finished sending.This function returns the\r
+ * number of bytes that were received from the PC.\r
+ *\r
+ * Parameters:\r
+ * None.\r
+ *\r
+ * Return:\r
+ * If the buffer can accept new data then this function returns a nonzero value.\r
+ * Otherwise zero is returned.\r
+ *\r
+ * Global variables:\r
+ * USBFS_cdc_data_in_ep: CDC IN endpoint number used.\r
+ *\r
+ *******************************************************************************/\r
+ uint8 USBFS_CDCIsReady(void) \r
+ {\r
+ return(USBFS_EP[USBFS_cdc_data_in_ep].apiEpState);\r
+ }\r
+\r
+\r
+ /*******************************************************************************\r
+ * Function Name: USBFS_GetData\r
+ ********************************************************************************\r
+ *\r
+ * Summary:\r
+ * Gets a specified number of bytes from the input buffer and places it in a\r
+ * data array specified by the passed pointer.\r
+ * USBFS_DataIsReady() API should be called before, to be sure\r
+ * that data is received from the Host.\r
+ *\r
+ * Parameters:\r
+ * pData: Pointer to the data array where data will be placed.\r
+ * Length: Number of bytes to read into the data array from the RX buffer.\r
+ * Maximum length is limited by the the number of received bytes.\r
+ *\r
+ * Return:\r
+ * Number of bytes received.\r
+ *\r
+ * Global variables:\r
+ * USBFS_cdc_data_out_ep: CDC OUT endpoint number used.\r
+ *\r
+ * Reentrant:\r
+ * No.\r
+ *\r
+ *******************************************************************************/\r
+ uint16 USBFS_GetData(uint8* pData, uint16 length) \r
+ {\r
+ return(USBFS_ReadOutEP(USBFS_cdc_data_out_ep, pData, length));\r
+ }\r
+\r
+\r
+ /*******************************************************************************\r
+ * Function Name: USBFS_GetAll\r
+ ********************************************************************************\r
+ *\r
+ * Summary:\r
+ * Gets all bytes of received data from the input buffer and places it into a\r
+ * specified data array. USBFS_DataIsReady() API should be called\r
+ * before, to be sure that data is received from the Host.\r
+ *\r
+ * Parameters:\r
+ * pData: Pointer to the data array where data will be placed.\r
+ *\r
+ * Return:\r
+ * Number of bytes received.\r
+ *\r
+ * Global variables:\r
+ * USBFS_cdc_data_out_ep: CDC OUT endpoint number used.\r
+ * USBFS_EP[].bufferSize: EP max packet size is used as a length\r
+ * to read all data from the EP buffer.\r
+ *\r
+ * Reentrant:\r
+ * No.\r
+ *\r
+ *******************************************************************************/\r
+ uint16 USBFS_GetAll(uint8* pData) \r
+ {\r
+ return (USBFS_ReadOutEP(USBFS_cdc_data_out_ep, pData,\r
+ USBFS_EP[USBFS_cdc_data_out_ep].bufferSize));\r
+ }\r
+\r
+\r
+ /*******************************************************************************\r
+ * Function Name: USBFS_GetChar\r
+ ********************************************************************************\r
+ *\r
+ * Summary:\r
+ * Reads one byte of received data from the buffer.\r
+ *\r
+ * Parameters:\r
+ * None.\r
+ *\r
+ * Return:\r
+ * Received one character.\r
+ *\r
+ * Global variables:\r
+ * USBFS_cdc_data_out_ep: CDC OUT endpoint number used.\r
+ *\r
+ * Reentrant:\r
+ * No.\r
+ *\r
+ *******************************************************************************/\r
+ uint8 USBFS_GetChar(void) \r
+ {\r
+ uint8 rxData;\r
+\r
+ (void) USBFS_ReadOutEP(USBFS_cdc_data_out_ep, &rxData, 1u);\r
+\r
+ return(rxData);\r
+ }\r
+\r
+ /*******************************************************************************\r
+ * Function Name: USBFS_IsLineChanged\r
+ ********************************************************************************\r
+ *\r
+ * Summary:\r
+ * This function returns clear on read status of the line.\r
+ *\r
+ * Parameters:\r
+ * None.\r
+ *\r
+ * Return:\r
+ * If SET_LINE_CODING or CDC_SET_CONTROL_LINE_STATE request received then not\r
+ * zero value returned. Otherwise zero is returned.\r
+ *\r
+ * Global variables:\r
+ * USBFS_transferState - it is checked to be sure then OUT data\r
+ * phase has been complete, and data written to the lineCoding or Control\r
+ * Bitmap buffer.\r
+ * USBFS_lineChanged: used as a flag to be aware that Host has been\r
+ * sent request for changing Line Coding or Control Bitmap.\r
+ *\r
+ *******************************************************************************/\r
+ uint8 USBFS_IsLineChanged(void) \r
+ {\r
+ uint8 state = 0u;\r
+\r
+ /* transferState is checked to be sure then OUT data phase has been complete */\r
+ if(USBFS_transferState == USBFS_TRANS_STATE_IDLE)\r
+ {\r
+ if(USBFS_lineChanged != 0u)\r
+ {\r
+ state = USBFS_lineChanged;\r
+ USBFS_lineChanged = 0u;\r
+ }\r
+ }\r
+\r
+ return(state);\r
+ }\r
+\r
+\r
+ /*******************************************************************************\r
+ * Function Name: USBFS_GetDTERate\r
+ ********************************************************************************\r
+ *\r
+ * Summary:\r
+ * Returns the data terminal rate set for this port in bits per second.\r
+ *\r
+ * Parameters:\r
+ * None.\r
+ *\r
+ * Return:\r
+ * Returns a uint32 value of the data rate in bits per second.\r
+ *\r
+ * Global variables:\r
+ * USBFS_lineCoding: First four bytes converted to uint32\r
+ * depend on compiler, and returned as a data rate.\r
+ *\r
+ *******************************************************************************/\r
+ uint32 USBFS_GetDTERate(void) \r
+ {\r
+ uint32 rate;\r
+\r
+ rate = USBFS_lineCoding[USBFS_LINE_CODING_RATE + 3u];\r
+ rate = (rate << 8u) | USBFS_lineCoding[USBFS_LINE_CODING_RATE + 2u];\r
+ rate = (rate << 8u) | USBFS_lineCoding[USBFS_LINE_CODING_RATE + 1u];\r
+ rate = (rate << 8u) | USBFS_lineCoding[USBFS_LINE_CODING_RATE];\r
+\r
+ return(rate);\r
+ }\r
+\r
+\r
+ /*******************************************************************************\r
+ * Function Name: USBFS_GetCharFormat\r
+ ********************************************************************************\r
+ *\r
+ * Summary:\r
+ * Returns the number of stop bits.\r
+ *\r
+ * Parameters:\r
+ * None.\r
+ *\r
+ * Return:\r
+ * Returns the number of stop bits.\r
+ *\r
+ * Global variables:\r
+ * USBFS_lineCoding: used to get a parameter.\r
+ *\r
+ *******************************************************************************/\r
+ uint8 USBFS_GetCharFormat(void) \r
+ {\r
+ return(USBFS_lineCoding[USBFS_LINE_CODING_STOP_BITS]);\r
+ }\r
+\r
+\r
+ /*******************************************************************************\r
+ * Function Name: USBFS_GetParityType\r
+ ********************************************************************************\r
+ *\r
+ * Summary:\r
+ * Returns the parity type for the CDC port.\r
+ *\r
+ * Parameters:\r
+ * None.\r
+ *\r
+ * Return:\r
+ * Returns the parity type.\r
+ *\r
+ * Global variables:\r
+ * USBFS_lineCoding: used to get a parameter.\r
+ *\r
+ *******************************************************************************/\r
+ uint8 USBFS_GetParityType(void) \r
+ {\r
+ return(USBFS_lineCoding[USBFS_LINE_CODING_PARITY]);\r
+ }\r
+\r
+\r
+ /*******************************************************************************\r
+ * Function Name: USBFS_GetDataBits\r
+ ********************************************************************************\r
+ *\r
+ * Summary:\r
+ * Returns the number of data bits for the CDC port.\r
+ *\r
+ * Parameters:\r
+ * None.\r
+ *\r
+ * Return:\r
+ * Returns the number of data bits.\r
+ * The number of data bits can be 5, 6, 7, 8 or 16.\r
+ *\r
+ * Global variables:\r
+ * USBFS_lineCoding: used to get a parameter.\r
+ *\r
+ *******************************************************************************/\r
+ uint8 USBFS_GetDataBits(void) \r
+ {\r
+ return(USBFS_lineCoding[USBFS_LINE_CODING_DATA_BITS]);\r
+ }\r
+\r
+\r
+ /*******************************************************************************\r
+ * Function Name: USBFS_GetLineControl\r
+ ********************************************************************************\r
+ *\r
+ * Summary:\r
+ * Returns Line control bitmap.\r
+ *\r
+ * Parameters:\r
+ * None.\r
+ *\r
+ * Return:\r
+ * Returns Line control bitmap.\r
+ *\r
+ * Global variables:\r
+ * USBFS_lineControlBitmap: used to get a parameter.\r
+ *\r
+ *******************************************************************************/\r
+ uint16 USBFS_GetLineControl(void) \r
+ {\r
+ return(USBFS_lineControlBitmap);\r
+ }\r
+\r
+#endif /* End USBFS_ENABLE_CDC_CLASS_API*/\r
+\r
+\r
+/*******************************************************************************\r
+* Additional user functions supporting CDC Requests\r
+********************************************************************************/\r
+\r
+/* `#START CDC_FUNCTIONS` Place any additional functions here */\r
+\r
+/* `#END` */\r
+\r
+#endif /* End USBFS_ENABLE_CDC_CLASS*/\r
+\r
+\r
+/* [] END OF FILE */\r
--- /dev/null
+/*******************************************************************************\r
+* File Name: USBFS_cdc.h\r
+* Version 2.60\r
+*\r
+* Description:\r
+* Header File for the USFS component.\r
+* Contains CDC class prototypes and constant values.\r
+*\r
+********************************************************************************\r
+* Copyright 2012-2013, Cypress Semiconductor Corporation. All rights reserved.\r
+* You may use this file only in accordance with the license, terms, conditions,\r
+* disclaimers, and limitations in the end user license agreement accompanying\r
+* the software package with which this file was provided.\r
+*******************************************************************************/\r
+\r
+#if !defined(CY_USBFS_USBFS_cdc_H)\r
+#define CY_USBFS_USBFS_cdc_H\r
+\r
+#include "cytypes.h"\r
+\r
+\r
+/***************************************\r
+* Prototypes of the USBFS_cdc API.\r
+***************************************/\r
+\r
+#if (USBFS_ENABLE_CDC_CLASS_API != 0u)\r
+ void USBFS_CDC_Init(void) ;\r
+ void USBFS_PutData(const uint8* pData, uint16 length) ;\r
+ void USBFS_PutString(const char8 string[]) ;\r
+ void USBFS_PutChar(char8 txDataByte) ;\r
+ void USBFS_PutCRLF(void) ;\r
+ uint16 USBFS_GetCount(void) ;\r
+ uint8 USBFS_CDCIsReady(void) ;\r
+ uint8 USBFS_DataIsReady(void) ;\r
+ uint16 USBFS_GetData(uint8* pData, uint16 length) ;\r
+ uint16 USBFS_GetAll(uint8* pData) ;\r
+ uint8 USBFS_GetChar(void) ;\r
+ uint8 USBFS_IsLineChanged(void) ;\r
+ uint32 USBFS_GetDTERate(void) ;\r
+ uint8 USBFS_GetCharFormat(void) ;\r
+ uint8 USBFS_GetParityType(void) ;\r
+ uint8 USBFS_GetDataBits(void) ;\r
+ uint16 USBFS_GetLineControl(void) ;\r
+#endif /* End USBFS_ENABLE_CDC_CLASS_API*/\r
+\r
+\r
+/***************************************\r
+* Constants for USBFS_cdc API.\r
+***************************************/\r
+\r
+/* CDC Class-Specific Request Codes (CDC ver 1.2 Table 19) */\r
+#define USBFS_CDC_SET_LINE_CODING (0x20u)\r
+#define USBFS_CDC_GET_LINE_CODING (0x21u)\r
+#define USBFS_CDC_SET_CONTROL_LINE_STATE (0x22u)\r
+\r
+#define USBFS_LINE_CODING_CHANGED (0x01u)\r
+#define USBFS_LINE_CONTROL_CHANGED (0x02u)\r
+\r
+#define USBFS_1_STOPBIT (0x00u)\r
+#define USBFS_1_5_STOPBITS (0x01u)\r
+#define USBFS_2_STOPBITS (0x02u)\r
+\r
+#define USBFS_PARITY_NONE (0x00u)\r
+#define USBFS_PARITY_ODD (0x01u)\r
+#define USBFS_PARITY_EVEN (0x02u)\r
+#define USBFS_PARITY_MARK (0x03u)\r
+#define USBFS_PARITY_SPACE (0x04u)\r
+\r
+#define USBFS_LINE_CODING_SIZE (0x07u)\r
+#define USBFS_LINE_CODING_RATE (0x00u)\r
+#define USBFS_LINE_CODING_STOP_BITS (0x04u)\r
+#define USBFS_LINE_CODING_PARITY (0x05u)\r
+#define USBFS_LINE_CODING_DATA_BITS (0x06u)\r
+\r
+#define USBFS_LINE_CONTROL_DTR (0x01u)\r
+#define USBFS_LINE_CONTROL_RTS (0x02u)\r
+\r
+\r
+/***************************************\r
+* External data references\r
+***************************************/\r
+\r
+extern volatile uint8 USBFS_lineCoding[USBFS_LINE_CODING_SIZE];\r
+extern volatile uint8 USBFS_lineChanged;\r
+extern volatile uint16 USBFS_lineControlBitmap;\r
+extern volatile uint8 USBFS_cdc_data_in_ep;\r
+extern volatile uint8 USBFS_cdc_data_out_ep;\r
+\r
+#endif /* End CY_USBFS_USBFS_cdc_H */\r
+\r
+\r
+/* [] END OF FILE */\r
--- /dev/null
+;******************************************************************************\r
+; File Name: USBFS_cdc.inf\r
+; Version 2.60\r
+;\r
+; Description:\r
+; Windows USB CDC setup file for USBUART Device.\r
+;\r
+;******************************************************************************\r
+; Copyright 2007-2013, Cypress Semiconductor Corporation. All rights reserved.\r
+; You may use this file only in accordance with the license, terms, conditions,\r
+; disclaimers, and limitations in the end user license agreement accompanying\r
+; the software package with which this file was provided.\r
+;******************************************************************************\r
+\r
+[Version]\r
+Signature="$Windows NT$"\r
+Class=Ports\r
+ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318}\r
+Provider=%PROVIDER%\r
+LayoutFile=layout.inf\r
+DriverVer=03/05/2007,2.0.0000.0\r
+\r
+[Manufacturer]\r
+%MFGNAME%=DeviceList, NTx86, NTia64, NTamd64\r
+\r
+[DestinationDirs]\r
+DefaultDestDir=12\r
+\r
+[SourceDisksFiles]\r
+\r
+[SourceDisksNames]\r
+\r
+[DeviceList.NTx86]\r
+%DESCRIPTION%=DriverInstall, USB\VID_04B4&PID_F232\r
+\r
+[DeviceList.NTia64]\r
+%DESCRIPTION%=DriverInstall, USB\VID_04B4&PID_F232\r
+\r
+[DeviceList.NTamd64]\r
+%DESCRIPTION%=DriverInstall, USB\VID_04B4&PID_F232\r
+\r
+\r
+;------------------------------------------------------------------------------\r
+; 32 bit section for Windows 2000/2003/XP/Vista\r
+;------------------------------------------------------------------------------\r
+\r
+[DriverInstall.NTx86]\r
+include=mdmcpq.inf\r
+CopyFiles=DriverCopyFiles\r
+AddReg=DriverInstall.NTx86.AddReg\r
+\r
+[DriverCopyFiles]\r
+usbser.sys,,,0x20\r
+\r
+[DriverInstall.NTx86.AddReg]\r
+HKR,,DevLoader,,*ntkern\r
+HKR,,NTMPDriver,,usbser.sys\r
+HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider"\r
+\r
+[DriverInstall.NTx86.Services]\r
+AddService=usbser, 0x00000002, DriverService\r
+\r
+;------------------------------------------------------------------------------\r
+; 64 bit section for Intel Itanium based systems\r
+;------------------------------------------------------------------------------\r
+\r
+[DriverInstall.NTia64]\r
+include=mdmcpq.inf\r
+CopyFiles=DriverCopyFiles\r
+AddReg=DriverInstall.NTia64.AddReg\r
+\r
+[DriverCopyFiles]\r
+usbser.sys,,,0x20\r
+\r
+[DriverInstall.NTia64.AddReg]\r
+HKR,,DevLoader,,*ntkern\r
+HKR,,NTMPDriver,,usbser.sys\r
+HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider"\r
+\r
+[DriverInstall.NTia64.Services]\r
+AddService=usbser, 0x00000002, DriverService\r
+\r
+;------------------------------------------------------------------------------\r
+; 64 bit section for AMD64 and Intel EM64T based systems\r
+;------------------------------------------------------------------------------\r
+\r
+[DriverInstall.NTamd64]\r
+include=mdmcpq.inf\r
+CopyFiles=DriverCopyFiles\r
+AddReg=DriverInstall.NTamd64.AddReg\r
+\r
+[DriverCopyFiles]\r
+usbser.sys,,,0x20\r
+\r
+[DriverInstall.NTamd64.AddReg]\r
+HKR,,DevLoader,,*ntkern\r
+HKR,,NTMPDriver,,usbser.sys\r
+HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider"\r
+\r
+[DriverInstall.NTamd64.Services]\r
+AddService=usbser, 0x00000002, DriverService\r
+\r
+;------------------------------------------------------------------------------\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+[DriverService]\r
+DisplayName=%SERVICE%\r
+ServiceType=1\r
+StartType=3\r
+ErrorControl=1\r
+ServiceBinary=%12%\usbser.sys\r
+\r
+;------------------------------------------------------------------------------\r
+; String Definitions\r
+;------------------------------------------------------------------------------\r
+\r
+[Strings]\r
+PROVIDER="Cypress"\r
+MFGNAME="Cypress Semiconductor Corporation"\r
+DESCRIPTION="Cypress USB UART"\r
+SERVICE="USB UART"\r
--- /dev/null
+/*******************************************************************************\r
+* File Name: USBFS_cls.c\r
+* Version 2.60\r
+*\r
+* Description:\r
+* USB Class request handler.\r
+*\r
+* Note:\r
+*\r
+********************************************************************************\r
+* Copyright 2008-2013, Cypress Semiconductor Corporation. All rights reserved.\r
+* You may use this file only in accordance with the license, terms, conditions,\r
+* disclaimers, and limitations in the end user license agreement accompanying\r
+* the software package with which this file was provided.\r
+*******************************************************************************/\r
+\r
+#include "USBFS.h"\r
+\r
+#if(USBFS_EXTERN_CLS == USBFS_FALSE)\r
+\r
+#include "USBFS_pvt.h"\r
+\r
+\r
+/***************************************\r
+* User Implemented Class Driver Declarations.\r
+***************************************/\r
+/* `#START USER_DEFINED_CLASS_DECLARATIONS` Place your declaration here */\r
+\r
+/* `#END` */\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_DispatchClassRqst\r
+********************************************************************************\r
+* Summary:\r
+* This routine dispatches class specific requests depend on interface class.\r
+*\r
+* Parameters:\r
+* None.\r
+*\r
+* Return:\r
+* requestHandled.\r
+*\r
+* Reentrant:\r
+* No.\r
+*\r
+*******************************************************************************/\r
+uint8 USBFS_DispatchClassRqst(void) \r
+{\r
+ uint8 requestHandled = USBFS_FALSE;\r
+ uint8 interfaceNumber = 0u;\r
+\r
+ switch(CY_GET_REG8(USBFS_bmRequestType) & USBFS_RQST_RCPT_MASK)\r
+ {\r
+ case USBFS_RQST_RCPT_IFC: /* Class-specific request directed to an interface */\r
+ interfaceNumber = CY_GET_REG8(USBFS_wIndexLo); /* wIndexLo contain Interface number */\r
+ break;\r
+ case USBFS_RQST_RCPT_EP: /* Class-specific request directed to the endpoint */\r
+ /* Find related interface to the endpoint, wIndexLo contain EP number */\r
+ interfaceNumber =\r
+ USBFS_EP[CY_GET_REG8(USBFS_wIndexLo) & USBFS_DIR_UNUSED].interface;\r
+ break;\r
+ default: /* RequestHandled is initialized as FALSE by default */\r
+ break;\r
+ }\r
+ /* Handle Class request depend on interface type */\r
+ switch(USBFS_interfaceClass[interfaceNumber])\r
+ {\r
+ case USBFS_CLASS_HID:\r
+ #if defined(USBFS_ENABLE_HID_CLASS)\r
+ requestHandled = USBFS_DispatchHIDClassRqst();\r
+ #endif /* USBFS_ENABLE_HID_CLASS */\r
+ break;\r
+ case USBFS_CLASS_AUDIO:\r
+ #if defined(USBFS_ENABLE_AUDIO_CLASS)\r
+ requestHandled = USBFS_DispatchAUDIOClassRqst();\r
+ #endif /* USBFS_ENABLE_HID_CLASS */\r
+ break;\r
+ case USBFS_CLASS_CDC:\r
+ #if defined(USBFS_ENABLE_CDC_CLASS)\r
+ requestHandled = USBFS_DispatchCDCClassRqst();\r
+ #endif /* USBFS_ENABLE_CDC_CLASS */\r
+ break;\r
+ default: /* requestHandled is initialized as FALSE by default */\r
+ break;\r
+ }\r
+\r
+ /* `#START USER_DEFINED_CLASS_CODE` Place your Class request here */\r
+\r
+ /* `#END` */\r
+\r
+ return(requestHandled);\r
+}\r
+\r
+\r
+/*******************************************************************************\r
+* Additional user functions supporting Class Specific Requests\r
+********************************************************************************/\r
+\r
+/* `#START CLASS_SPECIFIC_FUNCTIONS` Place any additional functions here */\r
+\r
+/* `#END` */\r
+\r
+#endif /* USBFS_EXTERN_CLS */\r
+\r
+\r
+/* [] END OF FILE */\r
--- /dev/null
+/*******************************************************************************\r
+* File Name: USBFS_descr.c\r
+* Version 2.60\r
+*\r
+* Description:\r
+* USB descriptors and storage.\r
+*\r
+* Note:\r
+*\r
+********************************************************************************\r
+* Copyright 2008-2013, Cypress Semiconductor Corporation. All rights reserved.\r
+* You may use this file only in accordance with the license, terms, conditions,\r
+* disclaimers, and limitations in the end user license agreement accompanying\r
+* the software package with which this file was provided.\r
+*******************************************************************************/\r
+\r
+#include "USBFS.h"\r
+#include "USBFS_pvt.h"\r
+\r
+\r
+/*****************************************************************************\r
+* User supplied descriptors. If you want to specify your own descriptors,\r
+* remove the comments around the define USER_SUPPLIED_DESCRIPTORS below and\r
+* add your descriptors.\r
+*****************************************************************************/\r
+/* `#START USER_DESCRIPTORS_DECLARATIONS` Place your declaration here */\r
+\r
+/* `#END` */\r
+\r
+\r
+/***************************************\r
+* USB Customizer Generated Descriptors\r
+***************************************/\r
+\r
+#if !defined(USER_SUPPLIED_DESCRIPTORS)\r
+/*********************************************************************\r
+* Device Descriptors\r
+*********************************************************************/\r
+const uint8 CYCODE USBFS_DEVICE0_DESCR[18u] = {\r
+/* Descriptor Length */ 0x12u,\r
+/* DescriptorType: DEVICE */ 0x01u,\r
+/* bcdUSB (ver 2.0) */ 0x00u, 0x02u,\r
+/* bDeviceClass */ 0x00u,\r
+/* bDeviceSubClass */ 0x00u,\r
+/* bDeviceProtocol */ 0x00u,\r
+/* bMaxPacketSize0 */ 0x08u,\r
+/* idVendor */ 0xB4u, 0x04u,\r
+/* idProduct */ 0x37u, 0x13u,\r
+/* bcdDevice */ 0x00u, 0x30u,\r
+/* iManufacturer */ 0x02u,\r
+/* iProduct */ 0x01u,\r
+/* iSerialNumber */ 0x80u,\r
+/* bNumConfigurations */ 0x01u\r
+};\r
+/*********************************************************************\r
+* Config Descriptor \r
+*********************************************************************/\r
+const uint8 CYCODE USBFS_DEVICE0_CONFIGURATION0_DESCR[41u] = {\r
+/* Config Descriptor Length */ 0x09u,\r
+/* DescriptorType: CONFIG */ 0x02u,\r
+/* wTotalLength */ 0x29u, 0x00u,\r
+/* bNumInterfaces */ 0x01u,\r
+/* bConfigurationValue */ 0x01u,\r
+/* iConfiguration */ 0x00u,\r
+/* bmAttributes */ 0x80u,\r
+/* bMaxPower */ 0xFAu,\r
+/*********************************************************************\r
+* Interface Descriptor\r
+*********************************************************************/\r
+/* Interface Descriptor Length */ 0x09u,\r
+/* DescriptorType: INTERFACE */ 0x04u,\r
+/* bInterfaceNumber */ 0x00u,\r
+/* bAlternateSetting */ 0x00u,\r
+/* bNumEndpoints */ 0x02u,\r
+/* bInterfaceClass */ 0x03u,\r
+/* bInterfaceSubClass */ 0x00u,\r
+/* bInterfaceProtocol */ 0x00u,\r
+/* iInterface */ 0x00u,\r
+/*********************************************************************\r
+* HID Class Descriptor\r
+*********************************************************************/\r
+/* HID Class Descriptor Length */ 0x09u,\r
+/* DescriptorType: HID_CLASS */ 0x21u,\r
+/* bcdHID */ 0x11u, 0x01u,\r
+/* bCountryCode */ 0x00u,\r
+/* bNumDescriptors */ 0x01u,\r
+/* bDescriptorType */ 0x22u,\r
+/* wDescriptorLength (LSB) */ USBFS_HID_RPT_1_SIZE_LSB,\r
+/* wDescriptorLength (MSB) */ USBFS_HID_RPT_1_SIZE_MSB,\r
+/*********************************************************************\r
+* Endpoint Descriptor\r
+*********************************************************************/\r
+/* Endpoint Descriptor Length */ 0x07u,\r
+/* DescriptorType: ENDPOINT */ 0x05u,\r
+/* bEndpointAddress */ 0x01u,\r
+/* bmAttributes */ 0x03u,\r
+/* wMaxPacketSize */ 0x40u, 0x00u,\r
+/* bInterval */ 0x80u,\r
+/*********************************************************************\r
+* Endpoint Descriptor\r
+*********************************************************************/\r
+/* Endpoint Descriptor Length */ 0x07u,\r
+/* DescriptorType: ENDPOINT */ 0x05u,\r
+/* bEndpointAddress */ 0x82u,\r
+/* bmAttributes */ 0x03u,\r
+/* wMaxPacketSize */ 0x40u, 0x00u,\r
+/* bInterval */ 0x80u\r
+};\r
+\r
+/*********************************************************************\r
+* String Descriptor Table\r
+*********************************************************************/\r
+const uint8 CYCODE USBFS_STRING_DESCRIPTORS[45u] = {\r
+/*********************************************************************\r
+* Language ID Descriptor\r
+*********************************************************************/\r
+/* Descriptor Length */ 0x04u,\r
+/* DescriptorType: STRING */ 0x03u,\r
+/* Language Id */ 0x09u, 0x04u,\r
+/*********************************************************************\r
+* String Descriptor: "SCSI2SD"\r
+*********************************************************************/\r
+/* Descriptor Length */ 0x10u,\r
+/* DescriptorType: STRING */ 0x03u,\r
+ (uint8)'S', 0u,(uint8)'C', 0u,(uint8)'S', 0u,(uint8)'I', 0u,(uint8)'2', 0u,\r
+ (uint8)'S', 0u,(uint8)'D', 0u,\r
+/*********************************************************************\r
+* String Descriptor: "codesrc.com"\r
+*********************************************************************/\r
+/* Descriptor Length */ 0x18u,\r
+/* DescriptorType: STRING */ 0x03u,\r
+ (uint8)'c', 0u,(uint8)'o', 0u,(uint8)'d', 0u,(uint8)'e', 0u,(uint8)'s', 0u,\r
+ (uint8)'r', 0u,(uint8)'c', 0u,(uint8)'.', 0u,(uint8)'c', 0u,(uint8)'o', 0u,\r
+ (uint8)'m', 0u,\r
+/*********************************************************************/\r
+/* Marks the end of the list. */ 0x00u};\r
+/*********************************************************************/\r
+\r
+/*********************************************************************\r
+* Serial Number String Descriptor\r
+*********************************************************************/\r
+const uint8 CYCODE USBFS_SN_STRING_DESCRIPTOR[10] = {\r
+/* Descriptor Length */ 0x0Au,\r
+/* DescriptorType: STRING */ 0x03u,\r
+(uint8)'1', 0u,(uint8)'2', 0u,(uint8)'3', 0u,(uint8)'4', 0u\r
+};\r
+\r
+/*********************************************************************\r
+* HID Report Descriptor: Generic HID\r
+*********************************************************************/\r
+const uint8 CYCODE USBFS_HIDREPORT_DESCRIPTOR1[40u] = {\r
+/* Descriptor Size (Not part of descriptor)*/ USBFS_HID_RPT_1_SIZE_LSB,\r
+USBFS_HID_RPT_1_SIZE_MSB,\r
+/* USAGE_PAGE */ 0x05u, 0x01u, \r
+/* USAGE */ 0x09u, 0x00u, \r
+/* COLLECTION */ 0xA1u, 0x00u, \r
+/* USAGE */ 0x09u, 0x00u, \r
+/* COLLECTION */ 0xA1u, 0x00u, \r
+/* USAGE */ 0x09u, 0x00u, \r
+/* LOGICAL_MINIMUM */ 0x15u, 0x00u, \r
+/* LOGICAL_MAXIMUM */ 0x25u, 0xFFu, \r
+/* REPORT_SIZE */ 0x75u, 0x08u, \r
+/* REPORT_COUNT */ 0x95u, 0x40u, \r
+/* OUTPUT */ 0x91u, 0x02u, \r
+/* USAGE */ 0x09u, 0x00u, \r
+/* LOGICAL_MINIMUM */ 0x15u, 0x00u, \r
+/* LOGICAL_MAXIMUM */ 0x25u, 0xFFu, \r
+/* REPORT_SIZE */ 0x75u, 0x08u, \r
+/* REPORT_COUNT */ 0x95u, 0x40u, \r
+/* INPUT */ 0x81u, 0x02u, \r
+/* END_COLLECTION */ 0xC0u, \r
+/* END_COLLECTION */ 0xC0u, \r
+/*********************************************************************/\r
+/* End of the HID Report Descriptor */ 0x00u, 0x00u};\r
+/*********************************************************************/\r
+\r
+#if !defined(USER_DEFINE_USBFS_DEVICE0_CONFIGURATION0_INTERFACE0_ALTERNATE0_HID_HID_RPT_STORAGE)\r
+/*********************************************************************\r
+* HID Input Report Storage\r
+*********************************************************************/\r
+T_USBFS_XFER_STATUS_BLOCK USBFS_DEVICE0_CONFIGURATION0_INTERFACE0_ALTERNATE0_HID_IN_RPT_SCB;\r
+uint8 USBFS_DEVICE0_CONFIGURATION0_INTERFACE0_ALTERNATE0_HID_IN_BUF[\r
+ USBFS_DEVICE0_CONFIGURATION0_INTERFACE0_ALTERNATE0_HID_IN_BUF_SIZE];\r
+\r
+/*********************************************************************\r
+* HID Input Report TD Table\r
+*********************************************************************/\r
+const T_USBFS_TD CYCODE USBFS_DEVICE0_CONFIGURATION0_INTERFACE0_ALTERNATE0_HID_IN_RPT_TABLE[1u] = {\r
+ {USBFS_DEVICE0_CONFIGURATION0_INTERFACE0_ALTERNATE0_HID_IN_BUF_SIZE,\r
+ &USBFS_DEVICE0_CONFIGURATION0_INTERFACE0_ALTERNATE0_HID_IN_BUF[0u],\r
+ &USBFS_DEVICE0_CONFIGURATION0_INTERFACE0_ALTERNATE0_HID_IN_RPT_SCB},\r
+};\r
+/*********************************************************************\r
+* HID Output Report Storage\r
+*********************************************************************/\r
+T_USBFS_XFER_STATUS_BLOCK USBFS_DEVICE0_CONFIGURATION0_INTERFACE0_ALTERNATE0_HID_OUT_RPT_SCB;\r
+uint8 USBFS_DEVICE0_CONFIGURATION0_INTERFACE0_ALTERNATE0_HID_OUT_BUF[\r
+ USBFS_DEVICE0_CONFIGURATION0_INTERFACE0_ALTERNATE0_HID_OUT_BUF_SIZE];\r
+\r
+/*********************************************************************\r
+* HID Output Report TD Table\r
+*********************************************************************/\r
+const T_USBFS_TD CYCODE USBFS_DEVICE0_CONFIGURATION0_INTERFACE0_ALTERNATE0_HID_OUT_RPT_TABLE[1u] = {\r
+ {USBFS_DEVICE0_CONFIGURATION0_INTERFACE0_ALTERNATE0_HID_OUT_BUF_SIZE,\r
+ &USBFS_DEVICE0_CONFIGURATION0_INTERFACE0_ALTERNATE0_HID_OUT_BUF[0u],\r
+ &USBFS_DEVICE0_CONFIGURATION0_INTERFACE0_ALTERNATE0_HID_OUT_RPT_SCB},\r
+};\r
+/*********************************************************************\r
+* HID Report Look Up Table This table has four entries:\r
+* IN Report Table\r
+* OUT Report Table\r
+* Feature Report Table\r
+* HID Report Descriptor\r
+* HID Class Descriptor\r
+*********************************************************************/\r
+const T_USBFS_LUT CYCODE USBFS_DEVICE0_CONFIGURATION0_INTERFACE0_ALTERNATE0_HID_TABLE[5u] = {\r
+ {0x00u, &USBFS_DEVICE0_CONFIGURATION0_INTERFACE0_ALTERNATE0_HID_IN_RPT_TABLE},\r
+ {0x00u, &USBFS_DEVICE0_CONFIGURATION0_INTERFACE0_ALTERNATE0_HID_OUT_RPT_TABLE},\r
+ {0x00u, NULL},\r
+ {0x01u, (const void *)&USBFS_HIDREPORT_DESCRIPTOR1[0]},\r
+ {0x01u, (const void *)&USBFS_DEVICE0_CONFIGURATION0_DESCR[18]}\r
+};\r
+#endif /* USER_DEFINE_USBFS_DEVICE0_CONFIGURATION0_INTERFACE0_ALTERNATE0_HID_HID_RPT_STORAGE */\r
+\r
+/*********************************************************************\r
+* Interface Dispatch Table -- Points to the Class Dispatch Tables\r
+*********************************************************************/\r
+const T_USBFS_LUT CYCODE USBFS_DEVICE0_CONFIGURATION0_INTERFACE0_TABLE[1u] = {\r
+ {USBFS_DEVICE0_CONFIGURATION0_INTERFACE0_ALTERNATE0_HID_COUNT, \r
+ &USBFS_DEVICE0_CONFIGURATION0_INTERFACE0_ALTERNATE0_HID_TABLE}\r
+};\r
+/*********************************************************************\r
+* Endpoint Setting Table -- This table contain the endpoint setting\r
+* for each endpoint in the configuration. It\r
+* contains the necessary information to\r
+* configure the endpoint hardware for each\r
+* interface and alternate setting.\r
+*********************************************************************/\r
+const T_USBFS_EP_SETTINGS_BLOCK CYCODE USBFS_DEVICE0_CONFIGURATION0_EP_SETTINGS_TABLE[2u] = {\r
+/* IFC ALT EPAddr bmAttr MaxPktSize Class ********************/\r
+{0x00u, 0x00u, 0x01u, 0x03u, 0x0040u, 0x03u},\r
+{0x00u, 0x00u, 0x82u, 0x03u, 0x0040u, 0x03u}\r
+};\r
+const uint8 CYCODE USBFS_DEVICE0_CONFIGURATION0_INTERFACE_CLASS[1u] = {\r
+0x03u\r
+};\r
+/*********************************************************************\r
+* Config Dispatch Table -- Points to the Config Descriptor and each of\r
+* and endpoint setup table and to each\r
+* interface table if it specifies a USB Class\r
+*********************************************************************/\r
+const T_USBFS_LUT CYCODE USBFS_DEVICE0_CONFIGURATION0_TABLE[4u] = {\r
+ {0x01u, &USBFS_DEVICE0_CONFIGURATION0_DESCR},\r
+ {0x02u, &USBFS_DEVICE0_CONFIGURATION0_EP_SETTINGS_TABLE},\r
+ {0x01u, &USBFS_DEVICE0_CONFIGURATION0_INTERFACE0_TABLE},\r
+ {0x00u, &USBFS_DEVICE0_CONFIGURATION0_INTERFACE_CLASS}\r
+};\r
+/*********************************************************************\r
+* Device Dispatch Table -- Points to the Device Descriptor and each of\r
+* and Configuration Tables for this Device \r
+*********************************************************************/\r
+const T_USBFS_LUT CYCODE USBFS_DEVICE0_TABLE[2u] = {\r
+ {0x01u, &USBFS_DEVICE0_DESCR},\r
+ {0x01u, &USBFS_DEVICE0_CONFIGURATION0_TABLE}\r
+};\r
+/*********************************************************************\r
+* Device Table -- Indexed by the device number.\r
+*********************************************************************/\r
+const T_USBFS_LUT CYCODE USBFS_TABLE[1u] = {\r
+ {0x01u, &USBFS_DEVICE0_TABLE}\r
+};\r
+\r
+#endif /* USER_SUPPLIED_DESCRIPTORS */\r
+\r
+#if defined(USBFS_ENABLE_MSOS_STRING)\r
+\r
+ /******************************************************************************\r
+ * USB Microsoft OS String Descriptor\r
+ * "MSFT" identifies a Microsoft host\r
+ * "100" specifies version 1.00\r
+ * USBFS_GET_EXTENDED_CONFIG_DESCRIPTOR becomes the bRequest value\r
+ * in a host vendor device/class request\r
+ ******************************************************************************/\r
+\r
+ const uint8 CYCODE USBFS_MSOS_DESCRIPTOR[USBFS_MSOS_DESCRIPTOR_LENGTH] = {\r
+ /* Descriptor Length */ 0x12u,\r
+ /* DescriptorType: STRING */ 0x03u,\r
+ /* qwSignature - "MSFT100" */ (uint8)'M', 0u, (uint8)'S', 0u, (uint8)'F', 0u, (uint8)'T', 0u,\r
+ (uint8)'1', 0u, (uint8)'0', 0u, (uint8)'0', 0u,\r
+ /* bMS_VendorCode: */ USBFS_GET_EXTENDED_CONFIG_DESCRIPTOR,\r
+ /* bPad */ 0x00u\r
+ };\r
+\r
+ /* Extended Configuration Descriptor */\r
+\r
+ const uint8 CYCODE USBFS_MSOS_CONFIGURATION_DESCR[USBFS_MSOS_CONF_DESCR_LENGTH] = {\r
+ /* Length of the descriptor 4 bytes */ 0x28u, 0x00u, 0x00u, 0x00u,\r
+ /* Version of the descriptor 2 bytes */ 0x00u, 0x01u,\r
+ /* wIndex - Fixed:INDEX_CONFIG_DESCRIPTOR */ 0x04u, 0x00u,\r
+ /* bCount - Count of device functions. */ 0x01u,\r
+ /* Reserved : 7 bytes */ 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u,\r
+ /* bFirstInterfaceNumber */ 0x00u,\r
+ /* Reserved */ 0x01u,\r
+ /* compatibleID - "CYUSB\0\0" */ (uint8)'C', (uint8)'Y', (uint8)'U', (uint8)'S', (uint8)'B',\r
+ 0x00u, 0x00u, 0x00u,\r
+ /* subcompatibleID - "00001\0\0" */ (uint8)'0', (uint8)'0', (uint8)'0', (uint8)'0', (uint8)'1',\r
+ 0x00u, 0x00u, 0x00u,\r
+ /* Reserved : 6 bytes */ 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u\r
+ };\r
+\r
+#endif /* USBFS_ENABLE_MSOS_STRING */\r
+\r
+/* DIE ID string descriptor for 8 bytes ID */\r
+#if defined(USBFS_ENABLE_IDSN_STRING)\r
+ uint8 USBFS_idSerialNumberStringDescriptor[USBFS_IDSN_DESCR_LENGTH];\r
+#endif /* USBFS_ENABLE_IDSN_STRING */\r
+\r
+\r
+/* [] END OF FILE */\r
--- /dev/null
+/*******************************************************************************\r
+* File Name: USBFS_drv.c\r
+* Version 2.60\r
+*\r
+* Description:\r
+* Endpoint 0 Driver for the USBFS Component.\r
+*\r
+* Note:\r
+*\r
+********************************************************************************\r
+* Copyright 2008-2013, Cypress Semiconductor Corporation. All rights reserved.\r
+* You may use this file only in accordance with the license, terms, conditions,\r
+* disclaimers, and limitations in the end user license agreement accompanying\r
+* the software package with which this file was provided.\r
+*******************************************************************************/\r
+\r
+#include "USBFS.h"\r
+#include "USBFS_pvt.h"\r
+\r
+\r
+/***************************************\r
+* Global data allocation\r
+***************************************/\r
+\r
+volatile T_USBFS_EP_CTL_BLOCK USBFS_EP[USBFS_MAX_EP];\r
+volatile uint8 USBFS_configuration;\r
+volatile uint8 USBFS_interfaceNumber;\r
+volatile uint8 USBFS_configurationChanged;\r
+volatile uint8 USBFS_deviceAddress;\r
+volatile uint8 USBFS_deviceStatus;\r
+volatile uint8 USBFS_interfaceSetting[USBFS_MAX_INTERFACES_NUMBER];\r
+volatile uint8 USBFS_interfaceSetting_last[USBFS_MAX_INTERFACES_NUMBER];\r
+volatile uint8 USBFS_interfaceStatus[USBFS_MAX_INTERFACES_NUMBER];\r
+volatile uint8 USBFS_device;\r
+const uint8 CYCODE *USBFS_interfaceClass;\r
+\r
+\r
+/***************************************\r
+* Local data allocation\r
+***************************************/\r
+\r
+volatile uint8 USBFS_ep0Toggle;\r
+volatile uint8 USBFS_lastPacketSize;\r
+volatile uint8 USBFS_transferState;\r
+volatile T_USBFS_TD USBFS_currentTD;\r
+volatile uint8 USBFS_ep0Mode;\r
+volatile uint8 USBFS_ep0Count;\r
+volatile uint16 USBFS_transferByteCount;\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_ep_0_Interrupt\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* This Interrupt Service Routine handles Endpoint 0 (Control Pipe) traffic.\r
+* It dispatches setup requests and handles the data and status stages.\r
+*\r
+* Parameters:\r
+* None.\r
+*\r
+* Return:\r
+* None.\r
+*\r
+*******************************************************************************/\r
+CY_ISR(USBFS_EP_0_ISR)\r
+{\r
+ uint8 bRegTemp;\r
+ uint8 modifyReg;\r
+\r
+\r
+ bRegTemp = CY_GET_REG8(USBFS_EP0_CR_PTR);\r
+ if ((bRegTemp & USBFS_MODE_ACKD) != 0u)\r
+ {\r
+ modifyReg = 1u;\r
+ if ((bRegTemp & USBFS_MODE_SETUP_RCVD) != 0u)\r
+ {\r
+ if((bRegTemp & USBFS_MODE_MASK) != USBFS_MODE_NAK_IN_OUT)\r
+ {\r
+ modifyReg = 0u; /* When mode not NAK_IN_OUT => invalid setup */\r
+ }\r
+ else\r
+ {\r
+ USBFS_HandleSetup();\r
+ if((USBFS_ep0Mode & USBFS_MODE_SETUP_RCVD) != 0u)\r
+ {\r
+ modifyReg = 0u; /* if SETUP bit set -> exit without modifying the mode */\r
+ }\r
+\r
+ }\r
+ }\r
+ else if ((bRegTemp & USBFS_MODE_IN_RCVD) != 0u)\r
+ {\r
+ USBFS_HandleIN();\r
+ }\r
+ else if ((bRegTemp & USBFS_MODE_OUT_RCVD) != 0u)\r
+ {\r
+ USBFS_HandleOUT();\r
+ }\r
+ else\r
+ {\r
+ modifyReg = 0u;\r
+ }\r
+ if(modifyReg != 0u)\r
+ {\r
+ bRegTemp = CY_GET_REG8(USBFS_EP0_CR_PTR); /* unlock registers */\r
+ if((bRegTemp & USBFS_MODE_SETUP_RCVD) == 0u) /* Check if SETUP bit is not set, otherwise exit */\r
+ {\r
+ /* Update the count register */\r
+ bRegTemp = USBFS_ep0Toggle | USBFS_ep0Count;\r
+ CY_SET_REG8(USBFS_EP0_CNT_PTR, bRegTemp);\r
+ if(bRegTemp == CY_GET_REG8(USBFS_EP0_CNT_PTR)) /* continue if writing was successful */\r
+ {\r
+ do\r
+ {\r
+ modifyReg = USBFS_ep0Mode; /* Init temporary variable */\r
+ /* Unlock registers */\r
+ bRegTemp = CY_GET_REG8(USBFS_EP0_CR_PTR) & USBFS_MODE_SETUP_RCVD;\r
+ if(bRegTemp == 0u) /* Check if SETUP bit is not set */\r
+ {\r
+ /* Set the Mode Register */\r
+ CY_SET_REG8(USBFS_EP0_CR_PTR, USBFS_ep0Mode);\r
+ /* Writing check */\r
+ modifyReg = CY_GET_REG8(USBFS_EP0_CR_PTR) & USBFS_MODE_MASK;\r
+ }\r
+ }while(modifyReg != USBFS_ep0Mode); /* Repeat if writing was not successful */\r
+ }\r
+ }\r
+ }\r
+ }\r
+}\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_HandleSetup\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* This Routine dispatches requests for the four USB request types\r
+*\r
+* Parameters:\r
+* None.\r
+*\r
+* Return:\r
+* None.\r
+*\r
+* Reentrant:\r
+* No.\r
+*\r
+*******************************************************************************/\r
+void USBFS_HandleSetup(void) \r
+{\r
+ uint8 requestHandled;\r
+\r
+ requestHandled = CY_GET_REG8(USBFS_EP0_CR_PTR); /* unlock registers */\r
+ CY_SET_REG8(USBFS_EP0_CR_PTR, requestHandled); /* clear setup bit */\r
+ requestHandled = CY_GET_REG8(USBFS_EP0_CR_PTR); /* reread register */\r
+ if((requestHandled & USBFS_MODE_SETUP_RCVD) != 0u)\r
+ {\r
+ USBFS_ep0Mode = requestHandled; /* if SETUP bit set -> exit without modifying the mode */\r
+ }\r
+ else\r
+ {\r
+ /* In case the previous transfer did not complete, close it out */\r
+ USBFS_UpdateStatusBlock(USBFS_XFER_PREMATURE);\r
+\r
+ switch (CY_GET_REG8(USBFS_bmRequestType) & USBFS_RQST_TYPE_MASK)\r
+ {\r
+ case USBFS_RQST_TYPE_STD:\r
+ requestHandled = USBFS_HandleStandardRqst();\r
+ break;\r
+ case USBFS_RQST_TYPE_CLS:\r
+ requestHandled = USBFS_DispatchClassRqst();\r
+ break;\r
+ case USBFS_RQST_TYPE_VND:\r
+ requestHandled = USBFS_HandleVendorRqst();\r
+ break;\r
+ default:\r
+ requestHandled = USBFS_FALSE;\r
+ break;\r
+ }\r
+ if (requestHandled == USBFS_FALSE)\r
+ {\r
+ USBFS_ep0Mode = USBFS_MODE_STALL_IN_OUT;\r
+ }\r
+ }\r
+}\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_HandleIN\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* This routine handles EP0 IN transfers.\r
+*\r
+* Parameters:\r
+* None.\r
+*\r
+* Return:\r
+* None.\r
+*\r
+* Reentrant:\r
+* No.\r
+*\r
+*******************************************************************************/\r
+void USBFS_HandleIN(void) \r
+{\r
+ switch (USBFS_transferState)\r
+ {\r
+ case USBFS_TRANS_STATE_IDLE:\r
+ break;\r
+ case USBFS_TRANS_STATE_CONTROL_READ:\r
+ USBFS_ControlReadDataStage();\r
+ break;\r
+ case USBFS_TRANS_STATE_CONTROL_WRITE:\r
+ USBFS_ControlWriteStatusStage();\r
+ break;\r
+ case USBFS_TRANS_STATE_NO_DATA_CONTROL:\r
+ USBFS_NoDataControlStatusStage();\r
+ break;\r
+ default: /* there are no more states */\r
+ break;\r
+ }\r
+}\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_HandleOUT\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* This routine handles EP0 OUT transfers.\r
+*\r
+* Parameters:\r
+* None.\r
+*\r
+* Return:\r
+* None.\r
+*\r
+* Reentrant:\r
+* No.\r
+*\r
+*******************************************************************************/\r
+void USBFS_HandleOUT(void) \r
+{\r
+ switch (USBFS_transferState)\r
+ {\r
+ case USBFS_TRANS_STATE_IDLE:\r
+ break;\r
+ case USBFS_TRANS_STATE_CONTROL_READ:\r
+ USBFS_ControlReadStatusStage();\r
+ break;\r
+ case USBFS_TRANS_STATE_CONTROL_WRITE:\r
+ USBFS_ControlWriteDataStage();\r
+ break;\r
+ case USBFS_TRANS_STATE_NO_DATA_CONTROL:\r
+ /* Update the completion block */\r
+ USBFS_UpdateStatusBlock(USBFS_XFER_ERROR);\r
+ /* We expect no more data, so stall INs and OUTs */\r
+ USBFS_ep0Mode = USBFS_MODE_STALL_IN_OUT;\r
+ break;\r
+ default: /* There are no more states */\r
+ break;\r
+ }\r
+}\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_LoadEP0\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* This routine loads the EP0 data registers for OUT transfers. It uses the\r
+* currentTD (previously initialized by the _InitControlWrite function and\r
+* updated for each OUT transfer, and the bLastPacketSize) to determine how\r
+* many uint8s to transfer on the current OUT.\r
+*\r
+* If the number of uint8s remaining is zero and the last transfer was full,\r
+* we need to send a zero length packet. Otherwise we send the minimum\r
+* of the control endpoint size (8) or remaining number of uint8s for the\r
+* transaction.\r
+*\r
+* Parameters:\r
+* None.\r
+*\r
+* Return:\r
+* None.\r
+*\r
+* Global variables:\r
+* USBFS_transferByteCount - Update the transfer byte count from the\r
+* last transaction.\r
+* USBFS_ep0Count - counts the data loaded to the SIE memory in\r
+* current packet.\r
+* USBFS_lastPacketSize - remembers the USBFS_ep0Count value for the\r
+* next packet.\r
+* USBFS_transferByteCount - sum of the previous bytes transferred\r
+* on previous packets(sum of USBFS_lastPacketSize)\r
+* USBFS_ep0Toggle - inverted\r
+* USBFS_ep0Mode - prepare for mode register content.\r
+* USBFS_transferState - set to TRANS_STATE_CONTROL_READ\r
+*\r
+* Reentrant:\r
+* No.\r
+*\r
+*******************************************************************************/\r
+void USBFS_LoadEP0(void) \r
+{\r
+ uint8 ep0Count = 0u;\r
+\r
+ /* Update the transfer byte count from the last transaction */\r
+ USBFS_transferByteCount += USBFS_lastPacketSize;\r
+ /* Now load the next transaction */\r
+ while ((USBFS_currentTD.count > 0u) && (ep0Count < 8u))\r
+ {\r
+ CY_SET_REG8((reg8 *)(USBFS_EP0_DR0_IND + ep0Count), *USBFS_currentTD.pData);\r
+ USBFS_currentTD.pData = &USBFS_currentTD.pData[1u];\r
+ ep0Count++;\r
+ USBFS_currentTD.count--;\r
+ }\r
+ /* Support zero-length packet*/\r
+ if( (USBFS_lastPacketSize == 8u) || (ep0Count > 0u) )\r
+ {\r
+ /* Update the data toggle */\r
+ USBFS_ep0Toggle ^= USBFS_EP0_CNT_DATA_TOGGLE;\r
+ /* Set the Mode Register */\r
+ USBFS_ep0Mode = USBFS_MODE_ACK_IN_STATUS_OUT;\r
+ /* Update the state (or stay the same) */\r
+ USBFS_transferState = USBFS_TRANS_STATE_CONTROL_READ;\r
+ }\r
+ else\r
+ {\r
+ /* Expect Status Stage Out */\r
+ USBFS_ep0Mode = USBFS_MODE_STATUS_OUT_ONLY;\r
+ /* Update the state (or stay the same) */\r
+ USBFS_transferState = USBFS_TRANS_STATE_CONTROL_READ;\r
+ }\r
+\r
+ /* Save the packet size for next time */\r
+ USBFS_lastPacketSize = ep0Count;\r
+ USBFS_ep0Count = ep0Count;\r
+}\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_InitControlRead\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* Initialize a control read transaction, usable to send data to the host.\r
+* The following global variables should be initialized before this function\r
+* called. To send zero length packet use InitZeroLengthControlTransfer\r
+* function.\r
+*\r
+* Parameters:\r
+* None.\r
+*\r
+* Return:\r
+* requestHandled state.\r
+*\r
+* Global variables:\r
+* USBFS_currentTD.count - counts of data to be sent.\r
+* USBFS_currentTD.pData - data pointer.\r
+*\r
+* Reentrant:\r
+* No.\r
+*\r
+*******************************************************************************/\r
+uint8 USBFS_InitControlRead(void) \r
+{\r
+ uint16 xferCount;\r
+ if(USBFS_currentTD.count == 0u)\r
+ {\r
+ (void) USBFS_InitZeroLengthControlTransfer();\r
+ }\r
+ else\r
+ {\r
+ /* Set up the state machine */\r
+ USBFS_transferState = USBFS_TRANS_STATE_CONTROL_READ;\r
+ /* Set the toggle, it gets updated in LoadEP */\r
+ USBFS_ep0Toggle = 0u;\r
+ /* Initialize the Status Block */\r
+ USBFS_InitializeStatusBlock();\r
+ xferCount = (((uint16)CY_GET_REG8(USBFS_lengthHi) << 8u) | (CY_GET_REG8(USBFS_lengthLo)));\r
+\r
+ if (USBFS_currentTD.count > xferCount)\r
+ {\r
+ USBFS_currentTD.count = xferCount;\r
+ }\r
+ USBFS_LoadEP0();\r
+ }\r
+\r
+ return(USBFS_TRUE);\r
+}\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_InitZeroLengthControlTransfer\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* Initialize a zero length data IN transfer.\r
+*\r
+* Parameters:\r
+* None.\r
+*\r
+* Return:\r
+* requestHandled state.\r
+*\r
+* Global variables:\r
+* USBFS_ep0Toggle - set to EP0_CNT_DATA_TOGGLE\r
+* USBFS_ep0Mode - prepare for mode register content.\r
+* USBFS_transferState - set to TRANS_STATE_CONTROL_READ\r
+* USBFS_ep0Count - cleared, means the zero-length packet.\r
+* USBFS_lastPacketSize - cleared.\r
+*\r
+* Reentrant:\r
+* No.\r
+*\r
+*******************************************************************************/\r
+uint8 USBFS_InitZeroLengthControlTransfer(void)\r
+ \r
+{\r
+ /* Update the state */\r
+ USBFS_transferState = USBFS_TRANS_STATE_CONTROL_READ;\r
+ /* Set the data toggle */\r
+ USBFS_ep0Toggle = USBFS_EP0_CNT_DATA_TOGGLE;\r
+ /* Set the Mode Register */\r
+ USBFS_ep0Mode = USBFS_MODE_ACK_IN_STATUS_OUT;\r
+ /* Save the packet size for next time */\r
+ USBFS_lastPacketSize = 0u;\r
+ USBFS_ep0Count = 0u;\r
+\r
+ return(USBFS_TRUE);\r
+}\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_ControlReadDataStage\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* Handle the Data Stage of a control read transfer.\r
+*\r
+* Parameters:\r
+* None.\r
+*\r
+* Return:\r
+* None.\r
+*\r
+* Reentrant:\r
+* No.\r
+*\r
+*******************************************************************************/\r
+void USBFS_ControlReadDataStage(void) \r
+\r
+{\r
+ USBFS_LoadEP0();\r
+}\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_ControlReadStatusStage\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* Handle the Status Stage of a control read transfer.\r
+*\r
+* Parameters:\r
+* None.\r
+*\r
+* Return:\r
+* None.\r
+*\r
+* Global variables:\r
+* USBFS_USBFS_transferByteCount - updated with last packet size.\r
+* USBFS_transferState - set to TRANS_STATE_IDLE.\r
+* USBFS_ep0Mode - set to MODE_STALL_IN_OUT.\r
+*\r
+* Reentrant:\r
+* No.\r
+*\r
+*******************************************************************************/\r
+void USBFS_ControlReadStatusStage(void) \r
+{\r
+ /* Update the transfer byte count */\r
+ USBFS_transferByteCount += USBFS_lastPacketSize;\r
+ /* Go Idle */\r
+ USBFS_transferState = USBFS_TRANS_STATE_IDLE;\r
+ /* Update the completion block */\r
+ USBFS_UpdateStatusBlock(USBFS_XFER_STATUS_ACK);\r
+ /* We expect no more data, so stall INs and OUTs */\r
+ USBFS_ep0Mode = USBFS_MODE_STALL_IN_OUT;\r
+}\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_InitControlWrite\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* Initialize a control write transaction\r
+*\r
+* Parameters:\r
+* None.\r
+*\r
+* Return:\r
+* requestHandled state.\r
+*\r
+* Global variables:\r
+* USBFS_USBFS_transferState - set to TRANS_STATE_CONTROL_WRITE\r
+* USBFS_ep0Toggle - set to EP0_CNT_DATA_TOGGLE\r
+* USBFS_ep0Mode - set to MODE_ACK_OUT_STATUS_IN\r
+*\r
+* Reentrant:\r
+* No.\r
+*\r
+*******************************************************************************/\r
+uint8 USBFS_InitControlWrite(void) \r
+{\r
+ uint16 xferCount;\r
+\r
+ /* Set up the state machine */\r
+ USBFS_transferState = USBFS_TRANS_STATE_CONTROL_WRITE;\r
+ /* This might not be necessary */\r
+ USBFS_ep0Toggle = USBFS_EP0_CNT_DATA_TOGGLE;\r
+ /* Initialize the Status Block */\r
+ USBFS_InitializeStatusBlock();\r
+\r
+ xferCount = (((uint16)CY_GET_REG8(USBFS_lengthHi) << 8u) | (CY_GET_REG8(USBFS_lengthLo)));\r
+\r
+ if (USBFS_currentTD.count > xferCount)\r
+ {\r
+ USBFS_currentTD.count = xferCount;\r
+ }\r
+\r
+ /* Expect Data or Status Stage */\r
+ USBFS_ep0Mode = USBFS_MODE_ACK_OUT_STATUS_IN;\r
+\r
+ return(USBFS_TRUE);\r
+}\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_ControlWriteDataStage\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* Handle the Data Stage of a control write transfer\r
+* 1. Get the data (We assume the destination was validated previously)\r
+* 2. Update the count and data toggle\r
+* 3. Update the mode register for the next transaction\r
+*\r
+* Parameters:\r
+* None.\r
+*\r
+* Return:\r
+* None.\r
+*\r
+* Global variables:\r
+* USBFS_transferByteCount - Update the transfer byte count from the\r
+* last transaction.\r
+* USBFS_ep0Count - counts the data loaded from the SIE memory\r
+* in current packet.\r
+* USBFS_transferByteCount - sum of the previous bytes transferred\r
+* on previous packets(sum of USBFS_lastPacketSize)\r
+* USBFS_ep0Toggle - inverted\r
+* USBFS_ep0Mode - set to MODE_ACK_OUT_STATUS_IN.\r
+*\r
+* Reentrant:\r
+* No.\r
+*\r
+*******************************************************************************/\r
+void USBFS_ControlWriteDataStage(void) \r
+{\r
+ uint8 ep0Count;\r
+ uint8 regIndex = 0u;\r
+\r
+ ep0Count = (CY_GET_REG8(USBFS_EP0_CNT_PTR) & USBFS_EPX_CNT0_MASK) -\r
+ USBFS_EPX_CNTX_CRC_COUNT;\r
+\r
+ USBFS_transferByteCount += ep0Count;\r
+\r
+ while ((USBFS_currentTD.count > 0u) && (ep0Count > 0u))\r
+ {\r
+ *USBFS_currentTD.pData = CY_GET_REG8((reg8 *)(USBFS_EP0_DR0_IND + regIndex));\r
+ USBFS_currentTD.pData = &USBFS_currentTD.pData[1u];\r
+ regIndex++;\r
+ ep0Count--;\r
+ USBFS_currentTD.count--;\r
+ }\r
+ USBFS_ep0Count = ep0Count;\r
+ /* Update the data toggle */\r
+ USBFS_ep0Toggle ^= USBFS_EP0_CNT_DATA_TOGGLE;\r
+ /* Expect Data or Status Stage */\r
+ USBFS_ep0Mode = USBFS_MODE_ACK_OUT_STATUS_IN;\r
+}\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_ControlWriteStatusStage\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* Handle the Status Stage of a control write transfer\r
+*\r
+* Parameters:\r
+* None.\r
+*\r
+* Return:\r
+* None.\r
+*\r
+* Global variables:\r
+* USBFS_transferState - set to TRANS_STATE_IDLE.\r
+* USBFS_USBFS_ep0Mode - set to MODE_STALL_IN_OUT.\r
+*\r
+* Reentrant:\r
+* No.\r
+*\r
+*******************************************************************************/\r
+void USBFS_ControlWriteStatusStage(void) \r
+{\r
+ /* Go Idle */\r
+ USBFS_transferState = USBFS_TRANS_STATE_IDLE;\r
+ /* Update the completion block */\r
+ USBFS_UpdateStatusBlock(USBFS_XFER_STATUS_ACK);\r
+ /* We expect no more data, so stall INs and OUTs */\r
+ USBFS_ep0Mode = USBFS_MODE_STALL_IN_OUT;\r
+}\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_InitNoDataControlTransfer\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* Initialize a no data control transfer\r
+*\r
+* Parameters:\r
+* None.\r
+*\r
+* Return:\r
+* requestHandled state.\r
+*\r
+* Global variables:\r
+* USBFS_transferState - set to TRANS_STATE_NO_DATA_CONTROL.\r
+* USBFS_ep0Mode - set to MODE_STATUS_IN_ONLY.\r
+* USBFS_ep0Count - cleared.\r
+* USBFS_ep0Toggle - set to EP0_CNT_DATA_TOGGLE\r
+*\r
+* Reentrant:\r
+* No.\r
+*\r
+*******************************************************************************/\r
+uint8 USBFS_InitNoDataControlTransfer(void) \r
+{\r
+ USBFS_transferState = USBFS_TRANS_STATE_NO_DATA_CONTROL;\r
+ USBFS_ep0Mode = USBFS_MODE_STATUS_IN_ONLY;\r
+ USBFS_ep0Toggle = USBFS_EP0_CNT_DATA_TOGGLE;\r
+ USBFS_ep0Count = 0u;\r
+\r
+ return(USBFS_TRUE);\r
+}\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_NoDataControlStatusStage\r
+********************************************************************************\r
+* Summary:\r
+* Handle the Status Stage of a no data control transfer.\r
+*\r
+* SET_ADDRESS is special, since we need to receive the status stage with\r
+* the old address.\r
+*\r
+* Parameters:\r
+* None.\r
+*\r
+* Return:\r
+* None.\r
+*\r
+* Global variables:\r
+* USBFS_transferState - set to TRANS_STATE_IDLE.\r
+* USBFS_ep0Mode - set to MODE_STALL_IN_OUT.\r
+* USBFS_ep0Toggle - set to EP0_CNT_DATA_TOGGLE\r
+* USBFS_deviceAddress - used to set new address and cleared\r
+*\r
+* Reentrant:\r
+* No.\r
+*\r
+*******************************************************************************/\r
+void USBFS_NoDataControlStatusStage(void) \r
+{\r
+ /* Change the USB address register if we got a SET_ADDRESS. */\r
+ if (USBFS_deviceAddress != 0u)\r
+ {\r
+ CY_SET_REG8(USBFS_CR0_PTR, USBFS_deviceAddress | USBFS_CR0_ENABLE);\r
+ USBFS_deviceAddress = 0u;\r
+ }\r
+ /* Go Idle */\r
+ USBFS_transferState = USBFS_TRANS_STATE_IDLE;\r
+ /* Update the completion block */\r
+ USBFS_UpdateStatusBlock(USBFS_XFER_STATUS_ACK);\r
+ /* We expect no more data, so stall INs and OUTs */\r
+ USBFS_ep0Mode = USBFS_MODE_STALL_IN_OUT;\r
+}\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_UpdateStatusBlock\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* Update the Completion Status Block for a Request. The block is updated\r
+* with the completion code the USBFS_transferByteCount. The\r
+* StatusBlock Pointer is set to NULL.\r
+*\r
+* Parameters:\r
+* completionCode - status.\r
+*\r
+* Return:\r
+* None.\r
+*\r
+* Global variables:\r
+* USBFS_currentTD.pStatusBlock->status - updated by the\r
+* completionCode parameter.\r
+* USBFS_currentTD.pStatusBlock->length - updated.\r
+* USBFS_currentTD.pStatusBlock - cleared.\r
+*\r
+* Reentrant:\r
+* No.\r
+*\r
+*******************************************************************************/\r
+void USBFS_UpdateStatusBlock(uint8 completionCode) \r
+{\r
+ if (USBFS_currentTD.pStatusBlock != NULL)\r
+ {\r
+ USBFS_currentTD.pStatusBlock->status = completionCode;\r
+ USBFS_currentTD.pStatusBlock->length = USBFS_transferByteCount;\r
+ USBFS_currentTD.pStatusBlock = NULL;\r
+ }\r
+}\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_InitializeStatusBlock\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* Initialize the Completion Status Block for a Request. The completion\r
+* code is set to USB_XFER_IDLE.\r
+*\r
+* Also, initializes USBFS_transferByteCount. Save some space,\r
+* this is the only consumer.\r
+*\r
+* Parameters:\r
+* None.\r
+*\r
+* Return:\r
+* None.\r
+*\r
+* Global variables:\r
+* USBFS_currentTD.pStatusBlock->status - set to XFER_IDLE.\r
+* USBFS_currentTD.pStatusBlock->length - cleared.\r
+* USBFS_transferByteCount - cleared.\r
+*\r
+* Reentrant:\r
+* No.\r
+*\r
+*******************************************************************************/\r
+void USBFS_InitializeStatusBlock(void) \r
+{\r
+ USBFS_transferByteCount = 0u;\r
+ if(USBFS_currentTD.pStatusBlock != NULL)\r
+ {\r
+ USBFS_currentTD.pStatusBlock->status = USBFS_XFER_IDLE;\r
+ USBFS_currentTD.pStatusBlock->length = 0u;\r
+ }\r
+}\r
+\r
+\r
+/* [] END OF FILE */\r
--- /dev/null
+/*******************************************************************************\r
+* File Name: USBFS_episr.c\r
+* Version 2.60\r
+*\r
+* Description:\r
+* Data endpoint Interrupt Service Routines\r
+*\r
+* Note:\r
+*\r
+********************************************************************************\r
+* Copyright 2008-2013, Cypress Semiconductor Corporation. All rights reserved.\r
+* You may use this file only in accordance with the license, terms, conditions,\r
+* disclaimers, and limitations in the end user license agreement accompanying\r
+* the software package with which this file was provided.\r
+*******************************************************************************/\r
+\r
+#include "USBFS.h"\r
+#include "USBFS_pvt.h"\r
+#if defined(USBFS_ENABLE_MIDI_STREAMING) && (USBFS_ENABLE_MIDI_API != 0u)\r
+ #include "USBFS_midi.h"\r
+#endif /* End USBFS_ENABLE_MIDI_STREAMING*/\r
+\r
+\r
+/***************************************\r
+* Custom Declarations\r
+***************************************/\r
+/* `#START CUSTOM_DECLARATIONS` Place your declaration here */\r
+\r
+/* `#END` */\r
+\r
+\r
+#if(USBFS_EP1_ISR_REMOVE == 0u)\r
+\r
+\r
+ /******************************************************************************\r
+ * Function Name: USBFS_EP_1_ISR\r
+ *******************************************************************************\r
+ *\r
+ * Summary:\r
+ * Endpoint 1 Interrupt Service Routine\r
+ *\r
+ * Parameters:\r
+ * None.\r
+ *\r
+ * Return:\r
+ * None.\r
+ *\r
+ ******************************************************************************/\r
+ CY_ISR(USBFS_EP_1_ISR)\r
+ {\r
+ #if (defined(USBFS_ENABLE_MIDI_STREAMING) && USBFS_ISR_SERVICE_MIDI_OUT && CY_PSOC3)\r
+ uint8 int_en;\r
+ #endif /* USBFS_ISR_SERVICE_MIDI_OUT && CY_PSOC3 */\r
+\r
+ /* `#START EP1_USER_CODE` Place your code here */\r
+\r
+ /* `#END` */\r
+\r
+ #if (defined(USBFS_ENABLE_MIDI_STREAMING) && USBFS_ISR_SERVICE_MIDI_OUT && CY_PSOC3)\r
+ int_en = EA;\r
+ CyGlobalIntEnable; /* Make sure nested interrupt is enabled */\r
+ #endif /* USBFS_ISR_SERVICE_MIDI_OUT && CY_PSOC3 */\r
+\r
+ CY_GET_REG8(USBFS_SIE_EP1_CR0_PTR); /* Must read the mode reg */\r
+ /* Do not toggle ISOC endpoint */\r
+ if((USBFS_EP[USBFS_EP1].attrib & USBFS_EP_TYPE_MASK) !=\r
+ USBFS_EP_TYPE_ISOC)\r
+ {\r
+ USBFS_EP[USBFS_EP1].epToggle ^= USBFS_EPX_CNT_DATA_TOGGLE;\r
+ }\r
+ USBFS_EP[USBFS_EP1].apiEpState = USBFS_EVENT_PENDING;\r
+ CY_SET_REG8(USBFS_SIE_EP_INT_SR_PTR, CY_GET_REG8(USBFS_SIE_EP_INT_SR_PTR) &\r
+ (uint8)~USBFS_SIE_EP_INT_EP1_MASK);\r
+\r
+ #if( defined(USBFS_ENABLE_MIDI_STREAMING) && USBFS_ISR_SERVICE_MIDI_OUT )\r
+ if(USBFS_midi_out_ep == USBFS_EP1)\r
+ {\r
+ USBFS_MIDI_OUT_EP_Service();\r
+ }\r
+ #endif /* End USBFS_ISR_SERVICE_MIDI_OUT */\r
+\r
+ /* `#START EP1_END_USER_CODE` Place your code here */\r
+\r
+ /* `#END` */\r
+\r
+ #if ( defined(USBFS_ENABLE_MIDI_STREAMING) && USBFS_ISR_SERVICE_MIDI_OUT && CY_PSOC3 )\r
+ EA = int_en;\r
+ #endif /* USBFS_ISR_SERVICE_MIDI_OUT && CY_PSOC3 */\r
+ }\r
+\r
+#endif /* End USBFS_EP1_ISR_REMOVE */\r
+\r
+\r
+#if(USBFS_EP2_ISR_REMOVE == 0u)\r
+\r
+ /*******************************************************************************\r
+ * Function Name: USBFS_EP_2_ISR\r
+ ********************************************************************************\r
+ *\r
+ * Summary:\r
+ * Endpoint 2 Interrupt Service Routine\r
+ *\r
+ * Parameters:\r
+ * None.\r
+ *\r
+ * Return:\r
+ * None.\r
+ *\r
+ *******************************************************************************/\r
+ CY_ISR(USBFS_EP_2_ISR)\r
+ {\r
+ #if (defined(USBFS_ENABLE_MIDI_STREAMING) && USBFS_ISR_SERVICE_MIDI_OUT && CY_PSOC3)\r
+ uint8 int_en;\r
+ #endif /* USBFS_ISR_SERVICE_MIDI_OUT && CY_PSOC3 */\r
+\r
+ /* `#START EP2_USER_CODE` Place your code here */\r
+\r
+ /* `#END` */\r
+\r
+ #if (defined(USBFS_ENABLE_MIDI_STREAMING) && USBFS_ISR_SERVICE_MIDI_OUT && CY_PSOC3 )\r
+ int_en = EA;\r
+ CyGlobalIntEnable; /* Make sure nested interrupt is enabled */\r
+ #endif /* USBFS_ISR_SERVICE_MIDI_OUT && CY_PSOC3 */\r
+\r
+ CY_GET_REG8(USBFS_SIE_EP2_CR0_PTR); /* Must read the mode reg */\r
+ /* Do not toggle ISOC endpoint */\r
+ if((USBFS_EP[USBFS_EP2].attrib & USBFS_EP_TYPE_MASK) !=\r
+ USBFS_EP_TYPE_ISOC)\r
+ {\r
+ USBFS_EP[USBFS_EP2].epToggle ^= USBFS_EPX_CNT_DATA_TOGGLE;\r
+ }\r
+ USBFS_EP[USBFS_EP2].apiEpState = USBFS_EVENT_PENDING;\r
+ CY_SET_REG8(USBFS_SIE_EP_INT_SR_PTR, CY_GET_REG8(USBFS_SIE_EP_INT_SR_PTR)\r
+ & (uint8)~USBFS_SIE_EP_INT_EP2_MASK);\r
+\r
+ #if( defined(USBFS_ENABLE_MIDI_STREAMING) && USBFS_ISR_SERVICE_MIDI_OUT )\r
+ if(USBFS_midi_out_ep == USBFS_EP2)\r
+ {\r
+ USBFS_MIDI_OUT_EP_Service();\r
+ }\r
+ #endif /* End USBFS_ISR_SERVICE_MIDI_OUT */\r
+\r
+ /* `#START EP2_END_USER_CODE` Place your code here */\r
+\r
+ /* `#END` */\r
+\r
+ #if (defined(USBFS_ENABLE_MIDI_STREAMING) && USBFS_ISR_SERVICE_MIDI_OUT && CY_PSOC3)\r
+ EA = int_en;\r
+ #endif /* USBFS_ISR_SERVICE_MIDI_OUT && CY_PSOC3 */\r
+ }\r
+\r
+#endif /* End USBFS_EP2_ISR_REMOVE */\r
+\r
+\r
+#if(USBFS_EP3_ISR_REMOVE == 0u)\r
+\r
+ /*******************************************************************************\r
+ * Function Name: USBFS_EP_3_ISR\r
+ ********************************************************************************\r
+ *\r
+ * Summary:\r
+ * Endpoint 3 Interrupt Service Routine\r
+ *\r
+ * Parameters:\r
+ * None.\r
+ *\r
+ * Return:\r
+ * None.\r
+ *\r
+ *******************************************************************************/\r
+ CY_ISR(USBFS_EP_3_ISR)\r
+ {\r
+ #if (defined(USBFS_ENABLE_MIDI_STREAMING) && USBFS_ISR_SERVICE_MIDI_OUT && CY_PSOC3)\r
+ uint8 int_en;\r
+ #endif /* USBFS_ISR_SERVICE_MIDI_OUT && CY_PSOC3 */\r
+\r
+ /* `#START EP3_USER_CODE` Place your code here */\r
+\r
+ /* `#END` */\r
+\r
+ #if (defined(USBFS_ENABLE_MIDI_STREAMING) && USBFS_ISR_SERVICE_MIDI_OUT && CY_PSOC3)\r
+ int_en = EA;\r
+ CyGlobalIntEnable; /* Make sure nested interrupt is enabled */\r
+ #endif /* CY_PSOC3 & USBFS_ISR_SERVICE_MIDI_OUT */\r
+\r
+ CY_GET_REG8(USBFS_SIE_EP3_CR0_PTR); /* Must read the mode reg */\r
+ /* Do not toggle ISOC endpoint */\r
+ if((USBFS_EP[USBFS_EP3].attrib & USBFS_EP_TYPE_MASK) !=\r
+ USBFS_EP_TYPE_ISOC)\r
+ {\r
+ USBFS_EP[USBFS_EP3].epToggle ^= USBFS_EPX_CNT_DATA_TOGGLE;\r
+ }\r
+ USBFS_EP[USBFS_EP3].apiEpState = USBFS_EVENT_PENDING;\r
+ CY_SET_REG8(USBFS_SIE_EP_INT_SR_PTR, CY_GET_REG8(USBFS_SIE_EP_INT_SR_PTR)\r
+ & (uint8)~USBFS_SIE_EP_INT_EP3_MASK);\r
+\r
+ #if (defined(USBFS_ENABLE_MIDI_STREAMING) && USBFS_ISR_SERVICE_MIDI_OUT)\r
+ if(USBFS_midi_out_ep == USBFS_EP3)\r
+ {\r
+ USBFS_MIDI_OUT_EP_Service();\r
+ }\r
+ #endif /* End USBFS_ISR_SERVICE_MIDI_OUT */\r
+\r
+ /* `#START EP3_END_USER_CODE` Place your code here */\r
+\r
+ /* `#END` */\r
+\r
+ #if (defined(USBFS_ENABLE_MIDI_STREAMING) && USBFS_ISR_SERVICE_MIDI_OUT && CY_PSOC3)\r
+ EA = int_en;\r
+ #endif /* CY_PSOC3 & USBFS_ISR_SERVICE_MIDI_OUT */\r
+ }\r
+\r
+#endif /* End USBFS_EP3_ISR_REMOVE */\r
+\r
+\r
+#if(USBFS_EP4_ISR_REMOVE == 0u)\r
+\r
+ /*******************************************************************************\r
+ * Function Name: USBFS_EP_4_ISR\r
+ ********************************************************************************\r
+ *\r
+ * Summary:\r
+ * Endpoint 4 Interrupt Service Routine\r
+ *\r
+ * Parameters:\r
+ * None.\r
+ *\r
+ * Return:\r
+ * None.\r
+ *\r
+ *******************************************************************************/\r
+ CY_ISR(USBFS_EP_4_ISR)\r
+ {\r
+ #if (defined(USBFS_ENABLE_MIDI_STREAMING) && USBFS_ISR_SERVICE_MIDI_OUT && CY_PSOC3)\r
+ uint8 int_en;\r
+ #endif /* CY_PSOC3 & USBFS_ISR_SERVICE_MIDI_OUT */\r
+\r
+ /* `#START EP4_USER_CODE` Place your code here */\r
+\r
+ /* `#END` */\r
+\r
+ #if (defined(USBFS_ENABLE_MIDI_STREAMING) && USBFS_ISR_SERVICE_MIDI_OUT && CY_PSOC3)\r
+ int_en = EA;\r
+ CyGlobalIntEnable; /* Make sure nested interrupt is enabled */\r
+ #endif /* CY_PSOC3 & USBFS_ISR_SERVICE_MIDI_OUT */\r
+\r
+ CY_GET_REG8(USBFS_SIE_EP4_CR0_PTR); /* Must read the mode reg */\r
+ /* Do not toggle ISOC endpoint */\r
+ if((USBFS_EP[USBFS_EP4].attrib & USBFS_EP_TYPE_MASK) !=\r
+ USBFS_EP_TYPE_ISOC)\r
+ {\r
+ USBFS_EP[USBFS_EP4].epToggle ^= USBFS_EPX_CNT_DATA_TOGGLE;\r
+ }\r
+ USBFS_EP[USBFS_EP4].apiEpState = USBFS_EVENT_PENDING;\r
+ CY_SET_REG8(USBFS_SIE_EP_INT_SR_PTR, CY_GET_REG8(USBFS_SIE_EP_INT_SR_PTR)\r
+ & (uint8)~USBFS_SIE_EP_INT_EP4_MASK);\r
+\r
+ #if (defined(USBFS_ENABLE_MIDI_STREAMING) && USBFS_ISR_SERVICE_MIDI_OUT)\r
+ if(USBFS_midi_out_ep == USBFS_EP4)\r
+ {\r
+ USBFS_MIDI_OUT_EP_Service();\r
+ }\r
+ #endif /* End USBFS_ISR_SERVICE_MIDI_OUT */\r
+\r
+ /* `#START EP4_END_USER_CODE` Place your code here */\r
+\r
+ /* `#END` */\r
+\r
+ #if (defined(USBFS_ENABLE_MIDI_STREAMING) && USBFS_ISR_SERVICE_MIDI_OUT && CY_PSOC3)\r
+ EA = int_en;\r
+ #endif /* CY_PSOC3 & USBFS_ISR_SERVICE_MIDI_OUT */\r
+ }\r
+\r
+#endif /* End USBFS_EP4_ISR_REMOVE */\r
+\r
+\r
+#if(USBFS_EP5_ISR_REMOVE == 0u)\r
+\r
+ /*******************************************************************************\r
+ * Function Name: USBFS_EP_5_ISR\r
+ ********************************************************************************\r
+ *\r
+ * Summary:\r
+ * Endpoint 5 Interrupt Service Routine\r
+ *\r
+ * Parameters:\r
+ * None.\r
+ *\r
+ * Return:\r
+ * None.\r
+ *\r
+ *******************************************************************************/\r
+ CY_ISR(USBFS_EP_5_ISR)\r
+ {\r
+ #if (defined(USBFS_ENABLE_MIDI_STREAMING) && USBFS_ISR_SERVICE_MIDI_OUT && CY_PSOC3)\r
+ uint8 int_en;\r
+ #endif /* CY_PSOC3 & USBFS_ISR_SERVICE_MIDI_OUT */\r
+\r
+ /* `#START EP5_USER_CODE` Place your code here */\r
+\r
+ /* `#END` */\r
+\r
+ #if (defined(USBFS_ENABLE_MIDI_STREAMING) && USBFS_ISR_SERVICE_MIDI_OUT && CY_PSOC3)\r
+ int_en = EA;\r
+ CyGlobalIntEnable; /* Make sure nested interrupt is enabled */\r
+ #endif /* CY_PSOC3 & USBFS_ISR_SERVICE_MIDI_OUT */\r
+\r
+ CY_GET_REG8(USBFS_SIE_EP5_CR0_PTR); /* Must read the mode reg */\r
+ /* Do not toggle ISOC endpoint */\r
+ if((USBFS_EP[USBFS_EP5].attrib & USBFS_EP_TYPE_MASK) !=\r
+ USBFS_EP_TYPE_ISOC)\r
+ {\r
+ USBFS_EP[USBFS_EP5].epToggle ^= USBFS_EPX_CNT_DATA_TOGGLE;\r
+ }\r
+ USBFS_EP[USBFS_EP5].apiEpState = USBFS_EVENT_PENDING;\r
+ CY_SET_REG8(USBFS_SIE_EP_INT_SR_PTR, CY_GET_REG8(USBFS_SIE_EP_INT_SR_PTR)\r
+ & (uint8)~USBFS_SIE_EP_INT_EP5_MASK);\r
+\r
+ #if (defined(USBFS_ENABLE_MIDI_STREAMING) && USBFS_ISR_SERVICE_MIDI_OUT)\r
+ if(USBFS_midi_out_ep == USBFS_EP5)\r
+ {\r
+ USBFS_MIDI_OUT_EP_Service();\r
+ }\r
+ #endif /* End USBFS_ISR_SERVICE_MIDI_OUT */\r
+\r
+ /* `#START EP5_END_USER_CODE` Place your code here */\r
+\r
+ /* `#END` */\r
+\r
+ #if (defined(USBFS_ENABLE_MIDI_STREAMING) && USBFS_ISR_SERVICE_MIDI_OUT && CY_PSOC3)\r
+ EA = int_en;\r
+ #endif /* CY_PSOC3 & USBFS_ISR_SERVICE_MIDI_OUT */\r
+ }\r
+#endif /* End USBFS_EP5_ISR_REMOVE */\r
+\r
+\r
+#if(USBFS_EP6_ISR_REMOVE == 0u)\r
+\r
+ /*******************************************************************************\r
+ * Function Name: USBFS_EP_6_ISR\r
+ ********************************************************************************\r
+ *\r
+ * Summary:\r
+ * Endpoint 6 Interrupt Service Routine\r
+ *\r
+ * Parameters:\r
+ * None.\r
+ *\r
+ * Return:\r
+ * None.\r
+ *\r
+ *******************************************************************************/\r
+ CY_ISR(USBFS_EP_6_ISR)\r
+ {\r
+ #if (defined(USBFS_ENABLE_MIDI_STREAMING) && USBFS_ISR_SERVICE_MIDI_OUT && CY_PSOC3)\r
+ uint8 int_en;\r
+ #endif /* CY_PSOC3 & USBFS_ISR_SERVICE_MIDI_OUT */\r
+\r
+ /* `#START EP6_USER_CODE` Place your code here */\r
+\r
+ /* `#END` */\r
+\r
+ #if (defined(USBFS_ENABLE_MIDI_STREAMING) && USBFS_ISR_SERVICE_MIDI_OUT && CY_PSOC3)\r
+ int_en = EA;\r
+ CyGlobalIntEnable; /* Make sure nested interrupt is enabled */\r
+ #endif /* CY_PSOC3 & USBFS_ISR_SERVICE_MIDI_OUT */\r
+\r
+ CY_GET_REG8(USBFS_SIE_EP6_CR0_PTR); /* Must read the mode reg */\r
+ /* Do not toggle ISOC endpoint */\r
+ if((USBFS_EP[USBFS_EP6].attrib & USBFS_EP_TYPE_MASK) !=\r
+ USBFS_EP_TYPE_ISOC)\r
+ {\r
+ USBFS_EP[USBFS_EP6].epToggle ^= USBFS_EPX_CNT_DATA_TOGGLE;\r
+ }\r
+ USBFS_EP[USBFS_EP6].apiEpState = USBFS_EVENT_PENDING;\r
+ CY_SET_REG8(USBFS_SIE_EP_INT_SR_PTR, CY_GET_REG8(USBFS_SIE_EP_INT_SR_PTR)\r
+ & (uint8)~USBFS_SIE_EP_INT_EP6_MASK);\r
+\r
+ #if (defined(USBFS_ENABLE_MIDI_STREAMING) && USBFS_ISR_SERVICE_MIDI_OUT)\r
+ if(USBFS_midi_out_ep == USBFS_EP6)\r
+ {\r
+ USBFS_MIDI_OUT_EP_Service();\r
+ }\r
+ #endif /* End USBFS_ISR_SERVICE_MIDI_OUT */\r
+\r
+ /* `#START EP6_END_USER_CODE` Place your code here */\r
+\r
+ /* `#END` */\r
+\r
+ #if (defined(USBFS_ENABLE_MIDI_STREAMING) && USBFS_ISR_SERVICE_MIDI_OUT && CY_PSOC3)\r
+ EA = int_en;\r
+ #endif /* CY_PSOC3 & USBFS_ISR_SERVICE_MIDI_OUT */\r
+ }\r
+\r
+#endif /* End USBFS_EP6_ISR_REMOVE */\r
+\r
+\r
+#if(USBFS_EP7_ISR_REMOVE == 0u)\r
+\r
+ /*******************************************************************************\r
+ * Function Name: USBFS_EP_7_ISR\r
+ ********************************************************************************\r
+ *\r
+ * Summary:\r
+ * Endpoint 7 Interrupt Service Routine\r
+ *\r
+ * Parameters:\r
+ * None.\r
+ *\r
+ * Return:\r
+ * None.\r
+ *\r
+ *******************************************************************************/\r
+ CY_ISR(USBFS_EP_7_ISR)\r
+ {\r
+ #if (defined(USBFS_ENABLE_MIDI_STREAMING) && USBFS_ISR_SERVICE_MIDI_OUT && CY_PSOC3)\r
+ uint8 int_en;\r
+ #endif /* CY_PSOC3 & USBFS_ISR_SERVICE_MIDI_OUT */\r
+\r
+ /* `#START EP7_USER_CODE` Place your code here */\r
+\r
+ /* `#END` */\r
+\r
+ #if (defined(USBFS_ENABLE_MIDI_STREAMING) && USBFS_ISR_SERVICE_MIDI_OUT && CY_PSOC3)\r
+ int_en = EA;\r
+ CyGlobalIntEnable; /* Make sure nested interrupt is enabled */\r
+ #endif /* CY_PSOC3 & USBFS_ISR_SERVICE_MIDI_OUT */\r
+\r
+ CY_GET_REG8(USBFS_SIE_EP7_CR0_PTR); /* Must read the mode reg */\r
+ /* Do not toggle ISOC endpoint */\r
+ if((USBFS_EP[USBFS_EP7].attrib & USBFS_EP_TYPE_MASK) !=\r
+ USBFS_EP_TYPE_ISOC)\r
+ {\r
+ USBFS_EP[USBFS_EP7].epToggle ^= USBFS_EPX_CNT_DATA_TOGGLE;\r
+ }\r
+ USBFS_EP[USBFS_EP7].apiEpState = USBFS_EVENT_PENDING;\r
+ CY_SET_REG8(USBFS_SIE_EP_INT_SR_PTR, CY_GET_REG8(USBFS_SIE_EP_INT_SR_PTR)\r
+ & (uint8)~USBFS_SIE_EP_INT_EP7_MASK);\r
+\r
+ #if (defined(USBFS_ENABLE_MIDI_STREAMING) && USBFS_ISR_SERVICE_MIDI_OUT)\r
+ if(USBFS_midi_out_ep == USBFS_EP7)\r
+ {\r
+ USBFS_MIDI_OUT_EP_Service();\r
+ }\r
+ #endif /* End USBFS_ISR_SERVICE_MIDI_OUT */\r
+\r
+ /* `#START EP7_END_USER_CODE` Place your code here */\r
+\r
+ /* `#END` */\r
+\r
+ #if (defined(USBFS_ENABLE_MIDI_STREAMING) && USBFS_ISR_SERVICE_MIDI_OUT && CY_PSOC3)\r
+ EA = int_en;\r
+ #endif /* CY_PSOC3 & USBFS_ISR_SERVICE_MIDI_OUT */\r
+ }\r
+\r
+#endif /* End USBFS_EP7_ISR_REMOVE */\r
+\r
+\r
+#if(USBFS_EP8_ISR_REMOVE == 0u)\r
+\r
+ /*******************************************************************************\r
+ * Function Name: USBFS_EP_8_ISR\r
+ ********************************************************************************\r
+ *\r
+ * Summary:\r
+ * Endpoint 8 Interrupt Service Routine\r
+ *\r
+ * Parameters:\r
+ * None.\r
+ *\r
+ * Return:\r
+ * None.\r
+ *\r
+ *******************************************************************************/\r
+ CY_ISR(USBFS_EP_8_ISR)\r
+ {\r
+ #if (defined(USBFS_ENABLE_MIDI_STREAMING) && USBFS_ISR_SERVICE_MIDI_OUT && CY_PSOC3)\r
+ uint8 int_en;\r
+ #endif /* CY_PSOC3 & USBFS_ISR_SERVICE_MIDI_OUT */\r
+\r
+ /* `#START EP8_USER_CODE` Place your code here */\r
+\r
+ /* `#END` */\r
+\r
+ #if (defined(USBFS_ENABLE_MIDI_STREAMING) && USBFS_ISR_SERVICE_MIDI_OUT && CY_PSOC3)\r
+ int_en = EA;\r
+ CyGlobalIntEnable; /* Make sure nested interrupt is enabled */\r
+ #endif /* CY_PSOC3 & USBFS_ISR_SERVICE_MIDI_OUT */\r
+\r
+ CY_GET_REG8(USBFS_SIE_EP8_CR0_PTR); /* Must read the mode reg */\r
+ /* Do not toggle ISOC endpoint */\r
+ if((USBFS_EP[USBFS_EP8].attrib & USBFS_EP_TYPE_MASK) !=\r
+ USBFS_EP_TYPE_ISOC)\r
+ {\r
+ USBFS_EP[USBFS_EP8].epToggle ^= USBFS_EPX_CNT_DATA_TOGGLE;\r
+ }\r
+ USBFS_EP[USBFS_EP8].apiEpState = USBFS_EVENT_PENDING;\r
+ CY_SET_REG8(USBFS_SIE_EP_INT_SR_PTR, CY_GET_REG8(USBFS_SIE_EP_INT_SR_PTR)\r
+ & (uint8)~USBFS_SIE_EP_INT_EP8_MASK);\r
+\r
+ #if (defined(USBFS_ENABLE_MIDI_STREAMING) && USBFS_ISR_SERVICE_MIDI_OUT)\r
+ if(USBFS_midi_out_ep == USBFS_EP8)\r
+ {\r
+ USBFS_MIDI_OUT_EP_Service();\r
+ }\r
+ #endif /* End USBFS_ISR_SERVICE_MIDI_OUT */\r
+\r
+ /* `#START EP8_END_USER_CODE` Place your code here */\r
+\r
+ /* `#END` */\r
+\r
+ #if (defined(USBFS_ENABLE_MIDI_STREAMING) && USBFS_ISR_SERVICE_MIDI_OUT && CY_PSOC3)\r
+ EA = int_en;\r
+ #endif /* CY_PSOC3 & USBFS_ISR_SERVICE_MIDI_OUT */\r
+ }\r
+\r
+#endif /* End USBFS_EP8_ISR_REMOVE */\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_SOF_ISR\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* Start of Frame Interrupt Service Routine\r
+*\r
+* Parameters:\r
+* None.\r
+*\r
+* Return:\r
+* None.\r
+*\r
+*******************************************************************************/\r
+CY_ISR(USBFS_SOF_ISR)\r
+{\r
+ /* `#START SOF_USER_CODE` Place your code here */\r
+\r
+ /* `#END` */\r
+}\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_BUS_RESET_ISR\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* USB Bus Reset Interrupt Service Routine. Calls _Start with the same\r
+* parameters as the last USER call to _Start\r
+*\r
+* Parameters:\r
+* None.\r
+*\r
+* Return:\r
+* None.\r
+*\r
+*******************************************************************************/\r
+CY_ISR(USBFS_BUS_RESET_ISR)\r
+{\r
+ /* `#START BUS_RESET_USER_CODE` Place your code here */\r
+\r
+ /* `#END` */\r
+\r
+ USBFS_ReInitComponent();\r
+}\r
+\r
+\r
+#if((USBFS_EP_MM != USBFS__EP_MANUAL) && (USBFS_ARB_ISR_REMOVE == 0u))\r
+\r
+\r
+ /*******************************************************************************\r
+ * Function Name: USBFS_ARB_ISR\r
+ ********************************************************************************\r
+ *\r
+ * Summary:\r
+ * Arbiter Interrupt Service Routine\r
+ *\r
+ * Parameters:\r
+ * None.\r
+ *\r
+ * Return:\r
+ * None.\r
+ *\r
+ * Side effect:\r
+ * Search for EP8 int_status will be much slower than search for EP1 int_status.\r
+ *\r
+ *******************************************************************************/\r
+ CY_ISR(USBFS_ARB_ISR)\r
+ {\r
+ uint8 int_status;\r
+ uint8 ep_status;\r
+ uint8 ep = USBFS_EP1;\r
+ uint8 ptr = 0u;\r
+\r
+ /* `#START ARB_BEGIN_USER_CODE` Place your code here */\r
+\r
+ /* `#END` */\r
+\r
+ int_status = USBFS_ARB_INT_SR_REG; /* read Arbiter Status Register */\r
+ USBFS_ARB_INT_SR_REG = int_status; /* Clear Serviced Interrupts */\r
+\r
+ while(int_status != 0u)\r
+ {\r
+ if((int_status & 1u) != 0u) /* If EpX interrupt present */\r
+ { /* read Endpoint Status Register */\r
+ ep_status = CY_GET_REG8((reg8 *)(USBFS_ARB_EP1_SR_IND + ptr));\r
+ /* If In Buffer Full */\r
+ if((ep_status & USBFS_ARB_EPX_SR_IN_BUF_FULL) != 0u)\r
+ {\r
+ if((USBFS_EP[ep].addr & USBFS_DIR_IN) != 0u)\r
+ {\r
+ /* Clear Data ready status */\r
+ *(reg8 *)(USBFS_ARB_EP1_CFG_IND + ptr) &=\r
+ (uint8)~USBFS_ARB_EPX_CFG_IN_DATA_RDY;\r
+ /* Write the Mode register */\r
+ CY_SET_REG8((reg8 *)(USBFS_SIE_EP1_CR0_IND + ptr), USBFS_EP[ep].epMode);\r
+ #if (defined(USBFS_ENABLE_MIDI_STREAMING) && USBFS_ISR_SERVICE_MIDI_IN)\r
+ if(ep == USBFS_midi_in_ep)\r
+ { /* Clear MIDI input pointer */\r
+ USBFS_midiInPointer = 0u;\r
+ }\r
+ #endif /* End USBFS_ENABLE_MIDI_STREAMING*/\r
+ }\r
+ }\r
+ /* (re)arm Out EP only for mode2 */\r
+ #if(USBFS_EP_MM != USBFS__EP_DMAAUTO)\r
+ /* If DMA Grant */\r
+ if((ep_status & USBFS_ARB_EPX_SR_DMA_GNT) != 0u)\r
+ {\r
+ if((USBFS_EP[ep].addr & USBFS_DIR_IN) == 0u)\r
+ {\r
+ USBFS_EP[ep].apiEpState = USBFS_NO_EVENT_PENDING;\r
+ /* Write the Mode register */\r
+ CY_SET_REG8((reg8 *)(USBFS_SIE_EP1_CR0_IND + ptr),\r
+ USBFS_EP[ep].epMode);\r
+ }\r
+ }\r
+ #endif /* End USBFS_EP_MM */\r
+\r
+ /* `#START ARB_USER_CODE` Place your code here for handle Buffer Underflow/Overflow */\r
+\r
+ /* `#END` */\r
+\r
+ CY_SET_REG8((reg8 *)(USBFS_ARB_EP1_SR_IND + ptr), ep_status); /* Clear Serviced events */\r
+ }\r
+ ptr += USBFS_EPX_CNTX_ADDR_OFFSET; /* prepare pointer for next EP */\r
+ ep++;\r
+ int_status >>= 1u;\r
+ }\r
+\r
+ /* `#START ARB_END_USER_CODE` Place your code here */\r
+\r
+ /* `#END` */\r
+ }\r
+\r
+#endif /* End USBFS_EP_MM */\r
+\r
+\r
+/* [] END OF FILE */\r
--- /dev/null
+/*******************************************************************************\r
+* File Name: USBFS_hid.c\r
+* Version 2.60\r
+*\r
+* Description:\r
+* USB HID Class request handler.\r
+*\r
+* Note:\r
+*\r
+********************************************************************************\r
+* Copyright 2008-2013, Cypress Semiconductor Corporation. All rights reserved.\r
+* You may use this file only in accordance with the license, terms, conditions,\r
+* disclaimers, and limitations in the end user license agreement accompanying\r
+* the software package with which this file was provided.\r
+*******************************************************************************/\r
+\r
+#include "USBFS.h"\r
+\r
+#if defined(USBFS_ENABLE_HID_CLASS)\r
+\r
+#include "USBFS_pvt.h"\r
+#include "USBFS_hid.h"\r
+\r
+\r
+/***************************************\r
+* HID Variables\r
+***************************************/\r
+\r
+volatile uint8 USBFS_hidProtocol[USBFS_MAX_INTERFACES_NUMBER]; /* HID device protocol status */\r
+volatile uint8 USBFS_hidIdleRate[USBFS_MAX_INTERFACES_NUMBER]; /* HID device idle reload value */\r
+volatile uint8 USBFS_hidIdleTimer[USBFS_MAX_INTERFACES_NUMBER]; /* HID device idle rate value */\r
+\r
+\r
+/***************************************\r
+* Custom Declarations\r
+***************************************/\r
+\r
+/* `#START HID_CUSTOM_DECLARATIONS` Place your declaration here */\r
+\r
+/* `#END` */\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_UpdateHIDTimer\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* Updates the HID report timer and reloads it if expired\r
+*\r
+* Parameters:\r
+* interface: Interface Number.\r
+*\r
+* Return:\r
+* status.\r
+*\r
+* Reentrant:\r
+* No.\r
+*\r
+*******************************************************************************/\r
+uint8 USBFS_UpdateHIDTimer(uint8 interface) \r
+{\r
+ uint8 stat = USBFS_IDLE_TIMER_INDEFINITE;\r
+\r
+ if(USBFS_hidIdleRate[interface] != 0u)\r
+ {\r
+ if(USBFS_hidIdleTimer[interface] > 0u)\r
+ {\r
+ USBFS_hidIdleTimer[interface]--;\r
+ stat = USBFS_IDLE_TIMER_RUNNING;\r
+ }\r
+ else\r
+ {\r
+ USBFS_hidIdleTimer[interface] = USBFS_hidIdleRate[interface];\r
+ stat = USBFS_IDLE_TIMER_EXPIRED;\r
+ }\r
+ }\r
+\r
+ return(stat);\r
+}\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_GetProtocol\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* Returns the selected protocol value to the application\r
+*\r
+* Parameters:\r
+* interface: Interface Number.\r
+*\r
+* Return:\r
+* Interface protocol.\r
+*\r
+*******************************************************************************/\r
+uint8 USBFS_GetProtocol(uint8 interface) \r
+{\r
+ return(USBFS_hidProtocol[interface]);\r
+}\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_DispatchHIDClassRqst\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* This routine dispatches class requests\r
+*\r
+* Parameters:\r
+* None.\r
+*\r
+* Return:\r
+* requestHandled\r
+*\r
+* Reentrant:\r
+* No.\r
+*\r
+*******************************************************************************/\r
+uint8 USBFS_DispatchHIDClassRqst(void) \r
+{\r
+ uint8 requestHandled = USBFS_FALSE;\r
+ uint8 interfaceNumber;\r
+\r
+ interfaceNumber = CY_GET_REG8(USBFS_wIndexLo);\r
+ if ((CY_GET_REG8(USBFS_bmRequestType) & USBFS_RQST_DIR_MASK) == USBFS_RQST_DIR_D2H)\r
+ { /* Control Read */\r
+ switch (CY_GET_REG8(USBFS_bRequest))\r
+ {\r
+ case USBFS_GET_DESCRIPTOR:\r
+ if (CY_GET_REG8(USBFS_wValueHi) == USBFS_DESCR_HID_CLASS)\r
+ {\r
+ USBFS_FindHidClassDecriptor();\r
+ if (USBFS_currentTD.count != 0u)\r
+ {\r
+ requestHandled = USBFS_InitControlRead();\r
+ }\r
+ }\r
+ else if (CY_GET_REG8(USBFS_wValueHi) == USBFS_DESCR_HID_REPORT)\r
+ {\r
+ USBFS_FindReportDescriptor();\r
+ if (USBFS_currentTD.count != 0u)\r
+ {\r
+ requestHandled = USBFS_InitControlRead();\r
+ }\r
+ }\r
+ else\r
+ { /* requestHandled is initialezed as FALSE by default */\r
+ }\r
+ break;\r
+ case USBFS_HID_GET_REPORT:\r
+ USBFS_FindReport();\r
+ if (USBFS_currentTD.count != 0u)\r
+ {\r
+ requestHandled = USBFS_InitControlRead();\r
+ }\r
+ break;\r
+\r
+ case USBFS_HID_GET_IDLE:\r
+ /* This function does not support multiple reports per interface*/\r
+ /* Validate interfaceNumber and Report ID (should be 0) */\r
+ if( (interfaceNumber < USBFS_MAX_INTERFACES_NUMBER) &&\r
+ (CY_GET_REG8(USBFS_wValueLo) == 0u ) ) /* Do not support Idle per Report ID */\r
+ {\r
+ USBFS_currentTD.count = 1u;\r
+ USBFS_currentTD.pData = &USBFS_hidIdleRate[interfaceNumber];\r
+ requestHandled = USBFS_InitControlRead();\r
+ }\r
+ break;\r
+ case USBFS_HID_GET_PROTOCOL:\r
+ /* Validate interfaceNumber */\r
+ if( interfaceNumber < USBFS_MAX_INTERFACES_NUMBER)\r
+ {\r
+ USBFS_currentTD.count = 1u;\r
+ USBFS_currentTD.pData = &USBFS_hidProtocol[interfaceNumber];\r
+ requestHandled = USBFS_InitControlRead();\r
+ }\r
+ break;\r
+ default: /* requestHandled is initialized as FALSE by default */\r
+ break;\r
+ }\r
+ }\r
+ else if ((CY_GET_REG8(USBFS_bmRequestType) & USBFS_RQST_DIR_MASK) ==\r
+ USBFS_RQST_DIR_H2D)\r
+ { /* Control Write */\r
+ switch (CY_GET_REG8(USBFS_bRequest))\r
+ {\r
+ case USBFS_HID_SET_REPORT:\r
+ USBFS_FindReport();\r
+ if (USBFS_currentTD.count != 0u)\r
+ {\r
+ requestHandled = USBFS_InitControlWrite();\r
+ }\r
+ break;\r
+ case USBFS_HID_SET_IDLE:\r
+ /* This function does not support multiple reports per interface */\r
+ /* Validate interfaceNumber and Report ID (should be 0) */\r
+ if( (interfaceNumber < USBFS_MAX_INTERFACES_NUMBER) &&\r
+ (CY_GET_REG8(USBFS_wValueLo) == 0u ) ) /* Do not support Idle per Report ID */\r
+ {\r
+ USBFS_hidIdleRate[interfaceNumber] = CY_GET_REG8(USBFS_wValueHi);\r
+ /* With regards to HID spec: "7.2.4 Set_Idle Request"\r
+ * Latency. If the current period has gone past the\r
+ * newly proscribed time duration, then a report\r
+ * will be generated immediately.\r
+ */\r
+ if(USBFS_hidIdleRate[interfaceNumber] <\r
+ USBFS_hidIdleTimer[interfaceNumber])\r
+ {\r
+ /* Set the timer to zero and let the UpdateHIDTimer() API return IDLE_TIMER_EXPIRED status*/\r
+ USBFS_hidIdleTimer[interfaceNumber] = 0u;\r
+ }\r
+ /* If the new request is received within 4 milliseconds\r
+ * (1 count) of the end of the current period, then the\r
+ * new request will have no effect until after the report.\r
+ */\r
+ else if(USBFS_hidIdleTimer[interfaceNumber] <= 1u)\r
+ {\r
+ /* Do nothing.\r
+ * Let the UpdateHIDTimer() API continue to work and\r
+ * return IDLE_TIMER_EXPIRED status\r
+ */\r
+ }\r
+ else\r
+ { /* Reload the timer*/\r
+ USBFS_hidIdleTimer[interfaceNumber] =\r
+ USBFS_hidIdleRate[interfaceNumber];\r
+ }\r
+ requestHandled = USBFS_InitNoDataControlTransfer();\r
+ }\r
+ break;\r
+\r
+ case USBFS_HID_SET_PROTOCOL:\r
+ /* Validate interfaceNumber and protocol (must be 0 or 1) */\r
+ if( (interfaceNumber < USBFS_MAX_INTERFACES_NUMBER) &&\r
+ (CY_GET_REG8(USBFS_wValueLo) <= 1u) )\r
+ {\r
+ USBFS_hidProtocol[interfaceNumber] = CY_GET_REG8(USBFS_wValueLo);\r
+ requestHandled = USBFS_InitNoDataControlTransfer();\r
+ }\r
+ break;\r
+ default: /* requestHandled is initialized as FALSE by default */\r
+ break;\r
+ }\r
+ }\r
+ else\r
+ { /* requestHandled is initialized as FALSE by default */\r
+ }\r
+\r
+ return(requestHandled);\r
+}\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USB_FindHidClassDescriptor\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* This routine find Hid Class Descriptor pointer based on the Interface number\r
+* and Alternate setting then loads the currentTD structure with the address of\r
+* the buffer and the size.\r
+* The HID Class Descriptor resides inside the config descriptor.\r
+*\r
+* Parameters:\r
+* None.\r
+*\r
+* Return:\r
+* currentTD\r
+*\r
+* Reentrant:\r
+* No.\r
+*\r
+*******************************************************************************/\r
+void USBFS_FindHidClassDecriptor(void) \r
+{\r
+ const T_USBFS_LUT CYCODE *pTmp;\r
+ volatile uint8 *pDescr;\r
+ uint8 interfaceN;\r
+\r
+ pTmp = USBFS_GetConfigTablePtr(USBFS_configuration - 1u);\r
+ interfaceN = CY_GET_REG8(USBFS_wIndexLo);\r
+ /* Third entry in the LUT starts the Interface Table pointers */\r
+ /* Now use the request interface number*/\r
+ pTmp = &pTmp[interfaceN + 2u];\r
+ /* USB_DEVICEx_CONFIGURATIONy_INTERFACEz_TABLE */\r
+ pTmp = (const T_USBFS_LUT CYCODE *) pTmp->p_list;\r
+ /* Now use Alternate setting number */\r
+ pTmp = &pTmp[USBFS_interfaceSetting[interfaceN]];\r
+ /* USB_DEVICEx_CONFIGURATIONy_INTERFACEz_ALTERNATEi_HID_TABLE */\r
+ pTmp = (const T_USBFS_LUT CYCODE *) pTmp->p_list;\r
+ /* Fifth entry in the LUT points to Hid Class Descriptor in Configuration Descriptor */\r
+ pTmp = &pTmp[4u];\r
+ pDescr = (volatile uint8 *)pTmp->p_list;\r
+ /* The first byte contains the descriptor length */\r
+ USBFS_currentTD.count = *pDescr;\r
+ USBFS_currentTD.pData = pDescr;\r
+}\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USB_FindReportDescriptor\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* This routine find Hid Report Descriptor pointer based on the Interface\r
+* number, then loads the currentTD structure with the address of the buffer\r
+* and the size.\r
+* Hid Report Descriptor is located after IN/OUT/FEATURE reports.\r
+*\r
+* Parameters:\r
+* void\r
+*\r
+* Return:\r
+* currentTD\r
+*\r
+* Reentrant:\r
+* No.\r
+*\r
+*******************************************************************************/\r
+void USBFS_FindReportDescriptor(void) \r
+{\r
+ const T_USBFS_LUT CYCODE *pTmp;\r
+ volatile uint8 *pDescr;\r
+ uint8 interfaceN;\r
+\r
+ pTmp = USBFS_GetConfigTablePtr(USBFS_configuration - 1u);\r
+ interfaceN = CY_GET_REG8(USBFS_wIndexLo);\r
+ /* Third entry in the LUT starts the Interface Table pointers */\r
+ /* Now use the request interface number */\r
+ pTmp = &pTmp[interfaceN + 2u];\r
+ /* USB_DEVICEx_CONFIGURATIONy_INTERFACEz_TABLE */\r
+ pTmp = (const T_USBFS_LUT CYCODE *) pTmp->p_list;\r
+ /* Now use Alternate setting number */\r
+ pTmp = &pTmp[USBFS_interfaceSetting[interfaceN]];\r
+ /* USB_DEVICEx_CONFIGURATIONy_INTERFACEz_ALTERNATEi_HID_TABLE */\r
+ pTmp = (const T_USBFS_LUT CYCODE *) pTmp->p_list;\r
+ /* Fourth entry in the LUT starts the Hid Report Descriptor */\r
+ pTmp = &pTmp[3u];\r
+ pDescr = (volatile uint8 *)pTmp->p_list;\r
+ /* The 1st and 2nd bytes of descriptor contain its length. LSB is 1st. */\r
+ USBFS_currentTD.count = (((uint16)pDescr[1u] << 8u) | pDescr[0u]);\r
+ USBFS_currentTD.pData = &pDescr[2u];\r
+}\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_FindReport\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* This routine sets up a transfer based on the Interface number, Report Type\r
+* and Report ID, then loads the currentTD structure with the address of the\r
+* buffer and the size. The caller has to decide if it is a control read or\r
+* control write.\r
+*\r
+* Parameters:\r
+* None.\r
+*\r
+* Return:\r
+* currentTD\r
+*\r
+* Reentrant:\r
+* No.\r
+*\r
+*******************************************************************************/\r
+void USBFS_FindReport(void) \r
+{\r
+ const T_USBFS_LUT CYCODE *pTmp;\r
+ T_USBFS_TD *pTD;\r
+ uint8 interfaceN;\r
+ uint8 reportType;\r
+\r
+ /* `#START HID_FINDREPORT` Place custom handling here */\r
+\r
+ /* `#END` */\r
+ USBFS_currentTD.count = 0u; /* Init not supported condition */\r
+ pTmp = USBFS_GetConfigTablePtr(USBFS_configuration - 1u);\r
+ reportType = CY_GET_REG8(USBFS_wValueHi);\r
+ interfaceN = CY_GET_REG8(USBFS_wIndexLo);\r
+ /* Third entry in the LUT COnfiguration Table starts the Interface Table pointers */\r
+ /* Now use the request interface number */\r
+ pTmp = &pTmp[interfaceN + 2u];\r
+ /* USB_DEVICEx_CONFIGURATIONy_INTERFACEz_TABLE*/\r
+ pTmp = (const T_USBFS_LUT CYCODE *) pTmp->p_list;\r
+ if(interfaceN < USBFS_MAX_INTERFACES_NUMBER)\r
+ {\r
+ /* Now use Alternate setting number */\r
+ pTmp = &pTmp[USBFS_interfaceSetting[interfaceN]];\r
+ /* USB_DEVICEx_CONFIGURATIONy_INTERFACEz_ALTERNATEi_HID_TABLE */\r
+ pTmp = (const T_USBFS_LUT CYCODE *) pTmp->p_list;\r
+ /* Validate reportType to comply with "7.2.1 Get_Report Request" */\r
+ if((reportType >= USBFS_HID_GET_REPORT_INPUT) &&\r
+ (reportType <= USBFS_HID_GET_REPORT_FEATURE))\r
+ {\r
+ /* Get the entry proper TD (IN, OUT or Feature Report Table)*/\r
+ pTmp = &pTmp[reportType - 1u];\r
+ reportType = CY_GET_REG8(USBFS_wValueLo); /* Get reportID */\r
+ /* Validate table support by the HID descriptor, compare table count with reportID */\r
+ if(pTmp->c >= reportType)\r
+ {\r
+ pTD = (T_USBFS_TD *) pTmp->p_list;\r
+ pTD = &pTD[reportType]; /* select entry depend on report ID*/\r
+ USBFS_currentTD.pData = pTD->pData; /* Buffer pointer */\r
+ USBFS_currentTD.count = pTD->count; /* Buffer Size */\r
+ USBFS_currentTD.pStatusBlock = pTD->pStatusBlock;\r
+ }\r
+ }\r
+ }\r
+}\r
+\r
+\r
+/*******************************************************************************\r
+* Additional user functions supporting HID Requests\r
+********************************************************************************/\r
+\r
+/* `#START HID_FUNCTIONS` Place any additional functions here */\r
+\r
+/* `#END` */\r
+\r
+#endif /* End USBFS_ENABLE_HID_CLASS */\r
+\r
+\r
+/* [] END OF FILE */\r
--- /dev/null
+/*******************************************************************************\r
+* File Name: USBFS_hid.h\r
+* Version 2.60\r
+*\r
+* Description:\r
+* Header File for the USFS component. Contains prototypes and constant values.\r
+*\r
+********************************************************************************\r
+* Copyright 2008-2013, Cypress Semiconductor Corporation. All rights reserved.\r
+* You may use this file only in accordance with the license, terms, conditions,\r
+* disclaimers, and limitations in the end user license agreement accompanying\r
+* the software package with which this file was provided.\r
+*******************************************************************************/\r
+\r
+#if !defined(CY_USBFS_USBFS_hid_H)\r
+#define CY_USBFS_USBFS_hid_H\r
+\r
+#include "cytypes.h"\r
+\r
+\r
+/***************************************\r
+* Prototypes of the USBFS_hid API.\r
+***************************************/\r
+\r
+uint8 USBFS_UpdateHIDTimer(uint8 interface) ;\r
+uint8 USBFS_GetProtocol(uint8 interface) ;\r
+\r
+\r
+/***************************************\r
+*Renamed Functions for backward compatible\r
+***************************************/\r
+\r
+#define USBFS_bGetProtocol USBFS_GetProtocol\r
+\r
+\r
+/***************************************\r
+* Constants for USBFS_hid API.\r
+***************************************/\r
+\r
+#define USBFS_PROTOCOL_BOOT (0x00u)\r
+#define USBFS_PROTOCOL_REPORT (0x01u)\r
+\r
+/* Request Types (HID Chapter 7.2) */\r
+#define USBFS_HID_GET_REPORT (0x01u)\r
+#define USBFS_HID_GET_IDLE (0x02u)\r
+#define USBFS_HID_GET_PROTOCOL (0x03u)\r
+#define USBFS_HID_SET_REPORT (0x09u)\r
+#define USBFS_HID_SET_IDLE (0x0Au)\r
+#define USBFS_HID_SET_PROTOCOL (0x0Bu)\r
+\r
+/* Descriptor Types (HID Chapter 7.1) */\r
+#define USBFS_DESCR_HID_CLASS (0x21u)\r
+#define USBFS_DESCR_HID_REPORT (0x22u)\r
+#define USBFS_DESCR_HID_PHYSICAL (0x23u)\r
+\r
+/* Report Request Types (HID Chapter 7.2.1) */\r
+#define USBFS_HID_GET_REPORT_INPUT (0x01u)\r
+#define USBFS_HID_GET_REPORT_OUTPUT (0x02u)\r
+#define USBFS_HID_GET_REPORT_FEATURE (0x03u)\r
+\r
+#endif /* End CY_USBFS_USBFS_hid_H */\r
+\r
+\r
+/* [] END OF FILE */\r
--- /dev/null
+/*******************************************************************************\r
+* File Name: USBFS_midi.c\r
+* Version 2.60\r
+*\r
+* Description:\r
+* MIDI Streaming request handler.\r
+* This file contains routines for sending and receiving MIDI\r
+* messages, and handles running status in both directions.\r
+*\r
+********************************************************************************\r
+* Copyright 2008-2013, Cypress Semiconductor Corporation. All rights reserved.\r
+* You may use this file only in accordance with the license, terms, conditions,\r
+* disclaimers, and limitations in the end user license agreement accompanying\r
+* the software package with which this file was provided.\r
+*******************************************************************************/\r
+\r
+#include "USBFS.h"\r
+\r
+#if defined(USBFS_ENABLE_MIDI_STREAMING)\r
+\r
+#include "USBFS_midi.h"\r
+#include "USBFS_pvt.h"\r
+\r
+\r
+/***************************************\r
+* MIDI Constants\r
+***************************************/\r
+\r
+#if (USBFS_MIDI_EXT_MODE >= USBFS_ONE_EXT_INTRF)\r
+ /* The Size of the MIDI messages (MIDI Table 4-1) */\r
+ static const uint8 CYCODE USBFS_MIDI_SIZE[] = {\r
+ /* Miscellaneous function codes(Reserved) */ 0x03u,\r
+ /* Cable events (Reserved) */ 0x03u,\r
+ /* Two-byte System Common messages */ 0x02u,\r
+ /* Three-byte System Common messages */ 0x03u,\r
+ /* SysEx starts or continues */ 0x03u,\r
+ /* Single-byte System Common Message or\r
+ SysEx ends with following single byte */ 0x01u,\r
+ /* SysEx ends with following two bytes */ 0x02u,\r
+ /* SysEx ends with following three bytes */ 0x03u,\r
+ /* Note-off */ 0x03u,\r
+ /* Note-on */ 0x03u,\r
+ /* Poly-KeyPress */ 0x03u,\r
+ /* Control Change */ 0x03u,\r
+ /* Program Change */ 0x02u,\r
+ /* Channel Pressure */ 0x02u,\r
+ /* PitchBend Change */ 0x03u,\r
+ /* Single Byte */ 0x01u\r
+ };\r
+#endif /* USBFS_MIDI_EXT_MODE >= USBFS_ONE_EXT_INTRF */\r
+\r
+\r
+\r
+/***************************************\r
+* Global variables\r
+***************************************/\r
+\r
+#if (USBFS_MIDI_IN_BUFF_SIZE > 0)\r
+ #if (USBFS_MIDI_IN_BUFF_SIZE >= 256)\r
+ volatile uint16 USBFS_midiInPointer; /* Input endpoint buffer pointer */\r
+ #else\r
+ volatile uint8 USBFS_midiInPointer; /* Input endpoint buffer pointer */\r
+ #endif /* End USBFS_MIDI_IN_BUFF_SIZE >=256 */\r
+ volatile uint8 USBFS_midi_in_ep; /* Input endpoint number */\r
+ uint8 USBFS_midiInBuffer[USBFS_MIDI_IN_BUFF_SIZE]; /* Input endpoint buffer */\r
+#endif /* USBFS_MIDI_IN_BUFF_SIZE > 0 */\r
+\r
+#if (USBFS_MIDI_OUT_BUFF_SIZE > 0)\r
+ volatile uint8 USBFS_midi_out_ep; /* Output endpoint number */\r
+ uint8 USBFS_midiOutBuffer[USBFS_MIDI_OUT_BUFF_SIZE]; /* Output endpoint buffer */\r
+#endif /* USBFS_MIDI_OUT_BUFF_SIZE > 0 */\r
+\r
+#if (USBFS_MIDI_EXT_MODE >= USBFS_ONE_EXT_INTRF)\r
+ static USBFS_MIDI_RX_STATUS USBFS_MIDI1_Event; /* MIDI RX status structure */\r
+ static volatile uint8 USBFS_MIDI1_TxRunStat; /* MIDI Output running status */\r
+ volatile uint8 USBFS_MIDI1_InqFlags; /* Device inquiry flag */\r
+\r
+ #if (USBFS_MIDI_EXT_MODE >= USBFS_TWO_EXT_INTRF)\r
+ static USBFS_MIDI_RX_STATUS USBFS_MIDI2_Event; /* MIDI RX status structure */\r
+ static volatile uint8 USBFS_MIDI2_TxRunStat; /* MIDI Output running status */\r
+ volatile uint8 USBFS_MIDI2_InqFlags; /* Device inquiry flag */\r
+ #endif /* End USBFS_MIDI_EXT_MODE >= USBFS_TWO_EXT_INTRF */\r
+#endif /* End USBFS_MIDI_EXT_MODE >= USBFS_ONE_EXT_INTRF */\r
+\r
+\r
+/***************************************\r
+* Custom Declarations\r
+***************************************/\r
+\r
+/* `#START MIDI_CUSTOM_DECLARATIONS` Place your declaration here */\r
+\r
+/* `#END` */\r
+\r
+\r
+/***************************************\r
+* Optional MIDI APIs\r
+***************************************/\r
+#if (USBFS_ENABLE_MIDI_API != 0u)\r
+\r
+\r
+/*******************************************************************************\r
+* Function Name: USBFS_MIDI_EP_Init\r
+********************************************************************************\r
+*\r
+* Summary:\r
+* This function initializes the MIDI interface and UART(s) to be ready to\r
+* receive data from the PC and MIDI ports.\r
+*\r
+* Parameters:\r
+* None\r
+*\r
+* Return:\r
+* None\r
+*\r
+* Global variables:\r
+* USBFS_midiInBuffer: This buffer is used for saving and combining\r
+* the received data from UART(s) and(or) generated internally by\r
+* PutUsbMidiIn() function messages. USBFS_MIDI_IN_EP_Service()\r
+* function transfers the data from this buffer to the PC.\r
+* USBFS_midiOutBuffer: This buffer is used by the\r
+* USBFS_MIDI_OUT_EP_Service() function for saving the received\r
+* from the PC data, then the data are parsed and transferred to UART(s)\r
+* buffer and to the internal processing by the\r
+* USBFS_callbackLocalMidiEvent function.\r
+* USBFS_midi_out_ep: Used as an OUT endpoint number.\r
+* USBFS_midi_in_ep: Used as an IN endpoint number.\r
+* USBFS_midiInPointer: Initialized to zero.\r
+*\r
+* Reentrant:\r
+* No\r
+*\r
+*******************************************************************************/\r
+void USBFS_MIDI_EP_Init(void) \r
+{\r
+ #if (USBFS_MIDI_IN_BUFF_SIZE > 0)\r
+ USBFS_midiInPointer = 0u;\r
+ #endif /* USBFS_MIDI_IN_BUFF_SIZE > 0 */\r
+\r
+ #if(USBFS_EP_MM == USBFS__EP_DMAAUTO)\r
+ #if (USBFS_MIDI_IN_BUFF_SIZE > 0)\r
+ /* Init DMA configurations for IN EP*/\r
+ USBFS_LoadInEP(USBFS_midi_in_ep, USBFS_midiInBuffer,\r
+ USBFS_MIDI_IN_BUFF_SIZE);\r
+ \r
+ #endif /* USBFS_MIDI_IN_BUFF_SIZE > 0 */\r
+ #if (USBFS_MIDI_OUT_BUFF_SIZE > 0)\r
+ /* Init DMA configurations for OUT EP*/\r
+ (void)USBFS_ReadOutEP(USBFS_midi_out_ep, USBFS_midiOutBuffer,\r
+ USBFS_MIDI_OUT_BUFF_SIZE);\r
+ #endif /*USBFS_MIDI_OUT_BUFF_SIZE > 0 */\r
+ #endif /* End USBFS__EP_DMAAUTO */\r
+\r
+ #if (USBFS_MIDI_OUT_BUFF_SIZE > 0)\r
+ USBFS_EnableOutEP(USBFS_midi_out_ep);\r
+ #endif /* USBFS_MIDI_OUT_BUFF_SIZE > 0 */\r
+\r
+ /* Initialize the MIDI port(s) */\r
+ #if (USBFS_MIDI_EXT_MODE >= USBFS_ONE_EXT_INTRF)\r
+ USBFS_MIDI_Init();\r
+ #endif /* USBFS_MIDI_EXT_MODE >= USBFS_ONE_EXT_INTRF */\r
+}\r
+\r
+#if (USBFS_MIDI_OUT_BUFF_SIZE > 0)\r
+\r
+\r
+ /*******************************************************************************\r
+ * Function Name: USBFS_MIDI_OUT_EP_Service\r
+ ********************************************************************************\r
+ *\r
+ * Summary:\r
+ * Services the USB MIDI OUT en