Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6Event Flags • Used for synchronization of tasks with the occurrence of multiples of events • Events are grouped o 8, 16 or 32 bits per
Trang 1Introduction to uCOS-II V2.6
Trang 2Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6
About SwiftACT
• A Technology services startup company
o Under establishment
• Areas of specialties:
o Mobile telecommunication services development
o Embedded systems development
• Types of services:
o Consultation
o Managed services
o Sourcing
o Training
Trang 3Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6
About Me
• Graduated 2004
o ECE, ASU: 5 yrs distinction
• 5+ years in embedded systems development
o SDLC, Apps, MW, DD, Porting,
• 3+ years in SW engineering
o PSP, CMMI, Systematic reuse,
• 3+ years in SW testing
o IBM certified, ISTQB certified,
Trang 4Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6
Copyright
• Materials in this course is the property of Amr Ali Abdel-Naby
• Reproduction or transmission of the materials in any manner without the copyright owner permission is a law violation
Trang 5Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6
Course References
• MicroC/OS-II The Real-Time Kernel, 2nd Edition, by Jean J Labrosse
Trang 6Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6
Outline
• Introduction to µC/OS-II
• Kernel Structure
• Task Management
• Time Management
• Semaphore Management
• Mutual Exclusion Semaphores
• Event Flag Management
• Message Mailbox Management
• Message Queue Management
• Memory Management
Trang 7Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6
Outline
• Introduction to µC/OS-II
• Kernel Structure
• Task Management
• Time Management
• Semaphore Management
• Mutual Exclusion Semaphores
• Event Flag Management
• Message Mailbox Management
• Message Queue Management
• Memory Management
Trang 8Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6
Event Flags
• Used for synchronization of tasks with the occurrence of multiples of events
• Events are grouped
o 8, 16 or 32 bits per group
• Types of synchronization
o ORed: Any event occurred
o ANDed: All events occured
Trang 9Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6
Event Flags cont’d
Trang 10Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6
Event Flags Management APIs
OSFlagPost()
OSFlagCreate () OSFlagDel() OSFlagPost () OSFlagAccept ()
OSFlagPend () OSQFlagQuery ()
ISR
Task
ISR
Task
OSFlagAccept () OSQFlagQuery ()
Trang 11Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6
Creating an Event Flag Group, OSFlagCreate
OS_FLAG_GRP *OSFlagCreate (OS_FLAGS flags, INT8U *err)
• flags: A bit pattern that contains the initial values
• err:
• Return value:
Trang 12Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6
Deleting an Event Flag Group, OSFlagDel
OS_FLAG_GRP *OSFlagDel (OS_FLAG_GRP *pgrp, INT8U opt, INT8U *err)
• pgrp: A pointer to the desired event flag group to be deleted
• opt: Delete options
• err:
Trang 13Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6
Deleting an Event Flag Group, OSFlagDel cont’d
OS_FLAG_GRP *OSFlagDel (OS_FLAG_GRP *pgrp, INT8U opt, INT8U *err)
• Return value: Null if successful
Trang 14Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6
Waiting for Events of an Event Flag Group, OSFlagPend
OS_FLAGS OSFlagPend (OS_FLAG_GRP *pgrp, OS_FLAGS flags, INT8U wait_type, INT16U timeout, INT8U *err)
• pgrp: A pointer to the desired event flag group to pend to
• flags: A bit pattern that indicates which flags we will wait for
• wait_type: Specifies whether you want ALL bits to be set/cleared or ANY of the bits to be set/cleared as well as flags consumptions or not
• timeout:
Trang 15Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6
Waiting for Events of an Event Flag Group, OSFlagPend cont’d
OS_FLAGS OSFlagPend (OS_FLAG_GRP *pgrp, OS_FLAGS flags, INT8U wait_type, INT16U timeout, INT8U *err)
• err:
• Return value: Final flag group state
Trang 16Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6
Setting or Clearing Events in an Event Flag Group, OSFlagPost
OS_FLAGS OSFlagPost (OS_FLAG_GRP *pgrp, OS_FLAGS flags, INT8U opt, INT8U *err)
• pgrp: A pointer to the desired event flag group to post to
• flags: A bit pattern that indicates which flags will be changed
• opt: Indicates whether flags are set or cleared
• err:
• Return value: Final flag group state
Trang 17Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6
Looking for Events of an Event Flag Group, OSFlagAccept
OS_FLAGS OSFlagAccept (OS_FLAG_GRP *pgrp, OS_FLAGS flags, INT8U wait_type, INT8U *err)
• pgrp: A pointer to the desired event flag group to pend to
• flags: A bit pattern that indicates which flags we will wait for
• wait_type: Specifies whether you want ALL bits to be set/cleared or ANY of the bits to be set/cleared
• err:
• Return value: Final flag group state
Trang 18Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6
Querying an Event Flag Group, OSFlagQuery
OS_FLAGS OSFlagQuery (OS_FLAG_GRP *pgrp, INT8U *err)
• pgrp: A pointer to the desired event flag group
• err:
• Return value: current value of the flag group