#include <stdio.h>
#include <unistd.h>
#include <stdint.h>
+#include <stdlib.h>
#include "avr_uart.h"
#include "sim_hex.h"
p->usec_per_byte, avr_uart_txc_raise, p); // should be uart speed dependent
if (p->flags & AVR_UART_FLAG_STDIO) {
- static char buf[128];
- static int l = 0;
- buf[l++] = v < ' ' ? '.' : v;
- buf[l] = 0;
- if (v == '\n' || l == 127) {
- l = 0;
- printf( FONT_GREEN "%s\n" FONT_DEFAULT, buf);
+ const int maxsize = 256;
+ if (!p->stdio_out)
+ p->stdio_out = malloc(maxsize);
+ p->stdio_out[p->stdio_len++] = v < ' ' ? '.' : v;
+ p->stdio_out[p->stdio_len] = 0;
+ if (v == '\n' || p->stdio_len == maxsize) {
+ p->stdio_len = 0;
+ printf( FONT_GREEN "%s\n" FONT_DEFAULT, p->stdio_out);
}
}
TRACE(printf("UDR%c(%02x) = %02x\n", p->name, addr, v);)
uint32_t flags;
avr_cycle_count_t usec_per_byte;
+
+ uint8_t * stdio_out;
+ int stdio_len; // current size in the stdio output
} avr_uart_t;
/* takes a uint32_t* as parameter */