From faac7250697466428896e25a1d315e680b0e5ba5 Mon Sep 17 00:00:00 2001 From: Sander Speetjens Date: Sun, 25 Dec 2022 13:13:50 +0100 Subject: [PATCH] Add some comment headers in my libraries --- NTP/Core/Inc/Time.h | 6 ++++++ NTP/Core/Inc/ds3231_for_stm32_hal.h | 8 +++++--- NTP/Core/Src/Time.c | 13 ++++++++++--- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/NTP/Core/Inc/Time.h b/NTP/Core/Inc/Time.h index 32a703c..bee4b76 100644 --- a/NTP/Core/Inc/Time.h +++ b/NTP/Core/Inc/Time.h @@ -2,6 +2,12 @@ #include #include "debug.h" +/* + * TimeLib + * Based on the Time library by Michael Margolis (make and break time functions) + * Additions by: Sani7 (Sander Speetjens) +*/ + // to transform a number of seconds into a current time you need to do some maths #define NUMBEROFSECONDSPERDAY 86400UL #define NUMBEROFSECONDSPERHOUR 3600UL diff --git a/NTP/Core/Inc/ds3231_for_stm32_hal.h b/NTP/Core/Inc/ds3231_for_stm32_hal.h index adb1ab4..a0ce435 100755 --- a/NTP/Core/Inc/ds3231_for_stm32_hal.h +++ b/NTP/Core/Inc/ds3231_for_stm32_hal.h @@ -1,7 +1,9 @@ -/* An STM32 HAL library written for the DS3231 real-time clock IC. */ -/* Based on a Library by @eepj www.github.com/eepj */ -/* Moddifications by Sani7 */ +/* An STM32 HAL library written for the DS3231 real-time clock IC. + * Based on a Library by @eepj www.github.com/eepj + * Moddifications by Sani7 + */ + #ifndef DS3231_FOR_STM32_HAL_H #define DS3231_FOR_STM32_HAL_H #include "main.h" diff --git a/NTP/Core/Src/Time.c b/NTP/Core/Src/Time.c index 9f37644..514687d 100644 --- a/NTP/Core/Src/Time.c +++ b/NTP/Core/Src/Time.c @@ -1,5 +1,12 @@ #include "Time.h" +/* + * TimeLib + * Based on the Time library by Michael Margolis (make and break time functions) + * Additions by: Sani7 (Sander Speetjens) +*/ + + /** * @fn uint8_t IsDST(ts*) * @brief This function calculates if we are in EDST @@ -14,13 +21,13 @@ uint8_t IsDST(ts *utc) // number of days of each month uint8_t days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; - // January, february, and december are out. + // November, December, January, february are out of DST. if (utc->Month < 3 || utc->Month > 10) { utc->IsDST = 0; return utc->IsDST; } - // April to september are in + // April to september are in DST if (utc->Month > 3 && utc->Month < 10) { utc->IsDST = 1; @@ -32,7 +39,7 @@ uint8_t IsDST(ts *utc) days[1] -= (y % 4) || (!(y % 100) && (y % 400)); d = days[m - 1]; - /* dow is in normal format*/ + // dow is in normal format nextSunday = days[m - 1] - ((d += m < 3 ? y-- : y - 2, 23 * m / 9 + d + 4 + y / 4 - y / 100 + y / 400) % 7); // Start: Last Sunday in March if (utc->Month == 3)