예제 #1
0
    def msg(self, aSpeed, aLen, aMsg):
        """ send/rcv message
            aSpeed : spi speed
            aLen : number of bits to send
            aMsg : list of bytes to send (max 8)
        """
        if aLen <= 0:
            raise AsSpiError("aLen must be upper than 0")
        if aLen > 64:
            raise AsSpiError("aLen can't be upper than 64")

        if type(aMsg) != type([]):
            raise AsSpiError("aMsg argument must be a list")
        if len(aMsg) <= 0:
            raise AsSpiError("aMsg list must have at least one value")
        if len(aMsg) > 8:
            raise AsSpiError("aMsg list can have 8 values maximum")
   
        if aLen%8 == 0:
            list_len = aLen/8
        else:
            list_len = (aLen/8) + 1

        msg = aMsg + [0 for i in range(8 - list_len)]

        try:
            return wrapper.spi_msg(self.__device, aSpeed, aLen,
                    msg[7], msg[6], msg[5], msg[4], msg[3], msg[2], msg[1], msg[0])
        except Exception, e:
            raise AsSpiError(str(e))
예제 #2
0
 def setBitsPerWord(self, aBits):
     """ Set bits per word
     """
     try:
         return wrapper.spi_set_bits_per_word(self.__device, aBits)
     except Exception, e:
         raise AsSpiError(str(e))
예제 #3
0
 def getSpeed(self):
     """ get speed
     """
     try:
         return wrapper.spi_get_speed(self.__device)
     except Exception, e:
         raise AsSpiError(str(e))
예제 #4
0
 def setSpeed(self, aSpeed):
     """ Set speed
     """
     try:
         return wrapper.spi_set_speed(self.__device, aSpeed)
     except Exception, e:
         raise AsSpiError(str(e))
예제 #5
0
 def getSpeed(self):
     """ get speed
     """
     try:
         return wrapper.spi_get_speed(self.__device)
     except Exception, e:
         raise AsSpiError(str(e))
예제 #6
0
 def getLsb(self):
     """ Get lsb
     """
     try:
         return wrapper.spi_get_lsb(self.__device)
     except Exception, e:
         raise AsSpiError(str(e))
예제 #7
0
 def getMode(self):
     """ Set mode
     """
     try:
         return wrapper.spi_get_mode(self.__device)
     except Exception, e:
         raise AsSpiError(str(e))
예제 #8
0
    def msg(self, aSpeed, aLen, aMsg):
        """ send/rcv message
            aSpeed : spi speed
            aLen : number of bits to send
            aMsg : list of bytes to send (max 8)
        """
        if aLen <= 0:
            raise AsSpiError("aLen must be upper than 0")
        if aLen > 64:
            raise AsSpiError("aLen can't be upper than 64")

        if type(aMsg) != type([]):
            raise AsSpiError("aMsg argument must be a list")
        if len(aMsg) <= 0:
            raise AsSpiError("aMsg list must have at least one value")
        if len(aMsg) > 8:
            raise AsSpiError("aMsg list can have 8 values maximum")

        if aLen % 8 == 0:
            list_len = aLen / 8
        else:
            list_len = (aLen / 8) + 1

        msg = aMsg + [0 for i in range(8 - list_len)]

        try:
            return wrapper.spi_msg(self.__device, aSpeed, aLen, msg[7], msg[6],
                                   msg[5], msg[4], msg[3], msg[2], msg[1],
                                   msg[0])
        except Exception, e:
            raise AsSpiError(str(e))
예제 #9
0
 def setLsb(self, aLsb):
     """ Set lsb
     """
     try:
         return wrapper.spi_set_lsb(self.__device, aLsb)
     except Exception, e:
         raise AsSpiError(str(e))
예제 #10
0
 def getBitsPerWord(self):
     """ Get bits per word
     """
     try:
         return wrapper.spi_get_bits_per_word(self.__device)
     except Exception, e:
         raise AsSpiError(str(e))
예제 #11
0
 def setBitsPerWord(self, aBits):
     """ Set bits per word
     """
     try:
         return wrapper.spi_set_bits_per_word(self.__device, aBits)
     except Exception, e:
         raise AsSpiError(str(e))
예제 #12
0
 def setSpeed(self, aSpeed):
     """ Set speed
     """
     try:
         return wrapper.spi_set_speed(self.__device, aSpeed)
     except Exception, e:
         raise AsSpiError(str(e))
예제 #13
0
 def getBitsPerWord(self):
     """ Get bits per word
     """
     try:
         return wrapper.spi_get_bits_per_word(self.__device)
     except Exception, e:
         raise AsSpiError(str(e))
예제 #14
0
 def getMode(self):
     """ Set mode
     """
     try:
         return wrapper.spi_get_mode(self.__device)
     except Exception, e:
         raise AsSpiError(str(e))
예제 #15
0
 def getLsb(self):
     """ Get lsb
     """
     try:
         return wrapper.spi_get_lsb(self.__device)
     except Exception, e:
         raise AsSpiError(str(e))
예제 #16
0
 def setLsb(self, aLsb):
     """ Set lsb
     """
     try:
         return wrapper.spi_set_lsb(self.__device, aLsb)
     except Exception, e:
         raise AsSpiError(str(e))
예제 #17
0
 def __del__(self):
     try:
         wrapper.spi_close(self.__device)
     except Exception, e:
         pass
예제 #18
0
 def __init__(self, aSpidevName):
     try:
         self.__device = wrapper.spi_open(aSpidevName)
     except Exception, e:
         raise AsSpiError(str(e))
예제 #19
0
 def __del__(self):
     try:
         wrapper.spi_close(self.__device)
     except Exception, e:
         pass
예제 #20
0
 def __init__(self, aSpidevName):
     try:
         self.__device = wrapper.spi_open(aSpidevName)
     except Exception, e:
         raise AsSpiError(str(e))