19 Commits

Author SHA1 Message Date
b4f1512463 docs patch 2 2025-02-13 15:47:50 +01:00
e9ec01fc60 Merge pull request 'doc fixes' (#48) from va108xx-embassy-doc-fix into main
Reviewed-on: #48
2025-02-13 15:38:50 +01:00
d57cd383cd doc fixes 2025-02-13 15:38:38 +01:00
df4e943f48 Merge pull request 'use released package versions' (#47) from use-released-package-versions into main
Reviewed-on: #47
2025-02-13 15:26:41 +01:00
93b67a4795 README update 2025-02-13 15:26:24 +01:00
a9f2e6dcee use released package versions 2025-02-13 15:25:01 +01:00
271c853df1 Merge pull request 'prepare va108xx-embassy release' (#46) from prepare-va108xx-embassy-release into main
Reviewed-on: #46
2025-02-13 15:22:36 +01:00
107189b166 prepare va108xx-embassy release 2025-02-13 15:22:18 +01:00
872944bebf Merge pull request 'prepare BSP release' (#45) from vorago-reb1-release into main
Reviewed-on: #45
2025-02-13 15:08:22 +01:00
d077bb6210 prepare BSP release 2025-02-13 15:06:02 +01:00
bd286bdb2a Merge pull request 'small README tweak' (#44) from readme-tweak into main
Reviewed-on: #44
2025-02-13 14:56:48 +01:00
d3cc00a4a5 small README tweak 2025-02-13 14:56:24 +01:00
1018a65447 Merge pull request 'add more defmt features' (#42) from add-more-defmt-features into main
Reviewed-on: #42
2025-02-13 14:52:03 +01:00
0a31b637e6 add more defmt features 2025-02-13 14:51:54 +01:00
6e1ae70054 Merge pull request 'add various debug impls' (#43) from add-various-debug-impls into main
Reviewed-on: #43
2025-02-13 14:51:27 +01:00
8ae2d6189a add various debug impls 2025-02-13 14:50:00 +01:00
549a98dbaf Merge pull request 'all doc fixes' (#41) from doc-fixes into main
Reviewed-on: #41
2025-02-13 12:23:56 +01:00
e24fc608a3 all doc fixes 2025-02-13 11:44:14 +01:00
7b74312013 Merge pull request 'completed async RX support as well' (#39) from async-uart-rx into main
Reviewed-on: #39
2025-02-13 11:33:36 +01:00
26 changed files with 152 additions and 74 deletions

View File

@@ -14,6 +14,8 @@ This workspace contains the following released crates:
crate containing basic low-level register definition. crate containing basic low-level register definition.
- The [`va108xx-hal`](https://egit.irs.uni-stuttgart.de/rust/va108xx-rs/src/branch/main/va108xx-hal) - The [`va108xx-hal`](https://egit.irs.uni-stuttgart.de/rust/va108xx-rs/src/branch/main/va108xx-hal)
HAL crate containing higher-level abstractions on top of the PAC register crate. HAL crate containing higher-level abstractions on top of the PAC register crate.
- The [`va108xx-embassy`](https://egit.irs.uni-stuttgart.de/rust/va108xx-rs/src/branch/main/va108xx-embassy)
crate containing support for running the embassy-rs RTOS.
- The [`vorago-reb1`](https://egit.irs.uni-stuttgart.de/rust/va108xx-rs/src/branch/main/vorago-reb1) - The [`vorago-reb1`](https://egit.irs.uni-stuttgart.de/rust/va108xx-rs/src/branch/main/vorago-reb1)
BSP crate containing support for the REB1 development board. BSP crate containing support for the REB1 development board.

View File

@@ -15,10 +15,12 @@ num_enum = { version = "0.7", default-features = false }
static_assertions = "1" static_assertions = "1"
[dependencies.va108xx-hal] [dependencies.va108xx-hal]
path = "../va108xx-hal" version = "0.9"
# path = "../va108xx-hal"
[dependencies.vorago-reb1] [dependencies.vorago-reb1]
path = "../vorago-reb1" version = "0.7"
# path = "../vorago-reb1"
[features] [features]
default = [] default = []

View File

@@ -27,8 +27,8 @@ embassy-executor = { version = "0.7", features = [
"executor-interrupt" "executor-interrupt"
]} ]}
va108xx-hal = { path = "../../va108xx-hal" } va108xx-hal = "0.9"
va108xx-embassy = { path = "../../va108xx-embassy", default-features = false } va108xx-embassy = "0.1"
[features] [features]
default = ["ticks-hz-1_000", "va108xx-embassy/irq-oc30-oc31"] default = ["ticks-hz-1_000", "va108xx-embassy/irq-oc30-oc31"]

View File

@@ -22,5 +22,5 @@ rtic-sync = { version = "1.3", features = ["defmt-03"] }
once_cell = {version = "1", default-features = false, features = ["critical-section"]} once_cell = {version = "1", default-features = false, features = ["critical-section"]}
ringbuf = { version = "0.4.7", default-features = false, features = ["portable-atomic"] } ringbuf = { version = "0.4.7", default-features = false, features = ["portable-atomic"] }
va108xx-hal = { version = "0.9", path = "../../va108xx-hal" } va108xx-hal = "0.9"
vorago-reb1 = { path = "../../vorago-reb1" } vorago-reb1 = "0.7"

View File

@@ -16,9 +16,8 @@ embedded-io = "0.6"
cortex-m-semihosting = "0.5.0" cortex-m-semihosting = "0.5.0"
[dependencies.va108xx-hal] [dependencies.va108xx-hal]
path = "../../va108xx-hal"
version = "0.9" version = "0.9"
features = ["rt", "defmt"] features = ["rt", "defmt"]
[dependencies.vorago-reb1] [dependencies.vorago-reb1]
path = "../../vorago-reb1" version = "0.7"

View File

@@ -29,7 +29,9 @@ rtic-monotonics = { version = "2", features = ["cortex-m-systick"] }
rtic-sync = {version = "1", features = ["defmt-03"]} rtic-sync = {version = "1", features = ["defmt-03"]}
[dependencies.va108xx-hal] [dependencies.va108xx-hal]
path = "../va108xx-hal" version = "0.9"
# path = "../va108xx-hal"
[dependencies.vorago-reb1] [dependencies.vorago-reb1]
path = "../vorago-reb1" version = "0.7"
# path = "../vorago-reb1"

View File

@@ -0,0 +1,17 @@
Change Log
=======
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/).
## [unreleased]
## [v0.1.2] and [v0.1.1] 2025-02-13
Docs patch
## [v0.1.0] 2025-02-13
Initial release

View File

@@ -1,11 +1,17 @@
[package] [package]
name = "va108xx-embassy" name = "va108xx-embassy"
version = "0.1.0" version = "0.1.2"
edition = "2021" edition = "2021"
authors = ["Robin Mueller <muellerr@irs.uni-stuttgart.de>"]
description = "Embassy-rs support for the Vorago VA108xx family of microcontrollers"
homepage = "https://egit.irs.uni-stuttgart.de/rust/va108xx-rs"
repository = "https://egit.irs.uni-stuttgart.de/rust/va108xx-rs"
license = "Apache-2.0"
keywords = ["no-std", "hal", "cortex-m", "vorago", "va108xx"]
categories = ["aerospace", "embedded", "no-std", "hardware-support"]
[dependencies] [dependencies]
critical-section = "1" critical-section = "1"
portable-atomic = { version = "1", features = ["unsafe-assume-single-core"]}
embassy-sync = "0.6" embassy-sync = "0.6"
embassy-executor = "0.7" embassy-executor = "0.7"
@@ -14,8 +20,12 @@ embassy-time-queue-utils = "0.1"
once_cell = { version = "1", default-features = false, features = ["critical-section"] } once_cell = { version = "1", default-features = false, features = ["critical-section"] }
[dependencies.va108xx-hal] va108xx-hal = "0.9"
path = "../va108xx-hal"
[target.'cfg(all(target_arch = "arm", target_os = "none"))'.dependencies]
portable-atomic = { version = "1", features = ["unsafe-assume-single-core"] }
[target.'cfg(not(all(target_arch = "arm", target_os = "none")))'.dependencies]
portable-atomic = "1"
[features] [features]
default = ["irq-oc30-oc31"] default = ["irq-oc30-oc31"]
@@ -25,3 +35,6 @@ irqs-in-lib = []
irq-oc28-oc29 = ["irqs-in-lib"] irq-oc28-oc29 = ["irqs-in-lib"]
irq-oc29-oc30 = ["irqs-in-lib"] irq-oc29-oc30 = ["irqs-in-lib"]
irq-oc30-oc31 = ["irqs-in-lib"] irq-oc30-oc31 = ["irqs-in-lib"]
[package.metadata.docs.rs]
rustdoc-args = ["--generate-link-to-definition"]

3
va108xx-embassy/docs.sh Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/sh
export RUSTDOCFLAGS="--cfg docsrs --generate-link-to-definition -Z unstable-options"
cargo +nightly doc --open

View File

@@ -23,14 +23,15 @@
//! //!
//! You can disable the default features and then specify one of the features above to use the //! You can disable the default features and then specify one of the features above to use the
//! documented combination of IRQs. It is also possible to specify custom IRQs by importing and //! documented combination of IRQs. It is also possible to specify custom IRQs by importing and
//! using the [embassy::embassy_time_driver_irqs] macro to declare the IRQ handlers in the //! using the [embassy_time_driver_irqs] macro to declare the IRQ handlers in the
//! application code. If this is done, [embassy::init_with_custom_irqs] must be used //! application code. If this is done, [embassy::init_with_custom_irqs] must be used
//! method to pass the IRQ numbers to the library. //! method to pass the IRQ numbers to the library.
//! //!
//! ## Examples //! ## Examples
//! //!
//! [embassy example project](https://egit.irs.uni-stuttgart.de/rust/va108xx-rs/src/branch/main/examples/embassy) //! [embassy example projects](https://egit.irs.uni-stuttgart.de/rust/va108xx-rs/src/branch/main/examples/embassy)
#![no_std] #![no_std]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
use core::cell::{Cell, RefCell}; use core::cell::{Cell, RefCell};
use critical_section::CriticalSection; use critical_section::CriticalSection;
use embassy_sync::blocking_mutex::CriticalSectionMutex as Mutex; use embassy_sync::blocking_mutex::CriticalSectionMutex as Mutex;
@@ -62,7 +63,7 @@ time_driver_impl!(
/// the feature flags specified. However, the macro is exported to allow users to specify the /// the feature flags specified. However, the macro is exported to allow users to specify the
/// interrupt handlers themselves. /// interrupt handlers themselves.
/// ///
/// Please note that you have to explicitely import the [va108xx_hal::pac::interrupt] /// Please note that you have to explicitely import the [macro@va108xx_hal::pac::interrupt]
/// macro in the application code in case this macro is used there. /// macro in the application code in case this macro is used there.
#[macro_export] #[macro_export]
macro_rules! embassy_time_driver_irqs { macro_rules! embassy_time_driver_irqs {

View File

@@ -25,12 +25,6 @@ rustup target add thumbv6m-none-eabi
After that, you can use `cargo build` to build the development version of the crate. After that, you can use `cargo build` to build the development version of the crate.
If you have not done this yet, it is recommended to read some of the excellent resources
available to learn Rust:
- [Rust Embedded Book](https://docs.rust-embedded.org/book/)
- [Rust Discovery Book](https://docs.rust-embedded.org/discovery/)
## Setting up your own binary crate ## Setting up your own binary crate
If you have a custom board, you might be interested in setting up a new binary crate for your If you have a custom board, you might be interested in setting up a new binary crate for your
@@ -65,3 +59,11 @@ 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 in primary README. more than one way. You can find example instructions in primary README.
## Embedded Rust
If you have not done this yet, it is recommended to read some of the excellent resources available
to learn Rust:
- [Rust Embedded Book](https://docs.rust-embedded.org/book/)
- [Rust Discovery Book](https://docs.rust-embedded.org/discovery/)

View File

@@ -11,6 +11,7 @@ static SYS_CLOCK: Mutex<OnceCell<Hertz>> = Mutex::new(OnceCell::new());
pub type PeripheralClocks = PeripheralSelect; pub type PeripheralClocks = PeripheralSelect;
#[derive(Debug, PartialEq, Eq)] #[derive(Debug, PartialEq, Eq)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum FilterClkSel { pub enum FilterClkSel {
SysClk = 0, SysClk = 0,
Clk1 = 1, Clk1 = 1,

View File

@@ -4,7 +4,7 @@
//! the [embedded_hal_async::digital::Wait] trait. These types allow for asynchronous waiting //! the [embedded_hal_async::digital::Wait] trait. These types allow for asynchronous waiting
//! on GPIO pins. Please note that this module does not specify/declare the interrupt handlers //! on GPIO pins. Please note that this module does not specify/declare the interrupt handlers
//! which must be provided for async support to work. However, it provides one generic //! which must be provided for async support to work. However, it provides one generic
//! [handler][handle_interrupt_for_async_gpio] which should be called in ALL user interrupt handlers //! [handler][on_interrupt_for_asynch_gpio] which should be called in ALL user interrupt handlers
//! which handle GPIO interrupts. //! which handle GPIO interrupts.
//! //!
//! # Example //! # Example
@@ -90,7 +90,7 @@ pub struct InputPinFuture {
impl InputPinFuture { impl InputPinFuture {
/// # Safety /// # Safety
/// ///
/// This calls [Self::new] but uses [pac::Peripherals::steal] to get the system configuration /// This calls [Self::new_with_dyn_pin] but uses [pac::Peripherals::steal] to get the system configuration
/// and IRQ selection peripherals. Users must ensure that the registers and configuration /// and IRQ selection peripherals. Users must ensure that the registers and configuration
/// related to this input pin are not being used elsewhere concurrently. /// related to this input pin are not being used elsewhere concurrently.
pub unsafe fn new_unchecked_with_dyn_pin( pub unsafe fn new_unchecked_with_dyn_pin(
@@ -127,7 +127,7 @@ impl InputPinFuture {
/// # Safety /// # Safety
/// ///
/// This calls [Self::new] but uses [pac::Peripherals::steal] to get the system configuration /// This calls [Self::new_with_pin] but uses [pac::Peripherals::steal] to get the system configuration
/// and IRQ selection peripherals. Users must ensure that the registers and configuration /// and IRQ selection peripherals. Users must ensure that the registers and configuration
/// related to this input pin are not being used elsewhere concurrently. /// related to this input pin are not being used elsewhere concurrently.
pub unsafe fn new_unchecked_with_pin<I: PinId, C: InputConfig>( pub unsafe fn new_unchecked_with_pin<I: PinId, C: InputConfig>(
@@ -200,7 +200,7 @@ impl InputDynPinAsync {
/// passed as well and is used to route and enable the interrupt. /// passed as well and is used to route and enable the interrupt.
/// ///
/// Please note that the interrupt handler itself must be provided by the user and the /// Please note that the interrupt handler itself must be provided by the user and the
/// generic [handle_interrupt_for_async_gpio] function must be called inside that function for /// generic [on_interrupt_for_asynch_gpio] function must be called inside that function for
/// the asynchronous functionality to work. /// the asynchronous functionality to work.
pub fn new(pin: DynPin, irq: pac::Interrupt) -> Result<Self, InvalidPinTypeError> { pub fn new(pin: DynPin, irq: pac::Interrupt) -> Result<Self, InvalidPinTypeError> {
if !pin.is_input_pin() { if !pin.is_input_pin() {
@@ -335,7 +335,7 @@ impl<I: PinId, C: InputConfig> InputPinAsync<I, C> {
/// passed as well and is used to route and enable the interrupt. /// passed as well and is used to route and enable the interrupt.
/// ///
/// Please note that the interrupt handler itself must be provided by the user and the /// Please note that the interrupt handler itself must be provided by the user and the
/// generic [handle_interrupt_for_async_gpio] function must be called inside that function for /// generic [on_interrupt_for_asynch_gpio] function must be called inside that function for
/// the asynchronous functionality to work. /// the asynchronous functionality to work.
pub fn new(pin: Pin<I, pin::Input<C>>, irq: pac::Interrupt) -> Self { pub fn new(pin: Pin<I, pin::Input<C>>, irq: pac::Interrupt) -> Self {
Self { pin, irq } Self { pin, irq }

View File

@@ -69,6 +69,7 @@ use crate::{clock::FilterClkSel, enable_nvic_interrupt, pac, FunSel, InterruptCo
/// Value-level `enum` for disabled configurations /// Value-level `enum` for disabled configurations
#[derive(PartialEq, Eq, Clone, Copy)] #[derive(PartialEq, Eq, Clone, Copy)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum DynDisabled { pub enum DynDisabled {
Floating, Floating,
PullDown, PullDown,
@@ -156,14 +157,16 @@ pub const DYN_ALT_FUNC_3: DynPinMode = DynPinMode::Alternate(DynAlternate::Sel3)
//================================================================================================== //==================================================================================================
/// Value-level `enum` for pin groups /// Value-level `enum` for pin groups
#[derive(PartialEq, Eq, Clone, Copy)] #[derive(Debug, PartialEq, Eq, Clone, Copy)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum DynGroup { pub enum DynGroup {
A, A,
B, B,
} }
/// Value-level `struct` representing pin IDs /// Value-level `struct` representing pin IDs
#[derive(PartialEq, Eq, Clone, Copy)] #[derive(Debug, PartialEq, Eq, Clone, Copy)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct DynPinId { pub struct DynPinId {
pub group: DynGroup, pub group: DynGroup,
pub num: u8, pub num: u8,
@@ -177,6 +180,7 @@ pub struct DynPinId {
/// ///
/// This `struct` takes ownership of a [`DynPinId`] and provides an API to /// This `struct` takes ownership of a [`DynPinId`] and provides an API to
/// access the corresponding regsiters. /// access the corresponding regsiters.
#[derive(Debug)]
pub(crate) struct DynRegisters(DynPinId); pub(crate) struct DynRegisters(DynPinId);
// [`DynRegisters`] takes ownership of the [`DynPinId`], and [`DynPin`] // [`DynRegisters`] takes ownership of the [`DynPinId`], and [`DynPin`]
@@ -209,6 +213,7 @@ impl DynRegisters {
/// ///
/// This type acts as a type-erased version of [`Pin`]. Every pin is represented /// This type acts as a type-erased version of [`Pin`]. Every pin is represented
/// by the same type, and pins are tracked and distinguished at run-time. /// by the same type, and pins are tracked and distinguished at run-time.
#[derive(Debug)]
pub struct DynPin { pub struct DynPin {
pub(crate) regs: DynRegisters, pub(crate) regs: DynRegisters,
mode: DynPinMode, mode: DynPinMode,

View File

@@ -119,8 +119,11 @@ pub trait InputConfig: Sealed {
const DYN: DynInput; const DYN: DynInput;
} }
#[derive(Debug)]
pub enum Floating {} pub enum Floating {}
#[derive(Debug)]
pub enum PullDown {} pub enum PullDown {}
#[derive(Debug)]
pub enum PullUp {} pub enum PullUp {}
impl InputConfig for Floating { impl InputConfig for Floating {
@@ -148,6 +151,7 @@ pub type InputPullUp = Input<PullUp>;
/// ///
/// Type `C` is one of three input configurations: [`Floating`], [`PullDown`] or /// Type `C` is one of three input configurations: [`Floating`], [`PullDown`] or
/// [`PullUp`] /// [`PullUp`]
#[derive(Debug)]
pub struct Input<C: InputConfig> { pub struct Input<C: InputConfig> {
cfg: PhantomData<C>, cfg: PhantomData<C>,
} }
@@ -177,13 +181,17 @@ pub trait OutputConfig: Sealed {
pub trait ReadableOutput: Sealed {} pub trait ReadableOutput: Sealed {}
/// Type-level variant of [`OutputConfig`] for a push-pull configuration /// Type-level variant of [`OutputConfig`] for a push-pull configuration
#[derive(Debug)]
pub enum PushPull {} pub enum PushPull {}
/// Type-level variant of [`OutputConfig`] for an open drain configuration /// Type-level variant of [`OutputConfig`] for an open drain configuration
#[derive(Debug)]
pub enum OpenDrain {} pub enum OpenDrain {}
/// Type-level variant of [`OutputConfig`] for a readable push-pull configuration /// Type-level variant of [`OutputConfig`] for a readable push-pull configuration
#[derive(Debug)]
pub enum ReadablePushPull {} pub enum ReadablePushPull {}
/// Type-level variant of [`OutputConfig`] for a readable open-drain configuration /// Type-level variant of [`OutputConfig`] for a readable open-drain configuration
#[derive(Debug)]
pub enum ReadableOpenDrain {} pub enum ReadableOpenDrain {}
impl Sealed for PushPull {} impl Sealed for PushPull {}
@@ -210,6 +218,7 @@ impl OutputConfig for ReadableOpenDrain {
/// ///
/// Type `C` is one of four output configurations: [`PushPull`], [`OpenDrain`] or /// Type `C` is one of four output configurations: [`PushPull`], [`OpenDrain`] or
/// their respective readable versions /// their respective readable versions
#[derive(Debug)]
pub struct Output<C: OutputConfig> { pub struct Output<C: OutputConfig> {
cfg: PhantomData<C>, cfg: PhantomData<C>,
} }
@@ -304,6 +313,7 @@ macro_rules! pin_id {
// Need paste macro to use ident in doc attribute // Need paste macro to use ident in doc attribute
paste! { paste! {
#[doc = "Pin ID representing pin " $Id] #[doc = "Pin ID representing pin " $Id]
#[derive(Debug)]
pub enum $Id {} pub enum $Id {}
impl Sealed for $Id {} impl Sealed for $Id {}
impl PinId for $Id { impl PinId for $Id {
@@ -321,6 +331,7 @@ macro_rules! pin_id {
//================================================================================================== //==================================================================================================
/// A type-level GPIO pin, parameterized by [PinId] and [PinMode] types /// A type-level GPIO pin, parameterized by [PinId] and [PinMode] types
#[derive(Debug)]
pub struct Pin<I: PinId, M: PinMode> { pub struct Pin<I: PinId, M: PinMode> {
inner: DynPin, inner: DynPin,
phantom: PhantomData<(I, M)>, phantom: PhantomData<(I, M)>,
@@ -741,6 +752,7 @@ macro_rules! pins {
) => { ) => {
paste!( paste!(
/// Collection of all the individual [`Pin`]s for a given port (PORTA or PORTB) /// Collection of all the individual [`Pin`]s for a given port (PORTA or PORTB)
#[derive(Debug)]
pub struct $PinsName { pub struct $PinsName {
port: $Port, port: $Port,
$( $(

View File

@@ -18,6 +18,7 @@ const CLK_400K: Hertz = Hertz::from_raw(400_000);
const MIN_CLK_400K: Hertz = Hertz::from_raw(8_000_000); const MIN_CLK_400K: Hertz = Hertz::from_raw(8_000_000);
#[derive(Debug, PartialEq, Eq, Copy, Clone)] #[derive(Debug, PartialEq, Eq, Copy, Clone)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum FifoEmptyMode { pub enum FifoEmptyMode {
Stall = 0, Stall = 0,
EndTransaction = 1, EndTransaction = 1,
@@ -89,18 +90,21 @@ enum I2cCmd {
} }
#[derive(Debug, PartialEq, Eq, Copy, Clone)] #[derive(Debug, PartialEq, Eq, Copy, Clone)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum I2cSpeed { pub enum I2cSpeed {
Regular100khz = 0, Regular100khz = 0,
Fast400khz = 1, Fast400khz = 1,
} }
#[derive(Debug, PartialEq, Eq)] #[derive(Debug, PartialEq, Eq)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum I2cDirection { pub enum I2cDirection {
Send = 0, Send = 0,
Read = 1, Read = 1,
} }
#[derive(Debug, PartialEq, Eq, Copy, Clone)] #[derive(Debug, PartialEq, Eq, Copy, Clone)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum I2cAddress { pub enum I2cAddress {
Regular(u8), Regular(u8),
TenBit(u16), TenBit(u16),
@@ -141,9 +145,12 @@ impl Instance for pac::I2cb {
// Config // Config
//================================================================================================== //==================================================================================================
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct TrTfThighTlow(u8, u8, u8, u8); pub struct TrTfThighTlow(u8, u8, u8, u8);
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct TsuStoTsuStaThdStaTBuf(u8, u8, u8, u8); pub struct TsuStoTsuStaThdStaTBuf(u8, u8, u8, u8);
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct TimingCfg { pub struct TimingCfg {
// 4 bit max width // 4 bit max width
tr: u8, tr: u8,
@@ -218,6 +225,7 @@ impl Default for TimingCfg {
} }
} }
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct MasterConfig { pub struct MasterConfig {
pub tx_fe_mode: FifoEmptyMode, pub tx_fe_mode: FifoEmptyMode,
pub rx_fe_mode: FifoEmptyMode, pub rx_fe_mode: FifoEmptyMode,

View File

@@ -51,8 +51,8 @@ pub enum PeripheralSelect {
/// Generic interrupt config which can be used to specify whether the HAL driver will /// Generic interrupt config which can be used to specify whether the HAL driver will
/// use the IRQSEL register to route an interrupt, and whether the IRQ will be unmasked in the /// use the IRQSEL register to route an interrupt, and whether the IRQ will be unmasked in the
/// Cortex-M0 NVIC. Both are generally necessary for IRQs to work, but the user might perform /// Cortex-M0 NVIC. Both are generally necessary for IRQs to work, but the user might want to
/// this steps themselves /// perform those steps themselves.
#[derive(Debug, PartialEq, Eq, Clone, Copy)] #[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub struct InterruptConfig { pub struct InterruptConfig {
/// Interrupt target vector. Should always be set, might be required for disabling IRQs /// Interrupt target vector. Should always be set, might be required for disabling IRQs
@@ -77,6 +77,7 @@ impl InterruptConfig {
pub type IrqCfg = InterruptConfig; pub type IrqCfg = InterruptConfig;
#[derive(Debug, PartialEq, Eq)] #[derive(Debug, PartialEq, Eq)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct InvalidPin(pub(crate) ()); pub struct InvalidPin(pub(crate) ());
/// Can be used to manually manipulate the function select of port pins /// Can be used to manually manipulate the function select of port pins

View File

@@ -15,7 +15,9 @@ use crate::{clock::enable_peripheral_clock, gpio::DynPinId};
const DUTY_MAX: u16 = u16::MAX; const DUTY_MAX: u16 = u16::MAX;
pub struct PwmCommon { #[derive(Debug)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub(crate) struct PwmCommon {
sys_clk: Hertz, sys_clk: Hertz,
/// For PWMB, this is the upper limit /// For PWMB, this is the upper limit
current_duty: u16, current_duty: u16,

View File

@@ -37,6 +37,7 @@ pub const BMSTART_BMSTOP_MASK: u32 = 1 << 31;
pub const DEFAULT_CLK_DIV: u16 = 2; pub const DEFAULT_CLK_DIV: u16 = 2;
#[derive(Debug, PartialEq, Eq, Copy, Clone)] #[derive(Debug, PartialEq, Eq, Copy, Clone)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum HwChipSelectId { pub enum HwChipSelectId {
Id0 = 0, Id0 = 0,
Id1 = 1, Id1 = 1,
@@ -50,6 +51,7 @@ pub enum HwChipSelectId {
} }
#[derive(Debug)] #[derive(Debug)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum SpiPort { pub enum SpiPort {
Porta = 0, Porta = 0,
Portb = 1, Portb = 1,
@@ -58,6 +60,7 @@ pub enum SpiPort {
} }
#[derive(Debug, PartialEq, Eq, Copy, Clone)] #[derive(Debug, PartialEq, Eq, Copy, Clone)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum WordSize { pub enum WordSize {
OneBit = 0x00, OneBit = 0x00,
FourBits = 0x03, FourBits = 0x03,

View File

@@ -79,6 +79,7 @@ pub enum Event {
} }
#[derive(Default, Debug, PartialEq, Eq, Copy, Clone)] #[derive(Default, Debug, PartialEq, Eq, Copy, Clone)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct CascadeCtrl { pub struct CascadeCtrl {
/// Enable Cascade 0 signal active as a requirement for counting /// Enable Cascade 0 signal active as a requirement for counting
pub enb_start_src_csd0: bool, pub enb_start_src_csd0: bool,
@@ -108,6 +109,7 @@ pub struct CascadeCtrl {
} }
#[derive(Debug, PartialEq, Eq)] #[derive(Debug, PartialEq, Eq)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum CascadeSel { pub enum CascadeSel {
Csd0 = 0, Csd0 = 0,
Csd1 = 1, Csd1 = 1,

View File

@@ -23,6 +23,7 @@ use crate::{
use embedded_hal_nb::serial::Read; use embedded_hal_nb::serial::Read;
#[derive(Debug)] #[derive(Debug)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Bank { pub enum Bank {
A = 0, A = 0,
B = 1, B = 1,
@@ -237,6 +238,7 @@ impl From<Hertz> for Config {
//================================================================================================== //==================================================================================================
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct IrqContextTimeoutOrMaxSize { pub struct IrqContextTimeoutOrMaxSize {
rx_idx: usize, rx_idx: usize,
mode: IrqReceptionMode, mode: IrqReceptionMode,
@@ -262,6 +264,7 @@ impl IrqContextTimeoutOrMaxSize {
/// This struct is used to return the default IRQ handler result to the user /// This struct is used to return the default IRQ handler result to the user
#[derive(Debug, Default)] #[derive(Debug, Default)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct IrqResult { pub struct IrqResult {
pub bytes_read: usize, pub bytes_read: usize,
pub errors: Option<UartErrors>, pub errors: Option<UartErrors>,
@@ -269,6 +272,7 @@ pub struct IrqResult {
/// This struct is used to return the default IRQ handler result to the user /// This struct is used to return the default IRQ handler result to the user
#[derive(Debug, Default)] #[derive(Debug, Default)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct IrqResultMaxSizeOrTimeout { pub struct IrqResultMaxSizeOrTimeout {
complete: bool, complete: bool,
timeout: bool, timeout: bool,
@@ -319,6 +323,7 @@ impl IrqResultMaxSizeOrTimeout {
} }
#[derive(Debug, PartialEq, Copy, Clone)] #[derive(Debug, PartialEq, Copy, Clone)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
enum IrqReceptionMode { enum IrqReceptionMode {
Idle, Idle,
Pending, Pending,
@@ -407,7 +412,7 @@ impl Instance for pac::Uarta {
} }
#[inline(always)] #[inline(always)]
fn ptr() -> *const uart_base::RegisterBlock { fn ptr() -> *const uart_base::RegisterBlock {
pac::Uarta::ptr() as *const _ Self::ptr() as *const _
} }
} }
@@ -422,7 +427,7 @@ impl Instance for pac::Uartb {
} }
#[inline(always)] #[inline(always)]
fn ptr() -> *const uart_base::RegisterBlock { fn ptr() -> *const uart_base::RegisterBlock {
pac::Uartb::ptr() as *const _ Self::ptr() as *const _
} }
} }
@@ -1108,10 +1113,10 @@ impl<Uart: Instance> embedded_io::Write for Tx<Uart> {
/// ///
/// 1. The first way simply empties the FIFO on an interrupt into a user provided buffer. You /// 1. The first way simply empties the FIFO on an interrupt into a user provided buffer. You
/// can simply use [Self::start] to prepare the peripheral and then call the /// can simply use [Self::start] to prepare the peripheral and then call the
/// [Self::irq_handler] in the interrupt service routine. /// [Self::on_interrupt] in the interrupt service routine.
/// 2. The second way reads packets bounded by a maximum size or a baudtick based timeout. You /// 2. The second way reads packets bounded by a maximum size or a baudtick based timeout. You
/// can use [Self::read_fixed_len_or_timeout_based_using_irq] to prepare the peripheral and /// can use [Self::read_fixed_len_or_timeout_based_using_irq] to prepare the peripheral and
/// then call the [Self::irq_handler_max_size_or_timeout_based] in the interrupt service /// then call the [Self::on_interrupt_max_size_or_timeout_based] in the interrupt service
/// routine. You have to call [Self::read_fixed_len_or_timeout_based_using_irq] in the ISR to /// routine. You have to call [Self::read_fixed_len_or_timeout_based_using_irq] in the ISR to
/// start reading the next packet. /// start reading the next packet.
pub struct RxWithInterrupt<Uart>(Rx<Uart>); pub struct RxWithInterrupt<Uart>(Rx<Uart>);
@@ -1122,7 +1127,7 @@ impl<Uart: Instance> RxWithInterrupt<Uart> {
} }
/// This function should be called once at initialization time if the regular /// This function should be called once at initialization time if the regular
/// [Self::irq_handler] is used to read the UART receiver to enable and start the receiver. /// [Self::on_interrupt] is used to read the UART receiver to enable and start the receiver.
pub fn start(&mut self) { pub fn start(&mut self) {
self.0.enable(); self.0.enable();
self.enable_rx_irq_sources(true); self.enable_rx_irq_sources(true);
@@ -1133,13 +1138,13 @@ impl<Uart: Instance> RxWithInterrupt<Uart> {
&self.0.uart &self.0.uart
} }
/// This function is used together with the [Self::irq_handler_max_size_or_timeout_based] /// This function is used together with the [Self::on_interrupt_max_size_or_timeout_based]
/// function to read packets with a maximum size or variable sized packets by using the /// function to read packets with a maximum size or variable sized packets by using the
/// receive timeout of the hardware. /// receive timeout of the hardware.
/// ///
/// This function should be called once at initialization to initiate the context state /// This function should be called once at initialization to initiate the context state
/// and to [Self::start] the receiver. After that, it should be called after each /// and to [Self::start] the receiver. After that, it should be called after each
/// completed [Self::irq_handler_max_size_or_timeout_based] call to restart the reception /// completed [Self::on_interrupt_max_size_or_timeout_based] call to restart the reception
/// of a packet. /// of a packet.
pub fn read_fixed_len_or_timeout_based_using_irq( pub fn read_fixed_len_or_timeout_based_using_irq(
&mut self, &mut self,

View File

@@ -286,7 +286,7 @@ impl Drop for ActiveReadGuard {
} }
} }
/// Core data structure to allow asynchrnous UART reception. /// Core data structure to allow asynchronous UART reception.
/// ///
/// If the ring buffer becomes full, data will be lost. /// If the ring buffer becomes full, data will be lost.
pub struct RxAsync<Uart: Instance, const N: usize> { pub struct RxAsync<Uart: Instance, const N: usize> {
@@ -295,7 +295,7 @@ pub struct RxAsync<Uart: Instance, const N: usize> {
} }
impl<Uart: Instance, const N: usize> ErrorType for RxAsync<Uart, N> { impl<Uart: Instance, const N: usize> ErrorType for RxAsync<Uart, N> {
/// Error reporting is done using atomic booleans and the [get_and_clear_errors] function. /// Error reporting is done using the result of the interrupt functions.
type Error = Infallible; type Error = Infallible;
} }
@@ -345,7 +345,7 @@ impl<Uart: Instance, const N: usize> embedded_io_async::Read for RxAsync<Uart, N
} }
} }
/// Core data structure to allow asynchrnous UART reception. /// Core data structure to allow asynchronous UART reception.
/// ///
/// If the ring buffer becomes full, the oldest data will be overwritten when using the /// If the ring buffer becomes full, the oldest data will be overwritten when using the
/// [on_interrupt_uart_a_overwriting] and [on_interrupt_uart_b_overwriting] interrupt handlers. /// [on_interrupt_uart_a_overwriting] and [on_interrupt_uart_b_overwriting] interrupt handlers.
@@ -355,7 +355,7 @@ pub struct RxAsyncSharedConsumer<Uart: Instance, const N: usize> {
} }
impl<Uart: Instance, const N: usize> ErrorType for RxAsyncSharedConsumer<Uart, N> { impl<Uart: Instance, const N: usize> ErrorType for RxAsyncSharedConsumer<Uart, N> {
/// Error reporting is done using atomic booleans and the [get_and_clear_errors] function. /// Error reporting is done using the result of the interrupt functions.
type Error = Infallible; type Error = Infallible;
} }

View File

@@ -8,6 +8,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## [unreleased] ## [unreleased]
## [v0.7.0] 2025-02-13
- Bumped `va108xx-hal` dependency to 0.9
- Minor adjustments to `Button` API.
- `Button`, `Led` and `Leds` now simply wrap a type using a tuple struct.
## [v0.6.0] 2024-09-30 ## [v0.6.0] 2024-09-30
- Added M95M01 EEPROM module/API - Added M95M01 EEPROM module/API

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "vorago-reb1" name = "vorago-reb1"
version = "0.6.0" version = "0.7.0"
authors = ["Robin Mueller <muellerr@irs.uni-stuttgart.de>"] authors = ["Robin Mueller <muellerr@irs.uni-stuttgart.de>"]
edition = "2021" edition = "2021"
description = "Board Support Crate for the Vorago REB1 development board" description = "Board Support Crate for the Vorago REB1 development board"
@@ -19,7 +19,6 @@ bitfield = ">=0.17, <=0.18"
max116xx-10bit = "0.3" max116xx-10bit = "0.3"
[dependencies.va108xx-hal] [dependencies.va108xx-hal]
path = "../va108xx-hal"
version = "0.9" version = "0.9"
features = ["rt"] features = ["rt"]

View File

@@ -10,23 +10,22 @@ use va108xx_hal::{
pac, InterruptConfig, pac, InterruptConfig,
}; };
pub struct Button { #[derive(Debug)]
button: Pin<PA11, InputFloating>, pub struct Button(pub Pin<PA11, InputFloating>);
}
impl Button { impl Button {
pub fn new(pin: Pin<PA11, InputFloating>) -> Button { pub fn new(pin: Pin<PA11, InputFloating>) -> Button {
Button { button: pin } Button(pin)
} }
#[inline] #[inline]
pub fn pressed(&mut self) -> bool { pub fn pressed(&mut self) -> bool {
self.button.is_low().ok().unwrap() self.0.is_low().ok().unwrap()
} }
#[inline] #[inline]
pub fn released(&mut self) -> bool { pub fn released(&mut self) -> bool {
self.button.is_high().ok().unwrap() self.0.is_high().ok().unwrap()
} }
/// Configures an IRQ on edge. /// Configures an IRQ on edge.
@@ -37,7 +36,7 @@ impl Button {
syscfg: Option<&mut pac::Sysconfig>, syscfg: Option<&mut pac::Sysconfig>,
irqsel: Option<&mut pac::Irqsel>, irqsel: Option<&mut pac::Irqsel>,
) { ) {
self.button self.0
.configure_edge_interrupt(edge_type, irq_cfg, syscfg, irqsel); .configure_edge_interrupt(edge_type, irq_cfg, syscfg, irqsel);
} }
@@ -49,7 +48,7 @@ impl Button {
syscfg: Option<&mut pac::Sysconfig>, syscfg: Option<&mut pac::Sysconfig>,
irqsel: Option<&mut pac::Irqsel>, irqsel: Option<&mut pac::Irqsel>,
) { ) {
self.button self.0
.configure_level_interrupt(level, irq_cfg, syscfg, irqsel); .configure_level_interrupt(level, irq_cfg, syscfg, irqsel);
} }
@@ -58,6 +57,6 @@ impl Button {
/// Please note that you still have to set a clock divisor yourself using the /// Please note that you still have to set a clock divisor yourself using the
/// [`va108xx_hal::clock::set_clk_div_register`] function in order for this to work. /// [`va108xx_hal::clock::set_clk_div_register`] function in order for this to work.
pub fn configure_filter_type(&mut self, filter: FilterType, clksel: FilterClkSel) { pub fn configure_filter_type(&mut self, filter: FilterType, clksel: FilterClkSel) {
self.button.configure_filter_type(filter, clksel); self.0.configure_filter_type(filter, clksel);
} }
} }

View File

@@ -15,15 +15,12 @@ pub type LD2 = Pin<PA10, PushPullOutput>;
pub type LD3 = Pin<PA7, PushPullOutput>; pub type LD3 = Pin<PA7, PushPullOutput>;
pub type LD4 = Pin<PA6, PushPullOutput>; pub type LD4 = Pin<PA6, PushPullOutput>;
pub struct Leds { #[derive(Debug)]
leds: [Led; 3], pub struct Leds(pub [Led; 3]);
}
impl Leds { impl Leds {
pub fn new(led_pin1: LD2, led_pin2: LD3, led_pin3: LD4) -> Leds { pub fn new(led_pin1: LD2, led_pin2: LD3, led_pin3: LD4) -> Leds {
Leds { Leds([led_pin1.into(), led_pin2.into(), led_pin3.into()])
leds: [led_pin1.into(), led_pin2.into(), led_pin3.into()],
}
} }
} }
@@ -31,13 +28,13 @@ impl core::ops::Deref for Leds {
type Target = [Led]; type Target = [Led];
fn deref(&self) -> &[Led] { fn deref(&self) -> &[Led] {
&self.leds &self.0
} }
} }
impl core::ops::DerefMut for Leds { impl core::ops::DerefMut for Leds {
fn deref_mut(&mut self) -> &mut [Led] { fn deref_mut(&mut self) -> &mut [Led] {
&mut self.leds &mut self.0
} }
} }
@@ -45,28 +42,25 @@ impl core::ops::Index<usize> for Leds {
type Output = Led; type Output = Led;
fn index(&self, i: usize) -> &Led { fn index(&self, i: usize) -> &Led {
&self.leds[i] &self.0[i]
} }
} }
impl core::ops::IndexMut<usize> for Leds { impl core::ops::IndexMut<usize> for Leds {
fn index_mut(&mut self, i: usize) -> &mut Led { fn index_mut(&mut self, i: usize) -> &mut Led {
&mut self.leds[i] &mut self.0[i]
} }
} }
pub struct Led { #[derive(Debug)]
pin: DynPin, pub struct Led(pub DynPin);
}
macro_rules! ctor { macro_rules! ctor {
($($ldx:ident),+) => { ($($ldx:ident),+) => {
$( $(
impl From<$ldx> for Led { impl From<$ldx> for Led {
fn from(led: $ldx) -> Self { fn from(led: $ldx) -> Self {
Led { Led(led.into())
pin: led.into()
}
} }
} }
)+ )+
@@ -79,18 +73,18 @@ impl Led {
/// Turns the LED off. Setting the pin high actually turns the LED off /// Turns the LED off. Setting the pin high actually turns the LED off
#[inline] #[inline]
pub fn off(&mut self) { pub fn off(&mut self) {
self.pin.set_high().ok(); self.0.set_high().ok();
} }
/// Turns the LED on. Setting the pin low actually turns the LED on /// Turns the LED on. Setting the pin low actually turns the LED on
#[inline] #[inline]
pub fn on(&mut self) { pub fn on(&mut self) {
self.pin.set_low().ok(); self.0.set_low().ok();
} }
/// Toggles the LED /// Toggles the LED
#[inline] #[inline]
pub fn toggle(&mut self) { pub fn toggle(&mut self) {
self.pin.toggle_with_toggle_reg().ok(); self.0.toggle_with_toggle_reg().ok();
} }
} }