Compare commits
7 Commits
6f1d2554d5
...
v0.4.1
Author | SHA1 | Date | |
---|---|---|---|
3fc8ce519a | |||
2ad405d325 | |||
063a7a56e5 | |||
1db363fe1a | |||
659b7e8f27 | |||
5f6914a93a | |||
2de11478fb |
17
CHANGELOG.md
17
CHANGELOG.md
@ -8,6 +8,23 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
|
|
||||||
## [unreleased]
|
## [unreleased]
|
||||||
|
|
||||||
|
## [v0.4.1]
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Initial blockmode setting was not set in SPI constructor
|
||||||
|
|
||||||
|
## [v0.4.0]
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Replaced `Hertz` by `impl Into<Hertz>` completely and removed
|
||||||
|
`+ Copy` where not necessary
|
||||||
|
|
||||||
|
## [v0.3.1]
|
||||||
|
|
||||||
|
- Updated all links to point to new repository
|
||||||
|
|
||||||
## [v0.3.0]
|
## [v0.3.0]
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "va108xx-hal"
|
name = "va108xx-hal"
|
||||||
version = "0.3.0"
|
version = "0.4.1"
|
||||||
authors = ["Robin Mueller <muellerr@irs.uni-stuttgart.de>"]
|
authors = ["Robin Mueller <muellerr@irs.uni-stuttgart.de>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
description = "HAL for the Vorago VA108xx family of microcontrollers"
|
description = "HAL for the Vorago VA108xx family of microcontrollers"
|
||||||
|
@ -59,7 +59,7 @@ your custom board.
|
|||||||
|
|
||||||
The hello world of embedded development is usually to blinky a LED. This example
|
The hello world of embedded development is usually to blinky a LED. This example
|
||||||
is contained within the
|
is contained within the
|
||||||
[examples folder](https://github.com/robamu-org/va108xx-hal-rs/tree/main/examples/blinky.rs).
|
[examples folder](https://egit.irs.uni-stuttgart.de/rust/va108xx-hal/src/branch/main/examples/blinky.rs).
|
||||||
|
|
||||||
1. Set up your Rust cross-compiler if you have not done so yet. See more in the [build chapter](#Building)
|
1. Set up your Rust cross-compiler if you have not done so yet. See more in the [build chapter](#Building)
|
||||||
2. Create a new binary crate with `cargo init`
|
2. Create a new binary crate with `cargo init`
|
||||||
@ -85,4 +85,4 @@ is contained within the
|
|||||||
|
|
||||||
7. Flashing the board might work differently for different boards and there is usually
|
7. Flashing the board might work differently for different boards and there is usually
|
||||||
more than one way. You can find example instructions for the REB1 development board
|
more than one way. You can find example instructions for the REB1 development board
|
||||||
[here](https://github.com/robamu/vorago-reb1-rs).
|
[here](https://github.com/robamu-org/vorago-reb1-rs).
|
||||||
|
@ -114,12 +114,8 @@ fn main() -> ! {
|
|||||||
match SPI_BUS_SEL {
|
match SPI_BUS_SEL {
|
||||||
SpiBusSelect::SpiAPortA | SpiBusSelect::SpiAPortB => {
|
SpiBusSelect::SpiAPortA | SpiBusSelect::SpiAPortB => {
|
||||||
if let Some(ref mut spi) = *spia_ref.borrow_mut() {
|
if let Some(ref mut spi) = *spia_ref.borrow_mut() {
|
||||||
let transfer_cfg = TransferConfig::new_no_hw_cs(
|
let transfer_cfg =
|
||||||
SPI_SPEED_KHZ.khz().into(),
|
TransferConfig::new_no_hw_cs(SPI_SPEED_KHZ.khz(), SPI_MODE, BLOCKMODE, false);
|
||||||
SPI_MODE,
|
|
||||||
BLOCKMODE,
|
|
||||||
false,
|
|
||||||
);
|
|
||||||
spi.cfg_transfer(&transfer_cfg);
|
spi.cfg_transfer(&transfer_cfg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -127,7 +123,7 @@ fn main() -> ! {
|
|||||||
if let Some(ref mut spi) = *spib_ref.borrow_mut() {
|
if let Some(ref mut spi) = *spib_ref.borrow_mut() {
|
||||||
let hw_cs_pin = pinsb.pb2.into_funsel_1();
|
let hw_cs_pin = pinsb.pb2.into_funsel_1();
|
||||||
let transfer_cfg = TransferConfig::new(
|
let transfer_cfg = TransferConfig::new(
|
||||||
SPI_SPEED_KHZ.khz().into(),
|
SPI_SPEED_KHZ.khz(),
|
||||||
SPI_MODE,
|
SPI_MODE,
|
||||||
Some(hw_cs_pin),
|
Some(hw_cs_pin),
|
||||||
BLOCKMODE,
|
BLOCKMODE,
|
||||||
|
@ -25,7 +25,7 @@ fn main() -> ! {
|
|||||||
(tx, rx),
|
(tx, rx),
|
||||||
115200.bps(),
|
115200.bps(),
|
||||||
&mut dp.SYSCONFIG,
|
&mut dp.SYSCONFIG,
|
||||||
50.mhz().into(),
|
50.mhz(),
|
||||||
);
|
);
|
||||||
let (mut tx, mut rx) = uartb.split();
|
let (mut tx, mut rx) = uartb.split();
|
||||||
writeln!(tx, "Hello World\r").unwrap();
|
writeln!(tx, "Hello World\r").unwrap();
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
//!
|
//!
|
||||||
//! ## Examples
|
//! ## Examples
|
||||||
//!
|
//!
|
||||||
//! - [Blinky example](https://github.com/robamu-org/va108xx-hal-rs/blob/main/examples/blinky.rs)
|
//! - [Blinky example](https://egit.irs.uni-stuttgart.de/rust/va108xx-hal/src/branch/main/examples/blinky.rs)
|
||||||
pub mod dynpins;
|
pub mod dynpins;
|
||||||
pub use dynpins::*;
|
pub use dynpins::*;
|
||||||
|
|
||||||
|
@ -231,7 +231,7 @@ macro_rules! i2c_base {
|
|||||||
impl I2cBase<$I2CX> {
|
impl I2cBase<$I2CX> {
|
||||||
pub fn $i2cx(
|
pub fn $i2cx(
|
||||||
i2c: $I2CX,
|
i2c: $I2CX,
|
||||||
sys_clk: impl Into<Hertz> + Copy,
|
sys_clk: impl Into<Hertz>,
|
||||||
speed_mode: I2cSpeed,
|
speed_mode: I2cSpeed,
|
||||||
ms_cfg: Option<&MasterConfig>,
|
ms_cfg: Option<&MasterConfig>,
|
||||||
sl_cfg: Option<&SlaveConfig>,
|
sl_cfg: Option<&SlaveConfig>,
|
||||||
@ -740,7 +740,7 @@ macro_rules! i2c_slave {
|
|||||||
fn $i2cx_slave(
|
fn $i2cx_slave(
|
||||||
i2c: $I2CX,
|
i2c: $I2CX,
|
||||||
cfg: SlaveConfig,
|
cfg: SlaveConfig,
|
||||||
sys_clk: impl Into<Hertz> + Copy,
|
sys_clk: impl Into<Hertz>,
|
||||||
speed_mode: I2cSpeed,
|
speed_mode: I2cSpeed,
|
||||||
sys_cfg: Option<&mut SYSCONFIG>,
|
sys_cfg: Option<&mut SYSCONFIG>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
@ -897,7 +897,7 @@ macro_rules! i2c_slave {
|
|||||||
pub fn i2ca(
|
pub fn i2ca(
|
||||||
i2c: $I2CX,
|
i2c: $I2CX,
|
||||||
cfg: SlaveConfig,
|
cfg: SlaveConfig,
|
||||||
sys_clk: impl Into<Hertz> + Copy,
|
sys_clk: impl Into<Hertz>,
|
||||||
speed_mode: I2cSpeed,
|
speed_mode: I2cSpeed,
|
||||||
sys_cfg: Option<&mut SYSCONFIG>,
|
sys_cfg: Option<&mut SYSCONFIG>,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
@ -912,7 +912,7 @@ macro_rules! i2c_slave {
|
|||||||
pub fn $i2cx(
|
pub fn $i2cx(
|
||||||
i2c: $I2CX,
|
i2c: $I2CX,
|
||||||
cfg: SlaveConfig,
|
cfg: SlaveConfig,
|
||||||
sys_clk: impl Into<Hertz> + Copy,
|
sys_clk: impl Into<Hertz>,
|
||||||
speed_mode: I2cSpeed,
|
speed_mode: I2cSpeed,
|
||||||
sys_cfg: Option<&mut SYSCONFIG>,
|
sys_cfg: Option<&mut SYSCONFIG>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
//!
|
//!
|
||||||
//! ## Examples
|
//! ## Examples
|
||||||
//!
|
//!
|
||||||
//! - [PWM example](https://github.com/robamu-org/va108xx-hal-rs/blob/main/examples/pwm.rs)
|
//! - [PWM example](https://egit.irs.uni-stuttgart.de/rust/va108xx-hal/src/branch/main/examples/pwm.rs)
|
||||||
use core::marker::PhantomData;
|
use core::marker::PhantomData;
|
||||||
|
|
||||||
use crate::{clock::enable_peripheral_clock, gpio::DynPinId};
|
use crate::{clock::enable_peripheral_clock, gpio::DynPinId};
|
||||||
|
17
src/spi.rs
17
src/spi.rs
@ -2,7 +2,7 @@
|
|||||||
//!
|
//!
|
||||||
//! ## Examples
|
//! ## Examples
|
||||||
//!
|
//!
|
||||||
//! - [Blocking SPI example](https://github.com/robamu-org/va108xx-hal-rs/blob/main/examples/spi.rs)
|
//! - [Blocking SPI example](https://egit.irs.uni-stuttgart.de/rust/va108xx-hal/src/branch/main/examples/spi.rs)
|
||||||
use crate::Sealed;
|
use crate::Sealed;
|
||||||
use crate::{
|
use crate::{
|
||||||
clock::{enable_peripheral_clock, PeripheralClocks},
|
clock::{enable_peripheral_clock, PeripheralClocks},
|
||||||
@ -218,9 +218,9 @@ pub struct ReducedTransferConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl TransferConfig<NoneT> {
|
impl TransferConfig<NoneT> {
|
||||||
pub fn new_no_hw_cs(spi_clk: Hertz, mode: Mode, blockmode: bool, sod: bool) -> Self {
|
pub fn new_no_hw_cs(spi_clk: impl Into<Hertz>, mode: Mode, blockmode: bool, sod: bool) -> Self {
|
||||||
TransferConfig {
|
TransferConfig {
|
||||||
spi_clk,
|
spi_clk: spi_clk.into(),
|
||||||
mode,
|
mode,
|
||||||
hw_cs: None,
|
hw_cs: None,
|
||||||
sod,
|
sod,
|
||||||
@ -231,14 +231,14 @@ impl TransferConfig<NoneT> {
|
|||||||
|
|
||||||
impl<HWCS: HwCs> TransferConfig<HWCS> {
|
impl<HWCS: HwCs> TransferConfig<HWCS> {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
spi_clk: Hertz,
|
spi_clk: impl Into<Hertz>,
|
||||||
mode: Mode,
|
mode: Mode,
|
||||||
hw_cs: Option<HWCS>,
|
hw_cs: Option<HWCS>,
|
||||||
blockmode: bool,
|
blockmode: bool,
|
||||||
sod: bool,
|
sod: bool,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
TransferConfig {
|
TransferConfig {
|
||||||
spi_clk,
|
spi_clk: spi_clk.into(),
|
||||||
mode,
|
mode,
|
||||||
hw_cs,
|
hw_cs,
|
||||||
sod,
|
sod,
|
||||||
@ -428,6 +428,7 @@ macro_rules! spi {
|
|||||||
w.sod().bit(sod);
|
w.sod().bit(sod);
|
||||||
w.ms().bit(ms);
|
w.ms().bit(ms);
|
||||||
w.mdlycap().bit(mdlycap);
|
w.mdlycap().bit(mdlycap);
|
||||||
|
w.blockmode().bit(init_blockmode);
|
||||||
unsafe { w.ss().bits(ss) }
|
unsafe { w.ss().bits(ss) }
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -452,7 +453,7 @@ macro_rules! spi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn cfg_clock(&mut self, spi_clk: Hertz) {
|
pub fn cfg_clock(&mut self, spi_clk: impl Into<Hertz>) {
|
||||||
self.spi_base.cfg_clock(spi_clk);
|
self.spi_base.cfg_clock(spi_clk);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -482,8 +483,8 @@ macro_rules! spi {
|
|||||||
|
|
||||||
impl<WORD: Word> SpiBase<$SPIX, WORD> {
|
impl<WORD: Word> SpiBase<$SPIX, WORD> {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn cfg_clock(&mut self, spi_clk: Hertz) {
|
pub fn cfg_clock(&mut self, spi_clk: impl Into<Hertz>) {
|
||||||
let clk_prescale = self.sys_clk.0 / (spi_clk.0 * (self.cfg.scrdv as u32 + 1));
|
let clk_prescale = self.sys_clk.0 / (spi_clk.into().0 * (self.cfg.scrdv as u32 + 1));
|
||||||
self.spi
|
self.spi
|
||||||
.clkprescale
|
.clkprescale
|
||||||
.write(|w| unsafe { w.bits(clk_prescale) });
|
.write(|w| unsafe { w.bits(clk_prescale) });
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
//!
|
//!
|
||||||
//! ## Examples
|
//! ## Examples
|
||||||
//!
|
//!
|
||||||
//! - [MS and second tick implementation](https://github.com/robamu-org/va108xx-hal-rs/blob/main/examples/timer-ticks.rs)
|
//! - [MS and second tick implementation](https://egit.irs.uni-stuttgart.de/rust/va108xx-hal/src/branch/main/examples/timer-ticks.rs)
|
||||||
|
//! - [Cascade feature example](https://egit.irs.uni-stuttgart.de/rust/va108xx-hal/src/branch/main/examples/cascade.rs)
|
||||||
use crate::{
|
use crate::{
|
||||||
clock::{enable_peripheral_clock, PeripheralClocks},
|
clock::{enable_peripheral_clock, PeripheralClocks},
|
||||||
gpio::{
|
gpio::{
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
//!
|
//!
|
||||||
//! ## Examples
|
//! ## Examples
|
||||||
//!
|
//!
|
||||||
//! - [UART example](https://github.com/robamu-org/va108xx-hal-rs/blob/main/examples/uart.rs)
|
//! - [UART example](https://egit.irs.uni-stuttgart.de/rust/va108xx-hal/src/branch/main/examples/uart.rs)
|
||||||
use core::{convert::Infallible, ptr};
|
use core::{convert::Infallible, ptr};
|
||||||
use core::{marker::PhantomData, ops::Deref};
|
use core::{marker::PhantomData, ops::Deref};
|
||||||
use libm::floorf;
|
use libm::floorf;
|
||||||
@ -306,12 +306,12 @@ macro_rules! uart_impl {
|
|||||||
pins: PINS,
|
pins: PINS,
|
||||||
config: impl Into<Config>,
|
config: impl Into<Config>,
|
||||||
syscfg: &mut SYSCONFIG,
|
syscfg: &mut SYSCONFIG,
|
||||||
sys_clk: Hertz
|
sys_clk: impl Into<Hertz>
|
||||||
) -> Self
|
) -> Self
|
||||||
{
|
{
|
||||||
enable_peripheral_clock(syscfg, $clk_enb_enum);
|
enable_peripheral_clock(syscfg, $clk_enb_enum);
|
||||||
Uart { uart, pins, tx: Tx::new(), rx: Rx::new() }.init(
|
Uart { uart, pins, tx: Tx::new(), rx: Rx::new() }.init(
|
||||||
config.into(), sys_clk
|
config.into(), sys_clk.into()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user