freertos是支持自定义裁剪的, 用户可用根据实际硬件资源, 进行合适裁剪使得占用合适, 裁剪主要是通过配置文件实现, 本文借鉴了原子的配置, 并且根据实际做出的配置, 配置文件如下:
#ifndef freertos_config_h#define freertos_config_h#include gd32f10x.h#include hal_printf.h// 针对不同的编译器调用不同的stdint.h文件#if defined(__iccarm__) || defined(__cc_arm) || defined(__gnuc__)#include extern uint32_t systemcoreclock;#endif// 断言#define vassertcalled(char, int) usert_printf(usart0, error:%s,%d, char, int)#define configassert(x) if ((x) == 0) vassertcalled(__file__, __line__)/***************************************************************************************************************//* freertos基础配置配置选项 *//***************************************************************************************************************/#define configuse_preemption 1 // 1使用抢占式内核,0使用协程#define configuse_time_slicing 1 // 1使能时间片调度(默认式使能的)#define configuse_port_optimised_task_selection 1 // 1启用特殊方法来选择下一个要运行的任务 // 一般是硬件计算前导零指令,如果所使用的 // mcu没有这些硬件指令的话此宏应该设置为0!#define configuse_tickless_idle 0 // 1启用低功耗tickless模式#define configuse_queue_sets 1 // 为1时启用队列#define configcpu_clock_hz (systemcoreclock) // cpu频率#define configtick_rate_hz (1000) // 时钟节拍频率,这里设置为1000,周期就是1ms#define configmax_priorities (32) // 可使用的最大优先级#define configminimal_stack_size ((unsigned short)130) // 空闲任务使用的堆栈大小#define configmax_task_name_len (16) // 任务名字字符串长度#define configuse_16_bit_ticks 0 // 系统节拍计数器变量数据类型, // 1表示为16位无符号整形,0表示为32位无符号整形#define configidle_should_yield 1 // 为1时空闲任务放弃cpu使用权给其他同优先级的用户任务#define configuse_task_notifications 1 // 为1时开启任务通知功能,默认开启#define configuse_mutexes 1 // 为1时使用互斥信号量#define configqueue_registry_size 8 // 不为0时表示启用队列记录,具体的值是可以 // 记录的队列和信号量最大数目。#define configcheck_for_stack_overflow 0 // 大于0时启用堆栈溢出检测功能,如果使用此功能 // 用户必须提供一个栈溢出钩子函数,如果使用的话 // 此值可以为1或者2,因为有两种栈溢出检测方法。#define configuse_recursive_mutexes 1 // 为1时使用递归互斥信号量#define configuse_malloc_failed_hook 0 // 1使用内存申请失败钩子函数#define configuse_application_task_tag 0#define configuse_counting_semaphores 1 // 为1时使用计数信号量/***************************************************************************************************************//* freertos与内存申请有关配置选项 *//***************************************************************************************************************/#define configsupport_dynamic_allocation 1 // 支持动态内存申请#define configtotal_heap_size ((size_t)(20 * 1024)) // 系统所有总的堆大小/***************************************************************************************************************//* freertos与钩子函数有关的配置选项 *//***************************************************************************************************************/#define configuse_idle_hook 0 // 1,使用空闲钩子;0,不使用#define configuse_tick_hook 0 // 1,使用时间片钩子;0,不使用/***************************************************************************************************************//* freertos与运行时间和任务状态收集有关的配置选项 *//***************************************************************************************************************/#define configgenerate_run_time_stats 0 // 为1时启用运行时间统计功能#define configuse_trace_facility 1 // 为1启用可视化跟踪调试#define configuse_stats_formatting_functions 1 // 与宏configuse_trace_facility同时为1时会编译下面3个函数 // prvwritenametobuffer(),vtasklist(), // vtaskgetruntimestats()/***************************************************************************************************************//* freertos与协程有关的配置选项 *//***************************************************************************************************************/#define configuse_co_routines 0 // 为1时启用协程,启用协程以后必须添加文件croutine.c#define configmax_co_routine_priorities (2) // 协程的有效优先级数目/***************************************************************************************************************//* freertos与软件定时器有关的配置选项 *//***************************************************************************************************************/#define configuse_timers 1 // 为1时启用软件定时器#define configtimer_task_priority (configmax_priorities - 1) // 软件定时器优先级#define configtimer_queue_length 5 // 软件定时器队列长度#define configtimer_task_stack_depth (configminimal_stack_size * 2) // 软件定时器任务堆栈大小/***************************************************************************************************************//* freertos可选函数配置选项 *//***************************************************************************************************************/#define include_xtaskgetschedulerstate 1#define include_vtaskpriorityset 1#define include_uxtaskpriorityget 1#define include_vtaskdelete 1#define include_vtaskcleanupresources 1#define include_vtasksuspend 1#define include_vtaskdelayuntil 1#define include_vtaskdelay 1#define include_etaskgetstate 1#define include_xtimerpendfunctioncall 1/***************************************************************************************************************//* freertos与中断有关的配置选项 *//***************************************************************************************************************/#ifdef __nvic_prio_bits#define configprio_bits __nvic_prio_bits#else#define configprio_bits 4#endif#define configlibrary_lowest_interrupt_priority 15 // 中断最低优先级#define configlibrary_max_syscall_interrupt_priority 5 // 系统可管理的最高中断优先级#define configkernel_interrupt_priority (configlibrary_lowest_interrupt_priority << (8 - configprio_bits))#define configmax_syscall_interrupt_priority (configlibrary_max_syscall_interrupt_priority << (8 - configprio_bits))/***************************************************************************************************************//* freertos与中断服务函数有关的配置选项 *//***************************************************************************************************************/#define vportsvchandler svc_handler#define xportpendsvhandler pendsv_handler#define xportsystickhandler systick_handler#endif /* freertos_config_h */
裁剪的本质就是通过宏来配置, 减少编译后生成文件的占用大小, 从而减少rtos的占用空间!
Intel技术人员:未来可能出现千内核处理器
智慧物流市场规模将超万亿 电商平台与物流企业纷纷布局来抢占先机
今年AMD服务器CPU市场份额有望提升到10%
一文简述976nm泵浦技术的前生今世
【广州华锐互动】智慧楼宇可视化为智慧城市升级提供新契机
FreeRTOS|自定义裁剪
贴片式电阻器的制作工艺解析
重庆飞狐航空为无人机爱好者科普宣讲和试飞表演
PTVA120501EA-V1高功率放大器
重庆电信公司召开了5G二期工程百日攻坚动员部署会
分享一个互补10W MOSFET放大器电路
消防控制柜作为一种消防安全设备,它的自检方式有几种
反制与拦截无人机技术解析
AMOLED详解:amoled和oled的区别
为什么在ADS中共轭匹配也可以用S11参数来衡量?
贞光科技 | 智能汽车芯片梳理
专门为游戏打造的游戏本 神舟战神游戏本K680D-G4D1就是这么贴心
中国使用人工智能技术来改善春运出行体验
单脉冲捕获驱动电路设计
荣耀10青春版与小米8青春版自拍对比 哪个最好