Git Product home page Git Product logo

pybuspiratelite's Introduction

Documentation Status

pyBusPirateLite

Python library for BusPirate based on code from Garrett Berg. It tries to be more Pythonic than the original code.

This library allows using the following modes:

  • SPI
  • I2C
  • UART
  • Bitbang
  • Onewire
  • Rawwire
  • ADC measurements

For more information about the BusPirate see http://dangerousprototypes.com/docs/Bus_Pirate

Based on code from Garrett Berg [email protected] (http://dangerousprototypes.com/2011/03/14/new-version-of-pybuspiratelite-python-library/)

Note: Python 3.6 is required, mainly due to the use of f-strings.

Examples

SPI

from pyBusPirateLite.SPI import SPI

spi = SPI()
spi.pins = SPI.PIN_POWER | SPI.PIN_CS 
spi.config = SPI.CFG_PUSH_PULL | SPI.CFG_IDLE
spi.speed = '1MHz'

# send two bytes and receive answer
spi.cs = True
data = spi.transfer( [0x82, 0x00])
spi.cs = False

Bitbang

from pyBusPirateLite.BitBang import BitBang

bb = BitBang()
bb.outputs = bb.PIN_AUX
bb.pins = 0        # set aux pin = 0   
bb.pins = bb.PIN_AUX  # set aux pin = 1

I2C

from pyBusPirateLite.I2C import I2C
i2c = I2C()
i2c.speed = '400kHz'
i2c.configure(power=True)
i2c.write_then_read(2,0, [0xec, 0xf6])  # set write register
i2c.write_then_read(1,1,[ 0xed])        # read from register

Detect port

from pyBusPirateLite.BitBang import BitBang
bb = BitBang(connect=False)
port = bb.get_port()
print(port)
bb.connect()

pybuspiratelite's People

Contributors

juhasch avatar fgervais avatar jaseg avatar a3f avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.