//----------------------------------------------------------------------------- #include "usart.h" #include "num_conversion.h" #include //----------------------------------------------------------------------------- #ifdef USART_USE_TX_IRQ #endif U08 usart_tx_buffer[USART_TX_BUFFER_SIZE]; U08 usart_tx_buffer_index = 0; bool usart_tx_buffer_overflow = false; // true if usart_tx_buffer was full. #ifdef USART_USE_RX_IRQ U08 usart_rx_buffer[USART_RX_BUFFER_SIZE]; //U08 *usart_rx_buffer_ptr = &usart_rx_buffer[0]; U08 usart_received_chars; volatile BOOL usart_rx_ready = false; static U08 usart_rx_buffer_index = 0; static U08 usart_receive_char; static BOOL usart_receive_suspended = false; #endif //----------------------------------------------------------------------------- void usart_init(void) { USART_SET_BAUDRATE(USART_BAUDRATE); UCSRA = 0x00; UCSRB = 0x00; // Disable receiver and transmitter and interrupts #ifdef USART_USE_RX UCSRB |= (1 << RXEN); // Turn on receiver DDRD &= ~(1<= 'a' && usart_receive_char <= 'z') { usart_receive_char -= 32; } #endif if (usart_rx_buffer_index < USART_RX_BUFFER_SIZE - 1) // Store character { usart_rx_buffer[usart_rx_buffer_index++] = usart_receive_char; //usart_writeln_str(usart_rx_buffer); } //usart_write_char(usart_rx_buffer[usart_rx_buffer_index]); //usart_writeln_str(usart_rx_buffer); //usart_write_char(usart_rx_buffer[1,2]); //usart_write_char(usart_rx_buffer[usart_rx_buffer_index]); //usart_writeln_flash_str(*usart_rx_buffer); //usart_write_char(usart_rx_buffer); } #endif #ifdef USART_USE_TX_IRQ ISR(TRALA_vect) { // if it is necessary to write something via USART ... then send // if not ... disable this interrupt. if (usart_write_start_index < usart_write_stop_index) // some bytes in the usart_tx_buffer should be send away. { UDR = usart_tx_buffer[usart_write_start_index%USART_TX_BUFFER_SIZE]; } else { // disable this interrupt source UCSRB &= ~(1<