Esempio n. 1
1
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  uint32_t index = 0;
  RTC_TamperTypeDef  stamperstructure;
  
  /* STM32F4xx HAL library initialization:
       - Configure the Flash prefetch
       - 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
     */
  HAL_Init();


  /* Configure the system clock to 180 MHz */
  SystemClock_Config();

  /* Wait until MFX is ready after reset */
  HAL_Delay(100);
  
  /* Since MFX is used, LED init is done after clock config */
  /* Configure LED1, LED2, LED3 and LED4 */
  BSP_LED_Init(LED1);
  BSP_LED_Init(LED2);
  BSP_LED_Init(LED3);
  BSP_LED_Init(LED4);
  
  /* Configure Tamper push-button button */
  BSP_PB_Init(BUTTON_TAMPER, BUTTON_MODE_GPIO);
  
  /*##-1- Configure the RTC peripheral #######################################*/
  /* Configure RTC prescaler and RTC data registers */
  /* RTC configured 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;
  RtcHandle.Instance            = RTC;
  
  if (HAL_RTC_Init(&RtcHandle) != HAL_OK)
  {
    /* Initialization Error */
    Error_Handler();
  }

  /*##-2- Configure RTC Tamper ###############################################*/
  stamperstructure.Tamper                       = RTC_TAMPER_1;
  stamperstructure.PinSelection                 = RTC_TAMPERPIN_PC13;
  stamperstructure.Trigger                      = RTC_TAMPERTRIGGER_FALLINGEDGE;
  stamperstructure.Filter                       = RTC_TAMPERFILTER_DISABLE;
  stamperstructure.SamplingFrequency            = RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV32768;
  stamperstructure.PrechargeDuration            = RTC_TAMPERPRECHARGEDURATION_1RTCCLK;
  stamperstructure.TamperPullUp                 = RTC_TAMPER_PULLUP_ENABLE;
  stamperstructure.TimeStampOnTamperDetection   = RTC_TIMESTAMPONTAMPERDETECTION_DISABLE;
  
  if (HAL_RTCEx_SetTamper_IT(&RtcHandle, &stamperstructure) != HAL_OK)
  {
    /* Initialization Error */
    Error_Handler();
  }

  /* Clear the Tamper interrupt pending bit */
  __HAL_RTC_TAMPER_CLEAR_FLAG(&RtcHandle,RTC_FLAG_TAMP1F);

  /*##-3- Write Data on the Back Up registers ################################*/
  for (index = 0; index < BACKUP_COUNT; index++)
  {
    HAL_RTCEx_BKUPWrite(&RtcHandle, aBKPDataReg[index], 0xDF59 + (index * 0x5A));
  }

  /*##-4- Check Data is stored on the Back Up registers ######################*/
  for (index = 0; index < BACKUP_COUNT; index++)
  {
    if (HAL_RTCEx_BKUPRead(&RtcHandle, aBKPDataReg[index]) != (0xDF59 + (index * 0x5A)))
    {
      Error_Handler();
    }
  }

  /* Turn LED2 on */
  BSP_LED_On(LED2);

  /*##-5- Wait for the tamper button is pressed ##############################*/
  while (TamperStatus != SET);

  /*##-6- Deactivate the tamper                 ##############################*/
  HAL_RTCEx_DeactivateTamper(&RtcHandle, RTC_TAMPER_1);
    
  /*##-7- Check Data is cleared on the Back Up registers #####################*/
  for (index = 0; index < BACKUP_COUNT; index++)
  {
    if (HAL_RTCEx_BKUPRead(&RtcHandle, aBKPDataReg[index]) != 0x00)
    {
      Error_Handler();
    }
  }

  /* Infinite loop */
  while (1)
  {
    /* Turn LED4 on */
    BSP_LED_Toggle(LED4);

    /* Delay */
    HAL_Delay(100);
  }
}
Esempio n. 2
0
void MX_RTC_BACKUP_Init(void){
	
  RTC_TimeTypeDef sTime;
  RTC_DateTypeDef sDate;
	
	if(HAL_RTCEx_BKUPRead(&hrtc,RTC_BKP_DR1) != TSTWORD){
	HAL_RTCEx_BKUPWrite(&hrtc,RTC_BKP_DR1, TSTWORD);

  sTime.Hours = 22;
  sTime.Minutes = 02;
  sTime.Seconds = 00;
		sTime.

  HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BIN);

	sDate.WeekDay = RTC_WEEKDAY_FRIDAY;
  sDate.Month = RTC_MONTH_APRIL;
  sDate.Date = 23;
  sDate.Year = 16;

  HAL_RTC_SetDate(&hrtc, &sDate, RTC_FORMAT_BIN);
	
		HAL_RTCEx_BKUPWrite(&hrtc, RTC_BKP_DR2,sDate.Month);
		HAL_RTCEx_BKUPWrite(&hrtc, RTC_BKP_DR3,sDate.Date);
		HAL_RTCEx_BKUPWrite(&hrtc, RTC_BKP_DR4,sDate.Year);
} else {
		sDate.Month = HAL_RTCEx_BKUPRead(&hrtc, RTC_BKP_DR2);
		sDate.Date = HAL_RTCEx_BKUPRead(&hrtc, RTC_BKP_DR3);
		sDate.Year = HAL_RTCEx_BKUPRead(&hrtc, RTC_BKP_DR4);
  HAL_RTC_SetDate(&hrtc, &sDate, RTC_FORMAT_BIN);
}
}
Esempio n. 3
0
/**
  * @brief  Configure the RTC peripheral by selecting the clock source.
  * @param  None
  * @retval None
  */
static void RTC_Config(void)
{
  /*##-1- Configure the RTC peripheral #######################################*/
  /* Configure RTC prescaler and RTC data registers */
  /* RTC configured as follow:
      - Asynch Prediv  = Calculated automatically by HAL (based on LSI at 40kHz) */
  RtcHandle.Instance = RTC; 
  RtcHandle.Init.AsynchPrediv = RTC_AUTO_1_SECOND;
  
  if(HAL_RTC_Init(&RtcHandle) != HAL_OK)
  {
    /* Initialization Error */
    Error_Handler(); 
  }
  
  /*##-2- Check if data stored in BackUp register1: Wakeup timer enable #######*/
  /* Read the Back Up Register 1 Data */
  if (HAL_RTCEx_BKUPRead(&RtcHandle, RTC_BKP_DR1) == WAKEUP_TIMER_ENABLE)
  {
    /* if the wakeup timer is enabled then desable it to disable the wakeup timer interrupt */
    if(HAL_RTCEx_DeactivateSecond(&RtcHandle) != HAL_OK)
    {
      /* Initialization Error */
      Error_Handler(); 
    }
  }
  
  /*##-3- Configure the RTC Wakeup peripheral #################################*/
  HAL_RTCEx_SetSecond_IT(&RtcHandle);
  
  /*##-4- Write 'wakeup timer enabled' tag in RTC Backup data Register 1 #######*/
  HAL_RTCEx_BKUPWrite(&RtcHandle, RTC_BKP_DR1, WAKEUP_TIMER_ENABLE);

}
Esempio n. 4
0
/**
  * @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 LED2 */
  BSP_LED_Init(LED2);

  /*##-1- Configure the RTC peripheral #######################################*/
  /* Configure RTC prescaler and RTC data registers */
  /* RTC configured 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.Instance = RTC; 
  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(); 
  }
   
  /*##-2- Check if Data stored in BackUp register1: No Need to reconfigure RTC#*/
  /* Read the BackUp Register 1 Data */
  if(HAL_RTCEx_BKUPRead(&RtcHandle, RTC_BKP_DR1) != 0x32F2)
  {  
    /* Configure RTC Calendar */
    RTC_CalendarConfig();
  }
  
  /* Infinite loop */  
  while (1)
  {
    /*##-3- Display the updated Time and Date ################################*/
    RTC_CalendarShow(aShowTime, aShowDate);
  }
}
Esempio n. 5
0
File: rtc.c Progetto: theapi/solar
/* RTC init function */
void MX_RTC_Init(void)
{
  RTC_TimeTypeDef sTime;
  RTC_DateTypeDef sDate;

    /**Initialize RTC Only 
    */
  hrtc.Instance = RTC;
  hrtc.Init.HourFormat = RTC_HOURFORMAT_24;
  hrtc.Init.AsynchPrediv = 127;
  hrtc.Init.SynchPrediv = 255;
  hrtc.Init.OutPut = RTC_OUTPUT_DISABLE;
  hrtc.Init.OutPutRemap = RTC_OUTPUT_REMAP_NONE;
  hrtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;
  hrtc.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;
  if (HAL_RTC_Init(&hrtc) != HAL_OK)
  {
    _Error_Handler(__FILE__, __LINE__);
  }

    /**Initialize RTC and set the Time and Date 
    */
  if(HAL_RTCEx_BKUPRead(&hrtc, RTC_BKP_DR0) != 0x32F2){
  sTime.Hours = 0x0;
  sTime.Minutes = 0x0;
  sTime.Seconds = 0x0;
  sTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;
  sTime.StoreOperation = RTC_STOREOPERATION_RESET;
  if (HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BCD) != HAL_OK)
  {
    _Error_Handler(__FILE__, __LINE__);
  }

  sDate.WeekDay = RTC_WEEKDAY_MONDAY;
  sDate.Month = RTC_MONTH_JANUARY;
  sDate.Date = 0x1;
  sDate.Year = 0x0;

  if (HAL_RTC_SetDate(&hrtc, &sDate, RTC_FORMAT_BCD) != HAL_OK)
  {
    _Error_Handler(__FILE__, __LINE__);
  }

    HAL_RTCEx_BKUPWrite(&hrtc,RTC_BKP_DR0,0x32F2);
  }
    /**Enable the WakeUp 
    */
  if (HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, 5, RTC_WAKEUPCLOCK_CK_SPRE_16BITS) != HAL_OK)
  {
    _Error_Handler(__FILE__, __LINE__);
  }

}
Esempio n. 6
0
void RTC_Init(void)
{

	/*##-1- Configure the RTC peripheral #######################################*/
	/* Configure RTC prescaler and RTC data registers */
	/* RTC configured 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;
	RtcHandle.Instance = RTC;

	if (HAL_RTC_Init(&RtcHandle) != HAL_OK)
	{
		/* Initialization Error */
			    Error_Handler();
	}

	/*##-2- Check if Data stored in BackUp register0: No Need to reconfigure RTC#*/
	/* Read the Back Up Register 0 Data */
	if (HAL_RTCEx_BKUPRead(&RtcHandle, RTC_BKP_DR0) != 0x32F2)
	{
		/* Configure RTC Calendar */
		RTC_CalendarConfig(____TIMESTAMP____);
	}
	else
	{
		/* Check if the Power On Reset flag is set */
		if (__HAL_RCC_GET_FLAG(RCC_FLAG_PORRST) != RESET)
		{
			/* Turn on LED2: Power on reset occured */
		}
		/* Check if Pin Reset flag is set */
		if (__HAL_RCC_GET_FLAG(RCC_FLAG_PINRST) != RESET)
		{
			/* Turn on LED4: External reset occured */
		}
		/* Clear source Reset Flag */
		__HAL_RCC_CLEAR_RESET_FLAGS();
	}

}
Esempio n. 7
0
static uint8_t rtc_check()
{
	uint8_t hour,min;
	RTC_AlarmTypeDef sAlarm;
	RTC_DateTypeDef sdatestructureget;
  RTC_TimeTypeDef stimestructureget;
	if (HAL_RTCEx_BKUPRead(&hrtc, RTC_BKP_DR1) != 0x32F2)
	{	
		HAL_RTCEx_BKUPWrite(&hrtc, RTC_BKP_DR1, 0x32F2);
		return 0;
	}
	else
	{
		//read time
		HAL_RTC_GetTime(&hrtc, &stimestructureget, RTC_FORMAT_BIN);		
		HAL_RTC_GetDate(&hrtc, &sdatestructureget, RTC_FORMAT_BIN);
		//set alarm
		    /**Enable the Alarm A 
			*/
			hour=stimestructureget.Hours;
			min=stimestructureget.Minutes+1;
			if(min>59)
			{	
				min-=60;
				if(hour==23)
					hour=0;
				else
					hour++;
			}

		sAlarm.AlarmTime.Hours = hour;
		sAlarm.AlarmTime.Minutes = min;
		sAlarm.AlarmTime.Seconds = 1;
		sAlarm.AlarmTime.SubSeconds = 0;
		sAlarm.AlarmTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;
		sAlarm.AlarmTime.StoreOperation = RTC_STOREOPERATION_RESET;
		sAlarm.AlarmMask = RTC_ALARMMASK_DATEWEEKDAY;
		sAlarm.AlarmSubSecondMask = RTC_ALARMSUBSECONDMASK_ALL;
		sAlarm.AlarmDateWeekDaySel = RTC_ALARMDATEWEEKDAYSEL_DATE;
		sAlarm.AlarmDateWeekDay = 1;
		sAlarm.Alarm = RTC_ALARM_A;
		HAL_RTC_SetAlarm_IT(&hrtc, &sAlarm, FORMAT_BIN);

		return 1;
	}

}
Esempio n. 8
0
__task void KEY_Sound (void)
{
   //unsigned int keycount =0;
   //unsigned short BlankLED =0;

  // if(BackLED!=NULL)  os_tmr_kill (BackLED);  

  // BlankLED =  BKP_ReadBackupRegister(BKP_DR34);
     
  // BackLED = os_tmr_create((unsigned int)(BlankLED*100*1.8),1);

   if( HAL_RTCEx_BKUPRead(&RtcHandle, RTC_BKP_DR3)==0)
   {
	    HAL_GPIO_WritePin(GPIOA,GPIO_PIN_7,GPIO_PIN_SET);
	    os_dly_wait (20);
	    HAL_GPIO_WritePin(GPIOA,GPIO_PIN_7,GPIO_PIN_RESET);
   }
   os_tsk_delete_self ();
		 
  
}
Esempio n. 9
0
__task void init (void) {

   os_mut_init(mut_GLCD);
	 
	 os_mut_init(mut_Gclock);
	
   GUI_UC_SetEncodeUTF8();  

  if(HAL_RTCEx_BKUPRead(&RtcHandle, RTC_BKP_DR6) !=1)
	{
		 
		 zhuantskid = os_tsk_create (zhuan1, 0);
	   maintskid  = os_tsk_create (Main_Task, 0);  
     keytskid   = os_tsk_create (phase_KEY, 0);    
	   servertskid = os_tsk_create (Server_Task, 0);  		
	}else
	{
		                                   Time3Disable();																			                              												 
																			 HAL_GPIO_WritePin(GPIOE,GPIO_PIN_3,GPIO_PIN_SET);  
																			 HAL_GPIO_WritePin(GPIOE,GPIO_PIN_2,GPIO_PIN_RESET);  
                                   
                                       HAL_GPIO_WritePin(GPIOG,GPIO_PIN_3,GPIO_PIN_RESET);  
																			 HAL_GPIO_WritePin(GPIOG,GPIO_PIN_2,GPIO_PIN_SET);  
		
	}	
  	
	 
	
	 
	 os_tsk_create (power, 0);  
   
 
  // os_tmr_create(500,2);     

  os_tsk_delete_self ();
}
Esempio n. 10
0
/**
  * @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 LED1, LED2, LED3 and LED4 */
  BSP_LED_Init(LED1);
  BSP_LED_Init(LED2);
  BSP_LED_Init(LED3);
  BSP_LED_Init(LED4);

  /* Turn on LED1 */
  BSP_LED_On(LED1);

  /*##-1- Configure the RTC peripheral #######################################*/
  /* Configure RTC prescaler and RTC data registers */
  /* RTC configured 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.Instance = RTC; 
  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();
  }

  /*##-2- Check if Data stored in BackUp register1: No Need to reconfigure RTC#*/
  /* Read the Back Up Register 1 Data */
  if (HAL_RTCEx_BKUPRead(&RtcHandle, RTC_BKP_DR1) != 0x32F2)
  {
    /* Configure RTC Calendar */
    RTC_CalendarConfig();
  }
  else
  {
    /* Check if the Power On Reset flag is set */
    if (__HAL_RCC_GET_FLAG(RCC_FLAG_PORRST) != RESET)
    {
      /* Turn on LED2: Power on reset occured */
      BSP_LED_On(LED2);
    }
    /* Check if Pin Reset flag is set */
    if (__HAL_RCC_GET_FLAG(RCC_FLAG_PINRST) != RESET)
    {
      /* Turn on LED4: External reset occured */
      BSP_LED_On(LED4);
    }
    /* Clear source Reset Flag */
    __HAL_RCC_CLEAR_RESET_FLAGS();
  }

  /* Infinite loop */
  while (1)
  {
    /*##-3- Display the updated Time and Date ################################*/
    RTC_CalendarShow(aShowTime, aShowDate);
  }
}
uint32_t TM_RTC_Init(TM_RTC_ClockSource_t source) {
	uint32_t status;
	TM_RTC_t datatime;
	
	/* Set instance */
	hRTC.Instance = RTC;
	hRTC.Init.AsynchPrediv = RTC_ASYNC_PREDIV;
	hRTC.Init.SynchPrediv = RTC_SYNC_PREDIV;
	hRTC.Init.HourFormat = RTC_HOURFORMAT_24;
	hRTC.Init.OutPut = RTC_OUTPUT_DISABLE;
	hRTC.Init.OutPutType = RTC_OUTPUT_TYPE_PUSHPULL;
	hRTC.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;
	
	/* Enable PWR peripheral clock */
	__HAL_RCC_PWR_CLK_ENABLE();

	/* Allow access to BKP Domain */
	HAL_PWR_EnableBkUpAccess();
	
	/* Get RTC status */
	status = HAL_RTCEx_BKUPRead(&hRTC, RTC_STATUS_REG);
	
	/* Check if RTC already initialized */
	if (status == RTC_STATUS_TIME_OK) {
		/* Start internal clock if we choose internal clock */
		if (source == TM_RTC_ClockSource_Internal) {
			TM_RTC_Config(TM_RTC_ClockSource_Internal);
		}
		
		/* Wait for RTC APB registers synchronisation (needed after start-up from Reset) */
		HAL_RTC_WaitForSynchro(&hRTC);
		
		/* Get date and time */
		TM_RTC_GetDateTime(&datatime, TM_RTC_Format_BIN);
		
		/* Clear reset flags */
		__HAL_RCC_CLEAR_RESET_FLAGS();
		
		/* Return OK */
		return 1;
	} else {
		/* Start RTC clock */
		TM_RTC_Config(source);
		
		/* Set date */
		RTC_DateStruct.Year = 0;
		RTC_DateStruct.Month = 1;
		RTC_DateStruct.Date = 1;
		RTC_DateStruct.WeekDay = RTC_WEEKDAY_TUESDAY;

		/* Set date */
		HAL_RTC_SetDate(&hRTC, &RTC_DateStruct, RTC_FORMAT_BIN);

		/* Set time */
		RTC_TimeStruct.Hours = 0x00;
		RTC_TimeStruct.Minutes = 0x00;
		RTC_TimeStruct.Seconds = 0x00;
		RTC_TimeStruct.TimeFormat = RTC_HOURFORMAT_24;
		RTC_TimeStruct.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;
		RTC_TimeStruct.StoreOperation = RTC_STOREOPERATION_RESET;

		/* Set time */
		HAL_RTC_SetTime(&hRTC, &RTC_TimeStruct, RTC_FORMAT_BCD);
		
		/* Init RTC */
		HAL_RTC_Init(&hRTC);

		/* Save data to backup regiser */
		HAL_RTCEx_BKUPWrite(&hRTC, RTC_STATUS_REG, RTC_STATUS_TIME_OK); 
		
		/* RTC was initialized now */
		return 0;
	}
}
Esempio n. 12
0
/**
  * @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();  
  
  /* Turn on LED1 */
  BSP_LED_On(LED1);


  /*##-1- Configure the RTC peripheral #######################################*/
  RtcHandle.Instance = RTC;

  /* Configure RTC prescaler and RTC data registers */
  /* RTC configured 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(); 
  }
  
  /*##-2- Check if Data stored in BackUp register0: No Need to reconfigure RTC#*/
  /* Read the Back Up Register 0 Data */
  if(HAL_RTCEx_BKUPRead(&RtcHandle, RTC_BKP_DR0) != 0x32F2)
  {  
    /* Configure RTC Calendar */
    RTC_CalendarConfig();
  }
  else
  {
    /* Check if the Power On Reset flag is set */  
    if(__HAL_RCC_GET_FLAG(RCC_FLAG_PORRST) != RESET)
    {
      /* Turn on LED2: Power on reset occurred */
      BSP_LED_On(LED2);
    }
    /* Check if Pin Reset flag is set */
    if(__HAL_RCC_GET_FLAG(RCC_FLAG_PINRST) != RESET)
    {
      /* Turn on LED4: External reset occurred */
      BSP_LED_On(LED4);
    }
    /* Clear source Reset Flag */
    __HAL_RCC_CLEAR_RESET_FLAGS();
  }

  /* Infinite loop */  
  while (1)
  {
    /*##-3- Display the updated Time and Date ################################*/
    RTC_CalendarShow(aShowTime, aShowDate);
  }
}
Esempio n. 13
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  uint32_t index = 0;
  RTC_TamperTypeDef  stamperstructure;
  
  /* STM32F103xG HAL library initialization:
       - Configure the Flash prefetch
       - 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
     */
  HAL_Init();

  /* Configure the system clock to 72 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);

  /* Configure Key push-button button */
  BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_GPIO);
  
  /*##-1- Configure the RTC peripheral #######################################*/
  /* Configure RTC prescaler and RTC data registers */
  /* RTC configured as follow:
      - Asynch Prediv  = Calculated automatically by HAL */
  RtcHandle.Instance            = RTC;
  RtcHandle.Init.AsynchPrediv   = RTC_AUTO_1_SECOND;
  
  if (HAL_RTC_Init(&RtcHandle) != HAL_OK)
  {
    /* Initialization Error */
    Error_Handler();
  }

  /*##-2- Configure RTC Tamper ###############################################*/
  stamperstructure.Tamper                       = RTC_TAMPER_1;
  stamperstructure.Trigger                      = RTC_TAMPERTRIGGER_LOWLEVEL;

  if (HAL_RTCEx_SetTamper_IT(&RtcHandle, &stamperstructure) != HAL_OK)
  {
    /* Initialization Error */
    Error_Handler();
  }

  /* Clear the Tamper interrupt pending bit */
  __HAL_RTC_TAMPER_CLEAR_FLAG(&RtcHandle,RTC_FLAG_TAMP1F);

  /*##-3- Write Data on the Back Up registers ################################*/
  for (index = 0; index < BACKUP_COUNT; index++)
  {
    HAL_RTCEx_BKUPWrite(&RtcHandle, aBKPDataReg[index], 0xDF59 + (index * 0x5A));
  }

  /*##-4- Check Data is stored on the Back Up registers ######################*/
  for (index = 0; index < BACKUP_COUNT; index++)
  {
    if (HAL_RTCEx_BKUPRead(&RtcHandle, aBKPDataReg[index]) != (0xDF59 + (index * 0x5A)))
    {
      Error_Handler();
    }
  }

  /* Turn LED2 on */
  BSP_LED_On(LED2);

  /*##-5- Wait for the tamper button is pressed ##############################*/
  while (TamperStatus != SET);
  

  /*##-6- Deactivate the tamper                 ##############################*/
  HAL_RTCEx_DeactivateTamper(&RtcHandle, RTC_TAMPER_1);
    
  /*##-7- Check Data is cleared on the Back Up registers #####################*/
  for (index = 0; index < BACKUP_COUNT; index++)
  {
    if (HAL_RTCEx_BKUPRead(&RtcHandle, aBKPDataReg[index]) != 0x00)
    {
      Error_Handler();
    }
  }

  /* Infinite loop */
  while (1)
  {
    /* Turn LED4 on */
    BSP_LED_Toggle(LED4);

    /* Delay */
    HAL_Delay(100);
  }
}
Esempio n. 14
0
File: Init.c Progetto: antgrem/Meteo
void RTC_Init(void)
{

  RTC_DateTypeDef DateToUpdate;
	
    HAL_PWR_EnableBkUpAccess();
    /* Enable BKP CLK enable for backup registers */
    __HAL_RCC_BKP_CLK_ENABLE();
    /* Peripheral clock enable */
    __HAL_RCC_RTC_ENABLE();
    /* Peripheral interrupt init */
    HAL_NVIC_SetPriority(RTC_IRQn, 0, 0);
    HAL_NVIC_EnableIRQ(RTC_IRQn);
    HAL_NVIC_SetPriority(RTC_Alarm_IRQn, 0, 0);
    HAL_NVIC_EnableIRQ(RTC_Alarm_IRQn);	
	
    /**Initialize RTC and set the Time and Date 
    */
		hrtc.Instance = RTC;
		hrtc.Init.AsynchPrediv = RTC_AUTO_1_SECOND;
		hrtc.Init.OutPut = RTC_OUTPUTSOURCE_NONE;
		HAL_RTC_Init(&hrtc);

	if (HAL_RTCEx_BKUPRead(&hrtc, 1) != RTC_IS_SET)
		{// check RTC is init or no
			HAL_RTC_GetDate(&hrtc, &DateToUpdate, RTC_FORMAT_BCD);
			
			if (DateToUpdate.Year == 0x0)
			{
					sTime.Hours = 0x20;
					sTime.Minutes = 0x10;
					sTime.Seconds = 0;

					//HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BCD);


					DateToUpdate.WeekDay = RTC_WEEKDAY_THURSDAY;
					DateToUpdate.Month = RTC_MONTH_AUGUST;
					DateToUpdate.Date = 0x11;
					DateToUpdate.Year = 0x16;
					
					//HAL_RTC_SetDate(&hrtc, &DateToUpdate, RTC_FORMAT_BCD);
				
//directly write to counter						
//		if(something == 1)
//		{
//			something = 0;
//			while ((hrtc.Instance->CRL | RTC_CRL_RTOFF) == 0);
//			hrtc.Instance->CRL |= RTC_CRL_CNF;
//			hrtc.Instance->CNTL = 0xD63C;
//			hrtc.Instance->CNTH = 0x57DF;
//			hrtc.Instance->CRL &= ~RTC_CRL_CNF;
//		}


			}
			HAL_RTCEx_BKUPWrite(&hrtc, 1, RTC_IS_SET);
		}
		
		HAL_RTCEx_SetSecond_IT(&hrtc);
	

}
Esempio n. 15
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{ 
  uint32_t index = 0;
  
  /* 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();

  RtcHandle.Instance = RTC;
  
  /*##-1- Configure the RTC peripheral #######################################*/
  /* Configure RTC prescaler and RTC data registers */
  /* RTC configured 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(); 
  }
        
  /* Clear the Tamper Flag */
  __HAL_RTC_TAMPER_CLEAR_FLAG(&RtcHandle,RTC_FLAG_TAMP1F);
  
  /*##-2- Configure RTC Tamper ###############################################*/
  /* Configure RTC Tamper */
  RTC_TamperConfig();
  
  /*##-3- Write Data on the Back Up registers ################################*/
  for(index = 0; index < BACKUP_COUNT; index++)
  {
    HAL_RTCEx_BKUPWrite(&RtcHandle,aBKPDataReg[index], 0xDF59 + (index * 0x5A));
  }
  
  /*##-4- Check Data is stored on the Back Up registers ######################*/
  for(index = 0; index < BACKUP_COUNT; index++)
  {
    if(HAL_RTCEx_BKUPRead(&RtcHandle, aBKPDataReg[index]) != (0xDF59 + (index * 0x5A)))
    {
      Error_Handler();
    }
  }
  
  /* Turn LED2 on */
  BSP_LED_On(LED2);
  
  /*##-5- Wait for the tamper button is pressed ##############################*/
  while(TamperStatus != SET);
  
  /*##-6- Deactivate the tamper ##############################################*/
  HAL_RTCEx_DeactivateTamper(&RtcHandle, RTC_TAMPER_1);
 
  /*##-7- Check Data is cleared on the Back Up registers #####################*/
  for(index = 0; index < BACKUP_COUNT; index++)
  {
    if(HAL_RTCEx_BKUPRead(&RtcHandle, aBKPDataReg[index]) != 0x00)
    {
      Error_Handler();
    }
  }
  
  /* Infinite loop */  
  while (1)
  {
    /* Toggle LED4 */
    BSP_LED_Toggle(LED4);
    
    /* Delay */
    HAL_Delay(100);
  }
}
Esempio n. 16
0
/**
  * @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 have a system clock = 180 Mhz */
  SystemClock_Config();
  
  /* Init the STemWin GUI Library */
 BSP_SDRAM_Init(); /* Initializes the SDRAM device */
 __CRC_CLK_ENABLE(); /* Enable the CRC Module */
	
	
//	__PWR_CLK_ENABLE();
//	HAL_PWR_EnableBkUpAccess();

//	__HAL_RCC_LSE_CONFIG(RCC_LSE_BYPASS);
//	__HAL_RCC_RTC_ENABLE();
	
	/*##-1- Configure the RTC peripheral #######################################*/
  RtcHandle.Instance = RTC;
  
  /* Configure RTC prescaler and RTC data registers */
  /* RTC configured 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(); 
  }
   
  /*##-2- Check if Data stored in BackUp register0: No Need to reconfigure RTC#*/
  /* Read the BackUp Register 0 Data */
  if(HAL_RTCEx_BKUPRead(&RtcHandle, RTC_BKP_DR0) != 0x32F2)
  {  
    /* Configure RTC Calendar */
    RTC_CalendarConfig();
  }
  else
  {
    /* Check if the Power On Reset flag is set */  
    if(__HAL_RCC_GET_FLAG(RCC_FLAG_PORRST) != RESET)
    {
     
    }
    /* Check if Pin Reset flag is set */
    if(__HAL_RCC_GET_FLAG(RCC_FLAG_PINRST) != RESET)
    {
     
    }
    
    /* Clear Reset Flag */
    __HAL_RCC_CLEAR_RESET_FLAGS();
  }
	
  
	
  GUI_Init();  
  //GUI_Initialized = 1;
  GPIO_Config();
	if(HAL_RTCEx_BKUPRead(&RtcHandle, RTC_BKP_DR1) ==0)
	{
		 HAL_RTCEx_BKUPWrite(&RtcHandle,RTC_BKP_DR1,600);  
	}
	Time3Enable(HAL_RTCEx_BKUPRead(&RtcHandle, RTC_BKP_DR1));

  /* Activate the use of memory device feature */
  WM_SetCreateFlags(WM_CF_MEMDEV);
    
 os_sys_init (init); 
  
}
Esempio n. 17
0
__task   void phase_KEY (void)
{
	  static GPIO_InitTypeDef  GPIO_InitStruct;
	  GPIO_PinState bitstatus;
	
	  __GPIOF_CLK_ENABLE();
	  __GPIOA_CLK_ENABLE();
	
	  while(1)
		{		
			  // 1 TOUCH
	      GPIO_InitStruct.Pin = GPIO_PIN_6;
        GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
        GPIO_InitStruct.Pull = GPIO_PULLUP;
        GPIO_InitStruct.Speed = GPIO_SPEED_FAST;  
        HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); 	  
	      bitstatus   =   HAL_GPIO_ReadPin(GPIOF,GPIO_PIN_6);	      
        if(bitstatus==GPIO_PIN_RESET)
				{			
             os_dly_wait (2);
             bitstatus   =   HAL_GPIO_ReadPin(GPIOF,GPIO_PIN_6);
					   if(bitstatus==GPIO_PIN_RESET)
						 {	 
							   do{
							           bitstatus   =   HAL_GPIO_ReadPin(GPIOF,GPIO_PIN_6);
								   }while(bitstatus==GPIO_PIN_RESET); 
								 
							   GUI_StoreKeyMsg(GUI_KEY_ENTER, 1);
                 
	               os_tsk_create (KEY_Sound,0);  	
                 LEDCURRENTTIME =0; // 清除掉关闭背光标识
 								 Time3Enable(HAL_RTCEx_BKUPRead(&RtcHandle, RTC_BKP_DR1));
	 
	           }
	  
	      }
				// 2 TOUCH
	      GPIO_InitStruct.Pin = GPIO_PIN_8;
        GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
        GPIO_InitStruct.Pull = GPIO_PULLUP;
        GPIO_InitStruct.Speed = GPIO_SPEED_FAST;  
        HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); 	  
	      bitstatus   =   HAL_GPIO_ReadPin(GPIOF,GPIO_PIN_8);	      
        if(bitstatus==GPIO_PIN_RESET)
				{			
             os_dly_wait (2);
             bitstatus   =   HAL_GPIO_ReadPin(GPIOF,GPIO_PIN_8);
					   if(bitstatus==GPIO_PIN_RESET)
						 {	 
							   do{
							        bitstatus   =   HAL_GPIO_ReadPin(GPIOF,GPIO_PIN_8);
								   }while(bitstatus==GPIO_PIN_RESET); 
								 
							   GUI_StoreKeyMsg(GUI_KEY_DOWN, 1);
	               os_tsk_create (KEY_Sound,0);  	
                 LEDCURRENTTIME =0; // 清除掉关闭背光标识
 								 Time3Enable(HAL_RTCEx_BKUPRead(&RtcHandle, RTC_BKP_DR1));
	 
	           }
	  
	      }
			// 3 TOUCH
	      GPIO_InitStruct.Pin = GPIO_PIN_0;
        GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
        GPIO_InitStruct.Pull = GPIO_PULLUP;
        GPIO_InitStruct.Speed = GPIO_SPEED_FAST;  
        HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 	  
	      bitstatus   =   HAL_GPIO_ReadPin(GPIOA,GPIO_PIN_0);	      
        if(bitstatus==GPIO_PIN_RESET)
				{			
             os_dly_wait (2);
             bitstatus   =   HAL_GPIO_ReadPin(GPIOA,GPIO_PIN_0);
					   if(bitstatus==GPIO_PIN_RESET)
						 {	 
							   do{
							        bitstatus   =   HAL_GPIO_ReadPin(GPIOA,GPIO_PIN_0);
								   }while(bitstatus==GPIO_PIN_RESET); 
								 
							   GUI_StoreKeyMsg(GUI_KEY_UP, 1);
	               os_tsk_create (KEY_Sound,0);  	
                 LEDCURRENTTIME =0; // 清除掉关闭背光标识
 								 Time3Enable(HAL_RTCEx_BKUPRead(&RtcHandle, RTC_BKP_DR1));
 
	           }
	  
	      }	
		  // 4 TOUCH
	      GPIO_InitStruct.Pin = GPIO_PIN_2;
        GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
        GPIO_InitStruct.Pull = GPIO_PULLUP;
        GPIO_InitStruct.Speed = GPIO_SPEED_FAST;  
        HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); 	  
	      bitstatus   =   HAL_GPIO_ReadPin(GPIOC,GPIO_PIN_2);	      
        if(bitstatus==GPIO_PIN_RESET)
				{			
             os_dly_wait (2);
             bitstatus   =   HAL_GPIO_ReadPin(GPIOC,GPIO_PIN_2);
					   if(bitstatus==GPIO_PIN_RESET)
						 {	 
							   do{
							        bitstatus   =   HAL_GPIO_ReadPin(GPIOC,GPIO_PIN_2);
								   }while(bitstatus==GPIO_PIN_RESET); 
								 
							   GUI_StoreKeyMsg(GUI_KEY_ESCAPE, 1);
	               os_tsk_create (KEY_Sound,0);  	
                 LEDCURRENTTIME =0; // 清除掉关闭背光标识
 								 Time3Enable(HAL_RTCEx_BKUPRead(&RtcHandle, RTC_BKP_DR1));
	 
	           }
	  
	      }			
				
			os_tsk_pass();	
				
	  } 
}	
Esempio n. 18
0
__task void power (void)
 {
   unsigned int count =0;
   unsigned int temp;
	 static GPIO_InitTypeDef  GPIO_InitStruct;
	 GPIO_PinState bitstatus;
  
   while(1)
     {
	      GPIO_InitStruct.Pin = GPIO_PIN_2;
        GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
        GPIO_InitStruct.Pull = GPIO_PULLUP;
        GPIO_InitStruct.Speed = GPIO_SPEED_FAST;  
        HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); 	  
	      bitstatus   =   HAL_GPIO_ReadPin(GPIOC,GPIO_PIN_2);	      
        if(bitstatus==GPIO_PIN_RESET)
				{			
             os_dly_wait (200);
             bitstatus   =   HAL_GPIO_ReadPin(GPIOC,GPIO_PIN_2);
					   if(bitstatus==GPIO_PIN_RESET)
						 {	 
							 
							   if(HAL_RTCEx_BKUPRead(&RtcHandle, RTC_BKP_DR6)==0)
								 {
												count =0;
											 do{
															 bitstatus   =   HAL_GPIO_ReadPin(GPIOC,GPIO_PIN_2);
															 count++;
															 if(count>5000000)
															 {       
																			 Time3Disable();
																			 GUI_Clear();                                 												 
																			 HAL_GPIO_WritePin(GPIOE,GPIO_PIN_3,GPIO_PIN_SET);  
																			 HAL_GPIO_WritePin(GPIOE,GPIO_PIN_2,GPIO_PIN_RESET);  
																			 if(zhuantskid  !=NULL)  os_tsk_delete(zhuantskid);   
																			 if(maintskid   !=NULL)  os_tsk_delete(maintskid);   
																			 if(keytskid    !=NULL)  os_tsk_delete(keytskid);  
																			 if(servertskid !=NULL)  os_tsk_delete(servertskid);  
																			 if(meuntskid !=NULL)  os_tsk_delete(meuntskid);  
																			 if(setsystemtimetskid !=NULL)  os_tsk_delete(setsystemtimetskid);  
																			 if(setledlighttskid !=NULL)  os_tsk_delete(setledlighttskid);  
																			 if(setledtimetskid !=NULL)  os_tsk_delete(setledtimetskid);  
																			 if(setsoundtskid !=NULL)  os_tsk_delete(setsoundtskid);   													 
																			 if(setworkmodetskid !=NULL)  os_tsk_delete(setworkmodetskid);  
																			 if(yushentskid !=NULL)  os_tsk_delete(yushentskid);

                                       HAL_RTCEx_BKUPWrite(&RtcHandle,RTC_BKP_DR6,1);  		// 说明是正常关机状态;

                                       														 
                                       HAL_GPIO_WritePin(GPIOG,GPIO_PIN_3,GPIO_PIN_RESET);  
																			 HAL_GPIO_WritePin(GPIOG,GPIO_PIN_2,GPIO_PIN_SET);  
                                     											 
																	 
															 } 	 
													 
												 }while(bitstatus==GPIO_PIN_RESET); 	
									}else
                  {
                         os_mut_init(mut_GLCD);
	 
												 os_mut_init(mut_Gclock);
												
												 GUI_UC_SetEncodeUTF8();   
												 
												 zhuantskid = os_tsk_create (zhuan1, 0);
												 maintskid  = os_tsk_create (Main_Task, 0);  
												 keytskid   = os_tsk_create (phase_KEY, 0);    
												 servertskid = os_tsk_create (Server_Task, 0);   
                         Time3Enable(HAL_RTCEx_BKUPRead(&RtcHandle, RTC_BKP_DR1));
                        
										     HAL_GPIO_WritePin(GPIOE,GPIO_PIN_3,GPIO_PIN_RESET);  
												 HAL_GPIO_WritePin(GPIOE,GPIO_PIN_2,GPIO_PIN_SET);  
										
                         HAL_RTCEx_BKUPWrite(&RtcHandle,RTC_BKP_DR6,0);  // 清楚掉关机状态 	
                  }										
					
	           }
	  
	      }
     
	    }    
   
 }
Esempio n. 19
0
/**
  * @brief RTC MSP De-Initialization
  *        This function frees the hardware resources used in this application:
  *          - Disable the Peripheral's clock
  * @param hrtc: RTC handle pointer
  * @retval None
  */
uint32_t BACKUP_RestoreParameter(uint32_t address)
{
    return HAL_RTCEx_BKUPRead(&RtcHandle,address);
}
Esempio n. 20
0
uint32_t rtcBackUpGetValue(uint32_t RegNumber)
{
    return HAL_RTCEx_BKUPRead(&RtcHandle, RegNumber);
}