WEB开发网
开发学院手机开发Android 开发 Android HAL 阅读

Android HAL

 2010-04-21 06:36:00 来源:WEB开发网   
核心提示:context = (struct led_control_context_t *)malloc(sizeof(*context));memset(context, 0, sizeof(*context));//HAL must init propertycontext->device.common.tag= H

context = (struct led_control_context_t *)malloc(sizeof(*context));

memset(context, 0, sizeof(*context));

//HAL must init property

context->device.common.tag= HARDWARE_DEVICE_TAG;

context->device.common.version = 0;

context->device.common.module= module;

context->device.common.close = led_device_close;

// 初始化控制 API

context->device.set_on= led_set_on;

context->device.set_off= led_set_off;

context->device.getcount_led = led_getcount;

*device= (struct hw_device_t *)&(context->device);

return 0;

}

static struct hw_module_methods_t led_module_methods = {

open: led_device_open

};

const struct led_module_t HAL_MODULE_INFO_SYM = {

common: {

tag: HARDWARE_MODULE_TAG,

version_major: 1,

version_minor: 0,

id: LED_HARDWARE_MODULE_ID,

name: "led HAL module",

author: "gggggg",

methods: &led_module_methods,

},

/* supporting APIs go here */

};

Android.mk 文件:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_PRELINK_MODULE := false

LOCAL_SHARED_LIBRARIES := liblog

LOCAL_SRC_FILES := led.c

LOCAL_MODULE := led.goldfish

include $(BUILD_SHARED_LIBRARY)

三、在 Eclipse 中建一个工程使用我们编写的 led stub 。

1. 定义两个类,源码如下:

Myhal.java 文件:

package com.hello.MyHal;

import android.app.Activity;

import android.os.Bundle;

import android.util.Log;

import android.view.View;

import android.widget.Button;

import com.hello.LedService.LedService;;

public class Myhal extends Activity implements View.onClickListener {

上一页  1 2 3 4 5 6 7 8 9 10  下一页

Tags:Android HAL

编辑录入:coldstar [复制链接] [打 印]
赞助商链接