Skip to content

Commit

Permalink
#102: Sensors: acquire pressure sensor only 100 times per seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
ataffanel committed Apr 27, 2016
1 parent d54d929 commit e076413
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
3 changes: 0 additions & 3 deletions src/modules/interface/stabilizer_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,6 @@ typedef struct setpointZ_s {
bool isUpdate; // True = small update of setpoint, false = completely new
} setpointZ_t;

#include "FreeRTOS.h"
#include "task.h"

#define _RATE_SKIP_HZ(T, X) ((T % (1000/X)) != 0)

#define RATE_SKIP_500HZ(tick) _RATE_SKIP_HZ(tick, 500)
Expand Down
27 changes: 13 additions & 14 deletions src/modules/src/sensors_stock.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,20 @@ bool sensorsTest(void)

bool sensorsAcquire(sensorData_t *sensors, const uint32_t tick)
{
if (RATE_SKIP_500HZ(tick)) {
return imu6IsCalibrated();
}
if (!RATE_SKIP_500HZ(tick)) {
imu9Read(&sensors->gyro, &sensors->acc, &sensors->mag);
}

imu9Read(&sensors->gyro, &sensors->acc, &sensors->mag);
if (imuHasBarometer()) {
#ifdef PLATFORM_CF1
ms5611GetData(&sensors->baro.pressure,
&sensors->baro.temperature,
&sensors->baro.asl);
#else
lps25hGetData(&sensors->baro.pressure,
&sensors->baro.temperature,
&sensors->baro.asl);
#endif
if (!RATE_SKIP_100HZ(tick) && imuHasBarometer()) {
#ifdef PLATFORM_CF1
ms5611GetData(&sensors->baro.pressure,
&sensors->baro.temperature,
&sensors->baro.asl);
#else
lps25hGetData(&sensors->baro.pressure,
&sensors->baro.temperature,
&sensors->baro.asl);
#endif
}
// Get the position

Expand Down
2 changes: 1 addition & 1 deletion src/modules/src/stabilizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ bool stabilizerTest(void)
*/
static void stabilizerTask(void* param)
{
uint32_t tick;
uint32_t tick = 0;
uint32_t lastWakeTime;
vTaskSetApplicationTaskTag(0, (void*)TASK_STABILIZER_ID_NBR);

Expand Down

0 comments on commit e076413

Please sign in to comment.