OK6410A學(xué)習(xí)筆記三:嵌入式Linux驅(qū)動之LED驅(qū)動
Windows7 + vmware workstation 6.5 + Ubuntu9.10
Linux Source Code: FORLINX_linux-3.0.1.tar.gz
ARM CROSS GCC: arm-linux-gcc v4.3.2
源碼:
//s3c6410_led.c – driver file
#include
#include
#include
#include
#include
#define DEV_MAJOR 176
#define DEV_NAME "s3c6410_leds"
#define GPMCON 0x7F008820
#define GPMDAT 0x7F008824
#define GPMPUD 0x7F008828
volatile unsigned long *gpmcon = NULL;
volatile unsigned long *gpmdat = NULL;
volatile unsigned long *gpmpud = NULL;
static int s3c6410_led_open(struct inode *inode, struct file *filp)
{
}
static ssize_t s3c6410_led_write(struct file *filp,const char __user *buf,size_t count,loff_t *ppos)
{
}
struct file_operations s3c6410_led_flops = {
};
static int __init s3c6410_led_init(void)
{
}
static void __exit s3c6410_led_exit(void)
{
}
module_init(s3c6410_led_init);
module_exit(s3c6410_led_exit);
MODULE_DESCRIPTION("This is led driver sample for OK6410A board.");
MODULE_VERSION("1.0");
MODULE_AUTHOR("");
MODULE_LICENSE("Dual BSD/GPL");
//s3c6410_led_test.c – test file
#include
#include
int main(int argc,char* argv[])
{
}
解析:
1.
2.
3.
4.
驅(qū)動程序Makefile如下:
obj-m:=s3c6410_led.o
KERNELDIR?=/usr/src/linux-3.0.1
default:
$(MAKE) -C $(KERNELDIR) M=$(shell pwd) modules
clean:
rm -rf *.o *~ *.ko *.mod.c *.order *.symvers
在終端下執(zhí)行如下命令:
#make //編譯驅(qū)動程序,得到s3c6410_led.ko文件
#arm-linux-gcc s3c6410_led_test.c –o s3c6410_led_test //編譯測試源碼
5.
評論