Quantcast
Viewing all articles
Browse latest Browse all 3780

Troubleshooting • Problems using Raspberry Pi PicoW with FreeRTOS

I want to use picoW with FreeRTOS. I sort of have it. My directory structure for the project is below.

In src/main.cpp I have the following and it works fine. I get different tasks running:

xTaskCreate((TaskFunction_t) &led_task, "LED_Task", 256, NULL, 1, NULL);
xTaskCreate((TaskFunction_t) &temp_task, "Temperatue_Task", 256, NULL, 2, NULL);
vTaskStartScheduler();

They do what I expect. One blinks the light at the correct rate and the other prints out the temperature to the console at the correct rate which is all I have it doing now.

In one of the drivers I want to add a delay. The file is i2c_devices/i2c_sht4x.cpp and this seems to work:

retval = i2c_write_blocking(i2c_bus_, SSHT4x_I2C_ADDRESS, &command, SHT4x_COMMAND_LENGTH, true);
sleep_ms(10); // Datasheet says to put in a delay.
retval = i2c_read_blocking(i2c_bus_, SSHT4x_I2C_ADDRESS, (uint8_t *)buffer, SHT4x_SERIAL_LENGTH, false);

Rather than using sleep_ms() I try to use vTaskDelay(). So, I add an include of:

#include "task.h"

And then change the code to:

retval = i2c_write_blocking(i2c_bus_, SSHT4x_I2C_ADDRESS, &command, SHT4x_COMMAND_LENGTH, true);
//sleep_ms(10); // Datasheet says to put in a delay.
vTaskDelay(1000);
retval = i2c_read_blocking(i2c_bus_, SSHT4x_I2C_ADDRESS, (uint8_t *)buffer, SHT4x_SERIAL_LENGTH, false);

I assume this is a CMake issue where the /src level seems to know to use /opt/sdk/FreeRTOS-Kernel/include but the /lib sub-directory does not.
The CMakeLists.txt file in /src has:

target_link_libraries(${ProjectName}
pico_stdlib
pico_cyw43_arch_none # we need Wifi to access the GPIO
pico_cyw43_arch_lwip_threadsafe_background
FreeRTOS-Kernel-Heap4
)

I tried adding FreeRTOS-Kernel-Heap4 to the /lib/CMakeLists.txt:

target_link_libraries(i2c_bus PUBLIC
pico_stdlib
pico_cyw43_arch_none # we need Wifi to access the GPIO
hardware_gpio
hardware_i2c
FreeRTOS-Kernel-Heap4
)

When I do I get:
[build] /opt/sdk/FreeRTOS-Kernel/portable/ThirdParty/GCC/RP2040/include/freertos_sdk_config.h:33:14: fatal error: FreeRTOSConfig.h: No such file or directory
[build] 33 | #include "FreeRTOSConfig.h"
[build] | ^~~~~~~~~~~~~~~~~~

The FreeRTOSConfig.h file is up in the /src directory, but also seems to be needed by /lib. I don't think I want multiple copies.

Is there some central place I should put FreeRTOSConfig.h so that all sub-directories can find it?

Thanks


├── CMakeLists.txt
├── lib
│   ├── CMakeLists.txt
│   ├── i2c_bus
│   │   ├── CMakeLists.txt
│   │   ├── i2c_bus.cpp
│   │   ├── i2c_bus.h
│   │   ├── i2c_bus_interface.h
│   │   └── pico_i2c.h
│   ├── i2c_devices
│   │   ├── CMakeLists.txt
│   │   ├── i2c_lps22hb.cpp
│   │   ├── i2c_lps22hb.h
│   │   ├── i2c_sht4x.cpp
│   │   └── i2c_sht4x.h
│   └── units
│   ├── barometric_pressure_interface.h
│   ├── CMakeLists.txt
│   ├── relative_humidity_interface.h
│   └── temperature_interface.h
├── pico_sdk_import.cmake
└── src
├── CMakeLists.txt
├── FreeRTOSConfig.h
├── includes
│   └── lwipopts.h
└── main.cpp

Statistics: Posted by chriskot870 — Wed Feb 07, 2024 7:35 pm



Viewing all articles
Browse latest Browse all 3780

Trending Articles