Python LT8900 via SPI

Check-in [c9419b56ad]
Login

Check-in [c9419b56ad]

Overview
Comment:Rename class to upper-case
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: c9419b56adcbd405ee83f8a1882967a29ab88eed4458685b39a8b5cd6360069c
User & Date: rkeene on 2020-04-29 00:37:42
Other Links: manifest | tags
Context
2020-04-29
00:38
lt8900_spi v2.0 check-in: 5fd146a915 user: rkeene tags: 2.0, trunk
00:37
Rename class to upper-case check-in: c9419b56ad user: rkeene tags: trunk
00:02
lt8900_spi v1.0 check-in: ba248e2cfc user: rkeene tags: 1.0, trunk
Changes

Modified README.md from [e27f58af7d] to [4e3efca6a5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22















23
24
25
26
27
28
29
1
2
3
4
5
6
7















8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29







-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







# 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
    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

61
62
63
64
65
66
67
68

69
70
71
72
73
74
75
76
77
61
62
63
64
65
66
67

68
69
70
71
72
73
74
75
76
77







-
+









    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, {
    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)

Modified lt8900_spi/__init__.py from [c7ac30653e] to [d3ab104dc8].

18
19
20
21
22
23
24
25

26
27
28
29
30
31
32
18
19
20
21
22
23
24

25
26
27
28
29
30
31
32







-
+







# | P1-17 | P1-18 | P1-21 | P1-19 | P1-23 | P1-24 | P1-25  |
# -________________________________________________________-
#                     Raspberry Pi

import spidev
import time

class radio:
class Radio:
	_register_map = [
		{'name': "Unknown"}, # 0
		{'name': "Unknown"}, # 1
		{'name': "Unknown"}, # 2
		{                    # 3
			'name': 'phase_lock',
			'reserved_1': [13, 15],