Author-------Dansen-----xzd2734@163.com
给出我写的源码,其中中断和几个变量是为了追球的任务特别添加的,基本不是通用的,还能继续改进的吧,不过暂时先这么用了。没有对中断中使用的共享变量进行保护啊,这是错误的地方,至少要关中断啊!再修改了!
/*
Dsp hpi interface with ARM 9 for s3c2410
Author--------Dansen----2007.09.05
*/
#ifndef __KERNEL__
# define __KERNEL__
#endif
#ifndef MODULE
# define MODULE
#endif
#include <linux/config.h>
#include <linux/module.h>
#include <linux/kernel.h> /* printk() */
#include <linux/slab.h> /* kmalloc() */
#include <linux/ioport.h>
#include <linux/fs.h> /* everything... */
#include <linux/errno.h> /* error codes */
#include <linux/types.h> /* size_t */
#include <linux/proc_fs.h>
#include <linux/fcntl.h> /* O_ACCMODE */
#include <asm/uaccess.h>
#include <asm/hardware.h>
#include <asm/io.h>
#include <asm/irq.h>
//#define HPI_DEBUG
#undef PDEBUG /* undef it, just in case */
#ifdef HPI_DEBUG
# ifdef __KERNEL__ /* This one if debugging is on, and kernel space */
# define PDEBUG(fmt, args...) printk( KERN_EMERG "hpi: " fmt, ## args)
# else /* This one for user space */
# define PDEBUG(fmt, args...) fprintf(stderr, fmt, ## args)
# endif
#else
# define PDEBUG(fmt, args...) /* not debugging: nothing */
#endif
#define HPI_BASEADDR 0x10000300 // BANK 2
#define HPI_MAJOR 200 /* dynamic major by default */
#define HPI_INT IRQ_EINT19
#define HPI_MAGIC 'K'
#define HPI_RESET _IO(HPI_MAGIC, 0)
#define Write_HPIC _IO(HPI_MAGIC, 1)
#define Read_HPIC _IO(HPI_MAGIC, 2)
#define Write_HPIA _IO(HPI_MAGIC, 3)
#define Read_HPIA _IO(HPI_MAGIC, 4)
#define Write_HPID_Auto _IO(HPI_MAGIC, 5)
#define Read_HPID_Auto _IO(HPI_MAGIC, 6)
#define Write_HPID _IO(HPI_MAGIC, 7)
#define Read_HPID _IO(HPI_MAGIC, 8)
#define Auto_HPID _IO(HPI_MAGIC, 9)
#define NoAuto_HPID _IO(HPI_MAGIC, 10)
#define Set_DSPINT _IO(HPI_MAGIC, 11)
#define Get_ball_found _IO(HPI_MAGIC, 12)
#define Get_ball_cy _IO(HPI_MAGIC, 13)
#define