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