From e823ead4b0af94b12b3cf5ffae7ea4ca4bc0628f Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sat, 18 Mar 2017 14:36:35 +0000 Subject: [PATCH] Tidy up web demo ADC code style --- .../cc26xx/cc26xx-web-demo/cc26xx-web-demo.c | 35 +++++++++++-------- .../cc26xx/cc26xx-web-demo/cc26xx-web-demo.h | 1 - .../cc26xx/cc26xx-web-demo/project-conf.h | 2 +- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/examples/cc26xx/cc26xx-web-demo/cc26xx-web-demo.c b/examples/cc26xx/cc26xx-web-demo/cc26xx-web-demo.c index 1b80801a6..e14991d04 100644 --- a/examples/cc26xx/cc26xx-web-demo/cc26xx-web-demo.c +++ b/examples/cc26xx/cc26xx-web-demo/cc26xx-web-demo.c @@ -57,7 +57,6 @@ #include #include "ti-lib.h" - /*---------------------------------------------------------------------------*/ PROCESS_NAME(cetic_6lbr_client_process); PROCESS(cc26xx_web_demo_process, "CC26XX Web Demo"); @@ -1008,45 +1007,53 @@ PROCESS_THREAD(cc26xx_web_demo_process, ev, data) PROCESS_END(); } - +/*---------------------------------------------------------------------------*/ #if CC26XX_WEB_DEMO_ADC_DEMO PROCESS_THREAD(adc_process, ev, data) { PROCESS_BEGIN(); + etimer_set(&et_adc, CLOCK_SECOND * 5); + while(1) { + PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et_adc)); + /* intialisation of ADC */ ti_lib_aon_wuc_aux_wakeup_event(AONWUC_AUX_WAKEUP); - while(!(ti_lib_aon_wuc_power_status_get() & AONWUC_AUX_POWER_ON)) { - } + while(!(ti_lib_aon_wuc_power_status_get() & AONWUC_AUX_POWER_ON)); - /* Enable clock for ADC digital and analog interface (not currently enabled in driver) */ - /* Enable clocks */ - ti_lib_aux_wuc_clock_enable(AUX_WUC_ADI_CLOCK | AUX_WUC_ANAIF_CLOCK | AUX_WUC_SMPH_CLOCK); - while(ti_lib_aux_wuc_clock_status(AUX_WUC_ADI_CLOCK | AUX_WUC_ANAIF_CLOCK | AUX_WUC_SMPH_CLOCK) != AUX_WUC_CLOCK_READY) { - } + /* + * Enable clock for ADC digital and analog interface (not currently enabled + * in driver) + */ + ti_lib_aux_wuc_clock_enable(AUX_WUC_ADI_CLOCK | AUX_WUC_ANAIF_CLOCK | + AUX_WUC_SMPH_CLOCK); + while(ti_lib_aux_wuc_clock_status(AUX_WUC_ADI_CLOCK | AUX_WUC_ANAIF_CLOCK | + AUX_WUC_SMPH_CLOCK) + != AUX_WUC_CLOCK_READY); /* Connect AUX IO7 (DIO23, but also DP2 on XDS110) as analog input. */ ti_lib_aux_adc_select_input(ADC_COMPB_IN_AUXIO7); - /* Set up ADC range */ - /* AUXADC_REF_FIXED = nominally 4.3 V */ - ti_lib_aux_adc_enable_sync(AUXADC_REF_FIXED, AUXADC_SAMPLE_TIME_2P7_US, AUXADC_TRIGGER_MANUAL); + /* Set up ADC range, AUXADC_REF_FIXED = nominally 4.3 V */ + ti_lib_aux_adc_enable_sync(AUXADC_REF_FIXED, AUXADC_SAMPLE_TIME_2P7_US, + AUXADC_TRIGGER_MANUAL); /* Trigger ADC converting */ ti_lib_aux_adc_gen_manual_trigger(); - /* reading adc value */ + /* Read value */ single_adc_sample = ti_lib_aux_adc_read_fifo(); - /* shut the adc down */ + /* Shut the adc down */ ti_lib_aux_adc_disable(); get_adc_reading(NULL); etimer_reset(&et_adc); } + PROCESS_END(); } #endif diff --git a/examples/cc26xx/cc26xx-web-demo/cc26xx-web-demo.h b/examples/cc26xx/cc26xx-web-demo/cc26xx-web-demo.h index b740a5d4c..e40cd1864 100644 --- a/examples/cc26xx/cc26xx-web-demo/cc26xx-web-demo.h +++ b/examples/cc26xx/cc26xx-web-demo/cc26xx-web-demo.h @@ -85,7 +85,6 @@ #else #define CC26XX_WEB_DEMO_ADC_DEMO 0 #endif - /*---------------------------------------------------------------------------*/ /* Active probing of RSSI from our preferred parent */ #if (CC26XX_WEB_DEMO_COAP_SERVER || CC26XX_WEB_DEMO_MQTT_CLIENT) diff --git a/examples/cc26xx/cc26xx-web-demo/project-conf.h b/examples/cc26xx/cc26xx-web-demo/project-conf.h index 1d2355006..67b0971c7 100644 --- a/examples/cc26xx/cc26xx-web-demo/project-conf.h +++ b/examples/cc26xx/cc26xx-web-demo/project-conf.h @@ -41,13 +41,13 @@ #define CC26XX_WEB_DEMO_CONF_6LBR_CLIENT 1 #define CC26XX_WEB_DEMO_CONF_COAP_SERVER 1 #define CC26XX_WEB_DEMO_CONF_NET_UART 1 + /* * ADC sensor functionality. To test this, an external voltage source should be * connected to DIO23 * Enable/Disable DIO23 ADC reading by setting CC26XX_WEB_DEMO_CONF_ADC_DEMO */ #define CC26XX_WEB_DEMO_CONF_ADC_DEMO 0 - /*---------------------------------------------------------------------------*/ /* Enable the ROM bootloader */ #define ROM_BOOTLOADER_ENABLE 1