Python interface to an LT8900 connected via SPI
Project description
Python LT8900 via SPI
This Python module enables a Python to talk to an LT8900 radio attached to an serial peripheral interface (SPI).
API
Synopsis
lt8900_spi.Radio(spi_bus, spi_dev, config = None) -> instance
lt8900_spi.Radio.put_register(reg, value) -> value
lt8900_spi.Radio.put_register_bits(reg, bits_dict) -> value
lt8900_spi.Radio.get_register(reg) -> value
lt8900_spi.Radio.get_register_bits(reg, value = None) -> dictionary
lt8900_spi.Radio.configure(config) -> None
lt8900_spi.Radio.initialize() -> boolean
lt8900_spi.Radio.set_channel(channel) -> dictionary
lt8900_spi.Radio.set_syncword(syncword) -> None
lt8900_spi.Radio.fill_fifo(message, include_length = True) -> list
lt8900_spi.Radio.transmit(message, channel = None) -> boolean
lt8900_spi.Radio.multi_transmit(message, channels, retries = 3, delay = 0.1) -> boolean
lt8900_spi.Radio.start_listening(channel) -> boolean
lt8900_spi.Radio.stop_listening() -> boolean
lt8900_spi.Radio.receive(channel = None, wait = False, length = None, wait_time = 0.1) -> list
instance.get_register_bits
Low-level primitive to get a named register with bitfields expanded to names.
instance.put_register_bits
Low-level primitive to set a named register by bitfield value.
instance.set_syncword
High-level interface to syncword mechanism. The syncword can be 1, 2, 3, or 4 16-bit words long and should be provided as an array.
Example:
instance.set_syncword([1, 2, 3, 4])
instance.transmit
Transmit a message. If a channel is specified transmit on that channel -- otherwise the current channel is queried and then used.
instance.multi_transmit
Transmit a message across multiple channels multiple times. This is a common pattern so this function is provided for convience.
Example
#! /usr/bin/env python3
import time
import gpiozero
import lt8900_spi
# Need to keep this attached to drive the line high -- if the object disappears then
# the GPIO port gets reconfigured as an input port
# Note broadcom pin numbers are used
reset_gpio = gpiozero.LED(24)
reset_gpio.on()
def reset_module_via_gpio():
reset_gpio.off()
time.sleep(0.1)
reset_gpio.on()
time.sleep(0.1)
radio = lt8900_spi.Radio(0, 0, {
'reset_command': reset_module_via_gpio
})
if not radio.initialize():
raise ValueError('Initialize failed')
radio.set_syncword([0x258B, 0x147A])
radio.multi_transmit([0xB0, 0x51, 0xF0, 0x00, 0x00, 0x01, 212], [9, 40, 71], delay = 0.5)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lt8900_spi-2.6.tar.gz.
File metadata
- Download URL: lt8900_spi-2.6.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.4.2 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6fd87e9e366a4c27970772a0d652f7ba95f5adc2a71e6398e4e3a025d7da2e8d
|
|
| MD5 |
e3451ed71f6ec524d1e0bdabe102153b
|
|
| BLAKE2b-256 |
cf2d58d716d45e67424a006b15959da26b970e0757ebacef18e80f5c14959bc0
|
File details
Details for the file lt8900_spi-2.6-py3-none-any.whl.
File metadata
- Download URL: lt8900_spi-2.6-py3-none-any.whl
- Upload date:
- Size: 10.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.4.2 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
249e807ec8e628b4fc993ed11502279c917d4c1a233ab86e6cd9094a852f4cbe
|
|
| MD5 |
741d3bcec61ad5b803f4ae318d956de0
|
|
| BLAKE2b-256 |
34f54eac9e1e02fe7907ec219332d9f08b29ed92da4caf5192cc5ffa35428bd2
|