X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=src%2Fstm%2Fao_adc_stm.c;h=8c827aae78bb66f703038327cf6f3f09086c32c8;hp=67416a9d43ae9a5a2fec6f3f03f5dcd85031b8fd;hb=6aeb000899ad7f22e92b487b5891664554bc4d33;hpb=864d1e2282ac1d241478cf663ee24112c9d3dc37 diff --git a/src/stm/ao_adc_stm.c b/src/stm/ao_adc_stm.c index 67416a9d..8c827aae 100644 --- a/src/stm/ao_adc_stm.c +++ b/src/stm/ao_adc_stm.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of @@ -44,23 +45,7 @@ static void ao_adc_done(int index) (void) index; 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_data_fill(ao_data_head); ao_adc_ready = 1; } @@ -92,20 +77,6 @@ ao_adc_poll(void) stm_adc.cr2 = AO_ADC_CR2_VAL | (1 << STM_ADC_CR2_SWSTART); } -/* - * Fetch a copy of the most recent ADC data - */ -void -ao_adc_get(__xdata struct ao_adc *packet) -{ -#if HAS_FLIGHT - uint8_t i = ao_data_ring_prev(ao_sample_data); -#else - uint8_t i = ao_data_ring_prev(ao_data_head); -#endif - memcpy(packet, (void *) &ao_data_ring[i].adc, sizeof (struct ao_adc)); -} - #ifdef AO_ADC_SQ1_NAME static const char *ao_adc_name[AO_NUM_ADC] = { AO_ADC_SQ1_NAME, @@ -173,7 +144,7 @@ static const char *ao_adc_name[AO_NUM_ADC] = { #endif static void -ao_adc_dump(void) __reentrant +ao_adc_dump(void) { struct ao_data packet; #ifndef AO_ADC_DUMP @@ -199,7 +170,7 @@ ao_adc_dump(void) __reentrant #endif } -__code struct ao_cmds ao_adc_cmds[] = { +const struct ao_cmds ao_adc_cmds[] = { { ao_adc_dump, "a\0Display current ADC values" }, { 0, NULL }, }; @@ -376,7 +347,7 @@ ao_adc_init(void) #if AO_NUM_ADC > 18 #error "need to finish stm_adc.sqr settings" #endif - + /* Turn ADC on */ stm_adc.cr2 = AO_ADC_CR2_VAL;