This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

[MCB2300] - LPC2368 - UVC - help

I have one MCB2300,the demo "USBUVC",how can I add a jpg
file for test? thank you,very much.

Parents
  • 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.

Reply
  • 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.

Children
  • 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