Adding FreeRTOS mutex to sensor library to protect i2c communication

I am trying to develop a simple inertial measurement unit on a custom board with a BMP581, BMI088, and BMM350. The code is found under my github account wurdahl, under the [rp2040-freertos-template] repo. I am using the rp2040 pico SDK with cmake.

Overall, the issue I am having is using cmake to link the freeRTOS library to the library I am using to access the sensors.

Because all 3 sensors are on the same i2c bus, the tasks sampling the sensors can’t use the i2c bus at the same time, or else I will run into problems. I am trying to a add an i2c mutex to the respective i2c functions for the BMP and the BMI (hosted in the libraries starting with common). When I add the #include “FreeRTOS.h” to the top of the lib/commonBMI08X/src/commonBMI08X.c file, I get an error saying that the file is not found. So how do I properly link using cmake the freeRTOS library to any library in general so that I can use FreeRTOS’s mutex features.

If this is not the right place to ask, please let me know.

1 Like

I think your question is how to add the FreeRTOS include path to your cmake build so the compiler can locate FreeRTOS.h. Is that correct?

Yes. I have tried adding freeRTOS to the target_link_libraries command in the cmakeLists file in the library’s folder, but that did not work.

Thanks for the response, I believe I have solved my problem by properly including the directories including both the FreeRTOS library and the FreeRTOSConfig.h file.

Thank you for sharing your solution!