任务:实现led1\led2\led3三盏灯进行点亮,并且使用结构体进行映射
led.h文件>>>
#ifndef __LED_H__
#define __LED_H__
typedef struct
{
volatile unsigned int MODER;
volatile unsigned int OTYPER;
volatile unsigned int OSPEEDR;
volatile unsigned int PUPDR;
volatile unsigned int IDR;
volatile unsigned int ODR;
}gpio_t;
#define GPIOE ((gpio_t*)0x50006000)
#define GPIOF ((gpio_t*)0x50007000)
#define RCC (0x50000A28)
#endif
mycdev.c驱动源码>>>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/uaccess.h>
#include <linux/io.h>
#include "led.h"
#define CNAME "myled"
int major;
char kbuf[128]={0};
volatile unsigned int* vir_rcc;
gpio_t* vir_gpioe;
gpio_t* vir_gpiof;
int mycdev_open(struct inode *inode,struct file *file)
{
printk("%s:%s:%d\n",__FILE__,__func__,__LINE__);
return 0;
}
ssiz