Skip to content

Commit 41efcc3

Browse files
Merge pull request #40 from riscv-rust/svd2rust-v0.36.1
Regenerate with svd2rust v0.36.1
2 parents 295cc97 + ae2da61 commit 41efcc3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+283
-1308
lines changed

e310x/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10+
### Changed
11+
12+
- Regenerate code with `svd2rust` 0.36.1
13+
- Use `riscv` v0.13.0 and `riscv-rt` v0.14.0
14+
- In vectored mode, align `mtvec` to 64 bytes
15+
1016
## [v0.12.0] - 2024-12-10
1117

1218
### Changed

e310x/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ edition = "2021"
1212

1313
[dependencies]
1414
critical-section = { version = "1.2.0", optional = true }
15-
riscv = "0.12.0"
15+
riscv = "0.13.0"
1616
riscv-peripheral = "0.2.0"
17-
riscv-rt = { version = "0.13.0", features = ["no-interrupts"], optional = true }
17+
riscv-rt = { version = "0.14.0", features = ["no-interrupts"], optional = true }
1818
vcell = "0.1.3"
1919

2020
[features]

e310x/build.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ fn main() {
1212
.unwrap();
1313
println!("cargo:rustc-link-search={}", out.display());
1414
println!("cargo:rerun-if-changed=device.x");
15+
println!("cargo:rustc-env=RISCV_MTVEC_ALIGN={}", 64usize);
16+
println!("cargo:rerun-if-env-changed=RISCV_MTVEC_ALIGN");
1517
}
1618
println!("cargo:rerun-if-changed=build.rs");
1719
}

e310x/settings.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,5 @@ riscv_config:
5050
name: "PLIC"
5151
core_interrupt: "MachineExternal"
5252
hart_id: "H0"
53+
54+
mtvec_align: 64

e310x/src/aonclk.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ impl RegisterBlock {
1111
&self.lfrosccfg
1212
}
1313
}
14-
#[doc = "lfrosccfg (rw) register accessor: AON Clock Configuration Register\n\nYou can [`read`](crate::Reg::read) this register and get [`lfrosccfg::R`]. You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`lfrosccfg::W`]. You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [`mod@lfrosccfg`]
15-
module"]
14+
#[doc = "lfrosccfg (rw) register accessor: AON Clock Configuration Register\n\nYou can [`read`](crate::Reg::read) this register and get [`lfrosccfg::R`]. You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`lfrosccfg::W`]. You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [`mod@lfrosccfg`] module"]
1615
#[doc(alias = "lfrosccfg")]
1716
pub type Lfrosccfg = crate::Reg<lfrosccfg::LfrosccfgSpec>;
1817
#[doc = "AON Clock Configuration Register"]

e310x/src/aonclk/lfrosccfg.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,6 @@ impl crate::Readable for LfrosccfgSpec {}
7272
#[doc = "`write(|w| ..)` method takes [`lfrosccfg::W`](W) writer structure"]
7373
impl crate::Writable for LfrosccfgSpec {
7474
type Safety = crate::Unsafe;
75-
const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
76-
const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
7775
}
7876
#[doc = "`reset()` method sets lfrosccfg to value 0"]
79-
impl crate::Resettable for LfrosccfgSpec {
80-
const RESET_VALUE: u32 = 0;
81-
}
77+
impl crate::Resettable for LfrosccfgSpec {}

e310x/src/backup.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ impl RegisterBlock {
1717
self.backup.iter()
1818
}
1919
}
20-
#[doc = "backup (rw) register accessor: Backup Register\n\nYou can [`read`](crate::Reg::read) this register and get [`backup::R`]. You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`backup::W`]. You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [`mod@backup`]
21-
module"]
20+
#[doc = "backup (rw) register accessor: Backup Register\n\nYou can [`read`](crate::Reg::read) this register and get [`backup::R`]. You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`backup::W`]. You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [`mod@backup`] module"]
2221
#[doc(alias = "backup")]
2322
pub type Backup = crate::Reg<backup::BackupSpec>;
2423
#[doc = "Backup Register"]

e310x/src/backup/backup.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ impl crate::Readable for BackupSpec {}
1818
#[doc = "`write(|w| ..)` method takes [`backup::W`](W) writer structure"]
1919
impl crate::Writable for BackupSpec {
2020
type Safety = crate::Unsafe;
21-
const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
22-
const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
23-
}
24-
#[doc = "`reset()` method sets backup[%s]
25-
to value 0"]
26-
impl crate::Resettable for BackupSpec {
27-
const RESET_VALUE: u32 = 0;
2821
}
22+
#[doc = "`reset()` method sets backup[%s] to value 0"]
23+
impl crate::Resettable for BackupSpec {}

e310x/src/generic.rs

Lines changed: 68 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,54 @@
11
use core::marker;
22

3+
/// Generic peripheral accessor
4+
pub struct Periph<RB, const A: usize> {
5+
_marker: marker::PhantomData<RB>,
6+
}
7+
8+
unsafe impl<RB, const A: usize> Send for Periph<RB, A> {}
9+
10+
impl<RB, const A: usize> Periph<RB, A> {
11+
///Pointer to the register block
12+
pub const PTR: *const RB = A as *const _;
13+
14+
///Return the pointer to the register block
15+
#[inline(always)]
16+
pub const fn ptr() -> *const RB {
17+
Self::PTR
18+
}
19+
20+
/// Steal an instance of this peripheral
21+
///
22+
/// # Safety
23+
///
24+
/// Ensure that the new instance of the peripheral cannot be used in a way
25+
/// that may race with any existing instances, for example by only
26+
/// accessing read-only or write-only registers, or by consuming the
27+
/// original peripheral and using critical sections to coordinate
28+
/// access between multiple new instances.
29+
///
30+
/// Additionally, other software such as HALs may rely on only one
31+
/// peripheral instance existing to ensure memory safety; ensure
32+
/// no stolen instances are passed to such software.
33+
pub unsafe fn steal() -> Self {
34+
Self {
35+
_marker: marker::PhantomData,
36+
}
37+
}
38+
}
39+
40+
impl<RB, const A: usize> core::ops::Deref for Periph<RB, A> {
41+
type Target = RB;
42+
43+
#[inline(always)]
44+
fn deref(&self) -> &Self::Target {
45+
unsafe { &*Self::PTR }
46+
}
47+
}
48+
349
/// Raw register type (`u8`, `u16`, `u32`, ...)
450
pub trait RawReg:
551
Copy
6-
+ Default
752
+ From<bool>
853
+ core::ops::BitOr<Output = Self>
954
+ core::ops::BitAnd<Output = Self>
@@ -14,8 +59,10 @@ pub trait RawReg:
1459
{
1560
/// Mask for bits of width `WI`
1661
fn mask<const WI: u8>() -> Self;
17-
/// Mask for bits of width 1
18-
fn one() -> Self;
62+
/// `0`
63+
const ZERO: Self;
64+
/// `1`
65+
const ONE: Self;
1966
}
2067

2168
macro_rules! raw_reg {
@@ -25,10 +72,8 @@ macro_rules! raw_reg {
2572
fn mask<const WI: u8>() -> Self {
2673
$mask::<WI>()
2774
}
28-
#[inline(always)]
29-
fn one() -> Self {
30-
1
31-
}
75+
const ZERO: Self = 0;
76+
const ONE: Self = 1;
3277
}
3378
const fn $mask<const WI: u8>() -> $U {
3479
<$U>::MAX >> ($size - WI)
@@ -74,10 +119,10 @@ pub trait Writable: RegisterSpec {
74119
type Safety;
75120

76121
/// Specifies the register bits that are not changed if you pass `1` and are changed if you pass `0`
77-
const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux;
122+
const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = Self::Ux::ZERO;
78123

79124
/// Specifies the register bits that are not changed if you pass `0` and are changed if you pass `1`
80-
const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux;
125+
const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = Self::Ux::ZERO;
81126
}
82127

83128
/// Reset value of the register.
@@ -86,7 +131,7 @@ pub trait Writable: RegisterSpec {
86131
/// register by using the `reset` method.
87132
pub trait Resettable: RegisterSpec {
88133
/// Reset value of the register.
89-
const RESET_VALUE: Self::Ux;
134+
const RESET_VALUE: Self::Ux = Self::Ux::ZERO;
90135

91136
/// Reset value of the register.
92137
#[inline(always)]
@@ -341,7 +386,7 @@ pub struct RangeTo<const MAX: u64>;
341386
pub type FieldWriter<'a, REG, const WI: u8, FI = u8, Safety = Unsafe> =
342387
raw::FieldWriter<'a, REG, WI, FI, Safety>;
343388

344-
impl<'a, REG, const WI: u8, FI, Safety> FieldWriter<'a, REG, WI, FI, Safety>
389+
impl<REG, const WI: u8, FI, Safety> FieldWriter<'_, REG, WI, FI, Safety>
345390
where
346391
REG: Writable + RegisterSpec,
347392
FI: FieldSpec,
@@ -493,8 +538,8 @@ macro_rules! bit_proxy {
493538
/// Writes bit to the field
494539
#[inline(always)]
495540
pub fn bit(self, value: bool) -> &'a mut W<REG> {
496-
self.w.bits &= !(REG::Ux::one() << self.o);
497-
self.w.bits |= (REG::Ux::from(value) & REG::Ux::one()) << self.o;
541+
self.w.bits &= !(REG::Ux::ONE << self.o);
542+
self.w.bits |= (REG::Ux::from(value) & REG::Ux::ONE) << self.o;
498543
self.w
499544
}
500545
/// Writes `variant` to the field
@@ -522,13 +567,13 @@ where
522567
/// Sets the field bit
523568
#[inline(always)]
524569
pub fn set_bit(self) -> &'a mut W<REG> {
525-
self.w.bits |= REG::Ux::one() << self.o;
570+
self.w.bits |= REG::Ux::ONE << self.o;
526571
self.w
527572
}
528573
/// Clears the field bit
529574
#[inline(always)]
530575
pub fn clear_bit(self) -> &'a mut W<REG> {
531-
self.w.bits &= !(REG::Ux::one() << self.o);
576+
self.w.bits &= !(REG::Ux::ONE << self.o);
532577
self.w
533578
}
534579
}
@@ -541,7 +586,7 @@ where
541586
/// Sets the field bit
542587
#[inline(always)]
543588
pub fn set_bit(self) -> &'a mut W<REG> {
544-
self.w.bits |= REG::Ux::one() << self.o;
589+
self.w.bits |= REG::Ux::ONE << self.o;
545590
self.w
546591
}
547592
}
@@ -554,7 +599,7 @@ where
554599
/// Clears the field bit
555600
#[inline(always)]
556601
pub fn clear_bit(self) -> &'a mut W<REG> {
557-
self.w.bits &= !(REG::Ux::one() << self.o);
602+
self.w.bits &= !(REG::Ux::ONE << self.o);
558603
self.w
559604
}
560605
}
@@ -567,7 +612,7 @@ where
567612
///Clears the field bit by passing one
568613
#[inline(always)]
569614
pub fn clear_bit_by_one(self) -> &'a mut W<REG> {
570-
self.w.bits |= REG::Ux::one() << self.o;
615+
self.w.bits |= REG::Ux::ONE << self.o;
571616
self.w
572617
}
573618
}
@@ -580,7 +625,7 @@ where
580625
///Sets the field bit by passing zero
581626
#[inline(always)]
582627
pub fn set_bit_by_zero(self) -> &'a mut W<REG> {
583-
self.w.bits &= !(REG::Ux::one() << self.o);
628+
self.w.bits &= !(REG::Ux::ONE << self.o);
584629
self.w
585630
}
586631
}
@@ -593,7 +638,7 @@ where
593638
///Toggle the field bit by passing one
594639
#[inline(always)]
595640
pub fn toggle_bit(self) -> &'a mut W<REG> {
596-
self.w.bits |= REG::Ux::one() << self.o;
641+
self.w.bits |= REG::Ux::ONE << self.o;
597642
self.w
598643
}
599644
}
@@ -606,7 +651,7 @@ where
606651
///Toggle the field bit by passing zero
607652
#[inline(always)]
608653
pub fn toggle_bit(self) -> &'a mut W<REG> {
609-
self.w.bits &= !(REG::Ux::one() << self.o);
654+
self.w.bits &= !(REG::Ux::ONE << self.o);
610655
self.w
611656
}
612657
}
@@ -761,7 +806,7 @@ impl<REG: Writable> Reg<REG> {
761806
F: FnOnce(&mut W<REG>) -> &mut W<REG>,
762807
{
763808
let value = f(&mut W {
764-
bits: REG::Ux::default(),
809+
bits: REG::Ux::ZERO,
765810
_reg: marker::PhantomData,
766811
})
767812
.bits;
@@ -782,7 +827,7 @@ impl<REG: Writable> Reg<REG> {
782827
F: FnOnce(&mut W<REG>) -> T,
783828
{
784829
let mut writer = W {
785-
bits: REG::Ux::default(),
830+
bits: REG::Ux::ZERO,
786831
_reg: marker::PhantomData,
787832
};
788833

0 commit comments

Comments
 (0)