Skip to content

uart-dma example with changing data length #112

@usbalbin

Description

@usbalbin

The uart-dma example does not show how to send data with different length using dma.

Is this not supported by this crate or is it even a hardware limitation?

example:

[...]

let data_to_send = [
    &b"Hello"[..], // These are to be sent one at a time to simulate sending messages of different sizes
    &b"I"[..],
    &b"am Bob the Bot"[..],
];


// Setup DMA for USART2 TX with dma channel 1.
let mut transfer =
    streams
        .0
        .into_memory_to_peripheral_transfer(tx.enable_dma(), &mut tx_buffer[..], config);

transfer.start(|_tx| {});
loop {
    while !transfer.get_transfer_complete_flag() {}

    delay_syst.delay(1000.millis());
    led.toggle().unwrap();
    transfer.restart(|_tx| {}); // <---------- Do something here to either change buffer to data_to_send[i],
                                // , or copy to tx_buffer (assuming it is large enough) and tell `transfer` the new data length
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions