OM13092 LPCXpressso54608

Hello All,

I want to interface CAN bus protocol on the OM13092 LPCXpressso54608 development board without the CAN transceiver.

Below is the CAN bus code

#include “mbed.h”
#include “CAN.h”

// Define CAN bus pins
CAN can0(P1_18, P1_17); // Change these pins based on your hardware for CAN0
CAN can1(P3_19, P3_18); // Change these pins based on your hardware for CAN1

int write(CANMessage msg);

// Define LED pins
DigitalOut led1(P3_21); // Change this pin based on your hardware for LED1
DigitalOut led2(P3_22); // Change this pin based on your hardware for LED2

int main()
{
// Set up CAN bus parameters
can0.frequency(500000); // Set the CAN bus frequency to 500 kHz
can0.mode(CAN::Normal); // Set the CAN mode to Normal mode

can1.frequency(500000);
can1.mode(CAN::Normal);

printf("CAN Bus Example: Sending from CAN0, Receiving on CAN1, and vice versa\n");

while (1)
{
    // Sending from CAN0 to CAN1
    CANMessage msg_out;
    msg_out.id = 0x100;     // CAN message ID
    msg_out.len = 3;        // Length of the data
    msg_out.data[0] = 0xAA; // Data byte 1
    msg_out.data[1] = 0xBB; // Data byte 2
    msg_out.data[2] = 0xCC; // Data byte 3

    if (can0.write(msg_out))
    {
        printf("Message sent from CAN0 to CAN1: ID = 0x%X, Data = 0x%X 0x%X 0x%X\n",
               msg_out.id, msg_out.data[0], msg_out.data[1], msg_out.data[2]);
    }
    else
    {
        printf("Failed to send message from CAN0 to CAN1\n");
    }

    // Toggle LED1 to indicate message sent from CAN0
    led1 = !led1;

    // Receiving on CAN1
    CANMessage msg_in;
    if (can1.read(msg_in))
    {
        printf("Message received on CAN1: ID = 0x%X, Data = 0x%X 0x%X 0x%X\n",
               msg_in.id, msg_in.data[0], msg_in.data[1], msg_in.data[2]);
    }

    // Toggle LED2 to indicate message received on CAN1
    led2 = !led2;

    // Sending from CAN1 to CAN0
    msg_out.id = 0x200;
    if (can1.write(msg_out))
    {
        printf("Message sent from CAN1 to CAN0: ID = 0x%X, Data = 0x%X 0x%X 0x%X\n",
               msg_out.id, msg_out.data[0], msg_out.data[1], msg_out.data[2]);
    }
    else
    {
        printf("Failed to send message from CAN1 to CAN0\n");
    }

    // Toggle LED2 to indicate message sent from CAN1
    led2 = !led2;

    // Receiving on CAN0
    if (can0.read(msg_in))
    {
        printf("Message received on CAN0: ID = 0x%X, Data = 0x%X 0x%X 0x%X\n",
               msg_in.id, msg_in.data[0], msg_in.data[1], msg_in.data[2]);
    }

    // Toggle LED1 to indicate message received on CAN0
    led1 = !led1;

    ThisThread::sleep_for(1000s);  // Sleep for 1 second
}

}

These are the errors I am getting when I build the code in the Mbed Studio 6.17.0

Unknown type name 'CAN’clang(unknown_typename)[6, 1]
Unknown type name 'CAN’clang(unknown_typename)[7, 1]
Unknown type name 'CANMessage’clang(unknown_typename)[9, 11]
Use of undeclared identifier 'CAN’clang(undeclared_var_use)[19, 15]
Use of undeclared identifier 'CAN’clang(undeclared_var_use)[22, 15]
Unknown type name 'CANMessage’clang(unknown_typename)[29, 9]
Unknown type name 'CANMessage’clang(unknown_typename)[50, 9]

Could you please help me with this?