The unified diff between revisions [056a532c..] and [bfc9e27f..] is displayed below. It can also be downloaded as a raw diff.
This diff has been restricted to the following files: 'sensors.c'
# # old_revision [056a532c92301bcb224e1f786c5f6720e8acf3eb] # new_revision [bfc9e27f5c40da31ae4269394aaf0545e5856a70] # # patch "sensors.c" # from [129fa873f84fea1677a1d27563afd5402f8d6677] # to [ba01cef6cd239a12b9171dccb25fd02092ca037c] # ============================================================ --- sensors.c 129fa873f84fea1677a1d27563afd5402f8d6677 +++ sensors.c ba01cef6cd239a12b9171dccb25fd02092ca037c @@ -1,6 +1,8 @@ /* sensors.c */ #include "mpu6050.h" +#include "hmc5883l.h" +#include "mpl3115a2.h" #include "dcm.h" #include "fisqrt.h" #include "watchdog.h" @@ -11,10 +13,19 @@ #include "log.h" #include "stick.h" +bool (*sensor_init_fns[])(void) = { + mpu6050_init, + hmc5883l_init, + mpl3115a2_init, +}; + bool (*sensor_start_fns[])(void) = { mpu6050_start_sample, + hmc5883l_start_sample, + mpl3115a2_start_sample, }; +#define SENSOR_INIT_FNS (sizeof(sensor_init_fns)/sizeof(sensor_init_fns[0])) #define SENSOR_START_FNS (sizeof(sensor_start_fns)/sizeof(sensor_start_fns[0])) static unsigned int next_sensor; @@ -53,10 +64,13 @@ bool sensors_init(void) bool sensors_init(void) { + unsigned int i; + next_sensor = 0; - if (!mpu6050_init()) - return FALSE; + for (i = 0; i < SENSOR_INIT_FNS; i++) + if (!(sensor_init_fns[i])()) + return FALSE; return TRUE; } @@ -65,7 +79,7 @@ bool sensors_next_sample(void) { bool result; - result = (sensor_start_fns[next_sensor])(); + result = (sensor_start_fns[next_sensor++])(); if (next_sensor >= SENSOR_START_FNS) next_sensor = 0;