Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Radio modes #1

Open
wants to merge 37 commits into
base: dual_rxtx
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
c16d2d5
add config for flake8
tomyyyD Jun 27, 2023
4cbbb9e
Creating RadioHead class independent of driver
tomyyyD Jun 27, 2023
e163ecf
updating gs_setup to use Radiohead class
tomyyyD Jun 27, 2023
dec925f
removing unused code from driver
tomyyyD Jun 27, 2023
9e7493f
initialize with default values
tomyyyD Jun 27, 2023
c6c66a7
rh config
tomyyyD Jun 27, 2023
33a452c
fsk_send_with_ack -> send_wth_ack
tomyyyD Jun 27, 2023
50b5378
update arguments
tomyyyD Jun 27, 2023
2aec7b6
receive uses keyword args
tomyyyD Jun 27, 2023
1621267
type annotations and awaits
tomyyyD Jun 27, 2023
d013cb1
using keyword args for send functions
tomyyyD Jun 27, 2023
5bed26d
switching to LoRa protocol
tomyyyD Jun 27, 2023
374788c
LoRa config stuff included
tomyyyD Jun 27, 2023
07c18e7
import properly
tomyyyD Jun 27, 2023
9680707
add lna gain to LoRa driver
tomyyyD Jun 27, 2023
271b77e
update LoRa to use internal rx/tx devices
tomyyyD Jun 27, 2023
d01647c
updating LoRa radiohead to use internal devices
tomyyyD Jun 27, 2023
9cf2aea
missed a few functions to be made internal
tomyyyD Jun 27, 2023
8cd23ba
adding debugging to LoRa receive
tomyyyD Jun 27, 2023
033d00f
more debugging
tomyyyD Jun 27, 2023
01494ba
debugging tools
tomyyyD Jun 27, 2023
203d481
LoRa works, small bug
tomyyyD Jun 27, 2023
1fc2939
consolidating the send function
tomyyyD Jun 28, 2023
e6f1d4e
removes unused send functions
tomyyyD Jun 28, 2023
a55dee7
pycubed_rfm0x -> pycubedrfm9x_lora
tomyyyD Jun 28, 2023
347a7ea
some repo cleanup
tomyyyD Jun 28, 2023
bd82ac5
consolidating receive function
tomyyyD Jun 28, 2023
2224e67
update length with driver function
tomyyyD Jun 28, 2023
e1d1986
updating packet getting sequence
tomyyyD Jun 28, 2023
4e4799c
updates fsk with correct function name
tomyyyD Jun 28, 2023
255ad1c
packet already proper length
tomyyyD Jun 28, 2023
12ae3c8
remove unused functions
tomyyyD Jun 29, 2023
0c79c06
clear interrupt after LoRa read
tomyyyD Jun 29, 2023
8fdf62e
A few cleanup changes
tomyyyD Jul 5, 2023
096dd8f
removing all register I/O from radiohead
tomyyyD Jul 17, 2023
05de346
type annotating and try catching
tomyyyD Jul 17, 2023
024ac8f
update hw config
tomyyyD May 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions gs_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
import board
import busio
import digitalio
from lib import pycubed_rfm9x_fsk
from lib import radiohead
from lib.configuration import radio_configuration as rf_config
from shell_utils import bold, normal


def initialize_radio(tx_spi, tx_cs, tx_reset, rx_spi=None, rx_cs=None, rx_reset=None, rxtx_switch=None):
Expand Down
2 changes: 2 additions & 0 deletions lib/configuration/radio_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Defines the default settings used to configure the RFM9x satellite
"""

# either "lora" or "fsk"
PROTOCOL = "lora"

# FSK specific
Expand All @@ -14,6 +15,7 @@
SIGNAL_BANDWIDTH = 125000
CODING_RATE = 5

tomyyyD marked this conversation as resolved.
Show resolved Hide resolved
# shared between lora/fsk
CHECKSUM = True
TX_POWER = 23 # dB
FREQUENCY = 433.0 # MHz
Expand Down
15 changes: 13 additions & 2 deletions lib/pycubed_rfm9x_fsk.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@
====================================================
Modified to use FSK in 2022 by Jacob Willis
"""
import random
import time
import adafruit_bus_device.spi_device as spidev
from micropython import const
import tasko

HAS_SUPERVISOR = False

Expand Down Expand Up @@ -663,3 +661,16 @@ def crc_ok(self):
def fifo_empty(self):
"""True when FIFO is empty"""
return (self._read_u8(Constants._RH_RF95_REG_3F_IRQ_FLAGS_2) & (0b1 << 6)) >> 6

def write_payload(self, payload):
self._write_from(Constants._RH_RF95_REG_00_FIFO, payload)

def check_data(self, data):
assert 0 < len(data) <= 57

def get_packet(self):
packet = bytearray(Constants._MAX_FIFO_LENGTH)
packet_length = self._read_until_flag(Constants._RH_RF95_REG_00_FIFO,
packet,
self.fifo_empty)
return packet[:packet_length]
29 changes: 27 additions & 2 deletions lib/pycubed_rfm9x.py → lib/pycubed_rfm9x_lora.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@

* Author(s): Tony DiCola, Jerry Needell
"""
import random
import time
import adafruit_bus_device.spi_device as spidev
from micropython import const
import tasko

HAS_SUPERVISOR = False

Expand Down Expand Up @@ -130,6 +128,8 @@ class Constants:
_TICKS_MAX = const(_TICKS_PERIOD - 1)
_TICKS_HALFPERIOD = const(_TICKS_PERIOD // 2)

_MAX_FIFO_LENGTH = 258

# Disable the too many instance members warning. Pylint has no knowledge
# of the context and is merely guessing at the proper amount of members. This
# is a complex chip which requires exposing many attributes and state. Disable
Expand Down Expand Up @@ -687,3 +687,28 @@ def rx_done(self) -> bool:
def crc_error(self) -> bool:
"""crc status"""
return (self._read_u8(Constants._RH_RF95_REG_12_IRQ_FLAGS) & 0x20) >> 5

def write_payload(self, payload) -> bool:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this actually return a bool?

# Write payload.
self._write_from(Constants._RH_RF95_REG_00_FIFO, payload)
# Write payload and header length.
self._write_u8(Constants._RH_RF95_REG_22_PAYLOAD_LENGTH, len(payload))

def check_data(self, data):
assert 0 < len(data) <= 241

def get_packet(self):
# get length of data in FIFO
fifo_length = self._read_u8(Constants._RH_RF95_REG_13_RX_NB_BYTES)
# get start address of last packet in FIFO
current_addr = self._read_u8(Constants._RH_RF95_REG_10_FIFO_RX_CURRENT_ADDR)
# write to the pointer where we need to get data
self._write_u8(Constants._RH_RF95_REG_0D_FIFO_ADDR_PTR, current_addr)
# create a packet of fifo_length size
packet = bytearray(fifo_length)
# Read the packet.
self._read_into(Constants._RH_RF95_REG_00_FIFO, packet)
# Clear interrupt.
self._write_u8(Constants._RH_RF95_REG_12_IRQ_FLAGS, 0xFF)

return packet
Loading