这篇教程C++ HAL_PWR_EnterSTOPMode函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中HAL_PWR_EnterSTOPMode函数的典型用法代码示例。如果您正苦于以下问题:C++ HAL_PWR_EnterSTOPMode函数的具体用法?C++ HAL_PWR_EnterSTOPMode怎么用?C++ HAL_PWR_EnterSTOPMode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了HAL_PWR_EnterSTOPMode函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: StopModevoid StopMode(void){ GPIO_InitTypeDef GPIO_InitStruct; /* Disable all GPIOs to reduce power */ MX_GPIO_Deinit(); /* Configure User push-button as external interrupt generator */ __HAL_RCC_GPIOC_CLK_ENABLE(); GPIO_InitStruct.Pin = B1_Pin; GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(B1_GPIO_Port, &GPIO_InitStruct); HAL_UART_DeInit(&huart2); /* Suspend Tick increment to prevent wakeup by Systick interrupt. Otherwise the Systick interrupt will wake up the device within 1ms (HAL time base) */ HAL_SuspendTick(); /* We enable again the PWR peripheral */ __HAL_RCC_PWR_CLK_ENABLE(); /* Request to enter SLEEP mode */ HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_SLEEPENTRY_WFI); /* Resume Tick interrupt if disabled prior to sleep mode entry*/ HAL_ResumeTick(); /* Reinitialize GPIOs */ MX_GPIO_Init(); /* Reinitialize UART2 */ MX_USART2_UART_Init();}
开发者ID:Shreeyak,项目名称:mastering-stm32,代码行数:34,
示例2: stopmode_entryvoidstopmode_entry(){ extern xSemaphoreHandle semaphore_puts; xSemaphoreTake(semaphore_puts, portMAX_DELAY); puts("modem power off/n/r"); puts("cpu enter stop mode/n/r"); xSemaphoreGive(semaphore_puts); modem_power(0); stopmode_gpio_configuration(); vTaskSuspendAll(); watchdogtimer_stop(); rtc_backup_write(19, SYSRESET_STOP_MODE); HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); /* STOP here until EXTI interrupt */ NVIC_SystemReset(); while(1){ vTaskDelay(1000); }}
开发者ID:abit-corp,项目名称:phs-shield,代码行数:26,
示例3: LowPowerStopEXTI/** * @brief Enter in stop mode and exit by pressingf the tamper button * @param None * @note This example enter in stop mode. * @retval None */void LowPowerStopEXTI(void){ kWindow_Popup("STOP EXTI", LCD_COLOR_WHITE, LCD_COLOR_BLUE, / "/n/nPres JOY sel to/nstart/nstop mode/n", / LCD_COLOR_WHITE, LCD_COLOR_BLUE ); HAL_Delay(100); user_event = JOY_UP; while(user_event != JOY_SEL) { user_action = 0; }; kWindow_Popup("STOP EXTI", LCD_COLOR_WHITE, LCD_COLOR_BLUE, / "/n/nstop mode/nstarted/npress tamper/nto exit/n", / LCD_COLOR_BLUE, LCD_COLOR_WHITE ); /* User push-button (EXTI_Line0) will be used to wakeup the system from STOP mode */ BSP_PB_Init(BUTTON_TAMPER, BUTTON_MODE_EXTI); /* avoid wakeup from JOY event */ BSP_JOY_Init(JOY_MODE_GPIO); /* Clear PWR wake up Flag */ __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU); /* Enter Stop Mode */ HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); /* Restore the clock configuration */ SystemClock_STOPExit(); /* User push-button (EXTI_Line0) will be used to wakeup the system from STOP mode */ BSP_PB_Init(BUTTON_TAMPER, BUTTON_MODE_GPIO); BSP_JOY_Init(JOY_MODE_EXTI); }
开发者ID:GreyCardinalRus,项目名称:stm32-cube,代码行数:40,
示例4: machine_sleepSTATIC mp_obj_t machine_sleep(void) { // takes longer to wake but reduces stop current HAL_PWREx_EnableFlashPowerDown(); HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); // reconfigure the system clock after waking up // enable HSE __HAL_RCC_HSE_CONFIG(RCC_HSE_ON); while (!__HAL_RCC_GET_FLAG(RCC_FLAG_HSERDY)) { } // enable PLL __HAL_RCC_PLL_ENABLE(); while (!__HAL_RCC_GET_FLAG(RCC_FLAG_PLLRDY)) { } // select PLL as system clock source MODIFY_REG(RCC->CFGR, RCC_CFGR_SW, RCC_SYSCLKSOURCE_PLLCLK); while (__HAL_RCC_GET_SYSCLK_SOURCE() != RCC_CFGR_SWS_PLL) { } return mp_const_none;}
开发者ID:jaafarbarek,项目名称:pyrtos,代码行数:25,
示例5: LowPowerStopRTCAlarm/** * @brief Enter in stop mode and exit by an alarm * @param None * @note This example enter in stop mode. * @retval None */void LowPowerStopRTCAlarm(void){ kWindow_Popup("STOP Alarme", LCD_COLOR_WHITE, LCD_COLOR_BLUE,/ "/nset delay time/n", / LCD_COLOR_BLUE, LCD_COLOR_WHITE ); /* set the alarm */ LowPowerHandleAlarm(); kWindow_Popup("STOP Alarm", LCD_COLOR_WHITE, LCD_COLOR_BLUE, / "/n/nstop mode/nstarted/nwait alarm/nto exit/n", / LCD_COLOR_BLUE, LCD_COLOR_WHITE ); BSP_JOY_Init(JOY_MODE_GPIO); /* Enter Stop Mode */ HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFE); /* Restore the clock configuration */ SystemClock_STOPExit(); HAL_RTC_DeactivateAlarm(&RtcHandle, RTC_ALARM_A); /* Clear the Alarm interrupt pending bit */ __HAL_RTC_ALARM_CLEAR_FLAG(&RtcHandle,RTC_FLAG_ALRAF); /* Clear the EXTI's line Flag for RTC Alarm */ __HAL_RTC_EXTI_CLEAR_FLAG(RTC_EXTI_LINE_ALARM_EVENT); BSP_JOY_Init(JOY_MODE_EXTI);}
开发者ID:GreyCardinalRus,项目名称:stm32-cube,代码行数:35,
示例6: StopSequence_Config/** * @brief Prepare the system to enter STOP mode. * @param None * @retval None */static void StopSequence_Config(void){ GPIO_InitTypeDef GPIO_InitStruct; /* PWR Peripheral clock enable */ __HAL_RCC_PWR_CLK_ENABLE(); /* Enable GPIOs clock */ __HAL_RCC_GPIOA_CLK_ENABLE(); __HAL_RCC_GPIOB_CLK_ENABLE(); __HAL_RCC_GPIOC_CLK_ENABLE(); __HAL_RCC_GPIOD_CLK_ENABLE(); __HAL_RCC_GPIOE_CLK_ENABLE(); __HAL_RCC_GPIOF_CLK_ENABLE(); /* Configure all GPIO port pins in Analog mode */ GPIO_InitStruct.Pin = GPIO_PIN_All; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); /* Request to enter STOP mode with regulator in low power */ HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); EnterInStopMode = 1;}
开发者ID:NjordCZ,项目名称:stm32cubef0,代码行数:35,
示例7: DEVICE_Handlervoid DEVICE_Handler(void){ char buf[10]; static uint8_t _start = 1;// device.door->NEW = 1; while (1) { if (sleep) {// HAL_PCD_DevDisconnect(&hpcd_USB_FS); /* отключить SysTick */ HAL_SuspendTick(); /* Enters Stop mode */ HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); /* выход из STOPMode и инициализация USB */ /* включить SysTick */ HAL_ResumeTick(); /* Configure the system clock */ SystemClock_Config();// HAL_PCD_DevConnect(&hpcd_USB_FS); } else {// HAL_Delay(200);// printf("test/n");// HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_15); } }}
开发者ID:sapfir63,项目名称:door_sensor_stm,代码行数:33,
示例8: main/** * @brief Main program * @param None * @retval None */int main(void){ GPIO_InitTypeDef GPIO_InitStruct; /* STM32L0xx HAL library initialization: - Configure the Flash prefetch, Flash preread and Buffer caches - Systick timer is configured by default as source of time base, but user can eventually implement his proper time base source (a general purpose timer for example or other time source), keeping in mind that Time base duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and handled in milliseconds basis. - Low Level Initialization */ HAL_Init(); /* Configure the system clock to 2 MHz */ SystemClock_Config(); while (1) { /* Configure LED3 */ BSP_LED_Init(LED3); /* Turn LED3 on */ BSP_LED_On(LED3); /* Insert 5 second delay */ HAL_Delay(5000); /* Turn LED3 OFF */ BSP_LED_Off(LED3); /* Configure the system Power */ SystemPower_Config(); /* Configure PA.12 (Arduino D2) as input with External interrupt */ GPIO_InitStruct.Pin = GPIO_PIN_12; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; /* Enable GPIOA clock */ __HAL_RCC_GPIOA_CLK_ENABLE(); HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* Enable and set PA.12 (Arduino D2) EXTI Interrupt to the lowest priority */ NVIC_SetPriority((IRQn_Type)(EXTI4_15_IRQn), 0x03); HAL_NVIC_EnableIRQ((IRQn_Type)(EXTI4_15_IRQn)); /* Enable Power Control clock */ __HAL_RCC_PWR_CLK_ENABLE(); /* Enter Stop Mode */ HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); /* Configures system clock after wake-up from STOP */ SystemClock_Config(); }}
开发者ID:pengphei,项目名称:STM32Cube_L0,代码行数:64,
示例9: deepsleepvoid deepsleep(void){ // Request to enter STOP mode with regulator in low power mode HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); // After wake-up from STOP reconfigure the PLL SetSysClock();}
开发者ID:1deus,项目名称:tmk_keyboard,代码行数:8,
示例10: StopMode_Measure/** * @brief This function configures the system to enter Stop mode with RTC * clocked by LSE or LSI for current consumption measurement purpose. * STOP Mode with RTC clocked by LSE/LSI * ===================================== * - RTC Clocked by LSE or LSI * - Regulator in LP mode * - HSI, HSE OFF and LSI OFF if not used as RTC Clock source * - No IWDG * - Wakeup using EXTI Line (User push-button PC.13) * @param None * @retval None */void StopMode_Measure(void){ GPIO_InitTypeDef GPIO_InitStruct; /* Configure all GPIO as analog to reduce current consumption on non used IOs */ /* Warning : Reconfiguring all GPIO will close the connexion with the debugger */ /* Enable GPIOs clock */ __HAL_RCC_GPIOA_CLK_ENABLE(); __HAL_RCC_GPIOB_CLK_ENABLE(); __HAL_RCC_GPIOC_CLK_ENABLE(); __HAL_RCC_GPIOD_CLK_ENABLE(); __HAL_RCC_GPIOF_CLK_ENABLE(); GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pin = GPIO_PIN_All; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); /* Disable GPIOs clock */ __HAL_RCC_GPIOA_CLK_DISABLE(); __HAL_RCC_GPIOB_CLK_DISABLE(); __HAL_RCC_GPIOC_CLK_DISABLE(); __HAL_RCC_GPIOD_CLK_DISABLE(); __HAL_RCC_GPIOF_CLK_DISABLE(); /* Configure User Button */ BSP_PB_Init(BUTTON_USER, BUTTON_MODE_EXTI); /* Enter Stop Mode */ HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); /* Configures system clock after wake-up from STOP: enable HSI and PLL with HSI as source*/ SYSCLKConfig_STOP(); /* Initialize LED2 on the board */ BSP_LED_Init(LED2); /* Turn LED2 On */ BSP_LED_On(LED2); /* Inserted Delay */ HAL_Delay(200); }
开发者ID:jmoyerman,项目名称:stm32f0_cube,代码行数:68,
示例11: MCU_Enter_StopModevoid MCU_Enter_StopMode(void){ HAL_SuspendTick(); __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU); while((PWR->CSR & (uint32_t) 0x00000001)!=0);//attesa che il WUF si azzeri (via HW) HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFE); /* Infinite loop */ HAL_ResumeTick();}
开发者ID:adibacco,项目名称:sp1ml,代码行数:11,
示例12: deepsleepvoid deepsleep(void){ // Request to enter STOP mode with regulator in low power mode HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); // After wake-up from STOP need to reconfigure the system clock SetSysClock(); #if DEVICE_LOWPOWERTIMER rtc_synchronize();#endif}
开发者ID:AlessandroA,项目名称:mbed,代码行数:12,
示例13: main/*** @brief Main program* @param None* @retval None*/int main(void){ /* STM32L0xx HAL library initialization: - Configure the Flash prefetch, Flash preread and Buffer caches - Systick timer is configured by default as source of time base, but user can eventually implement his proper time base source (a general purpose timer for example or other time source), keeping in mind that Time base duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and handled in milliseconds basis. - Low Level Initialization */ HAL_Init(); /* Configure LED2 to handle error handler */ BSP_LED_Init(LED2); /* Configure the system clock @ 32 Mhz */ SystemClock_Config(); /* Configure the system Power */ SystemPower_Config(); while (1) { /* Insert 5 seconds delay */ HAL_Delay(5000); /* Disable Wakeup Counter */ HAL_RTCEx_DeactivateWakeUpTimer(&RTCHandle); /*## Setting the Wake up time ############################################*/ /* RTC Wakeup Interrupt Generation: Wakeup Time Base = (RTC_WAKEUPCLOCK_RTCCLK_DIV /(LSE or LSI)) Wakeup Time = Wakeup Time Base * WakeUpCounter = (RTC_WAKEUPCLOCK_RTCCLK_DIV /(LSE or LSI)) * WakeUpCounter ==> WakeUpCounter = Wakeup Time / Wakeup Time Base To configure the wake up timer to 4s the WakeUpCounter is set to 0x1FFF: RTC_WAKEUPCLOCK_RTCCLK_DIV = RTCCLK_Div16 = 16 Wakeup Time Base = 16 /(~39.000KHz) = ~0,410 ms Wakeup Time = ~4s = 0,410ms * WakeUpCounter ==> WakeUpCounter = ~4s/0,410ms = 9750 = 0x2616 */ HAL_RTCEx_SetWakeUpTimer_IT(&RTCHandle, 0x2616, RTC_WAKEUPCLOCK_RTCCLK_DIV16); /* Enter Stop Mode */ HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); /* Configures system clock after wake-up from STOP: enable HSI, PLL and select PLL as system clock source (HSI and PLL are disabled automatically in STOP mode) */ SystemClockConfig_STOP(); }}
开发者ID:shjere,项目名称:common,代码行数:57,
示例14: RtcEnterLowPowerStopModevoid RtcEnterLowPowerStopMode( void ){ if( ( LowPowerDisableDuringTask == false ) && ( RtcTimerEventAllowsLowPower == true ) ) { // Disable IRQ while the MCU is being deinitialized to prevent race issues __disable_irq( ); HAL_MspDeInit(); __enable_irq( ); /* Enter Stop Mode */ HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); }}
开发者ID:qlcGit,项目名称:NPLink-Mote-STM32-SDK,代码行数:15,
示例15: deepsleepvoid deepsleep(void){ // Disable HAL tick interrupt TimMasterHandle.Instance = TIM5; __HAL_TIM_DISABLE_IT(&TimMasterHandle, TIM_IT_CC2); // Request to enter STOP mode with regulator in low power mode HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); // After wake-up from STOP reconfigure the PLL SetSysClock(); // Enable HAL tick interrupt __HAL_TIM_ENABLE_IT(&TimMasterHandle, TIM_IT_CC2);}
开发者ID:Sweet-Peas,项目名称:mbed,代码行数:15,
示例16: StopMode_Measure/** * @brief This function configures the system to enter Stop mode with RTC * clocked by LSE or LSI for current consumption measurement purpose. * STOP Mode with RTC clocked by LSE/LSI * ===================================== * - RTC Clocked by LSE or LSI * - Regulator in LP mode * - HSI, HSE OFF and LSI OFF if not used as RTC Clock source * - No IWDG * - FLASH in deep power down mode * - Automatic Wakeup using RTC clocked by LSE/LSI (~20s) * @param None * @retval None */void StopMode_Measure(void){#ifdef STOP_IO GPIO_InitTypeDef GPIO_InitStruct; /* Configure all GPIO as analog to reduce current consumption on non used IOs */ /* Enable GPIOs clock */ __HAL_RCC_GPIOA_CLK_ENABLE(); __HAL_RCC_GPIOB_CLK_ENABLE(); __HAL_RCC_GPIOC_CLK_ENABLE(); __HAL_RCC_GPIOH_CLK_ENABLE(); GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pin = GPIO_PIN_All; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); /* Disable GPIOs clock */ __HAL_RCC_GPIOA_CLK_DISABLE(); __HAL_RCC_GPIOB_CLK_DISABLE(); __HAL_RCC_GPIOC_CLK_DISABLE(); __HAL_RCC_GPIOH_CLK_DISABLE();#endif /* FLASH Deep Power Down Mode enabled */ HAL_PWREx_EnableFlashPowerDown(); /*## Enter Stop Mode #######################################################*/ HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFE); /* Configures system clock after wake-up from STOP: enable HSE, PLL and select PLL as system clock source (HSE and PLL are disabled in STOP mode) */ SYSCLKConfig_STOP(); /* Disable Wake-up timer */ if(HAL_RTCEx_DeactivateWakeUpTimer(&RTCHandle) != HAL_OK) { /* Initialization Error */ Error_Handler(); }}
开发者ID:gilbertjuly,项目名称:cannon,代码行数:59,
示例17: main/** * @brief Main program * @param None * @retval None */int main(void){ /* STM32F4xx HAL library initialization: - Configure the Flash prefetch, instruction and Data caches - Systick timer is configured by default as source of time base, but user can eventually implement his proper time base source (a general purpose timer for example or other time source), keeping in mind that Time base duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and handled in milliseconds basis. - Set NVIC Group Priority to 4 - Low Level Initialization: global MSP (MCU Support Package) initialization */ HAL_Init(); /* Configure the system clock to 180 MHz */ SystemClock_Config(); /* Configure LED3 */ BSP_LED_Init(LED3); while (1) { /* Configure LED1 */ BSP_LED_Init(LED1); /* Turn LED1 on */ BSP_LED_On(LED1); /* Insert 5 second delay */ HAL_Delay(5000); /* Turn LED1 OFF */ BSP_LED_Off(LED1); /* Tamper push-button (lines 15 to 10) will be used to wakeup the system from STOP mode */ BSP_PB_Init(BUTTON_TAMPER, BUTTON_MODE_EXTI); /* Enter Stop Mode */ HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); /* Configures system clock after wake-up from STOP */ SystemClock_Config(); }}
开发者ID:Joe-Merten,项目名称:Stm32-Tools-Evaluation,代码行数:50,
示例18: RtcEnterLowPowerStopModevoid RtcEnterLowPowerStopMode( void ){ if( ( LowPowerDisableDuringTask == false ) && ( RtcTimerEventAllowsLowPower == true ) ) { BoardDeInitMcu( ); // Disable the Power Voltage Detector HAL_PWR_DisablePVD( ); SET_BIT( PWR->CR, PWR_CR_CWUF ); // Enable Ultra low power mode HAL_PWREx_EnableUltraLowPower( ); // Enable the fast wake up from Ultra low power mode HAL_PWREx_EnableFastWakeUp( ); // Enter Stop Mode HAL_PWR_EnterSTOPMode( PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI ); }}
开发者ID:Lora-net,项目名称:LoRaMac-node,代码行数:21,
示例19: deepsleepvoid deepsleep(void){ // Stop HAL systick HAL_SuspendTick(); // Request to enter STOP mode with regulator in low power mode#if TARGET_STM32L4 HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI);#else /* TARGET_STM32L4 */ HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);#endif /* TARGET_STM32L4 */ // Restart HAL systick HAL_ResumeTick(); // After wake-up from STOP reconfigure the PLL SetSysClock();#if DEVICE_LOWPOWERTIMER rtc_synchronize();#endif}
开发者ID:SolarTeamEindhoven,项目名称:mbed,代码行数:22,
示例20: pyb_stop/// /function stop()STATIC mp_obj_t pyb_stop(void) { HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); // reconfigure the system clock after waking up // enable HSE __HAL_RCC_HSE_CONFIG(RCC_HSE_ON); while (!__HAL_RCC_GET_FLAG(RCC_FLAG_HSERDY)) { } // enable PLL __HAL_RCC_PLL_ENABLE(); while (!__HAL_RCC_GET_FLAG(RCC_FLAG_PLLRDY)) { } // select PLL as system clock source MODIFY_REG(RCC->CFGR, RCC_CFGR_SW, RCC_SYSCLKSOURCE_PLLCLK); while (__HAL_RCC_GET_SYSCLK_SOURCE() != RCC_CFGR_SWS_PLL) { } return mp_const_none;}
开发者ID:mrmichalis,项目名称:micropython,代码行数:23,
示例21: mainint main(void){ /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ /* MCU Configuration----------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* Configure the system clock */ SystemClock_Config(); /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_I2C1_Init(); MX_USART2_UART_Init(); /* USER CODE BEGIN 2 */ HAL_DBGMCU_EnableDBGSleepMode(); HAL_SuspendTick(); // we don't want systick to wake us up every 1ms main_app(); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ HAL_PWR_EnterSTOPMode(PWR_MAINREGULATOR_ON, PWR_STOPENTRY_WFI); } /* USER CODE END 3 */}
开发者ID:mryndzionek,项目名称:dcf77_clock,代码行数:39,
示例22: main/*** @brief Main program* @param None* @retval None*/int main(void){ /* STM32L0xx HAL library initialization: - Configure the Flash prefetch, Flash preread and Buffer caches - Systick timer is configured by default as source of time base, but user can eventually implement his proper time base source (a general purpose timer for example or other time source), keeping in mind that Time base duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and handled in milliseconds basis. - Low Level Initialization */ HAL_Init(); /* Configure LED3 */ BSP_LED_Init(LED3); /* Configure the system clock @ 32 Mhz */ SystemClock_Config(); /* Configure the system Power */ SystemPower_Config(); while (1) { /* Insert 5 second delay */ HAL_Delay(5000); /* Key button (EXTI_Line13) will be used to wakeup the system from STOP mode */ BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_EXTI); /* Enter Stop Mode */ HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); /* Configures system clock after wake-up from STOP: enable HSE, PLL and select PLL as system clock source (HSE and PLL are disabled in STOP mode) */ SystemClockConfig_STOP(); }}
开发者ID:shjere,项目名称:common,代码行数:43,
示例23: main/** * @brief The application entry point. * * @retval None */int main(void){ /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ /* MCU Configuration----------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* USER CODE BEGIN Init */ /* USER CODE END Init */ /* Configure the system clock */ SystemClock_Config(); /* USER CODE BEGIN SysInit */ /* USER CODE END SysInit */ /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_I2C1_Init(); MX_TIM3_Init(); //MX_IWDG_Init(); MX_TIM14_Init(); MX_TIM16_Init(); MX_TIM17_Init(); /* USER CODE BEGIN 2 */ HAL_TIM_Encoder_Start(&htim3, TIM_CHANNEL_ALL); HAL_NVIC_SetPriority(TIM3_IRQn, 0, 0); HAL_NVIC_EnableIRQ(TIM3_IRQn); HAL_TIM_Base_Start_IT(&htim3); // Seconds Counter startup duty HAL_TIM_Base_Start_IT(&htim14); HAL_TIM_Base_Stop_IT(&htim14); HAL_TIM_Base_Start_IT(&htim16); HAL_TIM_Base_Start_IT(&htim17); HAL_GPIO_WritePin(GPIOA, LED_RED_PIN, GPIO_PIN_RESET); ssd1306_Init(); current_cursor = exposition; /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ //HAL_IWDG_Refresh(&hiwdg); if(__HAL_RCC_GET_SYSCLK_SOURCE() == RCC_SYSCLKSOURCE_STATUS_HSE) HAL_GPIO_WritePin(GPIOA, LED_GREEN_PIN, GPIO_PIN_SET); else HAL_GPIO_WritePin(GPIOA, LED_GREEN_PIN, GPIO_PIN_RESET); if (update_screen_flag) { ssd1306_Fill(Black); ssd1306_UpdateScreen(); update_screen_flag = 0; } if (seconds_counter > STOP_TIME_SEC) //if more than 10 s need to stop { // Entering STOP Mode Procedure seconds_counter = 0; GPIO_InitTypeDef GPIO_InitStruct; ssd1306_WriteCommand(0xAE); // OLED Off GPIO_InitStruct.Pin = ENC_BUTTON_PIN; GPIO_InitStruct.Mode = GPIO_MODE_EVT_RISING_FALLING; GPIO_InitStruct.Pull = GPIO_PULLDOWN; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); HAL_NVIC_SetPriority(EXTI4_15_IRQn, 0, 0); HAL_NVIC_EnableIRQ(EXTI4_15_IRQn); HAL_GPIO_WritePin(GPIOA, LED_GREEN_PIN|LED_RED_PIN|GATE_PIN|FOCUS_PIN, GPIO_PIN_RESET); HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFE); // Exit from STOP Mode procedure SystemClock_Config(); ssd1306_WriteCommand(0xAF); // OLED On//.........这里部分代码省略.........
开发者ID:b-o-r-m-a-l-e-y,项目名称:Canon_timer,代码行数:101,
示例24: StopMode_Measure/** * @brief This function configures the system to enter Stop mode with RTC * clocked by LSE or LSI for current consumption measurement purpose. * STOP Mode with RTC clocked by LSE/LSI * ===================================== * - RTC Clocked by LSE or LSI * - Regulator in LP mode * - HSI, HSE OFF and LSI OFF if not used as RTC Clock source * - No IWDG * - FLASH in deep power down mode * - Automatic Wakeup using RTC clocked by LSE/LSI (~20s) * @param None * @retval None */void StopMode_Measure(void){ GPIO_InitTypeDef GPIO_InitStruct; /* Configure all GPIO as analog to reduce current consumption on non used IOs */ /* Enable GPIOs clock */ __HAL_RCC_GPIOA_CLK_ENABLE(); __HAL_RCC_GPIOB_CLK_ENABLE(); __HAL_RCC_GPIOC_CLK_ENABLE(); __HAL_RCC_GPIOD_CLK_ENABLE(); __HAL_RCC_GPIOE_CLK_ENABLE(); __HAL_RCC_GPIOF_CLK_ENABLE(); __HAL_RCC_GPIOG_CLK_ENABLE(); __HAL_RCC_GPIOH_CLK_ENABLE(); __HAL_RCC_GPIOI_CLK_ENABLE(); GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pin = GPIO_PIN_All; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); HAL_GPIO_Init(GPIOI, &GPIO_InitStruct); HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); /* Disable GPIOs clock */ __HAL_RCC_GPIOA_CLK_DISABLE(); __HAL_RCC_GPIOB_CLK_DISABLE(); __HAL_RCC_GPIOC_CLK_DISABLE(); __HAL_RCC_GPIOD_CLK_DISABLE(); __HAL_RCC_GPIOE_CLK_DISABLE(); __HAL_RCC_GPIOF_CLK_DISABLE(); __HAL_RCC_GPIOG_CLK_DISABLE(); __HAL_RCC_GPIOH_CLK_DISABLE(); __HAL_RCC_GPIOI_CLK_DISABLE(); RTCHandle.Instance = RTC; /* Configure RTC prescaler and RTC data registers as follow: - Hour Format = Format 24 - Asynch Prediv = Value according to source clock - Synch Prediv = Value according to source clock - OutPut = Output Disable - OutPutPolarity = High Polarity - OutPutType = Open Drain */ RTCHandle.Init.HourFormat = RTC_HOURFORMAT_24; RTCHandle.Init.AsynchPrediv = RTC_ASYNCH_PREDIV; RTCHandle.Init.SynchPrediv = RTC_SYNCH_PREDIV; RTCHandle.Init.OutPut = RTC_OUTPUT_DISABLE; RTCHandle.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH; RTCHandle.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN; if(HAL_RTC_Init(&RTCHandle) != HAL_OK) { /* Initialization Error */ Error_Handler(); } /*## Configure the Wake up timer ###########################################*/ /* RTC Wakeup Interrupt Generation: Wakeup Time Base = (RTC_WAKEUPCLOCK_RTCCLK_DIV /(LSI)) Wakeup Time = Wakeup Time Base * WakeUpCounter = (RTC_WAKEUPCLOCK_RTCCLK_DIV /(LSI)) * WakeUpCounter ==> WakeUpCounter = Wakeup Time / Wakeup Time Base To configure the wake up timer to 20s the WakeUpCounter is set to 0xA017: RTC_WAKEUPCLOCK_RTCCLK_DIV = RTCCLK_Div16 = 16 Wakeup Time Base = 16 /(~32.768KHz) = ~0,488 ms Wakeup Time = ~20s = 0,488ms * WakeUpCounter ==> WakeUpCounter = ~20s/0,488ms = 40983 = 0xA017 */ HAL_RTCEx_SetWakeUpTimer_IT(&RTCHandle, 0xA017, RTC_WAKEUPCLOCK_RTCCLK_DIV16); /* FLASH Deep Power Down Mode enabled */ HAL_PWREx_EnableFlashPowerDown(); /* Enter Stop Mode */ HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); /* Configures system clock after wake-up from STOP: enable HSE, PLL and select PLL as system clock source (HSE and PLL are disabled in STOP mode) */ SYSCLKConfig_STOP();//.........这里部分代码省略.........
开发者ID:RadMie,项目名称:STM32F7DiscoveryBase,代码行数:101,
示例25: main/*** @brief Main program* @param None* @retval None*/int main(void){ /* STM32F4xx HAL library initialization: - Configure the Flash prefetch, instruction and Data caches - Configure the Systick to generate an interrupt each 1 msec - Set NVIC Group Priority to 4 - Global MSP (MCU Support Package) initialization */ HAL_Init(); /* Configure LED1, LED2, LED3 and LED4 */ BSP_LED_Init(LED1); BSP_LED_Init(LED2); BSP_LED_Init(LED3); BSP_LED_Init(LED4); /* Configure the system clock to 168 MHz */ SystemClock_Config(); /* Configure Key Button (EXTI_Line15) will be used to wakeup the system from STOP mode */ BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_EXTI); /*## Configure the RTC peripheral #######################################*/ RTCHandle.Instance = RTC; /* Configure RTC prescaler and RTC data registers as follow: - Hour Format = Format 24 - Asynch Prediv = Value according to source clock - Synch Prediv = Value according to source clock - OutPut = Output Disable - OutPutPolarity = High Polarity - OutPutType = Open Drain */ RTCHandle.Init.HourFormat = RTC_HOURFORMAT_24; RTCHandle.Init.AsynchPrediv = RTC_ASYNCH_PREDIV; RTCHandle.Init.SynchPrediv = RTC_SYNCH_PREDIV; RTCHandle.Init.OutPut = RTC_OUTPUT_DISABLE; RTCHandle.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH; RTCHandle.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN; if(HAL_RTC_Init(&RTCHandle) != HAL_OK) { /* Initialization Error */ Error_Handler(); } /* Infinite loop */ while (1) { /* Insert 5 second delay */ HAL_Delay(5000); /*## Configure the Wake up timer ###########################################*/ /* RTC Wakeup Interrupt Generation: Wakeup Time Base = (RTC_WAKEUPCLOCK_RTCCLK_DIV /(LSE or LSI)) Wakeup Time = Wakeup Time Base * WakeUpCounter = (RTC_WAKEUPCLOCK_RTCCLK_DIV /(LSE or LSI)) * WakeUpCounter ==> WakeUpCounter = Wakeup Time / Wakeup Time Base To configure the wake up timer to 4s the WakeUpCounter is set to 0x1FFF: RTC_WAKEUPCLOCK_RTCCLK_DIV = RTCCLK_Div16 = 16 Wakeup Time Base = 16 /(~32.768KHz) = ~0,488 ms Wakeup Time = ~4s = 0,488ms * WakeUpCounter ==> WakeUpCounter = ~4s/0,488ms = 8191 = 0x1FFF */ HAL_RTCEx_SetWakeUpTimer_IT(&RTCHandle, 0x1FFF, RTC_WAKEUPCLOCK_RTCCLK_DIV16); /* Turn OFF LED's */ BSP_LED_Off(LED1); BSP_LED_Off(LED2); BSP_LED_Off(LED3); BSP_LED_Off(LED4); /* Enter Stop Mode */ HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); /* Disable Wakeup Counter */ HAL_RTCEx_DeactivateWakeUpTimer(&RTCHandle); /* Configures system clock after wake-up from STOP: enable HSE, PLL and select PLL as system clock source (HSE and PLL are disabled in STOP mode) */ SYSCLKConfig_STOP(); }}
开发者ID:pierreroth64,项目名称:STM32Cube_FW_F4,代码行数:85,
示例26: main/** * @brief Main program * @param None * @retval None */int main(void){ /* STM32L0xx HAL library initialization: - Configure the Flash prefetch - Configure the Systick to generate an interrupt each 1 msec - Low Level Initialization */ HAL_Init(); /* Configure LED3 */ BSP_LED_Init(LED3); BSP_LED_Init(LED4); /* Configure the system clock to 32 MHz */ SystemClock_Config(); /*##-1- Configure the LPUART peripheral ####################################*/ /* Put the USART peripheral in the Asynchronous mode (UART Mode) */ /* LPUART configured as follows: - Word Length = 8 Bits - Stop Bit = One Stop bit - Parity = None - BaudRate = 9600 baud - Hardware flow control disabled (RTS and CTS signals) */ UartHandle.Instance = USARTx; HAL_UART_DeInit(&UartHandle); UartHandle.Init.BaudRate = 9600; UartHandle.Init.WordLength = UART_WORDLENGTH_8B; UartHandle.Init.StopBits = UART_STOPBITS_1; UartHandle.Init.Parity = UART_PARITY_NONE; UartHandle.Init.HwFlowCtl = UART_HWCONTROL_NONE; UartHandle.Init.Mode = UART_MODE_TX_RX; UartHandle.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT; if(HAL_UART_Init(&UartHandle) != HAL_OK) { Error_Handler(); }#ifdef BOARD_IN_STOP_MODE BSP_LED_On(LED3); /* wait for two seconds before test start */ HAL_Delay(2000); /* make sure that no LPUART transfer is on-going */ while(__HAL_UART_GET_FLAG(&UartHandle, USART_ISR_BUSY) == SET); /* make sure that UART is ready to receive * (test carried out again later in HAL_UARTEx_StopModeWakeUpSourceConfig) */ while(__HAL_UART_GET_FLAG(&UartHandle, USART_ISR_REACK) == RESET); /* set the wake-up event: * specify wake-up on RXNE flag */ WakeUpSelection.WakeUpEvent = UART_WAKEUP_ON_READDATA_NONEMPTY; if (HAL_UARTEx_StopModeWakeUpSourceConfig(&UartHandle, WakeUpSelection)!= HAL_OK) { Error_Handler(); } /* Enable the LPUART Wake UP from stop mode Interrupt */ __HAL_UART_ENABLE_IT(&UartHandle, UART_IT_WUF); /* about to enter stop mode: switch off LED */ BSP_LED_Off(LED3); /* enable MCU wake-up by LPUART */ HAL_UARTEx_EnableStopMode(&UartHandle); /* enter stop mode */ HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); /* ... STOP mode ... */ SystemClock_Config_fromSTOP(); /* at that point, MCU has been awoken: the LED has been turned back on */ /* Wake Up based on RXNE flag successful */ HAL_UARTEx_DisableStopMode(&UartHandle); /* wait for some delay */ HAL_Delay(100); /* Inform other board that wake up is successful */ if (HAL_UART_Transmit(&UartHandle, (uint8_t*)aTxBuffer1, COUNTOF(aTxBuffer1)-1, 5000)!= HAL_OK) { Error_Handler(); } /*##-2- Wake Up second step ###############################################*/ /* make sure that no UART transfer is on-going */ BSP_LED_On(LED3); /* wait for two seconds before test start */ HAL_Delay(2000); while(__HAL_UART_GET_FLAG(&UartHandle, USART_ISR_BUSY) == SET); /* make sure that LPUART is ready to receive //.........这里部分代码省略.........
开发者ID:shjere,项目名称:common,代码行数:101,
示例27: MCU_Enter_StopMode/*** @brief This routine puts the MCU in stop mode* @param None* @retval None*/void MCU_Enter_StopMode(void){ HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); /* Infinite loop */}
开发者ID:adibacco,项目名称:stm32nucleo-spirit1-lib,代码行数:9,
示例28: main//.........这里部分代码省略......... /* Wait for USER Button press before starting the Communication */ while (BSP_PB_GetState(BUTTON_USER) != GPIO_PIN_RESET) { } /* Wait for USER Button release before starting the Communication */ while (BSP_PB_GetState(BUTTON_USER) != GPIO_PIN_SET) { } /*##-4- Put I2C peripheral in reception process ###########################*/ while(HAL_I2C_Master_Receive_IT(&I2cHandle, (uint16_t)I2C_ADDRESS, (uint8_t *)aRxBuffer, RXBUFFERSIZE) != HAL_OK) { /* Error_Handler() function is called when Timout error occurs. When Acknowledge failure ocucurs (Slave don't acknowledge it's address) Master restarts communication */ if (HAL_I2C_GetError(&I2cHandle) != HAL_I2C_ERROR_AF) { Error_Handler(); } }#else /*##-2- Enable I2C peripheral in wake up from stop mode ###################*/ HAL_I2CEx_EnableWakeUp(&I2cHandle); /*##-3- Put I2C peripheral in reception process ###########################*/ if(HAL_I2C_Slave_Receive_IT(&I2cHandle, (uint8_t *)aRxBuffer, RXBUFFERSIZE) != HAL_OK) { /* Transfer error in transmission process */ Error_Handler(); } /* enter stop mode */ /* Turn LED9 on */ BSP_LED_On(LED9); HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); /* ... STOP mode ... */ /* Wake Up from Stop mode */ /* Turn LED9 off */ BSP_LED_Off(LED9); /*##-4- Wait for the end of the transfer ###################################*/ /* Before starting a new communication transfer, you need to check the current state of the peripheral; if it’s busy you need to wait for the end of current transfer before starting a new one. For simplicity reasons, this example is just waiting till the end of the transfer, but application may perform other tasks while transfer operation is ongoing. */ while (HAL_I2C_GetState(&I2cHandle) != HAL_I2C_STATE_READY) { } /*##-5- Start the transmission process #####################################*/ /* While the I2C in reception process, user can transmit data through "aTxBuffer" buffer */ if(HAL_I2C_Slave_Transmit_IT(&I2cHandle, (uint8_t*)aTxBuffer, TXBUFFERSIZE)!= HAL_OK) { /* Transfer error in transmission process */ Error_Handler(); } /* enter stop mode */ /* Turn LED9 on */ BSP_LED_On(LED9); HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); /* ... STOP mode ... */ /* Wake Up from Stop mode */ /* Turn LED9 off */ BSP_LED_Off(LED9);#endif /* MASTER_BOARD */ /*##-6- Wait for the end of the transfer ###################################*/ /* Before starting a new communication transfer, you need to check the current state of the peripheral; if it’s busy you need to wait for the end of current transfer before starting a new one. For simplicity reasons, this example is just waiting till the end of the transfer, but application may perform other tasks while transfer operation is ongoing. */ while (HAL_I2C_GetState(&I2cHandle) != HAL_I2C_STATE_READY) { } /*##-7- Compare the sent and received buffers ##############################*/ if(Buffercmp((uint8_t*)aTxBuffer,(uint8_t*)aRxBuffer,RXBUFFERSIZE)) { /* Processing Error */ Error_Handler(); } /* Infinite loop */ while (1) { }}
开发者ID:GreyCardinalRus,项目名称:stm32-cube,代码行数:101,
示例29: main/** * @brief Main program * @param None * @retval None */int main(void){ /* STM32F4xx HAL library initialization: - Configure the Flash prefetch, instruction and Data caches - Configure the Systick to generate an interrupt each 1 msec - Set NVIC Group Priority to 4 - Global MSP (MCU Support Package) initialization */ HAL_Init(); /* Configure the system clock to 180 MHz */ SystemClock_Config(); /* Configure LED1, LED2, LED3 and LED4 */ BSP_LED_Init(LED1); BSP_LED_Init(LED2); BSP_LED_Init(LED3); BSP_LED_Init(LED4); /* WAKEUP button (EXTI_Line0) will be used to wakeup the system from STOP mode */ BSP_PB_Init(BUTTON_WAKEUP, BUTTON_MODE_EXTI); /* Configure Key Button */ BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_GPIO); /*##-1- Configure the SDRAM device #########################################*/ /* SDRAM device configuration */ BSP_SDRAM_Init(); /*##-2- SDRAM memory write access ##########################################*/ /* Fill the buffer to write */ Fill_Buffer(aTxBuffer, BUFFER_SIZE, 0xA244250F); /* Write data to the SDRAM memory */ BSP_SDRAM_WriteData(SDRAM_DEVICE_ADDR + WRITE_READ_ADDR, aTxBuffer, BUFFER_SIZE); /* Wait for TAMPER/KEY to be pushed to enter stop mode */ while(BSP_PB_GetState(BUTTON_TAMPER) != RESET) { } /*##-3- Issue self-refresh command to SDRAM device #########################*/ SDRAMCommandStructure.CommandMode = FMC_SDRAM_CMD_SELFREFRESH_MODE; SDRAMCommandStructure.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1; SDRAMCommandStructure.AutoRefreshNumber = 1; SDRAMCommandStructure.ModeRegisterDefinition = 0; if(BSP_SDRAM_Sendcmd(&SDRAMCommandStructure) != HAL_OK) { /* Command send Error */ Error_Handler(); } /*##-4- Enter CPU power stop mode ##########################################*/ /* Put LED4 on to indicate entering to STOP mode */ BSP_LED_On(LED4); /* Request to enter STOP mode */ HAL_PWR_EnterSTOPMode(PWR_MAINREGULATOR_ON, PWR_STOPENTRY_WFI); /*##-5- Wakeup CPU from power stop mode ###################################*/ /* Configure the system clock after wakeup from STOP: enable HSE, PLL and select PLL as system clock source (HSE and PLL are disabled in STOP mode) */ SystemClock_Config(); /*##-6- SDRAM memory read back access ######################################*/ SDRAMCommandStructure.CommandMode = FMC_SDRAM_CMD_NORMAL_MODE; if(BSP_SDRAM_Sendcmd(&SDRAMCommandStructure) != HAL_OK) { /* Command send Error */ Error_Handler(); } /* Read back data from the SDRAM memory */ BSP_SDRAM_ReadData(SDRAM_DEVICE_ADDR + WRITE_READ_ADDR, aRxBuffer, BUFFER_SIZE); /*##-7- Checking data integrity ############################################*/ uwWriteReadStatus = Buffercmp(aTxBuffer, aRxBuffer, BUFFER_SIZE); if (uwWriteReadStatus != PASSED) { /* KO */ /* Turn on LED2 */ BSP_LED_On(LED2); } else { /* OK */ /* Turn on LED1 */ BSP_LED_On(LED1); } /* Infinite loop */ while (1)//.........这里部分代码省略.........
开发者ID:eemei,项目名称:library-stm32f4,代码行数:101,
示例30: StopRTCMode_Measure/** * @brief This function configures the system to enter Stop mode with RTC * clocked by LSE or LSI for current consumption measurement purpose. * STOP Mode with RTC clocked by LSE/LSI * ===================================== * - RTC Clocked by LSE or LSI * - Regulator in LP mode * - HSI, HSE OFF and LSI OFF if not used as RTC Clock source * - No IWDG * - Automatic Wakeup using RTC clocked by LSE/LSI (~20s) * @param None * @retval None */void StopRTCMode_Measure(void){ GPIO_InitTypeDef GPIO_InitStruct; /* Configure all GPIO as analog to reduce current consumption on non used IOs */ /* Enable GPIOs clock */ /* Warning : Reconfiguring all GPIO will close the connexion with the debugger */ __HAL_RCC_GPIOA_CLK_ENABLE(); __HAL_RCC_GPIOB_CLK_ENABLE(); __HAL_RCC_GPIOC_CLK_ENABLE(); __HAL_RCC_GPIOD_CLK_ENABLE(); __HAL_RCC_GPIOF_CLK_ENABLE(); GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pin = GPIO_PIN_All; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); /* Disable GPIOs clock */ __HAL_RCC_GPIOA_CLK_DISABLE(); __HAL_RCC_GPIOB_CLK_DISABLE(); __HAL_RCC_GPIOC_CLK_DISABLE(); __HAL_RCC_GPIOD_CLK_DISABLE(); __HAL_RCC_GPIOF_CLK_DISABLE(); RTCHandle.Instance = RTC; /* Configure RTC prescaler and RTC data registers as follows: - Hour Format = Format 24 - Asynch Prediv = Value according to source clock - Synch Prediv = Value according to source clock - OutPut = Output Disable - OutPutPolarity = High Polarity - OutPutType = Open Drain */ RTCHandle.Init.HourFormat = RTC_HOURFORMAT_24; RTCHandle.Init.AsynchPrediv = RTC_ASYNCH_PREDIV; RTCHandle.Init.SynchPrediv = RTC_SYNCH_PREDIV; RTCHandle.Init.OutPut = RTC_OUTPUT_DISABLE; RTCHandle.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH; RTCHandle.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN; if (HAL_RTC_Init(&RTCHandle) != HAL_OK) { /* Initialization Error */ Error_Handler(); } /*## Configure the Wake up timer ###########################################*/ /* RTC Wakeup Interrupt Generation: Wakeup Time Base = (RTC_WAKEUPCLOCK_RTCCLK_DIV /(LSE or LSI)) Wakeup Time = Wakeup Time Base * WakeUpCounter = (RTC_WAKEUPCLOCK_RTCCLK_DIV /(LSE or LSI)) * WakeUpCounter ==> WakeUpCounter = Wakeup Time / Wakeup Time Base To configure the wake up timer to 20s the WakeUpCounter is set to 0xA017: RTC_WAKEUPCLOCK_RTCCLK_DIV = RTCCLK_Div16 = 16 Wakeup Time Base = 16 /(~32.768KHz) = ~0,488 ms Wakeup Time = ~20s = 0,488ms * WakeUpCounter ==> WakeUpCounter = ~20s/0,488ms = 40983 = 0xA017 */ /* Disable Wake-up timer */ HAL_RTCEx_DeactivateWakeUpTimer(&RTCHandle); HAL_RTCEx_SetWakeUpTimer_IT(&RTCHandle, 0xA017, RTC_WAKEUPCLOCK_RTCCLK_DIV16); /* Configure User push-button as external interrupt generator */ BSP_PB_Init(BUTTON_USER, BUTTON_MODE_EXTI); /* Enter Stop Mode */ HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); /* Configures system clock after wake-up from STOP: enable HSI and PLL with HSI as source*/ SystemClock_Config(); /* Disable Wake-up timer */ HAL_RTCEx_DeactivateWakeUpTimer(&RTCHandle);}
开发者ID:NjordCZ,项目名称:stm32cubef0,代码行数:98,
注:本文中的HAL_PWR_EnterSTOPMode函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ HAL_RCC_GetClockConfig函数代码示例 C++ HAL_PWR_EnableBkUpAccess函数代码示例 |