| LIN_slave_portable_Arduino 1.4 Arduino library for Local Interconnect Network slave node emulation

Loading...
Searching...
No Matches
LIN_slave_HardwareSerial.h
Go to the documentation of this file.
1
10// for AVR selection of HardwareSerial (sync on inter-frame pause) or NeoHWSerial (sync on BREAK)
11#include <LIN_slave_NeoHWSerial_AVR.h>
12
13// for AVR platform use NeoHWSerial or comment out USE_NEOSERIAL in file LIN_slave_NeoHWSerial_AVR.h
14#if !defined(ARDUINO_ARCH_AVR) || !defined(USE_NEOSERIAL)
15
16
17/*-----------------------------------------------------------------------------
18 MODULE DEFINITION FOR MULTIPLE INCLUSION
19-----------------------------------------------------------------------------*/
20#ifndef _LIN_SLAVE_HW_SERIAL_H_
21#define _LIN_SLAVE_HW_SERIAL_H_
22
23
24/*-----------------------------------------------------------------------------
25 INCLUDE FILES
26-----------------------------------------------------------------------------*/
27
28// include required libraries
29#include <LIN_slave_Base.h>
30
31
32/*-----------------------------------------------------------------------------
33 GLOBAL CLASS
34-----------------------------------------------------------------------------*/
35
41 class LIN_Slave_HardwareSerial : public LIN_Slave_Base
42{
43 // PROTECTED VARIABLES
44 protected:
45
46 HardwareSerial *pSerial;
47 bool flagBreak;
48 uint16_t minFramePause;
49
50
51 // PROTECTED METHODS
52 protected:
53
55 virtual bool _getBreakFlag(void);
56
58 void _resetBreakFlag(void);
59
60
62 inline uint8_t _serialPeek(void) { return this->pSerial->peek(); }
63
65 inline uint8_t _serialRead(void) { return this->pSerial->read(); }
66
68 inline void _serialWrite(uint8_t buf[], uint8_t num) { this->pSerial->write(buf, num); }
69
70
71 // PUBLIC METHODS
72 public:
73
75 LIN_Slave_HardwareSerial(HardwareSerial &Interface, uint16_t MinFramePause=1000L,
76 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);
77
79 void begin(uint16_t Baudrate = 19200);
80
82 void end(void);
83
85 inline bool available(void) { return this->pSerial->available(); }
86
88 virtual void handler(void);
89
90}; // class LIN_Slave_HardwareSerial
91
92
93/*-----------------------------------------------------------------------------
94 END OF MODULE DEFINITION FOR MULTIPLE INLUSION
95-----------------------------------------------------------------------------*/
96#endif // _LIN_SLAVE_HW_SERIAL_H_
97
98#endif // !ARDUINO_ARCH_AVR || !USE_NEOSERIAL
99
100/*-----------------------------------------------------------------------------
101 END OF FILE
102-----------------------------------------------------------------------------*/
LIN_slave_Base.h
Base class for LIN slave emulation (non-functional)
LIN_slave_NeoHWSerial_AVR.h
LIN slave emulation library using a NeoHWSerial interface of AVR.
LIN_Slave_Base
LIN slave node base class.
Definition LIN_slave_Base.h:106
LIN_Slave_Base::version_t
version_t
LIN protocol version.
Definition LIN_slave_Base.h:112
LIN_Slave_Base::LIN_V2
@ LIN_V2
LIN protocol version 2.x.
Definition LIN_slave_Base.h:114
LIN_Slave_HardwareSerial
LIN slave node class via generic HardwareSerial.
Definition LIN_slave_HardwareSerial.h:42
LIN_Slave_HardwareSerial::_serialRead
uint8_t _serialRead(void)
read next byte from Rx buffer
Definition LIN_slave_HardwareSerial.h:65
LIN_Slave_HardwareSerial::pSerial
HardwareSerial * pSerial
pointer to serial interface used for LIN
Definition LIN_slave_HardwareSerial.h:46
LIN_Slave_HardwareSerial::flagBreak
bool flagBreak
a break was detected, is set in handle
Definition LIN_slave_HardwareSerial.h:47
LIN_Slave_HardwareSerial::_serialWrite
void _serialWrite(uint8_t buf[], uint8_t num)
write bytes to Tx buffer
Definition LIN_slave_HardwareSerial.h:68
LIN_Slave_HardwareSerial::_resetBreakFlag
void _resetBreakFlag(void)
Clear break detection flag.
Definition LIN_slave_HardwareSerial.cpp:39
LIN_Slave_HardwareSerial::handler
virtual void handler(void)
Handle LIN protocol and call user-defined frame handlers.
Definition LIN_slave_HardwareSerial.cpp:132
LIN_Slave_HardwareSerial::begin
void begin(uint16_t Baudrate=19200)
Open serial interface.
Definition LIN_slave_HardwareSerial.cpp:83
LIN_Slave_HardwareSerial::end
void end(void)
Close serial interface.
Definition LIN_slave_HardwareSerial.cpp:111
LIN_Slave_HardwareSerial::_getBreakFlag
virtual bool _getBreakFlag(void)
Get break detection flag.
Definition LIN_slave_HardwareSerial.cpp:26
LIN_Slave_HardwareSerial::_serialPeek
uint8_t _serialPeek(void)
peek next byte from Rx buffer
Definition LIN_slave_HardwareSerial.h:62
LIN_Slave_HardwareSerial::minFramePause
uint16_t minFramePause
min. inter-frame pause [us] to start new frame (not standard compliant!)
Definition LIN_slave_HardwareSerial.h:48
LIN_Slave_HardwareSerial::available
bool available(void)
check if a byte is available in Rx buffer
Definition LIN_slave_HardwareSerial.h:85