소스 검색

[DeviceDrivers] uart configure issue.

uart configure shall not been performed if uart is not open.
Bernard Xiong 9 년 전
부모
커밋
99481cd0ac
1개의 변경된 파일12개의 추가작업 그리고 2개의 파일을 삭제
  1. 12 2
      components/drivers/serial/serial.c

+ 12 - 2
components/drivers/serial/serial.c

@@ -603,8 +603,18 @@ static rt_err_t rt_serial_control(struct rt_device *dev,
             break;
             break;
 
 
         case RT_DEVICE_CTRL_CONFIG:
         case RT_DEVICE_CTRL_CONFIG:
-            /* configure device */
-            serial->ops->configure(serial, (struct serial_configure *)args);
+			if (args)
+			{
+				/* set serial configure */
+				serial->config = *(struct serial_configure *)args;
+
+				if (dev->ref_count)
+				{
+		            /* serial device has been opened, to configure it */
+		            serial->ops->configure(serial, (struct serial_configure *)args);
+				}
+			}
+			
             break;
             break;
 
 
         default :
         default :