Hello,
I am getting the error mentioned in the title when I compile and link my code, which is shown below.
================================== sketch.ino ==================================
void setup() {
// put your setup code here, to run once:
Serial.begin(115200); //delay(400);
delay(400);
Initialise_CAN_Ports();
}
void loop() {
// put your main code here, to run repeatedly:
}
void setup() {
// put your setup code here, to run once:
Serial.begin(115200); //delay(400);
delay(400);
Initialise_CAN_Ports();
}
void loop() {
// put your main code here, to run repeatedly:
}
================================== can.ino ==================================
#include <FlexCAN_T4.h>
FlexCAN_T4<CAN1, RX_SIZE_16, TX_SIZE_16> Can1; /* orig RX_SIZE_256 TX_SIZE_64 */
FlexCAN_T4<CAN2, RX_SIZE_16, TX_SIZE_16> Can2; /* orig RX_SIZE_256 TX_SIZE_64 */
#define CAN_BUFFER_STORE_LEN (1024U * 8U)
struct Rx_CAN_TIME
{
int hr;
int mins;
int secs;
uint32_t ms;
uint32_t microseconds;
}
CAN_Rx_time[CAN_BUFFER_STORE_LEN];
CAN_message_t CAN_store[CAN_BUFFER_STORE_LEN];
uint32_t CAN_store_wr_idx;
uint32_t CAN_store_rd_idx;
/* ------------------------------------------------------------------ */
/* */
/* Interrupt routine to handle the received CAN messages */
/* */
/* ------------------------------------------------------------------ */
void canSniff(uint8_t bus, const CAN_message_t &msg)
{
CAN_Rx_time[CAN_store_wr_idx].microseconds = micros();
memcpy(&CAN_store[CAN_store_wr_idx], (const void *)&msg, sizeof(CAN_message_t));
CAN_store_wr_idx = (CAN_store_wr_idx + 1U) % CAN_BUFFER_STORE_LEN;
}
/* ------------------------------------------------------------------ */
/* */
/* CAN 1 interrupt Callback function */
/* */
/* ------------------------------------------------------------------ */
void can1_Sniff(const CAN_message_t &msg)
{
canSniff(1, msg);
}
/* ------------------------------------------------------------------ */
/* */
/* CAN 2 interrupt Callback function */
/* */
/* ------------------------------------------------------------------ */
void can2_Sniff(const CAN_message_t &msg)
{
canSniff(2, msg);
}
/* ------------------------------------------------------------------ */
/* */
/* Initialise the CAN hardware for ports 1 and 2 */
/* */
/* ------------------------------------------------------------------ */
void Initialise_CAN_Ports(void)
{
Can1.begin();
Can1.setBaudRate(1000000);
Can1.setMaxMB(16);
Can1.enableFIFO();
Can1.enableFIFOInterrupt();
Can1.onReceive(can1_Sniff);
Can1.mailboxStatus();
Can1.enableMBInterrupts();
Can2.begin();
Can2.setBaudRate(1000000);
Can2.setMaxMB(16);
Can2.enableFIFO();
Can2.enableFIFOInterrupt();
Can2.onReceive(can2_Sniff);
Can2.mailboxStatus();
Can2.enableMBInterrupts();
}
If I put all the code into one file it compiles and links, but I have no idea why. I would be grateful for some advice on how to remove this error, while still keeping two files.
regards,
Ray
I am getting the error mentioned in the title when I compile and link my code, which is shown below.
================================== sketch.ino ==================================
void setup() {
// put your setup code here, to run once:
Serial.begin(115200); //delay(400);
delay(400);
Initialise_CAN_Ports();
}
void loop() {
// put your main code here, to run repeatedly:
}
void setup() {
// put your setup code here, to run once:
Serial.begin(115200); //delay(400);
delay(400);
Initialise_CAN_Ports();
}
void loop() {
// put your main code here, to run repeatedly:
}
================================== can.ino ==================================
#include <FlexCAN_T4.h>
FlexCAN_T4<CAN1, RX_SIZE_16, TX_SIZE_16> Can1; /* orig RX_SIZE_256 TX_SIZE_64 */
FlexCAN_T4<CAN2, RX_SIZE_16, TX_SIZE_16> Can2; /* orig RX_SIZE_256 TX_SIZE_64 */
#define CAN_BUFFER_STORE_LEN (1024U * 8U)
struct Rx_CAN_TIME
{
int hr;
int mins;
int secs;
uint32_t ms;
uint32_t microseconds;
}
CAN_Rx_time[CAN_BUFFER_STORE_LEN];
CAN_message_t CAN_store[CAN_BUFFER_STORE_LEN];
uint32_t CAN_store_wr_idx;
uint32_t CAN_store_rd_idx;
/* ------------------------------------------------------------------ */
/* */
/* Interrupt routine to handle the received CAN messages */
/* */
/* ------------------------------------------------------------------ */
void canSniff(uint8_t bus, const CAN_message_t &msg)
{
CAN_Rx_time[CAN_store_wr_idx].microseconds = micros();
memcpy(&CAN_store[CAN_store_wr_idx], (const void *)&msg, sizeof(CAN_message_t));
CAN_store_wr_idx = (CAN_store_wr_idx + 1U) % CAN_BUFFER_STORE_LEN;
}
/* ------------------------------------------------------------------ */
/* */
/* CAN 1 interrupt Callback function */
/* */
/* ------------------------------------------------------------------ */
void can1_Sniff(const CAN_message_t &msg)
{
canSniff(1, msg);
}
/* ------------------------------------------------------------------ */
/* */
/* CAN 2 interrupt Callback function */
/* */
/* ------------------------------------------------------------------ */
void can2_Sniff(const CAN_message_t &msg)
{
canSniff(2, msg);
}
/* ------------------------------------------------------------------ */
/* */
/* Initialise the CAN hardware for ports 1 and 2 */
/* */
/* ------------------------------------------------------------------ */
void Initialise_CAN_Ports(void)
{
Can1.begin();
Can1.setBaudRate(1000000);
Can1.setMaxMB(16);
Can1.enableFIFO();
Can1.enableFIFOInterrupt();
Can1.onReceive(can1_Sniff);
Can1.mailboxStatus();
Can1.enableMBInterrupts();
Can2.begin();
Can2.setBaudRate(1000000);
Can2.setMaxMB(16);
Can2.enableFIFO();
Can2.enableFIFOInterrupt();
Can2.onReceive(can2_Sniff);
Can2.mailboxStatus();
Can2.enableMBInterrupts();
}
If I put all the code into one file it compiles and links, but I have no idea why. I would be grateful for some advice on how to remove this error, while still keeping two files.
regards,
Ray