HAL update finished
All checks were successful
Rust/va108xx-rs/pipeline/head This commit looks good

This commit is contained in:
Robin Müller 2024-07-04 17:46:17 +02:00
parent 395a6a0538
commit 5a6227e764
Signed by: muellerr
GPG Key ID: A649FB78196E3849
10 changed files with 667 additions and 346 deletions

View File

@ -24,8 +24,7 @@ rustflags = [
# "-C", "link-arg=-Tdefmt.x", # "-C", "link-arg=-Tdefmt.x",
# Can be useful for debugging. # Can be useful for debugging.
"-Clink-args=-Map=app.map" # "-Clink-args=-Map=app.map"
] ]
[build] [build]

View File

@ -8,7 +8,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## [v0.7.0] 2024-07-04 ## [v0.7.0] 2024-07-04
- Replace `uarta` and `uartb` `Uart` constructors by `new` method. - Replace `uarta` and `uartb` `Uart` constructors by `new` constructor.
- Replace SPI `spia`, `spib` and `spic` constructors by `new` constructor.
- Replace I2C `i2ca`, `i2cb` constructors by `new` constructor. Update constructor
to fail on invalid fast I2C speed system clock values.
## [v0.6.0] 2024-06-16 ## [v0.6.0] 2024-06-16

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,5 @@
//! Prelude //! Prelude
pub use fugit::ExtU32 as _; pub use fugit::ExtU32 as _;
pub use fugit::RateExtU32 as _; pub use fugit::RateExtU32 as _;
pub use crate::time::*;

View File

@ -19,6 +19,7 @@ embedded-hal = "1"
version = "0.3" version = "0.3"
[dependencies.va108xx-hal] [dependencies.va108xx-hal]
path = "../va108xx-hal"
version = "0.6" version = "0.6"
features = ["rt"] features = ["rt"]
@ -26,7 +27,6 @@ features = ["rt"]
rt = ["va108xx-hal/rt"] rt = ["va108xx-hal/rt"]
[dev-dependencies] [dev-dependencies]
cortex-m-rtic = "1.1"
panic-halt = "0.2" panic-halt = "0.2"
nb = "1" nb = "1"
@ -36,6 +36,14 @@ version = "0.5"
[dev-dependencies.panic-rtt-target] [dev-dependencies.panic-rtt-target]
version = "0.1" version = "0.1"
[dev-dependencies.rtic]
version = "2"
features = ["thumbv6-backend"]
[dev-dependencies.rtic-monotonics]
version = "1"
features = ["cortex-m-systick"]
[package.metadata.docs.rs] [package.metadata.docs.rs]
all-features = true all-features = true
rustdoc-args = ["--generate-link-to-definition"] rustdoc-args = ["--generate-link-to-definition"]

View File

@ -13,7 +13,7 @@ fn main() -> ! {
rprintln!("-- Vorago Temperature Sensor and I2C Example --"); rprintln!("-- Vorago Temperature Sensor and I2C Example --");
let mut dp = pac::Peripherals::take().unwrap(); let mut dp = pac::Peripherals::take().unwrap();
let mut delay = set_up_ms_delay_provider(&mut dp.sysconfig, 50.MHz(), dp.tim0); let mut delay = set_up_ms_delay_provider(&mut dp.sysconfig, 50.MHz(), dp.tim0);
let mut temp_sensor = Adt75TempSensor::new(dp.i2ca, 50.MHz(), Some(&mut dp.sysconfig)) let mut temp_sensor = Adt75TempSensor::new(&mut dp.sysconfig, 50.MHz(), dp.i2ca)
.expect("Creating temperature sensor struct failed"); .expect("Creating temperature sensor struct failed");
loop { loop {
let temp = temp_sensor let temp = temp_sensor

View File

@ -52,12 +52,12 @@ fn main() -> ! {
false, false,
true, true,
); );
let mut spi = Spi::spib( let mut spi = Spi::new(
&mut dp.sysconfig,
50.MHz(),
dp.spib, dp.spib,
(sck, miso, mosi), (sck, miso, mosi),
50.MHz(),
spi_cfg, spi_cfg,
Some(&mut dp.sysconfig),
Some(&transfer_cfg.downgrade()), Some(&transfer_cfg.downgrade()),
); );

View File

@ -5,6 +5,7 @@
#[rtic::app(device = pac)] #[rtic::app(device = pac)]
mod app { mod app {
use panic_rtt_target as _; use panic_rtt_target as _;
use rtic_monotonics::systick::Systick;
use rtt_target::{rprintln, rtt_init_default, set_print_channel}; use rtt_target::{rprintln, rtt_init_default, set_print_channel};
use va108xx_hal::{ use va108xx_hal::{
clock::{set_clk_div_register, FilterClkSel}, clock::{set_clk_div_register, FilterClkSel},
@ -43,10 +44,18 @@ mod app {
struct Shared {} struct Shared {}
#[init] #[init]
fn init(ctx: init::Context) -> (Shared, Local, init::Monotonics) { fn init(ctx: init::Context) -> (Shared, Local) {
let channels = rtt_init_default!(); let channels = rtt_init_default!();
set_print_channel(channels.up.0); set_print_channel(channels.up.0);
rprintln!("-- Vorago Button IRQ Example --"); rprintln!("-- Vorago Button IRQ Example --");
// Initialize the systick interrupt & obtain the token to prove that we did
let systick_mono_token = rtic_monotonics::create_systick_token!();
Systick::start(
ctx.core.SYST,
Hertz::from(50.MHz()).raw(),
systick_mono_token,
);
let mode = match CFG_MODE { let mode = match CFG_MODE {
// Ask mode from user via RTT // Ask mode from user via RTT
CfgMode::Prompt => prompt_mode(channels.down.0), CfgMode::Prompt => prompt_mode(channels.down.0),
@ -90,7 +99,7 @@ mod app {
50.MHz(), 50.MHz(),
dp.tim0, dp.tim0,
); );
(Shared {}, Local { leds, button, mode }, init::Monotonics()) (Shared {}, Local { leds, button, mode })
} }
// `shared` cannot be accessed from this context // `shared` cannot be accessed from this context

View File

@ -139,12 +139,12 @@ fn main() -> ! {
.expect("Setting accelerometer chip select high failed"); .expect("Setting accelerometer chip select high failed");
let transfer_cfg = TransferConfig::<NoneT>::new(3.MHz(), spi::MODE_0, None, true, false); let transfer_cfg = TransferConfig::<NoneT>::new(3.MHz(), spi::MODE_0, None, true, false);
let spi = Spi::spib( let spi = Spi::new(
&mut dp.sysconfig,
50.MHz(),
dp.spib, dp.spib,
(sck, miso, mosi), (sck, miso, mosi),
50.MHz(),
spi_cfg, spi_cfg,
Some(&mut dp.sysconfig),
Some(&transfer_cfg.downgrade()), Some(&transfer_cfg.downgrade()),
) )
.downgrade(); .downgrade();

View File

@ -7,7 +7,7 @@
//! - [Temperature Sensor example](https://egit.irs.uni-stuttgart.de/rust/vorago-reb1/src/branch/main/examples/adt75-temp-sensor.rs) //! - [Temperature Sensor example](https://egit.irs.uni-stuttgart.de/rust/vorago-reb1/src/branch/main/examples/adt75-temp-sensor.rs)
use embedded_hal::i2c::{I2c, SevenBitAddress}; use embedded_hal::i2c::{I2c, SevenBitAddress};
use va108xx_hal::{ use va108xx_hal::{
i2c::{Error, I2cMaster, I2cSpeed, MasterConfig}, i2c::{Error, I2cMaster, I2cSpeed, InitError, MasterConfig},
pac, pac,
time::Hertz, time::Hertz,
}; };
@ -29,20 +29,40 @@ pub enum RegAddresses {
OneShot = 0x04, OneShot = 0x04,
} }
#[derive(Debug)]
pub enum AdtInitError {
Init(InitError),
I2c(Error),
}
impl From<InitError> for AdtInitError {
fn from(value: InitError) -> Self {
Self::Init(value)
}
}
impl From<Error> for AdtInitError {
fn from(value: Error) -> Self {
Self::I2c(value)
}
}
impl Adt75TempSensor { impl Adt75TempSensor {
pub fn new( pub fn new(
i2ca: pac::I2ca, sys_cfg: &mut pac::Sysconfig,
sys_clk: impl Into<Hertz> + Copy, sys_clk: impl Into<Hertz> + Copy,
sys_cfg: Option<&mut pac::Sysconfig>, i2ca: pac::I2ca,
) -> Result<Self, Error> { ) -> Result<Self, Error> {
let mut sensor = Adt75TempSensor { let mut sensor = Adt75TempSensor {
sensor_if: I2cMaster::i2ca( // The master construction can not fail for regular I2C speed.
sensor_if: I2cMaster::new(
sys_cfg,
sys_clk,
i2ca, i2ca,
MasterConfig::default(), MasterConfig::default(),
sys_clk,
I2cSpeed::Regular100khz, I2cSpeed::Regular100khz,
sys_cfg, )
), .unwrap(),
cmd_buf: [RegAddresses::Temperature as u8], cmd_buf: [RegAddresses::Temperature as u8],
current_reg: RegAddresses::Temperature, current_reg: RegAddresses::Temperature,
}; };