macchina / LIN

Arduino library to add dual LIN support on SAM3X based boards with a TJA1021/TJA1027 transceiver
MIT License
108 stars 46 forks source link

LIN TX on Channel 1 not working? #5

Open adamvoss opened 7 years ago

adamvoss commented 7 years ago

From @rocketjosh on August 10, 2017 15:13

It appears as though LIN1.write( may not be working? LIN2.write( does appear to work. Tested using this example.

RX on both channels does work as verified using this example.

Copied from original issue: macchina/m2-libraries#3

duronflo commented 5 years ago

Hello, I encounterd the same problem and I have found the problem. It is a typo in the source code there is an assignment instead of a comparison in the if clause which causes this problem.

Here the corresponding code snipped.

// PRIVATE METHODS int lin_stack::serial_pause(int no_bits){ // Calculate delay needed for 13 bits, depends on bound rate unsigned int del = period*no_bits; // delay for number of bits (no-bits) in microseconds, depends on period if(ch=2){ PIOA->PIO_PER = PIO_PA13; // enable PIO register PIOA->PIO_OER = PIO_PA13; // enable PA13 as output PIOA->PIO_CODR = PIO_PA13; // clear PA13 delayMicroseconds(del); // delay PIOA->PIO_SODR = PIO_PA13; // set pin high PIOA->PIO_PDR = PIO_PA13; // clear configuration for PIO, needs to be done because Serial wont work with it }else if(ch=1){

duronflo commented 5 years ago

Also I did a fork on your project doing some changes and extensions.

The link is: https://github.com/duronflo/LIN

So far I did:

collin80 commented 5 years ago

If you'd like, issue a pull request and I'll look it over and merge it. Otherwise, I can go to your link and do the changes myself. Thanks for working on it either way!

collin80 commented 5 years ago

I just merged your changes. They seem reasonable to me. Can someone else who uses LIN confirm that things are improved?