#include "platform.h"
+#include <avr/io.h>
+#include <util/delay.h>
+
//! Receive a byte.
unsigned char serial0_rx(){
- return 0;
+ while( !(UCSR0A & (1 << RXC0)) );
+ return UDR0;
}
//! Receive a byte.
//! Transmit a byte.
void serial0_tx(unsigned char x){
+ while (!(UCSR0A & (1<<UDRE0)) );
+ UDR0 = x;
}
//! Transmit a byte on the second UART.
//! Set the baud rate.
void setbaud0(unsigned char rate){
+ //TODO support multiple rates.
+ #define SPEED 9600
+
- //http://mspgcc.sourceforge.net/baudrate.html
switch(rate){
case 1://9600 baud
break;
}
+
+#define F_CPU 8000000L
+ //#define BAUD 115200L
+#define BAUD 9600L
+#include <util/setbaud.h>
+ 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.
}
-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() {
-
-}
-