/* BMA020 ioctl control entry point. 
Support and FAQ: visit  */
static bool bma020_ioctl(sensor_t *sensor, sensor_command_t cmd, void *arg)
/* BMA020 ioctl control entry point. 
Support and FAQ: visit  */
static bool bma020_ioctl(sensor_t *sensor, sensor_command_t cmd, void *arg)
{
	sensor_hal_t *const hal = sensor->hal;
	sensor_data_t sample = {.scaled = true};
	switch (cmd) {
	case SENSOR_SET_RANGE:
		return bma020_set_range(hal, *((uint16_t *)arg));
	case SENSOR_SET_BANDWIDTH:
		return bma020_set_bandwidth(hal, *((uint16_t *)arg));
	case SENSOR_READ_VECTOR:
		if (bma020_get_accel(hal, &sample)) {
			vector3_t *const pvec = (vector3_t *)arg;
			pvec->x = sample.axis.x;
			pvec->y = sample.axis.y;
			pvec->z = sample.axis.z;
			return true;
		} else {
			return false;
		}
	default:
		sensor->err = SENSOR_ERR_UNSUPPORTED;
		return false;
	}
}