/* * doorlock-avr, AVR code of Binary Kitchen's doorlock * * Copyright (c) Binary Kitchen, 2018 * * Authors: * Ralf Ramsauer * * This work is licensed under the terms of the GNU GPL, version 2. See * the COPYING file in the top-level directory. */ #include #include #include #include "uart.h" #define UBRR_VAL ((F_OSC+UART_BAUD*8)/(UART_BAUD*16)-1) #define BAUD_REAL (F_OSC/(16*(UBRR_VAL+1))) #define BAUD_ERROR ((BAUD_REAL*1000)/UART_BAUD) #if ((BAUD_ERROR<985) || (BAUD_ERROR>1010)) #warn BAUD_ERROR #error Choose another crystal. Baud error too high. #endif void uart_init() { // Enable receive and transmit UCSRB = (1<> 8; UBRRL = UBRR_VAL & 0xFF; } void uart_putc(const char c) { while ( !(UCSRA & (1<