trash. not working yet

This commit is contained in:
Filipriec
2026-05-12 22:14:02 +02:00
parent d0fd820434
commit 89ad23b3a0

View File

@@ -5,8 +5,9 @@
use core::sync::atomic::{AtomicBool, Ordering}; use core::sync::atomic::{AtomicBool, Ordering};
use defmt::info; use defmt::info;
use embassy_executor::Spawner; use embassy_executor::Spawner;
use embassy_stm32::exti;
use embassy_stm32::gpio; use embassy_stm32::gpio;
use embassy_stm32::gpio::Output; use embassy_stm32::gpio::{Input, Output, Pull};
use embassy_stm32::usart::{Config, InterruptHandler, Uart, UartRx, UartTx}; use embassy_stm32::usart::{Config, InterruptHandler, Uart, UartRx, UartTx};
use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
use embassy_sync::channel::Channel; use embassy_sync::channel::Channel;
@@ -26,8 +27,7 @@ async fn main(spawner: Spawner) {
let p = embassy_stm32::init(Default::default()); let p = embassy_stm32::init(Default::default());
let mut tx = Output::new(p.PF2, gpio::Level::High, gpio::Speed::VeryHigh); let mut tx = Output::new(p.PF2, gpio::Level::High, gpio::Speed::VeryHigh);
// let _rx = Input::new(p.PA3, Pull::Up); let rx = Input::new(p.PA3, Pull::Up);
// let _tx = Output::new(p.PA2, Level::High, Speed::VeryHigh);
let config = Config::default(); let config = Config::default();
let sender = PIPE.sender(); let sender = PIPE.sender();
@@ -38,9 +38,6 @@ async fn main(spawner: Spawner) {
info!("starting echo"); info!("starting echo");
let mut v: Vec<u8, 38, u8> = Vec::new(); let mut v: Vec<u8, 38, u8> = Vec::new();
// let data = b"filip\r\n";
// let idle = &[0x13u8];
loop { loop {
let slovko = "ahoj"; let slovko = "ahoj";
info!("slovo: {}", slovko); info!("slovo: {}", slovko);
@@ -49,19 +46,7 @@ async fn main(spawner: Spawner) {
info!("enkodovane, posielame do pipy..."); info!("enkodovane, posielame do pipy...");
nrz(&v, &sender).await; nrz(&v, &sender).await;
// let current_send_allowed = SEND_ALLOWED.load(Ordering::Relaxed);
// let current_rec_allowed = REC_ALLOWED.load(Ordering::Relaxed);
// if current_rec_allowed == true {
// if current_send_allowed {
// if let Ok(stored_byte) = receiver.try_receive() {
// // TODO
// // let _ = tx.write(&[stored_byte]).await;
// } else {
// // TODO
// // let _ = tx.write(data).await;
// }
// }
// }
let _ = Timer::after(Duration::from_millis(1000)); let _ = Timer::after(Duration::from_millis(1000));
embassy_time::block_for(Duration::from_millis(1000)); embassy_time::block_for(Duration::from_millis(1000));
} }
@@ -121,3 +106,12 @@ async fn bit_send(mut pin: Output<'static>) {
ticker.next().await; ticker.next().await;
} }
} }
#[embassy_executor::task]
async fn bit_receive(mut pin: Input<'static>) {
let mut ticker = Ticker::every(Duration::from_millis(10));
loop {
// bitrate
ticker.next().await;
}
}