Skip to content

Commit

Permalink
width, offset
Browse files Browse the repository at this point in the history
  • Loading branch information
burrbull committed Oct 25, 2023
1 parent e7d4788 commit 4ac1400
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/).

- `FieldWriter` takes offset as struct field instead of const generic.
Improves SVD field array access
Add `width`, `offset` methods
- *breaking change* Always numerates field arrays from 0

## [v0.30.2] - 2023-10-22
Expand Down
36 changes: 36 additions & 0 deletions src/generate/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,18 @@ where
/// Field width
pub const WIDTH: u8 = WI;

/// Field width
#[inline(always)]
pub const fn width(&self) -> u8 {
WI
}

/// Field offset
#[inline(always)]
pub const fn offset(&self) -> u8 {
self.o
}

/// Writes raw bits to the field
///
/// # Safety
Expand Down Expand Up @@ -491,6 +503,18 @@ where
/// Field width
pub const WIDTH: u8 = WI;

/// Field width
#[inline(always)]
pub const fn width(&self) -> u8 {
WI
}

/// Field offset
#[inline(always)]
pub const fn offset(&self) -> u8 {
self.o
}

/// Writes raw bits to the field
#[inline(always)]
pub fn bits(self, value: FI::Ux) -> &'a mut W<REG> {
Expand Down Expand Up @@ -521,6 +545,18 @@ macro_rules! bit_proxy {
/// Field width
pub const WIDTH: u8 = 1;

/// Field width
#[inline(always)]
pub const fn width(&self) -> u8 {
1
}

/// Field offset
#[inline(always)]
pub const fn offset(&self) -> u8 {
self.o
}

/// Writes bit to the field
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W<REG> {
Expand Down

0 comments on commit 4ac1400

Please sign in to comment.