Compare commits
2 Commits
main
...
stm32-ring
Author | SHA1 | Date | |
---|---|---|---|
|
b49bc449d7 | ||
|
a21a2901ac |
@ -3,7 +3,7 @@ build-std = ["core"]
|
|||||||
build-std-features = ["panic_immediate_abort"]
|
build-std-features = ["panic_immediate_abort"]
|
||||||
|
|
||||||
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
|
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
|
||||||
runner = "teleprobe client run --target bluepill-stm32f103c8 --elf"
|
runner = "teleprobe client run --target nucleo-stm32f429zi --elf"
|
||||||
#runner = "teleprobe local run --chip STM32F103C8 --elf"
|
#runner = "teleprobe local run --chip STM32F103C8 --elf"
|
||||||
|
|
||||||
rustflags = [
|
rustflags = [
|
||||||
|
@ -9,7 +9,11 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||||||
println!("cargo:rustc-link-arg-bins=--nmagic");
|
println!("cargo:rustc-link-arg-bins=--nmagic");
|
||||||
|
|
||||||
// too little RAM to run from RAM.
|
// too little RAM to run from RAM.
|
||||||
if cfg!(any(feature = "stm32f103c8", feature = "stm32c031c6")) {
|
if cfg!(any(
|
||||||
|
feature = "stm32f429zi",
|
||||||
|
feature = "stm32f103c8",
|
||||||
|
feature = "stm32c031c6"
|
||||||
|
)) {
|
||||||
println!("cargo:rustc-link-arg-bins=-Tlink.x");
|
println!("cargo:rustc-link-arg-bins=-Tlink.x");
|
||||||
println!("cargo:rerun-if-changed=link.x");
|
println!("cargo:rerun-if-changed=link.x");
|
||||||
} else {
|
} else {
|
||||||
|
@ -127,7 +127,7 @@ async fn main(spawner: Spawner) {
|
|||||||
let mut config = Config::default();
|
let mut config = Config::default();
|
||||||
// this is the fastest we can go without tuning RCC
|
// this is the fastest we can go without tuning RCC
|
||||||
// some chips have default pclk=8mhz, and uart can run at max pclk/16
|
// some chips have default pclk=8mhz, and uart can run at max pclk/16
|
||||||
config.baudrate = 500_000;
|
config.baudrate = 1_000_000;
|
||||||
config.data_bits = DataBits::DataBits8;
|
config.data_bits = DataBits::DataBits8;
|
||||||
config.stop_bits = StopBits::STOP1;
|
config.stop_bits = StopBits::STOP1;
|
||||||
config.parity = Parity::ParityNone;
|
config.parity = Parity::ParityNone;
|
||||||
@ -154,7 +154,7 @@ async fn transmit_task(mut tx: UartTx<'static, board::Uart, board::TxDma>) {
|
|||||||
|
|
||||||
let mut i: u8 = 0;
|
let mut i: u8 = 0;
|
||||||
loop {
|
loop {
|
||||||
let mut buf = [0; 256];
|
let mut buf = [0; 32];
|
||||||
let len = 1 + (rng.next_u32() as usize % buf.len());
|
let len = 1 + (rng.next_u32() as usize % buf.len());
|
||||||
for b in &mut buf[..len] {
|
for b in &mut buf[..len] {
|
||||||
*b = i;
|
*b = i;
|
||||||
@ -162,7 +162,9 @@ async fn transmit_task(mut tx: UartTx<'static, board::Uart, board::TxDma>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tx.write(&buf[..len]).await.unwrap();
|
tx.write(&buf[..len]).await.unwrap();
|
||||||
Timer::after(Duration::from_micros((rng.next_u32() % 1000) as _)).await;
|
info!("sent {=usize}", len);
|
||||||
|
|
||||||
|
Timer::after(Duration::from_micros((rng.next_u32() % 500) as _)).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,7 +177,7 @@ async fn receive_task(mut rx: RingBufferedUartRx<'static, board::Uart, board::Rx
|
|||||||
let mut i = 0;
|
let mut i = 0;
|
||||||
let mut expected = 0;
|
let mut expected = 0;
|
||||||
loop {
|
loop {
|
||||||
let mut buf = [0; 256];
|
let mut buf = [0; 32];
|
||||||
let max_len = 1 + (rng.next_u32() as usize % buf.len());
|
let max_len = 1 + (rng.next_u32() as usize % buf.len());
|
||||||
let received = match rx.read(&mut buf[..max_len]).await {
|
let received = match rx.read(&mut buf[..max_len]).await {
|
||||||
Ok(r) => r,
|
Ok(r) => r,
|
||||||
@ -183,6 +185,7 @@ async fn receive_task(mut rx: RingBufferedUartRx<'static, board::Uart, board::Rx
|
|||||||
panic!("Test fail! read error: {:?}", e);
|
panic!("Test fail! read error: {:?}", e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
info!("received {=usize}", received);
|
||||||
|
|
||||||
for byte in &buf[..received] {
|
for byte in &buf[..received] {
|
||||||
assert_eq!(*byte, expected);
|
assert_eq!(*byte, expected);
|
||||||
@ -190,12 +193,12 @@ async fn receive_task(mut rx: RingBufferedUartRx<'static, board::Uart, board::Rx
|
|||||||
}
|
}
|
||||||
|
|
||||||
if received < max_len {
|
if received < max_len {
|
||||||
Timer::after(Duration::from_micros((rng.next_u32() % 1000) as _)).await;
|
Timer::after(Duration::from_micros((rng.next_u32() % 500) as _)).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
i += received;
|
i += received;
|
||||||
|
|
||||||
if i > 100000 {
|
if i > 1000000 {
|
||||||
info!("Test OK!");
|
info!("Test OK!");
|
||||||
cortex_m::asm::bkpt();
|
cortex_m::asm::bkpt();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user