clock_main.c 966 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * SPDX-FileCopyrightText: 2022 Helmut Pozimski <helmut@pozimski.eu>
  3. *
  4. * SPDX-License-Identifier: GPL-2.0-only
  5. */
  6. #include <stdio.h>
  7. #include "ds3231.h"
  8. #include "freertos/FreeRTOS.h"
  9. #include "freertos/task.h"
  10. #define DS3231_SDA_PIN 4
  11. #define DS3231_SCL_PIN 5
  12. void app_main() {
  13. ESP_ERROR_CHECK(ds3231_init(DS3231_SDA_PIN, DS3231_SCL_PIN));
  14. for (int i=0; i<100; i++) {
  15. date_time date_time = { .seconds = 58,
  16. .minutes = 15,
  17. .hours = 23,
  18. .dow = 3,
  19. .day = 21,
  20. .month = 8,
  21. .year = 22 };
  22. ds3231_write_date_time(date_time);
  23. ds3231_read_date_time(&date_time);
  24. printf("Seconds: %d\n", date_time.seconds);
  25. printf("Minutes: %d\n", date_time.minutes);
  26. printf("Hours: %d\n", date_time.hours);
  27. printf("Day of week: %d\n", date_time.dow);
  28. printf("Day of month: %d\n", date_time.day);
  29. printf("Month: %d\n", date_time.month);
  30. printf("Year: %d\n", date_time.year);
  31. vTaskDelay(1000 / portTICK_PERIOD_MS);
  32. }
  33. printf("Hello World\n");
  34. }