| 263 | } |
| 264 | |
| 265 | rt_inline int _serial_poll_tx(struct rt_serial_device *serial, const rt_uint8_t *data, int length) |
| 266 | { |
| 267 | int size; |
| 268 | RT_ASSERT(serial != RT_NULL); |
| 269 | |
| 270 | size = length; |
| 271 | while (length) |
| 272 | { |
| 273 | /* |
| 274 | * to be polite with serial console add a line feed |
| 275 | * to the carriage return character |
| 276 | */ |
| 277 | if (*data == '\n' && (serial->parent.open_flag & RT_DEVICE_FLAG_STREAM)) |
| 278 | { |
| 279 | serial->ops->putc(serial, '\r'); |
| 280 | } |
| 281 | |
| 282 | if(serial->ops->putc(serial, *data) < 0) { |
| 283 | break; |
| 284 | } |
| 285 | |
| 286 | ++ data; |
| 287 | -- length; |
| 288 | } |
| 289 | |
| 290 | return size - length; |
| 291 | } |
| 292 | |
| 293 | /* |
| 294 | * Serial interrupt routines |