123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- #include <stddef.h>
- #include <stdint.h>
- #include <string.h>
- #include <stdio.h>
- #include <stdarg.h>
- #include "fw.h"
- #include "console.h"
- #include "io.h"
- static __always_inline void __con_putc(char c)
- {
- /*
- * Wait for FIFO space IF DTR is asserted (otherwise there might
- * not be anyone listening...
- */
- while (CON_FLOW_CTL &&
- (CON_STATUS & (TTY_STATUS_TX_HIGH|TTY_STATUS_DTR_IN))
- == (TTY_STATUS_TX_HIGH|TTY_STATUS_DTR_IN))
- pause();
- if (c == '\n')
- CON_DATA = '\r';
- CON_DATA = c;
- }
- void __hot con_putc(char c)
- {
- __con_putc(c);
- }
- void __hot con_puts(const char *str)
- {
- while (*str)
- __con_putc(*str++);
- }
- void con_vprintf(const char *fmt, va_list ap)
- {
- char buf[128]; /* Maximum text size */
- unsigned int len;
- const char *p;
- vsnprintf(buf, sizeof buf, fmt, ap);
- con_puts(buf);
- }
- void con_printf(const char *fmt, ...)
- {
- va_list ap;
- va_start(ap, fmt);
- con_vprintf(fmt, ap);
- va_end(ap);
- }
|