/**************************************************************************
Name            - print_hexbyte(unsigned char)
Parameters      - character to be printed 
Responsibility  -Converts an 8 bit unsigned value to two ascii bytes to be
                 printed on a terminal (usually).
                
Notes           - 
                 
Returns         - void
Autor           - wje
                  Based on Atmel application note - AVR313
**************************************************************************/
#include <stdio.h>
#include "gpr.h"
#include "uart_putchar.h"

extern FILE *uart_out;
void print_hexbyte(unsigned char i)
{
    unsigned char h, l;
    
    h = i & 0xF0;               // High nibble
    h = h>>4;
    h = h + '0';
    
    if (h > '9')
        h = h + 7;

    l = (i & 0x0F)+'0';         // Low nibble
    if (l > '9')
        l = l + 7;


    uart_putchar(h, uart_out);
    uart_putchar(l, uart_out);
}


/**************************************************************************
Name            - delay
Parameters      - 8 bit value (char)
Responsibility  - Burns up a little time. 
                
Notes           - This will be replaced with a more capable routine soon
                 
Returns         - nothing
**************************************************************************/
void delay(unsigned long d) {
    unsigned long i,j,k;
    for(i=0; i<d; i++)
        for(j=0; j<40; j++)
            for(k=0; k<176; k++);
}

