天嵌 ARM开发社区

 找回密码
 注册
查看: 1984|回复: 3

tq210 android系统下的led驱动,怎样改成让灯一闪一闪的?

[复制链接]
moonswift 发表于 2014-3-21 09:34:35 | 显示全部楼层 |阅读模式
控制led亮灭的函数式这个:
/**
*函数功能:用于控制led的亮灭
*控制字为cmd,arg为控制哪个灯的亮灭取值范围为0-1:cmd为IOCTL_GPIO_ON时亮,cmd为IOCTL_GPIO_OFF为灭
**/

static long tq210_gpio_ioctl(
        struct file *file,
        unsigned int cmd,
        unsigned long arg)
{
        arg -= 1;
        if (arg > sizeof(gpio_table)/sizeof(unsigned long))
        {
                return -EINVAL;
        }

        switch(cmd)
        {
        case IOCTL_GPIO_ON:
                // 设置指定引脚的输出电平为1
                gpio_direction_output(gpio_table[arg], 1);
                //s3c_gpio_setpin(gpio_table[arg], 1);
                return 0;

        case IOCTL_GPIO_OFF:
                // 设置指定引脚的输出电平为0
                gpio_direction_output(gpio_table[arg], 0);
                //s3c_gpio_setpin(gpio_table[arg], 0);
                return 0;

        default:
                return -EINVAL;
        }
}
TQ-ZQL 发表于 2014-3-21 10:38:10 | 显示全部楼层
加个for不就可以了吗?
 楼主| moonswift 发表于 2014-3-23 15:20:34 | 显示全部楼层
TQ-ZQL 发表于 2014-3-21 10:38
加个for不就可以了吗?

如果是,按下按钮,led亮0.5s后自动熄灭,该怎么做?
s1005056 发表于 2014-3-28 13:20:18 | 显示全部楼层
用gpio_direction_input跟gpio_get_value來取得gpio腳的電壓?
參考:http://rritw.com/a/bianchengyuyan/C__/20130411/338161.html

沒試過就是了
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

i.MX8系列ARM cortex A53 M4 工控板上一条 /1 下一条

Archiver|手机版|小黑屋|天嵌 嵌入式开发社区 ( 粤ICP备11094220号 )

GMT+8, 2024-5-19 19:29 , Processed in 1.062500 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表