Revision 3b2655dc Adafruit_BNO055.cpp

View differences:

Adafruit_BNO055.cpp
104 104
    @brief  Gets the latest system status info
105 105
*/
106 106
/**************************************************************************/
107
void Adafruit_BNO055::getSystemStatus(adafruit_bno055_system_status_t * status)
107
void Adafruit_BNO055::getSystemStatus(uint8_t *system_status, uint8_t *self_test_result, uint8_t *system_error)
108 108
{
109
  memset(status, 0, sizeof(adafruit_bno055_system_status_t));
110
  
109
  write8(BNO055_SYS_TRIGGER_ADDR, read8(BNO055_SYS_TRIGGER_ADDR) | 0x1);
110
  delay(10);
111 111
  /* Read the system status register */
112
  status->system_status    = read8(BNO055_SYS_STAT_ADDR);
113
  status->self_test_result = read8(BNO055_SELFTEST_RESULT_ADDR);
114
  status->system_error     = read8(BNO055_SYS_ERR_ADDR);
112
  if (system_status != 0)
113
    *system_status    = read8(BNO055_SYS_STAT_ADDR);
114
  if (self_test_result != 0)
115
    *self_test_result = read8(BNO055_SELFTEST_RESULT_ADDR);
116
  if (system_error != 0)
117
    *system_error     = read8(BNO055_SYS_ERR_ADDR);
115 118
}
116 119

  
117 120
/**************************************************************************/
......
121 124
/**************************************************************************/
122 125
void Adafruit_BNO055::displaySystemStatus(void)
123 126
{
124
  adafruit_bno055_system_status_t status;
125
  getSystemStatus(&status);
127
  uint8_t system_status, self_test_result, system_error;
128
  getSystemStatus(&system_status, &self_test_result, &system_error);
126 129
  
127 130
  /* System Status (see section 4.3.58)
128 131
     ---------------------------------
......
135 138
     6 = System running without fusion algorithms */
136 139
  
137 140
  Serial.print("System Status:          0x");
138
  Serial.println(status.system_status, HEX);
141
  Serial.println(system_status, HEX);
139 142

  
140 143
  /* Self Test Results (see section )
141 144
     --------------------------------
......
149 152
     0x0F = all good! */
150 153
  
151 154
  Serial.print("Self Test Results:      0x");
152
  Serial.println(status.self_test_result, HEX);
155
  Serial.println(self_test_result, HEX);
153 156

  
154 157
  /* System Error (see section 4.3.59)
155 158
     ---------------------------------
......
166 169
     A = Sensor configuration error */
167 170
  
168 171
  Serial.print("System Error:           0x");
169
  Serial.println(status.system_error, HEX);
172
  Serial.println(system_error, HEX);
170 173
}
171 174

  
172 175
/**************************************************************************/

Also available in: Unified diff