BeattieBoy
Member
I'm making a library to interface the Teensy with a Spektrum Satellite R/C receiver which sends out serial data instead of standard PPM servo pulses. What I'm trying to do is initialize the receiver object by passing the constructor a hardware serial port reference.
But so far I'm stuck as to how I can tell it which serial port to use without multiple variations of the code (one for each HardwareSerial). I've seen that for the Arduino Mega, all the hardware serial ports (Serial1, Serial2, and Serial3) are still just HardwareSerial objects. So is there a way to make the Teensy's HardwareSerial, HardwareSerial2, and HardwareSerial3 act in that manner? So that I can pass it any hardware serial port and it will use that port?
Code:
SatelliteRX(HardwareSerial3& _serial);
SatelliteRX::SatelliteRX(HardwareSerial3& _serial) : _serialPort(_serial)
{
// Do nothing
}