|
控制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;
}
}
|
|