CY_ISR(isr_Button)
{
CyDelay(200u);
state = 1u;
Pin_ClearInterrupt();
}
CY_ISR(isr_Timer)
{
SecondFlag=1;
Second++;
if(Second>59)
{
Second=0;
Minute++;
if(Minute>59)
{
Minute=0;
Hour++;
if(Hour>23)
{
Hour=0;
Week++;
if(Week>6)
{
Week=0;
}
}
}
}
Timer_ClearInterrupt(Timer_INTR_MASK_TC);
}
void main()
{
volatile uint32 temp = 0u;
/* Enable the global interrupts */
CyGlobalIntEnable;
/* Enable the Interrupt component connected to the Button interrupt */
isr_Button_StartEx(isr_Button);
/* Enable the Interrupt component connected to the Timer interrupt */
isr_Timer_StartEx(isr_Timer);
/* Start the Timer component */
Timer_Start();
/* Start the Segment LCD component */
LCD_Seg_Start();
for(;;)
{
if(0u == state)
{
/* Displaying the timer value */
if(SecondFlag==1)
{
SecondFlag=0;
LCD_Seg_WriteBargraph_2(Week+1u, 0u);
LCD_Seg_Write7SegNumber_0(10000+Hour*100+Minute, 0u, LCD_Seg_NO_LEADING_ZEROES);
LCD_Seg_WritePixel(LCD_Seg_COL, Second%2);
LCD_Seg_Write7SegNumber_1(100+Second, 0u, LCD_Seg_NO_LEADING_ZEROES);
}
}
else
{
if (0u == temp)
{
/* Prepare the Timer component to Sleep mode */
Timer_Sleep();
temp = 1u;
/* Put the chip into Deep Sleep mode */
CySysPmDeepSleep();
}
else
{
/* Restore the Timer component after Sleep */
Timer_Wakeup();
temp = 0u;
state = 0u;
}
}
}
}