RK3288开发板PopMetal上的GPIO驱动实例
来源:互联网 发布:乐乎城市青年社区投诉 编辑:程序博客网 时间:2024/06/06 19:48
RK3288开发板该驱动需要涉及到的知识点:1,DTS设备树的作用,2,platform虚拟总线驱动的编写。第一步,添加DTS节点在/kernel/arch/arm/boot/dts/rockchip.dts下添加如下内容。下图rockchip-leds-gpio这部分的内容,修改保存, 第二步,在kernel/drivers下创建个LED文件夹,然后加入如下几个文件驱动文件leds.c,Makefile和Kconfig.如下图源码:/************************************************************************************ driver for led0***********************************************************************************/#include <linux/miscdevice.h>#include <linux/input.h>#include <linux/clk.h>#include <linux/delay.h>#include <asm/io.h>#include <asm/uaccess.h>#include <linux/module.h>#include <linux/init.h>#include <linux/of_gpio.h>#include <linux/gpio.h>#include <linux/of_platform.h>static int leds_probe(struct platform_device *pdev){ int ret =-1int iint ledenum of_gpio_flags flagstruct device_node *led_node = pdev->dev.of_nodeled = of_get_named_gpio_flags(led_node,”led-gpios”,0,&flag)printk(“get gpio id successful\n”)if(!gpio_is_valid(led)){ printk(“invalid led-gpios: %d\n”,led) return -1}if(gpio_request(led,”led_gpio”)){printk(“led gpio request failed!\n”)return ret} gpio_direction_output(led,1)for(i=0 i < 10 i++){ gpio_set_value(led,1) mdelay(500) gpio_set_value(led,0) mdelay(500) printk(“it’s %d\n”,i)}return 0}static int leds_remove(struct platform_device *pdev){ return 0}static struct of_device_id leds_of_match[] = { { .compatible = “rockchip-leds-gpio” }, { }}MODULE_DEVICE_TABLE(of, leds_of_match)static struct platform_driver leds_driver = { .driver = { .name = “leds-drivers”, .owner = THIS_MODULE, .of_match_table = of_match_ptr(leds_of_match), }, .probe = leds_probe, .remove = leds_remove,};/*static int __init leds_init(void){ printk(KERN_INFO “Enter %s\n”, __FUNCTION__) return platform_driver_register(&leds_driver) return 0}static void __exit leds_exit(void){platform_driver_unregister(&leds_driver) printk(“close leds\n”)}*/module_platform_driver(leds_driver)module_platform_driver(leds_driver)MODULE_DESCRIPTION(“leds Driver”)MODULE_LICENSE(“GPL”)MODULE_ALIAS(“platform:leds-drivers”)/************************************************************************************ driver for led0***********************************************************************************/Kconfig:Makefile:第三步,修改drivers下的Kconfig和Makefile,修改内容如下在Kconfig末尾添加:source “drivers/led/Kconfig”在Makefile末尾添加: obj-$(CONFIG_LED0_TEST) +=led/第四步,编译新的kernel与resource并烧写进板子里,然后DTS中定义的引脚就会按照驱动的内容,进行高低电平的变化。
阅读全文
0 0
- RK3288开发板PopMetal上的GPIO驱动实例
- RK3288开发板PopMetal上的GPIO驱动实例
- RK3288开发板PopMetal上的GPIO驱动实例
- 芯客网推出PopMetal基于RK3288开源开发板上市!
- PopMetal基于RK3288最强开源开发板
- RK3288开发板GPIO介绍
- 修改RK3288-PopMetal的printk的波特率
- rk3288开发板的shell方式操作底层GPIO
- RK3288的gpio设置
- PopMetal—基于RK3288的开源硬件平台
- 解决Popmetal板上I2C挂载额驱动不正常,含陀螺仪、重力传感器
- [RK3288][Android6.0] 调试笔记 --- 通用GPIO驱动控制LED
- 驱动程序开发--AT91SAM9260的GPIO驱动笔记
- 驱动程序开发--AT91SAM9260的GPIO驱动笔记
- SmartARM2200开发板GPIO驱动学习心得
- NRF52832开发:GPIO驱动
- 【谍照】PopMetal开发板运行Chrome OS
- LCD背光驱动在2440上的实例开发
- HDU
- maven profile不生效解决办法,加上下面插件
- UVA
- 阿里云CentOS7.2系统JavaWeb开发环境搭建
- 整理一下 PagerSlidingTabStrip
- RK3288开发板PopMetal上的GPIO驱动实例
- 判断多选框是否被选中
- 强制文件下载header设置
- linux OSI七层模型、TCP-IP协议栈及每层结构大揭秘
- POJ 3281 Dining(网络流建模)
- PAT (Basic Level) Practise (中文) 1026. 程序运行时间(15)
- 基于概率论的分类方法:朴素贝叶斯
- linux下查看CPU、内存、磁盘信息
- dblink链接数据库简介(oracle)