X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fstm-demo-adc%2Fao_demo.c;h=75716c1c2f6f8d19eac55bb4db95ab1ca5569f47;hb=ffcdffbac36771faa1aa9c3bb9ab510718aa7f95;hp=fba42d8d125134ccd1459513afdeb18851cb6b62;hpb=0582c27a6e86ed856809bd37739ede37b9219607;p=fw%2Faltos diff --git a/src/stm-demo-adc/ao_demo.c b/src/stm-demo-adc/ao_demo.c index fba42d8d..75716c1c 100644 --- a/src/stm-demo-adc/ao_demo.c +++ b/src/stm-demo-adc/ao_demo.c @@ -22,6 +22,7 @@ #include #include #include +#include struct ao_task demo_task; @@ -138,19 +139,27 @@ ao_i2c_write(void) { } } + static void ao_temp (void) { - struct ao_data packet; + struct ao_adc adc; int temp; +#if HAS_ADC + struct ao_data packet; ao_data_get(&packet); + adc = packet.adc; +#endif +#if HAS_ADC_SINGLE + ao_adc_single_get(&adc); +#endif /* * r = (110 - 25) / (ts_cal_hot - ts_cal_cold) * 25 + (110 - 25) * (temp - ts_cal_cold) / (ts_cal_hot - ts_cal_cold) */ - temp = 25 + (110 - 25) * (packet.adc.temp - stm_temp_cal.ts_cal_cold) / (stm_temp_cal.ts_cal_hot - stm_temp_cal.ts_cal_cold); + temp = 25 + (110 - 25) * (adc.temp - stm_temp_cal.ts_cal_cold) / (stm_temp_cal.ts_cal_hot - stm_temp_cal.ts_cal_cold); printf ("temp: %d\n", temp); } @@ -231,7 +240,7 @@ main(void) // ao_timer_set_adc_interval(100); - ao_adc_init(); + ao_adc_single_init(); ao_usb_init(); ao_add_task(&ao_blink_task, ao_blink, "blink");