1. Trang chủ
  2. » Cao đẳng - Đại học

Introduction to uCOS II v2 6 m8

18 222 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 18
Dung lượng 334 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Introduction to uCOS-II V2.6... Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6Course References • MicroC/OS-II The Real-Time Kernel, 2nd Edition, by Jean J... Message Mailboxes• A

Trang 1

Introduction to uCOS-II V2.6

Trang 2

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 3

Amr 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 4

• 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 5

Amr 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 6

• 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 7

Amr 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 8

Message Mailboxes

• A message mailbox is

a μC/OS-II object that allows a task or an ISR to send pointer-sized variable to another task.

OSMboxCreate()

Message OSMboxPost()

OSMboxAccept()

OSMboxPost()

OSMboxPend() OSMboxAccept() OSMboxQuery()

ISR Task

Task

Trang 9

Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6

Creating a Mailbox, OSMboxCreate

OS_EVENT *OSMboxCreate (void *msg)

• msg: A pointer to a message to deposit in the mailbox

o If null, mailbox is empty & used to signal occurrence of events

o If ! null, mailbox is used to access shared resources

• Return value:

o Non-null for successful creation

o Null for failure

Trang 10

Deleting a Mailbox, OSMboxDel

OS_EVENT *OSMboxDel (OS_EVENT *pevent, INT8U opt, INT8U

*err)

• pevent: A pointer to the mailbox to be deleted

• opt: Delete options

o Delete always

o Delete if no pending tasks

• err:

o No error

o Called from ISR

o Invalid option

o There are tasks pending.

o pevent is null.

o pevent is not a mailbox.

Trang 11

Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6

Deleting a Mailbox, OSMboxDel cont’d

OS_EVENT *OSMboxDel (OS_EVENT *pevent, INT8U opt, INT8U

*err)

• Return value: Null if successful

Trang 12

Waiting for a Message at a Mailbox, OSMboxPend

void *OSMboxPend (OS_EVENT *pevent, INT16U timeout, INT8U

*err)

• pevent: A pointer to the mailbox to pend to

• timeout:

o 0 wait for ever 

o !0 wait with specific timeout 

• err:

o No error

o Timeout

o pevent is not a mailbox.

o pevent is null.

o Called from ISR

Trang 13

Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6

Sending a Message to a Mailbox, OSMboxPost

INT8U OSMboxPost (OS_EVENT *pevent, void *msg)

• pevent: A pointer to the mailbox to post to

• msg: A pointer to the message to send

• Return value:

o No error

o Mailbox is full.

o pevent is not a mailbox.

o pevent is null.

o Posting a null pointer

Trang 14

Sending a Message to a Mailbox, OSMboxPostOpt

INT8U OSMboxPostOpt (OS_EVENT *pevent, void *msg, INT8U opt)

• OSMboxPostOpt = OSMboxPost + options

• opt:

o Post to a single waiting task

o Post to all tasks waiting

Trang 15

Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6

Getting a Message without Waiting, OSMboxAccept

void *OSMboxAccept (OS_EVENT *pevent)

• pevent: A pointer to the mailbox to pend to

• Return value:

o !Null Message received 

o Null Case of error or mailbox is empty 

Trang 16

Obtaining the Status of a Mailbox, OSMboxQuery

INT8U OSMboxQuery (OS_EVENT *pevent, OS_MBOX_DATA

*pdata)

• pevent: A pointer to the desired mailbox

• pdata: A pointer to the returned mailbox information

• Return value:

o No error

o pevent is not a mailbox.

o pevent is null.

Trang 17

Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6

Using a Mailbox as a Binary Semaphore

OS_EVENT *MboxSem;

void Task (void *pdata){

INT8U err;

for (;;) { OSMboxPend(MboxSem, 0, &err); /* Obtain access to resource */ /* Task has semaphore, access resources */

OSMboxPost(MboxSem, (void*)1); /* Release access to resource */

} }

Trang 18

Using a Mailbox Instead to Signal Occurrence of Events

OS_EVENT *MboxTimeDly;

void Task1(void *pdata){

INT8U err;

for (;;) { OSMboxPend(MboxTimeDly, timeout, &err); /* Wait for event */

/* Code after time delay */

} } void Task2(void *pdata){

INT8U err;

for (;;) { OSMboxPost(MboxTimeDly, (void *)1); /* Signal event */

} }

Ngày đăng: 10/08/2016, 09:56