本文整理汇总了C++中CMU_ClockEnable函数的典型用法代码示例。如果您正苦于以下问题:C++ CMU_ClockEnable函数的具体用法?C++ CMU_ClockEnable怎么用?C++ CMU_ClockEnable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CMU_ClockEnable函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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,代码来源:dvk.c
示例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,代码来源:td_timer.c
示例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,代码来源:main.c
示例4: gpioSetup
void 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,代码来源:gpio.cpp
示例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,代码来源:sleep_on_exit.c
示例6: i2c_setup
void 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,代码来源:adxl.c
示例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,代码来源:main.c
示例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,代码来源:touch.c
示例9: main
int 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,代码来源:opamp_DAC_to_opamp.c
示例10: us_ticker_init
void 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,代码来源:us_ticker.c
示例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,代码来源:low_power_tick_management.c
示例12: setupCmu
/**************************************************************************//**
* @brief Enabling clocks
*****************************************************************************/
void setupCmu(void)
{
/* Enabling clocks */
CMU_ClockEnable(cmuClock_DMA, true);
}
开发者ID:AndreMiras,项目名称:EFM32-Library,代码行数:8,代码来源:memory_scatter_gather.c
示例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,代码来源:main_ofb_128.c
示例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,代码来源:decode.c
示例15: main
int 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,代码来源:main_pwm_fading.c
示例16: i2c_poweron
void i2c_poweron(i2c_t dev)
{
CMU_ClockEnable(i2c_config[dev].cmu, true);
}
开发者ID:chrysn-pull-requests,项目名称:EFM2Riot,代码行数:4,代码来源:i2c.c
示例17: i2c_poweroff
void i2c_poweroff(i2c_t dev)
{
CMU_ClockEnable(i2c_config[dev].cmu, false);
}
开发者ID:chrysn-pull-requests,项目名称:EFM2Riot,代码行数:4,代码来源:i2c.c
示例18: initPWM
void 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,代码来源:dimming.c
示例19: InitAudioPWM
void 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,代码来源:dac.c
示例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,代码来源:main.c
注:本文中的CMU_ClockEnable函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论