Ejemplo n.º 1
0
# gpio.py
# Part of PyBBIO
# github.com/alexanderhiam/PyBBIO
# MIT License
#
# Beaglebone GPIO driver

import os, math, sysfs
from bbio.util import addToCleanup
from config import GET_USR_LED_DIRECTORY, GPIO, GPIO_FILE_BASE, INPUT,\
                   CONF_PULLUP, CONF_PULLDOWN, CONF_PULL_DISABLE,\
                   CONF_GPIO_INPUT, CONF_GPIO_OUTPUT, FALLING, HIGH, LOW,\
                   MSBFIRST

from bbio.platform.platform import detect_platform
_platform = detect_platform()
if "3.8" in _platform:
    from bone_3_8 import pinmux
elif "3.2" in _platform:
    from bone_3_2 import pinmux
del _platform


def getGPIODirectory(gpio_pin):
    """ Returns the sysfs kernel driver base directory for the given pin. """
    if 'USR' in gpio_pin:
        # USR LEDs use a different driver
        return GET_USR_LED_DIRECTORY(gpio_pin)
    gpio_num = GPIO[gpio_pin][2]
    return '%s/gpio%i' % (GPIO_FILE_BASE, gpio_num)
Ejemplo n.º 2
0
Archivo: i2c.py Proyecto: Ikario/PyBBIO
# github.com/alexanderhiam/PyBBIO
# This library - github.com/deepakkarki
# MIT License
# 
# Beaglebone i2c driver

#Note : Three i2c buses are present on the BBB; i2c-0 is used for eeprom access - so not useable
#       i2c-1 is loaded default; /devices/ocp.2/4819c000.i2c/i2c-1  ---- this actually is the i2c2 bus
#       to activate i2c1 bus; echo BB-I2C1 > /sys/devices/bone_capemgr.8/slots; will be now present at /dev/i2c-2
#       reference : http://datko.net/2013/11/03/bbb_i2c/

import bbio
from config import I2C

from bbio.platform.platform import detect_platform 
_platform = detect_platform()
if "3.8" in _platform:
  from bone_3_8.i2c_setup import i2cInit
elif "3.2" in _platform:
  from bone_3_2.i2c_setup import i2cInit
del _platform

try:
  import smbus
except:
  print "\n python-smbus module not found\n"
  print "on Angstrom Linux : ~#opkg install python-smbus\n"
  print "on Ubuntu, Debian : ~#apt-get install python-smbus"


class _I2C_BUS(object):
Ejemplo n.º 3
0
# initialization for beaglebone

from bbio.platform.platform import detect_platform 
PLATFORM = detect_platform()

if "3.8" in PLATFORM:
  from bone_3_8 import config
  from bone_3_8.adc import analogRead, inVolts
  from bone_3_8.pwm import analogWrite, pwmFrequency, pwmEnable, pwmDisable
  
elif "3.2" in PLATFORM:
  from bone_3_2 import config
  from bone_3_2.adc import analogRead, inVolts
  from bone_3_2.pwm import analogWrite, pwmFrequency, pwmEnable, pwmDisable
  
from gpio import pinMode, digitalWrite, digitalRead, toggle, pinState, \
                 shiftIn, shiftOut
from interrupt import attachInterrupt, detachInterrupt
from serial_port import Serial1, Serial2, Serial4, Serial5
from i2c import Wire1, Wire2
from spi import SPI0, SPI1

from api import platform_init, platform_cleanup

from config import USR0, USR1, USR2, USR3, GPIO0_2, GPIO0_3, GPIO0_4, GPIO0_5,\
                   GPIO0_7, GPIO0_8, GPIO0_9, GPIO0_10, GPIO0_11, GPIO0_12,\
                   GPIO0_13, GPIO0_14, GPIO0_15, GPIO0_20, GPIO0_22, GPIO0_23,\
                   GPIO0_26, GPIO0_27, GPIO0_30, GPIO0_31, GPIO1_0, GPIO1_1,\
                   GPIO1_2, GPIO1_3, GPIO1_4, GPIO1_5, GPIO1_6, GPIO1_7,\
                   GPIO1_12, GPIO1_13, GPIO1_14, GPIO1_15, GPIO1_16, GPIO1_17,\
                   GPIO1_18, GPIO1_19, GPIO1_28, GPIO1_29, GPIO1_30, GPIO1_31,\
Ejemplo n.º 4
0
Archivo: api.py Proyecto: sintrb/PyBBIO
# api.py 
# Part of PyBBIO
# github.com/alexanderhiam/PyBBIO
# MIT License
# 
# Beaglebone platform API file.


from bbio.platform.platform import detect_platform 
PLATFORM = detect_platform()

if "3.8" in PLATFORM:
  from bone_3_8.adc import analog_init, analog_cleanup
  from bone_3_8.pwm import pwm_init, pwm_cleanup
  from serial_port import serial_cleanup
  
elif "3.2" in PLATFORM:
  from bone_3_2.adc import analog_init, analog_cleanup
  from bone_3_2.pwm import pwm_init, pwm_cleanup
  from serial_port import serial_cleanup
  
def platform_init():
  analog_init()
  pwm_init()

def platform_cleanup():
  analog_cleanup()
  pwm_cleanup()
  serial_cleanup()