STM32F1 CMSIS RTX RTOS

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

Previous topic - Next topic

tha

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



Description

The Status and Error Codes section แสดงรายการ the return values ทั้งหมดที่ the CMSIS-RTOS functions จะ return.

Enumeration Type Documentation
(ตารางดูในเว็บเอานะครับ สั้นๆคงจะแปลไม่ยาก)

tha

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

RTX Specific Functions

ส่วนนี้อธิบาย the functions ที่เฉพาะเจาะจงไปยัง CMSIS-RTOS RTX. เพิ่มเติม...



Description

The RTX kernel สามารถถูกปรับแต่งตาม different application requirements:

     •   ถ้าคุณขึ้นอยู่กับ the lowest power consumption เท่าที่เป็นไปได้, คุณจำเป็นต้องปรับ the function os_idle_demon เพื่อส่ง
          the system ไปยัง sleep mode บ่อยที่สุดเท่าที่จะเป็นไปได้. นอกจากนี้, ใช้ the low power RTX extensions os_suspend
          and os_resume เพื่อแขวน the RTX scheduler และเพื่อหยุด the SysTick timer.
     •   ถ้าคุณจำเป็นต้องระบุ an alternate hardware timer เป็น the system tick timer, คุณจำเป็นต้อง
          1.  จัดให้มีใช้ the functions os_tick_init, os_tick_ovf, os_tick_val, และทางเลือก the function os_tick_irqack.
          2.  แทนที่ the alternate timer interrupt vector ด้วย the OS_Tick_Handler ใน the Interrupt Vector Table ใน
               startup file.
     •   ถ้าคุณพยายามหา a runtime error, ใช้ the function os_error เพื่อดีบัก the error.

tha

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



Parameters
          [in]        error_code   actual error code ที่ถูกตรวจพบ.

Some system error conditions สามารถถูกตรวจพบในระหว่าง runtime. ถ้า the RTX kernel ตรวจพบ a runtime error, มันจะเรียกใช้ the runtime error function os_error.

The argument error_code ส่งผ่าน the actual error code ไปยัง function นี้ :



The function os_error ต้องบรรจุ an infinite loop เพื่อป้องกัน further program execution. คุณสามารถใช้ an emulator เพื่อก้าวข้าม infinite loop และติดตามลงใน the code ที่มี a runtime error. สำหรับ the overflow errors นี้หมายความว่าคุณจำเป็นต้องเพิ่ม the size of the object ที่เป็นสาเหตุ an overflow.

Note
          ไม่สามารถถูกเรียกใช้จาก Interrupt Service Routines.



tha



The function os_idle_demon ถูกปฏิบัติโดย the RTX kernel, เมื่อไม่มี threads อื่นพร้อมที่จะรัน. โดยเริ่มต้น, task นี้เป็น an empty end-less loop ที่ไม่ทำอะไรเลย. มันจะรอจนกระทั่ง task อื่นกลายมาเป็นพร้อมที่จะรันเท่านั้น. คุณอาจเปลี่ยน the code of the os_idle_demon function เพื่อใส่ the CPU ลงใน a power-saving or idle mode.

The default stack size สำหรับ task นี้ถูกกำหนดใน the file #RTX_Conf_CM.c. อ้างอิงถึง Thread Configuration รายการ Default Thread stack size [bytes].

Note
          ไม่สามารถถูกเรียกใช้จาก Interrupt Service Routines.


tha



Parameters
          [in]         sleep_time     ระบุระยะเวลาที่ the system เคยอยู่ใน sleep หรือ power-down mode.

The function os_resume กลับมาดำเนินงานต่อ the RTX task scheduler. คุณต้องเรียกใช้ฟังชั่นนี้หลังจากคุณเรียกใช้ os_suspend แล้วเพื่อเปิดการใช้งานใหม่ the task scheduler.

The argument sleep_time ระบุระยะเวลาที่ the system เคยอยู่ใน sleep or power-down mode. มันถูกวัดในจำนวนของ system intervals.

Note
     •   คุณสามารถเรียกใช้ฟังชั่นนี้จาก the idle task เท่านั้น.
     •   เมื่อ the system อยู่ใน power-down, the system tick timer ไม่กำลังรัน.
     •   ไม่สามารถถูกเรียกใช้จาก Interrupt Service Routines.

ดู os_suspend สำหรับ a Code Example.

tha



Returns
          จำนวนของ ticks, เป็นระยะเวลาที่ the system สามารถ sleep หรือ power-down.

The function os_suspend แขวน the RTX task scheduler. The function คำนวณ the time, เป็นระยะเวลาที่ the system ถูกยอมให้ power-down, และล็อค the task scheduler. เมื่อ the function returns, the task switches ถูก disabled. สำหรับ normal RTX operation, หลังจากการเรียกใช้ os_suspend, คุณต้องเรียกใช้l the os_resume function เพื่อเปิดการใช้งานใหม่ the OS task scheduler.

Note
     •   คุณสามารถเรียกใช้ฟังชั่นนี้จาก the idle task เท่านั้น.
     •   เมื่อ the system อยู่ใน power-down, the system tick timer ไม่กำลังรัน.
     •   ไม่สามารถถูกเรียกใช้จาก Interrupt Service Routines.

Code Example

The low power RTX ถูกควบคุมจาก the os_idle_demon. The peripheral wake-up timer ต้องถูกเริ่มต้นก่อน the system เข้าสู่ an endless loop. os_suspend คำนวณ the timeout จนกว่า the first suspended task กลายมาเป็นพร้อมทำงาน, และ returns the timeout ไปยัง the user:



The user ตั้งค่า a peripheral timer เพื่อสลีป timeout และสตาร์ท the timer. The timeout ถูกวัดใน system ticks.



เมื่อ the wake-up timer ถูก set-up และ running, the user ใส่ the system ใน power-down mode. The wake-up timer ต้องรันใน power-down mode ด้วย. All other peripherals และ the CPU อาจ power-down เพื่อลด power.



The wake-up timer, เมื่อหมดเวลา, จะสร้าง the interrupt และ wakes-up the system. ดังนั้น, มันต้องรันใน power-down mode ด้วย. The system คืนกลับมาทำงานต่อและจำเป็นต้องเรียกใช้ the function os_resume. ฟังชั่นนี้กู้คืน the RTX และเปิดการใช้งาน the scheduler ใหม่.



ไม่ว่าด้วยเหตุผลใดก็ตาม ถ้า the system ไม่ wake up ทันทีหลังจาก the wake-up interrupt, the actual sleep time จะถูกตรวจสอบและปรับเปลี่ยน.

tha



The function os_tick_init เริ่มต้น an alternate hardware timer เป็นดั่ง the system tick timer และสตาร์ทมัน. ถ้าคุณตั้งค่า OS_SYSTICK เป็น 0, ฟังชั่นนี้จะมีให้ใช้เป็นประโยนช์สำหรับการเพิ่ม the alternate timer. มัน returns the interrupt number ของ the alternative hardware timer.

Note
        -   เมื่อใช้ an alternate timer, คุณต้องเข้าสู่ the OS_Tick_Handler ใน the interrupt vector table ใน the startup file.
        -   ไม่สามารถถูกเรียกใช้จาก Interrupt Service Routines.


tha



The function os_tick_irqack รับทราบ the peripheral timer interrupt.

Note
        -    เมื่อใช้ an alternate timer, คุณต้องเข้าสู่ the OS_Tick_Handler ใน the interrupt vector table ใน the startup file.
        -    ไม่สามารถถูกเรียกใช้จาก Interrupt Service Routines.