Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4 add support for 64 bit register #5

Merged
merged 3 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/rust_gen/xml2ir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ fn get_register(reg: &svd::Register) -> Register {
.size
.expect("All registers shall have a defined size")
{
64 => BitSize::BIT64,
32 => BitSize::BIT32,
16 => BitSize::BIT16,
8 => BitSize::BIT8,
Expand Down
12 changes: 6 additions & 6 deletions templates/rust/common.tera
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
{{ir.license_text}}
*/
use core::convert::From;
use core::marker::PhantomData;
use ::core::convert::From;
use ::core::marker::PhantomData;

{% if tracing %}
#[cfg(feature = "tracing")]
Expand All @@ -22,7 +22,7 @@ pub(crate) mod sealed {
impl Access for R {}
impl Access for W {}
impl Access for RW {}
use core::ops::{BitAnd, BitAndAssign, BitOrAssign, Not, Shl, Shr};
use ::core::ops::{BitAnd, BitAndAssign, BitOrAssign, Not, Shl, Shr};

// It would be better with const fn
// waiting for RFC: const functions in traits #3490
Expand Down Expand Up @@ -346,16 +346,16 @@ where
#[cfg(not(feature="tracing"))]
{% endif -%}
unsafe {
core::arch::tricore::intrinsics::__ldmst(self.ptr as *mut u32, res.data, res.mask);
::core::arch::tricore::intrinsics::__ldmst(self.ptr as *mut u32, res.data, res.mask);
}

}
}

#[cfg(not(feature="tracing"))]
use core::arch::tricore::intrinsics::{__mfcr, __mtcr};
use ::core::arch::tricore::intrinsics::{__mfcr, __mtcr};
#[cfg(all(any(target_feature = "tc18", doc),not(feature="tracing")))]
use core::arch::tricore::intrinsics::{__mfdcr, __mtdcr};
use ::core::arch::tricore::intrinsics::{__mfdcr, __mtdcr};

/// Type of core special register of Aurix (CSFR)
pub struct RegCore<T: RegSpec, A: Access, const ADDR: u16> {
Expand Down
8 changes: 5 additions & 3 deletions templates/rust/macros.tera
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ u8
u16
{%- elif bit_size=="BIT32" -%}
u32
{%- elif bit_size=="BIT64" -%}
u64
{%- else -%}
Unsupported register size
{%- endif -%}
Expand Down Expand Up @@ -99,7 +101,7 @@ impl {{reg_struct_name}} {
{%- endfor %}
}
{% endif -%}
impl core::default::Default for {{reg_struct_name}} {
impl ::core::default::Default for {{reg_struct_name}} {
#[inline(always)]
fn default() -> {{reg_struct_name}} {
<crate::RegValueT::<{{reg_struct_name}}_SPEC> as RegisterValue<_>>::new({{reg.reset_value}})
Expand Down Expand Up @@ -159,8 +161,8 @@ pub fn {{cluster_func}}(self) -> [{{cluster_struct_path}};{{cluster.dim}}] {
#[doc = "{{cluster.description | svd_description_to_doc}}"]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct {{ cluster_struct }}(pub(super) *mut u8);
unsafe impl core::marker::Send for {{ cluster_struct}} {}
unsafe impl core::marker::Sync for {{ cluster_struct }} {}
unsafe impl ::core::marker::Send for {{ cluster_struct}} {}
unsafe impl ::core::marker::Sync for {{ cluster_struct }} {}
impl {{cluster_struct}} {
{% for register_name,reg in cluster.registers -%}
{{self::register_func(types_mod=cluster_mod,reg=reg)}}
Expand Down
Loading
Loading