Hi, jimit here, I built my own BMI270 API for Arduino boards, and I have a question regarding the BMI270 interrupt function, I want to generate an interrupt Acceleration sensor data. but to us, a surprise interrupt generates without attaching an interrupt pin attach, and I don't know how? can you guide me? here is my code. IMU imu = IMU(Wire); BMI imu1 = BMI(); void setup() { Serial.begin(57600); Wire.begin(); Wire.setClock(400000UL); delay(100); // imu.start(); // imu.setConfig(); // pinMode(9, INPUT); // attachInterrupt(9, drdy, RISING); imu1.start(); imu1.setInterruptPin(); imu1.setConfig(); } void loop() { // uint8_t buf[12] = {0}; int16_t ax = 0, ay = 0, az = 0; // int16_t x1 = 0, y1 = 0, z1 = 0; float x, y, z; // imu.readAccSensor(); // x = imu.getAccl_X(); // y = imu.getAccl_Y(); // z = imu.getAccl_Z(); imu1.getINTstatus(&int_status); int ret = ((int_status | _int_status) & BMI2_ACC_DRDY_INT_MASK); _int_status = int_status; _int_status &= ~BMI2_ACC_DRDY_INT_MASK; // Serial.println(int_status); if (ret) { imu1.getAccData(); ax = imu1.get_accX(); ay = imu1.get_accY(); az = imu1.get_accZ(); Serial.print(ax); Serial.print(","); Serial.print(ay); Serial.print(","); Serial.println(az); } Serial.println("new data"); // imu1.read(0x68, 0x0c, buf, 12); // ax = buf[0] | (buf[1] << 8); // ay = buf[2] | (buf[3] << 8); // az = buf[4] | (buf[5] << 8); // x1 = (int16_t)ax; // y1 = (int16_t)ay; // z1 = (int16_t)az; // Wire.beginTransmission(0x68); // Wire.write(0x1B); // Wire.endTransmission(); // Wire.requestFrom(0x68, 1); uint8_t data = 10; data = imu1.check_event_id(); // while (Wire.available()) // { // data = Wire.read(); // /* code */ // // Serial.println(BMI3_GET_BITS(Wire.read(), BMI2_EVENT_FLAG)); // } // Serial.println(BMI3_GET_BITS(data, BMI2_EVENT_FLAG)); /* Set accelerometer range */ // reg_data = BMI2_SET_BIT_POS0(data_array[1], BMI2_ACC_RANGE, config->range); // Serial.print(","); // Serial.print((int16_t)ax); // Serial.print(","); // imu1.read(0x68, 0x53, buf, 3); // Serial.print(buf[0], BIN); // Serial.print(","); // Serial.print(buf[1], BIN); // Serial.print(","); // Serial.println(); delay(5); // Wait for 100ms before reading again } void BMI::setInterruptPin() { write(BMI270_ADDRESS, 0x53, B1010); delay(2); write(BMI270_ADDRESS, 0x55, 0x00); delay(2); write(BMI270_ADDRESS, 0x58, 0x04); delay(2); } void BMI::getINTstatus(uint16_t *int_status) { uint8_t data_array[2] = {0}; read(BMI270_ADDRESS, 0x1C, data_array, 2); *int_status = (uint16_t)data_array[0] | ((uint16_t)data_array[1] << 8); } uint8_t BMI::write(uint16_t address, uint16_t subAddress, uint16_t data) { Wire.beginTransmission(address); Wire.write(subAddress); Wire.write(data); return Wire.endTransmission(); } void BMI::read(uint8_t addr, uint8_t reg, uint8_t *buf, uint8_t len) { // uint8_t addr = 0; Wire.beginTransmission(addr); Wire.write(reg); Wire.endTransmission(); Wire.requestFrom(addr, len); while (Wire.available()) { for (uint16_t i = 0; i < len; i++) { buf[i] = Wire.read(); } } }
... View more