mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-01 09:24:10 +01:00
OP-1658 - Support reset for main sensors
This commit is contained in:
parent
73a7dc00d4
commit
bdd9ac7c60
@ -68,6 +68,7 @@
|
|||||||
#include <CoordinateConversions.h>
|
#include <CoordinateConversions.h>
|
||||||
#include <pios_board_info.h>
|
#include <pios_board_info.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
// Private constants
|
// Private constants
|
||||||
#define STACK_SIZE_BYTES 1000
|
#define STACK_SIZE_BYTES 1000
|
||||||
#define TASK_PRIORITY (tskIDLE_PRIORITY + 3)
|
#define TASK_PRIORITY (tskIDLE_PRIORITY + 3)
|
||||||
@ -123,6 +124,7 @@ PERF_DEFINE_COUNTER(counterAccelPeriod);
|
|||||||
PERF_DEFINE_COUNTER(counterMagPeriod);
|
PERF_DEFINE_COUNTER(counterMagPeriod);
|
||||||
PERF_DEFINE_COUNTER(counterBaroPeriod);
|
PERF_DEFINE_COUNTER(counterBaroPeriod);
|
||||||
PERF_DEFINE_COUNTER(counterSensorPeriod);
|
PERF_DEFINE_COUNTER(counterSensorPeriod);
|
||||||
|
PERF_DEFINE_COUNTER(counterSensorResets);
|
||||||
|
|
||||||
// Private functions
|
// Private functions
|
||||||
static void SensorsTask(void *parameters);
|
static void SensorsTask(void *parameters);
|
||||||
@ -202,6 +204,7 @@ int32_t SensorsInitialize(void)
|
|||||||
RevoCalibrationConnectCallback(&settingsUpdatedCb);
|
RevoCalibrationConnectCallback(&settingsUpdatedCb);
|
||||||
AttitudeSettingsConnectCallback(&settingsUpdatedCb);
|
AttitudeSettingsConnectCallback(&settingsUpdatedCb);
|
||||||
AccelGyroSettingsConnectCallback(&settingsUpdatedCb);
|
AccelGyroSettingsConnectCallback(&settingsUpdatedCb);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,6 +253,7 @@ static void SensorsTask(__attribute__((unused)) void *parameters)
|
|||||||
PERF_INIT_COUNTER(counterMagPeriod, 0x53000003);
|
PERF_INIT_COUNTER(counterMagPeriod, 0x53000003);
|
||||||
PERF_INIT_COUNTER(counterBaroPeriod, 0x53000004);
|
PERF_INIT_COUNTER(counterBaroPeriod, 0x53000004);
|
||||||
PERF_INIT_COUNTER(counterSensorPeriod, 0x53000005);
|
PERF_INIT_COUNTER(counterSensorPeriod, 0x53000005);
|
||||||
|
PERF_INIT_COUNTER(counterSensorResets, 0x53000006);
|
||||||
|
|
||||||
// Test sensors
|
// Test sensors
|
||||||
bool sensors_test = true;
|
bool sensors_test = true;
|
||||||
@ -270,7 +274,7 @@ static void SensorsTask(__attribute__((unused)) void *parameters)
|
|||||||
|
|
||||||
// Main task loop
|
// Main task loop
|
||||||
lastSysTime = xTaskGetTickCount();
|
lastSysTime = xTaskGetTickCount();
|
||||||
|
uint32_t reset_counter = 0;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
// TODO: add timeouts to the sensor reads and set an error if the fail
|
// TODO: add timeouts to the sensor reads and set an error if the fail
|
||||||
@ -302,6 +306,9 @@ static void SensorsTask(__attribute__((unused)) void *parameters)
|
|||||||
processSamples3d(&sensor_context, sensor);
|
processSamples3d(&sensor_context, sensor);
|
||||||
clearContext(&sensor_context);
|
clearContext(&sensor_context);
|
||||||
} else if (is_primary) {
|
} else if (is_primary) {
|
||||||
|
PIOS_SENSOR_Reset(sensor);
|
||||||
|
reset_counter++;
|
||||||
|
PERF_TRACK_VALUE(counterSensorResets, reset_counter);
|
||||||
error = true;
|
error = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -143,6 +143,12 @@ static inline void PIOS_SENSOR_Fetch(const PIOS_SENSORS_Instance *sensor, void *
|
|||||||
sensor->driver->fetch(samples, size, sensor->context);
|
sensor->driver->fetch(samples, size, sensor->context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void PIOS_SENSOR_Reset(const PIOS_SENSORS_Instance *sensor)
|
||||||
|
{
|
||||||
|
PIOS_Assert(sensor);
|
||||||
|
sensor->driver->reset(sensor->context);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* retrieve the sensor queue
|
* retrieve the sensor queue
|
||||||
* @param sensor
|
* @param sensor
|
||||||
|
Loading…
Reference in New Issue
Block a user