-
Notifications
You must be signed in to change notification settings - Fork 115
start adding argument and response module #232
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
Open
robamu
wants to merge
1
commit into
rust-embedded-community:develop
Choose a base branch
from
robamu:argument-response-module
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,179 @@ | ||
| //! # Argument module | ||
| //! | ||
| //! Arguments are additional command parameters. | ||
|
|
||
| use arbitrary_int::u24; | ||
|
|
||
| /// Voltage settings supplied in CMD8. | ||
| #[bitbybit::bitenum(u4, exhaustive = false)] | ||
| #[derive(Debug, Default, PartialEq, Eq)] | ||
| #[cfg_attr(feature = "defmt-log", derive(defmt::Format))] | ||
| pub enum VoltageSuppliedSelect { | ||
| /// Regular voltage range. | ||
| #[default] | ||
| _2_7To3_6V = 0b0001, | ||
| /// Reserved for low voltage. | ||
| LowVoltageRange = 0b0010, | ||
| } | ||
|
|
||
| /// CMD8 argument. | ||
| #[bitbybit::bitfield(u32, default = 0x0, debug, defmt_fields(feature = "defmt-log"))] | ||
| pub struct Cmd8 { | ||
| /// PCIe v1.2 support. | ||
| #[bit(13, rw)] | ||
| pcie_1_2v_support: bool, | ||
| /// PCIe available. | ||
| #[bit(12, rw)] | ||
| pcie_availability: bool, | ||
| /// Voltage settings. | ||
| #[bits(8..=11, rw)] | ||
| voltage_supplied: Option<VoltageSuppliedSelect>, | ||
| /// Check pattern which is echoed. | ||
| #[bits(0..=7, rw)] | ||
| check_pattern: u8, | ||
| } | ||
|
|
||
| /// Power control (XPC) settings. | ||
| #[bitbybit::bitenum(u1, exhaustive = true)] | ||
| #[derive(Debug, PartialEq, Eq)] | ||
| #[cfg_attr(feature = "defmt-log", derive(defmt::Format))] | ||
| pub enum PowerControl { | ||
| /// Power saving. | ||
| PowerSaving = 0, | ||
| /// Maximum performance. | ||
| MaximumPerformance = 1, | ||
| } | ||
|
|
||
| /// HPC. | ||
| #[bitbybit::bitenum(u1, exhaustive = true)] | ||
| #[derive(Debug, PartialEq, Eq)] | ||
| #[cfg_attr(feature = "defmt-log", derive(defmt::Format))] | ||
| pub enum HostCapacitySupport { | ||
| /// SDSC only. | ||
| SdscOnly = 0, | ||
| /// Extended capacity - SDHC or SDXC. | ||
| SdhcOrSdxc = 1, | ||
| } | ||
|
|
||
| /// Lower OCR bits used to negotiate voltage capabilities. | ||
| #[bitbybit::bitfield(u24, default = 0x0, debug, defmt_fields(feature = "defmt-log"))] | ||
| pub struct OcrLower { | ||
| /// 3.5 to 3.6V | ||
| #[bit(23, rw)] | ||
| _3_5_to_3_6v: bool, | ||
| /// 3.4 to 3.5V | ||
| #[bit(22, rw)] | ||
| _3_4_to_3_5v: bool, | ||
| /// 3.3 to 3.4V | ||
| #[bit(21, rw)] | ||
| _3_3_to_3_4v: bool, | ||
| /// 3.2 to 3.3V | ||
| #[bit(20, rw)] | ||
| _3_2_to_3_3v: bool, | ||
| /// 3.1 to 3.2V | ||
| #[bit(19, rw)] | ||
| _3_1_to_3_2v: bool, | ||
| /// 3.0 to 3.1V | ||
| #[bit(18, rw)] | ||
| _3_0_to_3_1v: bool, | ||
| /// 2.9 to 3.0V | ||
| #[bit(17, rw)] | ||
| _2_9_to_3_0v: bool, | ||
| /// 2.8 to 2.9V | ||
| #[bit(16, rw)] | ||
| _2_8_to_2_9v: bool, | ||
| /// 2.7 to 2.8V | ||
| #[bit(15, rw)] | ||
| _2_7_to_2_8v: bool, | ||
| /// Reserved for low voltage | ||
| #[bit(7, rw)] | ||
| reserved_low_voltage: bool, | ||
| } | ||
|
|
||
| /// Bus width setting. | ||
| #[bitbybit::bitenum(u2, exhaustive = false)] | ||
| #[derive(Debug, PartialEq, Eq)] | ||
| #[cfg_attr(feature = "defmt-log", derive(defmt::Format))] | ||
| pub enum BusWidth { | ||
| /// 1 bit bus. | ||
| _1bit = 0b00, | ||
| /// 4 bit bus. | ||
| _4bits = 0b10, | ||
| } | ||
|
|
||
| /// ACMD6 - Set bus width. | ||
| #[bitbybit::bitfield( | ||
| u32, | ||
| default = 0x0, | ||
| debug, | ||
| defmt_fields(feature = "defmt-log"), | ||
| forbid_overlaps | ||
| )] | ||
| pub struct Acmd6 { | ||
| /// Bus width. | ||
| #[bits(0..=1, rw)] | ||
| bus_width: Option<BusWidth>, | ||
| } | ||
|
|
||
| /// ACMD41 argument - Capability negotiation. | ||
| #[bitbybit::bitfield( | ||
| u32, | ||
| default = 0x0, | ||
| debug, | ||
| defmt_fields(feature = "defmt-log"), | ||
| forbid_overlaps | ||
| )] | ||
| pub struct Acmd41 { | ||
| /// HPC. | ||
| #[bit(30, rw)] | ||
| host_capacity_support: HostCapacitySupport, | ||
| /// FB. | ||
| #[bit(29, rw)] | ||
| fast_boot: bool, | ||
| /// XPC. | ||
| #[bit(28, rw)] | ||
| xpc: PowerControl, | ||
| /// Switch to 1.8V signal voltage request. | ||
| #[bit(24, rw)] | ||
| s18r: bool, | ||
| /// If this is set to 0. ACMD41 is called "inquire CMD41" that does not start | ||
| /// initialization and is used for getting OCR. Bits 24 to 31 are ignored. | ||
| #[bits(0..=23, rw)] | ||
| ocr: OcrLower, | ||
| } | ||
|
|
||
| /// Relative Card Address (RCA) select. | ||
| #[bitbybit::bitfield( | ||
| u32, | ||
| default = 0x0, | ||
| debug, | ||
| defmt_bitfields(feature = "defmt-log"), | ||
| forbid_overlaps | ||
| )] | ||
| pub struct RcaSelect { | ||
| /// RCA. | ||
| #[bits(16..=31, rw)] | ||
| rca: u16, | ||
| } | ||
|
|
||
| /// CMD9 argument. | ||
| pub type Cmd9 = RcaSelect; | ||
| /// CMD7 argument. | ||
| pub type Cmd7 = RcaSelect; | ||
|
|
||
| /// CMD13 argument. | ||
| #[bitbybit::bitfield( | ||
| u32, | ||
| default = 0x0, | ||
| debug, | ||
| defmt_bitfields(feature = "defmt-log"), | ||
| forbid_overlaps | ||
| )] | ||
| pub struct Cmd13 { | ||
| /// RCA. | ||
| #[bits(16..=31, rw)] | ||
| rca: u16, | ||
| /// Send task status instead of regular card status. | ||
| #[bit(15, rw)] | ||
| send_task_status: bool, | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HPC?