[Error] main.cpp@11,1: 'CAN' does not name a type; did you mean 'CAN1'?

I was trying to play with the CAN APIs with the target “IMXRT1050-EVKB”.
However, when I tried to created a simple instance like:

CAN Testcan(CAN2_RX,CAN2_TX);

Where:
#define CAN2_TX GPIO_AD_B0_14
#define CAN2_RX GPIO_AD_B0_15

And I always have the following error when compiling:
[Error] main.cpp@11,1: ‘CAN’ does not name a type; did you mean ‘CAN1’?
[ERROR] .\main.cpp:11:1: error: ‘CAN’ does not name a type; did you mean ‘CAN1’?

The LED and SPI ones works fine.

I am using the latest version of the Mbed studio.
Mbed Studio: 1.4.4

Any one knows what might be the issue there?

Thanks a lot for the help

Ni

Hello,

the error does not point to these macros, but to object CAN and that is because the CAN API is not enabled on this target - targets.json. Maybe is also the CAN driver not implemented and that is reason why it is not enabled, but I am not familiar with NXP targets.

BR, Jan

Hi Jan

Thanks for the reply, I can see the CAN.cpp file is there, and also, I can see the CAN driver .c files are there in the target driver folders. I can take a try to enable the CAN and see if that works or not.

You can try.
Just add content below to your mbed_app.json file (or create one)

{
    "target_overrides": {
        "*": {
            "target.device_has_add": ["CAN"]
        }
    }
}

BR, Jan

Hi Jan
Thanks for the info. Unfortunately this target does not have CAN support. …

BR
Ni

Hello,

May I suggest that you move your post to the “Mbed OS” category please? The problem you encountered does not seem to be directly linked to Mbed Studio.
Thank you.

Elise - Studio team.

Hi Elise

Sure, could you provide the info of how to move the post? I am not sure how to move it.

Thank you

Try edit your first post via the pen icon at bottom of that post or something like that.

BR, Jan

Hello,

Yes, there’s a pen icon to edit your post:


Thank you.

Hi
Looks like I do not have that edit icon, and I cannot find anywhere to edit the post. T_T

Ni