Esempio n. 1
0
/**
  * @brief  Tamper callback 
  * @param  hrtc: RTC handle
  * @retval None
  */
void HAL_RTCEx_TimeStampEventCallback(RTC_HandleTypeDef *hrtc)
{
  RTC_DateTypeDef sTimeStampDateget;
  RTC_TimeTypeDef sTimeStampget;
  
  /* Toggle LED4 */
  BSP_LED_Toggle(LED4);
  
#ifdef USE_LCD 
  HAL_RTCEx_GetTimeStamp(&RtcHandle, &sTimeStampget, &sTimeStampDateget, RTC_FORMAT_BCD);
  /* Set the Back Color */
  BSP_LCD_SetBackColor(LCD_COLOR_WHITE);
  /* Set the Text Color */
  BSP_LCD_SetTextColor(LCD_COLOR_BLUE);
  BSP_LCD_DisplayStringAtLine(8, (uint8_t *)"TimeStamp Display");
  /* Display Time Stamp */
  RTC_Time_display(9, LCD_COLOR_BLACK , RTC_Get_Time(&sTimeStampget));
#else
    
  HAL_RTCEx_GetTimeStamp(&RtcHandle, &sTimeStampget, &sTimeStampDateget, RTC_FORMAT_BIN);
  /* Display time Format : hh:mm:ss */
  sprintf((char*)aShowTimeStamp,"%0.2d:%0.2d:%0.2d", sTimeStampget.Hours, sTimeStampget.Minutes, sTimeStampget.Seconds);
  /* Display date Format : mm-dd */
  sprintf((char*)aShowDateStamp,"%0.2d-%0.2d-%0.2d", sTimeStampDateget.Month, sTimeStampDateget.Date, 2013); 
#endif /* USE_LCD */
}
Esempio n. 2
0
/**
  * @brief  Displays the current time and date.
  * @param  None
  * @retval None
  */
static void RTC_CalendarShow(void)
{
  RTC_DateTypeDef sdatestructureget;
  RTC_TimeTypeDef stimestructureget;
  
#ifdef USE_LCD   
  /* Get the RTC current Time */
  HAL_RTC_GetTime(&RtcHandle, &stimestructureget, RTC_FORMAT_BCD);
  /* Get the RTC current Date */
  HAL_RTC_GetDate(&RtcHandle, &sdatestructureget, RTC_FORMAT_BCD);
  /* Set the Back Color */
  BSP_LCD_SetBackColor(LCD_COLOR_WHITE);
  /* Set the Text Color */
  BSP_LCD_SetTextColor(LCD_COLOR_BLUE);
  BSP_LCD_DisplayStringAtLine(6, (uint8_t *)"Current Time Display");

  RTC_Time_display(7, LCD_COLOR_BLACK , RTC_Get_Time(&stimestructureget));
#else
  /* Get the RTC current Time */
  HAL_RTC_GetTime(&RtcHandle, &stimestructureget, RTC_FORMAT_BIN);
  /* Get the RTC current Date */
  HAL_RTC_GetDate(&RtcHandle, &sdatestructureget, RTC_FORMAT_BIN);
  /* Display time Format : hh:mm:ss */
  sprintf((char*)aShowTime,"%0.2d:%0.2d:%0.2d", stimestructureget.Hours, stimestructureget.Minutes, stimestructureget.Seconds);
  /* Display date Format : mm-dd-yy */
  sprintf((char*)aShowDate,"%0.2d-%0.2d-%0.2d", sdatestructureget.Month, sdatestructureget.Date, 2000 + sdatestructureget.Year); 
#endif /* USE_LCD */
} 
Esempio n. 3
0
/**
  * @brief  Display the current TimeStamp (time and date) on the Hyperterminal.
  * @param  None
  * @retval None
  */
void RTC_TimeStampShow(void)
{
    /* Get the current TimeStamp */
    RTC_GetTimeStamp(RTC_Format_BCD, &RTC_TimeStampStructure, &RTC_TimeStampDateStructure);

    /* Set the Back Color */
    LCD_SetBackColor(LCD_COLOR_WHITE);

    /* Set the Text Color */
    LCD_SetTextColor(LCD_COLOR_BLUE);
    LCD_DisplayStringLine(LCD_LINE_8, (uint8_t *)"TimeStamp Display");

    /* Display the curent time and the sub second on the LCD */
    LCD_DisplayStringLine(LCD_LINE_9, (uint8_t *) " Time");
    RTC_Time_display(LCD_LINE_9, Black , RTC_Get_Time(uwSecondfraction , &RTC_TimeStampStructure));

    /* Set the Text Color */
    LCD_SetTextColor(LCD_COLOR_BLUE);
    LCD_DisplayStringLine(LCD_LINE_10, (uint8_t *) " Date");
    RTC_Time_display(LCD_LINE_10, Black,  RTC_Get_Date( &RTC_TimeStampDateStructure));
}
/**
  * @brief  Display the current TimeStamp (time and date) on the Hyperterminal.
  * @param  None
  * @retval None
  */
static void RTC_TimeStampShow(void)
{
  RTC_TimeTypeDef  RTC_TimeStampStructure;
  RTC_DateTypeDef  RTC_TimeStampDateStructure;
  /* Get the current TimeStamp */
  RTC_GetTimeStamp(RTC_Format_BCD, &RTC_TimeStampStructure, &RTC_TimeStampDateStructure);

  /* Set the Back Color */
  LCD_SetBackColor(LCD_COLOR_WHITE);
  
  /* Set the Text Color */
  LCD_SetTextColor(LCD_COLOR_BLUE);
  LCD_SetFont(&Font16x24);
  LCD_DisplayStringLine(LCD_LINE_4, (uint8_t *)"TimeStamp Display");
  /* Display the curent time and the sub second on the LCD */
  LCD_DisplayStringLine(LCD_LINE_5, (uint8_t *) "Time");
  RTC_Time_display(LCD_LINE_5, Black , RTC_Get_Time(Secondfraction , &RTC_TimeStampStructure));
  /* Set the Text Color */
  LCD_SetTextColor(LCD_COLOR_BLUE);
  LCD_DisplayStringLine(LCD_LINE_6, (uint8_t *) "Date");
  RTC_Time_display(LCD_LINE_6, Black,  RTC_Get_Date( &RTC_TimeStampDateStructure));
}
Esempio n. 5
0
/**
  * @brief  Display the current time on the Hyperterminal.
  * @param  None
  * @retval None
  */
void RTC_TimeShow(void)
{
    /* Get the current Time and Date */
    RTC_GetTime(RTC_Format_BCD, &RTC_TimeStructure);

    /* Set the Back Color */
    LCD_SetBackColor(LCD_COLOR_WHITE);

    /* Set the Text Color */
    LCD_SetTextColor(LCD_COLOR_BLUE);
    LCD_DisplayStringLine(LCD_LINE_4, (uint8_t *)"Current Time Display");

    /* Display the curent time and the sub second on the LCD */
    RTC_Time_display(LCD_LINE_5, Black , RTC_Get_Time(uwSecondfraction , &RTC_TimeStructure));
}
Esempio n. 6
0
/**
  * @brief  Display the current date on the Hyperterminal.
  * @param  None
  * @retval None
  */
void RTC_DateShow(void)
{
    /* Get the current Date */
    RTC_GetDate(RTC_Format_BCD, &RTC_DateStructure);

    /* Set the Back Color */
    LCD_SetBackColor(LCD_COLOR_WHITE);

    /* Set the Text Color */
    LCD_SetTextColor(LCD_COLOR_BLUE);
    LCD_DisplayStringLine(LCD_LINE_6, (uint8_t *)"Current Date Display");

    /* Set the Text Color */
    LCD_SetTextColor(LCD_COLOR_BLACK);
    RTC_Time_display( LCD_LINE_7, Black,  RTC_Get_Date( &RTC_DateStructure));
}
Esempio n. 7
0
/**
  * @brief  This function handles External lines 15 to 10 interrupt request.
  * @param  None
  * @retval None
  */
void EXTI15_10_IRQHandler(void)
{
  if((EXTI_GetITStatus(TAMPER_BUTTON_EXTI_LINE) != RESET) && (ubStartevent !=0) && (uwBackupindex < 11))
  {
    uint16_t Colorx;
    uint8_t index = 0;
    
    if (uwBackupindex < 10)
    {
      /* Increment counter */
      ubRTCCount++;
      
      /* Set LCD background color*/
      if((uint8_t)(ubRTCCount % 2) != 0)
      { 
        LCD_SetBackColor(Blue2);
        Colorx = White;
      }
      else
      {
        LCD_SetBackColor(Cyan);
        Colorx = Black;
      }
      
      /* Get the Current sub seconds and time */
      ubSSecondfraction = 1000 - ((uint32_t)((uint32_t)RTC_GetSubSecond() * 1000) / (uint32_t)0x3FF);
      RTC_GetTime(RTC_Format_BCD, &RTC_StampTimeStruct);
      
      LCD_SetFont(&Font12x12);
      
      /* Display result on the LCD */
      RTC_Time_display(LINE(7 + uwBackupindex), Colorx, RTC_Get_Time(ubSSecondfraction , &RTC_StampTimeStruct)); 
      
      /* Save time register  to Backup register (the first 10 registers are reserved for time) */
      RTC_WriteBackupRegister(aBKPDataReg[uwBackupindex],(uint32_t)RTC->TR);
      
      /* Save sub second time stamp register (the latest 10 registers are reserved for sub second) */
      RTC_WriteBackupRegister(aBKPDataReg[uwBackupindex + 10], ubSSecondfraction);
    }
    else
    {      
      /* Set the LCD Background Color */
      LCD_SetBackColor(White);
      LCD_SetFont(&Font12x12);
      
      /* Clear all LCD lines from 7 to 19 */
      for (index = 0; index < 13; index++)
      {
        LCD_ClearLine(LINE(7 + index));
      }
      
      /* Reset Counters */
      ubRTCCount = 0;
      uwBackupindex = 0 ;
      
      /* Enter to idle */
      ubStartevent =0;
      
      /* Set the time to 00h 00mn 00s AM */
      RTC_TimeStructure.RTC_H12     = RTC_H12_AM;
      RTC_TimeStructure.RTC_Hours   = 0;
      RTC_TimeStructure.RTC_Minutes = 0;
      RTC_TimeStructure.RTC_Seconds = 0;  
      RTC_SetTime(RTC_Format_BCD, &RTC_TimeStructure);
      
      /* Disable the RTC Clock */
      RCC_RTCCLKCmd(DISABLE);
      LCD_SetFont(&Font16x24);
      
      /* Set the LCD Text Color */
      LCD_SetTextColor(Blue);
      
      /* Display message to the LCD */
      LCD_DisplayStringLine(LINE(5), (uint8_t *)MESSAGE1);
      
      /* Clear EXTI line 21 */
      EXTI_ClearITPendingBit(EXTI_Line21);
      
      /* Clear Tamper pin interrupt pending bit */
      RTC_ClearITPendingBit(RTC_IT_TAMP1);
    }  
    
    uwBackupindex++;
  }
  /* Clear the TAMPER EXTI pending bit */
  EXTI_ClearITPendingBit(TAMPER_BUTTON_EXTI_LINE);     
}
Esempio n. 8
0
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
int main(void)
{

  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       file (startup_stm32f4xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f4xx.c file
     */  
  
  /* Initialize the LCD */
  STM324xG_LCD_Init(); 
  
  /* Clear the LCD */ 
  LCD_Clear(White);

  /* Set the LCD Back Color */
  LCD_SetBackColor(Blue);
  
  /* Set the LCD Text Color */
  LCD_SetTextColor(White);
   
  /* Displays MESSAGE1 on line 1 */
  LCD_DisplayStringLine(LINE(0), (uint8_t *)MESSAGE1);

  /* RTC configuration  */
  RTC_Config();
  
  /* Set the LCD Text Color */
  LCD_SetTextColor(Red);
  
  /* Set the LCD Back Color */
  LCD_SetBackColor(White);
  
  /* Draw rectangle on the LCD */
  LCD_DrawRect(43, 300, 30, 260);

  /* Configure the external interrupt "WAKEUP" and "KEY" buttons */
  STM_EVAL_PBInit(BUTTON_WAKEUP,BUTTON_MODE_EXTI);
  STM_EVAL_PBInit(BUTTON_KEY,BUTTON_MODE_EXTI);
  
  /* Configure the RTC tamper register */
  RTC_TamperConfig();
  
  /* Set the LCD Text Color */
  LCD_SetTextColor(Blue);
  
  /* Displays MESSAGE2 on line 5 */
  LCD_DisplayStringLine(LINE(5), (uint8_t *)MESSAGE2);
  
  /* Infinite loop */
  while (1)
  {
    /* Set The LCD font size */
    LCD_SetFont(&Font16x24);
     
    /* Set the LCD Back Color */
    LCD_SetBackColor(White);

    /* Check on the event 'start'*/
    if(Startevent != 0x0)
    {
       /* Get the RTC sub second fraction */
       Secondfraction = 1000 - ((uint32_t)((uint32_t)RTC_GetSubSecond() * 1000) / (uint32_t)0x3FF);
    }
    else
    {
      /* Idle */
      Secondfraction =0x0;
    }
    
    /* Get the Curent time */
    RTC_GetTime(RTC_Format_BCD, &RTC_TimeStruct);
    
    /* Display the curent time and the sub second on the LCD */
    RTC_Time_display(Line2, Black , RTC_Get_Time(Secondfraction , &RTC_TimeStruct));
  }
}