You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

957 lines
36 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #include "BNO055.h"
  2. #define LOG( X ) m_pLog->Log( "BNO055", this, X )
  3. #define LOG_ERROR( X ) m_pLog->Log( "BNO055", this, _LOG_ERROR, X )
  4. const char * BNO_ERROR_MESSAGES[11] = {
  5. "No error",
  6. "Peripheral initialization error",
  7. "System initialization error",
  8. "Self test result failed",
  9. "Register map value out of range",
  10. "Register map address out of range",
  11. "Register map write error",
  12. "BNO low power mode not available for selected operation mode",
  13. "Accelerometer power mode not available",
  14. "Fusion algorithm configuration error",
  15. "Sensor configuration error"
  16. };
  17. const char * BNO_STATUS_MESSAGES[7] = {
  18. "System idle",
  19. "System Error",
  20. "Initializing peripherals",
  21. "System Initialization",
  22. "Executing selftest",
  23. "Sensor fusion algorithm running",
  24. "System running without fusion algorithm"
  25. };
  26. const uint32_t BNO_OUTPUT_DATA_DELAY[12] = {
  27. 1000,
  28. 10,
  29. 50,
  30. 10,
  31. 20,
  32. 100,
  33. 20,
  34. 10,
  35. 50,
  36. 20,
  37. 10,
  38. 10
  39. };
  40. sensorBNO::sensorBNO( config_setting_t *Settings, PATHFINDER_DBC *DBC ): basicThread(){
  41. m_pLog = basicLogCollection::getInstance();
  42. m_pSettings = basicSettingsProvider::getInstance()->getSubNode( Settings, "BNO055" );
  43. m_pBLOG = objectPathfinderBinaryLog::getInstance();
  44. m_pBus = NULL;
  45. m_pDBC = DBC;
  46. m_pDevicePath = "/dev/i2c-1";
  47. m_bDeviceAddress = 0x29;
  48. m_nSampleDelay = 100;
  49. m_bTargetWM = BNO_WM_CONFIG;
  50. m_bActualWM = 0;
  51. memset( &m_sSettings, 0 , sizeof(BNO_SETTINGS) );
  52. m_sSettings.wmode = BNO_WM_IMU;
  53. m_sSettings.map_x = 1;
  54. m_sSettings.map_y = 2;
  55. m_sSettings.map_z = 3;
  56. memset( &m_sID, 0, sizeof(BNO_ID_MAP) );
  57. memset( &m_sDATA, 0, sizeof(BNO_DATA_MAP) );
  58. memset( &m_sSTATUS, 0, sizeof(BNO_STATUS_MAP) );
  59. memset( &m_sCONFIG0, 0, sizeof(BNO_CONFIG0_MAP) );
  60. memset( &m_sCONFIG1, 0, sizeof(BNO_CONFIG1_MAP) );
  61. };
  62. sensorBNO::~sensorBNO(){
  63. waitThreadEnd( true );
  64. if(m_pBus != NULL ) delete( m_pBus );
  65. };
  66. void sensorBNO::logConfig(){
  67. char tBuff[256];
  68. sprintf( tBuff, "OPR_MODE: 0x%02X", m_sCONFIG0.OP_MODE );
  69. LOG( tBuff );
  70. switch( m_sCONFIG0.OP_MODE & BNO_WMODE_MASK ) {
  71. case BNO_WM_CONFIG: LOG("CHIP WM is CONFIG"); break;
  72. case BNO_WM_ACC_ONLY: LOG("CHIP WM is Acc Only"); break;
  73. case BNO_WM_MAG_ONLY: LOG("CHIP WM is Magnetometer Only"); break;
  74. case BNO_WM_GYR_ONLY: LOG("CHIP WM is Gyroscope Only"); break;
  75. case BNO_WM_ACC_MAG: LOG("CHIP WM is Acc and Magnetometer"); break;
  76. case BNO_WM_ACC_GYR: LOG("CHIP WM is Acc and Gyroscope"); break;
  77. case BNO_WM_MAG_GYR: LOG("CHIP WM is Magnetometer and Gyroscope"); break;
  78. case BNO_WM_AMG_NO_FUSION: LOG("CHIP WM is All sensors - No Fusion!"); break;
  79. case BNO_WM_IMU: LOG("CHIP WM is Fusion IMU"); break;
  80. case BNO_WM_COMPAS: LOG("CHIP WM is Fusion Compas"); break;
  81. case BNO_WM_M4G: LOG("CHIP WM is Fusion Magnetometer and Gyroscope"); break;
  82. case BNO_WM_NDOF_FMC_OFF: LOG("CHIP WM is Fusion NDOF no fast Mag calibartion"); break;
  83. case BNO_WM_NDOF: LOG("CHIP WM is Fusion NDOF"); break;
  84. default: LOG_ERROR("CHIP WM is Unknown!");
  85. };
  86. switch( m_eAccWorkMode ) {
  87. case BNO_ACC_NORMAL: LOG("ACC WM is Normal"); break;
  88. case BNO_ACC_SUSPEND: LOG("ACC WM is Suspended"); break;
  89. case BNO_ACC_LP1: LOG("ACC WM is Low Power 1"); break;
  90. case BNO_ACC_STANDBY: LOG("ACC WM is Standby"); break;
  91. case BNO_ACC_LP2: LOG("ACC WM is Low Power 2"); break;
  92. case BNO_ACC_DEEP_SUSPEND: LOG("ACC WM is Deep Suspend"); break;
  93. };
  94. switch( m_eAccRange ) {
  95. case BNO_ACC_2G: LOG("ACC Range is 2G"); break;
  96. case BNO_ACC_4G: LOG("ACC Range is 4G"); break;
  97. case BNO_ACC_8G: LOG("ACC Range is 8G"); break;
  98. case BNO_ACC_16G: LOG("ACC Range is 16G"); break;
  99. };
  100. switch( m_eAccBandwidth ) {
  101. case BNO_ACC_7_81HZ: LOG("ACC Bandwidth is 7.81Hz"); break;
  102. case BNO_ACC_15_36HZ: LOG("ACC Bandwidth is 15.36Hz"); break;
  103. case BNO_ACC_31_25HZ: LOG("ACC Bandwidth is 31.25Hz"); break;
  104. case BNO_ACC_62_50HZ: LOG("ACC Bandwidth is 62.5Hz"); break;
  105. case BNO_ACC_125HZ: LOG("ACC Bandwidth is 125Hz"); break;
  106. case BNO_ACC_250HZ: LOG("ACC Bandwidth is 250Hz"); break;
  107. case BNO_ACC_500HZ: LOG("ACC Bandwidth is 500Hz"); break;
  108. case BNO_ACC_1000HZ: LOG("ACC Bandwidth is 1KHz"); break;
  109. };
  110. };
  111. bool sensorBNO::updateSettings(){
  112. if( m_pDevicePath == NULL ) return false;
  113. if( m_pBus == NULL ) return false;
  114. if( m_pDBC!= NULL ) {
  115. if( !m_pDBC->getSettingsIMU( &m_sSettings ) ) return false;
  116. };
  117. m_bTargetWM = BNO_WM_CONFIG;
  118. setMode( BNO_WM_CONFIG );
  119. LOG("Mode Set to Config");
  120. /* Reset */
  121. LOG("Trigger Reset");
  122. m_pBus->write8( BNO055_SYS_TRIGGER_ADDR, 0x20 );
  123. /* Delay incrased to 30ms due to power issues https://tinyurl.com/y375z699 */
  124. SLEEP(1000);
  125. LOG("Read Chip ID");
  126. while( m_pBus->read8( BNO055_CHIP_ID_ADDR) != BNO055_ID ){
  127. SLEEP(10);
  128. };
  129. LOG("Done!" );
  130. SLEEP(50);
  131. LOG("Set PowerMode");
  132. /* Set to normal power mode */
  133. m_pBus->write8( BNO055_PWR_MODE_ADDR, BNO_PM_NORMAL );
  134. SLEEP(10);
  135. LOG("Set Page 0");
  136. m_pBus->write8( BNO055_PAGE_ID_ADDR, 0 );
  137. /* Set the output units */
  138. uint8_t unitsel = (0 << 7) | // Orientation = Android
  139. (0 << 4) | // Temperature = Celsius
  140. (0 << 2) | // Euler = Degrees
  141. (1 << 1) | // Gyro = Rads
  142. (0 << 0); // Accelerometer = m/s^2
  143. m_pBus->write8(BNO055_UNIT_SEL_ADDR, unitsel);
  144. /* Configure axis mapping (see section 3.4) */
  145. uint8_t axis_map_cfg = 0;
  146. axis_map_cfg = ((m_sSettings.map_z & 3) << 4) | ((m_sSettings.map_y & 3) << 2) | (m_sSettings.map_x & 3);
  147. m_pBus->write8(BNO055_AXIS_MAP_CONFIG_ADDR, axis_map_cfg );//REMAP_CONFIG_P2); // P0-P7, Default is P1
  148. SLEEP(10);
  149. uint8_t axis_sign_cfg = 0;
  150. axis_sign_cfg = (m_sSettings.map_x & 4) | ((m_sSettings.map_y & 4) >> 1) || ((m_sSettings.map_x & 4) >> 2);
  151. m_pBus->write8(BNO055_AXIS_MAP_SIGN_ADDR, axis_sign_cfg );//REMAP_SIGN_P2); // P0-P7, Default is P1
  152. SLEEP(10);
  153. LOG("Clear Triggers");
  154. m_pBus->write8( BNO055_SYS_TRIGGER_ADDR, 0x0 );
  155. SLEEP( 10 );
  156. LOG("Start WM");
  157. setMode( m_sSettings.wmode );
  158. SLEEP(20);
  159. m_bTargetWM = m_sSettings.wmode;
  160. return true;
  161. };
  162. bool sensorBNO::create(){
  163. if( m_pDevicePath == NULL ) return false;
  164. if( m_pBus != NULL ) delete( m_pBus );
  165. m_pBus = new i2cPort( m_pDevicePath, m_bDeviceAddress );
  166. if( m_pBus != NULL ) {
  167. if( m_pDBC!= NULL ) {
  168. if( m_pDBC->getSettingsIMU( &m_sSettings ) ){
  169. m_bTargetWM = m_sSettings.wmode;
  170. };
  171. };
  172. LOG("Read Chip ID");
  173. uint8_t id = m_pBus->read8( BNO055_CHIP_ID_ADDR );
  174. if( id != BNO055_ID ){
  175. SLEEP( 1000 ); // hold on for boot
  176. id = m_pBus->read8( BNO055_CHIP_ID_ADDR );
  177. if( id != BNO055_ID ){
  178. return false; // still not? ok -> fail
  179. };
  180. };
  181. LOG("Chip ID - OK");
  182. //setExtCrystalUse( true );
  183. //SLEEP(1000);
  184. LOG("Mode Seting");
  185. /* Switch to config mode (just in case since this is the default) */
  186. setMode( BNO_WM_CONFIG );
  187. LOG("Mode Set to Config");
  188. /* Reset */
  189. LOG("Trigger Reset");
  190. m_pBus->write8( BNO055_SYS_TRIGGER_ADDR, 0x20 );
  191. /* Delay incrased to 30ms due to power issues https://tinyurl.com/y375z699 */
  192. SLEEP(1000);
  193. LOG("Read Chip ID");
  194. while( m_pBus->read8( BNO055_CHIP_ID_ADDR) != BNO055_ID ){
  195. SLEEP(10);
  196. };
  197. LOG("Done!" );
  198. SLEEP(50);
  199. LOG("Set PowerMode");
  200. /* Set to normal power mode */
  201. m_pBus->write8( BNO055_PWR_MODE_ADDR, BNO_PM_NORMAL );
  202. SLEEP(10);
  203. LOG("Set Page 0");
  204. m_pBus->write8( BNO055_PAGE_ID_ADDR, 0 );
  205. /* Set the output units */
  206. uint8_t unitsel = (0 << 7) | // Orientation = Android
  207. (0 << 4) | // Temperature = Celsius
  208. (0 << 2) | // Euler = Degrees
  209. (1 << 1) | // Gyro = Rads
  210. (0 << 0); // Accelerometer = m/s^2
  211. m_pBus->write8(BNO055_UNIT_SEL_ADDR, unitsel);
  212. /* Configure axis mapping (see section 3.4) */
  213. uint8_t axis_map_cfg = 0;
  214. axis_map_cfg = ((m_sSettings.map_z & 3) << 4) | ((m_sSettings.map_y & 3) << 2) | (m_sSettings.map_x & 3);
  215. m_pBus->write8(BNO055_AXIS_MAP_CONFIG_ADDR, axis_map_cfg );//REMAP_CONFIG_P2); // P0-P7, Default is P1
  216. SLEEP(10);
  217. uint8_t axis_sign_cfg = 0;
  218. axis_sign_cfg = (m_sSettings.map_x & 4) | ((m_sSettings.map_y & 4) >> 1) || ((m_sSettings.map_x & 4) >> 2);
  219. m_pBus->write8(BNO055_AXIS_MAP_SIGN_ADDR, axis_sign_cfg );//REMAP_SIGN_P2); // P0-P7, Default is P1
  220. SLEEP(10);
  221. LOG("Clear Triggers");
  222. m_pBus->write8( BNO055_SYS_TRIGGER_ADDR, 0x0 );
  223. SLEEP( 10 );
  224. /*
  225. LOG("Trigger Self Test");
  226. m_pBus->write8( BNO055_SYS_TRIGGER_ADDR, 0x01 );
  227. SLEEP( 5000 );
  228. LOG("Read Test Results");
  229. uint8_t tr = m_pBus->read8( BNO055_SELFTEST_RESULT_ADDR );
  230. if( ( tr & 0x0F ) == 0x0F ) {
  231. LOG("Self Test Passed");
  232. char tBuff[64];
  233. sprintf( tBuff, "Code: 0x%02X", tr );
  234. LOG( tBuff );
  235. } else {
  236. LOG_ERROR("Self Test Failure!");
  237. char tBuff[64];
  238. sprintf( tBuff, "Code: 0x%02X", tr );
  239. LOG( tBuff );
  240. return false;
  241. };
  242. LOG("Clear Triggers");
  243. m_pBus->write8( BNO055_SYS_TRIGGER_ADDR, 0x0 );
  244. SLEEP(10);
  245. */
  246. /* Set the requested operating mode (see section 3.3) */
  247. LOG("Start WM");
  248. if( setMode( m_bTargetWM ) ) {
  249. SLEEP(20);
  250. return init();
  251. };
  252. } else LOG_ERROR("No I2C Bus Created!");
  253. return false;
  254. };
  255. bool sensorBNO::validate(){
  256. if( getStatus( &m_sSTATUS ) ){
  257. #ifdef DEBUG
  258. char tBuff[256];
  259. sprintf( tBuff, "Temperature: %02X", m_sSTATUS.temper );
  260. LOG( tBuff );
  261. sprintf( tBuff, "Calibration: %02X", m_sSTATUS.cal_status );
  262. LOG( tBuff );
  263. sprintf( tBuff, "ST Result: %02X", m_sSTATUS.st_result );
  264. LOG( tBuff );
  265. sprintf( tBuff, "INT Status: %02X", m_sSTATUS.int_status );
  266. LOG( tBuff );
  267. sprintf( tBuff, "CLC Status: %02X", m_sSTATUS.sys_clc_status );
  268. LOG( tBuff );
  269. sprintf( tBuff, "SYS Status: %02X", m_sSTATUS.system_status );
  270. LOG( tBuff );
  271. sprintf( tBuff, "SYS Error: %02X [%s]", m_sSTATUS.system_error, BNO_ERROR_MESSAGES[m_sSTATUS.system_error] );
  272. LOG( tBuff );
  273. #endif
  274. return true;
  275. };
  276. return false;
  277. };
  278. void sensorBNO::m_fThreadProc( void ){
  279. m_bThreadStatus = TH_WORKING;
  280. while( m_bThreadStatus < TH_ENDED ){
  281. if( m_bTargetWM != 0 ){
  282. uint8_t S_S, STS, S_E;
  283. if( m_bActualWM == 0 ) {
  284. m_bActualWM = getMode();
  285. if( m_bActualWM != 0 ) continue;
  286. // Config Procedures
  287. } else {
  288. BNO_EVTREC * tDATA;
  289. tDATA = getEVT_REC();
  290. if( tDATA != NULL ) {
  291. if( m_pBLOG != NULL ) {
  292. m_pBLOG->registerBNO( tDATA );
  293. };
  294. if( m_pDBC != NULL ) {
  295. m_pDBC->updateBNO_DATA( tDATA );
  296. };
  297. free( tDATA );
  298. };
  299. };
  300. /*
  301. if( getSystemStatus( &S_S, &STS, &S_E ) ){
  302. switch( S_S ) {
  303. case 0: {
  304. char tBuffer[64];
  305. uint8_t tMode =
  306. sprintf( tBuffer, "Idle Mode %d:%d", tMode, m_eWorkMode );
  307. LOG(tBuffer);
  308. sprintf( tBuffer, "Temperature: %d", getTemp() );
  309. LOG(tBuffer);
  310. if( isFullyCalibrated() ) {
  311. LOG("Fully Calibrated!");
  312. } else {
  313. LOG("Not Calibrated!");
  314. };
  315. if( tMode != m_eWorkMode ) {
  316. if( setMode( m_eWorkMode ) ){
  317. LOG("Mode Changed");
  318. SLEEP( 200 );
  319. } else {
  320. LOG("Mode Changed Failure");
  321. };
  322. };
  323. break;
  324. };
  325. case 1: LOG("System Error"); break;
  326. case 2: LOG("Initializing Peripherals"); break;
  327. case 3: LOG("System Iniitalization"); break;
  328. case 4: LOG("Executing Self-Test"); break;
  329. case 5: LOG("Sensor fusion algorithm running"); break;
  330. case 6: LOG("System running without fusion algorithms"); break;
  331. };
  332. }; */
  333. SLEEP( BNO_OUTPUT_DATA_DELAY[ m_bActualWM ] );
  334. } else SLEEP( 1000 );
  335. };
  336. };
  337. /*!
  338. * @brief Puts the chip in the specified operating mode
  339. * @param mode
  340. * mode values
  341. * [OPERATION_MODE_CONFIG,
  342. * OPERATION_MODE_ACCONLY,
  343. * OPERATION_MODE_MAGONLY,
  344. * OPERATION_MODE_GYRONLY,
  345. * OPERATION_MODE_ACCMAG,
  346. * OPERATION_MODE_ACCGYRO,
  347. * OPERATION_MODE_MAGGYRO,
  348. * OPERATION_MODE_AMG,
  349. * OPERATION_MODE_IMUPLUS,
  350. * OPERATION_MODE_COMPASS,
  351. * OPERATION_MODE_M4G,
  352. * OPERATION_MODE_NDOF_FMC_OFF,
  353. * OPERATION_MODE_NDOF]
  354. */
  355. bool sensorBNO::setMode( uint8_t mode ){
  356. if( m_pBus != NULL ){
  357. if( m_pBus->write8( BNO055_OPR_MODE_ADDR, mode ) ) {
  358. SLEEP( 30 );
  359. return true;
  360. };
  361. };
  362. return false;
  363. };
  364. uint8_t sensorBNO::getMode(){
  365. uint8_t retVal = 255;
  366. if( m_pBus != NULL ){
  367. retVal = m_pBus->read8( BNO055_OPR_MODE_ADDR ) & BNO_WMODE_MASK;
  368. };
  369. return retVal;
  370. };
  371. /*!
  372. * @brief Use the external 32.768KHz crystal
  373. * @param usextal
  374. * use external crystal boolean
  375. */
  376. bool sensorBNO::setExtCrystalUse( bool usextal) {
  377. if( m_pBus != NULL ){
  378. uint8_t tMode = m_bActualWM;
  379. /* Switch to config mode (just in case since this is the default) */
  380. setMode( BNO_WM_CONFIG );
  381. SLEEP( 25 );
  382. m_pBus->write8( BNO055_PAGE_ID_ADDR, 0 );
  383. if( usextal ){
  384. m_pBus->write8( BNO055_SYS_TRIGGER_ADDR, 0x80 );
  385. } else {
  386. m_pBus->write8( BNO055_SYS_TRIGGER_ADDR, 0x00 );
  387. };
  388. SLEEP( 10 );
  389. /* Set the requested operating mode (see section 3.3) */
  390. setMode( tMode );
  391. SLEEP( 20 );
  392. };
  393. return false;
  394. };
  395. /*!
  396. * @brief Gets the latest system status info
  397. * @param system_status
  398. * system status info
  399. * @param self_test_result
  400. * self test result
  401. * @param system_error
  402. * system error info
  403. */
  404. bool sensorBNO::getSystemStatus( uint8_t *system_status, uint8_t *self_test_result, uint8_t *system_error ){
  405. if( m_pBus != NULL ){
  406. m_pBus->write8( BNO055_PAGE_ID_ADDR, 0 );
  407. /* System Status (see section 4.3.58)
  408. 0 = Idle
  409. 1 = System Error
  410. 2 = Initializing Peripherals
  411. 3 = System Iniitalization
  412. 4 = Executing Self-Test
  413. 5 = Sensor fusion algorithm running
  414. 6 = System running without fusion algorithms
  415. */
  416. if( system_status != NULL ) *system_status = m_pBus->read8(BNO055_SYS_STAT_ADDR);
  417. /* Self Test Results
  418. 1 = test passed, 0 = test failed
  419. Bit 0 = Accelerometer self test
  420. Bit 1 = Magnetometer self test
  421. Bit 2 = Gyroscope self test
  422. Bit 3 = MCU self test
  423. 0x0F = all good!
  424. */
  425. if( self_test_result != NULL ) *self_test_result = m_pBus->read8(BNO055_SELFTEST_RESULT_ADDR);
  426. /* System Error (see section 4.3.59)
  427. 0 = No error
  428. 1 = Peripheral initialization error
  429. 2 = System initialization error
  430. 3 = Self test result failed
  431. 4 = Register map value out of range
  432. 5 = Register map address out of range
  433. 6 = Register map write error
  434. 7 = BNO low power mode not available for selected operat ion mode
  435. 8 = Accelerometer power mode not available
  436. 9 = Fusion algorithm configuration error
  437. A = Sensor configuration error
  438. */
  439. if( system_error != NULL ) *system_error = m_pBus->read8(BNO055_SYS_ERR_ADDR);
  440. SLEEP( 200 );
  441. return true;
  442. };
  443. return false;
  444. };
  445. /*!
  446. * @brief Gets the chip revision numbers
  447. * @param info
  448. * revision info
  449. */
  450. bool sensorBNO::getRevInfo( bno055_rev_info_t *info ){
  451. if( m_pBus != NULL ){
  452. uint8_t a, b;
  453. memset( info, 0, sizeof( bno055_rev_info_t ) );
  454. /* Check the accelerometer revision */
  455. info->accel_rev = m_pBus->read8(BNO055_ACCEL_REV_ID_ADDR);
  456. /* Check the magnetometer revision */
  457. info->mag_rev = m_pBus->read8(BNO055_MAG_REV_ID_ADDR);
  458. /* Check the gyroscope revision */
  459. info->gyro_rev = m_pBus->read8(BNO055_GYRO_REV_ID_ADDR);
  460. /* Check the SW revision */
  461. info->bl_rev = m_pBus->read8(BNO055_BL_REV_ID_ADDR);
  462. a = m_pBus->read8( BNO055_SW_REV_ID_LSB_ADDR );
  463. b = m_pBus->read8( BNO055_SW_REV_ID_MSB_ADDR );
  464. info->sw_rev = (((uint16_t)b) << 8) | ((uint16_t)a);
  465. return true;
  466. };
  467. return false;
  468. };
  469. /*!
  470. * @brief Gets current calibration state. Each value should be a uint8_t
  471. * pointer and it will be set to 0 if not calibrated and 3 if
  472. * fully calibrated.
  473. * See section 34.3.54
  474. * @param sys
  475. * Current system calibration status, depends on status of all sensors,
  476. * read-only
  477. * @param gyro
  478. * Current calibration status of Gyroscope, read-only
  479. * @param accel
  480. * Current calibration status of Accelerometer, read-only
  481. * @param mag
  482. * Current calibration status of Magnetometer, read-only
  483. */
  484. bool sensorBNO::getCalibration( uint8_t *sys, uint8_t *gyro, uint8_t *accel, uint8_t *mag ){
  485. if( m_pBus != NULL ){
  486. uint8_t calData = m_pBus->read8( BNO055_CALIB_STAT_ADDR );
  487. if( sys != NULL ) *sys = (calData >> 6) & 0x03;
  488. if( gyro != NULL ) *gyro = (calData >> 4) & 0x03;
  489. if( accel != NULL ) *accel = (calData >> 2) & 0x03;
  490. if( mag != NULL ) *mag = calData & 0x03;
  491. return true;
  492. };
  493. return false;
  494. };
  495. /*!
  496. * @brief Gets the temperature in degrees celsius
  497. * @return temperature in degrees celsius
  498. */
  499. int8_t sensorBNO::getTemp(){
  500. if( m_pBus != NULL ){
  501. int8_t temp = (int8_t)(m_pBus->read8(BNO055_TEMP_ADDR));
  502. return temp;
  503. };
  504. return -128;
  505. };
  506. /*!
  507. * @brief Checks of all cal status values are set to 3 (fully calibrated)
  508. * @return status of calibration
  509. */
  510. bool sensorBNO::isFullyCalibrated(){
  511. uint8_t system, gyro, accel, mag;
  512. if( getCalibration( &system, &gyro, &accel, &mag ) ){
  513. char tBuff[128];
  514. sprintf( tBuff, "Calibration Sys: %d Gyr: %d Acc: %d Mag: %d", system, gyro, accel, mag );
  515. LOG( tBuff );
  516. switch( m_bActualWM ){
  517. case BNO_WM_ACC_ONLY: return (accel == 3);
  518. case BNO_WM_MAG_ONLY: return (mag == 3);
  519. case BNO_WM_GYR_ONLY:
  520. case BNO_WM_M4G: /* No magnetometer calibration required. */
  521. return (gyro == 3);
  522. case BNO_WM_ACC_MAG:
  523. case BNO_WM_COMPAS:
  524. return (accel == 3 && mag == 3);
  525. case BNO_WM_ACC_GYR:
  526. case BNO_WM_IMU:
  527. return (accel == 3 && gyro == 3);
  528. case BNO_WM_MAG_GYR:
  529. return (mag == 3 && gyro == 3);
  530. default:
  531. return (system == 3 && gyro == 3 && accel == 3 && mag == 3);
  532. };
  533. };
  534. return false;
  535. };
  536. /*!
  537. * @brief Enter Suspend mode (i.e., sleep)
  538. */
  539. bool sensorBNO::enterSuspendMode(){
  540. if( m_pBus != NULL ){
  541. uint8_t tMode = m_bActualWM;
  542. /* Switch to config mode (just in case since this is the default) */
  543. setMode( BNO_WM_CONFIG );
  544. SLEEP( 25 );
  545. m_pBus->write8( BNO055_PWR_MODE_ADDR, 0x02 );
  546. /* Set the requested operating mode (see section 3.3) */
  547. setMode( tMode );
  548. SLEEP( 20 );
  549. return true;
  550. };
  551. return false;
  552. };
  553. /*!
  554. * @brief Enter Normal mode (i.e., wake)
  555. */
  556. bool sensorBNO::enterNormalMode(){
  557. if( m_pBus != NULL ){
  558. uint8_t tMode = m_bActualWM;
  559. /* Switch to config mode (just in case since this is the default) */
  560. setMode( BNO_WM_CONFIG );
  561. SLEEP( 25 );
  562. m_pBus->write8( BNO055_PWR_MODE_ADDR, 0x00 );
  563. /* Set the requested operating mode (see section 3.3) */
  564. setMode( tMode );
  565. SLEEP( 20 );
  566. return true;
  567. };
  568. return false;
  569. };
  570. /*!
  571. * @brief Gets a vector reading from the specified source
  572. * @param vector_type
  573. * possible vector type values
  574. * [VECTOR_ACCELEROMETER
  575. * VECTOR_MAGNETOMETER
  576. * VECTOR_GYROSCOPE
  577. * VECTOR_EULER
  578. * VECTOR_LINEARACCEL
  579. * VECTOR_GRAVITY]
  580. * @return vector from specified source
  581. */
  582. bool sensorBNO::getVector( uint16_t vector_type, BNO_3D_VECTOR *xyz ){
  583. if( xyz != NULL ) {
  584. if( m_pBus != NULL ){
  585. uint8_t buffer[6];
  586. memset(buffer, 0, 6);
  587. int16_t x, y, z;
  588. x = y = z = 0;
  589. /* Read vector data (6 bytes) */
  590. if( m_pBus->readMZ( vector_type, buffer, 6 ) ){
  591. x = ((int16_t)buffer[0]) | (((int16_t)buffer[1]) << 8);
  592. y = ((int16_t)buffer[2]) | (((int16_t)buffer[3]) << 8);
  593. z = ((int16_t)buffer[4]) | (((int16_t)buffer[5]) << 8);
  594. /*!
  595. * Convert the value to an appropriate range (section 3.6.4)
  596. * and assign the value to the Vector type
  597. */
  598. switch( vector_type ){
  599. case VECTOR_MAGNETOMETER:
  600. /* 1uT = 16 LSB */
  601. xyz->x = ((double)x) / 16.0;
  602. xyz->y = ((double)y) / 16.0;
  603. xyz->z = ((double)z) / 16.0;
  604. break;
  605. case VECTOR_GYROSCOPE:
  606. /* 1dps = 16 LSB */
  607. xyz->x = ((double)x) / 16.0;
  608. xyz->y = ((double)y) / 16.0;
  609. xyz->z = ((double)z) / 16.0;
  610. break;
  611. case VECTOR_EULER:
  612. /* 1 degree = 16 LSB */
  613. xyz->x = ((double)x) / 16.0;
  614. xyz->y = ((double)y) / 16.0;
  615. xyz->z = ((double)z) / 16.0;
  616. break;
  617. case VECTOR_ACCELEROMETER:
  618. /* 1m/s^2 = 100 LSB */
  619. xyz->x = ((double)x) / 100.0;
  620. xyz->y = ((double)y) / 100.0;
  621. xyz->z = ((double)z) / 100.0;
  622. break;
  623. case VECTOR_LINEARACCEL:
  624. /* 1m/s^2 = 100 LSB */
  625. xyz->x = ((double)x) / 100.0;
  626. xyz->y = ((double)y) / 100.0;
  627. xyz->z = ((double)z) / 100.0;
  628. break;
  629. case VECTOR_GRAVITY:
  630. /* 1m/s^2 = 100 LSB */
  631. xyz->x = ((double)x) / 100.0;
  632. xyz->y = ((double)y) / 100.0;
  633. xyz->z = ((double)z) / 100.0;
  634. break;
  635. };
  636. return true;
  637. };
  638. };
  639. };
  640. return false;
  641. };
  642. /*!
  643. * @brief Gets a quaternion reading from the specified source
  644. * @return quaternion reading
  645. */
  646. bool sensorBNO::getQuat( BNO_Quat *quat ){
  647. if( quat != NULL ){
  648. if( m_pBus != NULL ){
  649. uint8_t buffer[8];
  650. memset(buffer, 0, 8);
  651. int16_t x, y, z, w;
  652. x = y = z = w = 0;
  653. /* Read quat data (8 bytes) */
  654. if( m_pBus->readMZ( BNO055_QUATERNION_DATA_W_LSB_ADDR, buffer, 8 ) ){
  655. w = (((uint16_t)buffer[1]) << 8) | ((uint16_t)buffer[0]);
  656. x = (((uint16_t)buffer[3]) << 8) | ((uint16_t)buffer[2]);
  657. y = (((uint16_t)buffer[5]) << 8) | ((uint16_t)buffer[4]);
  658. z = (((uint16_t)buffer[7]) << 8) | ((uint16_t)buffer[6]);
  659. /*!
  660. * Assign to Quaternion
  661. * See
  662. * http://ae-bst.resource.bosch.com/media/products/dokumente/bno055/BST_BNO055_DS000_12~1.pdf
  663. * 3.6.5.5 Orientation (Quaternion)
  664. */
  665. const double scale = ( 1.0 / (1 << 14) );
  666. quat->w = scale * w;
  667. quat->x = scale * x;
  668. quat->y = scale * y;
  669. quat->z = scale * z;
  670. return true;
  671. };
  672. };
  673. };
  674. return false;
  675. };
  676. BNO_EVTREC *sensorBNO::getEVT_REC(){
  677. const double scale = ( 1.0 / (1 << 14) );
  678. BNO_EVTREC * retVal = NULL;
  679. PF_TIMESTAMP * tTS1 = NULL;
  680. PF_TIMESTAMP * tTS2 = NULL;
  681. tTS1 = getPFTS();
  682. if( tTS1 != NULL ) {
  683. BNO_DATA_MAP * tDATA;
  684. tDATA = getData();
  685. if( tDATA != NULL ) {
  686. tTS2 = getPFTS();
  687. if( tTS2 != NULL ) {
  688. retVal = (BNO_EVTREC *) malloc(sizeof(BNO_EVTREC));
  689. if( retVal != NULL ) {
  690. uint32_t tVal;
  691. memset(retVal, 0 , sizeof(BNO_EVTREC));
  692. retVal->wm_mode = m_bTargetWM;//m_bActualWM;
  693. if( tTS2->seconds > tTS1->seconds ) {
  694. tVal = ( tTS1->milliseconds + 1000 + tTS2->milliseconds ) >> 1;
  695. } else {
  696. tVal = ( tTS1->milliseconds + tTS2->milliseconds ) >> 1;
  697. };
  698. if( tVal > 999 ) {
  699. retVal->milliseconds = tVal - 1000;
  700. retVal->seconds = tTS1->seconds + 1;
  701. } else {
  702. retVal->milliseconds = tVal;
  703. retVal->seconds = tTS1->seconds;
  704. };
  705. switch( m_bActualWM ) {
  706. case BNO_WM_ACC_ONLY:
  707. /* 1m/s^2 = 100 LSB */
  708. retVal->acc.x = ((double)tDATA->ACC_DATA_X) / 100.0;
  709. retVal->acc.y = ((double)tDATA->ACC_DATA_Y) / 100.0;
  710. retVal->acc.z = ((double)tDATA->ACC_DATA_Z) / 100.0;
  711. case BNO_WM_MAG_ONLY:
  712. /* 1uT = 16 LSB */
  713. retVal->mag.x = ((double)tDATA->MAG_DATA_X) / 16.0;
  714. retVal->mag.y = ((double)tDATA->MAG_DATA_Y) / 16.0;
  715. retVal->mag.z = ((double)tDATA->MAG_DATA_Z) / 16.0;
  716. case BNO_WM_GYR_ONLY:
  717. /* 1uT = 16 LSB */
  718. retVal->gyr.x = ((double)tDATA->GYR_DATA_X) / 16.0;
  719. retVal->gyr.y = ((double)tDATA->GYR_DATA_Y) / 16.0;
  720. retVal->gyr.z = ((double)tDATA->GYR_DATA_Z) / 16.0;
  721. case BNO_WM_ACC_MAG:
  722. /* 1m/s^2 = 100 LSB */
  723. retVal->acc.x = ((double)tDATA->ACC_DATA_X) / 100.0;
  724. retVal->acc.y = ((double)tDATA->ACC_DATA_Y) / 100.0;
  725. retVal->acc.z = ((double)tDATA->ACC_DATA_Z) / 100.0;
  726. /* 1uT = 16 LSB */
  727. retVal->mag.x = ((double)tDATA->MAG_DATA_X) / 16.0;
  728. retVal->mag.y = ((double)tDATA->MAG_DATA_Y) / 16.0;
  729. retVal->mag.z = ((double)tDATA->MAG_DATA_Z) / 16.0;
  730. case BNO_WM_ACC_GYR:
  731. /* 1m/s^2 = 100 LSB */
  732. retVal->acc.x = ((double)tDATA->ACC_DATA_X) / 100.0;
  733. retVal->acc.y = ((double)tDATA->ACC_DATA_Y) / 100.0;
  734. retVal->acc.z = ((double)tDATA->ACC_DATA_Z) / 100.0;
  735. /* 1uT = 16 LSB */
  736. retVal->gyr.x = ((double)tDATA->GYR_DATA_X) / 16.0;
  737. retVal->gyr.y = ((double)tDATA->GYR_DATA_Y) / 16.0;
  738. retVal->gyr.z = ((double)tDATA->GYR_DATA_Z) / 16.0;
  739. case BNO_WM_MAG_GYR:
  740. /* 1uT = 16 LSB */
  741. retVal->mag.x = ((double)tDATA->MAG_DATA_X) / 16.0;
  742. retVal->mag.y = ((double)tDATA->MAG_DATA_Y) / 16.0;
  743. retVal->mag.z = ((double)tDATA->MAG_DATA_Z) / 16.0;
  744. /* 1uT = 16 LSB */
  745. retVal->gyr.x = ((double)tDATA->GYR_DATA_X) / 16.0;
  746. retVal->gyr.y = ((double)tDATA->GYR_DATA_Y) / 16.0;
  747. retVal->gyr.z = ((double)tDATA->GYR_DATA_Z) / 16.0;
  748. case BNO_WM_AMG_NO_FUSION:
  749. /* 1m/s^2 = 100 LSB */
  750. retVal->acc.x = ((double)tDATA->ACC_DATA_X) / 100.0;
  751. retVal->acc.y = ((double)tDATA->ACC_DATA_Y) / 100.0;
  752. retVal->acc.z = ((double)tDATA->ACC_DATA_Z) / 100.0;
  753. /* 1uT = 16 LSB */
  754. retVal->mag.x = ((double)tDATA->MAG_DATA_X) / 16.0;
  755. retVal->mag.y = ((double)tDATA->MAG_DATA_Y) / 16.0;
  756. retVal->mag.z = ((double)tDATA->MAG_DATA_Z) / 16.0;
  757. /* 1uT = 16 LSB */
  758. retVal->gyr.x = ((double)tDATA->GYR_DATA_X) / 16.0;
  759. retVal->gyr.y = ((double)tDATA->GYR_DATA_Y) / 16.0;
  760. retVal->gyr.z = ((double)tDATA->GYR_DATA_Z) / 16.0;
  761. case BNO_WM_IMU: // Fusion Modes -> All datas Update!
  762. case BNO_WM_COMPAS:
  763. case BNO_WM_M4G:
  764. case BNO_WM_NDOF_FMC_OFF:
  765. case BNO_WM_NDOF:
  766. /* 1m/s^2 = 100 LSB */
  767. retVal->acc.x = ((double)tDATA->ACC_DATA_X) / 100.0;
  768. retVal->acc.y = ((double)tDATA->ACC_DATA_Y) / 100.0;
  769. retVal->acc.z = ((double)tDATA->ACC_DATA_Z) / 100.0;
  770. /* 1uT = 16 LSB */
  771. retVal->mag.x = ((double)tDATA->MAG_DATA_X) / 16.0;
  772. retVal->mag.y = ((double)tDATA->MAG_DATA_Y) / 16.0;
  773. retVal->mag.z = ((double)tDATA->MAG_DATA_Z) / 16.0;
  774. /* 1uT = 16 LSB */
  775. retVal->gyr.x = ((double)tDATA->GYR_DATA_X) / 16.0;
  776. retVal->gyr.y = ((double)tDATA->GYR_DATA_Y) / 16.0;
  777. retVal->gyr.z = ((double)tDATA->GYR_DATA_Z) / 16.0;
  778. /* 1 degree = 16 LSB */
  779. retVal->eul.x = ((double)tDATA->EUL_PITCH) / 16.0;
  780. retVal->eul.y = ((double)tDATA->EUL_ROLL) / 16.0;
  781. retVal->eul.z = ((double)tDATA->EUL_YAW) / 16.0;
  782. /* 1m/s^2 = 100 LSB */
  783. retVal->mov.x = ((double)tDATA->LIA_X) / 100.0;
  784. retVal->mov.y = ((double)tDATA->LIA_Y) / 100.0;
  785. retVal->mov.z = ((double)tDATA->LIA_Z) / 100.0;
  786. /* 1m/s^2 = 100 LSB */
  787. retVal->grav.x = ((double)tDATA->GRV_X ) / 100.0;
  788. retVal->grav.y = ((double)tDATA->GRV_Y ) / 100.0;
  789. retVal->grav.z = ((double)tDATA->GRV_Z ) / 100.0;
  790. /* Quat */
  791. retVal->quat.w = scale * tDATA->QUA_W;//(((uint16_t)buffer[1]) << 8) | ((uint16_t)buffer[0]);
  792. retVal->quat.x = scale * tDATA->QUA_X;//(((uint16_t)buffer[3]) << 8) | ((uint16_t)buffer[2]);
  793. retVal->quat.y = scale * tDATA->QUA_Y;//(((uint16_t)buffer[5]) << 8) | ((uint16_t)buffer[4]);
  794. retVal->quat.z = scale * tDATA->QUA_Z;//(((uint16_t)buffer[7]) << 8) | ((uint16_t)buffer[6]);
  795. };
  796. };
  797. free( tTS2 );
  798. };
  799. //free( tDATA );
  800. // No free - getdata uses Class mem
  801. };
  802. free( tTS1 );
  803. };
  804. return retVal;
  805. };
  806. BNO_DATA_MAP *sensorBNO::getData(){
  807. if( switchPage(0) ) {
  808. m_pBus->readMZ( BNO_DATA_OFFSET, (uint8_t *)&m_sDATA, sizeof(BNO_DATA_MAP));
  809. };
  810. return &m_sDATA;
  811. };
  812. bool sensorBNO::getStatus( BNO_STATUS_MAP *tPtr ){
  813. if( switchPage(0) ) {
  814. if( m_pBus->readMZ( BNO_STATUS_OFFSET, (uint8_t *)tPtr, sizeof(BNO_STATUS_MAP))) {
  815. return true;
  816. };
  817. };
  818. return false;
  819. };
  820. bool sensorBNO::resetInterupts(){
  821. if( m_pBus != NULL ) {
  822. uint8_t tVal;
  823. tVal = 0x40;
  824. if( m_pBus->writeMZ( BNO_SYS_TRIG_OFFSET, (uint8_t *)&tVal, 1 ) ){
  825. SLEEP( 30 );
  826. return true;
  827. };
  828. };
  829. return false;
  830. };
  831. bool sensorBNO::resetSystem(){
  832. if( m_pBus != NULL ) {
  833. uint8_t tVal;
  834. tVal = 0x20;
  835. if( m_pBus->writeMZ( BNO_SYS_TRIG_OFFSET, (uint8_t *)&tVal, 1 ) ){
  836. SLEEP( 30 );
  837. return true;
  838. };
  839. };
  840. return false;
  841. };
  842. bool sensorBNO::startBIST(){
  843. if( m_pBus != NULL ) {
  844. uint8_t tVal;
  845. tVal = 0x01;
  846. if( m_pBus->writeMZ( BNO_SYS_TRIG_OFFSET, (uint8_t *)&tVal, 1 ) ){
  847. SLEEP( 30 );
  848. return true;
  849. };
  850. };
  851. return false;
  852. };
  853. bool sensorBNO::setConfigPage0( BNO_CONFIG0_MAP *tPtr ){
  854. if( switchPage(0) ) {
  855. if( m_pBus->writeMZ( BNO_CONFIG0_OFFSET, (uint8_t *)tPtr, sizeof(BNO_CONFIG0_MAP))) {
  856. return true;
  857. };
  858. };
  859. return false;
  860. };
  861. bool sensorBNO::getConfigPage0( BNO_CONFIG0_MAP *tPtr ){
  862. if( switchPage(0) ) {
  863. if( m_pBus->readMZ( BNO_CONFIG0_OFFSET, (uint8_t *)tPtr, sizeof(BNO_CONFIG0_MAP))) {
  864. return true;
  865. };
  866. };
  867. return false;
  868. };
  869. bool sensorBNO::getConfigPage1( BNO_CONFIG1_MAP *tPtr ){
  870. if( switchPage(1) ) {
  871. if( m_pBus->readMZ( BNO_CONFIG1_OFFSET, (uint8_t *)tPtr, sizeof(BNO_CONFIG1_MAP))) {
  872. return true;
  873. };
  874. };
  875. return false;
  876. };
  877. bool sensorBNO::switchPage( uint8_t PageID ){
  878. if( m_pBus!= NULL ){
  879. if( m_sID.PAGE_ID != PageID ) {
  880. if( m_pBus->readMZ( BNO_ID_OFFSET, (uint8_t *)&m_sID, sizeof(BNO_ID_MAP))) {
  881. if( m_sID.PAGE_ID == PageID ) return true;
  882. m_sID.PAGE_ID = PageID;
  883. if( m_pBus->writeMZ( BNO_ID_OFFSET, (uint8_t *)&m_sID, sizeof(BNO_ID_MAP)) ) {
  884. return true;
  885. };
  886. };
  887. } else return true;
  888. };
  889. return false;
  890. };
  891. bool sensorBNO::isDead(){
  892. if( m_pBus!= NULL ){
  893. uint8_t id;
  894. id = m_pBus->read8( BNO055_CHIP_ID_ADDR );
  895. if( id == BNO055_ID ){
  896. return false;
  897. };
  898. };
  899. return true;
  900. };
  901. #undef LOG
  902. #undef LOG_ERROR