49 lines
1.4 KiB
Rust
49 lines
1.4 KiB
Rust
// src/bin/main.rs
|
|
#![no_std]
|
|
#![no_main]
|
|
|
|
use defmt::info;
|
|
use embassy_executor::Spawner;
|
|
use embassy_stm32::exti::ExtiInput;
|
|
use embassy_stm32::gpio;
|
|
use embassy_stm32::gpio::{Output, Pull};
|
|
use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
|
|
use embassy_sync::channel::Channel;
|
|
use embassy_time::Duration;
|
|
use semestralka2::receive::bit_receive_and_decode;
|
|
use semestralka2::send::nrz;
|
|
use semestralka2::send::Tx;
|
|
|
|
use {defmt_rtt as _, panic_probe as _};
|
|
|
|
static PIPE: Channel<CriticalSectionRawMutex, u8, 128> = Channel::new();
|
|
static PIPE_REC: Channel<CriticalSectionRawMutex, u8, 128> = Channel::new();
|
|
// static REC_ALLOWED: AtomicBool = AtomicBool::new(true);
|
|
|
|
#[embassy_executor::main]
|
|
async fn main(spawner: Spawner) {
|
|
info!("tititititi");
|
|
|
|
let p = embassy_stm32::init(Default::default());
|
|
let tx = Output::new(p.PF2, gpio::Level::High, gpio::Speed::VeryHigh);
|
|
let rx = ExtiInput::new(p.PA3, p.EXTI3, Pull::Up);
|
|
|
|
let sender = PIPE.sender();
|
|
let receiver = PIPE.receiver();
|
|
|
|
spawner.spawn(bit_send(tx, receiver)).unwrap();
|
|
spawner.spawn(bit_receive_and_decode(rx)).unwrap();
|
|
|
|
info!("starting loop");
|
|
loop {
|
|
nrz(b"ahoj", &sender).await;
|
|
nrz(b"hello", &sender).await;
|
|
|
|
let data = [0x01, 0x02, 0x03, 0x04];
|
|
nrz(&data, &sender).await;
|
|
|
|
info!("frame sent");
|
|
embassy_time::Timer::after(Duration::from_secs(1)).await;
|
|
}
|
|
}
|