Simple LIN master node emulation with blocking operation Simple emulation of a LIN master node via Serial3 (+ LIN transceiver) for DAI MRA2 FED1.0 with blocking operation. Status is printed periodically.
- Author
- Georg Icking-Konert
- Date
- 2020-03-15
#define PIN_TOGGLE 30
#define LIN_PAUSE 250
void setup(void)
{
pinMode(PIN_TOGGLE, OUTPUT);
Serial.begin(115200); while(!Serial);
}
void loop(void)
{
static uint32_t lastCall = LIN_PAUSE;
static uint8_t count = 0;
uint8_t Tx[2] = {0,0};
uint8_t Rx[8];
digitalWrite(PIN_TOGGLE, !digitalRead(PIN_TOGGLE));
if (millis() - lastCall > LIN_PAUSE) {
lastCall = millis();
if (count == 0) {
count++;
}
else {
count=0;
Serial.print(millis()); Serial.println("ms");
Serial.println("data:");
for (uint8_t i=0; i<8; i++)
{
Serial.print(" "); Serial.print(i); Serial.print("\t0x"); Serial.println(Rx[i], HEX);
}
Serial.println();
}
}
}