| 359 | } |
| 360 | |
| 361 | rt_inline int _serial_int_tx(struct rt_serial_device *serial, const rt_uint8_t *data, int length) |
| 362 | { |
| 363 | int size; |
| 364 | struct rt_serial_tx_fifo *tx; |
| 365 | |
| 366 | RT_ASSERT(serial != RT_NULL); |
| 367 | |
| 368 | size = length; |
| 369 | tx = (struct rt_serial_tx_fifo*) serial->serial_tx; |
| 370 | RT_ASSERT(tx != RT_NULL); |
| 371 | |
| 372 | while (length) |
| 373 | { |
| 374 | /* |
| 375 | * to be polite with serial console add a line feed |
| 376 | * to the carriage return character |
| 377 | */ |
| 378 | if (*data == '\n' && (serial->parent.open_flag & RT_DEVICE_FLAG_STREAM)) |
| 379 | { |
| 380 | if (serial->ops->putc(serial, '\r') == -1) |
| 381 | { |
| 382 | rt_completion_wait(&(tx->completion), RT_WAITING_FOREVER); |
| 383 | continue; |
| 384 | } |
| 385 | } |
| 386 | |
| 387 | while (serial->ops->putc(serial, *(char*)data) == -1) |
| 388 | { |
| 389 | rt_completion_wait(&(tx->completion), RT_WAITING_FOREVER); |
| 390 | } |
| 391 | |
| 392 | data ++; length --; |
| 393 | } |
| 394 | |
| 395 | return size - length; |
| 396 | } |
| 397 | |
| 398 | static void _serial_check_buffer_size(void) |
| 399 | { |
no test coverage detected