uint8_t bmi270_read(uint8_t reg) { uint8_t d; (void)nrf_drv_twi_tx(&m_twi, BMI2_I2C_PRIM_ADDR, ®, 1, true); (void)nrf_drv_twi_rx(&m_twi, BMI2_I2C_PRIM_ADDR, &d, 1); return d; } void bmi270_write(uint8_t reg, uint8_t data) { uint8_t r[2]; r[0] = reg; r[1] = data; (void)nrf_drv_twi_tx(&m_twi, BMI2_I2C_PRIM_ADDR, r, 2, false); } The setup in last post will give interrupt. Interrupt handler is: void data_ready_interrupt(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action) { int16_t dta[6]; int16_t accx; int16_t accy; int16_t accz; int16_t gyrox; int16_t gyroy; int16_t gyroz; dta[0] = 0x0c; (void)nrf_drv_twi_tx(&m_twi, BMI2_I2C_PRIM_ADDR, (uint8_t *)dta, 1, true); (void)nrf_drv_twi_rx(&m_twi, BMI2_I2C_PRIM_ADDR, (uint8_t *)dta, 12); accx = *(dta + 0); gyrox = *(dta + 3); accy = *(dta + 1); gyroy = *(dta + 4); accz = *(dta + 2); gyroz = *(dta + 5); } Main loop: while(1);
... View more