/* MIPS I system
* Copyright 2011-2012 Stefan Schuermans <stefan@blinkenarea.org>
* Copyleft GNU public license V2 or later
* http://www.gnu.org/copyleft/gpl.html
*/
#include "debug.h"
#include "format.h"
#include "macros.h"
#include "uart.h"
/**
* @brief print a character to debug output
* @param[in] chr character to print
*/
void debug_chr(char chr)
{
uart_tx((unsigned char)chr);
}
/**
* @brief print a string to debug output
* @param[in] str string to print
*/
void debug_str(const char *str)
{
while (*str)
debug_chr(*str++);
}
/**
* @brief print an unsigned integer in decimal to debug output
* @param[in] uint unsigned integer value
* @param[in] cnt number of digits
*/
void debug_uint_dec(unsigned int uint, unsigned int cnt)
{
char buf[11];
if (cnt > count(buf) - 1)
cnt = count(buf) - 1;
format_uint2dec(uint, cnt, buf);
buf[cnt] = 0;
debug_str(buf);
}
/**
* @brief print an unsigned integer in hexdecimal to debug output
* @param[in] uint unsigned integer value
* @param[in] cnt number of digits
*/
void debug_uint_hex(unsigned int uint, unsigned int cnt)