Commit 90c88f4c authored by juhasch's avatar juhasch

Docs fixes

parent acf2c6bc
# pyBusPirateLite
Python library for BusPirate based on code from Garrett Berg.
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:
......@@ -15,9 +17,9 @@ For more information about the BusPirate see http://dangerousprototypes.com/docs
Based on code from Garrett Berg <cloudform511@gmail.com>
(http://dangerousprototypes.com/2011/03/14/new-version-of-pybuspiratelite-python-library/)
-------------------------
## Examples
Examples
--------
### SPI
......
......@@ -14,13 +14,11 @@
# serve to show the default.
import sys
import os
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.insert(1, '/Users/juhasch/git/PhysicalQuantities/')
#os.path.abspath('..'))
sys.path.insert(1, '../')
import pyBusPirateLite
......@@ -34,11 +32,9 @@ import pyBusPirateLite
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.mathjax',
'sphinx.ext.viewcode',
'numpydoc',
'sphinx.ext.autosummary',
'IPython.sphinxext.ipython_console_highlighting'
'sphinx.ext.autosummary'
]
# Add any paths that contain templates here, relative to this directory.
......@@ -56,7 +52,7 @@ master_doc = 'index'
# General information about the project.
project = 'pyBusPirateLite'
copyright = '2016, Juergen Hasch'
copyright = '2017, Juergen Hasch'
author = 'Jürgen Hasch'
# The version info for the project you're documenting, acts as replacement for
......@@ -64,9 +60,9 @@ author = 'Jürgen Hasch'
# built documents.
#
# The short X.Y version.
version = pyBusPirateLite.__version__
version = str(pyBusPirateLite.__version__)
# The full version, including alpha/beta/rc tags.
release = pyBusPirateLite.__version__
release = str(pyBusPirateLite.__version__)
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
......@@ -146,7 +142,7 @@ html_theme = 'alabaster'
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
#html_static_path = ['_static']
# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
......
.. pyBusPirateLite documentation master file
*****************************
pyBusPirateLite Documentation
================================
*****************************
# pyBusPirateLite
Python library for BusPirate
Python library for BusPirate based on code from Garrett Berg.
It tries to be more Pythonic than the original code. This mostly means using getters/setters instead of explicit
function calls.
This library allows using the following modes:
* SPI
* I2C
* UART
* Bitbang
* Onewire
* Rawwire
* SPI
* I2C
* UART
* Bitbang
* Onewire
* Rawwire
For more information about the BusPirate see http://dangerousprototypes.com/docs/Bus_Pirate
Based on code from Garrett Berg <cloudform511@gmail.com>
(http://dangerousprototypes.com/2011/03/14/new-version-of-pybuspiratelite-python-library/)
Examples
########
SPI::
from pyBusPirateLite.SPI import *
spi = SPI()
spi.pins = PIN_POWER | PIN_CS
spi.config = CFG_PUSH_PULL | 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
from pyBusPirateLite.BBIO_base import PIN_AUX
bb = BitBang()
bb.outputs = PIN_AUX
bb.pins = 0 # set aux pin = 0
bb.pins = PIN_AUX # set aux pin = 1
2C::
from pyBusPirateLite.SPI import *
i2c = I2C()
i2c.pins = PIN_POWER | PIN_CS
i2c.speed = '50kHz'
Get BusPirate serial port::
from pyBusPirateLite.BitBang import BitBang
bb = BitBang(connect=False)
port = bb.get_port()
print(port)
Classes
#######
pyBusPirateLite.BBIO_base.BBIO_base
-----------------------------------
.. autoclass:: pyBusPirateLite.BBIO_base.BBIO_base
:members:
:undoc-members:
:show-inheritance:
pyBusPirateLite.BitBang.BitBang
-------------------------------
.. autoclass:: pyBusPirateLite.BitBang.BitBang
:members:
:undoc-members:
:show-inheritance:
pyBusPirateLite.I2C.I2C
-----------------------
.. autoclass:: pyBusPirateLite.I2C.I2C
:members:
:undoc-members:
:show-inheritance:
pyBusPirateLite.SPI.SPI
-----------------------
.. autoclass:: pyBusPirateLite.SPI.SPI
:members:
:undoc-members:
:show-inheritance:
pyBusPirateLite.UART.UART
-------------------------
**Contents**
.. autoclass:: pyBusPirateLite.UART.UART
:members:
:undoc-members:
:show-inheritance:
*User Guide:*
pyBusPirateLite.UC.UC
---------------------
.. toctree::
:maxdepth: 2
.. autoclass:: pyBusPirateLite.UC.UC
:members:
:undoc-members:
:show-inheritance:
*Reference:*
pyBusPirateLite.onewire.OneWire
-------------------------------
.. toctree::
:maxdepth: 2
.. autoclass:: pyBusPirateLite.onewire.OneWire
:members:
:undoc-members:
:show-inheritance:
Quantity
Unit
constants
pyBusPirateLite.rawwire.RawWire
-------------------------------
**Indices and tables**
.. autoclass:: pyBusPirateLite.rawwire.RawWire
:members:
:undoc-members:
:show-inheritance:
Indices and tables
------------------
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
......@@ -28,7 +28,7 @@ PIN_POWER = 0x40
class BBIO_base:
"""functions used in every mode, the base of class. Most of these you can
"""Functions used in every mode, the base of class. Most of these you can
probably ignore, as they are just used in the other member classes
Note: Also contains some of the older functions that are now probably outdated
"""
......@@ -59,9 +59,13 @@ class BBIO_base:
It also resets to raw bitbang mode from raw SPI mode, or any other protocol mode.
This command always returns a five byte bitbang version string "BBIOx", w
here x is the current protocol version (currently 1).
Some terminals send a NULL character (0x00) on start-up, causing the Bus Pirate to enter binary mode when
it wasn't wanted. To get around this, you must now enter 0x00 at least 20 times to enter raw bitbang mode.
Note: The Bus Pirate user terminal could be stuck in a configuration menu when your program attempts to enter
Notes
-----
The Bus Pirate user terminal could be stuck in a configuration menu when your program attempts to enter
binary mode. One way to ensure that you're at the command line is to send <enter> at least 10 times,
and then send '#' to reset. Next, send 0x00 to the command line 20+ times until you get the BBIOx version string.
After entering bitbang mode, you can enter other binary protocol modes.
......@@ -99,7 +103,7 @@ class BBIO_base:
raise BPError('Could not enter bitbang mode')
def enter(self):
"""Enter bitbang mode
"""Enter bitbang mode.
Will be overriden by other classes
"""
if self.mode == 'bb':
......@@ -149,12 +153,12 @@ class BBIO_base:
return port.name
def connect(self, portname='', speed=115200, timeout=0.1):
""" will try to automatically find a port regardless of os
"""Will try to automatically find a port regardless of os
Parameters
----------
portname : str
Name of comport (/dev/bus_pirate or COM3)
Name of comport (e.g. /dev/ttyUSB0 or COM3)
speed : int
Communication speed, use default of 115200
timeout : int
......
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Example of I2C data transfer
from pyBusPirateLite.I2C import *
i2c = I2C()
#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""
Created by Sean Nelson on 2009-10-14.
Copyright 2009 Sean Nelson <audiohacked@gmail.com>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment