|
From: <mu...@as...> - 2007-06-12 13:27:36
|
Hi all,
=20
I am on a project, which uses this driver for the USB communication betwe=
en a software on PC, and Motorola DSP. I can currently use the driver wit=
hout problem, but have some problems when I try to change somethings.=20
=20
1 ) As it can be seen in code that follows, the endpoint's buffer size is=
=2064, I know that the ideal packet size to obtain higher speeds is to be=
=20a multiple of endpoint's buffer size, 64. But the problem is, when I t=
ry to send packets from PC to DSP whose size is a multiple of 64; 1024 fo=
r example, the packet reachs DSP but the USB_bulkOutDatHandler() method i=
s not called, so the semaphore is not given etc. I see the packet of size=
=201024 bytes correctly on my receive buffer, but why do you think the ha=
ndler is not invoked?? When the packet size is 1032 bytes there is no suc=
h problem.
=20
2 ) The packet is sent from the PC using the function as;
=20 ret =3D usb_bulk_write(usb_handle, 0x02, USBSt.=
txBuffer, 1032, 300);=20
Since this code runs on PC, the buffer is 1032 bytes, not words. So a buf=
fer of 516 words (plus some extensions for header etc.) must be enough on=
=20DSP. But the code does not work correctly if the size of this receivin=
g buffer on DSP is less than about 1050 (!). The data is stored in the fi=
rst 516 words correctly and remaining part of the buffer never changes. B=
ut it still must be that long. This is really strange, I must be making s=
ome mistake, but I dont know what is wrong.=20
=20
3 ) I cannot change the endpoint's buffer size, when I change it, problem=
s occur.. (Actually I have no problem with this, but I am writing in case=
=20it helps for the solution of the other problems)
=20
Here are some important parts of the code... Your help is appreciated.=20
=20
---------------------------------------------------------------------
#define WLEN_USBPROBUFFER 1050
#define BLEN_USBPROBUFFER WLEN_USBPROBUFFER*2
Uint16 USBInBuffer[WLEN_USBPROBUFFER];
=20
USB_EpHandle myUsbConfig[] =3D {&usbEpObjOut0, &usbEpObjIn0, &usbEpObjOu=
t2,
=20 &usbEpObjIn2, NULL};
interrupt void _USB_isr()
{
=20 USB_evDispatch( );
}
---------------------------------------------------------------------
UsbInit()
{
=20USB_setAPIVectorAddress();
=20event_mask =3D USB_EVENT_RESET | USB_EVENT_SETUP | USB_EVENT_SUSPEND |=
=20 USB_EVENT_RESUME | USB_EVENT_EOT;
=20
=20usb_status =3D USB_initEndptObj(USB0, &usbEpObjOut0, USB_OUT_EP0, USB_=
CTRL,
=20 0x40, event_mask, USB_ctl_handler);
=20usb_status =3D USB_initEndptObj(USB0, &usbEpObjIn0, USB_IN_EP0, USB_CT=
RL,
=20 0x40, USB_EVENT_EOT,USB_ctl_handler);
=20usb_status =3D USB_initEndptObj(USB0, &usbEpObjOut2, USB_OUT_EP2, USB_=
BULK,
=20 0x40, USB_EVENT_EOT,USB_bulkOutEvHandle=
r);
=20usb_status =3D USB_initEndptObj(USB0, &usbEpObjIn2, USB_IN_EP2, USB_BU=
LK, 0x40,
=20 USB_EVENT_HINT|USB_EVENT_EOT| =
=20 =20
=20 USB_EVENT_RESET,USB_bulkInEvHandler);
=20
=20usb_status =3D USB_init(USB0, myUsbConfig, 0x80);
=20IRQ_clear(usbId);
=20IRQ_enable(usbId);
=20IRQ_plug(usbId,&_USB_isr);
=20IRQ_globalEnable();
=20if (usb_status) USB_connectDev(USB0);
}
---------------------------------------------------------------------
void USB_bulkOutEvHandler()
{
=20 USB_bulkOutDatHandler(&usbEpObjIn2, &usbEpObjOut2);
}
---------------------------------------------------------------------
void USB_bulkOutDatHandler(USB_EpHandle hEpIn, USB_EpHandle hEpOut)
{
=20 if (USB_isTransactionDone(hEpOut))
=20 {
=20 USB_postTransaction(hEpOut, BLEN_USBPROBUFFER, USBInBuffer, USB_IOF=
LAG_SWAP);
=20 newpack_received++;
=20 SEM_post(&SEM_UsbPacketReceived);
=20 }
}
---------------------------------------------------------------------
void USB_bulkInEvHandler()
{
=20 ev =3D USB_peekEvents(&usbEpObjIn2);
=20 USB_bulkInDatHandler(&usbEpObjIn2, &usbEpObjOut2);
=20 =20
=20 if(USB_peekEvents(&usbEpObjIn2) & USB_EVENT_EOT) {
=20 asm(" nop");
=20 asm(" nop");
=20 }
}
---------------------------------------------------------------------
void USB_bulkInDatHandler(USB_EpHandle hEpIn, USB_EpHandle hEpOut)
{
=20 cnt ++;
=20 cntk++;
=20
=20 if (USB_isTransactionDone(hEpIn))
=20 {
=20 if (USBSt.replyBufFlag) {
=20 USB_postTransaction(&usbEpObjIn2, USBSt.replyLength, USBSt.replyB=
uf, USB_IOFLAG_SWAP);
=20 }
=20 else
=20 USB_postTransaction(&usbEpObjIn2, 0, USBSt.replyBuf, USB_IOFLAG_S=
WAP);
=20 }
}
-------------------------------------------------------------------
void TSK_Usb()
{
=20 while(1)
=20 {
=20 SEM_pend(&SEM_UsbPacketReceived, SYS_FOREVER);
=20 if (newpack_received>0)
=20 {
=20 if(newpack_received>1) printf("slow packet handling!\n");
=20
=20 PcRcvStateMachine(); //input buffer is processed here, replyBuf, =
replyLength are set
=20
=20 if (reply_packet>1) printf("slow reply handling!\n");
=20 }
=20 }
}
-------------------------------------------------------
=20
######################################################################
Dikkat:
Bu elektronik posta mesaji kisisel ve ozeldir. Eger size=20
gonderilmediyse lutfen gondericiyi bilgilendirip mesaji siliniz.=20
Firmamiza gelen ve giden mesajlar virus taramasindan gecirilmekte,=20
guvenlik nedeni ile kontrol edilerek saklanmaktadir. Mesajdaki=20
gorusler ve bakis acisi gondericiye ait olup Aselsan A.S. resmi=20
gorusu olmak zorunda degildir.
######################################################################
Attention:=20
This e-mail message is privileged and confidential. If you are=20
not the intended recipient please delete the message and notify=20
the sender. E-mails to and from the company are monitored for=20
operational reasons and in accordance with lawful business practices.=20
Any views or opinions presented are solely those of the author and=20
do not necessarily represent the views of the company.
######################################################################
|