aboutsummaryrefslogtreecommitdiffhomepage
path: root/Cart_Reader/ClockedSerial.h
blob: 21c59b1a6488a9f1d0d39a40d08c44a9edc9291c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/********************************************************************
*                   Open Source Cartridge Reader                    *
********************************************************************/
#ifndef CLOCKEDSERIAL_H_
#define CLOCKEDSERIAL_H_

#include <HardwareSerial.h>
#include <HardwareSerial_private.h>

/*C******************************************************************
* NAME :            ClockedSerial
*
* DESCRIPTION :     HardwareSerial wrapper that allows for dynamic clock speed adjustments.
*
* USAGE :           See HardwareSerial
*
* NOTES :           If this class isn't used the compiler will optimize it out, so there is
*                   no harm in leaving it.
*C*/
class DynamicClockSerial : public HardwareSerial
{
  using HardwareSerial::HardwareSerial;
  public:
  // Various functions to allow parameter omission and automatic handling.
  void begin(unsigned long baud) { begin(baud, SERIAL_8N1, clock); }
  void begin(unsigned long baud, byte config) { begin(baud, config, clock); }
  void begin(unsigned long baud, unsigned long sclock) { begin(baud, SERIAL_8N1, sclock); }
  void begin(unsigned long baud, byte config, unsigned long sclock);
};

extern DynamicClockSerial ClockedSerial;

#endif /* CLOCKEDSERIAL_H_ */