Several OS calls have been implemented for initialization, message passing, debugging, and task management. They are all layed out as macros which call various subroutines. As a result, they are called with the following format:
Also note that while all of these calls preserve the registers, the way this is done requires that r16, r17, r18, and Z not be used as destination registers in these calls.
OSInit |
Initializes the OS Memory, system clock, and possibly the UART. |
Arguments:
|
Example: OSInit 0x0cff, OSDebug Initializes the OS with the UART and a timeout interval of 3 seconds |
OSStart |
Starts the scheduler, beginning normal operation |
Arguments: None |
OSCreateTask |
Sets up the PCB for a new task and increments OSNumTasks |
Arguments:
|
Example: OSCreateTask TestTaskLabel, 20, 0b00000101 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. |
OSReturn |
Returns control from a task to the scheduler |
Arguments:
|
Example: OSReturn 0 Returns execution to the scheduler and indicates that all is well. |
OSSetTimeout |
Changes the periodicity properties of the currently running task |
Arguments:
|
Example: (Taking place within task 2's code) ldi r19, 25 OSSetTimeout r19 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. |
Arguments:
|
Example: (Within task 3's code) OSSetMessMask 0b00000110 Cause task 3 to wait for messages from tasks 1 and 2 before running again. |
OSSetEntryPt |
Sets the address at which the current task will resume execution for subsequent runs of the task |
Arguments:
|
Example: (Task is created with the entry point at the label TaskStart) TaskStart: ... OSSetEntryPt TaskResume OSReturn 0 TaskResume: ... The next time the task is scheduled, it will start running at TaskResume, not TaskStart. |
OSPCBZ |
Used INTERNALLY by many OS calls. Places the address of the currently running task's PCB into the Z register |
Arguments: None |
OSSendMess |
Sends a message to the specified task. Sets the bit in the target task's PCBMessSrc corresponding to the sender's task number. |
Arguments:
|
Example: (Within task 3) ldi r20, 0xf3 OSSendMess r20, 1 Sends the message 0xf3 to task 1. |
OSGetMess |
Retrieves message for the currently running task that was sent using OSSendMess |
Arguments:
|
Example: (Within task 1) OSGetMess r14, 3 Places the message sent by task 3 into r14. |
ISRSendMess |
Called by an ISR to send a message to a task |
Arguments:
|
Example: (Within an ISR designated as task 6) ldi r25, 0x34 ISRSendMess r25, 3, 6 Sends the message 0x34 to task 3. |
OSGetMessageSrc |
Loads the current task's message source byte into a register and clears it in memory. |
Arguments:
|
Example: OSGetMessageSrc r14 Places the current task's message source byte into r14, then clears the byte in memory |
OSGetAck |
Returns the PCBAck byte of the currently running process. |
Arguments:
|
Example: (Within task 1) OSGetAck r24 Places task 1's ack byte in r24. |
OSSendAck |
Sends an acknowledgement of a message to the specified 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. |
Arguments:
|
Example: (Within task 1) ldi r23, 0x01 OSSetOwnAck r23 Places the value of 0x01 into task 1's PCBAck byte |
OSSetState |
Place the specified value into the current task's PCBState byte. |
Arguments:
|
Example: (Within task 1) ldi r23, 0x53 OSSetState r23 Places the value of 0x53 into task 1's PCBState byte |
OSGetState |
Reads the current task's PCBState byte into the specified register |
Arguments:
|
Example: (Within task 1) OSGetState r26 Places task 1's PCBState value into r26 |
OSHextoAscY |
Converts a specified byte into an ascii string representing its hex value and stores that string at the location pointed to by the Y register. |
Arguments:
|
Example: ldi r26, 0x3f ldi YL, low(USRBase) ldi YH, high(USRBase) OSHextoAscY r26 Places the characters '3' and 'f' at USRBase and USRBase+1 respectively |
OSUARTWait |
Begins transmission of a specified number of characters and returns when transmission is complete. |
Arguments:
|
Example: ldi ZL, low(USRBase+1) ldi ZH, high(USRBase+1) ldi r26, 4 sts OSBase+OSUARTCharCnt, r26 ldi r25, 'a' OSUARTWait r25 Sends 4 characters starting with 'a' to the UART |
OSRegDump |
Sends the values of all the registers to the UART NOTE: Requires that DinkyBug be running on the PC |
Arguments: None |