Esempio n. 1
0
/**
 * This function will initial board.
 */
void rt_hw_board_init(void)
{
    /* must call first to configure gpio Alternate functions according the hardware design */
    wm_gpio_config();

    wm_sys_clk_config();

#ifdef RT_USING_HEAP
    rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END);
#endif

#ifdef RT_USING_COMPONENTS_INIT
    rt_components_board_init();
#endif

#ifdef RT_USING_CONSOLE
    rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
#endif

#if TLS_CONFIG_HARD_CRYPTO
    tls_crypto_init();
#endif

    NVIC_SystemLPConfig(NVIC_LP_SLEEPDEEP, ENABLE);
    rt_thread_idle_sethook(_idle_hook_callback);
}
Esempio n. 2
0
void Sys_StandbyMode(void)
{
    NVIC_SystemLPConfig(NVIC_LP_SLEEPDEEP,ENABLE);                               //使能SLEEPDEEP位 (SYS->CTRL)
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE);     //使能PWR和BKP外设时钟
    printf("\n\rThe System Goes into StandBy Mode...\n\r");
    PWR_EnterSTANDBYMode();	                                                   //进入待命(STANDBY)模式
}
Esempio n. 3
0
void Sys_Standby(void)
{
	stop_flag=1;
	  
// 	while(1)
// 	{
			NVIC_SystemLPConfig(NVIC_LP_SLEEPDEEP,ENABLE);	   
			RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);	//使能PWR和BKP外设时钟    
			PWR_WakeUpPinCmd(ENABLE);  //使能唤醒管脚功能

			//PWR_EnterSTANDBYMode();	  //进入待命(STANDBY)模式 	
			PWR_EnterSTOPMode(PWR_Regulator_LowPower, PWR_STOPEntry_WFI); 			//在停机模式时,程序停在这个函数中
			//PWR_EnterSTOPMode(PWR_Regulator_ON, PWR_STOPEntry_WFI); 			//在停机模式时,程序停在这个函数中
			
		
			//WFI表示wait for interrupt,WFE表示wait for event
			//如果发生中断唤醒,会先执行中断程序 ,再执行PWR_EnterSTOPMode的下1行代码
			
			//重新初始化
			SystemInit();
			
		  //SoftReset();
			
// 		 	if(Check_WKUP())
// 		 		break;
	
	
// 			if(longpress==0)
// 					break;
//  	}
	
			//重新初始化
			//SystemInit();	
	
}
Esempio n. 4
0
void Sys_Standby(void)
{
	NVIC_SystemLPConfig(NVIC_LP_SLEEPDEEP,ENABLE);	   
	RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);	//使能PWR和BKP外设时钟    
	PWR_WakeUpPinCmd(ENABLE);  //使能唤醒管脚功能

	PWR_EnterSTANDBYMode();	  //进入待命(STANDBY)模式 		 
}
Esempio n. 5
0
CommandExecutor::CommandExecutor(CommandReader& reader,Panel& panel,StatusIndicators& indicators)
  : _reader(reader),
    _commandBuffer(reader.getCommandBuffer()),
    _panel(panel),
    _indicators(indicators ){

  // we want the immediate wake-up low power mode and we'll be calling it from normal
  // code so the sleep-on-exit bit is irrelevant

  NVIC_SystemLPConfig(NVIC_LP_SLEEPDEEP | NVIC_LP_SLEEPONEXIT,DISABLE);
}
Esempio n. 6
0
void StandBy(void)
{
	PushREG(REGA,REG_Shut,0x00,0x00);
	RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE); 
	NVIC_SystemLPConfig(NVIC_LP_SEVONPEND,ENABLE);
	PWR_WakeUpPinCmd(ENABLE);
	PWR_ClearFlag(PWR_FLAG_WU);
	PWR_ClearFlag(PWR_FLAG_SB);
	PWR_EnterSTANDBYMode();
	return;
}
Esempio n. 7
0
/*******************************************************************************
* Function Name  : main
* Description    : Main program
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
int main(void)
{
#ifdef DEBUG
  debug();
#endif
  
  /* Configure the system clocks */
  RCC_Configuration();

  /* Configure GPIOs */
  GPIO_Configuration();

  /* Configures the EXTI Lines */
  EXTI_Configuration();
  
#ifdef  VECT_TAB_RAM  
  /* Set the Vector Table base location at 0x20000000 */ 
  NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0); 
#else  /* VECT_TAB_FLASH  */
  /* Set the Vector Table base location at 0x08000000 */ 
  NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);   
#endif  

  NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);

  NVIC_InitStructure.NVIC_IRQChannel = EXTI15_10_IRQChannel;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);
  
  NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQChannel;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
  NVIC_Init(&NVIC_InitStructure);
 
  while (1)
  {
    if(LowPowerMode == 1)
    {
      LowPowerMode = 0;

      /* Toggle GPIO_LED pin 6 */
      GPIO_WriteBit(GPIO_LED, GPIO_Pin_6, (BitAction)(1 - GPIO_ReadOutputDataBit(GPIO_LED, GPIO_Pin_6)));
      
      #ifdef  WFISLEEPONEXIT
        NVIC_SystemLPConfig(NVIC_LP_SLEEPONEXIT, ENABLE);
      #endif

      #ifdef  WFISLEEPNOW
        NVIC_SystemLPConfig(NVIC_LP_SLEEPONEXIT, DISABLE);
        __WFI();
      #endif

      #ifdef  WFESEVONPEND
        NVIC_SystemLPConfig(NVIC_LP_SEVONPEND, ENABLE);
        /* Boost the execution priority to 0: no further exception can be asserted */
		NVIC_SETPRIMASK();
		#ifdef RTC_Alarm_WFEWakeUp
		  /* Set the RTC Alarm interrupt after 6s */
          RTC_SetAlarm(0xFFFFFFFA);
          /* Wait until last write operation on RTC registers has finished */
          RTC_WaitForLastTask();
          /* Set the Counter to 0xFFFFFFF5 */
          RTC_SetCounter(0xFFFFFFF5);
          /* Wait until last write operation on RTC registers has finished */
          RTC_WaitForLastTask();
		#endif		
        __WFE();
      #endif

      #ifdef  WFESEVONEVENT
       NVIC_SystemLPConfig(NVIC_LP_SEVONPEND, DISABLE);
		#ifdef RTC_Alarm_WFEWakeUp
		  /* Set the RTC Alarm interrupt after 6s */
          RTC_SetAlarm(0xFFFFFFFA);
          /* Wait until last write operation on RTC registers has finished */
          RTC_WaitForLastTask();
          /* Set the Counter to 0xFFFFFFF5 */
          RTC_SetCounter(0xFFFFFFF5);
          /* Wait until last write operation on RTC registers has finished */
          RTC_WaitForLastTask();
		#endif	   
        __WFE();
      #endif
    }

    Delay(0xFFFFF);

	/* Toggle GPIO_LED pin 9 */
    GPIO_WriteBit(GPIO_LED, GPIO_Pin_9, (BitAction)(1 - GPIO_ReadOutputDataBit(GPIO_LED, GPIO_Pin_9)));
  }
}