Terminato gertione driver e implementato prima versione beta del driver spb16ch

This commit is contained in:
lejubila
2017-08-20 12:21:30 +02:00
parent 2056b30be0
commit 4322a83977
26 changed files with 739 additions and 10 deletions

35
drv/spb16ch/scripts/ee_write.py Executable file
View File

@@ -0,0 +1,35 @@
#!/usr/bin/python
# coding=utf-8
# Write the eeprom 24C16
# I2C Address: 0x50 (24C16)
# sudo ./ee_write.py 0x50 address data
# Example: sudo ./ee_write.py 50 0 1
import time
import argparse
import RPi.GPIO as GPIO
import smbus
def I2C_setup(i2c_address, eeprom_address, eeprom_data):
I2C_address = 0x50
if GPIO.RPI_REVISION in [2, 3]:
I2C_bus_number = 1
else:
I2C_bus_number = 0
bus = smbus.SMBus(I2C_bus_number)
bus.write_byte_data(I2C_address, eeprom_address, eeprom_data)
def menu():
parser = argparse.ArgumentParser(description='Select address and data to write on eeprom 24C16 ')
parser.add_argument('i2c_address', type=int)
parser.add_argument('eeprom_address', type=int)
parser.add_argument('eeprom_data', type=int)
args = parser.parse_args()
I2C_setup(args.i2c_address, args.eeprom_address, args.eeprom_data)
if __name__ == "__main__":
menu()