Subversion Repositories NaviCtrl

Rev

Rev 110 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 110 Rev 111
Line 96... Line 96...
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.
Line 191... Line 188...
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);
Line 197... Line 194...
197
               
194
               
198
  CopyRoutine = NULL;
195
        CopyRoutine = NULL;
199
 
196
       
-
 
197
        if (RequestNo == GET_LINE_CODING)
200
  if (RequestNo == GET_LINE_CODING) {
198
        {
201
                if (Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT))
-
 
202
                        CopyRoutine = Virtual_Com_Port_GetLineCoding;
199
                if (Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT)) CopyRoutine = Virtual_Com_Port_GetLineCoding;
203
        }
200
        }
-
 
201
        else if (RequestNo == SET_LINE_CODING)
204
        else if (RequestNo == SET_LINE_CODING) {
202
        {
205
                if (Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT))
-
 
206
                        CopyRoutine = Virtual_Com_Port_SetLineCoding;
203
                if (Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT)) CopyRoutine = Virtual_Com_Port_SetLineCoding;
207
         Request = SET_LINE_CODING;
204
                Request = SET_LINE_CODING;
-
 
205
        }
Line 208... Line -...
208
        }
-
 
209
       
-
 
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)
-
 
225
{
220
RESULT Virtual_Com_Port_NoData_Setup(u8 RequestNo)
226
 
221
{
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;
-
 
231
  }
225
                else if (RequestNo == SET_CONTROL_LINE_STATE) return USB_SUCCESS;
232
 
226
        }
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.
Line 275... Line 269...
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
}
Line 316... Line 310...
316
 
310