2015-06-27 20:10:45 -04:00
|
|
|
// This is free and unencumbered software released into the public domain.
|
2015-07-02 04:49:35 -04:00
|
|
|
//
|
2015-06-27 20:10:45 -04:00
|
|
|
// Anyone is free to copy, modify, publish, use, compile, sell, or
|
|
|
|
// distribute this software, either in source code form or as a compiled
|
|
|
|
// binary, for any purpose, commercial or non-commercial, and by any
|
|
|
|
// means.
|
2015-06-26 16:02:22 -04:00
|
|
|
|
|
|
|
#include "firmware.h"
|
|
|
|
|
|
|
|
#define OUTPORT 0x10000000
|
|
|
|
|
|
|
|
void print_chr(char ch)
|
|
|
|
{
|
|
|
|
*((volatile uint32_t*)OUTPORT) = ch;
|
|
|
|
}
|
|
|
|
|
|
|
|
void print_str(const char *p)
|
|
|
|
{
|
|
|
|
while (*p != 0)
|
|
|
|
*((volatile uint32_t*)OUTPORT) = *(p++);
|
|
|
|
}
|
|
|
|
|
2015-07-02 04:46:21 -04:00
|
|
|
void print_dec(unsigned int val)
|
2015-06-26 16:02:22 -04:00
|
|
|
{
|
|
|
|
char buffer[10];
|
|
|
|
char *p = buffer;
|
|
|
|
while (val || p == buffer) {
|
|
|
|
*(p++) = val % 10;
|
|
|
|
val = val / 10;
|
|
|
|
}
|
|
|
|
while (p != buffer) {
|
|
|
|
*((volatile uint32_t*)OUTPORT) = '0' + *(--p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-03 10:33:01 -05:00
|
|
|
void print_hex(unsigned int val, int digits)
|
2015-06-26 16:02:22 -04:00
|
|
|
{
|
2016-02-03 10:33:01 -05:00
|
|
|
for (int i = (4*digits)-4; i >= 0; i -= 4)
|
2015-06-26 16:02:22 -04:00
|
|
|
*((volatile uint32_t*)OUTPORT) = "0123456789ABCDEF"[(val >> i) % 16];
|
|
|
|
}
|
|
|
|
|