/* * File: uart.hpp * Author: naopross * * Created on May 2, 2018, 7:04 PM * * Note: Non working or untested features are commented out with #if 0 .. #endif */ #ifndef UART_HPP #define UART_HPP #include #include #include extern "C" { void usart_1_isr(); void usart_2_isr(); void usart_3_isr(); void usart_4_isr(); } namespace uart { const unsigned devices_count = 4; #if 0 enum class status : unsigned int { rx_data_available = 1<<0, rx_overrun_error = 1<<1, framing_error = 1<<2, parity_error = 1<<3, receiver_ide = 1<<4, tx_complete = 1<<8, tx_full = 1<<9, }; enum class transfer_status : unsigned int { rx_full = 1<<0, rx_data_present = 1<<1, rx_empty = 1<<2, tx_full = 1<<3, tx_empty = 1<<4, }; #endif bool _echo[devices_count]; std::queue _rx_buffer[devices_count]; std::queue _tx_buffer[devices_count]; // the following commented functions have been inlined // template // std::queue& rx_buffer(); // template // std::queue& tx_buffer(); template void initialize(); #if 0 template void set_baudrate(long baud); #endif // the following commented functions have been inlined // template // void echo(bool enabled); // template // bool echo_enabled(); template uint8_t read(); template uint8_t read_wait(); #if 0 template std::string read(const unsigned len); template std::string readline(const std::string &eol = "\n\r"); template unsigned read(uint8_t *buffer, const unsigned numbytes); #endif template void write(const uint8_t byte); template void write(const std::string &str); template unsigned write(const uint8_t *buffer, const unsigned numbytes); template void print(const std::string &str); #if 0 template status status(); template transfer_status tranfer_status(); #endif } #endif /* UART_HPP */