MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / _serial_int_tx

Function _serial_int_tx

components/drivers/serial/dev_serial.c:361–396  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

359}
360
361rt_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
398static void _serial_check_buffer_size(void)
399{

Callers 1

rt_serial_writeFunction · 0.85

Calls 1

rt_completion_waitFunction · 0.85

Tested by

no test coverage detected