void BMA423_initialization() { uint16_t rslt = BMA4_OK; struct bma4_int_pin_config int_config; struct bma423_anymotion_config anymotion_conf; bma423.interface = BMA4_SPI_INTERFACE; bma423.bus_read = BMA423_reg_read; bma423.bus_write = BMA423_reg_write; bma423.delay = delay_ms; bma423.read_write_len = 64; rslt |= bma423_init(&bma423); rslt |= bma423_write_config_file(&bma423); rslt |= bma4_set_accel_enable(BMA4_ENABLE, &bma423); // rslt |= bma4_set_advance_power_save(BMA4_ENABLE, &bma423); struct bma4_accel_config accel_conf; accel_conf.odr = BMA4_OUTPUT_DATA_RATE_1600HZ; accel_conf.bandwidth = BMA4_ACCEL_NORMAL_AVG4; accel_conf.range = BMA4_ACCEL_RANGE_16G; accel_conf.perf_mode = BMA4_CONTINUOUS_MODE; rslt |= bma4_set_accel_config(&accel_conf, &bma423); // rslt |= bma423_select_platform(BMA423_WRIST_CONFIG, &bma423); rslt |= bma423_map_interrupt(BMA4_INTR1_MAP, BMA423_ANY_NO_MOTION_INT, BMA4_ENABLE, &bma423); int_config.edge_ctrl = BMA4_LEVEL_TRIGGER; int_config.lvl = BMA4_ACTIVE_LOW; int_config.od = BMA4_PUSH_PULL; int_config.output_en = BMA4_OUTPUT_ENABLE; int_config.input_en = BMA4_INPUT_DISABLE; rslt |= bma4_set_int_pin_config(&int_config, BMA4_INTR1_MAP, &bma423); rslt |= bma4_set_interrupt_mode(BMA4_LATCH_MODE, &bma423); anymotion_conf.threshold = 0x15; // Def.: 0xAA, 0xAA/(2^11) = 83mg anymotion_conf.duration = 1; // X*20ms anymotion_conf.nomotion_sel = 0; // 0 Anymotion, 1 Nomotion rslt |= bma423_set_any_motion_config(&anymotion_conf, &bma423); rslt |= bma423_anymotion_enable_axis(BMA423_Z_AXIS_EN, &bma423); rslt |= bma423_feature_enable(BMA423_ANY_MOTION, BMA4_ENABLE, &bma423); rslt |= bma423_reset_step_counter(&bma423); rslt |= bma423_step_detector_enable(BMA4_ENABLE, &bma423); rslt |= bma423_feature_enable(BMA423_STEP_CNTR, BMA4_ENABLE, &bma423); print_rslt(rslt, line_offset); line_offset++; if(rslt != BMA4_OK) { while(1); } }