]> git.sur5r.net Git - freertos/blob
66d3fecce46d4e67cb437d4cbd8a773c834371cd
[freertos] /
1 /*\r
2  * @brief Endpoint declarations and functions for the LPC microcontrollers\r
3  *\r
4  * @note\r
5  * Copyright(C) NXP Semiconductors, 2012\r
6  * All rights reserved.\r
7  *\r
8  * @par\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
22  *\r
23  * @par\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
29  * this code.\r
30  */\r
31 \r
32 #define  __INCLUDE_FROM_USB_DRIVER\r
33 #include "USBMode.h"\r
34 \r
35 #if defined(USB_CAN_BE_DEVICE)\r
36 #include "Endpoint.h"\r
37 \r
38 #if !defined(FIXED_CONTROL_ENDPOINT_SIZE)\r
39 uint8_t USB_Device_ControlEndpointSize = ENDPOINT_CONTROLEP_DEFAULT_SIZE;\r
40 #endif\r
41 \r
42 PRAGMA_ALIGN_64\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
44 \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
52 \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
56 \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
61 {\r
62 #if defined(CONTROL_ONLY_DEVICE) || defined(ORDERED_EP_CONFIG)\r
63         Endpoint_SelectEndpoint(corenum, Number);\r
64         Endpoint_EnableEndpoint();\r
65 \r
66         //      UECFG1X = 0;\r
67         //      UECFG0X = UECFG0XData;\r
68         //      UECFG1X = UECFG1XData;\r
69 \r
70         return Endpoint_IsConfigured();\r
71 #else\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
76 \r
77                 Endpoint_SelectEndpoint(corenum, EPNum);\r
78 \r
79                 if (EPNum == Number) {\r
80                         //                      UECFG0XTemp = UECFG0XData;\r
81                         //                      UECFG1XTemp = UECFG1XData;\r
82                         //                      UEIENXTemp  = 0;\r
83                 }\r
84                 else {\r
85                         //                      UECFG0XTemp = UECFG0X;\r
86                         //                      UECFG1XTemp = UECFG1X;\r
87                         //                      UEIENXTemp  = UEIENX;\r
88                 }\r
89 \r
90                 //              if (!(UECFG1XTemp & (1 << ALLOC)))\r
91                 //                continue;\r
92 \r
93                 Endpoint_DisableEndpoint();\r
94                 //              UECFG1X &= ~(1 << ALLOC);\r
95 \r
96                 Endpoint_EnableEndpoint();\r
97                 //              UECFG0X = UECFG0XTemp;\r
98                 //              UECFG1X = UECFG1XTemp;\r
99                 //              UEIENX  = UEIENXTemp;\r
100 \r
101                 if (!(Endpoint_IsConfigured())) {\r
102                         return false;\r
103                 }\r
104         }\r
105 \r
106         Endpoint_SelectEndpoint(corenum, Number);\r
107         return true;\r
108 #endif\r
109 }\r
110 \r
111 void Endpoint_ClearEndpoints(uint8_t corenum)\r
112 {\r
113         //      UEINT = 0;\r
114 \r
115         for (uint8_t EPNum = 0; EPNum < ENDPOINT_TOTAL_ENDPOINTS(corenum); EPNum++) {\r
116                 Endpoint_SelectEndpoint(corenum, EPNum);\r
117                 //              UEIENX  = 0;\r
118                 //              UEINTX  = 0;\r
119                 //              UECFG1X = 0;\r
120                 Endpoint_DisableEndpoint();\r
121         }\r
122 }\r
123 \r
124 void Endpoint_ClearStatusStage(uint8_t corenum)\r
125 {\r
126         if (USB_ControlRequest.bmRequestType & REQDIR_DEVICETOHOST) {\r
127                 Endpoint_ClearOUT(corenum);\r
128         }\r
129         else {\r
130                 Endpoint_ClearIN(corenum);\r
131         }\r
132 }\r
133 \r
134 #if !defined(CONTROL_ONLY_DEVICE)\r
135 uint8_t Endpoint_WaitUntilReady(void)\r
136 {\r
137         return ENDPOINT_READYWAIT_NoError;\r
138 }\r
139 \r
140 #endif\r
141 \r
142 #endif\r