STM32F411: serial-stm32.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. Removed while-loop. Looks like we need some more us than the LPC?!? With +7us we do not lose characters anymore.
This commit is contained in:
parent
2a96564228
commit
b9107397b2
|
|
@ -11,7 +11,9 @@
|
|||
*/
|
||||
|
||||
#if defined TEACUP_C_INCLUDE && defined __ARM_STM32F411__
|
||||
|
||||
#include "arduino.h"
|
||||
#include "delay.h"
|
||||
|
||||
#ifdef XONXOFF
|
||||
#error XON/XOFF protocol not yet implemented for ARM. \
|
||||
|
|
@ -83,7 +85,9 @@ void serial_init()
|
|||
Divisor = int((div - int(div))*16)
|
||||
BRR = Mantisse + Divisor
|
||||
*/
|
||||
#if !defined BAUD
|
||||
#define BAUD 115200
|
||||
#endif
|
||||
|
||||
#define SERIAL_APBCLK (__SYSTEM_CLOCK/2)
|
||||
|
||||
|
|
@ -132,7 +136,8 @@ uint8_t serial_txchars(void) {
|
|||
/** Send one character.
|
||||
*/
|
||||
void serial_writechar(uint8_t data) {
|
||||
while (!serial_txchars());
|
||||
if ( !serial_txchars()) // Queue full?
|
||||
delay_us((1000000 / BAUD * 10) + 7);
|
||||
USART2->DR = (uint32_t)(data & 0x1FF);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue