def writeModule(address1,address2,data1,data2): if wiringdata.checkSetting() == 0: spi.mode = 0 #print "writeModule data1 = ",data1,"data2 = ",data2 #spi.max_speed_hz = 1000000 spi.max_speed_hz = ModuleSPIHz addr1=(address1>>8) & 0x00ff addr2=(address1 & 0x00ff) addr3=(address2>>8) & 0x00ff addr4=(address2 & 0x00ff) resp=spi.xfer2([addr1]) #time.sleep(ModuleSPIdelay) resp=spi.xfer2([addr2]) #time.sleep(ModuleSPIdelay) resp=spi.xfer2([addr3]) #time.sleep(ModuleSPIdelay) resp=spi.xfer2([addr4]) #time.sleep(ModuleSPIdelay) resp=spi.xfer2([data1]) #time.sleep(ModuleSPIdelay) resp=spi.xfer2([data2]) time.sleep(ModuleSPIdelay)
def restSignal(): if wiringdata.checkSetting() == 0: spi.mode = 0 #spi.max_speed_hz = 1000000 spi.max_speed_hz = ModuleSPIHz resp=spi.xfer2([0x00]) #time.sleep(ModuleSPIdelay) resp=spi.xfer2([0x00]) #time.sleep(ModuleSPIdelay) resp=spi.xfer2([0x00]) #time.sleep(ModuleSPIdelay) resp=spi.xfer2([0x00]) #time.sleep(ModuleSPIdelay) resp=spi.xfer2([0x00]) #time.sleep(ModuleSPIdelay) resp=spi.xfer2([0x00]) time.sleep(ModuleSPIdelay)
def secondConnect(self): #print "second connect!" #self.regSecondBank(self.BANK) #mil.openModule(self.addr1,self.addr2,self.pinTypeData) if wiringdata.checkSetting() == 0: self.pinData = self.secondPinData self.regSecondBank(self.BANK) #print self.pinTypeData if self.pinTypeData != 0x03: mil.openModule(self.addr1, self.addr2, self.pinTypeData)
def writeBase(data1,data2): if wiringdata.checkSetting() == 0: spi.mode = 0 #print "writeBase data1 = ",data1,"data2 = ",data2 #spi.max_speed_hz = 1000000 spi.max_speed_hz = BaseSPIHz resp=spi.xfer2([0x80]) resp=spi.xfer2([0x00]) resp=spi.xfer2([0x00]) resp=spi.xfer2([0x00]) resp=spi.xfer2([data1]) resp=spi.xfer2([data2]) time.sleep(BaseSPIdelay)
def detectModule(address1,address2): location = 0xff if wiringdata.checkSetting() == 0: #print "address1 = ",hex(address1)," address2 = ",hex(address2) detectInit() #location = 0xff #writeModule((address>>8),(address & 0x00ff),0x03,0xff) #time.sleep(0.1) writeModule(address1,address2,0x03,0xff) #time.sleep(5) #if GPIO.input(p.inpin[4])==False: if wiringdata.IOin(p.inpin[0])==False: #print("CON 1") location = 1 #elif GPIO.input(p.inpin[5])==False: elif wiringdata.IOin(p.inpin[1])==False: #print("CON 2") location = 5 #elif GPIO.input(p.inpin[6])==False: elif wiringdata.IOin(p.inpin[2])==False: #print("CON 3") location = 9 #elif GPIO.input(p.inpin[7])==False: elif wiringdata.IOin(p.inpin[3])==False: #print("CON 4") location = 13 #writeModule((address>>8),(address & 0x00ff),0x04,0xff) writeModule(address1,address2,0x04,0xff) detectEnd() return location