STM32F1 CMSIS RTX RTOS

Started by tha, August 02, 2021, 08:34:26 AM

Previous topic - Next topic

tha

ลองค้นกูเกิ้ล "CMSIS" โหลดเอา CMSIS 5 กับ CMSIS 4 ใน Github มาเลย จะมี RTX RTOS อยู่ CMSIS 5 มันเปิดเอกสารไม่ได้ ผมก็จะแปลตามเอกสารใน STM32CubeF1-master เลย RTOS น่าจะเป็นรุ่นล่าสุดแล้ว ลองๆดูกัน มีอะไรแนะนำก็ว่ามานะครับ

tha

https://arm-software.github.io/CMSIS_5/RTOS/html/index.html

CMSIS-RTOS Documentation

คู่มือนี้อธิบาย CMSIS-RTOS API เวอร์ชัน 1 และการจัดมีให้ใช้งานอ้างอิง CMSIS-RTOS RTX ซึ่งถูกออกแบบมาสำหรับ Cortex-M processor-based devices. The RTOS kernel สามารถถูกใช้สำหรับการสร้าง applications ที่ทำงานหลายอย่างพร้อมกัน.  tasks เหล่านี้ถูกปฏิบัติโดย threads ที่ทำงานใน a quasi-parallel fashion.

แม้ว่าจะเป็นไปได้อย่างแน่นอนที่จะสร้าง real-time applications โดยไม่ต้องใช้ an RTOS (โดยปฏิบัติหนึ่ง tasks หรือมากกว่าใน a loop), มี scheduling, maintenance, and timing มากมายปล่อยออกมาที่สามารถถูกแก้ไขได้ดียิ่งขึ้นด้วย an RTOS. ตัวอย่างเช่น, an RTOS เปิดการใช้งาน flexible scheduling of system resources เหมือน CPU and memory, และเสนอวิธีเพื่อติดต่อระหว่าง threads.

CMSIS-RTOS API programs ถูกเขียนโดยใช้ standard C/C++ constructs และถูก compiled ด้วย the ARMCC, GCC, or IAR Compiler. The cmsis_os.h header file กำหนด functions และ macros ที่ยอมให้การประกาศ tasks และการเข้าถึงทุก RTOS features นั้นง่าย.

tha

คู่มือนี้ประกอบด้วยส่วนต่อไปนี้:

•   Revision History : เอกสารที่เปลี่ยนแปลงที่ทำในแต่ละเวอร์ชันสำหรับ CMSIS-RTOS API and RTX.
•   Generic RTOS Interface : จัดให้มีภาพรวมเกี่ยวกับ the CMSIS-RTOS API.
•   Using a CMSIS-RTOS Implementation : จัดให้มีคำแนะนำทั่วไปสำหรับการใช้ a CMSIS-RTOS API compliant implementation.
•   Function Overview : แสดงรายการ the CMSIS-RTOS API functions รวมถึง RTX-specific extensions.
•   RTOS Validation : อธิบาย the Software Pack ที่สามารถถูกใช้ตรวจสอบ a CMSIS-RTOS implementation.
•   RTX Implementation : จัดทำเอกสาร the open-source implementation CMSIS-RTOS RTX

Note

An extended version ของ the CMSIS-RTOS API มีให้ใช้ประโยชน์ใน CMSIS-RTOS v2.


tha

CMSIS-RTOS in ARM::CMSIS Pack

ไฟล์ต่อไปนี้ที่เกี่ยวข้องกับ CMSIS-RTOS ถูกแสดงใน the ARM::CMSIS Pack directories:


tha

https://arm-software.github.io/CMSIS_5/RTOS/html/genRTOSIF.html

Generic RTOS Interface

The CMSIS-RTOS API เป็น a generic RTOS interface สำหรับ Arm® Cortex®-M processor-based devices. CMSIS-RTOS จัดให้มี a standardized API สำหรับ software components ที่ต้องการ RTOS functionality  และดังนั้นให้ประโยชน์อย่างมากต่อ the users และ the software industry.

     •   CMSIS-RTOS จัดให้มี basic features ที่ถูกต้องการใน applications หรือ technologies มากมายอย่างเช่น UML หรือ Java
         (JVM).
     •   The unified feature set ของ the CMSIS-RTOS API ง่ายต่อการแชร์ software components และลดความพยายามในการ
         เรียนรู้.
     •   Middleware components ที่ใช้ the CMSIS-RTOS API เป็น RTOS agnostic. CMSIS-RTOS compliant middleware
         ง่ายกว่าที่จะปรับ.
     •   Standard project templates (อย่างเช่น motor control) ของ the CMSIS-RTOS API อาจถูกส่งพร้อมกับการมีให้ใช้
         ประโยชน์ CMSIS-RTOS implementations แบบฟรีๆ.

Note
     The CMSIS-RTOS API กำหนด a minimum feature set. Implementations ด้วย extended features อาจถูกจัดให้โดย
     RTOS vendors.


tha

A typical CMSIS-RTOS API implementation อินเตอร์เฟสไปยัง an existing real-time Kernel. The CMSIS-RTOS API จัดให้มี the following attributes and functionalities:

•   Function names, identifiers, and parameters เป็นคำอธิบายและง่ายต่อการเข้าใจ. The functions มีประสิทธิภาพและหยืดหยุ่น
    ซึ่งลดจำนวนของฟังชั่นที่เปิดเผยต่อ the user.
•   Thread Management ยอมให้คุณ define, create, และ control threads.
•   Interrupt Service Routines (ISR) สามารถเรียกใช้ some CMSIS-RTOS functions. เมื่อ a CMSIS-RTOS function
    ไม่สามารถถูกเรียกใช้จาก ISR context, มันจะปฏิเสธการร้องขอ.   
•   Three different thread event types ที่รองรับการสื่อสารระหว่างหลายๆ threads และ/หรือ ISR
      •   Signal: คือ a flag ที่อาจถูกใช้เพื่อแสดงให้เห็นเงื่อนไขพิเศษไปยัง a thread. Signals สามารถถูกแก้ไขใน an ISR
           หรือถูกเซ็ตมาจาก threads อื่นๆ.
      •   Message: คือ a 32-bit value ที่สามารถถูกส่งไปยัง a thread หรือ an ISR. Messages ถูกบัฟเฟอร์ใน a queue.
           The message type และ queue size ถูกกำหนดใน a descriptor.
      •   Mail: คือ a fixed-size memory block ที่สามารถถูกส่งไปยัง a thread หรือ an ISR. Mails ถูกบัฟเฟอร์ใน a queue
           และ memory allocation ถูกจัดให้. The mail type และ queue size ถูกกำหนดใน a descriptor.
•   Mutexes and Semaphores ถูกรวมเข้าด้วยกัน.
•   CPU time สามารถถูกกำหนดเวลาด้วยฟังชั่นต่อไปนี้ :
      •   A timeout parameter ถูกรวมเข้าในหลาย CMSIS-RTOS functions เพื่อหลีกเลี่ยง system lockup. เมื่อ a
           timeout ถูกระบุ, the system คอยนกระทั่ง a resource มีให้ใช้ประโยชน์หรือ an event เกิดขึ้น. ในขณะที่กำลังคอย, threads
           อื่นๆถูก scheduled.
     •   The osDelay function ใส่ a thread ลงในสถานะ WAITING เป็นเวลา a specified period of time.
     •   The generic osWait function จะรอสำหรับ events ที่ถูกกำหนดให้กับ a thread.
     •   The osThreadYield จัดให้มี co-operative thread switching และส่งผ่านการทำงานไปยัง thread อื่นที่มีลำดับความ
          สำคัญเดียวกัน.

tha

The CMSIS-RTOS API ถูกออกแบบเพื่อรวมทางเลือก multi-processor systems และ/หรือ access protection โดยทาง the Cortex-M Memory Protection Unit (MPU).

ในบาง RTOS implementations threads อาจปฏิบัติบน processors ที่แตกต่างกันและ Mail and Message queues สามารถดังนั้นอาศัยอยู่ใน shared memory resources

The CMSIS-RTOS API สนับสนุน the software industry พัฒนา RTOS implementations ที่มีอยู่. Kernel objects ถูกกำหนดและเข้าถึงโดยใช้ macros. นี้ยอมให้เกิดความแตกต่าง. RTOS implementations สามารถมีความแตกต่างและปรับให้เหมาะในด้านต่างๆสู่ the Cortex-M processors. คุณลักษณะเสริมอาจเป็นตัวอย่างเช่น

     •   Generic wait function; i.e. with support of time intervals.
     •   Support of the Cortex-M Memory Protection Unit (MPU).
     •   Zero-copy mail queue.
     •   Support of multi-processor systems.
     •   Support of a DMA controller.
     •   Deterministic context switching.
     •   Round-robin context switching.
     •   Deadlock avoidance, for example with priority inversion.
     •   Zero interrupt latency by using the Cortex-M3/M4 instructions LDREX and STREX.

tha

https://arm-software.github.io/CMSIS_5/RTOS/html/usingOS.html

Using a CMSIS-RTOS Implementation

A CMSIS-RTOS implementation โดยทั่วไปถูกจัดให้มีเป็น a library. เพื่อเพิ่ม the RTOS functionality ไปยัง an existing CMSIS-based application, the RTOS library (และโดยทั่วไป a configuration file) จำเป็นต้องถูกเพิ่ม. The available functionality ของ the RTOS library ถูกกำหนดใน the header file cmsis_os.h ที่ระบุสำหรับแต่ละ CMSIS-RTOS implementation.



ขึ้นอยู่กับ the CMSIS-RTOS implementation, การดำเนินการอาจสตาร์ทด้วย the main function เป็น the first thread. นี้มีประโยชน์ที่ an application programmer อาจใช้ middleware libraries อื่นที่สร้าง threads อยู่ภายใน, แต่ส่วนที่เหลือของ the user application ใช้ the main thread เท่านั้น. ดังนั้น, การใช้ the RTOS จึงไม่ปรากฎแก่ the application programmer, แต่ libraries สามารถใช้ CMSIS-RTOS features.

เมื่อ the files ถูกเพิ่มลงใน a project, the user สามารถเริ่มการทำงานด้วย the CMSIS-RTOS functions. A code example ถูกจัดให้มีข้างล่าง:

Code Example
(ดูในเว็บเอานะครับ)