⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 driver.c

📁 fft的工业级的EP9315的开发板的所有驱动程序
💻 C
字号:
/****************************************Copyright (c)**************************************************
**                                  XIAN FFT-COMPANY STUDYING ROM
**                                   
**                              http://www.FFTChina.com
**-----------------------------------------文件信息-----------------------------------------------------
**文   件   名: cantest.c
**创   建   人: 
**最后修改日期: 2005年6月30日
**描        述: CAN模块测试驱动程序(查询模式)
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
#ifndef __KERNEL__
#define __KERNEL__
#endif
#ifndef MODULE
#define MODULE
#endif
#include  "linux/capability.h"
#include  "linux/smp_lock.h"
#include "linux/module.h"
#include "asm/hardware.h"
#include "asm/io.h"

#if LINUX_KERNEL_VERSION >= KERNEL_VERSION(2,4,0)
#include  "linux/smp_lock.h"
#endif

#include  "iic.c"
char   kernel_version[]=UTS_RELEASE;
/*******************************************************
*函数原形:read_fftiic(struct file *file, char *buf, size_t count,loff_t *f_pos)
*参数:        buf  : 传入该函数的数据缓冲区指针
*	           count:CAN的通道号
*返回值 : 0
*函数说明:读出接收到的CAN数据
/*******************************************************/

 int  read_fftiic(struct file *file, char *buf, size_t count,loff_t *f_pos)
{	
     P8563_gettime(*buf);
     for(i = 0;i < 4 ;i++)
        printk("time %x\n",buf[i]);
     return 0;
}

/*******************************************************
*函数原形:write_fftiic(struct file *file,const char *buf,size_t count,loff_t *f_pos)
*参数:    buf  : 传入该函数的数据缓冲区指针
*	       count:CAN的通道号
*返回值 : 0 说明成功写入
*函数说明:向CAN总线发送数据
/*******************************************************/

int  write_fftiic(struct file *file,const char *buf,size_t count,loff_t *f_pos)
{    
	
	return 0;	
}

/*******************************************************
*函数原形:open_fftiic(struct inode *inode,struct file *file)
*参数:               
*返回值 : 
*函数说明:
/*******************************************************/

int open_fftiic(struct inode *inode,struct file *file)
{   
    return 0;
}

/*******************************************************
*函数原形:open_fftiic(struct inode *inode,struct file *file)
*参数:               
*返回值 : 
*函数说明:
/*******************************************************/
int release_fftiic(struct inode *inode,struct file *file)
{
    return 0;
}
/***************************************************************************************************
*函数原形:ioctl_fftiic(struct inode *inode,struct file *file,unsigned int cmd,unsigned long arg)
*参数:    cmd  : 传入该函数的命令参数
*	           0  :判断是否CAN0收到可用数据
               1  :判断是否CAN1收到可用数据
               3  :初始化CAN0总线
               4  :初始化CAN1总线   
           arg :传入的参数
*返回值 :     0  :接收到有效数据 
               1  :没有接收到有效数据
               3  :成功初始化CAN0
               4  :成功初始化CAN1
               5  :无效的命令 
*函数说明:向CAN总线发送数据
/**************************************************************************************************/
static int ioctl_fftiic(struct inode *inode,struct file *file,unsigned int cmd,unsigned long arg)
{
   return 0;
}
/**************************************
** 函数指针结构: file_operations
** 说明        :
***************************************/
struct file_operations fftiic_fops={

  	read :      read_fftiic,
    write:      write_fftiic,
	ioctl:	    ioctl_fftiic,
	open :	    open_fftiic,
    release:    release_fftiic,

};
/******************************************************
**  初始化模块:在加载模块时候调用
**  函数原形  : init_module(void)
**  说    明  :不用修改
******************************************************/
 int  init_module(void)
{
   int result;
   result=register_chrdev(0,"fftiic",&fftiic_fops);           //注册一个设备,得到驱动的主设备号
   if(result<0)
   {
      printk("cannot get fftiic major number\n");           //没有成功
      return result;
   }
   printk("congraulation,fftiic are successful registed\n");
   outl(0x03,GPIO_EEDRIVE);         //init io port to be IIC interface
   P8563_init();
   if(fftiic_major==0)
   {
      fftiic_major=result;                                 //记录下主设备号
   }
   return 0;
}
/*******************************************************
**  函数原形 : cleanup_module(void)
**  说明     : 在卸载模块时调用
******************************************************/
void cleanup_module(void)
{
   unregister_chrdev(fftiic_major,"fftiic");
   printk("exit fftiic\n");

}
MODULE_LICENSE("GPL");



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -