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
d0fcad21
Commit
d0fcad21
authored
Apr 23, 2019
by
Oleg Dzhimiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added auto-setting of OEM bit when working with OEM/RAD modules
parent
b89b815a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
6 deletions
+21
-6
x393_sensor.py
py393/x393_sensor.py
+21
-6
No files found.
py393/x393_sensor.py
View file @
d0fcad21
...
@@ -2426,7 +2426,7 @@ input mem mtd4 ram1
...
@@ -2426,7 +2426,7 @@ input mem mtd4 ram1
def
lepton35_i2c_w
(
self
,
num_sensor
,
reg
,
val
):
def
lepton35_i2c_w
(
self
,
num_sensor
,
reg
,
val
):
"""
"""
w
rite 16 bit value to an i2c register via sysfs
W
rite 16 bit value to an i2c register via sysfs
@param num_sensor - sensor port number (0..3)
@param num_sensor - sensor port number (0..3)
@param reg - register address (0x0 - power_on reg, 0x2 - status reg, 0x4 - command reg, 0x6 - data length reg, 0x08-0x26 - data regs)
@param reg - register address (0x0 - power_on reg, 0x2 - status reg, 0x4 - command reg, 0x6 - data length reg, 0x08-0x26 - data regs)
@param val - value
@param val - value
...
@@ -2439,7 +2439,7 @@ input mem mtd4 ram1
...
@@ -2439,7 +2439,7 @@ input mem mtd4 ram1
def
lepton35_i2c_r
(
self
,
num_sensor
,
reg
):
def
lepton35_i2c_r
(
self
,
num_sensor
,
reg
):
"""
"""
r
ead 16 bit value from an i2c register via sysfs
R
ead 16 bit value from an i2c register via sysfs
@param num_sensor - sensor port number (0..3)
@param num_sensor - sensor port number (0..3)
@param reg - register address (0x0 - power_on reg, 0x2 - status reg, 0x4 - command reg, 0x6 - data length reg, 0x08-0x26 - data regs)
@param reg - register address (0x0 - power_on reg, 0x2 - status reg, 0x4 - command reg, 0x6 - data length reg, 0x08-0x26 - data regs)
"""
"""
...
@@ -2458,7 +2458,7 @@ input mem mtd4 ram1
...
@@ -2458,7 +2458,7 @@ input mem mtd4 ram1
def
lepton35_poll_BUSY
(
self
,
num_sensor
,
ntries
=
10
):
def
lepton35_poll_BUSY
(
self
,
num_sensor
,
ntries
=
10
):
"""
"""
p
oll BUSY bit of a status reg
P
oll BUSY bit of a status reg
@param num_sensor - sensor port number (0..3)
@param num_sensor - sensor port number (0..3)
@param ntries - timeout, exit after ntries times
@param ntries - timeout, exit after ntries times
"""
"""
...
@@ -2480,12 +2480,18 @@ input mem mtd4 ram1
...
@@ -2480,12 +2480,18 @@ input mem mtd4 ram1
def
lepton35_read
(
self
,
num_sensor
,
cmdreg
,
datalen
):
def
lepton35_read
(
self
,
num_sensor
,
cmdreg
,
datalen
):
"""
"""
Read attribute sequence
Read attribute sequence
, auto-sets OEM bit for OEM(0x08..) and RAD(0x0e..) modules
@param num_sensor - sensor port number (0..3)
@param num_sensor - sensor port number (0..3)
@param cmdreg - register base address
@param cmdreg - register base address
@param datalen - number of 16-bit words to read
@param datalen - number of 16-bit words to read
"""
"""
res
=
[]
res
=
[]
mod
=
(
cmdreg
>>
8
)
&
0xf
# mode
if
mod
==
0x8
or
mod
==
0xe
:
cmdreg
+=
0x4000
busy
=
self
.
lepton35_poll_BUSY
(
num_sensor
)
busy
=
self
.
lepton35_poll_BUSY
(
num_sensor
)
if
not
busy
:
if
not
busy
:
print
(
"not busy, writing data length and command"
)
print
(
"not busy, writing data length and command"
)
...
@@ -2504,12 +2510,17 @@ input mem mtd4 ram1
...
@@ -2504,12 +2510,17 @@ input mem mtd4 ram1
def
lepton35_write
(
self
,
num_sensor
,
cmdreg
,
cmddata
):
def
lepton35_write
(
self
,
num_sensor
,
cmdreg
,
cmddata
):
"""
"""
Write sequence
Write sequence
, auto-sets OEM bit for OEM(0x08..) and RAD(0x0e..) modules
@param num_sensor - sensor port number (0..3)
@param num_sensor - sensor port number (0..3)
@param cmdreg - register base address (true addr = cmdreg|0x1)
@param cmdreg - register base address (true addr = cmdreg|0x1)
@param cmddata - string with comma separated values "0,1,2,3,4"
@param cmddata - string with comma separated values "0,1,2,3,4"
"""
"""
cmdreg
=
cmdreg
|
0x1
cmdreg
=
cmdreg
|
0x1
mod
=
(
cmdreg
>>
8
)
&
0xf
# mode
if
mod
==
0x8
or
mod
==
0xe
:
cmdreg
+=
0x4000
cmddata
=
[
int
(
a
)
for
a
in
cmddata
.
split
(
","
)]
cmddata
=
[
int
(
a
)
for
a
in
cmddata
.
split
(
","
)]
datalen
=
len
(
cmddata
)
datalen
=
len
(
cmddata
)
...
@@ -2526,10 +2537,14 @@ input mem mtd4 ram1
...
@@ -2526,10 +2537,14 @@ input mem mtd4 ram1
def
lepton35_run
(
self
,
num_sensor
,
cmdreg
):
def
lepton35_run
(
self
,
num_sensor
,
cmdreg
):
"""
"""
Run command sequence
Run command sequence
, auto-sets OEM bit for OEM(0x08..) and RAD(0x0e..) modules
@param num_sensor - sensor port number (0..3)
@param num_sensor - sensor port number (0..3)
@param cmdreg - register base address (true addr = cmdreg|0x2)
@param cmdreg - register base address (true addr = cmdreg|0x2)
"""
"""
mod
=
(
cmdreg
>>
8
)
&
0xf
# mode
if
mod
==
0x8
or
mod
==
0xe
:
cmdreg
+=
0x4000
busy
=
self
.
lepton35_poll_BUSY
(
num_sensor
)
busy
=
self
.
lepton35_poll_BUSY
(
num_sensor
)
if
not
busy
:
if
not
busy
:
self
.
lepton35_i2c_w
(
num_sensor
,
self
.
LEPTON35_REG_CMD
,
cmdreg
)
self
.
lepton35_i2c_w
(
num_sensor
,
self
.
LEPTON35_REG_CMD
,
cmdreg
)
...
...
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