Running a cocoOS application in windows


During development it is very helpful to be able to test the application on another platform before the real hardware is available. This is easy accomplished by using for instance Eclipse with MinGW toolchain to build a windows application.

Off course you have to stub out all the hardware related code and take care of the interrupts in some way. Then the only needed interface to Windows is a thread that periodically calls the os_tick() function to drive the cocoOS timebase.


  int main(void) {

    os_init();

    task_create(sendTask, 30, 0, 0, 0);
    task_create(receiveTask, 40, (Msg_t*)recPool, 10, sizeof(TestMsg_t));
    task_create(testTask, 20, 0, 0, 0);

    HANDLE timerThread = CreateThread(0, 0, tickProc, 0, 0, 0);

    if ( NULL == timerThread ) {
      printf("Could not create tick thread\n");
      return 0;
    }

    os_start();
    return 0;
  }

  DWORD WINAPI tickProc(LPVOID lpParameter) {
    while (1) {
      Sleep(10);
      os_tick();
    }
    return 0;
  }

 

 

 

 

 

© cocoOS  2010

www.cocoos.net