mirror of
https://github.com/Fishwaldo/bl_mcu_sdk.git
synced 2025-03-15 19:31:43 +00:00
[update][cherryusb] sync code from master
This commit is contained in:
parent
47c662afae
commit
0dc6e5782e
14 changed files with 249 additions and 266 deletions
|
@ -132,6 +132,12 @@
|
||||||
#define AUDIO_FORMAT_ALAW 0x0004
|
#define AUDIO_FORMAT_ALAW 0x0004
|
||||||
#define AUDIO_FORMAT_MULAW 0x0005
|
#define AUDIO_FORMAT_MULAW 0x0005
|
||||||
|
|
||||||
|
#define AUDIO_V2_FORMAT_PCM 0x00000001
|
||||||
|
#define AUDIO_V2_FORMAT_PCM8 0x00000002
|
||||||
|
#define AUDIO_V2_FORMAT_IEEE_FLOAT 0x00000004
|
||||||
|
#define AUDIO_V2_FORMAT_ALAW 0x00000008
|
||||||
|
#define AUDIO_V2_FORMAT_MULAW 0x00000010
|
||||||
|
|
||||||
/* bmChannelConfig: a bitmap field that indicates which spatial locations
|
/* bmChannelConfig: a bitmap field that indicates which spatial locations
|
||||||
* are occupied by the channels present in the cluster. The bit allocations
|
* are occupied by the channels present in the cluster. The bit allocations
|
||||||
* are as follows:
|
* are as follows:
|
||||||
|
@ -640,7 +646,7 @@ struct audio_cs_if_ac_feature_unit_descriptor {
|
||||||
uint8_t iFeature;
|
uint8_t iFeature;
|
||||||
} __PACKED;
|
} __PACKED;
|
||||||
|
|
||||||
#define AUDIO_SIZEOF_AC_FEATURE_UNIT_DESC(ch, n) (7 + ch * n)
|
#define AUDIO_SIZEOF_AC_FEATURE_UNIT_DESC(ch, n) (7 + (ch + 1) * n)
|
||||||
|
|
||||||
struct audio_cs_if_as_general_descriptor {
|
struct audio_cs_if_as_general_descriptor {
|
||||||
uint8_t bLength;
|
uint8_t bLength;
|
||||||
|
@ -754,7 +760,7 @@ struct audio_cs_ep_ep_general_descriptor {
|
||||||
__VA_ARGS__, /* bmaControls(0) Mute */ \
|
__VA_ARGS__, /* bmaControls(0) Mute */ \
|
||||||
0x00 /* iTerminal */
|
0x00 /* iTerminal */
|
||||||
|
|
||||||
#define AUDIO_AS_DESCRIPTOR_INIT(bInterfaceNumber, bTerminalLink, bNrChannels, bEndpointAddress, wMaxPacketSize, bInterval, ...) \
|
#define AUDIO_AS_DESCRIPTOR_INIT(bInterfaceNumber, bTerminalLink, bNrChannels, bSubFrameSize, bBitResolution, bEndpointAddress, wMaxPacketSize, bInterval, ...) \
|
||||||
0x09, /* bLength */ \
|
0x09, /* bLength */ \
|
||||||
USB_DESCRIPTOR_TYPE_INTERFACE, /* bDescriptorType */ \
|
USB_DESCRIPTOR_TYPE_INTERFACE, /* bDescriptorType */ \
|
||||||
bInterfaceNumber, /* bInterfaceNumber */ \
|
bInterfaceNumber, /* bInterfaceNumber */ \
|
||||||
|
@ -784,8 +790,8 @@ struct audio_cs_ep_ep_general_descriptor {
|
||||||
AUDIO_STREAMING_FORMAT_TYPE, /* bDescriptorSubtype */ \
|
AUDIO_STREAMING_FORMAT_TYPE, /* bDescriptorSubtype */ \
|
||||||
AUDIO_FORMAT_TYPE_I, /* bFormatType */ \
|
AUDIO_FORMAT_TYPE_I, /* bFormatType */ \
|
||||||
bNrChannels, /* bNrChannels */ \
|
bNrChannels, /* bNrChannels */ \
|
||||||
0x02, /* bSubFrameSize : 2 Bytes per audio subframe */ \
|
bSubFrameSize, /* bSubFrameSize : Bytes per audio subframe */ \
|
||||||
0x10, /* bBitResolution : 16 bits per sample */ \
|
bBitResolution, /* bBitResolution : bits per sample */ \
|
||||||
(PP_NARG(__VA_ARGS__)/3), /* bSamFreqType : only one frequency supported */ \
|
(PP_NARG(__VA_ARGS__)/3), /* bSamFreqType : only one frequency supported */ \
|
||||||
__VA_ARGS__, /* tSamFreq : Audio sampling frequency coded on 3 bytes */ \
|
__VA_ARGS__, /* tSamFreq : Audio sampling frequency coded on 3 bytes */ \
|
||||||
0x09, /* bLength */ \
|
0x09, /* bLength */ \
|
||||||
|
@ -905,7 +911,7 @@ struct audio_v2_cs_if_ac_feature_unit_descriptor {
|
||||||
uint8_t iFeature;
|
uint8_t iFeature;
|
||||||
} __PACKED;
|
} __PACKED;
|
||||||
|
|
||||||
#define AUDIO_V2_SIZEOF_AC_FEATURE_UNIT_DESC(ch) (6 + ch * 4)
|
#define AUDIO_V2_SIZEOF_AC_FEATURE_UNIT_DESC(ch) (6 + (ch + 1) * 4)
|
||||||
|
|
||||||
struct audio_v2_cs_if_as_general_descriptor {
|
struct audio_v2_cs_if_as_general_descriptor {
|
||||||
uint8_t bLength;
|
uint8_t bLength;
|
||||||
|
@ -959,7 +965,7 @@ struct audio_v2_control_range3_param_block {
|
||||||
bFirstInterface, \
|
bFirstInterface, \
|
||||||
bInterfaceCount, \
|
bInterfaceCount, \
|
||||||
USB_DEVICE_CLASS_AUDIO, \
|
USB_DEVICE_CLASS_AUDIO, \
|
||||||
AUDIO_SUBCLASS_AUDIOCONTROL, \
|
AUDIO_SUBCLASS_UNDEFINED, \
|
||||||
AUDIO_PROTOCOLv20, \
|
AUDIO_PROTOCOLv20, \
|
||||||
0x00, \
|
0x00, \
|
||||||
/* ------------------ AudioControl Interface ------------------ */\
|
/* ------------------ AudioControl Interface ------------------ */\
|
||||||
|
@ -1049,10 +1055,10 @@ struct audio_v2_control_range3_param_block {
|
||||||
0x10, /* bLength */ \
|
0x10, /* bLength */ \
|
||||||
AUDIO_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */ \
|
AUDIO_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */ \
|
||||||
AUDIO_STREAMING_GENERAL, /* bDescriptorSubtype */ \
|
AUDIO_STREAMING_GENERAL, /* bDescriptorSubtype */ \
|
||||||
bTerminalLink, /* bTerminalLink : Unit ID of the Output Terminal*/ \
|
bTerminalLink, /* bTerminalLink : Unit ID of the Output or Input Terminal*/ \
|
||||||
0x00, /* bmControls */ \
|
0x00, /* bmControls */ \
|
||||||
AUDIO_FORMAT_TYPE_I, /* bFormatType : AUDIO_FORMAT_TYPE_I */ \
|
AUDIO_FORMAT_TYPE_I, /* bFormatType : AUDIO_FORMAT_TYPE_I */ \
|
||||||
DBVAL(AUDIO_FORMAT_PCM), /* bmFormats PCM */ \
|
DBVAL(AUDIO_V2_FORMAT_PCM), /* bmFormats PCM */ \
|
||||||
bNrChannels, /* bNrChannels */ \
|
bNrChannels, /* bNrChannels */ \
|
||||||
DBVAL(bmChannelConfig), /* bmChannelConfig */ \
|
DBVAL(bmChannelConfig), /* bmChannelConfig */ \
|
||||||
0x00, /* iChannelNames */ \
|
0x00, /* iChannelNames */ \
|
||||||
|
@ -1063,10 +1069,10 @@ struct audio_v2_control_range3_param_block {
|
||||||
bSubslotSize, /* bSubslotSize */ \
|
bSubslotSize, /* bSubslotSize */ \
|
||||||
bBitResolution, /* bBitResolution */ \
|
bBitResolution, /* bBitResolution */ \
|
||||||
0x07, /* bLength */ \
|
0x07, /* bLength */ \
|
||||||
0x05, /* bDescriptorType */ \
|
USB_DESCRIPTOR_TYPE_ENDPOINT, /* bDescriptorType */ \
|
||||||
bEndpointAddress, /* bEndpointAddress 3 out endpoint for Audio */ \
|
bEndpointAddress, /* bEndpointAddress 3 out endpoint for Audio */ \
|
||||||
0x01, /* bmAttributes */ \
|
0x01, /* bmAttributes */ \
|
||||||
WBVAL(wMaxPacketSize), /* XXXX wMaxPacketSize in Bytes (Freq(Samples)*2(Stereo)*2(HalfWord)) */ \
|
WBVAL(wMaxPacketSize), /* XXXX wMaxPacketSize in Bytes (SampleRate * SlotByteSize * NumChannels) */ \
|
||||||
bInterval, /* bInterval */ \
|
bInterval, /* bInterval */ \
|
||||||
0x08, /* bLength */ \
|
0x08, /* bLength */ \
|
||||||
AUDIO_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */ \
|
AUDIO_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */ \
|
||||||
|
|
|
@ -46,36 +46,6 @@ struct audio_entity_info {
|
||||||
|
|
||||||
static usb_slist_t usbd_audio_entity_info_head = USB_SLIST_OBJECT_INIT(usbd_audio_entity_info_head);
|
static usb_slist_t usbd_audio_entity_info_head = USB_SLIST_OBJECT_INIT(usbd_audio_entity_info_head);
|
||||||
|
|
||||||
#if CONFIG_USBDEV_AUDIO_VERSION >= 0x0200
|
|
||||||
const uint8_t default_sampling_freq_table[] = {
|
|
||||||
AUDIO_SAMPLE_FREQ_NUM(1),
|
|
||||||
// AUDIO_SAMPLE_FREQ_4B(8000),
|
|
||||||
// AUDIO_SAMPLE_FREQ_4B(8000),
|
|
||||||
// AUDIO_SAMPLE_FREQ_4B(0x00),
|
|
||||||
AUDIO_SAMPLE_FREQ_4B(16000),
|
|
||||||
AUDIO_SAMPLE_FREQ_4B(16000),
|
|
||||||
AUDIO_SAMPLE_FREQ_4B(0x00),
|
|
||||||
AUDIO_SAMPLE_FREQ_4B(32000),
|
|
||||||
AUDIO_SAMPLE_FREQ_4B(32000),
|
|
||||||
AUDIO_SAMPLE_FREQ_4B(0x00),
|
|
||||||
AUDIO_SAMPLE_FREQ_4B(44100),
|
|
||||||
AUDIO_SAMPLE_FREQ_4B(44100),
|
|
||||||
AUDIO_SAMPLE_FREQ_4B(0x00),
|
|
||||||
AUDIO_SAMPLE_FREQ_4B(48000),
|
|
||||||
AUDIO_SAMPLE_FREQ_4B(48000),
|
|
||||||
AUDIO_SAMPLE_FREQ_4B(0x00),
|
|
||||||
AUDIO_SAMPLE_FREQ_4B(88200),
|
|
||||||
AUDIO_SAMPLE_FREQ_4B(88200),
|
|
||||||
AUDIO_SAMPLE_FREQ_4B(0x00),
|
|
||||||
AUDIO_SAMPLE_FREQ_4B(96000),
|
|
||||||
AUDIO_SAMPLE_FREQ_4B(96000),
|
|
||||||
AUDIO_SAMPLE_FREQ_4B(0x00),
|
|
||||||
AUDIO_SAMPLE_FREQ_4B(192000),
|
|
||||||
AUDIO_SAMPLE_FREQ_4B(192000),
|
|
||||||
AUDIO_SAMPLE_FREQ_4B(0x00),
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if CONFIG_USBDEV_AUDIO_VERSION < 0x0200
|
#if CONFIG_USBDEV_AUDIO_VERSION < 0x0200
|
||||||
static int audio_class_endpoint_request_handler(struct usb_setup_packet *setup, uint8_t **data, uint32_t *len)
|
static int audio_class_endpoint_request_handler(struct usb_setup_packet *setup, uint8_t **data, uint32_t *len)
|
||||||
{
|
{
|
||||||
|
@ -109,6 +79,7 @@ static int audio_class_endpoint_request_handler(struct usb_setup_packet *setup,
|
||||||
sampling_freq = 16000;
|
sampling_freq = 16000;
|
||||||
memcpy(*data, &sampling_freq, 4);
|
memcpy(*data, &sampling_freq, 4);
|
||||||
*len = 4;
|
*len = 4;
|
||||||
|
USB_LOG_DBG("Get ep:%02x %d Hz\r\n", ep, (int)sampling_freq);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
USB_LOG_WRN("Unhandled Audio Class bRequest 0x%02x\r\n", setup->bRequest);
|
USB_LOG_WRN("Unhandled Audio Class bRequest 0x%02x\r\n", setup->bRequest);
|
||||||
|
@ -246,6 +217,7 @@ static int audio_class_interface_request_handler(struct usb_setup_packet *setup,
|
||||||
*len = 1;
|
*len = 1;
|
||||||
} else {
|
} else {
|
||||||
mute = (*data)[0];
|
mute = (*data)[0];
|
||||||
|
current_feature_control->mute_bCUR = mute;
|
||||||
USB_LOG_DBG("Set UnitId:%d ch[%d] mute %s\r\n", entity_id, ch, mute_string[mute]);
|
USB_LOG_DBG("Set UnitId:%d ch[%d] mute %s\r\n", entity_id, ch, mute_string[mute]);
|
||||||
usbd_audio_set_mute(entity_id, ch, mute);
|
usbd_audio_set_mute(entity_id, ch, mute);
|
||||||
}
|
}
|
||||||
|
@ -299,6 +271,7 @@ static int audio_class_interface_request_handler(struct usb_setup_packet *setup,
|
||||||
case AUDIO_CS_CONTROL_SAM_FREQ:
|
case AUDIO_CS_CONTROL_SAM_FREQ:
|
||||||
if (setup->bmRequestType & USB_REQUEST_DIR_MASK) {
|
if (setup->bmRequestType & USB_REQUEST_DIR_MASK) {
|
||||||
memcpy(*data, &sampling_freq[ch], sizeof(uint32_t));
|
memcpy(*data, &sampling_freq[ch], sizeof(uint32_t));
|
||||||
|
USB_LOG_DBG("Get ClockId:%d ch[%d] %d Hz\r\n", entity_id, ch, (int)sampling_freq[ch]);
|
||||||
*len = 4;
|
*len = 4;
|
||||||
} else {
|
} else {
|
||||||
memcpy(&sampling_freq[ch], *data, setup->wLength);
|
memcpy(&sampling_freq[ch], *data, setup->wLength);
|
||||||
|
@ -327,8 +300,9 @@ static int audio_class_interface_request_handler(struct usb_setup_packet *setup,
|
||||||
|
|
||||||
usbd_audio_get_sampling_freq_table(entity_id, &sampling_freq_table);
|
usbd_audio_get_sampling_freq_table(entity_id, &sampling_freq_table);
|
||||||
num = (uint16_t)((uint16_t)(sampling_freq_table[1] << 8) | ((uint16_t)sampling_freq_table[0]));
|
num = (uint16_t)((uint16_t)(sampling_freq_table[1] << 8) | ((uint16_t)sampling_freq_table[0]));
|
||||||
*data = sampling_freq_table;
|
memcpy(*data, sampling_freq_table, (12 * num + 2));
|
||||||
*len = (12 * num + 2);
|
*len = (12 * num + 2);
|
||||||
|
USB_LOG_DBG("Get sampling_freq_table entity_id:%d ch[%d] addr:%x\r\n", entity_id, ch, (uint32_t)sampling_freq_table);
|
||||||
} else {
|
} else {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -415,7 +389,7 @@ void usbd_audio_add_entity(uint8_t entity_id, uint16_t bDescriptorSubtype)
|
||||||
control->volume.subrange[ch].wMax = 100;
|
control->volume.subrange[ch].wMax = 100;
|
||||||
control->volume.subrange[ch].wRes = 1;
|
control->volume.subrange[ch].wRes = 1;
|
||||||
control->mute[ch] = 0;
|
control->mute[ch] = 0;
|
||||||
control->volume_bCUR = 50;
|
control->volume_bCUR = 0;
|
||||||
control->mute_bCUR = 0;
|
control->mute_bCUR = 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -446,12 +420,13 @@ __WEAK void usbd_audio_set_mute(uint8_t entity_id, uint8_t ch, uint8_t enable)
|
||||||
__WEAK void usbd_audio_set_sampling_freq(uint8_t entity_id, uint8_t ep_ch, uint32_t sampling_freq)
|
__WEAK void usbd_audio_set_sampling_freq(uint8_t entity_id, uint8_t ep_ch, uint32_t sampling_freq)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CONFIG_USBDEV_AUDIO_VERSION >= 0x0200
|
#if CONFIG_USBDEV_AUDIO_VERSION >= 0x0200
|
||||||
__WEAK void usbd_audio_get_sampling_freq_table(uint8_t entity_id, uint8_t **sampling_freq_table)
|
__WEAK void usbd_audio_get_sampling_freq_table(uint8_t entity_id, uint8_t **sampling_freq_table)
|
||||||
{
|
{
|
||||||
*sampling_freq_table = (uint8_t *)default_sampling_freq_table;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__WEAK void usbd_audio_set_pitch(uint8_t ep, bool enable)
|
__WEAK void usbd_audio_set_pitch(uint8_t ep, bool enable)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -387,7 +387,7 @@
|
||||||
#define HID_KBD_USAGE_PAGEDOWN 0x4e /* Keyboard PageDown */
|
#define HID_KBD_USAGE_PAGEDOWN 0x4e /* Keyboard PageDown */
|
||||||
#define HID_KBD_USAGE_RIGHT 0x4f /* eyboard RightArrow */
|
#define HID_KBD_USAGE_RIGHT 0x4f /* eyboard RightArrow */
|
||||||
#define HID_KBD_USAGE_LEFT 0x50 /* Keyboard LeftArrow */
|
#define HID_KBD_USAGE_LEFT 0x50 /* Keyboard LeftArrow */
|
||||||
#define HID_KBD_USAGE_DOWN 0x5a /* Keyboard DownArrow */
|
#define HID_KBD_USAGE_DOWN 0x51 /* Keyboard DownArrow */
|
||||||
#define HID_KBD_USAGE_UP 0x52 /* Keyboard UpArrow */
|
#define HID_KBD_USAGE_UP 0x52 /* Keyboard UpArrow */
|
||||||
#define HID_KBD_USAGE_KPDNUMLOCK 0x53 /* Keypad Num Lock and Clear */
|
#define HID_KBD_USAGE_KPDNUMLOCK 0x53 /* Keypad Num Lock and Clear */
|
||||||
#define HID_KBD_USAGE_KPDNUMLOCKCLEAR 0x53 /* Keypad Num Lock and Clear */
|
#define HID_KBD_USAGE_KPDNUMLOCKCLEAR 0x53 /* Keypad Num Lock and Clear */
|
||||||
|
|
|
@ -14,7 +14,9 @@
|
||||||
|
|
||||||
#define EXTHUB_FIRST_INDEX 2
|
#define EXTHUB_FIRST_INDEX 2
|
||||||
|
|
||||||
|
#if CONFIG_USBHOST_MAX_EXTHUBS > 0
|
||||||
static uint32_t g_devinuse = 0;
|
static uint32_t g_devinuse = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t g_hub_buf[32];
|
USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t g_hub_buf[32];
|
||||||
USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t g_hub_intbuf[CONFIG_USBHOST_MAX_EXTHUBS + 1][1];
|
USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t g_hub_intbuf[CONFIG_USBHOST_MAX_EXTHUBS + 1][1];
|
||||||
|
@ -65,6 +67,7 @@ static void usbh_hub_register(struct usbh_hub *hub)
|
||||||
usb_slist_add_tail(&hub_class_head, &hub->list);
|
usb_slist_add_tail(&hub_class_head, &hub->list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if CONFIG_USBHOST_MAX_EXTHUBS > 0
|
||||||
static void usbh_hub_unregister(struct usbh_hub *hub)
|
static void usbh_hub_unregister(struct usbh_hub *hub)
|
||||||
{
|
{
|
||||||
usb_slist_remove(&hub_class_head, &hub->list);
|
usb_slist_remove(&hub_class_head, &hub->list);
|
||||||
|
@ -111,6 +114,7 @@ static int _usbh_hub_get_status(struct usbh_hub *hub, uint8_t *buffer)
|
||||||
memcpy(buffer, g_hub_buf, 2);
|
memcpy(buffer, g_hub_buf, 2);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static int _usbh_hub_get_portstatus(struct usbh_hub *hub, uint8_t port, struct hub_port_status *port_status)
|
static int _usbh_hub_get_portstatus(struct usbh_hub *hub, uint8_t port, struct hub_port_status *port_status)
|
||||||
{
|
{
|
||||||
|
@ -163,6 +167,7 @@ static int _usbh_hub_clear_feature(struct usbh_hub *hub, uint8_t port, uint8_t f
|
||||||
return usbh_control_transfer(hub->parent->ep0, setup, NULL);
|
return usbh_control_transfer(hub->parent->ep0, setup, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if CONFIG_USBHOST_MAX_EXTHUBS > 0
|
||||||
static int parse_hub_descriptor(struct usb_hub_descriptor *desc, uint16_t length)
|
static int parse_hub_descriptor(struct usb_hub_descriptor *desc, uint16_t length)
|
||||||
{
|
{
|
||||||
if (desc->bLength != USB_SIZEOF_HUB_DESC) {
|
if (desc->bLength != USB_SIZEOF_HUB_DESC) {
|
||||||
|
@ -184,6 +189,7 @@ static int parse_hub_descriptor(struct usb_hub_descriptor *desc, uint16_t length
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static int usbh_hub_get_portstatus(struct usbh_hub *hub, uint8_t port, struct hub_port_status *port_status)
|
static int usbh_hub_get_portstatus(struct usbh_hub *hub, uint8_t port, struct hub_port_status *port_status)
|
||||||
{
|
{
|
||||||
|
|
|
@ -53,36 +53,32 @@ static int usbh_msc_get_maxlun(struct usbh_msc *msc_class, uint8_t *buffer)
|
||||||
|
|
||||||
static void usbh_msc_cbw_dump(struct CBW *cbw)
|
static void usbh_msc_cbw_dump(struct CBW *cbw)
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
USB_LOG_INFO("CBW:\r\n");
|
USB_LOG_DBG("CBW:\r\n");
|
||||||
USB_LOG_INFO(" signature: 0x%08x\r\n", (unsigned int)cbw->dSignature);
|
USB_LOG_DBG(" signature: 0x%08x\r\n", (unsigned int)cbw->dSignature);
|
||||||
USB_LOG_INFO(" tag: 0x%08x\r\n", (unsigned int)cbw->dTag);
|
USB_LOG_DBG(" tag: 0x%08x\r\n", (unsigned int)cbw->dTag);
|
||||||
USB_LOG_INFO(" datlen: 0x%08x\r\n", (unsigned int)cbw->dDataLength);
|
USB_LOG_DBG(" datlen: 0x%08x\r\n", (unsigned int)cbw->dDataLength);
|
||||||
USB_LOG_INFO(" flags: 0x%02x\r\n", cbw->bmFlags);
|
USB_LOG_DBG(" flags: 0x%02x\r\n", cbw->bmFlags);
|
||||||
USB_LOG_INFO(" lun: 0x%02x\r\n", cbw->bLUN);
|
USB_LOG_DBG(" lun: 0x%02x\r\n", cbw->bLUN);
|
||||||
USB_LOG_INFO(" cblen: 0x%02x\r\n", cbw->bCBLength);
|
USB_LOG_DBG(" cblen: 0x%02x\r\n", cbw->bCBLength);
|
||||||
|
|
||||||
USB_LOG_INFO("CB:\r\n");
|
USB_LOG_DBG("CB:\r\n");
|
||||||
for (i = 0; i < cbw->bCBLength; i += 8) {
|
for (i = 0; i < cbw->bCBLength; i += 8) {
|
||||||
USB_LOG_INFO(" 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\r\n",
|
USB_LOG_DBG(" 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\r\n",
|
||||||
cbw->CB[i], cbw->CB[i + 1], cbw->CB[i + 2],
|
cbw->CB[i], cbw->CB[i + 1], cbw->CB[i + 2],
|
||||||
cbw->CB[i + 3], cbw->CB[i + 4], cbw->CB[i + 5],
|
cbw->CB[i + 3], cbw->CB[i + 4], cbw->CB[i + 5],
|
||||||
cbw->CB[i + 6], cbw->CB[i + 7]);
|
cbw->CB[i + 6], cbw->CB[i + 7]);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void usbh_msc_csw_dump(struct CSW *csw)
|
static void usbh_msc_csw_dump(struct CSW *csw)
|
||||||
{
|
{
|
||||||
#if 0
|
USB_LOG_DBG("CSW:\r\n");
|
||||||
USB_LOG_INFO("CSW:\r\n");
|
USB_LOG_DBG(" signature: 0x%08x\r\n", (unsigned int)csw->dSignature);
|
||||||
USB_LOG_INFO(" signature: 0x%08x\r\n", (unsigned int)csw->dSignature);
|
USB_LOG_DBG(" tag: 0x%08x\r\n", (unsigned int)csw->dTag);
|
||||||
USB_LOG_INFO(" tag: 0x%08x\r\n", (unsigned int)csw->dTag);
|
USB_LOG_DBG(" residue: 0x%08x\r\n", (unsigned int)csw->dDataResidue);
|
||||||
USB_LOG_INFO(" residue: 0x%08x\r\n", (unsigned int)csw->dDataResidue);
|
USB_LOG_DBG(" status: 0x%02x\r\n", csw->bStatus);
|
||||||
USB_LOG_INFO(" status: 0x%02x\r\n", csw->bStatus);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int usbh_msc_bulk_in_transfer(struct usbh_msc *msc_class, uint8_t *buffer, uint32_t buflen, uint32_t timeout)
|
static inline int usbh_msc_bulk_in_transfer(struct usbh_msc *msc_class, uint8_t *buffer, uint32_t buflen, uint32_t timeout)
|
||||||
|
@ -113,9 +109,65 @@ static inline int usbh_msc_bulk_out_transfer(struct usbh_msc *msc_class, uint8_t
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int usbh_msc_scsi_testunitready(struct usbh_msc *msc_class)
|
int usbh_bulk_cbw_csw_xfer(struct usbh_msc *msc_class, struct CBW *cbw, struct CSW *csw, uint8_t *buffer)
|
||||||
{
|
{
|
||||||
int nbytes;
|
int nbytes;
|
||||||
|
|
||||||
|
usbh_msc_cbw_dump(cbw);
|
||||||
|
|
||||||
|
/* Send the CBW */
|
||||||
|
nbytes = usbh_msc_bulk_out_transfer(msc_class, (uint8_t *)cbw, USB_SIZEOF_MSC_CBW, CONFIG_USBHOST_MSC_TIMEOUT);
|
||||||
|
if (nbytes < 0) {
|
||||||
|
USB_LOG_ERR("cbw transfer error\n");
|
||||||
|
goto __err_exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cbw->dDataLength != 0) {
|
||||||
|
if (cbw->CB[0] == SCSI_CMD_WRITE10) {
|
||||||
|
nbytes = usbh_msc_bulk_out_transfer(msc_class, buffer, cbw->dDataLength, CONFIG_USBHOST_MSC_TIMEOUT);
|
||||||
|
} else if (cbw->CB[0] == SCSI_CMD_READCAPACITY10) {
|
||||||
|
nbytes = usbh_msc_bulk_in_transfer(msc_class, buffer, cbw->dDataLength, CONFIG_USBHOST_MSC_TIMEOUT);
|
||||||
|
if (nbytes >= 0) {
|
||||||
|
/* Save the capacity information */
|
||||||
|
msc_class->blocknum = GET_BE32(&buffer[0]) + 1;
|
||||||
|
msc_class->blocksize = GET_BE32(&buffer[4]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
nbytes = usbh_msc_bulk_in_transfer(msc_class, buffer, cbw->dDataLength, CONFIG_USBHOST_MSC_TIMEOUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nbytes < 0) {
|
||||||
|
USB_LOG_ERR("csw cbw data response error\n");
|
||||||
|
goto __err_exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Receive the CSW */
|
||||||
|
memset(csw, 0, USB_SIZEOF_MSC_CSW);
|
||||||
|
nbytes = usbh_msc_bulk_in_transfer(msc_class, (uint8_t *)csw, USB_SIZEOF_MSC_CSW, CONFIG_USBHOST_MSC_TIMEOUT);
|
||||||
|
if (nbytes < 0) {
|
||||||
|
USB_LOG_ERR("csw transfer error\r\n");
|
||||||
|
goto __err_exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
usbh_msc_csw_dump(csw);
|
||||||
|
|
||||||
|
/* check csw status */
|
||||||
|
if (csw->dSignature != MSC_CSW_Signature) {
|
||||||
|
USB_LOG_ERR("csw signature error\r\n");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (csw->bStatus != 0) {
|
||||||
|
USB_LOG_ERR("csw bStatus %d\r\n", csw->bStatus);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
__err_exit:
|
||||||
|
return nbytes < 0 ? (int)nbytes : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int usbh_msc_scsi_testunitready(struct usbh_msc *msc_class)
|
||||||
|
{
|
||||||
struct CBW *cbw;
|
struct CBW *cbw;
|
||||||
|
|
||||||
/* Construct the CBW */
|
/* Construct the CBW */
|
||||||
|
@ -126,22 +178,11 @@ static inline int usbh_msc_scsi_testunitready(struct usbh_msc *msc_class)
|
||||||
cbw->bCBLength = SCSICMD_TESTUNITREADY_SIZEOF;
|
cbw->bCBLength = SCSICMD_TESTUNITREADY_SIZEOF;
|
||||||
cbw->CB[0] = SCSI_CMD_TESTUNITREADY;
|
cbw->CB[0] = SCSI_CMD_TESTUNITREADY;
|
||||||
|
|
||||||
usbh_msc_cbw_dump(cbw);
|
return usbh_bulk_cbw_csw_xfer(msc_class, cbw, (struct CSW *)g_msc_buf, NULL);
|
||||||
/* Send the CBW */
|
|
||||||
nbytes = usbh_msc_bulk_out_transfer(msc_class, (uint8_t *)cbw, USB_SIZEOF_MSC_CBW, CONFIG_USBHOST_MSC_TIMEOUT);
|
|
||||||
if (nbytes >= 0) {
|
|
||||||
/* Receive the CSW */
|
|
||||||
nbytes = usbh_msc_bulk_in_transfer(msc_class, g_msc_buf, USB_SIZEOF_MSC_CSW, CONFIG_USBHOST_MSC_TIMEOUT);
|
|
||||||
if (nbytes >= 0) {
|
|
||||||
usbh_msc_csw_dump((struct CSW *)g_msc_buf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nbytes < 0 ? (int)nbytes : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int usbh_msc_scsi_requestsense(struct usbh_msc *msc_class)
|
static inline int usbh_msc_scsi_requestsense(struct usbh_msc *msc_class)
|
||||||
{
|
{
|
||||||
int nbytes;
|
|
||||||
struct CBW *cbw;
|
struct CBW *cbw;
|
||||||
|
|
||||||
/* Construct the CBW */
|
/* Construct the CBW */
|
||||||
|
@ -155,26 +196,11 @@ static inline int usbh_msc_scsi_requestsense(struct usbh_msc *msc_class)
|
||||||
cbw->CB[0] = SCSI_CMD_REQUESTSENSE;
|
cbw->CB[0] = SCSI_CMD_REQUESTSENSE;
|
||||||
cbw->CB[4] = SCSIRESP_FIXEDSENSEDATA_SIZEOF;
|
cbw->CB[4] = SCSIRESP_FIXEDSENSEDATA_SIZEOF;
|
||||||
|
|
||||||
usbh_msc_cbw_dump(cbw);
|
return usbh_bulk_cbw_csw_xfer(msc_class, cbw, (struct CSW *)g_msc_buf, NULL);
|
||||||
/* Send the CBW */
|
|
||||||
nbytes = usbh_msc_bulk_out_transfer(msc_class, (uint8_t *)cbw, USB_SIZEOF_MSC_CBW, CONFIG_USBHOST_MSC_TIMEOUT);
|
|
||||||
if (nbytes >= 0) {
|
|
||||||
/* Receive the sense data response */
|
|
||||||
nbytes = usbh_msc_bulk_in_transfer(msc_class, g_msc_buf, SCSIRESP_FIXEDSENSEDATA_SIZEOF, CONFIG_USBHOST_MSC_TIMEOUT);
|
|
||||||
if (nbytes >= 0) {
|
|
||||||
/* Receive the CSW */
|
|
||||||
nbytes = usbh_msc_bulk_in_transfer(msc_class, g_msc_buf, USB_SIZEOF_MSC_CSW, CONFIG_USBHOST_MSC_TIMEOUT);
|
|
||||||
if (nbytes >= 0) {
|
|
||||||
usbh_msc_csw_dump((struct CSW *)g_msc_buf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nbytes < 0 ? (int)nbytes : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int usbh_msc_scsi_inquiry(struct usbh_msc *msc_class)
|
static inline int usbh_msc_scsi_inquiry(struct usbh_msc *msc_class)
|
||||||
{
|
{
|
||||||
int nbytes;
|
|
||||||
struct CBW *cbw;
|
struct CBW *cbw;
|
||||||
|
|
||||||
/* Construct the CBW */
|
/* Construct the CBW */
|
||||||
|
@ -188,21 +214,7 @@ static inline int usbh_msc_scsi_inquiry(struct usbh_msc *msc_class)
|
||||||
cbw->CB[0] = SCSI_CMD_INQUIRY;
|
cbw->CB[0] = SCSI_CMD_INQUIRY;
|
||||||
cbw->CB[4] = SCSIRESP_INQUIRY_SIZEOF;
|
cbw->CB[4] = SCSIRESP_INQUIRY_SIZEOF;
|
||||||
|
|
||||||
usbh_msc_cbw_dump(cbw);
|
return usbh_bulk_cbw_csw_xfer(msc_class, cbw, (struct CSW *)g_msc_buf, g_msc_buf);
|
||||||
/* Send the CBW */
|
|
||||||
nbytes = usbh_msc_bulk_out_transfer(msc_class, (uint8_t *)cbw, USB_SIZEOF_MSC_CBW, CONFIG_USBHOST_MSC_TIMEOUT);
|
|
||||||
if (nbytes >= 0) {
|
|
||||||
/* Receive the sense data response */
|
|
||||||
nbytes = usbh_msc_bulk_in_transfer(msc_class, g_msc_buf, SCSIRESP_INQUIRY_SIZEOF, CONFIG_USBHOST_MSC_TIMEOUT);
|
|
||||||
if (nbytes >= 0) {
|
|
||||||
/* Receive the CSW */
|
|
||||||
nbytes = usbh_msc_bulk_in_transfer(msc_class, g_msc_buf, USB_SIZEOF_MSC_CSW, CONFIG_USBHOST_MSC_TIMEOUT);
|
|
||||||
if (nbytes >= 0) {
|
|
||||||
usbh_msc_csw_dump((struct CSW *)g_msc_buf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nbytes < 0 ? (int)nbytes : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int usbh_msc_scsi_readcapacity10(struct usbh_msc *msc_class)
|
static inline int usbh_msc_scsi_readcapacity10(struct usbh_msc *msc_class)
|
||||||
|
@ -220,29 +232,11 @@ static inline int usbh_msc_scsi_readcapacity10(struct usbh_msc *msc_class)
|
||||||
cbw->bCBLength = SCSICMD_READCAPACITY10_SIZEOF;
|
cbw->bCBLength = SCSICMD_READCAPACITY10_SIZEOF;
|
||||||
cbw->CB[0] = SCSI_CMD_READCAPACITY10;
|
cbw->CB[0] = SCSI_CMD_READCAPACITY10;
|
||||||
|
|
||||||
usbh_msc_cbw_dump(cbw);
|
return usbh_bulk_cbw_csw_xfer(msc_class, cbw, (struct CSW *)g_msc_buf, g_msc_buf);
|
||||||
/* Send the CBW */
|
|
||||||
nbytes = usbh_msc_bulk_out_transfer(msc_class, (uint8_t *)cbw, USB_SIZEOF_MSC_CBW, CONFIG_USBHOST_MSC_TIMEOUT);
|
|
||||||
if (nbytes >= 0) {
|
|
||||||
/* Receive the sense data response */
|
|
||||||
nbytes = usbh_msc_bulk_in_transfer(msc_class, g_msc_buf, SCSIRESP_READCAPACITY10_SIZEOF, CONFIG_USBHOST_MSC_TIMEOUT);
|
|
||||||
if (nbytes >= 0) {
|
|
||||||
/* Save the capacity information */
|
|
||||||
msc_class->blocknum = GET_BE32(&g_msc_buf[0]) + 1;
|
|
||||||
msc_class->blocksize = GET_BE32(&g_msc_buf[4]);
|
|
||||||
/* Receive the CSW */
|
|
||||||
nbytes = usbh_msc_bulk_in_transfer(msc_class, g_msc_buf, USB_SIZEOF_MSC_CSW, CONFIG_USBHOST_MSC_TIMEOUT);
|
|
||||||
if (nbytes >= 0) {
|
|
||||||
usbh_msc_csw_dump((struct CSW *)g_msc_buf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nbytes < 0 ? (int)nbytes : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int usbh_msc_scsi_write10(struct usbh_msc *msc_class, uint32_t start_sector, const uint8_t *buffer, uint32_t nsectors)
|
int usbh_msc_scsi_write10(struct usbh_msc *msc_class, uint32_t start_sector, const uint8_t *buffer, uint32_t nsectors)
|
||||||
{
|
{
|
||||||
int nbytes;
|
|
||||||
struct CBW *cbw;
|
struct CBW *cbw;
|
||||||
|
|
||||||
/* Construct the CBW */
|
/* Construct the CBW */
|
||||||
|
@ -257,26 +251,11 @@ int usbh_msc_scsi_write10(struct usbh_msc *msc_class, uint32_t start_sector, con
|
||||||
SET_BE32(&cbw->CB[2], start_sector);
|
SET_BE32(&cbw->CB[2], start_sector);
|
||||||
SET_BE16(&cbw->CB[7], nsectors);
|
SET_BE16(&cbw->CB[7], nsectors);
|
||||||
|
|
||||||
usbh_msc_cbw_dump(cbw);
|
return usbh_bulk_cbw_csw_xfer(msc_class, cbw, (struct CSW *)g_msc_buf, (uint8_t *)buffer);
|
||||||
/* Send the CBW */
|
|
||||||
nbytes = usbh_msc_bulk_out_transfer(msc_class, (uint8_t *)cbw, USB_SIZEOF_MSC_CBW, CONFIG_USBHOST_MSC_TIMEOUT);
|
|
||||||
if (nbytes >= 0) {
|
|
||||||
/* Send the user data */
|
|
||||||
nbytes = usbh_msc_bulk_out_transfer(msc_class, (uint8_t *)buffer, msc_class->blocksize * nsectors, CONFIG_USBHOST_MSC_TIMEOUT);
|
|
||||||
if (nbytes >= 0) {
|
|
||||||
/* Receive the CSW */
|
|
||||||
nbytes = usbh_msc_bulk_in_transfer(msc_class, g_msc_buf, USB_SIZEOF_MSC_CSW, CONFIG_USBHOST_MSC_TIMEOUT);
|
|
||||||
if (nbytes >= 0) {
|
|
||||||
usbh_msc_csw_dump((struct CSW *)g_msc_buf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nbytes < 0 ? (int)nbytes : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int usbh_msc_scsi_read10(struct usbh_msc *msc_class, uint32_t start_sector, const uint8_t *buffer, uint32_t nsectors)
|
int usbh_msc_scsi_read10(struct usbh_msc *msc_class, uint32_t start_sector, const uint8_t *buffer, uint32_t nsectors)
|
||||||
{
|
{
|
||||||
int nbytes;
|
|
||||||
struct CBW *cbw;
|
struct CBW *cbw;
|
||||||
|
|
||||||
/* Construct the CBW */
|
/* Construct the CBW */
|
||||||
|
@ -292,21 +271,7 @@ int usbh_msc_scsi_read10(struct usbh_msc *msc_class, uint32_t start_sector, cons
|
||||||
SET_BE32(&cbw->CB[2], start_sector);
|
SET_BE32(&cbw->CB[2], start_sector);
|
||||||
SET_BE16(&cbw->CB[7], nsectors);
|
SET_BE16(&cbw->CB[7], nsectors);
|
||||||
|
|
||||||
usbh_msc_cbw_dump(cbw);
|
return usbh_bulk_cbw_csw_xfer(msc_class, cbw, (struct CSW *)g_msc_buf, (uint8_t *)buffer);
|
||||||
/* Send the CBW */
|
|
||||||
nbytes = usbh_msc_bulk_out_transfer(msc_class, (uint8_t *)cbw, USB_SIZEOF_MSC_CBW, CONFIG_USBHOST_MSC_TIMEOUT);
|
|
||||||
if (nbytes >= 0) {
|
|
||||||
/* Receive the user data */
|
|
||||||
nbytes = usbh_msc_bulk_in_transfer(msc_class, (uint8_t *)buffer, msc_class->blocksize * nsectors, CONFIG_USBHOST_MSC_TIMEOUT);
|
|
||||||
if (nbytes >= 0) {
|
|
||||||
/* Receive the CSW */
|
|
||||||
nbytes = usbh_msc_bulk_in_transfer(msc_class, g_msc_buf, USB_SIZEOF_MSC_CSW, CONFIG_USBHOST_MSC_TIMEOUT);
|
|
||||||
if (nbytes >= 0) {
|
|
||||||
usbh_msc_csw_dump((struct CSW *)g_msc_buf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nbytes < 0 ? (int)nbytes : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int usbh_msc_connect(struct usbh_hubport *hport, uint8_t intf)
|
static int usbh_msc_connect(struct usbh_hubport *hport, uint8_t intf)
|
||||||
|
@ -345,16 +310,17 @@ static int usbh_msc_connect(struct usbh_hubport *hport, uint8_t intf)
|
||||||
|
|
||||||
ret = usbh_msc_scsi_testunitready(msc_class);
|
ret = usbh_msc_scsi_testunitready(msc_class);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
USB_LOG_ERR("Fail to scsi_testunitready\r\n");
|
ret = usbh_msc_scsi_requestsense(msc_class);
|
||||||
return ret;
|
if (ret < 0) {
|
||||||
|
USB_LOG_ERR("Fail to scsi_testunitready\r\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = usbh_msc_scsi_inquiry(msc_class);
|
ret = usbh_msc_scsi_inquiry(msc_class);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
USB_LOG_ERR("Fail to scsi_inquiry\r\n");
|
USB_LOG_ERR("Fail to scsi_inquiry\r\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = usbh_msc_scsi_readcapacity10(msc_class);
|
ret = usbh_msc_scsi_readcapacity10(msc_class);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
USB_LOG_ERR("Fail to scsi_readcapacity10\r\n");
|
USB_LOG_ERR("Fail to scsi_readcapacity10\r\n");
|
||||||
|
@ -407,12 +373,10 @@ static int usbh_msc_disconnect(struct usbh_hubport *hport, uint8_t intf)
|
||||||
|
|
||||||
__WEAK void usbh_msc_run(struct usbh_msc *msc_class)
|
__WEAK void usbh_msc_run(struct usbh_msc *msc_class)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
__WEAK void usbh_msc_stop(struct usbh_msc *msc_class)
|
__WEAK void usbh_msc_stop(struct usbh_msc *msc_class)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct usbh_class_driver msc_class_driver = {
|
const struct usbh_class_driver msc_class_driver = {
|
||||||
|
|
|
@ -576,10 +576,10 @@ static int usbd_video_stream_request_handler(struct usb_setup_packet *setup, uin
|
||||||
case VIDEO_VS_PROBE_CONTROL:
|
case VIDEO_VS_PROBE_CONTROL:
|
||||||
switch (setup->bRequest) {
|
switch (setup->bRequest) {
|
||||||
case VIDEO_REQUEST_SET_CUR:
|
case VIDEO_REQUEST_SET_CUR:
|
||||||
//memcpy((uint8_t *)usbd_video_cfg.probe, *data, setup->wLength);
|
//memcpy((uint8_t *)&usbd_video_cfg.probe, *data, setup->wLength);
|
||||||
break;
|
break;
|
||||||
case VIDEO_REQUEST_GET_CUR:
|
case VIDEO_REQUEST_GET_CUR:
|
||||||
*data = (uint8_t *)&usbd_video_cfg.probe;
|
memcpy(*data, (uint8_t *)&usbd_video_cfg.probe, setup->wLength);
|
||||||
*len = sizeof(struct video_probe_and_commit_controls);
|
*len = sizeof(struct video_probe_and_commit_controls);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -587,7 +587,7 @@ static int usbd_video_stream_request_handler(struct usb_setup_packet *setup, uin
|
||||||
case VIDEO_REQUEST_GET_MAX:
|
case VIDEO_REQUEST_GET_MAX:
|
||||||
case VIDEO_REQUEST_GET_RES:
|
case VIDEO_REQUEST_GET_RES:
|
||||||
case VIDEO_REQUEST_GET_DEF:
|
case VIDEO_REQUEST_GET_DEF:
|
||||||
*data = (uint8_t *)&usbd_video_cfg.probe;
|
memcpy(*data, (uint8_t *)&usbd_video_cfg.probe, setup->wLength);
|
||||||
*len = sizeof(struct video_probe_and_commit_controls);
|
*len = sizeof(struct video_probe_and_commit_controls);
|
||||||
break;
|
break;
|
||||||
case VIDEO_REQUEST_GET_LEN:
|
case VIDEO_REQUEST_GET_LEN:
|
||||||
|
@ -608,17 +608,17 @@ static int usbd_video_stream_request_handler(struct usb_setup_packet *setup, uin
|
||||||
case VIDEO_VS_COMMIT_CONTROL:
|
case VIDEO_VS_COMMIT_CONTROL:
|
||||||
switch (setup->bRequest) {
|
switch (setup->bRequest) {
|
||||||
case VIDEO_REQUEST_SET_CUR:
|
case VIDEO_REQUEST_SET_CUR:
|
||||||
//memcpy((uint8_t *)usbd_video_cfg.commit, *data, setup->wLength);
|
//memcpy((uint8_t *)&usbd_video_cfg.commit, *data, setup->wLength);
|
||||||
break;
|
break;
|
||||||
case VIDEO_REQUEST_GET_CUR:
|
case VIDEO_REQUEST_GET_CUR:
|
||||||
*data = (uint8_t *)&usbd_video_cfg.commit;
|
memcpy(*data, (uint8_t *)&usbd_video_cfg.commit, setup->wLength);
|
||||||
*len = sizeof(struct video_probe_and_commit_controls);
|
*len = sizeof(struct video_probe_and_commit_controls);
|
||||||
break;
|
break;
|
||||||
case VIDEO_REQUEST_GET_MIN:
|
case VIDEO_REQUEST_GET_MIN:
|
||||||
case VIDEO_REQUEST_GET_MAX:
|
case VIDEO_REQUEST_GET_MAX:
|
||||||
case VIDEO_REQUEST_GET_RES:
|
case VIDEO_REQUEST_GET_RES:
|
||||||
case VIDEO_REQUEST_GET_DEF:
|
case VIDEO_REQUEST_GET_DEF:
|
||||||
*data = (uint8_t *)&usbd_video_cfg.commit;
|
memcpy(*data, (uint8_t *)&usbd_video_cfg.commit, setup->wLength);
|
||||||
*len = sizeof(struct video_probe_and_commit_controls);
|
*len = sizeof(struct video_probe_and_commit_controls);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -640,7 +640,7 @@ static int usbd_video_stream_request_handler(struct usb_setup_packet *setup, uin
|
||||||
case VIDEO_VS_STREAM_ERROR_CODE_CONTROL:
|
case VIDEO_VS_STREAM_ERROR_CODE_CONTROL:
|
||||||
switch (setup->bRequest) {
|
switch (setup->bRequest) {
|
||||||
case VIDEO_REQUEST_GET_CUR:
|
case VIDEO_REQUEST_GET_CUR:
|
||||||
*data = &usbd_video_cfg.error_code;
|
(*data)[0] = usbd_video_cfg.error_code;
|
||||||
*len = 1;
|
*len = 1;
|
||||||
break;
|
break;
|
||||||
case VIDEO_REQUEST_GET_INFO:
|
case VIDEO_REQUEST_GET_INFO:
|
||||||
|
|
|
@ -85,15 +85,15 @@ uint16_t usbh_get_frame_number(void);
|
||||||
int usbh_roothub_control(struct usb_setup_packet *setup, uint8_t *buf);
|
int usbh_roothub_control(struct usb_setup_packet *setup, uint8_t *buf);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief reconfig control endpoint pipe.
|
* @brief reconfig endpoint pipe.
|
||||||
*
|
*
|
||||||
* @param pipe A memory allocated for pipe.
|
* @param pipe A memory allocated for pipe.
|
||||||
* @param dev_addr device address.
|
* @param dev_addr device address.
|
||||||
* @param ep_mps control endpoint max packet size.
|
* @param ep_mps endpoint max packet size.
|
||||||
* @param speed port speed
|
* @param mult endpoint additional transcation
|
||||||
* @return On success will return 0, and others indicate fail.
|
* @return On success will return 0, and others indicate fail.
|
||||||
*/
|
*/
|
||||||
int usbh_ep0_pipe_reconfigure(usbh_pipe_t pipe, uint8_t dev_addr, uint8_t ep_mps, uint8_t speed);
|
int usbh_ep_pipe_reconfigure(usbh_pipe_t pipe, uint8_t dev_addr, uint8_t ep_mps, uint8_t mult);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Allocate pipe for endpoint
|
* @brief Allocate pipe for endpoint
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
#include "usbd_core.h"
|
#include "usbd_core.h"
|
||||||
#ifdef CONFIG_USBDEV_TX_RX_THREAD
|
#if defined(CONFIG_USBDEV_TX_THREAD) || defined(CONFIG_USBDEV_RX_THREAD)
|
||||||
#include "usb_osal.h"
|
#include "usb_osal.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ USB_NOCACHE_RAM_SECTION struct usbd_core_cfg_priv {
|
||||||
/** Zero length packet flag of control transfer */
|
/** Zero length packet flag of control transfer */
|
||||||
bool zlp_flag;
|
bool zlp_flag;
|
||||||
/** Pointer to registered descriptors */
|
/** Pointer to registered descriptors */
|
||||||
#if defined(CHERRYUSB_VERSION) && (CHERRYUSB_VERSION > 0x000700)
|
#ifdef CONFIG_USBDEV_ADVANCE_DESC
|
||||||
struct usb_descriptor *descriptors;
|
struct usb_descriptor *descriptors;
|
||||||
#else
|
#else
|
||||||
const uint8_t *descriptors;
|
const uint8_t *descriptors;
|
||||||
|
@ -72,9 +72,13 @@ static struct usb_bos_descriptor *bos_desc;
|
||||||
struct usbd_tx_rx_msg tx_msg[USB_EP_IN_NUM];
|
struct usbd_tx_rx_msg tx_msg[USB_EP_IN_NUM];
|
||||||
struct usbd_tx_rx_msg rx_msg[USB_EP_OUT_NUM];
|
struct usbd_tx_rx_msg rx_msg[USB_EP_OUT_NUM];
|
||||||
|
|
||||||
#ifdef CONFIG_USBDEV_TX_RX_THREAD
|
#if defined(CONFIG_USBDEV_TX_THREAD)
|
||||||
usb_osal_mq_t usbd_tx_rx_mq;
|
usb_osal_mq_t usbd_tx_mq;
|
||||||
usb_osal_thread_t usbd_tx_rx_thread;
|
usb_osal_thread_t usbd_tx_thread;
|
||||||
|
#endif
|
||||||
|
#if defined(CONFIG_USBDEV_RX_THREAD)
|
||||||
|
usb_osal_mq_t usbd_rx_mq;
|
||||||
|
usb_osal_thread_t usbd_rx_thread;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void usbd_class_event_notify_handler(uint8_t event, void *arg);
|
static void usbd_class_event_notify_handler(uint8_t event, void *arg);
|
||||||
|
@ -113,7 +117,7 @@ static bool usbd_set_endpoint(const struct usb_endpoint_descriptor *ep_desc)
|
||||||
ep_cfg.ep_mps = ep_desc->wMaxPacketSize & USB_MAXPACKETSIZE_MASK;
|
ep_cfg.ep_mps = ep_desc->wMaxPacketSize & USB_MAXPACKETSIZE_MASK;
|
||||||
ep_cfg.ep_type = ep_desc->bmAttributes & USB_ENDPOINT_TYPE_MASK;
|
ep_cfg.ep_type = ep_desc->bmAttributes & USB_ENDPOINT_TYPE_MASK;
|
||||||
|
|
||||||
USB_LOG_INFO("Open endpoint:0x%x type:%u mps:%u\r\n",
|
USB_LOG_INFO("Open ep:0x%02x type:%u mps:%u\r\n",
|
||||||
ep_cfg.ep_addr, ep_cfg.ep_type, ep_cfg.ep_mps);
|
ep_cfg.ep_addr, ep_cfg.ep_type, ep_cfg.ep_mps);
|
||||||
|
|
||||||
return usbd_ep_open(&ep_cfg) == 0 ? true : false;
|
return usbd_ep_open(&ep_cfg) == 0 ? true : false;
|
||||||
|
@ -136,7 +140,7 @@ static bool usbd_reset_endpoint(const struct usb_endpoint_descriptor *ep_desc)
|
||||||
ep_cfg.ep_mps = ep_desc->wMaxPacketSize & USB_MAXPACKETSIZE_MASK;
|
ep_cfg.ep_mps = ep_desc->wMaxPacketSize & USB_MAXPACKETSIZE_MASK;
|
||||||
ep_cfg.ep_type = ep_desc->bmAttributes & USB_ENDPOINT_TYPE_MASK;
|
ep_cfg.ep_type = ep_desc->bmAttributes & USB_ENDPOINT_TYPE_MASK;
|
||||||
|
|
||||||
USB_LOG_INFO("Close endpoint:0x%x type:%u\r\n",
|
USB_LOG_INFO("Close ep:0x%02x type:%u\r\n",
|
||||||
ep_cfg.ep_addr, ep_cfg.ep_type);
|
ep_cfg.ep_addr, ep_cfg.ep_type);
|
||||||
|
|
||||||
return usbd_ep_close(ep_cfg.ep_addr) == 0 ? true : false;
|
return usbd_ep_close(ep_cfg.ep_addr) == 0 ? true : false;
|
||||||
|
@ -154,7 +158,7 @@ static bool usbd_reset_endpoint(const struct usb_endpoint_descriptor *ep_desc)
|
||||||
*
|
*
|
||||||
* @return true if the descriptor was found, false otherwise
|
* @return true if the descriptor was found, false otherwise
|
||||||
*/
|
*/
|
||||||
#if defined(CHERRYUSB_VERSION) && (CHERRYUSB_VERSION > 0x000700)
|
#ifdef CONFIG_USBDEV_ADVANCE_DESC
|
||||||
static bool usbd_get_descriptor(uint16_t type_index, uint8_t **data, uint32_t *len)
|
static bool usbd_get_descriptor(uint16_t type_index, uint8_t **data, uint32_t *len)
|
||||||
{
|
{
|
||||||
uint8_t type = 0U;
|
uint8_t type = 0U;
|
||||||
|
@ -173,18 +177,18 @@ static bool usbd_get_descriptor(uint16_t type_index, uint8_t **data, uint32_t *l
|
||||||
case USB_DESCRIPTOR_TYPE_CONFIGURATION:
|
case USB_DESCRIPTOR_TYPE_CONFIGURATION:
|
||||||
usbd_core_cfg.speed = usbd_get_port_speed(0);
|
usbd_core_cfg.speed = usbd_get_port_speed(0);
|
||||||
if (usbd_core_cfg.speed == USB_SPEED_HIGH) {
|
if (usbd_core_cfg.speed == USB_SPEED_HIGH) {
|
||||||
if (usbd_core_cfg.descriptors->hs_config_descriptor[index]) {
|
if (usbd_core_cfg.descriptors->hs_config_descriptor) {
|
||||||
*data = (uint8_t *)usbd_core_cfg.descriptors->hs_config_descriptor[index];
|
*data = (uint8_t *)usbd_core_cfg.descriptors->hs_config_descriptor;
|
||||||
*len = (usbd_core_cfg.descriptors->hs_config_descriptor[index][CONF_DESC_wTotalLength] |
|
*len = (usbd_core_cfg.descriptors->hs_config_descriptor[CONF_DESC_wTotalLength] |
|
||||||
(usbd_core_cfg.descriptors->hs_config_descriptor[index][CONF_DESC_wTotalLength + 1] << 8));
|
(usbd_core_cfg.descriptors->hs_config_descriptor[CONF_DESC_wTotalLength + 1] << 8));
|
||||||
} else {
|
} else {
|
||||||
found = false;
|
found = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (usbd_core_cfg.descriptors->fs_config_descriptor[index]) {
|
if (usbd_core_cfg.descriptors->fs_config_descriptor) {
|
||||||
*data = (uint8_t *)usbd_core_cfg.descriptors->fs_config_descriptor[index];
|
*data = (uint8_t *)usbd_core_cfg.descriptors->fs_config_descriptor;
|
||||||
*len = (usbd_core_cfg.descriptors->fs_config_descriptor[index][CONF_DESC_wTotalLength] |
|
*len = (usbd_core_cfg.descriptors->fs_config_descriptor[CONF_DESC_wTotalLength] |
|
||||||
(usbd_core_cfg.descriptors->fs_config_descriptor[index][CONF_DESC_wTotalLength + 1] << 8));
|
(usbd_core_cfg.descriptors->fs_config_descriptor[CONF_DESC_wTotalLength + 1] << 8));
|
||||||
} else {
|
} else {
|
||||||
found = false;
|
found = false;
|
||||||
}
|
}
|
||||||
|
@ -332,9 +336,6 @@ static bool usbd_get_descriptor(uint16_t type_index, uint8_t **data, uint32_t *l
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found) {
|
if (found) {
|
||||||
/* found descriptor, save descriptor premiere address */
|
|
||||||
*data = p;
|
|
||||||
|
|
||||||
if ((type == USB_DESCRIPTOR_TYPE_CONFIGURATION) || ((type == USB_DESCRIPTOR_TYPE_OTHER_SPEED))) {
|
if ((type == USB_DESCRIPTOR_TYPE_CONFIGURATION) || ((type == USB_DESCRIPTOR_TYPE_OTHER_SPEED))) {
|
||||||
/* configuration or other speed descriptor is an
|
/* configuration or other speed descriptor is an
|
||||||
* exception, length is at offset 2 and 3
|
* exception, length is at offset 2 and 3
|
||||||
|
@ -345,6 +346,7 @@ static bool usbd_get_descriptor(uint16_t type_index, uint8_t **data, uint32_t *l
|
||||||
/* normally length is at offset 0 */
|
/* normally length is at offset 0 */
|
||||||
*len = p[DESC_bLength];
|
*len = p[DESC_bLength];
|
||||||
}
|
}
|
||||||
|
memcpy(*data, p, *len);
|
||||||
} else {
|
} else {
|
||||||
/* nothing found */
|
/* nothing found */
|
||||||
USB_LOG_ERR("descriptor <type:%x,index:%x> not found!\r\n", type, index);
|
USB_LOG_ERR("descriptor <type:%x,index:%x> not found!\r\n", type, index);
|
||||||
|
@ -372,11 +374,11 @@ static bool usbd_set_configuration(uint8_t config_index, uint8_t alt_setting)
|
||||||
uint8_t cur_config = 0xFF;
|
uint8_t cur_config = 0xFF;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
uint8_t *p;
|
uint8_t *p;
|
||||||
#if defined(CHERRYUSB_VERSION) && (CHERRYUSB_VERSION > 0x000700)
|
#ifdef CONFIG_USBDEV_ADVANCE_DESC
|
||||||
if (usbd_core_cfg.speed == USB_SPEED_HIGH) {
|
if (usbd_core_cfg.speed == USB_SPEED_HIGH) {
|
||||||
p = (uint8_t *)usbd_core_cfg.descriptors->hs_config_descriptor[0];
|
p = (uint8_t *)usbd_core_cfg.descriptors->hs_config_descriptor;
|
||||||
} else {
|
} else {
|
||||||
p = (uint8_t *)usbd_core_cfg.descriptors->fs_config_descriptor[0];
|
p = (uint8_t *)usbd_core_cfg.descriptors->fs_config_descriptor;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
p = (uint8_t *)usbd_core_cfg.descriptors;
|
p = (uint8_t *)usbd_core_cfg.descriptors;
|
||||||
|
@ -436,11 +438,11 @@ static bool usbd_set_interface(uint8_t iface, uint8_t alt_setting)
|
||||||
uint8_t cur_iface = 0xFF;
|
uint8_t cur_iface = 0xFF;
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
uint8_t *p;
|
uint8_t *p;
|
||||||
#if defined(CHERRYUSB_VERSION) && (CHERRYUSB_VERSION > 0x000700)
|
#ifdef CONFIG_USBDEV_ADVANCE_DESC
|
||||||
if (usbd_core_cfg.speed == USB_SPEED_HIGH) {
|
if (usbd_core_cfg.speed == USB_SPEED_HIGH) {
|
||||||
p = (uint8_t *)usbd_core_cfg.descriptors->hs_config_descriptor[0];
|
p = (uint8_t *)usbd_core_cfg.descriptors->hs_config_descriptor;
|
||||||
} else {
|
} else {
|
||||||
p = (uint8_t *)usbd_core_cfg.descriptors->fs_config_descriptor[0];
|
p = (uint8_t *)usbd_core_cfg.descriptors->fs_config_descriptor;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
p = (uint8_t *)usbd_core_cfg.descriptors;
|
p = (uint8_t *)usbd_core_cfg.descriptors;
|
||||||
|
@ -787,7 +789,7 @@ static int usbd_class_request_handler(struct usb_setup_packet *setup, uint8_t **
|
||||||
*/
|
*/
|
||||||
static int usbd_vendor_request_handler(struct usb_setup_packet *setup, uint8_t **data, uint32_t *len)
|
static int usbd_vendor_request_handler(struct usb_setup_packet *setup, uint8_t **data, uint32_t *len)
|
||||||
{
|
{
|
||||||
#if defined(CHERRYUSB_VERSION) && (CHERRYUSB_VERSION > 0x000700)
|
#ifdef CONFIG_USBDEV_ADVANCE_DESC
|
||||||
if (usbd_core_cfg.descriptors->msosv1_descriptor) {
|
if (usbd_core_cfg.descriptors->msosv1_descriptor) {
|
||||||
if (setup->bRequest == usbd_core_cfg.descriptors->msosv1_descriptor->vendor_code) {
|
if (setup->bRequest == usbd_core_cfg.descriptors->msosv1_descriptor->vendor_code) {
|
||||||
switch (setup->wIndex) {
|
switch (setup->wIndex) {
|
||||||
|
@ -819,6 +821,19 @@ static int usbd_vendor_request_handler(struct usb_setup_packet *setup, uint8_t *
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (usbd_core_cfg.descriptors->webusb_url_descriptor) {
|
||||||
|
if (setup->bRequest == usbd_core_cfg.descriptors->webusb_url_descriptor->vendor_code) {
|
||||||
|
switch (setup->wIndex) {
|
||||||
|
case WINUSB_REQUEST_GET_DESCRIPTOR_SET:
|
||||||
|
USB_LOG_INFO("GET Webusb url Descriptor\r\n");
|
||||||
|
*data = (uint8_t *)usbd_core_cfg.descriptors->webusb_url_descriptor->string;
|
||||||
|
*len = usbd_core_cfg.descriptors->webusb_url_descriptor->string_len;
|
||||||
|
return 0;
|
||||||
|
default:
|
||||||
|
USB_LOG_ERR("unknown vendor code\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (msosv1_desc) {
|
if (msosv1_desc) {
|
||||||
|
@ -884,6 +899,12 @@ static bool usbd_setup_request_handler(struct usb_setup_packet *setup, uint8_t *
|
||||||
switch (setup->bmRequestType & USB_REQUEST_TYPE_MASK) {
|
switch (setup->bmRequestType & USB_REQUEST_TYPE_MASK) {
|
||||||
case USB_REQUEST_STANDARD:
|
case USB_REQUEST_STANDARD:
|
||||||
if (usbd_standard_request_handler(setup, data, len) < 0) {
|
if (usbd_standard_request_handler(setup, data, len) < 0) {
|
||||||
|
#ifndef CONFIG_USB_HS
|
||||||
|
if ((setup->bRequest == 0x06) && (setup->wValue == 0x0600)) {
|
||||||
|
USB_LOG_WRN("Ignore DQD in fs\r\n"); /* Device Qualifier Descriptor */
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
USB_LOG_ERR("standard request error\r\n");
|
USB_LOG_ERR("standard request error\r\n");
|
||||||
usbd_print_setup(setup);
|
usbd_print_setup(setup);
|
||||||
return false;
|
return false;
|
||||||
|
@ -1008,22 +1029,11 @@ void usbd_event_ep0_setup_complete_handler(uint8_t *psetup)
|
||||||
#endif
|
#endif
|
||||||
/* Send smallest of requested and offered length */
|
/* Send smallest of requested and offered length */
|
||||||
usbd_core_cfg.ep0_data_buf_residue = MIN(usbd_core_cfg.ep0_data_buf_len, setup->wLength);
|
usbd_core_cfg.ep0_data_buf_residue = MIN(usbd_core_cfg.ep0_data_buf_len, setup->wLength);
|
||||||
|
if (usbd_core_cfg.ep0_data_buf_residue > CONFIG_USBDEV_REQUEST_BUFFER_LEN) {
|
||||||
#if defined(CHERRYUSB_VERSION) && (CHERRYUSB_VERSION > 0x000700)
|
USB_LOG_ERR("Request buffer too small\r\n");
|
||||||
#else
|
return;
|
||||||
/* check if the data buf addr matches align size,if not, copy into align buf */
|
|
||||||
#ifndef CONFIG_USBDEV_ALIGN_CHECK_DISABLE
|
|
||||||
if (((unsigned long)usbd_core_cfg.ep0_data_buf) & (CONFIG_USB_ALIGN_SIZE - 1)) {
|
|
||||||
if (usbd_core_cfg.ep0_data_buf_residue > CONFIG_USBDEV_REQUEST_BUFFER_LEN) {
|
|
||||||
USB_LOG_ERR("Request buffer too small\r\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
/* copy data buf from misalignx addr to alignx addr */
|
|
||||||
memcpy(usbd_core_cfg.req_data, usbd_core_cfg.ep0_data_buf, usbd_core_cfg.ep0_data_buf_residue);
|
|
||||||
usbd_core_cfg.ep0_data_buf = usbd_core_cfg.req_data;
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
/* Send data or status to host */
|
/* Send data or status to host */
|
||||||
usbd_ep_start_write(USB_CONTROL_IN_EP0, usbd_core_cfg.ep0_data_buf, usbd_core_cfg.ep0_data_buf_residue);
|
usbd_ep_start_write(USB_CONTROL_IN_EP0, usbd_core_cfg.ep0_data_buf, usbd_core_cfg.ep0_data_buf_residue);
|
||||||
/*
|
/*
|
||||||
|
@ -1101,36 +1111,36 @@ void usbd_event_ep0_out_complete_handler(uint8_t ep, uint32_t nbytes)
|
||||||
|
|
||||||
void usbd_event_ep_in_complete_handler(uint8_t ep, uint32_t nbytes)
|
void usbd_event_ep_in_complete_handler(uint8_t ep, uint32_t nbytes)
|
||||||
{
|
{
|
||||||
#ifndef CONFIG_USBDEV_TX_RX_THREAD
|
#ifndef CONFIG_USBDEV_TX_THREAD
|
||||||
if (tx_msg[ep & 0x7f].cb) {
|
if (tx_msg[ep & 0x7f].cb) {
|
||||||
tx_msg[ep & 0x7f].cb(ep, nbytes);
|
tx_msg[ep & 0x7f].cb(ep, nbytes);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
tx_msg[ep & 0x7f].nbytes = nbytes;
|
tx_msg[ep & 0x7f].nbytes = nbytes;
|
||||||
usb_osal_mq_send(usbd_tx_rx_mq, (uint32_t)&tx_msg[ep & 0x7f]);
|
usb_osal_mq_send(usbd_tx_mq, (uint32_t)&tx_msg[ep & 0x7f]);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void usbd_event_ep_out_complete_handler(uint8_t ep, uint32_t nbytes)
|
void usbd_event_ep_out_complete_handler(uint8_t ep, uint32_t nbytes)
|
||||||
{
|
{
|
||||||
#ifndef CONFIG_USBDEV_TX_RX_THREAD
|
#ifndef CONFIG_USBDEV_RX_THREAD
|
||||||
if (rx_msg[ep & 0x7f].cb) {
|
if (rx_msg[ep & 0x7f].cb) {
|
||||||
rx_msg[ep & 0x7f].cb(ep, nbytes);
|
rx_msg[ep & 0x7f].cb(ep, nbytes);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
rx_msg[ep & 0x7f].nbytes = nbytes;
|
rx_msg[ep & 0x7f].nbytes = nbytes;
|
||||||
usb_osal_mq_send(usbd_tx_rx_mq, (uint32_t)&rx_msg[ep & 0x7f]);
|
usb_osal_mq_send(usbd_rx_mq, (uint32_t)&rx_msg[ep & 0x7f]);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_USBDEV_TX_RX_THREAD
|
#ifdef CONFIG_USBDEV_TX_THREAD
|
||||||
static void usbdev_tx_rx_thread(void *argument)
|
static void usbdev_tx_thread(void *argument)
|
||||||
{
|
{
|
||||||
struct usbd_tx_rx_msg *msg;
|
struct usbd_tx_rx_msg *msg;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
ret = usb_osal_mq_recv(usbd_tx_rx_mq, (uint32_t *)&msg, 0xffffffff);
|
ret = usb_osal_mq_recv(usbd_tx_mq, (uint32_t *)&msg, 0xffffffff);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1142,7 +1152,26 @@ static void usbdev_tx_rx_thread(void *argument)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CHERRYUSB_VERSION) && (CHERRYUSB_VERSION > 0x000700)
|
#ifdef CONFIG_USBDEV_RX_THREAD
|
||||||
|
static void usbdev_rx_thread(void *argument)
|
||||||
|
{
|
||||||
|
struct usbd_tx_rx_msg *msg;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
ret = usb_osal_mq_recv(usbd_rx_mq, (uint32_t *)&msg, 0xffffffff);
|
||||||
|
if (ret < 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (msg->cb) {
|
||||||
|
msg->cb(msg->ep, msg->nbytes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_USBDEV_ADVANCE_DESC
|
||||||
void usbd_desc_register(struct usb_descriptor *desc)
|
void usbd_desc_register(struct usb_descriptor *desc)
|
||||||
{
|
{
|
||||||
usbd_core_cfg.descriptors = desc;
|
usbd_core_cfg.descriptors = desc;
|
||||||
|
@ -1206,13 +1235,23 @@ bool usb_device_is_configured(void)
|
||||||
|
|
||||||
int usbd_initialize(void)
|
int usbd_initialize(void)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_USBDEV_TX_RX_THREAD
|
#ifdef CONFIG_USBDEV_TX_THREAD
|
||||||
usbd_tx_rx_mq = usb_osal_mq_create(32);
|
usbd_tx_mq = usb_osal_mq_create(16);
|
||||||
if (usbd_tx_rx_mq == NULL) {
|
if (usbd_tx_mq == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
usbd_tx_rx_thread = usb_osal_thread_create("usbd_tx_rx", CONFIG_USBDEV_TX_RX_STACKSIZE, CONFIG_USBDEV_TX_RX_PRIO, usbdev_tx_rx_thread, NULL);
|
usbd_tx_thread = usb_osal_thread_create("usbd_tx", CONFIG_USBDEV_TX_STACKSIZE, CONFIG_USBDEV_TX_PRIO, usbdev_tx_thread, NULL);
|
||||||
if (usbd_tx_rx_thread == NULL) {
|
if (usbd_tx_thread == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef CONFIG_USBDEV_RX_THREAD
|
||||||
|
usbd_rx_mq = usb_osal_mq_create(16);
|
||||||
|
if (usbd_rx_mq == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
usbd_rx_thread = usb_osal_thread_create("usbd_rx", CONFIG_USBDEV_RX_STACKSIZE, CONFIG_USBDEV_RX_PRIO, usbdev_rx_thread, NULL);
|
||||||
|
if (usbd_rx_thread == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1224,7 +1263,7 @@ int usbd_deinitialize(void)
|
||||||
usbd_core_cfg.intf_offset = 0;
|
usbd_core_cfg.intf_offset = 0;
|
||||||
usb_slist_init(&usbd_intf_head);
|
usb_slist_init(&usbd_intf_head);
|
||||||
usb_dc_deinit();
|
usb_dc_deinit();
|
||||||
#ifdef CONFIG_USBDEV_TX_RX_THREAD
|
#if defined(CONFIG_USBDEV_TX_THREAD) || defined(CONFIG_USBDEV_RX_THREAD)
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -438,7 +438,7 @@ int usbh_enumerate(struct usbh_hubport *hport)
|
||||||
ep_mps = ((struct usb_device_descriptor *)ep0_request_buffer)->bMaxPacketSize0;
|
ep_mps = ((struct usb_device_descriptor *)ep0_request_buffer)->bMaxPacketSize0;
|
||||||
|
|
||||||
/* Reconfigure EP0 with the correct maximum packet size */
|
/* Reconfigure EP0 with the correct maximum packet size */
|
||||||
usbh_ep0_pipe_reconfigure(hport->ep0, 0, ep_mps, hport->speed);
|
usbh_ep_pipe_reconfigure(hport->ep0, 0, ep_mps, 0);
|
||||||
|
|
||||||
#ifdef CONFIG_USBHOST_XHCI
|
#ifdef CONFIG_USBHOST_XHCI
|
||||||
extern int usbh_get_xhci_devaddr(usbh_pipe_t * pipe);
|
extern int usbh_get_xhci_devaddr(usbh_pipe_t * pipe);
|
||||||
|
@ -478,7 +478,7 @@ int usbh_enumerate(struct usbh_hubport *hport)
|
||||||
hport->dev_addr = dev_addr;
|
hport->dev_addr = dev_addr;
|
||||||
|
|
||||||
/* And reconfigure EP0 with the correct address */
|
/* And reconfigure EP0 with the correct address */
|
||||||
usbh_ep0_pipe_reconfigure(hport->ep0, dev_addr, ep_mps, hport->speed);
|
usbh_ep_pipe_reconfigure(hport->ep0, dev_addr, ep_mps, 0);
|
||||||
|
|
||||||
/* Read the full device descriptor */
|
/* Read the full device descriptor */
|
||||||
setup->bmRequestType = USB_REQUEST_DIR_IN | USB_REQUEST_STANDARD | USB_REQUEST_RECIPIENT_DEVICE;
|
setup->bmRequestType = USB_REQUEST_DIR_IN | USB_REQUEST_STANDARD | USB_REQUEST_RECIPIENT_DEVICE;
|
||||||
|
|
|
@ -959,13 +959,13 @@ int usbh_roothub_control(struct usb_setup_packet *setup, uint8_t *buf)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int usbh_ep0_pipe_reconfigure(usbh_pipe_t pipe, uint8_t dev_addr, uint8_t ep_mps, uint8_t speed)
|
int usbh_ep_pipe_reconfigure(usbh_pipe_t pipe, uint8_t dev_addr, uint8_t ep_mps, uint8_t mult)
|
||||||
{
|
{
|
||||||
struct ehci_pipe *ppipe = (struct ehci_pipe *)pipe;
|
struct ehci_pipe *ppipe = (struct ehci_pipe *)pipe;
|
||||||
|
|
||||||
ppipe->dev_addr = dev_addr;
|
ppipe->dev_addr = dev_addr;
|
||||||
ppipe->ep_mps = ep_mps;
|
ppipe->ep_mps = ep_mps;
|
||||||
ppipe->speed = speed;
|
ppipe->mult = mult;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@
|
||||||
#define EHCI_USBCMD_IAAD (1 << 6) /* Bit 6: Interrupt on Async Advance Doorbell */
|
#define EHCI_USBCMD_IAAD (1 << 6) /* Bit 6: Interrupt on Async Advance Doorbell */
|
||||||
#define EHCI_USBCMD_LRESET (1 << 7) /* Bit 7: Light Host Controller Reset */
|
#define EHCI_USBCMD_LRESET (1 << 7) /* Bit 7: Light Host Controller Reset */
|
||||||
#define EHCI_USBCMD_ASYNC_PARKCNT_SHIFT (8) /* Bits 8-9: Asynchronous Schedule Park Mode Count */
|
#define EHCI_USBCMD_ASYNC_PARKCNT_SHIFT (8) /* Bits 8-9: Asynchronous Schedule Park Mode Count */
|
||||||
#define EHCI_USBCMD_ASYNC_PARKCNT_MASK (3 << EHCI_USBCMD_PARKCNT_SHIFT)
|
#define EHCI_USBCMD_ASYNC_PARKCNT_MASK (3 << EHCI_USBCMD_ASYNC_PARKCNT_SHIFT)
|
||||||
#define EHCI_USBCMD_ASYNC_PARK (1 << 11) /* Bit 11: Asynchronous Schedule Park Mode Enable */
|
#define EHCI_USBCMD_ASYNC_PARK (1 << 11) /* Bit 11: Asynchronous Schedule Park Mode Enable */
|
||||||
#define EHCI_USBCMD_ITHRE_SHIFT (16) /* Bits 16-23: Interrupt Threshold Control */
|
#define EHCI_USBCMD_ITHRE_SHIFT (16) /* Bits 16-23: Interrupt Threshold Control */
|
||||||
#define EHCI_USBCMD_ITHRE_MASK (0xff << EHCI_USBCMD_ITHRE_SHIFT)
|
#define EHCI_USBCMD_ITHRE_MASK (0xff << EHCI_USBCMD_ITHRE_SHIFT)
|
||||||
|
@ -247,7 +247,7 @@
|
||||||
#define ITD_TSCL_STATUS_XACTERR (1 << 28) /* Bit 28: Transaction error */
|
#define ITD_TSCL_STATUS_XACTERR (1 << 28) /* Bit 28: Transaction error */
|
||||||
#define ITD_TSCL_STATUS_BABBLE (1 << 29) /* Bit 29: Babble Detected */
|
#define ITD_TSCL_STATUS_BABBLE (1 << 29) /* Bit 29: Babble Detected */
|
||||||
#define ITD_TSCL_STATUS_DBERROR (1 << 30) /* Bit 30: Data Buffer Error */
|
#define ITD_TSCL_STATUS_DBERROR (1 << 30) /* Bit 30: Data Buffer Error */
|
||||||
#define ITD_TSCL_STATUS_ACTIVE (1 << 31) /* Bit 28: Transaction error */
|
#define ITD_TSCL_STATUS_ACTIVE (1 << 31) /* Bit 31: Active error */
|
||||||
|
|
||||||
/* iTD Buffer Page Pointer List. Paragraph 3.3.4 */
|
/* iTD Buffer Page Pointer List. Paragraph 3.3.4 */
|
||||||
|
|
||||||
|
|
|
@ -5,18 +5,11 @@
|
||||||
|
|
||||||
| CHIP | Remark |
|
| CHIP | Remark |
|
||||||
|:----------------:|:------:|
|
|:----------------:|:------:|
|
||||||
|BL702/BL704/BL706 | |
|
|
||||||
|BL616/BL618 | |
|
|BL616/BL618 | |
|
||||||
|BL808 | D0 has no irq |
|
|BL808 | D0 has no irq |
|
||||||
|
|
||||||
## Compile
|
## Compile
|
||||||
|
|
||||||
- BL702/BL704/BL706
|
|
||||||
|
|
||||||
```
|
|
||||||
make CHIP=bl702 BOARD=bl702dk
|
|
||||||
```
|
|
||||||
|
|
||||||
- BL616/BL618
|
- BL616/BL618
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
|
@ -16,14 +16,19 @@
|
||||||
#define AUDIO_OUT_EP 0x02
|
#define AUDIO_OUT_EP 0x02
|
||||||
|
|
||||||
/* AUDIO Class Config */
|
/* AUDIO Class Config */
|
||||||
#define AUDIO_FREQ 16000U
|
#define AUDIO_SPEAKER_FREQ 16000U
|
||||||
|
#define AUDIO_SPEAKER_FRAME_SIZE_BYTE 2u
|
||||||
|
#define AUDIO_SPEAKER_RESOLUTION_BIT 16u
|
||||||
|
#define AUDIO_MIC_FREQ 16000U
|
||||||
|
#define AUDIO_MIC_FRAME_SIZE_BYTE 2u
|
||||||
|
#define AUDIO_MIC_RESOLUTION_BIT 16u
|
||||||
|
|
||||||
#define AUDIO_SAMPLE_FREQ(frq) (uint8_t)(frq), (uint8_t)((frq >> 8)), (uint8_t)((frq >> 16))
|
#define AUDIO_SAMPLE_FREQ(frq) (uint8_t)(frq), (uint8_t)((frq >> 8)), (uint8_t)((frq >> 16))
|
||||||
|
|
||||||
/* AudioFreq * DataSize (2 bytes) * NumChannels (Stereo: 2) */
|
/* AudioFreq * DataSize (2 bytes) * NumChannels (Stereo: 2) */
|
||||||
#define AUDIO_OUT_PACKET ((uint32_t)((AUDIO_FREQ * 2 * 2) / 1000))
|
#define AUDIO_OUT_PACKET ((uint32_t)((AUDIO_SPEAKER_FREQ * AUDIO_SPEAKER_FRAME_SIZE_BYTE * 2) / 1000))
|
||||||
/* 16bit(2 Bytes) 双声道(Mono:2) */
|
/* 16bit(2 Bytes) 双声道(Mono:2) */
|
||||||
#define AUDIO_IN_PACKET ((uint32_t)((AUDIO_FREQ * 2 * 2) / 1000))
|
#define AUDIO_IN_PACKET ((uint32_t)((AUDIO_MIC_FREQ * AUDIO_MIC_FRAME_SIZE_BYTE * 2) / 1000))
|
||||||
|
|
||||||
#define USB_AUDIO_CONFIG_DESC_SIZ (unsigned long)(9 + \
|
#define USB_AUDIO_CONFIG_DESC_SIZ (unsigned long)(9 + \
|
||||||
AUDIO_AC_DESCRIPTOR_INIT_LEN(2) + \
|
AUDIO_AC_DESCRIPTOR_INIT_LEN(2) + \
|
||||||
|
@ -49,13 +54,15 @@ const uint8_t audio_descriptor[] = {
|
||||||
USB_CONFIG_DESCRIPTOR_INIT(USB_AUDIO_CONFIG_DESC_SIZ, 0x03, 0x01, USB_CONFIG_BUS_POWERED, USBD_MAX_POWER),
|
USB_CONFIG_DESCRIPTOR_INIT(USB_AUDIO_CONFIG_DESC_SIZ, 0x03, 0x01, USB_CONFIG_BUS_POWERED, USBD_MAX_POWER),
|
||||||
AUDIO_AC_DESCRIPTOR_INIT(0x00, 0x03, AUDIO_AC_SIZ, 0x00, 0x01, 0x02),
|
AUDIO_AC_DESCRIPTOR_INIT(0x00, 0x03, AUDIO_AC_SIZ, 0x00, 0x01, 0x02),
|
||||||
AUDIO_AC_INPUT_TERMINAL_DESCRIPTOR_INIT(0x01, AUDIO_INTERM_MIC, 0x02, 0x0003),
|
AUDIO_AC_INPUT_TERMINAL_DESCRIPTOR_INIT(0x01, AUDIO_INTERM_MIC, 0x02, 0x0003),
|
||||||
AUDIO_AC_FEATURE_UNIT_DESCRIPTOR_INIT(0x02, 0x01, 0x01, 0x03, 0x00),
|
AUDIO_AC_FEATURE_UNIT_DESCRIPTOR_INIT(0x02, 0x01, 0x01, 0x03, 0x00, 0x00),
|
||||||
AUDIO_AC_OUTPUT_TERMINAL_DESCRIPTOR_INIT(0x03, AUDIO_TERMINAL_STREAMING, 0x02),
|
AUDIO_AC_OUTPUT_TERMINAL_DESCRIPTOR_INIT(0x03, AUDIO_TERMINAL_STREAMING, 0x02),
|
||||||
AUDIO_AC_INPUT_TERMINAL_DESCRIPTOR_INIT(0x04, AUDIO_TERMINAL_STREAMING, 0x02, 0x0003),
|
AUDIO_AC_INPUT_TERMINAL_DESCRIPTOR_INIT(0x04, AUDIO_TERMINAL_STREAMING, 0x02, 0x0003),
|
||||||
AUDIO_AC_FEATURE_UNIT_DESCRIPTOR_INIT(0x05, 0x04, 0x01, 0x03, 0x00),
|
AUDIO_AC_FEATURE_UNIT_DESCRIPTOR_INIT(0x05, 0x04, 0x01, 0x03, 0x00, 0x00),
|
||||||
AUDIO_AC_OUTPUT_TERMINAL_DESCRIPTOR_INIT(0x06, AUDIO_OUTTERM_SPEAKER, 0x05),
|
AUDIO_AC_OUTPUT_TERMINAL_DESCRIPTOR_INIT(0x06, AUDIO_OUTTERM_SPEAKER, 0x05),
|
||||||
AUDIO_AS_DESCRIPTOR_INIT(0x01, 0x04, 0x02, AUDIO_OUT_EP, AUDIO_OUT_PACKET, EP_INTERVAL, AUDIO_SAMPLE_FREQ_3B(AUDIO_FREQ)),
|
AUDIO_AS_DESCRIPTOR_INIT(0x01, 0x04, 0x02, AUDIO_SPEAKER_FRAME_SIZE_BYTE, AUDIO_SPEAKER_RESOLUTION_BIT, AUDIO_OUT_EP, AUDIO_OUT_PACKET,\
|
||||||
AUDIO_AS_DESCRIPTOR_INIT(0x02, 0x03, 0x02, AUDIO_IN_EP, AUDIO_IN_PACKET, EP_INTERVAL, AUDIO_SAMPLE_FREQ_3B(AUDIO_FREQ)),
|
EP_INTERVAL, AUDIO_SAMPLE_FREQ_3B(AUDIO_SPEAKER_FREQ)),
|
||||||
|
AUDIO_AS_DESCRIPTOR_INIT(0x02, 0x03, 0x02, AUDIO_MIC_FRAME_SIZE_BYTE, AUDIO_MIC_RESOLUTION_BIT, AUDIO_IN_EP, AUDIO_IN_PACKET,\
|
||||||
|
EP_INTERVAL, AUDIO_SAMPLE_FREQ_3B(AUDIO_MIC_FREQ)),
|
||||||
///////////////////////////////////////
|
///////////////////////////////////////
|
||||||
/// string0 descriptor
|
/// string0 descriptor
|
||||||
///////////////////////////////////////
|
///////////////////////////////////////
|
||||||
|
@ -130,6 +137,9 @@ const uint8_t audio_descriptor[] = {
|
||||||
0x00
|
0x00
|
||||||
};
|
};
|
||||||
|
|
||||||
|
USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t write_buffer[2048];
|
||||||
|
USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t out_buffer[AUDIO_OUT_PACKET];
|
||||||
|
|
||||||
volatile bool tx_flag = 0;
|
volatile bool tx_flag = 0;
|
||||||
volatile bool rx_flag = 0;
|
volatile bool rx_flag = 0;
|
||||||
|
|
||||||
|
@ -137,6 +147,8 @@ void usbd_audio_open(uint8_t intf)
|
||||||
{
|
{
|
||||||
if (intf == 1) {
|
if (intf == 1) {
|
||||||
rx_flag = 1;
|
rx_flag = 1;
|
||||||
|
/* setup first out ep read transfer */
|
||||||
|
usbd_ep_start_read(AUDIO_OUT_EP, out_buffer, AUDIO_OUT_PACKET);
|
||||||
printf("OPEN1\r\n");
|
printf("OPEN1\r\n");
|
||||||
} else {
|
} else {
|
||||||
tx_flag = 1;
|
tx_flag = 1;
|
||||||
|
@ -160,15 +172,10 @@ void usbd_audio_close(uint8_t intf)
|
||||||
#define AUDIO_OUT_EP_MPS 64
|
#define AUDIO_OUT_EP_MPS 64
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t write_buffer[2048];
|
|
||||||
USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t out_buffer[AUDIO_OUT_PACKET];
|
|
||||||
|
|
||||||
volatile bool ep_tx_busy_flag = false;
|
volatile bool ep_tx_busy_flag = false;
|
||||||
|
|
||||||
void usbd_configure_done_callback(void)
|
void usbd_configure_done_callback(void)
|
||||||
{
|
{
|
||||||
/* setup first out ep read transfer */
|
|
||||||
usbd_ep_start_read(AUDIO_OUT_EP, out_buffer, AUDIO_OUT_PACKET);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void usbd_audio_out_callback(uint8_t ep, uint32_t nbytes)
|
void usbd_audio_out_callback(uint8_t ep, uint32_t nbytes)
|
||||||
|
@ -216,11 +223,11 @@ void audio_test()
|
||||||
{
|
{
|
||||||
while (1) {
|
while (1) {
|
||||||
if (tx_flag) {
|
if (tx_flag) {
|
||||||
memset(write_buffer, 'a', 2048);
|
// memset(write_buffer, 'a', 2048);
|
||||||
ep_tx_busy_flag = true;
|
// ep_tx_busy_flag = true;
|
||||||
usbd_ep_start_write(AUDIO_IN_EP, write_buffer, 2048);
|
// usbd_ep_start_write(AUDIO_IN_EP, write_buffer, 2048);
|
||||||
while (ep_tx_busy_flag) {
|
// while (ep_tx_busy_flag) {
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,18 +5,11 @@
|
||||||
|
|
||||||
| CHIP | Remark |
|
| CHIP | Remark |
|
||||||
|:----------------:|:------:|
|
|:----------------:|:------:|
|
||||||
|BL702/BL704/BL706 | |
|
|
||||||
|BL616/BL618 | |
|
|BL616/BL618 | |
|
||||||
|BL808 | D0 has no irq |
|
|BL808 | D0 has no irq |
|
||||||
|
|
||||||
## Compile
|
## Compile
|
||||||
|
|
||||||
- BL702/BL704/BL706
|
|
||||||
|
|
||||||
```
|
|
||||||
make CHIP=bl702 BOARD=bl702dk
|
|
||||||
```
|
|
||||||
|
|
||||||
- BL616/BL618
|
- BL616/BL618
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
Loading…
Add table
Reference in a new issue