embassy-rs / stm32-data

69 stars 101 forks source link

make address of registers show as hex #412

Closed eZioPan closed 6 months ago

eZioPan commented 6 months ago

combine with embassy-rs/chiptool#27, this will make address of registers show as hex in output metapac, which align with RM, and make a little bit easier for us to comapre output with RM using eyes.

This doesn't touch stm32-data-gen, so there shouldn't be any changes in output json.

example of stm32-metapac changes:

stm32-metapac/src/chips/metadata_XXXX.rs

 Peripheral {
     name: "ADC1",
-    address: 1073816576,
+    address: 0x40012400,
     registers: None,

stm32-metapac/src/chips/stm32XXXXXX/metadata.rs

 MemoryRegion {
     name: "BANK_1",
     kind: MemoryRegionKind::Flash,
-    address: 134217728,
+    address: 0x8000000,

stm32-metapac/src/peripherals/XXX.rs

 #[doc = "sample time register 1"]
 #[inline(always)]
 pub const fn smpr1(self) -> crate::common::Reg<regs::Smpr1, crate::common::RW> {
-    unsafe { crate::common::Reg::from_ptr(self.ptr.add(12usize) as _) }
+    unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x0cusize) as _) }
 }

^ I would proposal use uppercase hex instead. 0x0Cusize is a little bit easier to read than 0x0cusize. What would you think?

and all hex value 0 will write as 0x0

  #[doc = "status register"]
  #[inline(always)]
  pub const fn sr(self) -> crate::common::Reg<regs::Sr, crate::common::RW> {
-     unsafe { crate::common::Reg::from_ptr(self.ptr.add(0usize) as _) }
+     unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x0usize) as _) }
 }
 pub mod vals {
     #[repr(u8)]
     #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
     pub enum Dualmod {
         #[doc = "Independent mode."]
-        INDEPENDENT = 0,
+        INDEPENDENT = 0x0,
         #[doc = "Combined regular simultaneous + injected simultaneous mode"]
         REGULARINJECTED = 0x01,

will need

embassy-ci[bot] commented 6 months ago

diff: https://ci.embassy.dev/jobs/deca955e192d/artifacts/diff.html

embassy-ci[bot] commented 6 months ago

diff: https://ci.embassy.dev/jobs/ddafe4fc4c4f/artifacts/diff.html