Skip to content

Commit dbfd15d

Browse files
committed
Fixes based on review
1 parent d18b1d1 commit dbfd15d

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

NetX/src/rtc.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
#include "rtc.h"
22
#include <stdio.h>
3-
#include <stdint.h>
43
#include "stm32h5xx_hal_rtc.h"
54

6-
#define ptp_utc_offset 0 // UTC 0
5+
#define PTP_UTC_OFFSET 0 // UTC 0
76
extern RTC_HandleTypeDef hrtc1;
87

98
NX_PTP_TIME *ptp_time;
@@ -30,11 +29,11 @@ static void set_subsecond(UINT rtc_sub_second_tick, UINT second_fractions)
3029
ptp_date_time->nanosecond / 1000, second_fractions);
3130

3231
UINT offset_tick = 0; // ticks to go backwards
33-
UINT offset_ahead_1s = 0;
32+
UINT offset_ahead_1s = RTC_SHIFTADD1S_RESET;
3433
if (rtc_sub_second_tick > rtp_sub_second_tick) { // local ahead
3534
offset_tick = rtc_sub_second_tick - rtp_sub_second_tick;
3635
} else { // local behind
37-
offset_ahead_1s = 1;
36+
offset_ahead_1s = RTC_SHIFTADD1S_SET;
3837
offset_tick = second_fractions + rtc_sub_second_tick -
3938
rtp_sub_second_tick;
4039
}
@@ -76,7 +75,7 @@ UINT nx_ptp_client_hard_clock_callback(NX_PTP_CLIENT *client_ptr,
7675
ptp_time = time_ptr;
7776

7877
nx_ptp_client_utility_convert_time_to_date(
79-
ptp_time, -ptp_utc_offset, ptp_date_time);
78+
ptp_time, -PTP_UTC_OFFSET, ptp_date_time);
8079

8180
RTC_TimeTypeDef rtp_time = {
8281
.Hours = ptp_date_time->hour,
@@ -160,7 +159,7 @@ UINT nx_ptp_client_hard_clock_callback(NX_PTP_CLIENT *client_ptr,
160159
ptp_time = time_ptr;
161160

162161
nx_ptp_client_utility_convert_time_to_date(
163-
ptp_time, -ptp_utc_offset, ptp_date_time);
162+
ptp_time, -PTP_UTC_OFFSET, ptp_date_time);
164163

165164
HAL_RTC_GetTime(&hrtc1, &rtc_time, RTC_FORMAT_BCD);
166165

@@ -182,4 +181,4 @@ UINT nx_ptp_client_hard_clock_callback(NX_PTP_CLIENT *client_ptr,
182181
}
183182

184183
return NX_SUCCESS;
185-
}
184+
}

0 commit comments

Comments
 (0)