bma456.c
/*!
 *	@brief This API performs x, y and z axis remapping in the sensor.
 */
@brief This API performs x, y and z axis remapping in the sensor.
@brief This API performs x y and z axis remapping in the sensor .
uint16_t bma456_set_remap_axes(const struct bma456_axes_remap *remap_data, struct bma4_dev *dev)
{
	uint8_t feature_config[BMA456_FEATURE_SIZE] = {0};
	uint8_t index = BMA456_AXES_REMAP_OFFSET;
	uint16_t rslt = BMA4_OK;
	uint8_t x_axis = 0;
	uint8_t x_axis_sign = 0;
	uint8_t y_axis = 0;
	uint8_t y_axis_sign = 0;
	uint8_t z_axis = 0;
	if (dev != NULL) {
		if (dev->chip_id == BMA456_CHIP_ID) {
			rslt = bma4_read_regs(BMA4_FEATURE_CONFIG_ADDR, feature_config, BMA456_FEATURE_SIZE, dev);
			if (rslt == BMA4_OK) {
				x_axis = remap_data->x_axis & BMA456_X_AXIS_MASK;
				x_axis_sign = (remap_data->x_axis_sign << 2) & BMA456_X_AXIS_SIGN_MASK;
				y_axis = (remap_data->y_axis << 3) & BMA456_Y_AXIS_MASK;
				y_axis_sign = (remap_data->y_axis_sign << 5) & BMA456_Y_AXIS_SIGN_MASK;
				z_axis = (remap_data->z_axis << 6) & BMA456_Z_AXIS_MASK;
				feature_config[index] = x_axis | x_axis_sign | y_axis | y_axis_sign | z_axis;
				feature_config[index + 1] = remap_data->z_axis_sign & BMA456_Z_AXIS_SIGN_MASK;
				rslt |= bma4_write_regs(BMA4_FEATURE_CONFIG_ADDR, feature_config,
							BMA456_FEATURE_SIZE, dev);
			}
		} else {
			rslt = BMA4_E_INVALID_SENSOR;
		}
	} else {
		rslt = BMA4_E_NULL_PTR;
	}
	return rslt;
}
uint16_t bma456_set_remap_axes ( const struct bma456_axes_remap * remap_data , struct bma4_dev * dev ) { uint8_t feature_config [ BMA456_FEATURE_SIZE ] = { 0 } ; uint8_t index = BMA456_AXES_REMAP_OFFSET ; uint16_t rslt = BMA4_OK ; uint8_t x_axis = 0 ; uint8_t x_axis_sign = 0 ; uint8_t y_axis = 0 ; uint8_t y_axis_sign = 0 ; uint8_t z_axis = 0 ; if ( dev != NULL ) { if ( dev -> chip_id == BMA456_CHIP_ID ) { rslt = bma4_read_regs ( BMA4_FEATURE_CONFIG_ADDR , feature_config , BMA456_FEATURE_SIZE , dev ) ; if ( rslt == BMA4_OK ) { x_axis = remap_data -> x_axis & BMA456_X_AXIS_MASK ; x_axis_sign = ( remap_data -> x_axis_sign << 2 ) & BMA456_X_AXIS_SIGN_MASK ; y_axis = ( remap_data -> y_axis << 3 ) & BMA456_Y_AXIS_MASK ; y_axis_sign = ( remap_data -> y_axis_sign << 5 ) & BMA456_Y_AXIS_SIGN_MASK ; z_axis = ( remap_data -> z_axis << 6 ) & BMA456_Z_AXIS_MASK ; feature_config [ index ] = x_axis | x_axis_sign | y_axis | y_axis_sign | z_axis ; feature_config [ index + 1 ] = remap_data -> z_axis_sign & BMA456_Z_AXIS_SIGN_MASK ; rslt |= bma4_write_regs ( BMA4_FEATURE_CONFIG_ADDR , feature_config , BMA456_FEATURE_SIZE , dev ) ; } } else { rslt = BMA4_E_INVALID_SENSOR ; } } else { rslt = BMA4_E_NULL_PTR ; } return rslt ; }
@brief This API performs x, y and z axis remapping in the sensor.
@brief This API performs x y and z axis remapping in the sensor .