FreeRTOS API Event Groups

Started by tha, January 28, 2022, 08:18:14 AM

Previous topic - Next topic

tha

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

xEventGroupClearBitsFromISR()
[Event Group API]

event_groups.h

BaseType_t xEventGroupClearBitsFromISR(
                                EventGroupHandle_t xEventGroup,
                                const EventBits_t uxBitsToClear );


เวอร์ชั่นของ xEventGroupClearBits() ที่สามารถถูกเรียกจาก an interrupt. The clear operation ถูกเลื่อนไปยัง the RTOS daemon task - ซึ่งเรียกอีกอย่างว่า the timer service task. The priority of the daemon task ถูกเซ็ตโดย the configTIMER_TASK_PRIORITY เซ็ตใน FreeRTOSConfig.h.

The RTOS source file FreeRTOS/source/event_groups.c ต้องถูก included ใน the build สำหรับ the xEventGroupClearBitsFromISR() function มีให้ใช้ประโยชน์.

Parameters:

     xEventGroup             The event group ซึ่ง the bits ในนั้นถูกเคลียร์. The event group ต้องถูกสร้างก่อนหน้าแล้วโดยใช้การ
                                          เรียกถึง xEventGroupCreate().

     uxBitsToClear             A bitwise value ที่แสดง the bit เดียวหรือหลาย bits เคลียร์ใน the event group. ตัวอย่างเช่น, เซ็ต
                                          uxBitsToClear เป็น 0x08 เพื่อเคลียร์เฉพาะ bit 3. เซ็ต uxBitsToClear เป็น 0x09 เพื่อเคลียร์ bit 3
                                          และ bit 0.

Returns:

     pdPASS ถ้า the operation ถูกเลื่อนไปยัง the RTOS daemon task สำเร็จ. ถ้าเป็นอย่างอื่น pdFALSE. pdFALSE จะถูกส่งคืน
     กลับเฉพาะถ้า the timer command queue เต็มเท่านั้น.

Example usage:
(ตัวอย่างโค้ดดูในลิ้งค์เอานะครับ)

tha

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

xEventGroupGetBits()
[Event Group API]

event_groups.h

EventBits_t xEventGroupGetBits( EventGroupHandle_t xEventGroup );

ส่งคืนกลับค่าปัจจุบันของ the event bits (event flags) ใน an RTOS event group. ฟังชั่นนี้ไม่สามารถถูกใช้จาก an interrupt. ดู xEventGroupGetBitsFromISR() สำหรับเวอร์ชั่นที่สามารถถูกใช้ใน an interrupt.

The RTOS source file FreeRTOS/source/event_groups.c ต้องถูก included ใน the build สำหรับ the xEventGroupGetBits() function มีให้ใช้ประโยชน์.

Parameters:

     xEventGroup               The event group ที่กำลังถูกสอบถาม. The event group ต้องถูกสร้างก่อนหน้าแล้วโดยใช้การเรียกถึง
                                            xEventGroupCreate().

Returns:

     ค่าของ the event bits ใน the event group ณ เวลาที่ xEventGroupGetBits() ถูกเรียก.

tha

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

xEventGroupGetBitsFromISR()
[Event Group API]

event_groups.h

EventBits_t xEventGroupGetBitsFromISR(
                               EventGroupHandle_t xEventGroup );


เวอร์ชั่นของ xEventGroupGetBits() ที่สามารถถูกเรียกจาก an interrupt.

The RTOS source file FreeRTOS/source/event_groups.c ต้องถูก included ใน the build สำหรับ the xEventGroupGetBitsFromISR() function มีให้ใช้ประโยชน์.

Parameters:

     xEventGroup               The event group ที่กำลังถูกสอบถาม. The event group ต้องถูกสร้างก่อนหน้าแล้วโดยใช้การเรียกถึง
                                             xEventGroupCreate().

Returns:

     ค่าของ the event bits ใน the event group ณ เวลาที่ xEventGroupGetBitsFromISR() ถูกเรียก.


tha

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

xEventGroupSync()
[Event Group API]

event_groups.h

EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup,
                              const EventBits_t uxBitsToSet,
                              const EventBits_t uxBitsToWaitFor,
                              TickType_t xTicksToWait );


เซ็ต bits (flags) แบบอะตอมมิคภายใน an RTOS event group, จากนั้นรอสำหรับการรวมกันของหลาย bits ถูกเซ็ตภายใน the same event group. ฟังชั่นนี้โดยปกติถูกใช้เพื่อซิงโครไนส์หลายๆ tasks (มักจะเรียกว่า a task rendezvous), โดยที่แต่ละ task ต้องรอให้ tasks อื่นถึง a synchronisation point ก่อนจะดำเนินการต่อ.

ฟังชั่นนี้ไม่สามารถถูกใช้จาก an interrupt.

The function จะส่งคืนกลับก่อนที่ block time ของมันจะหมดเวลาลงถ้า the bits ที่ระบุโดย the uxBitsToWait parameter ถูกเซ็ต, หรือกลายมาเป็นเซ็ตภายในเวลาดังกล่าว. ในกรณีนี้ทุก the bits ที่ระบุโดย uxBitsToWait จะถูกเคลียร์โดยอัตโนมัติก่อน the function จะส่งคืนกลับ.

The RTOS source file FreeRTOS/source/event_groups.c ต้องถูก included ใน the build สำหรับ the xEventGroupSync() function มีให้ใช้ประโยชน์.

tha

Parameters:

     xEventGroup           The event group ซึ่ง the bits ในนั้นกำลังถูกทดสอบ. The event group ต้องถูกสร้างก่อนหน้าโดยใช้การ
                                         เรียกถึง xEventGroupCreate().

     uxBitsToSet             The bit เดียวหรือหลาย bits ที่เซ็ตใน the event group ก่อนพิจารณาว่า (และอาจกำลังรอสำหรับ), ทุก
                                        the bits ที่ระบุโดย the uxBitsToWait parameter ถูกเซ็ต. ตัวอย่างเช่น, เซ็ต uxBitsToSet เป็น
                                        0x04 เพื่อเซ็ต bit 2 ภายใน the event group.

     uxBitsToWaitFor     A bitwise value ที่แสดง the bit เดียวหรือหลาย bits ที่ทดสอบภายใน the event group. ตัวอย่างเช่น,
                                       เซ็ต uxBitsToWaitFor เป็น 0x05 เพื่อรอสำหรับ bit 0 และ bit 2. เซ็ต uxBitsToWaitFor เป็น 0x07
                                       เพื่อรอสำหรับ bits 0 และ bit 1 และ bit 2 . เป็นต้น.

     xTicksToWait          จำนวนสูงสุดของเวลา (ระบุเป็น 'ticks') เพื่อรอสำหรับทุก the bits ที่ระบุโดย uxBitsToWaitFor parameter
                                       value กลายมาเป็นเซ็ต.

tha

Returns:

     ค่าของ the event group ณ เวลาที่อย่างใดอย่างหนึ่ง  the bits ที่กำลังรออยู่กลายมาเป็นเซ็ต, หรือ the block time หมดเวลาลง.
     ทดสอบ the return value เพื่อให้รู้ว่า bits ใดถูกเซ็ตบ้าง.

     ถ้า xEventGroupSync() ส่งคืนกลับเนื่องจาก timeout ของมันหมดเวลาลงดังนั้นไม่ทุก the bits ที่กำลังรออยู่จะถูกเซ็ต.   

     ถ้า xEventGroupSync() ส่งคืนกลับเนื่องจากทุก the bits ที่กำลังรออยู่ถูกเซ็ตดังนั้น the returned value คือ the event group
     value ก่อนที่ bits ใดๆจะถูกเคลียร์โดยอัตโนมัติ.

Example usage:
(ตัวอย่างโค้ดดูในลิ้งค์เอานะครับ)