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

}

}

OSTimeDlyHMSM()

void OSTimeDlyHMSM(INT8U hours, INT8U minutes, INT8U seconds, INT8U milli);

File

Called from

Code enabled by

OS_TIME.C

Task only

N/A

OSTimeDlyHMSM() allows a task to delay itself for a user specified amount of seconds and milliseconds. This is a more convenient and natural format than ticks. at least one of the parameters is non-zero.

time specified in hours, minutes, Rescheduling always occurs when

Arguments

hours is the number of hours that the task will be delayed. The valid range of values is from 0 to 255 hours.

minutes is the number of minutes that the task will be delayed. The valid range of values is from 0 to 59. seconds is the number of seconds that the task will be delayed. The valid range of values is from 0 to 59.

milli is the number of milliseconds that the task will be delayed. The valid range of values is from 0 to 999. Note that the resolution of this argument is in multiples o f the tick rate. For instance, if the tick rate is set to 10 mS then a delay of 5 mS would result in no delay. The delay is actually rounded to the nearest tick. Thus, a delay of 15 mS would actually result in a delay of 20 mS.

Returned Value

OSTimeDlyHMSM() returns one of the following error codes:

1)OS_NO_ERR, if you specified valid arguments and the call was successful.

2)OS_TIME_INVALID_MINUTES, if the minutes argument is greater than 59.

3)OS_TIME_INVALID_SECONDS, if the seconds argument is greater than 59.

4)OS_TIME_INVALID_MS, if the milliseconds argument is greater than 999.

5)OS_TIME_ZERO_DLY, if all four arguments are 0.

Notes/Warnings

Note that calling this function with a delay of 0 hours, 0 minutes, 0 seconds and 0 milliseconds results in no delay and thus the function returns immediately to the caller. Also, if the total delay time ends up being larger than 65535 clock ticks then, you will not be able to abort the delay and resume the task by calling OSTimeDlyResume().

Example

void TaskX(void *pdata)

{

for (;;) {

.

.

OSTimeDlyHMSM(0, 0, 1, 0); /* Delay task for 1 second */

.

.

}

}

OSTimeDlyResume()

INT8U OSTimeDlyResume(INT8U prio);

File

Called from

Code enabled by

OS_TIME.C

Task only

N/A

OSTimeDlyResume() allows your application to resume a task that has been delayed through a call to either

OSTimeDly() or OSTimeDlyHMSM().

Arguments

prio specifies the priority of the task to resume.

Returned Value

OSTimeDlyResume() returns one of the following error codes:

1)OS_NO_ERR, if the call was successful.

2)OS_PRIO_INVALID, if you specified a task priority greater than OS_LOWEST_PRIO.

3)OS_TIME_NOT_DLY, if the task is not waiting for time to expire.

4)OS_TASK_NOT_EXIST, if the task has not been created.

Notes/Warnings

Note that you MUST NOT call this function to resume a task that is waiting for an event with timeout. This situation would make the task look like a timeout occurred (unless you desire this effect).

You cannot resume a task that has calledOSTimeDlyHMSM() with a combined time that exceeds 65535 clock ticks. In other words, if the clock tick runs at 100 Hz then, you will not be able to resume a delayed task that called

OSTimeDlyHMSM(0, 10, 55, 350) or higher.

(10 Minutes * 60 + 55 Seconds + 0.35) * 100 ticks/second

Example

void TaskX(void *pdata)

{

INT8U err;

 

 

pdata = pdata;

 

 

for (;;) {

 

 

.

 

 

err = OSTimeDlyResume(10);

/* Resume task with priority 10

*/

if (err == OS_NO_ERR) {

/* Task was resumed

*/

.

.

 

 

}

 

 

.

 

 

}

 

 

}

 

 

OSTimeGet()

INT32U OSTimeGet(void);

File

Called from

Code enabled by

OS_TIME.C

Task or ISR

N/A

OSTimeGet() allows a task obtain the current value of the system clock. The system clock is a 32-bit counter that counts the number of clock ticks since power was applied or since the system clock was last set.

Arguments

NONE

Returned Value

The current system clock value (in number of ticks).

Notes/Warnings

NONE

Example

void TaskX(void *pdata)

{

INT32U clk;

for (;;) {

.

.

clk = OSTimeGet(); /* Get current value of system clock */

.

.

}

}

OSTimeSet()

void OSTimeSet(INT32U ticks);

File

Called from

Code enabled by

OS_TIME.C

Task or ISR

N/A

OSTimeSet() allows a task to set the system clock. The system clock is a 32-bit counter which counts the number of clock ticks since power was applied or since the system clock was last set.

Arguments

ticks is the desired value for the system clock, in ticks.

Returned Value

NONE

Notes/Warnings

NONE

Example

void TaskX(void *pdata)

{

for (;;) {

.

.

OSTimeSet(0L); /* Reset the system clock */

.

.

}

}

OSTimeTick()

void OSTimeTick(void);

File

Called from

Code enabled by

OS_TIME.C

Task or ISR

N/A

OSTimeTick() is used to process a clock tick. expire (because they called OSTimeDly() or timeout.

µC/OS-II checks all tasks to see if they were either waiting for time to OSTimeDlyHMSM()) or, are waiting for events to occur until they

Arguments

NONE

Returned Value

NONE

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