Xenomai: Hard Real Time Driver Example Tutorial with MMAP using the RTDM (Real Time Driver Model)
Include file inc.h and Makefile
Real Time Driver Example Tutorial Home
NO REPRODUCTION OR PUBLISHING ON ANY OTHER WEBSITE THAN ON CAPTAIN.AT IS PERMITTED.
inc.h
// if TIMERINT is defined, the linux timer interrupt is used
// otherwise the parallel port interrupt is used
#define TIMERINT
// if USEMMAP IS defined, also MMAP operations will be made
#define USEMMAP
#define DEV_FILE "demodev0"
#define DEV_FILE_NAME "demodev"
#define DRV_NAME "demodrv"
#define BUFFER_SIZE 100000
#define BUFSIZE 17
#define PAR_INT 7
#define TIMER_INT 0
#define BASEPORT 0x378
#define MMAP 0
#define GETVALUE 1
#define SETVALUE 2
#define STATE_FILE_OPENED 1
#define STATE_TASK_CREATED 2
Makefile
####################################################################
# MAKEFILE TEMPLATE FOR KERNEL MODULES AND USER SPACE APPLICATIONS #
# V0.3 (C) 2006 www.captain.at #####################################
####################################################################
### Names of the kernel module(s) and user space application(s) ####
### separated by spaces ##########################################
### (omit names if no module(s) or application(s) is(are) built) ###
KERNELMODULES ?= realtimedriver
USERAPPS ?= user
### SKIN = xeno, posix etc.
SKIN ?= xeno
UNAME := $(shell uname -r)
KERNELSOURCEDIR ?= /lib/modules/$(UNAME)/build
### Xenomai directory, xeno-config and library directory ###########
XENO_DIR ?= /usr/xenomai
XENO_CONFIG ?= $(XENO_DIR)/bin/xeno-config
XENO_LIB_DIR ?= $(shell $(XENO_CONFIG) --library-dir)
### User space application compile options #########################
USERAPP_LIBS ?= -lnative -lrtdm
USERAPP_LDFLAGS ?= $(shell $(XENO_CONFIG) --$(SKIN)-ldflags)
USERAPP_CFLAGS ?= $(shell $(XENO_CONFIG) --$(SKIN)-cflags)
### General configuration stuff ####################################
CC = $(shell $(XENO_CONFIG) --cc)
####################################################################
#### Usually you don't need to modify this file below this line ####
####################################################################
################ KERNEL MODULE START ###############################
OBJS := ${patsubst %, %.o, $(KERNELMODULES)}
CLEANTHIS := ${patsubst %, .%*, $(KERNELMODULES)}
ifneq ($(KERNELMODULES),)
ifeq ($(findstring 2.6,$(KERNELSOURCEDIR)),2.6)
### KERNEL 2.6 #####################################################
obj-m := $(OBJS)
EXTRA_CFLAGS := -I$(XENO_DIR)/include
PWD := $(shell pwd)
all:: $(USERAPPS)
$(MAKE) -C $(KERNELSOURCEDIR) SUBDIRS=$(PWD) modules
else ###############################################################
### KERNEL 2.4 #####################################################
HELP := -I$(KERNELSOURCEDIR)/include/xenomai/compat -I$(XENO_DIR)/include
INCLUDE := -I$(KERNELSOURCEDIR)/include $(HELP)
CFLAGS := -O2 -Wall -DMODULE -D__KERNEL__ -DLINUX $(INCLUDE)
all:: $(OBJS) $(USERAPPS)
endif
endif
clean::
$(RM) $(CLEANTHIS) *.cmd *.o *.ko *.mod.c
$(RM) -R .tmp*
################ KERNEL MODULE END #################################
################ USER APPLICATIONS START ###########################
ifneq ($(USERAPPS),)
USERSP := ${patsubst %, %.c, $(USERAPPS)}
$(USERAPPS): $(USERSP)
$(CC) -o $@ $< $(USERAPP_CFLAGS) $(USERAPP_LDFLAGS) $(USERAPP_LIBS)
endif
clean::
$(RM) $(USERAPPS)
################# USER APPLICATIONS END ############################
.PHONY: clean
Last-Modified: Sun, 26 Feb 2006 20:44:56 GMT