Esempio n. 1
0
void CLCD_Configuration(void) {
  GPIO_InitTypeDef GPIO_InitStructure;
  
  /* RCC Configuration -----------------------------------------------------------*/
  /* Enable CLCD pin */
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE, ENABLE);
  
  /* GPIO Configuration ------------------------------------------------------*/
  /* RS, RW, E pin configuration */  
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD;
  GPIO_Init(GPIOD, &GPIO_InitStructure);
  
  /* DB0, DB1, DB2, DB3, DB4, DB5, DB6, DB7 pin configuration */
  GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | 
                                 GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD;
  GPIO_Init(GPIOE, &GPIO_InitStructure);
  
  /* CLCD initialization */
  delay_ms(30); // wait before CLCD to be activated
  CLCD_FunctionSet();       delay_us(50);
  CLCD_OnOFF(HIGH);         delay_us(50);
  CLCD_Clear();             delay_ms(2);
  CLCD_EntryMode();         delay_ms(1);
  CLCD_Write(0, 0, "- IDSP PROJECT -");
  CLCD_Write(0, 1, "- LOADING SYS. -");
}
Esempio n. 2
0
void CLCD_Configuration(void) {
  GPIO_InitTypeDef GPIO_InitStructure;
  
  /* Pin Configuration -----------------------------------------------------------*/
  /* CLCD Pinmap
   * 1. VSS - GND       6. E - PE4          11. DB4 - PE11
   * 2. VDD - 3.3V      7. DB0 - PE5        12. DB5 - PE12
   * 3. V0 - GND        8. DB1 - PE6        13. DB6 - PE13
   * 4. RS - PE2        9. DB2 - PC6        14. DB7 - PE14
   * 5. R/W - PE3       10. DB3 - PC7
  */
  
  /* RCC Configuration -----------------------------------------------------------*/
  /* Enable CLCD pin */
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOE, ENABLE);
  
  /* GPIO Configuration ------------------------------------------------------*/
  /* RS, RW, E, DB0, DB1 pin configuration */  
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | 
                                GPIO_Pin_5 | GPIO_Pin_6;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  GPIO_Init(GPIOE, &GPIO_InitStructure);
  
  /* DB2, DB3 pin configuration */  
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  GPIO_Init(GPIOC, &GPIO_InitStructure);
  
  /* DB4, DB5, DB6, DB7 pin configuration */
  GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  GPIO_Init(GPIOE, &GPIO_InitStructure);
  
  /* CLCD initialization */
  delay_ms(30); // wait before CLCD to be activated
  CLCD_FunctionSet();       delay_us(50);
  CLCD_OnOFF(HIGH);         delay_us(50);
  CLCD_Clear();             delay_ms(2);
  CLCD_EntryMode();         delay_ms(1);
  //CLCD_Write(0, 0, "- IDSP PROJECT -");
  //CLCD_Write(0, 1, "- LOADING SYS. -");
  CLCD_Write(0, 0, "0000000000000000");
  CLCD_Write(0, 1, "0000000000000000");
}
Esempio n. 3
0
/**
  * @brief  Displays the current time.
  * @param  TimeVar: RTC counter value.
  * @retval None
  */
void Time_Display(uint32_t TimeVar) { 
  /* Reset RTC Counter when Time is 23:59:59 */
  if (RTC_GetCounter() == 0x0001517F) {
    RTC_SetCounter(0x0);
    IncreaseSingleDay();
    /* Wait until last write operation on RTC registers has finished */
    RTC_WaitForLastTask();
    
    /* Backup routine*/
    int YY, MD;
    YY = GetYearAndMergeToInt();
    MD = GetMonthAndMergeToInt() * 100 + GetDayAndMergeToInt();
    
    printf("\r\n\n Automatic Backup routine excuted");
    
    BKP_WriteBackupRegister(BKP_DR2, YY);
    BKP_WriteBackupRegister(BKP_DR3, MD);
    
    printf("\r\n Calendar data successfully saved to backup register BKP_DR2, 3");
  }
  
  /* get calendar */
  TYR = GetYearAndMergeToInt();
  TMO = GetMonthAndMergeToInt();
  TDD = GetDayAndMergeToInt();
  
  /* Compute  hours */
  THH = TimeVar / 3600;
  /* Compute minutes */
  TMM = (TimeVar % 3600) / 60;
  /* Compute seconds */
  TSS = (TimeVar % 3600) % 60;
  
  int mTHH, mTMM, mTSS;
  mTHH = THH; mTMM = TMM; mTSS = TSS;

  sprintf(DATE, "DATE: %04d.%02d.%02d", TYR, TMO, TDD);
  sprintf(TIME, "TIME:   %02d:%02d:%02d", mTHH, mTMM, mTSS);
  
  /* Display through CLCD */
  CLCD_Write(0, 0, DATE);
  CLCD_Write(0, 1, TIME);
}