Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
A
AIDA-2020 TLU - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
AIDA-2020 TLU - Software
Commits
0193c6e8
Commit
0193c6e8
authored
Jun 07, 2018
by
Paolo Baesso
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Attempt to read the SFP I2C lines, created a class for it. Still in progress
parent
9bac0797
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
0 deletions
+59
-0
SFPI2C.py
packages/SFPI2C.py
+59
-0
No files found.
packages/SFPI2C.py
0 → 100644
View file @
0193c6e8
# -*- coding: utf-8 -*-
import
uhal
from
I2CuHal
import
I2CCore
import
StringIO
class
SFPI2C
:
#Class to configure the EEPROM
def
__init__
(
self
,
i2c
,
slaveaddr
=
0x50
):
self
.
i2c
=
i2c
self
.
slaveaddr
=
slaveaddr
def
readEEPROM
(
self
,
startadd
,
nBytes
):
#Read EEPROM memory locations
mystop
=
False
myaddr
=
[
startadd
]
#0xfa
self
.
i2c
.
write
(
self
.
slaveaddr
,
[
startadd
],
mystop
)
res
=
self
.
i2c
.
read
(
self
.
slaveaddr
,
nBytes
)
return
res
def
writeReg
(
self
,
regN
,
regContent
,
verbose
=
False
):
#Basic functionality to write to register.
if
(
regN
<
0
)
|
(
regN
>
7
):
print
"PCA9539PW - ERROR: register number should be in range [0:7]"
return
regContent
=
regContent
&
0xFF
mystop
=
True
cmd
=
[
regN
,
regContent
]
self
.
i2c
.
write
(
self
.
slaveaddr
,
cmd
,
mystop
)
def
readReg
(
self
,
regN
,
nwords
,
verbose
=
False
):
#Basic functionality to read from register.
mystop
=
False
self
.
i2c
.
write
(
self
.
slaveaddr
,
[
regN
],
mystop
)
res
=
self
.
i2c
.
read
(
self
.
slaveaddr
,
nwords
)
return
res
def
getVendorId
(
self
):
""" Returns the OUI vendor id"""
id
=
[
0
,
0
,
0
]
id
[
0
]
=
self
.
readReg
(
37
,
1
,
False
)[
0
]
id
[
1
]
=
self
.
readReg
(
38
,
1
,
False
)[
0
]
id
[
2
]
=
self
.
readReg
(
39
,
1
,
False
)[
0
]
print
id
return
id
def
getVendorPN
(
self
):
""" Returns the part number defined by the vendor"""
pn
=
[]
for
iaddr
in
range
(
0
,
16
):
item
=
self
.
readReg
(
40
+
iaddr
,
1
,
False
)[
0
]
pn
.
append
(
item
)
print
pn
return
pn
def
scanI2C
(
self
):
mystop
=
True
for
iAddr
in
range
(
0
,
128
):
self
.
i2c
.
write
(
iAddr
,
[],
mystop
)
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