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
6
Merge Requests
6
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
b239aaff
Commit
b239aaff
authored
Dec 21, 2016
by
Mattia Rizzi
Committed by
Grzegorz Daniluk
Aug 15, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added support for the external board
parent
41d63e41
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
10 deletions
+28
-10
spll_external.c
softpll/spll_external.c
+28
-10
No files found.
softpll/spll_external.c
View file @
b239aaff
...
@@ -13,14 +13,15 @@
...
@@ -13,14 +13,15 @@
#include <wrc.h>
#include <wrc.h>
#include "softpll_ng.h"
#include "softpll_ng.h"
#include "irq.h"
#include "irq.h"
#include "gpio-wrs.h"
#include "ext-board.h"
#define ALIGN_SAMPLE_PERIOD 100000
#define ALIGN_SAMPLE_PERIOD 100000
#define ALIGN_TARGET 0
#define ALIGN_TARGET 0
#define EXT_PERIOD_NS 100
#define EXT_PERIOD_NS 100
#define EXT_FREQ_HZ 10000000
#define EXT_FREQ_HZ 10000000
#define EXT_PPS_LATENCY_PS
30
000 // fixme: make configurable
#define EXT_PPS_LATENCY_PS
63
000 // fixme: make configurable
void
external_init
(
volatile
struct
spll_external_state
*
s
,
int
ext_ref
,
void
external_init
(
volatile
struct
spll_external_state
*
s
,
int
ext_ref
,
...
@@ -28,6 +29,8 @@ void external_init(volatile struct spll_external_state *s, int ext_ref,
...
@@ -28,6 +29,8 @@ void external_init(volatile struct spll_external_state *s, int ext_ref,
{
{
int
idx
=
spll_n_chan_ref
+
spll_n_chan_out
;
int
idx
=
spll_n_chan_ref
+
spll_n_chan_out
;
if
(
gpio_in
(
GPIO_EXT_BOARD_DETECT
))
idx
++
;
helper_init
(
s
->
helper
,
idx
);
helper_init
(
s
->
helper
,
idx
);
mpll_init
(
s
->
main
,
idx
,
spll_n_chan_ref
);
mpll_init
(
s
->
main
,
idx
,
spll_n_chan_ref
);
...
@@ -49,10 +52,16 @@ void external_start(struct spll_external_state *s)
...
@@ -49,10 +52,16 @@ void external_start(struct spll_external_state *s)
int
external_locked
(
volatile
struct
spll_external_state
*
s
)
int
external_locked
(
volatile
struct
spll_external_state
*
s
)
{
{
if
(
!
s
->
helper
->
ld
.
locked
||
!
s
->
main
->
ld
.
locked
||
if
(
!
s
->
helper
->
ld
.
locked
||
!
s
->
main
->
ld
.
locked
)
!
(
SPLL
->
ECCR
&
SPLL_ECCR_EXT_REF_LOCKED
)
||
// ext PLL became unlocked
return
0
;
(
SPLL
->
ECCR
&
SPLL_ECCR_EXT_REF_STOPPED
))
// 10MHz unplugged (only SPEC)
if
(
!
gpio_in
(
GPIO_EXT_BOARD_DETECT
)
&&
(
!
(
SPLL
->
ECCR
&
SPLL_ECCR_EXT_REF_LOCKED
)
||
// ext PLL became unlocked
(
SPLL
->
ECCR
&
SPLL_ECCR_EXT_REF_STOPPED
)))
// 10MHz unplugged (only SPEC)
return
0
;
return
0
;
//FIXME A bug prevents the correct locking if the external lock check is executed
// Correct way to solve it: export the LOCK signal from the gateware and check it
// if (gpio_in(GPIO_EXT_BOARD_DETECT) && ext_ad9516_locked())
// return 1;
switch
(
s
->
align_state
)
{
switch
(
s
->
align_state
)
{
case
ALIGN_STATE_EXT_OFF
:
case
ALIGN_STATE_EXT_OFF
:
...
@@ -86,24 +95,33 @@ static int align_sample(int channel, int *v)
...
@@ -86,24 +95,33 @@ static int align_sample(int channel, int *v)
int
external_align_fsm
(
volatile
struct
spll_external_state
*
s
)
int
external_align_fsm
(
volatile
struct
spll_external_state
*
s
)
{
{
int
v
,
done_sth
=
0
;
int
v
,
done_sth
=
0
;
uint32_t
f_ext
=
0
;
switch
(
s
->
align_state
)
{
switch
(
s
->
align_state
)
{
case
ALIGN_STATE_EXT_OFF
:
case
ALIGN_STATE_EXT_OFF
:
break
;
break
;
case
ALIGN_STATE_WAIT_CLKIN
:
case
ALIGN_STATE_WAIT_CLKIN
:
if
(
!
(
SPLL
->
ECCR
&
SPLL_ECCR_EXT_REF_STOPPED
)
)
{
if
(
!
gpio_in
(
GPIO_EXT_BOARD_DETECT
)
&&
!
(
SPLL
->
ECCR
&
SPLL_ECCR_EXT_REF_STOPPED
)
)
{
SPLL
->
ECCR
|=
SPLL_ECCR_EXT_REF_PLLRST
;
SPLL
->
ECCR
|=
SPLL_ECCR_EXT_REF_PLLRST
;
s
->
align_state
=
ALIGN_STATE_WAIT_PLOCK
;
s
->
align_state
=
ALIGN_STATE_WAIT_PLOCK
;
done_sth
++
;
done_sth
++
;
}
}
f_ext
=
spll_measure_frequency
(
SPLL_OSC_EXT
);
if
(
gpio_in
(
GPIO_EXT_BOARD_DETECT
)
&&
(
f_ext
>
9999000
)
&&
(
f_ext
<
10001000
))
if
(
!
ext_ad9516_init
())
{
s
->
align_state
=
ALIGN_STATE_WAIT_PLOCK
;
pp_printf
(
"External AD9516 locked
\n
"
);
}
break
;
break
;
case
ALIGN_STATE_WAIT_PLOCK
:
case
ALIGN_STATE_WAIT_PLOCK
:
SPLL
->
ECCR
&=
(
~
SPLL_ECCR_EXT_REF_PLLRST
);
SPLL
->
ECCR
&=
(
~
SPLL_ECCR_EXT_REF_PLLRST
);
if
(
SPLL
->
ECCR
&
SPLL_ECCR_EXT_REF_STOPPED
)
if
(
!
gpio_in
(
GPIO_EXT_BOARD_DETECT
)
&&
SPLL
->
ECCR
&
SPLL_ECCR_EXT_REF_STOPPED
)
s
->
align_state
=
ALIGN_STATE_WAIT_CLKIN
;
s
->
align_state
=
ALIGN_STATE_WAIT_CLKIN
;
else
if
(
SPLL
->
ECCR
&
SPLL_ECCR_EXT_REF_LOCKED
)
else
if
((
!
gpio_in
(
GPIO_EXT_BOARD_DETECT
)
&&
SPLL
->
ECCR
&
SPLL_ECCR_EXT_REF_LOCKED
)
||
gpio_in
(
GPIO_EXT_BOARD_DETECT
)
&&
ext_ad9516_locked
())
s
->
align_state
=
ALIGN_STATE_START
;
s
->
align_state
=
ALIGN_STATE_START
;
done_sth
++
;
done_sth
++
;
break
;
break
;
...
...
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