Skip to main content

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

lt8900_spi-2.6.tar.gz (10.3 kB view hashes)

Uploaded Source

Built Distribution

lt8900_spi-2.6-py3-none-any.whl (10.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page