mirror of
https://github.com/Fishwaldo/bl_mcu_sdk.git
synced 2025-07-07 13:28:48 +00:00
[feat][examples/usb] add USB HS control for descriptor
This commit is contained in:
parent
48479d0e20
commit
ecb43ef0d0
18 changed files with 55 additions and 40 deletions
|
@ -111,6 +111,7 @@ uint8_t cdc_descriptor[] = {
|
|||
'i', 0x00, /* wcChar20 */
|
||||
'a', 0x00, /* wcChar21 */
|
||||
'l', 0x00, /* wcChar22 */
|
||||
#ifdef CONFIG_USB_HS
|
||||
///////////////////////////////////////
|
||||
/// device qualifier descriptor
|
||||
///////////////////////////////////////
|
||||
|
@ -124,11 +125,11 @@ uint8_t cdc_descriptor[] = {
|
|||
0x40,
|
||||
0x01,
|
||||
0x00,
|
||||
|
||||
#endif
|
||||
0x00
|
||||
};
|
||||
struct device *usb_fs;
|
||||
usbd_class_t cdc_class;
|
||||
|
||||
uint8_t filter_buf[sizeof(USB_CDC_RESET_FILTER_PATTERN) + 1 + 1] = { 0 };
|
||||
|
||||
static void hexarr2string(uint8_t *hexarray, int length, uint8_t *string)
|
||||
|
|
|
@ -381,6 +381,7 @@ USB_DESC_SECTION const uint8_t audio_descriptor[] = {
|
|||
'0', 0x00, /* wcChar7 */
|
||||
'0', 0x00, /* wcChar8 */
|
||||
'0', 0x00, /* wcChar9 */
|
||||
#ifdef CONFIG_USB_HS
|
||||
///////////////////////////////////////
|
||||
/// device qualifier descriptor
|
||||
///////////////////////////////////////
|
||||
|
@ -394,7 +395,7 @@ USB_DESC_SECTION const uint8_t audio_descriptor[] = {
|
|||
0x40,
|
||||
0x01,
|
||||
0x00,
|
||||
|
||||
#endif
|
||||
0x00
|
||||
};
|
||||
|
||||
|
@ -417,6 +418,8 @@ static uint8_t record_data_buff[2][BUFF_SIZE + 128] __attribute__((section(".sys
|
|||
volatile static uint8_t play_buff_using_num = 0, play_updata_flag = 0;
|
||||
static uint8_t play_data_buff[2][BUFF_SIZE + 128] __attribute__((section(".system_ram"), aligned(4)));
|
||||
|
||||
static uint8_t vol_change_flag = 0;
|
||||
|
||||
static ES8388_Cfg_Type ES8388Cfg = {
|
||||
.work_mode = ES8388_CODEC_MDOE, /*!< ES8388 work mode */
|
||||
.role = ES8388_SLAVE, /*!< ES8388 role */
|
||||
|
@ -462,9 +465,9 @@ void usbd_audio_set_interface_callback(uint8_t value)
|
|||
{
|
||||
if (value) {
|
||||
play_status = 1;
|
||||
MSG("OPEN\r\n");
|
||||
device_control(usb_fs, DEVICE_CTRL_USB_DC_SET_ACK, (void *)0x81);
|
||||
device_control(usb_fs, DEVICE_CTRL_USB_DC_SET_ACK, (void *)0x2);
|
||||
MSG("OPEN\r\n");
|
||||
} else {
|
||||
play_status = 0;
|
||||
usb_data_offset = 0;
|
||||
|
@ -477,23 +480,14 @@ static usbd_endpoint_t audio_out_ep = {
|
|||
.ep_addr = AUDIO_OUT_EP
|
||||
};
|
||||
|
||||
// static usbd_endpoint_t audio_in_ep = {
|
||||
// .ep_cb = NULL,
|
||||
// .ep_addr = AUDIO_IN_EP
|
||||
// };
|
||||
void usbd_audio_set_volume(uint8_t vol)
|
||||
{
|
||||
ES8388_Set_Voice_Volume(vol);
|
||||
vol_change_flag = vol;
|
||||
}
|
||||
|
||||
extern struct device *usb_dc_init(void);
|
||||
struct device *dma_ch4_usb_tx;
|
||||
|
||||
uint32_t audio_pos = 0;
|
||||
uint32_t musci_size = 0;
|
||||
uint32_t frame_count = 0;
|
||||
uint32_t frame_cnt = 0;
|
||||
uint32_t last_frame_size = 0;
|
||||
|
||||
static void dma_ch2_i2s_tx_irq_callback(struct device *dev, void *args, uint32_t size, uint32_t state)
|
||||
{
|
||||
// if (play_updata_flag) {
|
||||
|
@ -561,8 +555,8 @@ void audio_init()
|
|||
device_control(i2s, DEVICE_CTRL_ATTACH_TX_DMA, (void *)dma_ch2_i2s_tx);
|
||||
|
||||
/* Set the interrupt function, for double buffering*/
|
||||
device_set_callback(dma_ch2_i2s_tx, dma_ch2_i2s_tx_irq_callback);
|
||||
device_control(dma_ch2_i2s_tx, DEVICE_CTRL_SET_INT, NULL);
|
||||
device_set_callback(I2S_DEV(i2s)->tx_dma, dma_ch2_i2s_tx_irq_callback);
|
||||
device_control(I2S_DEV(i2s)->tx_dma, DEVICE_CTRL_SET_INT, NULL);
|
||||
}
|
||||
|
||||
dma_register(DMA0_CH3_INDEX, "dma_ch3_i2s_rx");
|
||||
|
@ -582,8 +576,8 @@ void audio_init()
|
|||
device_control(i2s, DEVICE_CTRL_ATTACH_RX_DMA, (void *)dma_ch3_i2s_rx);
|
||||
|
||||
/* Set the interrupt function, for double buffering*/
|
||||
device_set_callback(dma_ch3_i2s_rx, dma_ch3_i2s_rx_irq_callback);
|
||||
device_control(dma_ch3_i2s_rx, DEVICE_CTRL_SET_INT, NULL);
|
||||
device_set_callback(I2S_DEV(i2s)->rx_dma, dma_ch3_i2s_rx_irq_callback);
|
||||
device_control(I2S_DEV(i2s)->rx_dma, DEVICE_CTRL_SET_INT, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -646,6 +640,11 @@ int main(void)
|
|||
usb_data_offset = 0;
|
||||
}
|
||||
|
||||
if (vol_change_flag) {
|
||||
ES8388_Set_Voice_Volume(vol_change_flag);
|
||||
vol_change_flag = 0;
|
||||
}
|
||||
|
||||
__asm volatile("nop");
|
||||
__asm volatile("nop");
|
||||
}
|
||||
|
|
|
@ -297,6 +297,7 @@ USB_DESC_SECTION const uint8_t audio_descriptor[] = {
|
|||
'0', 0x00, /* wcChar7 */
|
||||
'0', 0x00, /* wcChar8 */
|
||||
'0', 0x00, /* wcChar9 */
|
||||
#ifdef CONFIG_USB_HS
|
||||
///////////////////////////////////////
|
||||
/// device qualifier descriptor
|
||||
///////////////////////////////////////
|
||||
|
@ -310,7 +311,7 @@ USB_DESC_SECTION const uint8_t audio_descriptor[] = {
|
|||
0x40,
|
||||
0x01,
|
||||
0x00,
|
||||
|
||||
#endif
|
||||
0x00
|
||||
};
|
||||
|
||||
|
|
|
@ -94,6 +94,7 @@ USB_DESC_SECTION const uint8_t cdc_descriptor[] = {
|
|||
'0', 0x00, /* wcChar7 */
|
||||
'0', 0x00, /* wcChar8 */
|
||||
'0', 0x00, /* wcChar9 */
|
||||
#ifdef CONFIG_USB_HS
|
||||
///////////////////////////////////////
|
||||
/// device qualifier descriptor
|
||||
///////////////////////////////////////
|
||||
|
@ -107,7 +108,7 @@ USB_DESC_SECTION const uint8_t cdc_descriptor[] = {
|
|||
0x40,
|
||||
0x01,
|
||||
0x00,
|
||||
|
||||
#endif
|
||||
0x00
|
||||
};
|
||||
|
||||
|
|
|
@ -93,6 +93,7 @@ USB_DESC_SECTION const uint8_t cdc_descriptor[] = {
|
|||
'0', 0x00, /* wcChar7 */
|
||||
'0', 0x00, /* wcChar8 */
|
||||
'0', 0x00, /* wcChar9 */
|
||||
#ifdef CONFIG_USB_HS
|
||||
///////////////////////////////////////
|
||||
/// device qualifier descriptor
|
||||
///////////////////////////////////////
|
||||
|
@ -106,7 +107,7 @@ USB_DESC_SECTION const uint8_t cdc_descriptor[] = {
|
|||
0x40,
|
||||
0x01,
|
||||
0x00,
|
||||
|
||||
#endif
|
||||
0x00
|
||||
};
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
set(BSP_COMMON_DIR ${CMAKE_SOURCE_DIR}/bsp/bsp_common)
|
||||
set(TARGET_REQUIRED_LIBS usb_stack)
|
||||
set(LINKER_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/usb_cdc_msc.ld)
|
||||
set(TARGET_REQUIRED_PRIVATE_INCLUDE ${BSP_COMMON_DIR}/usb ${BSP_COMMON_DIR}/spi_sd)
|
||||
set(TARGET_REQUIRED_SRCS ${BSP_COMMON_DIR}/usb/usb_dc.c ${BSP_COMMON_DIR}/usb/uart_interface.c ${BSP_COMMON_DIR}/spi_sd/bsp_spi_sd.c)
|
||||
set(mains main.c)
|
||||
|
|
|
@ -109,6 +109,7 @@ USB_DESC_SECTION const uint8_t cdc_msc_descriptor[] = {
|
|||
'3', 0x00, /* wcChar7 */
|
||||
'4', 0x00, /* wcChar8 */
|
||||
'5', 0x00, /* wcChar9 */
|
||||
#ifdef CONFIG_USB_HS
|
||||
///////////////////////////////////////
|
||||
/// device qualifier descriptor
|
||||
///////////////////////////////////////
|
||||
|
@ -122,7 +123,7 @@ USB_DESC_SECTION const uint8_t cdc_msc_descriptor[] = {
|
|||
0x40,
|
||||
0x01,
|
||||
0x00,
|
||||
|
||||
#endif
|
||||
0x00
|
||||
};
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
set(BSP_COMMON_DIR ${CMAKE_SOURCE_DIR}/bsp/bsp_common)
|
||||
set(TARGET_REQUIRED_LIBS usb_stack shell)
|
||||
set(TARGET_REQUIRED_PRIVATE_INCLUDE ${BSP_COMMON_DIR}/usb)
|
||||
set(TARGET_REQUIRED_SRCS ${BSP_COMMON_DIR}/usb/usb_dc.c ${BSP_COMMON_DIR}/usb/uart_interface.c)
|
||||
set(TARGET_REQUIRED_SRCS ${BSP_COMMON_DIR}/usb/usb_dc.c)
|
||||
set(mains main.c)
|
||||
generate_bin()
|
||||
|
||||
|
|
|
@ -94,6 +94,7 @@ USB_DESC_SECTION const uint8_t cdc_descriptor[] = {
|
|||
'0', 0x00, /* wcChar7 */
|
||||
'0', 0x00, /* wcChar8 */
|
||||
'0', 0x00, /* wcChar9 */
|
||||
#ifdef CONFIG_USB_HS
|
||||
///////////////////////////////////////
|
||||
/// device qualifier descriptor
|
||||
///////////////////////////////////////
|
||||
|
@ -107,7 +108,7 @@ USB_DESC_SECTION const uint8_t cdc_descriptor[] = {
|
|||
0x40,
|
||||
0x01,
|
||||
0x00,
|
||||
|
||||
#endif
|
||||
0x00
|
||||
};
|
||||
|
||||
|
@ -185,3 +186,10 @@ int main(void)
|
|||
while (1) {
|
||||
}
|
||||
}
|
||||
|
||||
int enter_ota(int argc, char *argv[])
|
||||
{
|
||||
hal_enter_usb_iap();
|
||||
return 0;
|
||||
}
|
||||
SHELL_CMD_EXPORT(enter_ota, enter_ota test)
|
|
@ -146,6 +146,7 @@ USB_DESC_SECTION const uint8_t cdc_descriptor[] = {
|
|||
'0', 0x00, /* wcChar7 */
|
||||
'0', 0x00, /* wcChar8 */
|
||||
'0', 0x00, /* wcChar9 */
|
||||
#ifdef CONFIG_USB_HS
|
||||
///////////////////////////////////////
|
||||
/// device qualifier descriptor
|
||||
///////////////////////////////////////
|
||||
|
@ -159,7 +160,7 @@ USB_DESC_SECTION const uint8_t cdc_descriptor[] = {
|
|||
0x40,
|
||||
0x01,
|
||||
0x00,
|
||||
|
||||
#endif
|
||||
0x00
|
||||
};
|
||||
|
||||
|
|
|
@ -164,6 +164,7 @@ USB_DESC_SECTION const uint8_t hid_descriptor[] = {
|
|||
'0', 0x00, /* wcChar7 */
|
||||
'0', 0x00, /* wcChar8 */
|
||||
'0', 0x00, /* wcChar9 */
|
||||
#ifdef CONFIG_USB_HS
|
||||
///////////////////////////////////////
|
||||
/// device qualifier descriptor
|
||||
///////////////////////////////////////
|
||||
|
@ -177,7 +178,7 @@ USB_DESC_SECTION const uint8_t hid_descriptor[] = {
|
|||
0x40,
|
||||
0x01,
|
||||
0x00,
|
||||
|
||||
#endif
|
||||
0x00
|
||||
};
|
||||
|
||||
|
|
|
@ -128,6 +128,7 @@ USB_DESC_SECTION const uint8_t hid_descriptor[] = {
|
|||
'0', 0x00, /* wcChar7 */
|
||||
'0', 0x00, /* wcChar8 */
|
||||
'0', 0x00, /* wcChar9 */
|
||||
#ifdef CONFIG_USB_HS
|
||||
///////////////////////////////////////
|
||||
/// device qualifier descriptor
|
||||
///////////////////////////////////////
|
||||
|
@ -141,7 +142,7 @@ USB_DESC_SECTION const uint8_t hid_descriptor[] = {
|
|||
0x40,
|
||||
0x01,
|
||||
0x00,
|
||||
|
||||
#endif
|
||||
0x00
|
||||
};
|
||||
|
||||
|
|
|
@ -128,6 +128,7 @@ USB_DESC_SECTION const uint8_t hid_descriptor[] = {
|
|||
'0', 0x00, /* wcChar7 */
|
||||
'0', 0x00, /* wcChar8 */
|
||||
'0', 0x00, /* wcChar9 */
|
||||
#ifdef CONFIG_USB_HS
|
||||
///////////////////////////////////////
|
||||
/// device qualifier descriptor
|
||||
///////////////////////////////////////
|
||||
|
@ -141,7 +142,7 @@ USB_DESC_SECTION const uint8_t hid_descriptor[] = {
|
|||
0x40,
|
||||
0x01,
|
||||
0x00,
|
||||
|
||||
#endif
|
||||
0x00
|
||||
};
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
set(BSP_COMMON_DIR ${CMAKE_SOURCE_DIR}/bsp/bsp_common)
|
||||
set(TARGET_REQUIRED_LIBS usb_stack)
|
||||
set(LINKER_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/usb_msc_ram.ld)
|
||||
set(TARGET_REQUIRED_PRIVATE_INCLUDE ${BSP_COMMON_DIR}/usb ${BSP_COMMON_DIR}/spi_sd)
|
||||
set(TARGET_REQUIRED_SRCS ${BSP_COMMON_DIR}/usb/usb_dc.c ${BSP_COMMON_DIR}/usb/uart_interface.c ${BSP_COMMON_DIR}/spi_sd/bsp_spi_sd.c)
|
||||
set(TARGET_REQUIRED_PRIVATE_INCLUDE ${BSP_COMMON_DIR}/usb)
|
||||
set(TARGET_REQUIRED_SRCS ${BSP_COMMON_DIR}/usb/usb_dc.c)
|
||||
set(mains main.c)
|
||||
generate_bin()
|
||||
|
||||
|
|
|
@ -92,6 +92,7 @@ USB_DESC_SECTION const uint8_t msc_ram_descriptor[] = {
|
|||
'0', 0x00, /* wcChar7 */
|
||||
'0', 0x00, /* wcChar8 */
|
||||
'0', 0x00, /* wcChar9 */
|
||||
#ifdef CONFIG_USB_HS
|
||||
///////////////////////////////////////
|
||||
/// device qualifier descriptor
|
||||
///////////////////////////////////////
|
||||
|
@ -105,7 +106,7 @@ USB_DESC_SECTION const uint8_t msc_ram_descriptor[] = {
|
|||
0x40,
|
||||
0x01,
|
||||
0x00,
|
||||
|
||||
#endif
|
||||
0x00
|
||||
};
|
||||
|
||||
|
|
|
@ -95,6 +95,7 @@ USB_DESC_SECTION const uint8_t msc_ram_descriptor[] = {
|
|||
'0', 0x00, /* wcChar7 */
|
||||
'0', 0x00, /* wcChar8 */
|
||||
'0', 0x00, /* wcChar9 */
|
||||
#ifdef CONFIG_USB_HS
|
||||
///////////////////////////////////////
|
||||
/// device qualifier descriptor
|
||||
///////////////////////////////////////
|
||||
|
@ -108,7 +109,7 @@ USB_DESC_SECTION const uint8_t msc_ram_descriptor[] = {
|
|||
0x40,
|
||||
0x01,
|
||||
0x00,
|
||||
|
||||
#endif
|
||||
0x00
|
||||
};
|
||||
|
||||
|
|
|
@ -319,6 +319,7 @@ USB_DESC_SECTION const uint8_t video_descriptor[] = {
|
|||
'0', 0x00, /* wcChar7 */
|
||||
'0', 0x00, /* wcChar8 */
|
||||
'0', 0x00, /* wcChar9 */
|
||||
#ifdef CONFIG_USB_HS
|
||||
///////////////////////////////////////
|
||||
/// device qualifier descriptor
|
||||
///////////////////////////////////////
|
||||
|
@ -332,7 +333,7 @@ USB_DESC_SECTION const uint8_t video_descriptor[] = {
|
|||
0x40,
|
||||
0x01,
|
||||
0x00,
|
||||
|
||||
#endif
|
||||
0x00
|
||||
};
|
||||
|
||||
|
@ -340,8 +341,8 @@ static struct device *usb_fs;
|
|||
static struct device *dma_ch2;
|
||||
|
||||
// static uint8_t header[2] = {0x02,0x00};
|
||||
uint8_t packet_buffer1[VIDEO_PACKET_SIZE] __attribute__((section(".tcm_code"))) = { 0x02, 0x00 };
|
||||
uint8_t packet_buffer2[VIDEO_PACKET_SIZE] __attribute__((section(".tcm_code"))) = { 0x02, 0x00 };
|
||||
ATTR_DTCM_SECTION uint8_t packet_buffer1[VIDEO_PACKET_SIZE] = { 0x02, 0x00 };
|
||||
ATTR_DTCM_SECTION uint8_t packet_buffer2[VIDEO_PACKET_SIZE] = { 0x02, 0x00 };
|
||||
static uint32_t picture_pos = 0;
|
||||
static uint32_t packets_cnt = 0;
|
||||
static uint32_t packets_in_frame;
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
**board/bl706_avb/pinmux_config.h** 中 **PINMUX_SELECT** 选择 **PINMUX_UVC**
|
||||
|
||||
**bsp_common/image_sensor/bsp_image_sensor.c** 中**FORMAT_SEL** 选择 **UYVY**
|
||||
|
||||
```bash
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue