你好,你的做成功么,我这一直有问题
我没有直接用rtthread工程生成usb做控制台,而是通过手动修改的方式把控制台使用的串口输入输出函数替换为cdc的输入输出函数,目前使用一切正常,替换如下,修改相应的读写机制,
static const struct rt_uart_ops stm32_vcom_ops =
{
usbvcom_configure,
usbvcom_control,
usbvcom_putc,
usbvcom_getc,
};
static const struct rt_uart_ops stm32_uart_ops =
{
stm32_configure,
stm32_control,
stm32_putc,
stm32_getc,
};
/////////////////////////////////////////////////////////////
static int bendich = ‘6’;
static int getflag = 0;
void set_bendi_CH(int ch)
{
bendich = ch;
getflag = 1;
}
rt_err_t usbvcom_configure(struct rt_serial_device serial, struct serial_configure cfg)
{
}
rt_err_t usbvcom_control(struct rt_serial_device serial, int cmd, void arg)
{
}
extern rt_device_t vcom_dev;
int usbvcom_init_flag=0;
int usbvcom_putc(struct rt_serial_device *serial, char c)
{
if(usbvcom_init_flag)
{
rt_device_write(vcom_dev, 0, &c, 1);
}
return 1;
}
int usbvcom_getc(struct rt_serial_device *serial)
{
if(getflag)
{
getflag = 0;
return bendich;
}
else
{
return -1;
}
}
void usbvcom_uart_isr(void)
{
}
//////////////////////////////////////////////////////
/ 接收数据回调函数 /
static rt_err_t uart_input(rt_device_t dev, rt_size_t size)
{
/ 串口接收到数据后产生中断,调用此回调函数,然后发送接收信号量 /
rt_sem_release(&rx_sem);
}
static void serial_thread_entry(void *parameter)
{
char ch;
// rt_device_write(vcom_dev, 0, &ch, 1);
}
}
问 FINSH能用USB的CDC类吗?