#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;
}
+
+ uint16_t bittimer=( F_CPU / SPEED / 16 ) - 1;
+ UBRR0H = (unsigned char) (bittimer >> 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.
//! 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() {
-
+ //
}