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)
static
struct
cdev dev;
分配cdev結構
static
dev_t dev_no;
struct
class
*led_class;
static
unsigned
int
*led_con;
static
unsigned
int
*led_dat;
long
led_ioctl(
struct
file *file, unsigned
int
cmd, unsigned
long
arg )
return
0;
}
struct
file_operations led_fops = ;
static
void
hw_init()
static
int
led_init()
void
led_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 ...