123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- #include <stddef.h>
- #include <stdint.h>
- #include <string.h>
- #include <stdio.h>
- #include <stdarg.h>
- #include "console.h"
- #include "io.h"
- void con_set_baudrate(uint32_t b)
- {
- uint32_t bauddiv;
-
- bauddiv = (b * ((1ULL << (32+CON_BAUD_BITS))/CON_BAUD_BASE+1)) >> 32;
-
- CON_BAUDDIV = bauddiv - 1;
- }
- void con_putc(char c)
- {
-
- while (CON_STATUS & (1 << 4))
- pause();
- if (c == '\n')
- CON_DATA = '\r';
- CON_DATA = c;
- }
- void con_puts(const char *str)
- {
- while (*str)
- con_putc(*str++);
- }
- void con_vprintf(const char *fmt, va_list ap)
- {
- char buf[128];
- 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);
- }
|