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

Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | List of all members
LIN_Slave_HardwareSerial_ESP32 Class Reference

LIN slave node class via ESP32 HardwareSerial. More...

`#include <LIN_slave_HardwareSerial_ESP32.h>`

Inheritance diagram for LIN_Slave_HardwareSerial_ESP32:
[legend]

## Public Member Functions
| LIN_Slave_HardwareSerial_ESP32 (HardwareSerial &Interface, uint8_t PinRx, uint8_t PinTx, 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.
void | begin (uint16_t Baudrate=19200)
| Open serial interface.
void | end (void)
| Close serial interface.
bool | available (void)
| check if a byte is available in Rx buffer
Public Member Functions inherited from LIN_Slave_Base
| LIN_Slave_Base (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)
| LIN slave node constructor.
virtual | ~LIN_Slave_Base (void)
| LIN slave node destructor, here dummy. Any class with virtual functions should have virtual destructor.
void | resetStateMachine (void)
| Reset LIN state machine.
LIN_Slave_Base::state_t | getState (void)
| Getter for LIN state machine state.
void | resetError (void)
| Clear error of LIN state machine.
LIN_Slave_Base::error_t | getError (void)
| Getter for LIN state machine error.
void | getFrame (LIN_Slave_Base::frame_t &Type, uint8_t &Id, uint8_t &NumData, uint8_t Data[])
| Getter for LIN frame.
void | registerMasterRequestHandler (uint8_t ID, LIN_Slave_Base::LinMessageCallback Fct, uint8_t NumData)
| Attach user callback function for master request frame.
void | registerSlaveResponseHandler (uint8_t ID, LIN_Slave_Base::LinMessageCallback Fct, uint8_t NumData)
| Attach user callback function for slave response frame.
virtual void | handler (void)
| Handle LIN protocol and call user-defined frame callbacks.

## Public Attributes
HardwareSerial * | pSerial
| pointer to serial interface used for LIN
uint8_t | pinRx
| pin used for receive
uint8_t | pinTx
| pin used for transmit
uint8_t | idxSerial
| index to flagBreak[] of this instance
Public Attributes inherited from LIN_Slave_Base
char | nameLIN [LIN_SLAVE_BUFLEN_NAME]
| LIN node name, e.g. for debug.

## Static Public Attributes
static bool | flagBreak [LIN_SLAVE_ESP32_MAX_SERIAL]
| break flags for Serial0..N

## Protected Member Functions
bool | _getBreakFlag (void)
| Get break detection flag.
void | _resetBreakFlag (void)
| Clear break detection flag.
uint8_t | _serialPeek (void)
| peek next byte from Rx buffer
uint8_t | _serialRead (void)
| read next byte from Rx buffer
void | _serialWrite (uint8_t buf[], uint8_t num)
| write bytes to Tx buffer
Protected Member Functions inherited from LIN_Slave_Base
uint8_t | _calculatePID (uint8_t ID)
| Calculate protected frame ID.
uint8_t | _calculateChecksum (uint8_t NumData, uint8_t Data[])
| Calculate LIN frame checksum.
void | _enableTransmitter (void)
| Enable RS485 transmitter (DE=high)
void | _disableTransmitter (void)
| Disable RS485 transmitter (DE=low)

## Additional Inherited Members
Public Types inherited from LIN_Slave_Base
enum | version_t : uint8_t { LIN_V1 = 1 , LIN_V2 = 2 }
| LIN protocol version. More...
enum | frame_t : uint8_t { MASTER_REQUEST = 0x10 , SLAVE_RESPONSE = 0x20 }
| LIN frame type. Use high nibble for type, low nibble for number of data bytes -> minimize callback[] size. More...
enum | state_t : uint8_t { STATE_OFF = 0x01 , STATE_WAIT_FOR_BREAK = 0x02 , STATE_WAIT_FOR_SYNC = 0x04 , STATE_WAIT_FOR_PID = 0x08 , STATE_RECEIVING_DATA = 0x10 , STATE_RECEIVING_ECHO = 0x20 , STATE_WAIT_FOR_CHK = 0x40 , STATE_DONE = 0x80 }
| LIN state machine states. Use bitmasks for fast checking multiple states. More...
enum | error_t : uint8_t { NO_ERROR = 0x00 , ERROR_STATE = 0x01 , ERROR_ECHO = 0x02 , ERROR_TIMEOUT = 0x04 , ERROR_CHK = 0x08 , ERROR_SYNC = 0x10 , ERROR_PID = 0x20 , ERROR_MISC = 0x80 }
| LIN error codes. Use bitmasks, as error is latched. Use same as LIN_master_portable. More...
Protected Types inherited from LIN_Slave_Base
typedef void(* | LinMessageCallback) (uint8_t numData, uint8_t *data)
| Type for frame callback function.
Protected Attributes inherited from LIN_Slave_Base
int8_t | pinTxEN
| optional Tx direction pin, e.g. for LIN via RS485
uint16_t | baudrate
| communication baudrate [Baud]
LIN_Slave_Base::version_t | version
| LIN protocol version.
LIN_Slave_Base::state_t | state
| status of LIN state machine
LIN_Slave_Base::error_t | error
| error state. Is latched until cleared
bool | flagBreak
| flag for BREAK detected. Needs to be set in Rx-ISR
LIN_Slave_Base::callback_t | callback [64]
| array of user callback functions for IDs 0x00..0x3F
uint8_t | pid
| protected frame identifier (0..255)
uint8_t | id
| unprotected frame identifier (0..63)
LIN_Slave_Base::frame_t | type
| frame type (master request or slave response)
uint8_t | numData
| number of data bytes in frame
uint8_t | bufData [9]
| buffer for data bytes (max. 8B) + checksum
uint8_t | idxData
| current index in bufData
uint32_t | timeoutRx
| timeout [us] for bytes in frame
uint32_t | timeLastRx
| time [us] of last received byte in frame

## Detailed Description

LIN slave node class via ESP32 HardwareSerial.

LIN slave node class via ESP32 HardwareSerial.

Definition at line 53 of file LIN_slave_HardwareSerial_ESP32.h.

## Constructor & Destructor Documentation

## ◆ LIN_Slave_HardwareSerial_ESP32()

LIN_Slave_HardwareSerial_ESP32::LIN_Slave_HardwareSerial_ESP32 | ( | HardwareSerial & | Interface,
|  | uint8_t | PinRx,
|  | uint8_t | PinTx,
|  | 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.

Constructor for LIN node class using ESP32 HardwareSerial.

Constructor for LIN node class for using ESP32 HardwareSerial. Inherit all methods from LIN_Slave_Base, only different constructor

Parameters

  [in] | Interface | serial interface for LIN
  [in] | PinRx | GPIO used for reception
  [in] | PinTx | GPIO used for transmission
  [in] | Version | LIN protocol version (default = v2)
  [in] | NameLIN | LIN node name (default = "Slave")
  [in] | PinTxEN | optional Tx enable pin (high active) e.g. for LIN via RS485 (default = -127/none)
  [in] | TimeoutRx | timeout [us] for bytes in frame (default = 1500)

Definition at line 170 of file LIN_slave_HardwareSerial_ESP32.cpp.

## Member Function Documentation

## ◆ _getBreakFlag()

bool LIN_Slave_HardwareSerial_ESP32::_getBreakFlag | ( | void |  | ) |
| protected virtual

Get break detection flag.

Get break detection flag. Is hardware dependent

Returns
  status of break detection

Reimplemented from LIN_Slave_Base.

Definition at line 133 of file LIN_slave_HardwareSerial_ESP32.cpp.

## ◆ _resetBreakFlag()

void LIN_Slave_HardwareSerial_ESP32::_resetBreakFlag | ( | void |  | ) |
| protected virtual

Clear break detection flag.

Clear break detection flag. Is hardware dependent.

Clear break detection flag. Is hardware dependent

Reimplemented from LIN_Slave_Base.

Definition at line 146 of file LIN_slave_HardwareSerial_ESP32.cpp.

Here is the caller graph for this function:

## ◆ _serialPeek()

uint8_t LIN_Slave_HardwareSerial_ESP32::_serialPeek | ( | void |  | ) |
| inline protected virtual

peek next byte from Rx buffer

Reimplemented from LIN_Slave_Base.

Definition at line 95 of file LIN_slave_HardwareSerial_ESP32.h.

## ◆ _serialRead()

uint8_t LIN_Slave_HardwareSerial_ESP32::_serialRead | ( | void |  | ) |
| inline protected virtual

read next byte from Rx buffer

Reimplemented from LIN_Slave_Base.

Definition at line 98 of file LIN_slave_HardwareSerial_ESP32.h.

## ◆ _serialWrite()

void LIN_Slave_HardwareSerial_ESP32::_serialWrite | ( | uint8_t | buf[],
|  | uint8_t | num
| ) |  |
| inline protected virtual

write bytes to Tx buffer

Reimplemented from LIN_Slave_Base.

Definition at line 101 of file LIN_slave_HardwareSerial_ESP32.h.

## ◆ available()

bool LIN_Slave_HardwareSerial_ESP32::available | ( | void |  | ) |
| inline virtual

check if a byte is available in Rx buffer

Reimplemented from LIN_Slave_Base.

Definition at line 118 of file LIN_slave_HardwareSerial_ESP32.h.

## ◆ begin()

void LIN_Slave_HardwareSerial_ESP32::begin | ( | uint16_t | Baudrate = `19200` | ) |
| virtual

Open serial interface.

Open serial interface with specified baudrate

Parameters

  [in] | Baudrate | communication speed [Baud] (default = 19200)

Reimplemented from LIN_Slave_Base.

Definition at line 190 of file LIN_slave_HardwareSerial_ESP32.cpp.

Here is the call graph for this function:

## ◆ end()

void LIN_Slave_HardwareSerial_ESP32::end | ( | void |  | ) |
| virtual

Close serial interface.

Close serial interface. Here dummy!

Reimplemented from LIN_Slave_Base.

Definition at line 242 of file LIN_slave_HardwareSerial_ESP32.cpp.

Here is the call graph for this function:

## Member Data Documentation

## ◆ flagBreak

bool LIN_Slave_HardwareSerial_ESP32::flagBreak
| static

break flags for Serial0..N

Definition at line 62 of file LIN_slave_HardwareSerial_ESP32.h.

## ◆ idxSerial

uint8_t LIN_Slave_HardwareSerial_ESP32::idxSerial

index to flagBreak[] of this instance

Definition at line 61 of file LIN_slave_HardwareSerial_ESP32.h.

## ◆ pinRx

uint8_t LIN_Slave_HardwareSerial_ESP32::pinRx

pin used for receive

Definition at line 59 of file LIN_slave_HardwareSerial_ESP32.h.

## ◆ pinTx

uint8_t LIN_Slave_HardwareSerial_ESP32::pinTx

pin used for transmit

Definition at line 60 of file LIN_slave_HardwareSerial_ESP32.h.

## ◆ pSerial

HardwareSerial* LIN_Slave_HardwareSerial_ESP32::pSerial

pointer to serial interface used for LIN

Definition at line 58 of file LIN_slave_HardwareSerial_ESP32.h.

The documentation for this class was generated from the following files:

- LIN_slave_HardwareSerial_ESP32.h
- LIN_slave_HardwareSerial_ESP32.cpp