14#if defined(_LIN_SLAVE_NEOHWSERIAL_AVR_H_)
18bool LIN_Slave_NeoHWSerial_AVR::flagBreak[];
25#if defined(HAVE_HWSERIAL0)
34 bool LIN_Slave_NeoHWSerial_AVR::_onSerialReceive0(uint8_t
byte, uint8_t status)
37 if ((
byte ==0x00) && (status & (0x01<< FE0)))
40 (LIN_Slave_NeoHWSerial_AVR::flagBreak)[0] =
true;
43 DEBUG_PRINT_STATIC(3,
"Rx=0x%02X, BRK",
byte);
50 DEBUG_PRINT_STATIC(3,
"Rx=0x%02X",
byte);
60#if defined(HAVE_HWSERIAL1)
69 bool LIN_Slave_NeoHWSerial_AVR::_onSerialReceive1(uint8_t
byte, uint8_t status)
72 if ((
byte ==0x00) && (status & (0x01<< FE0)))
75 (LIN_Slave_NeoHWSerial_AVR::flagBreak)[1] =
true;
78 DEBUG_PRINT_STATIC(3,
"Rx=0x%02X, BRK",
byte);
85 DEBUG_PRINT_STATIC(3,
"Rx=0x%02X",
byte);
95#if defined(HAVE_HWSERIAL2)
104 bool LIN_Slave_NeoHWSerial_AVR::_onSerialReceive2(uint8_t
byte, uint8_t status)
107 if ((
byte ==0x00) && (status & (0x01<< FE0)))
110 (LIN_Slave_NeoHWSerial_AVR::flagBreak)[2] =
true;
113 DEBUG_PRINT_STATIC(3,
"Rx=0x%02X, BRK",
byte);
120 DEBUG_PRINT_STATIC(3,
"Rx=0x%02X",
byte);
130#if defined(HAVE_HWSERIAL3)
139 bool LIN_Slave_NeoHWSerial_AVR::_onSerialReceive3(uint8_t
byte, uint8_t status)
142 if ((
byte ==0x00) && (status & (0x01<< FE0)))
145 (LIN_Slave_NeoHWSerial_AVR::flagBreak)[3] =
true;
148 DEBUG_PRINT_STATIC(3,
"Rx=0x%02X, BRK",
byte);
155 DEBUG_PRINT_STATIC(3,
"Rx=0x%02X",
byte);
178 return (this->flagBreak)[this->idxSerial];
191 (this->flagBreak)[this->idxSerial] =
false;
217 this->pSerial = &Interface;
234 this->pSerial->end();
235 this->pSerial->begin(this->
baudrate);
236 #if defined(LIN_SLAVE_LIN_PORT_TIMEOUT) && (LIN_SLAVE_LIN_PORT_TIMEOUT > 0)
237 uint32_t startMillis = millis();
238 while ((!(*(this->pSerial))) && (millis() - startMillis < LIN_SLAVE_LIN_PORT_TIMEOUT));
240 while(!(*(this->pSerial)));
244 #if defined(HAVE_HWSERIAL0)
245 if (this->pSerial == &NeoSerial)
248 this->pSerial->attachInterrupt(this->_onSerialReceive0);
251 #if defined(HAVE_HWSERIAL1)
252 if (this->pSerial == &NeoSerial1)
255 pSerial->attachInterrupt(this->_onSerialReceive1);
258 #if defined(HAVE_HWSERIAL2)
259 if (this->pSerial == &NeoSerial2)
262 pSerial->attachInterrupt(this->_onSerialReceive2);
265 #if defined(HAVE_HWSERIAL3)
266 if (this->pSerial == &NeoSerial3)
269 pSerial->attachInterrupt(this->_onSerialReceive3);
277 #if defined(LIN_SLAVE_DEBUG_SERIAL) && (LIN_SLAVE_DEBUG_LEVEL >= 2)
278 LIN_SLAVE_DEBUG_SERIAL.print(this->
nameLIN);
279 LIN_SLAVE_DEBUG_SERIAL.println(
": LIN_Slave_NeoHWSerial_AVR::begin()");
296 this->pSerial->end();
LIN slave emulation library using a NeoHWSerial interface of AVR.
LIN slave node base class.
uint16_t baudrate
communication baudrate [Baud]
virtual void begin(uint16_t Baudrate=19200)
Open serial interface.
char nameLIN[LIN_SLAVE_BUFLEN_NAME]
LIN node name, e.g. for debug.
version_t
LIN protocol version.
virtual void end(void)
Close serial interface.
LIN_Slave_NeoHWSerial_AVR(NeoHWSerial &Interface, LIN_Slave_Base::version_t Version=LIN_Slave_Base::LIN_V2, const char NameLIN[]="Slave", uint32_t TimeoutRx=1500L, const int8_t PinTxEN=INT8_MIN)
Class constructor.
bool _getBreakFlag(void)
Get break detection flag.
void _resetBreakFlag(void)
Clear break detection flag.
void begin(uint16_t Baudrate=19200)
Open serial interface.
void end(void)
Close serial interface.