#include #include #include #include #ifndef F_CPU #define F_CPU 16000000L #include #endif #define UART_UBRR_CALC(BAUD_,FREQ_) ((FREQ_)/((BAUD_)*16L)-1) #define UART_BAUD_RATE 115200 #define UART_BUFFER 64 #define FREQUENCY 20000L ///////////////////////////////////////////////////////////////////////////////// uint8_t uart_buffer[UART_BUFFER]; int8_t uart_count = 0; uint16_t volatile phase0 =0; ///////////////////////////////////////////////////////////////////////////////// //Interrupts ISR(SIG_INPUT_CAPTURE1) { //timer capture phase0 = TCNT1; } ISR(SIG_UART_RECV) { /* INTERRUPT: receive char from UART and save it the buffer */ if (uart_count < UART_BUFFER) uart_buffer[uart_count++] = UDR; } // ///////////////////////////////////////////////////////////////////////////////// //Methodes inline void uart_init(uint8_t tx, uint8_t rx) { uint16_t baudrate; baudrate = UART_BAUD_RATE/2; UBRRH = (uint8_t) (UART_UBRR_CALC(baudrate,F_CPU)>>8); UBRRL = (uint8_t) UART_UBRR_CALC(baudrate,F_CPU); UCSRA |= (1<