联大大纲—通信—电子
;教师介绍;
单片机课程学习经验-
学习路线图;
1.概述
-应用
-定义
-特点
-构成;
2.嵌入式处理器
—DIY CPU
—处理器
—ARM处理器
—Cortex-A8
—S5PV210
—讨论;
3.汇编语言
-作业
4.Bootloader
-作业
5.Linux内核移植
6.嵌入式Linux程序设计
7.图形用户接口QT
8.其他框架介绍;
9.嵌入式物联网应用系统设计
#include <linux/kernel.h> #include <linux/module.h> #include <linux/miscdevice.h> #include <linux/fs.h> #include <linux/types.h> #include <linux/moduleparam.h> #include <linux/slab.h> #include <linux/ioctl.h> #include <linux/cdev.h> #include <linux/delay.h>
#include <mach/gpio.h> #include <mach/regs-gpio.h> #include <plat/gpio-cfg.h>
#define DEVICE_NAME "leds"
static int led_gpios[] = { S5PV210_GPJ2(0), S5PV210_GPJ2(1), S5PV210_GPJ2(2), S5PV210_GPJ2(3), };
#define LED_NUM ARRAY_SIZE(led_gpios)
static long mini210_leds_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) { switch(cmd) { case 0: case 1: if (arg > LED_NUM) { return -EINVAL; }
gpio_set_value(led_gpios[arg], !cmd); //printk(DEVICE_NAME": %d %d\n", arg, cmd); break;
default: return -EINVAL; }
return 0; }
static struct file_operations mini210_led_dev_fops = { .owner = THIS_MODULE, .unlocked_ioctl = mini210_leds_ioctl, };
static struct miscdevice mini210_led_dev = { .minor = MISC_DYNAMIC_MINOR, .name = DEVICE_NAME, .fops = &mini210_led_dev_fops, };
static int __init mini210_led_dev_init(void) { int ret; int i;
for (i = 0; i < LED_NUM; i++) { ret = gpio_request(led_gpios[i], "LED"); if (ret) { printk("%s: request GPIO %d for LED failed, ret = %d\n", DEVICE_NAME, led_gpios[i], ret); return ret; }
s3c_gpio_cfgpin(led_gpios[i], S3C_GPIO_OUTPUT); gpio_set_value(led_gpios[i], 1); }
ret = misc_register(&mini210_led_dev);
printk(DEVICE_NAME"\tinitialized\n");
return ret; }
static void __exit mini210_led_dev_exit(void) { int i;
for (i = 0; i < LED_NUM; i++) { gpio_free(led_gpios[i]); }
misc_deregister(&mini210_led_dev); }
module_init(mini210_led_dev_init); module_exit(mini210_led_dev_exit);
MODULE_LICENSE("GPL"); MODULE_AUTHOR("Inc.");