Advertisement
Guest User

Untitled

a guest
Feb 28th, 2020
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.14 KB | None | 0 0
  1. void zmain(void)
  2. {
  3.     RTC_Start(); // start real time clock
  4.    
  5.     RTC_TIME_DATE now;
  6.    
  7.     // set current time
  8.     int hours = 0;
  9.     int minutes = 0;
  10.    
  11.     printf("Hours: ");
  12.     scanf("%d", &hours);
  13.     now.Hour = hours;
  14.    
  15.     printf("\nMinutes: ");
  16.     scanf("%d", &minutes);
  17.     now.Min = minutes;
  18.    
  19.     now.Sec = 0;
  20.     now.DayOfMonth = 0;
  21.     now.Month = 0;
  22.     now.Year = 2020;
  23.     RTC_WriteTime(&now); // write the time to real time clock
  24.    
  25.    
  26.     for(;;)
  27.     {
  28.         if(SW1_Read() == 0) {
  29.             // read the current time
  30.             RTC_DisableInt(); /* Disable Interrupt of RTC Component */
  31.             now = *RTC_ReadTime(); /* copy the current time to a local variable */
  32.             RTC_EnableInt(); /* Enable Interrupt of RTC Component */
  33.  
  34.             // print the current time
  35.             printf("%2d:%02d.%02d\n", now.Hour, now.Min, now.Sec);
  36.             print_mqtt("Zumo018/time:, %2d:%02d.", now.Hour, now.Min);
  37.            
  38.             // wait until button is released
  39.             while(SW1_Read() == 0) vTaskDelay(50);
  40.         }
  41.        
  42.         vTaskDelay(50);
  43.     }
  44. }
  45.  
  46. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement