Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
2012 / uCOS / uCOSII_ebook.pdf
Скачиваний:
70
Добавлен:
10.02.2015
Размер:
1.08 Mб
Скачать

10.05Summary

Table 10.3 provides a summary of the changes needed to bring a port for µC/OS towork with µC/OS-II. You should note that ‘processor_name.?’Is the name of the µC/OS file containing the port.

µC/OS

µC/OS-II

Processor_name.H

OS_CPU.H

Data types:

Data types

Change UBYTE to

INT8U

Change BYTE to

INT8S

Change UWORD to

INT16U

Change WORD to

INT16S

Change ULONG to

INT32U

Change LONG to

INT32S

Change OS_STK_TYPE to

OS_STK

OS_ENTER_CRITICAL(

No change

)

 

OS_EXIT_CRITICAL()

No change

-

Add OS_STK_GROWTH

OS_TASK_SW()

No change

OS_FAR

Define OS_FAR to nothing or,

 

Remove all references to OS_FAR

Processor_name.ASM

OS_CPU_A.ASM

OSStartHighRdy()

Add call to OSTaskSwHook()

 

Set OSRunning to 1 (8-bit)

OSCtxSw()

Add call to OSTaskSwHook()

 

Copy OSPrioHighRdy to OSPrioCur (8-bit)

OSIntCtxSw()

Add call to OSTaskSwHook()

 

Copy OSPrioHighRdy to OSPrioCur (8-bit)

OSTickISR()

No change

Processor_name.C

OS_CPU_C.C

OSTaskCreate()

Extract stack initialization code and put this code in a function called

 

OSTaskStkInit().

-

Add an empty function called OSTaskCreateHook().

-

Add an empty function called OSTaskDelHook().

-

Add an empty function called OSTaskSwHook().

-

Add an empty function called OSTaskStatHook().

-

Add an empty function called OSTimeTickHook().

Table 10.3, Summary of migrating a µC/OS port to µC/OS-II.

Chapter 11

Reference Manual

This chapter provides a user's guide to µC/OS-II services. Each of the user accessible kernel services is presented in alphabetical order and the following information is provided for each of the services:

1)A brief description

2)The function prototype

3)The file name where the source code is found

4)The #define constant needed to enable the code for the service

5)A description of the arguments passed to the function

6)A description of the return value(s)

7)Specific notes and warning on the usage of the service

8)One or two examples on how to use the function

OSInit()

void OSInit(void)

File

Called from

Code enabled by

OS_CORE.C

Startup code only

N/A

OSInit() is used to initialize µC/OS-II. OSInit() must be called prior to calling OSStart() which will actually start multitasking.

Arguments

NONE

Returned Value

NONE

Notes/Warnings

OSInit() must be called before OSStart().

 

Example

 

 

void main (void)

 

{

 

.

 

.

 

OSInit();

/* Initialize uC/OS-II */

.

 

.

 

OSStart();

/* Start Multitasking */

}

 

OSIntEnter()

void OSIntEnter(void)

File

Called from

Code enabled by

OS_CORE.C

ISR only

N/A

OSIntEnter() is used to notify µC/OS-II that an ISR is being processed. This allows µC/OS-II to keep track of interrupt nesting. OSIntEnter() is used in conjunction with OSIntExit().

Arguments

NONE

Returned Value

NONE

Notes/Warnings

1)This function must not be called by task level code.

2)You can actually increment the interrupt nesting counter ( OSIntNesting) directly if your processor can perform this operation indivisibly. In other words, if your processor can perform a read-modify-write as an atomic operation then you don't need to call OSIntEnter() and instead, directly increment OSIntNesting. This would avoid the overhead associated with calling a function.

Example #1

(Intel 80x86, Real-Mode, Large Model)

Here we call OSIntEnter() because of backward compatibility with µC/OS. Also, you would do this if the processor you are using does not allow you to increment OSIntNesting using a single instruction.

ISRx

PROC

FAR

 

 

PUSHA

 

; Save interrupted task's context

 

PUSH

ES

 

;

PUSH

DS

 

MOV

AX, DGROUP

; Reload DS

 

;

MOV

DS, AX

 

CALL

FAR PTR _OSIntEnter ; Notify µC/OS-II of start of ISR

 

 

.

 

 

 

.

 

 

 

POP

DS

; Restore processor registers

 

POP

ES

 

 

POPA

 

 

 

IRET

 

; Return from interrupt

ISRx

ENDP

 

 

Example #2

(Intel 80x86, Real-Mode, Large Model)

Here we increment OSIntNesting because the 80x86 allow you to perform this operation indivisibly.

ISRx PROC

FAR

 

PUSHA

 

; Save interrupted task's context

PUSH

ES

 

PUSH

DS

 

;

 

 

MOV

AX, DGROUP

; Reload DS

MOV

DS, AX

 

;

 

 

INC

BYTE PTR _OSIntNesting ; Notify µC/OS-II of start of ISR

.

 

 

.

.

Соседние файлы в папке uCOS