Эх сурвалжийг харах

rename video hs with video static

sakumisu 3 жил өмнө
parent
commit
8868d76555

+ 1 - 1
SConscript

@@ -53,7 +53,7 @@ if GetDepend(['PKG_CHERRYUSB_DEVICE']):
     if GetDepend(['PKG_CHERRYUSB_DEVICE_AUDIO_V2_TEMPLATE']):
         src += Glob('demo/audio_v2_mic_speaker_multichan_template.c')
     if GetDepend(['PKG_CHERRYUSB_DEVICE_VIDEO_TEMPLATE']):
-        src += Glob('demo/video_hs_mjpeg_template.c')
+        src += Glob('demo/video_static_mjpeg_template.c')
 
     if GetDepend(['PKG_CHERRYUSB_DEVICE_FSDEV_STM32']):
         src += Glob('port/fsdev/usb_dc_fsdev.c')

+ 23 - 6
demo/video_hs_mjpeg_template.c → demo/video_static_mjpeg_template.c

@@ -4,8 +4,20 @@
 
 #define VIDEO_IN_EP 0x81
 
-#define MAX_PAYLOAD_SIZE  2048
-#define VIDEO_PACKET_SIZE (unsigned int)(((MAX_PAYLOAD_SIZE / 2)) | (0x01 << 11))
+#ifdef CONFIG_USB_HS
+#define MAX_PAYLOAD_SIZE  1024 // for high speed with one transcations every one micro frame
+#define VIDEO_PACKET_SIZE (unsigned int)(((MAX_PAYLOAD_SIZE / 1)) | (0x00 << 11))
+
+// #define MAX_PAYLOAD_SIZE  2048 // for high speed with two transcations every one micro frame
+// #define VIDEO_PACKET_SIZE (unsigned int)(((MAX_PAYLOAD_SIZE / 2)) | (0x01 << 11))
+
+// #define MAX_PAYLOAD_SIZE  3072 // for high speed with three transcations every one micro frame
+// #define VIDEO_PACKET_SIZE (unsigned int)(((MAX_PAYLOAD_SIZE / 3)) | (0x02 << 11))
+
+#else
+#define MAX_PAYLOAD_SIZE  256
+#define VIDEO_PACKET_SIZE (unsigned int)(((MAX_PAYLOAD_SIZE / 1)) | (0x00 << 11))
+#endif
 
 #define WIDTH  (unsigned int)(640)
 #define HEIGHT (unsigned int)(480)
@@ -142,7 +154,6 @@ void usbd_video_close(uint8_t intf)
     tx_flag = 0;
 }
 
-
 static usbd_class_t video_class;
 static usbd_interface_t video_control_intf;
 static usbd_interface_t video_stream_intf;
@@ -173,11 +184,17 @@ uint8_t packet_buffer[10 * 1024];
 void video_test()
 {
     uint32_t out_len;
-
+    uint32_t packets;
     while (1) {
         if (tx_flag) {
-            usbd_video_mjpeg_payload_fill((uint8_t *)jpeg_data, sizeof(jpeg_data), packet_buffer, &out_len);
-            usbd_ep_write(0x81, packet_buffer, out_len, NULL);
+            packets = usbd_video_mjpeg_payload_fill((uint8_t *)jpeg_data, sizeof(jpeg_data), packet_buffer, &out_len);
+            for (uint32_t i = 0; i < packets; i++) {
+                if (i == (packets - 1)) {
+                    usbd_ep_write(VIDEO_IN_EP, &packet_buffer[i * MAX_PAYLOAD_SIZE], out_len - (packets - 1) * MAX_PAYLOAD_SIZE, NULL);
+                } else {
+                    usbd_ep_write(VIDEO_IN_EP, &packet_buffer[i * MAX_PAYLOAD_SIZE], MAX_PAYLOAD_SIZE, NULL);
+                }
+            }
         }
     }
 }