I have recently installed MS Visual Studio 2015 with the Arduino plugin "Visual Micro". Everything works fine, upload a sketch etc. Except when I try to compile my code when I use FreeRTOS. I downloaded the FreeRTOS libary through the Arduino IDE (library manager). Therefore(in MS VS 2015) I could chose to include the library in MS VS 2015. So I included the library in one of my sketches. Below you see my code example. Within the Arduino IDE i can compile the code and upload it to the device, but in MS VS there are some errors.
#include <timers.h>
#include <task.h>
#include <StackMacros.h>
#include <semphr.h>
#include <queue.h>
#include <projdefs.h>
#include <portmacro.h>
#include <portable.h>
#include <mpu_wrappers.h>
#include <list.h>
#include <FreeRTOSVariant.h>
#include <FreeRTOSConfig.h>
#include <event_groups.h>
#include <croutine.h>
#include <Arduino_FreeRTOS.h>
//define Tasks
void TaskBlinkSlow(void *pvParameters);
void TaskBlinkFast(void *pvParameters);
void setup()
{
/* add setup code here */
xTaskCreate(TaskBlinkSlow, "TaskSlow", 128, NULL, 1, NULL);
xTaskCreate(TaskBlinkFast, "TaskFast", 128, NULL, 2, NULL);
pinMode(13, OUTPUT);
}
void loop()
{
//Empty, things are done in tasks!!!
}
void TaskBlinkSlow(void * pvParameters)
{
for (;;) {
for (int i = 0; i < 8; i++) {
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
}
vTaskDelay(5000 / portTICK_PERIOD_MS);
}
}
void TaskBlinkFast(void * pvParameters)
{
for (;;) {
digitalWrite(13, HIGH);
delay(500);
digitalWrite(13, LOW);
delay(500);
}
}
At the end of this post you will find the short snippet of the compilers error log. Maybe someone already came around the same issue and has a quick fix.
An example debugger breakpoint has been created. To switch the demo breakpoint off, deselect Visual Micro>Tutorial Mode.
Compiling debug version of 'FreeRTOS' for 'Arduino/Genuino Uno' FreeRTOS.ino:In file included from timers.h:75:3: error: #error "include Arduino_FreeRTOS.h must appear in source files before include timers.h" :#error "include Arduino_FreeRTOS.h must appear in source files before include timers.h" timers.h:In file included from FreeRTOS.ino:from task.h:75:3: error: #error "include Arduino_FreeRTOS.h must appear in source files before include task.h" :#error "include Arduino_FreeRTOS.h must appear in source files before include task.h" task.h:In file included from timers.h:from FreeRTOS.ino:from list.h:99:3: error: #error Arduino_FreeRTOS.h must be included before list.h :#error Arduino_FreeRTOS.h must be included before list.h FreeRTOS.ino:In file included from semphr.h:74:3: error:
error "include Arduino_FreeRTOS.h" must appear in source files before "include semphr.h" :#error "include Arduino_FreeRTOS.h" must appear in
source files before "include semphr.h" semphr.h:In file included from FreeRTOS.ino:from queue.h:75:3: error: #error "include Arduino_FreeRTOS.h" must appear in source files before "include queue.h" :#error "include Arduino_FreeRTOS.h" must appear in source files before "include queue.h" FreeRTOS.ino:In file included from list.h:99:3: error: #error Arduino_FreeRTOS.h must be included before list.h :#error Arduino_FreeRTOS.h must be included before list.h task.h:In file included from timers.h:from FreeRTOS.ino:from list.h:184:22: error: 'TickType_t' does not name a type :configLIST_VOLATILE TickType_t xItemValue; *< The value being listed. In most cases this is used to sort the list in descending order. * list.h:196:22: error: 'TickType_t' does not name a type :configLIST_VOLATILE TickType_t xItemValue list.h:208:22: error: 'UBaseType_t' does not name a type :configLIST_VOLATILE UBaseType_t uxNumberOfItems list.h:386:47: error: expected initializer before 'PRIVILEGED_FUNCTION :void vListInitialise( List_t * const pxList ) PRIVILEGED_FUNCTION list.h:397:55: error: expected initializer before 'PRIVILEGED_FUNCTION :void vListInitialiseItem( ListItem_t * const pxItem ) PRIVILEGED_FUNCTION list.h:410:77: error: expected initializer before 'PRIVILEGED_FUNCTION :void vListInsert( List_t * const pxList, ListItem_t * const pxNewListItem ) PRIVILEGED_FUNCTION list.h:431:80: error: expected initializer before 'PRIVILEGED_FUNCTION :void vListInsertEnd( List_t * const pxList, ListItem_t * const pxNewListItem ) PRIVILEGED_FUNCTION list.h:446:1: error: 'UBaseType_t' does not name a type :UBaseType_t uxListRemove( ListItem_t * const pxItemToRemove ) PRIVILEGED_FUNCTION timers.h:In file included from FreeRTOS.ino:from task.h:109:20: error: ISO C++ forbids declaration of 'BaseType_t' with no type [-fpermissive] :typedef BaseType_t (*TaskHookFunction_t)( void * ) task.h:109:20: error: typedef 'BaseType_t' is initialized (use decltype instead) task.h:109:22: error: 'TaskHookFunction_t' was not declared in this scope :typedef BaseType_t (*TaskHookFunction_t)( void * ) timers.h:In file included from FreeRTOS.ino:from task.h:136:2: error: 'BaseType_t' does not name a type :BaseType_t xOverflowCount task.h:137:2: error: 'TickType_t' does not name a type :TickType_t xTimeOnEntering task.h:146:2: error: 'uint32_t' does not name a type :uint32_t ulLengthInBytes task.h:147:2: error: 'uint32_t' does not name a type :uint32_t ulParameters task.h:155:2: error: 'TaskFunction_t' does not name a type :TaskFunction_t pvTaskCode task.h:157:2: error: 'uint16_t' does not name a type :uint16_t usStackDepth task.h:159:2: error: 'UBaseType_t' does not name a type :UBaseType_t uxPriority task.h:160:2: error: 'StackType_t' does not name a type :StackType_t *puxStackBuffer task.h:161:27: error: 'portNUM_CONFIGURABLE_REGIONS' was not declared in this scope :MemoryRegion_t xRegions[ portNUM_CONFIGURABLE_REGIONS ] task.h:170:2: error: 'UBaseType_t' does not name a type :UBaseType_t xTaskNumber; * A number unique to the task. * task.h:172:2: error: 'UBaseType_t' does not name a type :UBaseType_t uxCurrentPriority; * The priority at which the task was running (may be inherited) when the structure was populated. * task.h:173:2: error: 'UBaseType_t' does not name a type :UBaseType_t uxBasePriority; * The priority to which the task will return if the task's current priority has been inherited to avoid unbounded priority inversion when obtaining a mutex. Only valid if configUSE_MUTEXES is defined as 1 in FreeRTOSConfig.h. * timers.h:In file include