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
8a8dc145
Commit
8a8dc145
authored
Oct 10, 2015
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improved printout of the i2c read data (print_sensor_i2c command)
parent
e3d8632e
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67274 additions
and
67914 deletions
+67274
-67914
x393_mcntrl.pickle
py393/dbg/x393_mcntrl.pickle
+67211
-67911
x393_jpeg.py
py393/x393_jpeg.py
+13
-1
x393_sensor.py
py393/x393_sensor.py
+50
-2
No files found.
py393/dbg/x393_mcntrl.pickle
View file @
8a8dc145
This diff is collapsed.
Click to expand it.
py393/x393_jpeg.py
View file @
8a8dc145
...
@@ -940,6 +940,7 @@ mem_save "/usr/local/verilog/memdump_chn0" 0x27a00000 0x01001000
...
@@ -940,6 +940,7 @@ mem_save "/usr/local/verilog/memdump_chn0" 0x27a00000 0x01001000
write_sensor_i2c 0 1 0 0x91900004
write_sensor_i2c 0 1 0 0x91900004
read_sensor_i2c 0
read_sensor_i2c 0
print_sensor_i2c 0
set_sensor_i2c_table_reg_wr 0 0x00 0x48 3 100 1
set_sensor_i2c_table_reg_wr 0 0x00 0x48 3 100 1
set_sensor_i2c_table_reg_wr 0 0x90 0x48 3 100 1
set_sensor_i2c_table_reg_wr 0 0x90 0x48 3 100 1
...
@@ -947,6 +948,7 @@ set_sensor_i2c_table_reg_rd 0 0x01 0 2 100 1
...
@@ -947,6 +948,7 @@ set_sensor_i2c_table_reg_rd 0 0x01 0 2 100 1
set_sensor_i2c_table_reg_rd 0 0x91 0 2 100 1
set_sensor_i2c_table_reg_rd 0 0x91 0 2 100 1
========
========
cd /usr/local/verilog/; test_mcntrl.py @hargs
measure_all "*DI"
measure_all "*DI"
setup_all_sensors True None 0xf
setup_all_sensors True None 0xf
set_sensor_io_ctl 0 None None None None None 0 0x4
set_sensor_io_ctl 0 None None None None None 0 0x4
...
@@ -963,7 +965,17 @@ axi_write_single_w 0x696 0x079800a3
...
@@ -963,7 +965,17 @@ axi_write_single_w 0x696 0x079800a3
axi_write_single_w 0x686 0x079800a3
axi_write_single_w 0x686 0x079800a3
axi_write_single_w 0x6a6 0x079800a3
axi_write_single_w 0x6a6 0x079800a3
axi_write_single_w 0x6b6 0x079800a3
axi_write_single_w 0x6b6 0x079800a3
r
compressor_control all 2
jpeg_write "img.jpeg" all
write_sensor_i2c 0 1 0 0x91900004
print_sensor_i2c 0
#r
"""
"""
py393/x393_sensor.py
View file @
8a8dc145
...
@@ -514,11 +514,13 @@ class X393Sensor(object):
...
@@ -514,11 +514,13 @@ class X393Sensor(object):
def
read_sensor_i2c
(
self
,
def
read_sensor_i2c
(
self
,
num_sensor
,
num_sensor
,
num_bytes
=
None
):
num_bytes
=
None
,
verbose
=
0
):
"""
"""
Read sequence of bytes available
Read sequence of bytes available
@param num_sensor - sensor port number (0..3), or "all" - same to all sensors
@param num_sensor - sensor port number (0..3), or "all" - same to all sensors
@param num_bytes - number of bytes to read (None - all in FIFO)
@param num_bytes - number of bytes to read (None - all in FIFO)
@verbose - verbose level
@return list of read bytes
@return list of read bytes
"""
"""
ODDEVEN
=
"ODDEVEN"
ODDEVEN
=
"ODDEVEN"
...
@@ -547,7 +549,7 @@ class X393Sensor(object):
...
@@ -547,7 +549,7 @@ class X393Sensor(object):
self
.
set_sensor_i2c_command
(
self
.
set_sensor_i2c_command
(
num_sensor
=
num_sensor
,
num_sensor
=
num_sensor
,
advance_FIFO
=
True
,
advance_FIFO
=
True
,
verbose
=
1
)
verbose
=
verbose
)
# wait until odd/even bit reverses (no timeout here)
# wait until odd/even bit reverses (no timeout here)
while
d
[
ODDEVEN
]
==
oddeven
:
while
d
[
ODDEVEN
]
==
oddeven
:
d
=
read_i2c_data
(
num_sensor
)
d
=
read_i2c_data
(
num_sensor
)
...
@@ -555,6 +557,52 @@ class X393Sensor(object):
...
@@ -555,6 +557,52 @@ class X393Sensor(object):
break
# read all that was requested (num_bytes == None will not get here)
break
# read all that was requested (num_bytes == None will not get here)
return
rslt
return
rslt
def
print_sensor_i2c
(
self
,
num_sensor
,
reg_addr
,
indx
=
1
,
sa7
=
0x48
,
verbose
=
0
):
"""
Read sequence of bytes available and print the result as a single hex number
@param num_sensor - sensor port number (0..3), or "all" - same to all sensors
@param reg_addr - register to read address 1/2 bytes (defined by previously set format)
@param indx - i2c command index in 1 256-entry table (defines here i2c delay, number of address bytes and number of data bytes)
@param sa7 - 7-bit i2c slave address
@param verbose - verbose level
"""
#clean up FIFO
dl
=
self
.
read_sensor_i2c
(
num_sensor
=
num_sensor
,
num_bytes
=
None
,
verbose
=
verbose
)
if
len
(
dl
):
d
=
0
for
b
in
dl
:
d
=
(
d
<<
8
)
|
(
b
&
0xff
)
fmt
=
"FIFO contained
%
d bytes i2c data = 0x
%%0%
dx"
%
(
len
(
dl
),
len
(
dl
*
2
))
print
(
fmt
%
(
d
))
#create and send i2c command in ASAP mode:
i2c_cmd
=
((
indx
&
0xff
)
<<
24
)
|
(
sa7
<<
17
)
|
(
reg_addr
&
0xffff
)
#write_sensor_i2c 0 1 0 0x91900004
self
.
write_sensor_i2c
(
num_sensor
=
num_sensor
,
rel_addr
=
1
,
addr
=
0
,
data
=
i2c_cmd
)
time
.
sleep
(
0.05
)
# We do not know how many bytes are expected, so just wait long enough and hope all bytes are in fifo already
dl
=
self
.
read_sensor_i2c
(
num_sensor
=
num_sensor
,
num_bytes
=
None
,
verbose
=
verbose
)
if
len
(
dl
):
d
=
0
for
b
in
dl
:
d
=
(
d
<<
8
)
|
(
b
&
0xff
)
fmt
=
"i2c data[0x
%02
x:0x
%
x] = 0x
%%0%
dx"
%
(
sa7
,
reg_addr
,
len
(
dl
)
*
2
)
print
(
fmt
%
(
d
))
def
set_sensor_io_ctl
(
self
,
def
set_sensor_io_ctl
(
self
,
num_sensor
,
num_sensor
,
mrst
=
None
,
mrst
=
None
,
...
...
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