Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
P
pts
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
misc
pts
Commits
86691b14
Commit
86691b14
authored
Jul 15, 2011
by
Samuel Iglesias Gonsalvez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tps/test: update si570 class to latest version
parent
b8e4bbf2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
189 additions
and
9 deletions
+189
-9
test05.py
test/spec/python/test05.py
+164
-0
test06.py
test/spec/python/test06.py
+25
-9
No files found.
test/spec/python/test05.py
View file @
86691b14
...
...
@@ -134,6 +134,148 @@ class SWITCH_ADN4600:
def
enable_tx
(
self
,
channel
)
:
self
.
wr_reg8
(
0xC0
+
0x8
*
channel
,
(
1
<<
5
))
class
CSI570
:
HS_N1_DIV
=
0x7
;
REF_FREQ_37_32
=
0x8
;
REF_FREQ_31_24
=
0x9
;
REF_FREQ_23_16
=
0xA
;
REF_FREQ_15_8
=
0xB
;
REF_FREQ_7_0
=
0xC
;
RST_MEM_CTRL
=
0x87
;
FREEZE_DCO
=
0x89
;
def
__init__
(
self
,
i2c
,
addr
):
self
.
i2c
=
i2c
;
self
.
addr
=
addr
;
def
wr_reg16
(
self
,
addr
,
value
):
self
.
i2c
.
start
(
self
.
addr
,
True
);
self
.
i2c
.
write
(
addr
,
False
);
tmp
=
(
value
>>
8
)
&
0xFF
;
self
.
i2c
.
write
(
value
,
False
);
tmp
=
value
&
0xFF
;
self
.
i2c
.
write
(
value
,
True
)
def
wr_reg8
(
self
,
addr
,
value
):
self
.
i2c
.
start
(
self
.
addr
,
True
);
# write cycle
self
.
i2c
.
write
(
addr
,
False
);
self
.
i2c
.
write
(
value
,
True
);
def
rd_reg16
(
self
,
addr
):
self
.
i2c
.
start
(
self
.
addr
,
True
);
self
.
i2c
.
write
(
addr
,
False
);
self
.
i2c
.
start
(
self
.
addr
,
False
);
tmp_MSB
=
self
.
i2c
.
read
(
False
);
tmp_LSB
=
self
.
i2c
.
read
(
True
);
value
=
(
tmp_MSB
<<
8
)
|
tmp_LSB
;
return
value
;
def
rd_reg8
(
self
,
addr
):
self
.
i2c
.
start
(
self
.
addr
,
True
);
self
.
i2c
.
write
(
addr
,
False
);
self
.
i2c
.
start
(
self
.
addr
,
False
);
return
self
.
i2c
.
read
(
True
);
def
calculate_hs
(
self
,
hs_div
)
:
convert
=
{
'4'
:
0
,
'5'
:
1
,
'6'
:
2
,
'7'
:
3
,
'9'
:
5
,
'11'
:
7
};
return
convert
[
str
(
hs_div
)];
def
read_setup_oscillator
(
self
)
:
""" Data saved in internal variables of the class """
tmp
=
self
.
rd_reg8
(
self
.
HS_N1_DIV
);
self
.
hs_div
=
tmp
>>
5
;
self
.
n1
=
(
tmp
&
0x1F
)
<<
2
;
tmp
=
self
.
rd_reg8
(
self
.
REF_FREQ_37_32
);
self
.
n1
|=
tmp
>>
6
;
self
.
rfreq
=
(
tmp
&
0x3F
)
<<
32
;
self
.
rfreq
|=
self
.
rd_reg8
(
self
.
REF_FREQ_31_24
)
<<
24
;
self
.
rfreq
|=
self
.
rd_reg8
(
self
.
REF_FREQ_23_16
)
<<
16
;
self
.
rfreq
|=
self
.
rd_reg8
(
self
.
REF_FREQ_15_8
)
<<
8
;
self
.
rfreq
|=
self
.
rd_reg8
(
self
.
REF_FREQ_7_0
);
def
setup_oscillator
(
self
,
hs_div
,
n1_div
,
rfreq
)
:
""" Setup the oscillator with the given parameters """
# Freeze the oscillator to setup it
self
.
wr_reg8
(
self
.
FREEZE_DCO
,
(
1
<<
4
));
# Write setup
val
=
((
hs_div
&
0x7
)
<<
5
)
|
(
n1_div
>>
2
)
self
.
wr_reg8
(
self
.
HS_N1_DIV
,
val
);
val
=
((
n1_div
&
0x3
)
<<
6
)
|
(
rfreq
>>
32
);
self
.
wr_reg8
(
self
.
REF_FREQ_37_32
,
val
);
val
=
(
rfreq
>>
24
)
&
0xFF
;
self
.
wr_reg8
(
self
.
REF_FREQ_31_24
,
val
);
val
=
(
rfreq
>>
16
)
&
0xFF
;
self
.
wr_reg8
(
self
.
REF_FREQ_23_16
,
val
);
val
=
(
rfreq
>>
8
)
&
0xFF
;
self
.
wr_reg8
(
self
.
REF_FREQ_15_8
,
val
);
val
=
rfreq
&
0xFF
;
self
.
wr_reg8
(
self
.
REF_FREQ_7_0
,
val
);
self
.
read_setup_oscillator
();
print
"wrote before confirmation"
print
"HS DIV: "
+
str
(
self
.
hs_div
);
print
"N1: "
+
str
(
self
.
n1
);
print
"RFREQ: "
+
str
(
self
.
rfreq
);
# Unfreeze it
tmp
=
self
.
rd_reg8
(
self
.
FREEZE_DCO
);
self
.
wr_reg8
(
self
.
FREEZE_DCO
,
tmp
&
0xEF
);
self
.
wr_reg8
(
self
.
RST_MEM_CTRL
,
(
1
<<
6
));
while
(
self
.
rd_reg8
(
self
.
RST_MEM_CTRL
)
&
(
1
<<
6
)):
pass
;
def
setup_frequency
(
self
,
freq
)
:
""" Calculate the proper parameters and setup them into the oscillator"""
finish
=
0
;
for
N1
in
range
(
0
,
65
)
:
if
N1
==
0
:
n1
=
1
;
else
:
n1
=
N1
*
2
;
for
HSDIV
in
[
4
,
5
,
6
,
7
,
9
,
11
]
:
x
=
freq
*
HSDIV
*
n1
;
if
(
x
<
5670
)
and
(
x
>
4850
)
:
finish
=
1
;
freq_dco
=
x
;
break
;
if
finish
:
break
;
if
(
not
finish
):
raise
TpsError
(
'SI570: Not found a proper setup'
)
tmp
=
freq_dco
/
114.28
;
rfreq
=
int
((
tmp
*
(
2
**
28
)));
hsdiv
=
self
.
calculate_hs
(
HSDIV
);
n1
=
n1
-
1
;
self
.
setup_oscillator
(
hsdiv
,
n1
,
rfreq
);
def
reset
(
self
)
:
val
=
(
1
<<
7
);
self
.
wr_reg8
(
self
.
RST_MEM_CTRL
,
val
);
class
CMinic
:
OFFSET_EP
=
0x4000
...
...
@@ -331,6 +473,8 @@ def main (default_directory='.'):
adn4600
.
enable_tx
(
6
)
# channel 5
adn4600
.
enable_tx
(
7
)
# channel 4
print
"------------------------------------"
print
"Setup ADN4600 chip (crossing point)
\n
"
print
"adn4600 tx 1-0: "
+
hex
(
adn4600
.
rd_reg8
(
0xC8
))
+
" "
+
hex
(
adn4600
.
rd_reg8
(
0xC0
))
print
"adn4600 tx 3-2: "
+
hex
(
adn4600
.
rd_reg8
(
0xD8
))
+
" "
+
hex
(
adn4600
.
rd_reg8
(
0xD0
))
print
"adn4600 tx 5-4: "
+
hex
(
adn4600
.
rd_reg8
(
0xF0
))
+
" "
+
hex
(
adn4600
.
rd_reg8
(
0xF8
))
...
...
@@ -361,6 +505,26 @@ def main (default_directory='.'):
time
.
sleep
(
1
)
# The address of the SI570 is fixed in the part number
si570
=
CSI570
(
i2c
,
0x55
);
si570
.
read_setup_oscillator
()
print
"------------------------------------"
print
"Original setup of FMC Carrier tester's Si570"
print
"HS DIV: "
+
str
(
si570
.
hs_div
);
print
"N1: "
+
str
(
si570
.
n1
);
print
"RFREQ: "
+
str
(
si570
.
rfreq
);
print
"
\n
"
time
.
sleep
(
1
)
si570
.
setup_frequency
(
125
)
si570
.
read_setup_oscillator
()
print
"After setup of FMC Carrier tester's Si570 for f_out = 125 MHz:"
print
"HS DIV: "
+
str
(
si570
.
hs_div
);
print
"N1: "
+
str
(
si570
.
n1
);
print
"RFREQ: "
+
str
(
si570
.
rfreq
);
print
"------------------------------------"
minic_sata
=
CMinic
(
gennum
,
0x20000
,
0
);
minic_sata
.
init_ep
()
...
...
test/spec/python/test06.py
View file @
86691b14
...
...
@@ -135,6 +135,12 @@ class CSI570 :
self
.
i2c
.
start
(
self
.
addr
,
False
);
return
self
.
i2c
.
read
(
True
);
def
calculate_hs
(
self
,
hs_div
)
:
convert
=
{
'4'
:
0
,
'5'
:
1
,
'6'
:
2
,
'7'
:
3
,
'9'
:
5
,
'11'
:
7
};
return
convert
[
str
(
hs_div
)];
def
read_setup_oscillator
(
self
)
:
""" Data saved in internal variables of the class """
tmp
=
self
.
rd_reg8
(
self
.
HS_N1_DIV
);
...
...
@@ -177,11 +183,21 @@ class CSI570 :
val
=
rfreq
&
0xFF
;
self
.
wr_reg8
(
self
.
REF_FREQ_7_0
,
val
);
self
.
read_setup_oscillator
();
print
"wrote before confirmation"
print
"HS DIV: "
+
str
(
self
.
hs_div
);
print
"N1: "
+
str
(
self
.
n1
);
print
"RFREQ: "
+
str
(
self
.
rfreq
);
# Unfreeze it
self
.
wr_reg8
(
self
.
FREEZE_DCO
,
0
);
tmp
=
self
.
rd_reg8
(
self
.
FREEZE_DCO
);
self
.
wr_reg8
(
self
.
FREEZE_DCO
,
tmp
&
0xEF
);
self
.
wr_reg8
(
self
.
RST_MEM_CTRL
,
(
1
<<
6
));
time
.
sleep
(
0.010
)
self
.
wr_reg8
(
self
.
RST_MEM_CTRL
,
0
);
while
(
self
.
rd_reg8
(
self
.
RST_MEM_CTRL
)
&
(
1
<<
6
)):
pass
;
def
setup_frequency
(
self
,
freq
)
:
""" Calculate the proper parameters and setup them into the oscillator"""
...
...
@@ -194,7 +210,7 @@ class CSI570 :
n1
=
N1
*
2
;
for
HSDIV
in
[
4
,
5
,
6
,
7
,
9
,
11
]
:
x
=
HSDIV
*
n1
;
x
=
freq
*
HSDIV
*
n1
;
if
(
x
<
5670
)
and
(
x
>
4850
)
:
finish
=
1
;
freq_dco
=
x
;
...
...
@@ -206,11 +222,11 @@ class CSI570 :
if
(
not
finish
):
raise
TpsError
(
'SI570: Not found a proper setup'
)
tmp
=
freq_dco
/
114.28
5
;
rfreq
=
int
((
tmp
*
2
**
28
));
rfreq
=
hex
(
rfreq
);
self
.
setup_oscillator
(
HSDIV
,
n1
,
rfreq
)
;
tmp
=
freq_dco
/
114.28
;
rfreq
=
int
((
tmp
*
(
2
**
28
)
));
hsdiv
=
self
.
calculate_hs
(
HSDIV
);
n1
=
n1
-
1
;
self
.
setup_oscillator
(
hsdiv
,
n1
,
rfreq
);
def
reset
(
self
)
:
val
=
(
1
<<
7
);
...
...
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