/** * @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); }
////////////////////////main end/////////////////// void sysclk_ini(void) { CLK_HSECmd(ENABLE);//外部时钟开?? CLK_LSICmd(ENABLE);//内部低频RC开?? CLK_HSICmd(ENABLE);//内部高频RC开???? CLK_ClockSwitchCmd(ENABLE);//切换使能?? CLK_ClockSwitchConfig(CLK_SWITCHMODE_AUTO,CLK_SOURCE_HSE,DISABLE,CLK_CURRENTCLOCKSTATE_DISABLE);//切换配置到外部时钟,关闭原来时钟 }
void clockInit(void) { /* Turn on internal high speed clock and use it */ CLK_HSICmd(ENABLE); CLK_SYSCLKConfig(CLK_PRESCALER_HSIDIV1); CLK_ClockSwitchConfig(CLK_SWITCHMODE_AUTO, CLK_SOURCE_HSI, ENABLE, CLK_CURRENTCLOCKSTATE_ENABLE); CLK_LSICmd(DISABLE); }
void Beep_Init(BEEP_Frequency_TypeDef BEEP_Frequency) { BEEP_Init(BEEP_Frequency); CLK_LSICmd(ENABLE); BEEP_Cmd(ENABLE); }