From c6e57291d91f1f6c4de5c54a5cfd3eef66d9f830 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 15 Aug 2018 17:47:37 -0700 Subject: altos: Remove 8051 address space specifiers Signed-off-by: Keith Packard --- src/stm/ao_adc_stm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/stm/ao_adc_stm.c') diff --git a/src/stm/ao_adc_stm.c b/src/stm/ao_adc_stm.c index 24912bb2..2399e6a2 100644 --- a/src/stm/ao_adc_stm.c +++ b/src/stm/ao_adc_stm.c @@ -100,7 +100,7 @@ ao_adc_poll(void) * Fetch a copy of the most recent ADC data */ void -ao_adc_get(__xdata struct ao_adc *packet) +ao_adc_get(struct ao_adc *packet) { #if HAS_FLIGHT uint8_t i = ao_data_ring_prev(ao_sample_data); @@ -177,7 +177,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 @@ -203,7 +203,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 }, }; -- cgit v1.2.3 From 80affca535c5c43a5d9963dfafc74f9675c9b155 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 19 Oct 2018 08:12:22 -0700 Subject: altos: Create ao_data_fill shared function This fills a data ring entry with all of the current sensor values other than the ADC. It is used in all of the adc completion functions. Signed-off-by: Keith Packard --- src/kernel/ao_data.h | 28 ++++++++++++++++++++++++++++ src/lpc/ao_adc_lpc.c | 18 +----------------- src/stm/ao_adc_stm.c | 21 +-------------------- src/stmf0/ao_adc_stm.c | 18 +----------------- 4 files changed, 31 insertions(+), 54 deletions(-) (limited to 'src/stm/ao_adc_stm.c') diff --git a/src/kernel/ao_data.h b/src/kernel/ao_data.h index f88b30c9..97f7e06e 100644 --- a/src/kernel/ao_data.h +++ b/src/kernel/ao_data.h @@ -400,4 +400,32 @@ typedef int16_t ao_mag_t; /* in raw sample units */ #endif +#ifdef AO_DATA_RING + +static inline void +ao_data_fill(int head) { + if (ao_data_present == AO_DATA_ALL) { +#if HAS_MS5607 + ao_data_ring[head].ms5607_raw = ao_ms5607_current; +#endif +#if HAS_MMA655X + ao_data_ring[head].mma655x = ao_mma655x_current; +#endif +#if HAS_HMC5883 + ao_data_ring[head].hmc5883 = ao_hmc5883_current; +#endif +#if HAS_MPU6000 + ao_data_ring[head].mpu6000 = ao_mpu6000_current; +#endif +#if HAS_MPU9250 + ao_data_ring[head].mpu9250 = ao_mpu9250_current; +#endif + ao_data_ring[head].tick = ao_tick_count; + ao_data_head = ao_data_ring_next(head); + ao_wakeup((void *) &ao_data_head); + } +} + +#endif + #endif /* _AO_DATA_H_ */ diff --git a/src/lpc/ao_adc_lpc.c b/src/lpc/ao_adc_lpc.c index 6743c1f4..63241559 100644 --- a/src/lpc/ao_adc_lpc.c +++ b/src/lpc/ao_adc_lpc.c @@ -112,23 +112,7 @@ void lpc_adc_isr(void) } AO_DATA_PRESENT(AO_DATA_ADC); - 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; } diff --git a/src/stm/ao_adc_stm.c b/src/stm/ao_adc_stm.c index 2399e6a2..ffdcccc0 100644 --- a/src/stm/ao_adc_stm.c +++ b/src/stm/ao_adc_stm.c @@ -45,26 +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 -#if HAS_MPU9250 - ao_data_ring[ao_data_head].mpu9250 = ao_mpu9250_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; } diff --git a/src/stmf0/ao_adc_stm.c b/src/stmf0/ao_adc_stm.c index e62bb16e..d48726a1 100644 --- a/src/stmf0/ao_adc_stm.c +++ b/src/stmf0/ao_adc_stm.c @@ -38,23 +38,7 @@ static void ao_adc_done(int index) AO_DATA_PRESENT(AO_DATA_ADC); ao_dma_done_transfer(STM_DMA_INDEX(STM_DMA_CHANNEL_ADC_1)); - 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; } -- cgit v1.2.3