02.01.2015 Views

CooCox CoOS User's Guide

CooCox CoOS User's Guide

CooCox CoOS User's Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

6 API Reference<br />

6.1 System Management<br />

6.1.1 CoInitOS()<br />

Function Prototype:<br />

void CoInitOS (void);<br />

Descriptions:<br />

Initialize the system.<br />

Parameters:<br />

None<br />

Returns:<br />

None<br />

Example usage:<br />

#include "CCRTOS.h"<br />

#define TASK0PRIO 10<br />

OS_STK Task0Stk[100];<br />

OS_TID Task0Id;<br />

void Task0 (void *pdata);<br />

int main(void)<br />

{<br />

System_init ();<br />

CoInitOS ();<br />

// Initialize <strong>CoOS</strong><br />

…<br />

Task0Id = CoCreateTask (Task0, (void *)0, TASK0PRIO , &Task0Stk[99], 100);<br />

…<br />

CoStartOS();<br />

// Start <strong>CoOS</strong><br />

}<br />

void Task0 (void *pdata)<br />

{<br />

...<br />

for(;;)<br />

{<br />

...<br />

}<br />

}<br />

Note:<br />

1) A requirement of <strong>CooCox</strong> <strong>CoOS</strong> is that you call CoInitOS() before you<br />

call any of its other services.<br />

2) You need to set the CPU clock and configure the OS well before<br />

41

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!