Uso de RTOS
|
Go to the source code of this file.
Data Structures | |
struct | os_tcb |
Typedefs | |
typedef struct os_tcb | OS_TCB |
Functions | |
void | OSTimeDly (INT16U ticks) |
DELAY TASK 'n' TICKS (n from 0 to 65535) param ticks. More... | |
void | OSTimeTick (void) |
PROCESS SYSTEM TICK. | |
void | OSInit (void) |
INITIALIZATION. | |
void | OSIntEnter (void) |
ENTER ISR. | |
void | OSIntExit (void) |
EXIT ISR. | |
void | OSStart (void) |
START MULTITASKING. | |
void | OSStatInit (void) |
STATISTICS INITIALIZATION. | |
INT16U | OSVersion (void) |
GET VERSION. More... | |
void | OS_Sched (void) |
SCHEDULER This function is called by other uC/OS-II services to determine whether a new, high priority task has been made ready to run. This function is invoked by TASK level code and is not used to reschedule tasks from ISRs (see OSIntExit() for ISR rescheduling). More... | |
void | OS_TaskIdle (void *data) |
IDLE TASK. | |
INT8U | OS_TCBInit (INT8U prio, OS_STK *ptos, OS_STK *pbos, INT16U id, INT32U stk_size, void *pext, INT16U opt) |
INITIALIZE TCB. More... | |
void | OSInitHookBegin (void) |
OS INITIALIZATION HOOK This function is called by OSInit() at the beginning of OSInit(). More... | |
void | OSInitHookEnd (void) |
OS INITIALIZATION HOOK This This function is called by OSInit() at the end of OSInit(). More... | |
void | OSIntCtxSw (void) |
PERFORM A CONTEXT SWITCH (From an ISR) More... | |
void | OSStartHighRdy (void) |
START HIGHEST PRIORITY TASK. More... | |
void | OSTaskCreateHook (OS_TCB *ptcb) |
TASK CREATION HOOK This function is called when a task is created. More... | |
void | OSTaskDelHook (OS_TCB *ptcb) |
TASK DELETION HOOK This function is called when a task is deleted. More... | |
void | OSTaskIdleHook (void) |
IDLE TASK HOOK This function is called by OS_TaskIdle() which is executed whenever no other task is ready to run. This function can put the CPU to sleep, ready to be woken by an interupt or it can blink a LED to indicate how busy the processor is. | |
void | OSTaskStatHook (void) |
STATISTIC TASK HOOK This function is called every second by uC/OS-II's statistics task. This allows your application to add functionality to the statistics task. More... | |
OS_STK * | OSTaskStkInit (void(*task)(void *pd), void *pdata, OS_STK *ptos, INT16U opt) |
INITIALIZE A TASK'S STACK This function is called by either OSTaskCreate() or OSTaskCreateExt() to initialize the stack frame of the task being created. This function is highly processor specific. More... | |
void | OSTaskSwHook (void) |
TASK SWITCH HOOK This function is called when a task switch is performed. This allows you to perform other operations during a context switch. More... | |
void | OSTCBInitHook (OS_TCB *ptcb) |
TICK HOOK. More... | |
void | OSTimeTickHook (void) |
TICK HOOK This function is called every tick. More... | |
void | OSCtxSw (void) |
Switch the context by calling the function directly, since there are no software interrupts in a PIC18 processor. More... | |
void | OSTickISR (void) |
Variables | |
OS_EXT INT32U | OSCtxSwCtr |
OS_EXT INT8U | OSIntNesting |
OS_EXT INT8U | OSIntExitY |
OS_EXT INT8U | OSLockNesting |
OS_EXT INT8U | OSPrioCur |
OS_EXT INT8U | OSPrioHighRdy |
OS_EXT INT8U | OSRdyGrp |
OS_EXT INT8U | OSRdyTbl [OS_RDY_TBL_SIZE] |
OS_EXT BOOLEAN | OSRunning |
OS_EXT INT8U | OSTaskCtr |
OS_EXT volatile INT32U | OSIdleCtr |
OS_EXT OS_STK | OSTaskIdleStk [OS_TASK_IDLE_STK_SIZE] |
OS_EXT OS_TCB * | OSTCBCur |
OS_EXT OS_TCB * | OSTCBFreeList |
OS_EXT OS_TCB * | OSTCBHighRdy |
OS_EXT OS_TCB * | OSTCBList |
OS_EXT OS_TCB * | OSTCBPrioTbl [OS_LOWEST_PRIO+1] |
OS_EXT OS_TCB | OSTCBTbl [OS_MAX_TASKS+OS_N_SYS_TASKS] |
rom INT8U const | OSMapTbl [] |
rom INT8U const | OSUnMapTbl [] |
#define FALSE 0 |
Falso Verdadero
#define OS_DEL_ALWAYS 1 |
1 - TRUE
#define OS_DEL_NO_PEND 0 |
0 - FALSE
#define OS_ERR_CREATE_ISR 141 |
Error 141 - Error Crear ISR
#define OS_ERR_DEL_ISR 140 |
Error 140 - Error Delete ISR
#define OS_ERR_EVENT_TYPE 1 |
Error 1
#define OS_ERR_INVALID_OPT 7 |
Error 7
#define OS_ERR_NOT_MUTEX_OWNER 120 |
Error 120 - Mutex Error
#define OS_ERR_PEND_ISR 2 |
Error 2
#define OS_ERR_PEVENT_NULL 4 |
Error 4
#define OS_ERR_POST_ISR 5 |
Error 5
#define OS_ERR_POST_NULL_PTR 3 |
Error 3
#define OS_ERR_QUERY_ISR 6 |
Error 6
#define OS_ERR_TASK_WAITING 8 |
Error 8
#define OS_EVENT_EN (((OS_Q_EN > 0) && (OS_MAX_QS > 0)) || (OS_MBOX_EN > 0) || (OS_SEM_EN > 0) || (OS_MUTEX_EN > 0)) |
Event Enabled
#define OS_EVENT_TBL_SIZE ((OS_LOWEST_PRIO) / 8 + 1) |
Size of event table
#define OS_EVENT_TYPE_FLAG 5 |
Event Type 5
#define OS_EVENT_TYPE_MBOX 1 |
Event Type 1
#define OS_EVENT_TYPE_MUTEX 4 |
Event Type 4
#define OS_EVENT_TYPE_Q 2 |
Event Type 2
#define OS_EVENT_TYPE_SEM 3 |
Event Type 3
#define OS_EVENT_TYPE_UNUSED 0 |
Event Type 0 - Sin USO
#define OS_FLAG_CLR 0 |
0 - FALSE
#define OS_FLAG_CONSUME 0x80 |
Consume the flags if condition(s) satisfied
#define OS_FLAG_ERR_NOT_RDY 152 |
Error 152 - Error Not Ready
#define OS_FLAG_ERR_WAIT_TYPE 151 |
Error 151 - Error tipo Evento Espera
#define OS_FLAG_GRP_DEPLETED 154 |
Error 154 - Flag GRP
#define OS_FLAG_INVALID_OPT 153 |
Error 153 - Opcion Invalida
#define OS_FLAG_INVALID_PGRP 150 |
Error 150 - Flaf Invalido
#define OS_FLAG_SET 1 |
1 - TRUE
#define OS_FLAG_WAIT_CLR_ALL 0 |
Wait for ALL the bits specified to be CLR (i.e. 0)
#define OS_FLAG_WAIT_CLR_AND 0 |
Wait for AND the bits specified to be CLR (i.e. 0)
#define OS_FLAG_WAIT_CLR_ANY 1 |
Wait for ANY of the bits specified to be CLR (i.e. 0)
#define OS_FLAG_WAIT_CLR_OR 1 |
Wait for OR of the bits specified to be CLR (i.e. 0)
#define OS_FLAG_WAIT_SET_ALL 2 |
Wait for ALL the bits specified to be SET (i.e. 1)
#define OS_FLAG_WAIT_SET_AND 2 |
Wait for AND the bits specified to be SET (i.e. 1)
#define OS_FLAG_WAIT_SET_ANY 3 |
Wait for ANY of the bits specified to be SET (i.e. 1)
#define OS_FLAG_WAIT_SET_OR 3 |
Wait for OR of the bits specified to be SET (i.e. 1)
#define OS_IDLE_PRIO (OS_LOWEST_PRIO) |
IDLE task priority
#define OS_MBOX_FULL 20 |
Error 20
#define OS_MEM_FULL 114 |
Error 114
#define OS_MEM_INVALID_ADDR 118 |
Error 118 - Memoria Invalida
#define OS_MEM_INVALID_BLKS 111 |
Error 111
#define OS_MEM_INVALID_PART 110 |
Error 110
#define OS_MEM_INVALID_PBLK 115 |
Error 115
#define OS_MEM_INVALID_PDATA 117 |
Error 117
#define OS_MEM_INVALID_PMEM 116 |
Error 116
#define OS_MEM_INVALID_SIZE 112 |
Error 112
#define OS_MEM_NO_FREE_BLKS 113 |
Error 113
#define OS_N_SYS_TASKS 1 |
Number of system tasks
#define OS_NO_ERR 0 |
Error 0
#define OS_NO_MORE_TCB 70 |
Error 70
#define OS_POST_OPT_BROADCAST 0x01 |
Broadcast message to ALL tasks waiting
#define OS_POST_OPT_FRONT 0x02 |
Post to highest priority task waiting
#define OS_POST_OPT_NONE 0x00 |
Post to highest priority task waiting
#define OS_PRIO_ERR 41 |
Error 41
#define OS_PRIO_EXIST 40 |
Error 40
#define OS_PRIO_INVALID 42 |
Error 42
#define OS_PRIO_SELF 0xFF |
Indicate SELF priority
#define OS_Q_FULL 30 |
Error 30
#define OS_RDY_TBL_SIZE ((OS_LOWEST_PRIO) / 8 + 1) |
Size of ready table
#define OS_SEM_OVF 50 |
Error 50
#define OS_STAT_FLAG 0x20 |
Pending on event flag group
#define OS_STAT_MBOX 0x02 |
Pending on mailbox
#define OS_STAT_MUTEX 0x10 |
Pending on mutual exclusion semaphore
#define OS_STAT_PRIO (OS_LOWEST_PRIO - 1) |
Statistic task priority
#define OS_STAT_Q 0x04 |
Pending on queue
#define OS_STAT_RDY 0x00 |
Ready to run
#define OS_STAT_SEM 0x01 |
Pending on semaphore
#define OS_STAT_SUSPEND 0x08 |
Task is suspended
#define OS_TASK_DEL_ERR 60 |
Error 60
#define OS_TASK_DEL_IDLE 61 |
Error 61
#define OS_TASK_DEL_ISR 63 |
Error 63
#define OS_TASK_DEL_REQ 62 |
Error 62
#define OS_TASK_IDLE_ID 65535 |
I.D. numbers for Idle tasks
#define OS_TASK_NOT_EXIST 11 |
Error 11
#define OS_TASK_NOT_SUSPENDED 101 |
Error 101
#define OS_TASK_OPT_ERR 130 |
Error 130 - Mutex Error
#define OS_TASK_OPT_SAVE_FP 0x0004 |
Save the contents of any floating-point registers
#define OS_TASK_OPT_STK_CHK 0x0001 |
Enable stack checking for the task
#define OS_TASK_OPT_STK_CLR 0x0002 |
Clear the stack when the task is create
#define OS_TASK_RESUME_PRIO 100 |
Error 100
#define OS_TASK_STAT_ID 65534 |
I.D. numbers for Stat tasks
#define OS_TASK_SUSPEND_IDLE 91 |
Error 91
#define OS_TASK_SUSPEND_PRIO 90 |
Error 90
#define OS_TIME_INVALID_MILLI 83 |
Error 83
#define OS_TIME_INVALID_MINUTES 81 |
Error 81
#define OS_TIME_INVALID_SECONDS 82 |
Error 82
#define OS_TIME_NOT_DLY 80 |
Error 80
#define OS_TIME_ZERO_DLY 84 |
Error 84
#define OS_TIMEOUT 10 |
Error 10
#define OS_VERSION 252 |
Version of uC/OS-II (Vx.yy mult. by 100)
void OS_Sched | ( | void | ) |
SCHEDULER
This function is called by other uC/OS-II services to determine whether a new, high priority task has been made ready to run. This function is invoked by TASK level code and is not used to reschedule tasks from ISRs (see OSIntExit() for ISR rescheduling).
INT8U OS_TCBInit | ( | INT8U | prio, |
OS_STK * | ptos, | ||
OS_STK * | pbos, | ||
INT16U | id, | ||
INT32U | stk_size, | ||
void * | pext, | ||
INT16U | opt | ||
) |
INITIALIZE TCB.
prio | |
ptos | |
pbos | |
id | |
stk_size | |
pext | |
opt |
void OSCtxSw | ( | void | ) |
Switch the context by calling the function directly, since there are no software interrupts in a PIC18 processor.
TASK LEVEL CONTEXT SWITCH
This function is called when a task makes a higher priority task ready-to-run. /*.
TASK CONTEXT SWITCH
Switch the context by calling the function directly, since there are no software interrupts in a PIC18 processor.
TASK LEVEL CONTEXT SWITCH
Description : This function is called when a task makes a higher priority task ready-to-run.
Arguments : none
Note(s) : 1) Upon entry, OSTCBCur points to the OS_TCB of the task to suspend OSTCBHighRdy points to the OS_TCB of the task to resume
2) The stack frame of the task to resume looks as follows:
LOW MEMORY - 19 pdata (lower 8 bits) - 18 pdata (upper 8 bits) - 17 XX (pointed to by FSR1, frame pointer) - 16 STATUS register - 15 BSR register - 14 W register - 13 FSR0L register - 12 FSR0H register - 11 FSR2L register (frame pointer, low) - 10 FSR2H register (frame pointer, high) - 9 TBLPTRL register - 8 TBLPTRH register - 7 TBLPTRU register - 6 PRODL register - 5 PRODH register (end repeating, based on number of items) - 4 TOSL (top of return stack, low) - 3 TOSH (top of return stack, high) - 2 TOSU (top of return stack, upper) (start repeating, based on number of items) - 1 (number of return stack items)
OSTCBHighRdy->OSTCBStkPtr - 0 -—> (free item) HIGH MEMORY
void OSInitHookBegin | ( | void | ) |
OS INITIALIZATION HOOK
This function is called by OSInit() at the beginning of OSInit().
OS INITIALIZATION HOOK (BEGINNING)
Description: This function is called by OSInit() at the beginning of OSInit().
Arguments : none
Note(s) : 1) Interrupts should be disabled during this call.
void OSInitHookEnd | ( | void | ) |
OS INITIALIZATION HOOK
This This function is called by OSInit() at the end of OSInit().
OS INITIALIZATION HOOK (END)
Description: This function is called by OSInit() at the end of OSInit().
Arguments : none
Note(s) : 1) Interrupts should be disabled during this call.
void OSIntCtxSw | ( | void | ) |
PERFORM A CONTEXT SWITCH (From an ISR)
void OSStartHighRdy | ( | void | ) |
START HIGHEST PRIORITY TASK.
void OSTaskCreateHook | ( | OS_TCB * | ptcb | ) |
TASK CREATION HOOK
This function is called when a task is created.
*ptcb |
void OSTaskDelHook | ( | OS_TCB * | ptcb | ) |
TASK DELETION HOOK
This function is called when a task is deleted.
*ptcb |
void OSTaskStatHook | ( | void | ) |
STATISTIC TASK HOOK
This function is called every second by uC/OS-II's statistics task. This allows your application to add functionality to the statistics task.
INITIALIZE A TASK'S STACK
This function is called by either OSTaskCreate() or OSTaskCreateExt() to initialize the stack frame of the task being created. This function is highly processor specific.
*task | |
*pdata | |
*ptos | |
opt |
void OSTaskSwHook | ( | void | ) |
TASK SWITCH HOOK
This function is called when a task switch is performed. This allows you to perform other operations during a context switch.
void OSTCBInitHook | ( | struct os_tcb * | ptcb | ) |
TICK HOOK.
*ptcb | This function is called by OSTCBInit() after setting up most of the TCB. |
void OSTimeDly | ( | INT16U | ticks | ) |
DELAY TASK 'n' TICKS (n from 0 to 65535) param ticks.
void OSTimeTickHook | ( | void | ) |
TICK HOOK
This function is called every tick.
INT16U OSVersion | ( | void | ) |
GET VERSION.
OS_EXT INT32U OSCtxSwCtr |
Counter of number of context switches
OS_EXT volatile INT32U OSIdleCtr |
Idle counter
OS_EXT INT8U OSIntExitY |
Valor de Exit Y
OS_EXT INT8U OSIntNesting |
Interrupt nesting level
OS_EXT INT8U OSLockNesting |
Multitasking lock nesting level
rom INT8U const OSMapTbl[] |
Priority->Bit Mask lookup table
OS_EXT INT8U OSPrioCur |
Priority of current task
OS_EXT INT8U OSPrioHighRdy |
Priority of highest priority task
OS_EXT INT8U OSRdyGrp |
Ready list group
OS_EXT INT8U OSRdyTbl[OS_RDY_TBL_SIZE] |
Table of tasks which are ready to run
OS_EXT BOOLEAN OSRunning |
Flag indicating that kernel is running
OS_EXT INT8U OSTaskCtr |
Number of tasks created
OS_EXT OS_STK OSTaskIdleStk[OS_TASK_IDLE_STK_SIZE] |
Idle task stack
OS_EXT OS_TCB* OSTCBCur |
Pointer to currently running TCB
OS_EXT OS_TCB* OSTCBFreeList |
Pointer to list of free TCBs
OS_EXT OS_TCB* OSTCBHighRdy |
Pointer to highest priority TCB R-to-R
OS_EXT OS_TCB* OSTCBList |
Pointer to doubly linked list of TCBs
OS_EXT OS_TCB* OSTCBPrioTbl[OS_LOWEST_PRIO+1] |
Table of pointers to created TCBs
OS_EXT OS_TCB OSTCBTbl[OS_MAX_TASKS+OS_N_SYS_TASKS] |
Table of TCBs
rom INT8U const OSUnMapTbl[] |
Priority->Index lookup table