快速业务通道

Davinci DM6446开发攻略——LINUX GPIO驱动源码移植

作者 佚名技术 来源 Linux系统 浏览 发布时间 2012-04-16
depends on ARCH_DAVINCI help This option enables support for LEDs and Buzzer connected to GPIO lines on Ti Davinci DM644x CPUs, such as the DM6446. 修改Makefile文件,在128行 obj-$(CONFIG_DAVINCI_DM646X_TSIF) = tsif_control.o tsif_data.o下面,加入: obj-$( DAVINCI_DM644X_GPIOS) = davinci_dm644x_gpios.o 修改linux-2.6.18 内核menu配置 选上“Character devices”里的“Davinci DM644x GPIOs”,保存修改后的配置,然后make uImage,对内核的编译; 四、GPIO应用程序源码 源码添加: /* dm644x_gpio_test.c*/ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/ioctl.h> /* ./dm644x_gpio_test 0 1 */ //led0 on /* ./dm644x_gpio_test 0 0 */ //led0 off /* ./dm644x_gpio_test 1 1 */ //led1 on /* ./dm644x_gpio_test 1 0 */ //led1 off /* ./dm644x_gpio_test 2 1 */ // buzzer on /* ./dm644x_gpio_test 2 0 */ // buzzer off int main(int argc, char **argv) { int on; int gpio_number; int fd; // argv[0]== dm644x_gpio_test // argv[1]== gpio_number // argv[1]== on if (argc != 3 || sscanf(argv[1], "%d", &gpio_number) != 1 || sscanf(argv[2],"%d", &on) != 1 ||on < 0 || on > 1 || gpio _number < 0 || gpio _number > 3) { fprintf(stderr, "Usage:\n"); fprintf(stderr, "\t dm644x_gpio_test gpio_number on|off\n"); fprintf(stderr, "Options:\n"); fprintf(stderr, "\t gpio_number from 0 to 2\n"); fprintf(stderr, "\t on 1 off 0\n"); exit(1); } fd = open("/dev/dm644x_gpios", 0); if (fd < 0) { perror("open device /dev/dm644x_gpios"); exit(1); } ioctl(fd, on, gpio_number); close(fd); return 0; } Makefile添加: #application makefile for dm644x gpio test CROSSCOMPILE = arm_v5t_le- CC=$(CROSSCOMPILE)gcc LD=$(CROSSCOMPILE)ld OBJCOPY=$(CROSSCOMPILE)objcopy OBJDUMP=$(CROSSCOMPILE)objdump INCLUDE = /home/user/linux-2.6.18_pro500/include/*指向你的内核include*/ all: dm644x_gpio_test dm644x_gpio_test: dm644x_gpio_test.c $(CROSSCOMPILE)gcc -Wall -O2 dm644x_gpio_test.c -I $(INCLUDE) -o dm644x_gpio_test $(CROSSCOMPILE)strip dm644x_gpio_test cp -f dm644x_gpio_test /home/user/nfs/target/opt/app/ clean: @rm -vf dm644x_gpio_test *.o *~ 五、文件系统节点添加 文件系统里,/etc/init.d/rcS文件 # Run /etc/rc.d/rc.local if it exists [ -x /etc/rc.d/rc.local ] && /etc/rc.d/rc.local 前面加mknod /dev/dm644x_gpios c 199 0或在shell命令行下执行mknod /dev/dm644x_gpios c 199 0;这就是静态分配设备节点的做法. 运行系统,进入shell命令下, #cd / opt/app/ #./ dm644x_gpio_test 0 1可以控制点亮LED0 等等,有平台的朋友可

凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

分享到: 更多

Copyright ©1999-2011 厦门凌众科技有限公司 厦门优通互联科技开发有限公司 All rights reserved

地址(ADD):厦门软件园二期望海路63号701E(东南融通旁) 邮编(ZIP):361008

电话:0592-5908028 传真:0592-5908039 咨询信箱:web@lingzhong.cn 咨询OICQ:173723134

《中华人民共和国增值电信业务经营许可证》闽B2-20100024  ICP备案:闽ICP备05037997号