解决控制台无法输入bug
rt_uint16_t old_flag = _console_device->open_flag; _console_device->open_flag |= RT_DEVICE_FLAG_STREAM; rt_device_write(_console_device, 0, str, rt_strlen(str)); _console_device->open_flag = old_flag; 当一个线程正在执行 rt_device_write(_console_device, 0, str, rt_strlen(str));函数时,一个高优先级线程 抢占当前线程并修改 _console_device->open_flag(修改为RT_DEVICE_FLAG_INT_RX,之前不是中断接收), 高优先级线程执行完后,继续执行以前线程,此时old_flag与_console_device->open_flag不一致,执行 _console_device->open_flag = old_flag;后_console_device->open_flag新的值被覆盖。控制台串口实际配置 成硬件中断接收,因为_console_device->open_flag值被修改为不是中断,最后导致控制台串口无法接收任何数据 输入。
Showing
想要评论请 注册 或 登录