static void usart_slave_operation_thread_entry(void *parameter)
{
static rt_device_t serial; //´®¿ÚÉ豸¾ä±ú
struct serial_configure config=RT_SERIAL_CONFIG_DEFAULT;//ÏÈÉèÖÃΪĬÈϲÎÊý
struct serial_configure *config_p=&config;
serial = rt_device_find(WIRELESS_UART_NAME);//²éÕÒ´®¿ÚÉ豸
if (!serial)
rt_kprintf("find %s failed!", WIRELESS_UART_NAME);
}
result=rt_device_open(serial, RT_DEVICE_FLAG_INT_TX);//就这里串口打开失败,只要是发送的设置就打开失败,如RT_DEVICE_FLAG_INT_TX、RT_DEVICE_FLAG_DMA_TX
if(result!=RT_EOK)
rt_kprintf("open %s failed!", WIRELESS_UART_NAME);
//ÅäÖô®¿Ú²ÎÊý
config_p->baud_rate=BAUD_RATE_57600;
result= rt_device_control(serial, RT_DEVICE_CTRL_CONFIG, config_p);
rt_kprintf("config %s failed!", WIRELESS_UART_NAME);
rt_device_set_rx_indicate(serial, uart_slave_input);//ÉèÖýÓÊջص÷º¯Êý
rt_device_write( serial,0,&(rx_array_temp[0]),2 );
while(1)
rt_thread_mdelay(20);
int usart_slave_operation(void)
tid1 = rt_thread_create("usart_slave",
usart_slave_operation_thread_entry, RT_NULL,
USART_SLAVE_OPERATION_THREAD_STACK_SIZE,
USART_SLAVE_OPERATION_THREAD_PRIORITY,
USART_SLAVE_OPERATION_THREAD_TIMESLICE);
if (tid1 != RT_NULL)
rt_thread_startup(tid1);
return 0;
查看更多
回到 顶部
发布 问题
分享 好友
手机 浏览
投诉 建议
回到 底部