41 NODEBUG2
void RTC_Init(
void )
44 RCC_APB1PeriphClockCmd( RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE );
47 PWR_BackupAccessCmd( ENABLE );
50 RCC_LSEConfig( RCC_LSE_ON );
56 #ifndef BUG_RTC_CRYSTAL
58 GPIO_WriteBit( GPIOx_LED, GPIO_Pin_LED0, Bit_RESET );
60 GPIO_WriteBit( GPIOx_LED, GPIO_Pin_LED0, Bit_SET );
63 while ( RCC_GetFlagStatus( RCC_FLAG_LSERDY ) == RESET )
67 GPIO_WriteBit( GPIOx_LED, GPIO_Pin_LED0, Bit_SET );
69 GPIO_WriteBit( GPIOx_LED, GPIO_Pin_LED0, Bit_RESET );
74 RCC_RTCCLKConfig( RCC_RTCCLKSource_LSE );
77 RCC_RTCCLKCmd( ENABLE );
79 #ifndef BUG_RTC_CRYSTAL
81 GPIO_WriteBit( GPIOx_LED, GPIO_Pin_LED1, Bit_RESET );
83 GPIO_WriteBit( GPIOx_LED, GPIO_Pin_LED1, Bit_SET );
90 GPIO_WriteBit( GPIOx_LED, GPIO_Pin_LED1, Bit_SET );
92 GPIO_WriteBit( GPIOx_LED, GPIO_Pin_LED1, Bit_RESET );
97 RTC_WaitForLastTask();
100 RTC_ITConfig( RTC_IT_SEC, ENABLE );
103 RTC_WaitForLastTask();
107 RTC_SetPrescaler( 32767 );
109 #ifndef BUG_RTC_CRYSTAL
111 GPIO_WriteBit( GPIOx_LED, GPIO_Pin_LED1, Bit_RESET );
113 GPIO_WriteBit( GPIOx_LED, GPIO_Pin_LED1, Bit_SET );
117 RTC_WaitForLastTask();
120 GPIO_WriteBit( GPIOx_LED, GPIO_Pin_LED1, Bit_SET );
122 GPIO_WriteBit( GPIOx_LED, GPIO_Pin_LED1, Bit_RESET );
151 Tmp = RTC_GetCounter();
154 *THH = ( Tmp / 3600 ) % 24;
157 *TMM = ( Tmp / 60 ) % 60;
181 RTC_SetCounter( THH * 3600 + TMM * 60 + TSS );
199 static counter_t last_time = 0;
200 counter_t new_time = RTC_GetCounter();
204 if ( last_time != new_time )
206 last_time = new_time ;
208 if ( fDisplayTime == 1 )
214 DRAW_DisplayTemp( 90, 0 );