Several OS calls have been implemented for initialization, message passing, debugging, and task management. There is nothing special about these calls; they are standard C functions. Each function is listed with the action it performs. In order to access them, you must include the comatos8515.c file at the beginning of your source code as follows:
#include <90s8515.h>
#include "comatos8515.c"
OSInit |
Initializes the OS Memory, system clock, and possibly the UART. |
Prototype: void OSInit(unsigned maxTimeout, unsigned char debug) |
Arguments:
|
Example: OSInit(0x0cff, 1) Initializes the OS with the UART and a timeout interval of 3 seconds |
OSStart |
Starts the scheduler, beginning normal operation |
Prototype: void OSStart(void) |
Arguments: None |
OSCreateTask |
Sets up the PCB for a new task and increments OSNumTasks |
Prototype: void OSCreateTask(int (*entry_pt_a)(void),unsigned char timeout, unsigned char messageMask, unsigned char state) |
Arguments:
|
Example: OSCreateTask(TestTaskName, 20, 0x05, 0x01); Creates the PCB for a new task whose code is located at the label "TestTaskLabel". This task will run every 20 milliseconds or when a message is received from tasks 0 and 2. It has an initial state of 0x01. |
OSSetTimeout |
Changes the periodicity properties of the currently running task |
Prototype: void OSSetTimeout(unsigned char timeout); |
Arguments:
|
Example: (Taking place within task 2's code) OSSetTimeout(25); Sets task 2 to be run every 25 milliseconds |
OSSetMessMask |
Specifies which messages the currently running task will be waiting for before it is eligible to run again. |
Prototype: void OSSetMessMask(unsigned char mask) |
Arguments:
|
Example: (Within task 3's code) OSSetMessMask(0x06); Cause task 3 to wait for messages from tasks 1 and 2 before running again. |
OSSendMess |
Sends a message to the specified task. Sets the bit in the target task's PCBMessSrc corresponding to the sender's task number. |
Prototype: void OSSendMess(unsigned char recipTask, unsigned char message) |
Arguments:
|
Example: (Within task 3) OSSendMess(1, 0xf3); Sends the message 0xf3 to task 1. |
OSGetMess |
Retrieves message for the currently running task that was sent using OSSendMess |
Prototype: unsigned char OSGetMess(unsigned char senderTask) |
Arguments:
|
Example: (Within task 1) unsigned char x; x=OSGetMess(3) Places the message sent by task 3 into x. |
ISRSendMess |
Called by an ISR to send a message to a task |
Prototype: void ISRSendMess(unsigned char recipTask, unsigned sendTask, unsigned char message) |
Arguments:
|
Example: (Within an ISR designated as task 6) ISRSendMess(3,6,0x34); Sends the message 0x34 to task 3. |
OSGetMessSrc |
Returns thecurrent task's message source byte and clears it in memory. |
Prototype: unsigned char OSGetMessSrc(void) |
Arguments: none |
Example: unsigned char x; x=OSGetMessageSrc() Places the current task's message source byte into x, then clears the byte in memory |
OSGetAck |
Returns the PCBAck byte of the currently running process. |
Prototype: unsigned char OSGetAck(void) |
Arguments: none |
Example: (Within task 1) unsigned char x; x=OSGetAck(); Places task 1's ack byte in x. |
OSSendAck |
Sends an acknowledgement of a message to the specified task. |
Prototype: void OSSendAck(unsigned char task); |
Arguments:
|
Example: (Within task 1) OSSendAck(3) Sets bit 1 of task 3's PCBAck byte |
OSSetOwnAck |
Places the specified value into the currently running task's PCBAck byte. |
Prototype: void OSSetOwnAck(unsigned char val); |
Arguments:
|
Example: (Within task 1) OSSetOwnAck(0x01); Places the value of 0x01 into task 1's PCBAck byte |
OSSetState |
Place the specified value into the current task's PCBState byte. |
Prototype: void OSSetState(unsigned char val) |
Arguments:
|
Example: (Within task 1) OSSetState(0x53); Places the value of 0x53 into task 1's PCBState byte |
OSGetState |
Reads the current task's PCBState byte into the specified register |
Prototype: unsigned char OSGetState(void) |
Arguments: none |
Example: (Within task 1) unsigned char x; x=OSGetState(); Places task 1's PCBState value into x |
OSInitUART |
Sets the UART baud rate, activates the receive interrupt, and initializes the pointers to the UART ring buffer. For details, see the C UART features page. |
Prototype: void OSInitUART(unsigned char baudrate) |
Arguments:
|
Example: (Within the initialization code before OSStart) OSInitUART(25); Initializes the UART with a baudrate of 9600 bps. |
OSUARTReceiveByte |
Returns one character received on the UART and removes it from the ring buffer. Note that if no character is available, it will wait for one to arrive. For details, see the C UART features page. |
Prototype: unsigned char OSUARTReceiveByte(void) |
Arguments: none |
Example: unsigned char c; c=OSUARTReceiveByte(); |
OSUARTReceiveBytes |
Reads the specified number of characters from the UART. Returns the number of characters read. If the desired number of characters are not available, simply transfers as many as are in the buffer. For details, see the C UART features page. |
Prototype: unsigned int OSUARTReceiveBytes(char *data, unsigned int n) |
Arguments:
|
Example: char buf[10]; c=OSUARTReceiveBytes(&buf[0],5); Reads up to five characters into the buf[] array. |
OSUARTTransmitByte |
Places the specified character in the UART ring buffer for transmission. If space is unavailable within the buffer, waits for it to become available. The actual transmission is interrupt based and not blocking. For details, see the C UART features page. |
Prototype: void OSUARTTransmitByte(unsigned char data) |
Arguments:
|
Example: OSUARTTransmitByte('B'); Sends the letter B. |
OSUARTTransmitBytes |
Places the specified characters in the UART ring buffer for transmission. If space is unavailable within the buffer, waits for it to become available. The actual transmission is interrupt based and not blocking. For details, see the C UART features page. |
Prototype: void OSUARTTransmitBytes(unsigned char *data, unsigned int n) |
Arguments:
|
Example: char buf[]={"Hello",0x00}; OSUARTTransmitBytes(&buf[0],6); Sends the word Hello with a null character at the end. |