初级会员
- 积分
- 189
- 金钱
- 189
- 注册时间
- 2019-6-28
- 在线时间
- 27 小时
|
1金钱
int main(void)
{
dev0 = rt_device_find("uart2");
config.baud_rate = BAUD_RATE_115200; //?????? 9600
config.data_bits = DATA_BITS_8; //??? 8
config.stop_bits = STOP_BITS_1; //??? 1
config.bufsz = 12; //????? buff size ? 128
config.parity = PARITY_NONE; //??????
rt_device_control(dev0, RT_DEVICE_CTRL_CONFIG, &config);
err_flag = rt_device_open(dev0,RT_DEVICE_FLAG_INT_RX);
if(err_flag == RT_EOK)
{
rt_kprintf("open uart2 seccsse\r\n");
}
rt_device_set_rx_indicate(dev0,usart_input);
}
static rt_err_t usart_input(rt_device_t dev,rt_size_t size)
{
rt_uint8_t ch;
rt_device_read(dev0,-1,&ch, 1);
rt_device_write(dev0,0,&ch,sizeof(ch));
return 0;
}
代码是按照文档写的,请问还需要更改什么配置吗??
|
|