FreeRTOS V10.0接口详解与参考指南

版权申诉
0 下载量 16 浏览量 更新于2024-10-04 收藏 2.07MB RAR 举报
资源摘要信息:"FreeRTOS是一个开源的实时操作系统内核,专为嵌入式设备设计,具有高度可裁剪性、可扩展性和可靠性。FreeRTOS提供了任务管理、时间管理、信号量、互斥量、消息队列等基本的实时操作功能。" 1. FreeRTOS基础概念 FreeRTOS是一套实时操作系统的核心,允许开发者在小型的微控制器上运行多任务处理。它的核心部分非常小,只占用几千字节的代码空间,同时拥有包括内核调度、多线程同步机制、内存管理等基本功能。 2. 任务管理 在FreeRTOS中,每个独立的执行流程被称为任务(Task)。任务管理包含了任务的创建、删除、挂起和恢复等功能。每个任务都有其自己的执行上下文和优先级,调度器会根据优先级来决定哪个任务获得执行时间。 3. 时间管理 FreeRTOS提供了时间管理的服务,包括延迟(Delay)、超时(Timeout)和软件定时器(Software Timer)。这些功能使任务能够按照预定的时间间隔或基于事件的触发来执行。 4. 信号量和互斥量 信号量(Semaphore)和互斥量(Mutex)是同步任务的机制,用于管理共享资源和任务之间的同步。信号量可以用于一般性的同步,而互斥量则是一种特殊类型的二进制信号量,它提供了一种机制来防止资源访问冲突,即互斥访问。 5. 消息队列 消息队列是一种允许任务间通过发送和接收消息来交换数据的通信机制。FreeRTOS的消息队列支持消息的FIFO(先进先出)管理,能够存储一定数量的消息,并在消息到达时通知接收任务。 6. 内存管理 FreeRTOS对内存的管理提供了不同的策略,允许用户根据应用场景选择合适的方式,包括静态内存分配和动态内存分配。静态内存分配在编译时确定,而动态内存分配则使用标准的C库函数。 7. 调度器 FreeRTOS的调度器(Scheduler)是整个系统的核心,负责根据任务的优先级分配处理器时间。FreeRTOS支持抢占式调度和时间片轮转调度。 8. 中断管理 FreeRTOS对中断的管理提供了一种灵活的方式,允许中断服务例程(ISR)与任务进行通信。通常ISR不会执行时间敏感的任务,而是将任务放入队列中由任务来执行。 9. FreeRTOS的配置选项 FreeRTOS允许用户通过宏定义进行配置,以适配不同硬件平台和应用需求。这些配置选项包括任务堆栈大小、系统时钟频率、任务的数量等。 10. 实时性能 FreeRTOS的一个主要特点是其提供的确定性实时性能。这意味着系统能够保证在特定时间内完成特定任务,这对于要求高可靠性和快速响应的应用非常重要。 11. 兼容性和可移植性 FreeRTOS具有很好的兼容性,支持多种编译器和处理器架构。其源代码是用标准C语言编写的,因此可以轻松地移植到不同的硬件和开发环境。 12. FreeRTOS的社区和支持 作为一个开源项目,FreeRTOS拥有一个活跃的开发社区,提供各种资源和支持,包括论坛、文档、教程、以及丰富的示例代码和工具。 13. 应用案例 FreeRTOS被广泛应用于多种行业,如消费电子、汽车、医疗、工业控制和航天等。由于其轻量级的特性,它非常适合用于资源受限的嵌入式设备。 总结而言,FreeRTOS参考手册V10.0为开发者提供了关于实时操作系统核心功能的详细描述和使用示例,从基础概念到高级特性都进行了全面覆盖,是学习和应用FreeRTOS不可或缺的参考资料。
2018-11-18 上传
中文的参考手册 内容 Contents5..................................................................................................................................................... 列表 Figures8............................................................................................................................................... 代码清单 Listings9....................................................................................................................................... Tables15 名单.............................................................................................................................................. 列表 Notation15........................................................................................................................................... 章节 1 关于这............................................................................................................................. Manual16 1.1Scope17............................................................................................................................................. 章节 2Task 和调度........................................................................................................................... API20 2.1 portSWITCH_TO_USER_MODE() 21.................................................................................. 2.2 vTaskAllocateMPURegions() 22........................................................................................... 2.3 xTaskAbortDelay() 25............................................................................................................. 2.4 xTaskCallApplicationTaskHook() 27.................................................................................... 2.5 xTaskCheckForTimeOut() 30................................................................................................ 2.6 xTaskCreate() 32..................................................................................................................... 2.7 xTaskCreateStatic() 37........................................................................................................... 2.8 xTaskCreateRestricted() 41................................................................................................... 2.9 vTaskDelay() 46....................................................................................................................... 2.10 vTaskDelayUntil() 48............................................................................................................... 2.11 vTaskDelete() 51..................................................................................................................... 2.12 taskDISABLE_INTERRUPTS() 53........................................................................................ 2.13 taskENABLE_INTERRUPTS() 55......................................................................................... 2.14 taskENTER_CRITICAL() 56.................................................................................................. 2.15 taskENTER_CRITICAL_FROM_ISR() 59........................................................................... 2.16 taskEXIT_CRITICAL() 61....................................................................................................... 2.1 taskEXIT_CRITICAL_FROM_ISR() 63................................................................................ 2.2 xTaskGetApplicationTaskTag() 65....................................................................................... 2.3 xTaskGetCurrentTaskHandle() 67........................................................................................ 2.4 xTaskGetIdleTaskHandle() 68............................................................................................... 2.1 xTaskGetHandle() 69.............................................................................................................. 2.2 uxTaskGetNumberOfTasks() 71........................................................................................... 2.3 vTaskGetRunTimeStats() 72................................................................................................. 2.4 xTaskGetSchedulerState() 76...............................................................................................六 2.5 uxTaskGetStackHighWaterMark() 77.................................................................................. 2.6 eTaskGetState() 79................................................................................................................. 2.7 uxTaskGetSystemState() 81.................................................................................................. 2.8 vTaskGetTaskInfo() 85........................................................................................................... 2.9 pvTaskGetThreadLocalStoragePointer() 87.......................................................................7 2.10 pcTaskGetName() 89.............................................................................................................. 2.11 xTaskGetTickCount() 90........................................................................................................ 2.12 xTaskGetTickCountFromISR() 92........................................................................................ 2.13 vTaskList() 94........................................................................................................................... 2.14 xTaskNotify() 97....................................................................................................................... 2.15 xTaskNotifyAndQuery() 100.................................................................................................. 2.16 xTaskNotifyAndQueryFromISR() 104.................................................................................. 2.17 xTaskNotifyFromISR() 108.................................................................................................... 2.18 xTaskNotifyGive() 113............................................................................................................ 2.19 vTaskNotifyGiveFromISR() 116............................................................................................ 2.20 xTaskNotifyStateClear() 119.................................................................................................. 2.21 ulTask​ ​ NotifyTake() 121.................................................................................................. 2.22 xTaskNotifyWait() 124............................................................................................................ 2.23 uxTaskPriorityGet() 127.......................................................................................................... 2.24 vTaskPrioritySet() 129............................................................................................................ 2.25 vTaskResume() 131................................................................................................................ 2.26 xTaskResumeAll() 133........................................................................................................... 2.27 xTaskResumeFromISR() 136................................................................................................ 2.28 vTaskSetApplicationTaskTag() 139...................................................................................... 2.29 vTaskSetThreadLocalStoragePointer() 141........................................................................ 2.30 vTaskSetTimeOutState() 143................................................................................................ 2.31 vTaskStartScheduler() 145.................................................................................................... 2.32 vTaskStepTick() 147............................................................................................................... 2.33 vTaskSuspend() 149............................................................................................................... 2.34 vTaskSuspendAll() 151.......................................................................................................... 2.35 taskYIELD() 153...................................................................................................................... 章节 3Queue.................................................................................................................................. API155 3.1 vQueueAddToRegistry() 156................................................................................................. 3.2 xQueueAddToSet() 158.......................................................................................................... 3.3 xQueueCreate() 160............................................................................................................... 3.4 xQueueCreateSet() 162......................................................................................................... 3.5 xQueueCreateStatic() 166..................................................................................................... 3.6 vQueueDelete() 168................................................................................................................ 3.7 pcQueueGetName() 170........................................................................................................ 3.8 xQueueIsQueueEmptyFromISR() 171................................................................................. 3.9 xQueueIsQueueFullFromISR() 172...................................................................................... 3.10 uxQueueMessagesWaiting() 173.......................................................................................... 3.11 uxQueueMessagesWaitingFromISR() 174..........................................................................六 3.12 xQueueOverwrite() 176.......................................................................................................... 3.13 xQueueOverwriteFromISR() 178.......................................................................................... 3.14 xQueuePeek() 180.................................................................................................................. 3.15 xQueuePeekFromISR() 183.................................................................................................. 3.16 xQueueReceive() 184............................................................................................................. 3.17 xQueueReceiveFromISR() 187............................................................................................. 3.18 xQueueRemoveFromSet() 190............................................................................................. 3.19 xQueueReset() 192................................................................................................................. 3.20 xQueueSelectFromSet() 193................................................................................................. 3.21 xQueueSelectFromSetFromISR() 195................................................................................. 3.22 xQueueSend() , xQueueSendToFront() , xQueueSendToBack() 197............... 3.23 xQueueSendFromISR() , xQueueSendToBackFromISR() , xQueueSendToFrontFromISR() ............................................................200 3.24 uxQueueSpacesAvailable() 204............................................................................................ 章节 4Semaphore......................................................................................................................... API206 4.1 vSemaphoreCreateBinary() 207........................................................................................... 4.2 xSemaphoreCreateBinary() 210........................................................................................... 4.3 xSemaphoreCreateBinaryStatic() 213................................................................................. 4.4 xSemaphoreCreateCounting() 216....................................................................................... 4.5 xSemaphoreCreateCountingStatic() 219............................................................................. 4.6 xSemaphoreCreateMutex() 222............................................................................................ 4.7 xSemaphoreCreateMutexStatic() 224.................................................................................. 4.8 xSemaphoreCreateRecursiveMutex() 226.......................................................................... 4.9 xSemaphoreCreateRecursiveMutexStatic() 229................................................................ 4.10 vSemaphoreDelete() 231....................................................................................................... 4.11 uxSemaphoreGetCount() 232............................................................................................... 4.12 xSemaphoreGetMutexHolder() 233...................................................................................... 4.13 xSemaphoreGive() 234.......................................................................................................... 4.14 xSemaphoreGiveFromISR() 236.......................................................................................... 4.15 xSemaphoreGiveRecursive() 239......................................................................................... 4.16 xSemaphoreTake() 242.......................................................................................................... 4.17 xSemaphoreTakeFromISR() 245.......................................................................................... 4.18 xSemaphoreTakeRecursive() 247........................................................................................ 章节 5Software 定时器................................................................................................................. API251 5.1 xTimerChangePeriod() 252.................................................................................................... 5.2 xTimerChangePeriodFromISR() 255.................................................................................... 5.3 xTimerCreate() 257................................................................................................................. 5.4 xTimerCreateStatic() 261.......................................................................................................9 5.5 xTimerDelete() 265.................................................................................................................. 5.1 xTimerGetExpiryTime() ....................................................................................................267 5.1 pcTimerGetName() 269.......................................................................................................... 5.2 xTimerGetPeriod() 270........................................................................................................... 5.3 xTimerGetTimerDaemonTaskHandle() 271........................................................................ 5.4 pvTimerGetTimerID() 272...................................................................................................... 5.5 xTimerIsTimerActive() 274..................................................................................................... 5.6 xTimerPendFunctionCall() 276.............................................................................................. 5.7 xTimerPendFunctionCallFromISR() 278..............................................................................8 5.8 xTimerReset() 281................................................................................................................... 5.9 xTimerResetFromISR() 284................................................................................................... 5.10 vTimerSetTimerID() 286......................................................................................................... 5.11 xTimerStart() 288..................................................................................................................... 5.12 xTimerStartFromISR() 290..................................................................................................... 5.13 xTimerStop() 292..................................................................................................................... 5.14 xTimerStopFromISR() 294..................................................................................................... 章节 6Event 组............................................................................................................................... API296 6.1 xEventGroupClearBits() 297.................................................................................................. 6.2 xEventGroupClearBitsFromISR() 299.................................................................................. 6.3 xEventGroupCreate() 302...................................................................................................... 6.4 xEventGroupCreateStatic() 304............................................................................................ 6.1 vEventGroupDelete() 306...................................................................................................... 6.2 xEventGroupGetBits() 307..................................................................................................... 6.1 xEventGroupGetBitsFromISR() 308..................................................................................... 6.2 xEventGroupSetBits() 309..................................................................................................... 6.3 xEventGroupSetBitsFromISR() 311..................................................................................... 6.1 xEventGroupSync() 314......................................................................................................... 6.2 xEventGroupWaitBits() 318................................................................................................... 章节 7Kernel................................................................................................................. Configuration321 7.1 FreeRTOSConfig.h322............................................................................................................... 7.2 常量开始“INCLUDE_”...........................................................................................................323 7.3 常量开始“配置”.......................................................................................................................327 附录 1: 数据类型和编码样式.................................................................................................. Guide347