From 9b4b0cac673d04a34187b4a655fff451e007520c Mon Sep 17 00:00:00 2001 From: BlackMark Date: Sat, 3 Aug 2019 16:26:32 +0200 Subject: [PATCH] Adapted to new interface --- uart/main.cpp | 45 +++------------- uart/uart | 2 +- uart/uart.cppproj | 130 +++++++++++++++++++++++----------------------- 3 files changed, 73 insertions(+), 104 deletions(-) diff --git a/uart/main.cpp b/uart/main.cpp index cc2f359..f932ace 100644 --- a/uart/main.cpp +++ b/uart/main.cpp @@ -6,14 +6,13 @@ #include "flash/flash.hpp" #include "io/io.hpp" -#include "uart/uart.h" #include "uart/uart.hpp" -#include "uart/usart.h" void newUartUsage() { using namespace uart; Uart, Driven::INTERRUPT>> serial1; + serial1.init(); sei(); serial1 << F("Hello World from RAM. ") << F("Hello World from flash\r\n"); @@ -21,7 +20,7 @@ void newUartUsage() while (true) { uint8_t received = 0; - while (!serial1.peek(received)) + while (!serial1.peek()) ; { @@ -46,27 +45,15 @@ void newUartUsage2() using config = Config<9600, DataBits::EIGHT, Parity::NONE, StopBits::ONE>; using uart0 = Hardware0; - using softuart = Software; Uart serial; - Uart softSerial; + serial.init(); serial << "Hello World from RAM. " << F("Hello World from flash\r\n"); - // softSerial << "Hello World using finalized software interface!" << F("\r\nAlso greetz from progmem\r\n"); _delay_ms(1000); } -void oldUsartUsage() -{ - USART0 &serial = USART0::inst(); - serial.init(9600); - - serial << "Hello World from RAM. " - << "Hello World from flash\r\n"; - - _delay_ms(1000); -} /* namespace spi { @@ -145,17 +132,17 @@ void spiTest() */ static inline void initUart(const uint32_t baudRate) { - UBRR0 = static_cast((F_CPU / (16 * baudRate)) - 1); - UCSR0C = (1 << UCSZ01) | (1 << UCSZ00); - UCSR0B = (1 << RXEN0) | (1 << TXEN0); + UBRR1 = static_cast((F_CPU / (16 * baudRate)) - 1); + UCSR1C = (1 << UCSZ11) | (1 << UCSZ10); + UCSR1B = (1 << RXEN1) | (1 << TXEN1); } static inline void txUart(uint8_t byte) { - while (!(UCSR0A & (1 << UDRE0))) + while (!(UCSR1A & (1 << UDRE1))) ; - UDR0 = byte; + UDR1 = byte; } static inline void txString(const char *str) @@ -185,26 +172,10 @@ void optimalUartTest() _delay_ms(1000); } -void cUartLibTest() -{ - auto ramString = "Hello World from RAM. "; - auto flashString = F("Hello World from flash\r\n"); - - uart1_init(UART_BAUD_SELECT(9600, F_CPU)); - sei(); - - uart1_puts(ramString); - uart1_puts_p(reinterpret_cast(flashString)); - - _delay_ms(1000); -} - int main() { newUartUsage(); - // oldUsartUsage(); // optimalUartTest(); - // cUartLibTest(); // spiTest(); diff --git a/uart/uart b/uart/uart index 925bb56..fe9e670 160000 --- a/uart/uart +++ b/uart/uart @@ -1 +1 @@ -Subproject commit 925bb56f9895ff46a81209fe5f0f6b59f6c809f9 +Subproject commit fe9e67036e4acfb539499d0fa31afbc9ef99315d diff --git a/uart/uart.cppproj b/uart/uart.cppproj index fb99325..7a89214 100644 --- a/uart/uart.cppproj +++ b/uart/uart.cppproj @@ -42,8 +42,8 @@ 070000004699 JTAGICE mkII - ISP - 125000 + JTAG + 5000000 @@ -75,8 +75,9 @@ 125000 + 5000000 - ISP + JTAG com.atmel.avrdbg.tool.atmelice J41800099437 @@ -86,58 +87,58 @@ - -mmcu=atmega1284p -B "%24(PackRepoDir)\Atmel\ATmega_DFP\1.3.300\gcc\dev\atmega1284p" - True - True - True - True - True - False - True - True - - - NDEBUG - - - - - %24(PackRepoDir)\Atmel\ATmega_DFP\1.3.300\include - - - Optimize for size (-Os) - True - True - True - True - True - - - NDEBUG - - - - - %24(PackRepoDir)\Atmel\ATmega_DFP\1.3.300\include - - - Optimize for size (-Os) - True - True - True - True - -Wextra -std=c++17 - - - libm - - - - - %24(PackRepoDir)\Atmel\ATmega_DFP\1.3.300\include - - - + -mmcu=atmega1284p -B "%24(PackRepoDir)\Atmel\ATmega_DFP\1.3.300\gcc\dev\atmega1284p" + True + True + True + True + True + False + True + True + + + NDEBUG + + + + + %24(PackRepoDir)\Atmel\ATmega_DFP\1.3.300\include + + + Optimize for size (-Os) + True + True + True + True + True + + + NDEBUG + + + + + %24(PackRepoDir)\Atmel\ATmega_DFP\1.3.300\include + + + Optimize for size (-Os) + True + True + True + True + -Wextra -std=c++17 + + + libm + + + + + %24(PackRepoDir)\Atmel\ATmega_DFP\1.3.300\include + + + @@ -213,34 +214,31 @@ compile - + compile - + compile + + compile + compile - + compile - + compile compile - - compile - - - compile - compile - + compile