FreeRTOS

Started by tha, October 08, 2021, 08:24:01 AM

Previous topic - Next topic

tha

configENABLE_BACKWARD_COMPATIBILITY

The FreeRTOS.h header file รวมเอาชุดของ #define macros ที่แม็ป the names of data types ที่ใช้ใน versions of FreeRTOS ก่อน version 8.0.0 กับ the names ที่ใช้ใน FreeRTOS version 8.0.0. The macros ยอมให้ application code อัปเดต the version of FreeRTOS ที่พวกมันถูกบิ้วด์จาก a pre 8.0.0 version ถึง a post 8.0.0 version โดยปราศจากการแก้ไข. การตั้งค่า configENABLE_BACKWARD_COMPATIBILITY เป็น 0 ใน FreeRTOSConfig.h จะไม่รวม the macros จาก the build,  และดังนั้นจึงอนุญาตให้ตรวจสอบได้ว่าไม่มีก่อน version 8.0.0 names ถูกใช้.

tha

configNUM_THREAD_LOCAL_STORAGE_POINTERS

เซ็ต the number of indexes ในแต่ละ task's thread local storage array.

configSTACK_DEPTH_TYPE

เซ็ต the type ที่ใช้ระบุ the stack depth ในการเรียกถึง xTaskCreate(), และในสถานที่อื่นๆทั้งหลายที่ stack sizes ถูกใช้ (ตัวอย่างเช่น, เมื่อรีเทิร์น the stack high water mark).

เวอร์ชั่นเก่าของ FreeRTOS จะระบุ stack sizes โดยใช้ตัวแปรประเภท UBaseType_t, แต่ถูกพบว่ามีข้อจำกัดเกินไปบน 8-bit microcontrollers. configSTACK_DEPTH_TYPE ได้ลบข้อจำกัดนั้นโดยเปิดการใช้งานให้ application developers ระบุประเภทที่จะใช้.

tha

configMESSAGE_BUFFER_LENGTH_TYPE

FreeRTOS Message buffers ใช้ตัวแปรประเภท configMESSAGE_BUFFER_LENGTH_TYPE เพื่อเก็บความยาวของแต่ละ message. ถ้า configMESSAGE_BUFFER_LENGTH_TYPE ไม่ถูกกำหนดดังนั้นมันจะมีค่าเริ่มต้นเป็น size_t. ถ้า the messages ที่เก็บใน a message buffer จะไม่เคยใหญ่กว่า 255 bytes ดังนั้นการกำหนด configMESSAGE_BUFFER_LENGTH_TYPE เป็น uint8_t จะบันทึก 3 bytes ต่อ message บน a 32-bit microcontroller. ในทำนองเดียวกันถ้า the messages ที่เก็บใน a message buffer จะไม่เคยใหญ่กว่า 65535 bytes ดังนั้นการกำหนด configMESSAGE_BUFFER_LENGTH_TYPE เป็น uint16_t จะบันทึก 2 bytes ต่อ message บน a 32-bit microcontroller.


tha

configSUPPORT_STATIC_ALLOCATION

ถ้า configSUPPORT_STATIC_ALLOCATION ถูกเซ็ตเป็น 1 ดังนั้น RTOS objects สามารถถูกสร้างโดยใช้ RAM ที่จัดให้มีโดย the application writer.

ถ้า configSUPPORT_STATIC_ALLOCATION ถูกเซ็ตเป็น 0 ดังนั้น RTOS objects สามารถถูกสร้างโดยใช้ RAM ที่จัดสรรจาก the FreeRTOS heap.

ถ้า configSUPPORT_STATIC_ALLOCATION ถูกทิ้งไว้ไม่กำหนดมันจะมีค่าเริ่มต้นเป็น 0.

ถ้า configSUPPORT_STATIC_ALLOCATION ถูกเซ็ตเป็น 1 ดังนั้น the application writer ต้องจัดให้มี two callback functions อีกด้วย: vApplicationGetIdleTaskMemory() เพื่อจัดให้มี the memory สำหรับใช้โดย the RTOS Idle task, และ (ถ้า configUSE_TIMERS ถูกเซ็ตเป็น 1) vApplicationGetTimerTaskMemory() เพื่อจัดให้มี memory สำหรับใช้โดย the RTOS Daemon/Timer Service task. ตัวอย่างถูกจัดให้มีข้างล่าง.

(ตัวอย่างโค้ดดูในลิ้งค์เอานะครับ)
https://www.freertos.org/a00110.html

ดู the Static Vs Dynamic Memory Allocation page สำหรับข้อมูลเพิ่มเติม.

tha

configSUPPORT_DYNAMIC_ALLOCATION

ถ้า configSUPPORT_DYNAMIC_ALLOCATION ถูกเซ็ตเป็น 1 ดังนั้น RTOS objects สามารถถูกสร้างโดยใช้ RAM ที่ถูกจัดสรรโดยอัตโนมัติจาก the FreeRTOS heap.

ถ้า configSUPPORT_DYNAMIC_ALLOCATION ถูกเซ็ตเป็น 1 ดังนั้น RTOS objects สามารถถูกสร้างโดยใช้ RAM ที่จัดให้มีโดย the application writer เท่านั้น.

ถ้า configSUPPORT_DYNAMIC_ALLOCATION ถูกทิ้งไว้ไม่กำหนดมันจะมีค่าเริ่มต้นเป็น 1.

ดู the Static Vs Dynamic Memory Allocation page สำหรับข้อมูลเพิ่มเติม.

tha

configTOTAL_HEAP_SIZE

The total amount of RAM มีให้ใช้ประโยชน์ใน the FreeRTOS heap.

ค่านี้จะถูกใช้เฉพาะถ้า configSUPPORT_DYNAMIC_ALLOCATION ถูกเซ็ตเป็น 1 และ the application ทำการใช้ของหนึ่งของ the sample memory allocation schemes ที่จัดให้มีใน the FreeRTOS source code download. ดู the memory configuration section สำหรับรายละเอียดที่มากขึ้น.

tha

configAPPLICATION_ALLOCATED_HEAP

โดยค่าเริ่มต้น the FreeRTOS heap ถูกประกาศโดย FreeRTOS และถูกวางใน memory โดย the linker. การเซ็ต configAPPLICATION_ALLOCATED_HEAP เป็น 1 ยอมให้ the heap ถูกประกาศแทนโดย the application writer, ซึ่งยอมให้ the application writer วาง the heap ที่ไหนก็ได้ที่พวกมันชอบใน memory.

ถ้า heap_1.c, heap_2.c or heap_4.c ถูกใช้, และ configAPPLICATION_ALLOCATED_HEAP ถูกเซ็ตเป็น 1, ดังนั้น the application writer ต้องจัดให้มี a uint8_t array ที่มี the exact name and dimension ดังแสดงข้างล่าง. The array จะถูกใช้เป็น the FreeRTOS heap. วิธีที่ the array ถูกวางที่ a specific memory location ขึ้นอยู่กับ on the compiler ที่กำลังถูกใช้ - โปรดดู your compiler's documentation.

uint8_t ucHeap[ configTOTAL_HEAP_SIZE ];

tha

configSTACK_ALLOCATION_FROM_SEPARATE_HEAP

ถ้า configSTACK_ALLOCATION_FROM_SEPARATE_HEAP ถูกเซ็ตเป็น 1 ดังนั้น stack สำหรับ task ใดๆที่สร้างโดยใช้ xTaskCreate or xTaskCreateRestricted API ถูกจัดสรรโดยใช้ pvPortMallocStack และปล่อยฟรีโดยใช้ vPortFreeStack function. The user จำเป็นต้องจัดให้มี thread-safe implementations of pvPortMallocStack and vPortFreeStack functions. นี้ทำให้ the user จัดสรร stacks สำหรับ tasks จาก a separate region of memory (อาจเป็น heap อื่นที่แตกต่างจาก the FreeRTOS heap).

ถ้า configSTACK_ALLOCATION_FROM_SEPARATE_HEAP ถูกทิ้งไว้ไม่กำหนดมันจะมีค่าเริ่มต้นเป็น 0.

ตัวอย่าง implementation of pvPortMallocStack and vPortFreeStack functions คือข้างล่าง :