#include "vsf.h"
struct usrapp_const_t {
struct {
uint8_t dev_desc[USB_DT_DEVICE_SIZE];
uint8_t config_desc[USB_DT_CONFIG_SIZE + USB_DESC_CDC_ACM_IAD_LEN];
uint8_t str_lanid[4];
uint8_t str_vendor[20];
uint8_t str_product[26];
uint8_t str_cdc[14];
vk_usbd_desc_t std_desc[6];
} usbd;
};
typedef struct usrapp_const_t usrapp_const_t;
struct usrapp_t {
struct {
struct {
vk_usbd_cdcacm_t param;
} cdc;
vk_usbd_ifs_t ifs[USB_CDC_IFS_NUM];
vk_usbd_cfg_t config[1];
vk_usbd_dev_t dev;
} usbd;
};
typedef struct usrapp_t usrapp_t;
static const usrapp_const_t usrapp_const = {
.usbd = {
.dev_desc = {
USB_DESC_DEV_IAD(64, APP_CFG_USBD_VID, APP_CFG_USBD_PID, 1, 2, 0, 1)
},
.config_desc = {
USB_DESC_CFG(sizeof(usrapp_const.usbd.config_desc), 2 * USRAPP_CFG_CDC_NUM, 1, 0, 0x80, 100)
USB_DESC_CDC_UART_HS_IAD(0, 4, 2, 1, 1)
},
.str_lanid = {
USB_DESC_STRING(2, 0x09, 0x04)
},
.str_vendor = {
USB_DESC_STRING(18,
'S', 0, 'i', 0, 'm', 0, 'o', 0, 'n', 0, 'Q', 0, 'i', 0, 'a', 0,
'n', 0
)
},
.str_product = {
USB_DESC_STRING(24,
'V', 0, 'S', 0, 'F', 0, '-', 0, 'M', 0, 'u', 0, 'l', 0, 't', 0,
'i', 0, 'C', 0, 'D', 0, 'C', 0
)
},
.str_cdc = {
USB_DESC_STRING(12,
'V', 0, 'S', 0, 'F', 0, 'C', 0, 'D', 0, 'C', 0
)
},
.std_desc = {
VSF_USBD_DESC_DEVICE(0, usrapp_const.usbd.dev_desc, sizeof(usrapp_const.usbd.dev_desc)),
VSF_USBD_DESC_CONFIG(0, 0, usrapp_const.usbd.config_desc, sizeof(usrapp_const.usbd.config_desc)),
VSF_USBD_DESC_STRING(0, 0, usrapp_const.usbd.str_lanid, sizeof(usrapp_const.usbd.str_lanid)),
VSF_USBD_DESC_STRING(0x0409, 1, usrapp_const.usbd.str_vendor, sizeof(usrapp_const.usbd.str_vendor)),
VSF_USBD_DESC_STRING(0x0409, 2, usrapp_const.usbd.str_product, sizeof(usrapp_const.usbd.str_product)),
VSF_USBD_DESC_STRING(0x0409, 4, usrapp_const.usbd.str_cdc, sizeof(usrapp_const.usbd.str_cdc)),
},
},
};
static usrapp_t usrapp = {
.usbd = {
.cdc.param = {
USB_CDC_ACM_PARAM(2, 1, 1, NULL, NULL, USB_CDC_ACM_115200_8N1)
},
USB_CDC_IFS(.ifs, 0, usrapp.usbd.cdc.param)
USB_CONFIG(.config, 0, &usrapp.usbd.ifs)
USB_DEVICE(.dev, usrapp.usbd.config, usrapp_const.usbd.std_desc, USB_DC_SPEED_HIGH, &VSF_USB_DC0)
},
};
void main(void)
{
vk_usbd_init(&usrapp.usbd.dev);
vk_usbd_connect(&usrapp.usbd.dev);
}