hpi 驱动源码

本文档提供了一个针对S3C2410平台的DSP HPI(Host Port Interface)驱动程序的源代码,包括设备打开、释放、读写操作以及中断处理等关键函数的实现。驱动程序使用了内核I/O宏,实现了与硬件的交互,并定义了中断处理函数以获取和更新设备状态。
摘要由CSDN通过智能技术生成

 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

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值