Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
x393
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
x393
Commits
cca9678b
Commit
cca9678b
authored
Feb 22, 2018
by
Oleg Dzhimiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
14MPx phase adjustment testing
parent
2dcd8eb3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
336 additions
and
178 deletions
+336
-178
x393_sensor.py
py393/x393_sensor.py
+336
-178
No files found.
py393/x393_sensor.py
View file @
cca9678b
...
...
@@ -42,6 +42,9 @@ import x393_utils
import
time
import
vrlg
import
x393_mcntrl
import
subprocess
#import x393_sens_cmprs
SENSOR_INTERFACE_PARALLEL
=
"PAR12"
SENSOR_INTERFACE_HISPI
=
"HISPI"
...
...
@@ -2041,5 +2044,160 @@ input mem mtd4 ram1
((
window_top
&
0xffff
)
<<
16
)
|
(
window_left
&
0xffff
))
#WINDOW_X0+ (WINDOW_Y0<<16));
self
.
x393_axi_tasks
.
write_control_register
(
base_addr
+
vrlg
.
MCNTRL_SCANLINE_WINDOW_STARTXY
,
0
)
self
.
x393_axi_tasks
.
write_control_register
(
base_addr
+
vrlg
.
MCNTRL_SCANLINE_MODE
,
mode
)
def
test_hispi_phases
(
self
,
num_sensor
):
"""
Try to adjust phases
@param num_sensor - sensor port number (0..3)
"""
def
thp_set_phase
(
num_sensor
,
phase
):
path
=
"/sys/devices/soc0/elphel393-sensor-i2c@0/i2c"
+
str
(
num_sensor
)
f
=
open
(
path
,
'w'
)
f
.
write
(
"mt9f002 0 0x31c0 "
+
str
(
phase
))
f
.
close
()
def
thp_reset_flags
(
num_sensor
):
self
.
x393_axi_tasks
.
write_control_register
(
0x40e
+
0x40
*
num_sensor
,
0x0
)
#self.x393_axi_tasks.write_control_register(0x40f+0x40*num_sensor,0x0)
def
thp_read_flags
(
num_sensor
,
shift
):
# read a few times
n
=
1
switched
=
False
value
=
0
count
=
0
for
j
in
range
(
n
):
# reset bits
thp_reset_flags
(
num_sensor
)
status
=
int
(
self
.
x393_axi_tasks
.
read_status
(
0x21
+
2
*
num_sensor
)
&
0x01ffffff
)
barrel
=
(
status
>>
14
)
&
0xff
barrel
=
(
barrel
>>
(
2
*
shift
))
&
0x3
print
(
str
(
barrel
)
+
" "
,
end
=
''
)
return
barrel
def
thp_run
(
num_sensor
,
phase0
,
shift
,
bitshift
):
shift
=
shift
*
3
switched
=
False
start
=
0
stop
=
0
count
=
0
value
=
0
for
i
in
range
(
16
):
if
(
i
==
8
):
phase0
+=
0x4000
print
(
"| "
,
end
=
''
)
# set phase
phase
=
phase0
+
((
i
%
8
)
<<
shift
)
thp_set_phase
(
num_sensor
,
phase
)
phase_read
=
int
(
self
.
print_sensor_i2c
(
num_sensor
,
0x31c0
,
0xff
,
0x10
,
0
))
if
phase_read
!=
phase
:
print
(
"ERROR: phase_read ("
+
(
"{:04x}"
.
format
(
phase_read
))
+
") != phase ("
+
(
"{:04x}"
.
format
(
phase
))
+
")"
)
barrel
=
thp_read_flags
(
num_sensor
,
bitshift
)
if
i
==
0
:
value
=
barrel
if
i
==
8
:
if
not
switched
:
start
=
0
count
=
8
if
(
i
<
8
and
i
!=
0
):
if
value
!=
barrel
:
if
not
switched
:
switched
=
True
else
:
if
not
switched
:
count
+=
1
if
i
>=
8
:
if
value
==
barrel
:
count
+=
1
print
(
""
)
return
[
start
,
count
]
chn
=
num_sensor
print
(
"Test HiSPI phases"
)
# check status register
status_reg
=
self
.
x393_axi_tasks
.
read_control_register
(
0x409
+
0x40
*
chn
)
if
(
status_reg
==
0
):
print
(
"Programming status register"
)
self
.
x393_axi_tasks
.
write_control_register
(
0x409
+
0x40
*
chn
,
0xc0
)
status_reg
=
self
.
x393_axi_tasks
.
read_control_register
(
0x409
+
0x40
*
chn
)
print
(
"Status register: "
+
hex
(
self
.
x393_axi_tasks
.
read_control_register
(
0x409
+
0x40
*
chn
)))
phase0
=
0x8000
for
i
in
range
(
4
):
print
(
""
)
print
(
"D"
+
str
(
i
))
res
=
thp_run
(
num_sensor
,
phase0
,
i
,
i
)
phase
=
((
res
[
0
]
+
(
res
[
1
]
>>
1
))
%
8
)
<<
(
3
*
i
)
phase0
+=
phase
print
(
"Updated phase = 0x"
+
"{:04x}"
.
format
(
phase0
))
print
(
"i = "
+
str
(
res
[
0
])
+
" count = "
+
str
(
res
[
1
]))
if
(
res
[
1
]
<
2
):
print
(
"ERROR_D"
+
str
(
i
))
print
(
"Done"
)
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