Conversation
|
@jr1221 do you want me to also make a get time function using the PTP formate or just rely on the HAL getters? |
|
RTC config: LSE clock, FR BCD calendar mode, Clock and Calendar, ASync Pre-Scaler = 0, Sync Pre-Scaler = 32767 (to preserve 1 Hz ck_spre while maximizing sub second ticks) |
caiodasilva2005
left a comment
There was a problem hiding this comment.
very good work Alex. Just some nits and some questions. Thanks!
NetX/src/rtc.c
Outdated
| #include <stdint.h> | ||
| #include "stm32h5xx_hal_rtc.h" | ||
|
|
||
| #define ptp_utc_offset 0 // UTC 0 |
There was a problem hiding this comment.
very nit: make this var all caps
NetX/src/rtc.c
Outdated
| ptp_date_time->nanosecond / 1000, second_fractions); | ||
|
|
||
| UINT offset_tick = 0; // ticks to go backwards | ||
| UINT offset_ahead_1s = 0; |
There was a problem hiding this comment.
also very nit: they have macros for this I believe. Set this to RTC_SHIFTADD1S_RESET and then RTC_SHIFTADD1S_SET when you want to set it
NetX/src/rtc.c
Outdated
| if (rtc_sub_second_tick > rtp_sub_second_tick) { // local ahead | ||
| offset_tick = rtc_sub_second_tick - rtp_sub_second_tick; | ||
| } else { // local behind | ||
| offset_ahead_1s = 1; |
There was a problem hiding this comment.
why do we have to offset the seconds in this situation. Isn't it just comparing the sub-second ticks and you would just have to offset by that? Wouldn't we just have to add a second if the offset goes above the max sub-second value?
| { | ||
| switch (operation) { | ||
| case NX_PTP_CLIENT_CLOCK_INIT: | ||
| HAL_RTC_Init( |
There was a problem hiding this comment.
we should probably do this in main.c? This is okay for now

Closes #366