BRTOS  1.90
Brazilian Real-Time Operating System
 All Data Structures Files Functions Variables Macros
Functions | Variables
BRTOS.c File Reference

BRTOS kernel functions. More...

#include "BRTOS.h"

Functions

uint8_t OSSchedule (void)
 Priority Preemptive Scheduler (Internal kernel function). More...
 
BRTOS_TH OSGetCurrentTaskHandle (void)
 Return the handle of the current task. The user must call this function in order to receive the current task handle. More...
 
OS_CPU_TYPE OSGetTaskPriority (BRTOS_TH task_handle)
 Return the priority of the specified task. The user must call this function in order to receive the priority of the specified task. More...
 
ostick_t OSGetTickCount (void)
 Return current tick count. The user must call this function in order to receive the current tick count. More...
 
ostick_t OSGetCount (void)
 Return current tick count. Internal BRTOS function. More...
 
void OSIncCounter (void)
 Update the tick counter. More...
 
uint8_t OSDelayTask (ostick_t time_wait)
 Wait for a specified period. A task that calling this function will be suspended for a certain time. When this time is reached the task back to ready state. More...
 
uint8_t OSDelayTaskHMSM (uint8_t hours, uint8_t minutes, uint8_t seconds, uint16_t miliseconds)
 Wait for a specified period (in hours, minutes, seconds and miliseconds). A task that calling this function will be suspended for a certain time. When this time is reached the task back to ready state. More...
 
void OS_TICK_HANDLER (void)
 Tick timer interrupt handler routine (Internal kernel function).
 
uint8_t BRTOSStart (void)
 Start the Operating System Scheduler The user must call this function to start the tasks execution. More...
 
void PreInstallTasks (void)
 Function that initialize the kernel main variables. This function resets the kernel main variables, preparing the system to be started. More...
 
uint8_t OSBlockPriority (uint8_t iPriority)
 Blocks a specific priority Blocks the task that is associated with the specified priority. The user must be careful when using this function in together with mutexes. This can lead to undesired results due the "cealing priority" property used in the mutex. More...
 
uint8_t OSUnBlockPriority (uint8_t iPriority)
 UnBlock a specific priority UnBlocks the task that is associated with the specified priority. The user must be careful when using this function in together with mutexes. This can lead to undesired results due the "cealing priority" property used in the mutex. More...
 
uint8_t OSBlockMultipleTask (uint8_t TaskStart, uint8_t TaskNumber)
 Blocks a set of tasks. More...
 
uint8_t OSUnBlockMultipleTask (uint8_t TaskStart, uint8_t TaskNumber)
 UnBlocks a set of tasks. More...
 
void Idle (void)
 Idle Task. May be used to implement low power commands. More...
 
void BRTOSInit (void)
 Initialize BRTOS control blocks and tick timer (Internal kernel function).
 
void initEvents (void)
 Initialize event control blocks. More...
 
uint8_t SAScheduler (PriorityType ReadyList)
 Sucessive Aproximation Scheduler (Internal kernel function). More...
 

Variables

const CHAR8 version[] PROGMEM = BRTOS_VERSION
 Informs BRTOS version.
 
uint8_t PriorityVector [configMAX_TASK_INSTALL]
 Allocate task priorities.
 
uint16_t iStackAddress = 0
 Virtual stack counter - Informs the stack occupation in bytes.
 
uint16_t iQueueAddress = 0
 Queue heap control.
 
stack_pointer_t StackAddress
 Virtual stack pointer.
 
uint8_t NumberOfInstalledTasks
 Number of Installed tasks at the moment.
 
volatile uint8_t currentTask
 Current task being executed.
 
volatile uint32_t OSDuty =0
 Used to compute the CPU load.
 
volatile uint32_t OSDutyTmp =0
 Used to compute the CPU load.
 
volatile uint16_t LastOSDuty = 0
 Last CPU load computed.
 
uint16_t DutyCnt = 0
 Used to compute the CPU load.
 
uint32_t TaskAlloc = 0
 Used to search a empty task control block.
 
uint8_t iNesting = 0
 Used to inform if the current code position is an interrupt handler code.
 
ContextType ContextTask [NUMBER_OF_TASKS+1]
 

Detailed Description

BRTOS kernel functions.

Kernel functions, such as: scheduler, block tasks, unblock tasks, Delay, Change Context

Function Documentation

uint8_t BRTOSStart ( void  )

Start the Operating System Scheduler The user must call this function to start the tasks execution.

Returns
OK Success
NO_MEMORY There was not enough memory to start all tasks
void Idle ( void  )

Idle Task. May be used to implement low power commands.

Returns
NONE
void initEvents ( void  )

Initialize event control blocks.

Returns
NONE
uint8_t OSBlockMultipleTask ( uint8_t  TaskStart,
uint8_t  TaskNumber 
)

Blocks a set of tasks.

Parameters
TaskStartNumber of the first task to be blocked
TaskNumberNumber of tasks to be blocked from the specified task start
Returns
OK - Success
IRQ_PEND_ERR - Can not use block multiple tasks function from interrupt handler code
uint8_t OSBlockPriority ( uint8_t  iPriority)

Blocks a specific priority Blocks the task that is associated with the specified priority. The user must be careful when using this function in together with mutexes. This can lead to undesired results due the "cealing priority" property used in the mutex.

Parameters
iPriorityPriority to be blocked
Returns
OK - Success
IRQ_PEND_ERR - Can not use block priority function from interrupt handler code
uint8_t OSDelayTask ( ostick_t  time_wait)

Wait for a specified period. A task that calling this function will be suspended for a certain time. When this time is reached the task back to ready state.

Parameters
time_waitTime in ticks to delay. System default = 1ms. The user can change the time value.
Returns
OK Success
IRQ_PEND_ERR - Can not use block priority function from interrupt handler code
uint8_t OSDelayTaskHMSM ( uint8_t  hours,
uint8_t  minutes,
uint8_t  seconds,
uint16_t  miliseconds 
)

Wait for a specified period (in hours, minutes, seconds and miliseconds). A task that calling this function will be suspended for a certain time. When this time is reached the task back to ready state.

Parameters
hoursHours to delay
minutesMinutes to delay
secondsSeconds to delay
milisecondsMiliseconds to delay
Returns
OK Success
INVALID_TIME The specified parameters are outside of the permitted range
ostick_t OSGetCount ( void  )

Return current tick count. Internal BRTOS function.

Returns
current tick count
BRTOS_TH OSGetCurrentTaskHandle ( void  )

Return the handle of the current task. The user must call this function in order to receive the current task handle.

Returns
current task handle
BRTOS_TH OSGetTaskPriority ( BRTOS_TH  task_handle)

Return the priority of the specified task. The user must call this function in order to receive the priority of the specified task.

Returns
task priority
ostick_t OSGetTickCount ( void  )

Return current tick count. The user must call this function in order to receive the current tick count.

Returns
current tick count
void OSIncCounter ( void  )

Update the tick counter.

Returns
NONE
uint8_t OSSchedule ( void  )

Priority Preemptive Scheduler (Internal kernel function).

BRTOS Scheduler function (Internal kernel function).

uint8_t OSUnBlockMultipleTask ( uint8_t  TaskStart,
uint8_t  TaskNumber 
)

UnBlocks a set of tasks.

Parameters
TaskStartNumber of the first task to be unblocked
TaskNumberNumber of tasks to be unblocked from the specified task start
Returns
OK - Success
IRQ_PEND_ERR - Can not use unblock multiple tasks function from interrupt handler code
uint8_t OSUnBlockPriority ( uint8_t  iPriority)

UnBlock a specific priority UnBlocks the task that is associated with the specified priority. The user must be careful when using this function in together with mutexes. This can lead to undesired results due the "cealing priority" property used in the mutex.

Parameters
iPriorityPriority to be unblocked
Returns
OK - Success
IRQ_PEND_ERR - Can not use unblock priority function from interrupt handler code
void PreInstallTasks ( void  )

Function that initialize the kernel main variables. This function resets the kernel main variables, preparing the system to be started.

Returns
NONE
uint8_t SAScheduler ( PriorityType  ReadyList)

Sucessive Aproximation Scheduler (Internal kernel function).

Parameters
ReadyListList of the tasks ready to run
Returns
The priority of the highest priority task ready to run

Variable Documentation

ContextType ContextTask[NUMBER_OF_TASKS+1]

Task context info ContextTask[0] not used Last ContexTask is the Idle Task