FreeRTOSConfig.h

该头文件对裁剪整个 FreeRTOS 所需的功能的宏均做了定义,有些宏定义被使能,有些宏定义被失能,一开始只需要配置最简单的功能即可。

/* USER CODE BEGIN Header */
/*
 * FreeRTOS Kernel V10.0.1
 * Copyright (C) 2017 Amazon.com, Inc. or its affiliates.  All Rights Reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of
 * this software and associated documentation files (the "Software"), to deal in
 * the Software without restriction, including without limitation the rights to
 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
 * the Software, and to permit persons to whom the Software is furnished to do so,
 * subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * http://www.FreeRTOS.org
 * http://aws.amazon.com/freertos
 *
 * 1 tab == 4 spaces!
 */
/* USER CODE END Header */

#ifndef FREERTOS_CONFIG_H
#define FREERTOS_CONFIG_H

/*-----------------------------------------------------------
 * Application specific definitions.
 *
 * These definitions should be adjusted for your particular hardware and
 * application requirements.
 *
 * These parameters and more are described within the 'configuration' section of the
 * FreeRTOS API documentation available on the FreeRTOS.org web site.
 *
 * See http://www.freertos.org/a00110.html
 *----------------------------------------------------------*/

/* USER CODE BEGIN Includes */
/* Section where include file can be added */
/* USER CODE END Includes */

/* Ensure definitions are only used by the compiler, and not by the assembler. */
//针对不同的编译器调用不同的 stdint.h 文件
#if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__)
  #include <stdint.h>
  extern uint32_t SystemCoreClock;
/* USER CODE BEGIN 0 */
  extern void configureTimerForRunTimeStats(void);
  extern unsigned long getRunTimeCounterValue(void);
/* USER CODE END 0 */
#endif
// 置 1:RTOS 使用抢占式调度器;置 0:RTOS 使用协作式调度器(时间片)
#define configUSE_PREEMPTION                     1
//支持静态内存任务申请
#define configSUPPORT_STATIC_ALLOCATION          1
//支持动态内存任务申请
#define configSUPPORT_DYNAMIC_ALLOCATION         1
//写入实际的 CPU 内核时钟频率,也就是 CPU 指令执行频率,通常称为 Fclk
#define configCPU_CLOCK_HZ                       ( SystemCoreClock )
//RTOS 系统节拍中断的频率。即一秒中断的次数,每次中断 RTOS 都会进行任务调度
#define configTICK_RATE_HZ                       ((TickType_t)1000)
//可使用的最大优先级
#define configMAX_PRIORITIES                     ( 7 )
//空闲任务使用的堆栈大小
#define configMINIMAL_STACK_SIZE                 ((uint16_t)128)
//系统所有总的堆大小
#define configTOTAL_HEAP_SIZE                    ((size_t)36*1024)
//任务名字字符串长度
#define configMAX_TASK_NAME_LEN                  ( 16 )
#define configGENERATE_RUN_TIME_STATS            1
#define configUSE_TRACE_FACILITY                 1
#define configUSE_STATS_FORMATTING_FUNCTIONS     1
//系统节拍计数器变量数据类型,1 表示为 16 位无符号整形,0 表示为 32 位无符号整形
#define configUSE_16_BIT_TICKS                   0
//使用互斥信号量
#define configUSE_MUTEXES                        1
/* 设置可以注册的信号量和消息队列个数 */
#define configQUEUE_REGISTRY_SIZE                8

#define configUSE_COUNTING_SEMAPHORES            1
#define configUSE_PORT_OPTIMISED_TASK_SELECTION  1

/******************FreeRTOS 与钩子函数有关的配置选项***************************/
/* 
* 置 1:使用空闲钩子(Idle Hook 类似于回调函数);置 0:忽略空闲钩子
* 空闲任务钩子是一个函数,这个函数由用户来实现,
* FreeRTOS 规定了函数的名字和参数:void vApplicationIdleHook(void ),
* 这个函数在每个空闲任务周期都会被调用
* 对于已经删除的 RTOS 任务,空闲任务可以释放分配给它们的堆栈内存。
* 因此必须保证空闲任务可以被 CPU 执行
* 使用空闲钩子函数设置 CPU 进入省电模式是很常见的
* 不可以调用会引起空闲任务阻塞的 API 函数
*/
#define configUSE_IDLE_HOOK                      0
/* 
* 置 1:使用时间片钩子(Tick Hook);置 0:忽略时间片钩子
* 时间片钩子是一个函数,这个函数由用户来实现,
* FreeRTOS 规定了函数的名字和参数:void vApplicationTickHook(void )
* 时间片中断可以周期性的调用
* 函数必须非常短小,不能大量使用堆栈,
* 不能调用以”FromISR" 或 "FROM_ISR”结尾的 API 函数
*/
#define configUSE_TICK_HOOK                      0

/*************************FreeRTOS 与协程有关的配置选项********************/
//启用协程,启用协程以后必须添加文件 croutine.c
#define configUSE_CO_ROUTINES                    0
//协程的有效优先级数目
#define configMAX_CO_ROUTINE_PRIORITIES          ( 2 )

/************************FreeRTOS 与软件定时器有关的配置选项***************/
//启用软件定时器
#define configUSE_TIMERS 1 (30)
//软件定时器优先级
#define configTIMER_TASK_PRIORITY (configMAX_PRIORITIES-1) (31)
//软件定时器队列长度
#define configTIMER_QUEUE_LENGTH 10 (32)
//软件定时器任务堆栈大小
#define configTIMER_TASK_STACK_DEPTH (configMINIMAL_STACK_SIZE*2) (33)
/******************************FreeRTOS 可选函数配置选项******************/
#define INCLUDE_vTaskPrioritySet            1
#define INCLUDE_uxTaskPriorityGet           1
#define INCLUDE_vTaskDelete                 1
#define INCLUDE_vTaskCleanUpResources       0
#define INCLUDE_vTaskSuspend                1
#define INCLUDE_vTaskDelayUntil             0
#define INCLUDE_vTaskDelay                  1
#define INCLUDE_xTaskGetSchedulerState      1

/****************************FreeRTOS 与中断有关的配置选项****************/
#ifdef __NVIC_PRIO_BITS
 /* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */
 #define configPRIO_BITS         __NVIC_PRIO_BITS
#else
 #define configPRIO_BITS         4
#endif

/* The lowest interrupt priority that can be used in a call to a "set priority"
function. */
#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY   15

/* The highest interrupt priority that can be used by any interrupt service
routine that makes calls to interrupt safe FreeRTOS API functions.  DO NOT CALL
INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER
PRIORITY THAN THIS! (higher priorities are lower numeric values. */
#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5

/* Interrupt priorities used by the kernel port layer itself.  These are generic
to all Cortex-M ports, and do not rely on any particular library functions. */
#define configKERNEL_INTERRUPT_PRIORITY 		( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
#define configMAX_SYSCALL_INTERRUPT_PRIORITY 	( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )

/* Normal assert() semantics without relying on the provision of an assert.h
header file. */
/* USER CODE BEGIN 1 */
#define configASSERT( x ) if ((x) == 0) {taskDISABLE_INTERRUPTS(); for( ;; );}
/* USER CODE END 1 */

/********************FreeRTOS 与中断服务函数有关的配置选项**********************/
#define vPortSVCHandler    SVC_Handler
#define xPortPendSVHandler PendSV_Handler

/* IMPORTANT: This define is commented when used with STM32Cube firmware, when the timebase source is SysTick,
              to prevent overwriting SysTick_Handler defined within STM32Cube HAL */

#define xPortSysTickHandler SysTick_Handler

/* USER CODE BEGIN 2 */
/* Definitions needed when configGENERATE_RUN_TIME_STATS is on */
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS configureTimerForRunTimeStats
#define portGET_RUN_TIME_COUNTER_VALUE getRunTimeCounterValue
/* USER CODE END 2 */

/* USER CODE BEGIN Defines */
/* Section where parameter definitions can be added (for instance, to override default ones in FreeRTOS.h) */
/* USER CODE END Defines */

#endif /* FREERTOS_CONFIG_H */

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
FreeRTOSConfig.h文件是FreeRTOS的配置文件,用于配置FreeRTOS操作系统的功能和行为。用户可以根据自己的需求,在该文件中使用宏定义来定义所需的功能和配置选项。这些宏值几乎全部来自于FreeRTOS.h系统级头文件,用户可以根据需要在FreeRTOS.h中查找对应的宏值,并在FreeRTOSConfig.h中进行定义。FreeRTOS.h会检查特定功能的宏值是否在FreeRTOSConfig.h中定义,如果用户定义了指定的宏值,FreeRTOS将根据用户的定义来实现相应的功能。通过这种方式,用户可以根据自己的需求来配置FreeRTOS,而无需直接修改内核头文件FreeRTOS.h,实现了灵活的配置。 #### 引用[.reference_title] - *1* *3* [FreeRTOS 之三 全配置项(FreeRTOSConfig.h)详解、裁剪、使用示例](https://blog.csdn.net/ZCShouCSDN/article/details/54694511)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [FreeRTOS学习(二)FreeRTOSConfig.h配置文件](https://blog.csdn.net/qq_45231117/article/details/129364795)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值