2024年5月11日发(作者:)
S3C2410_
最近在做LED的驱动程序,编译出现很多问题。出现问题的代码如下:
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define DEVICE_NAME "leds"
static unsigned long led_table [] = {
S3C2410_GPB5,
S3C2410_GPB6,
S3C2410_GPB7,
S3C2410_GPB8,
};
static unsigned int led_cfg_table [] = {
S3C2410_GPB5_OUTP,
S3C2410_GPB6_OUTP,
S3C2410_GPB7_OUTP,
S3C2410_GPB8_OUTP,
};
static int sbc2440_leds_ioctl(
struct inode *inode,
struct file *file,
unsigned int cmd,
unsigned long arg)
{
switch(cmd) {
case 0:
case 1:
if (arg > 4) {
return -EINVAL;
}
s3c2410_gpio_setpin(led_table[arg], !cmd);
return 0;
default:
return -EINVAL;
}
}
static struct file_operations dev_fops = {
.owner = THIS_MODULE,
.ioctl = sbc2440_leds_ioctl,
};
static struct miscdevice misc = {
.minor = MISC_DYNAMIC_MINOR,
.name = DEVICE_NAME,
.fops = &dev_fops,
};
static int __init dev_init(void)
{
int ret;
int i;
for (i = 0; i < 4; i++) {
s3c2410_gpio_cfgpin(led_table[i], led_cfg_table[i]);
s3c2410_gpio_setpin(led_table[i], 0);
}
ret = misc_register(&misc);
printk (DEVICE_NAME"tinitializedn");
return ret;
}
static void __exit dev_exit(void)
{
misc_deregister(&misc);
}
module_init(dev_init);
module_exit(dev_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("FriendlyARM Inc.");
编译make ARCH=arm CROSS_COMPILE=arm-linux-,出现错误:
e/guoqian/4.3.1/linux-2.6.32.2 M=/home/guoqian/led modules ARCH=arm CROSS_COMPILE=arm-linux-
make[1]: Entering directory `/home/guoqian/4.3.1/linux-2.6.32.2'
CC [M] /home/guoqian/led/mini2440_leds.o
/home/guoqian/led/mini2440_leds.c:29: error: 'S3C2410_GPB5' undeclared here (not in a function)
/home/guoqian/led/mini2440_leds.c:30: error: 'S3C2410_GPB6' undeclared here (not in a function)
/home/guoqian/led/mini2440_leds.c:31: error: 'S3C2410_GPB7' undeclared here (not in a function)
/home/guoqian/led/mini2440_leds.c:32: error: 'S3C2410_GPB8' undeclared here (not in a function)
/home/guoqian/led/mini2440_leds.c:36: error: 'S3C2410_GPB5_OUTP' undeclared here (not in a function)
/home/guoqian/led/mini2440_leds.c:36: error: initializer element is not constant
/home/guoqian/led/mini2440_leds.c:36: error: (near initialization for 'led_cfg_table[0]')
/home/guoqian/led/mini2440_leds.c:37: error: 'S3C2410_GPB6_OUTP' undeclared here (not in a function)
/home/guoqian/led/mini2440_leds.c:37: error: initializer element is not constant
/home/guoqian/led/mini2440_leds.c:37: error: (near initialization for 'led_cfg_table[1]')
/home/guoqian/led/mini2440_leds.c:38: error: 'S3C2410_GPB7_OUTP' undeclared here (not in a function)
/home/guoqian/led/mini2440_leds.c:38: error: initializer element is not constant
/home/guoqian/led/mini2440_leds.c:38: error: (near initialization for 'led_cfg_table[2]')
/home/guoqian/led/mini2440_leds.c:39: error: 'S3C2410_GPB8_OUTP' undeclared here (not in a function)
/home/guoqian/led/mini2440_leds.c:39: error: initializer element is not constant
/home/guoqian/led/mini2440_leds.c:39: error: (near initialization for 'led_cfg_table[3]')


发布评论