X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=firmware%2Flib%2Fatmega168.c;h=d8705ba40735dbd56fc15ae13b3a62608d6af40d;hp=36795faf1c9177d5e0644d6928f7103dd3e4c0ae;hb=f244df1b2d3010548ed2cceabdde44f36089a29a;hpb=21ff17d2af1e50542d9343d7177269a8910ebbe3 diff --git a/firmware/lib/atmega168.c b/firmware/lib/atmega168.c index 36795fa..d8705ba 100644 --- a/firmware/lib/atmega168.c +++ b/firmware/lib/atmega168.c @@ -2,9 +2,13 @@ #include "platform.h" +#include +#include + //! Receive a byte. unsigned char serial0_rx(){ - return 0; + while( !(UCSR0A & (1 << RXC0)) ); + return UDR0; } //! Receive a byte. @@ -14,6 +18,8 @@ unsigned char serial1_rx(){ //! Transmit a byte. void serial0_tx(unsigned char x){ + while (!(UCSR0A & (1< + UBRR0H = UBRRH_VALUE; + UBRR0L = UBRRL_VALUE; + + UCSR0C = _BV(UCSZ01) | _BV(UCSZ00); + UCSR0B = _BV(RXEN0) | _BV(TXEN0); + return; + } //! Set the baud rate of the second uart. @@ -68,22 +88,15 @@ void setbaud1(unsigned char rate){ } -void msp430_init_uart0(){ +void avr_init_uart0(){ + PORTD = _BV(PD2); + setbaud0(0); + _delay_ms(500); //takes a bit to stabilize } -void msp430_init_uart1(){ +void avr_init_uart1(){ } -//! Initialization is correct. -void msp430_init_dco_done(){ - //Nothing to do for the 1612. -} - - -void msp430_init_dco() { - -} -