|
1 | | -# LIN-Transceiver-Library (TJA1020) |
| 1 | +# HAL for TJA1020 LIN Transceiver |
2 | 2 |
|
3 | | -Using a LIN Bus via TJA1020 Transceiver needs to handle the statemachine bevor you will be able to send or receive data from the bus. This is encapsulated within this class. |
| 3 | +Using a LIN Bus via TJA1020 Transceiver needs to handle the statemachine bevor you will be able to send or receive data from the bus. |
| 4 | +This is encapsulated within this class. |
4 | 5 |
|
5 | 6 | # dependencies |
6 | 7 |
|
7 | | -This library extends the Lin-Interface Library: |
| 8 | +none. |
| 9 | + |
| 10 | +But this was designed for use on the Lin Stack, my Lin-Interface Library: |
8 | 11 | https://github.com/mestrode/Lin-Interface-Library |
9 | 12 |
|
10 | 13 | # example |
11 | 14 | Take a look into the basic example. |
12 | 15 |
|
13 | | -Library should work like the Lin-Interface Library, but considers the statemachine in every readFrame and writeFrame method. |
14 | | -You can also control the statemachine, eg. the default slope mode. |
15 | | - |
16 | | -```cpp |
17 | | - #include "TJA1020.hpp" |
18 | | - |
19 | | - #define LIN_SERIAL_SPEED 19200 |
20 | | - #define lin_NSLP_Pin 32 |
21 | | - |
22 | | - // RX and TX Pin is defined per UART_nr |
23 | | - TJA1020 LinBus(2, LIN_SERIAL_SPEED, lin_NSLP_Pin); // UART_nr, Baudrate, /SLP-Pin |
24 | | - |
25 | | - void setup() |
26 | | - { |
27 | | - // use LowSlope mode all the time |
28 | | - LinBus.Slope(LinBus.LowSlope); |
29 | | - } |
30 | | - |
31 | | - uint8_t getData() |
32 | | - { |
33 | | - uint8_t data = 0x00; |
34 | | - |
35 | | - // Read Frame ID = 0x20 |
36 | | - if (LinBus.readFrame(0x20)) |
37 | | - { |
38 | | - // Read succesfull |
39 | | - data = LinBus.LinMessage[0]; // only consider byte 0 of the received data |
40 | | - } |
41 | | - |
42 | | - // let LIN-Tranceiver sleep --> changes also the INH Pin of the TJA1020 |
43 | | - LinBus.setMode(LinBus.Sleep); |
44 | | - |
45 | | - return data; |
46 | | - } |
47 | | -``` |
48 | | -
|
49 | 16 | # see also |
50 | 17 |
|
51 | 18 | * Datasheet of TJA1020 https://www.nxp.com/docs/en/data-sheet/TJA1020.pdf |
0 commit comments