From dafb7ee059b90450d3dfe7a4186ae34527f4256e Mon Sep 17 00:00:00 2001 From: BlackMark Date: Sat, 3 Aug 2019 16:53:29 +0200 Subject: [PATCH] Added test for stream operator overloading --- uart/main.cpp | 42 +++++++++++++++++- uart/uart | 2 +- uart/uart.cppproj | 109 +++++++++++++++++++++++----------------------- 3 files changed, 96 insertions(+), 57 deletions(-) diff --git a/uart/main.cpp b/uart/main.cpp index f932ace..10ab81d 100644 --- a/uart/main.cpp +++ b/uart/main.cpp @@ -54,6 +54,45 @@ void newUartUsage2() _delay_ms(1000); } +void newUartStreamOverloads() +{ + using namespace uart; + Uart1<> serial; + serial.init(); + sei(); + + bool bVal = true; + char chVal = 'c'; + signed char schVal = 's'; + unsigned char uchVal = 'u'; + short shVal = -12345; + unsigned short ushVal = 64123; + int iVal = -14321; + unsigned int uiVal = 32146; + long lVal = -571474496; + unsigned long ulVal = 2718958144; + long long llVal = -45197516864960; + unsigned long long ullVal = 4611685969606738496; + + serial << F("Stream overload test:") << F("\r\n"); + + serial << F("bool : ") << bVal << F("\r\n"); + serial << F("char : ") << chVal << F("\r\n"); + serial << F("signed char : ") << schVal << F("\r\n"); + serial << F("unsigned char : ") << uchVal << F("\r\n"); + serial << F("short : ") << shVal << F("\r\n"); + serial << F("unsigned short : ") << ushVal << F("\r\n"); + serial << F("int : ") << iVal << F("\r\n"); + serial << F("unsigned int : ") << uiVal << F("\r\n"); + serial << F("long : ") << lVal << F("\r\n"); + serial << F("unsigned long : ") << ulVal << F("\r\n"); + serial << F("long long : ") << llVal << F("\r\n"); + serial << F("unsigned long long : ") << ullVal << F("\r\n"); + serial << F("const void : ") << &bVal << F("\r\n"); + + _delay_ms(1000); +} + /* namespace spi { @@ -174,7 +213,8 @@ void optimalUartTest() int main() { - newUartUsage(); + // newUartUsage(); + newUartStreamOverloads(); // optimalUartTest(); // spiTest(); diff --git a/uart/uart b/uart/uart index fe9e670..8d07e2d 160000 --- a/uart/uart +++ b/uart/uart @@ -1 +1 @@ -Subproject commit fe9e67036e4acfb539499d0fa31afbc9ef99315d +Subproject commit 8d07e2d4db6f0fafebb00db7993b43b49aee30fc diff --git a/uart/uart.cppproj b/uart/uart.cppproj index 7a89214..099b2b9 100644 --- a/uart/uart.cppproj +++ b/uart/uart.cppproj @@ -144,61 +144,60 @@ - -mmcu=atmega1284p -B "%24(PackRepoDir)\Atmel\ATmega_DFP\1.3.300\gcc\dev\atmega1284p" - True - True - True - True - True - False - True - True - - - %24(PackRepoDir)\Atmel\ATmega_DFP\1.3.300\include - - - True - True - True - True - True - - - %24(PackRepoDir)\Atmel\ATmega_DFP\1.3.300\include - - - True - True - True - True - -Wextra -std=c++17 - - - libm - - - - - %24(PackRepoDir)\Atmel\ATmega_DFP\1.3.300\include - - - - - DEBUG - - - Optimize (-O1) - Default (-g2) - - - DEBUG - - - Optimize (-O1) - Default (-g2) - Default (-Wa,-g) - + -mmcu=atmega1284p -B "%24(PackRepoDir)\Atmel\ATmega_DFP\1.3.300\gcc\dev\atmega1284p" + True + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\Atmel\ATmega_DFP\1.3.300\include + + + Optimize (-O1) + True + True + Default (-g2) + True + True + True + + + DEBUG + + + + + %24(PackRepoDir)\Atmel\ATmega_DFP\1.3.300\include + + + True + True + Maximum (-g3) + True + True + -Wextra -std=c++17 + + + libm + + + + + %24(PackRepoDir)\Atmel\ATmega_DFP\1.3.300\include + + + Default (-Wa,-g) +