예제 #1
0
def get_default_bus():
    """
    Returns the default I2C Bus number based on the platform being used .
    Example: Raspberry Pi will either use bus 0 or 1 (Depending on Pi Revision)
    """
    plat = Platform.platform_detect()
    if plat == Platform.RASPBERRY_PI:
        if Platform.pi_revision() == 1:
            # Revision 1 uses I2C bus 0.
            return 0
        else:
            # Revision 2 Uses I2C Bus 1
            return 1
    elif plat == Platform.BEAGLEBONE_BLACK:
        # The Beaglebone Black has multiple I2C Busses. Default is set for bus1
        # Bus two is for EEPROM and has rules of how it can be used
        return 1
    elif plat == Platform.CUBIEBOARD:
        # This is to return the special bus configuration for the Curbieboards
        if Platform.cubie_revision() == 1:
            return 0
        elif Platform.cubie_revision == 2:
            return 1
        elif Platform.cubie_revision == 3:
            return 2
예제 #2
0
def get_default_bus():
    """
    Returns the default I2C Bus number based on the platform being used .
    Example: Raspberry Pi will either use bus 0 or 1 (Depending on Pi Revision)
    """
    plat = Platform.platform_detect()
    if plat == Platform.RASPBERRY_PI:
        if Platform.pi_revision() == 1:
            # Revision 1 uses I2C bus 0.
            return 0
        else:
            # Revision 2 Uses I2C Bus 1
            return 1
    elif plat == Platform.BEAGLEBONE_BLACK:
        # The Beaglebone Black has multiple I2C Busses. Default is set for bus1
        # Bus two is for EEPROM and has rules of how it can be used
        return 1
    elif plat == Platform.CUBIEBOARD:
        # This is to return the special bus configuration for the Curbieboards
        if Platform.cubie_revision() == 1:
            return 0
        elif Platform.cubie_revision == 2:
            return 1
        elif Platform.cubie_revision == 3:
            return 2
예제 #3
0
def require_repeated_start():
    """
    Enable repeated start conditions for I2C register reads. This is the normal
    behaviour for I2C, but some platforms such as the Raspi have issues with
    this feature and often require explicitly enabliing this feature
    """
    plat = Platform.platform_detetct()
    if plat == Platform.RASPBERRY_PI:
        subprocess.check_call(
            'chmod 666 /sys/module/i2c_bcm2708/parameters/combined',
            shell=True)
        subprocess.check_call(
            'echo -n 1 > /sys/module/i2c_bcm2708/parameters/combined',
            shell=True)
예제 #4
0
def require_repeated_start():
    """
    Enable repeated start conditions for I2C register reads. This is the normal
    behaviour for I2C, but some platforms such as the Raspi have issues with
    this feature and often require explicitly enabliing this feature
    """
    plat = Platform.platform_detetct()
    if plat == Platform.RASPBERRY_PI:
        subprocess.check_call(
            'chmod 666 /sys/module/i2c_bcm2708/parameters/combined',
            shell=True)
        subprocess.check_call(
            'echo -n 1 > /sys/module/i2c_bcm2708/parameters/combined',
            shell=True)