12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- #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 */
- while (CON_FLOW_CTL && (CON_STATUS & CON_STATUS_TX_HIGH))
- 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);
- }
|