logo资料库

161204_Mastering_the_FreeRTOS_Real_Time_Kernel-A_Hands-On_Tutori....pdf

第1页 / 共398页
第2页 / 共398页
第3页 / 共398页
第4页 / 共398页
第5页 / 共398页
第6页 / 共398页
第7页 / 共398页
第8页 / 共398页
资料共398页,剩余部分请下载后查看
Contents
List of Figures
List of Code Listings
List of Tables
List of Notation
Preface
Multitasking in Small Embedded Systems
About FreeRTOS
Value Proposition
A Note About Terminology
Why Use a Real-time Kernel?
FreeRTOS Features
Licensing, and The FreeRTOS, OpenRTOS, and SafeRTOS Family
Included Source Files and Projects
Obtaining the Examples that Accompany this Book
SECTION 1.
Chapter 1 The FreeRTOS Distribution
1.1 Chapter Introduction and Scope
Scope
1.2 Understanding the FreeRTOS Distribution
Definition: FreeRTOS Port
Building FreeRTOS
FreeRTOSConfig.h
The Official FreeRTOS Distribution
The Top Directories in the FreeRTOS Distribution
FreeRTOS Source Files Common to All Ports
FreeRTOS Source Files Specific to a Port
Header Files
1.3 Demo Applications
1.4 Creating a FreeRTOS Project
Adapting One of the Supplied Demo Projects
Creating a New Project from Scratch
1.5 Data Types and Coding Style Guide
Data Types
Variable Names
Function Names
Formatting
Macro Names
Rationale for Excessive Type Casting
Chapter 2 Heap Memory Management
2.1 Chapter Introduction and Scope
Prerequisites
Dynamic Memory Allocation and its Relevance to FreeRTOS
Options for Dynamic Memory Allocation
Scope
2.2 Example Memory Allocation Schemes
From FreeRTOS V9.0.0 FreeRTOS applications can be completely statically allocated, removing the need to include a heap memory manager
Heap_1
Heap_2
Heap_3
Heap_4
Setting a Start Address for the Array Used By Heap_4
Heap_5
The vPortDefineHeapRegions() API Function
2.3 Heap Related Utility Functions
The xPortGetFreeHeapSize() API Function
The xPortGetMinimumEverFreeHeapSize() API Function
Malloc Failed Hook Functions
Chapter 3 Task Management
3.1 Chapter Introduction and Scope
Scope
3.2 Task Functions
3.3 Top Level Task States
3.4 Creating Tasks
The xTaskCreate() API Function
Example 1. Creating tasks
Example 2. Using the task parameter
3.5 Task Priorities
3.6 Time Measurement and the Tick Interrupt
Example 3. Experimenting with priorities
3.7 Expanding the ‘Not Running’ State
The Blocked State
The Suspended State
The Ready State
Completing the State Transition Diagram
Example 4. Using the Blocked state to create a delay
The vTaskDelayUntil() API Function
Example 5. Converting the example tasks to use vTaskDelayUntil()
Example 6. Combining blocking and non-blocking tasks
3.8 The Idle Task and the Idle Task Hook
Idle Task Hook Functions
Limitations on the Implementation of Idle Task Hook Functions
Example 7. Defining an idle task hook function
3.9 Changing the Priority of a Task
The vTaskPrioritySet() API Function
The uxTaskPriorityGet() API Function
Example 8. Changing task priorities
3.10 Deleting a Task
The vTaskDelete() API Function
Example 9. Deleting tasks
3.11 Thread Local Storage
3.12 Scheduling Algorithms
A Recap of Task States and Events
Configuring the Scheduling Algorithm
Prioritized Pre-emptive Scheduling with Time Slicing
Prioritized Pre-emptive Scheduling (without Time Slicing)
Co-operative Scheduling
Chapter 4 Queue Management
4.1 Chapter Introduction and Scope
Scope
4.2 Characteristics of a Queue
Data Storage
Access by Multiple Tasks
Blocking on Queue Reads
Blocking on Queue Writes
Blocking on Multiple Queues
4.3 Using a Queue
The xQueueCreate() API Function
The xQueueSendToBack() and xQueueSendToFront() API Functions
The xQueueReceive() API Function
The uxQueueMessagesWaiting() API Function
Example 10. Blocking when receiving from a queue
4.4 Receiving Data From Multiple Sources
Example 11. Blocking when sending to a queue, and sending structures on a queue
4.5 Working with Large or Variable Sized Data
Queuing Pointers
Using a Queue to Send Different Types and Lengths of Data
4.6 Receiving From Multiple Queues
Queue Sets
The xQueueCreateSet() API Function
The xQueueAddToSet() API Function
The xQueueSelectFromSet() API Function
Example 12. Using a Queue Set
More Realistic Queue Set Use Cases
4.7 Using a Queue to Create a Mailbox
The xQueueOverwrite() API Function
The xQueuePeek() API Function
Chapter 5 Software Timer Management
5.1 Chapter Introduction and Scope
Scope
5.2 Software Timer Callback Functions
5.3 Attributes and States of a Software Timer
Period of a Software Timer
One-shot and Auto-reload Timers
Software Timer States
5.4 The Context of a Software Timer
The RTOS Daemon (Timer Service) Task
The Timer Command Queue
Daemon Task Scheduling
5.5 Creating and Starting a Software Timer
The xTimerCreate() API Function
The xTimerStart() API Function
Example 13. Creating one-shot and auto-reload timers
5.6 The Timer ID
The vTimerSetTimerID() API Function
The pvTimerGetTimerID() API Function
Example 14. Using the callback function parameter and the software timer ID
5.7 Changing the Period of a Timer
The xTimerChangePeriod() API Function
5.8 Resetting a Software Timer
The xTimerReset() API Function
Example 15. Resetting a software timer
Chapter 6 Interrupt Management
6.1 Chapter Introduction and Scope
Events
Scope
6.2 Using the FreeRTOS API from an ISR
The Interrupt Safe API
The Benefits of Using a Separate Interrupt Safe API
The Disadvantages of Using a Separate Interrupt Safe API
The xHigherPriorityTaskWoken Parameter
The portYIELD_FROM_ISR() and portEND_SWITCHING_ISR() Macros
6.3 Deferred Interrupt Processing
6.4 Binary Semaphores Used for Synchronization
The xSemaphoreCreateBinary() API Function
The xSemaphoreTake() API Function
The xSemaphoreGiveFromISR() API Function
Example 16. Using a binary semaphore to synchronize a task with an interrupt
Improving the Implementation of the Task Used in Example 16
6.5 Counting Semaphores
The xSemaphoreCreateCounting() API Function
Example 17. Using a counting semaphore to synchronize a task with an interrupt
6.6 Deferring Work to the RTOS Daemon Task
The xTimerPendFunctionCallFromISR() API Function
Example 18. Centralized deferred interrupt processing
6.7 Using Queues within an Interrupt Service Routine
The xQueueSendToFrontFromISR() and xQueueSendToBackFromISR() API Functions
Considerations When Using a Queue From an ISR
Example 19. Sending and receiving on a queue from within an interrupt
6.8 Interrupt Nesting
A Note to ARM Cortex-M and ARM GIC Users
Chapter 7 Resource Management
7.1 Chapter Introduction and Scope
Mutual Exclusion
Scope
7.2 Critical Sections and Suspending the Scheduler
Basic Critical Sections
Suspending (or Locking) the Scheduler
The vTaskSuspendAll() API Function
The xTaskResumeAll() API Function
7.3 Mutexes (and Binary Semaphores)
The xSemaphoreCreateMutex() API Function
Example 20. Rewriting vPrintString() to use a semaphore
Priority Inversion
Priority Inheritance
Deadlock (or Deadly Embrace)
Recursive Mutexes
Mutexes and Task Scheduling
7.4 Gatekeeper Tasks
Example 21. Re-writing vPrintString() to use a gatekeeper task
Chapter 8 Event Groups
8.1 Chapter Introduction and Scope
Scope
8.2 Characteristics of an Event Group
Event Groups, Event Flags and Event Bits
More About the EventBits_t Data Type
Access by Multiple Tasks
A Practical Example of Using an Event Group
8.3 Event Management Using Event Groups
The xEventGroupCreate() API Function
The xEventGroupSetBits() API Function
The xEventGroupSetBitsFromISR() API Function
The xEventGroupWaitBits() API Function
Example 22. Experimenting with event groups
8.4 Task Synchronization Using an Event Group
The xEventGroupSync() API Function
Example 23. Synchronizing tasks
Chapter 9 Task Notifications
9.1 Chapter Introduction and Scope
Communicating Through Intermediary Objects
Task Notifications—Direct to Task Communication
Scope
9.2 Task Notifications; Benefits and Limitations
Performance Benefits of Task Notifications
RAM Footprint Benefits of Task Notifications
Limitations of Task Notifications
9.3 Using Task Notifications
Task Notification API Options
The xTaskNotifyGive() API Function
The vTaskNotifyGiveFromISR() API Function
The ulTaskNotifyTake() API Function
Example 24. Using a task notification in place of a semaphore, method 1
Example 25. Using a task notification in place of a semaphore, method 2
The xTaskNotify() and xTaskNotifyFromISR() API Functions
The xTaskNotifyWait() API Function
Task Notifications Used in Peripheral Device Drivers: UART Example
Task Notifications Used in Peripheral Device Drivers: ADC Example
Task Notifications Used Directly Within an Application
Chapter 10 Low Power Support
Chapter 11 Developer Support
11.1 Chapter Introduction and Scope
11.2 configASSERT()
Example configASSERT() definitions
11.3 FreeRTOS+Trace
11.4 Debug Related Hook (Callback) Functions
Malloc failed hook
11.5 Viewing Run-time and Task State Information
Task Run-Time Statistics
The Run-Time Statistics Clock
Configuring an Application to Collect Run-Time Statistics
The uxTaskGetSystemState() API Function
The vTaskList() Helper Function
The vTaskGetRunTimeStats() Helper Function
Generating and Displaying Run-Time Statistics, a Worked Example
11.6 Trace Hook Macros
Available Trace Hook Macros
Defining Trace Hook Macros
FreeRTOS Aware Debugger Plug-ins
Chapter 12 Trouble Shooting
12.1 Chapter Introduction and Scope
12.2 Interrupt Priorities
12.3 Stack Overflow
The uxTaskGetStackHighWaterMark() API Function
Run Time Stack Checking—Overview
Run Time Stack Checking—Method 1
Run Time Stack Checking—Method 2
12.4 Inappropriate Use of printf() and sprintf()
Printf-stdarg.c
12.5 Other Common Sources of Error
Symptom: Adding a simple task to a demo causes the demo to crash
Symptom: Using an API function within an interrupt causes the application to crash
Symptom: Sometimes the application crashes within an interrupt service routine
Symptom: The scheduler crashes when attempting to start the first task
Symptom: Interrupts are unexpectedly left disabled, or critical sections do not nest correctly
Symptom: The application crashes even before the scheduler is started
Symptom: Calling API functions while the scheduler is suspended, or from inside a critical section, causes the application to crash
INDEX
Mastering the FreeRTOS™ Real Time Kernel This is the 161204 copy which does not yet cover FreeRTOS V9.0.0 or low power tick-less operation. Check http://www.FreeRTOS.org regularly for additional documentation and updates to this book, and see http://www.FreeRTOS.org/FreeRTOS-V9.html for information on FreeRTOS V9.x.x. Applications created using FreeRTOS V9.x.x can allocate all kernel objects statically at compile time, removing the need to include a heap memory manager. This text is being provided for free. In return we ask that you use the business contact email link on http://www.FreeRTOS.org/contact to provide feedback, comments and corrections. Thank you. i Click to buy NOW!PDF-XChange Viewerwww.docu-track.comClick to buy NOW!PDF-XChange Viewerwww.docu-track.comClick to buy NOW!PDF-XChange Viewerwww.docu-track.comClick to buy NOW!PDF-XChange Viewerwww.docu-track.comClick to buy NOW!PDF-XChange Viewerwww.docu-track.comClick to buy NOW!PDF-XChange Viewerwww.docu-track.com
ii Click to buy NOW!PDF-XChange Viewerwww.docu-track.comClick to buy NOW!PDF-XChange Viewerwww.docu-track.comClick to buy NOW!PDF-XChange Viewerwww.docu-track.comClick to buy NOW!PDF-XChange Viewerwww.docu-track.comClick to buy NOW!PDF-XChange Viewerwww.docu-track.comClick to buy NOW!PDF-XChange Viewerwww.docu-track.com
iii Click to buy NOW!PDF-XChange Viewerwww.docu-track.comClick to buy NOW!PDF-XChange Viewerwww.docu-track.comClick to buy NOW!PDF-XChange Viewerwww.docu-track.comClick to buy NOW!PDF-XChange Viewerwww.docu-track.comClick to buy NOW!PDF-XChange Viewerwww.docu-track.comClick to buy NOW!PDF-XChange Viewerwww.docu-track.com
Mastering the FreeRTOS™ Real Time Kernel A Hands-On Tutorial Guide Richard Barry iv Click to buy NOW!PDF-XChange Viewerwww.docu-track.comClick to buy NOW!PDF-XChange Viewerwww.docu-track.comClick to buy NOW!PDF-XChange Viewerwww.docu-track.comClick to buy NOW!PDF-XChange Viewerwww.docu-track.comClick to buy NOW!PDF-XChange Viewerwww.docu-track.comClick to buy NOW!PDF-XChange Viewerwww.docu-track.com
Pre-release 161204 Edition. All text, source code, and diagrams are the exclusive property of Real Time Engineers Ltd. unless otherwise noted inline. © Real Time Engineers Ltd. 2016. All rights reserved. http://www.FreeRTOS.org http://www.FreeRTOS.org/plus http://www.FreeRTOS.org/labs FreeRTOS™, FreeRTOS.org™ and the FreeRTOS logo are trademarks of Real Time Engineers Ltd. OPENRTOS® and SAFERTOS® are trademarks of WITTENSTEIN Aerospace and Simulation Ltd. All other brands or product names are the property of their respective holders. v Click to buy NOW!PDF-XChange Viewerwww.docu-track.comClick to buy NOW!PDF-XChange Viewerwww.docu-track.comClick to buy NOW!PDF-XChange Viewerwww.docu-track.comClick to buy NOW!PDF-XChange Viewerwww.docu-track.comClick to buy NOW!PDF-XChange Viewerwww.docu-track.comClick to buy NOW!PDF-XChange Viewerwww.docu-track.com
vi Click to buy NOW!PDF-XChange Viewerwww.docu-track.comClick to buy NOW!PDF-XChange Viewerwww.docu-track.comClick to buy NOW!PDF-XChange Viewerwww.docu-track.comClick to buy NOW!PDF-XChange Viewerwww.docu-track.comClick to buy NOW!PDF-XChange Viewerwww.docu-track.comClick to buy NOW!PDF-XChange Viewerwww.docu-track.com
To Caroline, India and Max. vii Click to buy NOW!PDF-XChange Viewerwww.docu-track.comClick to buy NOW!PDF-XChange Viewerwww.docu-track.comClick to buy NOW!PDF-XChange Viewerwww.docu-track.comClick to buy NOW!PDF-XChange Viewerwww.docu-track.comClick to buy NOW!PDF-XChange Viewerwww.docu-track.comClick to buy NOW!PDF-XChange Viewerwww.docu-track.com
viii Click to buy NOW!PDF-XChange Viewerwww.docu-track.comClick to buy NOW!PDF-XChange Viewerwww.docu-track.comClick to buy NOW!PDF-XChange Viewerwww.docu-track.comClick to buy NOW!PDF-XChange Viewerwww.docu-track.comClick to buy NOW!PDF-XChange Viewerwww.docu-track.comClick to buy NOW!PDF-XChange Viewerwww.docu-track.com
分享到:
收藏