Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
468 changes: 244 additions & 224 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ publish = false
cfg-if = "1.0.0"
critical-section = "1.1.3"

embassy-executor = { version = "0.5.0", features = ["task-arena-size-8192", "defmt"] }
embassy-executor = { version = "0.6.3", features = ["task-arena-size-8192", "defmt"] }
embassy-sync = "0.5.0"
embassy-time = { version = "0.3.1", features = ["defmt"]}
embassy-time-driver = { version = "0.1.0", optional = true }
Expand All @@ -20,14 +20,14 @@ embedded-hal-bus = { version = "0.1.0", features = ["async"] }
embedded-io-async = "0.6.1"

esp-backtrace = { version = "0.14.1", features = ["esp32c3", "exception-handler", "panic-handler", "println"] }
esp-hal = { version = "0.18.0", features = ["esp32c3", "async", "opsram-2m", "defmt"] }
esp-hal-embassy = { version = "0.1.0", features = ["esp32c3", "defmt", "integrated-timers", "time-timg0"]}
esp-hal = { version = "0.22.0", features = ["esp32c3", "defmt"] }
esp-hal-embassy = { version = "0.5.0", features = ["esp32c3", "defmt", "integrated-timers"]}
esp-println = { version = "0.11.0", features = ["esp32c3", "defmt-espflash"] }
defmt = "0.3.6"

nmea0183 = "0.4.0"
micromath = "2.1.0"
lora-phy = "3.0.0"
lora-phy = "3.0.1"


fugit = "0.3.7"
Expand Down
11 changes: 2 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,12 @@ The reciever (`rx`) has:
- an SX1278-based LoRA Radio

The transmitter (`tx`) additionally includes:
- a u-blox NEO-M8N/MAX-M8N GNSS module,
- a custom LiPo power regulation and monitoring

The full avionics setup (`av`) additionally includes:
- a BMP280 altimeter,
- a BMO055 IMU,
- multiple n-MOSFET terminals for firing pyrotechnic charges,
- additional hardware lockouts preventing unwanted firings.
- a u-blox GNSS module,

### Software
All written in async Rust, using [embassy](https://embassy.dev).

Each platform (`rx`, `tx`, and `av`) has a seperate binary, in `/src/bin/[platform].rs`.
Each platform has a seperate binary, in `/src/bin/[platform].rs`.

Each prehipheral is maintained in a resuable library in `/src/[prehipheral].rs`

Expand Down
18 changes: 18 additions & 0 deletions resources/pinmap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# rx v0.0.1
LORA NSS -> Pin 1
LORA MOSI -> Pin 2
LORA MISO -> Pin 3
LORA CLK -> Pin 4
LORA RST -> Pin 6
LORA IRQ -> Pin 5

# tx/rx breadboard
LORA NSS -> Pin 0
LORA MOSI -> Pin 1
LORA MISO -> Pin 21
LORA CLK -> Pin 20
LORA RST -> Pin 10
LORA IRQ -> Pin 2

UART RX -> Pin 5
UART TX -> Pin 6
40 changes: 0 additions & 40 deletions src/alt.rs

This file was deleted.

62 changes: 0 additions & 62 deletions src/bin/av.rs

This file was deleted.

49 changes: 20 additions & 29 deletions src/bin/rx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,68 +2,59 @@
#![no_main]
#![no_std]

use defmt::info;
use embassy_embedded_hal::shared_bus::asynch::spi::SpiDevice;
use embassy_executor::{task, Spawner};
use embassy_executor::Spawner;
use embassy_time::Timer;

use esp_backtrace as _;
use esp_hal::{
clock::{ClockControl, CpuClock},
gpio::{any_pin::AnyPin, AnyInput, AnyOutput, Io, Level, Pull},
gpio::{Input, Level, Output, Pin, Pull},
peripherals::Peripherals,
prelude::*,
system::SystemControl,
timer::timg::TimerGroup,
};

use defmt::info;
use esp_backtrace as _;

use stack_ripper::{lora, spi, state};

#[task]
#[embassy_executor::task]
async fn print_state() -> ! {
loop {
info!("{:?}", *state::STATE.lock().await);
Timer::after_millis(5_000).await;
}
}

#[main]
async fn main(_spawner: Spawner) -> () {
#[esp_hal_embassy::main]
async fn main(spawner: Spawner) {
info!("Initializing");

let peripherals: Peripherals = Peripherals::take();
let system = SystemControl::new(peripherals.SYSTEM);
let clocks = ClockControl::configure(system.clock_control, CpuClock::Clock160MHz).freeze();
let timg0 = TimerGroup::new_async(peripherals.TIMG0, &clocks);
let peripherals: Peripherals = esp_hal::init(esp_hal::Config::default());
let timg0 = TimerGroup::new(peripherals.TIMG0);

esp_hal_embassy::init(&clocks, timg0);

let io = Io::new(peripherals.GPIO, peripherals.IO_MUX);
esp_hal_embassy::init(timg0.timer0);

info!("Initializing compete");

// Set SPI bus
let spi_clock = AnyPin::new(io.pins.gpio4);
let spi_miso = AnyPin::new(io.pins.gpio3);
let spi_mosi = AnyPin::new(io.pins.gpio2);
let spi_clock = peripherals.GPIO4.degrade();
let spi_miso = peripherals.GPIO3.degrade();
let spi_mosi = peripherals.GPIO2.degrade();

let spi_bus = spi::init(
peripherals.DMA,
peripherals.SPI2,
&clocks,
spi_clock,
spi_mosi,
spi_miso,
);

let lora_spi_csb = AnyOutput::new(io.pins.gpio1, Level::High);
let lora_spi = SpiDevice::new(spi_bus, lora_spi_csb.into());
let lora_spi_csb = Output::new(peripherals.GPIO1.degrade(), Level::High);

let lora_spi = SpiDevice::new(spi_bus, lora_spi_csb);

let lora_rst = AnyOutput::new(io.pins.gpio6, Level::High);
let lora_irq = AnyInput::new(io.pins.gpio5, Pull::Up);
let lora_rst = Output::new(peripherals.GPIO6.degrade(), Level::High);
let lora_irq = Input::new(peripherals.GPIO5.degrade(), Pull::Up);

_spawner
.spawn(lora::receive(lora_spi, lora_irq.into(), lora_rst.into()))
spawner
.spawn(lora::receive(lora_spi, lora_irq, lora_rst))
.ok();
}
61 changes: 23 additions & 38 deletions src/bin/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,82 +3,67 @@
#![no_std]

use embassy_embedded_hal::shared_bus::asynch::spi::SpiDevice;
use embassy_executor::{task, Spawner};
use embassy_time::Timer;
use embassy_executor::Spawner;

use esp_hal::{
clock::{ClockControl, CpuClock},
gpio::{any_pin::AnyPin, AnyInput, AnyOutput, Io, Level, Pull},
gpio::{Input, Level, Output, Pull},
peripherals::Peripherals,
prelude::*,
system::SystemControl,
timer::timg::TimerGroup,
uart::{config::Config, TxRxPins, Uart},
uart::{Config, Uart},
};

use defmt::info;
use esp_backtrace as _;

use stack_ripper::{gps, lora, spi, state};

#[task]
async fn print_state() -> ! {
loop {
info!("{:?}", *state::STATE.lock().await);
Timer::after_millis(5_000).await;
}
}
use stack_ripper::{gps, lora, spi};

#[main]
async fn main(_spawner: Spawner) -> () {
info!("Initializing");

let peripherals: Peripherals = Peripherals::take();
let system = SystemControl::new(peripherals.SYSTEM);
let clocks = ClockControl::configure(system.clock_control, CpuClock::Clock160MHz).freeze();
let timg0 = TimerGroup::new_async(peripherals.TIMG0, &clocks);

esp_hal_embassy::init(&clocks, timg0);
let peripherals: Peripherals = esp_hal::init(esp_hal::Config::default());
let timg0 = TimerGroup::new(peripherals.TIMG0);

let io = Io::new(peripherals.GPIO, peripherals.IO_MUX);
esp_hal_embassy::init(timg0.timer0);

info!("Initializing compete");

// Setup UART for GPS
let uart_pins = Some(TxRxPins::new_tx_rx(io.pins.gpio21, io.pins.gpio20));
let uart_config = Config::default().baudrate(9200);
let uart = Uart::new_async_with_config(peripherals.UART0, uart_config, uart_pins, &clocks);
let rx_pin = peripherals.GPIO8.degrade();
let tx_pin = peripherals.GPIO7.degrade();

let (_, rx) = uart.split();
let uart_config = Config::default().baudrate(9600);
let uart = Uart::new_with_config(peripherals.UART0, uart_config, rx_pin, tx_pin)
.unwrap()
.into_async();

let (rx, _) = uart.split();

// Note that this task now owns the UART RX line completely
// UART is a 1:1 interface, so this is fine
_spawner.spawn(gps::sample_uart(rx)).unwrap();

// Setup SPI bus
let spi_clock = AnyPin::new(io.pins.gpio0);
let spi_miso = AnyPin::new(io.pins.gpio1);
let spi_mosi = AnyPin::new(io.pins.gpio2);
let spi_clock = peripherals.GPIO20.degrade();
let spi_miso = peripherals.GPIO21.degrade();
let spi_mosi = peripherals.GPIO1.degrade();

let spi_bus = spi::init(
peripherals.DMA,
peripherals.SPI2,
&clocks,
spi_clock,
spi_mosi,
spi_miso,
);

let lora_spi_csb = AnyOutput::new(io.pins.gpio3, Level::Low);
let lora_spi_device = SpiDevice::new(spi_bus, lora_spi_csb);
let lora_spi_csb = Output::new(peripherals.GPIO0.degrade(), Level::High);
let lora_spi = SpiDevice::new(spi_bus, lora_spi_csb);

let lora_rst = AnyOutput::new(io.pins.gpio9, Level::High);
let lora_irq = AnyInput::new(io.pins.gpio10, Pull::Up);
let lora_rst = Output::new(peripherals.GPIO10.degrade(), Level::High);
let lora_irq = Input::new(peripherals.GPIO2.degrade(), Pull::Up);

_spawner
.spawn(lora::transmit(lora_spi_device, lora_irq, lora_rst))
.spawn(lora::transmit(lora_spi, lora_irq, lora_rst))
.ok();

// Finally set up the task to print state
_spawner.spawn(print_state()).ok();
}
Loading
Loading