diff options
| author | WangHuachen <[email protected]> | 2020-11-08 19:30:50 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-11-08 19:30:50 +0800 |
| commit | 9756c77f0447f9ce4f00a37600298a1f1fd90cda (patch) | |
| tree | 093247a1719c087dba33783be3a4ee44c1026b2d /components/drivers/serial | |
| parent | 9545529b33cbaae137f1e389dd0e3a5233d516da (diff) | |
| parent | 4b2b9a87c6f0a87b125e5c5a18bcfcf663de9fbb (diff) | |
Merge pull request #1 from RT-Thread/master
同步原有仓库
Diffstat (limited to 'components/drivers/serial')
| -rw-r--r-- | components/drivers/serial/serial.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/components/drivers/serial/serial.c b/components/drivers/serial/serial.c index c442b052b1..2511f18102 100644 --- a/components/drivers/serial/serial.c +++ b/components/drivers/serial/serial.c @@ -22,6 +22,8 @@ * 2017-11-15 JasonJia fix poll rx issue when data is full. * add TCFLSH and FIONREAD support. * 2018-12-08 Ernest Chen add DMA choice + * 2020-09-14 WillianChan add a line feed to the carriage return character + * when using interrupt tx */ #include <rthw.h> @@ -315,6 +317,19 @@ rt_inline int _serial_int_tx(struct rt_serial_device *serial, const rt_uint8_t * while (length) { + /* + * to be polite with serial console add a line feed + * to the carriage return character + */ + if (*data == '\n' && (serial->parent.open_flag & RT_DEVICE_FLAG_STREAM)) + { + if (serial->ops->putc(serial, '\r') == -1) + { + rt_completion_wait(&(tx->completion), RT_WAITING_FOREVER); + continue; + } + } + if (serial->ops->putc(serial, *(char*)data) == -1) { rt_completion_wait(&(tx->completion), RT_WAITING_FOREVER); |
