Android 驅動編寫LED NDK程式

2021-09-25 13:14:48 字數 2171 閱讀 5309

1. 首先編寫linux核心模組led?

#include

#include

#include

#include

#include

#include

#include

#include

module_license("gpl");

#define gpm4con 0x110002e0

#define gpm4dat 0x110002e4

#define led_on _iow(『g『,0,int)

#define led_off _iow(『g『,1,int)

staticstructcdev dev;分配cdev結構

staticdev_t dev_no;

structclass*led_class;

staticunsignedint*led_con;

staticunsignedint*led_dat;

longled_ioctl(structfile *file, unsignedintcmd, unsignedlongarg )

return0;

}

structfile_operations led_fops = ;

staticvoidhw_init()

staticintled_init()

voidled_exit()

module_init( led_init );

module_exit( led_exit );

2. 需要生成標頭檔案。

開啟studio.sh,重新編譯工程。

其中/opt/android-sdk-linux/platforms/android-23/android.jar是安卓sdk中的位址。

其中的檔案宣告為我們需要實現的函式。

在jni檔案中建立ndk_led.c原始檔和makefile檔案android.mk?

local_path := $(call my-dir)

include $(clear_vars)

local_module := ndk_test_myled

local_src_files := ndk_led.c

include $(build_shared_library)

若想生成靜態庫 則修改shared為static即可。

然後返回上一級目錄  執行命令ndk-build。將會生成libs/armeabi/libndk_test_myled.so 庫檔案。

norflash驅動編寫

首先我們來看 參考drivers mtd maps physmap.c include include include include include include include include include include include include static struct map ...

norflash驅動編寫

首先我們來看 參考drivers mtd maps physmap.c include include include include include include include include include include include include static struct map ...

norflash驅動編寫

首先我們來看 參考drivers mtd maps physmap.c include include include include include include include include include include include include static struct map ...