X-Git-Url: https://git.cryptolib.org/?a=blobdiff_plain;f=test_src%2Fdebug.c;fp=test_src%2Fdebug.c;h=3b5fee4c74c71a3b5e873acd21b013841245f491;hb=2159c273c9d3361571a6ff1ab63d9bc76582fbab;hp=0000000000000000000000000000000000000000;hpb=4d76909e4282baf1420ee309e270384246b241b8;p=avr-crypto-lib.git diff --git a/test_src/debug.c b/test_src/debug.c new file mode 100644 index 0000000..3b5fee4 --- /dev/null +++ b/test_src/debug.c @@ -0,0 +1,64 @@ +/* debug.c */ +/* + This file is part of the Crypto-avr-lib/microcrypt-lib. + Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +/*************************** +* +* +* +****************************/ +#include "config.h" + +#if DEBUG == uart + #include "uart.h" +#else + #error "Your DEBUG methode is not suported!" +#endif + +#ifdef DEBUG + void debug_init(void){ + #if DBUG==uart + uart_init(); + #else + #error "Your DEBUG methode is not suported!" + #endif + } + + void debug_char(char c){ + static char initialised = 0; + if (!initialised){ + uart_init(); + initialised=1; + } + uart_putc(c); + } + + void debug_str(char* s){ + while (*s) + debug_char(*s++); + } + + + + void debug_byte(char b){ + char table[] = "0123456789ABCDEF"; + debug_char(table[(b>>4) & 0xf]); + debug_char(table[b&0xf]); + } + +#endif //DEBUG +