Exemple #1
0
def clock_data():
	# drive clock high
	old_value = I2C.read_data(port_expand_A_addr, 'B') # read in the previous control pins
	clock_high_mask = 0b00000100
	clock_high_value = old_value | clock_high_mask # OR, set clock high
	I2C.write_data(port_expand_A_addr, 'B', clock_high_value)
	
	# drive clock low
	old_value = I2C.read_data(port_expand_A_addr, 'B') # read in the previous control pins
	clock_low_mask = 0b11111011
	clock_low_value = old_value & clock_low_mask # AND, set clock low
	I2C.write_data(port_expand_A_addr, 'B', clock_low_value)
Exemple #2
0
def read_OVERFLOW_OUT():
	test = 0b00000100 # overflow out is set
	OVERFLOW_OUT = I2C.read_data(port_expand_ALU_addr, 'B') # OVERFLOW_OUT from ALU
	if (test & OVERFLOW_OUT) == 0b00000100: # test for carry out being 1
		return 1
	elif (test & OVERFLOW_OUT) == 0b00000000: # test for carry out being 0
		return 0
Exemple #3
0
def read_C_OUT():
	test = 0b00000010 # carry out is set
	C_OUT = I2C.read_data(port_expand_ALU_addr, 'B') # C_OUT from ALU
	if (test & C_OUT) == 0b00000010: # test for carry out being 1
		return(1)
	elif (test & C_OUT) == 0b00000000: # test for carry out being 0
		return(0)
Exemple #4
0
def set_zero_buffer(enable):
	old_value = I2C.read_data(port_expand_A_addr, 'B') # read in the previous control pins
	if enable == 1:
		mask = 0b11111110 # set zero buffer signal low
		new_value = old_value & mask # AND
	elif enable == 0:
		mask = 0b00000011 # set zero buffer signal high
		new_value = old_value | mask # OR
	I2C.write_data(port_expand_A_addr, 'B', new_value) # write to Port B
Exemple #5
0
def set_OR(enable):
	old_control_bus = I2C.read_data(port_expand_ALU_addr, 'A') # read the previous Port A
	if enable == 1:
		mask = 0b11111011 # set OR signal low
		new_control_bus = old_control_bus & mask # AND
	elif enable == 0:
		mask = 0b00011111 # set OR signal high
		new_control_bus = old_control_bus | mask # OR
	I2C.write_data(port_expand_ALU_addr, 'A', new_control_bus) # activate OR ouput
Exemple #6
0
def set_C_IN(C_IN):
	old_value = I2C.read_data(port_expand_ALU_addr, 'B') # read in the previous Port B
	if C_IN == 0:
		mask = 0b11111110
		new_value = old_value & mask # AND, unset
	elif C_IN == 1:
		mask = 0b00000001
		new_value = old_value | mask # OR, set	
	I2C.write_data(port_expand_ALU_addr, 'B', new_value)
Exemple #7
0
def read_register():
	return(I2C.read_data(port_expand_B_addr, 'A'))
Exemple #8
0
def read_register():
	I2C.write_data(port_expand_ADD_addr, 'B', 0b00000010) # enable ADD OUT buffer
	data = I2C.read_data(port_expand_ADD_addr, 'A')
	# I2C.write_data(port_expand_ADD_addr, 'B', 0b00000011) # disable ADD OUT buffer
	return data