国产台湾无码AV片在线观看,国产精品一页,国内精品久久久久久久999,欧美日韩免费专区在线,在线偷着国产精选视频,国产日韩欧美视频

 

聯(lián)系我們

聯(lián)系我們

中山市勤龍輸送設(shè)備科技有限公司

聯(lián)系人:黃先生 手機:13420032999

郵箱: qinlong@zgqinlong.com

電話: 0760-22586708

傳真: 0760-22586709

地址:廣東省中山市小欖鎮(zhèn)盛豐社區(qū)興祥路1號F棟之二

您現(xiàn)在的位置:首頁> 技術(shù)專題 技術(shù)專題

一個字符設(shè)備驅(qū)動--點亮和熄滅一個LED設(shè)備

時間:2013/6/10 0:00:00     關(guān)鍵字:

在mini2440開發(fā)板上(CPU是s3c2440)開發(fā)字符設(shè)備驅(qū)動完成一個led燈的亮滅。

1. 環(huán)境

硬件環(huán)境:

Host:X86PC

Target:友善之臂mini2440開發(fā)板

軟件環(huán)境:

Host:VMware虛擬機下的redhat linux 9.0(完全安裝)

Target:arm-linux kernel:linux-2.6.13

Crosstool: arm-linux-gcc-3.3.2

2. 完成過程

⑴驅(qū)動程序文件--mini2440_one_led.c,其具體內(nèi)容如下:

#define DEVICE_NAME "lsq_led"

#define LED_MAJOR 250

#define GPB5_ON 1

#define GPB5_OFF 2

static int mini2440_led_ioctl(

struct inode *inode,

struct file *file,

unsigned int cmd,

unsigned long arg)

{

if (cmd==GPB5_ON) {

//printk("ioctl LEDON successfully\n");

s3c2410_gpio_setpin(S3C2410_GPB5, 0);

return 0;

}

if (cmd==GPB5_OFF) {

//printk("ioctl LEDOFF successfully\n");

s3c2410_gpio_setpin(S3C2410_GPB5, 1);

return 0;

}

printk("ioctl error \n");

return -EFAULT;

}

static struct file_operations mini2440_led_fops = {

.owner = THIS_MODULE,

.ioctl = mini2440_led_ioctl,

};

static int __init mini2440_led_init(void)

{

int ret;

ret = register_chrdev(LED_MAJOR, DEVICE_NAME, &mini2440_led_fops);

if (ret < 0) {

printk(DEVICE_NAME " can''''''''''''''''''''''''''''''''t register major number\n");

return ret;

}

devfs_mk_cdev(MKDEV(LED_MAJOR, 0), S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP, DEVICE_NAME);

s3c2410_gpio_cfgpin(S3C2410_GPB5, S3C2410_GPB5_OUTP);

s3c2410_gpio_setpin(S3C2410_GPB5, 1);

printk(DEVICE_NAME " initialized\n");

return 0;

}

static void __exit mini2440_led_exit(void){

devfs_remove(DEVICE_NAME);

unregister_chrdev(LED_MAJOR, DEVICE_NAME);

}

module_init(mini2440_led_init);

module_exit(mini2440_led_exit);

應(yīng)用程序文件—文件名led.c,其內(nèi)容如下:

#define GPB5_ON 1

#define GPB5_OFF 2

int main(void)

{

//int k;

int dev_fd;

int retval;

dev_fd = open("/dev/lsq_led",O_RDWR | O_NONBLOCK);

if ( dev_fd == -1) {

printf("Can''t open file /dev/lsq_led\n");

exit(-1);

}

printf ("\n/dev/lsq_led opened successfully, fd=%d\n",dev_fd);

wlile(1)

{

retval=ioctl(dev_fd,GPB5_ON,0);

if(retval==-1){

perror("ioctl LEDON error\n");

exit(-1);

}

sleep(1);

retval=ioctl(dev_fd,GPB5_OFF,0);

if(retval==-1){

perror("ioctl LEDOFF error\n");

exit(-1);

}

sleep(1);

}

close(dev_fd);

}

⑶ 編譯應(yīng)用程序led.c的Makefile,其內(nèi)容如下:

all: led

led:

arm-linux-gcc -o led led.c

clean:

@rm -vf mini2440led *.o *~

⑷ 使內(nèi)核撐持和編譯驅(qū)動程序mini2440_one_led.c,需在相應(yīng)的目錄下增加如下內(nèi)容(自己的習(xí)氣,當(dāng)然這一步是可選的):

kernel...../drivers/char/

Makefile

obj-$(CONFIG_MINI2440_ONE_LED) += mini2440_one_led.o

Kconfig

config MINI2440_ONE_LED

tristate "mini2440 one LED Driver"

depends on ARCH_S3C2440

help

mini2440 User led, use GPB5.

   【上一篇:LED市場設(shè)備的分析和發(fā)展     下一篇:LED日光燈老化線的產(chǎn)品用途! 】    【返回】  

更多

服務(wù)熱線

0760-22586708

开江县| 岳池县| 元阳县| 新晃| 祁阳县| 保定市| 凤山市| 上饶市| 汾阳市| 兰西县| 南京市| 石河子市| 永吉县| 杨浦区| 赣州市| 博白县| 平南县| 郧西县| 襄樊市|