当前位置: 首页>>代码示例>>C++>>正文


C++ HAL_PWR_EnterSTOPMode函数代码示例

本文整理汇总了C++中HAL_PWR_EnterSTOPMode函数的典型用法代码示例。如果您正苦于以下问题:C++ HAL_PWR_EnterSTOPMode函数的具体用法?C++ HAL_PWR_EnterSTOPMode怎么用?C++ HAL_PWR_EnterSTOPMode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了HAL_PWR_EnterSTOPMode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: StopMode

void 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,代码来源:main-ex1.c

示例2: stopmode_entry

void
stopmode_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,代码来源:power_saving.c

示例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,代码来源:lowpower_app.c

示例4: machine_sleep

STATIC 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,代码来源:modmachine.c

示例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,代码来源:lowpower_app.c

示例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,代码来源:main.c

示例7: DEVICE_Handler

void 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,代码来源:handler.c

示例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,代码来源:main.c

示例9: deepsleep

void 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,代码来源:sleep.c

示例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,代码来源:stm32f0xx_lp_modes.c

示例11: MCU_Enter_StopMode

void 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,代码来源:spirit1_appli.c

示例12: deepsleep

void 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,代码来源:sleep.c

示例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,代码来源:main.c

示例14: RtcEnterLowPowerStopMode

void 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,代码来源:rtc_board.c

示例15: deepsleep

void 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,代码来源:sleep.c


注:本文中的HAL_PWR_EnterSTOPMode函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。