7.1 onethread

This is one of the sample programs in the package. It is not very useful because all it contains is the skeleton of a program that initializes the real time kernel.

#include "rtk.h"

struct Thread mainThread;

int main(void)
{
  // ... code before rtk is active
  rtkInitialize(&mainThread, &rtkQueues[0]);
  // ... code after rtk is active
  // not exciting because with one thread, there isn't much you need to use
  // from the RTK
  while (1)
  {
  }
}

The file onethread.make is the makefile for this program. It is very minimalist, also.

MMCU = -mmcu=atmega128
COMMONOPT = -g $(MMCU)
ASFLAGS = $(COMMONOPT) -D__ASM__
CFLAGS = $(COMMONOPT) -O3 # don't forget, otherwise defaulted to 8515!
                        # the mmcu option also controls how the linker
												# links (which linker script file to use)
LDFLAGS = -g $(MMCU)

MAIN_SRCFILE = onethread.c
C_SRCFILES = $(MAIN_SRCFILE)
ASM_SRCFILES = rtk.S

include main.make

The most critical part are explained here:

Copyright © 2008-10-25 by Tak Auyeung