From 7d4eddbd8b475edd5fa3fe728e445b9306f8bbc9 Mon Sep 17 00:00:00 2001 From: BlackMark Date: Sat, 3 Aug 2019 11:14:01 +0200 Subject: [PATCH] Changed interface to not initialize uart on construction --- uart.hpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/uart.hpp b/uart.hpp index 2d3e2ce..c7cef43 100644 --- a/uart.hpp +++ b/uart.hpp @@ -15,11 +15,10 @@ namespace uart { template class Uart { public: - // Initialization is done upon construction - Uart() - { - Driver::init(); - } + // Constructing a uart object does not initialize the driver to allow different specializations with the same + // back-end to exists at the same time + // Note that init must be called every time when switching specializations with the same back-end + Uart() = default; // Moving and copying uart objects is not supported Uart(const Uart &) = delete; @@ -27,6 +26,12 @@ class Uart { Uart &operator=(const Uart &) = delete; Uart &operator=(Uart &&) = delete; + // Before using the uart init must be called + static void init() + { + Driver::init(); + } + static void txByte(const typename Driver::data_t &byte) { Driver::txByte(byte);