本文整理汇总了C++中CLK_PeripheralClockConfig函数的典型用法代码示例。如果您正苦于以下问题:C++ CLK_PeripheralClockConfig函数的具体用法?C++ CLK_PeripheralClockConfig怎么用?C++ CLK_PeripheralClockConfig使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CLK_PeripheralClockConfig函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sEE_LowLevel_Init
/**
* @brief Initializes peripherals used by the I2C EEPROM driver.
* @param None
* @retval None
*/
void sEE_LowLevel_Init(void)
{
/*!< sEE_I2C Periph clock enable */
CLK_PeripheralClockConfig(sEE_I2C_CLK, ENABLE);
/*!< Enable the DMA clock */
CLK_PeripheralClockConfig(CLK_Peripheral_DMA1, ENABLE);
/* I2C TX DMA Channel configuration */
DMA_DeInit(sEE_I2C_DMA_CHANNEL_TX);
DMA_Init(sEE_I2C_DMA_CHANNEL_TX,
0, /* This parameter will be configured durig communication */
sEE_I2C_DR_Address,
0xFF, /* This parameter will be configured durig communication */
DMA_DIR_PeripheralToMemory,/* This parameter will be configured durig communication */
DMA_Mode_Normal,
DMA_MemoryIncMode_Inc,
DMA_Priority_VeryHigh,
DMA_MemoryDataSize_Byte);
/* I2C RX DMA Channel configuration */
DMA_DeInit(sEE_I2C_DMA_CHANNEL_RX);
DMA_Init(sEE_I2C_DMA_CHANNEL_RX, 0, /* This parameter will be configured durig communication */
sEE_I2C_DR_Address,
0xFF, /* This parameter will be configured durig communication */
DMA_DIR_PeripheralToMemory,/* This parameter will be configured durig communication */
DMA_Mode_Normal,
DMA_MemoryIncMode_Inc,
DMA_Priority_VeryHigh,
DMA_MemoryDataSize_Byte);
}
示例2: Halt_Init
/**
* @brief This function initializes in Ultra Low Power mode,
* disable the LCD, LSE and configures the unused IOs
* in output push-pull
* @caller main and ADC_Icc_Test
* @param None
* @retval None
*/
void Halt_Init(void)
{
/* Set STM8 in low power */
PWR->CSR2 = 0x2;
LCD_Cmd(DISABLE);
/* To wait LCD disable */
while ((LCD->CR3 & 0x40) != 0x00);
/* Set GPIO in low power*/
GPIO_LowPower_Config();
/* Stop RTC Source clock */
CLK_RTCClockConfig(CLK_RTCCLKSource_Off, CLK_RTCCLKDiv_1);
#ifdef USE_LSE
CLK_LSEConfig(CLK_LSE_OFF);
while ((CLK->ECKCR & 0x04) != 0x00);
#else
CLK_LSICmd(DISABLE);
while ((CLK->ICKCR & 0x04) != 0x00);
#endif
/* Stop clock RTC and LCD */
CLK_PeripheralClockConfig(CLK_Peripheral_RTC, DISABLE);
CLK_PeripheralClockConfig(CLK_Peripheral_LCD, DISABLE);
}
示例3: main
/*主程序*/
void main()
{
CLK_Config();
CLK_PeripheralClockConfig(CLK_PERIPHERAL_TIMER2, ENABLE);
CLK_PeripheralClockConfig(CLK_PERIPHERAL_TIMER3, ENABLE);
/* Check if the system has resumed from IWDG reset */
if (RST_GetFlagStatus(RST_FLAG_IWDGF) != RESET)
{
/* Clear IWDGF Flag */
RST_ClearFlag(RST_FLAG_IWDGF);
}
/*通信串口初始化*/
DBG_Config();
IR_Init();
printf("starting...\n");
/*打开全局中断*/
enableInterrupts();
while (1)
{
IR_Process();
}
}
示例4: sampleADC
char sampleADC(void)
{
char res = 0x0;
CLK_PeripheralClockConfig(CLK_Peripheral_ADC1, ENABLE);
ADC_DeInit(ADC1);
ADC_VrefintCmd(ENABLE);
delay_10us(3);
ADC_Cmd(ADC1, ENABLE);
ADC_Init(ADC1, ADC_ConversionMode_Single,
ADC_Resolution_6Bit, ADC_Prescaler_1);
ADC_SamplingTimeConfig(ADC1, ADC_Group_SlowChannels, ADC_SamplingTime_9Cycles);
ADC_ChannelCmd(ADC1, ADC_Channel_0, ENABLE);
delay_10us(3);
ADC_SoftwareStartConv(ADC1);
while( ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == 0);
res = (char)ADC_GetConversionValue(ADC1);
ADC_VrefintCmd(DISABLE);
ADC_DeInit(ADC1);
/* disable SchmittTrigger for ADC_Channel_24, to save power */
//ADC_SchmittTriggerConfig(ADC1, ADC_Channel_24, DISABLE);
CLK_PeripheralClockConfig(CLK_Peripheral_ADC1, DISABLE);
ADC_ChannelCmd(ADC1, ADC_Channel_0, DISABLE);
return res;
}
示例5: ADC_Config
void ADC_Config(void)
{
CLK_PeripheralClockConfig(CLK_Peripheral_ADC1, ENABLE);
CLK_PeripheralClockConfig(CLK_Peripheral_DMA1, ENABLE);
ADC_Init(ADC1, ADC_ConversionMode_Continuous, ADC_Resolution_12Bit, ADC_Prescaler_2);
ADC_SamplingTimeConfig(ADC1, ADC_Group_SlowChannels, ADC_SamplingTime_384Cycles);
ADC_Cmd(ADC1, ENABLE);
ADC_ChannelCmd(ADC1, ADC_Channel_24, ENABLE); //设置ADC通道
SYSCFG_REMAPDMAChannelConfig(REMAP_DMA1Channel_ADC1ToChannel0);
DMA_Init(DMA1_Channel0,
BUFFER_ADDRESS,
ADC1_DR_ADDRESS,
BUFFER_SIZE,
DMA_DIR_PeripheralToMemory,
DMA_Mode_Circular,
DMA_MemoryIncMode_Inc,
DMA_Priority_High,
DMA_MemoryDataSize_HalfWord);
DMA_Cmd(DMA1_Channel0, ENABLE);
DMA_ITConfig(DMA1_Channel0, DMA_ITx_TC, ENABLE);
DMA_GlobalCmd(ENABLE);
}
示例6: delay_ms
/**
* @brief delay for some time in ms unit
* @param n_ms is how many ms of time to delay
* @retval None
*/
void delay_ms(u16 n_ms)
{
/* Init TIMER 4 */
CLK_PeripheralClockConfig(CLK_Peripheral_TIM4, ENABLE);
/* Init TIMER 4 prescaler: TIM4_Prescaler_1: 38KHz / 1 = 38KHz */
TIM4->PSCR = 0;
/* LSI 38KHz --> Auto-Reload value: 38KHz / 1 = 38KHz, 38KHz / 1k = 38 */
TIM4->ARR = 38;
/* Counter value: 4, to compensate the initialization of TIMER*/
TIM4->CNTR = 4; //value may have to be changed
/* clear update flag */
TIM4->SR1 &= (u8)(~TIM4_FLAG_Update);
/* Enable Counter */
TIM4->CR1 |= TIM4_CR1_CEN;
while(n_ms--)
{
while((TIM4->SR1 & TIM4_FLAG_Update) == 0);
TIM4->SR1 &= (u8)(~TIM4_FLAG_Update);
}
/* Disable Counter */
TIM4->CR1 &= (u8)(~TIM4_CR1_CEN);
CLK_PeripheralClockConfig(CLK_Peripheral_TIM4, DISABLE);
}
示例7: delay_ms
/**
* @brief delay for some time in ms unit
* @caller auto_test
* @param n_ms is how many ms of time to delay
* @retval None
*/
static void delay_ms(u16 n_ms)
{
/* Init TIMER 4 */
CLK_PeripheralClockConfig(CLK_Peripheral_TIM2, ENABLE);
/* Init TIMER 4 prescaler: / (2^6) = /64 */
TIM2->PSCR = 6;
/* HSI div by 1 --> Auto-Reload value: 16M / 64 = 1/4M, 1/4M / 1k = 250*/
TIM2->ARRH = 0;
TIM2->ARRL = 250;
/* Counter value: 2, to compensate the initialization of TIMER*/
TIM2->CNTRH = 0;
TIM2->CNTRL = 2;
/* clear update flag */
TIM2->SR1 &= ~TIM_SR1_UIF;
/* Enable Counter */
TIM2->CR1 |= TIM_CR1_CEN;
while(n_ms--)
{
while((TIM2->SR1 & TIM_SR1_UIF) == 0) ;
TIM2->SR1 &= ~TIM_SR1_UIF;
}
/* Disable Counter */
TIM2->CR1 &= ~TIM_CR1_CEN;
CLK_PeripheralClockConfig(CLK_Peripheral_TIM2, DISABLE);
}
示例8: delay_10us
/**
* @brief delay for some time in 10us unit(partial accurate)
* @caller auto_test
* @param n_10us is how many 10us of time to delay
* @retval None
*/
static void delay_10us(u16 n_10us)
{
/* Init TIMER 4 */
CLK_PeripheralClockConfig(CLK_Peripheral_TIM2, ENABLE);
/* prescaler: / (2^0) = /1 */
TIM2->PSCR = 0;
/* SYS_CLK_HSI_DIV1 Auto-Reload value: 16M / 1 = 16M, 16M / 100k = 160 */
TIM2->ARRH = 0;
TIM2->ARRL = 160;
/* Counter value: 10, to compensate the initialization of TIMER */
TIM2->CNTRH = 0;
TIM2->CNTRL = 10;
/* clear update flag */
TIM2->SR1 &= ~TIM_SR1_UIF;
/* Enable Counter */
TIM2->CR1 |= TIM_CR1_CEN;
while(n_10us--)
{
while((TIM2->SR1 & TIM_SR1_UIF) == 0) ;
TIM2->SR1 &= ~TIM_SR1_UIF;
}
/* Disable Counter */
TIM2->CR1 &= ~TIM_CR1_CEN;
CLK_PeripheralClockConfig(CLK_Peripheral_TIM2, DISABLE);
}
示例9: Delay_Seconds
/**
* @brief Delay x sec
* @param Seconds : number of seconds to delay
* @retval None.
* Note : TIM4 is configured for a system clock = 2MHz
*/
void Delay_Seconds(uint8_t Seconds)
{
uint8_t i = 0;
/* Enable TIM4 Clock */
CLK_PeripheralClockConfig(CLK_Peripheral_TIM4, ENABLE);
/* Configure TIM4 to generate an update event each 1 s */
TIM4_TimeBaseInit(TIM4_Prescaler_16384, 123);
/* Enable TIM4 */
TIM4_Cmd(ENABLE);
/* Clear the Flag */
TIM4_ClearFlag(TIM4_FLAG_Update);
for (i = 0; i < Seconds; i++)
{
/* Wait 1 sec */
while ( TIM4_GetFlagStatus(TIM4_FLAG_Update) == RESET )
{}
/* Clear the Flag */
TIM4_ClearFlag(TIM4_FLAG_Update);
}
/* Disable TIM4 */
TIM4_Cmd(DISABLE);
/* Disable TIM4 Clock */
CLK_PeripheralClockConfig(CLK_Peripheral_TIM4, DISABLE);
}
示例10: CLK_Config
/**
* @brief Configure peripherals clock
* @param None
* @retval None
*/
static void CLK_Config(void)
{
/* Enable ADC1 clock */
CLK_PeripheralClockConfig(CLK_Peripheral_ADC1, ENABLE);
/* Enable COMP clock */
CLK_PeripheralClockConfig(CLK_Peripheral_COMP, ENABLE);
}
示例11: CLK_Config
/**
* @brief Configure peripherals Clock
* @param None
* @retval None
*/
static void CLK_Config(void)
{
/* Enable TIM1 clock */
CLK_PeripheralClockConfig(CLK_Peripheral_TIM1, ENABLE);
/* Enable TIM2 clock */
CLK_PeripheralClockConfig(CLK_Peripheral_TIM2, ENABLE);
/* Enable TIM3 clock */
CLK_PeripheralClockConfig(CLK_Peripheral_TIM3, ENABLE);
}
示例12: ADC_Supply
/**
* @brief Read ADC1
* @caller several functions
* @param None
* @retval ADC value
*/
u16 ADC_Supply(void)
{
uint8_t i;
uint16_t res;
/* Enable ADC clock */
CLK_PeripheralClockConfig(CLK_Peripheral_ADC1, ENABLE);
/* de-initialize ADC */
ADC_DeInit(ADC1);
/*ADC configuration
ADC configured as follow:
- Channel VREF
- Mode = Single ConversionMode(ContinuousConvMode disabled)
- Resolution = 12Bit
- Prescaler = /1
- sampling time 9 */
ADC_VrefintCmd(ENABLE);
delay_10us(3);
ADC_Cmd(ADC1, ENABLE);
ADC_Init(ADC1, ADC_ConversionMode_Single,
ADC_Resolution_12Bit, ADC_Prescaler_1);
ADC_SamplingTimeConfig(ADC1, ADC_Group_FastChannels, ADC_SamplingTime_9Cycles);
ADC_ChannelCmd(ADC1, ADC_Channel_Vrefint, ENABLE);
delay_10us(3);
/* initialize result */
res = 0;
for(i=8; i>0; i--)
{
/* start ADC convertion by software */
ADC_SoftwareStartConv(ADC1);
/* wait until end-of-covertion */
while( ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == 0 );
/* read ADC convertion result */
res += ADC_GetConversionValue(ADC1);
}
/* de-initialize ADC */
ADC_VrefintCmd(DISABLE);
ADC_DeInit(ADC1);
/* disable SchmittTrigger for ADC_Channel_24, to save power */
ADC_SchmittTriggerConfig(ADC1, ADC_Channel_24, DISABLE);
CLK_PeripheralClockConfig(CLK_Peripheral_ADC1, DISABLE);
ADC_ChannelCmd(ADC1, ADC_Channel_Vrefint, DISABLE);
return (res>>3);
}
示例13: Battery_Int_Measure
void Battery_Int_Measure(float * p_bat_voltage)
{
float voltage_shift = 0;
float voltage_VCC = 0;
#ifdef BATTERY_DEBUG
printf("[Battery] Start measuring battery ...\r\n");
#endif
result = 0;
GPIO_Init(GPIO_PORT_ADC_OUT, GPIO_PIN_ADC_OUT, GPIO_Mode_Out_PP_High_Fast);
GPIO_Init(GPIO_PORT_VTEST_5V, GPIO_PIN_VTEST_5V, GPIO_Mode_In_FL_No_IT);
/* Enable ADC1 clock */
CLK_PeripheralClockConfig(CLK_Peripheral_ADC1, ENABLE);
ADC_Config();
/* Infinite loop*/
for(uint8_t i = 0;i < BUFFER_SIZE;i ++)
{
/* Start ADC1 Conversion using Software trigger*/
ADC_SoftwareStartConv(ADC1);
/* Wait until ADC Channel 15 end of conversion */
while (ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == RESET)
{}
/* read ADC convertion result */
adc_value[i] = ADC_GetConversionValue(ADC1);
result += adc_value[i];
}
voltage_shift = (result * 3.6) / (BUFFER_SIZE * 4096);
voltage_VCC = (voltage_shift * (BAT_INT_SHIFT_PULLDOWN_RES + BAT_INT_SHIFT_PULLUP_RES)) / BAT_INT_SHIFT_PULLDOWN_RES;
/* Disable ADC1 */
ADC_Cmd(ADC1, DISABLE);
/* Disable ADC1 clock */
CLK_PeripheralClockConfig(CLK_Peripheral_ADC1, DISABLE);
GPIO_Init(GPIO_PORT_ADC_OUT, GPIO_PIN_ADC_OUT, GPIO_Mode_Out_PP_Low_Fast);
GPIO_Init(GPIO_PORT_VTEST_5V, GPIO_PIN_VTEST_5V, GPIO_Mode_Out_PP_Low_Fast);
*p_bat_voltage = voltage_VCC;
#ifdef BATTERY_DEBUG
for (uint8_t i = 0; i < BUFFER_SIZE; i++)
{
printf("[Battery] voltage is 0x%04x\r\n",adc_value[i]);
}
#endif
}
示例14: CLK_Config
/**
* @brief Configure peripherals clock
* @param None
* @retval None
*/
static void CLK_Config(void)
{
/* Enable ADC1 clock */
CLK_PeripheralClockConfig(CLK_Peripheral_ADC1, ENABLE);
/* Enable TIM1 clock */
CLK_PeripheralClockConfig(CLK_Peripheral_TIM1, ENABLE);
/* Enable DMA1 clock */
CLK_PeripheralClockConfig(CLK_Peripheral_DMA1, ENABLE);
}
示例15: I2C_RTC_Init
/*
名称: void I2C_RTC_Init(void)
功能: 硬件IIC初始化
形参: 无
返回值:无
*/
void IIC_RTC_Init(void)
{
I2C_Cmd(DISABLE);
I2C_DeInit();
CLK_PeripheralClockConfig(CLK_PERIPHERAL_I2C, DISABLE);
GPIO_Init(GPIOE, GPIO_PIN_1, GPIO_MODE_IN_PU_NO_IT);
GPIO_Init(GPIOE, GPIO_PIN_2, GPIO_MODE_IN_PU_NO_IT);
CLK_PeripheralClockConfig(CLK_PERIPHERAL_I2C, ENABLE);
I2C_Cmd( ENABLE);
I2C_Init(400000, 0xA0, I2C_DUTYCYCLE_2, I2C_ACK_CURR,
I2C_ADDMODE_7BIT, 16);
}