Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
Software for White Rabbit PTP Core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
32
Issues
32
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Software for White Rabbit PTP Core
Commits
6f5b3eb6
Commit
6f5b3eb6
authored
Apr 23, 2020
by
Tomasz Wlostowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wrc_main: implement wrc_is_timing_up() API function
parent
0bb4615c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
4 deletions
+29
-4
wrc.h
include/wrc.h
+3
-0
wrc_main.c
wrc_main.c
+26
-4
No files found.
include/wrc.h
View file @
6f5b3eb6
...
...
@@ -75,4 +75,7 @@ void rtipc_action(void);
/* div64.c, lifted from the linux kernel through pp_printf or ppsi */
extern
uint32_t
__div64_32
(
uint64_t
*
n
,
uint32_t
base
);
int
wrc_is_timing_up
(
void
);
#endif
/* __WRC_H__ */
wrc_main.c
View file @
6f5b3eb6
...
...
@@ -62,6 +62,12 @@ uint32_t cal_phase_transition = 2389;
int
wrc_vlan_number
=
CONFIG_VLAN_NR
;
// fixme: this probably deserves to be moved to another file...
static
int
prev_ptp_mode
;
static
int
prev_ptp_state
;
static
int
prev_servo_state
;
static
int
prev_timing_ok
;
static
void
wrc_initialize
(
void
)
{
uint8_t
mac_addr
[
6
];
...
...
@@ -132,6 +138,7 @@ static int wrc_check_link(void)
rv
=
1
;
}
else
if
(
prev_state
&&
!
state
)
{
wrc_verbose
(
"Link down.
\n
"
);
prev_timing_ok
=
0
;
event_post
(
WRC_EVENT_LINK_DOWN
);
gen_gpio_out
(
&
pin_sysc_led_link
,
0
);
link_status
=
LINK_WENT_DOWN
;
...
...
@@ -189,16 +196,17 @@ static int update_uptime(void)
return
0
;
}
// fixme: this probably deserves to be moved to another file...
static
int
prev_ptp_mode
;
static
int
prev_ptp_state
;
static
int
prev_servo_state
;
int
wrc_is_timing_up
()
{
return
prev_timing_ok
;
}
static
void
wrc_dispatch_ptp_events_init
(
void
)
{
prev_ptp_mode
=
-
1
;
prev_ptp_state
=
-
1
;
prev_servo_state
=
-
1
;
prev_timing_ok
=
0
;
}
static
void
wrc_dispatch_ptp_events_poll
(
void
)
...
...
@@ -212,6 +220,7 @@ static void wrc_dispatch_ptp_events_poll(void)
if
(
mode
!=
prev_ptp_mode
)
{
main_dbg
(
"PTP mode changed.
\n
"
);
prev_timing_ok
=
0
;
event_post
(
WRC_EVENT_PTP_MODE_CHANGED
);
}
...
...
@@ -222,21 +231,34 @@ static void wrc_dispatch_ptp_events_poll(void)
if
(
mode
==
WRC_MODE_MASTER
)
{
if
(
ppi
->
state
==
PPS_MASTER
&&
prev_ptp_state
!=
PPS_MASTER
)
{
prev_timing_ok
=
1
;
event_post
(
WRC_EVENT_TIMING_UP
);
}
else
if
(
ppi
->
state
!=
PPS_MASTER
&&
prev_ptp_state
==
PPS_MASTER
)
{
prev_timing_ok
=
0
;
event_post
(
WRC_EVENT_TIMING_DOWN
);
}
}
else
if
(
mode
==
WRC_MODE_SLAVE
)
{
if
(
ppi
->
state
==
PPS_SLAVE
)
{
if
(
ss
->
state
==
WR_TRACK_PHASE
&&
prev_servo_state
!=
WR_TRACK_PHASE
)
{
prev_timing_ok
=
1
;
event_post
(
WRC_EVENT_TIMING_UP
);
}
else
if
(
ss
->
state
!=
WR_TRACK_PHASE
&&
prev_servo_state
==
WR_TRACK_PHASE
)
{
prev_timing_ok
=
0
;
event_post
(
WRC_EVENT_TIMING_DOWN
);
}
}
else
if
(
ppi
->
state
!=
PPS_SLAVE
&&
prev_ptp_state
==
PPS_SLAVE
)
{
prev_timing_ok
=
0
;
event_post
(
WRC_EVENT_TIMING_DOWN
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment