Rev 110 | Rev 275 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 110 | Rev 111 | ||
---|---|---|---|
1 | /******************** (C) COPYRIGHT 2006 STMicroelectronics ******************** |
1 | /******************** (C) COPYRIGHT 2006 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/2006 : 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/2006 : 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_lib.h" |
19 | #include "usb_lib.h" |
20 | #include "usb_desc.h" |
20 | #include "usb_desc.h" |
21 | #include "usb_pwr.h" |
21 | #include "usb_pwr.h" |
22 | #include "usb_prop.h" |
22 | #include "usb_prop.h" |
23 | /* Private typedef -----------------------------------------------------------*/ |
23 | /* Private typedef -----------------------------------------------------------*/ |
24 | /* Private define ------------------------------------------------------------*/ |
24 | /* Private define ------------------------------------------------------------*/ |
25 | /* Private macro -------------------------------------------------------------*/ |
25 | /* Private macro -------------------------------------------------------------*/ |
26 | /* Private variables ---------------------------------------------------------*/ |
26 | /* Private variables ---------------------------------------------------------*/ |
27 | u32 Request = 0; |
27 | u32 Request = 0; |
28 | 28 | ||
29 | LINE_CODING linecoding = |
29 | LINE_CODING linecoding = |
30 | { |
30 | { |
31 | 57600, /* baud rate*/ |
31 | 57600, /* baud rate*/ |
32 | 0x00, /* stop bits-1*/ |
32 | 0x00, /* stop bits-1*/ |
33 | 0x00, /* parity - none*/ |
33 | 0x00, /* parity - none*/ |
34 | 0x08 /* no. of bits 8*/ |
34 | 0x08 /* no. of bits 8*/ |
35 | }; |
35 | }; |
36 | /* -------------------------------------------------------------------------- */ |
36 | /* -------------------------------------------------------------------------- */ |
37 | /* Structures initializations */ |
37 | /* Structures initializations */ |
38 | /* -------------------------------------------------------------------------- */ |
38 | /* -------------------------------------------------------------------------- */ |
39 | 39 | ||
40 | DEVICE Device_Table = { |
40 | DEVICE Device_Table = { |
41 | EP_NUM, |
41 | EP_NUM, |
42 | 1 |
42 | 1 |
43 | }; |
43 | }; |
44 | 44 | ||
45 | DEVICE_PROP Device_Property = { |
45 | DEVICE_PROP Device_Property = { |
46 | Virtual_Com_Port_init, |
46 | Virtual_Com_Port_init, |
47 | Virtual_Com_Port_Reset, |
47 | Virtual_Com_Port_Reset, |
48 | Virtual_Com_Port_Status_In, |
48 | Virtual_Com_Port_Status_In, |
49 | Virtual_Com_Port_Status_Out, |
49 | Virtual_Com_Port_Status_Out, |
50 | Virtual_Com_Port_Data_Setup, |
50 | Virtual_Com_Port_Data_Setup, |
51 | Virtual_Com_Port_NoData_Setup, |
51 | Virtual_Com_Port_NoData_Setup, |
52 | Virtual_Com_Port_Get_Interface_Setting, |
52 | Virtual_Com_Port_Get_Interface_Setting, |
53 | Virtual_Com_Port_GetDeviceDescriptor, |
53 | Virtual_Com_Port_GetDeviceDescriptor, |
54 | Virtual_Com_Port_GetConfigDescriptor, |
54 | Virtual_Com_Port_GetConfigDescriptor, |
55 | Virtual_Com_Port_GetStringDescriptor, |
55 | Virtual_Com_Port_GetStringDescriptor, |
56 | 0, |
56 | 0, |
57 | 0x40 /*MAX PACKET SIZE*/ |
57 | 0x40 /*MAX PACKET SIZE*/ |
58 | }; |
58 | }; |
59 | USER_STANDARD_REQUESTS User_Standard_Requests = { |
59 | USER_STANDARD_REQUESTS User_Standard_Requests = { |
60 | Virtual_Com_Port_GetConfiguration, |
60 | Virtual_Com_Port_GetConfiguration, |
61 | Virtual_Com_Port_SetConfiguration, |
61 | Virtual_Com_Port_SetConfiguration, |
62 | Virtual_Com_Port_GetInterface, |
62 | Virtual_Com_Port_GetInterface, |
63 | Virtual_Com_Port_SetInterface, |
63 | Virtual_Com_Port_SetInterface, |
64 | Virtual_Com_Port_GetStatus, |
64 | Virtual_Com_Port_GetStatus, |
65 | Virtual_Com_Port_ClearFeature, |
65 | Virtual_Com_Port_ClearFeature, |
66 | Virtual_Com_Port_SetEndPointFeature, |
66 | Virtual_Com_Port_SetEndPointFeature, |
67 | Virtual_Com_Port_SetDeviceFeature, |
67 | Virtual_Com_Port_SetDeviceFeature, |
68 | Virtual_Com_Port_SetDeviceAddress |
68 | Virtual_Com_Port_SetDeviceAddress |
69 | }; |
69 | }; |
70 | 70 | ||
71 | ONE_DESCRIPTOR Device_Descriptor = { |
71 | ONE_DESCRIPTOR Device_Descriptor = { |
72 | (u8*)Virtual_Com_Port_DeviceDescriptor, |
72 | (u8*)Virtual_Com_Port_DeviceDescriptor, |
73 | VIRTUAL_COM_PORT_SIZ_DEVICE_DESC |
73 | VIRTUAL_COM_PORT_SIZ_DEVICE_DESC |
74 | }; |
74 | }; |
75 | 75 | ||
76 | ONE_DESCRIPTOR Config_Descriptor = { |
76 | ONE_DESCRIPTOR Config_Descriptor = { |
77 | (u8*)Virtual_Com_Port_ConfigDescriptor, |
77 | (u8*)Virtual_Com_Port_ConfigDescriptor, |
78 | VIRTUAL_COM_PORT_SIZ_CONFIG_DESC |
78 | VIRTUAL_COM_PORT_SIZ_CONFIG_DESC |
79 | }; |
79 | }; |
80 | 80 | ||
81 | ONE_DESCRIPTOR String_Descriptor[5] = { |
81 | ONE_DESCRIPTOR String_Descriptor[5] = { |
82 | {(u8*)Virtual_Com_Port_StringLangID, VIRTUAL_COM_PORT_SIZ_STRING_LANGID}, |
82 | {(u8*)Virtual_Com_Port_StringLangID, VIRTUAL_COM_PORT_SIZ_STRING_LANGID}, |
83 | {(u8*)Virtual_Com_Port_StringVendor, VIRTUAL_COM_PORT_SIZ_STRING_VENDOR}, |
83 | {(u8*)Virtual_Com_Port_StringVendor, VIRTUAL_COM_PORT_SIZ_STRING_VENDOR}, |
84 | {(u8*)Virtual_Com_Port_StringProduct, VIRTUAL_COM_PORT_SIZ_STRING_PRODUCT}, |
84 | {(u8*)Virtual_Com_Port_StringProduct, VIRTUAL_COM_PORT_SIZ_STRING_PRODUCT}, |
85 | {(u8*)Virtual_Com_Port_StringSerial, VIRTUAL_COM_PORT_SIZ_STRING_SERIAL} |
85 | {(u8*)Virtual_Com_Port_StringSerial, VIRTUAL_COM_PORT_SIZ_STRING_SERIAL} |
86 | 86 | ||
87 | }; |
87 | }; |
88 | /* Extern variables ----------------------------------------------------------*/ |
88 | /* Extern variables ----------------------------------------------------------*/ |
89 | /* Private function prototypes -----------------------------------------------*/ |
89 | /* Private function prototypes -----------------------------------------------*/ |
90 | /* Extern function prototypes ------------------------------------------------*/ |
90 | /* Extern function prototypes ------------------------------------------------*/ |
91 | /* Private functions ---------------------------------------------------------*/ |
91 | /* Private functions ---------------------------------------------------------*/ |
92 | /******************************************************************************* |
92 | /******************************************************************************* |
93 | * Function Name : Virtual_Com_Port_init |
93 | * Function Name : Virtual_Com_Port_init |
94 | * Description : Virtual_Com_Port Mouse init routine |
94 | * Description : Virtual_Com_Port Mouse init routine |
95 | * Input : None. |
95 | * Input : None. |
96 | * Output : None. |
96 | * Output : None. |
97 | * Return : None. |
97 | * Return : None. |
98 | *******************************************************************************/ |
98 | *******************************************************************************/ |
99 | void Virtual_Com_Port_init(void) |
99 | void Virtual_Com_Port_init(void) |
100 | { |
100 | { |
101 | u32 timeout = 0; |
101 | u32 timeout = 0; |
102 | //SerialPutString(".vcpi."); |
- | |
- | 102 | ||
103 | pInformation->Current_Configuration = 0; |
103 | pInformation->Current_Configuration = 0; |
104 | /* Connect the device */ |
104 | /* Connect the device */ |
105 | PowerOn(); |
105 | PowerOn(); |
106 | /* USB interrupts initialization */ |
106 | /* USB interrupts initialization */ |
107 | _SetISTR(0); /* clear pending interrupts */ |
107 | _SetISTR(0); /* clear pending interrupts */ |
108 | wInterrupt_Mask = IMR_MSK; |
108 | wInterrupt_Mask = IMR_MSK; |
109 | _SetCNTR(wInterrupt_Mask); /* set interrupts mask */ |
109 | _SetCNTR(wInterrupt_Mask); /* set interrupts mask */ |
110 | pInformation->Current_Feature = Virtual_Com_Port_ConfigDescriptor[7]; |
110 | pInformation->Current_Feature = Virtual_Com_Port_ConfigDescriptor[7]; |
111 | /* Wait until device is configured */ |
111 | /* Wait until device is configured */ |
112 | // UART0_Config_Default(); |
- | |
113 | //UART1_PutString("..."); |
- | |
114 | while (pInformation->Current_Configuration == 0 && (timeout++<600000)) NOP_Process(); |
112 | while (pInformation->Current_Configuration == 0 && (timeout++<600000)) NOP_Process(); |
115 | if(pInformation->Current_Configuration !=0) bDeviceState = CONFIGURED; |
113 | if(pInformation->Current_Configuration !=0) bDeviceState = CONFIGURED; |
116 | //UART1_PutString(".done."); |
- | |
117 | } |
114 | } |
118 | /******************************************************************************* |
115 | /******************************************************************************* |
119 | * Function Name : Virtual_Com_Port_Reset |
116 | * Function Name : Virtual_Com_Port_Reset |
120 | * Description : Virtual_Com_Port Mouse reset routine |
117 | * Description : Virtual_Com_Port Mouse reset routine |
121 | * Input : None. |
118 | * Input : None. |
122 | * Output : None. |
119 | * Output : None. |
123 | * Return : None. |
120 | * Return : None. |
124 | *******************************************************************************/ |
121 | *******************************************************************************/ |
125 | void Virtual_Com_Port_Reset(void) |
122 | void Virtual_Com_Port_Reset(void) |
126 | { |
123 | { |
127 | /* Set Virtual_Com_Port_DEVICE as not configured */ |
124 | /* Set Virtual_Com_Port_DEVICE as not configured */ |
128 | pInformation->Current_Configuration = 0; |
125 | pInformation->Current_Configuration = 0; |
129 | pInformation->Current_Interface = 0;/*the default Interface*/ |
126 | pInformation->Current_Interface = 0;/*the default Interface*/ |
130 | SetBTABLE(BTABLE_ADDRESS); |
127 | SetBTABLE(BTABLE_ADDRESS); |
131 | 128 | ||
132 | /* Initialize Endpoint 0 */ |
129 | /* Initialize Endpoint 0 */ |
133 | SetEPType(ENDP0, EP_CONTROL); |
130 | SetEPType(ENDP0, EP_CONTROL); |
134 | SetEPTxStatus(ENDP0, EP_TX_STALL); |
131 | SetEPTxStatus(ENDP0, EP_TX_STALL); |
135 | SetEPRxAddr(ENDP0, ENDP0_RXADDR); |
132 | SetEPRxAddr(ENDP0, ENDP0_RXADDR); |
136 | SetEPTxAddr(ENDP0, ENDP0_TXADDR); |
133 | SetEPTxAddr(ENDP0, ENDP0_TXADDR); |
137 | Clear_Status_Out(ENDP0); |
134 | Clear_Status_Out(ENDP0); |
138 | SetEPRxCount(ENDP0, Device_Property.MaxPacketSize); |
135 | SetEPRxCount(ENDP0, Device_Property.MaxPacketSize); |
139 | SetEPRxValid(ENDP0); |
136 | SetEPRxValid(ENDP0); |
140 | 137 | ||
141 | /* Initialize Endpoint 1 */ |
138 | /* Initialize Endpoint 1 */ |
142 | SetEPType(ENDP1, EP_BULK); |
139 | SetEPType(ENDP1, EP_BULK); |
143 | SetEPTxAddr(ENDP1, ENDP1_TXADDR); |
140 | SetEPTxAddr(ENDP1, ENDP1_TXADDR); |
144 | SetEPTxStatus(ENDP1, EP_TX_NAK); |
141 | SetEPTxStatus(ENDP1, EP_TX_NAK); |
145 | SetEPRxStatus(ENDP1, EP_RX_DIS); |
142 | SetEPRxStatus(ENDP1, EP_RX_DIS); |
146 | 143 | ||
147 | /* Initialize Endpoint 2 */ |
144 | /* Initialize Endpoint 2 */ |
148 | SetEPType(ENDP2, EP_INTERRUPT); |
145 | SetEPType(ENDP2, EP_INTERRUPT); |
149 | SetEPTxAddr(ENDP2, ENDP2_TXADDR); |
146 | SetEPTxAddr(ENDP2, ENDP2_TXADDR); |
150 | SetEPRxStatus(ENDP2, EP_RX_DIS); |
147 | SetEPRxStatus(ENDP2, EP_RX_DIS); |
151 | SetEPTxStatus(ENDP2, EP_TX_NAK); |
148 | SetEPTxStatus(ENDP2, EP_TX_NAK); |
152 | 149 | ||
153 | /* Initialize Endpoint 3 */ |
150 | /* Initialize Endpoint 3 */ |
154 | SetEPType(ENDP3, EP_BULK); |
151 | SetEPType(ENDP3, EP_BULK); |
155 | SetEPRxAddr(ENDP3, ENDP3_RXADDR); |
152 | SetEPRxAddr(ENDP3, ENDP3_RXADDR); |
156 | SetEPRxCount(ENDP3, VIRTUAL_COM_PORT_DATA_SIZE); |
153 | SetEPRxCount(ENDP3, VIRTUAL_COM_PORT_DATA_SIZE); |
157 | SetEPRxStatus(ENDP3, EP_RX_VALID); |
154 | SetEPRxStatus(ENDP3, EP_RX_VALID); |
158 | SetEPTxStatus(ENDP3, EP_TX_DIS); |
155 | SetEPTxStatus(ENDP3, EP_TX_DIS); |
159 | 156 | ||
160 | /* Set this device to response on default address */ |
157 | /* Set this device to response on default address */ |
161 | SetDeviceAddress(0); |
158 | SetDeviceAddress(0); |
162 | } |
159 | } |
163 | /******************************************************************************* |
160 | /******************************************************************************* |
164 | * Function Name : Virtual_Com_Port_Status_In |
161 | * Function Name : Virtual_Com_Port_Status_In |
165 | * Description : |
162 | * Description : |
166 | * Input : None. |
163 | * Input : None. |
167 | * Output : None. |
164 | * Output : None. |
168 | * Return : None. |
165 | * Return : None. |
169 | *******************************************************************************/ |
166 | *******************************************************************************/ |
170 | void Virtual_Com_Port_Status_In(void) |
167 | void Virtual_Com_Port_Status_In(void) |
171 | { |
168 | { |
172 | if (Request == SET_LINE_CODING){ |
169 | if (Request == SET_LINE_CODING) |
173 | // UART0_Config(); |
170 | { |
174 | Request = 0; |
171 | Request = 0; |
175 | } |
172 | } |
176 | } |
173 | } |
177 | /******************************************************************************* |
174 | /******************************************************************************* |
178 | * Function Name : Virtual_Com_Port_Status_Out |
175 | * Function Name : Virtual_Com_Port_Status_Out |
179 | * Description : |
176 | * Description : |
180 | * Input : None. |
177 | * Input : None. |
181 | * Output : None. |
178 | * Output : None. |
182 | * Return : None. |
179 | * Return : None. |
183 | *******************************************************************************/ |
180 | *******************************************************************************/ |
184 | void Virtual_Com_Port_Status_Out (void) |
181 | void Virtual_Com_Port_Status_Out (void) |
185 | { |
182 | { |
186 | } |
183 | } |
187 | /******************************************************************************* |
184 | /******************************************************************************* |
188 | * Function Name : Virtual_Com_Port_Data_Setup |
185 | * Function Name : Virtual_Com_Port_Data_Setup |
189 | * Description : handle the data class specific requests |
186 | * Description : handle the data class specific requests |
190 | * Input : Request Nb. |
187 | * Input : Request Nb. |
191 | * Output : None. |
188 | * Output : None. |
192 | * Return : USB_UNSUPPORT or USB_SUCCESS. |
189 | * Return : USB_UNSUPPORT or USB_SUCCESS. |
193 | *******************************************************************************/ |
190 | *******************************************************************************/ |
194 | RESULT Virtual_Com_Port_Data_Setup(u8 RequestNo) |
191 | RESULT Virtual_Com_Port_Data_Setup(u8 RequestNo) |
195 | { |
192 | { |
196 | u8 *(*CopyRoutine)(u16); |
193 | u8 *(*CopyRoutine)(u16); |
197 | 194 | ||
198 | CopyRoutine = NULL; |
195 | CopyRoutine = NULL; |
199 | 196 | ||
- | 197 | if (RequestNo == GET_LINE_CODING) |
|
200 | if (RequestNo == GET_LINE_CODING) { |
198 | { |
- | 199 | if (Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT)) CopyRoutine = Virtual_Com_Port_GetLineCoding; |
|
- | 200 | } |
|
- | 201 | else if (RequestNo == SET_LINE_CODING) |
|
201 | if (Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT)) |
202 | { |
- | 203 | if (Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT)) CopyRoutine = Virtual_Com_Port_SetLineCoding; |
|
202 | CopyRoutine = Virtual_Com_Port_GetLineCoding; |
204 | Request = SET_LINE_CODING; |
203 | } |
- | |
204 | else if (RequestNo == SET_LINE_CODING) { |
- | |
205 | if (Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT)) |
- | |
206 | CopyRoutine = Virtual_Com_Port_SetLineCoding; |
- | |
207 | Request = SET_LINE_CODING; |
- | |
208 | } |
- | |
209 | 205 | } |
|
210 | if (CopyRoutine == NULL) return USB_UNSUPPORT; |
206 | if (CopyRoutine == NULL) return USB_UNSUPPORT; |
211 | 207 | ||
212 | pInformation->Ctrl_Info.CopyData = CopyRoutine; |
208 | pInformation->Ctrl_Info.CopyData = CopyRoutine; |
213 | pInformation->Ctrl_Info.Usb_wOffset = 0; |
209 | pInformation->Ctrl_Info.Usb_wOffset = 0; |
214 | (*CopyRoutine)(0); |
210 | (*CopyRoutine)(0); |
215 | return USB_SUCCESS; |
211 | return USB_SUCCESS; |
216 | } |
212 | } |
217 | /******************************************************************************* |
213 | /******************************************************************************* |
218 | * Function Name : Virtual_Com_Port_NoData_Setup |
214 | * Function Name : Virtual_Com_Port_NoData_Setup |
219 | * Description : handle the no data class specific requests |
215 | * Description : handle the no data class specific requests |
220 | * Input : Request Nb. |
216 | * Input : Request Nb. |
221 | * Output : None. |
217 | * Output : None. |
222 | * Return : USB_UNSUPPORT or USB_SUCCESS. |
218 | * Return : USB_UNSUPPORT or USB_SUCCESS. |
223 | *******************************************************************************/ |
219 | *******************************************************************************/ |
224 | RESULT Virtual_Com_Port_NoData_Setup(u8 RequestNo) |
220 | RESULT Virtual_Com_Port_NoData_Setup(u8 RequestNo) |
225 | { |
221 | { |
226 | - | ||
227 | if (Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT)) |
222 | if (Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT)) |
228 | { |
223 | { |
229 | if (RequestNo == SET_COMM_FEATURE) return USB_SUCCESS; |
224 | if (RequestNo == SET_COMM_FEATURE) return USB_SUCCESS; |
230 | else if (RequestNo == SET_CONTROL_LINE_STATE) return USB_SUCCESS; |
225 | else if (RequestNo == SET_CONTROL_LINE_STATE) return USB_SUCCESS; |
231 | } |
226 | } |
232 | - | ||
233 | return USB_UNSUPPORT; |
227 | return USB_UNSUPPORT; |
234 | } |
228 | } |
235 | /******************************************************************************* |
229 | /******************************************************************************* |
236 | * Function Name : Virtual_Com_Port_GetDeviceDescriptor. |
230 | * Function Name : Virtual_Com_Port_GetDeviceDescriptor. |
237 | * Description : Gets the device descriptor. |
231 | * Description : Gets the device descriptor. |
238 | * Input : Length |
232 | * Input : Length |
239 | * Output : None. |
233 | * Output : None. |
240 | * Return : The address of the device descriptor. |
234 | * Return : The address of the device descriptor. |
241 | *******************************************************************************/ |
235 | *******************************************************************************/ |
242 | u8 *Virtual_Com_Port_GetDeviceDescriptor(u16 Length) |
236 | u8 *Virtual_Com_Port_GetDeviceDescriptor(u16 Length) |
243 | { |
237 | { |
244 | return Standard_GetDescriptorData( Length, &Device_Descriptor ); |
238 | return Standard_GetDescriptorData( Length, &Device_Descriptor ); |
245 | } |
239 | } |
246 | /******************************************************************************* |
240 | /******************************************************************************* |
247 | * Function Name : Virtual_Com_Port_GetConfigDescriptor. |
241 | * Function Name : Virtual_Com_Port_GetConfigDescriptor. |
248 | * Description : get the configuration descriptor. |
242 | * Description : get the configuration descriptor. |
249 | * Input : Length |
243 | * Input : Length |
250 | * Output : None. |
244 | * Output : None. |
251 | * Return : The address of the configuration descriptor. |
245 | * Return : The address of the configuration descriptor. |
252 | *******************************************************************************/ |
246 | *******************************************************************************/ |
253 | u8 *Virtual_Com_Port_GetConfigDescriptor(u16 Length) |
247 | u8 *Virtual_Com_Port_GetConfigDescriptor(u16 Length) |
254 | { |
248 | { |
255 | return Standard_GetDescriptorData( Length, &Config_Descriptor ); |
249 | return Standard_GetDescriptorData( Length, &Config_Descriptor ); |
256 | } |
250 | } |
257 | /******************************************************************************* |
251 | /******************************************************************************* |
258 | * Function Name : Virtual_Com_Port_GetStringDescriptor |
252 | * Function Name : Virtual_Com_Port_GetStringDescriptor |
259 | * Description : Gets the string descriptors according to the needed index |
253 | * Description : Gets the string descriptors according to the needed index |
260 | * Input : Length |
254 | * Input : Length |
261 | * Output : None. |
255 | * Output : None. |
262 | * Return : The address of the string descriptors. |
256 | * Return : The address of the string descriptors. |
263 | *******************************************************************************/ |
257 | *******************************************************************************/ |
264 | u8 *Virtual_Com_Port_GetStringDescriptor(u16 Length) |
258 | u8 *Virtual_Com_Port_GetStringDescriptor(u16 Length) |
265 | { |
259 | { |
266 | u8 wValue0 = pInformation->USBwValue0; |
260 | u8 wValue0 = pInformation->USBwValue0; |
267 | return Standard_GetDescriptorData( Length, &String_Descriptor[wValue0] ); |
261 | return Standard_GetDescriptorData( Length, &String_Descriptor[wValue0] ); |
268 | } |
262 | } |
269 | /******************************************************************************* |
263 | /******************************************************************************* |
270 | * Function Name : Virtual_Com_Port_Get_Interface_Setting. |
264 | * Function Name : Virtual_Com_Port_Get_Interface_Setting. |
271 | * Description : test the interface and the alternate setting according to the |
265 | * Description : test the interface and the alternate setting according to the |
272 | * supported one. |
266 | * supported one. |
273 | * Input1 : u8: Interface : interface number. |
267 | * Input1 : u8: Interface : interface number. |
274 | * Input2 : u8: AlternateSetting : Alternate Setting number. |
268 | * Input2 : u8: AlternateSetting : Alternate Setting number. |
275 | * Output : None. |
269 | * Output : None. |
276 | * Return : The address of the string descriptors. |
270 | * Return : The address of the string descriptors. |
277 | *******************************************************************************/ |
271 | *******************************************************************************/ |
278 | RESULT Virtual_Com_Port_Get_Interface_Setting(u8 Interface,u8 AlternateSetting) |
272 | RESULT Virtual_Com_Port_Get_Interface_Setting(u8 Interface,u8 AlternateSetting) |
279 | { |
273 | { |
280 | if(AlternateSetting >0) return USB_UNSUPPORT; |
274 | if(AlternateSetting >0) return USB_UNSUPPORT; |
281 | else if(Interface > 1) return USB_UNSUPPORT; |
275 | else if(Interface > 1) return USB_UNSUPPORT; |
282 | return USB_SUCCESS; |
276 | return USB_SUCCESS; |
283 | } |
277 | } |
284 | /******************************************************************************* |
278 | /******************************************************************************* |
285 | * Function Name : Virtual_Com_Port_GetLineCoding. |
279 | * Function Name : Virtual_Com_Port_GetLineCoding. |
286 | * Description : send the linecoding structure to the PC host. |
280 | * Description : send the linecoding structure to the PC host. |
287 | * Input : Length |
281 | * Input : Length |
288 | * Output : None. |
282 | * Output : None. |
289 | * Return : Inecoding structure base address. |
283 | * Return : Inecoding structure base address. |
290 | *******************************************************************************/ |
284 | *******************************************************************************/ |
291 | u8 *Virtual_Com_Port_GetLineCoding(u16 Length) |
285 | u8 *Virtual_Com_Port_GetLineCoding(u16 Length) |
292 | { |
286 | { |
293 | if(Length==0) |
287 | if(Length==0) |
294 | { |
288 | { |
295 | pInformation->Ctrl_Info.Usb_wLength = sizeof(linecoding);; |
289 | pInformation->Ctrl_Info.Usb_wLength = sizeof(linecoding);; |
296 | return NULL; |
290 | return NULL; |
297 | } |
291 | } |
298 | return(u8 *)&linecoding; |
292 | return(u8 *)&linecoding; |
299 | } |
293 | } |
300 | /******************************************************************************* |
294 | /******************************************************************************* |
301 | * Function Name : Virtual_Com_Port_SetLineCoding. |
295 | * Function Name : Virtual_Com_Port_SetLineCoding. |
302 | * Description : Set the linecoding structure fields. |
296 | * Description : Set the linecoding structure fields. |
303 | * Input : Length |
297 | * Input : Length |
304 | * Output : None |
298 | * Output : None |
305 | * Return : Linecoding structure base address. |
299 | * Return : Linecoding structure base address. |
306 | *******************************************************************************/ |
300 | *******************************************************************************/ |
307 | u8 *Virtual_Com_Port_SetLineCoding(u16 Length) |
301 | u8 *Virtual_Com_Port_SetLineCoding(u16 Length) |
308 | { |
302 | { |
309 | if(Length==0) |
303 | if(Length==0) |
310 | { |
304 | { |
311 | pInformation->Ctrl_Info.Usb_wLength = sizeof(linecoding);; |
305 | pInformation->Ctrl_Info.Usb_wLength = sizeof(linecoding);; |
312 | return NULL; |
306 | return NULL; |
313 | } |
307 | } |
314 | return(u8 *)&linecoding; |
308 | return(u8 *)&linecoding; |
315 | } |
309 | } |
316 | 310 | ||
317 | /******************* (C) COPYRIGHT 2006 STMicroelectronics *****END OF FILE****/ |
311 | /******************* (C) COPYRIGHT 2006 STMicroelectronics *****END OF FILE****/ |
318 | 312 | ||
319 | 313 | ||
320 | 314 |