X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=src%2Fdrivers%2Fao_adxl375.c;fp=src%2Fdrivers%2Fao_adxl375.c;h=778c214b6e49b637a0ebd0be74b65c5de1120b68;hp=e0d094f214b3a42a8f48a9f5cced8f0685f5debb;hb=c01514fa1e0a2cea3955c71a833b4a21b3d33f24;hpb=0686a7b8aec524d81bda4c572549a3a068ce0eed diff --git a/src/drivers/ao_adxl375.c b/src/drivers/ao_adxl375.c index e0d094f2..778c214b 100644 --- a/src/drivers/ao_adxl375.c +++ b/src/drivers/ao_adxl375.c @@ -98,8 +98,8 @@ struct ao_adxl375_total { int32_t z; }; -#define AO_ADXL375_SELF_TEST_SAMPLES 16 -#define AO_ADXL375_SELF_TEST_SETTLE 6 +#define AO_ADXL375_SELF_TEST_SAMPLES 10 +#define AO_ADXL375_SELF_TEST_SETTLE 4 #define MIN_LSB_G 18.4 #define MAX_LSB_G 22.6 @@ -109,9 +109,6 @@ struct ao_adxl375_total { #define MIN_SELF_TEST ((int32_t) (MIN_LSB_G * SELF_TEST_MIN_G * AO_ADXL375_SELF_TEST_SAMPLES + 0.5)) #define MAX_SELF_TEST ((int32_t) (MAX_LSB_G * SELF_TEST_MAX_G * AO_ADXL375_SELF_TEST_SAMPLES + 0.5)) -static const int32_t min_self_test = MIN_SELF_TEST; -static const int32_t max_self_test = MAX_SELF_TEST; - static void ao_adxl375_total_value(struct ao_adxl375_total *total, int samples) { @@ -178,9 +175,6 @@ ao_adxl375_setup(void) (void) ao_adxl375_total_value; /* Perform self-test */ -#define AO_ADXL375_SELF_TEST_SAMPLES 16 -#define AO_ADXL375_SELF_TEST_SETTLE 6 - struct ao_adxl375_total self_test_off, self_test_on; /* Discard some samples to let it settle down */ @@ -210,22 +204,19 @@ ao_adxl375_setup(void) self_test_value = z_change; - if (z_change < min_self_test || max_self_test < z_change) + if (z_change < MIN_SELF_TEST || MAX_SELF_TEST < z_change) ao_sensor_errors = 1; /* Discard some samples to let it settle down */ ao_adxl375_total_value(&self_test_off, AO_ADXL375_SELF_TEST_SETTLE); } -static int adxl375_count; - static void ao_adxl375(void) { ao_adxl375_setup(); for (;;) { ao_adxl375_value(&ao_adxl375_current); - ++adxl375_count; ao_arch_critical( AO_DATA_PRESENT(AO_DATA_ADXL375); AO_DATA_WAIT(); @@ -238,11 +229,10 @@ static struct ao_task ao_adxl375_task; static void ao_adxl375_dump(void) { - printf ("ADXL375 value %d %d %d count %d self test %d min %d max %d\n", + printf ("ADXL375 value %d %d %d self test %d min %d max %d\n", ao_adxl375_current.x, ao_adxl375_current.y, ao_adxl375_current.z, - adxl375_count, self_test_value, MIN_SELF_TEST, MAX_SELF_TEST);