void MPU6050_ReadAcc(const nrf_drv_twi_t * twi, int16_t *pACC_X , int16_t *pACC_Y , int16_t *pACC_Z ) { uint8_t buf[6]; mpu6050_register_read(twi, MPU6050_RA_ACCEL_XOUT_H, buf, 6); *pACC_X = (buf[0] << 8) | buf[1]; if(*pACC_X & 0x8000) *pACC_X-=65536; *pACC_Y= (buf[2] << 8) | buf[3]; if(*pACC_Y & 0x8000) *pACC_Y-=65536; *pACC_Z = (buf[4] << 8) | buf[5]; if(*pACC_Z & 0x8000) *pACC_Z-=65536; }
bool mpu6050_verify_product_id(const nrf_drv_twi_t * twi) { uint8_t who_am_i; if (NRF_SUCCESS != mpu6050_register_read(twi, MPU6050_RA_WHO_AM_I, &who_am_i, 1)) { if (who_am_i != expected_who_am_i) { return false; } else { return true; } } else { return false; } }
bool mpu6050_verify_product_id(void) { uint8_t who_am_i; if (mpu6050_register_read(ADDRESS_WHO_AM_I, &who_am_i, 1)) { if (who_am_i != expected_who_am_i) { return false; } else { return true; } } else { return false; } }