diff options
| author | Bernard Xiong <[email protected]> | 2016-06-13 13:31:13 +0800 |
|---|---|---|
| committer | Bernard Xiong <[email protected]> | 2016-06-13 13:31:13 +0800 |
| commit | 99481cd0ac55c52d4023c50175766a18cefa7064 (patch) | |
| tree | 8ba0f96134ec7cc8ed810e4bec703c2dc09e3e32 /components | |
| parent | 45c7f030359df714f0f088a16e87d19bdea99fa0 (diff) | |
[DeviceDrivers] uart configure issue.
uart configure shall not been performed if uart is not open.
Diffstat (limited to 'components')
| -rw-r--r-- | components/drivers/serial/serial.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/components/drivers/serial/serial.c b/components/drivers/serial/serial.c index 7cb1c6b339..a7f1bcfc08 100644 --- a/components/drivers/serial/serial.c +++ b/components/drivers/serial/serial.c @@ -603,8 +603,18 @@ static rt_err_t rt_serial_control(struct rt_device *dev, break; 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; default : |
