diff options
| author | sakumisu <[email protected]> | 2022-06-04 22:11:29 +0800 |
|---|---|---|
| committer | sakumisu <[email protected]> | 2022-06-04 22:11:29 +0800 |
| commit | 8868d76555c152798fc7bf7ecb5085474856dfd4 (patch) | |
| tree | 71dae7cd1fdc7f150b5c4bb802de5f581ef0f5c3 | |
| parent | 7d0acaeaee248ac4d9c079ecd490737b9265befa (diff) | |
rename video hs with video static
| -rw-r--r-- | SConscript | 2 | ||||
| -rw-r--r-- | demo/video_static_mjpeg_template.c (renamed from demo/video_hs_mjpeg_template.c) | 29 |
2 files changed, 24 insertions, 7 deletions
@@ -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') diff --git a/demo/video_hs_mjpeg_template.c b/demo/video_static_mjpeg_template.c index 68df3879..e48b23cf 100644 --- a/demo/video_hs_mjpeg_template.c +++ b/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); + } + } } } }
\ No newline at end of file |
