Index: __init__.py ================================================================== --- __init__.py +++ __init__.py @@ -220,12 +220,10 @@ def __init__(self, spi_bus, spi_dev, config = None): spi = spidev.SpiDev() spi.open(spi_bus, spi_dev) self.__spi = spi - self.__set_spi_mode(1) - self.configure(config) if len(self.__register_map) != 53: raise ValueError('Inconsistent register map!') @@ -257,21 +255,11 @@ for reg_number, reg_info in enumerate(self.__register_map): if reg_info['name'] == reg_string: return reg_number raise NameError("Invalid register value {}".format(reg_string_orig)) - def __set_spi_mode(self, mode): - if mode != self.__spi.mode: - self.__spi.mode = mode - return True - - def __get_spi_mode(self): - return self.__spi.mode - def __check_radio(self): - old_mode = self.__get_spi_mode() - value1 = self.get_register(0); value2 = self.get_register(1); if value1 == 0x6fe0 and value2 == 0x5681: return True @@ -404,10 +392,16 @@ if config is None: return None self.__spi.max_speed_hz = self.__config.get('frequency', 4000000) + self.__spi.bits_per_word = self.__config.get('bits_per_word', 8) + self.__spi.cshigh = self.__config.get('csigh', False) + self.__spi.no_cs = self.__config.get('no_cs', False) + self.__spi.lsbfirst = self.__config.get('lsbfirst', False) + self.__spi.threewire = self.__config.get('threewire', False) + self.__spi.mode = self.__config.get('mode', 1) return None def initialize(self): self.__reset_device()