判断哪些文件被编译进内核:

1、通过 make menuconfig 查看

2、比如查看gpio类型的文件,输入 ls drivers/gpio/*.o,有生成.o文件表示被编译进内核

在编写驱动程序之前要保证该GPIO口没有被其他程序占用,若被占用则需要取消编译那个驱动程序。

/arch/arm/mach-exynos/include/mach/gpio-exynos4.h

/drivers/gpio/gpio-exynos4.c

#include

#include

/*驱动注册的头文件,包含驱动的结构体和注册和卸载的函数*/

#include

/*注册杂项设备头文件*/

#include

/*注册设备节点的文件结构体*/

#include

/*Linux中申请GPIO的头文件*/

#include

/*三星平台的GPIO配置函数头文件*/

/*三星平台EXYNOS系列平台,GPIO配置参数宏定义头文件*/

#include

#include

/*三星平台4412平台,GPIO宏定义头文件*/

#include

#define DRIVER_NAME "hello_ctl"

#define DEVICE_NAME "hello_ctl"

MODULE_LICENSE("Dual BSD/GPL");

MODULE_AUTHOR("TOPEET");

static long hello_ioctl( struct file *files, unsigned int cmd, unsigned long arg){

printk("cmd is %d,arg is %d\n",cmd,arg);

if(cmd > ){

printk(KERN_EMERG "cmd is 0 or 1\n");

}

if(arg > ){

printk(KERN_EMERG "arg is only 1\n");

}

gpio_set_value(EXYNOS4_GPL2(),cmd);

return ;

}

static int hello_release(struct inode *inode, struct file *file){

printk(KERN_EMERG "hello release\n");

return ;

}

static int hello_open(struct inode *inode, struct file *file){

printk(KERN_EMERG "hello open\n");

return ;

}

static struct file_operations hello_ops = {

.owner = THIS_MODULE,

.open = hello_open,

.release = hello_release,

.unlocked_ioctl = hello_ioctl,

};

static struct miscdevice hello_dev = {

.minor = MISC_DYNAMIC_MINOR,

.name = DEVICE_NAME,

.fops = &hello_ops,

};

static int hello_probe(struct platform_device *pdv){

int ret;

printk(KERN_EMERG "\tinitialized\n");

ret = gpio_request(EXYNOS4_GPL2(),"LEDS");

if(ret < ){

printk(KERN_EMERG "gpio_request EXYNOS4_GPL2(0) failed!\n");

return ret;

}

s3c_gpio_cfgpin(EXYNOS4_GPL2(),S3C_GPIO_OUTPUT);

gpio_set_value(EXYNOS4_GPL2(),);

misc_register(&hello_dev);

return ;

}

static int hello_remove(struct platform_device *pdv){

printk(KERN_EMERG "\tremove\n");

misc_deregister(&hello_dev);

return ;

}

static void hello_shutdown(struct platform_device *pdv){

;

}

static int hello_suspend(struct platform_device *pdv,pm_message_t pmt){

return ;

}

static int hello_resume(struct platform_device *pdv){

return ;

}

struct platform_driver hello_driver = {

.probe = hello_probe,

.remove = hello_remove,

.shutdown = hello_shutdown,

.suspend = hello_suspend,

.resume = hello_resume,

.driver = {

.name = DRIVER_NAME,

.owner = THIS_MODULE,

}

};

static int hello_init(void)

{

int DriverState;

printk(KERN_EMERG "HELLO WORLD enter!\n");

DriverState = platform_driver_register(&hello_driver);

printk(KERN_EMERG "\tDriverState is %d\n",DriverState);

return ;

}

static void hello_exit(void)

{

printk(KERN_EMERG "HELLO WORLD exit!\n");

platform_driver_unregister(&hello_driver);

}

module_init(hello_init);

module_exit(hello_exit);

linux driver ------ 字符设备驱动 之 &OpenCurlyDoubleQuote; 创建设备节点流程 ”

在字符设备驱动开发的入门教程中,最常见的就是用device_create()函数来创建设备节点了,但是在之后阅读内核源码的过程中却很少见device_create()的踪影了,取而代之的是device ...

linux driver error ------ 编译驱动出现 ERROR&colon; Kernel configuration is invalid

ERROR: Kernel configuration is invalid.         include/generated/autoconf.h or include/config/au ...

树莓派GPIO口驱动编写

一.wiringpi写法 #include #include int main(int argc,char *argv[]) { ...

如何编写linux下nand flash驱动-4

2.       软件方面 如果想要在Linux下编写Nand Flash驱动,那么就先要搞清楚Linux下,关于此部分的整个框架.弄明白,系统是如何管理你的nand flash的,以及,系统都帮你做 ...

nand flash详解及驱动编写

https://www.crifan.com/files/doc/docbook/linux_nand_driver/release/html/linux_nand_driver.html#nand_ ...

Linux驱动:I2C驱动编写要点

继续上一篇博文没讲完的内容“针对 RepStart 型i2c设备的驱动模型”,其中涉及的内容有:i2c_client 的注册.i2c_driver 的注册.驱动程序的编写. 一.i2c 设备的注册分析 ...

ARM Linux驱动篇 学习温度传感器ds18b20的驱动编写过程

linux编写gpio驱动程序,linux driver ------ GPIO的驱动编写和调用相关推荐

  1. Linux I2C总线(二)I2C设备驱动编写方法

    Linux I2C总线 Linux I2C总线(一)I2C驱动框架 Linux I2C总线(二)I2C设备驱动编写方法 Linux I2C总线(二)I2C设备驱动编写方法 文章目录 Linux I2C ...

  2. linux cdc设备驱动程序,Linux Kernel 'cdc-wdm' USB设备驱动程序堆缓冲区溢出漏洞

    发布日期:2013-03-14 更新日期:2013-03-19 受影响系统: Linux kernel 3.x Linux kernel 2.6.x 描述: --------------------- ...

  3. linux c蜂鸣器驱动程序,Linux 设备驱动简析—PC蜂鸣器驱动

    /* *By Neil Chiao () *欢迎到"新星湾()"指导 */ 在X86平台的主板上一般都有一个蜂鸣器,有人可能认为这么简单的东西,根本不需要驱动吧?但是其实Linux ...

  4. linux查看录音驱动程序,linux驱动由浅入深系列:ALSA框架详解 音频子系统之二

    本文以高通平台为例,介绍一下android下的音频结构.android使用的是tinyALSA作为音频系统,使用方法和基本框架与linux中常用的ALSA音频子系统是一致的. ALSA音频框架 ALS ...

  5. linux usb 总线驱动程序,Linux下的USB总线驱动

    一.USB理论 1.      USB概念概述 USB1.0版本速度1.5Mbps(低速USB) USB1.1版本速度12Mbps(全速USB)  USB2.0版本速度480Mbps(高速USB) U ...

  6. linux 网卡的驱动程序,Linux网卡驱动程序代码

    广告 100%的CPU性能,计算能力不会降低!选择最主流的云服务器来满足各种业务需求,有数百种流行的云产品和8888元起价套餐,可帮助行业恢复工作! 获取网卡信息的代码示例. 通过命令获取arp(地址 ...

  7. linux iic总线驱动程序,linux总线驱动之初识i2c驱动数据传输流程

    吃个晚饭,画个流程图,没想到已经这么晚了.还是速度把这篇文章搞定,收拾回去了. 先看下linux中的i2c的数据流程图吧.这里主要是用gpio模拟的i2c的. 还是具体看下代码吧,流程只是个大概,和i ...

  8. linux 禁用 内核 驱动程序,Linux设备驱动程序学习----5.模块的初始化和关闭

    模块的初始化和关闭 1. 初始化函数 模块的初始化函数负责注册模块所提供的任何设施,即可以被应用程序访问的新功能,可能是一个完整的驱动程序或者仅仅是一个新的软件抽象.初始化函数的定义通常如下所示: s ...

  9. linux内核 块驱动程序,linux – 为什么内核使用默认的块驱动程序而不是我的驱动程序代码?...

    我写了一个块驱动程序,它创建了一个虚拟块设备(sbd0).我为该块设备注册了所有设备操作:(请参阅2.6.32内核源代码中的include / linux / blkdev.h) static str ...

最新文章

  1. ubuntu如何打开命令行
  2. [转]设计高效SQL: 一种视觉的方法
  3. 用 Jackson 来处理 JSON
  4. python小项目-python 的一些小项目
  5. leetcode算法题--最长数对链
  6. java的framework_JAVA FRAMEWORK
  7. ROS中配置主从机需注意的几点
  8. phpDocumentor
  9. E1 PCM复用设备能当程控交换机用吗?
  10. MySQL对字符集_对MySQL字符集的认识
  11. 自己动手写Docker系列 -- 5.2实现查看运行中的容器
  12. 链表的应用 —— 实现 LRU(least recently unused)
  13. 数据库更新DATE类型的时间
  14. 通过HttpURLConnection模拟post表单提交
  15. 神经网络求解二阶常微分方程
  16. openresty性能调优
  17. 手动打开与关闭软键盘
  18. java赵云主角兵器谱游戏_赵云赵子龙的外号有哪些?赵云的武器是什么 赵
  19. 百兆网线和千兆网线做法的区别
  20. 一个误操作导致 5.4 万 Star 全部归零,10年的心血...

热门文章

  1. 群晖DSM7 使用Zerotier实现无公网IP外网访问
  2. 别找了,你要的财务预算表都在Smartbi
  3. 对 HTML 语义化的理解
  4. 一个简单的生产排程软件
  5. 安装RTAB-MAP,并用RealSense R200运行
  6. 复旦大学工研院生物医学工程考研经验贴(专业课957)
  7. 情感分析论文阅读之《Aspect Level Sentiment Classification with Deep Memory Network》
  8. 中国清洁供热行业运营状况与投资前景规划报告2022-2028年版
  9. Android camera系列:DNG格式
  10. iphone3开发基础教程中文版高清PDF全集迅雷高速下载