Tidy up web demo ADC code style

This commit is contained in:
George Oikonomou 2017-03-18 14:36:35 +00:00
parent 474dc33e12
commit e823ead4b0
3 changed files with 22 additions and 16 deletions

View file

@ -57,7 +57,6 @@
#include <string.h> #include <string.h>
#include "ti-lib.h" #include "ti-lib.h"
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
PROCESS_NAME(cetic_6lbr_client_process); PROCESS_NAME(cetic_6lbr_client_process);
PROCESS(cc26xx_web_demo_process, "CC26XX Web Demo"); PROCESS(cc26xx_web_demo_process, "CC26XX Web Demo");
@ -1008,45 +1007,53 @@ PROCESS_THREAD(cc26xx_web_demo_process, ev, data)
PROCESS_END(); PROCESS_END();
} }
/*---------------------------------------------------------------------------*/
#if CC26XX_WEB_DEMO_ADC_DEMO #if CC26XX_WEB_DEMO_ADC_DEMO
PROCESS_THREAD(adc_process, ev, data) PROCESS_THREAD(adc_process, ev, data)
{ {
PROCESS_BEGIN(); PROCESS_BEGIN();
etimer_set(&et_adc, CLOCK_SECOND * 5); etimer_set(&et_adc, CLOCK_SECOND * 5);
while(1) { while(1) {
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et_adc)); PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et_adc));
/* intialisation of ADC */ /* intialisation of ADC */
ti_lib_aon_wuc_aux_wakeup_event(AONWUC_AUX_WAKEUP); 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 */ * Enable clock for ADC digital and analog interface (not currently enabled
ti_lib_aux_wuc_clock_enable(AUX_WUC_ADI_CLOCK | AUX_WUC_ANAIF_CLOCK | AUX_WUC_SMPH_CLOCK); * in driver)
while(ti_lib_aux_wuc_clock_status(AUX_WUC_ADI_CLOCK | AUX_WUC_ANAIF_CLOCK | AUX_WUC_SMPH_CLOCK) != AUX_WUC_CLOCK_READY) { */
} 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. */ /* Connect AUX IO7 (DIO23, but also DP2 on XDS110) as analog input. */
ti_lib_aux_adc_select_input(ADC_COMPB_IN_AUXIO7); ti_lib_aux_adc_select_input(ADC_COMPB_IN_AUXIO7);
/* Set up ADC range */ /* Set up ADC range, AUXADC_REF_FIXED = nominally 4.3 V */
/* AUXADC_REF_FIXED = nominally 4.3 V */ ti_lib_aux_adc_enable_sync(AUXADC_REF_FIXED, AUXADC_SAMPLE_TIME_2P7_US,
ti_lib_aux_adc_enable_sync(AUXADC_REF_FIXED, AUXADC_SAMPLE_TIME_2P7_US, AUXADC_TRIGGER_MANUAL); AUXADC_TRIGGER_MANUAL);
/* Trigger ADC converting */ /* Trigger ADC converting */
ti_lib_aux_adc_gen_manual_trigger(); ti_lib_aux_adc_gen_manual_trigger();
/* reading adc value */ /* Read value */
single_adc_sample = ti_lib_aux_adc_read_fifo(); single_adc_sample = ti_lib_aux_adc_read_fifo();
/* shut the adc down */ /* Shut the adc down */
ti_lib_aux_adc_disable(); ti_lib_aux_adc_disable();
get_adc_reading(NULL); get_adc_reading(NULL);
etimer_reset(&et_adc); etimer_reset(&et_adc);
} }
PROCESS_END(); PROCESS_END();
} }
#endif #endif

View file

@ -85,7 +85,6 @@
#else #else
#define CC26XX_WEB_DEMO_ADC_DEMO 0 #define CC26XX_WEB_DEMO_ADC_DEMO 0
#endif #endif
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Active probing of RSSI from our preferred parent */ /* Active probing of RSSI from our preferred parent */
#if (CC26XX_WEB_DEMO_COAP_SERVER || CC26XX_WEB_DEMO_MQTT_CLIENT) #if (CC26XX_WEB_DEMO_COAP_SERVER || CC26XX_WEB_DEMO_MQTT_CLIENT)

View file

@ -41,13 +41,13 @@
#define CC26XX_WEB_DEMO_CONF_6LBR_CLIENT 1 #define CC26XX_WEB_DEMO_CONF_6LBR_CLIENT 1
#define CC26XX_WEB_DEMO_CONF_COAP_SERVER 1 #define CC26XX_WEB_DEMO_CONF_COAP_SERVER 1
#define CC26XX_WEB_DEMO_CONF_NET_UART 1 #define CC26XX_WEB_DEMO_CONF_NET_UART 1
/* /*
* ADC sensor functionality. To test this, an external voltage source should be * ADC sensor functionality. To test this, an external voltage source should be
* connected to DIO23 * connected to DIO23
* Enable/Disable DIO23 ADC reading by setting CC26XX_WEB_DEMO_CONF_ADC_DEMO * Enable/Disable DIO23 ADC reading by setting CC26XX_WEB_DEMO_CONF_ADC_DEMO
*/ */
#define CC26XX_WEB_DEMO_CONF_ADC_DEMO 0 #define CC26XX_WEB_DEMO_CONF_ADC_DEMO 0
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Enable the ROM bootloader */ /* Enable the ROM bootloader */
#define ROM_BOOTLOADER_ENABLE 1 #define ROM_BOOTLOADER_ENABLE 1