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
f0575e73
Commit
f0575e73
authored
Feb 15, 2016
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wrc_main: turn link-status polling into a task
Signed-off-by:
Alessandro Rubini
<
rubini@gnudd.com
>
parent
04898a1e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
17 deletions
+19
-17
wrc_main.c
wrc_main.c
+19
-17
No files found.
wrc_main.c
View file @
f0575e73
...
...
@@ -99,23 +99,31 @@ static void wrc_initialize(void)
wrc_ptp_start
();
}
int
link_status
;
static
int
wrc_check_link
(
void
)
{
static
int
prev_
link_
state
=
-
1
;
int
link_
state
=
ep_link_up
(
NULL
);
static
int
prev_state
=
-
1
;
int
state
=
ep_link_up
(
NULL
);
int
rv
=
0
;
if
(
!
prev_
link_state
&&
link_
state
)
{
if
(
!
prev_
state
&&
state
)
{
wrc_verbose
(
"Link up.
\n
"
);
gpio_out
(
GPIO_LED_LINK
,
1
);
rv
=
LINK_WENT_UP
;
}
else
if
(
prev_link_state
&&
!
link_state
)
{
link_status
=
LINK_WENT_UP
;
rv
=
1
;
}
else
if
(
prev_state
&&
!
state
)
{
wrc_verbose
(
"Link down.
\n
"
);
gpio_out
(
GPIO_LED_LINK
,
0
);
rv
=
LINK_WENT_DOWN
;
link_status
=
LINK_WENT_DOWN
;
rv
=
1
;
/* special case */
spll_init
(
SPLL_MODE_FREE_RUNNING_MASTER
,
0
,
1
);
shw_pps_gen_enable_output
(
0
);
}
else
rv
=
(
link_
state
?
LINK_UP
:
LINK_DOWN
);
prev_
link_state
=
link_
state
;
link_status
=
(
state
?
LINK_UP
:
LINK_DOWN
);
prev_
state
=
state
;
return
rv
;
}
...
...
@@ -148,12 +156,13 @@ void init_hw_after_reset(void)
timer_init
(
1
);
}
int
link_status
;
struct
wrc_task
wrc_tasks
[]
=
{
{
.
name
=
"idle"
,
.
init
=
wrc_initialize
,
},
{
.
name
=
"check-link"
,
.
job
=
wrc_check_link
,
},
{
.
name
=
"net-bh"
,
.
enable
=
&
link_status
,
...
...
@@ -221,13 +230,6 @@ int main(void)
uptime_sec
++
;
}
/* update link_status and do special-case processing */
link_status
=
wrc_check_link
();
if
(
link_status
==
LINK_WENT_DOWN
)
{
spll_init
(
SPLL_MODE_FREE_RUNNING_MASTER
,
0
,
1
);
shw_pps_gen_enable_output
(
0
);
}
/* run your tasks */
for
(
i
=
0
;
i
<
wrc_n_tasks
;
i
++
)
wrc_run_task
(
wrc_tasks
+
i
);
...
...
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