I have one MCB2300,the demo "USBUVC",how can I add a jpg file for test? thank you,very much.
I write a tool convert the *.jpg file to *.h developerarm7.googlecode.com/.../Tools
My problem is: I cannot realy understand the USB Video Class, so I cannot add any code to the demo. The UVC is difficult to me.
Thank you,:)
> It can checkout with SVN,windows XP OS:
Seems just fit the NXP LPC2888 USBUVC example to LPC2368 :-) The example doesn't implement any process for the streaming isoc endpoint.
Sample Code Bundle for LPC288x Peripherals, V1.30 (Sep 5, 2007) www.standardics.nxp.com/.../code.bundle.lpc288x.zip
For LPC2368, isoc EP is driven in SOF (FRAME) interrupt, or DMA.
As the example has already enabled USB_SOF_EVENT in usbcfg.h, fill in USB_SOF_Event() with your transfer process.
usbuser.c #if USB_SOF_EVENT void USB_SOF_Event (void) { } #endif
The video packets are passed to the isoc EP3, using USB_WriteEP(), one by one on each USB_SOF_Event() call. The packet format is defined in the UVC spec,
USB_Video_Payload_MJPEG_1.1.pdf
included in "Video Class 1.1 document set" www.usb.org/.../USB_Video_Class_1_1.zip
Tsuneo
> My problem is: I cannot realy understand the USB Video Class, so I cannot add any code to the demo. The UVC is difficult to me.
Your problem is that you don't write your problem clearly :-)
Surely, in most cases, if you could exactly specify what the problem is, the problem would be solved more than half. Then, take effort to explain your problem more clearly. It'll accelerate your progress effectively. In this way, we've become the learnt.
Thank you ! I will try it.
English is not my mother language,I'm a Chinese. Thank you.:)
1. I added the jpg data to the demo:
#ifndef _JPG_GLOBAL_ extern const unsigned int JPG_size; extern const unsigned char JPG_data[]; #else const unsigned int JPG_size = 0x2c5a; const unsigned char JPG_data[] = { 0xff,0xd8,0xff,0xe0,0x00,0x10 ..... ..... 0xfd,0x7f,0x4c,0xff,0xd9 };
2. transfer process
volatile DWORD TestCnt; volatile DWORD JPG_Cnt; #define EP3_MAX_PACKET 0x1FE #if USB_SOF_EVENT void USB_SOF_Event (void) { TestCnt++; if((JPG_size - JPG_Cnt) > EP3_MAX_PACKET) { USB_WriteEP(0x83,(BYTE *)(JPG_data + JPG_Cnt),EP3_MAX_PACKET); JPG_Cnt += EP3_MAX_PACKET; } else { USB_WriteEP(0x83,(BYTE *)(JPG_data + JPG_Cnt),JPG_size - JPG_Cnt); JPG_Cnt = 0; } } #endif
The data transfer to the host, I can see it with a usb tool - USBTrace. But the jpg can't display on the PC. Maybe need do something else.
I use two bytes for Payload Header Field,but fail too.
#if USB_SOF_EVENT void USB_SOF_Event (void) { /* Payload header - SOF_Event_Buf[0~1] */ if(JPG_Cnt == 0) /* Start of Frame */ { SOF_Event_Buf[0] = 0x02; SOF_Event_Buf[1] &= 0x01; } else { SOF_Event_Buf[1] ^= 0x01; /* FID */ /* The last packet of jpg */ if((JPG_size - JPG_Cnt) <= (EP3_MAX_PACKET - 2)) SOF_Event_Buf[1] |= 0x02; /* EOF - End of Frame */ } /* Copy data and send */ Write_To_Buf(); USB_WriteEP(0x83,(BYTE *)SOF_Event_Buf,Buf_Size); } #endif
Fixed but fail too.
#if USB_SOF_EVENT void USB_SOF_Event (void) { /* Payload header - SOF_Event_Buf[0~1] */ if(JPG_Cnt == 0) /* Start of Frame */ { SOF_Event_Buf[0] = 0x02; SOF_Event_Buf[1] &= 0x01; SOF_Event_Buf[1] ^= 0x01; /* FID */ SOF_Event_Buf[1] |= 0x80; /* EOH */ } else { /* The last packet of jpg */ if((JPG_size - JPG_Cnt) <= (EP3_MAX_PACKET - 2)) SOF_Event_Buf[1] |= 0x02; /* EOF - End of Frame */ } /* Copy data and send */ Write_To_Buf(); USB_WriteEP(0x83,(BYTE *)SOF_Event_Buf,Buf_Size); } #endif
Hi,Tsuneo
I modify the payload header,and it's work!
Thank you !
Xu