I am trying to modify a library I created to be able to use with Arduino UNO R4 Wifi.
The code below compiles with no issue in IDE v2.3.2 if I select to compile for a Mega, but if I select UNO R4 Wifi as board I am getting this following error:
C:\Users\sherz\AppData\Local\Temp\arduino\sketches\800F4B443EAAA27A181C00ED62FB9F67\sketch\LIN_ReadWrite.ino.cpp.o: In function
setup': C:\Users\sherz\OneDrive\Documents\Arduino\libraries\LIN-v.14\example\LIN_ReadWrite/LIN_ReadWrite.ino:26: undefined reference toLIN'
C:\Users\sherz\AppData\Local\Temp\arduino\sketches\800F4B443EAAA27A181C00ED62FB9F67\sketch\LIN_ReadWrite.ino.cpp.o: In functionloop': C:\Users\sherz\OneDrive\Documents\Arduino\libraries\LIN-v.14\example\LIN_ReadWrite/LIN_ReadWrite.ino:68: undefined reference toLIN'
collect2.exe: error: ld returned 1 exit statusUsing library LIN-v.14 in folder: C:\Users\sherz\OneDrive\Documents\Arduino\libraries\LIN-v.14 (legacy)
exit status 1Compilation error: exit status 1
Any suggestions how to resolve this?
R4 Wifi INO code:
#include <LIN.h>
#define LIN_BAUD1 9600
#define LIN_BAUD2 19200UL
const uint8_t msg_pid = 0x0D;
const uint8_t msg_dlc = 4;
uint8_t msg_Data[msg_dlc] = {0x00,0x79,0x00,0x00};
uint8_t Checksum;
void setup() {
Serial.begin(115200);
Serial1.begin(LIN_BAUD1);
Serial.println("READY");
Checksum = LIN.GetChecksum(msg_pid, msg_Data, msg_dlc, ENHANCED); //assuming LIN Version Protocol 2.x
}
void loop() {
Serial.print("\nSending LIN FRAME...");
LIN.SendHeaderFrame(Serial1, msg_pid);
LIN.SendDataFrame(Serial1, msg_Data , msg_dlc, Checksum);
++msg_Data[3];
Checksum = LIN.GetChecksum(msg_pid, msg_Data, msg_dlc, ENHANCED); //refesh checksum value
delay(1000); //arbitrary delay
while (Serial1.available()) {
LIN.RxData = Serial1.read();
if (LIN.RxDataType() == BREAKFIELD) {
Serial.println("");
}
else if (LIN.RxDataType() == NEW_FRAME) {
Serial.println("");
Serial.print("New Frame: ");
Serial.print(LIN.RxDataValue(), HEX);
Serial.print(", ");
}
else if (LIN.RxDataType() == SYNC) {
Serial.print("Sync: ");
Serial.print(LIN.RxDataValue(), HEX);
Serial.print(", ");
}
else if (LIN.RxDataType() == PID) {
Serial.print("PID: ");
Serial.print(LIN.RxDataValue(), HEX);
Serial.print(", ID: ");
Serial.print((LIN.RxDataValue()) & 0x3F, HEX);
Serial.print(", Data: ");
}
else if (LIN.RxDataType() == DATA) {
Serial.print(LIN.RxDataValue(), HEX); //data/checksum bytes.
//Last received DATA byte of a given LIN frame would normally be the Checksum Byte
Serial.print(", ");
}
}
}
header file:
#ifndef LIN_H
#define LIN_H
#include "Arduino.h"
#include "LIN_defs.h"
#ifndef ARDUINO_ARCH_RENESAS_UNO
#include "HardwareSerialLIN.h"
#include "HardwareSerialLIN_private.h"
#endif
class LINClass{
public:
LINClass() {};
inline uint16_t RxDataType(){ return (RxData & 0xFF00); }; //return the LIN data type of element read from UART buffer
inline uint8_t RxDataValue(){ return (RxData & 0xFF); }; //return the LIN data value of element read from UART buffer
uint8_t GetPID(uint8_t id); //return PID for given LIN ID
uint8_t VerifyPID(uint8_t pid); //returns if given PID is valid or not
uint8_t GetChecksum(uint8_t pid, uint8_t *msg_data, uint8_t dlc, enum Chksum_T typ); //returns Checksum for given LIN frame. enum Chksum_T {CLASSIC, ENHANCED};
#ifndef ARDUINO_ARCH_RENESAS_UNO
void SendBreak(HardwareSerialLIN &s, uint8_t brkbits = BREAK_BITS); //send break field
void SendHeaderFrame(HardwareSerialLIN &s, uint8_t pid, uint8_t brkbits = BREAK_BITS, uint8_t sync = 0x55); //send breakfield, sync field and LIN PID
void SendDataFrame(HardwareSerialLIN &s, uint8_t *data, uint8_t dlc, uint8_t checksum); //Send LIN data frame + checksum
#else
void SendBreak(UART &s, uint8_t brkbits = BREAK_BITS); //send break field
void SendHeaderFrame(UART &s, uint8_t pid, uint8_t brkbits = BREAK_BITS, uint8_t sync = 0x55); //send breakfield, sync field and LIN PID
void SendDataFrame(UART &s, uint8_t *data, uint8_t dlc, uint8_t checksum); //Send LIN data frame + checksum
#endif
static uint16_t RxData;
private:
};
extern LINClass LIN;
#endif
