FreeRTOS

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

Previous topic - Next topic

tha

Naming Conventions

The RTOS kernel และ demo application source code ใช้แบบแผนต่อไปนี้:

     •  Variables
          •  ตัวแปรประเภท uint32_t ถูกนำหน้าด้วย ul, โดยที่ the 'u' หมายถึง 'unsigned' และ the 'l' หมายถึง 'long'.
          •  ตัวแปรประเภท uint16_t ถูกนำหน้าด้วย us, โดยที่ the 'u' หมายถึง 'unsigned' และ the 's' หมายถึง 'short'.
          •  ตัวแปรประเภท uint8_t ถูกนำหน้าด้วย uc, โดยที่ the 'u' หมายถึง 'unsigned' และ the 'c' หมายถึง 'char'.
          •  ตัวแปรของ non stdint types ถูกนำหน้าด้วย x. ตัวอย่างได้แก่ BaseType_t และ TickType_t, ซึ่งเป็น portable layer ที่กำหนด typedefs สำหรับ the
              natural หรือ most efficient type สำหรับ the architecture และ the type ที่ใช้เพื่อถือ the RTOS tick count ตามลำดับ.
          •  Unsigned variables ของ non stdint types มี an additional prefix u. ตัวอย่างเช่น variables of type UBaseType_t (unsigned BaseType_t)
              ถูกนำหน้าด้วย ux.
          •  Variables of type size_t ถูกนำหน้าด้วย x.> อีกด้วย
          •  Enumerated variables ถูกนำหน้าด้วย e
          •  Pointers มี an additional prefixed p, ตัวอย่างเช่น a pointer ไปยัง a uint16_t จะมี prefix pus.
          •  ตามคำแนะนำของ MISRA, unqualified standard char types ถูกอนุญาติให้เฉพาะถือ ASCII characters และถูกนำหน้าด้วย c.
          •  ตามคำแนะนำของ MISRA, variables of type char * ถูกอนุญาติให้เฉพาะถือ pointers ไปยัง ASCII strings และถูกนำหน้าด้วย pc.

tha

     •  Functions
         •  File scope static (private) functions ถูกนำหน้าด้วย prv.
         •  API functions ถูกนำหน้าด้วย return type ของพวกมัน, ตามข้อตกลงที่กำหนดสำหรับ variables, ด้วยการเพิ่มของ the prefix v สำหรับ void.
         •  API function names เริ่มด้วยชื่อของ the file ซึ่งพวกมันถูกกำหนด. ตัวอย่างเช่น vTaskDelete ถูกกำหนดใน tasks.c, และมี a void return type.

     •  Macros
         •  Macros ถูกนำหน้าด้วย the file ซึ่งพวกมันถูกกำหนด. The pre-fix เป็นตัวพิมพ์เล็ก. ตัวอย่างเช่น, configUSE_PREEMPTION ถูกกำหนดใน
             FreeRTOSConfig.h.
         •  นอกเหนือจากคำนำหน้าแล้ว มาโครจะถูกเขียนด้วยตัวพิมพ์ใหญ่ทั้งหมด และใช้ขีดล่างเพื่อแยกคำต่างๆ

tha

Data Types

เฉพาะ stdint.h types และ the RTOS's own typedefs ถูกใช้, โดยมีข้อยกเว้นต่อไปนี้:

     •  char

         ตามคำแนะนำของ MISRA, unqualified char types ถูกอนุญาติให้, แต่เฉพาะเมื่อพวกมันถูกใช้เพื่อถือ ASCII characters.

     •  char *

         ตามคำแนะนำของ MISRA, unqualified character pointers ถูกอนุญาติให้, แต่เฉพาะเมื่อพวกมันถูกใช้เพื่อชี้ไปยัง ASCII strings. นี้ขจัดความจำเป็นใน
         การระงับ benign compiler warnings เมื่อ standard library functions ที่คาดว่า char * parameters ถูกใช้, โดยเฉพาะอย่างยิ่งการพิจารณาบาง
         compilers มีค่าเริ่มต้น unqualified char types เป็น signed ในขณะที่ compilers อื่นๆมีค่าเริ่มต้น unqualified char types เป็น unsigned.


tha

มี 4 types ที่ถูกกำหนดสำหรับแต่ละ port. เหล่านี้คือ:

     •  TickType_t

         ถ้า configUSE_16_BIT_TICKS ถูกตั้งค่าเป็น non-zero (true), ดังนั้น TickType_t ถูกกำหนดเป็น an unsigned 16-bit type. ถ้า
         configUSE_16_BIT_TICKS ถูกตั้งค่าเป็น zero (false), ดังนั้น TickType_t ถูกกำหนดเป็น an unsigned 32-bit type. ดู the customisation section
         ของ the API documentation สำหรับข้อมูลเติม.

         32-bit architectures ควรตั้งค่า configUSE_16_BIT_TICKS เป็น 0 เสมอ.

     •  BaseType_t

        นี้ถูกกำหนดเป็น the most efficient, natural, type สำหรับ the architecture. ตัวอย่างเช่น, บน a 32-bit architecture BaseType_t จะถูกกำหนดเป็น a
        32-bit type. บน a 16-bit architecture BaseType_t จะถูกกำหนดเป็น a 16-bit type. ถ้า BaseType_t ถูกกำหนดเป็น char จะต้องใช้ความระมัดระวังเป็น
        พิเศษเพื่อให้แน่ใจว่า signed chars ถูกใช้สำหรับ function return values ที่สามารถเป็น negative เพื่อแสดง an error.

     •  UBaseType_t

        นี้คือ an unsigned BaseType_t.

     •  StackType_t

        กำหนดไปยัง the type ที่ใช้โดย the architecture สำหรับ items ที่เก็บบน the stack. โดยปกตินี้ควรเป็น a 16-bit type บน 16-bit architectures และ a
        32-bit type บน 32-bit architectures, แม้ว่ามีบางข้อยกเว้น. ที่ใช้ภายในโดย FreeRTOS.

tha

Style Guide

     •  Indentation(เยื้อง)

        4 space characters ถูกใช้เพื่อเยื้อง.

     •  Comments

        Comments จะไม่ผ่าน column 80, เว้นแต่พวกมันตาม, และอธิบาย, a parameter.

        C++ style double slash (//) comments ไม่ถูกใช้.

     •  Layout

        The FreeRTOS source code lay out ถูกออกแบบให้ง่ายต่อการดูและอ่านให้มากที่สุดเท่าที่เป็นได้. The code snippets ข้างล่างแสดงอย่างแรก the file
        layout, จากนั้น the C code formatting.

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

tha

https://www.freertos.org/freertos/quality.html

Implementation Quality Management

FreeRTOS ได้รับการจัดการคุณภาพอย่างเข้มงวด ไม่ใช่แค่ใน software coding standards และดูและรู้สึก, แต่ยังรวมถึงการนำไปใช้งานด้วย ตัวอย่างเช่น:

•  FreeRTOS จะไม่ดำเนินการใด ๆ ที่ไม่ได้กำหนดไว้ อย่างเช่น การเดิน a linked list, จากภายใน  a critical section หรือ interrupt.

•  เราภูมิใจอย่างยิ่งกับ the efficient software timer implementation ที่ไม่ใช้ CPU time ใดๆเว้นแต่ a timer ที่จำเป็นต่อการบริการจริงๆ. Software timers ไม่
   บรรจุตัวแปรที่จำเป็นต้องถูกนับลงเป็นศูนย์.

•  ในทำนองเดียวกัน รายการของ tasks ที่ถูกบล็อก (รอดำเนินการ) ไม่จำเป็นต้องใช้เวลาในการให้บริการเป็นระยะ.

tha

•  ตรงไปยัง task notifications ยอมให้ fast task signalling, โดยแทบไม่ต้องเสีย RAM, และสามารถถูกใช้ในส่วนใหญ่ของ inter-task และอินเตอร์รัพท์ไปยัง task
    signalling scenarios.

•  The FreeRTOS queue usage model จัดการรวมความเรียบง่ายกับความหยืดหยุ่น (ในขนาดโค้ดที่เล็ก) - คุณลักษณะที่ปกติแล้วจะไม่เกิดร่วมกัน.

•  FreeRTOS queues เป็นพื้นฐานดั้งเดิมบนส่วนบนซึ่ง communication และ synchronisation primitives อื่นถูกสร้าง. The code re-use ทำให้ขนาดโค้ดโดย
    รวมลดลงอย่างมาก ซึ่งจะช่วยในการทดสอบและช่วยให้มั่นใจได้ถึงความทนทาน.

นอกจากนี้, the TÜV SÜD certified SIL 3 SafeRTOS real time kernel เดิมเกิดมาจาก FreeRTOS, และได้รับ the most stringent analysis และ test process - ซึ่งผลลัพธ์ดังกล่าวก็ถูกป้อนกลับเข้าไปใน the FreeRTOS code base (เมื่อความร่วมกันยังคงมีอยู่).

tha

https://www.freertos.org/differences-between-officially-supported-and-contributed-FreeRTOS-code.html

'Officially Supported' and 'Contributed' FreeRTOS Code ('รองรับอย่างเป็นทางการ' และ 'สนับสนุน' FreeRTOS Code)

แต่ละ supported architecture และ compiler combination ถูกพิจารณาว่าเป็น a separate FreeRTOS port.

A demo application เป็น a project ที่รัน a specific port บน a specific hardware platform.

The microcontroller architecture specific part ของ a FreeRTOS port ถูกเรียกว่า the port layer. แต่ละ port layer เป็นอย่างใดอย่างหนึ่ง 'officially supported' หรือ 'contributed'. หน้านี้อธิบายความแตกต่างระหว่างทั้งสอง.

Officially Supported Ports

พอร์ตที่รองรับอย่างเป็นทางการ:

     •  ถูกรวมใน the main FreeRTOS .zip file release (contributed ports ตอนนี้ได้ถูกย้ายไปยัง the FreeRTOS Interactive site สำหรับ FreeRTOS
         รุ่น 6.0.4 และใหม่กว่า).

     •  รวมอย่างน้อยหนึ่ง demo application ที่ถูกทำเป็นเอกสารบน the FreeRTOS.org site.

        A demo application เป็น a pre-configured project ที่มีเป้าหมายไปยัง a specific development board และใช้ a specific tool chain. มันมีจุดประสงค์
        เพื่อยอมให้ 'ทำจาก the box' การใช้แม้สำหรับผู้ใช้ใหม่, และรวมเอาหลายตัวอย่างของวิธีที่ the FreeRTOS API สามารถถูกใช้. บาง official ports รวมเอาหลาย
        demo projects เพื่อจัดให้ผู้ใช้มีตัวเลือกของทั้ง hardware และ build environments.

     •  มีต้นกำเนิดที่ทราบ ขจัดข้อสงสัยเกี่ยวกับความเป็นเจ้าของทรัพย์สินทางปัญญา  นี้จะยอมให้ commercial licenses และสัญญาที่รองรับถูก (เป็นทางเลือก) จ่ายโดย
         WITTENSTEIN high integrity systems ภายใต้ the OpenRTOS brand.

     •  ถูกเขียนและ/หรือตรวจสอบอย่างเต็มและทดสอบโดย Amazon Web Services Inc หรือพันธมิตรที่เชื่อถือได้อย่างสมบูรณ์

     •  โดยทั่วไปและหากเป็นไปได้ จะได้รับการบำรุงรักษาและอัปเดตเมื่อ new versions of the core FreeRTOS source code หรือ new versions of the
         relevant build tools ถูกเผยแพร่.

     •  สามารถถูกสนับสนุนอย่างปกติบนการเข้าถึงได้ฟรีและมอนิเตอร์ support forum.

Contributed Ports

พอร์ตที่สนับสนุน:

     •  ถูกจัดให้มีโดย FreeRTOS community users, มากกว่า Amazon Web Services โดยตรง

     •  ถูกทำให้ใช้เป็นประโยชน์ได้ฟรีสำหรับดาวน์โหลดจาก the FreeRTOS Interactive site.

     •  สามารถถูกจัดให้มีเฉพาะภายใต้ the standard open source FreeRTOS license. Commercial licenses ไม่ถูกเสนอสำหรับ contributed code.

     •  ถูกทำเป็นเอกสารโดย the contributors เอง. ปริมาณและคุณภาพของ documentation ที่จัดให้มี ดังนั้นจะแตกต่างกันระหว่าง contributed packages.

     •  บ่อยครั้งไม่สามารถถูกสนับสนุนโดยตรงจาก Amazon Web Services.