本文整理汇总了C++中CMU_ClockFreqGet函数的典型用法代码示例。如果您正苦于以下问题:C++ CMU_ClockFreqGet函数的具体用法?C++ CMU_ClockFreqGet怎么用?C++ CMU_ClockFreqGet使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CMU_ClockFreqGet函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(void)
{
CHIP_Init();
if (SysTick_Config(CMU_ClockFreqGet(cmuClock_CORE) / 1000)) while (1) ;
BSP_Init(BSP_INIT_DEFAULT);
BSP_LedsSet(0);
BSP_PeripheralAccess(BSP_AUDIO_IN, true);
BSP_PeripheralAccess(BSP_AUDIO_OUT, true);
RTCDRV_Trigger(1000, NULL);
EMU_EnterEM2(true);
initSource();
setupCMU();
setupDMA();
//setupADC();
//setupDAC();
//setupDMAInput();
//setupDMAOutput();
//setupDMASplit();
//setupDMAMerge();
ADCConfig();
DACConfig();
TIMER_Init_TypeDef timerInit = TIMER_INIT_DEFAULT;
TIMER_TopSet(TIMER0, CMU_ClockFreqGet(cmuClock_HFPER) / SAMPLE_RATE);
TIMER_Init(TIMER0, &timerInit);
Delay(100);
BSP_LedsSet(3);
Delay(500);
BSP_LedsSet(0);
Delay(100);
while(1) {
volatile bool result = test();
if (result) {
BSP_LedsSet(0x00FF);
} else {
BSP_LedsSet(0xFF00);
}
Delay(1000);
BSP_LedsSet(0x0);
Delay(1000);
}
}
示例2: CAN_GetClockFrequency
/***************************************************************************//**
* @brief
* Get the CAN module frequency.
*
* @details
* There is an internal prescaler of 2 inside the CAN module.
*
* @param[in] can
* Pointer to CAN peripheral register block.
*
* @return
* Clock value
******************************************************************************/
uint32_t CAN_GetClockFrequency(CAN_TypeDef *can)
{
#if defined CAN0
if (can == CAN0) {
return CMU_ClockFreqGet(cmuClock_CAN0) / 2;
}
#endif
#if defined CAN1
if (can == CAN1) {
return CMU_ClockFreqGet(cmuClock_CAN1) / 2;
}
#endif
EFM_ASSERT(false);
return 0;
}
示例3: rtccSetup
/**************************************************************************//**
* @brief Enables LFECLK and selects clock source for RTCC
* Sets up the RTCC to generate an interrupt every second.
*****************************************************************************/
static void rtccSetup(unsigned int frequency)
{
RTCC_Init_TypeDef rtccInit = RTCC_INIT_DEFAULT;
rtccInit.presc = rtccCntPresc_1;
palClockSetup(cmuClock_LFE);
/* Enable RTCC clock */
CMU_ClockEnable(cmuClock_RTCC, true);
/* Initialize RTC */
rtccInit.enable = false; /* Do not start RTC after initialization is complete. */
rtccInit.debugRun = false; /* Halt RTC when debugging. */
rtccInit.cntWrapOnCCV1 = true; /* Wrap around on CCV1 match. */
RTCC_Init(&rtccInit);
/* Interrupt at given frequency. */
RTCC_CCChConf_TypeDef ccchConf = RTCC_CH_INIT_COMPARE_DEFAULT;
ccchConf.compMatchOutAction = rtccCompMatchOutActionToggle;
RTCC_ChannelInit(1, &ccchConf);
RTCC_ChannelCCVSet(1, (CMU_ClockFreqGet(cmuClock_RTCC) / frequency) - 1);
#ifndef INCLUDE_PAL_GPIO_PIN_AUTO_TOGGLE_HW_ONLY
/* Enable interrupt */
NVIC_EnableIRQ(RTCC_IRQn);
RTCC_IntEnable(RTCC_IEN_CC1);
#endif
RTCC->CNT = _RTCC_CNT_RESETVALUE;
/* Start Counter */
RTCC_Enable(true);
}
示例4: main
/**************************************************************************//**
* @brief Main function
*****************************************************************************/
int main(void)
{
/* 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();
/* Setup SysTick Timer for 1 msec interrupts */
if (SysTick_Config(CMU_ClockFreqGet(cmuClock_CORE) / 1000))
{
while (1) ;
}
/* Initialize DK interrupt enable */
DK_IRQInit();
/* Initialize GPIO interrupt */
GPIO_IRQInit();
/* Turn off LEDs */
BSP_LedsSet(0x0000);
while (1)
{
/* Wait 5 seconds */
Delay(5000);
/* Quick flash to show we're alive */
BSP_LedsSet(0xffff);
Delay(20);
BSP_LedsSet(0x0000);
}
}
示例5: LEUART_BaudrateGet
/***************************************************************************//**
* @brief
* Get current baudrate for LEUART.
*
* @details
* This function returns the actual baudrate (not considering oscillator
* inaccuracies) used by a LEUART peripheral.
*
* @param[in] leuart
* Pointer to LEUART peripheral register block.
*
* @return
* Current baudrate.
******************************************************************************/
uint32_t LEUART_BaudrateGet(LEUART_TypeDef *leuart)
{
uint32_t freq;
CMU_Clock_TypeDef clock;
/* Get current frequency */
if (leuart == LEUART0)
{
clock = cmuClock_LEUART0;
}
#if (LEUART_COUNT > 1)
else if (leuart == LEUART1)
{
clock = cmuClock_LEUART1;
}
#endif
else
{
EFM_ASSERT(0);
return 0;
}
freq = CMU_ClockFreqGet(clock);
return LEUART_BaudrateCalc(freq, leuart->CLKDIV);
}
示例6: rtcSetup
/**************************************************************************//**
* @brief Enables LFACLK and selects LFXO as clock source for RTC
* Sets up the RTC to generate an interrupt every second.
*****************************************************************************/
static void rtcSetup(unsigned int frequency)
{
RTC_Init_TypeDef rtcInit = RTC_INIT_DEFAULT;
palClockSetup(cmuClock_LFA);
/* Set the prescaler. */
CMU_ClockDivSet( cmuClock_RTC, cmuClkDiv_2 );
/* Enable RTC clock */
CMU_ClockEnable(cmuClock_RTC, true);
/* Initialize RTC */
rtcInit.enable = false; /* Do not start RTC after initialization is complete. */
rtcInit.debugRun = false; /* Halt RTC when debugging. */
rtcInit.comp0Top = true; /* Wrap around on COMP0 match. */
RTC_Init(&rtcInit);
/* Interrupt at given frequency. */
RTC_CompareSet(0, ((CMU_ClockFreqGet(cmuClock_RTC) / frequency) - 1) & _RTC_COMP0_MASK );
#ifndef INCLUDE_PAL_GPIO_PIN_AUTO_TOGGLE_HW_ONLY
/* Enable interrupt */
NVIC_EnableIRQ(RTC_IRQn);
RTC_IntEnable(RTC_IEN_COMP0);
#endif
RTC_CounterReset();
/* Start Counter */
RTC_Enable(true);
}
示例7: OS_CPU_SysTickClkFreq
/***************************************************************************//**
* OS_CPU_SysTickClkFreq()
* @brief Get system tick clock frequency.
*
* @param[in] none
* @exception none
* @return Clock frequency (of system tick).
*
******************************************************************************/
CPU_INT32U OS_CPU_SysTickClkFreq (void)
{
CPU_INT32U freq;
freq = CMU_ClockFreqGet(cmuClock_HFPER);
return (freq);
}
示例8: main
/**************************************************************************//**
* @brief Main function
*****************************************************************************/
int main(void)
{
/* Chip revision alignment and errata fixes */
CHIP_Init();
/* 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();
/* Setup SysTick Timer for 1 msec interrupts */
if (SysTick_Config(CMU_ClockFreqGet(cmuClock_CORE) / 1000))
{
while (1) ;
}
/* Blink forever */
while (1)
{
/* Blink user leds on DVK board */
BSP_LedsSet(0x00ff);
Delay(200);
/* Blink user leds on DVK board */
BSP_LedsSet(0xff00);
Delay(200);
}
}
示例9: RTC_Setup
/***************************************************************************//**
* @brief
* Enables LFACLK and selects LFXO as clock source for RTC
*
* @param osc
* Oscillator
******************************************************************************/
void RTC_Setup(CMU_Select_TypeDef osc)
{
RTC_Init_TypeDef init;
rtcInitialized = 1;
/* Ensure LE modules are accessible */
CMU_ClockEnable(cmuClock_CORELE, true);
/* Enable osc as LFACLK in CMU (will also enable oscillator if not enabled) */
CMU_ClockSelectSet(cmuClock_LFA, osc);
/* Use a 32 division prescaler to reduce power consumption. */
CMU_ClockDivSet(cmuClock_RTC, cmuClkDiv_32);
rtcFreq = CMU_ClockFreqGet(cmuClock_RTC);
/* Enable clock to RTC module */
CMU_ClockEnable(cmuClock_RTC, true);
init.enable = false;
init.debugRun = false;
init.comp0Top = false; /* Count to max before wrapping */
RTC_Init(&init);
/* Disable interrupt generation from RTC0 */
RTC_IntDisable(_RTC_IF_MASK);
/* Enable interrupts */
NVIC_ClearPendingIRQ(RTC_IRQn);
NVIC_EnableIRQ(RTC_IRQn);
}
示例10: GUI_X_Delay
/***************************************************************************//**
* @brief
* is used to stop code execution for specified time
* @param[in] ms
* contains number of miliseconds to suspend program. Maximum allowed
* value is 10000 (10 seconds).
* @details
* This routine could enter into EM1 or EM2 mode to reduce power
* consumption. If touch panel is not pressed EM2 is executed, otherwise
* due to fact that ADC requires HF clock, only EM1 is enabled. This
* function is also used to handle joystick state and move cursor
* according to it. In addition it could also reinitialize LCD if
* previously Advanced Energy Monitor screen was active.
******************************************************************************/
void GUI_X_Delay(int ms)
{
volatile uint32_t now;
uint32_t startTime, waitTime;
if ( BSP_RegisterRead( &BC_REGISTER->UIF_AEM) != BC_UIF_AEM_EFM)
{
/* Switched to Advanced Energy Monitor, LCD will need to be reinitialized */
aemMode = true;
}
else if( aemMode )
{
/* Switched back from Advanced Energy Monitor, reinitialize LCD */
aemMode = false;
PLOT_DisplayInit();
}
if ( ms > 0 )
{
waitTime = ms * (CMU_ClockFreqGet(cmuClock_CORE) / 1000);
/* Enable DWT and make sure CYCCNT is running. */
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
DWT->CTRL |= 1;
startTime = DWT->CYCCNT;
do
{
now = DWT->CYCCNT;
} while ( ( now - startTime ) < waitTime );
}
}
示例11: ADC_TimebaseCalc
/***************************************************************************//**
* @brief
* Calculate timebase value in order to get a timebase providing at least 1us.
*
* @param[in] hfperFreq Frequency in Hz of reference HFPER clock. Set to 0 to
* use currently defined HFPER clock setting.
*
* @return
* Timebase value to use for ADC in order to achieve at least 1 us.
******************************************************************************/
uint8_t ADC_TimebaseCalc(uint32_t hfperFreq)
{
if (!hfperFreq)
{
hfperFreq = CMU_ClockFreqGet(cmuClock_HFPER);
/* Just in case, make sure we get non-zero freq for below calculation */
if (!hfperFreq)
{
hfperFreq = 1;
}
}
#if defined(_EFM32_GIANT_FAMILY) || defined(_EFM32_WONDER_FAMILY)
/* Handle errata on Giant Gecko, max TIMEBASE is 5 bits wide or max 0x1F */
/* cycles. This will give a warmp up time of e.g. 0.645us, not the */
/* required 1us when operating at 48MHz. One must also increase acqTime */
/* to compensate for the missing clock cycles, adding up to 1us in total.*/
/* See reference manual for details. */
if( hfperFreq > 32000000 )
{
hfperFreq = 32000000;
}
#endif
/* Determine number of HFPERCLK cycle >= 1us */
hfperFreq += 999999;
hfperFreq /= 1000000;
/* Return timebase value (N+1 format) */
return (uint8_t)(hfperFreq - 1);
}
示例12: TimerInit
/************************************************************************************//**
** \brief Initializes the timer.
** \return none.
**
****************************************************************************************/
void TimerInit(void)
{
/* configure the SysTick timer for 1 ms period */
SysTick_Config(CMU_ClockFreqGet(cmuClock_CORE) / 1000);
/* reset the millisecond counter */
TimerSet(0);
} /*** end of TimerInit ***/
示例13: USBTIMER_Init
/***************************************************************************//**
* @brief
* Activate the hardware timer used to pace the 1 millisecond timer system.
*
* @details
* Call this function whenever the HFPERCLK frequency is changed.
* This function is initially called by HOST and DEVICE stack xxxx_Init()
* functions.
******************************************************************************/
void USBTIMER_Init( void )
{
uint32_t freq;
TIMER_Init_TypeDef timerInit = TIMER_INIT_DEFAULT;
TIMER_InitCC_TypeDef timerCCInit = TIMER_INITCC_DEFAULT;
freq = CMU_ClockFreqGet( cmuClock_HFPER );
ticksPrMs = ( freq + 500 ) / 1000;
ticksPr1us = ( freq + 500000 ) / 1000000;
ticksPr10us = ( freq + 50000 ) / 100000;
ticksPr100us = ( freq + 5000 ) / 10000;
timerCCInit.mode = timerCCModeCompare;
CMU_ClockEnable( TIMER_CLK, true );
TIMER_TopSet( TIMER, 0xFFFF );
TIMER_InitCC( TIMER, 0, &timerCCInit );
TIMER_Init( TIMER, &timerInit );
#if ( NUM_QTIMERS > 0 )
TIMER_IntClear( TIMER, 0xFFFFFFFF );
TIMER_IntEnable( TIMER, TIMER_IEN_CC0 );
TIMER_CompareSet( TIMER, 0, TIMER_CounterGet( TIMER ) + ticksPrMs );
NVIC_ClearPendingIRQ( TIMER_IRQ );
NVIC_EnableIRQ( TIMER_IRQ );
#endif /* ( NUM_QTIMERS > 0 ) */
}
示例14: USART_BaudrateSyncSet
/***************************************************************************//**
* @brief
* Configure USART operating in synchronous mode to use a given baudrate
* (or as close as possible to specified baudrate).
*
* @details
* The configuration will be set to use a baudrate <= the specified baudrate
* in order to ensure that the baudrate does not exceed the specified value.
*
* Fractional clock division is suppressed, although the HW design allows it.
* It could cause half clock cycles to exceed specified limit, and thus
* potentially violate specifications for the slave device. In some special
* situations fractional clock division may be useful even in synchronous
* mode, but in those cases it must be directly adjusted, possibly assisted
* by USART_BaudrateCalc():
*
* @param[in] usart
* Pointer to USART peripheral register block. (Cannot be used on UART
* modules.)
*
* @param[in] refFreq
* USART reference clock frequency in Hz that will be used. If set to 0,
* the currently configured reference clock is assumed.
*
* @param[in] baudrate
* Baudrate to try to achieve for USART.
******************************************************************************/
void USART_BaudrateSyncSet(USART_TypeDef *usart, uint32_t refFreq, uint32_t baudrate)
{
uint32_t clkdiv;
/* Inhibit divide by 0 */
EFM_ASSERT(baudrate);
/*
* We want to use integer division to avoid forcing in float division
* utils, and yet keep rounding effect errors to a minimum.
*
* CLKDIV in synchronous mode is given by:
*
* CLKDIV = 256 * (fHFPERCLK/(2 * br) - 1)
* or
* CLKDIV = (256 * fHFPERCLK)/(2 * br) - 256 = (128 * fHFPERCLK)/br - 256
*
* The basic problem with integer division in the above formula is that
* the dividend (128 * fHFPERCLK) may become higher than max 32 bit
* integer. Yet, we want to evaluate dividend first before dividing in
* order to get as small rounding effects as possible. We do not want
* to make too harsh restrictions on max fHFPERCLK value either.
*
* One can possibly factorize 128 and br. However, since the last
* 6 bits of CLKDIV are don't care, we can base our integer arithmetic
* on the below formula without loosing any extra precision:
*
* CLKDIV / 64 = (2 * fHFPERCLK)/br - 4
*
* and calculate 1/64 of CLKDIV first. This allows for fHFPERCLK
* up to 2GHz without overflowing a 32 bit value!
*/
/* HFPERCLK used to clock all USART/UART peripheral modules */
if (!refFreq)
{
refFreq = CMU_ClockFreqGet(cmuClock_HFPER);
}
/* Calculate and set CLKDIV with fractional bits */
clkdiv = 2 * refFreq;
clkdiv += baudrate - 1;
clkdiv /= baudrate;
clkdiv -= 4;
clkdiv *= 64;
/* Make sure we don't use fractional bits by rounding CLKDIV */
/* up (and thus reducing baudrate, not increasing baudrate above */
/* specified value). */
clkdiv += 0xc0;
clkdiv &= 0xffffff00;
/* Verify that resulting clock divider is within limits */
EFM_ASSERT(clkdiv <= _USART_CLKDIV_MASK);
/* If EFM_ASSERT is not enabled, make sure we don't write to reserved bits */
clkdiv &= _USART_CLKDIV_DIV_MASK;
usart->CLKDIV = clkdiv;
}
示例15: delayUs
/**************************************************************************//**
* @brief Microsecond delay function
* @param[in] usec Delay in microseconds
*****************************************************************************/
static void delayUs( uint32_t usec )
{
uint64_t totalTicks;
totalTicks = (((uint64_t)CMU_ClockFreqGet(cmuClock_CORE)*usec)+500000)/1000000;
delayTicks( totalTicks );
}