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
ce236814
Commit
ce236814
authored
Feb 06, 2018
by
Paolo Baesso
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
First example of switching LED on/off
parent
21b8530c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
128 additions
and
4 deletions
+128
-4
AIDA_testPower.py
TLU_v1e/scripts/AIDA_testPower.py
+85
-0
TLU_v1e.py
TLU_v1e/scripts/TLU_v1e.py
+34
-2
localIni.ini
TLU_v1e/scripts/localIni.ini
+7
-0
startTLU_v1e.py
TLU_v1e/scripts/startTLU_v1e.py
+2
-2
No files found.
TLU_v1e/scripts/AIDA_testPower.py
0 → 100644
View file @
ce236814
# -*- coding: utf-8 -*-
import
uhal
from
I2CuHal
import
I2CCore
import
time
#import miniTLU
from
si5345
import
si5345
from
AD5665R
import
AD5665R
from
PCA9539PW
import
PCA9539PW
from
E24AA025E48T
import
E24AA025E48T
manager
=
uhal
.
ConnectionManager
(
"file://./TLUconnection.xml"
)
hw
=
manager
.
getDevice
(
"tlu"
)
# hw.getNode("A").write(255)
reg
=
hw
.
getNode
(
"version"
)
.
read
()
hw
.
dispatch
()
print
"CHECK REG= "
,
hex
(
reg
)
# #First I2C core
print
(
"Instantiating master I2C core:"
)
master_I2C
=
I2CCore
(
hw
,
10
,
5
,
"i2c_master"
,
None
)
master_I2C
.
state
()
#
# #######################################
enableCore
=
False
#Only need to run this once, after power-up
if
(
enableCore
):
mystop
=
True
print
" Write RegDir to set I/O[7] to output:"
myslave
=
0x21
mycmd
=
[
0x01
,
0x7F
]
nwords
=
1
master_I2C
.
write
(
myslave
,
mycmd
,
mystop
)
mystop
=
False
mycmd
=
[
0x01
]
master_I2C
.
write
(
myslave
,
mycmd
,
mystop
)
res
=
master_I2C
.
read
(
myslave
,
nwords
)
print
"
\t
Post RegDir: "
,
res
#DAC CONFIGURATION BEGIN
if
(
False
):
zeDAC1
=
AD5665R
(
master_I2C
,
0x1C
)
zeDAC1
.
setIntRef
(
intRef
=
False
,
verbose
=
True
)
zeDAC1
.
writeDAC
(
0x0
,
7
,
verbose
=
True
)
#7626
if
(
True
):
# #I2C EXPANDER CONFIGURATION BEGIN
IC6
=
PCA9539PW
(
master_I2C
,
0x76
)
#BANK 0
IC6
.
setInvertReg
(
0
,
0x00
)
# 0= normal
IC6
.
setIOReg
(
0
,
0x00
)
# 0= output <<<<<<<<<<<<<<<<<<<
IC6
.
setOutputs
(
0
,
0x00
)
res
=
IC6
.
getInputs
(
0
)
print
"IC6 read back bank 0: 0x
%
X"
%
res
[
0
]
#
#BANK 1
IC6
.
setInvertReg
(
1
,
0x00
)
# 0= normal
IC6
.
setIOReg
(
1
,
0x00
)
# 0= output <<<<<<<<<<<<<<<<<<<
IC6
.
setOutputs
(
1
,
0x00
)
res
=
IC6
.
getInputs
(
1
)
print
"IC6 read back bank 1: 0x
%
X"
%
res
[
0
]
# # #
IC7
=
PCA9539PW
(
master_I2C
,
0x77
)
#BANK 0
IC7
.
setInvertReg
(
0
,
0x00
)
# 0= normal
IC7
.
setIOReg
(
0
,
0x00
)
# 0= output <<<<<<<<<<<<<<<<<<<
IC7
.
setOutputs
(
0
,
0x00
)
res
=
IC7
.
getInputs
(
0
)
print
"IC7 read back bank 0: 0x
%
X"
%
res
[
0
]
#
#BANK 1
IC7
.
setInvertReg
(
1
,
0x00
)
# 0= normal
IC7
.
setIOReg
(
1
,
0x00
)
# 0= output <<<<<<<<<<<<<<<<<<<
IC7
.
setOutputs
(
1
,
0x00
)
res
=
IC7
.
getInputs
(
1
)
print
"IC7 read back bank 1: 0x
%
X"
%
res
[
0
]
# #I2C EXPANDER CONFIGURATION END
TLU_v1e/scripts/TLU_v1e.py
View file @
ce236814
...
...
@@ -101,10 +101,42 @@ class TLU:
self
.
IC7
.
setInvertReg
(
1
,
0x00
)
# 0= normal, 1= inverted
self
.
IC7
.
setIOReg
(
1
,
0x00
)
# 0= output, 1= input
self
.
IC7
.
setOutputs
(
1
,
0xB0
)
# If output, set to XX
#Display
self
.
DISP
=
CFA632
(
self
.
TLU_I2C
,
0x2A
)
#
#Power/Led Module
dac_addr_module
=
int
(
parsed_cfg
.
get
(
section_name
,
"I2C_DACModule_Addr"
),
16
)
self
.
zeDAC_pwr
=
AD5665R
(
self
.
TLU_I2C
,
dac_addr_module
)
self
.
zeDAC_pwr
.
setIntRef
(
self
.
intRefOn
,
self
.
verbose
)
print
"BOH"
self
.
writeThreshold
(
self
.
zeDAC_pwr
,
-
1
,
0
,
self
.
verbose
)
self
.
writeThreshold
(
self
.
zeDAC_pwr
,
-
1
,
1
,
self
.
verbose
)
self
.
writeThreshold
(
self
.
zeDAC_pwr
,
-
1
,
2
,
self
.
verbose
)
self
.
writeThreshold
(
self
.
zeDAC_pwr
,
-
1
,
3
,
self
.
verbose
)
exp1_addr
=
int
(
parsed_cfg
.
get
(
section_name
,
"I2C_EXP1Module_Addr"
),
16
)
self
.
ledExp1
=
PCA9539PW
(
self
.
TLU_I2C
,
exp1_addr
)
self
.
ledExp1
.
setInvertReg
(
0
,
0x00
)
# 0= normal, 1= inverted
self
.
ledExp1
.
setIOReg
(
0
,
0x00
)
# 0= output, 1= input
self
.
ledExp1
.
setOutputs
(
0
,
0x1F
)
# If output, set to XX
self
.
ledExp1
.
setInvertReg
(
1
,
0x00
)
# 0= normal, 1= inverted
self
.
ledExp1
.
setIOReg
(
1
,
0x00
)
# 0= output, 1= input
self
.
ledExp1
.
setOutputs
(
1
,
0x1D
)
# If output, set to XX
exp2_addr
=
int
(
parsed_cfg
.
get
(
section_name
,
"I2C_EXP2Module_Addr"
),
16
)
self
.
ledExp2
=
PCA9539PW
(
self
.
TLU_I2C
,
exp1_addr
)
self
.
ledExp2
.
setInvertReg
(
0
,
0x00
)
# 0= normal, 1= inverted
self
.
ledExp2
.
setIOReg
(
0
,
0x00
)
# 0= output, 1= input
self
.
ledExp2
.
setOutputs
(
0
,
0x85
)
# If output, set to XX
self
.
ledExp2
.
setInvertReg
(
1
,
0x00
)
# 0= normal, 1= inverted
self
.
ledExp2
.
setIOReg
(
1
,
0x00
)
# 0= output, 1= input
self
.
ledExp2
.
setOutputs
(
1
,
0x3E
)
# If output, set to XX
print
"BLAH"
print
self
.
ledExp2
.
getOutputs
(
1
)
##################################################################################################################################
##################################################################################################################################
...
...
TLU_v1e/scripts/localIni.ini
View file @
ce236814
...
...
@@ -25,6 +25,13 @@ I2C_ID_Addr = 0x50
I2C_EXP1_Addr
=
0x74
#I2C address of 2st expander PCA9539PW
I2C_EXP2_Addr
=
0x75
#I2C address of AD5665R on powermodule
I2C_DACModule_Addr
=
0x1C
#I2C address of 1st expander PCA9539PW on powermodule
I2C_EXP1Module_Addr
=
0x76
#I2C address of 2nd expander PCA9539PW on powermodule
I2C_EXP2Module_Addr
=
0x77
##CONFCLOCK 0= skip clock configuration, 1= configure si5345
CONFCLOCK
=
0
...
...
TLU_v1e/scripts/startTLU_v1e.py
View file @
ce236814
...
...
@@ -240,7 +240,7 @@ if __name__ == "__main__":
###TLU.stop(False, False)
# Start interactive prompt
print
"=
+
=================================================================="
print
"=
=
=================================================================="
print
"==========================TLU TEST CONSOLE=========================="
print
"
+
==================================================================="
print
"
=
==================================================================="
prompt
.
cmdloop
(
"Type 'help' for a list of commands."
)
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