From 5ac4c1769e9976b39e919bb5f5ac9e97f62e7d0f Mon Sep 17 00:00:00 2001 From: travisutk Date: Sun, 17 Apr 2011 21:58:59 +0000 Subject: [PATCH 1/1] AVR UARTs; not quite ready. git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@997 12e2690d-a6be-4b82-a7b7-67c4a43b65c8 --- firmware/include/msp430.h | 1 + firmware/lib/arduino.c | 8 +++++--- firmware/lib/atmega168.c | 28 ++++++++++++++++++++++++---- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/firmware/include/msp430.h b/firmware/include/msp430.h index 746ae51..d8d7c4d 100644 --- a/firmware/include/msp430.h +++ b/firmware/include/msp430.h @@ -1,3 +1,4 @@ + void msp430_init(); diff --git a/firmware/lib/arduino.c b/firmware/lib/arduino.c index 870f46e..503492c 100644 --- a/firmware/lib/arduino.c +++ b/firmware/lib/arduino.c @@ -12,19 +12,21 @@ void arduino_init(){ /* set PORTB for output*/ DDRB = 0xFF; - + + /* while (1) { - /* set PORTB.6 high */ + //LED on PORTB = 0x20; _delay_ms(1000); - /* set PORTB.6 low */ + //LED off PORTB = 0x00; _delay_ms(1000); } +*/ } #endif diff --git a/firmware/lib/atmega168.c b/firmware/lib/atmega168.c index 36795fa..1ed8840 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<> 8); + UBRR0L = (unsigned char) bittimer; + + + /* set the framing to 8N1 */ + UCSR0C = (3 << UCSZ00); + /* Engage! */ + UCSR0B = (1 << RXEN0) | (1 << TXEN0); + return; + } //! Set the baud rate of the second uart. @@ -79,11 +99,11 @@ void msp430_init_uart1(){ //! Initialization is correct. void msp430_init_dco_done(){ - //Nothing to do for the 1612. + //Nothing to do for the AVR w/ xtal. } void msp430_init_dco() { - + // } -- 2.20.1