{"id":5105,"date":"2022-11-06T19:03:29","date_gmt":"2022-11-06T18:03:29","guid":{"rendered":"https:\/\/www.pschatzmann.ch\/home\/?p=5105"},"modified":"2023-06-30T22:07:17","modified_gmt":"2023-06-30T20:07:17","slug":"freertos-addons-a-c-api-for-freertos","status":"publish","type":"post","link":"https:\/\/www.pschatzmann.ch\/home\/2022\/11\/06\/freertos-addons-a-c-api-for-freertos\/","title":{"rendered":"FreeRTOS-addons a C++ API on Arduino"},"content":{"rendered":"<p>Standard <a href=\"https:\/\/www.freertos.org\/\">FreeRTOS<\/a> uses C based API. However I prefer to have some lean <strong>C++ abstractions<\/strong>. That&#8217;s when I discovered the <a href=\"https:\/\/github.com\/michaelbecker\/freertos-addons\">freertos-addons project from Michael Becker<\/a>.<\/p>\n<p>I have converted it to an <strong>Arduino Library<\/strong>, so that it can be used e.g. on an <strong>ESP32<\/strong>. I also added a new Task class (which is a subclass of Thread) that allows to pass a function pointer in the constructor. For the ESP32 we support the <code>xTaskCreatePinnedToCore()<\/code> method by indicating the core in the Start method.<\/p>\n<p>Here is the link that shows all <a href=\"https:\/\/pschatzmann.github.io\/arduino-freertos-addons\/docs\/html\/annotated.html\">supported classes<\/a>!<\/p>\n<h2>Example<\/h2>\n<p>Here is a simple example that creates a task from a lambda function, starts it on core 0 and uses a queue to pass the information back to the Arduino task:<\/p>\n<pre><code>#include \"freertos-all.h\"\n\nQueue queue(100, sizeof(size_t));\nTask task(\"name\",1000,10, [](){ static size_t count=0; queue.Enqueue(&amp;(++count));});\n\nvoid setup() {\n  Serial.begin(115200);\n  task.Start(0);\n}\n\nvoid loop() {\n  size_t result;\n  queue.Dequeue(&amp;result);\n  Serial.println(result);\n}\n<\/code><\/pre>\n<h2>Further Information<\/h2>\n<p>Further information can be found on <a href=\"https:\/\/github.com\/pschatzmann\/arduino-freertos-addons.git\">Github<\/a>!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Standard FreeRTOS uses C based API. However I prefer to have some lean C++ abstractions. That&#8217;s when I discovered the freertos-addons project from Michael Becker. I have converted it to an Arduino Library, so that it can be used e.g. on an ESP32. I also added a new Task class [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":5104,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[20],"tags":[],"class_list":["post-5105","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-arduino"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>FreeRTOS-addons a C++ API on Arduino - Phil Schatzmann<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.pschatzmann.ch\/home\/2022\/11\/06\/freertos-addons-a-c-api-for-freertos\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"FreeRTOS-addons a C++ API on Arduino - Phil Schatzmann\" \/>\n<meta property=\"og:description\" content=\"Standard FreeRTOS uses C based API. However I prefer to have some lean C++ abstractions. That&#8217;s when I discovered the freertos-addons project from Michael Becker. I have converted it to an Arduino Library, so that it can be used e.g. on an ESP32. I also added a new Task class [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pschatzmann.ch\/home\/2022\/11\/06\/freertos-addons-a-c-api-for-freertos\/\" \/>\n<meta property=\"og:site_name\" content=\"Phil Schatzmann\" \/>\n<meta property=\"article:published_time\" content=\"2022-11-06T18:03:29+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-06-30T20:07:17+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/11\/freertos.jpeg\" \/>\n\t<meta property=\"og:image:width\" content=\"337\" \/>\n\t<meta property=\"og:image:height\" content=\"149\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"pschatzmann\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"pschatzmann\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/11\\\/06\\\/freertos-addons-a-c-api-for-freertos\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/11\\\/06\\\/freertos-addons-a-c-api-for-freertos\\\/\"},\"author\":{\"name\":\"pschatzmann\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\"},\"headline\":\"FreeRTOS-addons a C++ API on Arduino\",\"datePublished\":\"2022-11-06T18:03:29+00:00\",\"dateModified\":\"2023-06-30T20:07:17+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/11\\\/06\\\/freertos-addons-a-c-api-for-freertos\\\/\"},\"wordCount\":138,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\"},\"image\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/11\\\/06\\\/freertos-addons-a-c-api-for-freertos\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/11\\\/freertos.jpeg\",\"articleSection\":[\"Arduino\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/11\\\/06\\\/freertos-addons-a-c-api-for-freertos\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/11\\\/06\\\/freertos-addons-a-c-api-for-freertos\\\/\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/11\\\/06\\\/freertos-addons-a-c-api-for-freertos\\\/\",\"name\":\"FreeRTOS-addons a C++ API on Arduino - Phil Schatzmann\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/11\\\/06\\\/freertos-addons-a-c-api-for-freertos\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/11\\\/06\\\/freertos-addons-a-c-api-for-freertos\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/11\\\/freertos.jpeg\",\"datePublished\":\"2022-11-06T18:03:29+00:00\",\"dateModified\":\"2023-06-30T20:07:17+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/11\\\/06\\\/freertos-addons-a-c-api-for-freertos\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/11\\\/06\\\/freertos-addons-a-c-api-for-freertos\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/11\\\/06\\\/freertos-addons-a-c-api-for-freertos\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/11\\\/freertos.jpeg\",\"contentUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/11\\\/freertos.jpeg\",\"width\":337,\"height\":149},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/11\\\/06\\\/freertos-addons-a-c-api-for-freertos\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"FreeRTOS-addons a C++ API on Arduino\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#website\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/\",\"name\":\"Phil Schatzmann Consulting\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\",\"name\":\"pschatzmann\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/pschatzmann.png\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/pschatzmann.png\",\"contentUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/pschatzmann.png\",\"width\":305,\"height\":305,\"caption\":\"pschatzmann\"},\"logo\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/pschatzmann.png\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"FreeRTOS-addons a C++ API on Arduino - Phil Schatzmann","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.pschatzmann.ch\/home\/2022\/11\/06\/freertos-addons-a-c-api-for-freertos\/","og_locale":"en_US","og_type":"article","og_title":"FreeRTOS-addons a C++ API on Arduino - Phil Schatzmann","og_description":"Standard FreeRTOS uses C based API. However I prefer to have some lean C++ abstractions. That&#8217;s when I discovered the freertos-addons project from Michael Becker. I have converted it to an Arduino Library, so that it can be used e.g. on an ESP32. I also added a new Task class [&hellip;]","og_url":"https:\/\/www.pschatzmann.ch\/home\/2022\/11\/06\/freertos-addons-a-c-api-for-freertos\/","og_site_name":"Phil Schatzmann","article_published_time":"2022-11-06T18:03:29+00:00","article_modified_time":"2023-06-30T20:07:17+00:00","og_image":[{"width":337,"height":149,"url":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/11\/freertos.jpeg","type":"image\/jpeg"}],"author":"pschatzmann","twitter_card":"summary_large_image","twitter_misc":{"Written by":"pschatzmann","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/11\/06\/freertos-addons-a-c-api-for-freertos\/#article","isPartOf":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/11\/06\/freertos-addons-a-c-api-for-freertos\/"},"author":{"name":"pschatzmann","@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1"},"headline":"FreeRTOS-addons a C++ API on Arduino","datePublished":"2022-11-06T18:03:29+00:00","dateModified":"2023-06-30T20:07:17+00:00","mainEntityOfPage":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/11\/06\/freertos-addons-a-c-api-for-freertos\/"},"wordCount":138,"commentCount":2,"publisher":{"@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1"},"image":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/11\/06\/freertos-addons-a-c-api-for-freertos\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/11\/freertos.jpeg","articleSection":["Arduino"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.pschatzmann.ch\/home\/2022\/11\/06\/freertos-addons-a-c-api-for-freertos\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/11\/06\/freertos-addons-a-c-api-for-freertos\/","url":"https:\/\/www.pschatzmann.ch\/home\/2022\/11\/06\/freertos-addons-a-c-api-for-freertos\/","name":"FreeRTOS-addons a C++ API on Arduino - Phil Schatzmann","isPartOf":{"@id":"https:\/\/www.pschatzmann.ch\/home\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/11\/06\/freertos-addons-a-c-api-for-freertos\/#primaryimage"},"image":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/11\/06\/freertos-addons-a-c-api-for-freertos\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/11\/freertos.jpeg","datePublished":"2022-11-06T18:03:29+00:00","dateModified":"2023-06-30T20:07:17+00:00","breadcrumb":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/11\/06\/freertos-addons-a-c-api-for-freertos\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pschatzmann.ch\/home\/2022\/11\/06\/freertos-addons-a-c-api-for-freertos\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/11\/06\/freertos-addons-a-c-api-for-freertos\/#primaryimage","url":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/11\/freertos.jpeg","contentUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/11\/freertos.jpeg","width":337,"height":149},{"@type":"BreadcrumbList","@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/11\/06\/freertos-addons-a-c-api-for-freertos\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.pschatzmann.ch\/home\/"},{"@type":"ListItem","position":2,"name":"FreeRTOS-addons a C++ API on Arduino"}]},{"@type":"WebSite","@id":"https:\/\/www.pschatzmann.ch\/home\/#website","url":"https:\/\/www.pschatzmann.ch\/home\/","name":"Phil Schatzmann Consulting","description":"","publisher":{"@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.pschatzmann.ch\/home\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1","name":"pschatzmann","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/08\/pschatzmann.png","url":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/08\/pschatzmann.png","contentUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/08\/pschatzmann.png","width":305,"height":305,"caption":"pschatzmann"},"logo":{"@id":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/08\/pschatzmann.png"}}]}},"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts\/5105","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/comments?post=5105"}],"version-history":[{"count":9,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts\/5105\/revisions"}],"predecessor-version":[{"id":5114,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts\/5105\/revisions\/5114"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/media\/5104"}],"wp:attachment":[{"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/media?parent=5105"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/categories?post=5105"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/tags?post=5105"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}