1 //! MSP430F1612/1611 clock and I/O definitions
6 #include <util/delay.h>
9 unsigned char serial0_rx(){
10 while( !(UCSR0A & (1 << RXC0)) );
15 unsigned char serial1_rx(){
20 void serial0_tx(unsigned char x){
21 while (!(UCSR0A & (1<<UDRE0)) );
25 //! Transmit a byte on the second UART.
26 void serial1_tx(unsigned char x){
29 //! Set the baud rate.
30 void setbaud0(unsigned char rate){
31 /* disable everything briefly */
55 /* enabling rx/tx must be done before frame/baud setup */
56 UCSR0B = ((1 << TXEN0) | (1 << RXEN0));
58 UCSR0A = (1 << U2X0); /* double the baud rate */
59 UCSR0C = (3 << UCSZ00); /* 8N1 */
61 UBRR0L = (int8_t) (F_CPU/(r*8L)-1);
62 UBRR0H = (F_CPU/(r*8L)-1) >> 8;
68 //! Set the baud rate of the second uart.
69 void setbaud1(unsigned char rate){
70 //http://mspgcc.sourceforge.net/baudrate.html
92 void avr_init_uart0(){
95 _delay_ms(500); //takes a bit to stabilize
99 void avr_init_uart1(){