資源簡介
hal調用底層示例代碼
代碼片段和文件信息
#include?
#include?“../HAL/minicom.h“
#include?“jni.h“
static?int?fd;
//定義兩個指針
struct?usb_hw_module_t?*pModule;
struct?usb_hw_device_t?*pDevice;
jint?open_led(JNIEnv?*env?jobject?thiz)
{
LOGD(“------%s-----\n“?__FUNCTION__);
jint?ret;
ret?=?hw_get_module(MINICOM_ID?(const?struct?hw_module_t?*?*)?&pModule);
if(ret?==?0)
{
LOGD(“get?hal?module?ok\n“);
//調用module對象的open方法,實際上是調用usb_module_open方法
pModule->common.methods->open(&pModule->common?NULL?(struct?hw_device_t?*?*)&pDevice);
if(pDevice?!=?NULL)
{
//調用pDevice中的方法
pDevice->open();
}
}
else{
LOGD(“get?hal?module?failed?\n“);
return?-1;
}
return?0;
}
jint?led_on(JNIEnv?*env?jobject?thiz?jint?a)
{
LOGD(“------%s-----\n“?__FUNCTION__);
if(pDevic
- 上一篇:IOS 瀏覽器加載進度顯示源碼
- 下一篇:iOSDiner (商業)
評論
共有 條評論