diff --git a/lib/uart.c b/lib/uart.c
deleted file mode 100644
index 9092abf..0000000
--- a/lib/uart.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/* 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 3 of the License, or
- * (at your option) any later version.
- *
- * 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, see .
- *
- */
-/* This library handles the USART configuration */
-
-#include // Standard Integer Types
-#include // Standard IO facilities
-#include // General utilities
-#include // AVR device-specific IO definitions
-
-#include "uart.h" // UART header
-#include // Helper macros for baud rate calculations
-
-/* assign input and output streams */
-FILE uart_output = FDEV_SETUP_STREAM((int (*)(char, struct __file *)) uart_putchar, NULL, _FDEV_SETUP_WRITE);
-FILE uart_input = FDEV_SETUP_STREAM(NULL, (int (*)(struct __file *)) uart_getchar, _FDEV_SETUP_READ);
-FILE uart_io = FDEV_SETUP_STREAM((int (*)(char, struct __file *)) uart_putchar, (int (*)(struct __file *)) uart_getchar, _FDEV_SETUP_RW);
-
-/* configure serial port */
-void uart_init(void)
-{
- UBRR0H = UBRRH_VALUE; // set baurate (calculated from BAUD)
- UBRR0L = UBRRL_VALUE; // set baurate (calculated from BAUD)
-#if USE_2X
- UCSR0A |= (1<.
- *
- */
-/* This library handles the USART configuration */
-
-/* set tolerance to 3% to allow 115200 baudrate with 16 MHz clock, else use 9600 for default <2% */
-#define BAUD_TOL 3
-/* serial baudrate, in bits per second (with 8N1 8 bits, no parity bit, 1 stop bit settings) */
-#define BAUD 115200
-
-/* input & output streams */
-FILE uart_output;
-FILE uart_input;
-FILE uart_io;
-
-/* configure serial port */
-void uart_init(void);
-/* put character on UART stream (blocking) */
-void uart_putchar(char c, FILE *stream);
-/* get character from UART stream (blocking) */
-char uart_getchar(FILE *stream);
-
diff --git a/main.c b/main.c
index 0e54b4d..e86bc63 100644
--- a/main.c
+++ b/main.c
@@ -26,7 +26,7 @@
#include // Program Space Utilities
#include // Power Management and Sleep Modes
-#include "uart.h" // basic UART functions
+#include "usart.h" // basic USART functions
#include "main.h" // main definitions
/* help strings */
@@ -46,11 +46,11 @@ PGM_P const help_table[] PROGMEM = {
};
/* global variables */
-char uart_in[32] = {0}; // user input from USART
-volatile uint8_t uart_in_i = 0; // how many UART characters have been input
+char usart_in[32] = {0}; // user input from USART
+volatile uint8_t usart_in_i = 0; // how many USART characters have been input
/* flags, set in the interrupts and handled in the main program */
-volatile bool uart_flag = false; // UART input data is available
+volatile bool usart_flag = false; // USART input data is available
/* switch off LED */
void led_off(void)
@@ -162,16 +162,6 @@ void help(void)
}
}
-/* save the UART input into a string */
-ISR(USART_RX_vect) { /* UART receive interrupt */
- uart_in[uart_in_i] = getchar(); // save input
- if (uart_in_i1) { // ignore empty lines
+ usart_in[usart_in_i-1] = 0; // remove end of line
+ if (usart_in_i>1) { // ignore empty lines
command_action(); // process command
}
- uart_out_i = 0; // reset output
- uart_in_i = 0; // reset input
+ usart_out_i = 0; // reset output
+ usart_in_i = 0; // reset input
}
}
/* go to sleep and wait for next interrupt */