[ahrs] start getting rid of global ahrs.state

This commit is contained in:
Felix Ruess
2014-11-10 19:12:10 +01:00
parent 0972b7f262
commit 2b94da3284
4 changed files with 6 additions and 19 deletions
+4 -1
View File
@@ -92,7 +92,10 @@ bool_t autopilot_detect_ground_once;
#include "subsystems/ahrs.h"
static inline int ahrs_is_aligned(void)
{
return (ahrs.status == AHRS_RUNNING);
/* FIXME: proper ahrs status management
* maybe use one global AhrsStatus enum again that all implementations need to use
*/
return (DefaultAhrsImpl.status == AHRS_MLKF_RUNNING);
}
#else
PRINT_CONFIG_MSG("Using AUTOPILOT_DISABLE_AHRS_KILL")
+1 -4
View File
@@ -374,11 +374,8 @@ static inline void on_gyro_event( void ) {
AbiSendMsgIMU_GYRO_INT32(1, &now_ts, &imu.gyro_prev);
#if USE_AHRS_ALIGNER
if (ahrs.status != AHRS_RUNNING) {
if (ahrs_aligner.status != AHRS_ALIGNER_LOCKED) {
ahrs_aligner_run();
if (ahrs_aligner.status == AHRS_ALIGNER_LOCKED) {
ahrs.status = AHRS_RUNNING;
}
return;
}
#endif
+1 -5
View File
@@ -26,7 +26,6 @@
#include "subsystems/ahrs.h"
#include "subsystems/imu.h"
struct Ahrs ahrs;
@@ -36,20 +35,17 @@ void ahrs_register_impl(AhrsInit init, AhrsUpdateGps update_gps)
ahrs.update_gps = update_gps;
ahrs.init();
ahrs.status = AHRS_REGISTERED;
}
void ahrs_init(void)
{
ahrs.status = AHRS_UNINIT;
ahrs.init = NULL;
ahrs.update_gps = NULL;
}
void ahrs_update_gps(void)
{
if (ahrs.update_gps != NULL && ahrs.status == AHRS_RUNNING) {
if (ahrs.update_gps != NULL) {
ahrs.update_gps();
}
}
-9
View File
@@ -28,13 +28,6 @@
#define AHRS_H
#include "std.h"
#include "math/pprz_algebra_int.h"
#include "math/pprz_algebra_float.h"
#include "math/pprz_orientation_conversion.h"
#define AHRS_UNINIT 0
#define AHRS_REGISTERED 1
#define AHRS_RUNNING 2
/* underlying includes (needed for parameters) */
#ifdef AHRS_TYPE_H
@@ -46,8 +39,6 @@ typedef void (*AhrsUpdateGps)(void);
/** Attitude and Heading Reference System state */
struct Ahrs {
uint8_t status; ///< status of the AHRS, AHRS_UNINIT or AHRS_RUNNING
/* function pointers to actual implementation, set by ahrs_register_impl */
AhrsInit init;
AhrsUpdateGps update_gps;