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)
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
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-----------------------------------------------------------------------------*/
Base class for LIN slave emulation (non-functional)
LIN slave emulation library using a NeoHWSerial interface of AVR.
LIN slave node base class.
version_t
LIN protocol version.
@ LIN_V2
LIN protocol version 2.x.
LIN slave node class via generic HardwareSerial.
uint8_t _serialRead(void)
read next byte from Rx buffer
HardwareSerial * pSerial
pointer to serial interface used for LIN
bool flagBreak
a break was detected, is set in handle
void _serialWrite(uint8_t buf[], uint8_t num)
write bytes to Tx buffer
void _resetBreakFlag(void)
Clear break detection flag.
virtual void handler(void)
Handle LIN protocol and call user-defined frame handlers.
void begin(uint16_t Baudrate=19200)
Open serial interface.
void end(void)
Close serial interface.
virtual bool _getBreakFlag(void)
Get break detection flag.
uint8_t _serialPeek(void)
peek next byte from Rx buffer
uint16_t minFramePause
min. inter-frame pause [us] to start new frame (not standard compliant!)
bool available(void)
check if a byte is available in Rx buffer