1////////////////////////////////////////////////////////////////////////////////
2// //
3// This software is supplied under the terms of a license agreement or //
4// nondisclosure agreement with Mitov Software and may not be copied //
5// or disclosed except in accordance with the terms of that agreement. //
6// Copyright(c) 2002-2016 Mitov Software. All Rights Reserved. //
7// //
8////////////////////////////////////////////////////////////////////////////////
9
10#ifndef _MITOV_UART_SERIAL_h
11#define _MITOV_UART_SERIAL_h
12
13#include <Mitov.h>
14
15namespace Mitov
16{
17 const UARTClass::UARTModes CUARTSerialInits[] =
18 {
19 SERIAL_8N1,
20 SERIAL_8E1,
21 SERIAL_8O1,
22 SERIAL_8M1,
23 SERIAL_8S1
24 };
25//---------------------------------------------------------------------------
26 template<typename T_SERIAL_TYPE, T_SERIAL_TYPE *T_SERIAL> class UARTSerialPort : public Mitov::SpeedSerialPort<T_SERIAL_TYPE, T_SERIAL>
27 {
28 typedef Mitov::SpeedSerialPort<T_SERIAL_TYPE, T_SERIAL> inherited;
29
30 public:
31 TArduinoSerialParity Parity = spNone;
32
33 public:
34 void SetParity( TArduinoSerialParity AValue )
35 {
36 if( Parity == AValue )
37 return;
38
39 Parity = AValue;
40 inherited::RestartPort();
41 }
42
43 protected:
44 virtual void StartPort() override
45 {
46 int AIndex = ((int)Parity);
47 T_SERIAL->begin( inherited::Speed, CUARTSerialInits[ AIndex ] );
48 }
49
50 };
51//---------------------------------------------------------------------------
52} // Mitov
53
54#endif
55