pyfbsdspi-tspspi


Namepyfbsdspi-tspspi JSON
Version 0.0.1 PyPI version JSON
download
home_pagehttps://github.com/tspspi/fbsdspiwrapper
Summaryspigen device ioctl wrapper for FreeBSD
upload_time2023-11-12 23:35:48
maintainer
docs_urlNone
authorThomas Spielauer
requires_python>=3.6
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # FreeBSD SPI wrapper for Python

The ```pyfbsdspi-tspspi``` project contains a very thin wrapper
around the ```ioctl``` requests for the ```spigen``` device
on FreeBSD to test various hardware devices from Python. It allows
direct access to the SPI bus on devices like the RaspberryPi when running
under FreeBSD.

## Installation

```
pip install pyfbsdspi-tspspi
```

## Usage

The bus can be instantiated either using context management or by it's
constructor. One can select the bus via it's first constructor
argument (```spiDevname```):

```
from fbsdspi import FbsdSPI
from labdevs.spibus import SPIClockPolarity, SPIClockPhase
```

To instantiate via context management one can use:

```
with FbsdSPI() as spi:
    # Use spi. ....
```

To instantiate without context mangement:

```
spi = FbsdSPI()

# Use spi ...
```

In case one wants to open a different bus device - for example ```spigen0.1```
which would be the second SPI bus on a RaspberryPi one can simply specify the
name as first argument (```spiDevname```)

```
with FbsdSPI('/dev/spigen0.1') as spi1:
    # spi1. ...
```

Or without context management:

```
spi0 = FbsdSPI('/dev/spigen0.0')
spi1 = FbsdSPI('/dev/spigen0.1')
```

### Setting and querying bus clock speed

To query the bus speed one can use the ```getClockSpeed()``` method. This yields
the SPI clock frequency in Hz:

```
print(f"Current clock speed is {spi.getClockSpeed()} Hz")
```

To set the clock the counterpart ```setClockSpeed``` can be used. Again note that
this requires an integer argument in Hz:

```
spi.setClockSpeed(100000)
```

### Setting and getting the bus mode

As for any SPI abstraction library one can also set the four possible bus modes:

* Clock polarity can be either ```IDLE_HIGH``` or ```IDLE_LOW```
* Clock phase can be either ```TRAILING_EDGE``` or ```LEADING_EDGE```

```
spi.setMode(
    clockPolarity = SPIClockPolarity.IDLE_HIGH,
    clockPhase = SPIClockPhase.TRAILING_EDGE
)
```

To query the current mode one can use the `` getMode``  API:

```
print(f"Current mode: {spi.getMode()}")
# Return the tuple (SPIClockPhase, SPIClockPolarity)
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/tspspi/fbsdspiwrapper",
    "name": "pyfbsdspi-tspspi",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "",
    "author": "Thomas Spielauer",
    "author_email": "pypipackages01@tspi.at",
    "download_url": "https://files.pythonhosted.org/packages/9a/b5/7129f6f809624108106ab191475cb1135dfe0d327694f1f0993c27e0dc37/pyfbsdspi-tspspi-0.0.1.tar.gz",
    "platform": null,
    "description": "# FreeBSD SPI wrapper for Python\n\nThe ```pyfbsdspi-tspspi``` project contains a very thin wrapper\naround the ```ioctl``` requests for the ```spigen``` device\non FreeBSD to test various hardware devices from Python. It allows\ndirect access to the SPI bus on devices like the RaspberryPi when running\nunder FreeBSD.\n\n## Installation\n\n```\npip install pyfbsdspi-tspspi\n```\n\n## Usage\n\nThe bus can be instantiated either using context management or by it's\nconstructor. One can select the bus via it's first constructor\nargument (```spiDevname```):\n\n```\nfrom fbsdspi import FbsdSPI\nfrom labdevs.spibus import SPIClockPolarity, SPIClockPhase\n```\n\nTo instantiate via context management one can use:\n\n```\nwith FbsdSPI() as spi:\n    # Use spi. ....\n```\n\nTo instantiate without context mangement:\n\n```\nspi = FbsdSPI()\n\n# Use spi ...\n```\n\nIn case one wants to open a different bus device - for example ```spigen0.1```\nwhich would be the second SPI bus on a RaspberryPi one can simply specify the\nname as first argument (```spiDevname```)\n\n```\nwith FbsdSPI('/dev/spigen0.1') as spi1:\n    # spi1. ...\n```\n\nOr without context management:\n\n```\nspi0 = FbsdSPI('/dev/spigen0.0')\nspi1 = FbsdSPI('/dev/spigen0.1')\n```\n\n### Setting and querying bus clock speed\n\nTo query the bus speed one can use the ```getClockSpeed()``` method. This yields\nthe SPI clock frequency in Hz:\n\n```\nprint(f\"Current clock speed is {spi.getClockSpeed()} Hz\")\n```\n\nTo set the clock the counterpart ```setClockSpeed``` can be used. Again note that\nthis requires an integer argument in Hz:\n\n```\nspi.setClockSpeed(100000)\n```\n\n### Setting and getting the bus mode\n\nAs for any SPI abstraction library one can also set the four possible bus modes:\n\n* Clock polarity can be either ```IDLE_HIGH``` or ```IDLE_LOW```\n* Clock phase can be either ```TRAILING_EDGE``` or ```LEADING_EDGE```\n\n```\nspi.setMode(\n    clockPolarity = SPIClockPolarity.IDLE_HIGH,\n    clockPhase = SPIClockPhase.TRAILING_EDGE\n)\n```\n\nTo query the current mode one can use the `` getMode``  API:\n\n```\nprint(f\"Current mode: {spi.getMode()}\")\n# Return the tuple (SPIClockPhase, SPIClockPolarity)\n```\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "spigen device ioctl wrapper for FreeBSD",
    "version": "0.0.1",
    "project_urls": {
        "Homepage": "https://github.com/tspspi/fbsdspiwrapper"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "21f51d6eda5e5cda77a0506a9c0289cffa755d91da5f265017ed7654bfaed715",
                "md5": "20b6902e32e0c312552cbafa0f459dfb",
                "sha256": "d4e2531e84c587c89168072ec0de3ad49a75d576c02afb3859e8833d1f7eab8b"
            },
            "downloads": -1,
            "filename": "pyfbsdspi_tspspi-0.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "20b6902e32e0c312552cbafa0f459dfb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 3103,
            "upload_time": "2023-11-12T23:35:47",
            "upload_time_iso_8601": "2023-11-12T23:35:47.216188Z",
            "url": "https://files.pythonhosted.org/packages/21/f5/1d6eda5e5cda77a0506a9c0289cffa755d91da5f265017ed7654bfaed715/pyfbsdspi_tspspi-0.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9ab57129f6f809624108106ab191475cb1135dfe0d327694f1f0993c27e0dc37",
                "md5": "41828dd6cb28087911409b8632bec5d5",
                "sha256": "d4c1ff4481e42d919d3b435dc6b70e09f1b6417c50024ef3993cb0a607bbbe48"
            },
            "downloads": -1,
            "filename": "pyfbsdspi-tspspi-0.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "41828dd6cb28087911409b8632bec5d5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 3075,
            "upload_time": "2023-11-12T23:35:48",
            "upload_time_iso_8601": "2023-11-12T23:35:48.764184Z",
            "url": "https://files.pythonhosted.org/packages/9a/b5/7129f6f809624108106ab191475cb1135dfe0d327694f1f0993c27e0dc37/pyfbsdspi-tspspi-0.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-12 23:35:48",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "tspspi",
    "github_project": "fbsdspiwrapper",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "pyfbsdspi-tspspi"
}
        
Elapsed time: 0.13404s