X-Git-Url: https://git.cryptolib.org/?a=blobdiff_plain;f=test_src%2Fuart.c;h=56b22dd7fd29c65009bb36a923115767cc3588c9;hb=7f4bda01ca923c4a9aca6da3370a7c4793426a5c;hp=e35106cf816ae683822a74712dcee12d654ca973;hpb=2159c273c9d3361571a6ff1ab63d9bc76582fbab;p=avr-crypto-lib.git diff --git a/test_src/uart.c b/test_src/uart.c index e35106c..56b22dd 100644 --- a/test_src/uart.c +++ b/test_src/uart.c @@ -1,6 +1,6 @@ /* uart.c */ /* - This file is part of the Crypto-avr-lib/microcrypt-lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify @@ -23,7 +23,7 @@ #include #include #include - +#include "hexdigit_tab.h" #include "uart.h" #ifdef ATMEGA128 @@ -33,6 +33,9 @@ #define UBRRH UBRR0H #define UBRRL UBRR0L #define URSEL UMSEL +#define USART_UDRE_vect USART0_UDRE_vect +#define USART_RXC_vect USART0_RX_vect +#define UCSRA UCSR0A #endif #ifdef ATMEGA644 @@ -55,8 +58,32 @@ #define RXC RXC0 #endif +#ifdef AT90USB162 +#define UCSRB UCSR1B +#define UCSRC UCSR1C +#define UDR UDR1 +#define UBRRH UBRR1H +#define UBRRL UBRR1L +#define URSEL UMSEL10 +#define USART_UDRE_vect USART1_UDRE_vect +#define USART_RXC_vect USART1_RX_vect +#define UDRIE UDRIE1 +#define TXEN TXEN1 +#define UMSEL UMSEL1 +#define RXEN RXEN1 +#define RXCIE RXCIE1 +#define UCSZ0 UCSZ10 +#define UCSRA UCSR1A +#define UDRE UDRE1 +#define RXC RXC1 +#endif + + #ifdef UART_XON_XOFF +#define XON 0x11 +#define XOFF 0x13 + #ifdef UART_INTERRUPT void uart_insertc(char c); #else @@ -255,11 +282,9 @@ void uart_putstr_P(PGM_P str) { void uart_hexdump(const void* buf, int len) { - unsigned char table[]={'0','1','2','3','4','5','6','7', - '8','9','a','b','c','d','e','f'}; while(len--){ - uart_putc(table[((*((char*)buf))>>4)&0xf]); - uart_putc(table[(*((char*)buf))&0xf]); + uart_putc(pgm_read_byte(hexdigit_tab_P + ((*((uint8_t*)buf))>>4))); + uart_putc(pgm_read_byte(hexdigit_tab_P + ((*((uint8_t*)buf))&0xf))); uart_putc(' '); buf=(uint8_t*)buf+1; }