// auxIo, see MUX3 Register (Offset = 3h) [reset = X] // auxIo, sensor controller engine IO, will map to M3's IO automatilcally // for DIO23, auxIO7, the value should be 80h, 0x80 uint16_t OneShotADC(uint8_t auxIo) { static __root uint16_t retval = 0xABBA; // Enable clock for ADC digital and analog interface (not currently enabled in driver) AUXWUCClockEnable(AUX_WUC_MODCLKEN0_ANAIF_M|AUX_WUC_MODCLKEN0_AUX_ADI4_M); // Connect AUX IO7 (DIO23) as analog input. Light sensor on SmartRF06EB AUXADCSelectInput(auxIo); // Set up ADC AUXADCEnableSync(AUXADC_REF_FIXED, AUXADC_SAMPLE_TIME_2P7_US, AUXADC_TRIGGER_MANUAL); // Disallow STANDBY mode while using the ADC. Power_setConstraint(Power_SB_DISALLOW); // Trigger ADC sampling AUXADCGenManualTrigger(); retval = AUXADCReadFifo(); // Disable ADC AUXADCDisable(); // Allow STANDBY mode again Power_releaseConstraint(Power_SB_DISALLOW); return retval; }
//***************************************************************************** // // Enable System CPU access to the OSC_DIG module // //***************************************************************************** void OSCInterfaceEnable(void) { // // Force power on AUX to ensure CPU has access // AONWUCAuxWakeupEvent(AONWUC_AUX_WAKEUP); while(!(AONWUCPowerStatusGet() & AONWUC_AUX_POWER_ON)) { } // // Enable the AUX domain OSC clock and wait for it to be ready // AUXWUCClockEnable(AUX_WUC_OSCCTRL_CLOCK); while(AUXWUCClockStatus(AUX_WUC_OSCCTRL_CLOCK) != AUX_WUC_CLOCK_READY) { } }
/* * ======== SENSORTAG_CC2650_initGeneral ======== */ Void SENSORTAG_CC2650_initGeneral(Void) { /* force power on AUX - this will be released when entering sleep mode */ AONWUCAuxWakeupEvent(AONWUC_AUX_WAKEUP); /* enable the AUX oscillator clock */ AUXWUCClockEnable(AUX_WUC_OSCCTRL_CLOCK); while(AUXWUCClockStatus(AUX_WUC_OSCCTRL_CLOCK) != AUX_WUC_CLOCK_READY) { } /* This application will not be using the AUX domain out of boot * and we will leave out clock for optimal power conservation */ AONWUCAuxPowerDownConfig(AONWUC_NO_CLOCK); /* * Source the LF clock from the low frequency XTAL_OSC. * HF and MF are sourced from the high frequency RC_OSC. */ OSCClockSourceSet(OSC_SRC_CLK_LF, OSC_XOSC_LF); OSCClockSourceSet(OSC_SRC_CLK_MF | OSC_SRC_CLK_HF, OSC_RCOSC_HF); /* * Check if already sourcing the HF clock from RC_OSC. * If a switch of the clock source is not required, then the call to ROM * will loop forever. */ if(OSCClockSourceGet(OSC_SRC_CLK_HF) != OSC_RCOSC_HF) { OSCHfSourceSwitch(); } /* enable DCDC */ PowerCtrlSourceSet(PWRCTRL_PWRSRC_DCDC); /* make sure AON accesses are in sync and enable powerdown on AUX */ SysCtrlAonSync(); AUXWUCPowerCtrl(AUX_WUC_POWER_DOWN); }
//taskFxn void taskFxn(UArg a0, UArg a1) { Hwi_Params hwiParams; Hwi_Params_init(&hwiParams); hwiParams.enableInt = true; Hwi_construct(&hwi, INT_AUX_ADC, adcIsr, &hwiParams, NULL); UART_Params uParams; // Initialize default values UART_Params_init(&uParams); // Configure custom data, don't care about read params as not used // 115.2kBaud, Text, blocking mode uHandle = UART_open(Board_UART,&uParams); // Set up pins pinHandle = PIN_open(&pinState, alsPins); // Enable clock for ADC digital and analog interface (not currently enabled in driver) AUXWUCClockEnable(AUX_WUC_MODCLKEN0_SOC_M|AUX_WUC_MODCLKEN0_AUX_ADI4_M); // Connect AUX IO7 (DIO23) as analog input. Light sensor on SmartRF06EB AUXADCSelectInput(ADC_COMPB_IN_AUXIO7); // Set up ADC AUXADCEnableSync(AUXADC_REF_FIXED, AUXADC_SAMPLE_TIME_2P7_US, AUXADC_TRIGGER_MANUAL); // Disallow STANDBY mode while using the ADC. Power_setConstraint(Power_SB_DISALLOW); while(1) { //Sleep 100ms in IDLE mode //Task_sleep(100 * 1000 / Clock_tickPeriod); // Trigger ADC sampling AUXADCGenManualTrigger(); // Wait in IDLE until done Semaphore_pend(hSem, BIOS_WAIT_FOREVER ); //System_printf("ADC: %d\r\n", singleSample); //printf ("ADC: %d\r\n"); //printf ("ADC\r\n"); } /* // Disable ADC AUXADCDisable(); // Allow STANDBY mode again Power_releaseConstraint(Power_SB_DISALLOW); // Restore pins to values in BoardGpioTable PIN_close(pinHandle); // Log data through UART UART_write(uHandle, &adcSamples[1], SAMPLESIZE); // Goto STANDBY forever Task_sleep(BIOS_WAIT_FOREVER); */ }