static int yas_get_delay(void)
{
	int ret;

	/* Check intialize */
	if (pcb == NULL)
		return YAS_ERROR_NOT_INITIALIZED;

	yas_bma150_lock();
	ret = yas_bma150_get_delay();
	yas_bma150_unlock();

	return ret;
}
static int yas_get_position(void)
{
	int err;

	/* Check intialize */
	if (pcb == NULL)
		return YAS_ERROR_NOT_INITIALIZED;

	yas_bma150_lock();
	err = yas_bma150_get_position();
	yas_bma150_unlock();

	return err;
}
Exemplo n.º 3
0
static int yas_get_filter_enable(void)
{
    int err;

    /* Check intialize */
    if (pcb == NULL) {
        return YAS_ERROR_NOT_INITIALIZED;
    }

    yas_bma150_lock();
    err = yas_bma150_get_filter_enable();
    yas_bma150_unlock();

    return err;
}
static int yas_measure(struct yas_acc_data *data)
{
	int err;

	/* Check intialize */
	if (pcb == NULL)
		return YAS_ERROR_NOT_INITIALIZED;

	if (data == NULL)
		return YAS_ERROR_ARG;

	yas_bma150_lock();
	err = yas_bma150_measure(data->xyz.v, data->raw.v);
	yas_bma150_unlock();

	return err;
}
static int yas_set_position(int position)
{
	int err;

	/* Check intialize */
	if (pcb == NULL)
		return YAS_ERROR_NOT_INITIALIZED;

	if (!((position >= 0) && (position <= 7)))
		return YAS_ERROR_ARG;

	yas_bma150_lock();
	err = yas_bma150_set_position(position);
	yas_bma150_unlock();

	return err;
}
static int yas_set_filter_enable(int enable)
{
	int err;

	/* Check intialize */
	if (pcb == NULL)
		return YAS_ERROR_NOT_INITIALIZED;

	if (enable != 0)
		enable = 1;

	yas_bma150_lock();
	err = yas_bma150_set_filter_enable(enable);
	yas_bma150_unlock();

	return err;
}
static int yas_get_filter(struct yas_acc_filter *filter)
{
	int err;

	/* Check intialize */
	if (pcb == NULL)
		return YAS_ERROR_NOT_INITIALIZED;

	if (filter == NULL)
		return YAS_ERROR_ARG;

	yas_bma150_lock();
	err = yas_bma150_get_filter(filter);
	yas_bma150_unlock();

	return err;
}
static int yas_get_offset(struct yas_vector *offset)
{
	int err;

	/* Check intialize */
	if (pcb == NULL)
		return YAS_ERROR_NOT_INITIALIZED;

	if (offset == NULL)
		return YAS_ERROR_ARG;

	yas_bma150_lock();
	err = yas_bma150_get_offset(offset);
	yas_bma150_unlock();

	return err;
}
static int yas_set_filter(struct yas_acc_filter *filter)
{
	int err;

	/* Check intialize */
	if (pcb == NULL)
		return YAS_ERROR_NOT_INITIALIZED;

	if (filter == NULL || filter->threshold < 0
	    || filter->threshold > YAS_BMA150_ABSMAX_2G)
		return YAS_ERROR_ARG;

	yas_bma150_lock();
	err = yas_bma150_set_filter(filter);
	yas_bma150_unlock();

	return err;
}
Exemplo n.º 10
0
static int yas_set_delay(int delay)
{
	int err;

	/* Check intialize */
	if (pcb == NULL)
		return YAS_ERROR_NOT_INITIALIZED;

	if (delay < 0 || delay > YAS_BMA150_MAX_DELAY)
		return YAS_ERROR_ARG;
	else if (delay < YAS_BMA150_MIN_DELAY)
		delay = YAS_BMA150_MIN_DELAY;

	yas_bma150_lock();
	err = yas_bma150_set_delay(delay);
	yas_bma150_unlock();

	return err;
}
Exemplo n.º 11
0
static int yas_set_offset(struct yas_vector *offset)
{
    int err;

    /* Check intialize */
    if (pcb == NULL) {
        return YAS_ERROR_NOT_INITIALIZED;
    }

    if (offset == NULL ||
        offset->v[0] < YAS_BMA150_ABSMIN_2G || YAS_BMA150_ABSMAX_2G < offset->v[0] ||
        offset->v[1] < YAS_BMA150_ABSMIN_2G || YAS_BMA150_ABSMAX_2G < offset->v[1] ||
        offset->v[2] < YAS_BMA150_ABSMIN_2G || YAS_BMA150_ABSMAX_2G < offset->v[2]) {
        return YAS_ERROR_ARG;
    }

    yas_bma150_lock();
    err = yas_bma150_set_offset(offset);
    yas_bma150_unlock();

    return err;
}