Skip to content

How to work with n-bit numbers and bit fields. #212

Closed Answered by JiveyGuy
JiveyGuy asked this question in Q&A
Discussion options

You must be logged in to vote

Solution:

use modular_bitfield::{bitfield, specifiers::*, BitfieldSpecifier};

#[bitfield]
#[derive(BinRead, Debug)]
pub struct Sam1Word3Bitfield
{
    // bits
    status:         B16,
    number_4_bits:  B4, 

    enable_1:       bool,
    enable_2:       bool,
    enable_3:       bool,

    spare_group:    B3, // Spare, set to 0

    number_3_bit:   B3,
    number_3_bit:   B3,
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by JiveyGuy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant