rk3399_pac/crypto/
hash_ctrl.rs1#[doc = "Register `HASH_CTRL` reader"]
2pub type R = crate::R<HashCtrlSpec>;
3#[doc = "Register `HASH_CTRL` writer"]
4pub type W = crate::W<HashCtrlSpec>;
5#[doc = "\n\nValue on reset: 0"]
6#[cfg_attr(feature = "defmt", derive(defmt::Format))]
7#[derive(Clone, Copy, Debug, PartialEq, Eq)]
8#[repr(u8)]
9pub enum EngineSelection {
10 #[doc = "0: SHA1_HASH"]
11 B00 = 0,
12 #[doc = "1: MD5_HASH"]
13 B01 = 1,
14 #[doc = "2: SHA256_HASH"]
15 B10 = 2,
16 #[doc = "3: PRNG"]
17 B11 = 3,
18}
19impl From<EngineSelection> for u8 {
20 #[inline(always)]
21 fn from(variant: EngineSelection) -> Self {
22 variant as _
23 }
24}
25impl crate::FieldSpec for EngineSelection {
26 type Ux = u8;
27}
28#[doc = "Field `ENGINE_SELECTION` reader - "]
29pub type EngineSelectionR = crate::FieldReader<EngineSelection>;
30impl EngineSelectionR {
31 #[doc = "Get enumerated values variant"]
32 #[inline(always)]
33 pub const fn variant(&self) -> EngineSelection {
34 match self.bits {
35 0 => EngineSelection::B00,
36 1 => EngineSelection::B01,
37 2 => EngineSelection::B10,
38 3 => EngineSelection::B11,
39 _ => unreachable!(),
40 }
41 }
42 #[doc = "SHA1_HASH"]
43 #[inline(always)]
44 pub fn is_b00(&self) -> bool {
45 *self == EngineSelection::B00
46 }
47 #[doc = "MD5_HASH"]
48 #[inline(always)]
49 pub fn is_b01(&self) -> bool {
50 *self == EngineSelection::B01
51 }
52 #[doc = "SHA256_HASH"]
53 #[inline(always)]
54 pub fn is_b10(&self) -> bool {
55 *self == EngineSelection::B10
56 }
57 #[doc = "PRNG"]
58 #[inline(always)]
59 pub fn is_b11(&self) -> bool {
60 *self == EngineSelection::B11
61 }
62}
63#[doc = "Field `ENGINE_SELECTION` writer - "]
64pub type EngineSelectionW<'a, REG> = crate::FieldWriterSafe<'a, REG, 2, EngineSelection>;
65impl<'a, REG> EngineSelectionW<'a, REG>
66where
67 REG: crate::Writable + crate::RegisterSpec,
68 REG::Ux: From<u8>,
69{
70 #[doc = "SHA1_HASH"]
71 #[inline(always)]
72 pub fn b00(self) -> &'a mut crate::W<REG> {
73 self.variant(EngineSelection::B00)
74 }
75 #[doc = "MD5_HASH"]
76 #[inline(always)]
77 pub fn b01(self) -> &'a mut crate::W<REG> {
78 self.variant(EngineSelection::B01)
79 }
80 #[doc = "SHA256_HASH"]
81 #[inline(always)]
82 pub fn b10(self) -> &'a mut crate::W<REG> {
83 self.variant(EngineSelection::B10)
84 }
85 #[doc = "PRNG"]
86 #[inline(always)]
87 pub fn b11(self) -> &'a mut crate::W<REG> {
88 self.variant(EngineSelection::B11)
89 }
90}
91#[doc = "Field `HASH_SWAP_DO` reader - Specifies the Byte swap of data output (hash result)\n\n0 = Does not swap (default)\n\n1 = Swap"]
92pub type HashSwapDoR = crate::BitReader;
93#[doc = "Field `HASH_SWAP_DO` writer - Specifies the Byte swap of data output (hash result)\n\n0 = Does not swap (default)\n\n1 = Swap"]
94pub type HashSwapDoW<'a, REG> = crate::BitWriter<'a, REG>;
95impl R {
96 #[doc = "Bits 0:1"]
97 #[inline(always)]
98 pub fn engine_selection(&self) -> EngineSelectionR {
99 EngineSelectionR::new((self.bits & 3) as u8)
100 }
101 #[doc = "Bit 3 - Specifies the Byte swap of data output (hash result)\n\n0 = Does not swap (default)\n\n1 = Swap"]
102 #[inline(always)]
103 pub fn hash_swap_do(&self) -> HashSwapDoR {
104 HashSwapDoR::new(((self.bits >> 3) & 1) != 0)
105 }
106}
107impl W {
108 #[doc = "Bits 0:1"]
109 #[inline(always)]
110 #[must_use]
111 pub fn engine_selection(&mut self) -> EngineSelectionW<HashCtrlSpec> {
112 EngineSelectionW::new(self, 0)
113 }
114 #[doc = "Bit 3 - Specifies the Byte swap of data output (hash result)\n\n0 = Does not swap (default)\n\n1 = Swap"]
115 #[inline(always)]
116 #[must_use]
117 pub fn hash_swap_do(&mut self) -> HashSwapDoW<HashCtrlSpec> {
118 HashSwapDoW::new(self, 3)
119 }
120}
121#[doc = "Hash Control Register\n\nYou can [`read`](crate::generic::Reg::read) this register and get [`hash_ctrl::R`](R). You can [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero) this register using [`hash_ctrl::W`](W). You can also [`modify`](crate::generic::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
122pub struct HashCtrlSpec;
123impl crate::RegisterSpec for HashCtrlSpec {
124 type Ux = u32;
125}
126#[doc = "`read()` method returns [`hash_ctrl::R`](R) reader structure"]
127impl crate::Readable for HashCtrlSpec {}
128#[doc = "`write(|w| ..)` method takes [`hash_ctrl::W`](W) writer structure"]
129impl crate::Writable for HashCtrlSpec {
130 type Safety = crate::Unsafe;
131 const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
132 const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
133}
134#[doc = "`reset()` method sets HASH_CTRL to value 0"]
135impl crate::Resettable for HashCtrlSpec {
136 const RESET_VALUE: u32 = 0;
137}