Rev 111 | Rev 304 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 111 | Rev 275 | ||
---|---|---|---|
1 | /******************** (C) COPYRIGHT 2006 STMicroelectronics ******************** |
1 | /******************** (C) COPYRIGHT 2008 STMicroelectronics ******************** |
2 | * File Name : usb_prop.c |
2 | * File Name : usb_prop.c |
3 | * Author : MCD Application Team |
3 | * Author : MCD Application Team |
4 | * Date First Issued : 10/01/2006 : V1.0 |
4 | * Date First Issued : 10/01/2008 : V1.0 |
5 | * Description : All processings related to Virtual Com Port Demo |
5 | * Description : All processings related to Virtual Com Port Demo |
6 | ******************************************************************************** |
6 | ******************************************************************************** |
7 | * History: |
7 | * History: |
8 | * 10/01/2006 : V1.0 |
8 | * 10/01/2008 : V1.0 |
9 | ******************************************************************************** |
9 | ******************************************************************************** |
10 | * THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS |
10 | * THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS |
11 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. |
11 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. |
12 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, |
12 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, |
13 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE |
13 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE |
14 | * CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING |
14 | * CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING |
15 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. |
15 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. |
16 | *******************************************************************************/ |
16 | *******************************************************************************/ |
17 | 17 | ||
18 | /* Includes ------------------------------------------------------------------*/ |
18 | /* Includes ------------------------------------------------------------------*/ |
- | 19 | #include "usb.h" |
|
19 | #include "usb_lib.h" |
20 | #include "usb_lib.h" |
- | 21 | #include "usb_conf.h" |
|
- | 22 | #include "usb_prop.h" |
|
20 | #include "usb_desc.h" |
23 | #include "usb_desc.h" |
21 | #include "usb_pwr.h" |
24 | #include "usb_pwr.h" |
22 | #include "usb_prop.h" |
- | |
- | 25 | ||
23 | /* Private typedef -----------------------------------------------------------*/ |
26 | /* Private typedef -----------------------------------------------------------*/ |
24 | /* Private define ------------------------------------------------------------*/ |
27 | /* Private define ------------------------------------------------------------*/ |
25 | /* Private macro -------------------------------------------------------------*/ |
28 | /* Private macro -------------------------------------------------------------*/ |
26 | /* Private variables ---------------------------------------------------------*/ |
29 | /* Private variables ---------------------------------------------------------*/ |
27 | u32 Request = 0; |
30 | u32 Request = 0; |
28 | 31 | ||
29 | LINE_CODING linecoding = |
32 | LINE_CODING linecoding = |
30 | { |
33 | { |
31 | 57600, /* baud rate*/ |
34 | 57600, /* baud rate*/ |
32 | 0x00, /* stop bits-1*/ |
35 | 0x00, /* stop bits-1*/ |
33 | 0x00, /* parity - none*/ |
36 | 0x00, /* parity - none*/ |
34 | 0x08 /* no. of bits 8*/ |
37 | 0x08 /* no. of bits 8*/ |
35 | }; |
38 | }; |
36 | /* -------------------------------------------------------------------------- */ |
39 | /* -------------------------------------------------------------------------- */ |
37 | /* Structures initializations */ |
40 | /* Structures initializations */ |
38 | /* -------------------------------------------------------------------------- */ |
41 | /* -------------------------------------------------------------------------- */ |
39 | 42 | ||
40 | DEVICE Device_Table = { |
43 | DEVICE Device_Table = { |
41 | EP_NUM, |
44 | EP_NUM, |
42 | 1 |
45 | 1 |
43 | }; |
46 | }; |
44 | 47 | ||
45 | DEVICE_PROP Device_Property = { |
48 | DEVICE_PROP Device_Property = { |
46 | Virtual_Com_Port_init, |
49 | Virtual_Com_Port_init, |
47 | Virtual_Com_Port_Reset, |
50 | Virtual_Com_Port_Reset, |
48 | Virtual_Com_Port_Status_In, |
51 | Virtual_Com_Port_Status_In, |
49 | Virtual_Com_Port_Status_Out, |
52 | Virtual_Com_Port_Status_Out, |
50 | Virtual_Com_Port_Data_Setup, |
53 | Virtual_Com_Port_Data_Setup, |
51 | Virtual_Com_Port_NoData_Setup, |
54 | Virtual_Com_Port_NoData_Setup, |
52 | Virtual_Com_Port_Get_Interface_Setting, |
55 | Virtual_Com_Port_Get_Interface_Setting, |
53 | Virtual_Com_Port_GetDeviceDescriptor, |
56 | Virtual_Com_Port_GetDeviceDescriptor, |
54 | Virtual_Com_Port_GetConfigDescriptor, |
57 | Virtual_Com_Port_GetConfigDescriptor, |
55 | Virtual_Com_Port_GetStringDescriptor, |
58 | Virtual_Com_Port_GetStringDescriptor, |
56 | 0, |
59 | 0, |
57 | 0x40 /*MAX PACKET SIZE*/ |
60 | 0x40 /*MAX PACKET SIZE*/ |
58 | }; |
61 | }; |
59 | USER_STANDARD_REQUESTS User_Standard_Requests = { |
62 | USER_STANDARD_REQUESTS User_Standard_Requests = { |
60 | Virtual_Com_Port_GetConfiguration, |
63 | Virtual_Com_Port_GetConfiguration, |
61 | Virtual_Com_Port_SetConfiguration, |
64 | Virtual_Com_Port_SetConfiguration, |
62 | Virtual_Com_Port_GetInterface, |
65 | Virtual_Com_Port_GetInterface, |
63 | Virtual_Com_Port_SetInterface, |
66 | Virtual_Com_Port_SetInterface, |
64 | Virtual_Com_Port_GetStatus, |
67 | Virtual_Com_Port_GetStatus, |
65 | Virtual_Com_Port_ClearFeature, |
68 | Virtual_Com_Port_ClearFeature, |
66 | Virtual_Com_Port_SetEndPointFeature, |
69 | Virtual_Com_Port_SetEndPointFeature, |
67 | Virtual_Com_Port_SetDeviceFeature, |
70 | Virtual_Com_Port_SetDeviceFeature, |
68 | Virtual_Com_Port_SetDeviceAddress |
71 | Virtual_Com_Port_SetDeviceAddress |
69 | }; |
72 | }; |
70 | 73 | ||
71 | ONE_DESCRIPTOR Device_Descriptor = { |
74 | ONE_DESCRIPTOR Device_Descriptor = { |
72 | (u8*)Virtual_Com_Port_DeviceDescriptor, |
- | |
- | 75 | (u8*)Virtual_Com_Port_DeviceDescriptor, |
|
73 | VIRTUAL_COM_PORT_SIZ_DEVICE_DESC |
76 | VIRTUAL_COM_PORT_SIZ_DEVICE_DESC |
74 | }; |
77 | }; |
75 | 78 | ||
76 | ONE_DESCRIPTOR Config_Descriptor = { |
- | |
- | 79 | ONE_DESCRIPTOR Config_Descriptor = { |
|
77 | (u8*)Virtual_Com_Port_ConfigDescriptor, |
80 | (u8*)Virtual_Com_Port_ConfigDescriptor, |
78 | VIRTUAL_COM_PORT_SIZ_CONFIG_DESC |
81 | VIRTUAL_COM_PORT_SIZ_CONFIG_DESC |
79 | }; |
82 | }; |
80 | 83 | ||
81 | ONE_DESCRIPTOR String_Descriptor[5] = { |
84 | ONE_DESCRIPTOR String_Descriptor[5] = { |
82 | {(u8*)Virtual_Com_Port_StringLangID, VIRTUAL_COM_PORT_SIZ_STRING_LANGID}, |
- | |
- | 85 | {(u8*)Virtual_Com_Port_StringLangID, VIRTUAL_COM_PORT_SIZ_STRING_LANGID}, |
|
83 | {(u8*)Virtual_Com_Port_StringVendor, VIRTUAL_COM_PORT_SIZ_STRING_VENDOR}, |
86 | {(u8*)Virtual_Com_Port_StringVendor, VIRTUAL_COM_PORT_SIZ_STRING_VENDOR}, |
84 | {(u8*)Virtual_Com_Port_StringProduct, VIRTUAL_COM_PORT_SIZ_STRING_PRODUCT}, |
87 | {(u8*)Virtual_Com_Port_StringProduct, VIRTUAL_COM_PORT_SIZ_STRING_PRODUCT}, |
85 | {(u8*)Virtual_Com_Port_StringSerial, VIRTUAL_COM_PORT_SIZ_STRING_SERIAL} |
88 | {(u8*)Virtual_Com_Port_StringSerial, VIRTUAL_COM_PORT_SIZ_STRING_SERIAL} |
86 | 89 | ||
87 | }; |
90 | }; |
88 | /* Extern variables ----------------------------------------------------------*/ |
91 | /* Extern variables ----------------------------------------------------------*/ |
89 | /* Private function prototypes -----------------------------------------------*/ |
92 | /* Private function prototypes -----------------------------------------------*/ |
90 | /* Extern function prototypes ------------------------------------------------*/ |
93 | /* Extern function prototypes ------------------------------------------------*/ |
91 | /* Private functions ---------------------------------------------------------*/ |
94 | /* Private functions ---------------------------------------------------------*/ |
92 | /******************************************************************************* |
95 | /******************************************************************************* |
93 | * Function Name : Virtual_Com_Port_init |
96 | * Function Name : Virtual_Com_Port_init |
94 | * Description : Virtual_Com_Port Mouse init routine |
97 | * Description : Virtual_Com_Port Mouse init routine |
95 | * Input : None. |
98 | * Input : None. |
96 | * Output : None. |
99 | * Output : None. |
97 | * Return : None. |
100 | * Return : None. |
98 | *******************************************************************************/ |
101 | *******************************************************************************/ |
99 | void Virtual_Com_Port_init(void) |
102 | void Virtual_Com_Port_init(void) |
100 | { |
103 | { |
101 | u32 timeout = 0; |
- | |
102 | 104 | ||
103 | pInformation->Current_Configuration = 0; |
105 | pInformation->Current_Configuration = 0; |
104 | /* Connect the device */ |
106 | /* Connect the device */ |
105 | PowerOn(); |
107 | PowerOn(); |
106 | /* USB interrupts initialization */ |
108 | /* USB interrupts initialization */ |
107 | _SetISTR(0); /* clear pending interrupts */ |
109 | _SetISTR(0); /* clear pending interrupts */ |
108 | wInterrupt_Mask = IMR_MSK; |
110 | wInterrupt_Mask = IMR_MSK; |
109 | _SetCNTR(wInterrupt_Mask); /* set interrupts mask */ |
111 | _SetCNTR(wInterrupt_Mask); /* set interrupts mask */ |
110 | pInformation->Current_Feature = Virtual_Com_Port_ConfigDescriptor[7]; |
- | |
- | 112 | ||
111 | /* Wait until device is configured */ |
113 | //UART0_Config_Default(); |
112 | while (pInformation->Current_Configuration == 0 && (timeout++<600000)) NOP_Process(); |
- | |
- | 114 | ||
113 | if(pInformation->Current_Configuration !=0) bDeviceState = CONFIGURED; |
115 | bDeviceState = UNCONNECTED; |
114 | } |
116 | } |
115 | /******************************************************************************* |
117 | /******************************************************************************* |
116 | * Function Name : Virtual_Com_Port_Reset |
118 | * Function Name : Virtual_Com_Port_Reset |
117 | * Description : Virtual_Com_Port Mouse reset routine |
119 | * Description : Virtual_Com_Port Mouse reset routine |
118 | * Input : None. |
120 | * Input : None. |
119 | * Output : None. |
121 | * Output : None. |
120 | * Return : None. |
122 | * Return : None. |
121 | *******************************************************************************/ |
123 | *******************************************************************************/ |
122 | void Virtual_Com_Port_Reset(void) |
124 | void Virtual_Com_Port_Reset(void) |
123 | { |
125 | { |
124 | /* Set Virtual_Com_Port_DEVICE as not configured */ |
126 | /* Set Virtual_Com_Port_DEVICE as not configured */ |
125 | pInformation->Current_Configuration = 0; |
127 | pInformation->Current_Configuration = 0; |
126 | pInformation->Current_Interface = 0;/*the default Interface*/ |
128 | pInformation->Current_Interface = 0;/*the default Interface*/ |
- | 129 | ||
- | 130 | /* Current Feature initialization */ |
|
- | 131 | pInformation->Current_Feature = Virtual_Com_Port_ConfigDescriptor[7]; |
|
- | 132 | ||
127 | SetBTABLE(BTABLE_ADDRESS); |
133 | SetBTABLE(BTABLE_ADDRESS); |
128 | 134 | ||
129 | /* Initialize Endpoint 0 */ |
135 | /* Initialize Endpoint 0 */ |
130 | SetEPType(ENDP0, EP_CONTROL); |
136 | SetEPType(ENDP0, EP_CONTROL); |
131 | SetEPTxStatus(ENDP0, EP_TX_STALL); |
137 | SetEPTxStatus(ENDP0, EP_TX_STALL); |
132 | SetEPRxAddr(ENDP0, ENDP0_RXADDR); |
138 | SetEPRxAddr(ENDP0, ENDP0_RXADDR); |
133 | SetEPTxAddr(ENDP0, ENDP0_TXADDR); |
139 | SetEPTxAddr(ENDP0, ENDP0_TXADDR); |
134 | Clear_Status_Out(ENDP0); |
140 | Clear_Status_Out(ENDP0); |
135 | SetEPRxCount(ENDP0, Device_Property.MaxPacketSize); |
141 | SetEPRxCount(ENDP0, Device_Property.MaxPacketSize); |
136 | SetEPRxValid(ENDP0); |
142 | SetEPRxValid(ENDP0); |
137 | 143 | ||
138 | /* Initialize Endpoint 1 */ |
144 | /* Initialize Endpoint 1 */ |
139 | SetEPType(ENDP1, EP_BULK); |
145 | SetEPType(ENDP1, EP_BULK); |
140 | SetEPTxAddr(ENDP1, ENDP1_TXADDR); |
146 | SetEPTxAddr(ENDP1, ENDP1_TXADDR); |
141 | SetEPTxStatus(ENDP1, EP_TX_NAK); |
147 | SetEPTxStatus(ENDP1, EP_TX_NAK); |
142 | SetEPRxStatus(ENDP1, EP_RX_DIS); |
148 | SetEPRxStatus(ENDP1, EP_RX_DIS); |
143 | 149 | ||
144 | /* Initialize Endpoint 2 */ |
150 | /* Initialize Endpoint 2 */ |
145 | SetEPType(ENDP2, EP_INTERRUPT); |
151 | SetEPType(ENDP2, EP_INTERRUPT); |
146 | SetEPTxAddr(ENDP2, ENDP2_TXADDR); |
152 | SetEPTxAddr(ENDP2, ENDP2_TXADDR); |
147 | SetEPRxStatus(ENDP2, EP_RX_DIS); |
153 | SetEPRxStatus(ENDP2, EP_RX_DIS); |
148 | SetEPTxStatus(ENDP2, EP_TX_NAK); |
154 | SetEPTxStatus(ENDP2, EP_TX_NAK); |
149 | 155 | ||
150 | /* Initialize Endpoint 3 */ |
156 | /* Initialize Endpoint 3 */ |
151 | SetEPType(ENDP3, EP_BULK); |
157 | SetEPType(ENDP3, EP_BULK); |
152 | SetEPRxAddr(ENDP3, ENDP3_RXADDR); |
158 | SetEPRxAddr(ENDP3, ENDP3_RXADDR); |
153 | SetEPRxCount(ENDP3, VIRTUAL_COM_PORT_DATA_SIZE); |
159 | SetEPRxCount(ENDP3, VIRTUAL_COM_PORT_DATA_SIZE); |
154 | SetEPRxStatus(ENDP3, EP_RX_VALID); |
160 | SetEPRxStatus(ENDP3, EP_RX_VALID); |
155 | SetEPTxStatus(ENDP3, EP_TX_DIS); |
161 | SetEPTxStatus(ENDP3, EP_TX_DIS); |
156 | 162 | ||
157 | /* Set this device to response on default address */ |
163 | /* Set this device to response on default address */ |
158 | SetDeviceAddress(0); |
164 | SetDeviceAddress(0); |
- | 165 | bDeviceState = ATTACHED; |
|
- | 166 | } |
|
- | 167 | ||
- | 168 | /******************************************************************************* |
|
- | 169 | * Function Name : Virtual_Com_Port_SetConfiguration. |
|
- | 170 | * Description : Udpade the device state to configured. |
|
- | 171 | * Input : None. |
|
- | 172 | * Output : None. |
|
- | 173 | * Return : None. |
|
- | 174 | *******************************************************************************/ |
|
- | 175 | void Virtual_Com_Port_SetConfiguration(void) |
|
- | 176 | { |
|
- | 177 | DEVICE_INFO *pInfo = &Device_Info; |
|
- | 178 | ||
- | 179 | if (pInfo->Current_Configuration != 0) |
|
- | 180 | { |
|
- | 181 | /* Device configured */ |
|
- | 182 | bDeviceState = CONFIGURED; |
|
- | 183 | } |
|
- | 184 | } |
|
- | 185 | /******************************************************************************* |
|
- | 186 | * Function Name : Virtual_Com_Port_SetConfiguration. |
|
- | 187 | * Description : Udpade the device state to addressed. |
|
- | 188 | * Input : None. |
|
- | 189 | * Output : None. |
|
- | 190 | * Return : None. |
|
- | 191 | *******************************************************************************/ |
|
- | 192 | void Virtual_Com_Port_SetDeviceAddress (void) |
|
- | 193 | { |
|
- | 194 | bDeviceState = ADDRESSED; |
|
159 | } |
195 | } |
160 | /******************************************************************************* |
196 | /******************************************************************************* |
161 | * Function Name : Virtual_Com_Port_Status_In |
197 | * Function Name : Virtual_Com_Port_Status_In |
162 | * Description : |
198 | * Description : |
163 | * Input : None. |
199 | * Input : None. |
164 | * Output : None. |
200 | * Output : None. |
165 | * Return : None. |
201 | * Return : None. |
166 | *******************************************************************************/ |
202 | *******************************************************************************/ |
167 | void Virtual_Com_Port_Status_In(void) |
203 | void Virtual_Com_Port_Status_In(void) |
168 | { |
204 | { |
169 | if (Request == SET_LINE_CODING) |
205 | if (Request == SET_LINE_CODING) |
170 | { |
206 | { |
- | 207 | //UART0_Config(); |
|
171 | Request = 0; |
208 | Request = 0; |
172 | } |
209 | } |
173 | } |
210 | } |
174 | /******************************************************************************* |
211 | /******************************************************************************* |
175 | * Function Name : Virtual_Com_Port_Status_Out |
212 | * Function Name : Virtual_Com_Port_Status_Out |
176 | * Description : |
213 | * Description : |
177 | * Input : None. |
214 | * Input : None. |
178 | * Output : None. |
215 | * Output : None. |
179 | * Return : None. |
216 | * Return : None. |
180 | *******************************************************************************/ |
217 | *******************************************************************************/ |
181 | void Virtual_Com_Port_Status_Out (void) |
218 | void Virtual_Com_Port_Status_Out (void) |
182 | { |
- | |
183 | } |
219 | {} |
184 | /******************************************************************************* |
220 | /******************************************************************************* |
185 | * Function Name : Virtual_Com_Port_Data_Setup |
221 | * Function Name : Virtual_Com_Port_Data_Setup |
186 | * Description : handle the data class specific requests |
222 | * Description : handle the data class specific requests |
187 | * Input : Request Nb. |
223 | * Input : Request Nb. |
188 | * Output : None. |
224 | * Output : None. |
189 | * Return : USB_UNSUPPORT or USB_SUCCESS. |
225 | * Return : USB_UNSUPPORT or USB_SUCCESS. |
190 | *******************************************************************************/ |
226 | *******************************************************************************/ |
191 | RESULT Virtual_Com_Port_Data_Setup(u8 RequestNo) |
227 | RESULT Virtual_Com_Port_Data_Setup(u8 RequestNo) |
192 | { |
228 | { |
193 | u8 *(*CopyRoutine)(u16); |
229 | u8 *(*CopyRoutine)(u16); |
194 | 230 | ||
195 | CopyRoutine = NULL; |
231 | CopyRoutine = NULL; |
196 | 232 | ||
197 | if (RequestNo == GET_LINE_CODING) |
233 | if (RequestNo == GET_LINE_CODING) |
198 | { |
234 | { |
199 | if (Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT)) CopyRoutine = Virtual_Com_Port_GetLineCoding; |
235 | if (Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT)) |
- | 236 | CopyRoutine = Virtual_Com_Port_GetLineCoding; |
|
200 | } |
237 | } |
201 | else if (RequestNo == SET_LINE_CODING) |
238 | else if (RequestNo == SET_LINE_CODING) |
202 | { |
239 | { |
203 | if (Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT)) CopyRoutine = Virtual_Com_Port_SetLineCoding; |
240 | if (Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT)) |
- | 241 | CopyRoutine = Virtual_Com_Port_SetLineCoding; |
|
204 | Request = SET_LINE_CODING; |
242 | Request = SET_LINE_CODING; |
205 | } |
243 | } |
- | 244 | ||
206 | if (CopyRoutine == NULL) return USB_UNSUPPORT; |
245 | if (CopyRoutine == NULL) return USB_UNSUPPORT; |
207 | 246 | ||
208 | pInformation->Ctrl_Info.CopyData = CopyRoutine; |
247 | pInformation->Ctrl_Info.CopyData = CopyRoutine; |
209 | pInformation->Ctrl_Info.Usb_wOffset = 0; |
248 | pInformation->Ctrl_Info.Usb_wOffset = 0; |
210 | (*CopyRoutine)(0); |
249 | (*CopyRoutine)(0); |
211 | return USB_SUCCESS; |
250 | return USB_SUCCESS; |
212 | } |
251 | } |
213 | /******************************************************************************* |
252 | /******************************************************************************* |
214 | * Function Name : Virtual_Com_Port_NoData_Setup |
253 | * Function Name : Virtual_Com_Port_NoData_Setup |
215 | * Description : handle the no data class specific requests |
254 | * Description : handle the no data class specific requests |
216 | * Input : Request Nb. |
255 | * Input : Request Nb. |
217 | * Output : None. |
256 | * Output : None. |
218 | * Return : USB_UNSUPPORT or USB_SUCCESS. |
257 | * Return : USB_UNSUPPORT or USB_SUCCESS. |
219 | *******************************************************************************/ |
258 | *******************************************************************************/ |
220 | RESULT Virtual_Com_Port_NoData_Setup(u8 RequestNo) |
259 | RESULT Virtual_Com_Port_NoData_Setup(u8 RequestNo) |
221 | { |
260 | { |
- | 261 | ||
222 | if (Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT)) |
262 | if (Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT)) |
223 | { |
263 | { |
224 | if (RequestNo == SET_COMM_FEATURE) return USB_SUCCESS; |
264 | if (RequestNo == SET_COMM_FEATURE) return USB_SUCCESS; |
225 | else if (RequestNo == SET_CONTROL_LINE_STATE) return USB_SUCCESS; |
265 | else if (RequestNo == SET_CONTROL_LINE_STATE) return USB_SUCCESS; |
226 | } |
266 | } |
- | 267 | ||
227 | return USB_UNSUPPORT; |
268 | return USB_UNSUPPORT; |
228 | } |
269 | } |
229 | /******************************************************************************* |
270 | /******************************************************************************* |
230 | * Function Name : Virtual_Com_Port_GetDeviceDescriptor. |
271 | * Function Name : Virtual_Com_Port_GetDeviceDescriptor. |
231 | * Description : Gets the device descriptor. |
272 | * Description : Gets the device descriptor. |
232 | * Input : Length |
273 | * Input : Length |
233 | * Output : None. |
274 | * Output : None. |
234 | * Return : The address of the device descriptor. |
275 | * Return : The address of the device descriptor. |
235 | *******************************************************************************/ |
276 | *******************************************************************************/ |
236 | u8 *Virtual_Com_Port_GetDeviceDescriptor(u16 Length) |
277 | u8 *Virtual_Com_Port_GetDeviceDescriptor(u16 Length) |
237 | { |
278 | { |
238 | return Standard_GetDescriptorData( Length, &Device_Descriptor ); |
279 | return Standard_GetDescriptorData(Length, &Device_Descriptor); |
239 | } |
280 | } |
240 | /******************************************************************************* |
281 | /******************************************************************************* |
241 | * Function Name : Virtual_Com_Port_GetConfigDescriptor. |
282 | * Function Name : Virtual_Com_Port_GetConfigDescriptor. |
242 | * Description : get the configuration descriptor. |
283 | * Description : get the configuration descriptor. |
243 | * Input : Length |
284 | * Input : Length |
244 | * Output : None. |
285 | * Output : None. |
245 | * Return : The address of the configuration descriptor. |
286 | * Return : The address of the configuration descriptor. |
246 | *******************************************************************************/ |
287 | *******************************************************************************/ |
247 | u8 *Virtual_Com_Port_GetConfigDescriptor(u16 Length) |
288 | u8 *Virtual_Com_Port_GetConfigDescriptor(u16 Length) |
248 | { |
289 | { |
249 | return Standard_GetDescriptorData( Length, &Config_Descriptor ); |
290 | return Standard_GetDescriptorData(Length, &Config_Descriptor); |
250 | } |
291 | } |
251 | /******************************************************************************* |
292 | /******************************************************************************* |
252 | * Function Name : Virtual_Com_Port_GetStringDescriptor |
293 | * Function Name : Virtual_Com_Port_GetStringDescriptor |
253 | * Description : Gets the string descriptors according to the needed index |
294 | * Description : Gets the string descriptors according to the needed index |
254 | * Input : Length |
295 | * Input : Length |
255 | * Output : None. |
296 | * Output : None. |
256 | * Return : The address of the string descriptors. |
297 | * Return : The address of the string descriptors. |
257 | *******************************************************************************/ |
298 | *******************************************************************************/ |
258 | u8 *Virtual_Com_Port_GetStringDescriptor(u16 Length) |
299 | u8 *Virtual_Com_Port_GetStringDescriptor(u16 Length) |
259 | { |
300 | { |
260 | u8 wValue0 = pInformation->USBwValue0; |
301 | u8 wValue0 = pInformation->USBwValue0; |
- | 302 | ||
- | 303 | if (wValue0 > 5) |
|
- | 304 | { |
|
- | 305 | return NULL; |
|
- | 306 | } |
|
- | 307 | else |
|
- | 308 | { |
|
261 | return Standard_GetDescriptorData( Length, &String_Descriptor[wValue0] ); |
309 | return Standard_GetDescriptorData(Length, &String_Descriptor[wValue0]); |
- | 310 | } |
|
262 | } |
311 | } |
263 | /******************************************************************************* |
312 | /******************************************************************************* |
264 | * Function Name : Virtual_Com_Port_Get_Interface_Setting. |
313 | * Function Name : Virtual_Com_Port_Get_Interface_Setting. |
265 | * Description : test the interface and the alternate setting according to the |
314 | * Description : test the interface and the alternate setting according to the |
266 | * supported one. |
315 | * supported one. |
267 | * Input1 : u8: Interface : interface number. |
316 | * Input1 : u8: Interface : interface number. |
268 | * Input2 : u8: AlternateSetting : Alternate Setting number. |
317 | * Input2 : u8: AlternateSetting : Alternate Setting number. |
269 | * Output : None. |
318 | * Output : None. |
270 | * Return : The address of the string descriptors. |
319 | * Return : The address of the string descriptors. |
271 | *******************************************************************************/ |
320 | *******************************************************************************/ |
272 | RESULT Virtual_Com_Port_Get_Interface_Setting(u8 Interface,u8 AlternateSetting) |
321 | RESULT Virtual_Com_Port_Get_Interface_Setting(u8 Interface, u8 AlternateSetting) |
273 | { |
322 | { |
- | 323 | if (AlternateSetting > 0) |
|
- | 324 | { |
|
274 | if(AlternateSetting >0) return USB_UNSUPPORT; |
325 | return USB_UNSUPPORT; |
- | 326 | } |
|
- | 327 | else if (Interface > 1) |
|
- | 328 | { |
|
275 | else if(Interface > 1) return USB_UNSUPPORT; |
329 | return USB_UNSUPPORT; |
- | 330 | } |
|
276 | return USB_SUCCESS; |
331 | return USB_SUCCESS; |
277 | } |
332 | } |
278 | /******************************************************************************* |
333 | /******************************************************************************* |
279 | * Function Name : Virtual_Com_Port_GetLineCoding. |
334 | * Function Name : Virtual_Com_Port_GetLineCoding. |
280 | * Description : send the linecoding structure to the PC host. |
335 | * Description : send the linecoding structure to the PC host. |
281 | * Input : Length |
336 | * Input : Length |
282 | * Output : None. |
337 | * Output : None. |
283 | * Return : Inecoding structure base address. |
338 | * Return : Inecoding structure base address. |
284 | *******************************************************************************/ |
339 | *******************************************************************************/ |
285 | u8 *Virtual_Com_Port_GetLineCoding(u16 Length) |
340 | u8 *Virtual_Com_Port_GetLineCoding(u16 Length) |
286 | { |
341 | { |
287 | if(Length==0) |
342 | if (Length == 0) |
288 | { |
343 | { |
289 | pInformation->Ctrl_Info.Usb_wLength = sizeof(linecoding);; |
344 | pInformation->Ctrl_Info.Usb_wLength = sizeof(linecoding); |
290 | return NULL; |
345 | return NULL; |
291 | } |
346 | } |
292 | return(u8 *)&linecoding; |
347 | return(u8 *)&linecoding; |
293 | } |
348 | } |
294 | /******************************************************************************* |
349 | /******************************************************************************* |
295 | * Function Name : Virtual_Com_Port_SetLineCoding. |
350 | * Function Name : Virtual_Com_Port_SetLineCoding. |
296 | * Description : Set the linecoding structure fields. |
351 | * Description : Set the linecoding structure fields. |
297 | * Input : Length |
352 | * Input : Length |
298 | * Output : None |
353 | * Output : None |
299 | * Return : Linecoding structure base address. |
354 | * Return : Linecoding structure base address. |
300 | *******************************************************************************/ |
355 | *******************************************************************************/ |
301 | u8 *Virtual_Com_Port_SetLineCoding(u16 Length) |
356 | u8 *Virtual_Com_Port_SetLineCoding(u16 Length) |
302 | { |
357 | { |
303 | if(Length==0) |
358 | if (Length == 0) |
304 | { |
359 | { |
305 | pInformation->Ctrl_Info.Usb_wLength = sizeof(linecoding);; |
360 | pInformation->Ctrl_Info.Usb_wLength = sizeof(linecoding); |
306 | return NULL; |
361 | return NULL; |
307 | } |
362 | } |
308 | return(u8 *)&linecoding; |
363 | return(u8 *)&linecoding; |
309 | } |
364 | } |
310 | 365 | ||
311 | /******************* (C) COPYRIGHT 2006 STMicroelectronics *****END OF FILE****/ |
366 | /******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/ |
312 | 367 | ||
313 | 368 | ||
314 | 369 |