serial-arm.c: allow sending arbitrarily long messages.
On ARM we use only the 16 byte hardware buffer for sending and
receiving over the serial line, which is often too short for
debugging messages. This implementation works fine and still
neither blocks nor introduces delays for short messages.
Costs 72 bytes binary size, mostly because it's the first usage
of delay_us():
SIZES ARM... lpc1114
FLASH : 1656 bytes 6%
RAM : 136 bytes 4%
EEPROM : 0 bytes 0%
This commit is contained in:
parent
8f90e63e85
commit
fc124c14d4
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include "arduino.h"
|
||||
#include "mbed-LPC11xx.h"
|
||||
#include "delay.h"
|
||||
|
||||
#ifdef XONXOFF
|
||||
#error XON/XOFF protocol not yet implemented for ARM. \
|
||||
|
|
@ -161,9 +162,15 @@ uint8_t serial_popchar(void) {
|
|||
|
||||
/** Send one character.
|
||||
|
||||
If the queue is full, too bad. Do NOT block.
|
||||
If the queue is full, we wait as long as sending a character takes
|
||||
(87 microseconds at 115200 baud) and send then blindly. This way we can
|
||||
send arbitrarily long messages without slowing down short messages or even
|
||||
blocking.
|
||||
*/
|
||||
void serial_writechar(uint8_t data) {
|
||||
if ( ! (LPC_UART->LSR & (0x01 << 5))) // Queue full?
|
||||
delay_us((1000000 / BAUD * 10) + 1);
|
||||
|
||||
LPC_UART->THR = data;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue