moonswift 发表于 2014-3-21 09:34:35

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

控制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, 1);
                //s3c_gpio_setpin(gpio_table, 1);
                return 0;

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

        default:
                return -EINVAL;
        }
}

TQ-ZQL 发表于 2014-3-21 10:38:10

{:2_136:}加个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

沒試過就是了
页: [1]
查看完整版本: tq210 android系统下的led驱动,怎样改成让灯一闪一闪的?