Subversion Repositories Projects

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

/****************************************************************************
 *   Copyright (C) 2011 by Claas Anders "CaScAdE" Rathje                    *
 *   admiralcascade@gmail.com                                               *
 *   Project-URL: http://www.mylifesucks.de/oss/c-epilepsy/                 *
 *                                                                          *
 *   This program is free software; you can redistribute it and/or modify   *
 *   it under the terms of the GNU General Public License as published by   *
 *   the Free Software Foundation; either version 2 of the License.         *
 *                                                                          *
 *   This program is distributed in the hope that it will be useful,        *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
 *   GNU General Public License for more details.                           *
 *                                                                          *
 *   You should have received a copy of the GNU General Public License      *
 *   along with this program; if not, write to the                          *
 *   Free Software Foundation, Inc.,                                        *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.              *
 ****************************************************************************/


#include "usart1.h"

#ifdef __AVR_ATmega644P__

/**
 * init usart1
 */

void usart1_init() {
    UBRR1H = ((F_CPU / (16UL * USART1_BAUD)) - 1) >> 8;
    UBRR1L = (F_CPU / (16UL * USART1_BAUD)) - 1;

    // Enable receiver and transmitter; enable RX interrupt
    UCSR1B = (1 << RXEN1) | (1 << TXEN1) | (1 << RXCIE1);

    // set asynchronous mode
    UCSR1C &= ~(1 << UMSEL11);
    UCSR1C &= ~(1 << UMSEL10);
    // no parity
    UCSR1C &= ~(1 << UPM11);
    UCSR1C &= ~(1 << UPM10);
    // 1 stop bit
    UCSR1C &= ~(1 << USBS1);
    // 8-bit
    UCSR1B &= ~(1 << UCSZ12);
    UCSR1C |= (1 << UCSZ11);
    UCSR1C |= (1 << UCSZ10);

    // set direction of RXD1 and TXD1 pins
    // set RXD1 (PD2) as an input pin
    PORTD &= ~(1 << PORTD2);
    DDRD &= ~(1 << DDD2);
    // set TXD1 (PD3) as an output pin
    //PORTD |= (1 << PORTD3);
    //DDRD &= ~(1 << DDD3);

}

ISR(USART1_TX_vect, ISR_BLOCK) {
}

ISR(USART1_RX_vect, ISR_BLOCK) {
}



#endif // __AVR_ATmega644P__