Skip to content

Commit

Permalink
now needs tests
Browse files Browse the repository at this point in the history
  • Loading branch information
robamu committed Sep 27, 2024
1 parent f7ff749 commit 1f4d6f6
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 153 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ members = [
"examples/embassy",
"board-tests",
"bootloader",
# "flashloader",
"flashloader",
]

exclude = [
Expand Down
2 changes: 1 addition & 1 deletion examples/rtic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ cortex-m-rt = "0.7"
embedded-hal = "1"
embedded-io = "0.6"
rtt-target = { version = "0.5" }
panic-rtt-target = { version = "0.1" }

# Even though we do not use this directly, we need to activate this feature explicitely
# so that RTIC compiles because thumv6 does not have CAS operations natively.
portable-atomic = { version = "1", features = ["unsafe-assume-single-core"]}
panic-rtt-target = { version = "0.1" }

[dependencies.rtic]
version = "2"
Expand Down
46 changes: 27 additions & 19 deletions examples/rtic/src/bin/uart-echo-rtic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ mod app {
use rtic_monotonics::Monotonic;
use rtt_target::{rprintln, rtt_init_print};
use va108xx_hal::{
gpio::PinsB,
gpio::PinsA,
pac,
prelude::*,
uart::{self, RxWithIrq, Tx},
Expand All @@ -38,8 +38,8 @@ mod app {
struct Local {
data_producer: StaticProd<'static, u8, RX_RING_BUF_SIZE>,
data_consumer: CachingCons<&'static StaticRb<u8, RX_RING_BUF_SIZE>>,
rx: RxWithIrq<pac::Uartb>,
tx: Tx<pac::Uartb>,
rx: RxWithIrq<pac::Uarta>,
tx: Tx<pac::Uarta>,
}

#[shared]
Expand All @@ -50,23 +50,29 @@ mod app {
#[init]
fn init(cx: init::Context) -> (Shared, Local) {
rtt_init_print!();
rprintln!("-- VA108xx UART IRQ example application--");
rprintln!("-- VA108xx UART Echo with IRQ example application--");

Mono::start(cx.core.SYST, SYSCLK_FREQ.raw());

let mut dp = cx.device;
let gpiob = PinsB::new(&mut dp.sysconfig, Some(dp.ioconfig), dp.portb);
let tx = gpiob.pb21.into_funsel_1();
let rx = gpiob.pb20.into_funsel_1();

let irq_uart =
uart::Uart::new(&mut dp.sysconfig, 50.MHz(), dp.uartb, (tx, rx), 115200.Hz());
let gpioa = PinsA::new(&mut dp.sysconfig, Some(dp.ioconfig), dp.porta);
let tx = gpioa.pa9.into_funsel_2();
let rx = gpioa.pa8.into_funsel_2();

let irq_uart = uart::Uart::new(
&mut dp.sysconfig,
SYSCLK_FREQ,
dp.uarta,
(tx, rx),
115200.Hz(),
);
let (tx, rx) = irq_uart.split();
let mut rx = rx.into_rx_with_irq(&dp.irqsel, pac::interrupt::OC3);
let mut rx = rx.into_rx_with_irq(&mut dp.sysconfig, &mut dp.irqsel, pac::interrupt::OC3);

rx.start();

let (data_producer, data_consumer) = unsafe { RINGBUF.split_ref() };
echo_handler::spawn().unwrap();
(
Shared {},
Local {
Expand Down Expand Up @@ -121,14 +127,16 @@ mod app {
async fn echo_handler(cx: echo_handler::Context) {
loop {
let bytes_to_read = cx.local.data_consumer.occupied_len();
let actual_read_bytes = cx
.local
.data_consumer
.pop_slice(&mut cx.local.buf[0..bytes_to_read]);
cx.local
.tx
.write_all(&cx.local.buf[0..actual_read_bytes])
.expect("Failed to write to TX");
if bytes_to_read > 0 {
let actual_read_bytes = cx
.local
.data_consumer
.pop_slice(&mut cx.local.buf[0..bytes_to_read]);
cx.local
.tx
.write_all(&cx.local.buf[0..actual_read_bytes])
.expect("Failed to write to TX");
}
Mono::delay(50.millis()).await;
}
}
Expand Down
28 changes: 23 additions & 5 deletions flashloader/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,22 @@ embedded-hal-nb = "1"
embedded-io = "0.6"
panic-rtt-target = { version = "0.1.3" }
rtt-target = { version = "0.5" }
rtt-log = "0.3"
log = "0.4"
crc = "3"
rtic-sync = "1"

[dependencies.satrs]
version = "0.2"
default-features = false

[dependencies.rtt-log]
version = "0.3"
git = "https://github.com/us-irs/rtt-log-rs.git"
branch = "allow-usage-on-non-cas-systems"

[dependencies.ringbuf]
version = "0.4"
git = "https://github.com/us-irs/ringbuf.git"
branch = "use-portable-atomic-crate"
default-features = false

[dependencies.once_cell]
Expand All @@ -38,13 +43,26 @@ git = "https://github.com/robamu/cobs.rs.git"
branch = "all_features"
default-features = false

[dependencies.va108xx-hal]
path = "../va108xx-hal"
# Even though we do not use this directly, we need to activate this feature explicitely
# so that RTIC compiles because thumv6 does not have CAS operations natively.
[dependencies.portable-atomic]
version = "1"
features = ["unsafe-assume-single-core"]

[dependencies.rtic]
version = "2"
features = ["thumbv7-backend"]
features = ["thumbv6-backend"]

[dependencies.rtic-monotonics]
version = "2"
features = ["cortex-m-systick"]

[dependencies.rtic-sync]
version = "1"
features = ["defmt-03"]

[dependencies.va108xx-hal]
path = "../va108xx-hal"

[dependencies.vorago-reb1]
path = "../vorago-reb1"
Loading

0 comments on commit 1f4d6f6

Please sign in to comment.