Fair enough, here's a code example that pokes around a hardware timer from a user application:
include Rules.mak
ECLIPSE_WORKSPACE := /cygdrive/c/altera/kits/nios2/bin/eclipse/workspace
KERNEL_PROJECT := uKit_kernel_default
BUILDDIR := $(ECLIPSE_WORKSPACE)/$(KERNEL_PROJECT)/build/include
CFLAGS += -O0 -g -I$(BUILDDIR)
all: timer.exe timer.gdb
#include <errno.h># include <stdio.h># include "nios2_system.h"
int
main (int argc, char* argv)
{
int i;
np_timer *timer;
timer = na_timer0;
i = (timer->np_timerperiodh << 16) | timer->np_timerperiodl;
printf ("timer period valud is %i \n", i);
timer->np_timersnapl = 0;
i = (timer->np_timersnaph << 16) | timer->np_timersnapl;
printf ("The current timer value is %i\n", i);
return 0;
}
The first code segment is a Makefile and the second one is the timer.c file that is referenced within the Makefile.
You'll notice the inclusion of the "nios2_system.h" header file within timer.c, that file is dynamically generated and can be found within a kernel project build/include directory.
The two code segments can be copied into an application project and built after ensuring that you're referencing the correct kernel project.
Does this help?