/* * ======== main ======== */ int main() { PIN_init(BoardGpioInitTable); //enable iCache prefetching VIMSConfigure(VIMS_BASE, TRUE, TRUE); // Enable cache VIMSModeSet(VIMS_BASE, VIMS_MODE_ENABLED); #ifndef POWER_SAVING /* Set constraints for Standby, powerdown and idle mode */ Power_setConstraint (Power_SB_DISALLOW); Power_setConstraint (Power_IDLE_PD_DISALLOW); #endif //POWER_SAVING /* Initialize ICall module */ ICall_init(); /* Start tasks of external images - Priority 5 */ ICall_createRemoteTasks(); /* Kick off profile - Priority 3 */ GAPRole_createTask(); /* Kick off application - Priority 1 */ ProximityTag_createTask(); /* enable interrupts and start SYS/BIOS */ BIOS_start(); return 0; }
/* * ======== main ======== */ int main() { /* Register Application callback to trap asserts raised in the Stack */ RegisterAssertCback(AssertHandler); PIN_init(BoardGpioInitTable); #ifndef POWER_SAVING /* Set constraints for Standby, powerdown and idle mode */ Power_setConstraint(Power_SB_DISALLOW); Power_setConstraint(Power_IDLE_PD_DISALLOW); #endif //POWER_SAVING /* Initialize ICall module */ ICall_init(); /* Start tasks of external images - Priority 5 */ ICall_createRemoteTasks(); /* Kick off profile - Priority 3 */ GAPCentralRole_createTask(); /* Kick off application - Priority 1 */ security_examples_central_createTask(); /* enable interrupts and start SYS/BIOS */ BIOS_start(); return 0; }
/* * ======== main ======== */ int main() { PIN_init(BoardGpioInitTable); #ifndef POWER_SAVING /* Set constraints for Standby, powerdown and idle mode */ Power_setConstraint(Power_SB_DISALLOW); Power_setConstraint(Power_IDLE_PD_DISALLOW); #endif // POWER_SAVING /* Initialize ICall module */ ICall_init(); /* Start tasks of external images - Priority 5 */ ICall_createRemoteTasks(); /* Kick off profile - Priority 3 */ GAPRole_createTask(); /* Kick off application - Priority 1 */ SimpleBLEBroadcaster_createTask(); BIOS_start(); /* enable interrupts and start SYS/BIOS */ return 0; }
/* * ======== Board_initPower ======== */ void Board_initPower(void) { Power_setConstraint(PowerCC3200_DISALLOW_DEEPSLEEP); Power_setConstraint(PowerCC3200_DISALLOW_LPDS); // Power_registerNotify(&slNotify, PowerCC3200_AWAKE_LPDS|PowerCC3200_AWAKE_DEEPSLEEP, (Power_NotifyFxn)simpleLinkWakupCallback, NULL); Power_init(); }
/* * ======== UARTMSP432_write ======== */ int UARTMSP432_write(UART_Handle handle, const void *buffer, size_t size) { uintptr_t key; UARTMSP432_Object *object = handle->object; UARTMSP432_HWAttrs const *hwAttrs = handle->hwAttrs; if (!size) { return 0; } key = HwiP_disable(); if (object->writeCount) { HwiP_restore(key); DebugP_log1("UART:(%p) Could not write data, uart in use.", hwAttrs->baseAddr); return (UART_ERROR); } /* Save the data to be written and restore interrupts. */ object->writeBuf = buffer; object->writeSize = size; object->writeCount = size; HwiP_restore(key); /* * Set power constraint to keep peripheral active during transfer and * to prevent a performance level change */ Power_setConstraint(PowerMSP432_DISALLOW_DEEPSLEEP_0); Power_setConstraint(PowerMSP432_DISALLOW_PERF_CHANGES); /* Enabling TX interrupt will trigger the Hwi which will handle the write */ MAP_UART_enableInterrupt(hwAttrs->baseAddr, EUSCI_A_UART_TRANSMIT_INTERRUPT); /* If writeMode is blocking, block and get the state. */ if (object->state.writeMode == UART_MODE_BLOCKING) { /* Pend on semaphore and wait for Hwi to finish. */ if (SemaphoreP_pend(object->writeSem, object->writeTimeout) != SemaphoreP_OK) { /* Semaphore timed out, make the write empty and log the write. */ MAP_UART_disableInterrupt(hwAttrs->baseAddr, EUSCI_A_UART_TRANSMIT_INTERRUPT); object->writeCount = 0; DebugP_log2("UART:(%p) Write timed out, %d bytes written", hwAttrs->baseAddr, object->writeCount); } return (object->writeSize - object->writeCount); } return (0); }
// ----------------------------------------------------------------------------- //! \brief This routine is used to set constraints on power manager //! //! \return void // ----------------------------------------------------------------------------- static void NPITL_setPM(void) { if( npiPMSetConstraint ) { return; } // set constraints for Standby and idle mode Power_setConstraint(PowerCC26XX_SB_DISALLOW); Power_setConstraint(PowerCC26XX_IDLE_PD_DISALLOW); npiPMSetConstraint = TRUE; }
/******************************************************************************* * @fn Main * * @brief Application Main * * input parameters * * @param None. * * output parameters * * @param None. * * @return None. */ int main() { #ifdef CACHE_AS_RAM // Invalidate cache VIMSModeSet( VIMS_BASE, VIMS_MODE_DISABLED ); // Wait for disabling to be complete while ( VIMSModeGet( VIMS_BASE ) != VIMS_MODE_DISABLED ); // retain cache during standby Power_setConstraint(PowerCC26XX_SB_VIMS_CACHE_RETAIN); #endif RegisterAssertCback(AssertHandler); PIN_init(BoardGpioInitTable); #ifndef POWER_SAVING /* Set constraints for Standby, powerdown and idle mode */ Power_setConstraint(PowerCC26XX_SB_DISALLOW); Power_setConstraint(PowerCC26XX_IDLE_PD_DISALLOW); #endif //POWER_SAVING #ifdef PRINTF_ENABLED // Enable System_printf(..) UART output UART_Params uartParams; UART_Params_init(&uartParams); uartParams.baudRate = 1000000; UartPrintf_init(UART_open(Board_UART, &uartParams)); System_printf("Printf enabled\r\n"); #endif /* Initialize ICall module */ ICall_init(); /* Start tasks of external images - Priority 5 */ ICall_createRemoteTasks(); /* Kick off profile - Priority 3 */ GAPRole_createTask(); Keys_createTask(); /* Kick off application - Priority 1 */ SimpleTopology_createTask(); /* enable interrupts and start SYS/BIOS */ BIOS_start(); return 0; }
/* * ======== main ======== */ int main() { PIN_init(BoardGpioInitTable); #ifndef POWER_SAVING /* Set constraints for Standby, powerdown and idle mode */ Power_setConstraint(Power_SB_DISALLOW); Power_setConstraint(Power_IDLE_PD_DISALLOW); #endif // POWER_SAVING /* Initialize ICall module */ ICall_init(); /* Start tasks of external images - Priority 5 */ ICall_createRemoteTasks(); #ifdef PRINTF_ENABLED // Enable System_printf(..) UART output UART_Params uartParams; UART_Params_init(&uartParams); uartParams.baudRate = 921600; UartPrintf_init(UART_open(Board_UART, &uartParams)); #endif /* Kick off profile - Priority 3 */ GAPRole_createTask(); SimpleBLEPeripheral_createTask(); #ifdef FEATURE_OAD { uint8_t counter; uint32_t *vectorTable = (uint32_t*) 0x20000000; #if defined(__IAR_SYSTEMS_ICC__) uint32_t *flashVectors = &__vector_table; #elif defined(__TI_COMPILER_VERSION__) uint32_t *flashVectors = &ti_sysbios_family_arm_m3_Hwi_resetVectors; #endif //Compiler. // Write image specific interrupt vectors into RAM vector table. for(counter = 0; counter < 15; ++counter) { *vectorTable++ = *flashVectors++; } } #endif //FEATURE_OAD /* enable interrupts and start SYS/BIOS */ BIOS_start(); return 0; }
/* * ======== Power_Module_startup ======== */ Int ti_sysbios_family_arm_cc26xx_Power_Module_startup(Int status) { DRIVERLIB_ASSERT_CURR_RELEASE(); /* enable cache (in case boot ROM doesn't because of HIB) */ HWREG(VIMS_BASE + VIMS_O_CTL) = ((HWREG(VIMS_BASE + VIMS_O_CTL) & ~VIMS_CTL_MODE_M ) | VIMS_CTL_MODE_CACHE ); /* force AUX on and enable OSC clock */ OSCInterfaceEnable(); /* source the HF clock from RC_OSC */ OSCHF_SwitchToRcOscTurnOffXosc(); /* when in sleep, power off JTAG */ AONWUCJtagPowerOff(); /* allow AUX to power down */ AUXWUCPowerCtrl(AUX_WUC_POWER_DOWN); /* clear PDCTL1.VIMS_MODE to power VIMS only when CPU domain is powered */ HWREG(PRCM_BASE + PRCM_O_PDCTL1VIMS) &= ~PRCM_PDCTL1VIMS_ON; /* sync with AON */ SysCtrlAonSync(); /* set standby disallow constraint pending LF clock quailifier disabling */ Power_setConstraint(Power_SB_DISALLOW); return (Startup_DONE); }
/* * ======== switchToWatchdogTimer ======== * * Use 250ms watchdog timer interrupt to drive the Clock tick * Stop the default Timer_A then start the watchdog timer. */ static void switchToWatchdogTimer() { Clock_TimerProxy_Handle clockTimer; static Hwi_Handle wdtHwi = NULL; /* Stop Timer_A currrently being used by Clock */ clockTimer = Clock_getTimerHandle(); Clock_TimerProxy_stop(clockTimer); MAP_WDT_A_holdTimer(); if (wdtHwi == NULL) { /* Create watchdog Timer Hwi */ wdtHwi = Hwi_create(19, clockTickFxn, NULL, NULL); /* set WDT to use 32KHz input, 250ms period */ MAP_WDT_A_initIntervalTimer(WDT_A_CLOCKSOURCE_XCLK, WDT_A_CLOCKITERATIONS_8192); } /* don't allow deeper than DEEPSLEEP1 */ Power_setConstraint(PowerMSP432_DISALLOW_DEEPSLEEP_1); /* Start watchdog Timer */ MAP_WDT_A_clearTimer(); MAP_WDT_A_startTimer(); /* hence, Clock_tick() will be called from 250ms watchdog timer interrupt */ }
// 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; }
/******************************************************************************* * @fn Main * * @brief Application Main * * input parameters * * @param None. * * output parameters * * @param None. * * @return None. */ int main() { /* Register Application callback to trap asserts raised in the Stack */ RegisterAssertCback(AssertHandler); PIN_init(BoardGpioInitTable); #ifdef CC1350_LAUNCHXL // Enable 2.4GHz Radio radCtrlHandle = PIN_open(&radCtrlState, radCtrlCfg); #ifdef POWER_SAVING Power_registerNotify(&rFSwitchPowerNotifyObj, PowerCC26XX_ENTERING_STANDBY | PowerCC26XX_AWAKE_STANDBY, (Power_NotifyFxn) rFSwitchNotifyCb, NULL); #endif //POWER_SAVING #endif //CC1350_LAUNCHXL // Enable iCache prefetching VIMSConfigure(VIMS_BASE, TRUE, TRUE); // Enable cache VIMSModeSet(VIMS_BASE, VIMS_MODE_ENABLED); #ifndef POWER_SAVING /* Set constraints for Standby, powerdown and idle mode */ Power_setConstraint(PowerCC26XX_SB_DISALLOW); Power_setConstraint(PowerCC26XX_IDLE_PD_DISALLOW); #endif // POWER_SAVING /* Initialize ICall module */ ICall_init(); /* Start tasks of external images */ ICall_createRemoteTasks(); /* Kick off application */ HostTestApp_createTask(); /* Kick off NPI */ NPITask_createTask(ICALL_SERVICE_CLASS_BLE); /* enable interrupts and start SYS/BIOS */ BIOS_start(); return 0; }
/******************************************************************************* * @fn Main * * @brief Application Main * * input parameters * * @param None. * * output parameters * * @param None. * * @return None. */ int main() { /* Register Application callback to trap asserts raised in the Stack */ RegisterAssertCback(AssertHandler); PIN_init(BoardGpioInitTable); #ifdef CC1350_LAUNCHXL // Enable 2.4GHz Radio radCtrlHandle = PIN_open(&radCtrlState, radCtrlCfg); #ifdef POWER_SAVING Power_registerNotify(&rFSwitchPowerNotifyObj, PowerCC26XX_ENTERING_STANDBY | PowerCC26XX_AWAKE_STANDBY, (Power_NotifyFxn) rFSwitchNotifyCb, NULL); #endif //POWER_SAVING #endif //CC1350_LAUNCHXL #ifndef POWER_SAVING /* Set constraints for Standby, powerdown and idle mode */ Power_setConstraint(PowerCC26XX_SB_DISALLOW); Power_setConstraint(PowerCC26XX_IDLE_PD_DISALLOW); #endif // POWER_SAVING /* Initialize ICall module */ ICall_init(); /* Start tasks of external images - Priority 5 */ ICall_createRemoteTasks(); /* Kick off profile - Priority 3 */ GAPCentralRole_createTask(); /* SDI UART Example Task - Priority 2 */ SDITask_createTask(); /* Kick off application - Priority 1 */ SPPBLEClient_createTask(); /* enable interrupts and start SYS/BIOS */ BIOS_start(); return 0; }
/* * ======== main ======== */ Void main() { PIN_init(BoardGpioInitTable); //enable iCache prefetching VIMSConfigure(VIMS_BASE, TRUE, TRUE); // Enable cache VIMSModeSet(VIMS_BASE, VIMS_MODE_ENABLED); #ifndef POWER_SAVING /* Set constraints for Standby, powerdown and idle mode */ Power_setConstraint(Power_SB_DISALLOW); Power_setConstraint(Power_IDLE_PD_DISALLOW); #endif // POWER_SAVING /* Initialize ICall module */ ICall_init(); /* Start tasks of external images - Priority 5 */ ICall_createRemoteTasks(); /* Kick off profile - Priority 3 */ GAPRole_createTask(); nanoARCApplication_createTask(); #ifdef FEATURE_OAD_BIM { uint8_t counter; uint32_t *vectorTable = (uint32_t*) 0x20000000; uint32_t *flashVectors = &__vector_table; // Write image specific interrupt vectors into RAM vector table. for(counter = 0; counter < 15; ++counter) { *vectorTable++ = *flashVectors++; } } #endif //FEATURE_OAD_BIM /* enable interrupts and start SYS/BIOS */ BIOS_start(); }
/* * Ensure safe setting of the standby disallow constraint. */ static inline void threadSafeConstraintSet(uint32_t txBufAddr) { unsigned int key; /* Disable interrupts */ key = Hwi_disable(); if (!spiPowerConstraint) { /* Ensure flash is available if TX buffer is in flash. Flash starts with 0x0..*/ if ((txBufAddr & 0xF0000000) == 0x0) { Power_setConstraint(Power_NEED_FLASH_IN_IDLE); } /* Set constraints to guarantee operation */ Power_setConstraint(Power_SB_DISALLOW); spiPowerConstraint = true; } /* Re-enable interrupts */ Hwi_restore(key); }
/* * ======== main ======== */ int main() { #ifdef FEATURE_OAD { uint8_t counter; uint32_t *vectorTable = (uint32_t*) 0x20000000; #if defined(__IAR_SYSTEMS_ICC__) uint32_t *flashVectors = &__vector_table; #elif defined(__TI_COMPILER_VERSION__) uint32_t *flashVectors = &ti_sysbios_family_arm_m3_Hwi_resetVectors; #endif //Compiler. // Write image specific interrupt vectors into RAM vector table. for(counter = 0; counter < 15; ++counter) { *vectorTable++ = *flashVectors++; } } #endif //FEATURE_OAD PIN_init(BoardGpioInitTable); //enable iCache prefetching VIMSConfigure(VIMS_BASE, TRUE, TRUE); // Enable cache VIMSModeSet(VIMS_BASE, VIMS_MODE_ENABLED); #ifndef POWER_SAVING /* Set constraints for Standby, powerdown and idle mode */ Power_setConstraint(Power_SB_DISALLOW); Power_setConstraint(Power_IDLE_PD_DISALLOW); #endif // POWER_SAVING AP_createTask(); /* enable interrupts and start SYS/BIOS */ BIOS_start(); return 0; }
int main() { PIN_init(BoardGpioInitTable); //Board_initGeneral(); #ifndef POWER_SAVING /* Set constraints for Standby and Idle mode */ Power_setConstraint(Power_SB_DISALLOW); Power_setConstraint(Power_IDLE_PD_DISALLOW); #endif // POWER_SAVING /* Initialize ICall module */ ICall_init(); /* Start tasks of external images - Priority 5 */ ICall_createRemoteTasks(); /* Kick off profile - Priority 3 */ GAPRole_createTask(); /* Kick off application - Priority 1 */ SensorTag_createTask(); SensorTagTmp_createTask(); SensorTagHum_createTask(); SensorTagBar_createTask(); //UART_init(); //UART_Params uartParams; //UART_Params_init(&uartParams); //uartParams.baudRate = 115200; //UartPrintf_init(UART_open(Board_UART, &uartParams)); System_printf("Hello World :)"); System_flush(); //printf("Hello World :) 2"); BIOS_start(); /* enable interrupts and start SYS/BIOS */ return 0; }
/* * ======== main ======== */ int main() { PIN_init(BoardGpioInitTable); #ifndef POWER_SAVING /* Set constraints for Standby, powerdown and idle mode */ Power_setConstraint(Power_SB_DISALLOW); Power_setConstraint(Power_IDLE_PD_DISALLOW); #endif // POWER_SAVING /* Initialize ICall module */ ICall_init(); /* Start tasks of external images - Priority 5 */ ICall_createRemoteTasks(); /* Kick off profile - Priority 3 */ GAPRole_createTask(); OadTargetApp_createTask(); #ifdef FEATURE_OAD { uint8_t counter; uint32_t *vectorTable = (uint32_t*) 0x20000000; uint32_t *flashVectors = &__vector_table; // Write image specific interrupt vectors into RAM vector table. for(counter = 0; counter < 15; ++counter) { *vectorTable++ = *flashVectors++; } } #endif //FEATURE_OAD /* enable interrupts and start SYS/BIOS */ BIOS_start(); return 0; }
int CameraCC3200DMA_capture(Camera_Handle handle, void *buffer, unsigned int bufferlen) { CameraCC3200DMA_Object *object = handle->object; CameraCC3200DMA_HWAttrs const *hwAttrs = handle->hwAttrs; uintptr_t key; key = HwiP_disable(); if (object->inUse) { HwiP_restore(key); DebugP_log1("Camera:(%p) Could not capture data, camera in use.", ((CameraCC3200DMA_HWAttrs const *) (handle->hwAttrs))->baseAddr); return (CAMERA_STATUS_UNDEFINEDCMD); } object->captureBuf = buffer; object->bufferlength = bufferlen; object->frameLength = 0; object->cameraDMAxIntrRcvd = 0; object->inUse = 1; object->cameraDMA_PingPongMode = 0; HwiP_restore(key); /* Set constraints to guarantee transaction */ Power_setConstraint(PowerCC3200_DISALLOW_DEEPSLEEP); /* Start the DMA transfer */ CameraCC3200DMA_configDMA(handle); MAP_CameraCaptureStart(hwAttrs->baseAddr); /* If operationMode is blocking, block and get the status. */ if (object->operationMode == Camera_MODE_BLOCKING) { /* Pend on semaphore and wait for Hwi to finish. */ if (SemaphoreP_pend(object->captureSem, object->captureTimeout) != SemaphoreP_OK) { DebugP_log2("Camera:(%p) Capture timed out, %d bytes captured", ((CameraCC3200DMA_HWAttrs const *) (handle->hwAttrs))->baseAddr, object->frameLength); } else { MAP_CameraCaptureStop(hwAttrs->baseAddr, true); return (object->frameLength); } } return (0); }
/* * Ensure safe setting of the standby disallow constraint. */ static inline void threadSafeStdbyDisSet() { unsigned int key; /* Disable interrupts */ key = Hwi_disable(); if (!i2cPowerConstraint) { /* Set constraints to guarantee operation */ Power_setConstraint(Power_SB_DISALLOW); i2cPowerConstraint = true; } /* Re-enable interrupts */ Hwi_restore(key); }
void bspI2cSelect(uint8_t newInterface, uint8_t address) { /* Acquire I2C resource */ Semaphore_pend(Semaphore_handle(&mutex),BIOS_WAIT_FOREVER); #ifdef POWER_SAVING if (!checkI2cConstraint) { /* Prevent the system from entering standby while using I2C. */ Power_setConstraint(Power_SB_DISALLOW); checkI2cConstraint = true; } #endif slaveAddr = address; if (newInterface != interface) { interface = newInterface; I2C_close(I2Chandle); if (interface == BSP_I2C_INTERFACE_0) { i2cCC26xxHWAttrs[CC2650_I2C0].sdaPin = Board_I2C0_SDA0; i2cCC26xxHWAttrs[CC2650_I2C0].sclPin = Board_I2C0_SCL0; // Secondary I2C as GPIO IOCPinTypeGpioInput(Board_I2C0_SDA1); IOCPinTypeGpioInput(Board_I2C0_SCL1); IOCIOPortPullSet(Board_I2C0_SDA1, IOC_NO_IOPULL); IOCIOPortPullSet(Board_I2C0_SCL1, IOC_NO_IOPULL); } else if (interface == BSP_I2C_INTERFACE_1) { i2cCC26xxHWAttrs[CC2650_I2C0].sdaPin = Board_I2C0_SDA1; i2cCC26xxHWAttrs[CC2650_I2C0].sclPin = Board_I2C0_SCL1; // Primary I2C as GPIO IOCPinTypeGpioInput(Board_I2C0_SDA0); IOCPinTypeGpioInput(Board_I2C0_SCL0); IOCIOPortPullSet(Board_I2C0_SDA0, IOC_NO_IOPULL); IOCIOPortPullSet(Board_I2C0_SCL0, IOC_NO_IOPULL); } I2Chandle = I2C_open(Board_I2C, &I2CParams); } }
/* * ======== SPICC3200DMA_transfer ======== * @pre Function assumes that handle and transaction is not NULL */ bool SPICC3200DMA_transfer(SPI_Handle handle, SPI_Transaction *transaction) { uintptr_t key; SPICC3200DMA_Object *object = handle->object; SPICC3200DMA_HWAttrs const *hwAttrs = handle->hwAttrs; /* This is a limitation by the micro DMA controller */ if ((transaction->count == 0) || (transaction->count > 1024) || !(transaction->rxBuf || transaction->txBuf) || (!(transaction->rxBuf && transaction->txBuf) && !hwAttrs->scratchBufPtr)) { return (false); } /* Check if a transfer is in progress */ key = HwiP_disable(); if (object->transaction) { HwiP_restore(key); DebugP_log1("SPI:(%p) ERROR! Transaction still in progress", ((SPICC3200DMA_HWAttrs const *)(handle->hwAttrs))->baseAddr); return (false); } else { object->transaction = transaction; HwiP_restore(key); } /* Set constraints to guarantee transaction */ Power_setConstraint(PowerCC3200_DISALLOW_DEEPSLEEP); SPICC3200DMA_configDMA(handle, transaction); MAP_SPIIntClear(hwAttrs->baseAddr, SPI_INT_DMARX | SPI_INT_DMATX | SPI_INT_EOW); MAP_SPIIntEnable(hwAttrs->baseAddr, SPI_INT_DMARX | SPI_INT_DMATX | SPI_INT_EOW); MAP_SPIEnable(hwAttrs->baseAddr); MAP_SPICSEnable(hwAttrs->baseAddr); if (object->transferMode == SPI_MODE_BLOCKING) { DebugP_log1("SPI:(%p) transfer pending on transferComplete semaphore", ((SPICC3200DMA_HWAttrs const *)(handle->hwAttrs))->baseAddr); SemaphoreP_pend(object->transferComplete, SemaphoreP_WAIT_FOREVER); } return (true); }
/* * ======== UARTMSP432_writePolling ======== */ int UARTMSP432_writePolling(UART_Handle handle, const void *buf, size_t size) { int32_t count = 0; unsigned char *buffer = (unsigned char *)buf; UARTMSP432_Object *object = handle->object; UARTMSP432_HWAttrs const *hwAttrs = handle->hwAttrs; /* Set power constraint to prevent a performance level change. */ Power_setConstraint(PowerMSP432_DISALLOW_PERF_CHANGES); /* Write characters. */ while (size) { if (object->state.writeDataMode == UART_DATA_TEXT && *buffer == '\n') { /* Wait until we can TX a byte */ while (!MAP_UART_getInterruptStatus(hwAttrs->baseAddr, EUSCI_A_UART_TRANSMIT_INTERRUPT_FLAG)); MAP_UART_transmitData(hwAttrs->baseAddr, '\r'); count++; } /* Wait until we can TX a byte */ while (!MAP_UART_getInterruptStatus(hwAttrs->baseAddr, EUSCI_A_UART_TRANSMIT_INTERRUPT_FLAG)); MAP_UART_transmitData(hwAttrs->baseAddr, *buffer); DebugP_log2("UART:(%p) Wrote character 0x%x", hwAttrs->baseAddr, *buffer); buffer++; count++; size--; } Power_releaseConstraint(PowerMSP432_DISALLOW_PERF_CHANGES); DebugP_log2("UART:(%p) Write polling finished, %d bytes written", hwAttrs->baseAddr, count); return (count); }
/* * ======== UARTMSP432_open ======== */ UART_Handle UARTMSP432_open(UART_Handle handle, UART_Params *params) { unsigned int i; uintptr_t key; uint32_t clockFreq; uint8_t numPerfLevels; int32_t baudrateIndex; union { ClockP_Params clockParams; HwiP_Params hwiParams; SemaphoreP_Params semParams; } portsParams; PowerMSP432_Freqs powerFreqs; UARTMSP432_Object *object = handle->object; UARTMSP432_HWAttrs const *hwAttrs = handle->hwAttrs; if (params == NULL) { params = (UART_Params *) &UART_defaultParams; } /* Check that a callback is set */ DebugP_assert((params->readMode != UART_MODE_CALLBACK) || (params->readCallback != NULL)); DebugP_assert((params->writeMode != UART_MODE_CALLBACK) || (params->writeCallback != NULL)); key = HwiP_disable(); if (object->state.opened) { HwiP_restore(key); DebugP_log1("UART:(%p) already in use.", hwAttrs->baseAddr); return (NULL); } object->state.opened = true; HwiP_restore(key); /* Ensure a supported clock source is used */ if (hwAttrs->clockSource != EUSCI_A_UART_CLOCKSOURCE_ACLK && hwAttrs->clockSource != EUSCI_A_UART_CLOCKSOURCE_SMCLK) { DebugP_log1("UART:(%p) Error! Using unsupported clock source.", hwAttrs->baseAddr); object->state.opened = false; return (NULL); } /* * Add power management support - Disable performance transitions while * opening the driver is open. This constraint remains active until a * UART_control() disables receive interrupts. Afterwards performance * levels can be changed by the application. A UART_control() call can * enable RX interrupts again and set the pertinent constraints. */ Power_setConstraint(PowerMSP432_DISALLOW_PERF_CHANGES); /* * Verify that the driver can be opened at current performance level and * set constraints for other performance levels. */ numPerfLevels = PowerMSP432_getNumPerfLevels(); PowerMSP432_getFreqs(Power_getPerformanceLevel(), &powerFreqs); if (hwAttrs->clockSource == EUSCI_A_UART_CLOCKSOURCE_ACLK) { /* * Verify if driver can be opened with ACLK; ACLK does not change * in any performance level. */ baudrateIndex = findBaudDividerIndex(hwAttrs->baudrateLUT, hwAttrs->numBaudrateEntries, params->baudRate, powerFreqs.ACLK); if (baudrateIndex == -1) { DebugP_log3("UART:(%p) unable to find a valid buadrate %d " "configuration at clock input clock freq %d", hwAttrs->baseAddr, params->baudRate, powerFreqs.ACLK); Power_releaseConstraint(PowerMSP432_DISALLOW_PERF_CHANGES); object->state.opened = false; return (NULL); } clockFreq = powerFreqs.ACLK; } else { /* hwAttrs->clockSource == EUSCI_A_UART_CLOCKSOURCE_SMCLK */ baudrateIndex = findBaudDividerIndex(hwAttrs->baudrateLUT, hwAttrs->numBaudrateEntries, params->baudRate, powerFreqs.SMCLK); if (baudrateIndex == -1) { DebugP_log3("UART:(%p) unable to find a valid buadrate %d " "configuration at clock input clock freq %d", hwAttrs->baseAddr, params->baudRate, powerFreqs.SMCLK); Power_releaseConstraint(PowerMSP432_DISALLOW_PERF_CHANGES); object->state.opened = false; return (NULL); } clockFreq = powerFreqs.SMCLK; /* * SMCLK changes with performance levels. Set constraints for * unsupported performance levels. */ for (i = 0; i < numPerfLevels; i++) { PowerMSP432_getFreqs(i, &powerFreqs); baudrateIndex = findBaudDividerIndex(hwAttrs->baudrateLUT, hwAttrs->numBaudrateEntries, params->baudRate, powerFreqs.SMCLK); if (baudrateIndex == -1) { /* Set constraint and keep track of it in perfConstraintMask */ object->perfConstraintMask |= (1 << i); Power_setConstraint(PowerMSP432_DISALLOW_PERFLEVEL_0 + i); } } } /* * Shutdown not supported while driver is open. The DEEPSLEEP_0 constraint * keeps stops the device from going into LPM3 or higher. This is done * to keep the UART peripheral receiving in the background and storing data * in the internal ring buff. */ Power_setConstraint(PowerMSP432_DISALLOW_DEEPSLEEP_0); Power_setConstraint(PowerMSP432_DISALLOW_SHUTDOWN_0); Power_setConstraint(PowerMSP432_DISALLOW_SHUTDOWN_1); /* Register function to reconfigure peripheral on perf level changes */ Power_registerNotify(&object->perfChangeNotify, PowerMSP432_START_CHANGE_PERF_LEVEL | PowerMSP432_DONE_CHANGE_PERF_LEVEL, perfChangeNotifyFxn, (uintptr_t) handle); /* Create the Hwi for this UART peripheral */ HwiP_Params_init(&(portsParams.hwiParams)); portsParams.hwiParams.arg = (uintptr_t) handle; portsParams.hwiParams.priority = hwAttrs->intPriority; object->hwiHandle = HwiP_create(hwAttrs->intNum, UARTMSP432_hwiIntFxn, &(portsParams.hwiParams)); if (object->hwiHandle == NULL) { DebugP_log1("UART:(%p) HwiP_create() failed", hwAttrs->baseAddr); UARTMSP432_close(handle); return (NULL); } SemaphoreP_Params_init(&(portsParams.semParams)); portsParams.semParams.mode = SemaphoreP_Mode_BINARY; if (params->writeMode == UART_MODE_BLOCKING) { /* If write mode is blocking create a semaphore and set callback. */ object->writeSem = SemaphoreP_create(0, &(portsParams.semParams)); if (object->writeSem == NULL) { DebugP_log1("UART:(%p) SemaphoreP_create() failed.", hwAttrs->baseAddr); UARTMSP432_close(handle); return (NULL); } object->writeCallback = &writeSemCallback; } else { /* UART_MODE_CALLBACK - Store application callback */ object->writeCallback = params->writeCallback; } if (params->readMode == UART_MODE_BLOCKING) { /* If read mode is blocking create a semaphore and set callback. */ object->readSem = SemaphoreP_create(0, &(portsParams.semParams)); if (object->readSem == NULL) { DebugP_log1("UART:(%p) SemaphoreP_create() failed.", hwAttrs->baseAddr); UARTMSP432_close(handle); return (NULL); } object->readCallback = &readSemCallback; ClockP_Params_init(&(portsParams.clockParams)); portsParams.clockParams.arg = (uintptr_t) handle; object->timeoutClk = ClockP_create((ClockP_Fxn) &readBlockingTimeout, &(portsParams.clockParams)); if (object->timeoutClk == NULL) { DebugP_log1("UART:(%p) ClockP_create() failed.", hwAttrs->baseAddr); UARTMSP432_close(handle); return (NULL); } } else { object->state.drainByISR = false; object->readCallback = params->readCallback; } /* * Initialize UART read buffer - will store received bytes until * UART_read is invoked. */ RingBuf_construct(&object->ringBuffer, hwAttrs->ringBufPtr, hwAttrs->ringBufSize); /* * Store UART parameters & initialize peripheral. These are used to * re/initialize the peripheral when opened or changing performance level. */ object->state.readMode = params->readMode; object->state.writeMode = params->writeMode; object->state.readReturnMode = params->readReturnMode; object->state.readDataMode = params->readDataMode; object->state.writeDataMode = params->writeDataMode; object->state.readEcho = params->readEcho; object->readTimeout = params->readTimeout; object->writeTimeout = params->writeTimeout; object->baudRate = params->baudRate; object->stopBits = params->stopBits; object->parityType = params->parityType; object->readFxns = staticFxnTable[object->state.readMode][object->state.readDataMode]; object->writeBuf = NULL; object->readBuf = NULL; object->writeCount = 0; object->readCount = 0; object->writeSize = 0; object->readSize = 0; object->state.writeCR = false; object->state.txEnabled = false; object->state.rxEnabled = true; initHw(object, hwAttrs, clockFreq); DebugP_log1("UART:(%p) opened", hwAttrs->baseAddr); /* Return the handle */ return (handle); }
/* * ======== WatchdogMSP432_open ======== */ Watchdog_Handle WatchdogMSP432_open(Watchdog_Handle handle, Watchdog_Params *params) { uintptr_t key; HwiP_Params hwiParams; WatchdogMSP432_Object *object = handle->object; WatchdogMSP432_HWAttrs const *hwAttrs = handle->hwAttrs; /* If params are NULL use defaults. */ if (params == NULL) { params = (Watchdog_Params *) &Watchdog_defaultParams; } /* Ensure a callbackFxn is specified if using watchdog in interval mode */ DebugP_assert((params->resetMode == Watchdog_RESET_ON) || (params->callbackFxn != NULL)); /* Don't allow preemption */ key = HwiP_disable(); /* Check if the Watchdog is open already with the HWAttrs */ if (object->isOpen) { HwiP_restore(key); DebugP_log1("Watchdog: Handle %x already in use.", (uintptr_t) handle); return (NULL); } object->isOpen = true; HwiP_restore(key); /* * Add power management support - Disable performance transitions while * opening the driver. */ Power_setConstraint(PowerMSP432_DISALLOW_PERF_CHANGES); if (params->resetMode == Watchdog_RESET_ON || hwAttrs->clockSource == WDT_A_CLOCKSOURCE_SMCLK || hwAttrs->clockSource == WDT_A_CLOCKSOURCE_ACLK) { /* * Do not support power modes lower than LPM0 if in watchdog mode or * in interval mode and using SMCLK or ACLK as clock sources. * Additionally, LPM3.5 cannot be reached. */ Power_setConstraint(PowerMSP432_DISALLOW_DEEPSLEEP_0); Power_setConstraint(PowerMSP432_DISALLOW_SHUTDOWN_0); } else { /* * Interval mode and not using SMCLK and ACLK as clock sources. Can * be configured as a LPM3.5 wake up source, so we do not set the * SHUTDOWN_0 constraint. */ Power_setConstraint(PowerMSP432_DISALLOW_DEEPSLEEP_1); } /* SHUTDOWN_1 (LPM4.5) not supported while driver is open */ Power_setConstraint(PowerMSP432_DISALLOW_SHUTDOWN_1); /* Construct Hwi object for watchdog */ if (params->callbackFxn) { HwiP_Params_init(&hwiParams); hwiParams.arg = (uintptr_t) handle; hwiParams.priority = hwAttrs->intPriority; object->hwiHandle = HwiP_create(hwAttrs->intNum, params->callbackFxn, &hwiParams); if (!object->hwiHandle) { DebugP_log0("Watchdog: HwiP_create() failed"); Power_releaseConstraint(PowerMSP432_DISALLOW_PERF_CHANGES); WatchdogMSP432_close(handle); return (NULL); } } /* Configure and initialize WDT */ object->resetMode = params->resetMode; if (object->resetMode == Watchdog_RESET_ON) { MAP_WDT_A_initWatchdogTimer(hwAttrs->clockSource, hwAttrs->clockDivider); } else { MAP_WDT_A_initIntervalTimer(hwAttrs->clockSource, hwAttrs->clockDivider); } MAP_WDT_A_startTimer(); /* Allow performance level changes */ Power_releaseConstraint(PowerMSP432_DISALLOW_PERF_CHANGES); DebugP_log1("Watchdog: (0x%x) opened and enabled.", (uintptr_t) handle); /* Return handle of the Watchdog object */ return (handle); }
/********************************************************************* * @fn OADTarget_imgBlockWrite * * @brief Process the Image Block Write. * * @param connHandle - connection message was received on * @param pValue - pointer to data to be written * * @return status */ bStatus_t OADTarget_imgBlockWrite(uint16_t connHandle, uint8_t *pValue) { volatile uint16_t blkNum; blkNum = BUILD_UINT16(pValue[0], pValue[1]); // First block of OAD which included image header and CRC and CRC shadow // values. Do a sanity check on the received image header if (blkNum == 0) { img_hdr_t ImgHdr; uint16_t blkTot; blkTot = BUILD_UINT16(pValue[8], pValue[9]) / (OAD_BLOCK_SIZE / HAL_FLASH_WORD_SIZE); // Read out running image's header. uint8_t *flashAddr = (uint8_t *)(APP_IMAGE_START + OAD_IMG_HDR_OSET); memcpy(&ImgHdr,flashAddr,sizeof(img_hdr_t)); // Note: if additional customer criteria was checked in the Image // Identification step, it may be important to check again here. if ((oadBlkNum != blkNum) || (oadBlkTot != blkTot) ) { // Cancel download OADTarget_rejectImage(connHandle, &ImgHdr); // NB! This is meaningless for a WriteNoResp operation return (ATT_ERR_WRITE_NOT_PERMITTED); } #ifdef POWER_SAVING Power_setConstraint(Power_SB_DISALLOW); #endif } // Check that this is the expected block number. if (oadBlkNum == blkNum && flashOk) { uint32_t addr; // Calculate address to write as (start of OAD range) + (offset) addr = APP_IMAGE_START + oadBlkNum * OAD_BLOCK_SIZE; // If address starts a new page, erase that page first. if ((addr % HAL_FLASH_PAGE_SIZE) == 0) { flashOk = extFlashErase(addr, HAL_FLASH_PAGE_SIZE); } // Write a 16 byte block to Flash. if (flashOk) { flashOk = extFlashWrite(addr, OAD_BLOCK_SIZE, pValue+2); // Increment received block count. if (flashOk) oadBlkNum++; } // Toggle Green LED for every 8th block if ( (oadBlkNum % 8) == 0) { GPIO_toggle(Board_LED2); } } else { img_hdr_t ImgHdr; // Toggle RED LED and sound buzzer when overflow GPIO_toggle(Board_LED1); GPIO_toggle(Board_BUZZER); #ifdef POWER_SAVING Power_releaseConstraint(Power_SB_DISALLOW); #endif // Cancel download ImgHdr.len = 0; // Don't care content OADTarget_rejectImage(connHandle, &ImgHdr); } // Check if the OAD Image is complete. if (oadBlkNum == oadBlkTot) { extFlashClose(); // Run CRC check on new image. if (checkDL()) { HAL_SYSTEM_RESET(); } else { GPIO_toggle(Board_LED1); } #ifdef POWER_SAVING Power_releaseConstraint(Power_SB_DISALLOW); #endif } else { // Request the next OAD Image block. OADTarget_getNextBlockReq(connHandle, oadBlkNum); } return (SUCCESS); }
/********************************************************************* * @fn SensorTagLight_processCharChangeEvt * * @brief Callback from the profile indicating a data change * * @param paramID - parameter ID of the value that was changed. * * @return none */ void SensorTagLight_processCharChangeEvt(uint8_t paramID) { uint8_t newVal; switch (paramID) { case LIGHTSPROFILE_RED: Lights_getParameter(LIGHTSPROFILE_RED, &newVal); lvalRed = newVal; break; case LIGHTSPROFILE_GREEN: Lights_getParameter(LIGHTSPROFILE_GREEN, &newVal); lvalGreen = newVal; break; case LIGHTSPROFILE_BLUE: Lights_getParameter(LIGHTSPROFILE_BLUE, &newVal); lvalBlue = newVal; break; case LIGHTSPROFILE_WHITE: Lights_getParameter(LIGHTSPROFILE_WHITE, &newVal); lvalWhite = newVal; break; case LIGHTSPROFILE_RGBW: { uint8_t rgbwVal[LIGHTSPROFILE_RGBW_LEN]; Lights_getParameter(LIGHTSPROFILE_RGBW, &rgbwVal); lvalRed = rgbwVal[0]; lvalGreen = rgbwVal[1]; lvalBlue = rgbwVal[2]; lvalWhite = rgbwVal[3]; } break; default: // should not reach here! break; } // Apply the new values devpkSetLight(Board_DEVPK_LIGHT_RED, lvalRed); devpkSetLight(Board_DEVPK_LIGHT_GREEN, lvalGreen); devpkSetLight(Board_DEVPK_LIGHT_BLUE, lvalBlue); devpkSetLight(Board_DEVPK_LIGHT_WHITE, lvalWhite); #ifdef POWER_SAVING // Make sure the power domains are on if any light is active if (lvalRed>0 || lvalGreen>0 || lvalBlue>0 || lvalWhite>0) { /* Set constraints for Standby and Idle mode */ Power_setConstraint(PowerCC26XX_SB_DISALLOW); Power_setConstraint(PowerCC26XX_IDLE_PD_DISALLOW); } else { /* Release constraints for Standby and Idle mode */ Power_releaseConstraint(PowerCC26XX_SB_DISALLOW); Power_releaseConstraint(PowerCC26XX_IDLE_PD_DISALLOW); } #endif // POWER_SAVING }
/* * ======== main ======== */ Void main() { PIN_init(BoardGpioInitTable); //enable iCache prefetching VIMSConfigure(VIMS_BASE, TRUE, TRUE); // Enable cache VIMSModeSet(VIMS_BASE, VIMS_MODE_ENABLED); #ifndef POWER_SAVING /* Set constraints for Standby, powerdown and idle mode */ Power_setConstraint(Power_SB_DISALLOW); Power_setConstraint(Power_IDLE_PD_DISALLOW); #endif // POWER_SAVING //Initialize task Task_Params params; Task_Params_init(¶ms); params.priority = TASK_PRI; params.stackSize = TASK_STACK_SIZE; params.stack = taskStack; //semaphore init Semaphore_Params sParams; Semaphore_Params_init(&sParams); sParams.mode = Semaphore_Mode_BINARY; /* Initialize ICall module */ ICall_init(); /* Start tasks of external images - Priority 5 */ ICall_createRemoteTasks(); /* Kick off profile - Priority 3 */ GAPRole_createTask(); SimpleBLEPeripheral_createTask(); //Contruct task Task_construct(&taskStruct, taskFxn, ¶ms, NULL); // Construct semaphore used for pending in task ADC Semaphore_construct(&sem, 0, &sParams); hSem = Semaphore_handle(&sem); #ifdef FEATURE_OAD_BIM { uint8_t counter; uint32_t *vectorTable = (uint32_t*) 0x20000000; uint32_t *flashVectors = &__vector_table; // Write image specific interrupt vectors into RAM vector table. for(counter = 0; counter < 15; ++counter) { *vectorTable++ = *flashVectors++; } } #endif //FEATURE_OAD_BIM /* enable interrupts and start SYS/BIOS */ BIOS_start(); }
/* * ======== PWMTimerMSP432_open ======== * @pre Function assumes that the handle is not NULL */ PWM_Handle PWMTimerMSP432_open(PWM_Handle handle, PWM_Params *params) { uintptr_t key; bool timerIsRunning; uint8_t cyclesPerMicroSec; uint32_t clockFreq; uint32_t tempPeriod; Timer_A_PWMConfig pwmConfig; PowerMSP432_Freqs powerFreqs; PWMTimerMSP432_Object *object = handle->object; PWMTimerMSP432_HWAttrs const *hwAttrs = handle->hwAttrs; if(params == NULL) { params = (PWM_Params *) &PWM_defaultParams; } key = HwiP_disable(); /* * Before opening the PWM instance, we must verify that the Timer is not * already open or being used by another source (possibly the Kernel). * Additionally, the Timer peripheral could have already been initialized * by another PWM instance, so we must verify if any other PWM driver * (on the same Timer) is initialized. */ timerIsRunning = (TIMER_A_CMSIS(hwAttrs->baseAddr)->rCTL.b.bMC != TIMER_A_STOP_MODE); if (object->isOpen || (timerIsRunning && (object->pwmTimerStatus)->activeOutputsMask == 0)) { /* Timer already opened or used by source other than PWM driver */ HwiP_restore(key); DebugP_log1("PWM:(%p) timer used by another source.", (uintptr_t) handle); return (NULL); } /* * Timer capture/compare register 0 is used as the period. It cannot be * used to generate PWM output. */ DebugP_assert(hwAttrs->compareRegister != TIMER_A_CAPTURECOMPARE_REGISTER_0); /* * Add power management support - PWM driver does not allow performance * level changes, low power modes or shutdown while open. */ Power_setConstraint(PowerMSP432_DISALLOW_PERF_CHANGES); Power_setConstraint(PowerMSP432_DISALLOW_DEEPSLEEP_0); Power_setConstraint(PowerMSP432_DISALLOW_SHUTDOWN_0); Power_setConstraint(PowerMSP432_DISALLOW_SHUTDOWN_1); PowerMSP432_getFreqs(Power_getPerformanceLevel(), &powerFreqs); clockFreq = powerFreqs.SMCLK; cyclesPerMicroSec = clockFreq / 1000000; /* Assert if period is too large for peripheral */ tempPeriod = params->period * cyclesPerMicroSec; DebugP_assert(tempPeriod <= maxPrescalarValue * maxDutyValue); /* * Verify if timer has been initialized by another PWM instance. If so, * make sure PWM periods are the same, do not open driver if otherwise. */ if ((object->pwmTimerStatus)->period && (object->pwmTimerStatus)->period != params->period) { HwiP_restore(key); DebugP_log1("PWM:(%p) differing PWM periods, cannot open driver.", (uintptr_t) handle); PWMTimerMSP432_close(handle); return (NULL); } else { /* PWM timer has not been initialized */ (object->pwmTimerStatus)->cyclesPerMicroSec = cyclesPerMicroSec; (object->pwmTimerStatus)->prescalar = PWMTimerMSP432_calculatePrescalar(tempPeriod); (object->pwmTimerStatus)->period = params->period; } /* Mark driver as being used */ object->isOpen = true; (object->pwmTimerStatus)->activeOutputsMask |= object->pwmCompareOutputBit; HwiP_restore(key); /* Store PWM instance parameters */ object->dutyMode = params->dutyMode; /* Configure PWM output & start timer */ pwmConfig.clockSource = TIMER_A_CLOCKSOURCE_SMCLK; pwmConfig.clockSourceDivider = (object->pwmTimerStatus)->prescalar; pwmConfig.timerPeriod = tempPeriod / (object->pwmTimerStatus)->prescalar; pwmConfig.compareRegister = hwAttrs->compareRegister; pwmConfig.compareOutputMode = outputPolarity[params->polarity]; pwmConfig.dutyCycle = 0; MAP_Timer_A_generatePWM(hwAttrs->baseAddr, &pwmConfig); MAP_Timer_A_startCounter(hwAttrs->baseAddr, TIMER_A_UP_MODE); DebugP_log2("PWM:(%p) opened; period set to: %d", (uintptr_t) handle, params->period); return (handle); }
//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); */ }