Python LT8900 via SPI

Check-in [5b2064ba1c]
Login
Overview
Comment:Expose a mechanism for filling the chip FIFO, which otherwise requires privarte methods
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 5b2064ba1ce3f840f97913930a086f54c1bc6e04e4d09a94f304437d98101603
User & Date: rkeene on 2020-04-27 13:33:32
Other Links: manifest | tags
Context
2020-04-27
13:38
Allow user to configure multi-transmit delay check-in: a1662e7ae5 user: rkeene tags: trunk
13:33
Expose a mechanism for filling the chip FIFO, which otherwise requires privarte methods check-in: 5b2064ba1c user: rkeene tags: trunk
13:24
More registers and check packet flag check-in: 5f96d4e6ca user: rkeene tags: trunk
Changes

Modified __init__.py from [7b3709f395] to [5bb68ba2bd].

446
447
448
449
450
451
452













453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
			self.put_register("syncword_1", syncword[2])
			self.put_register("syncword_2", syncword[1])
			self.put_register("syncword_3", syncword[0])
		elif len(syncword) > 4:
			raise ValueError("SyncWord length must be less than 5")

		return None














	def transmit(self, message, channel = None):
		if channel is None:
			state = self.get_register_bits('radio_state')
			channel = state['channel']

		# Initialize the transmitter
		self.put_register_bits('radio_state', {
			'tx_enabled': 0,
			'rx_enabled': 0,
			'channel': 0
		})

		self.put_register_bits('fifo_state', {
			'clear_read': 1,
			'clear_write': 1
		})

		# Format message to send to fifo
		## XXX: TODO: Length encoding is optional, should check register
		message = [self.__register_number('fifo'), len(message)] + message
		log_message = [] + message

		# Transfer the message
		result = self.__spi.xfer(message, self.__spi.max_speed_hz, 10)
		self.__debug("Writing: {} = {}".format(log_message, result))

		# Tell the radio to transmit the FIFO buffer to the specified channel
		self.put_register_bits('radio_state', {
			'tx_enabled': 1,
			'rx_enabled': 0,
			'channel': channel
		})







>
>
>
>
>
>
>
>
>
>
>
>
>



















<
<
<
|
<
<
<







446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484



485



486
487
488
489
490
491
492
			self.put_register("syncword_1", syncword[2])
			self.put_register("syncword_2", syncword[1])
			self.put_register("syncword_3", syncword[0])
		elif len(syncword) > 4:
			raise ValueError("SyncWord length must be less than 5")

		return None

	def fill_fifo(self, message, include_length = True):
		new_message = [self.__register_number('fifo')]
		if include_length:
			new_message = new_message + [len(message)]
		new_message = new_message + message
		log_message = [] + new_message

		# Transfer the message
		result = self.__spi.xfer(new_message, self.__spi.max_speed_hz, 10)
		self.__debug("Writing: {} = {}".format(log_message, result))

		return new_message

	def transmit(self, message, channel = None):
		if channel is None:
			state = self.get_register_bits('radio_state')
			channel = state['channel']

		# Initialize the transmitter
		self.put_register_bits('radio_state', {
			'tx_enabled': 0,
			'rx_enabled': 0,
			'channel': 0
		})

		self.put_register_bits('fifo_state', {
			'clear_read': 1,
			'clear_write': 1
		})

		# Format message to send to fifo



		self.fill_fifo(message, True)




		# Tell the radio to transmit the FIFO buffer to the specified channel
		self.put_register_bits('radio_state', {
			'tx_enabled': 1,
			'rx_enabled': 0,
			'channel': channel
		})