stm32移植freeRTOS报错identifier “TickType_t“ is undefined;error: #20: identifier “UBaseType_t“ is undef

在stm32上移植freeRTOS时遇到错误,因头文件包含关系错乱导致‘TickType_t’和‘UBaseType_t’未定义。解决办法包括:创建并配置userRTOS.h和userRTOS.c,确保正确包含FreeRTOS.h和task.h,避免在stm32f0xx_conf.h中重复包含userRTOS.h,保持HAL库与freeRTOS的独立性。
摘要由CSDN通过智能技术生成

stm32移植freeRTOS报错error: #20: identifier "TickType_t" is undefined;error: #20: identifier "UBaseType_t" is undefined

先说问题原因

头文件包含关系错乱,导致找不到变量类型的定义。

错误的编译结果

高亮的 代码片.

compiling stm32f0xx_rtc.c...
compiling stm32f0xx_spi.c...
compiling stm32f0xx_syscfg.c...
compiling heap_4.c...
.\FreeRTOS\include\list.h(148): error:  #20: identifier "TickType_t" is undefined
      configLIST_VOLATILE TickType_t xItemValue;          /*< The value being listed.  In most cases this is used to sort the list in ascending order. */
.\FreeRTOS\include\list.h(176): error:  #20: identifier "UBaseType_t" is undefined
      volatile UBaseType_t uxNumberOfItems;
.\FreeRTOS\include\list.h(434): error:  #130: expected a "{"
  void vListInitialise( List_t * const pxList ) PRIVILEGED_FUNCTION;
.\FreeRTOS\include\task.h(97): warning:  #12-D: parsing restarts here after previous syntax error
  {
   
.\FreeRTOS\include\task.h(98): error:  #20: identifier "eRunning" is undefined
      eRunning = 0, /* A task is querying the state of itself, so must be running. */
.\FreeRTOS\include\task.h(99): error:  #20: identifier "eReady" is undefined
      eReady,       /* The task being queried is in a ready or pending ready list. */
.\FreeRTOS\include\task.h(100): error:  #20: identifier "eBlocked" is undefined
      eBlocked,     /* The task being queried is in the Blocked state. */
.\FreeRTOS\include\task.h(101): error:  #20: identifier "eSuspended" is undefined
      eSuspended,   /* The task being queried is in the Suspended state, or is in the Blocked state with an infinite time out. */
.\FreeRTOS\include\task.h(102): error:  #20: identifier "eDeleted" is undefined
      eDeleted,     /* The task being queried has been deleted, but its TCB has not yet been freed. */
.\FreeRTOS\include\task.h(103): error:  #20: identifier "eInvalid" is undefined
      eInvalid      /* Used as an 'invalid state' value. */
.\FreeRTOS\include\task.h(104): error:  #65: expected a ";"
  } eTaskState;
.\FreeRTOS\include\task.h(104): error:  #77-D: this declaration has no storage class or type specifier
  } eTaskState;
.\FreeRTOS\include\task.h(121): error:  #20: identifier "BaseType_t" is undefined
      BaseType_t xOverflowCount;
.\FreeRTOS\include\task.h(122): error:  #20: identifier "TickType_t" is undefined
      TickType_t xTimeOnEntering;
.\FreeRTOS\include\task.h(140): error:  #20: identifier "TaskFunction_t" is undefined
      TaskFunction_t pvTaskCode;
.\FreeRTOS\include\task.h(142): error:  #20: identifier "configSTACK_DEPTH_TYPE" is undefined
      configSTACK_DEPTH_TYPE usStackDepth;
.\FreeRTOS\include\task.h(144): error:  #20: identifier "UBaseType_t" is undefined
      UBaseType_t uxPriority;
.\FreeRTOS\include\task.h(145): error:  #20: identifier "StackType_t" is undefined
      StackType_t * puxStackBuffer;
.\FreeRTOS\include\task.h(146): error:  #20: identifier "portNUM_CONFIGURABLE_REGIONS" is undefined
      MemoryRegion_t xRegions[ portNUM_CONFIGURABLE_REGIONS ];
.\FreeRTOS\include\task.h(156): error:  #20: identifier "TaskHandle_t" is undefined
      TaskHandle_t xHandle;                         /* The handle of the task to which the rest of the information in the structure relates. */
.\FreeRTOS\include\task.h(158): error:  #20: identifier "UBaseType_t" is undefined
      UBaseType_t xTaskNumber;                      /* A number unique to the task. */
.\FreeRTOS\include\task.h(159): error:  #757: variable "eTaskState"  is not a type name
      eTaskState eCurrentState;                     /* The state in which the task existed when the structure was populated. */
.\FreeRTOS\include\task.h(160): error:  #20: identifier "UBaseType_t" is undefined
      UBaseType_t uxCurrentPriority;                /* The priority at which the task was running (may be inherited) when the structure was populated. */
.\FreeRTOS\include\task.h(161): error:  #20: identifier "UBaseType_t" is undefined
      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. */
.\FreeRTOS\include\task.h(162): error:  #20: identifier "configRUN_TIME_COUNTER_TYPE" is undefined
      configRUN_TIME_COUNTER_TYPE ulRunTimeCounter; /* The total run time allocated to the task so far, as defined by the run time stats clock.  See https://www.FreeRTOS.org/rtos-run-time-stats.html.  Only valid when configGENERATE_RUN_TIME_STATS is defined as 1 in FreeRTOSConfig.h. */
.\FreeRTOS\include\task.h(163): error:  #20: identifier "StackType_t" is undefined
      StackType_t * pxStackBase;                    /* Points to the lowest address of the task's stack area. */
.\FreeRTOS\include\task.h(168): error:  #20: identifier "configSTACK_DEPTH_TYPE" is undefined
      configSTACK_DEPTH_TYPE usStackHighWaterMark;  /* The minimum amount of stack space that has remained for the task since the task was created.  The closer this value is to zero the closer the task has come to overflowing its stack. */
.\FreeRTOS\include\task.h(696): error:  #20: identifier "TaskHandle_t" is undefined
  void vTaskAllocateMPURegions( TaskHandle_t xTask,
.\FreeRTOS\include\task.h(697): error:  #130: expected a "{"
                                const MemoryRegion_t * const pxRegions ) PRIVILEGED_FUNCTION;
.\FreeRTOS\include\portable.h(136): warning:  #12-D: parsing restarts here after previous syntax error
  {
   
.\FreeRTOS\include\portable.h(137): warning:  #177-D: variable "pucStartAddress"  was declared but never referenced
      uint8_t * pucStartAddress;
.\FreeRTOS\include\portable.h(138): warning:  #177-D: variable "xSizeInBytes"  was declared but never referenced
      size_t xSizeInBytes;
.\FreeRTOS\include\portable.h(139): error:  #77-D: this declaration has no storage class or type specifier
  } HeapRegion_t;
.\FreeRTOS\include\portable.h(164): error:  #757: variable "HeapRegion_t"  is not a type name
  void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions ) PRIVILEGED_FUNCTION;
FreeRTOS\port\MemMang\heap_4.c: 4 warnings, 30 errors
compiling stm32f0xx_usart.c...
compiling stm32f0xx_wwdg.c...
compiling stm32f0xx_tim.c...
compiling croutine.c...
.\FreeRTOS\include\list.h(148): error:  #20: identifier "TickType_t" is undefined
      configLIST_VOLATILE TickType_t xItemValue;          /*< The value being listed.  In most cases this is used to sort the list in ascending order. */
.\FreeRTOS\include\list.h(176): error:  #20: identifier "UBaseType_t" is undefined
      volatile UBaseType_t uxNumberOfItems;
.\FreeRTOS\include\list.h(434): error:  #130: expected a "{"
  void vListInitialise( List_t * const pxList ) PRIVILEGED_FUNCTION;
.\FreeRTOS\include\task.h(97): warning:  #12-D: parsing restarts here after previous syntax error
  {
   
.\FreeRTOS\include\task.h(98): error:  #20: identifier "eRunning" is undefined
      eRunning = 0, /* A task is querying the state of itself, so must be running. */
.\FreeRTOS\include\task.h(99): error:  #20: identifier "eReady" is undefined
      eReady,       /* The task being queried is in a ready or pending ready list. */
.\FreeRTOS\include\task.h(100): error:  #20: identifier "eBlocked" is undefined
      eBlocked,     /* The task being queried is in the Blocked state. */
.\FreeRTOS\include\task.h(101): error:  #20: identifier "eSuspended" is undefined
      eSuspended,   /* The task being queried is in the Suspended state, or is in the Blocked state with an infinite time out. */
.\FreeRTOS\include\task.h(102): error:  #20: identifier "eDeleted" is undefined
      eDeleted,     /* The task being queried has been deleted, but its TCB has not yet been freed. */
.\FreeRTOS\include\task.h(103): error:  #20: identifier "eInvalid" is undefined
      eInvalid      /* Used as an 'invalid state' value. */
.\FreeRTOS\include\task.h(104): error:  #65: expected a ";"
  } eTaskState;
.\FreeRTOS\include\task.h(104): error:  #77-D: this declaration has no storage class or type specifier
  } eTaskState;
.\FreeRTOS\include\task.h(121): error:  #20: identifier "BaseType_t" is undefined
      BaseType_t xOverflowCount;
.\FreeRTOS\include\task.h(122): error:  #20: identifier "TickType_t" is undefined
      TickType_t xTimeOnEntering;
.\FreeRTOS\include\task.h(140): error:  #20: identifier "TaskFunction_t" is undefined
      TaskFunction_t pvTaskCode;
.\FreeRTOS\include\task.h(142): error:  #20: identifier "configSTACK_DEPTH_TYPE" is undefined
      configSTACK_DEPTH_TYPE usStackDepth;
.\FreeRTOS\include\task.h(144): error:  #20: identifier "UBaseType_t" is undefined
      UBaseType_t uxPriority;
.\FreeRTOS\include\task.h(145): error:  #20: identifier "StackType_t" is undefined
      StackType_t * puxStackBuffer;
.\FreeRTOS\include\task.h(146): error:  #20: identifier "portNUM_CONFIGURABLE_REGIONS" is undefined
      MemoryRegion_t xRegions[ portNUM_CONFIGURABLE_REGIONS ];
.\FreeRTOS\include\task.h(156): error:  #20: identifier "TaskHandle_t" is undefined
      TaskHandle_t xHandle;                         /* The handle of the task to which the rest of the information in the structure relates. */
.\FreeRTOS\include\task.h(158): error:  #20: identifier "UBaseType_t" is undefined
      UBaseType_t xTaskNumber;                      /* A number unique to the task. */
.\FreeRTOS\include\task.h
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值