Android HAL
2010-04-21 06:36:00 来源:WEB开发网struct led_module_t {
struct hw_module_t common;
/* support API for LEDServices constructor */
};
struct led_control_device_t {
struct hw_device_t common;
/* supporting control APIs go here */
int (*getcount_led)(struct led_control_device_t *dev);
int (*set_on)(struct led_control_device_t *dev);
int (*set_off)(struct led_control_device_t *dev);
};
struct led_control_context_t {
struct led_control_device_t device;
};
led.c 文件:
#define LOG_TAG "LedStub"
#include
#include
#include
#include
#include
#include "../include/led.h"
static int led_device_close(struct hw_device_t* device)
{
struct led_control_context_t* ctx = (struct led_control_context_t*)device;
if (ctx) {
free(ctx);
}
return 0;
}
static int led_getcount(struct led_control_device_t *dev)
{
LOGI("led_getcount");
return 4;
}
static int led_set_on(struct led_control_device_t *dev)
{
//FIXME: do system call to control gpio led
LOGI("led_set_on");
return 0;
}
static int led_set_off(struct led_control_device_t *dev)
{
//FIXME: do system call to control gpio led
LOGI("led_set_off");
return 0;
}
static int led_device_open(const struct hw_module_t* module, const char* name,
struct hw_device_t** device)
{
struct led_control_context_t *context;
LOGD("led_device_open");
更多精彩
赞助商链接