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

📄 led.c

📁 fft的工业级的EP9315的开发板的所有驱动程序
💻 C
字号:
/*
    i2c-dev.c - i2c-bus driver, char device interface  

    Copyright (C) 1995-97 Simon G. Vogl
    Copyright (C) 1998-99 Frodo Looijaard <frodol@dds.nl>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

/* Note that this is a complete rewrite of Simon Vogl's i2c-dev module.
   But I have used so much of his original code and ideas that it seems
   only fair to recognize him as co-author -- Frodo */

/* The I2C_RDWR ioctl code is written by Kolja Waschk <waschk@telos.de> */

/* The devfs code is contributed by Philipp Matthias Hahn 
   <pmhahn@titan.lahn.de> */

/* $Id: i2c-dev.c,v 1.40 2001/08/25 01:28:01 mds Exp $ */

/**********Copyright (c)*********************************
**                   西安傅立叶电子有限公司
**                                     研    发    部
**                              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"
#include "linux/init.h"
#include "linux/devfs_fs_kernel.h"
#include "linux/init.h"

#if LINUX_KERNEL_VERSION >= KERNEL_VERSION(2,4,0)
#include  "linux/smp_lock.h"
#endif 
char         kernel_version[]=UTS_RELEASE;

#define  FFTLED_MAJOR  19
devfs_handle_t  dev_handle4; 

/* struct file_operations changed too often in the 2.1 series for nice code */
static ssize_t led_read (struct file *file, char *buf, size_t count,loff_t *offset)
{
    return 0;	
}

static ssize_t led_write (struct file *file, const char *buf, size_t count,loff_t *offset)
{
	
	return 0;
}

static int led_ioctrl (struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
{
    outl(cmd,GPIO_PADR);
    return 0;
}

static int led_open (struct inode *inode, struct file *file)
{
	MOD_INC_USE_COUNT;
	return 0;
}
/*******************************************************
*函数原形:open_fftpwm(struct inode *inode,struct file *file)
*参数:               
*返回值 : 
*函数说明:
/*******************************************************/
static int led_release(struct inode *inode,struct file *file)
{
    MOD_DEC_USE_COUNT;
    return 0;
}

static struct file_operations fftled_fops = {
#if LINUX_KERNEL_VERSION >= KERNEL_VERSION(2,4,0)
	owner:		THIS_MODULE,
#endif /* LINUX_KERNEL_VERSION >= KERNEL_VERSION(2,4,0) */
	read:		led_read,
	write:		led_write,
	ioctl:		led_ioctrl,
	open:		led_open,
	release:    led_release,
};

static  int  __init led_dev_init(void)
{
	
   int result;
   int uiTemp;
   dev_handle4 = devfs_register( NULL, "fftled", DEVFS_FL_DEFAULT, FFTLED_MAJOR, 0, S_IFCHR, &fftled_fops, NULL);
   /*result=register_chrdev(0,"fftled",&fftled_fops);           //??????,?????????
   if(result<0)
   {
      printk("cannot get fftled major number\n");           //????
      return result;
   }*/
   printk("congraulation,fftled are successful registed\n");
   uiTemp = inl(SYSCON_DEVCFG);                           //read the syscon register value
   uiTemp &= ~(SYSCON_DEVCFG_A1onG); 
   SysconSetLocked(SYSCON_DEVCFG, uiTemp);
   outl(0xff,GPIO_PADDR);
   outl(0x00,GPIO_PADR);
   /*if(fftled_major==0)
   {
      fftled_major=result;                                 //???????
   }*/
   return 0;
}

static void __exit leddev_cleanup(void)
{
	
	    int res;
	    outl(0xff,GPIO_PADR);
        devfs_unregister (dev_handle4);
        /*if ((res = unregister_chrdev(fftled_major,"fftled"))) 
	    {
		
			printk("i2c-dev.o: unable to release major %d for i2c bus\n",
			fftled_major);
		}*/
        		
}

module_init(led_dev_init);
module_exit(leddev_cleanup);

EXPORT_NO_SYMBOLS;
//MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl> and Simon G. Vogl <simon@tk.uni-linz.ac.at>");
//MODULE_DESCRIPTION("I2C /dev entries driver");
MODULE_LICENSE("GPL");

⌨️ 快捷键说明

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