2 * @brief Endpoint declarations and functions for the LPC microcontrollers
\r
5 * Copyright(C) NXP Semiconductors, 2012
\r
6 * All rights reserved.
\r
9 * Software that is described herein is for illustrative purposes only
\r
10 * which provides customers with programming information regarding the
\r
11 * LPC products. This software is supplied "AS IS" without any warranties of
\r
12 * any kind, and NXP Semiconductors and its licensor disclaim any and
\r
13 * all warranties, express or implied, including all implied warranties of
\r
14 * merchantability, fitness for a particular purpose and non-infringement of
\r
15 * intellectual property rights. NXP Semiconductors assumes no responsibility
\r
16 * or liability for the use of the software, conveys no license or rights under any
\r
17 * patent, copyright, mask work right, or any other intellectual property rights in
\r
18 * or to any products. NXP Semiconductors reserves the right to make changes
\r
19 * in the software without notification. NXP Semiconductors also makes no
\r
20 * representation or warranty that such application will be suitable for the
\r
21 * specified use without further testing or modification.
\r
24 * Permission to use, copy, modify, and distribute this software and its
\r
25 * documentation is hereby granted, under NXP Semiconductors' and its
\r
26 * licensor's relevant copyrights in the software, without fee, provided that it
\r
27 * is used in conjunction with NXP Semiconductors microcontrollers. This
\r
28 * copyright, permission, and disclaimer notice must appear in all copies of
\r
32 #define __INCLUDE_FROM_USB_DRIVER
\r
33 #include "USBMode.h"
\r
35 #if defined(USB_CAN_BE_DEVICE)
\r
36 #include "Endpoint.h"
\r
38 #if !defined(FIXED_CONTROL_ENDPOINT_SIZE)
\r
39 uint8_t USB_Device_ControlEndpointSize = ENDPOINT_CONTROLEP_DEFAULT_SIZE;
\r
43 uint8_t usb_data_buffer[MAX_USB_CORE][USB_DATA_BUFFER_TEM_LENGTH] ATTR_ALIGNED(64) __BSS(USBRAM_SECTION);/* TODO 11uxx require buffer is 64 byte aligned */
\r
45 volatile int32_t usb_data_buffer_size[MAX_USB_CORE];
\r
46 volatile uint32_t usb_data_buffer_index[MAX_USB_CORE];
\r
47 uint8_t usb_data_buffer_OUT[MAX_USB_CORE][USB_DATA_BUFFER_TEM_LENGTH] ATTR_ALIGNED(64) __BSS(USBRAM_SECTION);/* TODO 11uxx require buffer is 64 byte aligned */
\r
48 volatile uint32_t usb_data_buffer_OUT_size[MAX_USB_CORE];
\r
49 volatile uint32_t usb_data_buffer_OUT_index[MAX_USB_CORE];
\r
50 uint8_t usb_data_buffer_IN[MAX_USB_CORE][USB_DATA_BUFFER_TEM_LENGTH] ATTR_ALIGNED(64) __BSS(USBRAM_SECTION); /* TODO 11uxx require buffer is 64 byte aligned */
\r
51 volatile uint32_t usb_data_buffer_IN_index[MAX_USB_CORE];
\r
53 uint8_t endpointselected[MAX_USB_CORE];
\r
54 uint8_t endpointhandle0[ENDPOINT_TOTAL_ENDPOINTS0];
\r
55 uint8_t endpointhandle1[ENDPOINT_TOTAL_ENDPOINTS1];
\r
57 bool Endpoint_ConfigureEndpoint_Prv(uint8_t corenum,
\r
58 const uint8_t Number,
\r
59 const uint8_t UECFG0XData,
\r
60 const uint8_t UECFG1XData)
\r
62 #if defined(CONTROL_ONLY_DEVICE) || defined(ORDERED_EP_CONFIG)
\r
63 Endpoint_SelectEndpoint(corenum, Number);
\r
64 Endpoint_EnableEndpoint();
\r
67 // UECFG0X = UECFG0XData;
\r
68 // UECFG1X = UECFG1XData;
\r
70 return Endpoint_IsConfigured();
\r
72 for (uint8_t EPNum = Number; EPNum < ENDPOINT_TOTAL_ENDPOINTS(corenum); EPNum++) {
\r
73 // uint8_t UECFG0XTemp;
\r
74 // uint8_t UECFG1XTemp;
\r
75 // uint8_t UEIENXTemp;
\r
77 Endpoint_SelectEndpoint(corenum, EPNum);
\r
79 if (EPNum == Number) {
\r
80 // UECFG0XTemp = UECFG0XData;
\r
81 // UECFG1XTemp = UECFG1XData;
\r
85 // UECFG0XTemp = UECFG0X;
\r
86 // UECFG1XTemp = UECFG1X;
\r
87 // UEIENXTemp = UEIENX;
\r
90 // if (!(UECFG1XTemp & (1 << ALLOC)))
\r
93 Endpoint_DisableEndpoint();
\r
94 // UECFG1X &= ~(1 << ALLOC);
\r
96 Endpoint_EnableEndpoint();
\r
97 // UECFG0X = UECFG0XTemp;
\r
98 // UECFG1X = UECFG1XTemp;
\r
99 // UEIENX = UEIENXTemp;
\r
101 if (!(Endpoint_IsConfigured())) {
\r
106 Endpoint_SelectEndpoint(corenum, Number);
\r
111 void Endpoint_ClearEndpoints(uint8_t corenum)
\r
115 for (uint8_t EPNum = 0; EPNum < ENDPOINT_TOTAL_ENDPOINTS(corenum); EPNum++) {
\r
116 Endpoint_SelectEndpoint(corenum, EPNum);
\r
120 Endpoint_DisableEndpoint();
\r
124 void Endpoint_ClearStatusStage(uint8_t corenum)
\r
126 if (USB_ControlRequest.bmRequestType & REQDIR_DEVICETOHOST) {
\r
127 Endpoint_ClearOUT(corenum);
\r
130 Endpoint_ClearIN(corenum);
\r
134 #if !defined(CONTROL_ONLY_DEVICE)
\r
135 uint8_t Endpoint_WaitUntilReady(void)
\r
137 return ENDPOINT_READYWAIT_NoError;
\r