Skip to content
Snippets Groups Projects
Commit 9168a14d authored by Paulus Kruger's avatar Paulus Kruger
Browse files

UNB2 LED working, inverted

parent 51c1a4d0
No related branches found
No related tags found
No related merge requests found
...@@ -76,7 +76,7 @@ device_registers: ...@@ -76,7 +76,7 @@ device_registers:
description: IO-Expander for front panel description: IO-Expander for front panel
address: 0x41 address: 0x41
device: PCA9536 device: PCA9536
driver: d_front_panel driver: switch_FP
registers: registers:
- name: CONF #default 0xff = all input - name: CONF #default 0xff = all input
description: Direction of GPIO description: Direction of GPIO
...@@ -154,7 +154,7 @@ variables: ...@@ -154,7 +154,7 @@ variables:
mask: UNB2_mask mask: UNB2_mask
driver: switch_FP driver: switch_FP
devreg: FP_IO.GPIO devreg: FP_IO.GPIO
bitoffset: 4 # bitoffset: 4
width: 3 width: 3
rw: rw rw: rw
dtype: uint8 dtype: uint8
...@@ -367,10 +367,11 @@ methods: ...@@ -367,10 +367,11 @@ methods:
- name: UNB2_on - name: UNB2_on
mask: UNB2_mask mask: UNB2_mask
driver: switch_FP
instructions: instructions:
# - FP_IO.CONF: 0xff #TODO: setup correctly - FP_IO.CONF: 0xf8 #bit 0-2 output for LED
- UNB2_PWR_on: 0 #already inverted - UNB2_PWR_on: 0 #already inverted
- UNB2_Front_Panel_LED_colour: 1 - UNB2_Front_Panel_LED_colour: 3 #green
- UNB2_PCB_ID: Update - UNB2_PCB_ID: Update
- UNB2_PCB_version: Update - UNB2_PCB_version: Update
......
...@@ -26,6 +26,8 @@ class gpio(hwdev): ...@@ -26,6 +26,8 @@ class gpio(hwdev):
logging.warning("Wrong mask length"); logging.warning("Wrong mask length");
mask=[True]*self.Npins; mask=[True]*self.Npins;
if len(data)!=self.Npins: if len(data)!=self.Npins:
if len(data)==1: data=[data[0]]*self.Npins;
else:
logging.warning("Wrong data length"); logging.warning("Wrong data length");
return [] return []
for i,pin in enumerate(self.pins): for i,pin in enumerate(self.pins):
......
...@@ -37,9 +37,18 @@ class i2c_array2(i2c_array): ...@@ -37,9 +37,18 @@ class i2c_array2(i2c_array):
self.conf['parentcls'].SetSW3(self.sw3[RCUi]); self.conf['parentcls'].SetSW3(self.sw3[RCUi]);
def SetSwitchMask(self,mask): def SetSwitchMask(self,mask):
logging.warn("Not implemented!!") sw1=[];sw2=[];sw3=[];
# m=0; m=0;
# for RCUi in range(self.N): for RCUi in range(self.N):
# if mask[RCUi]: m|=1<<self.RCU_Switch1[RCUi]; if mask[RCUi]:
if self.sw1[RCUi] not in sw1: sw1.append(self.sw1[RCUi])
if self.sw2[RCUi] not in sw2: sw2.append(self.sw2[RCUi])
if len(self.sw3)>0:
if self.sw3[RCUi] not in sw3: sw3.append(self.sw3[RCUi])
logging.info(str(("SetSwitchMask",sw1,sw2,sw3)))
self.conf['parentcls'].SetSWx(sw1,sw2,sw3)
# self.conf['parentcls'].SetSW1(self.sw1[RCUi]);
# m|=1<<self.RCU_Switch1[RCUi];
# self.conf['parentcls'].SetChannel(m); # self.conf['parentcls'].SetChannel(m);
...@@ -12,7 +12,7 @@ class i2c_switch2(i2c): ...@@ -12,7 +12,7 @@ class i2c_switch2(i2c):
self.channel2=-1 self.channel2=-1
self.channel3=-1 self.channel3=-1
logging.info("i2c switch2 at address %i,%i,%i" % (self.SWaddr1,self.SWaddr2,self.SWaddr3)) logging.info("i2c switch2 at address %i,%i,%i" % (self.SWaddr1,self.SWaddr2,self.SWaddr3))
logging.warn("APSCT switch disabled for testing") # logging.warn("APSCT switch disabled for testing")
def SetSW1(self,channelbit): def SetSW1(self,channelbit):
channel=1<<(channelbit) channel=1<<(channelbit)
...@@ -21,8 +21,8 @@ class i2c_switch2(i2c): ...@@ -21,8 +21,8 @@ class i2c_switch2(i2c):
self.channel1=channel self.channel1=channel
self.channel2=-1 self.channel2=-1
self.channel3=-1 self.channel3=-1
return True; #testing without APSCT switch # return True; #testing without APSCT switch
# return self.i2csetget(self.SWaddr1,[channel]) return self.i2csetget(self.SWaddr1,[channel])
def SetSW2(self,channelbit): def SetSW2(self,channelbit):
channel=1<<(channelbit) channel=1<<(channelbit)
...@@ -39,3 +39,21 @@ class i2c_switch2(i2c): ...@@ -39,3 +39,21 @@ class i2c_switch2(i2c):
self.channel3=channel self.channel3=channel
return self.i2csetget(self.SWaddr3,[channel]) return self.i2csetget(self.SWaddr3,[channel])
def SetSWx(self,sw1,sw2,sw3):
channel=0;
for x in sw1: channel+=(1<<x);
self.channel1=channel;
self.i2csetget(self.SWaddr1,[channel])
if channel==0: return;
channel=0;
for x in sw2: channel+=(1<<x);
self.channel2=channel;
self.i2csetget(self.SWaddr2,[channel])
if channel==0: return;
channel=0;
for x in sw3: channel+=(1<<x);
if channel==0: return;
self.channel3=channel;
self.i2csetget(self.SWaddr3,[channel])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment