91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 2.21MB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發布日期: 2023-08-17
  • 語言: Java
  • 標簽: linux驅動??Android??

資源簡介

資源含Android應用程序->JNI->C語言層->驅動程序。 硬件開發板為訊為電子的exynos4412開發板。 主要實現從驅動到Android應用程序的逐層調用過程。關鍵是file_operations!! 通過Android應用程序,能夠控制GPIO LED,寫入數據,以及去讀已寫入的數據。 Android應用程序中有兩個BUTTON用不上,無關緊要,這就不刪掉了。

資源截圖

代碼片段和文件信息

/*
本文件目標:
1.學習字符設備驅動??注冊主次設備
2.用IO內存直接驅動GPIO?LED
*/
#include?
#include?
#include?
#include?//主次設備
#include?

#include?//釋放和分配設備編號
#include?//字符設備驅動
#include?//分配scull內存使用
#include?//包含device_create函數??class結構體的頭文件
//IO端口分配以及IO內存分配??ARM內核中與IO內存一樣
#include?
//IO內存讀寫
#include?
//CPU?物理地址
#include?
//copy_to_user函數頭文件
#include?

#define?CHRDEV_NAME?“tarkelc_chrdev“//所分配設備號的名稱
#define?DEVICE_NAME?“tarkelc_learn“//設備節點名稱(在/dev中)
#define?DRIVER_NAME?“mygpio“
#define?CLASS_NAME??“tarkelc_class“///sys/class中可查到
#define?Myled2?EXYNOS4_GPL2(0)
#define?Myled3?EXYNOS4_GPK1(1)

#define?GPL2base_PA?(EXYNOS4_PA_GPIO2+0x0100)
#define?GPK1base_PA?(EXYNOS4_PA_GPIO2+0x0060)
#define?GPL2LEN_PA??(0X20)
#define?GPK1LEN_PA??(0X20)

dev_t?mdev_t;

void?*p1;

char?buffer[1024];

static?struct?class?*myclass;

//操作SPI寄存器結構體
typedef?struct{
unsigned?long?CON; //0x00
unsigned?long?DAT; //0x04
unsigned?long?PUD; //0x08
unsigned?long?DRV; //0x0c
unsigned?long?CONPND; //0x10
unsigned?long?PUDPDN; //0x14
unsigned?long?RESERVED; //0x18
unsigned?long?RESERVED1; //0x1c
}GPIO_TypeDef;
GPIO_TypeDef?*GPL2;

/*?表示每一個設備?*/
struct?scull_dev?{
char?*data;
unsigned?int?size;
struct?cdev?cdev;
};
struct?scull_dev?*mydevice;

static?ssize_t?myspi_read(struct?file?*f?char?__user?*buf?size_t?len?loff_t?*loff)
{
int?ret=0;
/*char?*pp;//
pp=buffer;
for(ret=0;(ret *pp=(char)ret;
pp++;
}*/
ret=copy_to_user(bufbufferlen);
if(ret!=0){
return?-1;
}
return?len;
}

static?ssize_t?myspi_write(struct?file?*f?const?char?__user?*buf?size_t?len?loff_t?*loff)
{
int?ret;
ret=copy_from_user(bufferbuflen);
if(ret!=0){
return?-1;
}
return?len;
}

static?int?myspi_open(struct?inode?*?node?struct?file?*f)?{

printk(KERN_ALERT?“myspi?open!“);
return?0;
}

static?int?myspi_release(struct?inode?*node?struct?file?*f){
printk(KERN_ALERT?“myspi?release!“);
return?0;
}

/*?暫時用于debug?*/
static?long?myspi_ioctl(struct?file?*f?unsigned?int?cmd?unsigned?long?arg)
{
int?stateret;
state=ioread32(&GPL2->DAT);
iowrite32(state|0x00000001&GPL2->DAT);//配置IO輸出高電平
if(cmd==0){
state=ioread32(&GPL2->DAT);
ret=state&0x01;
if(ret!=0){
iowrite32(state&0xfffffffe&GPL2->DAT);//配置IO輸出低電平
}
else?{
iowrite32(state|0x00000001&GPL2->DAT);//配置IO輸出高電平
}
return?0;
}
else?{

}
return?0;
}

struct?file_operations?my_fops={
.owner?=?THIS_MODULE
.read?=?myspi_read
.write?=?myspi_write
.open?=?myspi_open
.release?=?myspi_release
.unlocked_ioctl?=?myspi_ioctl
};

/*?自定義函數?*/
static?void?gpio_init(void)
{
unsigned?int?state;
//GPL2base寄存器向IO內存的映射
if(request_mem_region(GPL2base_PAGPL2LEN_PADRIVER_NAME)==

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2016-04-19?22:23??資源\
?????目錄???????????0??2016-04-19?22:23??資源\MyledsTest\
?????文件?????????475??2016-03-13?21:46??資源\MyledsTest\.classpath
?????文件????????3683??2016-03-13?22:00??資源\MyledsTest\.cproject
?????文件????????1470??2016-03-13?22:00??資源\MyledsTest\.project
?????目錄???????????0??2016-04-19?22:22??資源\MyledsTest\.settings\
?????文件?????????177??2016-03-13?21:46??資源\MyledsTest\.settings\org.eclipse.jdt.core.prefs
?????文件?????????865??2016-03-13?21:46??資源\MyledsTest\AndroidManifest.xml
?????目錄???????????0??2016-04-19?22:25??資源\MyledsTest\assets\
?????目錄???????????0??2016-04-19?22:22??資源\MyledsTest\bin\
?????文件?????????865??2016-03-13?21:46??資源\MyledsTest\bin\AndroidManifest.xml
?????文件??????776031??2016-04-19?22:17??資源\MyledsTest\bin\MyledsTest.apk
?????文件???????30735??2016-04-19?22:16??資源\MyledsTest\bin\R.txt
?????目錄???????????0??2016-04-19?22:22??資源\MyledsTest\bin\classes\
?????目錄???????????0??2016-04-19?22:22??資源\MyledsTest\bin\classes\android\
?????目錄???????????0??2016-04-19?22:22??資源\MyledsTest\bin\classes\android\support\
?????目錄???????????0??2016-04-19?22:22??資源\MyledsTest\bin\classes\android\support\v7\
?????目錄???????????0??2016-04-19?22:22??資源\MyledsTest\bin\classes\android\support\v7\appcompat\
?????文件?????????629??2016-04-19?22:16??資源\MyledsTest\bin\classes\android\support\v7\appcompat\R$anim.class
?????文件????????5136??2016-04-19?22:16??資源\MyledsTest\bin\classes\android\support\v7\appcompat\R$attr.class
?????文件?????????763??2016-04-19?22:16??資源\MyledsTest\bin\classes\android\support\v7\appcompat\R$bool.class
?????文件?????????594??2016-04-19?22:16??資源\MyledsTest\bin\classes\android\support\v7\appcompat\R$color.class
?????文件????????1530??2016-04-19?22:16??資源\MyledsTest\bin\classes\android\support\v7\appcompat\R$dimen.class
?????文件????????5191??2016-04-19?22:16??資源\MyledsTest\bin\classes\android\support\v7\appcompat\R$drawable.class
?????文件????????2556??2016-04-19?22:16??資源\MyledsTest\bin\classes\android\support\v7\appcompat\R$id.class
?????文件?????????445??2016-04-19?22:16??資源\MyledsTest\bin\classes\android\support\v7\appcompat\R$integer.class
?????文件????????1629??2016-04-19?22:16??資源\MyledsTest\bin\classes\android\support\v7\appcompat\R$layout.class
?????文件????????1141??2016-04-19?22:16??資源\MyledsTest\bin\classes\android\support\v7\appcompat\R$string.class
?????文件????????9582??2016-04-19?22:16??資源\MyledsTest\bin\classes\android\support\v7\appcompat\R$style.class
?????文件????????6541??2016-04-19?22:16??資源\MyledsTest\bin\classes\android\support\v7\appcompat\R$styleable.class
?????文件????????1015??2016-04-19?22:16??資源\MyledsTest\bin\classes\android\support\v7\appcompat\R.class
............此處省略102個文件信息

評論

共有 條評論