Skip to content

Commit

Permalink
improve SPI HAL
Browse files Browse the repository at this point in the history
  • Loading branch information
robamu committed Jul 4, 2024
1 parent abb78c2 commit 395a6a0
Show file tree
Hide file tree
Showing 10 changed files with 803 additions and 970 deletions.
2 changes: 1 addition & 1 deletion examples/simple/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ features = ["cortex-m-systick"]
[dependencies.va108xx-hal]
version = "0.6"
path = "../../va108xx-hal"
features = ["rt", "defmt"]
features = ["rt", "defmt"]
4 changes: 3 additions & 1 deletion examples/simple/examples/rtt-log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
#![no_std]

use cortex_m_rt::entry;
use panic_halt as _;
use panic_rtt_target as _;
use rtt_target::{rprintln, rtt_init_print};
use va108xx_hal as _;

#[entry]
fn main() -> ! {
rtt_init_print!();
rprintln!("-- VA108XX RTT example --");
let mut counter = 0;
loop {
rprintln!("{}: Hello, world!", counter);
Expand Down
22 changes: 13 additions & 9 deletions examples/simple/examples/spi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ fn main() -> ! {
pinsa.pa30.into_funsel_1(),
pinsa.pa29.into_funsel_1(),
);
let mut spia = Spi::spia(
let mut spia = Spi::new(
&mut dp.sysconfig,
50.MHz(),
dp.spia,
(sck, miso, mosi),
50.MHz(),
spi_cfg,
Some(&mut dp.sysconfig),
None,
);
spia.set_fill_word(FILL_WORD);
Expand All @@ -90,12 +90,12 @@ fn main() -> ! {
pinsb.pb8.into_funsel_2(),
pinsb.pb7.into_funsel_2(),
);
let mut spia = Spi::spia(
let mut spia = Spi::new(
&mut dp.sysconfig,
50.MHz(),
dp.spia,
(sck, miso, mosi),
50.MHz(),
spi_cfg,
Some(&mut dp.sysconfig),
None,
);
spia.set_fill_word(FILL_WORD);
Expand All @@ -107,12 +107,12 @@ fn main() -> ! {
pinsb.pb4.into_funsel_1(),
pinsb.pb3.into_funsel_1(),
);
let mut spib = Spi::spib(
let mut spib = Spi::new(
&mut dp.sysconfig,
50.MHz(),
dp.spib,
(sck, miso, mosi),
50.MHz(),
spi_cfg,
Some(&mut dp.sysconfig),
None,
);
spib.set_fill_word(FILL_WORD);
Expand Down Expand Up @@ -195,6 +195,10 @@ fn main() -> ! {
if EXAMPLE_SEL == ExampleSelect::Loopback {
// Can't really verify correct reply here.
spi.write(&[0x42]).expect("write failed");
// Need small delay.. otherwise we will read back the sent byte (which we don't want here).
// The write function will return as soon as all bytes were shifted out, ignoring the
// reply bytes.
delay.delay_us(50);
// Because of the loopback mode, we should get back the fill word here.
spi.read(&mut reply_buf[0..1]).unwrap();
assert_eq!(reply_buf[0], FILL_WORD);
Expand Down
2 changes: 1 addition & 1 deletion examples/simple/examples/uart-irq-rtic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ mod app {

let irq_cfg = IrqCfg::new(pac::interrupt::OC3, true, true);
let (mut irq_uart, _) =
uart::Uart::uartb(dp.uartb, (tx, rx), 115200.Hz(), &mut dp.sysconfig, 50.MHz())
uart::Uart::new(&mut dp.sysconfig, 50.MHz(), dp.uartb, (tx, rx), 115200.Hz())
.into_uart_with_irq(irq_cfg, Some(&mut dp.sysconfig), Some(&mut dp.irqsel))
.downgrade();
irq_uart
Expand Down
2 changes: 1 addition & 1 deletion examples/simple/examples/uart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fn main() -> ! {
let tx = gpioa.pa9.into_funsel_2();
let rx = gpioa.pa8.into_funsel_2();

let uarta = uart::Uart::uarta(dp.uarta, (tx, rx), 115200.Hz(), &mut dp.sysconfig, 50.MHz());
let uarta = uart::Uart::new(&mut dp.sysconfig, 50.MHz(), dp.uarta, (tx, rx), 115200.Hz());
let (mut tx, mut rx) = uarta.split();
writeln!(tx, "Hello World\r").unwrap();
loop {
Expand Down
4 changes: 4 additions & 0 deletions va108xx-hal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [v0.7.0] 2024-07-04

- Replace `uarta` and `uartb` `Uart` constructors by `new` method.

## [v0.6.0] 2024-06-16

- Updated `embedded-hal` to v1
Expand Down
Loading

0 comments on commit 395a6a0

Please sign in to comment.