Example #1
0
void app_vibration_thread(void *data)
{
	EatEvent_st event;
	bool ret;

	LOG_INFO("vibration thread start.");

	ret = mma8652_init();
	if (!ret)
	{
        //LED_off();
        LOG_ERROR("mma8652 init failed");
	}
	else
	{
	    mma8652_config();
	}

	eat_timer_start(TIMER_VIBRATION, setting.vibration_timer_period);

	while(EAT_TRUE)
	{
        eat_get_event_for_user(THREAD_VIBRATION, &event);
        switch(event.event)
        {
            case EAT_EVENT_TIMER:
                switch (event.data.timer.timer_id)
                {
                    case TIMER_VIBRATION:
                        vibration_timer_handler();
                        eat_timer_start(TIMER_VIBRATION, setting.vibration_timer_period);
                        break;
                    case TIMER_MOVE_ALARM:
                        move_alarm_timer_handler();
                        break;

                    default:
                        LOG_ERROR("timer(%d) expire!", event.data.timer.timer_id);
                        break;
                }
                break;

            default:
            	LOG_ERROR("event(%d) not processed!", event.event);
                break;
        }
    }
}
Example #2
0
void auto_init_mma8652(void)
{
    for (int i = 0; i < MMA8652_NUM; i++) {
        const mma8652_params_t *p = &mma8652_params[i];

        DEBUG("[auto_init_saul] initializing mma8652 acc sensor\n");

        if (mma8652_init(&mma8652_devs[i], p->i2c, p->addr, p->rate, p->scale, p->type) < 0) {
            DEBUG("[auto_init_saul] error during initialization\n");
            return;
        }

        if (mma8652_set_active(&mma8652_devs[i]) < 0) {
            DEBUG("[auto_init_saul] error activating mma8652\n");
            return;
        }

        saul_entries[i].dev = &(mma8652_devs[i]);
        saul_entries[i].name = mma8652_saul_info[i].name;
        saul_entries[i].driver = &mma8652_saul_driver;
        saul_reg_add(&(saul_entries[i]));
    }
}