|
|
@@ -25,7 +25,8 @@ nBusAppInterface_t mcu_spi_driver = {
|
|
|
mcu_spi_start,
|
|
|
mcu_spi_stop,
|
|
|
mcu_spi_readData,
|
|
|
- //mcu_spi_store,
|
|
|
+ NULL, //mcu_spi_store,
|
|
|
+ mcu_spi_calibrate,
|
|
|
};
|
|
|
|
|
|
|
|
|
@@ -164,14 +165,17 @@ void mcu_spi_readData(void){
|
|
|
|
|
|
nBus_sensorType_t mcu_spi_getType(uint8_t sensor_index){
|
|
|
|
|
|
- if (sensor_index > mcu_spi_getSensorCount())
|
|
|
+ if (sensor_index > mcu_spi_getSensorCount()) {
|
|
|
return TYPE_UNKNOWN;
|
|
|
+ }
|
|
|
|
|
|
- if (sensor_index == 1)
|
|
|
+ if (sensor_index == 1) {
|
|
|
return TYPE_ACCELEROMETER;
|
|
|
+ }
|
|
|
|
|
|
- if (sensor_index == 2)
|
|
|
+ if (sensor_index == 2) {
|
|
|
return TYPE_GYROSCOPE;
|
|
|
+ }
|
|
|
|
|
|
return TYPE_UNKNOWN;
|
|
|
}
|
|
|
@@ -352,6 +356,43 @@ nBus_param_t mcu_spi_setParam(uint8_t sensor_index, nBus_param_t param, int32_t
|
|
|
return param;
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+/**
|
|
|
+ * @param sebslaveIndex sensorAccIndex, sensorGyroIndex, sensorAll
|
|
|
+ */
|
|
|
+uint8_t mcu_spi_calibrate(uint8_t subslaveIndex, uint8_t calibrationParamsNum, uint8_t *calibrationParams){
|
|
|
+
|
|
|
+ uint8_t wasReady = sensor->IsReady();
|
|
|
+ sensor->Stop();
|
|
|
+ uint8_t success = 0;
|
|
|
+ if (subslaveIndex == (uint8_t) sensorAccIndex){
|
|
|
+ sensor->accSensor->Calibrate();
|
|
|
+ success = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (subslaveIndex == (uint8_t) sensorGyroIndex){
|
|
|
+ sensor->gyroSensor->Calibrate();
|
|
|
+ success = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+// if (subslaveIndex == sensorMagIndex){
|
|
|
+// sensor->magSensor->Calibrate();
|
|
|
+// }
|
|
|
+
|
|
|
+ if (subslaveIndex == (uint8_t) sensorAll){
|
|
|
+ sensor->accSensor->Calibrate();
|
|
|
+ sensor->gyroSensor->Calibrate();
|
|
|
+// sensor->magSensor->Calibrate();
|
|
|
+ success = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (wasReady !=0 ) {
|
|
|
+ sensor->Start();
|
|
|
+ }
|
|
|
+
|
|
|
+ return success;
|
|
|
+}
|
|
|
+
|
|
|
/*
|
|
|
uint8_t mcu_spi_store(void){
|
|
|
return 0;
|