bma456.c
/*!
 *	@brief This API sets the watermark level for step counter
 *	interrupt in the sensor.
 */
@brief This API sets the watermark level for step counter
interrupt in the sensor.
@brief This API sets the watermark level for step counter interrupt in the sensor .
uint16_t bma456_step_counter_set_watermark(uint16_t step_counter_wm, struct bma4_dev *dev)
{
	uint8_t feature_config[BMA456_FEATURE_SIZE] = {0};
	uint8_t index = BMA456_STEP_CNTR_OFFSET;
	uint16_t wm_lsb = 0;
	uint16_t wm_msb = 0;
	uint16_t rslt = BMA4_OK;
	uint16_t data = 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) {
				wm_lsb = feature_config[index];
				wm_msb = feature_config[index + 1] << 8;
				data = wm_lsb | wm_msb;
				data = BMA4_SET_BITS_POS_0(data, BMA456_STEP_CNTR_WM,
					step_counter_wm);
				feature_config[index] = BMA4_GET_LSB(data);
				feature_config[index + 1] = BMA4_GET_MSB(data);
				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_step_counter_set_watermark ( uint16_t step_counter_wm , struct bma4_dev * dev ) { uint8_t feature_config [ BMA456_FEATURE_SIZE ] = { 0 } ; uint8_t index = BMA456_STEP_CNTR_OFFSET ; uint16_t wm_lsb = 0 ; uint16_t wm_msb = 0 ; uint16_t rslt = BMA4_OK ; uint16_t data = 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 ) { wm_lsb = feature_config [ index ] ; wm_msb = feature_config [ index + 1 ] << 8 ; data = wm_lsb | wm_msb ; data = BMA4_SET_BITS_POS_0 ( data , BMA456_STEP_CNTR_WM , step_counter_wm ) ; feature_config [ index ] = BMA4_GET_LSB ( data ) ; feature_config [ index + 1 ] = BMA4_GET_MSB ( data ) ; 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 sets the watermark level for step counter
      interrupt in the sensor.
@brief This API sets the watermark level for step counter interrupt in the sensor .
/* Sets only watermark bits in the complete
				16 bits of data */ /* Splits 16 bits of data to individual
				8 bits data */ /* Writes stepcounter watermark settings
				in the sensor */