markuspi/cppfreertos

0.1.3

uploaded 2 weeks ago
A FreeRTOS C++ wrapper for ESP32

readme

# cppfreertos

A FreeRTOS C++ wrapper for ESP32. Compatible with PlatformIO and ESP-IDF.

## Installation

### PlatformIO

In your platformio.ini file, add this repository to `lib_deps`:

```ini
[env:some_env]
platform = espressif32
framework = ...
board = ...
lib_deps =
    https://github.com/markuspi/cppfreertos.git#v0.1.3
```

### ESP-IDF

In your component directory (either `main` or any other component in `components/<name>`), edit or create the `idf_component.yml` manifest file and add this repository as a dependency:

```yaml
dependencies:
  markuspi/cppfreertos:
    git: https://github.com/markuspi/cppfreertos.git
    version: v0.1.3
```

## Usage Example

```cpp
#include <cppfreertos/task.h>
#include <cppfreertos/queue.h>

// define a queue of integers with a capacity of 5 items
cppfreertos::StaticQueue<int, 5> myQueue;

// define a task with 4096 bytes of stack size in static memory
cppfreertos::StaticTask<4096> myTask([](){
    int item;
    while (true) {
        if (myQueue.Receive(item, portMAX_DELAY)) {
            std::printf("Received: %d\n", item);
        }
    }
});

// can also use void setup() { ... } for Arduino
extern "C" void app_main() {
    // initialize queue
    myQueue.Init();

    // initialize the task and start it right away
    myTask.Init("MyTask");

    // add an item to the queue
    myQueue.Send(123);
}
```

Links

Supports all targets

License: MIT

To add this component to your project, run:

idf.py add-dependency "markuspi/cppfreertos^0.1.3"

or download archive

Stats

  • Archive size
    Archive size: 5.86 KB
  • Downloaded in total
    Downloaded in total 1 time
  • Downloaded this version
    This version: 1 time

Badge

markuspi/cppfreertos version: 0.1.3
|