STM32F1 CMSIS RTX RTOS

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

Previous topic - Next topic

tha

Header File Template: cmsis_os.h

The file cmsis_os.h เป็น a template header file สำหรับ a CMSIS-RTOS compliant Real-Time Operating System (RTOS). แต่ละ RTOS ที่สอดคล้องกับ CMSIS-RTOS จะจัดให้มี a specific cmsis_os.h header file ที่แสดงถึงการจัดให้มีใช้งานของมัน.

The file cmsis_os.h บรรจุ:

     •   CMSIS-RTOS API function definitions
     •   struct definitions for parameters and return types
     •   status and priority values used by CMSIS-RTOS API functions
     •   macros for defining threads and other kernel objects

tha

Name conventions and header file modifications

definitions ท้งหมดถูกนำหน้าด้วย os เพื่อให้ an unique name space สำหรับ CMSIS-RTOS functions. Definitions ที่ถูกนำหน้าด้วย os_ ไม่ถูกใช้ใน the application code แต่จะอยู่ใน header file นี้. definitions และ functions ทั้งหมดที่เป็นของ a module จะถูกจัดกลุ่มและมีคำนำหน้าร่วมกัน เช่น osThread.

Definitions ที่ถูกทำเครื่องด้วย CAN BE CHANGED สามารถถูกปรับให้เข้ากับความต้องการของ the actual CMSIS-RTOS implementation. definitions เหล่านี้สามารถระบุเฉพาะเจาะจงไปยัง the underlying RTOS kernel.

Definitions ที่ถูกทำเครื่องด้วย MUST REMAIN UNCHANGED ไม่สามารถถูกเปลี่ยนแปลง. มิฉะนั้น the CMSIS-RTOS implementation จะไม่เป็นไปตาม the standard อีกต่อไป. โปรดทราบว่าบาง functions เป็นทางเลือกและไม่จำเป็นต้องถูกจัดให้มีโดยทุกๆ CMSIS-RTOS implementation.

tha

Define and reference object definitions

ด้วย #define osObjectsExternal objects ถูกกำหนดเป็น external symbols. นี้ยอมให้สร้าง a consistent header file ที่ถูกใช้ตลอดทั้ง a project ดังที่แสดงด้านล่าง:

Header File


header file นี้กำหนดทุกl objects เมื่อถูก included ใน a C/C++ source file. เมื่อ #define osObjectsExternal ถุกแสดงก่อน the header file, the objects ถูกกำหนดเป็น external symbols. A single consistent header file สามารถดังนั้นถูกใช้ได้ตลอดทั้ง the whole project.

Example




Header file cmsis_os.h
(ดูในเว็บเอานะครับ)


tha

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

Function Overview

รายการต่อไปนี้จัดให้มีภาพรวมย่อๆของทุก CMSIS-RTOS functions. Functions ที่ทำเครื่องหมายด้วย $ เป็นทางเลือก. A specific CMSIS-RTOS implementation อาจไม่จัดให้มีในทุก functions, แต่นี้ถูกแสดงให้เห็นอย่างชัดเจนด้วย osFeatureXXXX defines.

Note
Functions ที่ไม่ถูกรองรับโดย the RTX Implementation, จะถูกทำเครื่องหมายด้วย (*).
(ดูในเว็บเอานะครับ สั้นๆคงจะแปลไม่ยาก)

tha

Timout Value

The timeout value ระบุจำนวนของ timer ticks จนกระทั่ง a timeout หรือ time delay ผ่านไป. The value คือขอบเขตบนและขึ้นอยู่กับเวลาจริงได้ผ่านไปเนื่องจาก the last timer tick.

สำหรับค่า 1 the system waits จนกระทั่ง the next timer tick เกิดขึ้น. นั้นหมายความว่า the actual timeout value สามารถเป็น one timer tick น้อยกว่า the specified timeout value.


tha

Calls from Interrupt Service Routines

The following CMSIS-RTOS functions สามารถถูกเรียกจาก threads และ Interrupt Service Routines (ISR):

     •   osKernelRunning
     •   osSignalSet
     •   osSemaphoreRelease
     •   osPoolAlloc, osPoolCAlloc, osPoolFree
     •   osMessagePut, osMessageGet
     •   osMailAlloc, osMailCAlloc, osMailGet, osMailPut, osMailFree


Functions ที่ไม่สามารถถูกเรียกจาก an ISR กำลังตรวจสอบ the interrupt status และ return, ในกรณีพวกมันถูกเรียกจาก an ISR context, the status code osErrorISR. ในบาง implementations, เงื่อนไขนี้อาจถูกจับโดยใช้ the HARD FAULT vector.

บาง CMSIS-RTOS implementations รองรับ CMSIS-RTOS function เรียกจากหลาย ISRs ในเวลาเดียวกัน. ถ้าเป็นไปไม่ได้, the CMSIS-RTOS จะทิ้งการเรียกโดย nested ISR functions ด้วย the status code osErrorISRRecursive.

tha

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

RTOS Validation

Arm เสนอ a Software Pack สำหรับ the CMSIS-RTOS Validation. The ARM::CMSIS-RTOS_Validation Pack บรรจุสิ่งต่อไปนี้:

     •   Source code of a CMSIS-RTOS Validation Suite พร้อมด้วย configuration file.
     •   Documentation of the CMSIS-RTOS Validation Suite.
     •   ตัวอย่างที่แสดงการใช้ของ the CMSIS-RTOS Validation Suite โดยใช้การจำลอง.

The CMSIS-RTOS Validation Suite มีให้ใช้ประโยชน์แล้วในรุ่นเบต้าและกระทำการตรวจสอบทั่วไปของ RTOS features ต่างๆ. The test cases ตรวจสอบ the functional behaviour, test invalid parameters และเรียก management functions จาก ISR.

The following CMSIS-RTOS features สามารถถูกตรวจสอบด้วยรุ่นปัจจุบัน :

     •   Thread : Create multiple threads, terminate, restart, yield, change priority
     •   Timer : Create periodic and one-shot timers
     •   GenWait : Call generic wait functions (osDelay and osWait)
     •   WaitFunc : Measure wait ticks (delay, mail, message, mutex, semaphore, signal)

นอกจากนี้ the following inter-thread communication functions สามารถถูกตรวจสอบ :

     •   Signal : Verify signal events
     •   Memory Pool : Verify memory allocation
     •   Message Queue : Exchange messages between threads
     •   Mail Queue : Exchange data between threads
     •   Mutex : Synchronize resource access
     •   Semaphore : Access shared resources

The RTOS Validation output สามารถถูกพิมพ์ไปยัง a console, output โดยทาง ITM printf, หรือ output ไปยัง a memory buffer.


tha

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

RTX Implementation

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

     •   The unified feature set ของ the CMSIS-RTOS API ง่ายต่อการแชร์ของ software components และลดความพยายามใน
          การเรียนรู้.
     •   Middleware components ที่ใช้ the CMSIS-RTOS API คือ RTOS agnostic และ CMSIS-RTOS compliant
          middleware ง่ายกว่าที่จะปรับ.
     •   This RTX implementation มีให้ใช้ประโยชน์ภายใต้ the Apache-2.0 license และสามารถถูกแจกจ่ายได้ฟรีๆด้วย project
          templates

The CMSIS-RTOS RTX จัดการทรัพยากรของ the microcontroller system และจัดให้มีใช้แนวคิดของ parallel threads ที่รันพร้อมกัน. มีข้อดีมากมายของการใช้ the CMSIS-RTOS RTX kernel.

Applications บ่อยครั้งต้องการกิจกรรมที่พร้อมกันหลายอย่าง. RTX สามารถจัดการ multiple concurrent activities ในเวลาเดียวกันเมื่อพวกมันถูกต้องการ. แต่ละ activity จะได้รับ thread หนึ่งที่แยกกันซึ่งกระทำ task หนึ่งเฉพาะและนี้ง่าย the overall program structure. The CMSIS-RTOS RTX system สามารถปรับขนาดได้และ threads เพิ่มเติมสามารถถูกเพิ่มเข้ามาได้ง่ายในภายหลัง. Threads ที่มี a priority ยอมให้การปฏิบัติเร็วขึ้นของช่วงเวลาวิกฤติของ an user application.

The CMSIS-RTOS RTX นำเสนอบริการที่จำเป็นใน many real-time applications, ตัวอย่างเช่น, periodical activation of timer functions, memory management, และ message exchange ระหว่าง threads ที่มีการจำกัดเวลา.