mirror of
https://github.com/Fishwaldo/bl_mcu_sdk.git
synced 2025-07-06 04:48:44 +00:00
[fix] fix adc/usb/spi/i2s demo
This commit is contained in:
parent
d98495bbb4
commit
ca849b3ed8
24 changed files with 673 additions and 116 deletions
|
@ -32,24 +32,13 @@ static void usb_dc_event_callback(struct device *dev, void *args, uint32_t size,
|
|||
switch (state)
|
||||
{
|
||||
case USB_DC_EVENT_ERROR:
|
||||
usbd_event_notify_handler(USB_EVENT_ERROR,NULL);
|
||||
break;
|
||||
case USB_DC_EVENT_RESET:
|
||||
{
|
||||
struct usbd_endpoint_cfg ep_cfg[2];
|
||||
ep_cfg[0].ep_addr = USB_CONTROL_IN_EP0;
|
||||
ep_cfg[0].ep_mps = USB_CTRL_EP_MPS;
|
||||
ep_cfg[0].ep_type = USBD_EP_TYPE_BULK;
|
||||
ep_cfg[1].ep_addr = USB_CONTROL_OUT_EP0;
|
||||
ep_cfg[1].ep_mps = USB_CTRL_EP_MPS;
|
||||
ep_cfg[1].ep_type = USBD_EP_TYPE_BULK;
|
||||
usbd_ep_open(&ep_cfg[0]);
|
||||
usbd_ep_open(&ep_cfg[1]);
|
||||
usbd_set_address(0);
|
||||
|
||||
usbd_event_notify_handler(USB_EVENT_RESET,NULL);
|
||||
}
|
||||
break;
|
||||
case USB_DC_EVENT_SOF:
|
||||
usbd_event_notify_handler(USB_EVENT_SOF,NULL);
|
||||
break;
|
||||
case USB_DC_EVENT_SETUP_NOTIFY:
|
||||
usbd_event_notify_handler(USB_EVENT_SETUP_NOTIFY,NULL);
|
||||
|
|
|
@ -28,7 +28,6 @@ static const char *parity_name[] = {"N","O","E","M","S"};
|
|||
|
||||
/* Device data structure */
|
||||
struct cdc_acm_cfg_private {
|
||||
// /* Interface data buffer */
|
||||
/* CDC ACM line coding properties. LE order */
|
||||
struct cdc_line_coding line_coding;
|
||||
/* CDC ACM line state bitmap, DTE side */
|
||||
|
@ -50,6 +49,7 @@ static void usbd_cdc_acm_reset(void)
|
|||
usbd_cdc_acm_cfg.line_coding.bDataBits = 8;
|
||||
usbd_cdc_acm_cfg.line_coding.bParityType = 0;
|
||||
usbd_cdc_acm_cfg.line_coding.bCharFormat = 0;
|
||||
usbd_cdc_acm_cfg.configured = false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -61,7 +61,7 @@ static void usbd_cdc_acm_reset(void)
|
|||
*
|
||||
* @return 0 on success, negative errno code on fail.
|
||||
*/
|
||||
int cdc_acm_class_request_handler(struct usb_setup_packet *pSetup,uint8_t **data,uint32_t *len)
|
||||
static int cdc_acm_class_request_handler(struct usb_setup_packet *pSetup,uint8_t **data,uint32_t *len)
|
||||
{
|
||||
switch (pSetup->bRequest)
|
||||
{
|
||||
|
@ -123,14 +123,13 @@ int cdc_acm_class_request_handler(struct usb_setup_packet *pSetup,uint8_t **data
|
|||
return 0;
|
||||
}
|
||||
|
||||
void cdc_notify_handler(uint8_t event, void* arg)
|
||||
static void cdc_notify_handler(uint8_t event, void* arg)
|
||||
{
|
||||
switch (event)
|
||||
{
|
||||
case USB_EVENT_RESET:
|
||||
usbd_cdc_acm_reset();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -166,24 +165,3 @@ void usbd_cdc_add_acm_interface(usbd_class_t *class, usbd_interface_t *intf)
|
|||
usbd_class_add_interface(class,intf);
|
||||
}
|
||||
|
||||
void usbd_cdc_add_custom_interface(usbd_class_t *class, usbd_interface_t *intf)
|
||||
{
|
||||
static usbd_class_t *last_class = NULL;
|
||||
|
||||
if(last_class != class)
|
||||
{
|
||||
last_class = class;
|
||||
usbd_class_register(class);
|
||||
}
|
||||
|
||||
intf->class_handler = cdc_acm_class_request_handler;
|
||||
intf->custom_handler = NULL;
|
||||
intf->vendor_handler = NULL;
|
||||
intf->notify_handler = cdc_notify_handler;
|
||||
usbd_class_add_interface(class,intf);
|
||||
}
|
||||
|
||||
void usbd_cdc_add_endpoint(usbd_interface_t *intf, usbd_endpoint_t *ep)
|
||||
{
|
||||
usbd_interface_add_endpoint(intf,ep);
|
||||
}
|
||||
|
|
|
@ -369,8 +369,6 @@ struct cdc_ecm_descriptor {
|
|||
0x01 /* bInterval */
|
||||
|
||||
void usbd_cdc_add_acm_interface(usbd_class_t *class, usbd_interface_t *intf);
|
||||
void usbd_cdc_add_custom_interface(usbd_class_t *class, usbd_interface_t *intf);
|
||||
void usbd_cdc_add_endpoint(usbd_interface_t *intf, usbd_endpoint_t *ep);
|
||||
|
||||
void usbd_cdc_acm_set_line_coding(uint32_t baudrate, uint8_t databits, uint8_t parity, uint8_t stopbits);
|
||||
void usbd_cdc_acm_set_dtr(bool dtr);
|
||||
|
|
|
@ -78,6 +78,7 @@ static struct usbd_core_cfg_priv
|
|||
static usb_slist_t usbd_class_head= USB_SLIST_OBJECT_INIT(usbd_class_head);
|
||||
static struct usb_msosv1_descriptor *msosv1_desc;
|
||||
static struct usb_bos_descriptor *bos_desc;
|
||||
static volatile uint32_t sof_tick = 0;
|
||||
/**
|
||||
* @brief print the contents of a setup packet
|
||||
*
|
||||
|
@ -840,6 +841,7 @@ static int usbd_vendor_request_handler(struct usb_setup_packet *setup, uint8_t *
|
|||
}
|
||||
|
||||
usb_slist_t *i, *j;
|
||||
|
||||
usb_slist_for_each(i,&usbd_class_head)
|
||||
{
|
||||
usbd_class_t* class= usb_slist_entry(i,struct usbd_class,list);
|
||||
|
@ -847,8 +849,10 @@ static int usbd_vendor_request_handler(struct usb_setup_packet *setup, uint8_t *
|
|||
usb_slist_for_each(j,&class->intf_list)
|
||||
{
|
||||
usbd_interface_t* intf = usb_slist_entry(j,struct usbd_interface,list);
|
||||
if(intf->vendor_handler && ((intf->intf_num == (setup->wValue & 0xFF)) || (intf->intf_num == (setup->wIndex & 0xFF))))
|
||||
return intf->vendor_handler(setup, data, len);
|
||||
if(intf->vendor_handler && !intf->vendor_handler(setup, data, len))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1162,12 +1166,16 @@ void usbd_event_notify_handler(uint8_t event, void* arg)
|
|||
{
|
||||
switch (event)
|
||||
{
|
||||
case USB_EVENT_SOF:
|
||||
sof_tick++;
|
||||
USBD_LOG_DBG("tick: %d\r\n", sof_tick);
|
||||
break;
|
||||
case USB_EVENT_RESET:
|
||||
usbd_set_address(0);
|
||||
#if USBD_EP_CALLBACK_SEARCH_METHOD == 1
|
||||
usbd_ep_callback_register();
|
||||
#endif
|
||||
case USB_EVENT_ERROR:
|
||||
case USB_EVENT_SOF:
|
||||
case USB_EVENT_CONNECTED:
|
||||
case USB_EVENT_CONFIGURED:
|
||||
case USB_EVENT_SUSPEND:
|
||||
|
@ -1230,3 +1238,13 @@ void usbd_interface_add_endpoint(usbd_interface_t *intf,usbd_endpoint_t *ep)
|
|||
{
|
||||
usb_slist_add_tail(&intf->ep_list,&ep->list);
|
||||
}
|
||||
|
||||
bool usb_device_is_configured(void)
|
||||
{
|
||||
return usbd_core_cfg.configured;
|
||||
}
|
||||
|
||||
uint32_t usbd_get_sof_tick(void)
|
||||
{
|
||||
return sof_tick;
|
||||
}
|
|
@ -130,6 +130,8 @@ void usbd_class_register(usbd_class_t *class);
|
|||
void usbd_msosv1_desc_register(struct usb_msosv1_descriptor *desc);
|
||||
void usbd_class_add_interface(usbd_class_t *class,usbd_interface_t *intf);
|
||||
void usbd_interface_add_endpoint(usbd_interface_t *intf,usbd_endpoint_t *ep);
|
||||
bool usb_device_is_configured(void);
|
||||
uint32_t usbd_get_sof_tick(void);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
5
examples/adc/adc_key/CMakeLists.txt
Normal file
5
examples/adc/adc_key/CMakeLists.txt
Normal file
|
@ -0,0 +1,5 @@
|
|||
set(mains main.c)
|
||||
generate_bin()
|
||||
|
||||
|
||||
|
|
@ -1,9 +1,8 @@
|
|||
/**
|
||||
* @file adc_key.c
|
||||
* @author Boufflao Lab MCU Team (jychen@bouffalolab.com)
|
||||
* @file main.c
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2021-03-23
|
||||
*
|
||||
* Copyright (c) 2021 Bouffalolab team
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -21,20 +20,19 @@
|
|||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "hal_adc.h"
|
||||
#include "hal_gpio.h"
|
||||
|
||||
|
||||
#define KEY0_ADC_VALUE 0
|
||||
#define KEY1_ADC_VALUE 100
|
||||
#define KEY2_ADC_VALUE 200
|
||||
#define KEY3_ADC_VALUE 300
|
||||
#define KEY4_ADC_VALUE 430
|
||||
#define KEY_NO_VALUE 3000
|
||||
#define KEY_MEASURE_OFFSET 30
|
||||
#define KEY0_ADC_VALUE (0)
|
||||
#define KEY1_ADC_VALUE (100)
|
||||
#define KEY2_ADC_VALUE (200)
|
||||
#define KEY3_ADC_VALUE (300)
|
||||
#define KEY4_ADC_VALUE (430)
|
||||
#define KEY_NO_VALUE (3000)
|
||||
#define KEY_MEASURE_OFFSET (30)
|
||||
|
||||
#define KEY_FILTER_NUM 200
|
||||
#define KEY_FILTER_NUM (200)
|
||||
typedef struct {
|
||||
uint32_t vaildKeyNum;
|
||||
uint16_t keyValue[KEY_FILTER_NUM];
|
||||
|
@ -47,13 +45,18 @@ adc_res_val_t result_val;
|
|||
|
||||
adc_keys_status key_machine;
|
||||
|
||||
struct device* adc_key;
|
||||
|
||||
uint32_t adc_value[2] = {0};
|
||||
uint32_t key_voltage = 0;
|
||||
|
||||
/**
|
||||
* @brief init adc key machine
|
||||
*
|
||||
*/
|
||||
static void key_machine_init(void){
|
||||
key_machine.vaildKeyNum = 0;
|
||||
memset(key_machine.keyValue,0xff,KEY_FILTER_NUM);
|
||||
memset(key_machine.keyValue,0xff,KEY_FILTER_NUM*2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -86,10 +89,10 @@ static uint16_t get_adc_value_range(uint32_t Vmv){
|
|||
* @return int
|
||||
*/
|
||||
static int get_adc_key_value(uint32_t Vmv){
|
||||
volatile uint16_t key_num[5]={0};
|
||||
uint8_t bigger=0,i=0,j=0;
|
||||
volatile uint16_t key_num[5] = {0};
|
||||
uint8_t bigger = 0, i = 0, j = 0;
|
||||
|
||||
if(Vmv>KEY0_ADC_VALUE && Vmv<KEY4_ADC_VALUE+KEY_MEASURE_OFFSET){
|
||||
if(Vmv > KEY0_ADC_VALUE && Vmv < KEY4_ADC_VALUE + KEY_MEASURE_OFFSET){
|
||||
key_machine.keyValue[key_machine.vaildKeyNum] = get_adc_value_range(Vmv);
|
||||
key_machine.vaildKeyNum++;
|
||||
|
||||
|
@ -126,6 +129,22 @@ static int get_adc_key_value(uint32_t Vmv){
|
|||
|
||||
}
|
||||
|
||||
// uint32_t sum = 0;
|
||||
// static uint32_t adc_val_filter(void)
|
||||
// {
|
||||
// static uint32_t cnt_filter = 0;
|
||||
// static uint32_t volt_value = 0;
|
||||
|
||||
// volt_value += adc_value[0];
|
||||
|
||||
// if( ++cnt_filter >= 20)
|
||||
// {
|
||||
// cnt_filter = 0;
|
||||
// key_voltage = (volt_value / 20 * 30 + key_voltage * 70) / 100;
|
||||
// volt_value = 0;
|
||||
// }
|
||||
// }
|
||||
|
||||
int main(void)
|
||||
{
|
||||
bflb_platform_init(0);
|
||||
|
@ -144,26 +163,27 @@ int main(void)
|
|||
|
||||
adc_register(ADC0_INDEX, "adc_key", DEVICE_OFLAG_STREAM_RX, &adc_user_cfg);
|
||||
|
||||
struct device* adc_test = device_find("adc_key");
|
||||
adc_key = device_find("adc_key");
|
||||
|
||||
if(adc_test)
|
||||
if(adc_key)
|
||||
{
|
||||
device_open(adc_test, DEVICE_OFLAG_STREAM_RX);
|
||||
device_open(adc_key, DEVICE_OFLAG_STREAM_RX);
|
||||
}else{
|
||||
MSG("device open failed\r\n");
|
||||
}
|
||||
|
||||
device_control(adc_test,DEVICE_CTRL_RESUME,0);
|
||||
device_control(adc_key,DEVICE_CTRL_RESUME,0);
|
||||
|
||||
key_machine_init();
|
||||
|
||||
while (1)
|
||||
{
|
||||
device_read(adc_test,0,(void *)&result_val,1);
|
||||
device_read(adc_key,0,(void *)&result_val,1);
|
||||
keyValue = get_adc_key_value(result_val.volt * 1000);
|
||||
if( keyValue!=KEY_NO_VALUE){
|
||||
MSG("key %d pressed\r\n",keyValue);
|
||||
}
|
||||
MSG("result_val.volt: %0.2f mv\n", (result_val.volt * 1000));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -17,6 +17,7 @@
|
|||
<Project Name="spi_loopback" Path="spi/spi_loopback/cdk/spi_loopback.cdkproj" Active="No"/>
|
||||
<Project Name="spi_lcd" Path="spi/spi_lcd/cdk/spi_lcd.cdkproj" Active="No"/>
|
||||
<Project Name="uart_dma" Path="uart/uart_dma/cdk/uart_dma.cdkproj" Active="No"/>
|
||||
<Project Name="uart_echo" Path="uart/uart_echo/cdk/uart_echo.cdkproj" Active="No"/>
|
||||
<Project Name="uart_poll" Path="uart/uart_poll/cdk/uart_poll.cdkproj" Active="No"/>
|
||||
<Project Name="uart_rx_it" Path="uart/uart_rx_it/cdk/uart_rx_it.cdkproj" Active="No"/>
|
||||
<Project Name="usb_cdc_loopback" Path="usb/usb_cdc_loopback/cdk/usb_cdc_loopback.cdkproj" Active="No"/>
|
||||
|
@ -44,6 +45,7 @@
|
|||
<Project Name="spi_loopback" ConfigName="BuildSet"/>
|
||||
<Project Name="spi_lcd" ConfigName="BuildSet"/>
|
||||
<Project Name="uart_dma" ConfigName="BuildSet"/>
|
||||
<Project Name="uart_echo" ConfigName="BuildSet"/>
|
||||
<Project Name="uart_poll" ConfigName="BuildSet"/>
|
||||
<Project Name="uart_rx_it" ConfigName="BuildSet"/>
|
||||
<Project Name="usb_cdc_loopback" ConfigName="BuildSet"/>
|
||||
|
|
|
@ -90,7 +90,7 @@ int main(void)
|
|||
}
|
||||
|
||||
/* connect dac device and dma device */
|
||||
device_control(dac,DEVICE_CTRL_DAC_ATTACH_TX_DMA,dac_dma);
|
||||
device_control(dac,DEVICE_CTRL_ATTACH_TX_DMA,dac_dma);
|
||||
|
||||
|
||||
while(1)
|
||||
|
|
|
@ -504,6 +504,32 @@ Board: bl70x_iot
|
|||
</VirtualDirectory>
|
||||
</VirtualDirectory>
|
||||
<Dependencies Name="BuildSet"/>
|
||||
<DebugSessions>
|
||||
<watchExpressions/>
|
||||
<memoryExpressions>;;;</memoryExpressions>
|
||||
<statistics>;;MHZ;</statistics>
|
||||
<peripheralTabs>
|
||||
<Tab disFormat="Hex">glb</Tab>
|
||||
<Tab disFormat="Hex">uart</Tab>
|
||||
</peripheralTabs>
|
||||
<WatchDisplayFormat>1</WatchDisplayFormat>
|
||||
<LocalDisplayFormat>1</LocalDisplayFormat>
|
||||
<debugLayout/>
|
||||
<memoryTabColSizeExpressions>100:8;100:8;100:8;100:8;</memoryTabColSizeExpressions>
|
||||
</DebugSessions>
|
||||
<DebugSessions>
|
||||
<watchExpressions/>
|
||||
<memoryExpressions>;;;</memoryExpressions>
|
||||
<statistics>;;MHZ;</statistics>
|
||||
<peripheralTabs>
|
||||
<Tab disFormat="Hex">glb</Tab>
|
||||
<Tab disFormat="Hex">uart</Tab>
|
||||
</peripheralTabs>
|
||||
<WatchDisplayFormat>1</WatchDisplayFormat>
|
||||
<LocalDisplayFormat>1</LocalDisplayFormat>
|
||||
<debugLayout/>
|
||||
<memoryTabColSizeExpressions>100:8;100:8;100:8;100:8;</memoryTabColSizeExpressions>
|
||||
</DebugSessions>
|
||||
<BuildConfigs>
|
||||
<BuildConfig Name="BuildSet">
|
||||
<Target>
|
||||
|
@ -603,7 +629,7 @@ Board: bl70x_iot
|
|||
<Undefine/>
|
||||
<Optim>Optimize more (-O2)</Optim>
|
||||
<DebugLevel>Default (-g)</DebugLevel>
|
||||
<IncludePath>$(ProjectPath);$(ProjectPath)../;$(ProjectPath)../../../../components/fatfs;$(ProjectPath)../../../../components/freertos/Source/include;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../components/usb_stack/class/audio;$(ProjectPath)../../../../components/usb_stack/class/cdc;$(ProjectPath)../../../../components/usb_stack/class/hid;$(ProjectPath)../../../../components/usb_stack/class/msc;$(ProjectPath)../../../../components/usb_stack/class/video;$(ProjectPath)../../../../components/usb_stack/class/webusb;$(ProjectPath)../../../../components/usb_stack/class/winusb;$(ProjectPath)../../../../components/usb_stack/common;$(ProjectPath)../../../../components/usb_stack/core;$(ProjectPath)../../../../bsp/board/bl706_iot;$(ProjectPath)../../../../bsp/bsp_common/platform;$(ProjectPath)../../../../common/libc/inc;$(ProjectPath)../../../../common/libc/inc/arm_gcc;$(ProjectPath)../../../../common/libc/inc/bits;$(ProjectPath)../../../../common/libc/inc/sys;$(ProjectPath)../../../../common/libc/src;$(ProjectPath)../../../../common/device;$(ProjectPath)../../../../common/list;$(ProjectPath)../../../../common/memheap;$(ProjectPath)../../../../common/misc;$(ProjectPath)../../../../common/ring_buffer;$(ProjectPath)../../../../common/soft_crc;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl702_driver/risc-v/Core/Include;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl702_driver/regs;$(ProjectPath)../../../../drivers/bl702_driver/startup;$(ProjectPath)../../../../drivers/bl702_driver/std_drv/inc;$(ProjectPath)../../../../drivers/bl602_driver/risc-v/Core/Include;$(ProjectPath)../../../../drivers/bl602_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl602_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl602_driver/regs;$(ProjectPath)../../../../drivers/bl602_driver/std_drv/inc</IncludePath>
|
||||
<IncludePath>$(ProjectPath);$(ProjectPath)../;$(ProjectPath)../../../../components/fatfs;$(ProjectPath)../../../../components/freertos/Source/include;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../components/usb_stack/class/audio;$(ProjectPath)../../../../components/usb_stack/class/cdc;$(ProjectPath)../../../../components/usb_stack/class/hid;$(ProjectPath)../../../../components/usb_stack/class/msc;$(ProjectPath)../../../../components/usb_stack/class/video;$(ProjectPath)../../../../components/usb_stack/class/webusb;$(ProjectPath)../../../../components/usb_stack/class/winusb;$(ProjectPath)../../../../components/usb_stack/common;$(ProjectPath)../../../../components/usb_stack/core;$(ProjectPath)../../../../bsp/board/bl706_iot;$(ProjectPath)../../../../bsp/bsp_common/platform;$(ProjectPath)../../../../common/libc/inc;$(ProjectPath)../../../../common/libc/inc/arm_gcc;$(ProjectPath)../../../../common/libc/inc/bits;$(ProjectPath)../../../../common/libc/inc/sys;$(ProjectPath)../../../../common/libc/src;$(ProjectPath)../../../../common/device;$(ProjectPath)../../../../common/list;$(ProjectPath)../../../../common/memheap;$(ProjectPath)../../../../common/misc;$(ProjectPath)../../../../common/ring_buffer;$(ProjectPath)../../../../common/soft_crc;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl702_driver/risc-v/Core/Include;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl702_driver/regs;$(ProjectPath)../../../../drivers/bl702_driver/startup;$(ProjectPath)../../../../drivers/bl702_driver/std_drv/inc</IncludePath>
|
||||
<OtherFlags>-fshort-enums -fno-common -fms-extensions -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -Wall -Wshift-negative-value -Wchar-subscripts -Wformat -Wuninitialized -Winit-self -fno-jump-tables -Wignored-qualifiers -Wswitch-default -Wunused -Wundef -msmall-data-limit=4</OtherFlags>
|
||||
<Verbose>no</Verbose>
|
||||
<Ansi>no</Ansi>
|
||||
|
@ -619,7 +645,7 @@ Board: bl70x_iot
|
|||
<Asm>
|
||||
<Define/>
|
||||
<Undefine/>
|
||||
<IncludePath>$(ProjectPath);$(ProjectPath)../;$(ProjectPath)../../../../components/fatfs;$(ProjectPath)../../../../components/freertos/Source/include;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../components/usb_stack/class/audio;$(ProjectPath)../../../../components/usb_stack/class/cdc;$(ProjectPath)../../../../components/usb_stack/class/hid;$(ProjectPath)../../../../components/usb_stack/class/msc;$(ProjectPath)../../../../components/usb_stack/class/video;$(ProjectPath)../../../../components/usb_stack/class/webusb;$(ProjectPath)../../../../components/usb_stack/class/winusb;$(ProjectPath)../../../../components/usb_stack/common;$(ProjectPath)../../../../components/usb_stack/core;$(ProjectPath)../../../../bsp/board/bl706_iot;$(ProjectPath)../../../../bsp/bsp_common/platform;$(ProjectPath)../../../../common/device;$(ProjectPath)../../../../common/list;$(ProjectPath)../../../../common/memheap;$(ProjectPath)../../../../common/misc;$(ProjectPath)../../../../common/ring_buffer;$(ProjectPath)../../../../common/soft_crc;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl702_driver/risc-v/Core/Include;$(ProjectPath)../../../../drivers/bl702_driver/regs;$(ProjectPath)../../../../drivers/bl702_driver/startup;$(ProjectPath)../../../../drivers/bl702_driver/std_drv/inc;$(ProjectPath)../../../../drivers/bl602_driver/risc-v/Core/Include;$(ProjectPath)../../../../drivers/bl602_driver/startup;$(ProjectPath)../../../../drivers/bl602_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl602_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl602_driver/regs;$(ProjectPath)../../../../drivers/bl602_driver/std_drv/inc</IncludePath>
|
||||
<IncludePath>$(ProjectPath);$(ProjectPath)../;$(ProjectPath)../../../../components/fatfs;$(ProjectPath)../../../../components/freertos/Source/include;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../components/usb_stack/class/audio;$(ProjectPath)../../../../components/usb_stack/class/cdc;$(ProjectPath)../../../../components/usb_stack/class/hid;$(ProjectPath)../../../../components/usb_stack/class/msc;$(ProjectPath)../../../../components/usb_stack/class/video;$(ProjectPath)../../../../components/usb_stack/class/webusb;$(ProjectPath)../../../../components/usb_stack/class/winusb;$(ProjectPath)../../../../components/usb_stack/common;$(ProjectPath)../../../../components/usb_stack/core;$(ProjectPath)../../../../bsp/board/bl706_iot;$(ProjectPath)../../../../bsp/bsp_common/platform;$(ProjectPath)../../../../common/device;$(ProjectPath)../../../../common/list;$(ProjectPath)../../../../common/memheap;$(ProjectPath)../../../../common/misc;$(ProjectPath)../../../../common/ring_buffer;$(ProjectPath)../../../../common/soft_crc;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl702_driver/risc-v/Core/Include;$(ProjectPath)../../../../drivers/bl702_driver/regs;$(ProjectPath)../../../../drivers/bl702_driver/startup;$(ProjectPath)../../../../drivers/bl702_driver/std_drv/inc</IncludePath>
|
||||
<OtherFlags/>
|
||||
<DebugLevel>gdwarf2</DebugLevel>
|
||||
</Asm>
|
||||
|
@ -697,30 +723,4 @@ Board: bl70x_iot
|
|||
</Flash>
|
||||
</BuildConfig>
|
||||
</BuildConfigs>
|
||||
<DebugSessions>
|
||||
<watchExpressions/>
|
||||
<memoryExpressions>;;;</memoryExpressions>
|
||||
<statistics>;;MHZ;</statistics>
|
||||
<peripheralTabs>
|
||||
<Tab disFormat="Hex">glb</Tab>
|
||||
<Tab disFormat="Hex">uart</Tab>
|
||||
</peripheralTabs>
|
||||
<WatchDisplayFormat>1</WatchDisplayFormat>
|
||||
<LocalDisplayFormat>1</LocalDisplayFormat>
|
||||
<debugLayout/>
|
||||
<memoryTabColSizeExpressions>100:8;100:8;100:8;100:8;</memoryTabColSizeExpressions>
|
||||
</DebugSessions>
|
||||
<DebugSessions>
|
||||
<watchExpressions/>
|
||||
<memoryExpressions>;;;</memoryExpressions>
|
||||
<statistics>;;MHZ;</statistics>
|
||||
<peripheralTabs>
|
||||
<Tab disFormat="Hex">glb</Tab>
|
||||
<Tab disFormat="Hex">uart</Tab>
|
||||
</peripheralTabs>
|
||||
<WatchDisplayFormat>1</WatchDisplayFormat>
|
||||
<LocalDisplayFormat>1</LocalDisplayFormat>
|
||||
<debugLayout/>
|
||||
<memoryTabColSizeExpressions>100:8;100:8;100:8;100:8;</memoryTabColSizeExpressions>
|
||||
</DebugSessions>
|
||||
</Project>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
set(BSP_COMMON_DIR ${CMAKE_SOURCE_DIR}/bsp/bsp_common)
|
||||
set(TARGET_REQUIRED_LIBS fatfs)
|
||||
set(TARGET_REQUIRED_PRIVATE_INCLUDE ${BSP_COMMON_DIR}/es8388 ${BSP_COMMON_DIR}/spi_sd ${BSP_COMMON_DIR}/audio )
|
||||
set(TARGET_REQUIRED_PRIVATE_INCLUDE ${BSP_COMMON_DIR}/es8388 ${BSP_COMMON_DIR}/spi_sd)
|
||||
set(TARGET_REQUIRED_SRCS ${BSP_COMMON_DIR}/es8388/bsp_es8388.c ${BSP_COMMON_DIR}/fatfs/fatfs_spi_sd.c ${BSP_COMMON_DIR}/spi_sd/bsp_spi_sd.c ./wav_play_form_sd_card.c)
|
||||
set(mains main.c)
|
||||
generate_bin()
|
||||
|
|
|
@ -40,7 +40,7 @@ int main(void)
|
|||
gpio_write(GPIO_PIN_30, 0);
|
||||
gpio_write(GPIO_PIN_31, 0);
|
||||
|
||||
pwm_register(PWM0_INDEX, "led_breath", DEVICE_OFLAG_RDWR);
|
||||
pwm_register(PWM_CH2_INDEX, "led_breath", DEVICE_OFLAG_RDWR);
|
||||
|
||||
struct device *led_breath = device_find("led_breath");
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
set(BSP_COMMON_DIR ${CMAKE_SOURCE_DIR}/bsp/bsp_common)
|
||||
set(TARGET_REQUIRED_LIBS fatfs)
|
||||
set(TARGET_REQUIRED_PRIVATE_INCLUDE ${BSP_COMMON_DIR}/il9431)
|
||||
set(TARGET_REQUIRED_SRCS ${BSP_COMMON_DIR}/il9431/bsp_il9431.c)
|
||||
set(TARGET_REQUIRED_PRIVATE_INCLUDE ${BSP_COMMON_DIR}/il9341)
|
||||
set(TARGET_REQUIRED_SRCS ${BSP_COMMON_DIR}/il9341/bsp_il9341.c)
|
||||
set(mains main.c)
|
||||
generate_bin()
|
||||
|
||||
|
|
|
@ -195,9 +195,7 @@ Board: bl70x_iot
|
|||
<File Name="../../../../bsp/bsp_common/platform/bflb_platform.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../bsp/bsp_common/il9431/bsp_il9431.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../bsp/bsp_common/il9341/bsp_il9341.c"/>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="common">
|
||||
<File Name="../../../../common/device/drv_device.c">
|
||||
|
@ -632,7 +630,7 @@ Board: bl70x_iot
|
|||
<Undefine/>
|
||||
<Optim>Optimize more (-O2)</Optim>
|
||||
<DebugLevel>Default (-g)</DebugLevel>
|
||||
<IncludePath>$(ProjectPath);$(ProjectPath)../;$(ProjectPath)../../../../components/fatfs;$(ProjectPath)../../../../components/freertos/Source/include;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../components/usb_stack/class/audio;$(ProjectPath)../../../../components/usb_stack/class/cdc;$(ProjectPath)../../../../components/usb_stack/class/hid;$(ProjectPath)../../../../components/usb_stack/class/msc;$(ProjectPath)../../../../components/usb_stack/class/video;$(ProjectPath)../../../../components/usb_stack/class/webusb;$(ProjectPath)../../../../components/usb_stack/class/winusb;$(ProjectPath)../../../../components/usb_stack/common;$(ProjectPath)../../../../components/usb_stack/core;$(ProjectPath)../../../../bsp/board/bl706_iot;$(ProjectPath)../../../../bsp/bsp_common/platform;$(ProjectPath)../../../../bsp/bsp_common/il9431;$(ProjectPath)../../../../common/libc/inc;$(ProjectPath)../../../../common/libc/inc/arm_gcc;$(ProjectPath)../../../../common/libc/inc/bits;$(ProjectPath)../../../../common/libc/inc/sys;$(ProjectPath)../../../../common/libc/src;$(ProjectPath)../../../../common/device;$(ProjectPath)../../../../common/list;$(ProjectPath)../../../../common/memheap;$(ProjectPath)../../../../common/misc;$(ProjectPath)../../../../common/ring_buffer;$(ProjectPath)../../../../common/soft_crc;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl702_driver/risc-v/Core/Include;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl702_driver/regs;$(ProjectPath)../../../../drivers/bl702_driver/startup;$(ProjectPath)../../../../drivers/bl702_driver/std_drv/inc;$(ProjectPath)../../../../drivers/bl602_driver/risc-v/Core/Include;$(ProjectPath)../../../../drivers/bl602_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl602_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl602_driver/regs;$(ProjectPath)../../../../drivers/bl602_driver/std_drv/inc</IncludePath>
|
||||
<IncludePath>$(ProjectPath);$(ProjectPath)../;$(ProjectPath)../../../../components/fatfs;$(ProjectPath)../../../../components/freertos/Source/include;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../components/usb_stack/class/audio;$(ProjectPath)../../../../components/usb_stack/class/cdc;$(ProjectPath)../../../../components/usb_stack/class/hid;$(ProjectPath)../../../../components/usb_stack/class/msc;$(ProjectPath)../../../../components/usb_stack/class/video;$(ProjectPath)../../../../components/usb_stack/class/webusb;$(ProjectPath)../../../../components/usb_stack/class/winusb;$(ProjectPath)../../../../components/usb_stack/common;$(ProjectPath)../../../../components/usb_stack/core;$(ProjectPath)../../../../bsp/board/bl706_iot;$(ProjectPath)../../../../bsp/bsp_common/platform;$(ProjectPath)../../../../bsp/bsp_common/il9341;$(ProjectPath)../../../../common/libc/inc;$(ProjectPath)../../../../common/libc/inc/arm_gcc;$(ProjectPath)../../../../common/libc/inc/bits;$(ProjectPath)../../../../common/libc/inc/sys;$(ProjectPath)../../../../common/libc/src;$(ProjectPath)../../../../common/device;$(ProjectPath)../../../../common/list;$(ProjectPath)../../../../common/memheap;$(ProjectPath)../../../../common/misc;$(ProjectPath)../../../../common/ring_buffer;$(ProjectPath)../../../../common/soft_crc;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl702_driver/risc-v/Core/Include;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl702_driver/regs;$(ProjectPath)../../../../drivers/bl702_driver/startup;$(ProjectPath)../../../../drivers/bl702_driver/std_drv/inc</IncludePath>
|
||||
<OtherFlags>-fshort-enums -fno-common -fms-extensions -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -Wall -Wshift-negative-value -Wchar-subscripts -Wformat -Wuninitialized -Winit-self -fno-jump-tables -Wignored-qualifiers -Wswitch-default -Wunused -Wundef -msmall-data-limit=4</OtherFlags>
|
||||
<Verbose>no</Verbose>
|
||||
<Ansi>no</Ansi>
|
||||
|
@ -648,7 +646,7 @@ Board: bl70x_iot
|
|||
<Asm>
|
||||
<Define/>
|
||||
<Undefine/>
|
||||
<IncludePath>$(ProjectPath);$(ProjectPath)../;$(ProjectPath)../../../../components/fatfs;$(ProjectPath)../../../../components/freertos/Source/include;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../components/usb_stack/class/audio;$(ProjectPath)../../../../components/usb_stack/class/cdc;$(ProjectPath)../../../../components/usb_stack/class/hid;$(ProjectPath)../../../../components/usb_stack/class/msc;$(ProjectPath)../../../../components/usb_stack/class/video;$(ProjectPath)../../../../components/usb_stack/class/webusb;$(ProjectPath)../../../../components/usb_stack/class/winusb;$(ProjectPath)../../../../components/usb_stack/common;$(ProjectPath)../../../../components/usb_stack/core;$(ProjectPath)../../../../bsp/board/bl706_iot;$(ProjectPath)../../../../bsp/bsp_common/platform;$(ProjectPath)../../../../bsp/bsp_common/il9431;$(ProjectPath)../../../../common/device;$(ProjectPath)../../../../common/list;$(ProjectPath)../../../../common/memheap;$(ProjectPath)../../../../common/misc;$(ProjectPath)../../../../common/ring_buffer;$(ProjectPath)../../../../common/soft_crc;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl702_driver/risc-v/Core/Include;$(ProjectPath)../../../../drivers/bl702_driver/regs;$(ProjectPath)../../../../drivers/bl702_driver/startup;$(ProjectPath)../../../../drivers/bl702_driver/std_drv/inc;$(ProjectPath)../../../../drivers/bl602_driver/risc-v/Core/Include;$(ProjectPath)../../../../drivers/bl602_driver/startup;$(ProjectPath)../../../../drivers/bl602_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl602_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl602_driver/regs;$(ProjectPath)../../../../drivers/bl602_driver/std_drv/inc</IncludePath>
|
||||
<IncludePath>$(ProjectPath);$(ProjectPath)../;$(ProjectPath)../../../../components/fatfs;$(ProjectPath)../../../../components/freertos/Source/include;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../components/usb_stack/class/audio;$(ProjectPath)../../../../components/usb_stack/class/cdc;$(ProjectPath)../../../../components/usb_stack/class/hid;$(ProjectPath)../../../../components/usb_stack/class/msc;$(ProjectPath)../../../../components/usb_stack/class/video;$(ProjectPath)../../../../components/usb_stack/class/webusb;$(ProjectPath)../../../../components/usb_stack/class/winusb;$(ProjectPath)../../../../components/usb_stack/common;$(ProjectPath)../../../../components/usb_stack/core;$(ProjectPath)../../../../bsp/board/bl706_iot;$(ProjectPath)../../../../bsp/bsp_common/platform;$(ProjectPath)../../../../bsp/bsp_common/il9341;$(ProjectPath)../../../../common/device;$(ProjectPath)../../../../common/list;$(ProjectPath)../../../../common/memheap;$(ProjectPath)../../../../common/misc;$(ProjectPath)../../../../common/ring_buffer;$(ProjectPath)../../../../common/soft_crc;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl702_driver/risc-v/Core/Include;$(ProjectPath)../../../../drivers/bl702_driver/regs;$(ProjectPath)../../../../drivers/bl702_driver/startup;$(ProjectPath)../../../../drivers/bl702_driver/std_drv/inc</IncludePath>
|
||||
<OtherFlags/>
|
||||
<DebugLevel>gdwarf2</DebugLevel>
|
||||
</Asm>
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include "hal_spi.h"
|
||||
#include "hal_gpio.h"
|
||||
#include "hal_dma.h"
|
||||
#include "bsp_il9431.h"
|
||||
#include "bsp_il9341.h"
|
||||
|
||||
|
||||
uint8_t bo[] = {
|
||||
|
|
|
@ -72,7 +72,7 @@ int main(void)
|
|||
device_control(dma_ch2, DEVICE_CTRL_SET_INT, NULL);
|
||||
}
|
||||
|
||||
device_control(uart,DEVICE_CTRL_UART_ATTACH_TX_DMA,dma_ch2);
|
||||
device_control(uart,DEVICE_CTRL_ATTACH_TX_DMA,dma_ch2);
|
||||
while (1)
|
||||
{
|
||||
device_write(uart,0,src_buffer,4100);
|
||||
|
|
8
examples/usb/usb2uart/CMakeLists.txt
Normal file
8
examples/usb/usb2uart/CMakeLists.txt
Normal file
|
@ -0,0 +1,8 @@
|
|||
set(BSP_COMMON_DIR ${CMAKE_SOURCE_DIR}/bsp/bsp_common)
|
||||
set(TARGET_REQUIRED_LIBS usb_stack)
|
||||
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(mains main.c)
|
||||
generate_bin()
|
||||
|
||||
|
288
examples/usb/usb2uart/main.c
Normal file
288
examples/usb/usb2uart/main.c
Normal file
|
@ -0,0 +1,288 @@
|
|||
/**
|
||||
* @file main.c
|
||||
* @brief
|
||||
*
|
||||
* Copyright (c) 2021 Bouffalolab team
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
#include "hal_usb.h"
|
||||
#include "usbd_core.h"
|
||||
#include "usbd_cdc.h"
|
||||
#include "uart_interface.h"
|
||||
#include "bl702_ef_ctrl.h"
|
||||
|
||||
#define CDC_IN_EP 0x82
|
||||
#define CDC_OUT_EP 0x01
|
||||
#define CDC_INT_EP 0x83
|
||||
|
||||
#define USBD_VID 0xFFFF
|
||||
#define USBD_PID 0xFFFF
|
||||
#define USBD_MAX_POWER 100
|
||||
#define USBD_LANGID_STRING 1033
|
||||
|
||||
#define USB_CONFIG_SIZE (9 + CDC_ACM_DESCRIPTOR_LEN)
|
||||
|
||||
#define USB_CDC_RESET_FILTER_PATTERN "BOUFFALOLAB5555RESET"
|
||||
|
||||
uint8_t cdc_descriptor[] =
|
||||
{
|
||||
USB_DEVICE_DESCRIPTOR_INIT(USB_2_0,0x02,0x02,0x01,USBD_VID,USBD_PID,0x0100,0x01),
|
||||
USB_CONFIG_DESCRIPTOR_INIT(USB_CONFIG_SIZE,0x02,0x01,USB_CONFIG_BUS_POWERED,USBD_MAX_POWER),
|
||||
CDC_ACM_DESCRIPTOR_INIT(0x00,CDC_INT_EP,CDC_OUT_EP,CDC_IN_EP,0x02),
|
||||
///////////////////////////////////////
|
||||
/// string0 descriptor
|
||||
///////////////////////////////////////
|
||||
USB_LANGID_INIT(USBD_LANGID_STRING),
|
||||
///////////////////////////////////////
|
||||
/// string1 descriptor
|
||||
///////////////////////////////////////
|
||||
0x12, /* bLength */
|
||||
USB_DESCRIPTOR_TYPE_STRING, /* bDescriptorType */
|
||||
'B', 0x00, /* wcChar0 */
|
||||
'o', 0x00, /* wcChar1 */
|
||||
'u', 0x00, /* wcChar2 */
|
||||
'f', 0x00, /* wcChar3 */
|
||||
'f', 0x00, /* wcChar4 */
|
||||
'a', 0x00, /* wcChar5 */
|
||||
'l', 0x00, /* wcChar6 */
|
||||
'o', 0x00, /* wcChar7 */
|
||||
///////////////////////////////////////
|
||||
/// string2 descriptor
|
||||
///////////////////////////////////////
|
||||
0x20, /* bLength */
|
||||
USB_DESCRIPTOR_TYPE_STRING, /* bDescriptorType */
|
||||
'B', 0x00, /* wcChar0 */
|
||||
'o', 0x00, /* wcChar1 */
|
||||
'u', 0x00, /* wcChar2 */
|
||||
'f', 0x00, /* wcChar3 */
|
||||
'f', 0x00, /* wcChar4 */
|
||||
'a', 0x00, /* wcChar5 */
|
||||
'l', 0x00, /* wcChar6 */
|
||||
'o', 0x00, /* wcChar7 */
|
||||
' ', 0x00, /* wcChar8 */
|
||||
'S', 0x00, /* wcChar9 */
|
||||
'e', 0x00, /* wcChar10 */
|
||||
'r', 0x00, /* wcChar11 */
|
||||
'i', 0x00, /* wcChar13 */
|
||||
'a', 0x00, /* wcChar14 */
|
||||
'l', 0x00, /* wcChar15 */
|
||||
///////////////////////////////////////
|
||||
/// string3 descriptor
|
||||
///////////////////////////////////////
|
||||
0x30, /* bLength */
|
||||
USB_DESCRIPTOR_TYPE_STRING, /* bDescriptorType */
|
||||
'F', 0x00, /* wcChar0 */
|
||||
'a', 0x00, /* wcChar1 */
|
||||
'c', 0x00, /* wcChar2 */
|
||||
't', 0x00, /* wcChar3 */
|
||||
'o', 0x00, /* wcChar4 */
|
||||
'r', 0x00, /* wcChar5 */
|
||||
'y', 0x00, /* wcChar6 */
|
||||
'A', 0x00, /* wcChar7 */
|
||||
'I', 0x00, /* wcChar8 */
|
||||
'O', 0x00, /* wcChar9 */
|
||||
'T', 0x00, /* wcChar10 */
|
||||
' ', 0x00, /* wcChar11 */
|
||||
'P', 0x00, /* wcChar12 */
|
||||
'r', 0x00, /* wcChar13 */
|
||||
'o', 0x00, /* wcChar14 */
|
||||
'g', 0x00, /* wcChar15 */
|
||||
' ', 0x00, /* wcChar16 */
|
||||
'S', 0x00, /* wcChar17 */
|
||||
'e', 0x00, /* wcChar18 */
|
||||
'r', 0x00, /* wcChar19 */
|
||||
'i', 0x00, /* wcChar20 */
|
||||
'a', 0x00, /* wcChar21 */
|
||||
'l', 0x00, /* wcChar22 */
|
||||
///////////////////////////////////////
|
||||
/// device qualifier descriptor
|
||||
///////////////////////////////////////
|
||||
0x0a,
|
||||
USB_DESCRIPTOR_TYPE_DEVICE_QUALIFIER,
|
||||
0x00,
|
||||
0x02,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x40,
|
||||
0x01,
|
||||
0x00,
|
||||
|
||||
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)
|
||||
{
|
||||
unsigned char num2string_table[] = "0123456789ABCDEF";
|
||||
int i = 0;
|
||||
while(i < length)
|
||||
{
|
||||
*(string++) = num2string_table[((hexarray[i] >> 4) & 0x0f)];
|
||||
*(string++) = num2string_table[(hexarray[i] & 0x0f)];
|
||||
i++;
|
||||
}
|
||||
}
|
||||
uint32_t usbd_cdc_filter_callback(uint8_t* data, uint32_t len)
|
||||
{
|
||||
uint32_t pattern_len=sizeof(USB_CDC_RESET_FILTER_PATTERN)-1;
|
||||
int32_t delay=10;
|
||||
|
||||
MSG("usbd_cdc_filter_callback Len:%d\r\n",len);
|
||||
if(memcmp(data,USB_CDC_RESET_FILTER_PATTERN,pattern_len)==0){
|
||||
data[len]=0;
|
||||
MSG("Filter get:%s\r\n",data);
|
||||
|
||||
uart1_dtr_init();
|
||||
uart1_rts_init();
|
||||
|
||||
if(data[pattern_len]=='0'||data[pattern_len]==0){
|
||||
usbd_cdc_acm_set_dtr(0);
|
||||
MSG("DTR0\r\n");
|
||||
}
|
||||
if(data[pattern_len]=='1'||data[pattern_len]==1){
|
||||
usbd_cdc_acm_set_dtr(1);
|
||||
MSG("DTR1\r\n");
|
||||
}
|
||||
if(data[pattern_len+1]=='0'||data[pattern_len+1]==0){
|
||||
usbd_cdc_acm_set_rts(0);
|
||||
MSG("RTS0\r\n");
|
||||
}
|
||||
if(data[pattern_len+1]=='1'||data[pattern_len+1]==1){
|
||||
usbd_cdc_acm_set_rts(1);
|
||||
MSG("RTS1\r\n");
|
||||
}
|
||||
//delay=atoi(( char *)&data[pattern_len+1]);
|
||||
if(delay<=0){
|
||||
delay=10;
|
||||
}
|
||||
bflb_platform_delay_ms(delay);
|
||||
if(data[pattern_len+1]=='0'||data[pattern_len+1]==0){
|
||||
usbd_cdc_acm_set_rts(1);
|
||||
MSG("RTS1\r\n");
|
||||
}
|
||||
if(data[pattern_len+1]=='1'||data[pattern_len+1]==1){
|
||||
usbd_cdc_acm_set_rts(0);
|
||||
MSG("RTS0\r\n");
|
||||
}
|
||||
bflb_platform_delay_ms(delay);
|
||||
|
||||
uart1_rts_deinit();
|
||||
bflb_platform_delay_ms(5);
|
||||
uart1_dtr_deinit();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void usbd_cdc_acm_bulk_out(uint8_t ep)
|
||||
{
|
||||
uint32_t filter_len=sizeof(USB_CDC_RESET_FILTER_PATTERN)+1;
|
||||
|
||||
usb_dc_receive_to_ringbuffer(usb_fs, &usb_rx_rb, ep);
|
||||
//MSG("Len:%d,%d\r\n",Ring_Buffer_Get_Length(&usb_rx_rb),filter_len);
|
||||
if(Ring_Buffer_Get_Length(&usb_rx_rb)==filter_len){
|
||||
Ring_Buffer_Peek(&usb_rx_rb, filter_buf, filter_len);
|
||||
if(1==usbd_cdc_filter_callback(filter_buf,filter_len)){
|
||||
Ring_Buffer_Read(&usb_rx_rb, filter_buf, filter_len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void usbd_cdc_acm_bulk_in(uint8_t ep)
|
||||
{
|
||||
usb_dc_send_from_ringbuffer(usb_fs, &uart1_rx_rb, ep);
|
||||
}
|
||||
|
||||
void usbd_cdc_acm_set_line_coding(uint32_t baudrate, uint8_t databits, uint8_t parity, uint8_t stopbits)
|
||||
{
|
||||
uart1_config(baudrate, databits, parity, stopbits);
|
||||
}
|
||||
|
||||
void usbd_cdc_acm_set_dtr(bool dtr)
|
||||
{
|
||||
dtr_pin_set(!dtr);
|
||||
}
|
||||
|
||||
void usbd_cdc_acm_set_rts(bool rts)
|
||||
{
|
||||
rts_pin_set(!rts);
|
||||
}
|
||||
|
||||
usbd_class_t cdc_class;
|
||||
usbd_interface_t cdc_cmd_intf;
|
||||
usbd_interface_t cdc_data_intf;
|
||||
|
||||
usbd_endpoint_t cdc_out_ep =
|
||||
{
|
||||
.ep_addr = CDC_OUT_EP,
|
||||
.ep_cb = usbd_cdc_acm_bulk_out
|
||||
};
|
||||
|
||||
usbd_endpoint_t cdc_in_ep =
|
||||
{
|
||||
.ep_addr = CDC_IN_EP,
|
||||
.ep_cb = usbd_cdc_acm_bulk_in
|
||||
};
|
||||
|
||||
extern struct device* usb_dc_init(void);
|
||||
|
||||
int main(void)
|
||||
{
|
||||
uint8_t chipid[8];
|
||||
uint8_t chipid2[6];
|
||||
|
||||
bflb_platform_init(0);
|
||||
uart_ringbuffer_init();
|
||||
uart1_init();
|
||||
uart1_dtr_deinit();
|
||||
uart1_rts_deinit();
|
||||
|
||||
usbd_desc_register(cdc_descriptor);
|
||||
|
||||
EF_Ctrl_Read_Chip_ID(chipid);
|
||||
hexarr2string(&chipid[2],3,chipid2);
|
||||
// bflb_platform_dump(chipid,8);
|
||||
// bflb_platform_dump(chipid2,6);
|
||||
cdc_descriptor[0x12+USB_CONFIG_SIZE+0x04+0x12+0x20+0x24] = chipid2[0];
|
||||
cdc_descriptor[0x12+USB_CONFIG_SIZE+0x04+0x12+0x20+0x24+2] = chipid2[1];
|
||||
cdc_descriptor[0x12+USB_CONFIG_SIZE+0x04+0x12+0x20+0x24+4] = chipid2[2];
|
||||
cdc_descriptor[0x12+USB_CONFIG_SIZE+0x04+0x12+0x20+0x24+6] = chipid2[3];
|
||||
cdc_descriptor[0x12+USB_CONFIG_SIZE+0x04+0x12+0x20+0x24+8] = chipid2[4];
|
||||
cdc_descriptor[0x12+USB_CONFIG_SIZE+0x04+0x12+0x20+0x24+10] = chipid2[5];
|
||||
|
||||
usbd_cdc_add_acm_interface(&cdc_class,&cdc_cmd_intf);
|
||||
usbd_cdc_add_acm_interface(&cdc_class,&cdc_data_intf);
|
||||
usbd_interface_add_endpoint(&cdc_data_intf,&cdc_out_ep);
|
||||
usbd_interface_add_endpoint(&cdc_data_intf,&cdc_in_ep);
|
||||
|
||||
usb_fs = usb_dc_init();
|
||||
if (usb_fs)
|
||||
{
|
||||
device_control(usb_fs, DEVICE_CTRL_SET_INT, (void *)(USB_EP1_DATA_OUT_IT | USB_EP2_DATA_IN_IT));
|
||||
}
|
||||
while(!usb_device_is_configured());
|
||||
while (1)
|
||||
{
|
||||
uart_send_from_ringbuffer();
|
||||
}
|
||||
}
|
8
examples/usb/usb_cdc_acm2/CMakeLists.txt
Normal file
8
examples/usb/usb_cdc_acm2/CMakeLists.txt
Normal file
|
@ -0,0 +1,8 @@
|
|||
set(BSP_COMMON_DIR ${CMAKE_SOURCE_DIR}/bsp/bsp_common)
|
||||
set(TARGET_REQUIRED_LIBS usb_stack)
|
||||
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(mains main.c)
|
||||
generate_bin()
|
||||
|
||||
|
233
examples/usb/usb_cdc_acm2/main.c
Normal file
233
examples/usb/usb_cdc_acm2/main.c
Normal file
|
@ -0,0 +1,233 @@
|
|||
/**
|
||||
* @file main.c
|
||||
* @brief
|
||||
*
|
||||
* Copyright (c) 2021 Bouffalolab team
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
#include "hal_usb.h"
|
||||
#include "usbd_core.h"
|
||||
#include "usbd_cdc.h"
|
||||
|
||||
#define CDC_IN_EP 0x82
|
||||
#define CDC_OUT_EP 0x01
|
||||
#define CDC_INT_EP 0x83
|
||||
|
||||
#define USBD_VID 0xFFFF
|
||||
#define USBD_PID 0xFFFF
|
||||
#define USBD_MAX_POWER 100
|
||||
#define USBD_LANGID_STRING 1033
|
||||
|
||||
#define USB_CONFIG_SIZE (9 + CDC_ACM_DESCRIPTOR_LEN + CDC_ACM_DESCRIPTOR_LEN)
|
||||
|
||||
USB_DESC_SECTION const uint8_t cdc_descriptor[] =
|
||||
{
|
||||
USB_DEVICE_DESCRIPTOR_INIT(USB_2_0,0x02,0x02,0x01,USBD_VID,USBD_PID,0x0100,0x01),
|
||||
USB_CONFIG_DESCRIPTOR_INIT(USB_CONFIG_SIZE,0x04,0x01,USB_CONFIG_BUS_POWERED,USBD_MAX_POWER),
|
||||
CDC_ACM_DESCRIPTOR_INIT(0x00,0x85,CDC_OUT_EP,CDC_IN_EP,0x02),
|
||||
CDC_ACM_DESCRIPTOR_INIT(0x02,0x86,0x04,0x83,0x02),
|
||||
///////////////////////////////////////
|
||||
/// string0 descriptor
|
||||
///////////////////////////////////////
|
||||
USB_LANGID_INIT(USBD_LANGID_STRING),
|
||||
///////////////////////////////////////
|
||||
/// string1 descriptor
|
||||
///////////////////////////////////////
|
||||
0x12, /* bLength */
|
||||
USB_DESCRIPTOR_TYPE_STRING, /* bDescriptorType */
|
||||
'B', 0x00, /* wcChar0 */
|
||||
'o', 0x00, /* wcChar1 */
|
||||
'u', 0x00, /* wcChar2 */
|
||||
'f', 0x00, /* wcChar3 */
|
||||
'f', 0x00, /* wcChar4 */
|
||||
'a', 0x00, /* wcChar5 */
|
||||
'l', 0x00, /* wcChar6 */
|
||||
'o', 0x00, /* wcChar7 */
|
||||
///////////////////////////////////////
|
||||
/// string2 descriptor
|
||||
///////////////////////////////////////
|
||||
0x24, /* bLength */
|
||||
USB_DESCRIPTOR_TYPE_STRING, /* bDescriptorType */
|
||||
'B', 0x00, /* wcChar0 */
|
||||
'o', 0x00, /* wcChar1 */
|
||||
'u', 0x00, /* wcChar2 */
|
||||
'f', 0x00, /* wcChar3 */
|
||||
'f', 0x00, /* wcChar4 */
|
||||
'a', 0x00, /* wcChar5 */
|
||||
'l', 0x00, /* wcChar6 */
|
||||
'o', 0x00, /* wcChar7 */
|
||||
' ', 0x00, /* wcChar8 */
|
||||
'C', 0x00, /* wcChar9 */
|
||||
'D', 0x00, /* wcChar10 */
|
||||
'C', 0x00, /* wcChar11 */
|
||||
' ', 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 */
|
||||
///////////////////////////////////////
|
||||
/// device qualifier descriptor
|
||||
///////////////////////////////////////
|
||||
0x0a,
|
||||
USB_DESCRIPTOR_TYPE_DEVICE_QUALIFIER,
|
||||
0x00,
|
||||
0x02,
|
||||
0x02,
|
||||
0x02,
|
||||
0x01,
|
||||
0x40,
|
||||
0x01,
|
||||
0x00,
|
||||
|
||||
0x00
|
||||
};
|
||||
|
||||
bool zlp_flag = false;
|
||||
|
||||
uint32_t actual_write_length = 0;
|
||||
uint32_t total_recv_length = 0;
|
||||
uint32_t rx_pos = 0;
|
||||
uint8_t tx_pos = 0;
|
||||
uint8_t out_buffer[4096];
|
||||
|
||||
void usbd_cdc_acm_bulk_out(uint8_t ep)
|
||||
{
|
||||
uint32_t actual_read_length = 0;
|
||||
|
||||
if (usbd_ep_read(ep, &out_buffer[rx_pos], 64, &actual_read_length) < 0)
|
||||
{
|
||||
USBD_LOG_DBG("Read DATA Packet failed\r\n");
|
||||
usbd_ep_set_stall(ep);
|
||||
return;
|
||||
}
|
||||
usbd_ep_read(ep,NULL,0,NULL);
|
||||
rx_pos += actual_read_length;
|
||||
total_recv_length += actual_read_length;
|
||||
actual_write_length = total_recv_length;
|
||||
|
||||
if(rx_pos > 4096)
|
||||
rx_pos = 0;
|
||||
}
|
||||
|
||||
void usbd_cdc_acm_bulk_in(uint8_t ep)
|
||||
{
|
||||
if ((zlp_flag == false) && actual_write_length)
|
||||
{
|
||||
if(actual_write_length > 64)
|
||||
{
|
||||
usbd_ep_write(ep, (uint8_t*)&out_buffer[tx_pos], 64, NULL);
|
||||
actual_write_length -= 64;
|
||||
tx_pos+=64;
|
||||
}
|
||||
else
|
||||
{
|
||||
usbd_ep_write(ep, (uint8_t*)&out_buffer[tx_pos], actual_write_length, NULL);
|
||||
actual_write_length = 0;
|
||||
tx_pos = 0;
|
||||
total_recv_length = 0;
|
||||
}
|
||||
if (!actual_write_length && !(total_recv_length % 64))
|
||||
{
|
||||
MSG("zlp\r\n");
|
||||
zlp_flag = true;
|
||||
}
|
||||
}
|
||||
else if (zlp_flag)
|
||||
{
|
||||
usbd_ep_write(ep, NULL, 0, NULL);
|
||||
zlp_flag = false;
|
||||
}
|
||||
}
|
||||
|
||||
usbd_class_t cdc_class1;
|
||||
usbd_interface_t cdc_cmd_intf1;
|
||||
usbd_interface_t cdc_data_intf1;
|
||||
|
||||
usbd_endpoint_t cdc_out_ep1 =
|
||||
{
|
||||
.ep_addr = CDC_OUT_EP,
|
||||
.ep_cb = usbd_cdc_acm_bulk_out
|
||||
};
|
||||
|
||||
usbd_endpoint_t cdc_in_ep1 =
|
||||
{
|
||||
.ep_addr = CDC_IN_EP,
|
||||
.ep_cb = usbd_cdc_acm_bulk_in
|
||||
};
|
||||
|
||||
usbd_class_t cdc_class2;
|
||||
usbd_interface_t cdc_cmd_intf2;
|
||||
usbd_interface_t cdc_data_intf2;
|
||||
|
||||
usbd_endpoint_t cdc_out_ep2 =
|
||||
{
|
||||
.ep_addr = 0x04,
|
||||
.ep_cb = usbd_cdc_acm_bulk_out
|
||||
};
|
||||
|
||||
usbd_endpoint_t cdc_in_ep2 =
|
||||
{
|
||||
.ep_addr = 0x83,
|
||||
.ep_cb = usbd_cdc_acm_bulk_in
|
||||
};
|
||||
|
||||
|
||||
struct device *usb_fs;
|
||||
|
||||
extern struct device* usb_dc_init(void);
|
||||
int main(void)
|
||||
{
|
||||
bflb_platform_init(0);
|
||||
|
||||
usbd_desc_register(cdc_descriptor);
|
||||
|
||||
usbd_cdc_add_acm_interface(&cdc_class1,&cdc_cmd_intf1);
|
||||
usbd_cdc_add_acm_interface(&cdc_class1,&cdc_data_intf1);
|
||||
usbd_interface_add_endpoint(&cdc_data_intf1,&cdc_out_ep1);
|
||||
usbd_interface_add_endpoint(&cdc_data_intf1,&cdc_in_ep1);
|
||||
|
||||
usbd_cdc_add_acm_interface(&cdc_class2,&cdc_cmd_intf2);
|
||||
usbd_cdc_add_acm_interface(&cdc_class2,&cdc_data_intf2);
|
||||
usbd_interface_add_endpoint(&cdc_data_intf2,&cdc_out_ep2);
|
||||
usbd_interface_add_endpoint(&cdc_data_intf2,&cdc_in_ep2);
|
||||
|
||||
usb_fs = usb_dc_init();
|
||||
if (usb_fs)
|
||||
{
|
||||
device_control(usb_fs, DEVICE_CTRL_SET_INT, (void *)(USB_EP1_DATA_OUT_IT|USB_EP2_DATA_IN_IT|USB_EP4_DATA_OUT_IT|USB_EP3_DATA_IN_IT));
|
||||
}
|
||||
|
||||
while (1)
|
||||
{
|
||||
}
|
||||
}
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
USB_DESC_SECTION const uint8_t cdc_descriptor[] =
|
||||
{
|
||||
USB_DEVICE_DESCRIPTOR_INIT(USB_2_0,USBD_VID,USBD_PID,0x0100,0x01),
|
||||
USB_DEVICE_DESCRIPTOR_INIT(USB_2_0,0x02,0x02,0x01,USBD_VID,USBD_PID,0x0100,0x01),
|
||||
USB_CONFIG_DESCRIPTOR_INIT(USB_CONFIG_SIZE,0x02,0x01,USB_CONFIG_BUS_POWERED,USBD_MAX_POWER),
|
||||
CDC_ACM_DESCRIPTOR_INIT(0x00,CDC_INT_EP,CDC_OUT_EP,CDC_IN_EP,0x02),
|
||||
///////////////////////////////////////
|
||||
|
@ -122,7 +122,6 @@ uint8_t out_buffer[4096];
|
|||
void usbd_cdc_acm_bulk_out(uint8_t ep)
|
||||
{
|
||||
uint32_t actual_read_length = 0;
|
||||
|
||||
if (usbd_ep_read(ep, &out_buffer[rx_pos], 64, &actual_read_length) < 0)
|
||||
{
|
||||
USBD_LOG_DBG("Read DATA Packet failed\r\n");
|
||||
|
@ -184,6 +183,8 @@ usbd_endpoint_t cdc_in_ep =
|
|||
.ep_cb = usbd_cdc_acm_bulk_in
|
||||
};
|
||||
|
||||
#define USING_POLL_RTX
|
||||
|
||||
struct device *usb_fs;
|
||||
|
||||
extern struct device* usb_dc_init(void);
|
||||
|
@ -195,16 +196,25 @@ int main(void)
|
|||
|
||||
usbd_cdc_add_acm_interface(&cdc_class,&cdc_cmd_intf);
|
||||
usbd_cdc_add_acm_interface(&cdc_class,&cdc_data_intf);
|
||||
usbd_cdc_add_endpoint(&cdc_data_intf,&cdc_out_ep);
|
||||
usbd_cdc_add_endpoint(&cdc_data_intf,&cdc_in_ep);
|
||||
usbd_interface_add_endpoint(&cdc_data_intf,&cdc_out_ep);
|
||||
usbd_interface_add_endpoint(&cdc_data_intf,&cdc_in_ep);
|
||||
|
||||
usb_fs = usb_dc_init();
|
||||
if (usb_fs)
|
||||
{
|
||||
#ifndef USING_POLL_RTX
|
||||
device_control(usb_fs, DEVICE_CTRL_SET_INT, (void *)(USB_EP1_DATA_OUT_IT|USB_EP2_DATA_IN_IT));
|
||||
#endif
|
||||
}
|
||||
|
||||
while(!usb_device_is_configured());
|
||||
while (1)
|
||||
{
|
||||
#ifdef USING_POLL_RTX
|
||||
if(usb_device_is_configured())
|
||||
{
|
||||
device_read(usb_fs,0x01,out_buffer,64);
|
||||
device_write(usb_fs,0x82,out_buffer,64);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
|
||||
USB_DESC_SECTION const uint8_t cdc_msc_descriptor[] =
|
||||
{
|
||||
USB_DEVICE_DESCRIPTOR_INIT(USB_2_0,USBD_VID,USBD_PID,0x0100,0x01),
|
||||
USB_DEVICE_DESCRIPTOR_INIT(USB_2_0,0x02,0x02,0x01,USBD_VID,USBD_PID,0x0100,0x01),
|
||||
USB_CONFIG_DESCRIPTOR_INIT(USB_CONFIG_SIZE,0x03,0x01,USB_CONFIG_BUS_POWERED,USBD_MAX_POWER),
|
||||
CDC_ACM_DESCRIPTOR_INIT(0x00,CDC_INT_EP,CDC_OUT_EP,CDC_IN_EP,0x02),
|
||||
///////////////////////////////////////
|
||||
|
@ -218,8 +218,8 @@ int main(void)
|
|||
|
||||
usbd_cdc_add_acm_interface(&cdc_class,&cdc_cmd_intf);
|
||||
usbd_cdc_add_acm_interface(&cdc_class,&cdc_data_intf);
|
||||
usbd_cdc_add_endpoint(&cdc_data_intf,&cdc_out_ep);
|
||||
usbd_cdc_add_endpoint(&cdc_data_intf,&cdc_in_ep);
|
||||
usbd_interface_add_endpoint(&cdc_data_intf,&cdc_out_ep);
|
||||
usbd_interface_add_endpoint(&cdc_data_intf,&cdc_in_ep);
|
||||
|
||||
usbd_msc_class_init(MSC_OUT_EP,MSC_IN_EP);
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
#define USB_CONFIG_SIZE (9 + MSC_DESCRIPTOR_LEN)
|
||||
|
||||
USB_DESC_SECTION const uint8_t msc_ram_descriptor[] = {
|
||||
USB_DEVICE_DESCRIPTOR_INIT(USB_2_0,USBD_VID,USBD_PID,0x0200,0x01),
|
||||
USB_DEVICE_DESCRIPTOR_INIT(USB_2_0,0x00,0x00,0x00,USBD_VID,USBD_PID,0x0200,0x01),
|
||||
USB_CONFIG_DESCRIPTOR_INIT(USB_CONFIG_SIZE,0x01,0x01,USB_CONFIG_BUS_POWERED,USBD_MAX_POWER),
|
||||
MSC_DESCRIPTOR_INIT(0x00,MSC_OUT_EP,MSC_IN_EP,0x02),
|
||||
///////////////////////////////////////
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#define USB_CONFIG_SIZE (9 + MSC_DESCRIPTOR_LEN)
|
||||
|
||||
USB_DESC_SECTION const uint8_t msc_ram_descriptor[] = {
|
||||
USB_DEVICE_DESCRIPTOR_INIT(USB_2_0,USBD_VID,USBD_PID,0x0200,0x01),
|
||||
USB_DEVICE_DESCRIPTOR_INIT(USB_2_0,0x00,0x00,0x00,USBD_VID,USBD_PID,0x0200,0x01),
|
||||
USB_CONFIG_DESCRIPTOR_INIT(USB_CONFIG_SIZE,0x01,0x01,USB_CONFIG_BUS_POWERED,USBD_MAX_POWER),
|
||||
MSC_DESCRIPTOR_INIT(0x02,MSC_OUT_EP,MSC_IN_EP,0x02),
|
||||
///////////////////////////////////////
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue