open-LIN/open-LIN-c implementation in ESP32.
This project implements hardware abstraction APIs of open-LIN-c
in ESP32 based on CW-B-W/ESP32-SoftwareLIN.
Besides of the implementation, there are simple examples to illustrate how to use open-LIN-c
.
- Send / Receive LIN bus frames on both LIN master and LIN slave
- Autobaud detection is supported by LIN slave
- Use VS Code with extension PlatformIO to open the project folder
- Build and upload the ESP32 firmware with PlatformIO
- If this device is acting as a LIN master, copy the
examples/master.cpp
tosrc/
- If this device is acting as a LIN slave, copy the
examples/slave.cpp
tosrc/
- If this device is acting as a LIN master, copy the
- Connect the UART pins of the ESP32 LIN master and ESP32 LIN slave
In examples/master.cpp
, master_frame_table
is used to store the periodic frames information. open-LIN-c
keeps iterating through the table and send each frame itme.
Refer to
ESP32-openLIN/examples/master.cpp
Lines 44 to 47 in 677470a
In examples/master.cpp
, frame_slot
is used to store the periodic frames information.
When a framed is received, open-LIN-c
searches the received frame PID in the frame_slot
and return the frame information if found.
Refer to
ESP32-openLIN/examples/slave.cpp
Lines 54 to 57 in 677470a
In examples/master.cpp
, function open_lin_master_dl_rx_callback
is used to handle the frames received. Refer to
ESP32-openLIN/examples/master.cpp
Lines 84 to 91 in 677470a
In examples/master.cpp
, function open_lin_error_handler
is used to handle the errors. Refer to
ESP32-openLIN/examples/master.cpp
Lines 93 to 153 in 677470a
In examples/slave.cpp
, function open_lin_on_rx_frame
is used to handle the frames received. Refer to
ESP32-openLIN/examples/slave.cpp
Lines 115 to 122 in 677470a
In examples/slave.cpp
, function open_lin_error_handler
is used to handle the errors. Refer to
ESP32-openLIN/examples/slave.cpp
Lines 124 to 185 in 677470a
In examples/slave.cpp
, if LIN_AUTOBAUD
is defined, autobaud is enabled, otherwise autobaud is disabled. Refer to
ESP32-openLIN/examples/slave.cpp
Line 35 in 677470a
This project was tested with Microchip LIN Serial Analyzer and NXP TJA1021 module.
(Sleep was not used in this test)
- Use
examples/master.cpp
to do this test. - Open LIN Serial Analyzer Debug Tool
- Hold ESP32 reset button (Don't release now)
- Connect Debug Tool with
LIN Serial Analyzer
- Choose to use Enhanced Checksum Type in Debug Tool
- Setup Slave Response in Debug Tool
- Select the responses and click
Add Slave Response Buffer
- Release ESP32 reset button
- LIN frames should be detected and shown on the screen
Compared with the result in logic analyzer
- Use
examples/slave.cpp
to do this test. - Open LIN Serial Analyzer Debug Tool
- Connect Debug Tool with
LIN Serial Analyzer
- Choose to use Enhanced Checksum Type in Debug Tool
- Setup Master frames in Debug Tool
- Select the two frames and click
Send Continuous
- LIN frames should be detected and shown on the screen
Compared with the result in logic analyzer
This project was also tested with VN1611.
We can take advantages of Vector XL Driver Library to test it with VN1611.