/*
* Mark a section of data as ready, check for data complete
*/
-#define AO_DATA_PRESENT(bit) do { \
- if ((ao_data_present |= (bit)) == AO_DATA_ALL) { \
- ao_data_ring[ao_data_head].tick = ao_tick_count; \
- ao_data_head = ao_data_ring_next(ao_data_head); \
- ao_data_present = 0; \
- ao_wakeup((void *) &ao_data_head); \
- } \
- } while (0);
+#define AO_DATA_PRESENT(bit) (ao_data_present |= (bit))
/*
* Wait until it is time to write a sensor sample; this is
return 1;
}
+struct ao_hmc5883_sample ao_hmc5883_current;
+
static void
ao_hmc5883(void)
{
ao_hmc5883_setup();
for (;;) {
- ao_hmc5883_sample((struct ao_hmc5883_sample *) &ao_data_ring[ao_data_head].hmc5883);
+ ao_hmc5883_sample(&ao_hmc5883_current);
ao_arch_critical(
AO_DATA_PRESENT(AO_DATA_HMC5883);
AO_DATA_WAIT();
int16_t x, y, z;
};
+extern struct ao_hmc5883_sample ao_hmc5883_current;
+
void
ao_hmc5883_init(void);
{ 0, NULL },
};
+uint16_t ao_mma655x_current;
+
static void
ao_mma655x(void)
{
ao_mma655x_setup();
for (;;) {
- ao_data_ring[ao_data_head].mma655x = ao_mma655x_value();
+ ao_mma655x_current = ao_mma655x_value();
ao_arch_critical(
AO_DATA_PRESENT(AO_DATA_MMA655X);
AO_DATA_WAIT();
#define AO_MMA655X_COUNT 0x15
#define AO_MMA655X_OFFCORR 0x16
+extern uint16_t ao_mma655x_current;
void
ao_mma655x_init(void);
ao_mpu6000_configured = 1;
}
+struct ao_mpu6000_sample ao_mpu6000_current;
+
static void
ao_mpu6000(void)
{
ao_mpu6000_setup();
for (;;)
{
- ao_mpu6000_sample((struct ao_mpu6000_sample *) &ao_data_ring[ao_data_head].mpu6000);
+ ao_mpu6000_sample(&ao_mpu6000_current);
ao_arch_critical(
AO_DATA_PRESENT(AO_DATA_MPU6000);
AO_DATA_WAIT();
int16_t gyro_z;
};
+extern struct ao_mpu6000_sample ao_mpu6000_current;
+
void
ao_mpu6000_init(void);
value->temp = TEMP;
}
+struct ao_ms5607_sample ao_ms5607_current;
+
static void
ao_ms5607(void)
{
ao_ms5607_setup();
for (;;)
{
- ao_ms5607_sample((struct ao_ms5607_sample *) &ao_data_ring[ao_data_head].ms5607_raw);
+ ao_ms5607_sample(&ao_ms5607_current);
ao_arch_critical(
AO_DATA_PRESENT(AO_DATA_MS5607);
AO_DATA_WAIT();
int32_t temp; /* in °C * 100 */
};
+extern struct ao_ms5607_sample ao_ms5607_current;
+
void
ao_ms5607_init(void);
{
AO_DATA_PRESENT(AO_DATA_ADC);
ao_dma_done_transfer(STM_DMA_INDEX(STM_DMA_CHANNEL_ADC1));
+ if (ao_data_present == AO_DATA_ALL) {
+#if HAS_MS5607
+ ao_data_ring[ao_data_head].ms5607_raw = ao_ms5607_current;
+#endif
+#if HAS_MMA655X
+ ao_data_ring[ao_data_head].mma655x = ao_mma655x_current;
+#endif
+#if HAS_HMC5883
+ ao_data_ring[ao_data_head].hmc5883 = ao_hmc5883_current;
+#endif
+#if HAS_MPU6000
+ ao_data_ring[ao_data_head].mpu6000 = ao_mpu6000_current;
+#endif
+ ao_data_ring[ao_data_head].tick = ao_tick_count;
+ ao_data_head = ao_data_ring_next(ao_data_head);
+ ao_wakeup((void *) &ao_data_head);
+ }
ao_adc_ready = 1;
}