|
|
|
@ -22,17 +22,27 @@ uint16_t AP_InertialSensor_VRBRAIN::_init_sensor( Sample_rate sample_rate )
@@ -22,17 +22,27 @@ uint16_t AP_InertialSensor_VRBRAIN::_init_sensor( Sample_rate sample_rate )
|
|
|
|
|
// assumes max 2 instances
|
|
|
|
|
_accel_fd[0] = open(ACCEL_DEVICE_PATH, O_RDONLY); |
|
|
|
|
_accel_fd[1] = open(ACCEL_DEVICE_PATH "1", O_RDONLY); |
|
|
|
|
_accel_fd[2] = open(ACCEL_DEVICE_PATH "2", O_RDONLY); |
|
|
|
|
_gyro_fd[0] = open(GYRO_DEVICE_PATH, O_RDONLY); |
|
|
|
|
_gyro_fd[1] = open(GYRO_DEVICE_PATH "1", O_RDONLY); |
|
|
|
|
_gyro_fd[2] = open(GYRO_DEVICE_PATH "2", O_RDONLY); |
|
|
|
|
|
|
|
|
|
if (_accel_fd[0] < 0) { |
|
|
|
|
_num_accel_instances = 0; |
|
|
|
|
_num_gyro_instances = 0; |
|
|
|
|
for (uint8_t i=0; i<INS_MAX_INSTANCES; i++) { |
|
|
|
|
if (_accel_fd[i] >= 0) { |
|
|
|
|
_num_accel_instances = i+1; |
|
|
|
|
} |
|
|
|
|
if (_gyro_fd[i] >= 0) { |
|
|
|
|
_num_gyro_instances = i+1; |
|
|
|
|
} |
|
|
|
|
}
|
|
|
|
|
if (_num_accel_instances == 0) { |
|
|
|
|
hal.scheduler->panic("Unable to open accel device " ACCEL_DEVICE_PATH); |
|
|
|
|
} |
|
|
|
|
if (_gyro_fd[0] < 0) { |
|
|
|
|
if (_num_gyro_instances == 0) { |
|
|
|
|
hal.scheduler->panic("Unable to open gyro device " GYRO_DEVICE_PATH); |
|
|
|
|
} |
|
|
|
|
_num_accel_instances = _accel_fd[1] >= 0?2:1; |
|
|
|
|
_num_gyro_instances = _gyro_fd[1] >= 0?2:1; |
|
|
|
|
|
|
|
|
|
switch (sample_rate) { |
|
|
|
|
case RATE_50HZ: |
|
|
|
|