How to use CAN drivers with FreeRTOS?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to use CAN drivers with FreeRTOS?

2,367 Views
skyguy
Contributor III

In order to use CAN with FreeRTOS, I have replaced the interrupt handler with my own that includes a semaphore for task switching.  I've modified the function MCAN_TransferCreateHandle in fsl_mcan.c in the SDK as follows:

//s_mcanIsr = MCAN_TransferHandleIRQ;
s_mcanIsr = can_TransferHandleIRQ_FreeRTOS;

I also have added the header for my code file to fsl_mcan.c.  I'm doing this because s_mcanIsr is defined within the module as a static variable and is used by other driver functions.  I really want to do this in a way that does not modify the fsl_mcan driver.  Is there another way to do this without modifying the driver?

Thanks,

Rick

0 Kudos
3 Replies

1,717 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi Rick:

Could you please let me know which device you are using and the SDK version?

Regards

Daniel

0 Kudos

1,717 Views
skyguy
Contributor III

Hi, Daniel,

I'm targeting the LPC54618J512 (208 pin package) and using SDK version 2.4.0.

Thanks,

Rick

0 Kudos

1,717 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi Rick:

For my understanding, the FreeRTOS driver is a wrapper built on top of standard SDK peripheral drivers.

The wrappers provide an API which blocks the calling task until the I/O operation completes and allows other tasks to run. This is achieved by using the asynchronous API of the underlying driver along with RTOS task synchronization object.

You can refer to the FreeRTOS usart driver in SDK installation folder.

LPCXpresso54618\devices\LPC54618\drivers\fsl_usart_freertos.c

LPCXpresso54618\devices\LPC54618\drivers\fsl_usart.c

Regards

Daniel

0 Kudos