Android 从上到下写一个例子 驱动加载(四)

Android HAL LED驱动示例
本文提供了一个Android HAL层LED驱动的实现示例,通过具体的C语言代码展示了如何注册字符设备,实现基本的读写及ioctl操作,并配置GPIO来控制LED的状态。

本文继上一篇文章继续写代码Android 从上到下写一个例子 HAL(三)_we1less的博客-优快云博客

驱动代码 

#include <linux/init.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/kernel.h>
#include <linux/cdev.h>
#include <linux/uaccess.h>
#include <linux/device.h>
#include <linux/device.h>
#include <linux/of.h>
#include <linux/of_gpio.h>
#include <linux/mm.h>
#include <asm/io.h>
		//GPF2
#define PAD_LEDCON 0x01c208b4
#define PAD_LEDDAT 0x01c208c4

static struct cdev obj;  //define cdev struct
struct class *cls;
static int major = 0;    //主设备号
static int minor = 0;    //次设备号
static int count = 1;    //设备的数量
dev_t dev;    //设备号
int i;
unsigned int *pad_con = NULL;
unsigned int *pad_dat = NULL;

char buf[] = {"hello world!"};

static int led_open(stru
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值