sdmmc_core/register/csd/mmc/ecc.rs
1use crate::lib_enum;
2use crate::result::{Error, Result};
3
4lib_enum! {
5 /// Represents the `ECC` and `DEFAULT_ECC` sub-fields of the `CSD` register.
6 Ecc: u8 {
7 default: NoEcc,
8 error: Error,
9 /// Indicates no ECC algorithm is in use.
10 NoEcc = 0,
11 /// Indicates the BCH ECC algorithm is in use (max correctible bits: 3).
12 Bch = 1,
13 }
14}
15
16impl Ecc {
17 /// Attempts to convert an inner representation into an [Ecc].
18 pub const fn try_from_inner(val: u8) -> Result<Self> {
19 Self::from_raw(val)
20 }
21
22 /// Converts an [Ecc] into an inner representation.
23 pub const fn into_inner(self) -> u8 {
24 self.into_raw()
25 }
26}