This commit is contained in:
Priec
2025-11-24 00:21:58 +01:00
parent 522236e20c
commit 6d694c840b
5 changed files with 4 additions and 8 deletions

View File

@@ -78,9 +78,7 @@ pub async fn rx_dma_task(
// } // }
} }
// Shift remaining data to front // Shift remaining data to history partition
// We processed 'consumed' samples.
// Keeping the rest of the data
let remaining = current_end - consumed; let remaining = current_end - consumed;
if remaining > 0 { if remaining > 0 {

View File

@@ -42,7 +42,6 @@ pub async fn encode_uart_frames<'a>(
pub async fn tx_dma_task( pub async fn tx_dma_task(
mut ch: Peri<'static, GPDMA1_CH0>, mut ch: Peri<'static, GPDMA1_CH0>,
register: *mut u32, // GPIOx_BSRR register: *mut u32, // GPIOx_BSRR
tx_ring_mem: &'static mut [u32],
pipe_rx: &'static Pipe<CriticalSectionRawMutex, 1024>, pipe_rx: &'static Pipe<CriticalSectionRawMutex, 1024>,
tx_pin_bit: u8, tx_pin_bit: u8,
uart_cfg: &'static UartConfig, uart_cfg: &'static UartConfig,

View File

@@ -148,7 +148,7 @@ pub fn decode_uart_samples(
let mut error_data = false; let mut error_data = false;
if cfg.parity != Parity::None { if cfg.parity != Parity::None {
let expected_parity = calculate_parity(data, cfg.parity, cfg.data_bits); let expected_parity = calculate_parity(data, cfg.parity);
let actual_parity = get_bit(scan_idx); let actual_parity = get_bit(scan_idx);
if expected_parity != actual_parity { if expected_parity != actual_parity {
// Parity error // Parity error
@@ -192,7 +192,7 @@ pub fn decode_uart_samples(
} }
/// Calculate the expected parity bit (0 or 1) for the given data and parity mode /// Calculate the expected parity bit (0 or 1) for the given data and parity mode
fn calculate_parity(data: u8, parity: Parity, data_bits: u8) -> u8 { fn calculate_parity(data: u8, parity: Parity) -> u8 {
match parity { match parity {
Parity::None => 0, Parity::None => 0,
Parity::Even | Parity::Odd => { Parity::Even | Parity::Odd => {

View File

@@ -141,7 +141,6 @@ async fn main(spawner: Spawner) {
spawner.spawn(tx_dma_task( spawner.spawn(tx_dma_task(
p.GPDMA1_CH0, p.GPDMA1_CH0,
bsrr_ptr, bsrr_ptr,
SW_TX_RING.init([0; TX_RING_BYTES]),
&PIPE_SW_TX, &PIPE_SW_TX,
TX_PIN_BIT, TX_PIN_BIT,
&UART_CFG, &UART_CFG,

View File

@@ -3,7 +3,7 @@ use software_uart::uart_emulation::{Parity, StopBits, UartConfig};
use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
use embassy_sync::pipe::Pipe; use embassy_sync::pipe::Pipe;
pub const BAUD: u32 = 9_600; pub const BAUD: u32 = 57_600;
// pub const TX_PIN_BIT: u8 = 2; // PA2 // pub const TX_PIN_BIT: u8 = 2; // PA2
// pub const RX_PIN_BIT: u8 = 3; // PA3 // pub const RX_PIN_BIT: u8 = 3; // PA3
pub const TX_PIN_BIT: u8 = 0; // PB2 pub const TX_PIN_BIT: u8 = 0; // PB2