diff --git a/demo/audio_mic_singlechan_template.c b/demo/audio_mic_singlechan_template.c new file mode 100644 index 00000000..615c3dfe --- /dev/null +++ b/demo/audio_mic_singlechan_template.c @@ -0,0 +1,164 @@ +#include "usbd_core.h" +#include "usbd_audio.h" +#include "music.h" + +#define USBD_VID 0xffff +#define USBD_PID 0xffff +#define USBD_MAX_POWER 100 +#define USBD_LANGID_STRING 1033 + +#ifdef CONFIG_USB_HS +#define EP_INTERVAL 0x04 +#else +#define EP_INTERVAL 0x01 +#endif + +#define AUDIO_IN_EP 0x81 + +/* AUDIO Class Config */ +#define AUDIO_FREQ 16000U + +#define AUDIO_SAMPLE_FREQ(frq) (uint8_t)(frq), (uint8_t)((frq >> 8)), (uint8_t)((frq >> 16)) + +/* AudioFreq * DataSize (2 bytes) * NumChannels (Stereo: 1) */ +/* 16bit(2 Bytes) 单声道(Mono:1) */ +#define AUDIO_IN_PACKET ((uint32_t)((AUDIO_FREQ * 2 * 1) / 1000)) + +#define USB_AUDIO_CONFIG_DESC_SIZ (unsigned long)(9 + \ + AUDIO_AC_DESCRIPTOR_INIT_LEN(1) + \ + AUDIO_SIZEOF_AC_INPUT_TERMINAL_DESC + \ + AUDIO_SIZEOF_AC_OUTPUT_TERMINAL_DESC + \ + AUDIO_SIZEOF_AC_FEATURE_UNIT_DESC(2) + \ + AUDIO_AS_DESCRIPTOR_INIT_LEN(1)) + +const uint8_t audio_descriptor[] = { + USB_DEVICE_DESCRIPTOR_INIT(USB_2_0, 0x00, 0x00, 0x00, USBD_VID, USBD_PID, 0x0001, 0x01), + USB_CONFIG_DESCRIPTOR_INIT(USB_AUDIO_CONFIG_DESC_SIZ, 0x02, 0x01, USB_CONFIG_BUS_POWERED, USBD_MAX_POWER), + AUDIO_AC_DESCRIPTOR_INIT(0x00, 0x02, 0x0100, 0x0027, 0x00, 0x01, 0x01), + AUDIO_AC_INPUT_TERMINAL_DESCRIPTOR_INIT(0x01, AUDIO_INTERM_MIC, 0x01, 0x0003), + AUDIO_AC_OUTPUT_TERMINAL_DESCRIPTOR_INIT(0x02, AUDIO_TERMINAL_STREAMING, 0x03), + AUDIO_AC_FEATURE_UNIT_DESCRIPTOR_INIT(0x03, 0x01, 0x02, 0x03, 0x00), + AUDIO_AS_DESCRIPTOR_INIT(0x01, 0x02, 0x01, AUDIO_IN_EP, AUDIO_IN_PACKET, EP_INTERVAL, 0x01, AUDIO_SAMPLE_FREQ(AUDIO_FREQ)), + /////////////////////////////////////// + /// string0 descriptor + /////////////////////////////////////// + USB_LANGID_INIT(USBD_LANGID_STRING), + /////////////////////////////////////// + /// string1 descriptor + /////////////////////////////////////// + 0x14, /* bLength */ + USB_DESCRIPTOR_TYPE_STRING, /* bDescriptorType */ + 'C', 0x00, /* wcChar0 */ + 'h', 0x00, /* wcChar1 */ + 'e', 0x00, /* wcChar2 */ + 'r', 0x00, /* wcChar3 */ + 'r', 0x00, /* wcChar4 */ + 'y', 0x00, /* wcChar5 */ + 'U', 0x00, /* wcChar6 */ + 'S', 0x00, /* wcChar7 */ + 'B', 0x00, /* wcChar8 */ + /////////////////////////////////////// + /// string2 descriptor + /////////////////////////////////////// + 0x26, /* bLength */ + USB_DESCRIPTOR_TYPE_STRING, /* bDescriptorType */ + 'C', 0x00, /* wcChar0 */ + 'h', 0x00, /* wcChar1 */ + 'e', 0x00, /* wcChar2 */ + 'r', 0x00, /* wcChar3 */ + 'r', 0x00, /* wcChar4 */ + 'y', 0x00, /* wcChar5 */ + 'U', 0x00, /* wcChar6 */ + 'S', 0x00, /* wcChar7 */ + 'B', 0x00, /* wcChar8 */ + ' ', 0x00, /* wcChar9 */ + 'U', 0x00, /* wcChar10 */ + 'A', 0x00, /* wcChar11 */ + 'C', 0x00, /* wcChar12 */ + ' ', 0x00, /* wcChar13 */ + 'D', 0x00, /* wcChar14 */ + 'E', 0x00, /* wcChar15 */ + 'M', 0x00, /* wcChar16 */ + 'O', 0x00, /* wcChar17 */ + /////////////////////////////////////// + /// string3 descriptor + /////////////////////////////////////// + 0x16, /* bLength */ + USB_DESCRIPTOR_TYPE_STRING, /* bDescriptorType */ + '2', 0x00, /* wcChar0 */ + '0', 0x00, /* wcChar1 */ + '2', 0x00, /* wcChar2 */ + '1', 0x00, /* wcChar3 */ + '0', 0x00, /* wcChar4 */ + '3', 0x00, /* wcChar5 */ + '1', 0x00, /* wcChar6 */ + '0', 0x00, /* wcChar7 */ + '0', 0x00, /* wcChar8 */ + '0', 0x00, /* wcChar9 */ +#ifdef CONFIG_USB_HS + /////////////////////////////////////// + /// device qualifier descriptor + /////////////////////////////////////// + 0x0a, + USB_DESCRIPTOR_TYPE_DEVICE_QUALIFIER, + 0x00, + 0x02, + 0x00, + 0x00, + 0x00, + 0x40, + 0x01, + 0x00, +#endif + 0x00 +}; + +volatile bool tx_flag = 0; + +void usbd_audio_open(uint8_t intf) +{ + tx_flag = 1; + printf("OPEN\r\n"); +} +void usbd_audio_close(uint8_t intf) +{ + printf("CLOSE\r\n"); + tx_flag = 0; +} + +static usbd_class_t audio_class; +static usbd_interface_t audio_control_intf; +static usbd_interface_t audio_stream_intf; + +void usbd_audio_iso_callback(uint8_t ep) +{ +} + +static usbd_endpoint_t audio_in_ep = { + .ep_cb = usbd_audio_iso_callback, + .ep_addr = AUDIO_IN_EP +}; + +void audio_init() +{ + usbd_desc_register(audio_descriptor); + usbd_audio_add_interface(&audio_class, &audio_control_intf); + usbd_audio_add_interface(&audio_class, &audio_stream_intf); + usbd_interface_add_endpoint(&audio_stream_intf, &audio_in_ep); + + usbd_initialize(); +} + +uint8_t buffer[1024]; + +void audio_test() +{ + for (size_t i = 0; i < 1000; i++) { + buffer[i] = i; + } + while (1) { + if (tx_flag) { + usbd_ep_write(0x81, buffer, 1024, NULL); + } + } +} \ No newline at end of file diff --git a/demo/audio_mic_speaker_dualchan_template.c b/demo/audio_mic_speaker_dualchan_template.c new file mode 100644 index 00000000..445569c4 --- /dev/null +++ b/demo/audio_mic_speaker_dualchan_template.c @@ -0,0 +1,186 @@ +#include "usbd_core.h" +#include "usbd_audio.h" + +#ifdef CONFIG_USB_HS +#define EP_INTERVAL 0x04 +#else +#define EP_INTERVAL 0x01 +#endif + +#define USBD_VID 0xffff +#define USBD_PID 0xffff +#define USBD_MAX_POWER 100 +#define USBD_LANGID_STRING 1033 + +#define AUDIO_IN_EP 0x81 +#define AUDIO_OUT_EP 0x02 + +/* AUDIO Class Config */ +#define AUDIO_FREQ 16000U + +#define AUDIO_SAMPLE_FREQ(frq) (uint8_t)(frq), (uint8_t)((frq >> 8)), (uint8_t)((frq >> 16)) + +/* AudioFreq * DataSize (2 bytes) * NumChannels (Stereo: 2) */ +#define AUDIO_OUT_PACKET ((uint32_t)((AUDIO_FREQ * 2 * 2) / 1000)) +/* 16bit(2 Bytes) 双声道(Mono:2) */ +#define AUDIO_IN_PACKET ((uint32_t)((AUDIO_FREQ * 2 * 2) / 1000)) + +#define USB_AUDIO_CONFIG_DESC_SIZ (unsigned long)(9 + \ + AUDIO_AC_DESCRIPTOR_INIT_LEN(2) + \ + AUDIO_SIZEOF_AC_INPUT_TERMINAL_DESC + \ + AUDIO_SIZEOF_AC_INPUT_TERMINAL_DESC + \ + AUDIO_SIZEOF_AC_OUTPUT_TERMINAL_DESC + \ + AUDIO_SIZEOF_AC_OUTPUT_TERMINAL_DESC + \ + AUDIO_SIZEOF_AC_FEATURE_UNIT_DESC(2) + \ + AUDIO_SIZEOF_AC_FEATURE_UNIT_DESC(2) + \ + AUDIO_AS_DESCRIPTOR_INIT_LEN(1) + \ + AUDIO_AS_DESCRIPTOR_INIT_LEN(1)) + +const uint8_t audio_descriptor[] = { + USB_DEVICE_DESCRIPTOR_INIT(USB_2_0, 0x00, 0x00, 0x00, USBD_VID, USBD_PID, 0x0001, 0x01), + USB_CONFIG_DESCRIPTOR_INIT(USB_AUDIO_CONFIG_DESC_SIZ, 0x03, 0x01, USB_CONFIG_BUS_POWERED, USBD_MAX_POWER), + AUDIO_AC_DESCRIPTOR_INIT(0x00, 0x03, 0x0100, 0x0046, 0x00, 0x02, 0x01, 0x02), + AUDIO_AC_INPUT_TERMINAL_DESCRIPTOR_INIT(0x01, AUDIO_INTERM_MIC, 0x02, 0x0001), + AUDIO_AC_INPUT_TERMINAL_DESCRIPTOR_INIT(0x02, AUDIO_TERMINAL_STREAMING, 0x02, 0x0001), + AUDIO_AC_OUTPUT_TERMINAL_DESCRIPTOR_INIT(0x03, AUDIO_OUTTERM_SPEAKER, 0x05), + AUDIO_AC_OUTPUT_TERMINAL_DESCRIPTOR_INIT(0x04, AUDIO_TERMINAL_STREAMING, 0x06), + AUDIO_AC_FEATURE_UNIT_DESCRIPTOR_INIT(0x05, 0x02, 0x02, 0x03, 0x00), + AUDIO_AC_FEATURE_UNIT_DESCRIPTOR_INIT(0x06, 0x01, 0x02, 0x03, 0x00), + AUDIO_AS_DESCRIPTOR_INIT(0x01, 0x02, 0x02, AUDIO_OUT_EP, AUDIO_OUT_PACKET, EP_INTERVAL, 0x01, AUDIO_SAMPLE_FREQ(AUDIO_FREQ)), + AUDIO_AS_DESCRIPTOR_INIT(0x02, 0x04, 0x02, AUDIO_IN_EP, AUDIO_IN_PACKET, EP_INTERVAL, 0x01, AUDIO_SAMPLE_FREQ(AUDIO_FREQ)), + /////////////////////////////////////// + /// string0 descriptor + /////////////////////////////////////// + USB_LANGID_INIT(USBD_LANGID_STRING), + /////////////////////////////////////// + /// string1 descriptor + /////////////////////////////////////// + 0x14, /* bLength */ + USB_DESCRIPTOR_TYPE_STRING, /* bDescriptorType */ + 'C', 0x00, /* wcChar0 */ + 'h', 0x00, /* wcChar1 */ + 'e', 0x00, /* wcChar2 */ + 'r', 0x00, /* wcChar3 */ + 'r', 0x00, /* wcChar4 */ + 'y', 0x00, /* wcChar5 */ + 'U', 0x00, /* wcChar6 */ + 'S', 0x00, /* wcChar7 */ + 'B', 0x00, /* wcChar8 */ + /////////////////////////////////////// + /// string2 descriptor + /////////////////////////////////////// + 0x26, /* bLength */ + USB_DESCRIPTOR_TYPE_STRING, /* bDescriptorType */ + 'C', 0x00, /* wcChar0 */ + 'h', 0x00, /* wcChar1 */ + 'e', 0x00, /* wcChar2 */ + 'r', 0x00, /* wcChar3 */ + 'r', 0x00, /* wcChar4 */ + 'y', 0x00, /* wcChar5 */ + 'U', 0x00, /* wcChar6 */ + 'S', 0x00, /* wcChar7 */ + 'B', 0x00, /* wcChar8 */ + ' ', 0x00, /* wcChar9 */ + 'U', 0x00, /* wcChar10 */ + 'A', 0x00, /* wcChar11 */ + 'C', 0x00, /* wcChar12 */ + ' ', 0x00, /* wcChar13 */ + 'D', 0x00, /* wcChar14 */ + 'E', 0x00, /* wcChar15 */ + 'M', 0x00, /* wcChar16 */ + 'O', 0x00, /* wcChar17 */ + /////////////////////////////////////// + /// string3 descriptor + /////////////////////////////////////// + 0x16, /* bLength */ + USB_DESCRIPTOR_TYPE_STRING, /* bDescriptorType */ + '2', 0x00, /* wcChar0 */ + '0', 0x00, /* wcChar1 */ + '2', 0x00, /* wcChar2 */ + '1', 0x00, /* wcChar3 */ + '0', 0x00, /* wcChar4 */ + '3', 0x00, /* wcChar5 */ + '1', 0x00, /* wcChar6 */ + '0', 0x00, /* wcChar7 */ + '0', 0x00, /* wcChar8 */ + '0', 0x00, /* wcChar9 */ +#ifdef CONFIG_USB_HS + /////////////////////////////////////// + /// device qualifier descriptor + /////////////////////////////////////// + 0x0a, + USB_DESCRIPTOR_TYPE_DEVICE_QUALIFIER, + 0x00, + 0x02, + 0x00, + 0x00, + 0x00, + 0x40, + 0x01, + 0x00, +#endif + 0x00 +}; + +volatile bool tx_flag = 0; +volatile bool rx_flag = 0; + +void usbd_audio_open(uint8_t intf) +{ + if (intf == 1) { + rx_flag = 1; + printf("OPEN1\r\n"); + } else { + tx_flag = 1; + printf("OPEN2\r\n"); + } +} +void usbd_audio_close(uint8_t intf) +{ + if (intf == 1) { + rx_flag = 1; + printf("CLOSE1\r\n"); + } else { + tx_flag = 0; + printf("CLOSE2\r\n"); + } +} + +static usbd_class_t audio_class; +static usbd_interface_t audio_control_intf; +static usbd_interface_t audio_stream_intf; +static usbd_interface_t audio_stream_intf2; + +void usbd_audio_iso_callback(uint8_t ep) +{ +} + +static usbd_endpoint_t audio_in_ep = { + .ep_cb = usbd_audio_iso_callback, + .ep_addr = AUDIO_IN_EP +}; + +static usbd_endpoint_t audio_out_ep = { + .ep_cb = usbd_audio_iso_callback, + .ep_addr = AUDIO_OUT_EP +}; + +void audio_init() +{ + usbd_desc_register(audio_descriptor); + usbd_audio_add_interface(&audio_class, &audio_control_intf); + usbd_audio_add_interface(&audio_class, &audio_stream_intf); + usbd_audio_add_interface(&audio_class, &audio_stream_intf2); + usbd_interface_add_endpoint(&audio_stream_intf, &audio_in_ep); + usbd_interface_add_endpoint(&audio_stream_intf2, &audio_out_ep); + + usbd_initialize(); +} + +void audio_test() +{ + while (1) { + if (tx_flag) { + } + } +} \ No newline at end of file diff --git a/demo/video_hs_mjpeg_template.c b/demo/video_hs_mjpeg_template.c index 9c9034a0..e459acbd 100644 --- a/demo/video_hs_mjpeg_template.c +++ b/demo/video_hs_mjpeg_template.c @@ -2,6 +2,8 @@ #include "usbd_video.h" #include "pic_data.h" +#define VIDEO_IN_EP 0x81 + #define MAX_PAYLOAD_SIZE 2048 #define VIDEO_PACKET_SIZE (unsigned int)(((MAX_PAYLOAD_SIZE / 2)) | (0x01 << 11)) @@ -14,153 +16,22 @@ #define MAX_BIT_RATE (unsigned long)(WIDTH * HEIGHT * 16 * CAM_FPS) #define MAX_FRAME_SIZE (unsigned long)(WIDTH * HEIGHT * 2) -#if 0 -#define USB_VIDEO_DESC_SIZ (unsigned long)(9 + \ - 8 + \ - 9 + \ - 52 + \ - 9 + \ - 181 + \ - 9 + \ - 7) - -#define VC_TERMINAL_SIZ (52) -#define VC_HEADER_SIZ (181) - -#define USBD_VID 0xffff -#define USBD_PID 0xffff -#define USBD_MAX_POWER 100 -#define USBD_LANGID_STRING 1033 - -USB_DESC_SECTION const uint8_t video_descriptor[] = { - USB_DEVICE_DESCRIPTOR_INIT(USB_2_0, 0xef, 0x02, 0x01, USBD_VID, USBD_PID, 0x0001, 0x01), - USB_CONFIG_DESCRIPTOR_INIT(USB_VIDEO_DESC_SIZ, 0x02, 0x01, USB_CONFIG_BUS_POWERED, USBD_MAX_POWER), - VIDEO_VC_DESCRIPTOR_INIT(0x00, 0, 0x0100, VC_TERMINAL_SIZ, 48000000, 0x02), - // 0x07, - // 0x05, - // 0x87, - // 0x03, - // 0x10, 0x00, - // 0x08, - - // 0x05, - // 0x25, - // 0x03, - // 0x10, 0x00, - VIDEO_VS_DESCRIPTOR_INIT(0x01, 0x00, 0x00), - VIDEO_VS_HEADER_DESCRIPTOR_INIT(0x03, VC_HEADER_SIZ, 0x81), - VIDEO_VS_FORMAT_UNCOMPRESSED_DESCRIPTOR_INIT(0x01, 0x01, VIDEO_GUID_YUY2), - VIDEO_VS_FRAME_UNCOMPRESSED_DESCRIPTOR_INIT(0x01, WIDTH, HEIGHT, MIN_BIT_RATE, MAX_BIT_RATE, MAX_FRAME_SIZE, INTERVAL, INTERVAL), - VIDEO_VS_FORMAT_MJPEG_DESCRIPTOR_INIT(0x02,0x01), - VIDEO_VS_FRAME_MJPEG_DESCRIPTOR_INIT(0x01, WIDTH, HEIGHT, MIN_BIT_RATE, MAX_BIT_RATE, MAX_FRAME_SIZE, INTERVAL, INTERVAL, 0x00061A80), - VIDEO_VS_FORMAT_UNCOMPRESSED_DESCRIPTOR_INIT(0x03, 0x01, VIDEO_GUID_NV12), - VIDEO_VS_FRAME_UNCOMPRESSED_DESCRIPTOR_INIT(0x01, WIDTH, HEIGHT, MIN_BIT_RATE, MAX_BIT_RATE, MAX_FRAME_SIZE, INTERVAL, INTERVAL), - - 0x06, - 0x24, - 0x0d, - 0x01, - 0x01, - 0x04, - - VIDEO_VS_DESCRIPTOR_INIT(0x01, 0x01, 0x01), - /* 1.2.2.2 Standard VideoStream Isochronous Video Data Endpoint Descriptor */ - 0x07, /* bLength */ - USB_DESCRIPTOR_TYPE_ENDPOINT, /* bDescriptorType: ENDPOINT */ - 0x81, /* bEndpointAddress: IN endpoint 2 */ - 0x01, /* bmAttributes: Isochronous transfer type. Asynchronous synchronization type. */ - WBVAL(VIDEO_PACKET_SIZE), /* wMaxPacketSize */ - 0x01, /* bInterval: One frame interval */ - - /////////////////////////////////////// - /// string0 descriptor - /////////////////////////////////////// - USB_LANGID_INIT(USBD_LANGID_STRING), - /////////////////////////////////////// - /// string1 descriptor - /////////////////////////////////////// - 0x14, /* bLength */ - USB_DESCRIPTOR_TYPE_STRING, /* bDescriptorType */ - 'C', 0x00, /* wcChar0 */ - 'h', 0x00, /* wcChar1 */ - 'e', 0x00, /* wcChar2 */ - 'r', 0x00, /* wcChar3 */ - 'r', 0x00, /* wcChar4 */ - 'y', 0x00, /* wcChar5 */ - 'U', 0x00, /* wcChar6 */ - 'S', 0x00, /* wcChar7 */ - 'B', 0x00, /* wcChar8 */ - /////////////////////////////////////// - /// string2 descriptor - /////////////////////////////////////// - 0x26, /* bLength */ - USB_DESCRIPTOR_TYPE_STRING, /* bDescriptorType */ - 'C', 0x00, /* wcChar0 */ - 'h', 0x00, /* wcChar1 */ - 'e', 0x00, /* wcChar2 */ - 'r', 0x00, /* wcChar3 */ - 'r', 0x00, /* wcChar4 */ - 'y', 0x00, /* wcChar5 */ - 'U', 0x00, /* wcChar6 */ - 'S', 0x00, /* wcChar7 */ - 'B', 0x00, /* wcChar8 */ - ' ', 0x00, /* wcChar9 */ - 'U', 0x00, /* wcChar10 */ - 'V', 0x00, /* wcChar11 */ - 'C', 0x00, /* wcChar12 */ - ' ', 0x00, /* wcChar13 */ - 'D', 0x00, /* wcChar14 */ - 'E', 0x00, /* wcChar15 */ - 'M', 0x00, /* wcChar16 */ - 'O', 0x00, /* wcChar17 */ - /////////////////////////////////////// - /// string3 descriptor - /////////////////////////////////////// - 0x16, /* bLength */ - USB_DESCRIPTOR_TYPE_STRING, /* bDescriptorType */ - '2', 0x00, /* wcChar0 */ - '0', 0x00, /* wcChar1 */ - '2', 0x00, /* wcChar2 */ - '1', 0x00, /* wcChar3 */ - '0', 0x00, /* wcChar4 */ - '3', 0x00, /* wcChar5 */ - '1', 0x00, /* wcChar6 */ - '0', 0x00, /* wcChar7 */ - '0', 0x00, /* wcChar8 */ - '0', 0x00, /* wcChar9 */ -#ifdef CONFIG_USB_HS - /////////////////////////////////////// - /// device qualifier descriptor - /////////////////////////////////////// - 0x0a, - USB_DESCRIPTOR_TYPE_DEVICE_QUALIFIER, - 0x00, - 0x02, - 0x00, - 0x00, - 0x00, - 0x40, - 0x01, - 0x00, -#endif - 0x00 -}; -#else #define USB_VIDEO_DESC_SIZ (unsigned long)(9 + \ 8 + \ 9 + \ 13 + \ 18 + \ 9 + \ + 12 + \ 9 + \ 14 + \ 11 + \ - 34 + \ + 38 + \ 9 + \ 7) -#define VC_TERMINAL_SIZ (unsigned int)(13 + 18 + 9) -#define VC_HEADER_SIZ (unsigned int)(14 + 11 + 34) +#define VC_TERMINAL_SIZ (unsigned int)(13 + 18 + 12 + 9) +#define VS_HEADER_SIZ (unsigned int)(13 + 1 + 11 + 38) #define USBD_VID 0xffff #define USBD_PID 0xffff @@ -172,9 +43,9 @@ USB_DESC_SECTION const uint8_t video_descriptor[] = { USB_CONFIG_DESCRIPTOR_INIT(USB_VIDEO_DESC_SIZ, 0x02, 0x01, USB_CONFIG_BUS_POWERED, USBD_MAX_POWER), VIDEO_VC_DESCRIPTOR_INIT(0x00, 0, 0x0100, VC_TERMINAL_SIZ, 48000000, 0x02), VIDEO_VS_DESCRIPTOR_INIT(0x01, 0x00, 0x00), - VIDEO_VS_HEADER_DESCRIPTOR_INIT(0x01, VC_HEADER_SIZ, 0x81), + VIDEO_VS_HEADER_DESCRIPTOR_INIT(0x01, VS_HEADER_SIZ, VIDEO_IN_EP, 1, 0x00), VIDEO_VS_FORMAT_MJPEG_DESCRIPTOR_INIT(0x01, 0x01), - VIDEO_VS_FRAME_MJPEG_DESCRIPTOR_INIT_V2(0x01, WIDTH, HEIGHT, MIN_BIT_RATE, MAX_BIT_RATE, MAX_FRAME_SIZE, INTERVAL, INTERVAL, INTERVAL), + VIDEO_VS_FRAME_MJPEG_DESCRIPTOR_INIT(0x01, WIDTH, HEIGHT, MIN_BIT_RATE, MAX_BIT_RATE, MAX_FRAME_SIZE, INTERVAL, 0x00, DBVAL(INTERVAL), DBVAL(INTERVAL), DBVAL(0)), VIDEO_VS_DESCRIPTOR_INIT(0x01, 0x01, 0x01), /* 1.2.2.2 Standard VideoStream Isochronous Video Data Endpoint Descriptor */ 0x07, /* bLength */ @@ -258,20 +129,19 @@ USB_DESC_SECTION const uint8_t video_descriptor[] = { 0x00 }; -#endif - volatile bool tx_flag = 0; -void usbd_video_set_interface_callback(uint8_t value) +void usbd_video_open(uint8_t intf) { - if (value) { - printf("OPEN\r\n"); - tx_flag = 1; - } else { - printf("CLOSE\r\n"); - tx_flag = 0; - } + tx_flag = 1; + MSG("OPEN\r\n"); } +void usbd_video_close(uint8_t intf) +{ + MSG("CLOSE\r\n"); + tx_flag = 0; +} + static usbd_class_t video_class; static usbd_interface_t video_control_intf; @@ -279,12 +149,11 @@ static usbd_interface_t video_stream_intf; void usbd_video_iso_callback(uint8_t ep) { - } static usbd_endpoint_t video_in_ep = { .ep_cb = usbd_video_iso_callback, - .ep_addr = 0x81 + .ep_addr = VIDEO_IN_EP }; void video_init()