这篇教程C++ CMU_ClockEnable函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中CMU_ClockEnable函数的典型用法代码示例。如果您正苦于以下问题:C++ CMU_ClockEnable函数的具体用法?C++ CMU_ClockEnable怎么用?C++ CMU_ClockEnable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了CMU_ClockEnable函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: DVK_spiControl/**************************************************************************//** * @brief Configure SPI for correct peripheral * * @param[in] device * Device to enable SPI bus for *****************************************************************************/void DVK_spiControl(DVK_SpiControl_TypeDef device){ switch (device) { case DVK_SPI_Audio: DVK_writeRegister(&BC_REGISTER->SPI_DEMUX, BC_SPI_DEMUX_SLAVE_AUDIO); break; case DVK_SPI_Ethernet: DVK_writeRegister(&BC_REGISTER->SPI_DEMUX, BC_SPI_DEMUX_SLAVE_ETHERNET); break; case DVK_SPI_Display: DVK_writeRegister(&BC_REGISTER->SPI_DEMUX, BC_SPI_DEMUX_SLAVE_DISPLAY); break; case DVK_SPI_OFF: USART_Reset(USART1); CMU_ClockEnable(cmuClock_USART1, false); break; }}
开发者ID:ketrum,项目名称:equine-health-monitor-gdp12,代码行数:28,
示例2: TD_TIMER_Start/***************************************************************************//** * @brief * Start the TIMER1 to generate a 50% duty cycle output. * * @param[in] frequency * The output frequency in Hz. ******************************************************************************/void TD_TIMER_Start(uint32_t frequency){ uint32_t top; top = CMU_ClockFreqGet(cmuClock_TIMER1); top = top / frequency; // Enable clock for TIMER1 module CMU_ClockEnable(cmuClock_TIMER1, true); // Configure CC channel 0 TIMER_InitCC(TIMER1, 0, &timerCCInit); // Route CC0 to location 0 (PC13) and enable pin //TIMER1->ROUTE |= (TIMER_ROUTE_CC0PEN | TIMER_ROUTE_LOCATION_LOC0); // Set Top Value TIMER_TopSet(TIMER1, top); // Set compare value starting at 0 - it will be incremented in the interrupt handler TIMER_CompareBufSet(TIMER1, 0, top >> 1); // Configure timer TIMER_Init(TIMER1, &timerInit); // Enable overflow interrupt TIMER_IntEnable(TIMER1, TIMER_IF_OF); // Disable interrupts //TIMER_IntDisable(TIMER1, TIMER_IF_OF); // Enable TIMER1 interrupt vector in NVIC NVIC_EnableIRQ(TIMER1_IRQn); // Enable timer TIMER_Enable(TIMER1, true); TD_TIMER_Enabled = true;}
开发者ID:jeromegros,项目名称:TD1208,代码行数:45,
示例3: uartSetup/******************************************************************************* @brief uartSetup function*******************************************************************************/void uartSetup(void){ /* Enable clock for GPIO module (required for pin configuration) */ CMU_ClockEnable(cmuClock_GPIO, true); /* Configure GPIO pins */ GPIO_PinModeSet(gpioPortB, 9, gpioModePushPull, 1); GPIO_PinModeSet(gpioPortB, 10, gpioModeInput, 0); /* Prepare struct for initializing UART in asynchronous mode*/ uartInit.enable = usartDisable; /* Don't enable UART upon intialization */ uartInit.refFreq = 0; /* Provide information on reference frequency. When set to 0, the reference frequency is */ uartInit.baudrate = 115200; /* Baud rate */ uartInit.oversampling = usartOVS16; /* Oversampling. Range is 4x, 6x, 8x or 16x */ uartInit.databits = usartDatabits8; /* Number of data bits. Range is 4 to 10 */ uartInit.parity = usartNoParity; /* Parity mode */ uartInit.stopbits = usartStopbits1; /* Number of stop bits. Range is 0 to 2 */ uartInit.mvdis = false; /* Disable majority voting */ uartInit.prsRxEnable = false; /* Enable USART Rx via Peripheral Reflex System */ uartInit.prsRxCh = usartPrsRxCh0; /* Select PRS channel if enabled */ /* Initialize USART with uartInit struct */ USART_InitAsync(uart, &uartInit); /* Prepare UART Rx and Tx interrupts */ USART_IntClear(uart, _UART_IF_MASK); USART_IntEnable(uart, UART_IF_RXDATAV); NVIC_ClearPendingIRQ(UART1_RX_IRQn); NVIC_ClearPendingIRQ(UART1_TX_IRQn); NVIC_EnableIRQ(UART1_RX_IRQn); NVIC_EnableIRQ(UART1_TX_IRQn); /* Enable I/O pins at UART1 location #2 */ uart->ROUTE = UART_ROUTE_RXPEN | UART_ROUTE_TXPEN | UART_ROUTE_LOCATION_LOC2; /* Enable UART */ USART_Enable(uart, usartEnable);}
开发者ID:jiaxinguo,项目名称:School-Work,代码行数:42,
示例4: gpioSetupvoid gpioSetup(){ /* Enable GPIO in CMU */ CMU_ClockEnable(cmuClock_GPIO, true); /* Configure PC0 as Output */ GPIO_PinModeSet(gpioPortC, 0, gpioModePushPull, 0); /* Configure PD0 as input */ GPIO_PinModeSet(gpioPortB, 9, gpioModeInput, 0); /* Set rising edge interrupt for both ports */ GPIO_IntConfig(gpioPortB, 9, true, false, true); motor_gpioSetup(); //set up the output pins for the step motor /* Enable interrupt in core for even and odd gpio interrupts */ NVIC_ClearPendingIRQ(GPIO_EVEN_IRQn); NVIC_EnableIRQ(GPIO_EVEN_IRQn); /* Set PC0 to 0 */ GPIO_PinOutSet(gpioPortC, 0);}
开发者ID:kairobert,项目名称:forget-me-not,代码行数:23,
示例5: initTimer/**************************************************************************//** * @brief Initialize TIMER0 in Up Count mode and to give interrupt on overflow *****************************************************************************/void initTimer(){ TIMER_Init_TypeDef initValues = TIMER_INIT_DEFAULT; /* Enable clock for TIMER0 */ CMU_ClockEnable(cmuClock_TIMER0, true); /* Enable overflow interrupt for TIMER0*/ TIMER_IntEnable(TIMER0, TIMER_IF_OF); /* Enable TIMER0 interrupt vector in NVIC */ NVIC_EnableIRQ(TIMER0_IRQn); /* Set TIMER0 Top value */ TIMER_TopSet(TIMER0, TOP); /* Initialize TIMER0 in with 1024x prescaling */ initValues.prescale = timerPrescale1024; TIMER_Init(TIMER0, &initValues); /* Start TIMER0 */ TIMER0->CMD = TIMER_CMD_START;}
开发者ID:AndreMiras,项目名称:EFM32-Library,代码行数:26,
示例6: i2c_setupvoid i2c_setup(){ CMU_ClockEnable(cmuClock_I2C0, true); I2C_Init_TypeDef init = I2C_INIT_DEFAULT; init.enable = 1; init.master = 1; init.freq = I2C_FREQ_STANDARD_MAX; init.clhr = i2cClockHLRStandard; I2C_Init(I2C0, &init); // The rest of this is cut-and-pasted from chapter 10's InitDevice.c file /* Module I2C0 is configured to location 1 */ I2C0->ROUTE = (I2C0->ROUTE & ~_I2C_ROUTE_LOCATION_MASK) | I2C_ROUTE_LOCATION_LOC1; /* Enable signals SCL, SDA */ I2C0->ROUTE |= I2C_ROUTE_SCLPEN | I2C_ROUTE_SDAPEN; /* Module PCNT0 is configured to location 1 */ PCNT0->ROUTE = (PCNT0->ROUTE & ~_PCNT_ROUTE_LOCATION_MASK) | PCNT_ROUTE_LOCATION_LOC1; /* Module USART1 is configured to location 1 */ USART1->ROUTE = (USART1->ROUTE & ~_USART_ROUTE_LOCATION_MASK) | USART_ROUTE_LOCATION_LOC1; /* Enable signals RX, TX */ USART1->ROUTE |= USART_ROUTE_RXPEN | USART_ROUTE_TXPEN; // [Route Configuration]$ /* Pin PD6 is configured to Open-drain with pull-up and filter */ GPIO->P[3].MODEL = (GPIO->P[3].MODEL & ~_GPIO_P_MODEL_MODE6_MASK) | GPIO_P_MODEL_MODE6_WIREDANDPULLUPFILTER; /* Pin PD7 is configured to Open-drain with pull-up and filter */ GPIO->P[3].MODEL = (GPIO->P[3].MODEL & ~_GPIO_P_MODEL_MODE7_MASK) | GPIO_P_MODEL_MODE7_WIREDANDPULLUPFILTER; // [Port D Configuration]$}
开发者ID:Rajusr70,项目名称:makersguide,代码行数:37,
示例7: gpioSetup/**************************************************************************//** * @brief Setup GPIO interrupt to set the time *****************************************************************************/void gpioSetup(void){ /* Configure PD8 as input */ //GPIO_PinModeSet(gpioPortD, 8, gpioModeInput, 0); /* Set falling edge interrupt */ //GPIO_IntConfig(gpioPortD, 8, false, true, true); //NVIC_ClearPendingIRQ(GPIO_EVEN_IRQn); //NVIC_EnableIRQ(GPIO_EVEN_IRQn); /* Configure PB11 as input */ //GPIO_PinModeSet(gpioPortB, 11, gpioModeInput, 0); /* Set falling edge interrupt */ //GPIO_IntConfig(gpioPortB, 11, false, true, true); //NVIC_ClearPendingIRQ(GPIO_ODD_IRQn); //NVIC_EnableIRQ(GPIO_ODD_IRQn); /* Enable GPIO in CMU */ CMU_ClockEnable(cmuClock_GPIO, true); /* Configure PD8 and PB11 as input */ GPIO_PinModeSet(gpioPortD, 8, gpioModeInput, 0); GPIO_PinModeSet(gpioPortB, 11, gpioModeInput, 0); /* Set falling edge interrupt for both ports */ GPIO_IntConfig(gpioPortD, 8, false, true, true); GPIO_IntConfig(gpioPortB, 11, false, true, true); /* Enable interrupt in core for even and odd gpio interrupts */ NVIC_ClearPendingIRQ(GPIO_EVEN_IRQn); NVIC_EnableIRQ(GPIO_EVEN_IRQn); NVIC_ClearPendingIRQ(GPIO_ODD_IRQn); NVIC_EnableIRQ(GPIO_ODD_IRQn);}
开发者ID:geirivtu,项目名称:brewHelper,代码行数:40,
示例8: TOUCH_Init/***************************************************************************//** * @brief * Initialize touch panel driver * * @param config * Driver configuration data. ******************************************************************************/void TOUCH_Init(TOUCH_Config_TypeDef *config){ ADC_Init_TypeDef init = ADC_INIT_DEFAULT;#ifndef TOUCH_WITHOUT_STORE touch_LoadCalibration();#endif CMU_ClockEnable(cmuClock_ADC0, true); ADC_IntDisable(ADC0, _ADC_IF_MASK); init.prescale = ADC_PrescaleCalc(config->frequency, 0); touch_ignore_move = config->ignore; init.ovsRateSel = config->oversampling; ADC_Init(ADC0, &init); BSP_PeripheralAccess(BSP_TOUCH, true); sInit.input = ADC_Y; sInit.reference = adcRefVDD; sInit.resolution = adcResOVS; ADC_InitSingle(ADC0, &sInit); ADC_IntClear(ADC0, _ADC_IF_MASK); touch_state = TOUCH_INIT; NVIC_ClearPendingIRQ(ADC0_IRQn); NVIC_EnableIRQ(ADC0_IRQn); ADC_IntEnable(ADC0, ADC_IF_SINGLE); ADC_Start(ADC0, adcStartSingle);}
开发者ID:Blone,项目名称:my-project-hihack,代码行数:31,
示例9: mainint main(void){ CHIP_Init(); /*Turn on the DAC clock.*/ CMU_ClockEnable(cmuClock_DAC0, true); /*configure and enable the DAC.*/ DAC_setup(); DAC_Enable(DAC0, 0, true); /*Write data to registers. V1 = 1.0*/ DAC0->CH0DATA = (uint32_t)((1.0 * 4096) / 3.3); /*configure OPA0, OPA1 and OPA2.*/ OPAMP_Init_TypeDef configuration0 = OPA_INIT_DIFF_RECEIVER_OPA0 ; OPAMP_Init_TypeDef configuration2 = OPA_INIT_DIFF_RECEIVER_OPA2 ; /*Redefine the resistances. Want to divide the difference by 3.*/ configuration2.resSel = opaResSelDefault; configuration0.resSel = opaResSelR2eq3R1; /*OPA2 positive input = VSS*/ configuration2.resInMux = opaResInMuxVss; /*Enable OPA0 and OPA2. All the configurations are set.*/ OPAMP_Enable(DAC0, OPA0, &configuration0); OPAMP_Enable(DAC0, OPA2, &configuration2); /*Disable OPA0. This is done because we want to use OPA0 as a part of the DAC. The configurations set above are still there.*/ DAC0->OPACTRL &= ~DAC_OPACTRL_OPA0EN; /*Never end.*/ while(1); }
开发者ID:AndreMiras,项目名称:EFM32-Library,代码行数:36,
示例10: us_ticker_initvoid us_ticker_init(void){ if (us_ticker_inited) { /* calling init again should cancel current interrupt */ us_ticker_disable_interrupt(); return; } us_ticker_inited = true; /* Enable clock for TIMERs */ CMU_ClockEnable(US_TICKER_TIMER_CLOCK, true); if (REFERENCE_FREQUENCY > 24000000) { US_TICKER_TIMER->CTRL = (US_TICKER_TIMER->CTRL & ~_TIMER_CTRL_PRESC_MASK) | (4 << _TIMER_CTRL_PRESC_SHIFT); } else { US_TICKER_TIMER->CTRL = (US_TICKER_TIMER->CTRL & ~_TIMER_CTRL_PRESC_MASK) | (3 << _TIMER_CTRL_PRESC_SHIFT); } /* Clear TIMER counter value */ TIMER_CounterSet(US_TICKER_TIMER, 0); /* Start TIMER */ TIMER_Enable(US_TICKER_TIMER, true); /* Select Compare Channel parameters */ TIMER_InitCC_TypeDef timerCCInit = TIMER_INITCC_DEFAULT; timerCCInit.mode = timerCCModeCompare; /* Configure Compare Channel 0 */ TIMER_InitCC(US_TICKER_TIMER, 0, &timerCCInit); /* Enable interrupt vector in NVIC */ TIMER_IntClear(US_TICKER_TIMER, TIMER_IEN_CC0); NVIC_SetVector(US_TICKER_TIMER_IRQ, (uint32_t) us_ticker_irq_handler); NVIC_EnableIRQ(US_TICKER_TIMER_IRQ);}
开发者ID:sg-,项目名称:mbed-os,代码行数:36,
示例11: vPortSetupTimerInterrupt/**************************************************************************//** * @brief vPortSetupTimerInterrupt * Override the default definition of vPortSetupTimerInterrupt() that is weakly * defined in the FreeRTOS Cortex-M3, which set source of system tick interrupt *****************************************************************************/void vPortSetupTimerInterrupt(void){ /* Set our timer's data used as system ticks*/ ulTimerReloadValueForOneTick = SYSTICK_LOAD_VALUE;#if (configUSE_TICKLESS_IDLE == 1) xMaximumPossibleSuppressedTicks = TIMER_CAPACITY / (SYSTICK_LOAD_VALUE); ulStoppedTimerCompensation = TIMER_COMPENSATION / (configCPU_CLOCK_HZ / configSYSTICK_CLOCK_HZ);#endif /* (configUSE_TICKLESS_IDLE == 1) */ /* Ensure LE modules are accessible */ CMU_ClockEnable(cmuClock_CORELE, true); /* Enable access to BURTC registers */ RMU_ResetControl(rmuResetBU, false); /* Configure BURTC as system tick source */ BURTC_Init_TypeDef burtcInit = BURTC_INIT_DEFAULT; burtcInit.mode = burtcModeEM3; /* BURTC is enabled to EM3 */ burtcInit.clkSel = burtcClkSelULFRCO; /* Select ULFRCO as clock source */ burtcInit.clkDiv = burtcClkDiv_1; /* Choose 2kHz ULFRCO clock frequency */ /* Initialization of BURTC */ BURTC_Init(&burtcInit); /* Disable interrupt generation from BURTC */ BURTC_IntDisable(BURTC_IF_COMP0); /* Tick interrupt MUST execute at the lowest interrupt priority. */ NVIC_SetPriority(BURTC_IRQn, 255); /* Enable interrupts */ NVIC_ClearPendingIRQ(BURTC_IRQn); NVIC_EnableIRQ(BURTC_IRQn); BURTC_CompareSet(0, SYSTICK_LOAD_VALUE); BURTC_IntClear(BURTC_IF_COMP0); BURTC_IntEnable(BURTC_IF_COMP0); BURTC_CounterReset();}
开发者ID:AndreMiras,项目名称:EFM32-Library,代码行数:41,
示例12: setupCmu/**************************************************************************//** * @brief Enabling clocks *****************************************************************************/void setupCmu(void){ /* Enabling clocks */ CMU_ClockEnable(cmuClock_DMA, true); }
开发者ID:AndreMiras,项目名称:EFM32-Library,代码行数:8,
示例13: main/**************************************************************************//** * @brief Main function * The example data is first encrypted and encrypted data is checked. * The encrypted data is then decrypted and checked against original data. * Program ends at last while loop if all is OK. *****************************************************************************/int main(void){ uint32_t i; /* Chip errata */ CHIP_Init(); /* Initialize error indicator */ bool error = false; /* Enable AES clock */ CMU_ClockEnable(cmuClock_AES, true); /* Copy plaintext to dataBuffer */ for (i=0; i<(sizeof(exampleData) / sizeof(exampleData[0])); i++) { dataBuffer[i] = exampleData[i]; } /* Encrypt data in AES-128 OFB */ AesOfb128(exampleKey, dataBuffer, dataBuffer, sizeof(dataBuffer) / (sizeof(dataBuffer[0]) * 16), initVector); /* Wait for AES to finish */ while (!AesFinished()); /* Check whether encrypted results are correct */ for (i = 0; i < (sizeof(dataBuffer) / sizeof(dataBuffer[0])); i++) { if (dataBuffer[i] != expectedEncryptedData[i]) { error = true; } } /* Decrypt data in AES-128 OFB. Note that this is the same operation as encrypt */ AesOfb128(exampleKey, dataBuffer, dataBuffer, sizeof(dataBuffer) / (sizeof(dataBuffer[0]) * 16), initVector); /* Wait for AES to finish */ while (!AesFinished()); /* Check whether decrypted result is identical to the plaintext */ for (i = 0; i < (sizeof(dataBuffer) / sizeof(dataBuffer[0])); i++) { if (dataBuffer[i] != exampleData[i]) { error = true; } } /* Check for success */ if (error) { while (1) ; /* Ends here if there has been an error */ } else { while (1) ; /* Ends here if all OK */ }}
开发者ID:AndreMiras,项目名称:EFM32-Library,代码行数:73,
示例14: TIMER_setup/**************************************************************************//** * @brief TIMER0_setup * Configures the TIMER *****************************************************************************/void TIMER_setup(void){ /* Enable necessary clocks */ CMU_ClockEnable(cmuClock_TIMER0, true); CMU_ClockEnable(cmuClock_PRS, true); /* Select CC channel parameters */ TIMER_InitCC_TypeDef timerCCInit = { .eventCtrl = timerEventEveryEdge, /* Input capture event control */ .edge = timerEdgeBoth, /* Input capture on falling edge */ .prsSel = timerPRSSELCh5, /* Prs channel select channel 5*/ .cufoa = timerOutputActionNone, /* No action on counter underflow */ .cofoa = timerOutputActionNone, /* No action on counter overflow */ .cmoa = timerOutputActionNone, /* No action on counter match */ .mode = timerCCModeCapture, /* CC channel mode capture */ .filter = false, /* No filter */ .prsInput = true, /* CC channel PRS input */ .coist = false, /* Comparator output initial state */ .outInvert = false, /* No output invert */ }; /* Initialize TIMER0 CC0 channel */ TIMER_InitCC(HIJACK_RX_TIMER, 0, &timerCCInit); /* Select timer parameters */ const TIMER_Init_TypeDef timerInit = { .enable = false, /* Do not start counting when init complete */ .debugRun = false, /* Counter not running on debug halt */ .prescale = HIJACK_TIMER_RESOLUTION, /* Prescaler of 1 */ .clkSel = timerClkSelHFPerClk, /* TIMER0 clocked by the HFPERCLK */ .fallAction = timerInputActionReloadStart, /* Stop counter on falling edge */ .riseAction = timerInputActionReloadStart, /* Reload and start on rising edge */ .mode = timerModeUp, /* Counting up */ .dmaClrAct = false, /* No DMA */ .quadModeX4 = false, /* No quad decoding */ .oneShot = false, /* Counting up constinuously */ .sync = false, /* No start/stop/reload by other timers */ }; /* Initialize TIMER0 */ TIMER_Init(HIJACK_RX_TIMER, &timerInit); /* PRS setup */ /* Select ACMP as source and ACMP0OUT (ACMP0 OUTPUT) as signal */ PRS_SourceSignalSet(5, PRS_CH_CTRL_SOURCESEL_ACMP0, PRS_CH_CTRL_SIGSEL_ACMP0OUT, prsEdgeOff); /* Enable CC0 interrupt */ TIMER_IntEnable(HIJACK_RX_TIMER, TIMER_IF_CC0); /* Enable TIMER0 interrupt vector in NVIC */ NVIC_EnableIRQ(TIMER0_IRQn);}/**************************************************************************//** * @brief ACMP_setup * Configures and starts the ACMP *****************************************************************************/static void ACMP_setup(void){ /* Enable necessary clocks */ CMU_ClockEnable(HIJACK_RX_ACMPCLK, true); CMU_ClockEnable(cmuClock_GPIO, true); /* Configure ACMP input pin. */ GPIO_PinModeSet(HIJACK_RX_GPIO_PORT, HIJACK_RX_GPIO_PIN, gpioModeInput, 0); /* Analog comparator parameters */ const ACMP_Init_TypeDef acmpInit = { .fullBias = false, /* No full bias current*/ .halfBias = true, /* No half bias current */ .biasProg = 2, /* Biasprog current 1.4 uA */ .interruptOnFallingEdge = false, /* Disable interrupt for falling edge */ .interruptOnRisingEdge = false, /* Disable interrupt for rising edge */ .warmTime = acmpWarmTime256, /* Warm-up time in clock cycles, should be >140 cycles for >10us warm-up @ 14MHz */ .hysteresisLevel = acmpHysteresisLevel7, /* Hysteresis level 0 - no hysteresis */ .inactiveValue = 1, /* Inactive comparator output value */ .lowPowerReferenceEnabled = false, /* Low power reference mode disabled */ .vddLevel = HIJACK_RX_ACMP_LEVEL, /* Vdd reference scaling of 32 */ }; /* Use ACMP0 output, PD6 . */ //GPIO_PinModeSet(gpioPortD, 6, gpioModePushPull, 0); //ACMP_GPIOSetup(ACMP0, 2, true, false); /* Init ACMP and set ACMP channel 4 as positive input and scaled Vdd as negative input */ ACMP_Init(HIJACK_RX_ACMP, &acmpInit); ACMP_ChannelSet(HIJACK_RX_ACMP, HIJACK_RX_ACMP_NEG, HIJACK_RX_ACMP_CH); ACMP_Enable(HIJACK_RX_ACMP);}/** * @brief calculate whether cnt is in 500us region//.........这里部分代码省略.........
开发者ID:Blone,项目名称:my-project-hihack,代码行数:101,
示例15: mainint main(void){ CHIP_Init(); CMU_ClockEnable(cmuClock_GPIO, true); CMU_ClockEnable(cmuClock_TIMER1, true); CMU_ClockEnable(cmuClock_TIMER3, true); // Set up TIMER1 for timekeeping TIMER_Init_TypeDef timerInit = TIMER_INIT_DEFAULT; timerInit.prescale = timerPrescale1024; TIMER_IntEnable(TIMER1, TIMER_IF_OF); // Enable TIMER1 interrupt vector in NVIC NVIC_EnableIRQ(TIMER1_IRQn); // Set TIMER Top value TIMER_TopSet(TIMER1, ONE_SECOND_TIMER_COUNT); TIMER_Init(TIMER1, &timerInit); // Wait for the timer to get going while (TIMER1->CNT == 0) ; // Enable LED output GPIO_PinModeSet(LED_PORT, LED_PIN, gpioModePushPull, 0); // Create the object initializer for LED PWM TIMER_InitCC_TypeDef timerCCInit = TIMER_INITCC_DEFAULT; timerCCInit.mode = timerCCModePWM; timerCCInit.cmoa = timerOutputActionToggle; // Configure TIMER3 CC channel 2 TIMER_InitCC(TIMER3, TIMER_CHANNEL, &timerCCInit); // Route CC2 to location 1 (PE3) and enable pin for cc2 TIMER3->ROUTE |= (TIMER_ROUTE_CC2PEN | TIMER_ROUTE_LOCATION_LOC1); // Set Top Value TIMER_TopSet(TIMER3, TIMER_TOP); // Set the PWM duty cycle here! TIMER_CompareBufSet(TIMER3, TIMER_CHANNEL, 0); // Create a timerInit object, based on the API default TIMER_Init_TypeDef timerInit2 = TIMER_INIT_DEFAULT; timerInit2.prescale = timerPrescale256; TIMER_Init(TIMER3, &timerInit2); enum mode_values { RAMPING_UP, HIGH, RAMPING_DOWN, LOW}; // Check for properly sized constants uint16_t delta = MAX_BRIGHTNESS - MIN_BRIGHTNESS; if ( delta == 0 || RAMP_UP_TIME_MS % delta || RAMP_DOWN_TIME_MS % delta) { DEBUG_BREAK } // Set the initial condition uint16_t mode = RAMPING_UP; uint32_t time_step = RAMP_UP_TIME_MS / delta; uint16_t brightness = MIN_BRIGHTNESS; TIMER_CompareBufSet(TIMER3, TIMER_CHANNEL, brightness); uint64_t mode_timeout = set_ms_timeout(RAMP_UP_TIME_MS); while (1) { switch (mode) { case RAMPING_UP: delay_ms(time_step); brightness++; TIMER_CompareBufSet(TIMER3, TIMER_CHANNEL, brightness); if (expired_ms(mode_timeout)) { mode = HIGH; mode_timeout = set_ms_timeout(HIGH_DURATION_MS); } break; case HIGH: if (expired_ms(mode_timeout)) { mode = RAMPING_DOWN; time_step = RAMP_DOWN_TIME_MS / delta; mode_timeout = set_ms_timeout(RAMP_DOWN_TIME_MS); } break; case RAMPING_DOWN: delay_ms(time_step); brightness--; TIMER_CompareBufSet(TIMER3, TIMER_CHANNEL, brightness); if (expired_ms(mode_timeout)) { mode = LOW; mode_timeout = set_ms_timeout(LOW_DURATION_MS); } break;//.........这里部分代码省略.........
开发者ID:Rajusr70,项目名称:makersguide,代码行数:101,
示例16: i2c_poweronvoid i2c_poweron(i2c_t dev){ CMU_ClockEnable(i2c_config[dev].cmu, true);}
开发者ID:chrysn-pull-requests,项目名称:EFM2Riot,代码行数:4,
示例17: i2c_poweroffvoid i2c_poweroff(i2c_t dev){ CMU_ClockEnable(i2c_config[dev].cmu, false);}
开发者ID:chrysn-pull-requests,项目名称:EFM2Riot,代码行数:4,
示例18: initPWMvoid initPWM() // Brightness should be less than TIMER_TOP (1024){ /* Enable clocks */ CMU->HFPERCLKEN0 |= CMU_HFPERCLKEN0_GPIO; CMU_ClockEnable(cmuClock_TIMER1, true); /* Set pins */ GPIO_PinModeSet(gpioPortE,10,gpioModePushPull,1); GPIO_PinModeSet(gpioPortE,11,gpioModePushPull,1); /* Select CC channel parameters */ TIMER_InitCC_TypeDef timerCCInit = { .eventCtrl = timerEventEveryEdge, .edge = timerEdgeBoth, .prsSel = timerPRSSELCh0, .cufoa = timerOutputActionNone, .cofoa = timerOutputActionNone, .cmoa = timerOutputActionToggle, .mode = timerCCModePWM, .filter = false, .prsInput = false, .coist = false, .outInvert = false, }; /* Configure CC channels */ TIMER_InitCC(TIMER1, 0, &timerCCInit); TIMER_InitCC(TIMER1, 1, &timerCCInit); /* Set which pins will be set by the timer */ TIMER1->ROUTE = TIMER_ROUTE_CC0PEN | TIMER_ROUTE_CC1PEN | TIMER_ROUTE_LOCATION_LOC1; /* Set Top Value */ TIMER_TopSet(TIMER1, TIMER_TOP); /* Set compare value starting at top - it will be incremented in the interrupt handler */ TIMER_CompareBufSet(TIMER1, 0, TIMER_TOP + 1); TIMER_CompareBufSet(TIMER1, 1, TIMER_TOP + 1); /* Select timer parameters */ TIMER_Init_TypeDef timerInit = { .enable = true, .debugRun = false, .prescale = timerPrescale16, .clkSel = timerClkSelHFPerClk, .fallAction = timerInputActionNone, .riseAction = timerInputActionNone, .mode = timerModeUp, .dmaClrAct = false, .quadModeX4 = false, .oneShot = false, .sync = false, }; /* Enable overflow interrupt */ TIMER_IntEnable(TIMER1, TIMER_IF_OF); TIMER_IntClear(TIMER1, TIMER_IF_OF); /* Enable TIMER1 interrupt vector in NVIC */ NVIC_EnableIRQ(TIMER1_IRQn); /* Configure timer */ TIMER_Init(TIMER1, &timerInit);}
开发者ID:wiktor-b,项目名称:slip-b,代码行数:68,
示例19: InitAudioPWMvoid InitAudioPWM(void){ CMU_ClockEnable(cmuClock_TIMER1, true); /* Select CC channel parameters */ TIMER_InitCC_TypeDef timerCCInit = { .eventCtrl = timerEventEveryEdge, .edge = timerEdgeBoth, .prsSel = timerPRSSELCh0, .cufoa = timerOutputActionNone, .cofoa = timerOutputActionNone, .cmoa = timerOutputActionToggle, .mode = timerCCModePWM, .filter = false, .prsInput = false, .coist = false, .outInvert = false, }; /* Configure CC channel 0 */ TIMER_InitCC(TIMER1, 0, &timerCCInit); TIMER_InitCC(TIMER1, 1, &timerCCInit); //TIMER_InitCC(TIMER0, 2, &timerCCInit);// TIMER3->ROUTE |= (TIMER_ROUTE_CC0PEN | TIMER_ROUTE_CC1PEN | TIMER_ROUTE_CC2PEN | TIMER_ROUTE_LOCATION_LOC0); TIMER1->ROUTE = TIMER_ROUTE_CC0PEN | TIMER_ROUTE_CC1PEN | TIMER_ROUTE_LOCATION_LOC1; /* Set Top Value */ TIMER_TopSet(TIMER1, 255);//384 /* Set compare value starting at top - it will be incremented in the interrupt handler */ TIMER_CompareBufSet(TIMER1, 0, 256);//385 TIMER_CompareBufSet(TIMER1, 1, 256);//385 //TIMER_CompareBufSet(TIMER3, 2, RGB_PWM_TIMER_TOP + 1); /* Select timer parameters */ TIMER_Init_TypeDef timerInit = { .enable = true, .debugRun = false, .prescale = timerPrescale8, .clkSel = timerClkSelHFPerClk, .fallAction = timerInputActionNone, .riseAction = timerInputActionNone, .mode = timerModeUp, .dmaClrAct = false, .quadModeX4 = false, .oneShot = false, .sync = false, }; ///* Enable overflow interrupt */ TIMER_IntEnable(TIMER1, TIMER_IF_OF); TIMER_IntClear(TIMER1, TIMER_IF_OF); /* Enable TIMER0 interrupt vector in NVIC */ NVIC_EnableIRQ(TIMER1_IRQn); /* Configure timer */ TIMER_Init(TIMER1, &timerInit);}void TIMER1_IRQHandler(void){ int audio_Sample = 0; if(toPlay > 0) { audio_Sample = buff[(iterator = next(iterator))]; toPlay--; } else { audio_Sample = 0; } TIMER_CompareBufSet(TIMER1, 0, (audio_Sample)); TIMER_IntClear(TIMER1, TIMER_IF_OF);}
开发者ID:SLIP-Group-C-2012,项目名称:SLIP-Group-C-2012,代码行数:82,
示例20: main/**************************************************************************//** * @brief main - the entrypoint after reset. *****************************************************************************/int main(void){ /* Initialize LEUSB state variables */ leusbTogglePushed = false; leusbEnabled = false; refreshDisplay = false; HIDKBD_Init_t hidInitStruct; /* Chip errata */ CHIP_Init(); /* Go slow to reduce current consumption. */ CMU_HFRCOBandSet( cmuHFRCOBand_7MHz ); CMU_ClockEnable( cmuClock_GPIO, true ); GPIO_PinModeSet( BUTTON0_PORT, BUTTON0_PIN, gpioModeInputPull, 1 ); GPIO_PinModeSet( BUTTON1_PORT, BUTTON1_PIN, gpioModeInputPull, 1 ); /* Initialize the display module. */ DISPLAY_Init(); /* Retrieve the properties of the display. */ if ( DISPLAY_DeviceGet( 0, &displayDevice ) != DISPLAY_EMSTATUS_OK ) { /* Unable to get display handle. */ while( 1 ); } memset( (void*)blank_image, 0xFF, 128*16 ); displayDevice.pPixelMatrixDraw( &displayDevice, (void*)blank_image, /* start column, width */ 0, displayDevice.geometry.width, /* start row, height */ 0, displayDevice.geometry.height); scrollLcd( &displayDevice, scrollLeft, blank_image, gecko_image ); /* Initialize HID keyboard driver. */ hidInitStruct.hidDescriptor = (void*)USBDESC_HidDescriptor; hidInitStruct.setReportFunc = NULL; HIDKBD_Init( &hidInitStruct ); /* Initialize and start USB device stack. */ USBD_Init( &usbInitStruct ); /* Turn off the Low Energy Mode (LEM) features that were enabled in USBD_Init() */ USB->CTRL &= ~USB_CTRL_LEMIDLEEN; // LEUSB off to begin demo /* * When using a debugger it is practical to uncomment the following three * lines to force host to re-enumerate the device. */ /* USBD_Disconnect(); */ /* USBTIMER_DelayMs(1000); */ /* USBD_Connect(); */ for (;;) { if (refreshDisplay) { refreshDisplay = false; /* Clear the "refresh display" flag */ if (leusbEnabled) { /* Update the LCD image to reflect USB Low Energy Mode enabled */ displayDevice.pPixelMatrixDraw( &displayDevice, (void*)leusb_image, /* start column, width */ 0, displayDevice.geometry.width, /* start row, height */ 0, displayDevice.geometry.height); } else { /* Update the LCD image to reflect normal USB HID keyboard demo status */ displayDevice.pPixelMatrixDraw( &displayDevice, (void*)usb_image, /* start column, width */ 0, displayDevice.geometry.width, /* start row, height */ 0, displayDevice.geometry.height); } } /* Conserve energy ! */ EMU_EnterEM1(); }}
开发者ID:uSasha,项目名称:gecko_reporter,代码行数:87,
示例21: MICROSD_PowerOn/**************************************************************************//** * @brief Turn on micro SD card power. * DK doesn't support socket power control, only enable the SPI clock. *****************************************************************************/void MICROSD_PowerOn(void){ /* Enable SPI clock */ CMU_ClockEnable(MICROSD_CMUCLOCK, true);}
开发者ID:JamesH001,项目名称:SX1231,代码行数:9,
示例22: mainint main(void){ /** Number of samples/channels taken from accelerometer. */ #define ACCEL_SAMPLES 3 /** X axis sample index. */ #define ACCEL_X 0 /** Y axis sample index. */ #define ACCEL_Y 1 /** Z axis sample index. */ #define ACCEL_Z 2 /* * Tilt levels: Midpoint is theoretically half value of max sampling value * (ie 0x800 for 12 bit sampling). In real world, some sort of calibration * is required if more accurate sensing is required. We just use set some * fixed limit, that should be sufficient for this basic example. */ /** Tilt left limit */ #define TILT_LEFT 0x750 /** Tilt right limit */ #define TILT_RIGHT 0x8b0 SYSTEM_ChipRevision_TypeDef chipRev; uint32_t leds; uint32_t samples[ACCEL_SAMPLES]; int errataShift = 0; int i; /* Chip revision alignment and errata fixes */ CHIP_Init(); /* ADC errata for rev B when using VDD as reference, need to multiply */ /* result by 2 */ SYSTEM_ChipRevisionGet(&chipRev); if ((chipRev.major == 1) && (chipRev.minor == 1)) { errataShift = 1; } /* Initialize DK board register access */ BSP_Init(BSP_INIT_DEFAULT); /* If first word of user data page is non-zero, enable eA Profiler trace */ BSP_TraceProfilerSetup(); /* Connect accelerometer to EFM32. */ BSP_PeripheralAccess(BSP_ACCEL, true); /* Enable clocks required */ CMU_ClockEnable(cmuClock_HFPER, true); CMU_ClockEnable(cmuClock_ADC0, true); CMU_ClockEnable(cmuClock_DMA, true); /* Configure ADC and DMA used for scanning accelerometer */ accelADCConfig(); accelDMAConfig(); /* Main loop, keep polling accelerometer */ leds = 0x0180; while (1) { DMA_ActivateBasic(ACCEL_DMA_CHANNEL, true, false, samples, (void *)((uint32_t)&(ADC0->SCANDATA)), ACCEL_SAMPLES - 1); /* Scan all axis', even though this app only use the X axis */ ADC_IntClear(ADC0, ADC_IF_SCAN); ADC_Start(ADC0, adcStartScan); /* Poll for completion, entering EM2 when waiting for next poll */ while (!(ADC_IntGet(ADC0) & ADC_IF_SCAN)) { RTCDRV_Trigger(5, NULL); EMU_EnterEM2(true); } if (errataShift) { for (i = 0; i < ACCEL_SAMPLES; i++) { samples[i] <<= errataShift; } } if (samples[ACCEL_X] < TILT_LEFT) { if (leds < 0xc000) { leds <<= 1; } } else if (samples[ACCEL_X] > TILT_RIGHT) { if (leds > 0x0003) {//.........这里部分代码省略.........
开发者ID:havardh,项目名称:bitless,代码行数:101,
示例23: initController/*! * @brief short basic initialization to enable generic controller functions * @note user initialization can vary here */void initController(void){ /* Enable required clock domains */ CMU_ClockEnable(cmuClock_HFPER, true); /* TODO : user initialization here */}
开发者ID:EnergyMicro,项目名称:EFM32_Gxxx_DK,代码行数:10,
示例24: CMU_enter_DefaultMode_from_RESET//================================================================================// CMU_enter_DefaultMode_from_RESET//================================================================================extern void CMU_enter_DefaultMode_from_RESET(void) { // $[LFXO enable] CMU_OscillatorEnable(cmuOsc_LFXO, true, true); // [LFXO enable]$ // $[HFXO enable] CMU_OscillatorEnable(cmuOsc_HFXO, true, true); // [HFXO enable]$ // $[LFACLK Setup] /* Select LFXO as clock source for LFACLK */ CMU_ClockSelectSet(cmuClock_LFA, cmuSelect_LFXO); //LFA采用外部低频晶振 // [LFACLK Setup]$ // $[High Frequency Clock select] /* Using HFXO as high frequency clock, HFCLK */ CMU_ClockSelectSet(cmuClock_HF, cmuSelect_HFXO);//HF采用外部高频晶振 /* Enable peripheral clock */ CMU_ClockEnable(cmuClock_HFPER, true); // [High Frequency Clock select]$ // $[LF clock tree setup] /* Enable LF clocks */ CMU_ClockEnable(cmuClock_CORELE, true); CMU_ClockSelectSet(cmuClock_LFA, cmuSelect_LFXO); CMU_ClockSelectSet(cmuClock_LFB, cmuSelect_LFXO); // [LF clock tree setup]$ // $[Peripheral Clock enables] /* Enable clock for ADC0 */ CMU_ClockEnable(cmuClock_ADC0, true); /* Enable clock for DMA */ CMU_ClockEnable(cmuClock_DMA, true); /* Enable clock for I2C0 */ CMU_ClockEnable(cmuClock_I2C0, true); /* Enable clock for LETIMER0 */ CMU_ClockEnable(cmuClock_LETIMER0, true); /* Enable clock for LEUART0 */ CMU_ClockEnable(cmuClock_LEUART0, true); /* Enable clock for RTC */ CMU_ClockEnable(cmuClock_RTC, true); /* Enable clock for TIMER0 */ CMU_ClockEnable(cmuClock_TIMER0, true); /* Enable clock for TIMER1 */ CMU_ClockEnable(cmuClock_TIMER1, true); /* Enable clock for TIMER2 */ CMU_ClockEnable(cmuClock_TIMER2, true); /* Enable clock for UART0 */ CMU_ClockEnable(cmuClock_UART0, true); /* Enable clock for USART0 */ CMU_ClockEnable(cmuClock_USART0, true); /* Enable clock for USART2 */ CMU_ClockEnable(cmuClock_USART2, true); /* Enable clock for GPIO by default */ CMU_ClockEnable(cmuClock_GPIO, true); // [Peripheral Clock enables]$}
开发者ID:jieqiuwuzhe,项目名称:Collector_v1.0,代码行数:78,
示例25: ACMP_setup/**************************************************************************//** * @brief ACMP_setup * Configures and starts the ACMP *****************************************************************************/void ACMP_setup(void){ /* Enable necessary clocks */ CMU_ClockEnable(cmuClock_ACMP0, true); CMU_ClockEnable(cmuClock_GPIO, true); /* Configure PC4 as input with pull down for ACMP channel 4 input */ GPIO_PinModeSet(gpioPortC, 4, gpioModeInputPullFilter, 0); /* Analog comparator parameters */ const ACMP_Init_TypeDef acmpInit = { .fullBias = false, /* no full bias current*/ .halfBias = false, /* no half bias current */ .biasProg = 7, /* Biasprog current 1.4 uA */ .interruptOnFallingEdge = false, /* disable interrupt for falling edge */ .interruptOnRisingEdge = false, /* disable interrupt for rising edge */ .warmTime = acmpWarmTime256, /* Warm-up time in clock cycles, should be >140 cycles for >10us warm-up @ 14MHz */ .hysteresisLevel = acmpHysteresisLevel0, /* Hysteresis level 0 - no hysteresis */ .inactiveValue = 0, /* Inactive comparator output value */ .lowPowerReferenceEnabled = false, /* Low power reference mode disabled */ .vddLevel = 32, /* Vdd reference scaling of 32 */ }; /* Init ACMP and set ACMP channel 4 as positive input and scaled Vdd as negative input */ ACMP_Init(ACMP0, &acmpInit); ACMP_ChannelSet(ACMP0, acmpChannelVDD, acmpChannel4); ACMP_Enable(ACMP0);}/**************************************************************************//** * @brief PRS_ScanChannel * Waits for activity on a selected PRS channel and writes on the LCD when activity occurs * * @param[in] timer * Pointer to TIMER peripheral register block. * * @param[in] prsCh * PRS Channel to be monitored * * @param[in] edgeType * Signal edge to be monitored/captured *****************************************************************************/void PRS_ScanChannel(TIMER_TypeDef *timer, TIMER_PRSSEL_TypeDef prsCh, TIMER_Edge_TypeDef edgeType){ /* enable the clock for the correct timer */ #define TIMER_Clock(T) (T==TIMER0 ? cmuClock_TIMER0 : / T==TIMER1 ? cmuClock_TIMER1 : 0) /* Enable necessary clocks */ CMU_ClockEnable((CMU_Clock_TypeDef)TIMER_Clock(timer), true); /* Initialize LCD */ SegmentLCD_Init(false); /* Select CC channel parameters */ const TIMER_InitCC_TypeDef timerCCInit = { .eventCtrl = timerEventFalling, /* input capture event control */ .edge = edgeType, /* input capture on falling edge */ .prsSel = prsCh, /* prs channel select channel 5*/ .cufoa = timerOutputActionNone, /* no action on counter underflow */ .cofoa = timerOutputActionNone, /* no action on counter overflow */ .cmoa = timerOutputActionNone, /* no action on counter match */ .mode = timerCCModeCapture, /* CC channel mode capture */ .filter = false, /* no filter */ .prsInput = true, /* CC channel PRS input */ .coist = false, /* comparator output initial state */ .outInvert = false, /* no output invert */ }; /* Initialize TIMER0 CC0 */ TIMER_InitCC(timer, 0, &timerCCInit); /* Select timer parameters */ const TIMER_Init_TypeDef timerInit = { .enable = true, /* start counting when init complete */ .debugRun = false, /* counter not running on debug halt */ .prescale = timerPrescale1024, /* prescaler of 64 */ .clkSel = timerClkSelHFPerClk, /* TIMER0 clocked by the HFPERCLK */ .fallAction = timerInputActionNone, /* stop counter on falling edge */ .riseAction = timerInputActionNone, /* reload and start on rising edge */ .mode = timerModeUp, /* counting up */ .dmaClrAct = false, /* no DMA */ .quadModeX4 = false, /* no quad decoding */ .oneShot = false, /* counting up constinuously */ .sync = false, /* no start/stop/reload by other timers */ }; /* Initialize TIMER0 */ TIMER_Init(timer, &timerInit); //.........这里部分代码省略.........
开发者ID:AndreMiras,项目名称:EFM32-Library,代码行数:101,
示例26: main/**************************************************************************//** * @brief Main function *****************************************************************************/int main(void){ /* Chip errata */ CHIP_Init(); /* Use 32MHZ HFXO as core clock frequency*/ CMU_ClockSelectSet(cmuClock_HF, cmuSelect_HFXO); /* Enable clock for HF peripherals */ CMU_ClockEnable(cmuClock_HFPER, true); /* Enabling clock to USART0*/ CMU_ClockEnable(cmuClock_USART0, true); /* Enable clock for GPIO module (required for pin configuration) */ CMU_ClockEnable(cmuClock_GPIO, true); /* If first word of user data page is non-zero, enable eA Profiler trace */ BSP_TraceProfilerSetup(); /* Setup SysTick Timer for 1 msec interrupts */ if (SysTick_Config(CMU_ClockFreqGet(cmuClock_CORE) / 1000)) while (1) ; /* Enable LCD without voltage boost */ SegmentLCD_Init(false); /* Enable all segments */ SegmentLCD_AllOff(); SegmentLCD_Write("GPS!"); Delay(2000); SegmentLCD_AllOff(); /* Initialization of GPS */ GPS_Initialization(); SegmentLCD_Write("SD!"); Delay(2000); SegmentLCD_AllOff(); /* Initialization of SDCARD */ SDCARD_Initialization(); SegmentLCD_AllOff(); SegmentLCD_Write("DONE!"); Delay(2000); SegmentLCD_AllOff(); /* Infinite loop with test pattern. */ while (1) { /* Wait for data in sleep mode */ GPS_WaitForData(&gpsData); /* Save it on SDCARD */ SDCARD_Save(&gpsData); /* Indicate on LCD */ LCD_Show(); }}
开发者ID:Crob4,项目名称:HackaGecko,代码行数:65,
示例27: main/**************************************************************************//** * @brief Main function *****************************************************************************/int main(void){ SYSTEM_ChipRevision_TypeDef revision; char string[8]; int i; uint32_t temp; /* Chip revision alignment and errata fixes */ CHIP_Init(); /* Initialize DVK board register access */ BSP_Init(BSP_INIT_DEFAULT); /* If first word of user data page is non-zero, enable eA Profiler trace */ BSP_TraceProfilerSetup(); CMU_ClockEnable(cmuClock_HFPER, true); CMU_ClockEnable(cmuClock_ADC0, true); CMU_ClockEnable(cmuClock_GPIO, true); /* Initialize LCD controller without boost */ SegmentLCD_Init(false); SegmentLCD_AllOff(); /* Check for revision after revision B. Chips with revision earlier than */ /* Revision C has known problems with the internal temperature sensor. */ /* Display a warning in this case */ SYSTEM_ChipRevisionGet(&revision); if (revision.minor < 2) { SegmentLCD_Write("WARNING"); RTCDRV_Trigger(2000, NULL); EMU_EnterEM2(true); SegmentLCD_Write("REV C+"); RTCDRV_Trigger(2000, NULL); EMU_EnterEM2(true); SegmentLCD_Write("REQUIRD"); RTCDRV_Trigger(2000, NULL); EMU_EnterEM2(true); } /* Enable board control interrupts */ BSP_InterruptDisable(0xffff); BSP_InterruptFlagsClear(0xffff); BSP_InterruptEnable(BC_INTEN_JOYSTICK); temperatureIRQInit(); /* Setup ADC for sampling internal temperature sensor. */ setupSensor(); /* Main loop - just read temperature and update LCD */ while (1) { /* Start one ADC sample */ ADC_Start(ADC0, adcStartSingle); /* Wait in EM1 for ADC to complete */ EMU_EnterEM1(); /* Read sensor value */ temp = ADC_DataSingleGet(ADC0); /* Convert ADC sample to Fahrenheit / Celsius and print string to display */ if (showFahrenheit) { /* Show Fahrenheit on alphanumeric part of display */ i = (int)(convertToFahrenheit(temp) * 10); snprintf(string, 8, "%2d,%1d%%F", (i/10), i%10); /* Show Celsius on numeric part of display */ i = (int)(convertToCelsius(temp) * 10); SegmentLCD_Number(i*10); SegmentLCD_Symbol(LCD_SYMBOL_DP10, 1); } else { /* Show Celsius on alphanumeric part of display */ i = (int)(convertToCelsius(temp) * 10); snprintf(string, 8, "%2d,%1d%%C", (i/10), i%10); /* Show Fahrenheit on numeric part of display */ i = (int)(convertToFahrenheit(temp) * 10); SegmentLCD_Number(i*10); SegmentLCD_Symbol(LCD_SYMBOL_DP10, 1); } SegmentLCD_Write(string); /* Sleep for 2 seconds in EM 2 */ RTCDRV_Trigger(2000, NULL); EMU_EnterEM2(true); }}
开发者ID:havardh,项目名称:bitless,代码行数:94,
示例28: main/**************************************************************************//** * @brief Main function *****************************************************************************/int main(void){ uint8_t prod_rev; uint32_t temp; uint32_t temp_offset; float temperature; /* Initialize DK board register access */ BSP_Init(BSP_INIT_DEFAULT); /* If first word of user data page is non-zero, enable eA Profiler trace */ BSP_TraceProfilerSetup(); /* Initialize the TFT stdio retarget module. */ RETARGET_TftInit(); printf("/nEFM32 onchip temperature sensor example/n/n"); CMU_ClockEnable(cmuClock_HFPER, true); CMU_ClockEnable(cmuClock_ADC0, true); CMU_ClockEnable(cmuClock_GPIO, true); /* Enable board control interrupts */ BSP_InterruptDisable(0xffff); BSP_InterruptFlagsClear(0xffff); BSP_InterruptEnable(BC_INTEN_JOYSTICK); temperatureIRQInit(); /* This is a work around for Chip Rev.D Errata, Revision 0.6. */ /* Check for product revision 16 and 17 and set the offset */ /* for ADC0_TEMP_0_READ_1V25. */ prod_rev = (DEVINFO->PART & _DEVINFO_PART_PROD_REV_MASK) >> _DEVINFO_PART_PROD_REV_SHIFT; if( (prod_rev == 16) || (prod_rev == 17) ) { temp_offset = 112; } else { temp_offset = 0; } /* Setup ADC for sampling internal temperature sensor. */ setupSensor(); /* Main loop - just read temperature and update LCD */ while (1) { /* Start one ADC sample */ ADC_Start(ADC0, adcStartSingle); /* Wait in EM1 for ADC to complete */ EMU_EnterEM1(); /* Read sensor value */ /* According to rev. D errata ADC0_TEMP_0_READ_1V25 should be decreased */ /* by the offset but it is the same if ADC reading is increased - */ /* reference manual 28.3.4.2. */ temp = ADC_DataSingleGet(ADC0) + temp_offset; /* Convert ADC sample to Fahrenheit / Celsius and print string to display */ if (showFahrenheit) { temperature = convertToFahrenheit(temp); } else { temperature = convertToCelsius(temp); } printf("%d.%d %c/n", (int) temperature, (int)(10*(temperature-(int)temperature)), showFahrenheit? 'F' : 'C'); /* Sleep for 2 seconds in EM 2 */ RTCDRV_Trigger(2000, NULL); EMU_EnterEM2(true); }}
开发者ID:AndreMiras,项目名称:EFM32-Library,代码行数:81,
示例29: I2CSPM_Init/***************************************************************************//** * @brief * Initalize I2C peripheral * * @details * This driver supports master mode only, single bus-master. In addition * to configuring the I2C peripheral module, it also configures DK/STK * specific setup in order to use the I2C bus. * * @param[in] init * Pointer to I2C initialization structure ******************************************************************************/void I2CSPM_Init(I2CSPM_Init_TypeDef *init){ int i; CMU_Clock_TypeDef i2cClock; I2C_Init_TypeDef i2cInit; EFM_ASSERT(init != NULL); CMU_ClockEnable(cmuClock_HFPER, true); /* Select I2C peripheral clock */ if (false) {#if defined( I2C0 ) } else if (init->port == I2C0) { i2cClock = cmuClock_I2C0;#endif#if defined( I2C1 ) } else if (init->port == I2C1) { i2cClock = cmuClock_I2C1;#endif } else { /* I2C clock is not defined */ EFM_ASSERT(false); return; } CMU_ClockEnable(i2cClock, true); /* Output value must be set to 1 to not drive lines low. Set SCL first, to ensure it is high before changing SDA. */ GPIO_PinModeSet(init->sclPort, init->sclPin, gpioModeWiredAndPullUp, 1); GPIO_PinModeSet(init->sdaPort, init->sdaPin, gpioModeWiredAndPullUp, 1); /* In some situations, after a reset during an I2C transfer, the slave device may be left in an unknown state. Send 9 clock pulses to set slave in a defined state. */ for (i = 0; i < 9; i++) { GPIO_PinOutSet(init->sclPort, init->sclPin); GPIO_PinOutClear(init->sclPort, init->sclPin); } /* Enable pins and set location */#if defined (_I2C_ROUTEPEN_MASK) init->port->ROUTEPEN = I2C_ROUTEPEN_SDAPEN | I2C_ROUTEPEN_SCLPEN; init->port->ROUTELOC0 = (init->portLocationSda << _I2C_ROUTELOC0_SDALOC_SHIFT) | (init->portLocationScl << _I2C_ROUTELOC0_SCLLOC_SHIFT);#else init->port->ROUTE = I2C_ROUTE_SDAPEN | I2C_ROUTE_SCLPEN | (init->portLocation << _I2C_ROUTE_LOCATION_SHIFT);#endif /* Set emlib init parameters */ i2cInit.enable = true; i2cInit.master = true; /* master mode only */ i2cInit.freq = init->i2cMaxFreq; i2cInit.refFreq = init->i2cRefFreq; i2cInit.clhr = init->i2cClhr; I2C_Init(init->port, &i2cInit);}
开发者ID:MOSAIC-LoPoW,项目名称:dash7-ap-open-source-stack,代码行数:80,
示例30: main/**************************************************************************//** * @brief Main function *****************************************************************************/int main(void){ uint32_t buttons; POINT P[ 3 ]; TOUCH_Config_TypeDef touch_config = TOUCH_INIT_DEFAULT; const char readmeText[] = / "USB Bitmap transfer using USB drive functionality./r/n/r/n"/ "This example demonstrate use several functionalities:/r/n"/ "1. Creation of virtual drive in system with FAT FS,/r/n"/ "2. Mounting the drive on PC and file transfer,/r/n"/ "3. Bitmap file creation based on TFT frame buffer content,/r/n"/ "4. Resistive touch panel interaction./r/n/r/n"/ "On system startup initial drive is created and/r/n"/ "formatted using FAT FS then simple readme.txt file/r/n"/ "is put on file system. Every time user press PB4 key/r/n"/ "new file, containing TFT frame buffer in bitmap format/r/n"/ "is added. All files could be retrieved after connecting/r/n"/ "board to PC by means of USB. For this connection use/r/n"/ "small USB socket located on Leopard Gecko CPU board, not/r/n"/ "the big one on development kit./r/n/r/n"/ "If new files doesn't appear on drive after pressing PB4,/r/n"/ "try to reconnect the board to PC./r/n/r/n"/ "Board: Energy Micro EFM32LG-DK3650 Development Kit/r/n"/ "Device: EFM32LG990F256/r/n"; /* Configure for 48MHz HFXO operation of core clock */ CMU_ClockSelectSet(cmuClock_HF, cmuSelect_HFXO); /* Initialize DK board register access */ BSP_Init(BSP_INIT_DEFAULT); /* If first word of user data page is non-zero, enable eA Profiler trace */ BSP_TraceProfilerSetup(); CMU_ClockEnable(cmuClock_GPIO, true); CMU_ClockEnable( cmuClock_ADC0, true); /* Set frame buffer start address */ frameBuffer = (uint16_t *) EBI_BankAddress(EBI_BANK2); /* Make sure CYCCNT is running, needed by delay functions. */ DWT_CTRL |= 1; /* Initialize USB subsystem and prepare for taking pictures */ BITMAP_Init(); /* Create our first file on disk - simple readme */ BITMAP_CreateFileAndSaveData("README.TXT", readmeText, sizeof(readmeText)); /* Indicate we are waiting for AEM button state enabling EFM */ while (BSP_RegisterRead(&BC_REGISTER->UIF_AEM) != BC_UIF_AEM_EFM) { /* Show a short "strobe light" on DK LEDs, indicating wait */ BSP_LedsSet(0x8001); delayMs(100); BSP_LedsSet(0x4002); delayMs(100); } touch_config.frequency = 13000000; /* use max ADC frequency */ touch_config.ignore = 0; /* notice every move, even 1 pixel */ TOUCH_Init(&touch_config); /* Initialize touch screen calibration factor matrix with approx. values */ setCalibrationMatrix( (POINT*)&lcdCalibPoints, /* Display coordinates */ (POINT*)&touchCalibPoints, /* Touch coordinates */ &calibFactors ); /* Calibration factor matrix */ while (1) { delayMs(100); if ( TFT_DirectInit(&tftInit) ) { delayMs(100); displayHelpScreen(); BSP_LedsSet(0x0000); BSP_PeripheralAccess(BSP_TOUCH, true); GPIO_PinModeSet(LCD_TOUCH_X1, gpioModeInput, 0); GPIO_PinModeSet(LCD_TOUCH_X2, gpioModeInput, 0); GPIO_PinModeSet(LCD_TOUCH_Y1, gpioModeInput, 0); GPIO_PinModeSet(LCD_TOUCH_Y2, gpioModeInput, 0); do { delayMs(25); buttons = readButtons(); /* Draw on screen */ if ( buttons & BC_UIF_PB1 ) { memset( frameBuffer, BLACK, 2 * WIDTH * HEIGHT ); /* Clear screen */ do { TOUCH_Pos_TypeDef *pos = TOUCH_GetPos(); if ( pos->pen ) drawPixel( pos->x, pos->y, COLOR ); delayMs(1);//.........这里部分代码省略.........
开发者ID:EnergyMicro,项目名称:EFM32LG_DK3650,代码行数:101,
注:本文中的CMU_ClockEnable函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ CMU_ClockFreqGet函数代码示例 C++ CMSetStatus函数代码示例 |