Skip to content

Commit 1f4d6f6

Browse files
committed
now needs tests
1 parent f7ff749 commit 1f4d6f6

File tree

6 files changed

+114
-153
lines changed

6 files changed

+114
-153
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ members = [
99
"examples/embassy",
1010
"board-tests",
1111
"bootloader",
12-
# "flashloader",
12+
"flashloader",
1313
]
1414

1515
exclude = [

examples/rtic/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ cortex-m-rt = "0.7"
99
embedded-hal = "1"
1010
embedded-io = "0.6"
1111
rtt-target = { version = "0.5" }
12+
panic-rtt-target = { version = "0.1" }
1213

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

1818
[dependencies.rtic]
1919
version = "2"

examples/rtic/src/bin/uart-echo-rtic.rs

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ mod app {
2828
use rtic_monotonics::Monotonic;
2929
use rtt_target::{rprintln, rtt_init_print};
3030
use va108xx_hal::{
31-
gpio::PinsB,
31+
gpio::PinsA,
3232
pac,
3333
prelude::*,
3434
uart::{self, RxWithIrq, Tx},
@@ -38,8 +38,8 @@ mod app {
3838
struct Local {
3939
data_producer: StaticProd<'static, u8, RX_RING_BUF_SIZE>,
4040
data_consumer: CachingCons<&'static StaticRb<u8, RX_RING_BUF_SIZE>>,
41-
rx: RxWithIrq<pac::Uartb>,
42-
tx: Tx<pac::Uartb>,
41+
rx: RxWithIrq<pac::Uarta>,
42+
tx: Tx<pac::Uarta>,
4343
}
4444

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

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

5757
let mut dp = cx.device;
58-
let gpiob = PinsB::new(&mut dp.sysconfig, Some(dp.ioconfig), dp.portb);
59-
let tx = gpiob.pb21.into_funsel_1();
60-
let rx = gpiob.pb20.into_funsel_1();
61-
62-
let irq_uart =
63-
uart::Uart::new(&mut dp.sysconfig, 50.MHz(), dp.uartb, (tx, rx), 115200.Hz());
58+
let gpioa = PinsA::new(&mut dp.sysconfig, Some(dp.ioconfig), dp.porta);
59+
let tx = gpioa.pa9.into_funsel_2();
60+
let rx = gpioa.pa8.into_funsel_2();
61+
62+
let irq_uart = uart::Uart::new(
63+
&mut dp.sysconfig,
64+
SYSCLK_FREQ,
65+
dp.uarta,
66+
(tx, rx),
67+
115200.Hz(),
68+
);
6469
let (tx, rx) = irq_uart.split();
65-
let mut rx = rx.into_rx_with_irq(&dp.irqsel, pac::interrupt::OC3);
70+
let mut rx = rx.into_rx_with_irq(&mut dp.sysconfig, &mut dp.irqsel, pac::interrupt::OC3);
6671

6772
rx.start();
6873

6974
let (data_producer, data_consumer) = unsafe { RINGBUF.split_ref() };
75+
echo_handler::spawn().unwrap();
7076
(
7177
Shared {},
7278
Local {
@@ -121,14 +127,16 @@ mod app {
121127
async fn echo_handler(cx: echo_handler::Context) {
122128
loop {
123129
let bytes_to_read = cx.local.data_consumer.occupied_len();
124-
let actual_read_bytes = cx
125-
.local
126-
.data_consumer
127-
.pop_slice(&mut cx.local.buf[0..bytes_to_read]);
128-
cx.local
129-
.tx
130-
.write_all(&cx.local.buf[0..actual_read_bytes])
131-
.expect("Failed to write to TX");
130+
if bytes_to_read > 0 {
131+
let actual_read_bytes = cx
132+
.local
133+
.data_consumer
134+
.pop_slice(&mut cx.local.buf[0..bytes_to_read]);
135+
cx.local
136+
.tx
137+
.write_all(&cx.local.buf[0..actual_read_bytes])
138+
.expect("Failed to write to TX");
139+
}
132140
Mono::delay(50.millis()).await;
133141
}
134142
}

flashloader/Cargo.toml

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,22 @@ embedded-hal-nb = "1"
1111
embedded-io = "0.6"
1212
panic-rtt-target = { version = "0.1.3" }
1313
rtt-target = { version = "0.5" }
14-
rtt-log = "0.3"
1514
log = "0.4"
1615
crc = "3"
17-
rtic-sync = "1"
1816

1917
[dependencies.satrs]
2018
version = "0.2"
2119
default-features = false
2220

21+
[dependencies.rtt-log]
22+
version = "0.3"
23+
git = "https://github.com/us-irs/rtt-log-rs.git"
24+
branch = "allow-usage-on-non-cas-systems"
25+
2326
[dependencies.ringbuf]
2427
version = "0.4"
28+
git = "https://github.com/us-irs/ringbuf.git"
29+
branch = "use-portable-atomic-crate"
2530
default-features = false
2631

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

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

4452
[dependencies.rtic]
4553
version = "2"
46-
features = ["thumbv7-backend"]
54+
features = ["thumbv6-backend"]
4755

4856
[dependencies.rtic-monotonics]
4957
version = "2"
5058
features = ["cortex-m-systick"]
59+
60+
[dependencies.rtic-sync]
61+
version = "1"
62+
features = ["defmt-03"]
63+
64+
[dependencies.va108xx-hal]
65+
path = "../va108xx-hal"
66+
67+
[dependencies.vorago-reb1]
68+
path = "../vorago-reb1"

0 commit comments

Comments
 (0)