diff options
| author | Dario Nieuwenhuis <[email protected]> | 2021-05-06 22:44:38 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-05-06 22:44:38 +0200 |
| commit | 3e83a495cb4f3aafdd1befe524f64c78de1a5972 (patch) | |
| tree | 6375511c4a85c8ea5d1781899caf8dd8d579cb26 | |
| parent | 386e4bf0de6369a3338f56877a779e1e05b4dcc2 (diff) | |
| parent | 75fe03a7e674b6fcded5219da3541bd1b3607582 (diff) | |
Merge pull request #165 from bobmcwhirter/rng_impl
Rng impl
| -rw-r--r-- | embassy-stm32/Cargo.toml | 3 | ||||
| -rw-r--r-- | embassy-stm32/gen.py | 5 | ||||
| -rw-r--r-- | embassy-stm32/src/lib.rs | 1 | ||||
| -rw-r--r-- | embassy-stm32/src/pac/regs.rs | 7186 | ||||
| -rw-r--r-- | embassy-stm32/src/rng.rs | 141 | ||||
| -rw-r--r-- | embassy-traits/src/rng.rs | 2 |
6 files changed, 3726 insertions, 3612 deletions
diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml index 9449f636b..6ae96dbca 100644 --- a/embassy-stm32/Cargo.toml +++ b/embassy-stm32/Cargo.toml | |||
| @@ -15,6 +15,7 @@ cortex-m-rt = { version = "0.6.13", features = ["device"] } | |||
| 15 | cortex-m = "0.7.1" | 15 | cortex-m = "0.7.1" |
| 16 | embedded-hal = { version = "0.2.4" } | 16 | embedded-hal = { version = "0.2.4" } |
| 17 | futures = { version = "0.3.5", default-features = false, features = ["async-await"] } | 17 | futures = { version = "0.3.5", default-features = false, features = ["async-await"] } |
| 18 | rand_core = { version = "0.6.2", optional=true} | ||
| 18 | 19 | ||
| 19 | [build-dependencies] | 20 | [build-dependencies] |
| 20 | regex = "1.4.6" | 21 | regex = "1.4.6" |
| @@ -321,7 +322,7 @@ _exti = [] | |||
| 321 | _exti_v1 = [] | 322 | _exti_v1 = [] |
| 322 | _gpio = [] | 323 | _gpio = [] |
| 323 | _gpio_v2 = [] | 324 | _gpio_v2 = [] |
| 324 | _rng = [] | 325 | _rng = [ "rand_core",] |
| 325 | _rng_v1 = [] | 326 | _rng_v1 = [] |
| 326 | _stm32f4 = [] | 327 | _stm32f4 = [] |
| 327 | _stm32l4 = [] | 328 | _stm32l4 = [] |
diff --git a/embassy-stm32/gen.py b/embassy-stm32/gen.py index a1af866f4..89c40ad7d 100644 --- a/embassy-stm32/gen.py +++ b/embassy-stm32/gen.py | |||
| @@ -201,6 +201,9 @@ for chip in chips.values(): | |||
| 201 | 201 | ||
| 202 | # ========= Update Cargo features | 202 | # ========= Update Cargo features |
| 203 | 203 | ||
| 204 | feature_optional_deps = {} | ||
| 205 | feature_optional_deps['_rng'] = ['rand_core'] | ||
| 206 | |||
| 204 | features = {} | 207 | features = {} |
| 205 | extra_features = set() | 208 | extra_features = set() |
| 206 | for name, chip in chips.items(): | 209 | for name, chip in chips.items(): |
| @@ -208,7 +211,7 @@ for name, chip in chips.items(): | |||
| 208 | for feature in chip['features']: | 211 | for feature in chip['features']: |
| 209 | extra_features.add(feature) | 212 | extra_features.add(feature) |
| 210 | for feature in sorted(list(extra_features)): | 213 | for feature in sorted(list(extra_features)): |
| 211 | features[feature] = [] | 214 | features[feature] = feature_optional_deps.get(feature) or [] |
| 212 | 215 | ||
| 213 | SEPARATOR_START = '# BEGIN GENERATED FEATURES\n' | 216 | SEPARATOR_START = '# BEGIN GENERATED FEATURES\n' |
| 214 | SEPARATOR_END = '# END GENERATED FEATURES\n' | 217 | SEPARATOR_END = '# END GENERATED FEATURES\n' |
diff --git a/embassy-stm32/src/lib.rs b/embassy-stm32/src/lib.rs index 557ed61af..c3ab55036 100644 --- a/embassy-stm32/src/lib.rs +++ b/embassy-stm32/src/lib.rs | |||
| @@ -15,6 +15,7 @@ pub mod exti; | |||
| 15 | pub mod gpio; | 15 | pub mod gpio; |
| 16 | #[cfg(feature = "_rng")] | 16 | #[cfg(feature = "_rng")] |
| 17 | pub mod rng; | 17 | pub mod rng; |
| 18 | #[cfg(feature = "_usart")] | ||
| 18 | pub mod usart; | 19 | pub mod usart; |
| 19 | 20 | ||
| 20 | // This must go LAST so that it sees the `impl_foo!` macros | 21 | // This must go LAST so that it sees the `impl_foo!` macros |
diff --git a/embassy-stm32/src/pac/regs.rs b/embassy-stm32/src/pac/regs.rs index e7f853c75..370d0c512 100644 --- a/embassy-stm32/src/pac/regs.rs +++ b/embassy-stm32/src/pac/regs.rs | |||
| @@ -1,231 +1,840 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![doc = "Peripheral access API (generated using svd2rust v0.17.0 (507115a 2021-04-19))"] | 2 | #![doc = "Peripheral access API (generated using svd2rust v0.17.0 (507115a 2021-04-19))"] |
| 3 | pub mod exti_v1 { | 3 | pub mod rng_v1 { |
| 4 | use crate::generic::*; | 4 | use crate::generic::*; |
| 5 | #[doc = "External interrupt/event controller"] | 5 | #[doc = "Random number generator"] |
| 6 | #[derive(Copy, Clone)] | 6 | #[derive(Copy, Clone)] |
| 7 | pub struct Exti(pub *mut u8); | 7 | pub struct Rng(pub *mut u8); |
| 8 | unsafe impl Send for Exti {} | 8 | unsafe impl Send for Rng {} |
| 9 | unsafe impl Sync for Exti {} | 9 | unsafe impl Sync for Rng {} |
| 10 | impl Exti { | 10 | impl Rng { |
| 11 | #[doc = "Interrupt mask register (EXTI_IMR)"] | 11 | #[doc = "control register"] |
| 12 | pub fn imr(self) -> Reg<regs::Imr, RW> { | 12 | pub fn cr(self) -> Reg<regs::Cr, RW> { |
| 13 | unsafe { Reg::from_ptr(self.0.add(0usize)) } | 13 | unsafe { Reg::from_ptr(self.0.add(0usize)) } |
| 14 | } | 14 | } |
| 15 | #[doc = "Event mask register (EXTI_EMR)"] | 15 | #[doc = "status register"] |
| 16 | pub fn emr(self) -> Reg<regs::Emr, RW> { | 16 | pub fn sr(self) -> Reg<regs::Sr, RW> { |
| 17 | unsafe { Reg::from_ptr(self.0.add(4usize)) } | 17 | unsafe { Reg::from_ptr(self.0.add(4usize)) } |
| 18 | } | 18 | } |
| 19 | #[doc = "Rising Trigger selection register (EXTI_RTSR)"] | 19 | #[doc = "data register"] |
| 20 | pub fn rtsr(self) -> Reg<regs::Rtsr, RW> { | 20 | pub fn dr(self) -> Reg<u32, R> { |
| 21 | unsafe { Reg::from_ptr(self.0.add(8usize)) } | 21 | unsafe { Reg::from_ptr(self.0.add(8usize)) } |
| 22 | } | 22 | } |
| 23 | #[doc = "Falling Trigger selection register (EXTI_FTSR)"] | 23 | } |
| 24 | pub fn ftsr(self) -> Reg<regs::Ftsr, RW> { | 24 | pub mod regs { |
| 25 | use crate::generic::*; | ||
| 26 | #[doc = "control register"] | ||
| 27 | #[repr(transparent)] | ||
| 28 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 29 | pub struct Cr(pub u32); | ||
| 30 | impl Cr { | ||
| 31 | #[doc = "Random number generator enable"] | ||
| 32 | pub const fn rngen(&self) -> bool { | ||
| 33 | let val = (self.0 >> 2usize) & 0x01; | ||
| 34 | val != 0 | ||
| 35 | } | ||
| 36 | #[doc = "Random number generator enable"] | ||
| 37 | pub fn set_rngen(&mut self, val: bool) { | ||
| 38 | self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize); | ||
| 39 | } | ||
| 40 | #[doc = "Interrupt enable"] | ||
| 41 | pub const fn ie(&self) -> bool { | ||
| 42 | let val = (self.0 >> 3usize) & 0x01; | ||
| 43 | val != 0 | ||
| 44 | } | ||
| 45 | #[doc = "Interrupt enable"] | ||
| 46 | pub fn set_ie(&mut self, val: bool) { | ||
| 47 | self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize); | ||
| 48 | } | ||
| 49 | } | ||
| 50 | impl Default for Cr { | ||
| 51 | fn default() -> Cr { | ||
| 52 | Cr(0) | ||
| 53 | } | ||
| 54 | } | ||
| 55 | #[doc = "status register"] | ||
| 56 | #[repr(transparent)] | ||
| 57 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 58 | pub struct Sr(pub u32); | ||
| 59 | impl Sr { | ||
| 60 | #[doc = "Data ready"] | ||
| 61 | pub const fn drdy(&self) -> bool { | ||
| 62 | let val = (self.0 >> 0usize) & 0x01; | ||
| 63 | val != 0 | ||
| 64 | } | ||
| 65 | #[doc = "Data ready"] | ||
| 66 | pub fn set_drdy(&mut self, val: bool) { | ||
| 67 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); | ||
| 68 | } | ||
| 69 | #[doc = "Clock error current status"] | ||
| 70 | pub const fn cecs(&self) -> bool { | ||
| 71 | let val = (self.0 >> 1usize) & 0x01; | ||
| 72 | val != 0 | ||
| 73 | } | ||
| 74 | #[doc = "Clock error current status"] | ||
| 75 | pub fn set_cecs(&mut self, val: bool) { | ||
| 76 | self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize); | ||
| 77 | } | ||
| 78 | #[doc = "Seed error current status"] | ||
| 79 | pub const fn secs(&self) -> bool { | ||
| 80 | let val = (self.0 >> 2usize) & 0x01; | ||
| 81 | val != 0 | ||
| 82 | } | ||
| 83 | #[doc = "Seed error current status"] | ||
| 84 | pub fn set_secs(&mut self, val: bool) { | ||
| 85 | self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize); | ||
| 86 | } | ||
| 87 | #[doc = "Clock error interrupt status"] | ||
| 88 | pub const fn ceis(&self) -> bool { | ||
| 89 | let val = (self.0 >> 5usize) & 0x01; | ||
| 90 | val != 0 | ||
| 91 | } | ||
| 92 | #[doc = "Clock error interrupt status"] | ||
| 93 | pub fn set_ceis(&mut self, val: bool) { | ||
| 94 | self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize); | ||
| 95 | } | ||
| 96 | #[doc = "Seed error interrupt status"] | ||
| 97 | pub const fn seis(&self) -> bool { | ||
| 98 | let val = (self.0 >> 6usize) & 0x01; | ||
| 99 | val != 0 | ||
| 100 | } | ||
| 101 | #[doc = "Seed error interrupt status"] | ||
| 102 | pub fn set_seis(&mut self, val: bool) { | ||
| 103 | self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize); | ||
| 104 | } | ||
| 105 | } | ||
| 106 | impl Default for Sr { | ||
| 107 | fn default() -> Sr { | ||
| 108 | Sr(0) | ||
| 109 | } | ||
| 110 | } | ||
| 111 | } | ||
| 112 | } | ||
| 113 | pub mod gpio_v1 { | ||
| 114 | use crate::generic::*; | ||
| 115 | #[doc = "General purpose I/O"] | ||
| 116 | #[derive(Copy, Clone)] | ||
| 117 | pub struct Gpio(pub *mut u8); | ||
| 118 | unsafe impl Send for Gpio {} | ||
| 119 | unsafe impl Sync for Gpio {} | ||
| 120 | impl Gpio { | ||
| 121 | #[doc = "Port configuration register low (GPIOn_CRL)"] | ||
| 122 | pub fn cr(self, n: usize) -> Reg<regs::Cr, RW> { | ||
| 123 | assert!(n < 2usize); | ||
| 124 | unsafe { Reg::from_ptr(self.0.add(0usize + n * 4usize)) } | ||
| 125 | } | ||
| 126 | #[doc = "Port input data register (GPIOn_IDR)"] | ||
| 127 | pub fn idr(self) -> Reg<regs::Idr, R> { | ||
| 128 | unsafe { Reg::from_ptr(self.0.add(8usize)) } | ||
| 129 | } | ||
| 130 | #[doc = "Port output data register (GPIOn_ODR)"] | ||
| 131 | pub fn odr(self) -> Reg<regs::Odr, RW> { | ||
| 25 | unsafe { Reg::from_ptr(self.0.add(12usize)) } | 132 | unsafe { Reg::from_ptr(self.0.add(12usize)) } |
| 26 | } | 133 | } |
| 27 | #[doc = "Software interrupt event register (EXTI_SWIER)"] | 134 | #[doc = "Port bit set/reset register (GPIOn_BSRR)"] |
| 28 | pub fn swier(self) -> Reg<regs::Swier, RW> { | 135 | pub fn bsrr(self) -> Reg<regs::Bsrr, W> { |
| 29 | unsafe { Reg::from_ptr(self.0.add(16usize)) } | 136 | unsafe { Reg::from_ptr(self.0.add(16usize)) } |
| 30 | } | 137 | } |
| 31 | #[doc = "Pending register (EXTI_PR)"] | 138 | #[doc = "Port bit reset register (GPIOn_BRR)"] |
| 32 | pub fn pr(self) -> Reg<regs::Pr, RW> { | 139 | pub fn brr(self) -> Reg<regs::Brr, W> { |
| 33 | unsafe { Reg::from_ptr(self.0.add(20usize)) } | 140 | unsafe { Reg::from_ptr(self.0.add(20usize)) } |
| 34 | } | 141 | } |
| 142 | #[doc = "Port configuration lock register"] | ||
| 143 | pub fn lckr(self) -> Reg<regs::Lckr, RW> { | ||
| 144 | unsafe { Reg::from_ptr(self.0.add(24usize)) } | ||
| 145 | } | ||
| 146 | } | ||
| 147 | pub mod regs { | ||
| 148 | use crate::generic::*; | ||
| 149 | #[doc = "Port output data register (GPIOn_ODR)"] | ||
| 150 | #[repr(transparent)] | ||
| 151 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 152 | pub struct Odr(pub u32); | ||
| 153 | impl Odr { | ||
| 154 | #[doc = "Port output data"] | ||
| 155 | pub fn odr(&self, n: usize) -> super::vals::Odr { | ||
| 156 | assert!(n < 16usize); | ||
| 157 | let offs = 0usize + n * 1usize; | ||
| 158 | let val = (self.0 >> offs) & 0x01; | ||
| 159 | super::vals::Odr(val as u8) | ||
| 160 | } | ||
| 161 | #[doc = "Port output data"] | ||
| 162 | pub fn set_odr(&mut self, n: usize, val: super::vals::Odr) { | ||
| 163 | assert!(n < 16usize); | ||
| 164 | let offs = 0usize + n * 1usize; | ||
| 165 | self.0 = (self.0 & !(0x01 << offs)) | (((val.0 as u32) & 0x01) << offs); | ||
| 166 | } | ||
| 167 | } | ||
| 168 | impl Default for Odr { | ||
| 169 | fn default() -> Odr { | ||
| 170 | Odr(0) | ||
| 171 | } | ||
| 172 | } | ||
| 173 | #[doc = "Port configuration lock register"] | ||
| 174 | #[repr(transparent)] | ||
| 175 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 176 | pub struct Lckr(pub u32); | ||
| 177 | impl Lckr { | ||
| 178 | #[doc = "Port A Lock bit"] | ||
| 179 | pub fn lck(&self, n: usize) -> super::vals::Lck { | ||
| 180 | assert!(n < 16usize); | ||
| 181 | let offs = 0usize + n * 1usize; | ||
| 182 | let val = (self.0 >> offs) & 0x01; | ||
| 183 | super::vals::Lck(val as u8) | ||
| 184 | } | ||
| 185 | #[doc = "Port A Lock bit"] | ||
| 186 | pub fn set_lck(&mut self, n: usize, val: super::vals::Lck) { | ||
| 187 | assert!(n < 16usize); | ||
| 188 | let offs = 0usize + n * 1usize; | ||
| 189 | self.0 = (self.0 & !(0x01 << offs)) | (((val.0 as u32) & 0x01) << offs); | ||
| 190 | } | ||
| 191 | #[doc = "Lock key"] | ||
| 192 | pub const fn lckk(&self) -> super::vals::Lckk { | ||
| 193 | let val = (self.0 >> 16usize) & 0x01; | ||
| 194 | super::vals::Lckk(val as u8) | ||
| 195 | } | ||
| 196 | #[doc = "Lock key"] | ||
| 197 | pub fn set_lckk(&mut self, val: super::vals::Lckk) { | ||
| 198 | self.0 = (self.0 & !(0x01 << 16usize)) | (((val.0 as u32) & 0x01) << 16usize); | ||
| 199 | } | ||
| 200 | } | ||
| 201 | impl Default for Lckr { | ||
| 202 | fn default() -> Lckr { | ||
| 203 | Lckr(0) | ||
| 204 | } | ||
| 205 | } | ||
| 206 | #[doc = "Port bit set/reset register (GPIOn_BSRR)"] | ||
| 207 | #[repr(transparent)] | ||
| 208 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 209 | pub struct Bsrr(pub u32); | ||
| 210 | impl Bsrr { | ||
| 211 | #[doc = "Set bit"] | ||
| 212 | pub fn bs(&self, n: usize) -> bool { | ||
| 213 | assert!(n < 16usize); | ||
| 214 | let offs = 0usize + n * 1usize; | ||
| 215 | let val = (self.0 >> offs) & 0x01; | ||
| 216 | val != 0 | ||
| 217 | } | ||
| 218 | #[doc = "Set bit"] | ||
| 219 | pub fn set_bs(&mut self, n: usize, val: bool) { | ||
| 220 | assert!(n < 16usize); | ||
| 221 | let offs = 0usize + n * 1usize; | ||
| 222 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | ||
| 223 | } | ||
| 224 | #[doc = "Reset bit"] | ||
| 225 | pub fn br(&self, n: usize) -> bool { | ||
| 226 | assert!(n < 16usize); | ||
| 227 | let offs = 16usize + n * 1usize; | ||
| 228 | let val = (self.0 >> offs) & 0x01; | ||
| 229 | val != 0 | ||
| 230 | } | ||
| 231 | #[doc = "Reset bit"] | ||
| 232 | pub fn set_br(&mut self, n: usize, val: bool) { | ||
| 233 | assert!(n < 16usize); | ||
| 234 | let offs = 16usize + n * 1usize; | ||
| 235 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | ||
| 236 | } | ||
| 237 | } | ||
| 238 | impl Default for Bsrr { | ||
| 239 | fn default() -> Bsrr { | ||
| 240 | Bsrr(0) | ||
| 241 | } | ||
| 242 | } | ||
| 243 | #[doc = "Port bit reset register (GPIOn_BRR)"] | ||
| 244 | #[repr(transparent)] | ||
| 245 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 246 | pub struct Brr(pub u32); | ||
| 247 | impl Brr { | ||
| 248 | #[doc = "Reset bit"] | ||
| 249 | pub fn br(&self, n: usize) -> bool { | ||
| 250 | assert!(n < 16usize); | ||
| 251 | let offs = 0usize + n * 1usize; | ||
| 252 | let val = (self.0 >> offs) & 0x01; | ||
| 253 | val != 0 | ||
| 254 | } | ||
| 255 | #[doc = "Reset bit"] | ||
| 256 | pub fn set_br(&mut self, n: usize, val: bool) { | ||
| 257 | assert!(n < 16usize); | ||
| 258 | let offs = 0usize + n * 1usize; | ||
| 259 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | ||
| 260 | } | ||
| 261 | } | ||
| 262 | impl Default for Brr { | ||
| 263 | fn default() -> Brr { | ||
| 264 | Brr(0) | ||
| 265 | } | ||
| 266 | } | ||
| 267 | #[doc = "Port configuration register (GPIOn_CRx)"] | ||
| 268 | #[repr(transparent)] | ||
| 269 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 270 | pub struct Cr(pub u32); | ||
| 271 | impl Cr { | ||
| 272 | #[doc = "Port n mode bits"] | ||
| 273 | pub fn mode(&self, n: usize) -> super::vals::Mode { | ||
| 274 | assert!(n < 8usize); | ||
| 275 | let offs = 0usize + n * 4usize; | ||
| 276 | let val = (self.0 >> offs) & 0x03; | ||
| 277 | super::vals::Mode(val as u8) | ||
| 278 | } | ||
| 279 | #[doc = "Port n mode bits"] | ||
| 280 | pub fn set_mode(&mut self, n: usize, val: super::vals::Mode) { | ||
| 281 | assert!(n < 8usize); | ||
| 282 | let offs = 0usize + n * 4usize; | ||
| 283 | self.0 = (self.0 & !(0x03 << offs)) | (((val.0 as u32) & 0x03) << offs); | ||
| 284 | } | ||
| 285 | #[doc = "Port n configuration bits"] | ||
| 286 | pub fn cnf(&self, n: usize) -> super::vals::Cnf { | ||
| 287 | assert!(n < 8usize); | ||
| 288 | let offs = 2usize + n * 4usize; | ||
| 289 | let val = (self.0 >> offs) & 0x03; | ||
| 290 | super::vals::Cnf(val as u8) | ||
| 291 | } | ||
| 292 | #[doc = "Port n configuration bits"] | ||
| 293 | pub fn set_cnf(&mut self, n: usize, val: super::vals::Cnf) { | ||
| 294 | assert!(n < 8usize); | ||
| 295 | let offs = 2usize + n * 4usize; | ||
| 296 | self.0 = (self.0 & !(0x03 << offs)) | (((val.0 as u32) & 0x03) << offs); | ||
| 297 | } | ||
| 298 | } | ||
| 299 | impl Default for Cr { | ||
| 300 | fn default() -> Cr { | ||
| 301 | Cr(0) | ||
| 302 | } | ||
| 303 | } | ||
| 304 | #[doc = "Port input data register (GPIOn_IDR)"] | ||
| 305 | #[repr(transparent)] | ||
| 306 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 307 | pub struct Idr(pub u32); | ||
| 308 | impl Idr { | ||
| 309 | #[doc = "Port input data"] | ||
| 310 | pub fn idr(&self, n: usize) -> super::vals::Idr { | ||
| 311 | assert!(n < 16usize); | ||
| 312 | let offs = 0usize + n * 1usize; | ||
| 313 | let val = (self.0 >> offs) & 0x01; | ||
| 314 | super::vals::Idr(val as u8) | ||
| 315 | } | ||
| 316 | #[doc = "Port input data"] | ||
| 317 | pub fn set_idr(&mut self, n: usize, val: super::vals::Idr) { | ||
| 318 | assert!(n < 16usize); | ||
| 319 | let offs = 0usize + n * 1usize; | ||
| 320 | self.0 = (self.0 & !(0x01 << offs)) | (((val.0 as u32) & 0x01) << offs); | ||
| 321 | } | ||
| 322 | } | ||
| 323 | impl Default for Idr { | ||
| 324 | fn default() -> Idr { | ||
| 325 | Idr(0) | ||
| 326 | } | ||
| 327 | } | ||
| 35 | } | 328 | } |
| 36 | pub mod vals { | 329 | pub mod vals { |
| 37 | use crate::generic::*; | 330 | use crate::generic::*; |
| 38 | #[repr(transparent)] | 331 | #[repr(transparent)] |
| 39 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 332 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 40 | pub struct Prw(pub u8); | 333 | pub struct Lckk(pub u8); |
| 41 | impl Prw { | 334 | impl Lckk { |
| 42 | #[doc = "Clears pending bit"] | 335 | #[doc = "Port configuration lock key not active"] |
| 43 | pub const CLEAR: Self = Self(0x01); | 336 | pub const NOTACTIVE: Self = Self(0); |
| 337 | #[doc = "Port configuration lock key active"] | ||
| 338 | pub const ACTIVE: Self = Self(0x01); | ||
| 44 | } | 339 | } |
| 45 | #[repr(transparent)] | 340 | #[repr(transparent)] |
| 46 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 341 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 47 | pub struct Swierw(pub u8); | 342 | pub struct Mode(pub u8); |
| 48 | impl Swierw { | 343 | impl Mode { |
| 49 | #[doc = "Generates an interrupt request"] | 344 | #[doc = "Input mode (reset state)"] |
| 50 | pub const PEND: Self = Self(0x01); | 345 | pub const INPUT: Self = Self(0); |
| 346 | #[doc = "Output mode 10 MHz"] | ||
| 347 | pub const OUTPUT: Self = Self(0x01); | ||
| 348 | #[doc = "Output mode 2 MHz"] | ||
| 349 | pub const OUTPUT2: Self = Self(0x02); | ||
| 350 | #[doc = "Output mode 50 MHz"] | ||
| 351 | pub const OUTPUT50: Self = Self(0x03); | ||
| 51 | } | 352 | } |
| 52 | #[repr(transparent)] | 353 | #[repr(transparent)] |
| 53 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 354 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 54 | pub struct Mr(pub u8); | 355 | pub struct Cnf(pub u8); |
| 55 | impl Mr { | 356 | impl Cnf { |
| 56 | #[doc = "Interrupt request line is masked"] | 357 | #[doc = "Analog mode / Push-Pull mode"] |
| 57 | pub const MASKED: Self = Self(0); | 358 | pub const PUSHPULL: Self = Self(0); |
| 58 | #[doc = "Interrupt request line is unmasked"] | 359 | #[doc = "Floating input (reset state) / Open Drain-Mode"] |
| 59 | pub const UNMASKED: Self = Self(0x01); | 360 | pub const OPENDRAIN: Self = Self(0x01); |
| 361 | #[doc = "Input with pull-up/pull-down / Alternate Function Push-Pull Mode"] | ||
| 362 | pub const ALTPUSHPULL: Self = Self(0x02); | ||
| 363 | #[doc = "Alternate Function Open-Drain Mode"] | ||
| 364 | pub const ALTOPENDRAIN: Self = Self(0x03); | ||
| 60 | } | 365 | } |
| 61 | #[repr(transparent)] | 366 | #[repr(transparent)] |
| 62 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 367 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 63 | pub struct Tr(pub u8); | 368 | pub struct Brw(pub u8); |
| 64 | impl Tr { | 369 | impl Brw { |
| 65 | #[doc = "Falling edge trigger is disabled"] | 370 | #[doc = "No action on the corresponding ODx bit"] |
| 66 | pub const DISABLED: Self = Self(0); | 371 | pub const NOACTION: Self = Self(0); |
| 67 | #[doc = "Falling edge trigger is enabled"] | 372 | #[doc = "Reset the ODx bit"] |
| 68 | pub const ENABLED: Self = Self(0x01); | 373 | pub const RESET: Self = Self(0x01); |
| 69 | } | 374 | } |
| 70 | #[repr(transparent)] | 375 | #[repr(transparent)] |
| 71 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 376 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 72 | pub struct Prr(pub u8); | 377 | pub struct Odr(pub u8); |
| 73 | impl Prr { | 378 | impl Odr { |
| 74 | #[doc = "No trigger request occurred"] | 379 | #[doc = "Set output to logic low"] |
| 75 | pub const NOTPENDING: Self = Self(0); | 380 | pub const LOW: Self = Self(0); |
| 76 | #[doc = "Selected trigger request occurred"] | 381 | #[doc = "Set output to logic high"] |
| 77 | pub const PENDING: Self = Self(0x01); | 382 | pub const HIGH: Self = Self(0x01); |
| 383 | } | ||
| 384 | #[repr(transparent)] | ||
| 385 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 386 | pub struct Idr(pub u8); | ||
| 387 | impl Idr { | ||
| 388 | #[doc = "Input is logic low"] | ||
| 389 | pub const LOW: Self = Self(0); | ||
| 390 | #[doc = "Input is logic high"] | ||
| 391 | pub const HIGH: Self = Self(0x01); | ||
| 392 | } | ||
| 393 | #[repr(transparent)] | ||
| 394 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 395 | pub struct Lck(pub u8); | ||
| 396 | impl Lck { | ||
| 397 | #[doc = "Port configuration not locked"] | ||
| 398 | pub const UNLOCKED: Self = Self(0); | ||
| 399 | #[doc = "Port configuration locked"] | ||
| 400 | pub const LOCKED: Self = Self(0x01); | ||
| 401 | } | ||
| 402 | #[repr(transparent)] | ||
| 403 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 404 | pub struct Bsw(pub u8); | ||
| 405 | impl Bsw { | ||
| 406 | #[doc = "No action on the corresponding ODx bit"] | ||
| 407 | pub const NOACTION: Self = Self(0); | ||
| 408 | #[doc = "Sets the corresponding ODRx bit"] | ||
| 409 | pub const SET: Self = Self(0x01); | ||
| 410 | } | ||
| 411 | } | ||
| 412 | } | ||
| 413 | pub mod gpio_v2 { | ||
| 414 | use crate::generic::*; | ||
| 415 | #[doc = "General-purpose I/Os"] | ||
| 416 | #[derive(Copy, Clone)] | ||
| 417 | pub struct Gpio(pub *mut u8); | ||
| 418 | unsafe impl Send for Gpio {} | ||
| 419 | unsafe impl Sync for Gpio {} | ||
| 420 | impl Gpio { | ||
| 421 | #[doc = "GPIO port mode register"] | ||
| 422 | pub fn moder(self) -> Reg<regs::Moder, RW> { | ||
| 423 | unsafe { Reg::from_ptr(self.0.add(0usize)) } | ||
| 424 | } | ||
| 425 | #[doc = "GPIO port output type register"] | ||
| 426 | pub fn otyper(self) -> Reg<regs::Otyper, RW> { | ||
| 427 | unsafe { Reg::from_ptr(self.0.add(4usize)) } | ||
| 428 | } | ||
| 429 | #[doc = "GPIO port output speed register"] | ||
| 430 | pub fn ospeedr(self) -> Reg<regs::Ospeedr, RW> { | ||
| 431 | unsafe { Reg::from_ptr(self.0.add(8usize)) } | ||
| 432 | } | ||
| 433 | #[doc = "GPIO port pull-up/pull-down register"] | ||
| 434 | pub fn pupdr(self) -> Reg<regs::Pupdr, RW> { | ||
| 435 | unsafe { Reg::from_ptr(self.0.add(12usize)) } | ||
| 436 | } | ||
| 437 | #[doc = "GPIO port input data register"] | ||
| 438 | pub fn idr(self) -> Reg<regs::Idr, R> { | ||
| 439 | unsafe { Reg::from_ptr(self.0.add(16usize)) } | ||
| 440 | } | ||
| 441 | #[doc = "GPIO port output data register"] | ||
| 442 | pub fn odr(self) -> Reg<regs::Odr, RW> { | ||
| 443 | unsafe { Reg::from_ptr(self.0.add(20usize)) } | ||
| 444 | } | ||
| 445 | #[doc = "GPIO port bit set/reset register"] | ||
| 446 | pub fn bsrr(self) -> Reg<regs::Bsrr, W> { | ||
| 447 | unsafe { Reg::from_ptr(self.0.add(24usize)) } | ||
| 448 | } | ||
| 449 | #[doc = "GPIO port configuration lock register"] | ||
| 450 | pub fn lckr(self) -> Reg<regs::Lckr, RW> { | ||
| 451 | unsafe { Reg::from_ptr(self.0.add(28usize)) } | ||
| 452 | } | ||
| 453 | #[doc = "GPIO alternate function register (low, high)"] | ||
| 454 | pub fn afr(self, n: usize) -> Reg<regs::Afr, RW> { | ||
| 455 | assert!(n < 2usize); | ||
| 456 | unsafe { Reg::from_ptr(self.0.add(32usize + n * 4usize)) } | ||
| 78 | } | 457 | } |
| 79 | } | 458 | } |
| 80 | pub mod regs { | 459 | pub mod regs { |
| 81 | use crate::generic::*; | 460 | use crate::generic::*; |
| 82 | #[doc = "Rising Trigger selection register (EXTI_RTSR)"] | 461 | #[doc = "GPIO alternate function register"] |
| 83 | #[repr(transparent)] | 462 | #[repr(transparent)] |
| 84 | #[derive(Copy, Clone, Eq, PartialEq)] | 463 | #[derive(Copy, Clone, Eq, PartialEq)] |
| 85 | pub struct Rtsr(pub u32); | 464 | pub struct Afr(pub u32); |
| 86 | impl Rtsr { | 465 | impl Afr { |
| 87 | #[doc = "Rising trigger event configuration of line 0"] | 466 | #[doc = "Alternate function selection for port x bit y (y = 0..15)"] |
| 88 | pub fn tr(&self, n: usize) -> super::vals::Tr { | 467 | pub fn afr(&self, n: usize) -> super::vals::Afr { |
| 89 | assert!(n < 23usize); | 468 | assert!(n < 8usize); |
| 469 | let offs = 0usize + n * 4usize; | ||
| 470 | let val = (self.0 >> offs) & 0x0f; | ||
| 471 | super::vals::Afr(val as u8) | ||
| 472 | } | ||
| 473 | #[doc = "Alternate function selection for port x bit y (y = 0..15)"] | ||
| 474 | pub fn set_afr(&mut self, n: usize, val: super::vals::Afr) { | ||
| 475 | assert!(n < 8usize); | ||
| 476 | let offs = 0usize + n * 4usize; | ||
| 477 | self.0 = (self.0 & !(0x0f << offs)) | (((val.0 as u32) & 0x0f) << offs); | ||
| 478 | } | ||
| 479 | } | ||
| 480 | impl Default for Afr { | ||
| 481 | fn default() -> Afr { | ||
| 482 | Afr(0) | ||
| 483 | } | ||
| 484 | } | ||
| 485 | #[doc = "GPIO port output data register"] | ||
| 486 | #[repr(transparent)] | ||
| 487 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 488 | pub struct Odr(pub u32); | ||
| 489 | impl Odr { | ||
| 490 | #[doc = "Port output data (y = 0..15)"] | ||
| 491 | pub fn odr(&self, n: usize) -> super::vals::Odr { | ||
| 492 | assert!(n < 16usize); | ||
| 90 | let offs = 0usize + n * 1usize; | 493 | let offs = 0usize + n * 1usize; |
| 91 | let val = (self.0 >> offs) & 0x01; | 494 | let val = (self.0 >> offs) & 0x01; |
| 92 | super::vals::Tr(val as u8) | 495 | super::vals::Odr(val as u8) |
| 93 | } | 496 | } |
| 94 | #[doc = "Rising trigger event configuration of line 0"] | 497 | #[doc = "Port output data (y = 0..15)"] |
| 95 | pub fn set_tr(&mut self, n: usize, val: super::vals::Tr) { | 498 | pub fn set_odr(&mut self, n: usize, val: super::vals::Odr) { |
| 96 | assert!(n < 23usize); | 499 | assert!(n < 16usize); |
| 97 | let offs = 0usize + n * 1usize; | 500 | let offs = 0usize + n * 1usize; |
| 98 | self.0 = (self.0 & !(0x01 << offs)) | (((val.0 as u32) & 0x01) << offs); | 501 | self.0 = (self.0 & !(0x01 << offs)) | (((val.0 as u32) & 0x01) << offs); |
| 99 | } | 502 | } |
| 100 | } | 503 | } |
| 101 | impl Default for Rtsr { | 504 | impl Default for Odr { |
| 102 | fn default() -> Rtsr { | 505 | fn default() -> Odr { |
| 103 | Rtsr(0) | 506 | Odr(0) |
| 104 | } | 507 | } |
| 105 | } | 508 | } |
| 106 | #[doc = "Falling Trigger selection register (EXTI_FTSR)"] | 509 | #[doc = "GPIO port output type register"] |
| 107 | #[repr(transparent)] | 510 | #[repr(transparent)] |
| 108 | #[derive(Copy, Clone, Eq, PartialEq)] | 511 | #[derive(Copy, Clone, Eq, PartialEq)] |
| 109 | pub struct Ftsr(pub u32); | 512 | pub struct Otyper(pub u32); |
| 110 | impl Ftsr { | 513 | impl Otyper { |
| 111 | #[doc = "Falling trigger event configuration of line 0"] | 514 | #[doc = "Port x configuration bits (y = 0..15)"] |
| 112 | pub fn tr(&self, n: usize) -> super::vals::Tr { | 515 | pub fn ot(&self, n: usize) -> super::vals::Ot { |
| 113 | assert!(n < 23usize); | 516 | assert!(n < 16usize); |
| 114 | let offs = 0usize + n * 1usize; | 517 | let offs = 0usize + n * 1usize; |
| 115 | let val = (self.0 >> offs) & 0x01; | 518 | let val = (self.0 >> offs) & 0x01; |
| 116 | super::vals::Tr(val as u8) | 519 | super::vals::Ot(val as u8) |
| 117 | } | 520 | } |
| 118 | #[doc = "Falling trigger event configuration of line 0"] | 521 | #[doc = "Port x configuration bits (y = 0..15)"] |
| 119 | pub fn set_tr(&mut self, n: usize, val: super::vals::Tr) { | 522 | pub fn set_ot(&mut self, n: usize, val: super::vals::Ot) { |
| 120 | assert!(n < 23usize); | 523 | assert!(n < 16usize); |
| 121 | let offs = 0usize + n * 1usize; | 524 | let offs = 0usize + n * 1usize; |
| 122 | self.0 = (self.0 & !(0x01 << offs)) | (((val.0 as u32) & 0x01) << offs); | 525 | self.0 = (self.0 & !(0x01 << offs)) | (((val.0 as u32) & 0x01) << offs); |
| 123 | } | 526 | } |
| 124 | } | 527 | } |
| 125 | impl Default for Ftsr { | 528 | impl Default for Otyper { |
| 126 | fn default() -> Ftsr { | 529 | fn default() -> Otyper { |
| 127 | Ftsr(0) | 530 | Otyper(0) |
| 128 | } | 531 | } |
| 129 | } | 532 | } |
| 130 | #[doc = "Pending register (EXTI_PR)"] | 533 | #[doc = "GPIO port pull-up/pull-down register"] |
| 131 | #[repr(transparent)] | 534 | #[repr(transparent)] |
| 132 | #[derive(Copy, Clone, Eq, PartialEq)] | 535 | #[derive(Copy, Clone, Eq, PartialEq)] |
| 133 | pub struct Pr(pub u32); | 536 | pub struct Pupdr(pub u32); |
| 134 | impl Pr { | 537 | impl Pupdr { |
| 135 | #[doc = "Pending bit 0"] | 538 | #[doc = "Port x configuration bits (y = 0..15)"] |
| 136 | pub fn pr(&self, n: usize) -> bool { | 539 | pub fn pupdr(&self, n: usize) -> super::vals::Pupdr { |
| 137 | assert!(n < 23usize); | 540 | assert!(n < 16usize); |
| 138 | let offs = 0usize + n * 1usize; | 541 | let offs = 0usize + n * 2usize; |
| 139 | let val = (self.0 >> offs) & 0x01; | 542 | let val = (self.0 >> offs) & 0x03; |
| 140 | val != 0 | 543 | super::vals::Pupdr(val as u8) |
| 141 | } | 544 | } |
| 142 | #[doc = "Pending bit 0"] | 545 | #[doc = "Port x configuration bits (y = 0..15)"] |
| 143 | pub fn set_pr(&mut self, n: usize, val: bool) { | 546 | pub fn set_pupdr(&mut self, n: usize, val: super::vals::Pupdr) { |
| 144 | assert!(n < 23usize); | 547 | assert!(n < 16usize); |
| 145 | let offs = 0usize + n * 1usize; | 548 | let offs = 0usize + n * 2usize; |
| 146 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | 549 | self.0 = (self.0 & !(0x03 << offs)) | (((val.0 as u32) & 0x03) << offs); |
| 147 | } | 550 | } |
| 148 | } | 551 | } |
| 149 | impl Default for Pr { | 552 | impl Default for Pupdr { |
| 150 | fn default() -> Pr { | 553 | fn default() -> Pupdr { |
| 151 | Pr(0) | 554 | Pupdr(0) |
| 152 | } | 555 | } |
| 153 | } | 556 | } |
| 154 | #[doc = "Software interrupt event register (EXTI_SWIER)"] | 557 | #[doc = "GPIO port output speed register"] |
| 155 | #[repr(transparent)] | 558 | #[repr(transparent)] |
| 156 | #[derive(Copy, Clone, Eq, PartialEq)] | 559 | #[derive(Copy, Clone, Eq, PartialEq)] |
| 157 | pub struct Swier(pub u32); | 560 | pub struct Ospeedr(pub u32); |
| 158 | impl Swier { | 561 | impl Ospeedr { |
| 159 | #[doc = "Software Interrupt on line 0"] | 562 | #[doc = "Port x configuration bits (y = 0..15)"] |
| 160 | pub fn swier(&self, n: usize) -> bool { | 563 | pub fn ospeedr(&self, n: usize) -> super::vals::Ospeedr { |
| 161 | assert!(n < 23usize); | 564 | assert!(n < 16usize); |
| 565 | let offs = 0usize + n * 2usize; | ||
| 566 | let val = (self.0 >> offs) & 0x03; | ||
| 567 | super::vals::Ospeedr(val as u8) | ||
| 568 | } | ||
| 569 | #[doc = "Port x configuration bits (y = 0..15)"] | ||
| 570 | pub fn set_ospeedr(&mut self, n: usize, val: super::vals::Ospeedr) { | ||
| 571 | assert!(n < 16usize); | ||
| 572 | let offs = 0usize + n * 2usize; | ||
| 573 | self.0 = (self.0 & !(0x03 << offs)) | (((val.0 as u32) & 0x03) << offs); | ||
| 574 | } | ||
| 575 | } | ||
| 576 | impl Default for Ospeedr { | ||
| 577 | fn default() -> Ospeedr { | ||
| 578 | Ospeedr(0) | ||
| 579 | } | ||
| 580 | } | ||
| 581 | #[doc = "GPIO port configuration lock register"] | ||
| 582 | #[repr(transparent)] | ||
| 583 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 584 | pub struct Lckr(pub u32); | ||
| 585 | impl Lckr { | ||
| 586 | #[doc = "Port x lock bit y (y= 0..15)"] | ||
| 587 | pub fn lck(&self, n: usize) -> super::vals::Lck { | ||
| 588 | assert!(n < 16usize); | ||
| 162 | let offs = 0usize + n * 1usize; | 589 | let offs = 0usize + n * 1usize; |
| 163 | let val = (self.0 >> offs) & 0x01; | 590 | let val = (self.0 >> offs) & 0x01; |
| 164 | val != 0 | 591 | super::vals::Lck(val as u8) |
| 165 | } | 592 | } |
| 166 | #[doc = "Software Interrupt on line 0"] | 593 | #[doc = "Port x lock bit y (y= 0..15)"] |
| 167 | pub fn set_swier(&mut self, n: usize, val: bool) { | 594 | pub fn set_lck(&mut self, n: usize, val: super::vals::Lck) { |
| 168 | assert!(n < 23usize); | 595 | assert!(n < 16usize); |
| 169 | let offs = 0usize + n * 1usize; | 596 | let offs = 0usize + n * 1usize; |
| 170 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | 597 | self.0 = (self.0 & !(0x01 << offs)) | (((val.0 as u32) & 0x01) << offs); |
| 598 | } | ||
| 599 | #[doc = "Port x lock bit y (y= 0..15)"] | ||
| 600 | pub const fn lckk(&self) -> super::vals::Lckk { | ||
| 601 | let val = (self.0 >> 16usize) & 0x01; | ||
| 602 | super::vals::Lckk(val as u8) | ||
| 603 | } | ||
| 604 | #[doc = "Port x lock bit y (y= 0..15)"] | ||
| 605 | pub fn set_lckk(&mut self, val: super::vals::Lckk) { | ||
| 606 | self.0 = (self.0 & !(0x01 << 16usize)) | (((val.0 as u32) & 0x01) << 16usize); | ||
| 171 | } | 607 | } |
| 172 | } | 608 | } |
| 173 | impl Default for Swier { | 609 | impl Default for Lckr { |
| 174 | fn default() -> Swier { | 610 | fn default() -> Lckr { |
| 175 | Swier(0) | 611 | Lckr(0) |
| 176 | } | 612 | } |
| 177 | } | 613 | } |
| 178 | #[doc = "Interrupt mask register (EXTI_IMR)"] | 614 | #[doc = "GPIO port mode register"] |
| 179 | #[repr(transparent)] | 615 | #[repr(transparent)] |
| 180 | #[derive(Copy, Clone, Eq, PartialEq)] | 616 | #[derive(Copy, Clone, Eq, PartialEq)] |
| 181 | pub struct Imr(pub u32); | 617 | pub struct Moder(pub u32); |
| 182 | impl Imr { | 618 | impl Moder { |
| 183 | #[doc = "Interrupt Mask on line 0"] | 619 | #[doc = "Port x configuration bits (y = 0..15)"] |
| 184 | pub fn mr(&self, n: usize) -> super::vals::Mr { | 620 | pub fn moder(&self, n: usize) -> super::vals::Moder { |
| 185 | assert!(n < 23usize); | 621 | assert!(n < 16usize); |
| 622 | let offs = 0usize + n * 2usize; | ||
| 623 | let val = (self.0 >> offs) & 0x03; | ||
| 624 | super::vals::Moder(val as u8) | ||
| 625 | } | ||
| 626 | #[doc = "Port x configuration bits (y = 0..15)"] | ||
| 627 | pub fn set_moder(&mut self, n: usize, val: super::vals::Moder) { | ||
| 628 | assert!(n < 16usize); | ||
| 629 | let offs = 0usize + n * 2usize; | ||
| 630 | self.0 = (self.0 & !(0x03 << offs)) | (((val.0 as u32) & 0x03) << offs); | ||
| 631 | } | ||
| 632 | } | ||
| 633 | impl Default for Moder { | ||
| 634 | fn default() -> Moder { | ||
| 635 | Moder(0) | ||
| 636 | } | ||
| 637 | } | ||
| 638 | #[doc = "GPIO port bit set/reset register"] | ||
| 639 | #[repr(transparent)] | ||
| 640 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 641 | pub struct Bsrr(pub u32); | ||
| 642 | impl Bsrr { | ||
| 643 | #[doc = "Port x set bit y (y= 0..15)"] | ||
| 644 | pub fn bs(&self, n: usize) -> bool { | ||
| 645 | assert!(n < 16usize); | ||
| 186 | let offs = 0usize + n * 1usize; | 646 | let offs = 0usize + n * 1usize; |
| 187 | let val = (self.0 >> offs) & 0x01; | 647 | let val = (self.0 >> offs) & 0x01; |
| 188 | super::vals::Mr(val as u8) | 648 | val != 0 |
| 189 | } | 649 | } |
| 190 | #[doc = "Interrupt Mask on line 0"] | 650 | #[doc = "Port x set bit y (y= 0..15)"] |
| 191 | pub fn set_mr(&mut self, n: usize, val: super::vals::Mr) { | 651 | pub fn set_bs(&mut self, n: usize, val: bool) { |
| 192 | assert!(n < 23usize); | 652 | assert!(n < 16usize); |
| 193 | let offs = 0usize + n * 1usize; | 653 | let offs = 0usize + n * 1usize; |
| 194 | self.0 = (self.0 & !(0x01 << offs)) | (((val.0 as u32) & 0x01) << offs); | 654 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); |
| 655 | } | ||
| 656 | #[doc = "Port x set bit y (y= 0..15)"] | ||
| 657 | pub fn br(&self, n: usize) -> bool { | ||
| 658 | assert!(n < 16usize); | ||
| 659 | let offs = 16usize + n * 1usize; | ||
| 660 | let val = (self.0 >> offs) & 0x01; | ||
| 661 | val != 0 | ||
| 662 | } | ||
| 663 | #[doc = "Port x set bit y (y= 0..15)"] | ||
| 664 | pub fn set_br(&mut self, n: usize, val: bool) { | ||
| 665 | assert!(n < 16usize); | ||
| 666 | let offs = 16usize + n * 1usize; | ||
| 667 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | ||
| 195 | } | 668 | } |
| 196 | } | 669 | } |
| 197 | impl Default for Imr { | 670 | impl Default for Bsrr { |
| 198 | fn default() -> Imr { | 671 | fn default() -> Bsrr { |
| 199 | Imr(0) | 672 | Bsrr(0) |
| 200 | } | 673 | } |
| 201 | } | 674 | } |
| 202 | #[doc = "Event mask register (EXTI_EMR)"] | 675 | #[doc = "GPIO port input data register"] |
| 203 | #[repr(transparent)] | 676 | #[repr(transparent)] |
| 204 | #[derive(Copy, Clone, Eq, PartialEq)] | 677 | #[derive(Copy, Clone, Eq, PartialEq)] |
| 205 | pub struct Emr(pub u32); | 678 | pub struct Idr(pub u32); |
| 206 | impl Emr { | 679 | impl Idr { |
| 207 | #[doc = "Event Mask on line 0"] | 680 | #[doc = "Port input data (y = 0..15)"] |
| 208 | pub fn mr(&self, n: usize) -> super::vals::Mr { | 681 | pub fn idr(&self, n: usize) -> super::vals::Idr { |
| 209 | assert!(n < 23usize); | 682 | assert!(n < 16usize); |
| 210 | let offs = 0usize + n * 1usize; | 683 | let offs = 0usize + n * 1usize; |
| 211 | let val = (self.0 >> offs) & 0x01; | 684 | let val = (self.0 >> offs) & 0x01; |
| 212 | super::vals::Mr(val as u8) | 685 | super::vals::Idr(val as u8) |
| 213 | } | 686 | } |
| 214 | #[doc = "Event Mask on line 0"] | 687 | #[doc = "Port input data (y = 0..15)"] |
| 215 | pub fn set_mr(&mut self, n: usize, val: super::vals::Mr) { | 688 | pub fn set_idr(&mut self, n: usize, val: super::vals::Idr) { |
| 216 | assert!(n < 23usize); | 689 | assert!(n < 16usize); |
| 217 | let offs = 0usize + n * 1usize; | 690 | let offs = 0usize + n * 1usize; |
| 218 | self.0 = (self.0 & !(0x01 << offs)) | (((val.0 as u32) & 0x01) << offs); | 691 | self.0 = (self.0 & !(0x01 << offs)) | (((val.0 as u32) & 0x01) << offs); |
| 219 | } | 692 | } |
| 220 | } | 693 | } |
| 221 | impl Default for Emr { | 694 | impl Default for Idr { |
| 222 | fn default() -> Emr { | 695 | fn default() -> Idr { |
| 223 | Emr(0) | 696 | Idr(0) |
| 224 | } | 697 | } |
| 225 | } | 698 | } |
| 226 | } | 699 | } |
| 700 | pub mod vals { | ||
| 701 | use crate::generic::*; | ||
| 702 | #[repr(transparent)] | ||
| 703 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 704 | pub struct Ot(pub u8); | ||
| 705 | impl Ot { | ||
| 706 | #[doc = "Output push-pull (reset state)"] | ||
| 707 | pub const PUSHPULL: Self = Self(0); | ||
| 708 | #[doc = "Output open-drain"] | ||
| 709 | pub const OPENDRAIN: Self = Self(0x01); | ||
| 710 | } | ||
| 711 | #[repr(transparent)] | ||
| 712 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 713 | pub struct Pupdr(pub u8); | ||
| 714 | impl Pupdr { | ||
| 715 | #[doc = "No pull-up, pull-down"] | ||
| 716 | pub const FLOATING: Self = Self(0); | ||
| 717 | #[doc = "Pull-up"] | ||
| 718 | pub const PULLUP: Self = Self(0x01); | ||
| 719 | #[doc = "Pull-down"] | ||
| 720 | pub const PULLDOWN: Self = Self(0x02); | ||
| 721 | } | ||
| 722 | #[repr(transparent)] | ||
| 723 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 724 | pub struct Bsw(pub u8); | ||
| 725 | impl Bsw { | ||
| 726 | #[doc = "Sets the corresponding ODRx bit"] | ||
| 727 | pub const SET: Self = Self(0x01); | ||
| 728 | } | ||
| 729 | #[repr(transparent)] | ||
| 730 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 731 | pub struct Moder(pub u8); | ||
| 732 | impl Moder { | ||
| 733 | #[doc = "Input mode (reset state)"] | ||
| 734 | pub const INPUT: Self = Self(0); | ||
| 735 | #[doc = "General purpose output mode"] | ||
| 736 | pub const OUTPUT: Self = Self(0x01); | ||
| 737 | #[doc = "Alternate function mode"] | ||
| 738 | pub const ALTERNATE: Self = Self(0x02); | ||
| 739 | #[doc = "Analog mode"] | ||
| 740 | pub const ANALOG: Self = Self(0x03); | ||
| 741 | } | ||
| 742 | #[repr(transparent)] | ||
| 743 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 744 | pub struct Idr(pub u8); | ||
| 745 | impl Idr { | ||
| 746 | #[doc = "Input is logic low"] | ||
| 747 | pub const LOW: Self = Self(0); | ||
| 748 | #[doc = "Input is logic high"] | ||
| 749 | pub const HIGH: Self = Self(0x01); | ||
| 750 | } | ||
| 751 | #[repr(transparent)] | ||
| 752 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 753 | pub struct Brw(pub u8); | ||
| 754 | impl Brw { | ||
| 755 | #[doc = "Resets the corresponding ODRx bit"] | ||
| 756 | pub const RESET: Self = Self(0x01); | ||
| 757 | } | ||
| 758 | #[repr(transparent)] | ||
| 759 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 760 | pub struct Lck(pub u8); | ||
| 761 | impl Lck { | ||
| 762 | #[doc = "Port configuration not locked"] | ||
| 763 | pub const UNLOCKED: Self = Self(0); | ||
| 764 | #[doc = "Port configuration locked"] | ||
| 765 | pub const LOCKED: Self = Self(0x01); | ||
| 766 | } | ||
| 767 | #[repr(transparent)] | ||
| 768 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 769 | pub struct Lckk(pub u8); | ||
| 770 | impl Lckk { | ||
| 771 | #[doc = "Port configuration lock key not active"] | ||
| 772 | pub const NOTACTIVE: Self = Self(0); | ||
| 773 | #[doc = "Port configuration lock key active"] | ||
| 774 | pub const ACTIVE: Self = Self(0x01); | ||
| 775 | } | ||
| 776 | #[repr(transparent)] | ||
| 777 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 778 | pub struct Afr(pub u8); | ||
| 779 | impl Afr { | ||
| 780 | #[doc = "AF0"] | ||
| 781 | pub const AF0: Self = Self(0); | ||
| 782 | #[doc = "AF1"] | ||
| 783 | pub const AF1: Self = Self(0x01); | ||
| 784 | #[doc = "AF2"] | ||
| 785 | pub const AF2: Self = Self(0x02); | ||
| 786 | #[doc = "AF3"] | ||
| 787 | pub const AF3: Self = Self(0x03); | ||
| 788 | #[doc = "AF4"] | ||
| 789 | pub const AF4: Self = Self(0x04); | ||
| 790 | #[doc = "AF5"] | ||
| 791 | pub const AF5: Self = Self(0x05); | ||
| 792 | #[doc = "AF6"] | ||
| 793 | pub const AF6: Self = Self(0x06); | ||
| 794 | #[doc = "AF7"] | ||
| 795 | pub const AF7: Self = Self(0x07); | ||
| 796 | #[doc = "AF8"] | ||
| 797 | pub const AF8: Self = Self(0x08); | ||
| 798 | #[doc = "AF9"] | ||
| 799 | pub const AF9: Self = Self(0x09); | ||
| 800 | #[doc = "AF10"] | ||
| 801 | pub const AF10: Self = Self(0x0a); | ||
| 802 | #[doc = "AF11"] | ||
| 803 | pub const AF11: Self = Self(0x0b); | ||
| 804 | #[doc = "AF12"] | ||
| 805 | pub const AF12: Self = Self(0x0c); | ||
| 806 | #[doc = "AF13"] | ||
| 807 | pub const AF13: Self = Self(0x0d); | ||
| 808 | #[doc = "AF14"] | ||
| 809 | pub const AF14: Self = Self(0x0e); | ||
| 810 | #[doc = "AF15"] | ||
| 811 | pub const AF15: Self = Self(0x0f); | ||
| 812 | } | ||
| 813 | #[repr(transparent)] | ||
| 814 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 815 | pub struct Ospeedr(pub u8); | ||
| 816 | impl Ospeedr { | ||
| 817 | #[doc = "Low speed"] | ||
| 818 | pub const LOWSPEED: Self = Self(0); | ||
| 819 | #[doc = "Medium speed"] | ||
| 820 | pub const MEDIUMSPEED: Self = Self(0x01); | ||
| 821 | #[doc = "High speed"] | ||
| 822 | pub const HIGHSPEED: Self = Self(0x02); | ||
| 823 | #[doc = "Very high speed"] | ||
| 824 | pub const VERYHIGHSPEED: Self = Self(0x03); | ||
| 825 | } | ||
| 826 | #[repr(transparent)] | ||
| 827 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 828 | pub struct Odr(pub u8); | ||
| 829 | impl Odr { | ||
| 830 | #[doc = "Set output to logic low"] | ||
| 831 | pub const LOW: Self = Self(0); | ||
| 832 | #[doc = "Set output to logic high"] | ||
| 833 | pub const HIGH: Self = Self(0x01); | ||
| 834 | } | ||
| 835 | } | ||
| 227 | } | 836 | } |
| 228 | pub mod syscfg_f4 { | 837 | pub mod syscfg_l4 { |
| 229 | use crate::generic::*; | 838 | use crate::generic::*; |
| 230 | #[doc = "System configuration controller"] | 839 | #[doc = "System configuration controller"] |
| 231 | #[derive(Copy, Clone)] | 840 | #[derive(Copy, Clone)] |
| @@ -234,114 +843,236 @@ pub mod syscfg_f4 { | |||
| 234 | unsafe impl Sync for Syscfg {} | 843 | unsafe impl Sync for Syscfg {} |
| 235 | impl Syscfg { | 844 | impl Syscfg { |
| 236 | #[doc = "memory remap register"] | 845 | #[doc = "memory remap register"] |
| 237 | pub fn memrm(self) -> Reg<regs::Memrm, RW> { | 846 | pub fn memrmp(self) -> Reg<regs::Memrmp, RW> { |
| 238 | unsafe { Reg::from_ptr(self.0.add(0usize)) } | 847 | unsafe { Reg::from_ptr(self.0.add(0usize)) } |
| 239 | } | 848 | } |
| 240 | #[doc = "peripheral mode configuration register"] | 849 | #[doc = "configuration register 1"] |
| 241 | pub fn pmc(self) -> Reg<regs::Pmc, RW> { | 850 | pub fn cfgr1(self) -> Reg<regs::Cfgr1, RW> { |
| 242 | unsafe { Reg::from_ptr(self.0.add(4usize)) } | 851 | unsafe { Reg::from_ptr(self.0.add(4usize)) } |
| 243 | } | 852 | } |
| 244 | #[doc = "external interrupt configuration register"] | 853 | #[doc = "external interrupt configuration register 1"] |
| 245 | pub fn exticr(self, n: usize) -> Reg<regs::Exticr, RW> { | 854 | pub fn exticr(self, n: usize) -> Reg<regs::Exticr, RW> { |
| 246 | assert!(n < 4usize); | 855 | assert!(n < 4usize); |
| 247 | unsafe { Reg::from_ptr(self.0.add(8usize + n * 4usize)) } | 856 | unsafe { Reg::from_ptr(self.0.add(8usize + n * 4usize)) } |
| 248 | } | 857 | } |
| 249 | #[doc = "Compensation cell control register"] | 858 | #[doc = "SCSR"] |
| 250 | pub fn cmpcr(self) -> Reg<regs::Cmpcr, R> { | 859 | pub fn scsr(self) -> Reg<regs::Scsr, RW> { |
| 860 | unsafe { Reg::from_ptr(self.0.add(24usize)) } | ||
| 861 | } | ||
| 862 | #[doc = "CFGR2"] | ||
| 863 | pub fn cfgr2(self) -> Reg<regs::Cfgr2, RW> { | ||
| 864 | unsafe { Reg::from_ptr(self.0.add(28usize)) } | ||
| 865 | } | ||
| 866 | #[doc = "SWPR"] | ||
| 867 | pub fn swpr(self) -> Reg<regs::Swpr, W> { | ||
| 251 | unsafe { Reg::from_ptr(self.0.add(32usize)) } | 868 | unsafe { Reg::from_ptr(self.0.add(32usize)) } |
| 252 | } | 869 | } |
| 870 | #[doc = "SKR"] | ||
| 871 | pub fn skr(self) -> Reg<regs::Skr, W> { | ||
| 872 | unsafe { Reg::from_ptr(self.0.add(36usize)) } | ||
| 873 | } | ||
| 253 | } | 874 | } |
| 254 | pub mod regs { | 875 | pub mod regs { |
| 255 | use crate::generic::*; | 876 | use crate::generic::*; |
| 256 | #[doc = "peripheral mode configuration register"] | 877 | #[doc = "SCSR"] |
| 257 | #[repr(transparent)] | 878 | #[repr(transparent)] |
| 258 | #[derive(Copy, Clone, Eq, PartialEq)] | 879 | #[derive(Copy, Clone, Eq, PartialEq)] |
| 259 | pub struct Pmc(pub u32); | 880 | pub struct Scsr(pub u32); |
| 260 | impl Pmc { | 881 | impl Scsr { |
| 261 | #[doc = "ADC1DC2"] | 882 | #[doc = "SRAM2 Erase"] |
| 262 | pub const fn adc1dc2(&self) -> bool { | 883 | pub const fn sram2er(&self) -> bool { |
| 263 | let val = (self.0 >> 16usize) & 0x01; | 884 | let val = (self.0 >> 0usize) & 0x01; |
| 264 | val != 0 | 885 | val != 0 |
| 265 | } | 886 | } |
| 266 | #[doc = "ADC1DC2"] | 887 | #[doc = "SRAM2 Erase"] |
| 267 | pub fn set_adc1dc2(&mut self, val: bool) { | 888 | pub fn set_sram2er(&mut self, val: bool) { |
| 268 | self.0 = (self.0 & !(0x01 << 16usize)) | (((val as u32) & 0x01) << 16usize); | 889 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); |
| 269 | } | 890 | } |
| 270 | #[doc = "ADC2DC2"] | 891 | #[doc = "SRAM2 busy by erase operation"] |
| 271 | pub const fn adc2dc2(&self) -> bool { | 892 | pub const fn sram2bsy(&self) -> bool { |
| 272 | let val = (self.0 >> 17usize) & 0x01; | 893 | let val = (self.0 >> 1usize) & 0x01; |
| 273 | val != 0 | 894 | val != 0 |
| 274 | } | 895 | } |
| 275 | #[doc = "ADC2DC2"] | 896 | #[doc = "SRAM2 busy by erase operation"] |
| 276 | pub fn set_adc2dc2(&mut self, val: bool) { | 897 | pub fn set_sram2bsy(&mut self, val: bool) { |
| 277 | self.0 = (self.0 & !(0x01 << 17usize)) | (((val as u32) & 0x01) << 17usize); | 898 | self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize); |
| 278 | } | 899 | } |
| 279 | #[doc = "ADC3DC2"] | 900 | } |
| 280 | pub const fn adc3dc2(&self) -> bool { | 901 | impl Default for Scsr { |
| 281 | let val = (self.0 >> 18usize) & 0x01; | 902 | fn default() -> Scsr { |
| 903 | Scsr(0) | ||
| 904 | } | ||
| 905 | } | ||
| 906 | #[doc = "CFGR2"] | ||
| 907 | #[repr(transparent)] | ||
| 908 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 909 | pub struct Cfgr2(pub u32); | ||
| 910 | impl Cfgr2 { | ||
| 911 | #[doc = "Cortex LOCKUP (Hardfault) output enable bit"] | ||
| 912 | pub const fn cll(&self) -> bool { | ||
| 913 | let val = (self.0 >> 0usize) & 0x01; | ||
| 282 | val != 0 | 914 | val != 0 |
| 283 | } | 915 | } |
| 284 | #[doc = "ADC3DC2"] | 916 | #[doc = "Cortex LOCKUP (Hardfault) output enable bit"] |
| 285 | pub fn set_adc3dc2(&mut self, val: bool) { | 917 | pub fn set_cll(&mut self, val: bool) { |
| 286 | self.0 = (self.0 & !(0x01 << 18usize)) | (((val as u32) & 0x01) << 18usize); | 918 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); |
| 287 | } | 919 | } |
| 288 | #[doc = "Ethernet PHY interface selection"] | 920 | #[doc = "SRAM2 parity lock bit"] |
| 289 | pub const fn mii_rmii_sel(&self) -> bool { | 921 | pub const fn spl(&self) -> bool { |
| 290 | let val = (self.0 >> 23usize) & 0x01; | 922 | let val = (self.0 >> 1usize) & 0x01; |
| 291 | val != 0 | 923 | val != 0 |
| 292 | } | 924 | } |
| 293 | #[doc = "Ethernet PHY interface selection"] | 925 | #[doc = "SRAM2 parity lock bit"] |
| 294 | pub fn set_mii_rmii_sel(&mut self, val: bool) { | 926 | pub fn set_spl(&mut self, val: bool) { |
| 295 | self.0 = (self.0 & !(0x01 << 23usize)) | (((val as u32) & 0x01) << 23usize); | 927 | self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize); |
| 928 | } | ||
| 929 | #[doc = "PVD lock enable bit"] | ||
| 930 | pub const fn pvdl(&self) -> bool { | ||
| 931 | let val = (self.0 >> 2usize) & 0x01; | ||
| 932 | val != 0 | ||
| 933 | } | ||
| 934 | #[doc = "PVD lock enable bit"] | ||
| 935 | pub fn set_pvdl(&mut self, val: bool) { | ||
| 936 | self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize); | ||
| 937 | } | ||
| 938 | #[doc = "ECC Lock"] | ||
| 939 | pub const fn eccl(&self) -> bool { | ||
| 940 | let val = (self.0 >> 3usize) & 0x01; | ||
| 941 | val != 0 | ||
| 942 | } | ||
| 943 | #[doc = "ECC Lock"] | ||
| 944 | pub fn set_eccl(&mut self, val: bool) { | ||
| 945 | self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize); | ||
| 946 | } | ||
| 947 | #[doc = "SRAM2 parity error flag"] | ||
| 948 | pub const fn spf(&self) -> bool { | ||
| 949 | let val = (self.0 >> 8usize) & 0x01; | ||
| 950 | val != 0 | ||
| 951 | } | ||
| 952 | #[doc = "SRAM2 parity error flag"] | ||
| 953 | pub fn set_spf(&mut self, val: bool) { | ||
| 954 | self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize); | ||
| 296 | } | 955 | } |
| 297 | } | 956 | } |
| 298 | impl Default for Pmc { | 957 | impl Default for Cfgr2 { |
| 299 | fn default() -> Pmc { | 958 | fn default() -> Cfgr2 { |
| 300 | Pmc(0) | 959 | Cfgr2(0) |
| 301 | } | 960 | } |
| 302 | } | 961 | } |
| 303 | #[doc = "Compensation cell control register"] | 962 | #[doc = "configuration register 1"] |
| 304 | #[repr(transparent)] | 963 | #[repr(transparent)] |
| 305 | #[derive(Copy, Clone, Eq, PartialEq)] | 964 | #[derive(Copy, Clone, Eq, PartialEq)] |
| 306 | pub struct Cmpcr(pub u32); | 965 | pub struct Cfgr1(pub u32); |
| 307 | impl Cmpcr { | 966 | impl Cfgr1 { |
| 308 | #[doc = "Compensation cell power-down"] | 967 | #[doc = "Firewall disable"] |
| 309 | pub const fn cmp_pd(&self) -> bool { | 968 | pub const fn fwdis(&self) -> bool { |
| 310 | let val = (self.0 >> 0usize) & 0x01; | 969 | let val = (self.0 >> 0usize) & 0x01; |
| 311 | val != 0 | 970 | val != 0 |
| 312 | } | 971 | } |
| 313 | #[doc = "Compensation cell power-down"] | 972 | #[doc = "Firewall disable"] |
| 314 | pub fn set_cmp_pd(&mut self, val: bool) { | 973 | pub fn set_fwdis(&mut self, val: bool) { |
| 315 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); | 974 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); |
| 316 | } | 975 | } |
| 317 | #[doc = "READY"] | 976 | #[doc = "I/O analog switch voltage booster enable"] |
| 318 | pub const fn ready(&self) -> bool { | 977 | pub const fn boosten(&self) -> bool { |
| 319 | let val = (self.0 >> 8usize) & 0x01; | 978 | let val = (self.0 >> 8usize) & 0x01; |
| 320 | val != 0 | 979 | val != 0 |
| 321 | } | 980 | } |
| 322 | #[doc = "READY"] | 981 | #[doc = "I/O analog switch voltage booster enable"] |
| 323 | pub fn set_ready(&mut self, val: bool) { | 982 | pub fn set_boosten(&mut self, val: bool) { |
| 324 | self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize); | 983 | self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize); |
| 325 | } | 984 | } |
| 985 | #[doc = "Fast-mode Plus (Fm+) driving capability activation on PB6"] | ||
| 986 | pub const fn i2c_pb6_fmp(&self) -> bool { | ||
| 987 | let val = (self.0 >> 16usize) & 0x01; | ||
| 988 | val != 0 | ||
| 989 | } | ||
| 990 | #[doc = "Fast-mode Plus (Fm+) driving capability activation on PB6"] | ||
| 991 | pub fn set_i2c_pb6_fmp(&mut self, val: bool) { | ||
| 992 | self.0 = (self.0 & !(0x01 << 16usize)) | (((val as u32) & 0x01) << 16usize); | ||
| 993 | } | ||
| 994 | #[doc = "Fast-mode Plus (Fm+) driving capability activation on PB7"] | ||
| 995 | pub const fn i2c_pb7_fmp(&self) -> bool { | ||
| 996 | let val = (self.0 >> 17usize) & 0x01; | ||
| 997 | val != 0 | ||
| 998 | } | ||
| 999 | #[doc = "Fast-mode Plus (Fm+) driving capability activation on PB7"] | ||
| 1000 | pub fn set_i2c_pb7_fmp(&mut self, val: bool) { | ||
| 1001 | self.0 = (self.0 & !(0x01 << 17usize)) | (((val as u32) & 0x01) << 17usize); | ||
| 1002 | } | ||
| 1003 | #[doc = "Fast-mode Plus (Fm+) driving capability activation on PB8"] | ||
| 1004 | pub const fn i2c_pb8_fmp(&self) -> bool { | ||
| 1005 | let val = (self.0 >> 18usize) & 0x01; | ||
| 1006 | val != 0 | ||
| 1007 | } | ||
| 1008 | #[doc = "Fast-mode Plus (Fm+) driving capability activation on PB8"] | ||
| 1009 | pub fn set_i2c_pb8_fmp(&mut self, val: bool) { | ||
| 1010 | self.0 = (self.0 & !(0x01 << 18usize)) | (((val as u32) & 0x01) << 18usize); | ||
| 1011 | } | ||
| 1012 | #[doc = "Fast-mode Plus (Fm+) driving capability activation on PB9"] | ||
| 1013 | pub const fn i2c_pb9_fmp(&self) -> bool { | ||
| 1014 | let val = (self.0 >> 19usize) & 0x01; | ||
| 1015 | val != 0 | ||
| 1016 | } | ||
| 1017 | #[doc = "Fast-mode Plus (Fm+) driving capability activation on PB9"] | ||
| 1018 | pub fn set_i2c_pb9_fmp(&mut self, val: bool) { | ||
| 1019 | self.0 = (self.0 & !(0x01 << 19usize)) | (((val as u32) & 0x01) << 19usize); | ||
| 1020 | } | ||
| 1021 | #[doc = "I2C1 Fast-mode Plus driving capability activation"] | ||
| 1022 | pub const fn i2c1_fmp(&self) -> bool { | ||
| 1023 | let val = (self.0 >> 20usize) & 0x01; | ||
| 1024 | val != 0 | ||
| 1025 | } | ||
| 1026 | #[doc = "I2C1 Fast-mode Plus driving capability activation"] | ||
| 1027 | pub fn set_i2c1_fmp(&mut self, val: bool) { | ||
| 1028 | self.0 = (self.0 & !(0x01 << 20usize)) | (((val as u32) & 0x01) << 20usize); | ||
| 1029 | } | ||
| 1030 | #[doc = "I2C2 Fast-mode Plus driving capability activation"] | ||
| 1031 | pub const fn i2c2_fmp(&self) -> bool { | ||
| 1032 | let val = (self.0 >> 21usize) & 0x01; | ||
| 1033 | val != 0 | ||
| 1034 | } | ||
| 1035 | #[doc = "I2C2 Fast-mode Plus driving capability activation"] | ||
| 1036 | pub fn set_i2c2_fmp(&mut self, val: bool) { | ||
| 1037 | self.0 = (self.0 & !(0x01 << 21usize)) | (((val as u32) & 0x01) << 21usize); | ||
| 1038 | } | ||
| 1039 | #[doc = "I2C3 Fast-mode Plus driving capability activation"] | ||
| 1040 | pub const fn i2c3_fmp(&self) -> bool { | ||
| 1041 | let val = (self.0 >> 22usize) & 0x01; | ||
| 1042 | val != 0 | ||
| 1043 | } | ||
| 1044 | #[doc = "I2C3 Fast-mode Plus driving capability activation"] | ||
| 1045 | pub fn set_i2c3_fmp(&mut self, val: bool) { | ||
| 1046 | self.0 = (self.0 & !(0x01 << 22usize)) | (((val as u32) & 0x01) << 22usize); | ||
| 1047 | } | ||
| 1048 | #[doc = "Floating Point Unit interrupts enable bits"] | ||
| 1049 | pub const fn fpu_ie(&self) -> u8 { | ||
| 1050 | let val = (self.0 >> 26usize) & 0x3f; | ||
| 1051 | val as u8 | ||
| 1052 | } | ||
| 1053 | #[doc = "Floating Point Unit interrupts enable bits"] | ||
| 1054 | pub fn set_fpu_ie(&mut self, val: u8) { | ||
| 1055 | self.0 = (self.0 & !(0x3f << 26usize)) | (((val as u32) & 0x3f) << 26usize); | ||
| 1056 | } | ||
| 326 | } | 1057 | } |
| 327 | impl Default for Cmpcr { | 1058 | impl Default for Cfgr1 { |
| 328 | fn default() -> Cmpcr { | 1059 | fn default() -> Cfgr1 { |
| 329 | Cmpcr(0) | 1060 | Cfgr1(0) |
| 330 | } | 1061 | } |
| 331 | } | 1062 | } |
| 332 | #[doc = "external interrupt configuration register"] | 1063 | #[doc = "external interrupt configuration register 4"] |
| 333 | #[repr(transparent)] | 1064 | #[repr(transparent)] |
| 334 | #[derive(Copy, Clone, Eq, PartialEq)] | 1065 | #[derive(Copy, Clone, Eq, PartialEq)] |
| 335 | pub struct Exticr(pub u32); | 1066 | pub struct Exticr(pub u32); |
| 336 | impl Exticr { | 1067 | impl Exticr { |
| 337 | #[doc = "EXTI x configuration"] | 1068 | #[doc = "EXTI12 configuration bits"] |
| 338 | pub fn exti(&self, n: usize) -> u8 { | 1069 | pub fn exti(&self, n: usize) -> u8 { |
| 339 | assert!(n < 4usize); | 1070 | assert!(n < 4usize); |
| 340 | let offs = 0usize + n * 4usize; | 1071 | let offs = 0usize + n * 4usize; |
| 341 | let val = (self.0 >> offs) & 0x0f; | 1072 | let val = (self.0 >> offs) & 0x0f; |
| 342 | val as u8 | 1073 | val as u8 |
| 343 | } | 1074 | } |
| 344 | #[doc = "EXTI x configuration"] | 1075 | #[doc = "EXTI12 configuration bits"] |
| 345 | pub fn set_exti(&mut self, n: usize, val: u8) { | 1076 | pub fn set_exti(&mut self, n: usize, val: u8) { |
| 346 | assert!(n < 4usize); | 1077 | assert!(n < 4usize); |
| 347 | let offs = 0usize + n * 4usize; | 1078 | let offs = 0usize + n * 4usize; |
| @@ -353,11 +1084,31 @@ pub mod syscfg_f4 { | |||
| 353 | Exticr(0) | 1084 | Exticr(0) |
| 354 | } | 1085 | } |
| 355 | } | 1086 | } |
| 1087 | #[doc = "SKR"] | ||
| 1088 | #[repr(transparent)] | ||
| 1089 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 1090 | pub struct Skr(pub u32); | ||
| 1091 | impl Skr { | ||
| 1092 | #[doc = "SRAM2 write protection key for software erase"] | ||
| 1093 | pub const fn key(&self) -> u8 { | ||
| 1094 | let val = (self.0 >> 0usize) & 0xff; | ||
| 1095 | val as u8 | ||
| 1096 | } | ||
| 1097 | #[doc = "SRAM2 write protection key for software erase"] | ||
| 1098 | pub fn set_key(&mut self, val: u8) { | ||
| 1099 | self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize); | ||
| 1100 | } | ||
| 1101 | } | ||
| 1102 | impl Default for Skr { | ||
| 1103 | fn default() -> Skr { | ||
| 1104 | Skr(0) | ||
| 1105 | } | ||
| 1106 | } | ||
| 356 | #[doc = "memory remap register"] | 1107 | #[doc = "memory remap register"] |
| 357 | #[repr(transparent)] | 1108 | #[repr(transparent)] |
| 358 | #[derive(Copy, Clone, Eq, PartialEq)] | 1109 | #[derive(Copy, Clone, Eq, PartialEq)] |
| 359 | pub struct Memrm(pub u32); | 1110 | pub struct Memrmp(pub u32); |
| 360 | impl Memrm { | 1111 | impl Memrmp { |
| 361 | #[doc = "Memory mapping selection"] | 1112 | #[doc = "Memory mapping selection"] |
| 362 | pub const fn mem_mode(&self) -> u8 { | 1113 | pub const fn mem_mode(&self) -> u8 { |
| 363 | let val = (self.0 >> 0usize) & 0x07; | 1114 | let val = (self.0 >> 0usize) & 0x07; |
| @@ -367,522 +1118,1129 @@ pub mod syscfg_f4 { | |||
| 367 | pub fn set_mem_mode(&mut self, val: u8) { | 1118 | pub fn set_mem_mode(&mut self, val: u8) { |
| 368 | self.0 = (self.0 & !(0x07 << 0usize)) | (((val as u32) & 0x07) << 0usize); | 1119 | self.0 = (self.0 & !(0x07 << 0usize)) | (((val as u32) & 0x07) << 0usize); |
| 369 | } | 1120 | } |
| 370 | #[doc = "Flash bank mode selection"] | 1121 | #[doc = "QUADSPI memory mapping swap"] |
| 1122 | pub const fn qfs(&self) -> bool { | ||
| 1123 | let val = (self.0 >> 3usize) & 0x01; | ||
| 1124 | val != 0 | ||
| 1125 | } | ||
| 1126 | #[doc = "QUADSPI memory mapping swap"] | ||
| 1127 | pub fn set_qfs(&mut self, val: bool) { | ||
| 1128 | self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize); | ||
| 1129 | } | ||
| 1130 | #[doc = "Flash Bank mode selection"] | ||
| 371 | pub const fn fb_mode(&self) -> bool { | 1131 | pub const fn fb_mode(&self) -> bool { |
| 372 | let val = (self.0 >> 8usize) & 0x01; | 1132 | let val = (self.0 >> 8usize) & 0x01; |
| 373 | val != 0 | 1133 | val != 0 |
| 374 | } | 1134 | } |
| 375 | #[doc = "Flash bank mode selection"] | 1135 | #[doc = "Flash Bank mode selection"] |
| 376 | pub fn set_fb_mode(&mut self, val: bool) { | 1136 | pub fn set_fb_mode(&mut self, val: bool) { |
| 377 | self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize); | 1137 | self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize); |
| 378 | } | 1138 | } |
| 379 | #[doc = "FMC memory mapping swap"] | 1139 | } |
| 380 | pub const fn swp_fmc(&self) -> u8 { | 1140 | impl Default for Memrmp { |
| 381 | let val = (self.0 >> 10usize) & 0x03; | 1141 | fn default() -> Memrmp { |
| 382 | val as u8 | 1142 | Memrmp(0) |
| 383 | } | 1143 | } |
| 384 | #[doc = "FMC memory mapping swap"] | 1144 | } |
| 385 | pub fn set_swp_fmc(&mut self, val: u8) { | 1145 | #[doc = "SWPR"] |
| 386 | self.0 = (self.0 & !(0x03 << 10usize)) | (((val as u32) & 0x03) << 10usize); | 1146 | #[repr(transparent)] |
| 1147 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 1148 | pub struct Swpr(pub u32); | ||
| 1149 | impl Swpr { | ||
| 1150 | #[doc = "SRAWM2 write protection."] | ||
| 1151 | pub fn pwp(&self, n: usize) -> bool { | ||
| 1152 | assert!(n < 32usize); | ||
| 1153 | let offs = 0usize + n * 1usize; | ||
| 1154 | let val = (self.0 >> offs) & 0x01; | ||
| 1155 | val != 0 | ||
| 1156 | } | ||
| 1157 | #[doc = "SRAWM2 write protection."] | ||
| 1158 | pub fn set_pwp(&mut self, n: usize, val: bool) { | ||
| 1159 | assert!(n < 32usize); | ||
| 1160 | let offs = 0usize + n * 1usize; | ||
| 1161 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | ||
| 387 | } | 1162 | } |
| 388 | } | 1163 | } |
| 389 | impl Default for Memrm { | 1164 | impl Default for Swpr { |
| 390 | fn default() -> Memrm { | 1165 | fn default() -> Swpr { |
| 391 | Memrm(0) | 1166 | Swpr(0) |
| 392 | } | 1167 | } |
| 393 | } | 1168 | } |
| 394 | } | 1169 | } |
| 395 | } | 1170 | } |
| 396 | pub mod generic { | 1171 | pub mod usart_v1 { |
| 397 | use core::marker::PhantomData; | 1172 | use crate::generic::*; |
| 398 | #[derive(Copy, Clone)] | 1173 | #[doc = "Universal asynchronous receiver transmitter"] |
| 399 | pub struct RW; | ||
| 400 | #[derive(Copy, Clone)] | ||
| 401 | pub struct R; | ||
| 402 | #[derive(Copy, Clone)] | ||
| 403 | pub struct W; | ||
| 404 | mod sealed { | ||
| 405 | use super::*; | ||
| 406 | pub trait Access {} | ||
| 407 | impl Access for R {} | ||
| 408 | impl Access for W {} | ||
| 409 | impl Access for RW {} | ||
| 410 | } | ||
| 411 | pub trait Access: sealed::Access + Copy {} | ||
| 412 | impl Access for R {} | ||
| 413 | impl Access for W {} | ||
| 414 | impl Access for RW {} | ||
| 415 | pub trait Read: Access {} | ||
| 416 | impl Read for RW {} | ||
| 417 | impl Read for R {} | ||
| 418 | pub trait Write: Access {} | ||
| 419 | impl Write for RW {} | ||
| 420 | impl Write for W {} | ||
| 421 | #[derive(Copy, Clone)] | 1174 | #[derive(Copy, Clone)] |
| 422 | pub struct Reg<T: Copy, A: Access> { | 1175 | pub struct Uart(pub *mut u8); |
| 423 | ptr: *mut u8, | 1176 | unsafe impl Send for Uart {} |
| 424 | phantom: PhantomData<*mut (T, A)>, | 1177 | unsafe impl Sync for Uart {} |
| 425 | } | 1178 | impl Uart { |
| 426 | unsafe impl<T: Copy, A: Access> Send for Reg<T, A> {} | 1179 | #[doc = "Status register"] |
| 427 | unsafe impl<T: Copy, A: Access> Sync for Reg<T, A> {} | 1180 | pub fn sr(self) -> Reg<regs::Sr, RW> { |
| 428 | impl<T: Copy, A: Access> Reg<T, A> { | 1181 | unsafe { Reg::from_ptr(self.0.add(0usize)) } |
| 429 | pub fn from_ptr(ptr: *mut u8) -> Self { | ||
| 430 | Self { | ||
| 431 | ptr, | ||
| 432 | phantom: PhantomData, | ||
| 433 | } | ||
| 434 | } | 1182 | } |
| 435 | pub fn ptr(&self) -> *mut T { | 1183 | #[doc = "Data register"] |
| 436 | self.ptr as _ | 1184 | pub fn dr(self) -> Reg<regs::Dr, RW> { |
| 1185 | unsafe { Reg::from_ptr(self.0.add(4usize)) } | ||
| 437 | } | 1186 | } |
| 438 | } | 1187 | #[doc = "Baud rate register"] |
| 439 | impl<T: Copy, A: Read> Reg<T, A> { | 1188 | pub fn brr(self) -> Reg<regs::Brr, RW> { |
| 440 | pub unsafe fn read(&self) -> T { | 1189 | unsafe { Reg::from_ptr(self.0.add(8usize)) } |
| 441 | (self.ptr as *mut T).read_volatile() | ||
| 442 | } | 1190 | } |
| 443 | } | 1191 | #[doc = "Control register 1"] |
| 444 | impl<T: Copy, A: Write> Reg<T, A> { | 1192 | pub fn cr1(self) -> Reg<regs::Cr1, RW> { |
| 445 | pub unsafe fn write_value(&self, val: T) { | 1193 | unsafe { Reg::from_ptr(self.0.add(12usize)) } |
| 446 | (self.ptr as *mut T).write_volatile(val) | ||
| 447 | } | 1194 | } |
| 448 | } | 1195 | #[doc = "Control register 2"] |
| 449 | impl<T: Default + Copy, A: Write> Reg<T, A> { | 1196 | pub fn cr2(self) -> Reg<regs::Cr2, RW> { |
| 450 | pub unsafe fn write<R>(&self, f: impl FnOnce(&mut T) -> R) -> R { | 1197 | unsafe { Reg::from_ptr(self.0.add(16usize)) } |
| 451 | let mut val = Default::default(); | ||
| 452 | let res = f(&mut val); | ||
| 453 | self.write_value(val); | ||
| 454 | res | ||
| 455 | } | 1198 | } |
| 456 | } | 1199 | #[doc = "Control register 3"] |
| 457 | impl<T: Copy, A: Read + Write> Reg<T, A> { | 1200 | pub fn cr3(self) -> Reg<regs::Cr3, RW> { |
| 458 | pub unsafe fn modify<R>(&self, f: impl FnOnce(&mut T) -> R) -> R { | 1201 | unsafe { Reg::from_ptr(self.0.add(20usize)) } |
| 459 | let mut val = self.read(); | ||
| 460 | let res = f(&mut val); | ||
| 461 | self.write_value(val); | ||
| 462 | res | ||
| 463 | } | 1202 | } |
| 464 | } | 1203 | } |
| 465 | } | 1204 | #[doc = "Universal synchronous asynchronous receiver transmitter"] |
| 466 | pub mod gpio_v2 { | ||
| 467 | use crate::generic::*; | ||
| 468 | #[doc = "General-purpose I/Os"] | ||
| 469 | #[derive(Copy, Clone)] | 1205 | #[derive(Copy, Clone)] |
| 470 | pub struct Gpio(pub *mut u8); | 1206 | pub struct Usart(pub *mut u8); |
| 471 | unsafe impl Send for Gpio {} | 1207 | unsafe impl Send for Usart {} |
| 472 | unsafe impl Sync for Gpio {} | 1208 | unsafe impl Sync for Usart {} |
| 473 | impl Gpio { | 1209 | impl Usart { |
| 474 | #[doc = "GPIO port mode register"] | 1210 | #[doc = "Status register"] |
| 475 | pub fn moder(self) -> Reg<regs::Moder, RW> { | 1211 | pub fn sr(self) -> Reg<regs::Sr, RW> { |
| 476 | unsafe { Reg::from_ptr(self.0.add(0usize)) } | 1212 | unsafe { Reg::from_ptr(self.0.add(0usize)) } |
| 477 | } | 1213 | } |
| 478 | #[doc = "GPIO port output type register"] | 1214 | #[doc = "Data register"] |
| 479 | pub fn otyper(self) -> Reg<regs::Otyper, RW> { | 1215 | pub fn dr(self) -> Reg<regs::Dr, RW> { |
| 480 | unsafe { Reg::from_ptr(self.0.add(4usize)) } | 1216 | unsafe { Reg::from_ptr(self.0.add(4usize)) } |
| 481 | } | 1217 | } |
| 482 | #[doc = "GPIO port output speed register"] | 1218 | #[doc = "Baud rate register"] |
| 483 | pub fn ospeedr(self) -> Reg<regs::Ospeedr, RW> { | 1219 | pub fn brr(self) -> Reg<regs::Brr, RW> { |
| 484 | unsafe { Reg::from_ptr(self.0.add(8usize)) } | 1220 | unsafe { Reg::from_ptr(self.0.add(8usize)) } |
| 485 | } | 1221 | } |
| 486 | #[doc = "GPIO port pull-up/pull-down register"] | 1222 | #[doc = "Control register 1"] |
| 487 | pub fn pupdr(self) -> Reg<regs::Pupdr, RW> { | 1223 | pub fn cr1(self) -> Reg<regs::Cr1, RW> { |
| 488 | unsafe { Reg::from_ptr(self.0.add(12usize)) } | 1224 | unsafe { Reg::from_ptr(self.0.add(12usize)) } |
| 489 | } | 1225 | } |
| 490 | #[doc = "GPIO port input data register"] | 1226 | #[doc = "Control register 2"] |
| 491 | pub fn idr(self) -> Reg<regs::Idr, R> { | 1227 | pub fn cr2(self) -> Reg<regs::Cr2Usart, RW> { |
| 492 | unsafe { Reg::from_ptr(self.0.add(16usize)) } | 1228 | unsafe { Reg::from_ptr(self.0.add(16usize)) } |
| 493 | } | 1229 | } |
| 494 | #[doc = "GPIO port output data register"] | 1230 | #[doc = "Control register 3"] |
| 495 | pub fn odr(self) -> Reg<regs::Odr, RW> { | 1231 | pub fn cr3(self) -> Reg<regs::Cr3Usart, RW> { |
| 496 | unsafe { Reg::from_ptr(self.0.add(20usize)) } | 1232 | unsafe { Reg::from_ptr(self.0.add(20usize)) } |
| 497 | } | 1233 | } |
| 498 | #[doc = "GPIO port bit set/reset register"] | 1234 | #[doc = "Guard time and prescaler register"] |
| 499 | pub fn bsrr(self) -> Reg<regs::Bsrr, W> { | 1235 | pub fn gtpr(self) -> Reg<regs::Gtpr, RW> { |
| 500 | unsafe { Reg::from_ptr(self.0.add(24usize)) } | 1236 | unsafe { Reg::from_ptr(self.0.add(24usize)) } |
| 501 | } | 1237 | } |
| 502 | #[doc = "GPIO port configuration lock register"] | ||
| 503 | pub fn lckr(self) -> Reg<regs::Lckr, RW> { | ||
| 504 | unsafe { Reg::from_ptr(self.0.add(28usize)) } | ||
| 505 | } | ||
| 506 | #[doc = "GPIO alternate function register (low, high)"] | ||
| 507 | pub fn afr(self, n: usize) -> Reg<regs::Afr, RW> { | ||
| 508 | assert!(n < 2usize); | ||
| 509 | unsafe { Reg::from_ptr(self.0.add(32usize + n * 4usize)) } | ||
| 510 | } | ||
| 511 | } | 1238 | } |
| 512 | pub mod vals { | 1239 | pub mod vals { |
| 513 | use crate::generic::*; | 1240 | use crate::generic::*; |
| 514 | #[repr(transparent)] | 1241 | #[repr(transparent)] |
| 515 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 1242 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 516 | pub struct Ot(pub u8); | 1243 | pub struct Ps(pub u8); |
| 517 | impl Ot { | 1244 | impl Ps { |
| 518 | #[doc = "Output push-pull (reset state)"] | 1245 | #[doc = "Even parity"] |
| 519 | pub const PUSHPULL: Self = Self(0); | 1246 | pub const EVEN: Self = Self(0); |
| 520 | #[doc = "Output open-drain"] | 1247 | #[doc = "Odd parity"] |
| 521 | pub const OPENDRAIN: Self = Self(0x01); | 1248 | pub const ODD: Self = Self(0x01); |
| 522 | } | 1249 | } |
| 523 | #[repr(transparent)] | 1250 | #[repr(transparent)] |
| 524 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 1251 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 525 | pub struct Brw(pub u8); | 1252 | pub struct M(pub u8); |
| 526 | impl Brw { | 1253 | impl M { |
| 527 | #[doc = "Resets the corresponding ODRx bit"] | 1254 | #[doc = "8 data bits"] |
| 528 | pub const RESET: Self = Self(0x01); | 1255 | pub const M8: Self = Self(0); |
| 1256 | #[doc = "9 data bits"] | ||
| 1257 | pub const M9: Self = Self(0x01); | ||
| 529 | } | 1258 | } |
| 530 | #[repr(transparent)] | 1259 | #[repr(transparent)] |
| 531 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 1260 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 532 | pub struct Pupdr(pub u8); | 1261 | pub struct Sbk(pub u8); |
| 533 | impl Pupdr { | 1262 | impl Sbk { |
| 534 | #[doc = "No pull-up, pull-down"] | 1263 | #[doc = "No break character is transmitted"] |
| 535 | pub const FLOATING: Self = Self(0); | 1264 | pub const NOBREAK: Self = Self(0); |
| 536 | #[doc = "Pull-up"] | 1265 | #[doc = "Break character transmitted"] |
| 537 | pub const PULLUP: Self = Self(0x01); | 1266 | pub const BREAK: Self = Self(0x01); |
| 538 | #[doc = "Pull-down"] | ||
| 539 | pub const PULLDOWN: Self = Self(0x02); | ||
| 540 | } | 1267 | } |
| 541 | #[repr(transparent)] | 1268 | #[repr(transparent)] |
| 542 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 1269 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 543 | pub struct Moder(pub u8); | 1270 | pub struct Stop(pub u8); |
| 544 | impl Moder { | 1271 | impl Stop { |
| 545 | #[doc = "Input mode (reset state)"] | 1272 | #[doc = "1 stop bit"] |
| 546 | pub const INPUT: Self = Self(0); | 1273 | pub const STOP1: Self = Self(0); |
| 547 | #[doc = "General purpose output mode"] | 1274 | #[doc = "0.5 stop bits"] |
| 548 | pub const OUTPUT: Self = Self(0x01); | 1275 | pub const STOP0P5: Self = Self(0x01); |
| 549 | #[doc = "Alternate function mode"] | 1276 | #[doc = "2 stop bits"] |
| 550 | pub const ALTERNATE: Self = Self(0x02); | 1277 | pub const STOP2: Self = Self(0x02); |
| 551 | #[doc = "Analog mode"] | 1278 | #[doc = "1.5 stop bits"] |
| 552 | pub const ANALOG: Self = Self(0x03); | 1279 | pub const STOP1P5: Self = Self(0x03); |
| 553 | } | 1280 | } |
| 554 | #[repr(transparent)] | 1281 | #[repr(transparent)] |
| 555 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 1282 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 556 | pub struct Bsw(pub u8); | 1283 | pub struct Hdsel(pub u8); |
| 557 | impl Bsw { | 1284 | impl Hdsel { |
| 558 | #[doc = "Sets the corresponding ODRx bit"] | 1285 | #[doc = "Half duplex mode is not selected"] |
| 559 | pub const SET: Self = Self(0x01); | 1286 | pub const FULLDUPLEX: Self = Self(0); |
| 1287 | #[doc = "Half duplex mode is selected"] | ||
| 1288 | pub const HALFDUPLEX: Self = Self(0x01); | ||
| 560 | } | 1289 | } |
| 561 | #[repr(transparent)] | 1290 | #[repr(transparent)] |
| 562 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 1291 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 563 | pub struct Odr(pub u8); | 1292 | pub struct Wake(pub u8); |
| 564 | impl Odr { | 1293 | impl Wake { |
| 565 | #[doc = "Set output to logic low"] | 1294 | #[doc = "USART wakeup on idle line"] |
| 566 | pub const LOW: Self = Self(0); | 1295 | pub const IDLELINE: Self = Self(0); |
| 567 | #[doc = "Set output to logic high"] | 1296 | #[doc = "USART wakeup on address mark"] |
| 568 | pub const HIGH: Self = Self(0x01); | 1297 | pub const ADDRESSMARK: Self = Self(0x01); |
| 569 | } | 1298 | } |
| 570 | #[repr(transparent)] | 1299 | #[repr(transparent)] |
| 571 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 1300 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 572 | pub struct Idr(pub u8); | 1301 | pub struct Rwu(pub u8); |
| 573 | impl Idr { | 1302 | impl Rwu { |
| 574 | #[doc = "Input is logic low"] | 1303 | #[doc = "Receiver in active mode"] |
| 575 | pub const LOW: Self = Self(0); | 1304 | pub const ACTIVE: Self = Self(0); |
| 576 | #[doc = "Input is logic high"] | 1305 | #[doc = "Receiver in mute mode"] |
| 577 | pub const HIGH: Self = Self(0x01); | 1306 | pub const MUTE: Self = Self(0x01); |
| 578 | } | 1307 | } |
| 579 | #[repr(transparent)] | 1308 | #[repr(transparent)] |
| 580 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 1309 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 581 | pub struct Lckk(pub u8); | 1310 | pub struct Lbdl(pub u8); |
| 582 | impl Lckk { | 1311 | impl Lbdl { |
| 583 | #[doc = "Port configuration lock key not active"] | 1312 | #[doc = "10-bit break detection"] |
| 584 | pub const NOTACTIVE: Self = Self(0); | 1313 | pub const LBDL10: Self = Self(0); |
| 585 | #[doc = "Port configuration lock key active"] | 1314 | #[doc = "11-bit break detection"] |
| 586 | pub const ACTIVE: Self = Self(0x01); | 1315 | pub const LBDL11: Self = Self(0x01); |
| 587 | } | 1316 | } |
| 588 | #[repr(transparent)] | 1317 | #[repr(transparent)] |
| 589 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 1318 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 590 | pub struct Ospeedr(pub u8); | 1319 | pub struct Cpol(pub u8); |
| 591 | impl Ospeedr { | 1320 | impl Cpol { |
| 592 | #[doc = "Low speed"] | 1321 | #[doc = "Steady low value on CK pin outside transmission window"] |
| 593 | pub const LOWSPEED: Self = Self(0); | 1322 | pub const LOW: Self = Self(0); |
| 594 | #[doc = "Medium speed"] | 1323 | #[doc = "Steady high value on CK pin outside transmission window"] |
| 595 | pub const MEDIUMSPEED: Self = Self(0x01); | 1324 | pub const HIGH: Self = Self(0x01); |
| 596 | #[doc = "High speed"] | ||
| 597 | pub const HIGHSPEED: Self = Self(0x02); | ||
| 598 | #[doc = "Very high speed"] | ||
| 599 | pub const VERYHIGHSPEED: Self = Self(0x03); | ||
| 600 | } | 1325 | } |
| 601 | #[repr(transparent)] | 1326 | #[repr(transparent)] |
| 602 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 1327 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 603 | pub struct Afr(pub u8); | 1328 | pub struct Cpha(pub u8); |
| 604 | impl Afr { | 1329 | impl Cpha { |
| 605 | #[doc = "AF0"] | 1330 | #[doc = "The first clock transition is the first data capture edge"] |
| 606 | pub const AF0: Self = Self(0); | 1331 | pub const FIRST: Self = Self(0); |
| 607 | #[doc = "AF1"] | 1332 | #[doc = "The second clock transition is the first data capture edge"] |
| 608 | pub const AF1: Self = Self(0x01); | 1333 | pub const SECOND: Self = Self(0x01); |
| 609 | #[doc = "AF2"] | ||
| 610 | pub const AF2: Self = Self(0x02); | ||
| 611 | #[doc = "AF3"] | ||
| 612 | pub const AF3: Self = Self(0x03); | ||
| 613 | #[doc = "AF4"] | ||
| 614 | pub const AF4: Self = Self(0x04); | ||
| 615 | #[doc = "AF5"] | ||
| 616 | pub const AF5: Self = Self(0x05); | ||
| 617 | #[doc = "AF6"] | ||
| 618 | pub const AF6: Self = Self(0x06); | ||
| 619 | #[doc = "AF7"] | ||
| 620 | pub const AF7: Self = Self(0x07); | ||
| 621 | #[doc = "AF8"] | ||
| 622 | pub const AF8: Self = Self(0x08); | ||
| 623 | #[doc = "AF9"] | ||
| 624 | pub const AF9: Self = Self(0x09); | ||
| 625 | #[doc = "AF10"] | ||
| 626 | pub const AF10: Self = Self(0x0a); | ||
| 627 | #[doc = "AF11"] | ||
| 628 | pub const AF11: Self = Self(0x0b); | ||
| 629 | #[doc = "AF12"] | ||
| 630 | pub const AF12: Self = Self(0x0c); | ||
| 631 | #[doc = "AF13"] | ||
| 632 | pub const AF13: Self = Self(0x0d); | ||
| 633 | #[doc = "AF14"] | ||
| 634 | pub const AF14: Self = Self(0x0e); | ||
| 635 | #[doc = "AF15"] | ||
| 636 | pub const AF15: Self = Self(0x0f); | ||
| 637 | } | 1334 | } |
| 638 | #[repr(transparent)] | 1335 | #[repr(transparent)] |
| 639 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 1336 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 640 | pub struct Lck(pub u8); | 1337 | pub struct Irlp(pub u8); |
| 641 | impl Lck { | 1338 | impl Irlp { |
| 642 | #[doc = "Port configuration not locked"] | 1339 | #[doc = "Normal mode"] |
| 643 | pub const UNLOCKED: Self = Self(0); | 1340 | pub const NORMAL: Self = Self(0); |
| 644 | #[doc = "Port configuration locked"] | 1341 | #[doc = "Low-power mode"] |
| 645 | pub const LOCKED: Self = Self(0x01); | 1342 | pub const LOWPOWER: Self = Self(0x01); |
| 646 | } | 1343 | } |
| 647 | } | 1344 | } |
| 648 | pub mod regs { | 1345 | pub mod regs { |
| 649 | use crate::generic::*; | 1346 | use crate::generic::*; |
| 650 | #[doc = "GPIO port output data register"] | 1347 | #[doc = "Control register 3"] |
| 651 | #[repr(transparent)] | 1348 | #[repr(transparent)] |
| 652 | #[derive(Copy, Clone, Eq, PartialEq)] | 1349 | #[derive(Copy, Clone, Eq, PartialEq)] |
| 653 | pub struct Odr(pub u32); | 1350 | pub struct Cr3(pub u32); |
| 654 | impl Odr { | 1351 | impl Cr3 { |
| 655 | #[doc = "Port output data (y = 0..15)"] | 1352 | #[doc = "Error interrupt enable"] |
| 656 | pub fn odr(&self, n: usize) -> super::vals::Odr { | 1353 | pub const fn eie(&self) -> bool { |
| 657 | assert!(n < 16usize); | 1354 | let val = (self.0 >> 0usize) & 0x01; |
| 658 | let offs = 0usize + n * 1usize; | 1355 | val != 0 |
| 659 | let val = (self.0 >> offs) & 0x01; | ||
| 660 | super::vals::Odr(val as u8) | ||
| 661 | } | 1356 | } |
| 662 | #[doc = "Port output data (y = 0..15)"] | 1357 | #[doc = "Error interrupt enable"] |
| 663 | pub fn set_odr(&mut self, n: usize, val: super::vals::Odr) { | 1358 | pub fn set_eie(&mut self, val: bool) { |
| 664 | assert!(n < 16usize); | 1359 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); |
| 665 | let offs = 0usize + n * 1usize; | 1360 | } |
| 666 | self.0 = (self.0 & !(0x01 << offs)) | (((val.0 as u32) & 0x01) << offs); | 1361 | #[doc = "IrDA mode enable"] |
| 1362 | pub const fn iren(&self) -> bool { | ||
| 1363 | let val = (self.0 >> 1usize) & 0x01; | ||
| 1364 | val != 0 | ||
| 1365 | } | ||
| 1366 | #[doc = "IrDA mode enable"] | ||
| 1367 | pub fn set_iren(&mut self, val: bool) { | ||
| 1368 | self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize); | ||
| 1369 | } | ||
| 1370 | #[doc = "IrDA low-power"] | ||
| 1371 | pub const fn irlp(&self) -> super::vals::Irlp { | ||
| 1372 | let val = (self.0 >> 2usize) & 0x01; | ||
| 1373 | super::vals::Irlp(val as u8) | ||
| 1374 | } | ||
| 1375 | #[doc = "IrDA low-power"] | ||
| 1376 | pub fn set_irlp(&mut self, val: super::vals::Irlp) { | ||
| 1377 | self.0 = (self.0 & !(0x01 << 2usize)) | (((val.0 as u32) & 0x01) << 2usize); | ||
| 1378 | } | ||
| 1379 | #[doc = "Half-duplex selection"] | ||
| 1380 | pub const fn hdsel(&self) -> super::vals::Hdsel { | ||
| 1381 | let val = (self.0 >> 3usize) & 0x01; | ||
| 1382 | super::vals::Hdsel(val as u8) | ||
| 1383 | } | ||
| 1384 | #[doc = "Half-duplex selection"] | ||
| 1385 | pub fn set_hdsel(&mut self, val: super::vals::Hdsel) { | ||
| 1386 | self.0 = (self.0 & !(0x01 << 3usize)) | (((val.0 as u32) & 0x01) << 3usize); | ||
| 1387 | } | ||
| 1388 | #[doc = "DMA enable receiver"] | ||
| 1389 | pub const fn dmar(&self) -> bool { | ||
| 1390 | let val = (self.0 >> 6usize) & 0x01; | ||
| 1391 | val != 0 | ||
| 1392 | } | ||
| 1393 | #[doc = "DMA enable receiver"] | ||
| 1394 | pub fn set_dmar(&mut self, val: bool) { | ||
| 1395 | self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize); | ||
| 1396 | } | ||
| 1397 | #[doc = "DMA enable transmitter"] | ||
| 1398 | pub const fn dmat(&self) -> bool { | ||
| 1399 | let val = (self.0 >> 7usize) & 0x01; | ||
| 1400 | val != 0 | ||
| 1401 | } | ||
| 1402 | #[doc = "DMA enable transmitter"] | ||
| 1403 | pub fn set_dmat(&mut self, val: bool) { | ||
| 1404 | self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize); | ||
| 667 | } | 1405 | } |
| 668 | } | 1406 | } |
| 669 | impl Default for Odr { | 1407 | impl Default for Cr3 { |
| 670 | fn default() -> Odr { | 1408 | fn default() -> Cr3 { |
| 671 | Odr(0) | 1409 | Cr3(0) |
| 672 | } | 1410 | } |
| 673 | } | 1411 | } |
| 674 | #[doc = "GPIO port bit set/reset register"] | 1412 | #[doc = "Control register 2"] |
| 675 | #[repr(transparent)] | 1413 | #[repr(transparent)] |
| 676 | #[derive(Copy, Clone, Eq, PartialEq)] | 1414 | #[derive(Copy, Clone, Eq, PartialEq)] |
| 677 | pub struct Bsrr(pub u32); | 1415 | pub struct Cr2(pub u32); |
| 678 | impl Bsrr { | 1416 | impl Cr2 { |
| 679 | #[doc = "Port x set bit y (y= 0..15)"] | 1417 | #[doc = "Address of the USART node"] |
| 680 | pub fn bs(&self, n: usize) -> bool { | 1418 | pub const fn add(&self) -> u8 { |
| 681 | assert!(n < 16usize); | 1419 | let val = (self.0 >> 0usize) & 0x0f; |
| 682 | let offs = 0usize + n * 1usize; | 1420 | val as u8 |
| 683 | let val = (self.0 >> offs) & 0x01; | 1421 | } |
| 1422 | #[doc = "Address of the USART node"] | ||
| 1423 | pub fn set_add(&mut self, val: u8) { | ||
| 1424 | self.0 = (self.0 & !(0x0f << 0usize)) | (((val as u32) & 0x0f) << 0usize); | ||
| 1425 | } | ||
| 1426 | #[doc = "lin break detection length"] | ||
| 1427 | pub const fn lbdl(&self) -> super::vals::Lbdl { | ||
| 1428 | let val = (self.0 >> 5usize) & 0x01; | ||
| 1429 | super::vals::Lbdl(val as u8) | ||
| 1430 | } | ||
| 1431 | #[doc = "lin break detection length"] | ||
| 1432 | pub fn set_lbdl(&mut self, val: super::vals::Lbdl) { | ||
| 1433 | self.0 = (self.0 & !(0x01 << 5usize)) | (((val.0 as u32) & 0x01) << 5usize); | ||
| 1434 | } | ||
| 1435 | #[doc = "LIN break detection interrupt enable"] | ||
| 1436 | pub const fn lbdie(&self) -> bool { | ||
| 1437 | let val = (self.0 >> 6usize) & 0x01; | ||
| 684 | val != 0 | 1438 | val != 0 |
| 685 | } | 1439 | } |
| 686 | #[doc = "Port x set bit y (y= 0..15)"] | 1440 | #[doc = "LIN break detection interrupt enable"] |
| 687 | pub fn set_bs(&mut self, n: usize, val: bool) { | 1441 | pub fn set_lbdie(&mut self, val: bool) { |
| 688 | assert!(n < 16usize); | 1442 | self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize); |
| 689 | let offs = 0usize + n * 1usize; | ||
| 690 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | ||
| 691 | } | 1443 | } |
| 692 | #[doc = "Port x set bit y (y= 0..15)"] | 1444 | #[doc = "STOP bits"] |
| 693 | pub fn br(&self, n: usize) -> bool { | 1445 | pub const fn stop(&self) -> super::vals::Stop { |
| 694 | assert!(n < 16usize); | 1446 | let val = (self.0 >> 12usize) & 0x03; |
| 695 | let offs = 16usize + n * 1usize; | 1447 | super::vals::Stop(val as u8) |
| 696 | let val = (self.0 >> offs) & 0x01; | 1448 | } |
| 1449 | #[doc = "STOP bits"] | ||
| 1450 | pub fn set_stop(&mut self, val: super::vals::Stop) { | ||
| 1451 | self.0 = (self.0 & !(0x03 << 12usize)) | (((val.0 as u32) & 0x03) << 12usize); | ||
| 1452 | } | ||
| 1453 | #[doc = "LIN mode enable"] | ||
| 1454 | pub const fn linen(&self) -> bool { | ||
| 1455 | let val = (self.0 >> 14usize) & 0x01; | ||
| 697 | val != 0 | 1456 | val != 0 |
| 698 | } | 1457 | } |
| 699 | #[doc = "Port x set bit y (y= 0..15)"] | 1458 | #[doc = "LIN mode enable"] |
| 700 | pub fn set_br(&mut self, n: usize, val: bool) { | 1459 | pub fn set_linen(&mut self, val: bool) { |
| 701 | assert!(n < 16usize); | 1460 | self.0 = (self.0 & !(0x01 << 14usize)) | (((val as u32) & 0x01) << 14usize); |
| 702 | let offs = 16usize + n * 1usize; | ||
| 703 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | ||
| 704 | } | 1461 | } |
| 705 | } | 1462 | } |
| 706 | impl Default for Bsrr { | 1463 | impl Default for Cr2 { |
| 707 | fn default() -> Bsrr { | 1464 | fn default() -> Cr2 { |
| 708 | Bsrr(0) | 1465 | Cr2(0) |
| 709 | } | 1466 | } |
| 710 | } | 1467 | } |
| 711 | #[doc = "GPIO port input data register"] | 1468 | #[doc = "Control register 2"] |
| 712 | #[repr(transparent)] | 1469 | #[repr(transparent)] |
| 713 | #[derive(Copy, Clone, Eq, PartialEq)] | 1470 | #[derive(Copy, Clone, Eq, PartialEq)] |
| 714 | pub struct Idr(pub u32); | 1471 | pub struct Cr2Usart(pub u32); |
| 715 | impl Idr { | 1472 | impl Cr2Usart { |
| 716 | #[doc = "Port input data (y = 0..15)"] | 1473 | #[doc = "Address of the USART node"] |
| 717 | pub fn idr(&self, n: usize) -> super::vals::Idr { | 1474 | pub const fn add(&self) -> u8 { |
| 718 | assert!(n < 16usize); | 1475 | let val = (self.0 >> 0usize) & 0x0f; |
| 719 | let offs = 0usize + n * 1usize; | 1476 | val as u8 |
| 720 | let val = (self.0 >> offs) & 0x01; | ||
| 721 | super::vals::Idr(val as u8) | ||
| 722 | } | 1477 | } |
| 723 | #[doc = "Port input data (y = 0..15)"] | 1478 | #[doc = "Address of the USART node"] |
| 724 | pub fn set_idr(&mut self, n: usize, val: super::vals::Idr) { | 1479 | pub fn set_add(&mut self, val: u8) { |
| 725 | assert!(n < 16usize); | 1480 | self.0 = (self.0 & !(0x0f << 0usize)) | (((val as u32) & 0x0f) << 0usize); |
| 726 | let offs = 0usize + n * 1usize; | 1481 | } |
| 727 | self.0 = (self.0 & !(0x01 << offs)) | (((val.0 as u32) & 0x01) << offs); | 1482 | #[doc = "lin break detection length"] |
| 1483 | pub const fn lbdl(&self) -> super::vals::Lbdl { | ||
| 1484 | let val = (self.0 >> 5usize) & 0x01; | ||
| 1485 | super::vals::Lbdl(val as u8) | ||
| 1486 | } | ||
| 1487 | #[doc = "lin break detection length"] | ||
| 1488 | pub fn set_lbdl(&mut self, val: super::vals::Lbdl) { | ||
| 1489 | self.0 = (self.0 & !(0x01 << 5usize)) | (((val.0 as u32) & 0x01) << 5usize); | ||
| 1490 | } | ||
| 1491 | #[doc = "LIN break detection interrupt enable"] | ||
| 1492 | pub const fn lbdie(&self) -> bool { | ||
| 1493 | let val = (self.0 >> 6usize) & 0x01; | ||
| 1494 | val != 0 | ||
| 1495 | } | ||
| 1496 | #[doc = "LIN break detection interrupt enable"] | ||
| 1497 | pub fn set_lbdie(&mut self, val: bool) { | ||
| 1498 | self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize); | ||
| 1499 | } | ||
| 1500 | #[doc = "Last bit clock pulse"] | ||
| 1501 | pub const fn lbcl(&self) -> bool { | ||
| 1502 | let val = (self.0 >> 8usize) & 0x01; | ||
| 1503 | val != 0 | ||
| 1504 | } | ||
| 1505 | #[doc = "Last bit clock pulse"] | ||
| 1506 | pub fn set_lbcl(&mut self, val: bool) { | ||
| 1507 | self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize); | ||
| 1508 | } | ||
| 1509 | #[doc = "Clock phase"] | ||
| 1510 | pub const fn cpha(&self) -> super::vals::Cpha { | ||
| 1511 | let val = (self.0 >> 9usize) & 0x01; | ||
| 1512 | super::vals::Cpha(val as u8) | ||
| 1513 | } | ||
| 1514 | #[doc = "Clock phase"] | ||
| 1515 | pub fn set_cpha(&mut self, val: super::vals::Cpha) { | ||
| 1516 | self.0 = (self.0 & !(0x01 << 9usize)) | (((val.0 as u32) & 0x01) << 9usize); | ||
| 1517 | } | ||
| 1518 | #[doc = "Clock polarity"] | ||
| 1519 | pub const fn cpol(&self) -> super::vals::Cpol { | ||
| 1520 | let val = (self.0 >> 10usize) & 0x01; | ||
| 1521 | super::vals::Cpol(val as u8) | ||
| 1522 | } | ||
| 1523 | #[doc = "Clock polarity"] | ||
| 1524 | pub fn set_cpol(&mut self, val: super::vals::Cpol) { | ||
| 1525 | self.0 = (self.0 & !(0x01 << 10usize)) | (((val.0 as u32) & 0x01) << 10usize); | ||
| 1526 | } | ||
| 1527 | #[doc = "Clock enable"] | ||
| 1528 | pub const fn clken(&self) -> bool { | ||
| 1529 | let val = (self.0 >> 11usize) & 0x01; | ||
| 1530 | val != 0 | ||
| 1531 | } | ||
| 1532 | #[doc = "Clock enable"] | ||
| 1533 | pub fn set_clken(&mut self, val: bool) { | ||
| 1534 | self.0 = (self.0 & !(0x01 << 11usize)) | (((val as u32) & 0x01) << 11usize); | ||
| 1535 | } | ||
| 1536 | #[doc = "STOP bits"] | ||
| 1537 | pub const fn stop(&self) -> super::vals::Stop { | ||
| 1538 | let val = (self.0 >> 12usize) & 0x03; | ||
| 1539 | super::vals::Stop(val as u8) | ||
| 1540 | } | ||
| 1541 | #[doc = "STOP bits"] | ||
| 1542 | pub fn set_stop(&mut self, val: super::vals::Stop) { | ||
| 1543 | self.0 = (self.0 & !(0x03 << 12usize)) | (((val.0 as u32) & 0x03) << 12usize); | ||
| 1544 | } | ||
| 1545 | #[doc = "LIN mode enable"] | ||
| 1546 | pub const fn linen(&self) -> bool { | ||
| 1547 | let val = (self.0 >> 14usize) & 0x01; | ||
| 1548 | val != 0 | ||
| 1549 | } | ||
| 1550 | #[doc = "LIN mode enable"] | ||
| 1551 | pub fn set_linen(&mut self, val: bool) { | ||
| 1552 | self.0 = (self.0 & !(0x01 << 14usize)) | (((val as u32) & 0x01) << 14usize); | ||
| 728 | } | 1553 | } |
| 729 | } | 1554 | } |
| 730 | impl Default for Idr { | 1555 | impl Default for Cr2Usart { |
| 731 | fn default() -> Idr { | 1556 | fn default() -> Cr2Usart { |
| 732 | Idr(0) | 1557 | Cr2Usart(0) |
| 733 | } | 1558 | } |
| 734 | } | 1559 | } |
| 735 | #[doc = "GPIO port mode register"] | 1560 | #[doc = "Guard time and prescaler register"] |
| 736 | #[repr(transparent)] | 1561 | #[repr(transparent)] |
| 737 | #[derive(Copy, Clone, Eq, PartialEq)] | 1562 | #[derive(Copy, Clone, Eq, PartialEq)] |
| 738 | pub struct Moder(pub u32); | 1563 | pub struct Gtpr(pub u32); |
| 739 | impl Moder { | 1564 | impl Gtpr { |
| 740 | #[doc = "Port x configuration bits (y = 0..15)"] | 1565 | #[doc = "Prescaler value"] |
| 741 | pub fn moder(&self, n: usize) -> super::vals::Moder { | 1566 | pub const fn psc(&self) -> u8 { |
| 742 | assert!(n < 16usize); | 1567 | let val = (self.0 >> 0usize) & 0xff; |
| 743 | let offs = 0usize + n * 2usize; | 1568 | val as u8 |
| 744 | let val = (self.0 >> offs) & 0x03; | ||
| 745 | super::vals::Moder(val as u8) | ||
| 746 | } | 1569 | } |
| 747 | #[doc = "Port x configuration bits (y = 0..15)"] | 1570 | #[doc = "Prescaler value"] |
| 748 | pub fn set_moder(&mut self, n: usize, val: super::vals::Moder) { | 1571 | pub fn set_psc(&mut self, val: u8) { |
| 749 | assert!(n < 16usize); | 1572 | self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize); |
| 750 | let offs = 0usize + n * 2usize; | 1573 | } |
| 751 | self.0 = (self.0 & !(0x03 << offs)) | (((val.0 as u32) & 0x03) << offs); | 1574 | #[doc = "Guard time value"] |
| 1575 | pub const fn gt(&self) -> u8 { | ||
| 1576 | let val = (self.0 >> 8usize) & 0xff; | ||
| 1577 | val as u8 | ||
| 1578 | } | ||
| 1579 | #[doc = "Guard time value"] | ||
| 1580 | pub fn set_gt(&mut self, val: u8) { | ||
| 1581 | self.0 = (self.0 & !(0xff << 8usize)) | (((val as u32) & 0xff) << 8usize); | ||
| 752 | } | 1582 | } |
| 753 | } | 1583 | } |
| 754 | impl Default for Moder { | 1584 | impl Default for Gtpr { |
| 755 | fn default() -> Moder { | 1585 | fn default() -> Gtpr { |
| 756 | Moder(0) | 1586 | Gtpr(0) |
| 757 | } | 1587 | } |
| 758 | } | 1588 | } |
| 759 | #[doc = "GPIO port pull-up/pull-down register"] | 1589 | #[doc = "Status register"] |
| 760 | #[repr(transparent)] | 1590 | #[repr(transparent)] |
| 761 | #[derive(Copy, Clone, Eq, PartialEq)] | 1591 | #[derive(Copy, Clone, Eq, PartialEq)] |
| 762 | pub struct Pupdr(pub u32); | 1592 | pub struct Sr(pub u32); |
| 763 | impl Pupdr { | 1593 | impl Sr { |
| 764 | #[doc = "Port x configuration bits (y = 0..15)"] | 1594 | #[doc = "Parity error"] |
| 765 | pub fn pupdr(&self, n: usize) -> super::vals::Pupdr { | 1595 | pub const fn pe(&self) -> bool { |
| 766 | assert!(n < 16usize); | 1596 | let val = (self.0 >> 0usize) & 0x01; |
| 767 | let offs = 0usize + n * 2usize; | 1597 | val != 0 |
| 768 | let val = (self.0 >> offs) & 0x03; | ||
| 769 | super::vals::Pupdr(val as u8) | ||
| 770 | } | 1598 | } |
| 771 | #[doc = "Port x configuration bits (y = 0..15)"] | 1599 | #[doc = "Parity error"] |
| 772 | pub fn set_pupdr(&mut self, n: usize, val: super::vals::Pupdr) { | 1600 | pub fn set_pe(&mut self, val: bool) { |
| 773 | assert!(n < 16usize); | 1601 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); |
| 774 | let offs = 0usize + n * 2usize; | 1602 | } |
| 775 | self.0 = (self.0 & !(0x03 << offs)) | (((val.0 as u32) & 0x03) << offs); | 1603 | #[doc = "Framing error"] |
| 1604 | pub const fn fe(&self) -> bool { | ||
| 1605 | let val = (self.0 >> 1usize) & 0x01; | ||
| 1606 | val != 0 | ||
| 1607 | } | ||
| 1608 | #[doc = "Framing error"] | ||
| 1609 | pub fn set_fe(&mut self, val: bool) { | ||
| 1610 | self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize); | ||
| 1611 | } | ||
| 1612 | #[doc = "Noise error flag"] | ||
| 1613 | pub const fn ne(&self) -> bool { | ||
| 1614 | let val = (self.0 >> 2usize) & 0x01; | ||
| 1615 | val != 0 | ||
| 1616 | } | ||
| 1617 | #[doc = "Noise error flag"] | ||
| 1618 | pub fn set_ne(&mut self, val: bool) { | ||
| 1619 | self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize); | ||
| 1620 | } | ||
| 1621 | #[doc = "Overrun error"] | ||
| 1622 | pub const fn ore(&self) -> bool { | ||
| 1623 | let val = (self.0 >> 3usize) & 0x01; | ||
| 1624 | val != 0 | ||
| 1625 | } | ||
| 1626 | #[doc = "Overrun error"] | ||
| 1627 | pub fn set_ore(&mut self, val: bool) { | ||
| 1628 | self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize); | ||
| 1629 | } | ||
| 1630 | #[doc = "IDLE line detected"] | ||
| 1631 | pub const fn idle(&self) -> bool { | ||
| 1632 | let val = (self.0 >> 4usize) & 0x01; | ||
| 1633 | val != 0 | ||
| 1634 | } | ||
| 1635 | #[doc = "IDLE line detected"] | ||
| 1636 | pub fn set_idle(&mut self, val: bool) { | ||
| 1637 | self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize); | ||
| 1638 | } | ||
| 1639 | #[doc = "Read data register not empty"] | ||
| 1640 | pub const fn rxne(&self) -> bool { | ||
| 1641 | let val = (self.0 >> 5usize) & 0x01; | ||
| 1642 | val != 0 | ||
| 1643 | } | ||
| 1644 | #[doc = "Read data register not empty"] | ||
| 1645 | pub fn set_rxne(&mut self, val: bool) { | ||
| 1646 | self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize); | ||
| 1647 | } | ||
| 1648 | #[doc = "Transmission complete"] | ||
| 1649 | pub const fn tc(&self) -> bool { | ||
| 1650 | let val = (self.0 >> 6usize) & 0x01; | ||
| 1651 | val != 0 | ||
| 1652 | } | ||
| 1653 | #[doc = "Transmission complete"] | ||
| 1654 | pub fn set_tc(&mut self, val: bool) { | ||
| 1655 | self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize); | ||
| 1656 | } | ||
| 1657 | #[doc = "Transmit data register empty"] | ||
| 1658 | pub const fn txe(&self) -> bool { | ||
| 1659 | let val = (self.0 >> 7usize) & 0x01; | ||
| 1660 | val != 0 | ||
| 1661 | } | ||
| 1662 | #[doc = "Transmit data register empty"] | ||
| 1663 | pub fn set_txe(&mut self, val: bool) { | ||
| 1664 | self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize); | ||
| 1665 | } | ||
| 1666 | #[doc = "LIN break detection flag"] | ||
| 1667 | pub const fn lbd(&self) -> bool { | ||
| 1668 | let val = (self.0 >> 8usize) & 0x01; | ||
| 1669 | val != 0 | ||
| 1670 | } | ||
| 1671 | #[doc = "LIN break detection flag"] | ||
| 1672 | pub fn set_lbd(&mut self, val: bool) { | ||
| 1673 | self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize); | ||
| 776 | } | 1674 | } |
| 777 | } | 1675 | } |
| 778 | impl Default for Pupdr { | 1676 | impl Default for Sr { |
| 779 | fn default() -> Pupdr { | 1677 | fn default() -> Sr { |
| 780 | Pupdr(0) | 1678 | Sr(0) |
| 781 | } | 1679 | } |
| 782 | } | 1680 | } |
| 783 | #[doc = "GPIO alternate function register"] | 1681 | #[doc = "Control register 1"] |
| 784 | #[repr(transparent)] | 1682 | #[repr(transparent)] |
| 785 | #[derive(Copy, Clone, Eq, PartialEq)] | 1683 | #[derive(Copy, Clone, Eq, PartialEq)] |
| 786 | pub struct Afr(pub u32); | 1684 | pub struct Cr1(pub u32); |
| 787 | impl Afr { | 1685 | impl Cr1 { |
| 788 | #[doc = "Alternate function selection for port x bit y (y = 0..15)"] | 1686 | #[doc = "Send break"] |
| 789 | pub fn afr(&self, n: usize) -> super::vals::Afr { | 1687 | pub const fn sbk(&self) -> super::vals::Sbk { |
| 790 | assert!(n < 8usize); | 1688 | let val = (self.0 >> 0usize) & 0x01; |
| 1689 | super::vals::Sbk(val as u8) | ||
| 1690 | } | ||
| 1691 | #[doc = "Send break"] | ||
| 1692 | pub fn set_sbk(&mut self, val: super::vals::Sbk) { | ||
| 1693 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val.0 as u32) & 0x01) << 0usize); | ||
| 1694 | } | ||
| 1695 | #[doc = "Receiver wakeup"] | ||
| 1696 | pub const fn rwu(&self) -> super::vals::Rwu { | ||
| 1697 | let val = (self.0 >> 1usize) & 0x01; | ||
| 1698 | super::vals::Rwu(val as u8) | ||
| 1699 | } | ||
| 1700 | #[doc = "Receiver wakeup"] | ||
| 1701 | pub fn set_rwu(&mut self, val: super::vals::Rwu) { | ||
| 1702 | self.0 = (self.0 & !(0x01 << 1usize)) | (((val.0 as u32) & 0x01) << 1usize); | ||
| 1703 | } | ||
| 1704 | #[doc = "Receiver enable"] | ||
| 1705 | pub const fn re(&self) -> bool { | ||
| 1706 | let val = (self.0 >> 2usize) & 0x01; | ||
| 1707 | val != 0 | ||
| 1708 | } | ||
| 1709 | #[doc = "Receiver enable"] | ||
| 1710 | pub fn set_re(&mut self, val: bool) { | ||
| 1711 | self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize); | ||
| 1712 | } | ||
| 1713 | #[doc = "Transmitter enable"] | ||
| 1714 | pub const fn te(&self) -> bool { | ||
| 1715 | let val = (self.0 >> 3usize) & 0x01; | ||
| 1716 | val != 0 | ||
| 1717 | } | ||
| 1718 | #[doc = "Transmitter enable"] | ||
| 1719 | pub fn set_te(&mut self, val: bool) { | ||
| 1720 | self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize); | ||
| 1721 | } | ||
| 1722 | #[doc = "IDLE interrupt enable"] | ||
| 1723 | pub const fn idleie(&self) -> bool { | ||
| 1724 | let val = (self.0 >> 4usize) & 0x01; | ||
| 1725 | val != 0 | ||
| 1726 | } | ||
| 1727 | #[doc = "IDLE interrupt enable"] | ||
| 1728 | pub fn set_idleie(&mut self, val: bool) { | ||
| 1729 | self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize); | ||
| 1730 | } | ||
| 1731 | #[doc = "RXNE interrupt enable"] | ||
| 1732 | pub const fn rxneie(&self) -> bool { | ||
| 1733 | let val = (self.0 >> 5usize) & 0x01; | ||
| 1734 | val != 0 | ||
| 1735 | } | ||
| 1736 | #[doc = "RXNE interrupt enable"] | ||
| 1737 | pub fn set_rxneie(&mut self, val: bool) { | ||
| 1738 | self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize); | ||
| 1739 | } | ||
| 1740 | #[doc = "Transmission complete interrupt enable"] | ||
| 1741 | pub const fn tcie(&self) -> bool { | ||
| 1742 | let val = (self.0 >> 6usize) & 0x01; | ||
| 1743 | val != 0 | ||
| 1744 | } | ||
| 1745 | #[doc = "Transmission complete interrupt enable"] | ||
| 1746 | pub fn set_tcie(&mut self, val: bool) { | ||
| 1747 | self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize); | ||
| 1748 | } | ||
| 1749 | #[doc = "TXE interrupt enable"] | ||
| 1750 | pub const fn txeie(&self) -> bool { | ||
| 1751 | let val = (self.0 >> 7usize) & 0x01; | ||
| 1752 | val != 0 | ||
| 1753 | } | ||
| 1754 | #[doc = "TXE interrupt enable"] | ||
| 1755 | pub fn set_txeie(&mut self, val: bool) { | ||
| 1756 | self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize); | ||
| 1757 | } | ||
| 1758 | #[doc = "PE interrupt enable"] | ||
| 1759 | pub const fn peie(&self) -> bool { | ||
| 1760 | let val = (self.0 >> 8usize) & 0x01; | ||
| 1761 | val != 0 | ||
| 1762 | } | ||
| 1763 | #[doc = "PE interrupt enable"] | ||
| 1764 | pub fn set_peie(&mut self, val: bool) { | ||
| 1765 | self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize); | ||
| 1766 | } | ||
| 1767 | #[doc = "Parity selection"] | ||
| 1768 | pub const fn ps(&self) -> super::vals::Ps { | ||
| 1769 | let val = (self.0 >> 9usize) & 0x01; | ||
| 1770 | super::vals::Ps(val as u8) | ||
| 1771 | } | ||
| 1772 | #[doc = "Parity selection"] | ||
| 1773 | pub fn set_ps(&mut self, val: super::vals::Ps) { | ||
| 1774 | self.0 = (self.0 & !(0x01 << 9usize)) | (((val.0 as u32) & 0x01) << 9usize); | ||
| 1775 | } | ||
| 1776 | #[doc = "Parity control enable"] | ||
| 1777 | pub const fn pce(&self) -> bool { | ||
| 1778 | let val = (self.0 >> 10usize) & 0x01; | ||
| 1779 | val != 0 | ||
| 1780 | } | ||
| 1781 | #[doc = "Parity control enable"] | ||
| 1782 | pub fn set_pce(&mut self, val: bool) { | ||
| 1783 | self.0 = (self.0 & !(0x01 << 10usize)) | (((val as u32) & 0x01) << 10usize); | ||
| 1784 | } | ||
| 1785 | #[doc = "Wakeup method"] | ||
| 1786 | pub const fn wake(&self) -> super::vals::Wake { | ||
| 1787 | let val = (self.0 >> 11usize) & 0x01; | ||
| 1788 | super::vals::Wake(val as u8) | ||
| 1789 | } | ||
| 1790 | #[doc = "Wakeup method"] | ||
| 1791 | pub fn set_wake(&mut self, val: super::vals::Wake) { | ||
| 1792 | self.0 = (self.0 & !(0x01 << 11usize)) | (((val.0 as u32) & 0x01) << 11usize); | ||
| 1793 | } | ||
| 1794 | #[doc = "Word length"] | ||
| 1795 | pub const fn m(&self) -> super::vals::M { | ||
| 1796 | let val = (self.0 >> 12usize) & 0x01; | ||
| 1797 | super::vals::M(val as u8) | ||
| 1798 | } | ||
| 1799 | #[doc = "Word length"] | ||
| 1800 | pub fn set_m(&mut self, val: super::vals::M) { | ||
| 1801 | self.0 = (self.0 & !(0x01 << 12usize)) | (((val.0 as u32) & 0x01) << 12usize); | ||
| 1802 | } | ||
| 1803 | #[doc = "USART enable"] | ||
| 1804 | pub const fn ue(&self) -> bool { | ||
| 1805 | let val = (self.0 >> 13usize) & 0x01; | ||
| 1806 | val != 0 | ||
| 1807 | } | ||
| 1808 | #[doc = "USART enable"] | ||
| 1809 | pub fn set_ue(&mut self, val: bool) { | ||
| 1810 | self.0 = (self.0 & !(0x01 << 13usize)) | (((val as u32) & 0x01) << 13usize); | ||
| 1811 | } | ||
| 1812 | } | ||
| 1813 | impl Default for Cr1 { | ||
| 1814 | fn default() -> Cr1 { | ||
| 1815 | Cr1(0) | ||
| 1816 | } | ||
| 1817 | } | ||
| 1818 | #[doc = "Baud rate register"] | ||
| 1819 | #[repr(transparent)] | ||
| 1820 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 1821 | pub struct Brr(pub u32); | ||
| 1822 | impl Brr { | ||
| 1823 | #[doc = "fraction of USARTDIV"] | ||
| 1824 | pub const fn div_fraction(&self) -> u8 { | ||
| 1825 | let val = (self.0 >> 0usize) & 0x0f; | ||
| 1826 | val as u8 | ||
| 1827 | } | ||
| 1828 | #[doc = "fraction of USARTDIV"] | ||
| 1829 | pub fn set_div_fraction(&mut self, val: u8) { | ||
| 1830 | self.0 = (self.0 & !(0x0f << 0usize)) | (((val as u32) & 0x0f) << 0usize); | ||
| 1831 | } | ||
| 1832 | #[doc = "mantissa of USARTDIV"] | ||
| 1833 | pub const fn div_mantissa(&self) -> u16 { | ||
| 1834 | let val = (self.0 >> 4usize) & 0x0fff; | ||
| 1835 | val as u16 | ||
| 1836 | } | ||
| 1837 | #[doc = "mantissa of USARTDIV"] | ||
| 1838 | pub fn set_div_mantissa(&mut self, val: u16) { | ||
| 1839 | self.0 = (self.0 & !(0x0fff << 4usize)) | (((val as u32) & 0x0fff) << 4usize); | ||
| 1840 | } | ||
| 1841 | } | ||
| 1842 | impl Default for Brr { | ||
| 1843 | fn default() -> Brr { | ||
| 1844 | Brr(0) | ||
| 1845 | } | ||
| 1846 | } | ||
| 1847 | #[doc = "Status register"] | ||
| 1848 | #[repr(transparent)] | ||
| 1849 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 1850 | pub struct SrUsart(pub u32); | ||
| 1851 | impl SrUsart { | ||
| 1852 | #[doc = "Parity error"] | ||
| 1853 | pub const fn pe(&self) -> bool { | ||
| 1854 | let val = (self.0 >> 0usize) & 0x01; | ||
| 1855 | val != 0 | ||
| 1856 | } | ||
| 1857 | #[doc = "Parity error"] | ||
| 1858 | pub fn set_pe(&mut self, val: bool) { | ||
| 1859 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); | ||
| 1860 | } | ||
| 1861 | #[doc = "Framing error"] | ||
| 1862 | pub const fn fe(&self) -> bool { | ||
| 1863 | let val = (self.0 >> 1usize) & 0x01; | ||
| 1864 | val != 0 | ||
| 1865 | } | ||
| 1866 | #[doc = "Framing error"] | ||
| 1867 | pub fn set_fe(&mut self, val: bool) { | ||
| 1868 | self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize); | ||
| 1869 | } | ||
| 1870 | #[doc = "Noise error flag"] | ||
| 1871 | pub const fn ne(&self) -> bool { | ||
| 1872 | let val = (self.0 >> 2usize) & 0x01; | ||
| 1873 | val != 0 | ||
| 1874 | } | ||
| 1875 | #[doc = "Noise error flag"] | ||
| 1876 | pub fn set_ne(&mut self, val: bool) { | ||
| 1877 | self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize); | ||
| 1878 | } | ||
| 1879 | #[doc = "Overrun error"] | ||
| 1880 | pub const fn ore(&self) -> bool { | ||
| 1881 | let val = (self.0 >> 3usize) & 0x01; | ||
| 1882 | val != 0 | ||
| 1883 | } | ||
| 1884 | #[doc = "Overrun error"] | ||
| 1885 | pub fn set_ore(&mut self, val: bool) { | ||
| 1886 | self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize); | ||
| 1887 | } | ||
| 1888 | #[doc = "IDLE line detected"] | ||
| 1889 | pub const fn idle(&self) -> bool { | ||
| 1890 | let val = (self.0 >> 4usize) & 0x01; | ||
| 1891 | val != 0 | ||
| 1892 | } | ||
| 1893 | #[doc = "IDLE line detected"] | ||
| 1894 | pub fn set_idle(&mut self, val: bool) { | ||
| 1895 | self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize); | ||
| 1896 | } | ||
| 1897 | #[doc = "Read data register not empty"] | ||
| 1898 | pub const fn rxne(&self) -> bool { | ||
| 1899 | let val = (self.0 >> 5usize) & 0x01; | ||
| 1900 | val != 0 | ||
| 1901 | } | ||
| 1902 | #[doc = "Read data register not empty"] | ||
| 1903 | pub fn set_rxne(&mut self, val: bool) { | ||
| 1904 | self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize); | ||
| 1905 | } | ||
| 1906 | #[doc = "Transmission complete"] | ||
| 1907 | pub const fn tc(&self) -> bool { | ||
| 1908 | let val = (self.0 >> 6usize) & 0x01; | ||
| 1909 | val != 0 | ||
| 1910 | } | ||
| 1911 | #[doc = "Transmission complete"] | ||
| 1912 | pub fn set_tc(&mut self, val: bool) { | ||
| 1913 | self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize); | ||
| 1914 | } | ||
| 1915 | #[doc = "Transmit data register empty"] | ||
| 1916 | pub const fn txe(&self) -> bool { | ||
| 1917 | let val = (self.0 >> 7usize) & 0x01; | ||
| 1918 | val != 0 | ||
| 1919 | } | ||
| 1920 | #[doc = "Transmit data register empty"] | ||
| 1921 | pub fn set_txe(&mut self, val: bool) { | ||
| 1922 | self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize); | ||
| 1923 | } | ||
| 1924 | #[doc = "LIN break detection flag"] | ||
| 1925 | pub const fn lbd(&self) -> bool { | ||
| 1926 | let val = (self.0 >> 8usize) & 0x01; | ||
| 1927 | val != 0 | ||
| 1928 | } | ||
| 1929 | #[doc = "LIN break detection flag"] | ||
| 1930 | pub fn set_lbd(&mut self, val: bool) { | ||
| 1931 | self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize); | ||
| 1932 | } | ||
| 1933 | #[doc = "CTS flag"] | ||
| 1934 | pub const fn cts(&self) -> bool { | ||
| 1935 | let val = (self.0 >> 9usize) & 0x01; | ||
| 1936 | val != 0 | ||
| 1937 | } | ||
| 1938 | #[doc = "CTS flag"] | ||
| 1939 | pub fn set_cts(&mut self, val: bool) { | ||
| 1940 | self.0 = (self.0 & !(0x01 << 9usize)) | (((val as u32) & 0x01) << 9usize); | ||
| 1941 | } | ||
| 1942 | } | ||
| 1943 | impl Default for SrUsart { | ||
| 1944 | fn default() -> SrUsart { | ||
| 1945 | SrUsart(0) | ||
| 1946 | } | ||
| 1947 | } | ||
| 1948 | #[doc = "Control register 3"] | ||
| 1949 | #[repr(transparent)] | ||
| 1950 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 1951 | pub struct Cr3Usart(pub u32); | ||
| 1952 | impl Cr3Usart { | ||
| 1953 | #[doc = "Error interrupt enable"] | ||
| 1954 | pub const fn eie(&self) -> bool { | ||
| 1955 | let val = (self.0 >> 0usize) & 0x01; | ||
| 1956 | val != 0 | ||
| 1957 | } | ||
| 1958 | #[doc = "Error interrupt enable"] | ||
| 1959 | pub fn set_eie(&mut self, val: bool) { | ||
| 1960 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); | ||
| 1961 | } | ||
| 1962 | #[doc = "IrDA mode enable"] | ||
| 1963 | pub const fn iren(&self) -> bool { | ||
| 1964 | let val = (self.0 >> 1usize) & 0x01; | ||
| 1965 | val != 0 | ||
| 1966 | } | ||
| 1967 | #[doc = "IrDA mode enable"] | ||
| 1968 | pub fn set_iren(&mut self, val: bool) { | ||
| 1969 | self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize); | ||
| 1970 | } | ||
| 1971 | #[doc = "IrDA low-power"] | ||
| 1972 | pub const fn irlp(&self) -> super::vals::Irlp { | ||
| 1973 | let val = (self.0 >> 2usize) & 0x01; | ||
| 1974 | super::vals::Irlp(val as u8) | ||
| 1975 | } | ||
| 1976 | #[doc = "IrDA low-power"] | ||
| 1977 | pub fn set_irlp(&mut self, val: super::vals::Irlp) { | ||
| 1978 | self.0 = (self.0 & !(0x01 << 2usize)) | (((val.0 as u32) & 0x01) << 2usize); | ||
| 1979 | } | ||
| 1980 | #[doc = "Half-duplex selection"] | ||
| 1981 | pub const fn hdsel(&self) -> super::vals::Hdsel { | ||
| 1982 | let val = (self.0 >> 3usize) & 0x01; | ||
| 1983 | super::vals::Hdsel(val as u8) | ||
| 1984 | } | ||
| 1985 | #[doc = "Half-duplex selection"] | ||
| 1986 | pub fn set_hdsel(&mut self, val: super::vals::Hdsel) { | ||
| 1987 | self.0 = (self.0 & !(0x01 << 3usize)) | (((val.0 as u32) & 0x01) << 3usize); | ||
| 1988 | } | ||
| 1989 | #[doc = "Smartcard NACK enable"] | ||
| 1990 | pub const fn nack(&self) -> bool { | ||
| 1991 | let val = (self.0 >> 4usize) & 0x01; | ||
| 1992 | val != 0 | ||
| 1993 | } | ||
| 1994 | #[doc = "Smartcard NACK enable"] | ||
| 1995 | pub fn set_nack(&mut self, val: bool) { | ||
| 1996 | self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize); | ||
| 1997 | } | ||
| 1998 | #[doc = "Smartcard mode enable"] | ||
| 1999 | pub const fn scen(&self) -> bool { | ||
| 2000 | let val = (self.0 >> 5usize) & 0x01; | ||
| 2001 | val != 0 | ||
| 2002 | } | ||
| 2003 | #[doc = "Smartcard mode enable"] | ||
| 2004 | pub fn set_scen(&mut self, val: bool) { | ||
| 2005 | self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize); | ||
| 2006 | } | ||
| 2007 | #[doc = "DMA enable receiver"] | ||
| 2008 | pub const fn dmar(&self) -> bool { | ||
| 2009 | let val = (self.0 >> 6usize) & 0x01; | ||
| 2010 | val != 0 | ||
| 2011 | } | ||
| 2012 | #[doc = "DMA enable receiver"] | ||
| 2013 | pub fn set_dmar(&mut self, val: bool) { | ||
| 2014 | self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize); | ||
| 2015 | } | ||
| 2016 | #[doc = "DMA enable transmitter"] | ||
| 2017 | pub const fn dmat(&self) -> bool { | ||
| 2018 | let val = (self.0 >> 7usize) & 0x01; | ||
| 2019 | val != 0 | ||
| 2020 | } | ||
| 2021 | #[doc = "DMA enable transmitter"] | ||
| 2022 | pub fn set_dmat(&mut self, val: bool) { | ||
| 2023 | self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize); | ||
| 2024 | } | ||
| 2025 | #[doc = "RTS enable"] | ||
| 2026 | pub const fn rtse(&self) -> bool { | ||
| 2027 | let val = (self.0 >> 8usize) & 0x01; | ||
| 2028 | val != 0 | ||
| 2029 | } | ||
| 2030 | #[doc = "RTS enable"] | ||
| 2031 | pub fn set_rtse(&mut self, val: bool) { | ||
| 2032 | self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize); | ||
| 2033 | } | ||
| 2034 | #[doc = "CTS enable"] | ||
| 2035 | pub const fn ctse(&self) -> bool { | ||
| 2036 | let val = (self.0 >> 9usize) & 0x01; | ||
| 2037 | val != 0 | ||
| 2038 | } | ||
| 2039 | #[doc = "CTS enable"] | ||
| 2040 | pub fn set_ctse(&mut self, val: bool) { | ||
| 2041 | self.0 = (self.0 & !(0x01 << 9usize)) | (((val as u32) & 0x01) << 9usize); | ||
| 2042 | } | ||
| 2043 | #[doc = "CTS interrupt enable"] | ||
| 2044 | pub const fn ctsie(&self) -> bool { | ||
| 2045 | let val = (self.0 >> 10usize) & 0x01; | ||
| 2046 | val != 0 | ||
| 2047 | } | ||
| 2048 | #[doc = "CTS interrupt enable"] | ||
| 2049 | pub fn set_ctsie(&mut self, val: bool) { | ||
| 2050 | self.0 = (self.0 & !(0x01 << 10usize)) | (((val as u32) & 0x01) << 10usize); | ||
| 2051 | } | ||
| 2052 | } | ||
| 2053 | impl Default for Cr3Usart { | ||
| 2054 | fn default() -> Cr3Usart { | ||
| 2055 | Cr3Usart(0) | ||
| 2056 | } | ||
| 2057 | } | ||
| 2058 | #[doc = "Data register"] | ||
| 2059 | #[repr(transparent)] | ||
| 2060 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 2061 | pub struct Dr(pub u32); | ||
| 2062 | impl Dr { | ||
| 2063 | #[doc = "Data value"] | ||
| 2064 | pub const fn dr(&self) -> u16 { | ||
| 2065 | let val = (self.0 >> 0usize) & 0x01ff; | ||
| 2066 | val as u16 | ||
| 2067 | } | ||
| 2068 | #[doc = "Data value"] | ||
| 2069 | pub fn set_dr(&mut self, val: u16) { | ||
| 2070 | self.0 = (self.0 & !(0x01ff << 0usize)) | (((val as u32) & 0x01ff) << 0usize); | ||
| 2071 | } | ||
| 2072 | } | ||
| 2073 | impl Default for Dr { | ||
| 2074 | fn default() -> Dr { | ||
| 2075 | Dr(0) | ||
| 2076 | } | ||
| 2077 | } | ||
| 2078 | } | ||
| 2079 | } | ||
| 2080 | pub mod syscfg_f4 { | ||
| 2081 | use crate::generic::*; | ||
| 2082 | #[doc = "System configuration controller"] | ||
| 2083 | #[derive(Copy, Clone)] | ||
| 2084 | pub struct Syscfg(pub *mut u8); | ||
| 2085 | unsafe impl Send for Syscfg {} | ||
| 2086 | unsafe impl Sync for Syscfg {} | ||
| 2087 | impl Syscfg { | ||
| 2088 | #[doc = "memory remap register"] | ||
| 2089 | pub fn memrm(self) -> Reg<regs::Memrm, RW> { | ||
| 2090 | unsafe { Reg::from_ptr(self.0.add(0usize)) } | ||
| 2091 | } | ||
| 2092 | #[doc = "peripheral mode configuration register"] | ||
| 2093 | pub fn pmc(self) -> Reg<regs::Pmc, RW> { | ||
| 2094 | unsafe { Reg::from_ptr(self.0.add(4usize)) } | ||
| 2095 | } | ||
| 2096 | #[doc = "external interrupt configuration register"] | ||
| 2097 | pub fn exticr(self, n: usize) -> Reg<regs::Exticr, RW> { | ||
| 2098 | assert!(n < 4usize); | ||
| 2099 | unsafe { Reg::from_ptr(self.0.add(8usize + n * 4usize)) } | ||
| 2100 | } | ||
| 2101 | #[doc = "Compensation cell control register"] | ||
| 2102 | pub fn cmpcr(self) -> Reg<regs::Cmpcr, R> { | ||
| 2103 | unsafe { Reg::from_ptr(self.0.add(32usize)) } | ||
| 2104 | } | ||
| 2105 | } | ||
| 2106 | pub mod regs { | ||
| 2107 | use crate::generic::*; | ||
| 2108 | #[doc = "external interrupt configuration register"] | ||
| 2109 | #[repr(transparent)] | ||
| 2110 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 2111 | pub struct Exticr(pub u32); | ||
| 2112 | impl Exticr { | ||
| 2113 | #[doc = "EXTI x configuration"] | ||
| 2114 | pub fn exti(&self, n: usize) -> u8 { | ||
| 2115 | assert!(n < 4usize); | ||
| 791 | let offs = 0usize + n * 4usize; | 2116 | let offs = 0usize + n * 4usize; |
| 792 | let val = (self.0 >> offs) & 0x0f; | 2117 | let val = (self.0 >> offs) & 0x0f; |
| 793 | super::vals::Afr(val as u8) | 2118 | val as u8 |
| 794 | } | 2119 | } |
| 795 | #[doc = "Alternate function selection for port x bit y (y = 0..15)"] | 2120 | #[doc = "EXTI x configuration"] |
| 796 | pub fn set_afr(&mut self, n: usize, val: super::vals::Afr) { | 2121 | pub fn set_exti(&mut self, n: usize, val: u8) { |
| 797 | assert!(n < 8usize); | 2122 | assert!(n < 4usize); |
| 798 | let offs = 0usize + n * 4usize; | 2123 | let offs = 0usize + n * 4usize; |
| 799 | self.0 = (self.0 & !(0x0f << offs)) | (((val.0 as u32) & 0x0f) << offs); | 2124 | self.0 = (self.0 & !(0x0f << offs)) | (((val as u32) & 0x0f) << offs); |
| 800 | } | 2125 | } |
| 801 | } | 2126 | } |
| 802 | impl Default for Afr { | 2127 | impl Default for Exticr { |
| 803 | fn default() -> Afr { | 2128 | fn default() -> Exticr { |
| 804 | Afr(0) | 2129 | Exticr(0) |
| 805 | } | 2130 | } |
| 806 | } | 2131 | } |
| 807 | #[doc = "GPIO port output speed register"] | 2132 | #[doc = "peripheral mode configuration register"] |
| 808 | #[repr(transparent)] | 2133 | #[repr(transparent)] |
| 809 | #[derive(Copy, Clone, Eq, PartialEq)] | 2134 | #[derive(Copy, Clone, Eq, PartialEq)] |
| 810 | pub struct Ospeedr(pub u32); | 2135 | pub struct Pmc(pub u32); |
| 811 | impl Ospeedr { | 2136 | impl Pmc { |
| 812 | #[doc = "Port x configuration bits (y = 0..15)"] | 2137 | #[doc = "ADC1DC2"] |
| 813 | pub fn ospeedr(&self, n: usize) -> super::vals::Ospeedr { | 2138 | pub const fn adc1dc2(&self) -> bool { |
| 814 | assert!(n < 16usize); | 2139 | let val = (self.0 >> 16usize) & 0x01; |
| 815 | let offs = 0usize + n * 2usize; | 2140 | val != 0 |
| 816 | let val = (self.0 >> offs) & 0x03; | ||
| 817 | super::vals::Ospeedr(val as u8) | ||
| 818 | } | 2141 | } |
| 819 | #[doc = "Port x configuration bits (y = 0..15)"] | 2142 | #[doc = "ADC1DC2"] |
| 820 | pub fn set_ospeedr(&mut self, n: usize, val: super::vals::Ospeedr) { | 2143 | pub fn set_adc1dc2(&mut self, val: bool) { |
| 821 | assert!(n < 16usize); | 2144 | self.0 = (self.0 & !(0x01 << 16usize)) | (((val as u32) & 0x01) << 16usize); |
| 822 | let offs = 0usize + n * 2usize; | 2145 | } |
| 823 | self.0 = (self.0 & !(0x03 << offs)) | (((val.0 as u32) & 0x03) << offs); | 2146 | #[doc = "ADC2DC2"] |
| 2147 | pub const fn adc2dc2(&self) -> bool { | ||
| 2148 | let val = (self.0 >> 17usize) & 0x01; | ||
| 2149 | val != 0 | ||
| 2150 | } | ||
| 2151 | #[doc = "ADC2DC2"] | ||
| 2152 | pub fn set_adc2dc2(&mut self, val: bool) { | ||
| 2153 | self.0 = (self.0 & !(0x01 << 17usize)) | (((val as u32) & 0x01) << 17usize); | ||
| 2154 | } | ||
| 2155 | #[doc = "ADC3DC2"] | ||
| 2156 | pub const fn adc3dc2(&self) -> bool { | ||
| 2157 | let val = (self.0 >> 18usize) & 0x01; | ||
| 2158 | val != 0 | ||
| 2159 | } | ||
| 2160 | #[doc = "ADC3DC2"] | ||
| 2161 | pub fn set_adc3dc2(&mut self, val: bool) { | ||
| 2162 | self.0 = (self.0 & !(0x01 << 18usize)) | (((val as u32) & 0x01) << 18usize); | ||
| 2163 | } | ||
| 2164 | #[doc = "Ethernet PHY interface selection"] | ||
| 2165 | pub const fn mii_rmii_sel(&self) -> bool { | ||
| 2166 | let val = (self.0 >> 23usize) & 0x01; | ||
| 2167 | val != 0 | ||
| 2168 | } | ||
| 2169 | #[doc = "Ethernet PHY interface selection"] | ||
| 2170 | pub fn set_mii_rmii_sel(&mut self, val: bool) { | ||
| 2171 | self.0 = (self.0 & !(0x01 << 23usize)) | (((val as u32) & 0x01) << 23usize); | ||
| 824 | } | 2172 | } |
| 825 | } | 2173 | } |
| 826 | impl Default for Ospeedr { | 2174 | impl Default for Pmc { |
| 827 | fn default() -> Ospeedr { | 2175 | fn default() -> Pmc { |
| 828 | Ospeedr(0) | 2176 | Pmc(0) |
| 829 | } | 2177 | } |
| 830 | } | 2178 | } |
| 831 | #[doc = "GPIO port output type register"] | 2179 | #[doc = "Compensation cell control register"] |
| 832 | #[repr(transparent)] | 2180 | #[repr(transparent)] |
| 833 | #[derive(Copy, Clone, Eq, PartialEq)] | 2181 | #[derive(Copy, Clone, Eq, PartialEq)] |
| 834 | pub struct Otyper(pub u32); | 2182 | pub struct Cmpcr(pub u32); |
| 835 | impl Otyper { | 2183 | impl Cmpcr { |
| 836 | #[doc = "Port x configuration bits (y = 0..15)"] | 2184 | #[doc = "Compensation cell power-down"] |
| 837 | pub fn ot(&self, n: usize) -> super::vals::Ot { | 2185 | pub const fn cmp_pd(&self) -> bool { |
| 838 | assert!(n < 16usize); | 2186 | let val = (self.0 >> 0usize) & 0x01; |
| 839 | let offs = 0usize + n * 1usize; | 2187 | val != 0 |
| 840 | let val = (self.0 >> offs) & 0x01; | ||
| 841 | super::vals::Ot(val as u8) | ||
| 842 | } | 2188 | } |
| 843 | #[doc = "Port x configuration bits (y = 0..15)"] | 2189 | #[doc = "Compensation cell power-down"] |
| 844 | pub fn set_ot(&mut self, n: usize, val: super::vals::Ot) { | 2190 | pub fn set_cmp_pd(&mut self, val: bool) { |
| 845 | assert!(n < 16usize); | 2191 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); |
| 846 | let offs = 0usize + n * 1usize; | 2192 | } |
| 847 | self.0 = (self.0 & !(0x01 << offs)) | (((val.0 as u32) & 0x01) << offs); | 2193 | #[doc = "READY"] |
| 2194 | pub const fn ready(&self) -> bool { | ||
| 2195 | let val = (self.0 >> 8usize) & 0x01; | ||
| 2196 | val != 0 | ||
| 2197 | } | ||
| 2198 | #[doc = "READY"] | ||
| 2199 | pub fn set_ready(&mut self, val: bool) { | ||
| 2200 | self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize); | ||
| 848 | } | 2201 | } |
| 849 | } | 2202 | } |
| 850 | impl Default for Otyper { | 2203 | impl Default for Cmpcr { |
| 851 | fn default() -> Otyper { | 2204 | fn default() -> Cmpcr { |
| 852 | Otyper(0) | 2205 | Cmpcr(0) |
| 853 | } | 2206 | } |
| 854 | } | 2207 | } |
| 855 | #[doc = "GPIO port configuration lock register"] | 2208 | #[doc = "memory remap register"] |
| 856 | #[repr(transparent)] | 2209 | #[repr(transparent)] |
| 857 | #[derive(Copy, Clone, Eq, PartialEq)] | 2210 | #[derive(Copy, Clone, Eq, PartialEq)] |
| 858 | pub struct Lckr(pub u32); | 2211 | pub struct Memrm(pub u32); |
| 859 | impl Lckr { | 2212 | impl Memrm { |
| 860 | #[doc = "Port x lock bit y (y= 0..15)"] | 2213 | #[doc = "Memory mapping selection"] |
| 861 | pub fn lck(&self, n: usize) -> super::vals::Lck { | 2214 | pub const fn mem_mode(&self) -> u8 { |
| 862 | assert!(n < 16usize); | 2215 | let val = (self.0 >> 0usize) & 0x07; |
| 863 | let offs = 0usize + n * 1usize; | 2216 | val as u8 |
| 864 | let val = (self.0 >> offs) & 0x01; | ||
| 865 | super::vals::Lck(val as u8) | ||
| 866 | } | 2217 | } |
| 867 | #[doc = "Port x lock bit y (y= 0..15)"] | 2218 | #[doc = "Memory mapping selection"] |
| 868 | pub fn set_lck(&mut self, n: usize, val: super::vals::Lck) { | 2219 | pub fn set_mem_mode(&mut self, val: u8) { |
| 869 | assert!(n < 16usize); | 2220 | self.0 = (self.0 & !(0x07 << 0usize)) | (((val as u32) & 0x07) << 0usize); |
| 870 | let offs = 0usize + n * 1usize; | ||
| 871 | self.0 = (self.0 & !(0x01 << offs)) | (((val.0 as u32) & 0x01) << offs); | ||
| 872 | } | 2221 | } |
| 873 | #[doc = "Port x lock bit y (y= 0..15)"] | 2222 | #[doc = "Flash bank mode selection"] |
| 874 | pub const fn lckk(&self) -> super::vals::Lckk { | 2223 | pub const fn fb_mode(&self) -> bool { |
| 875 | let val = (self.0 >> 16usize) & 0x01; | 2224 | let val = (self.0 >> 8usize) & 0x01; |
| 876 | super::vals::Lckk(val as u8) | 2225 | val != 0 |
| 877 | } | 2226 | } |
| 878 | #[doc = "Port x lock bit y (y= 0..15)"] | 2227 | #[doc = "Flash bank mode selection"] |
| 879 | pub fn set_lckk(&mut self, val: super::vals::Lckk) { | 2228 | pub fn set_fb_mode(&mut self, val: bool) { |
| 880 | self.0 = (self.0 & !(0x01 << 16usize)) | (((val.0 as u32) & 0x01) << 16usize); | 2229 | self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize); |
| 2230 | } | ||
| 2231 | #[doc = "FMC memory mapping swap"] | ||
| 2232 | pub const fn swp_fmc(&self) -> u8 { | ||
| 2233 | let val = (self.0 >> 10usize) & 0x03; | ||
| 2234 | val as u8 | ||
| 2235 | } | ||
| 2236 | #[doc = "FMC memory mapping swap"] | ||
| 2237 | pub fn set_swp_fmc(&mut self, val: u8) { | ||
| 2238 | self.0 = (self.0 & !(0x03 << 10usize)) | (((val as u32) & 0x03) << 10usize); | ||
| 881 | } | 2239 | } |
| 882 | } | 2240 | } |
| 883 | impl Default for Lckr { | 2241 | impl Default for Memrm { |
| 884 | fn default() -> Lckr { | 2242 | fn default() -> Memrm { |
| 885 | Lckr(0) | 2243 | Memrm(0) |
| 886 | } | 2244 | } |
| 887 | } | 2245 | } |
| 888 | } | 2246 | } |
| @@ -998,18 +2356,18 @@ pub mod timer_v1 { | |||
| 998 | unsafe { Reg::from_ptr(self.0.add(76usize)) } | 2356 | unsafe { Reg::from_ptr(self.0.add(76usize)) } |
| 999 | } | 2357 | } |
| 1000 | } | 2358 | } |
| 1001 | #[doc = "General purpose 16-bit timer"] | 2359 | #[doc = "Advanced-timers"] |
| 1002 | #[derive(Copy, Clone)] | 2360 | #[derive(Copy, Clone)] |
| 1003 | pub struct TimGp16(pub *mut u8); | 2361 | pub struct TimAdv(pub *mut u8); |
| 1004 | unsafe impl Send for TimGp16 {} | 2362 | unsafe impl Send for TimAdv {} |
| 1005 | unsafe impl Sync for TimGp16 {} | 2363 | unsafe impl Sync for TimAdv {} |
| 1006 | impl TimGp16 { | 2364 | impl TimAdv { |
| 1007 | #[doc = "control register 1"] | 2365 | #[doc = "control register 1"] |
| 1008 | pub fn cr1(self) -> Reg<regs::Cr1Gp, RW> { | 2366 | pub fn cr1(self) -> Reg<regs::Cr1Gp, RW> { |
| 1009 | unsafe { Reg::from_ptr(self.0.add(0usize)) } | 2367 | unsafe { Reg::from_ptr(self.0.add(0usize)) } |
| 1010 | } | 2368 | } |
| 1011 | #[doc = "control register 2"] | 2369 | #[doc = "control register 2"] |
| 1012 | pub fn cr2(self) -> Reg<regs::Cr2Gp, RW> { | 2370 | pub fn cr2(self) -> Reg<regs::Cr2Adv, RW> { |
| 1013 | unsafe { Reg::from_ptr(self.0.add(4usize)) } | 2371 | unsafe { Reg::from_ptr(self.0.add(4usize)) } |
| 1014 | } | 2372 | } |
| 1015 | #[doc = "slave mode control register"] | 2373 | #[doc = "slave mode control register"] |
| @@ -1017,15 +2375,15 @@ pub mod timer_v1 { | |||
| 1017 | unsafe { Reg::from_ptr(self.0.add(8usize)) } | 2375 | unsafe { Reg::from_ptr(self.0.add(8usize)) } |
| 1018 | } | 2376 | } |
| 1019 | #[doc = "DMA/Interrupt enable register"] | 2377 | #[doc = "DMA/Interrupt enable register"] |
| 1020 | pub fn dier(self) -> Reg<regs::DierGp, RW> { | 2378 | pub fn dier(self) -> Reg<regs::DierAdv, RW> { |
| 1021 | unsafe { Reg::from_ptr(self.0.add(12usize)) } | 2379 | unsafe { Reg::from_ptr(self.0.add(12usize)) } |
| 1022 | } | 2380 | } |
| 1023 | #[doc = "status register"] | 2381 | #[doc = "status register"] |
| 1024 | pub fn sr(self) -> Reg<regs::SrGp, RW> { | 2382 | pub fn sr(self) -> Reg<regs::SrAdv, RW> { |
| 1025 | unsafe { Reg::from_ptr(self.0.add(16usize)) } | 2383 | unsafe { Reg::from_ptr(self.0.add(16usize)) } |
| 1026 | } | 2384 | } |
| 1027 | #[doc = "event generation register"] | 2385 | #[doc = "event generation register"] |
| 1028 | pub fn egr(self) -> Reg<regs::EgrGp, W> { | 2386 | pub fn egr(self) -> Reg<regs::EgrAdv, W> { |
| 1029 | unsafe { Reg::from_ptr(self.0.add(20usize)) } | 2387 | unsafe { Reg::from_ptr(self.0.add(20usize)) } |
| 1030 | } | 2388 | } |
| 1031 | #[doc = "capture/compare mode register 1 (input mode)"] | 2389 | #[doc = "capture/compare mode register 1 (input mode)"] |
| @@ -1039,7 +2397,7 @@ pub mod timer_v1 { | |||
| 1039 | unsafe { Reg::from_ptr(self.0.add(24usize + n * 4usize)) } | 2397 | unsafe { Reg::from_ptr(self.0.add(24usize + n * 4usize)) } |
| 1040 | } | 2398 | } |
| 1041 | #[doc = "capture/compare enable register"] | 2399 | #[doc = "capture/compare enable register"] |
| 1042 | pub fn ccer(self) -> Reg<regs::CcerGp, RW> { | 2400 | pub fn ccer(self) -> Reg<regs::CcerAdv, RW> { |
| 1043 | unsafe { Reg::from_ptr(self.0.add(32usize)) } | 2401 | unsafe { Reg::from_ptr(self.0.add(32usize)) } |
| 1044 | } | 2402 | } |
| 1045 | #[doc = "counter"] | 2403 | #[doc = "counter"] |
| @@ -1054,11 +2412,19 @@ pub mod timer_v1 { | |||
| 1054 | pub fn arr(self) -> Reg<regs::Arr16, RW> { | 2412 | pub fn arr(self) -> Reg<regs::Arr16, RW> { |
| 1055 | unsafe { Reg::from_ptr(self.0.add(44usize)) } | 2413 | unsafe { Reg::from_ptr(self.0.add(44usize)) } |
| 1056 | } | 2414 | } |
| 2415 | #[doc = "repetition counter register"] | ||
| 2416 | pub fn rcr(self) -> Reg<regs::Rcr, RW> { | ||
| 2417 | unsafe { Reg::from_ptr(self.0.add(48usize)) } | ||
| 2418 | } | ||
| 1057 | #[doc = "capture/compare register"] | 2419 | #[doc = "capture/compare register"] |
| 1058 | pub fn ccr(self, n: usize) -> Reg<regs::Ccr16, RW> { | 2420 | pub fn ccr(self, n: usize) -> Reg<regs::Ccr16, RW> { |
| 1059 | assert!(n < 4usize); | 2421 | assert!(n < 4usize); |
| 1060 | unsafe { Reg::from_ptr(self.0.add(52usize + n * 4usize)) } | 2422 | unsafe { Reg::from_ptr(self.0.add(52usize + n * 4usize)) } |
| 1061 | } | 2423 | } |
| 2424 | #[doc = "break and dead-time register"] | ||
| 2425 | pub fn bdtr(self) -> Reg<regs::Bdtr, RW> { | ||
| 2426 | unsafe { Reg::from_ptr(self.0.add(68usize)) } | ||
| 2427 | } | ||
| 1062 | #[doc = "DMA control register"] | 2428 | #[doc = "DMA control register"] |
| 1063 | pub fn dcr(self) -> Reg<regs::Dcr, RW> { | 2429 | pub fn dcr(self) -> Reg<regs::Dcr, RW> { |
| 1064 | unsafe { Reg::from_ptr(self.0.add(72usize)) } | 2430 | unsafe { Reg::from_ptr(self.0.add(72usize)) } |
| @@ -1068,18 +2434,18 @@ pub mod timer_v1 { | |||
| 1068 | unsafe { Reg::from_ptr(self.0.add(76usize)) } | 2434 | unsafe { Reg::from_ptr(self.0.add(76usize)) } |
| 1069 | } | 2435 | } |
| 1070 | } | 2436 | } |
| 1071 | #[doc = "Advanced-timers"] | 2437 | #[doc = "General purpose 16-bit timer"] |
| 1072 | #[derive(Copy, Clone)] | 2438 | #[derive(Copy, Clone)] |
| 1073 | pub struct TimAdv(pub *mut u8); | 2439 | pub struct TimGp16(pub *mut u8); |
| 1074 | unsafe impl Send for TimAdv {} | 2440 | unsafe impl Send for TimGp16 {} |
| 1075 | unsafe impl Sync for TimAdv {} | 2441 | unsafe impl Sync for TimGp16 {} |
| 1076 | impl TimAdv { | 2442 | impl TimGp16 { |
| 1077 | #[doc = "control register 1"] | 2443 | #[doc = "control register 1"] |
| 1078 | pub fn cr1(self) -> Reg<regs::Cr1Gp, RW> { | 2444 | pub fn cr1(self) -> Reg<regs::Cr1Gp, RW> { |
| 1079 | unsafe { Reg::from_ptr(self.0.add(0usize)) } | 2445 | unsafe { Reg::from_ptr(self.0.add(0usize)) } |
| 1080 | } | 2446 | } |
| 1081 | #[doc = "control register 2"] | 2447 | #[doc = "control register 2"] |
| 1082 | pub fn cr2(self) -> Reg<regs::Cr2Adv, RW> { | 2448 | pub fn cr2(self) -> Reg<regs::Cr2Gp, RW> { |
| 1083 | unsafe { Reg::from_ptr(self.0.add(4usize)) } | 2449 | unsafe { Reg::from_ptr(self.0.add(4usize)) } |
| 1084 | } | 2450 | } |
| 1085 | #[doc = "slave mode control register"] | 2451 | #[doc = "slave mode control register"] |
| @@ -1087,15 +2453,15 @@ pub mod timer_v1 { | |||
| 1087 | unsafe { Reg::from_ptr(self.0.add(8usize)) } | 2453 | unsafe { Reg::from_ptr(self.0.add(8usize)) } |
| 1088 | } | 2454 | } |
| 1089 | #[doc = "DMA/Interrupt enable register"] | 2455 | #[doc = "DMA/Interrupt enable register"] |
| 1090 | pub fn dier(self) -> Reg<regs::DierAdv, RW> { | 2456 | pub fn dier(self) -> Reg<regs::DierGp, RW> { |
| 1091 | unsafe { Reg::from_ptr(self.0.add(12usize)) } | 2457 | unsafe { Reg::from_ptr(self.0.add(12usize)) } |
| 1092 | } | 2458 | } |
| 1093 | #[doc = "status register"] | 2459 | #[doc = "status register"] |
| 1094 | pub fn sr(self) -> Reg<regs::SrAdv, RW> { | 2460 | pub fn sr(self) -> Reg<regs::SrGp, RW> { |
| 1095 | unsafe { Reg::from_ptr(self.0.add(16usize)) } | 2461 | unsafe { Reg::from_ptr(self.0.add(16usize)) } |
| 1096 | } | 2462 | } |
| 1097 | #[doc = "event generation register"] | 2463 | #[doc = "event generation register"] |
| 1098 | pub fn egr(self) -> Reg<regs::EgrAdv, W> { | 2464 | pub fn egr(self) -> Reg<regs::EgrGp, W> { |
| 1099 | unsafe { Reg::from_ptr(self.0.add(20usize)) } | 2465 | unsafe { Reg::from_ptr(self.0.add(20usize)) } |
| 1100 | } | 2466 | } |
| 1101 | #[doc = "capture/compare mode register 1 (input mode)"] | 2467 | #[doc = "capture/compare mode register 1 (input mode)"] |
| @@ -1109,7 +2475,7 @@ pub mod timer_v1 { | |||
| 1109 | unsafe { Reg::from_ptr(self.0.add(24usize + n * 4usize)) } | 2475 | unsafe { Reg::from_ptr(self.0.add(24usize + n * 4usize)) } |
| 1110 | } | 2476 | } |
| 1111 | #[doc = "capture/compare enable register"] | 2477 | #[doc = "capture/compare enable register"] |
| 1112 | pub fn ccer(self) -> Reg<regs::CcerAdv, RW> { | 2478 | pub fn ccer(self) -> Reg<regs::CcerGp, RW> { |
| 1113 | unsafe { Reg::from_ptr(self.0.add(32usize)) } | 2479 | unsafe { Reg::from_ptr(self.0.add(32usize)) } |
| 1114 | } | 2480 | } |
| 1115 | #[doc = "counter"] | 2481 | #[doc = "counter"] |
| @@ -1124,19 +2490,11 @@ pub mod timer_v1 { | |||
| 1124 | pub fn arr(self) -> Reg<regs::Arr16, RW> { | 2490 | pub fn arr(self) -> Reg<regs::Arr16, RW> { |
| 1125 | unsafe { Reg::from_ptr(self.0.add(44usize)) } | 2491 | unsafe { Reg::from_ptr(self.0.add(44usize)) } |
| 1126 | } | 2492 | } |
| 1127 | #[doc = "repetition counter register"] | ||
| 1128 | pub fn rcr(self) -> Reg<regs::Rcr, RW> { | ||
| 1129 | unsafe { Reg::from_ptr(self.0.add(48usize)) } | ||
| 1130 | } | ||
| 1131 | #[doc = "capture/compare register"] | 2493 | #[doc = "capture/compare register"] |
| 1132 | pub fn ccr(self, n: usize) -> Reg<regs::Ccr16, RW> { | 2494 | pub fn ccr(self, n: usize) -> Reg<regs::Ccr16, RW> { |
| 1133 | assert!(n < 4usize); | 2495 | assert!(n < 4usize); |
| 1134 | unsafe { Reg::from_ptr(self.0.add(52usize + n * 4usize)) } | 2496 | unsafe { Reg::from_ptr(self.0.add(52usize + n * 4usize)) } |
| 1135 | } | 2497 | } |
| 1136 | #[doc = "break and dead-time register"] | ||
| 1137 | pub fn bdtr(self) -> Reg<regs::Bdtr, RW> { | ||
| 1138 | unsafe { Reg::from_ptr(self.0.add(68usize)) } | ||
| 1139 | } | ||
| 1140 | #[doc = "DMA control register"] | 2498 | #[doc = "DMA control register"] |
| 1141 | pub fn dcr(self) -> Reg<regs::Dcr, RW> { | 2499 | pub fn dcr(self) -> Reg<regs::Dcr, RW> { |
| 1142 | unsafe { Reg::from_ptr(self.0.add(72usize)) } | 2500 | unsafe { Reg::from_ptr(self.0.add(72usize)) } |
| @@ -1150,8 +2508,24 @@ pub mod timer_v1 { | |||
| 1150 | use crate::generic::*; | 2508 | use crate::generic::*; |
| 1151 | #[repr(transparent)] | 2509 | #[repr(transparent)] |
| 1152 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 2510 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 1153 | pub struct Icf(pub u8); | 2511 | pub struct CcmrOutputCcs(pub u8); |
| 1154 | impl Icf { | 2512 | impl CcmrOutputCcs { |
| 2513 | #[doc = "CCx channel is configured as output"] | ||
| 2514 | pub const OUTPUT: Self = Self(0); | ||
| 2515 | } | ||
| 2516 | #[repr(transparent)] | ||
| 2517 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 2518 | pub struct Arpe(pub u8); | ||
| 2519 | impl Arpe { | ||
| 2520 | #[doc = "TIMx_APRR register is not buffered"] | ||
| 2521 | pub const DISABLED: Self = Self(0); | ||
| 2522 | #[doc = "TIMx_APRR register is buffered"] | ||
| 2523 | pub const ENABLED: Self = Self(0x01); | ||
| 2524 | } | ||
| 2525 | #[repr(transparent)] | ||
| 2526 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 2527 | pub struct Etf(pub u8); | ||
| 2528 | impl Etf { | ||
| 1155 | #[doc = "No filter, sampling is done at fDTS"] | 2529 | #[doc = "No filter, sampling is done at fDTS"] |
| 1156 | pub const NOFILTER: Self = Self(0); | 2530 | pub const NOFILTER: Self = Self(0); |
| 1157 | #[doc = "fSAMPLING=fCK_INT, N=2"] | 2531 | #[doc = "fSAMPLING=fCK_INT, N=2"] |
| @@ -1187,12 +2561,60 @@ pub mod timer_v1 { | |||
| 1187 | } | 2561 | } |
| 1188 | #[repr(transparent)] | 2562 | #[repr(transparent)] |
| 1189 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 2563 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 1190 | pub struct Ece(pub u8); | 2564 | pub struct Urs(pub u8); |
| 1191 | impl Ece { | 2565 | impl Urs { |
| 1192 | #[doc = "External clock mode 2 disabled"] | 2566 | #[doc = "Any of counter overflow/underflow, setting UG, or update through slave mode, generates an update interrupt or DMA request"] |
| 2567 | pub const ANYEVENT: Self = Self(0); | ||
| 2568 | #[doc = "Only counter overflow/underflow generates an update interrupt or DMA request"] | ||
| 2569 | pub const COUNTERONLY: Self = Self(0x01); | ||
| 2570 | } | ||
| 2571 | #[repr(transparent)] | ||
| 2572 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 2573 | pub struct Ocm(pub u8); | ||
| 2574 | impl Ocm { | ||
| 2575 | #[doc = "The comparison between the output compare register TIMx_CCRy and the counter TIMx_CNT has no effect on the outputs"] | ||
| 2576 | pub const FROZEN: Self = Self(0); | ||
| 2577 | #[doc = "Set channel to active level on match. OCyREF signal is forced high when the counter matches the capture/compare register"] | ||
| 2578 | pub const ACTIVEONMATCH: Self = Self(0x01); | ||
| 2579 | #[doc = "Set channel to inactive level on match. OCyREF signal is forced low when the counter matches the capture/compare register"] | ||
| 2580 | pub const INACTIVEONMATCH: Self = Self(0x02); | ||
| 2581 | #[doc = "OCyREF toggles when TIMx_CNT=TIMx_CCRy"] | ||
| 2582 | pub const TOGGLE: Self = Self(0x03); | ||
| 2583 | #[doc = "OCyREF is forced low"] | ||
| 2584 | pub const FORCEINACTIVE: Self = Self(0x04); | ||
| 2585 | #[doc = "OCyREF is forced high"] | ||
| 2586 | pub const FORCEACTIVE: Self = Self(0x05); | ||
| 2587 | #[doc = "In upcounting, channel is active as long as TIMx_CNT<TIMx_CCRy else inactive. In downcounting, channel is inactive as long as TIMx_CNT>TIMx_CCRy else active"] | ||
| 2588 | pub const PWMMODE1: Self = Self(0x06); | ||
| 2589 | #[doc = "Inversely to PwmMode1"] | ||
| 2590 | pub const PWMMODE2: Self = Self(0x07); | ||
| 2591 | } | ||
| 2592 | #[repr(transparent)] | ||
| 2593 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 2594 | pub struct Etp(pub u8); | ||
| 2595 | impl Etp { | ||
| 2596 | #[doc = "ETR is noninverted, active at high level or rising edge"] | ||
| 2597 | pub const NOTINVERTED: Self = Self(0); | ||
| 2598 | #[doc = "ETR is inverted, active at low level or falling edge"] | ||
| 2599 | pub const INVERTED: Self = Self(0x01); | ||
| 2600 | } | ||
| 2601 | #[repr(transparent)] | ||
| 2602 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 2603 | pub struct Ossr(pub u8); | ||
| 2604 | impl Ossr { | ||
| 2605 | #[doc = "When inactive, OC/OCN outputs are disabled"] | ||
| 1193 | pub const DISABLED: Self = Self(0); | 2606 | pub const DISABLED: Self = Self(0); |
| 1194 | #[doc = "External clock mode 2 enabled. The counter is clocked by any active edge on the ETRF signal."] | 2607 | #[doc = "When inactive, OC/OCN outputs are enabled with their inactive level"] |
| 1195 | pub const ENABLED: Self = Self(0x01); | 2608 | pub const IDLELEVEL: Self = Self(0x01); |
| 2609 | } | ||
| 2610 | #[repr(transparent)] | ||
| 2611 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 2612 | pub struct Ccds(pub u8); | ||
| 2613 | impl Ccds { | ||
| 2614 | #[doc = "CCx DMA request sent when CCx event occurs"] | ||
| 2615 | pub const ONCOMPARE: Self = Self(0); | ||
| 2616 | #[doc = "CCx DMA request sent when update event occurs"] | ||
| 2617 | pub const ONUPDATE: Self = Self(0x01); | ||
| 1196 | } | 2618 | } |
| 1197 | #[repr(transparent)] | 2619 | #[repr(transparent)] |
| 1198 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 2620 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| @@ -1217,32 +2639,40 @@ pub mod timer_v1 { | |||
| 1217 | } | 2639 | } |
| 1218 | #[repr(transparent)] | 2640 | #[repr(transparent)] |
| 1219 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 2641 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 1220 | pub struct CcmrInputCcs(pub u8); | 2642 | pub struct Ts(pub u8); |
| 1221 | impl CcmrInputCcs { | 2643 | impl Ts { |
| 1222 | #[doc = "CCx channel is configured as input, normal mapping: ICx mapped to TIx"] | 2644 | #[doc = "Internal Trigger 0 (ITR0)"] |
| 1223 | pub const TI4: Self = Self(0x01); | 2645 | pub const ITR0: Self = Self(0); |
| 1224 | #[doc = "CCx channel is configured as input, alternate mapping (switches 1 with 2, 3 with 4)"] | 2646 | #[doc = "Internal Trigger 1 (ITR1)"] |
| 1225 | pub const TI3: Self = Self(0x02); | 2647 | pub const ITR1: Self = Self(0x01); |
| 1226 | #[doc = "CCx channel is configured as input, ICx is mapped on TRC"] | 2648 | #[doc = "Internal Trigger 2 (ITR2)"] |
| 1227 | pub const TRC: Self = Self(0x03); | 2649 | pub const ITR2: Self = Self(0x02); |
| 2650 | #[doc = "TI1 Edge Detector (TI1F_ED)"] | ||
| 2651 | pub const TI1F_ED: Self = Self(0x04); | ||
| 2652 | #[doc = "Filtered Timer Input 1 (TI1FP1)"] | ||
| 2653 | pub const TI1FP1: Self = Self(0x05); | ||
| 2654 | #[doc = "Filtered Timer Input 2 (TI2FP2)"] | ||
| 2655 | pub const TI2FP2: Self = Self(0x06); | ||
| 2656 | #[doc = "External Trigger input (ETRF)"] | ||
| 2657 | pub const ETRF: Self = Self(0x07); | ||
| 1228 | } | 2658 | } |
| 1229 | #[repr(transparent)] | 2659 | #[repr(transparent)] |
| 1230 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 2660 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 1231 | pub struct Ossi(pub u8); | 2661 | pub struct Ece(pub u8); |
| 1232 | impl Ossi { | 2662 | impl Ece { |
| 1233 | #[doc = "When inactive, OC/OCN outputs are disabled"] | 2663 | #[doc = "External clock mode 2 disabled"] |
| 1234 | pub const DISABLED: Self = Self(0); | 2664 | pub const DISABLED: Self = Self(0); |
| 1235 | #[doc = "When inactive, OC/OCN outputs are forced to idle level"] | 2665 | #[doc = "External clock mode 2 enabled. The counter is clocked by any active edge on the ETRF signal."] |
| 1236 | pub const IDLELEVEL: Self = Self(0x01); | 2666 | pub const ENABLED: Self = Self(0x01); |
| 1237 | } | 2667 | } |
| 1238 | #[repr(transparent)] | 2668 | #[repr(transparent)] |
| 1239 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 2669 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 1240 | pub struct Urs(pub u8); | 2670 | pub struct Tis(pub u8); |
| 1241 | impl Urs { | 2671 | impl Tis { |
| 1242 | #[doc = "Any of counter overflow/underflow, setting UG, or update through slave mode, generates an update interrupt or DMA request"] | 2672 | #[doc = "The TIMx_CH1 pin is connected to TI1 input"] |
| 1243 | pub const ANYEVENT: Self = Self(0); | 2673 | pub const NORMAL: Self = Self(0); |
| 1244 | #[doc = "Only counter overflow/underflow generates an update interrupt or DMA request"] | 2674 | #[doc = "The TIMx_CH1, CH2, CH3 pins are connected to TI1 input"] |
| 1245 | pub const COUNTERONLY: Self = Self(0x01); | 2675 | pub const XOR: Self = Self(0x01); |
| 1246 | } | 2676 | } |
| 1247 | #[repr(transparent)] | 2677 | #[repr(transparent)] |
| 1248 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 2678 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| @@ -1255,32 +2685,31 @@ pub mod timer_v1 { | |||
| 1255 | } | 2685 | } |
| 1256 | #[repr(transparent)] | 2686 | #[repr(transparent)] |
| 1257 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 2687 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 1258 | pub struct Mms(pub u8); | 2688 | pub struct Ossi(pub u8); |
| 1259 | impl Mms { | 2689 | impl Ossi { |
| 1260 | #[doc = "The UG bit from the TIMx_EGR register is used as trigger output"] | 2690 | #[doc = "When inactive, OC/OCN outputs are disabled"] |
| 1261 | pub const RESET: Self = Self(0); | 2691 | pub const DISABLED: Self = Self(0); |
| 1262 | #[doc = "The counter enable signal, CNT_EN, is used as trigger output"] | 2692 | #[doc = "When inactive, OC/OCN outputs are forced to idle level"] |
| 1263 | pub const ENABLE: Self = Self(0x01); | 2693 | pub const IDLELEVEL: Self = Self(0x01); |
| 1264 | #[doc = "The update event is selected as trigger output"] | ||
| 1265 | pub const UPDATE: Self = Self(0x02); | ||
| 1266 | #[doc = "The trigger output send a positive pulse when the CC1IF flag it to be set, as soon as a capture or a compare match occurred"] | ||
| 1267 | pub const COMPAREPULSE: Self = Self(0x03); | ||
| 1268 | #[doc = "OC1REF signal is used as trigger output"] | ||
| 1269 | pub const COMPAREOC1: Self = Self(0x04); | ||
| 1270 | #[doc = "OC2REF signal is used as trigger output"] | ||
| 1271 | pub const COMPAREOC2: Self = Self(0x05); | ||
| 1272 | #[doc = "OC3REF signal is used as trigger output"] | ||
| 1273 | pub const COMPAREOC3: Self = Self(0x06); | ||
| 1274 | #[doc = "OC4REF signal is used as trigger output"] | ||
| 1275 | pub const COMPAREOC4: Self = Self(0x07); | ||
| 1276 | } | 2694 | } |
| 1277 | #[repr(transparent)] | 2695 | #[repr(transparent)] |
| 1278 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 2696 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 1279 | pub struct Arpe(pub u8); | 2697 | pub struct Ckd(pub u8); |
| 1280 | impl Arpe { | 2698 | impl Ckd { |
| 1281 | #[doc = "TIMx_APRR register is not buffered"] | 2699 | #[doc = "t_DTS = t_CK_INT"] |
| 2700 | pub const DIV1: Self = Self(0); | ||
| 2701 | #[doc = "t_DTS = 2 × t_CK_INT"] | ||
| 2702 | pub const DIV2: Self = Self(0x01); | ||
| 2703 | #[doc = "t_DTS = 4 × t_CK_INT"] | ||
| 2704 | pub const DIV4: Self = Self(0x02); | ||
| 2705 | } | ||
| 2706 | #[repr(transparent)] | ||
| 2707 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 2708 | pub struct Ocpe(pub u8); | ||
| 2709 | impl Ocpe { | ||
| 2710 | #[doc = "Preload register on CCR2 disabled. New values written to CCR2 are taken into account immediately"] | ||
| 1282 | pub const DISABLED: Self = Self(0); | 2711 | pub const DISABLED: Self = Self(0); |
| 1283 | #[doc = "TIMx_APRR register is buffered"] | 2712 | #[doc = "Preload register on CCR2 enabled. Preload value is loaded into active register on each update event"] |
| 1284 | pub const ENABLED: Self = Self(0x01); | 2713 | pub const ENABLED: Self = Self(0x01); |
| 1285 | } | 2714 | } |
| 1286 | #[repr(transparent)] | 2715 | #[repr(transparent)] |
| @@ -1298,62 +2727,42 @@ pub mod timer_v1 { | |||
| 1298 | } | 2727 | } |
| 1299 | #[repr(transparent)] | 2728 | #[repr(transparent)] |
| 1300 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 2729 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 1301 | pub struct Ocm(pub u8); | 2730 | pub struct Dir(pub u8); |
| 1302 | impl Ocm { | 2731 | impl Dir { |
| 1303 | #[doc = "The comparison between the output compare register TIMx_CCRy and the counter TIMx_CNT has no effect on the outputs"] | 2732 | #[doc = "Counter used as upcounter"] |
| 1304 | pub const FROZEN: Self = Self(0); | 2733 | pub const UP: Self = Self(0); |
| 1305 | #[doc = "Set channel to active level on match. OCyREF signal is forced high when the counter matches the capture/compare register"] | 2734 | #[doc = "Counter used as downcounter"] |
| 1306 | pub const ACTIVEONMATCH: Self = Self(0x01); | 2735 | pub const DOWN: Self = Self(0x01); |
| 1307 | #[doc = "Set channel to inactive level on match. OCyREF signal is forced low when the counter matches the capture/compare register"] | ||
| 1308 | pub const INACTIVEONMATCH: Self = Self(0x02); | ||
| 1309 | #[doc = "OCyREF toggles when TIMx_CNT=TIMx_CCRy"] | ||
| 1310 | pub const TOGGLE: Self = Self(0x03); | ||
| 1311 | #[doc = "OCyREF is forced low"] | ||
| 1312 | pub const FORCEINACTIVE: Self = Self(0x04); | ||
| 1313 | #[doc = "OCyREF is forced high"] | ||
| 1314 | pub const FORCEACTIVE: Self = Self(0x05); | ||
| 1315 | #[doc = "In upcounting, channel is active as long as TIMx_CNT<TIMx_CCRy else inactive. In downcounting, channel is inactive as long as TIMx_CNT>TIMx_CCRy else active"] | ||
| 1316 | pub const PWMMODE1: Self = Self(0x06); | ||
| 1317 | #[doc = "Inversely to PwmMode1"] | ||
| 1318 | pub const PWMMODE2: Self = Self(0x07); | ||
| 1319 | } | ||
| 1320 | #[repr(transparent)] | ||
| 1321 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 1322 | pub struct Tis(pub u8); | ||
| 1323 | impl Tis { | ||
| 1324 | #[doc = "The TIMx_CH1 pin is connected to TI1 input"] | ||
| 1325 | pub const NORMAL: Self = Self(0); | ||
| 1326 | #[doc = "The TIMx_CH1, CH2, CH3 pins are connected to TI1 input"] | ||
| 1327 | pub const XOR: Self = Self(0x01); | ||
| 1328 | } | ||
| 1329 | #[repr(transparent)] | ||
| 1330 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 1331 | pub struct Ckd(pub u8); | ||
| 1332 | impl Ckd { | ||
| 1333 | #[doc = "t_DTS = t_CK_INT"] | ||
| 1334 | pub const DIV1: Self = Self(0); | ||
| 1335 | #[doc = "t_DTS = 2 × t_CK_INT"] | ||
| 1336 | pub const DIV2: Self = Self(0x01); | ||
| 1337 | #[doc = "t_DTS = 4 × t_CK_INT"] | ||
| 1338 | pub const DIV4: Self = Self(0x02); | ||
| 1339 | } | 2736 | } |
| 1340 | #[repr(transparent)] | 2737 | #[repr(transparent)] |
| 1341 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 2738 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 1342 | pub struct Ossr(pub u8); | 2739 | pub struct Mms(pub u8); |
| 1343 | impl Ossr { | 2740 | impl Mms { |
| 1344 | #[doc = "When inactive, OC/OCN outputs are disabled"] | 2741 | #[doc = "The UG bit from the TIMx_EGR register is used as trigger output"] |
| 1345 | pub const DISABLED: Self = Self(0); | 2742 | pub const RESET: Self = Self(0); |
| 1346 | #[doc = "When inactive, OC/OCN outputs are enabled with their inactive level"] | 2743 | #[doc = "The counter enable signal, CNT_EN, is used as trigger output"] |
| 1347 | pub const IDLELEVEL: Self = Self(0x01); | 2744 | pub const ENABLE: Self = Self(0x01); |
| 2745 | #[doc = "The update event is selected as trigger output"] | ||
| 2746 | pub const UPDATE: Self = Self(0x02); | ||
| 2747 | #[doc = "The trigger output send a positive pulse when the CC1IF flag it to be set, as soon as a capture or a compare match occurred"] | ||
| 2748 | pub const COMPAREPULSE: Self = Self(0x03); | ||
| 2749 | #[doc = "OC1REF signal is used as trigger output"] | ||
| 2750 | pub const COMPAREOC1: Self = Self(0x04); | ||
| 2751 | #[doc = "OC2REF signal is used as trigger output"] | ||
| 2752 | pub const COMPAREOC2: Self = Self(0x05); | ||
| 2753 | #[doc = "OC3REF signal is used as trigger output"] | ||
| 2754 | pub const COMPAREOC3: Self = Self(0x06); | ||
| 2755 | #[doc = "OC4REF signal is used as trigger output"] | ||
| 2756 | pub const COMPAREOC4: Self = Self(0x07); | ||
| 1348 | } | 2757 | } |
| 1349 | #[repr(transparent)] | 2758 | #[repr(transparent)] |
| 1350 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 2759 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 1351 | pub struct Etp(pub u8); | 2760 | pub struct Msm(pub u8); |
| 1352 | impl Etp { | 2761 | impl Msm { |
| 1353 | #[doc = "ETR is noninverted, active at high level or rising edge"] | 2762 | #[doc = "No action"] |
| 1354 | pub const NOTINVERTED: Self = Self(0); | 2763 | pub const NOSYNC: Self = Self(0); |
| 1355 | #[doc = "ETR is inverted, active at low level or falling edge"] | 2764 | #[doc = "The effect of an event on the trigger input (TRGI) is delayed to allow a perfect synchronization between the current timer and its slaves (through TRGO). It is useful if we want to synchronize several timers on a single external event."] |
| 1356 | pub const INVERTED: Self = Self(0x01); | 2765 | pub const SYNC: Self = Self(0x01); |
| 1357 | } | 2766 | } |
| 1358 | #[repr(transparent)] | 2767 | #[repr(transparent)] |
| 1359 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 2768 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| @@ -1370,26 +2779,19 @@ pub mod timer_v1 { | |||
| 1370 | } | 2779 | } |
| 1371 | #[repr(transparent)] | 2780 | #[repr(transparent)] |
| 1372 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 2781 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 1373 | pub struct Msm(pub u8); | 2782 | pub struct CcmrInputCcs(pub u8); |
| 1374 | impl Msm { | 2783 | impl CcmrInputCcs { |
| 1375 | #[doc = "No action"] | 2784 | #[doc = "CCx channel is configured as input, normal mapping: ICx mapped to TIx"] |
| 1376 | pub const NOSYNC: Self = Self(0); | 2785 | pub const TI4: Self = Self(0x01); |
| 1377 | #[doc = "The effect of an event on the trigger input (TRGI) is delayed to allow a perfect synchronization between the current timer and its slaves (through TRGO). It is useful if we want to synchronize several timers on a single external event."] | 2786 | #[doc = "CCx channel is configured as input, alternate mapping (switches 1 with 2, 3 with 4)"] |
| 1378 | pub const SYNC: Self = Self(0x01); | 2787 | pub const TI3: Self = Self(0x02); |
| 1379 | } | 2788 | #[doc = "CCx channel is configured as input, ICx is mapped on TRC"] |
| 1380 | #[repr(transparent)] | 2789 | pub const TRC: Self = Self(0x03); |
| 1381 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 1382 | pub struct Ccds(pub u8); | ||
| 1383 | impl Ccds { | ||
| 1384 | #[doc = "CCx DMA request sent when CCx event occurs"] | ||
| 1385 | pub const ONCOMPARE: Self = Self(0); | ||
| 1386 | #[doc = "CCx DMA request sent when update event occurs"] | ||
| 1387 | pub const ONUPDATE: Self = Self(0x01); | ||
| 1388 | } | 2790 | } |
| 1389 | #[repr(transparent)] | 2791 | #[repr(transparent)] |
| 1390 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 2792 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 1391 | pub struct Etf(pub u8); | 2793 | pub struct Icf(pub u8); |
| 1392 | impl Etf { | 2794 | impl Icf { |
| 1393 | #[doc = "No filter, sampling is done at fDTS"] | 2795 | #[doc = "No filter, sampling is done at fDTS"] |
| 1394 | pub const NOFILTER: Self = Self(0); | 2796 | pub const NOFILTER: Self = Self(0); |
| 1395 | #[doc = "fSAMPLING=fCK_INT, N=2"] | 2797 | #[doc = "fSAMPLING=fCK_INT, N=2"] |
| @@ -1423,410 +2825,263 @@ pub mod timer_v1 { | |||
| 1423 | #[doc = "fSAMPLING=fDTS/32, N=8"] | 2825 | #[doc = "fSAMPLING=fDTS/32, N=8"] |
| 1424 | pub const FDTS_DIV32_N8: Self = Self(0x0f); | 2826 | pub const FDTS_DIV32_N8: Self = Self(0x0f); |
| 1425 | } | 2827 | } |
| 1426 | #[repr(transparent)] | ||
| 1427 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 1428 | pub struct Ocpe(pub u8); | ||
| 1429 | impl Ocpe { | ||
| 1430 | #[doc = "Preload register on CCR2 disabled. New values written to CCR2 are taken into account immediately"] | ||
| 1431 | pub const DISABLED: Self = Self(0); | ||
| 1432 | #[doc = "Preload register on CCR2 enabled. Preload value is loaded into active register on each update event"] | ||
| 1433 | pub const ENABLED: Self = Self(0x01); | ||
| 1434 | } | ||
| 1435 | #[repr(transparent)] | ||
| 1436 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 1437 | pub struct Dir(pub u8); | ||
| 1438 | impl Dir { | ||
| 1439 | #[doc = "Counter used as upcounter"] | ||
| 1440 | pub const UP: Self = Self(0); | ||
| 1441 | #[doc = "Counter used as downcounter"] | ||
| 1442 | pub const DOWN: Self = Self(0x01); | ||
| 1443 | } | ||
| 1444 | #[repr(transparent)] | ||
| 1445 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 1446 | pub struct CcmrOutputCcs(pub u8); | ||
| 1447 | impl CcmrOutputCcs { | ||
| 1448 | #[doc = "CCx channel is configured as output"] | ||
| 1449 | pub const OUTPUT: Self = Self(0); | ||
| 1450 | } | ||
| 1451 | #[repr(transparent)] | ||
| 1452 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 1453 | pub struct Ts(pub u8); | ||
| 1454 | impl Ts { | ||
| 1455 | #[doc = "Internal Trigger 0 (ITR0)"] | ||
| 1456 | pub const ITR0: Self = Self(0); | ||
| 1457 | #[doc = "Internal Trigger 1 (ITR1)"] | ||
| 1458 | pub const ITR1: Self = Self(0x01); | ||
| 1459 | #[doc = "Internal Trigger 2 (ITR2)"] | ||
| 1460 | pub const ITR2: Self = Self(0x02); | ||
| 1461 | #[doc = "TI1 Edge Detector (TI1F_ED)"] | ||
| 1462 | pub const TI1F_ED: Self = Self(0x04); | ||
| 1463 | #[doc = "Filtered Timer Input 1 (TI1FP1)"] | ||
| 1464 | pub const TI1FP1: Self = Self(0x05); | ||
| 1465 | #[doc = "Filtered Timer Input 2 (TI2FP2)"] | ||
| 1466 | pub const TI2FP2: Self = Self(0x06); | ||
| 1467 | #[doc = "External Trigger input (ETRF)"] | ||
| 1468 | pub const ETRF: Self = Self(0x07); | ||
| 1469 | } | ||
| 1470 | } | 2828 | } |
| 1471 | pub mod regs { | 2829 | pub mod regs { |
| 1472 | use crate::generic::*; | 2830 | use crate::generic::*; |
| 1473 | #[doc = "prescaler"] | 2831 | #[doc = "DMA control register"] |
| 1474 | #[repr(transparent)] | 2832 | #[repr(transparent)] |
| 1475 | #[derive(Copy, Clone, Eq, PartialEq)] | 2833 | #[derive(Copy, Clone, Eq, PartialEq)] |
| 1476 | pub struct Psc(pub u32); | 2834 | pub struct Dcr(pub u32); |
| 1477 | impl Psc { | 2835 | impl Dcr { |
| 1478 | #[doc = "Prescaler value"] | 2836 | #[doc = "DMA base address"] |
| 1479 | pub const fn psc(&self) -> u16 { | 2837 | pub const fn dba(&self) -> u8 { |
| 1480 | let val = (self.0 >> 0usize) & 0xffff; | 2838 | let val = (self.0 >> 0usize) & 0x1f; |
| 1481 | val as u16 | 2839 | val as u8 |
| 1482 | } | 2840 | } |
| 1483 | #[doc = "Prescaler value"] | 2841 | #[doc = "DMA base address"] |
| 1484 | pub fn set_psc(&mut self, val: u16) { | 2842 | pub fn set_dba(&mut self, val: u8) { |
| 1485 | self.0 = (self.0 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 0usize); | 2843 | self.0 = (self.0 & !(0x1f << 0usize)) | (((val as u32) & 0x1f) << 0usize); |
| 2844 | } | ||
| 2845 | #[doc = "DMA burst length"] | ||
| 2846 | pub const fn dbl(&self) -> u8 { | ||
| 2847 | let val = (self.0 >> 8usize) & 0x1f; | ||
| 2848 | val as u8 | ||
| 2849 | } | ||
| 2850 | #[doc = "DMA burst length"] | ||
| 2851 | pub fn set_dbl(&mut self, val: u8) { | ||
| 2852 | self.0 = (self.0 & !(0x1f << 8usize)) | (((val as u32) & 0x1f) << 8usize); | ||
| 1486 | } | 2853 | } |
| 1487 | } | 2854 | } |
| 1488 | impl Default for Psc { | 2855 | impl Default for Dcr { |
| 1489 | fn default() -> Psc { | 2856 | fn default() -> Dcr { |
| 1490 | Psc(0) | 2857 | Dcr(0) |
| 1491 | } | 2858 | } |
| 1492 | } | 2859 | } |
| 1493 | #[doc = "control register 2"] | 2860 | #[doc = "counter"] |
| 1494 | #[repr(transparent)] | 2861 | #[repr(transparent)] |
| 1495 | #[derive(Copy, Clone, Eq, PartialEq)] | 2862 | #[derive(Copy, Clone, Eq, PartialEq)] |
| 1496 | pub struct Cr2Adv(pub u32); | 2863 | pub struct Cnt16(pub u32); |
| 1497 | impl Cr2Adv { | 2864 | impl Cnt16 { |
| 1498 | #[doc = "Capture/compare preloaded control"] | 2865 | #[doc = "counter value"] |
| 1499 | pub const fn ccpc(&self) -> bool { | 2866 | pub const fn cnt(&self) -> u16 { |
| 1500 | let val = (self.0 >> 0usize) & 0x01; | 2867 | let val = (self.0 >> 0usize) & 0xffff; |
| 1501 | val != 0 | 2868 | val as u16 |
| 1502 | } | ||
| 1503 | #[doc = "Capture/compare preloaded control"] | ||
| 1504 | pub fn set_ccpc(&mut self, val: bool) { | ||
| 1505 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); | ||
| 1506 | } | ||
| 1507 | #[doc = "Capture/compare control update selection"] | ||
| 1508 | pub const fn ccus(&self) -> bool { | ||
| 1509 | let val = (self.0 >> 2usize) & 0x01; | ||
| 1510 | val != 0 | ||
| 1511 | } | ||
| 1512 | #[doc = "Capture/compare control update selection"] | ||
| 1513 | pub fn set_ccus(&mut self, val: bool) { | ||
| 1514 | self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize); | ||
| 1515 | } | ||
| 1516 | #[doc = "Capture/compare DMA selection"] | ||
| 1517 | pub const fn ccds(&self) -> super::vals::Ccds { | ||
| 1518 | let val = (self.0 >> 3usize) & 0x01; | ||
| 1519 | super::vals::Ccds(val as u8) | ||
| 1520 | } | ||
| 1521 | #[doc = "Capture/compare DMA selection"] | ||
| 1522 | pub fn set_ccds(&mut self, val: super::vals::Ccds) { | ||
| 1523 | self.0 = (self.0 & !(0x01 << 3usize)) | (((val.0 as u32) & 0x01) << 3usize); | ||
| 1524 | } | ||
| 1525 | #[doc = "Master mode selection"] | ||
| 1526 | pub const fn mms(&self) -> super::vals::Mms { | ||
| 1527 | let val = (self.0 >> 4usize) & 0x07; | ||
| 1528 | super::vals::Mms(val as u8) | ||
| 1529 | } | ||
| 1530 | #[doc = "Master mode selection"] | ||
| 1531 | pub fn set_mms(&mut self, val: super::vals::Mms) { | ||
| 1532 | self.0 = (self.0 & !(0x07 << 4usize)) | (((val.0 as u32) & 0x07) << 4usize); | ||
| 1533 | } | 2869 | } |
| 1534 | #[doc = "TI1 selection"] | 2870 | #[doc = "counter value"] |
| 1535 | pub const fn ti1s(&self) -> super::vals::Tis { | 2871 | pub fn set_cnt(&mut self, val: u16) { |
| 1536 | let val = (self.0 >> 7usize) & 0x01; | 2872 | self.0 = (self.0 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 0usize); |
| 1537 | super::vals::Tis(val as u8) | ||
| 1538 | } | 2873 | } |
| 1539 | #[doc = "TI1 selection"] | 2874 | } |
| 1540 | pub fn set_ti1s(&mut self, val: super::vals::Tis) { | 2875 | impl Default for Cnt16 { |
| 1541 | self.0 = (self.0 & !(0x01 << 7usize)) | (((val.0 as u32) & 0x01) << 7usize); | 2876 | fn default() -> Cnt16 { |
| 2877 | Cnt16(0) | ||
| 1542 | } | 2878 | } |
| 1543 | #[doc = "Output Idle state 1"] | 2879 | } |
| 1544 | pub fn ois(&self, n: usize) -> bool { | 2880 | #[doc = "capture/compare enable register"] |
| 2881 | #[repr(transparent)] | ||
| 2882 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 2883 | pub struct CcerAdv(pub u32); | ||
| 2884 | impl CcerAdv { | ||
| 2885 | #[doc = "Capture/Compare 1 output enable"] | ||
| 2886 | pub fn cce(&self, n: usize) -> bool { | ||
| 1545 | assert!(n < 4usize); | 2887 | assert!(n < 4usize); |
| 1546 | let offs = 8usize + n * 2usize; | 2888 | let offs = 0usize + n * 4usize; |
| 1547 | let val = (self.0 >> offs) & 0x01; | 2889 | let val = (self.0 >> offs) & 0x01; |
| 1548 | val != 0 | 2890 | val != 0 |
| 1549 | } | 2891 | } |
| 1550 | #[doc = "Output Idle state 1"] | 2892 | #[doc = "Capture/Compare 1 output enable"] |
| 1551 | pub fn set_ois(&mut self, n: usize, val: bool) { | 2893 | pub fn set_cce(&mut self, n: usize, val: bool) { |
| 1552 | assert!(n < 4usize); | 2894 | assert!(n < 4usize); |
| 1553 | let offs = 8usize + n * 2usize; | 2895 | let offs = 0usize + n * 4usize; |
| 1554 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | 2896 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); |
| 1555 | } | 2897 | } |
| 1556 | #[doc = "Output Idle state 1"] | 2898 | #[doc = "Capture/Compare 1 output Polarity"] |
| 1557 | pub const fn ois1n(&self) -> bool { | 2899 | pub fn ccp(&self, n: usize) -> bool { |
| 1558 | let val = (self.0 >> 9usize) & 0x01; | 2900 | assert!(n < 4usize); |
| 2901 | let offs = 1usize + n * 4usize; | ||
| 2902 | let val = (self.0 >> offs) & 0x01; | ||
| 1559 | val != 0 | 2903 | val != 0 |
| 1560 | } | 2904 | } |
| 1561 | #[doc = "Output Idle state 1"] | 2905 | #[doc = "Capture/Compare 1 output Polarity"] |
| 1562 | pub fn set_ois1n(&mut self, val: bool) { | 2906 | pub fn set_ccp(&mut self, n: usize, val: bool) { |
| 1563 | self.0 = (self.0 & !(0x01 << 9usize)) | (((val as u32) & 0x01) << 9usize); | 2907 | assert!(n < 4usize); |
| 2908 | let offs = 1usize + n * 4usize; | ||
| 2909 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | ||
| 1564 | } | 2910 | } |
| 1565 | #[doc = "Output Idle state 2"] | 2911 | #[doc = "Capture/Compare 1 complementary output enable"] |
| 1566 | pub const fn ois2n(&self) -> bool { | 2912 | pub fn ccne(&self, n: usize) -> bool { |
| 1567 | let val = (self.0 >> 11usize) & 0x01; | 2913 | assert!(n < 4usize); |
| 2914 | let offs = 2usize + n * 4usize; | ||
| 2915 | let val = (self.0 >> offs) & 0x01; | ||
| 1568 | val != 0 | 2916 | val != 0 |
| 1569 | } | 2917 | } |
| 1570 | #[doc = "Output Idle state 2"] | 2918 | #[doc = "Capture/Compare 1 complementary output enable"] |
| 1571 | pub fn set_ois2n(&mut self, val: bool) { | 2919 | pub fn set_ccne(&mut self, n: usize, val: bool) { |
| 1572 | self.0 = (self.0 & !(0x01 << 11usize)) | (((val as u32) & 0x01) << 11usize); | 2920 | assert!(n < 4usize); |
| 2921 | let offs = 2usize + n * 4usize; | ||
| 2922 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | ||
| 1573 | } | 2923 | } |
| 1574 | #[doc = "Output Idle state 3"] | 2924 | #[doc = "Capture/Compare 1 output Polarity"] |
| 1575 | pub const fn ois3n(&self) -> bool { | 2925 | pub fn ccnp(&self, n: usize) -> bool { |
| 1576 | let val = (self.0 >> 13usize) & 0x01; | 2926 | assert!(n < 4usize); |
| 2927 | let offs = 3usize + n * 4usize; | ||
| 2928 | let val = (self.0 >> offs) & 0x01; | ||
| 1577 | val != 0 | 2929 | val != 0 |
| 1578 | } | 2930 | } |
| 1579 | #[doc = "Output Idle state 3"] | 2931 | #[doc = "Capture/Compare 1 output Polarity"] |
| 1580 | pub fn set_ois3n(&mut self, val: bool) { | 2932 | pub fn set_ccnp(&mut self, n: usize, val: bool) { |
| 1581 | self.0 = (self.0 & !(0x01 << 13usize)) | (((val as u32) & 0x01) << 13usize); | 2933 | assert!(n < 4usize); |
| 2934 | let offs = 3usize + n * 4usize; | ||
| 2935 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | ||
| 1582 | } | 2936 | } |
| 1583 | } | 2937 | } |
| 1584 | impl Default for Cr2Adv { | 2938 | impl Default for CcerAdv { |
| 1585 | fn default() -> Cr2Adv { | 2939 | fn default() -> CcerAdv { |
| 1586 | Cr2Adv(0) | 2940 | CcerAdv(0) |
| 1587 | } | 2941 | } |
| 1588 | } | 2942 | } |
| 1589 | #[doc = "control register 2"] | 2943 | #[doc = "auto-reload register"] |
| 1590 | #[repr(transparent)] | 2944 | #[repr(transparent)] |
| 1591 | #[derive(Copy, Clone, Eq, PartialEq)] | 2945 | #[derive(Copy, Clone, Eq, PartialEq)] |
| 1592 | pub struct Cr2Basic(pub u32); | 2946 | pub struct Arr16(pub u32); |
| 1593 | impl Cr2Basic { | 2947 | impl Arr16 { |
| 1594 | #[doc = "Master mode selection"] | 2948 | #[doc = "Auto-reload value"] |
| 1595 | pub const fn mms(&self) -> super::vals::Mms { | 2949 | pub const fn arr(&self) -> u16 { |
| 1596 | let val = (self.0 >> 4usize) & 0x07; | 2950 | let val = (self.0 >> 0usize) & 0xffff; |
| 1597 | super::vals::Mms(val as u8) | 2951 | val as u16 |
| 1598 | } | 2952 | } |
| 1599 | #[doc = "Master mode selection"] | 2953 | #[doc = "Auto-reload value"] |
| 1600 | pub fn set_mms(&mut self, val: super::vals::Mms) { | 2954 | pub fn set_arr(&mut self, val: u16) { |
| 1601 | self.0 = (self.0 & !(0x07 << 4usize)) | (((val.0 as u32) & 0x07) << 4usize); | 2955 | self.0 = (self.0 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 0usize); |
| 1602 | } | 2956 | } |
| 1603 | } | 2957 | } |
| 1604 | impl Default for Cr2Basic { | 2958 | impl Default for Arr16 { |
| 1605 | fn default() -> Cr2Basic { | 2959 | fn default() -> Arr16 { |
| 1606 | Cr2Basic(0) | 2960 | Arr16(0) |
| 1607 | } | 2961 | } |
| 1608 | } | 2962 | } |
| 1609 | #[doc = "slave mode control register"] | 2963 | #[doc = "event generation register"] |
| 1610 | #[repr(transparent)] | 2964 | #[repr(transparent)] |
| 1611 | #[derive(Copy, Clone, Eq, PartialEq)] | 2965 | #[derive(Copy, Clone, Eq, PartialEq)] |
| 1612 | pub struct Smcr(pub u32); | 2966 | pub struct EgrBasic(pub u32); |
| 1613 | impl Smcr { | 2967 | impl EgrBasic { |
| 1614 | #[doc = "Slave mode selection"] | 2968 | #[doc = "Update generation"] |
| 1615 | pub const fn sms(&self) -> super::vals::Sms { | 2969 | pub const fn ug(&self) -> bool { |
| 1616 | let val = (self.0 >> 0usize) & 0x07; | 2970 | let val = (self.0 >> 0usize) & 0x01; |
| 1617 | super::vals::Sms(val as u8) | 2971 | val != 0 |
| 1618 | } | ||
| 1619 | #[doc = "Slave mode selection"] | ||
| 1620 | pub fn set_sms(&mut self, val: super::vals::Sms) { | ||
| 1621 | self.0 = (self.0 & !(0x07 << 0usize)) | (((val.0 as u32) & 0x07) << 0usize); | ||
| 1622 | } | ||
| 1623 | #[doc = "Trigger selection"] | ||
| 1624 | pub const fn ts(&self) -> super::vals::Ts { | ||
| 1625 | let val = (self.0 >> 4usize) & 0x07; | ||
| 1626 | super::vals::Ts(val as u8) | ||
| 1627 | } | ||
| 1628 | #[doc = "Trigger selection"] | ||
| 1629 | pub fn set_ts(&mut self, val: super::vals::Ts) { | ||
| 1630 | self.0 = (self.0 & !(0x07 << 4usize)) | (((val.0 as u32) & 0x07) << 4usize); | ||
| 1631 | } | ||
| 1632 | #[doc = "Master/Slave mode"] | ||
| 1633 | pub const fn msm(&self) -> super::vals::Msm { | ||
| 1634 | let val = (self.0 >> 7usize) & 0x01; | ||
| 1635 | super::vals::Msm(val as u8) | ||
| 1636 | } | ||
| 1637 | #[doc = "Master/Slave mode"] | ||
| 1638 | pub fn set_msm(&mut self, val: super::vals::Msm) { | ||
| 1639 | self.0 = (self.0 & !(0x01 << 7usize)) | (((val.0 as u32) & 0x01) << 7usize); | ||
| 1640 | } | ||
| 1641 | #[doc = "External trigger filter"] | ||
| 1642 | pub const fn etf(&self) -> super::vals::Etf { | ||
| 1643 | let val = (self.0 >> 8usize) & 0x0f; | ||
| 1644 | super::vals::Etf(val as u8) | ||
| 1645 | } | ||
| 1646 | #[doc = "External trigger filter"] | ||
| 1647 | pub fn set_etf(&mut self, val: super::vals::Etf) { | ||
| 1648 | self.0 = (self.0 & !(0x0f << 8usize)) | (((val.0 as u32) & 0x0f) << 8usize); | ||
| 1649 | } | ||
| 1650 | #[doc = "External trigger prescaler"] | ||
| 1651 | pub const fn etps(&self) -> super::vals::Etps { | ||
| 1652 | let val = (self.0 >> 12usize) & 0x03; | ||
| 1653 | super::vals::Etps(val as u8) | ||
| 1654 | } | ||
| 1655 | #[doc = "External trigger prescaler"] | ||
| 1656 | pub fn set_etps(&mut self, val: super::vals::Etps) { | ||
| 1657 | self.0 = (self.0 & !(0x03 << 12usize)) | (((val.0 as u32) & 0x03) << 12usize); | ||
| 1658 | } | ||
| 1659 | #[doc = "External clock enable"] | ||
| 1660 | pub const fn ece(&self) -> super::vals::Ece { | ||
| 1661 | let val = (self.0 >> 14usize) & 0x01; | ||
| 1662 | super::vals::Ece(val as u8) | ||
| 1663 | } | ||
| 1664 | #[doc = "External clock enable"] | ||
| 1665 | pub fn set_ece(&mut self, val: super::vals::Ece) { | ||
| 1666 | self.0 = (self.0 & !(0x01 << 14usize)) | (((val.0 as u32) & 0x01) << 14usize); | ||
| 1667 | } | ||
| 1668 | #[doc = "External trigger polarity"] | ||
| 1669 | pub const fn etp(&self) -> super::vals::Etp { | ||
| 1670 | let val = (self.0 >> 15usize) & 0x01; | ||
| 1671 | super::vals::Etp(val as u8) | ||
| 1672 | } | 2972 | } |
| 1673 | #[doc = "External trigger polarity"] | 2973 | #[doc = "Update generation"] |
| 1674 | pub fn set_etp(&mut self, val: super::vals::Etp) { | 2974 | pub fn set_ug(&mut self, val: bool) { |
| 1675 | self.0 = (self.0 & !(0x01 << 15usize)) | (((val.0 as u32) & 0x01) << 15usize); | 2975 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); |
| 1676 | } | 2976 | } |
| 1677 | } | 2977 | } |
| 1678 | impl Default for Smcr { | 2978 | impl Default for EgrBasic { |
| 1679 | fn default() -> Smcr { | 2979 | fn default() -> EgrBasic { |
| 1680 | Smcr(0) | 2980 | EgrBasic(0) |
| 1681 | } | 2981 | } |
| 1682 | } | 2982 | } |
| 1683 | #[doc = "capture/compare mode register 2 (output mode)"] | 2983 | #[doc = "control register 1"] |
| 1684 | #[repr(transparent)] | 2984 | #[repr(transparent)] |
| 1685 | #[derive(Copy, Clone, Eq, PartialEq)] | 2985 | #[derive(Copy, Clone, Eq, PartialEq)] |
| 1686 | pub struct CcmrOutput(pub u32); | 2986 | pub struct Cr1Gp(pub u32); |
| 1687 | impl CcmrOutput { | 2987 | impl Cr1Gp { |
| 1688 | #[doc = "Capture/Compare 3 selection"] | 2988 | #[doc = "Counter enable"] |
| 1689 | pub fn ccs(&self, n: usize) -> super::vals::CcmrOutputCcs { | 2989 | pub const fn cen(&self) -> bool { |
| 1690 | assert!(n < 2usize); | 2990 | let val = (self.0 >> 0usize) & 0x01; |
| 1691 | let offs = 0usize + n * 8usize; | ||
| 1692 | let val = (self.0 >> offs) & 0x03; | ||
| 1693 | super::vals::CcmrOutputCcs(val as u8) | ||
| 1694 | } | ||
| 1695 | #[doc = "Capture/Compare 3 selection"] | ||
| 1696 | pub fn set_ccs(&mut self, n: usize, val: super::vals::CcmrOutputCcs) { | ||
| 1697 | assert!(n < 2usize); | ||
| 1698 | let offs = 0usize + n * 8usize; | ||
| 1699 | self.0 = (self.0 & !(0x03 << offs)) | (((val.0 as u32) & 0x03) << offs); | ||
| 1700 | } | ||
| 1701 | #[doc = "Output compare 3 fast enable"] | ||
| 1702 | pub fn ocfe(&self, n: usize) -> bool { | ||
| 1703 | assert!(n < 2usize); | ||
| 1704 | let offs = 2usize + n * 8usize; | ||
| 1705 | let val = (self.0 >> offs) & 0x01; | ||
| 1706 | val != 0 | 2991 | val != 0 |
| 1707 | } | 2992 | } |
| 1708 | #[doc = "Output compare 3 fast enable"] | 2993 | #[doc = "Counter enable"] |
| 1709 | pub fn set_ocfe(&mut self, n: usize, val: bool) { | 2994 | pub fn set_cen(&mut self, val: bool) { |
| 1710 | assert!(n < 2usize); | 2995 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); |
| 1711 | let offs = 2usize + n * 8usize; | ||
| 1712 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | ||
| 1713 | } | ||
| 1714 | #[doc = "Output compare 3 preload enable"] | ||
| 1715 | pub fn ocpe(&self, n: usize) -> super::vals::Ocpe { | ||
| 1716 | assert!(n < 2usize); | ||
| 1717 | let offs = 3usize + n * 8usize; | ||
| 1718 | let val = (self.0 >> offs) & 0x01; | ||
| 1719 | super::vals::Ocpe(val as u8) | ||
| 1720 | } | ||
| 1721 | #[doc = "Output compare 3 preload enable"] | ||
| 1722 | pub fn set_ocpe(&mut self, n: usize, val: super::vals::Ocpe) { | ||
| 1723 | assert!(n < 2usize); | ||
| 1724 | let offs = 3usize + n * 8usize; | ||
| 1725 | self.0 = (self.0 & !(0x01 << offs)) | (((val.0 as u32) & 0x01) << offs); | ||
| 1726 | } | 2996 | } |
| 1727 | #[doc = "Output compare 3 mode"] | 2997 | #[doc = "Update disable"] |
| 1728 | pub fn ocm(&self, n: usize) -> super::vals::Ocm { | 2998 | pub const fn udis(&self) -> bool { |
| 1729 | assert!(n < 2usize); | 2999 | let val = (self.0 >> 1usize) & 0x01; |
| 1730 | let offs = 4usize + n * 8usize; | 3000 | val != 0 |
| 1731 | let val = (self.0 >> offs) & 0x07; | ||
| 1732 | super::vals::Ocm(val as u8) | ||
| 1733 | } | 3001 | } |
| 1734 | #[doc = "Output compare 3 mode"] | 3002 | #[doc = "Update disable"] |
| 1735 | pub fn set_ocm(&mut self, n: usize, val: super::vals::Ocm) { | 3003 | pub fn set_udis(&mut self, val: bool) { |
| 1736 | assert!(n < 2usize); | 3004 | self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize); |
| 1737 | let offs = 4usize + n * 8usize; | ||
| 1738 | self.0 = (self.0 & !(0x07 << offs)) | (((val.0 as u32) & 0x07) << offs); | ||
| 1739 | } | 3005 | } |
| 1740 | #[doc = "Output compare 3 clear enable"] | 3006 | #[doc = "Update request source"] |
| 1741 | pub fn occe(&self, n: usize) -> bool { | 3007 | pub const fn urs(&self) -> super::vals::Urs { |
| 1742 | assert!(n < 2usize); | 3008 | let val = (self.0 >> 2usize) & 0x01; |
| 1743 | let offs = 7usize + n * 8usize; | 3009 | super::vals::Urs(val as u8) |
| 1744 | let val = (self.0 >> offs) & 0x01; | ||
| 1745 | val != 0 | ||
| 1746 | } | 3010 | } |
| 1747 | #[doc = "Output compare 3 clear enable"] | 3011 | #[doc = "Update request source"] |
| 1748 | pub fn set_occe(&mut self, n: usize, val: bool) { | 3012 | pub fn set_urs(&mut self, val: super::vals::Urs) { |
| 1749 | assert!(n < 2usize); | 3013 | self.0 = (self.0 & !(0x01 << 2usize)) | (((val.0 as u32) & 0x01) << 2usize); |
| 1750 | let offs = 7usize + n * 8usize; | ||
| 1751 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | ||
| 1752 | } | 3014 | } |
| 1753 | } | 3015 | #[doc = "One-pulse mode"] |
| 1754 | impl Default for CcmrOutput { | 3016 | pub const fn opm(&self) -> super::vals::Opm { |
| 1755 | fn default() -> CcmrOutput { | 3017 | let val = (self.0 >> 3usize) & 0x01; |
| 1756 | CcmrOutput(0) | 3018 | super::vals::Opm(val as u8) |
| 1757 | } | 3019 | } |
| 1758 | } | 3020 | #[doc = "One-pulse mode"] |
| 1759 | #[doc = "status register"] | 3021 | pub fn set_opm(&mut self, val: super::vals::Opm) { |
| 1760 | #[repr(transparent)] | 3022 | self.0 = (self.0 & !(0x01 << 3usize)) | (((val.0 as u32) & 0x01) << 3usize); |
| 1761 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 1762 | pub struct SrGp(pub u32); | ||
| 1763 | impl SrGp { | ||
| 1764 | #[doc = "Update interrupt flag"] | ||
| 1765 | pub const fn uif(&self) -> bool { | ||
| 1766 | let val = (self.0 >> 0usize) & 0x01; | ||
| 1767 | val != 0 | ||
| 1768 | } | 3023 | } |
| 1769 | #[doc = "Update interrupt flag"] | 3024 | #[doc = "Direction"] |
| 1770 | pub fn set_uif(&mut self, val: bool) { | 3025 | pub const fn dir(&self) -> super::vals::Dir { |
| 1771 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); | 3026 | let val = (self.0 >> 4usize) & 0x01; |
| 3027 | super::vals::Dir(val as u8) | ||
| 1772 | } | 3028 | } |
| 1773 | #[doc = "Capture/compare 1 interrupt flag"] | 3029 | #[doc = "Direction"] |
| 1774 | pub fn ccif(&self, n: usize) -> bool { | 3030 | pub fn set_dir(&mut self, val: super::vals::Dir) { |
| 1775 | assert!(n < 4usize); | 3031 | self.0 = (self.0 & !(0x01 << 4usize)) | (((val.0 as u32) & 0x01) << 4usize); |
| 1776 | let offs = 1usize + n * 1usize; | ||
| 1777 | let val = (self.0 >> offs) & 0x01; | ||
| 1778 | val != 0 | ||
| 1779 | } | 3032 | } |
| 1780 | #[doc = "Capture/compare 1 interrupt flag"] | 3033 | #[doc = "Center-aligned mode selection"] |
| 1781 | pub fn set_ccif(&mut self, n: usize, val: bool) { | 3034 | pub const fn cms(&self) -> super::vals::Cms { |
| 1782 | assert!(n < 4usize); | 3035 | let val = (self.0 >> 5usize) & 0x03; |
| 1783 | let offs = 1usize + n * 1usize; | 3036 | super::vals::Cms(val as u8) |
| 1784 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | ||
| 1785 | } | 3037 | } |
| 1786 | #[doc = "COM interrupt flag"] | 3038 | #[doc = "Center-aligned mode selection"] |
| 1787 | pub const fn comif(&self) -> bool { | 3039 | pub fn set_cms(&mut self, val: super::vals::Cms) { |
| 1788 | let val = (self.0 >> 5usize) & 0x01; | 3040 | self.0 = (self.0 & !(0x03 << 5usize)) | (((val.0 as u32) & 0x03) << 5usize); |
| 1789 | val != 0 | ||
| 1790 | } | 3041 | } |
| 1791 | #[doc = "COM interrupt flag"] | 3042 | #[doc = "Auto-reload preload enable"] |
| 1792 | pub fn set_comif(&mut self, val: bool) { | 3043 | pub const fn arpe(&self) -> super::vals::Arpe { |
| 1793 | self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize); | 3044 | let val = (self.0 >> 7usize) & 0x01; |
| 3045 | super::vals::Arpe(val as u8) | ||
| 1794 | } | 3046 | } |
| 1795 | #[doc = "Trigger interrupt flag"] | 3047 | #[doc = "Auto-reload preload enable"] |
| 1796 | pub const fn tif(&self) -> bool { | 3048 | pub fn set_arpe(&mut self, val: super::vals::Arpe) { |
| 1797 | let val = (self.0 >> 6usize) & 0x01; | 3049 | self.0 = (self.0 & !(0x01 << 7usize)) | (((val.0 as u32) & 0x01) << 7usize); |
| 1798 | val != 0 | ||
| 1799 | } | 3050 | } |
| 1800 | #[doc = "Trigger interrupt flag"] | 3051 | #[doc = "Clock division"] |
| 1801 | pub fn set_tif(&mut self, val: bool) { | 3052 | pub const fn ckd(&self) -> super::vals::Ckd { |
| 1802 | self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize); | 3053 | let val = (self.0 >> 8usize) & 0x03; |
| 3054 | super::vals::Ckd(val as u8) | ||
| 1803 | } | 3055 | } |
| 1804 | #[doc = "Break interrupt flag"] | 3056 | #[doc = "Clock division"] |
| 1805 | pub const fn bif(&self) -> bool { | 3057 | pub fn set_ckd(&mut self, val: super::vals::Ckd) { |
| 1806 | let val = (self.0 >> 7usize) & 0x01; | 3058 | self.0 = (self.0 & !(0x03 << 8usize)) | (((val.0 as u32) & 0x03) << 8usize); |
| 1807 | val != 0 | ||
| 1808 | } | 3059 | } |
| 1809 | #[doc = "Break interrupt flag"] | 3060 | } |
| 1810 | pub fn set_bif(&mut self, val: bool) { | 3061 | impl Default for Cr1Gp { |
| 1811 | self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize); | 3062 | fn default() -> Cr1Gp { |
| 3063 | Cr1Gp(0) | ||
| 1812 | } | 3064 | } |
| 1813 | #[doc = "Capture/Compare 1 overcapture flag"] | 3065 | } |
| 1814 | pub fn ccof(&self, n: usize) -> bool { | 3066 | #[doc = "counter"] |
| 1815 | assert!(n < 4usize); | 3067 | #[repr(transparent)] |
| 1816 | let offs = 9usize + n * 1usize; | 3068 | #[derive(Copy, Clone, Eq, PartialEq)] |
| 1817 | let val = (self.0 >> offs) & 0x01; | 3069 | pub struct Cnt32(pub u32); |
| 1818 | val != 0 | 3070 | impl Cnt32 { |
| 3071 | #[doc = "counter value"] | ||
| 3072 | pub const fn cnt(&self) -> u32 { | ||
| 3073 | let val = (self.0 >> 0usize) & 0xffff_ffff; | ||
| 3074 | val as u32 | ||
| 1819 | } | 3075 | } |
| 1820 | #[doc = "Capture/Compare 1 overcapture flag"] | 3076 | #[doc = "counter value"] |
| 1821 | pub fn set_ccof(&mut self, n: usize, val: bool) { | 3077 | pub fn set_cnt(&mut self, val: u32) { |
| 1822 | assert!(n < 4usize); | 3078 | self.0 = |
| 1823 | let offs = 9usize + n * 1usize; | 3079 | (self.0 & !(0xffff_ffff << 0usize)) | (((val as u32) & 0xffff_ffff) << 0usize); |
| 1824 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | ||
| 1825 | } | 3080 | } |
| 1826 | } | 3081 | } |
| 1827 | impl Default for SrGp { | 3082 | impl Default for Cnt32 { |
| 1828 | fn default() -> SrGp { | 3083 | fn default() -> Cnt32 { |
| 1829 | SrGp(0) | 3084 | Cnt32(0) |
| 1830 | } | 3085 | } |
| 1831 | } | 3086 | } |
| 1832 | #[doc = "event generation register"] | 3087 | #[doc = "event generation register"] |
| @@ -1889,89 +3144,140 @@ pub mod timer_v1 { | |||
| 1889 | EgrGp(0) | 3144 | EgrGp(0) |
| 1890 | } | 3145 | } |
| 1891 | } | 3146 | } |
| 1892 | #[doc = "control register 1"] | 3147 | #[doc = "status register"] |
| 1893 | #[repr(transparent)] | 3148 | #[repr(transparent)] |
| 1894 | #[derive(Copy, Clone, Eq, PartialEq)] | 3149 | #[derive(Copy, Clone, Eq, PartialEq)] |
| 1895 | pub struct Cr1Basic(pub u32); | 3150 | pub struct SrBasic(pub u32); |
| 1896 | impl Cr1Basic { | 3151 | impl SrBasic { |
| 1897 | #[doc = "Counter enable"] | 3152 | #[doc = "Update interrupt flag"] |
| 1898 | pub const fn cen(&self) -> bool { | 3153 | pub const fn uif(&self) -> bool { |
| 1899 | let val = (self.0 >> 0usize) & 0x01; | 3154 | let val = (self.0 >> 0usize) & 0x01; |
| 1900 | val != 0 | 3155 | val != 0 |
| 1901 | } | 3156 | } |
| 1902 | #[doc = "Counter enable"] | 3157 | #[doc = "Update interrupt flag"] |
| 1903 | pub fn set_cen(&mut self, val: bool) { | 3158 | pub fn set_uif(&mut self, val: bool) { |
| 1904 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); | 3159 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); |
| 1905 | } | 3160 | } |
| 1906 | #[doc = "Update disable"] | 3161 | } |
| 1907 | pub const fn udis(&self) -> bool { | 3162 | impl Default for SrBasic { |
| 1908 | let val = (self.0 >> 1usize) & 0x01; | 3163 | fn default() -> SrBasic { |
| 3164 | SrBasic(0) | ||
| 3165 | } | ||
| 3166 | } | ||
| 3167 | #[doc = "repetition counter register"] | ||
| 3168 | #[repr(transparent)] | ||
| 3169 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 3170 | pub struct Rcr(pub u32); | ||
| 3171 | impl Rcr { | ||
| 3172 | #[doc = "Repetition counter value"] | ||
| 3173 | pub const fn rep(&self) -> u8 { | ||
| 3174 | let val = (self.0 >> 0usize) & 0xff; | ||
| 3175 | val as u8 | ||
| 3176 | } | ||
| 3177 | #[doc = "Repetition counter value"] | ||
| 3178 | pub fn set_rep(&mut self, val: u8) { | ||
| 3179 | self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize); | ||
| 3180 | } | ||
| 3181 | } | ||
| 3182 | impl Default for Rcr { | ||
| 3183 | fn default() -> Rcr { | ||
| 3184 | Rcr(0) | ||
| 3185 | } | ||
| 3186 | } | ||
| 3187 | #[doc = "control register 2"] | ||
| 3188 | #[repr(transparent)] | ||
| 3189 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 3190 | pub struct Cr2Adv(pub u32); | ||
| 3191 | impl Cr2Adv { | ||
| 3192 | #[doc = "Capture/compare preloaded control"] | ||
| 3193 | pub const fn ccpc(&self) -> bool { | ||
| 3194 | let val = (self.0 >> 0usize) & 0x01; | ||
| 1909 | val != 0 | 3195 | val != 0 |
| 1910 | } | 3196 | } |
| 1911 | #[doc = "Update disable"] | 3197 | #[doc = "Capture/compare preloaded control"] |
| 1912 | pub fn set_udis(&mut self, val: bool) { | 3198 | pub fn set_ccpc(&mut self, val: bool) { |
| 1913 | self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize); | 3199 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); |
| 1914 | } | 3200 | } |
| 1915 | #[doc = "Update request source"] | 3201 | #[doc = "Capture/compare control update selection"] |
| 1916 | pub const fn urs(&self) -> super::vals::Urs { | 3202 | pub const fn ccus(&self) -> bool { |
| 1917 | let val = (self.0 >> 2usize) & 0x01; | 3203 | let val = (self.0 >> 2usize) & 0x01; |
| 1918 | super::vals::Urs(val as u8) | 3204 | val != 0 |
| 1919 | } | 3205 | } |
| 1920 | #[doc = "Update request source"] | 3206 | #[doc = "Capture/compare control update selection"] |
| 1921 | pub fn set_urs(&mut self, val: super::vals::Urs) { | 3207 | pub fn set_ccus(&mut self, val: bool) { |
| 1922 | self.0 = (self.0 & !(0x01 << 2usize)) | (((val.0 as u32) & 0x01) << 2usize); | 3208 | self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize); |
| 1923 | } | 3209 | } |
| 1924 | #[doc = "One-pulse mode"] | 3210 | #[doc = "Capture/compare DMA selection"] |
| 1925 | pub const fn opm(&self) -> super::vals::Opm { | 3211 | pub const fn ccds(&self) -> super::vals::Ccds { |
| 1926 | let val = (self.0 >> 3usize) & 0x01; | 3212 | let val = (self.0 >> 3usize) & 0x01; |
| 1927 | super::vals::Opm(val as u8) | 3213 | super::vals::Ccds(val as u8) |
| 1928 | } | 3214 | } |
| 1929 | #[doc = "One-pulse mode"] | 3215 | #[doc = "Capture/compare DMA selection"] |
| 1930 | pub fn set_opm(&mut self, val: super::vals::Opm) { | 3216 | pub fn set_ccds(&mut self, val: super::vals::Ccds) { |
| 1931 | self.0 = (self.0 & !(0x01 << 3usize)) | (((val.0 as u32) & 0x01) << 3usize); | 3217 | self.0 = (self.0 & !(0x01 << 3usize)) | (((val.0 as u32) & 0x01) << 3usize); |
| 1932 | } | 3218 | } |
| 1933 | #[doc = "Auto-reload preload enable"] | 3219 | #[doc = "Master mode selection"] |
| 1934 | pub const fn arpe(&self) -> super::vals::Arpe { | 3220 | pub const fn mms(&self) -> super::vals::Mms { |
| 3221 | let val = (self.0 >> 4usize) & 0x07; | ||
| 3222 | super::vals::Mms(val as u8) | ||
| 3223 | } | ||
| 3224 | #[doc = "Master mode selection"] | ||
| 3225 | pub fn set_mms(&mut self, val: super::vals::Mms) { | ||
| 3226 | self.0 = (self.0 & !(0x07 << 4usize)) | (((val.0 as u32) & 0x07) << 4usize); | ||
| 3227 | } | ||
| 3228 | #[doc = "TI1 selection"] | ||
| 3229 | pub const fn ti1s(&self) -> super::vals::Tis { | ||
| 1935 | let val = (self.0 >> 7usize) & 0x01; | 3230 | let val = (self.0 >> 7usize) & 0x01; |
| 1936 | super::vals::Arpe(val as u8) | 3231 | super::vals::Tis(val as u8) |
| 1937 | } | 3232 | } |
| 1938 | #[doc = "Auto-reload preload enable"] | 3233 | #[doc = "TI1 selection"] |
| 1939 | pub fn set_arpe(&mut self, val: super::vals::Arpe) { | 3234 | pub fn set_ti1s(&mut self, val: super::vals::Tis) { |
| 1940 | self.0 = (self.0 & !(0x01 << 7usize)) | (((val.0 as u32) & 0x01) << 7usize); | 3235 | self.0 = (self.0 & !(0x01 << 7usize)) | (((val.0 as u32) & 0x01) << 7usize); |
| 1941 | } | 3236 | } |
| 1942 | } | 3237 | #[doc = "Output Idle state 1"] |
| 1943 | impl Default for Cr1Basic { | 3238 | pub fn ois(&self, n: usize) -> bool { |
| 1944 | fn default() -> Cr1Basic { | 3239 | assert!(n < 4usize); |
| 1945 | Cr1Basic(0) | 3240 | let offs = 8usize + n * 2usize; |
| 3241 | let val = (self.0 >> offs) & 0x01; | ||
| 3242 | val != 0 | ||
| 1946 | } | 3243 | } |
| 1947 | } | 3244 | #[doc = "Output Idle state 1"] |
| 1948 | #[doc = "DMA control register"] | 3245 | pub fn set_ois(&mut self, n: usize, val: bool) { |
| 1949 | #[repr(transparent)] | 3246 | assert!(n < 4usize); |
| 1950 | #[derive(Copy, Clone, Eq, PartialEq)] | 3247 | let offs = 8usize + n * 2usize; |
| 1951 | pub struct Dcr(pub u32); | 3248 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); |
| 1952 | impl Dcr { | ||
| 1953 | #[doc = "DMA base address"] | ||
| 1954 | pub const fn dba(&self) -> u8 { | ||
| 1955 | let val = (self.0 >> 0usize) & 0x1f; | ||
| 1956 | val as u8 | ||
| 1957 | } | 3249 | } |
| 1958 | #[doc = "DMA base address"] | 3250 | #[doc = "Output Idle state 1"] |
| 1959 | pub fn set_dba(&mut self, val: u8) { | 3251 | pub const fn ois1n(&self) -> bool { |
| 1960 | self.0 = (self.0 & !(0x1f << 0usize)) | (((val as u32) & 0x1f) << 0usize); | 3252 | let val = (self.0 >> 9usize) & 0x01; |
| 3253 | val != 0 | ||
| 1961 | } | 3254 | } |
| 1962 | #[doc = "DMA burst length"] | 3255 | #[doc = "Output Idle state 1"] |
| 1963 | pub const fn dbl(&self) -> u8 { | 3256 | pub fn set_ois1n(&mut self, val: bool) { |
| 1964 | let val = (self.0 >> 8usize) & 0x1f; | 3257 | self.0 = (self.0 & !(0x01 << 9usize)) | (((val as u32) & 0x01) << 9usize); |
| 1965 | val as u8 | ||
| 1966 | } | 3258 | } |
| 1967 | #[doc = "DMA burst length"] | 3259 | #[doc = "Output Idle state 2"] |
| 1968 | pub fn set_dbl(&mut self, val: u8) { | 3260 | pub const fn ois2n(&self) -> bool { |
| 1969 | self.0 = (self.0 & !(0x1f << 8usize)) | (((val as u32) & 0x1f) << 8usize); | 3261 | let val = (self.0 >> 11usize) & 0x01; |
| 3262 | val != 0 | ||
| 3263 | } | ||
| 3264 | #[doc = "Output Idle state 2"] | ||
| 3265 | pub fn set_ois2n(&mut self, val: bool) { | ||
| 3266 | self.0 = (self.0 & !(0x01 << 11usize)) | (((val as u32) & 0x01) << 11usize); | ||
| 3267 | } | ||
| 3268 | #[doc = "Output Idle state 3"] | ||
| 3269 | pub const fn ois3n(&self) -> bool { | ||
| 3270 | let val = (self.0 >> 13usize) & 0x01; | ||
| 3271 | val != 0 | ||
| 3272 | } | ||
| 3273 | #[doc = "Output Idle state 3"] | ||
| 3274 | pub fn set_ois3n(&mut self, val: bool) { | ||
| 3275 | self.0 = (self.0 & !(0x01 << 13usize)) | (((val as u32) & 0x01) << 13usize); | ||
| 1970 | } | 3276 | } |
| 1971 | } | 3277 | } |
| 1972 | impl Default for Dcr { | 3278 | impl Default for Cr2Adv { |
| 1973 | fn default() -> Dcr { | 3279 | fn default() -> Cr2Adv { |
| 1974 | Dcr(0) | 3280 | Cr2Adv(0) |
| 1975 | } | 3281 | } |
| 1976 | } | 3282 | } |
| 1977 | #[doc = "control register 2"] | 3283 | #[doc = "control register 2"] |
| @@ -2012,77 +3318,25 @@ pub mod timer_v1 { | |||
| 2012 | Cr2Gp(0) | 3318 | Cr2Gp(0) |
| 2013 | } | 3319 | } |
| 2014 | } | 3320 | } |
| 2015 | #[doc = "DMA/Interrupt enable register"] | 3321 | #[doc = "auto-reload register"] |
| 2016 | #[repr(transparent)] | 3322 | #[repr(transparent)] |
| 2017 | #[derive(Copy, Clone, Eq, PartialEq)] | 3323 | #[derive(Copy, Clone, Eq, PartialEq)] |
| 2018 | pub struct DierGp(pub u32); | 3324 | pub struct Arr32(pub u32); |
| 2019 | impl DierGp { | 3325 | impl Arr32 { |
| 2020 | #[doc = "Update interrupt enable"] | 3326 | #[doc = "Auto-reload value"] |
| 2021 | pub const fn uie(&self) -> bool { | 3327 | pub const fn arr(&self) -> u32 { |
| 2022 | let val = (self.0 >> 0usize) & 0x01; | 3328 | let val = (self.0 >> 0usize) & 0xffff_ffff; |
| 2023 | val != 0 | 3329 | val as u32 |
| 2024 | } | ||
| 2025 | #[doc = "Update interrupt enable"] | ||
| 2026 | pub fn set_uie(&mut self, val: bool) { | ||
| 2027 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); | ||
| 2028 | } | ||
| 2029 | #[doc = "Capture/Compare 1 interrupt enable"] | ||
| 2030 | pub fn ccie(&self, n: usize) -> bool { | ||
| 2031 | assert!(n < 4usize); | ||
| 2032 | let offs = 1usize + n * 1usize; | ||
| 2033 | let val = (self.0 >> offs) & 0x01; | ||
| 2034 | val != 0 | ||
| 2035 | } | ||
| 2036 | #[doc = "Capture/Compare 1 interrupt enable"] | ||
| 2037 | pub fn set_ccie(&mut self, n: usize, val: bool) { | ||
| 2038 | assert!(n < 4usize); | ||
| 2039 | let offs = 1usize + n * 1usize; | ||
| 2040 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | ||
| 2041 | } | ||
| 2042 | #[doc = "Trigger interrupt enable"] | ||
| 2043 | pub const fn tie(&self) -> bool { | ||
| 2044 | let val = (self.0 >> 6usize) & 0x01; | ||
| 2045 | val != 0 | ||
| 2046 | } | ||
| 2047 | #[doc = "Trigger interrupt enable"] | ||
| 2048 | pub fn set_tie(&mut self, val: bool) { | ||
| 2049 | self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize); | ||
| 2050 | } | ||
| 2051 | #[doc = "Update DMA request enable"] | ||
| 2052 | pub const fn ude(&self) -> bool { | ||
| 2053 | let val = (self.0 >> 8usize) & 0x01; | ||
| 2054 | val != 0 | ||
| 2055 | } | ||
| 2056 | #[doc = "Update DMA request enable"] | ||
| 2057 | pub fn set_ude(&mut self, val: bool) { | ||
| 2058 | self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize); | ||
| 2059 | } | ||
| 2060 | #[doc = "Capture/Compare 1 DMA request enable"] | ||
| 2061 | pub fn ccde(&self, n: usize) -> bool { | ||
| 2062 | assert!(n < 4usize); | ||
| 2063 | let offs = 9usize + n * 1usize; | ||
| 2064 | let val = (self.0 >> offs) & 0x01; | ||
| 2065 | val != 0 | ||
| 2066 | } | ||
| 2067 | #[doc = "Capture/Compare 1 DMA request enable"] | ||
| 2068 | pub fn set_ccde(&mut self, n: usize, val: bool) { | ||
| 2069 | assert!(n < 4usize); | ||
| 2070 | let offs = 9usize + n * 1usize; | ||
| 2071 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | ||
| 2072 | } | ||
| 2073 | #[doc = "Trigger DMA request enable"] | ||
| 2074 | pub const fn tde(&self) -> bool { | ||
| 2075 | let val = (self.0 >> 14usize) & 0x01; | ||
| 2076 | val != 0 | ||
| 2077 | } | 3330 | } |
| 2078 | #[doc = "Trigger DMA request enable"] | 3331 | #[doc = "Auto-reload value"] |
| 2079 | pub fn set_tde(&mut self, val: bool) { | 3332 | pub fn set_arr(&mut self, val: u32) { |
| 2080 | self.0 = (self.0 & !(0x01 << 14usize)) | (((val as u32) & 0x01) << 14usize); | 3333 | self.0 = |
| 3334 | (self.0 & !(0xffff_ffff << 0usize)) | (((val as u32) & 0xffff_ffff) << 0usize); | ||
| 2081 | } | 3335 | } |
| 2082 | } | 3336 | } |
| 2083 | impl Default for DierGp { | 3337 | impl Default for Arr32 { |
| 2084 | fn default() -> DierGp { | 3338 | fn default() -> Arr32 { |
| 2085 | DierGp(0) | 3339 | Arr32(0) |
| 2086 | } | 3340 | } |
| 2087 | } | 3341 | } |
| 2088 | #[doc = "DMA/Interrupt enable register"] | 3342 | #[doc = "DMA/Interrupt enable register"] |
| @@ -2114,89 +3368,6 @@ pub mod timer_v1 { | |||
| 2114 | DierBasic(0) | 3368 | DierBasic(0) |
| 2115 | } | 3369 | } |
| 2116 | } | 3370 | } |
| 2117 | #[doc = "control register 1"] | ||
| 2118 | #[repr(transparent)] | ||
| 2119 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 2120 | pub struct Cr1Gp(pub u32); | ||
| 2121 | impl Cr1Gp { | ||
| 2122 | #[doc = "Counter enable"] | ||
| 2123 | pub const fn cen(&self) -> bool { | ||
| 2124 | let val = (self.0 >> 0usize) & 0x01; | ||
| 2125 | val != 0 | ||
| 2126 | } | ||
| 2127 | #[doc = "Counter enable"] | ||
| 2128 | pub fn set_cen(&mut self, val: bool) { | ||
| 2129 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); | ||
| 2130 | } | ||
| 2131 | #[doc = "Update disable"] | ||
| 2132 | pub const fn udis(&self) -> bool { | ||
| 2133 | let val = (self.0 >> 1usize) & 0x01; | ||
| 2134 | val != 0 | ||
| 2135 | } | ||
| 2136 | #[doc = "Update disable"] | ||
| 2137 | pub fn set_udis(&mut self, val: bool) { | ||
| 2138 | self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize); | ||
| 2139 | } | ||
| 2140 | #[doc = "Update request source"] | ||
| 2141 | pub const fn urs(&self) -> super::vals::Urs { | ||
| 2142 | let val = (self.0 >> 2usize) & 0x01; | ||
| 2143 | super::vals::Urs(val as u8) | ||
| 2144 | } | ||
| 2145 | #[doc = "Update request source"] | ||
| 2146 | pub fn set_urs(&mut self, val: super::vals::Urs) { | ||
| 2147 | self.0 = (self.0 & !(0x01 << 2usize)) | (((val.0 as u32) & 0x01) << 2usize); | ||
| 2148 | } | ||
| 2149 | #[doc = "One-pulse mode"] | ||
| 2150 | pub const fn opm(&self) -> super::vals::Opm { | ||
| 2151 | let val = (self.0 >> 3usize) & 0x01; | ||
| 2152 | super::vals::Opm(val as u8) | ||
| 2153 | } | ||
| 2154 | #[doc = "One-pulse mode"] | ||
| 2155 | pub fn set_opm(&mut self, val: super::vals::Opm) { | ||
| 2156 | self.0 = (self.0 & !(0x01 << 3usize)) | (((val.0 as u32) & 0x01) << 3usize); | ||
| 2157 | } | ||
| 2158 | #[doc = "Direction"] | ||
| 2159 | pub const fn dir(&self) -> super::vals::Dir { | ||
| 2160 | let val = (self.0 >> 4usize) & 0x01; | ||
| 2161 | super::vals::Dir(val as u8) | ||
| 2162 | } | ||
| 2163 | #[doc = "Direction"] | ||
| 2164 | pub fn set_dir(&mut self, val: super::vals::Dir) { | ||
| 2165 | self.0 = (self.0 & !(0x01 << 4usize)) | (((val.0 as u32) & 0x01) << 4usize); | ||
| 2166 | } | ||
| 2167 | #[doc = "Center-aligned mode selection"] | ||
| 2168 | pub const fn cms(&self) -> super::vals::Cms { | ||
| 2169 | let val = (self.0 >> 5usize) & 0x03; | ||
| 2170 | super::vals::Cms(val as u8) | ||
| 2171 | } | ||
| 2172 | #[doc = "Center-aligned mode selection"] | ||
| 2173 | pub fn set_cms(&mut self, val: super::vals::Cms) { | ||
| 2174 | self.0 = (self.0 & !(0x03 << 5usize)) | (((val.0 as u32) & 0x03) << 5usize); | ||
| 2175 | } | ||
| 2176 | #[doc = "Auto-reload preload enable"] | ||
| 2177 | pub const fn arpe(&self) -> super::vals::Arpe { | ||
| 2178 | let val = (self.0 >> 7usize) & 0x01; | ||
| 2179 | super::vals::Arpe(val as u8) | ||
| 2180 | } | ||
| 2181 | #[doc = "Auto-reload preload enable"] | ||
| 2182 | pub fn set_arpe(&mut self, val: super::vals::Arpe) { | ||
| 2183 | self.0 = (self.0 & !(0x01 << 7usize)) | (((val.0 as u32) & 0x01) << 7usize); | ||
| 2184 | } | ||
| 2185 | #[doc = "Clock division"] | ||
| 2186 | pub const fn ckd(&self) -> super::vals::Ckd { | ||
| 2187 | let val = (self.0 >> 8usize) & 0x03; | ||
| 2188 | super::vals::Ckd(val as u8) | ||
| 2189 | } | ||
| 2190 | #[doc = "Clock division"] | ||
| 2191 | pub fn set_ckd(&mut self, val: super::vals::Ckd) { | ||
| 2192 | self.0 = (self.0 & !(0x03 << 8usize)) | (((val.0 as u32) & 0x03) << 8usize); | ||
| 2193 | } | ||
| 2194 | } | ||
| 2195 | impl Default for Cr1Gp { | ||
| 2196 | fn default() -> Cr1Gp { | ||
| 2197 | Cr1Gp(0) | ||
| 2198 | } | ||
| 2199 | } | ||
| 2200 | #[doc = "break and dead-time register"] | 3371 | #[doc = "break and dead-time register"] |
| 2201 | #[repr(transparent)] | 3372 | #[repr(transparent)] |
| 2202 | #[derive(Copy, Clone, Eq, PartialEq)] | 3373 | #[derive(Copy, Clone, Eq, PartialEq)] |
| @@ -2280,95 +3451,151 @@ pub mod timer_v1 { | |||
| 2280 | Bdtr(0) | 3451 | Bdtr(0) |
| 2281 | } | 3452 | } |
| 2282 | } | 3453 | } |
| 2283 | #[doc = "capture/compare mode register 1 (input mode)"] | 3454 | #[doc = "DMA/Interrupt enable register"] |
| 2284 | #[repr(transparent)] | 3455 | #[repr(transparent)] |
| 2285 | #[derive(Copy, Clone, Eq, PartialEq)] | 3456 | #[derive(Copy, Clone, Eq, PartialEq)] |
| 2286 | pub struct CcmrInput(pub u32); | 3457 | pub struct DierGp(pub u32); |
| 2287 | impl CcmrInput { | 3458 | impl DierGp { |
| 2288 | #[doc = "Capture/Compare 1 selection"] | 3459 | #[doc = "Update interrupt enable"] |
| 2289 | pub fn ccs(&self, n: usize) -> super::vals::CcmrInputCcs { | 3460 | pub const fn uie(&self) -> bool { |
| 2290 | assert!(n < 2usize); | 3461 | let val = (self.0 >> 0usize) & 0x01; |
| 2291 | let offs = 0usize + n * 8usize; | 3462 | val != 0 |
| 2292 | let val = (self.0 >> offs) & 0x03; | ||
| 2293 | super::vals::CcmrInputCcs(val as u8) | ||
| 2294 | } | 3463 | } |
| 2295 | #[doc = "Capture/Compare 1 selection"] | 3464 | #[doc = "Update interrupt enable"] |
| 2296 | pub fn set_ccs(&mut self, n: usize, val: super::vals::CcmrInputCcs) { | 3465 | pub fn set_uie(&mut self, val: bool) { |
| 2297 | assert!(n < 2usize); | 3466 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); |
| 2298 | let offs = 0usize + n * 8usize; | ||
| 2299 | self.0 = (self.0 & !(0x03 << offs)) | (((val.0 as u32) & 0x03) << offs); | ||
| 2300 | } | 3467 | } |
| 2301 | #[doc = "Input capture 1 prescaler"] | 3468 | #[doc = "Capture/Compare 1 interrupt enable"] |
| 2302 | pub fn icpsc(&self, n: usize) -> u8 { | 3469 | pub fn ccie(&self, n: usize) -> bool { |
| 2303 | assert!(n < 2usize); | 3470 | assert!(n < 4usize); |
| 2304 | let offs = 2usize + n * 8usize; | 3471 | let offs = 1usize + n * 1usize; |
| 2305 | let val = (self.0 >> offs) & 0x03; | 3472 | let val = (self.0 >> offs) & 0x01; |
| 2306 | val as u8 | 3473 | val != 0 |
| 2307 | } | 3474 | } |
| 2308 | #[doc = "Input capture 1 prescaler"] | 3475 | #[doc = "Capture/Compare 1 interrupt enable"] |
| 2309 | pub fn set_icpsc(&mut self, n: usize, val: u8) { | 3476 | pub fn set_ccie(&mut self, n: usize, val: bool) { |
| 2310 | assert!(n < 2usize); | 3477 | assert!(n < 4usize); |
| 2311 | let offs = 2usize + n * 8usize; | 3478 | let offs = 1usize + n * 1usize; |
| 2312 | self.0 = (self.0 & !(0x03 << offs)) | (((val as u32) & 0x03) << offs); | 3479 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); |
| 2313 | } | 3480 | } |
| 2314 | #[doc = "Input capture 1 filter"] | 3481 | #[doc = "Trigger interrupt enable"] |
| 2315 | pub fn icf(&self, n: usize) -> super::vals::Icf { | 3482 | pub const fn tie(&self) -> bool { |
| 2316 | assert!(n < 2usize); | 3483 | let val = (self.0 >> 6usize) & 0x01; |
| 2317 | let offs = 4usize + n * 8usize; | 3484 | val != 0 |
| 2318 | let val = (self.0 >> offs) & 0x0f; | ||
| 2319 | super::vals::Icf(val as u8) | ||
| 2320 | } | 3485 | } |
| 2321 | #[doc = "Input capture 1 filter"] | 3486 | #[doc = "Trigger interrupt enable"] |
| 2322 | pub fn set_icf(&mut self, n: usize, val: super::vals::Icf) { | 3487 | pub fn set_tie(&mut self, val: bool) { |
| 2323 | assert!(n < 2usize); | 3488 | self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize); |
| 2324 | let offs = 4usize + n * 8usize; | ||
| 2325 | self.0 = (self.0 & !(0x0f << offs)) | (((val.0 as u32) & 0x0f) << offs); | ||
| 2326 | } | 3489 | } |
| 2327 | } | 3490 | #[doc = "Update DMA request enable"] |
| 2328 | impl Default for CcmrInput { | 3491 | pub const fn ude(&self) -> bool { |
| 2329 | fn default() -> CcmrInput { | 3492 | let val = (self.0 >> 8usize) & 0x01; |
| 2330 | CcmrInput(0) | 3493 | val != 0 |
| 2331 | } | 3494 | } |
| 2332 | } | 3495 | #[doc = "Update DMA request enable"] |
| 2333 | #[doc = "DMA address for full transfer"] | 3496 | pub fn set_ude(&mut self, val: bool) { |
| 2334 | #[repr(transparent)] | 3497 | self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize); |
| 2335 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 2336 | pub struct Dmar(pub u32); | ||
| 2337 | impl Dmar { | ||
| 2338 | #[doc = "DMA register for burst accesses"] | ||
| 2339 | pub const fn dmab(&self) -> u16 { | ||
| 2340 | let val = (self.0 >> 0usize) & 0xffff; | ||
| 2341 | val as u16 | ||
| 2342 | } | 3498 | } |
| 2343 | #[doc = "DMA register for burst accesses"] | 3499 | #[doc = "Capture/Compare 1 DMA request enable"] |
| 2344 | pub fn set_dmab(&mut self, val: u16) { | 3500 | pub fn ccde(&self, n: usize) -> bool { |
| 2345 | self.0 = (self.0 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 0usize); | 3501 | assert!(n < 4usize); |
| 3502 | let offs = 9usize + n * 1usize; | ||
| 3503 | let val = (self.0 >> offs) & 0x01; | ||
| 3504 | val != 0 | ||
| 3505 | } | ||
| 3506 | #[doc = "Capture/Compare 1 DMA request enable"] | ||
| 3507 | pub fn set_ccde(&mut self, n: usize, val: bool) { | ||
| 3508 | assert!(n < 4usize); | ||
| 3509 | let offs = 9usize + n * 1usize; | ||
| 3510 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | ||
| 3511 | } | ||
| 3512 | #[doc = "Trigger DMA request enable"] | ||
| 3513 | pub const fn tde(&self) -> bool { | ||
| 3514 | let val = (self.0 >> 14usize) & 0x01; | ||
| 3515 | val != 0 | ||
| 3516 | } | ||
| 3517 | #[doc = "Trigger DMA request enable"] | ||
| 3518 | pub fn set_tde(&mut self, val: bool) { | ||
| 3519 | self.0 = (self.0 & !(0x01 << 14usize)) | (((val as u32) & 0x01) << 14usize); | ||
| 2346 | } | 3520 | } |
| 2347 | } | 3521 | } |
| 2348 | impl Default for Dmar { | 3522 | impl Default for DierGp { |
| 2349 | fn default() -> Dmar { | 3523 | fn default() -> DierGp { |
| 2350 | Dmar(0) | 3524 | DierGp(0) |
| 2351 | } | 3525 | } |
| 2352 | } | 3526 | } |
| 2353 | #[doc = "counter"] | 3527 | #[doc = "slave mode control register"] |
| 2354 | #[repr(transparent)] | 3528 | #[repr(transparent)] |
| 2355 | #[derive(Copy, Clone, Eq, PartialEq)] | 3529 | #[derive(Copy, Clone, Eq, PartialEq)] |
| 2356 | pub struct Cnt32(pub u32); | 3530 | pub struct Smcr(pub u32); |
| 2357 | impl Cnt32 { | 3531 | impl Smcr { |
| 2358 | #[doc = "counter value"] | 3532 | #[doc = "Slave mode selection"] |
| 2359 | pub const fn cnt(&self) -> u32 { | 3533 | pub const fn sms(&self) -> super::vals::Sms { |
| 2360 | let val = (self.0 >> 0usize) & 0xffff_ffff; | 3534 | let val = (self.0 >> 0usize) & 0x07; |
| 2361 | val as u32 | 3535 | super::vals::Sms(val as u8) |
| 2362 | } | 3536 | } |
| 2363 | #[doc = "counter value"] | 3537 | #[doc = "Slave mode selection"] |
| 2364 | pub fn set_cnt(&mut self, val: u32) { | 3538 | pub fn set_sms(&mut self, val: super::vals::Sms) { |
| 2365 | self.0 = | 3539 | self.0 = (self.0 & !(0x07 << 0usize)) | (((val.0 as u32) & 0x07) << 0usize); |
| 2366 | (self.0 & !(0xffff_ffff << 0usize)) | (((val as u32) & 0xffff_ffff) << 0usize); | 3540 | } |
| 3541 | #[doc = "Trigger selection"] | ||
| 3542 | pub const fn ts(&self) -> super::vals::Ts { | ||
| 3543 | let val = (self.0 >> 4usize) & 0x07; | ||
| 3544 | super::vals::Ts(val as u8) | ||
| 3545 | } | ||
| 3546 | #[doc = "Trigger selection"] | ||
| 3547 | pub fn set_ts(&mut self, val: super::vals::Ts) { | ||
| 3548 | self.0 = (self.0 & !(0x07 << 4usize)) | (((val.0 as u32) & 0x07) << 4usize); | ||
| 3549 | } | ||
| 3550 | #[doc = "Master/Slave mode"] | ||
| 3551 | pub const fn msm(&self) -> super::vals::Msm { | ||
| 3552 | let val = (self.0 >> 7usize) & 0x01; | ||
| 3553 | super::vals::Msm(val as u8) | ||
| 3554 | } | ||
| 3555 | #[doc = "Master/Slave mode"] | ||
| 3556 | pub fn set_msm(&mut self, val: super::vals::Msm) { | ||
| 3557 | self.0 = (self.0 & !(0x01 << 7usize)) | (((val.0 as u32) & 0x01) << 7usize); | ||
| 3558 | } | ||
| 3559 | #[doc = "External trigger filter"] | ||
| 3560 | pub const fn etf(&self) -> super::vals::Etf { | ||
| 3561 | let val = (self.0 >> 8usize) & 0x0f; | ||
| 3562 | super::vals::Etf(val as u8) | ||
| 3563 | } | ||
| 3564 | #[doc = "External trigger filter"] | ||
| 3565 | pub fn set_etf(&mut self, val: super::vals::Etf) { | ||
| 3566 | self.0 = (self.0 & !(0x0f << 8usize)) | (((val.0 as u32) & 0x0f) << 8usize); | ||
| 3567 | } | ||
| 3568 | #[doc = "External trigger prescaler"] | ||
| 3569 | pub const fn etps(&self) -> super::vals::Etps { | ||
| 3570 | let val = (self.0 >> 12usize) & 0x03; | ||
| 3571 | super::vals::Etps(val as u8) | ||
| 3572 | } | ||
| 3573 | #[doc = "External trigger prescaler"] | ||
| 3574 | pub fn set_etps(&mut self, val: super::vals::Etps) { | ||
| 3575 | self.0 = (self.0 & !(0x03 << 12usize)) | (((val.0 as u32) & 0x03) << 12usize); | ||
| 3576 | } | ||
| 3577 | #[doc = "External clock enable"] | ||
| 3578 | pub const fn ece(&self) -> super::vals::Ece { | ||
| 3579 | let val = (self.0 >> 14usize) & 0x01; | ||
| 3580 | super::vals::Ece(val as u8) | ||
| 3581 | } | ||
| 3582 | #[doc = "External clock enable"] | ||
| 3583 | pub fn set_ece(&mut self, val: super::vals::Ece) { | ||
| 3584 | self.0 = (self.0 & !(0x01 << 14usize)) | (((val.0 as u32) & 0x01) << 14usize); | ||
| 3585 | } | ||
| 3586 | #[doc = "External trigger polarity"] | ||
| 3587 | pub const fn etp(&self) -> super::vals::Etp { | ||
| 3588 | let val = (self.0 >> 15usize) & 0x01; | ||
| 3589 | super::vals::Etp(val as u8) | ||
| 3590 | } | ||
| 3591 | #[doc = "External trigger polarity"] | ||
| 3592 | pub fn set_etp(&mut self, val: super::vals::Etp) { | ||
| 3593 | self.0 = (self.0 & !(0x01 << 15usize)) | (((val.0 as u32) & 0x01) << 15usize); | ||
| 2367 | } | 3594 | } |
| 2368 | } | 3595 | } |
| 2369 | impl Default for Cnt32 { | 3596 | impl Default for Smcr { |
| 2370 | fn default() -> Cnt32 { | 3597 | fn default() -> Smcr { |
| 2371 | Cnt32(0) | 3598 | Smcr(0) |
| 2372 | } | 3599 | } |
| 2373 | } | 3600 | } |
| 2374 | #[doc = "DMA/Interrupt enable register"] | 3601 | #[doc = "DMA/Interrupt enable register"] |
| @@ -2474,8 +3701,8 @@ pub mod timer_v1 { | |||
| 2474 | #[doc = "status register"] | 3701 | #[doc = "status register"] |
| 2475 | #[repr(transparent)] | 3702 | #[repr(transparent)] |
| 2476 | #[derive(Copy, Clone, Eq, PartialEq)] | 3703 | #[derive(Copy, Clone, Eq, PartialEq)] |
| 2477 | pub struct SrBasic(pub u32); | 3704 | pub struct SrAdv(pub u32); |
| 2478 | impl SrBasic { | 3705 | impl SrAdv { |
| 2479 | #[doc = "Update interrupt flag"] | 3706 | #[doc = "Update interrupt flag"] |
| 2480 | pub const fn uif(&self) -> bool { | 3707 | pub const fn uif(&self) -> bool { |
| 2481 | let val = (self.0 >> 0usize) & 0x01; | 3708 | let val = (self.0 >> 0usize) & 0x01; |
| @@ -2485,275 +3712,83 @@ pub mod timer_v1 { | |||
| 2485 | pub fn set_uif(&mut self, val: bool) { | 3712 | pub fn set_uif(&mut self, val: bool) { |
| 2486 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); | 3713 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); |
| 2487 | } | 3714 | } |
| 2488 | } | 3715 | #[doc = "Capture/compare 1 interrupt flag"] |
| 2489 | impl Default for SrBasic { | 3716 | pub fn ccif(&self, n: usize) -> bool { |
| 2490 | fn default() -> SrBasic { | ||
| 2491 | SrBasic(0) | ||
| 2492 | } | ||
| 2493 | } | ||
| 2494 | #[doc = "event generation register"] | ||
| 2495 | #[repr(transparent)] | ||
| 2496 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 2497 | pub struct EgrAdv(pub u32); | ||
| 2498 | impl EgrAdv { | ||
| 2499 | #[doc = "Update generation"] | ||
| 2500 | pub const fn ug(&self) -> bool { | ||
| 2501 | let val = (self.0 >> 0usize) & 0x01; | ||
| 2502 | val != 0 | ||
| 2503 | } | ||
| 2504 | #[doc = "Update generation"] | ||
| 2505 | pub fn set_ug(&mut self, val: bool) { | ||
| 2506 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); | ||
| 2507 | } | ||
| 2508 | #[doc = "Capture/compare 1 generation"] | ||
| 2509 | pub fn ccg(&self, n: usize) -> bool { | ||
| 2510 | assert!(n < 4usize); | 3717 | assert!(n < 4usize); |
| 2511 | let offs = 1usize + n * 1usize; | 3718 | let offs = 1usize + n * 1usize; |
| 2512 | let val = (self.0 >> offs) & 0x01; | 3719 | let val = (self.0 >> offs) & 0x01; |
| 2513 | val != 0 | 3720 | val != 0 |
| 2514 | } | 3721 | } |
| 2515 | #[doc = "Capture/compare 1 generation"] | 3722 | #[doc = "Capture/compare 1 interrupt flag"] |
| 2516 | pub fn set_ccg(&mut self, n: usize, val: bool) { | 3723 | pub fn set_ccif(&mut self, n: usize, val: bool) { |
| 2517 | assert!(n < 4usize); | 3724 | assert!(n < 4usize); |
| 2518 | let offs = 1usize + n * 1usize; | 3725 | let offs = 1usize + n * 1usize; |
| 2519 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | 3726 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); |
| 2520 | } | 3727 | } |
| 2521 | #[doc = "Capture/Compare control update generation"] | 3728 | #[doc = "COM interrupt flag"] |
| 2522 | pub const fn comg(&self) -> bool { | 3729 | pub const fn comif(&self) -> bool { |
| 2523 | let val = (self.0 >> 5usize) & 0x01; | 3730 | let val = (self.0 >> 5usize) & 0x01; |
| 2524 | val != 0 | 3731 | val != 0 |
| 2525 | } | 3732 | } |
| 2526 | #[doc = "Capture/Compare control update generation"] | 3733 | #[doc = "COM interrupt flag"] |
| 2527 | pub fn set_comg(&mut self, val: bool) { | 3734 | pub fn set_comif(&mut self, val: bool) { |
| 2528 | self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize); | 3735 | self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize); |
| 2529 | } | 3736 | } |
| 2530 | #[doc = "Trigger generation"] | 3737 | #[doc = "Trigger interrupt flag"] |
| 2531 | pub const fn tg(&self) -> bool { | 3738 | pub const fn tif(&self) -> bool { |
| 2532 | let val = (self.0 >> 6usize) & 0x01; | 3739 | let val = (self.0 >> 6usize) & 0x01; |
| 2533 | val != 0 | 3740 | val != 0 |
| 2534 | } | 3741 | } |
| 2535 | #[doc = "Trigger generation"] | 3742 | #[doc = "Trigger interrupt flag"] |
| 2536 | pub fn set_tg(&mut self, val: bool) { | 3743 | pub fn set_tif(&mut self, val: bool) { |
| 2537 | self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize); | 3744 | self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize); |
| 2538 | } | 3745 | } |
| 2539 | #[doc = "Break generation"] | 3746 | #[doc = "Break interrupt flag"] |
| 2540 | pub const fn bg(&self) -> bool { | 3747 | pub const fn bif(&self) -> bool { |
| 2541 | let val = (self.0 >> 7usize) & 0x01; | 3748 | let val = (self.0 >> 7usize) & 0x01; |
| 2542 | val != 0 | 3749 | val != 0 |
| 2543 | } | 3750 | } |
| 2544 | #[doc = "Break generation"] | 3751 | #[doc = "Break interrupt flag"] |
| 2545 | pub fn set_bg(&mut self, val: bool) { | 3752 | pub fn set_bif(&mut self, val: bool) { |
| 2546 | self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize); | 3753 | self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize); |
| 2547 | } | 3754 | } |
| 2548 | } | 3755 | #[doc = "Capture/Compare 1 overcapture flag"] |
| 2549 | impl Default for EgrAdv { | 3756 | pub fn ccof(&self, n: usize) -> bool { |
| 2550 | fn default() -> EgrAdv { | ||
| 2551 | EgrAdv(0) | ||
| 2552 | } | ||
| 2553 | } | ||
| 2554 | #[doc = "repetition counter register"] | ||
| 2555 | #[repr(transparent)] | ||
| 2556 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 2557 | pub struct Rcr(pub u32); | ||
| 2558 | impl Rcr { | ||
| 2559 | #[doc = "Repetition counter value"] | ||
| 2560 | pub const fn rep(&self) -> u8 { | ||
| 2561 | let val = (self.0 >> 0usize) & 0xff; | ||
| 2562 | val as u8 | ||
| 2563 | } | ||
| 2564 | #[doc = "Repetition counter value"] | ||
| 2565 | pub fn set_rep(&mut self, val: u8) { | ||
| 2566 | self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize); | ||
| 2567 | } | ||
| 2568 | } | ||
| 2569 | impl Default for Rcr { | ||
| 2570 | fn default() -> Rcr { | ||
| 2571 | Rcr(0) | ||
| 2572 | } | ||
| 2573 | } | ||
| 2574 | #[doc = "auto-reload register"] | ||
| 2575 | #[repr(transparent)] | ||
| 2576 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 2577 | pub struct Arr32(pub u32); | ||
| 2578 | impl Arr32 { | ||
| 2579 | #[doc = "Auto-reload value"] | ||
| 2580 | pub const fn arr(&self) -> u32 { | ||
| 2581 | let val = (self.0 >> 0usize) & 0xffff_ffff; | ||
| 2582 | val as u32 | ||
| 2583 | } | ||
| 2584 | #[doc = "Auto-reload value"] | ||
| 2585 | pub fn set_arr(&mut self, val: u32) { | ||
| 2586 | self.0 = | ||
| 2587 | (self.0 & !(0xffff_ffff << 0usize)) | (((val as u32) & 0xffff_ffff) << 0usize); | ||
| 2588 | } | ||
| 2589 | } | ||
| 2590 | impl Default for Arr32 { | ||
| 2591 | fn default() -> Arr32 { | ||
| 2592 | Arr32(0) | ||
| 2593 | } | ||
| 2594 | } | ||
| 2595 | #[doc = "event generation register"] | ||
| 2596 | #[repr(transparent)] | ||
| 2597 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 2598 | pub struct EgrBasic(pub u32); | ||
| 2599 | impl EgrBasic { | ||
| 2600 | #[doc = "Update generation"] | ||
| 2601 | pub const fn ug(&self) -> bool { | ||
| 2602 | let val = (self.0 >> 0usize) & 0x01; | ||
| 2603 | val != 0 | ||
| 2604 | } | ||
| 2605 | #[doc = "Update generation"] | ||
| 2606 | pub fn set_ug(&mut self, val: bool) { | ||
| 2607 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); | ||
| 2608 | } | ||
| 2609 | } | ||
| 2610 | impl Default for EgrBasic { | ||
| 2611 | fn default() -> EgrBasic { | ||
| 2612 | EgrBasic(0) | ||
| 2613 | } | ||
| 2614 | } | ||
| 2615 | #[doc = "counter"] | ||
| 2616 | #[repr(transparent)] | ||
| 2617 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 2618 | pub struct Cnt16(pub u32); | ||
| 2619 | impl Cnt16 { | ||
| 2620 | #[doc = "counter value"] | ||
| 2621 | pub const fn cnt(&self) -> u16 { | ||
| 2622 | let val = (self.0 >> 0usize) & 0xffff; | ||
| 2623 | val as u16 | ||
| 2624 | } | ||
| 2625 | #[doc = "counter value"] | ||
| 2626 | pub fn set_cnt(&mut self, val: u16) { | ||
| 2627 | self.0 = (self.0 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 0usize); | ||
| 2628 | } | ||
| 2629 | } | ||
| 2630 | impl Default for Cnt16 { | ||
| 2631 | fn default() -> Cnt16 { | ||
| 2632 | Cnt16(0) | ||
| 2633 | } | ||
| 2634 | } | ||
| 2635 | #[doc = "auto-reload register"] | ||
| 2636 | #[repr(transparent)] | ||
| 2637 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 2638 | pub struct Arr16(pub u32); | ||
| 2639 | impl Arr16 { | ||
| 2640 | #[doc = "Auto-reload value"] | ||
| 2641 | pub const fn arr(&self) -> u16 { | ||
| 2642 | let val = (self.0 >> 0usize) & 0xffff; | ||
| 2643 | val as u16 | ||
| 2644 | } | ||
| 2645 | #[doc = "Auto-reload value"] | ||
| 2646 | pub fn set_arr(&mut self, val: u16) { | ||
| 2647 | self.0 = (self.0 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 0usize); | ||
| 2648 | } | ||
| 2649 | } | ||
| 2650 | impl Default for Arr16 { | ||
| 2651 | fn default() -> Arr16 { | ||
| 2652 | Arr16(0) | ||
| 2653 | } | ||
| 2654 | } | ||
| 2655 | #[doc = "capture/compare enable register"] | ||
| 2656 | #[repr(transparent)] | ||
| 2657 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 2658 | pub struct CcerAdv(pub u32); | ||
| 2659 | impl CcerAdv { | ||
| 2660 | #[doc = "Capture/Compare 1 output enable"] | ||
| 2661 | pub fn cce(&self, n: usize) -> bool { | ||
| 2662 | assert!(n < 4usize); | ||
| 2663 | let offs = 0usize + n * 4usize; | ||
| 2664 | let val = (self.0 >> offs) & 0x01; | ||
| 2665 | val != 0 | ||
| 2666 | } | ||
| 2667 | #[doc = "Capture/Compare 1 output enable"] | ||
| 2668 | pub fn set_cce(&mut self, n: usize, val: bool) { | ||
| 2669 | assert!(n < 4usize); | ||
| 2670 | let offs = 0usize + n * 4usize; | ||
| 2671 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | ||
| 2672 | } | ||
| 2673 | #[doc = "Capture/Compare 1 output Polarity"] | ||
| 2674 | pub fn ccp(&self, n: usize) -> bool { | ||
| 2675 | assert!(n < 4usize); | ||
| 2676 | let offs = 1usize + n * 4usize; | ||
| 2677 | let val = (self.0 >> offs) & 0x01; | ||
| 2678 | val != 0 | ||
| 2679 | } | ||
| 2680 | #[doc = "Capture/Compare 1 output Polarity"] | ||
| 2681 | pub fn set_ccp(&mut self, n: usize, val: bool) { | ||
| 2682 | assert!(n < 4usize); | ||
| 2683 | let offs = 1usize + n * 4usize; | ||
| 2684 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | ||
| 2685 | } | ||
| 2686 | #[doc = "Capture/Compare 1 complementary output enable"] | ||
| 2687 | pub fn ccne(&self, n: usize) -> bool { | ||
| 2688 | assert!(n < 4usize); | ||
| 2689 | let offs = 2usize + n * 4usize; | ||
| 2690 | let val = (self.0 >> offs) & 0x01; | ||
| 2691 | val != 0 | ||
| 2692 | } | ||
| 2693 | #[doc = "Capture/Compare 1 complementary output enable"] | ||
| 2694 | pub fn set_ccne(&mut self, n: usize, val: bool) { | ||
| 2695 | assert!(n < 4usize); | ||
| 2696 | let offs = 2usize + n * 4usize; | ||
| 2697 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | ||
| 2698 | } | ||
| 2699 | #[doc = "Capture/Compare 1 output Polarity"] | ||
| 2700 | pub fn ccnp(&self, n: usize) -> bool { | ||
| 2701 | assert!(n < 4usize); | 3757 | assert!(n < 4usize); |
| 2702 | let offs = 3usize + n * 4usize; | 3758 | let offs = 9usize + n * 1usize; |
| 2703 | let val = (self.0 >> offs) & 0x01; | 3759 | let val = (self.0 >> offs) & 0x01; |
| 2704 | val != 0 | 3760 | val != 0 |
| 2705 | } | 3761 | } |
| 2706 | #[doc = "Capture/Compare 1 output Polarity"] | 3762 | #[doc = "Capture/Compare 1 overcapture flag"] |
| 2707 | pub fn set_ccnp(&mut self, n: usize, val: bool) { | 3763 | pub fn set_ccof(&mut self, n: usize, val: bool) { |
| 2708 | assert!(n < 4usize); | 3764 | assert!(n < 4usize); |
| 2709 | let offs = 3usize + n * 4usize; | 3765 | let offs = 9usize + n * 1usize; |
| 2710 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | 3766 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); |
| 2711 | } | 3767 | } |
| 2712 | } | 3768 | } |
| 2713 | impl Default for CcerAdv { | 3769 | impl Default for SrAdv { |
| 2714 | fn default() -> CcerAdv { | 3770 | fn default() -> SrAdv { |
| 2715 | CcerAdv(0) | 3771 | SrAdv(0) |
| 2716 | } | 3772 | } |
| 2717 | } | 3773 | } |
| 2718 | #[doc = "capture/compare register 1"] | 3774 | #[doc = "prescaler"] |
| 2719 | #[repr(transparent)] | 3775 | #[repr(transparent)] |
| 2720 | #[derive(Copy, Clone, Eq, PartialEq)] | 3776 | #[derive(Copy, Clone, Eq, PartialEq)] |
| 2721 | pub struct Ccr16(pub u32); | 3777 | pub struct Psc(pub u32); |
| 2722 | impl Ccr16 { | 3778 | impl Psc { |
| 2723 | #[doc = "Capture/Compare 1 value"] | 3779 | #[doc = "Prescaler value"] |
| 2724 | pub const fn ccr(&self) -> u16 { | 3780 | pub const fn psc(&self) -> u16 { |
| 2725 | let val = (self.0 >> 0usize) & 0xffff; | 3781 | let val = (self.0 >> 0usize) & 0xffff; |
| 2726 | val as u16 | 3782 | val as u16 |
| 2727 | } | 3783 | } |
| 2728 | #[doc = "Capture/Compare 1 value"] | 3784 | #[doc = "Prescaler value"] |
| 2729 | pub fn set_ccr(&mut self, val: u16) { | 3785 | pub fn set_psc(&mut self, val: u16) { |
| 2730 | self.0 = (self.0 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 0usize); | 3786 | self.0 = (self.0 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 0usize); |
| 2731 | } | 3787 | } |
| 2732 | } | 3788 | } |
| 2733 | impl Default for Ccr16 { | 3789 | impl Default for Psc { |
| 2734 | fn default() -> Ccr16 { | 3790 | fn default() -> Psc { |
| 2735 | Ccr16(0) | 3791 | Psc(0) |
| 2736 | } | ||
| 2737 | } | ||
| 2738 | #[doc = "capture/compare register 1"] | ||
| 2739 | #[repr(transparent)] | ||
| 2740 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 2741 | pub struct Ccr32(pub u32); | ||
| 2742 | impl Ccr32 { | ||
| 2743 | #[doc = "Capture/Compare 1 value"] | ||
| 2744 | pub const fn ccr(&self) -> u32 { | ||
| 2745 | let val = (self.0 >> 0usize) & 0xffff_ffff; | ||
| 2746 | val as u32 | ||
| 2747 | } | ||
| 2748 | #[doc = "Capture/Compare 1 value"] | ||
| 2749 | pub fn set_ccr(&mut self, val: u32) { | ||
| 2750 | self.0 = | ||
| 2751 | (self.0 & !(0xffff_ffff << 0usize)) | (((val as u32) & 0xffff_ffff) << 0usize); | ||
| 2752 | } | ||
| 2753 | } | ||
| 2754 | impl Default for Ccr32 { | ||
| 2755 | fn default() -> Ccr32 { | ||
| 2756 | Ccr32(0) | ||
| 2757 | } | 3792 | } |
| 2758 | } | 3793 | } |
| 2759 | #[doc = "capture/compare enable register"] | 3794 | #[doc = "capture/compare enable register"] |
| @@ -2806,628 +3841,581 @@ pub mod timer_v1 { | |||
| 2806 | CcerGp(0) | 3841 | CcerGp(0) |
| 2807 | } | 3842 | } |
| 2808 | } | 3843 | } |
| 2809 | #[doc = "status register"] | 3844 | #[doc = "capture/compare mode register 2 (output mode)"] |
| 2810 | #[repr(transparent)] | 3845 | #[repr(transparent)] |
| 2811 | #[derive(Copy, Clone, Eq, PartialEq)] | 3846 | #[derive(Copy, Clone, Eq, PartialEq)] |
| 2812 | pub struct SrAdv(pub u32); | 3847 | pub struct CcmrOutput(pub u32); |
| 2813 | impl SrAdv { | 3848 | impl CcmrOutput { |
| 2814 | #[doc = "Update interrupt flag"] | 3849 | #[doc = "Capture/Compare 3 selection"] |
| 2815 | pub const fn uif(&self) -> bool { | 3850 | pub fn ccs(&self, n: usize) -> super::vals::CcmrOutputCcs { |
| 2816 | let val = (self.0 >> 0usize) & 0x01; | 3851 | assert!(n < 2usize); |
| 2817 | val != 0 | 3852 | let offs = 0usize + n * 8usize; |
| 3853 | let val = (self.0 >> offs) & 0x03; | ||
| 3854 | super::vals::CcmrOutputCcs(val as u8) | ||
| 2818 | } | 3855 | } |
| 2819 | #[doc = "Update interrupt flag"] | 3856 | #[doc = "Capture/Compare 3 selection"] |
| 2820 | pub fn set_uif(&mut self, val: bool) { | 3857 | pub fn set_ccs(&mut self, n: usize, val: super::vals::CcmrOutputCcs) { |
| 2821 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); | 3858 | assert!(n < 2usize); |
| 3859 | let offs = 0usize + n * 8usize; | ||
| 3860 | self.0 = (self.0 & !(0x03 << offs)) | (((val.0 as u32) & 0x03) << offs); | ||
| 2822 | } | 3861 | } |
| 2823 | #[doc = "Capture/compare 1 interrupt flag"] | 3862 | #[doc = "Output compare 3 fast enable"] |
| 2824 | pub fn ccif(&self, n: usize) -> bool { | 3863 | pub fn ocfe(&self, n: usize) -> bool { |
| 2825 | assert!(n < 4usize); | 3864 | assert!(n < 2usize); |
| 2826 | let offs = 1usize + n * 1usize; | 3865 | let offs = 2usize + n * 8usize; |
| 2827 | let val = (self.0 >> offs) & 0x01; | 3866 | let val = (self.0 >> offs) & 0x01; |
| 2828 | val != 0 | 3867 | val != 0 |
| 2829 | } | 3868 | } |
| 2830 | #[doc = "Capture/compare 1 interrupt flag"] | 3869 | #[doc = "Output compare 3 fast enable"] |
| 2831 | pub fn set_ccif(&mut self, n: usize, val: bool) { | 3870 | pub fn set_ocfe(&mut self, n: usize, val: bool) { |
| 2832 | assert!(n < 4usize); | 3871 | assert!(n < 2usize); |
| 2833 | let offs = 1usize + n * 1usize; | 3872 | let offs = 2usize + n * 8usize; |
| 2834 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | 3873 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); |
| 2835 | } | 3874 | } |
| 2836 | #[doc = "COM interrupt flag"] | 3875 | #[doc = "Output compare 3 preload enable"] |
| 2837 | pub const fn comif(&self) -> bool { | 3876 | pub fn ocpe(&self, n: usize) -> super::vals::Ocpe { |
| 2838 | let val = (self.0 >> 5usize) & 0x01; | 3877 | assert!(n < 2usize); |
| 2839 | val != 0 | 3878 | let offs = 3usize + n * 8usize; |
| 2840 | } | 3879 | let val = (self.0 >> offs) & 0x01; |
| 2841 | #[doc = "COM interrupt flag"] | 3880 | super::vals::Ocpe(val as u8) |
| 2842 | pub fn set_comif(&mut self, val: bool) { | ||
| 2843 | self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize); | ||
| 2844 | } | ||
| 2845 | #[doc = "Trigger interrupt flag"] | ||
| 2846 | pub const fn tif(&self) -> bool { | ||
| 2847 | let val = (self.0 >> 6usize) & 0x01; | ||
| 2848 | val != 0 | ||
| 2849 | } | 3881 | } |
| 2850 | #[doc = "Trigger interrupt flag"] | 3882 | #[doc = "Output compare 3 preload enable"] |
| 2851 | pub fn set_tif(&mut self, val: bool) { | 3883 | pub fn set_ocpe(&mut self, n: usize, val: super::vals::Ocpe) { |
| 2852 | self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize); | 3884 | assert!(n < 2usize); |
| 3885 | let offs = 3usize + n * 8usize; | ||
| 3886 | self.0 = (self.0 & !(0x01 << offs)) | (((val.0 as u32) & 0x01) << offs); | ||
| 2853 | } | 3887 | } |
| 2854 | #[doc = "Break interrupt flag"] | 3888 | #[doc = "Output compare 3 mode"] |
| 2855 | pub const fn bif(&self) -> bool { | 3889 | pub fn ocm(&self, n: usize) -> super::vals::Ocm { |
| 2856 | let val = (self.0 >> 7usize) & 0x01; | 3890 | assert!(n < 2usize); |
| 2857 | val != 0 | 3891 | let offs = 4usize + n * 8usize; |
| 3892 | let val = (self.0 >> offs) & 0x07; | ||
| 3893 | super::vals::Ocm(val as u8) | ||
| 2858 | } | 3894 | } |
| 2859 | #[doc = "Break interrupt flag"] | 3895 | #[doc = "Output compare 3 mode"] |
| 2860 | pub fn set_bif(&mut self, val: bool) { | 3896 | pub fn set_ocm(&mut self, n: usize, val: super::vals::Ocm) { |
| 2861 | self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize); | 3897 | assert!(n < 2usize); |
| 3898 | let offs = 4usize + n * 8usize; | ||
| 3899 | self.0 = (self.0 & !(0x07 << offs)) | (((val.0 as u32) & 0x07) << offs); | ||
| 2862 | } | 3900 | } |
| 2863 | #[doc = "Capture/Compare 1 overcapture flag"] | 3901 | #[doc = "Output compare 3 clear enable"] |
| 2864 | pub fn ccof(&self, n: usize) -> bool { | 3902 | pub fn occe(&self, n: usize) -> bool { |
| 2865 | assert!(n < 4usize); | 3903 | assert!(n < 2usize); |
| 2866 | let offs = 9usize + n * 1usize; | 3904 | let offs = 7usize + n * 8usize; |
| 2867 | let val = (self.0 >> offs) & 0x01; | 3905 | let val = (self.0 >> offs) & 0x01; |
| 2868 | val != 0 | 3906 | val != 0 |
| 2869 | } | 3907 | } |
| 2870 | #[doc = "Capture/Compare 1 overcapture flag"] | 3908 | #[doc = "Output compare 3 clear enable"] |
| 2871 | pub fn set_ccof(&mut self, n: usize, val: bool) { | 3909 | pub fn set_occe(&mut self, n: usize, val: bool) { |
| 2872 | assert!(n < 4usize); | 3910 | assert!(n < 2usize); |
| 2873 | let offs = 9usize + n * 1usize; | 3911 | let offs = 7usize + n * 8usize; |
| 2874 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | 3912 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); |
| 2875 | } | 3913 | } |
| 2876 | } | 3914 | } |
| 2877 | impl Default for SrAdv { | 3915 | impl Default for CcmrOutput { |
| 2878 | fn default() -> SrAdv { | 3916 | fn default() -> CcmrOutput { |
| 2879 | SrAdv(0) | 3917 | CcmrOutput(0) |
| 2880 | } | 3918 | } |
| 2881 | } | 3919 | } |
| 2882 | } | 3920 | #[doc = "control register 2"] |
| 2883 | } | ||
| 2884 | pub mod syscfg_l4 { | ||
| 2885 | use crate::generic::*; | ||
| 2886 | #[doc = "System configuration controller"] | ||
| 2887 | #[derive(Copy, Clone)] | ||
| 2888 | pub struct Syscfg(pub *mut u8); | ||
| 2889 | unsafe impl Send for Syscfg {} | ||
| 2890 | unsafe impl Sync for Syscfg {} | ||
| 2891 | impl Syscfg { | ||
| 2892 | #[doc = "memory remap register"] | ||
| 2893 | pub fn memrmp(self) -> Reg<regs::Memrmp, RW> { | ||
| 2894 | unsafe { Reg::from_ptr(self.0.add(0usize)) } | ||
| 2895 | } | ||
| 2896 | #[doc = "configuration register 1"] | ||
| 2897 | pub fn cfgr1(self) -> Reg<regs::Cfgr1, RW> { | ||
| 2898 | unsafe { Reg::from_ptr(self.0.add(4usize)) } | ||
| 2899 | } | ||
| 2900 | #[doc = "external interrupt configuration register 1"] | ||
| 2901 | pub fn exticr(self, n: usize) -> Reg<regs::Exticr, RW> { | ||
| 2902 | assert!(n < 4usize); | ||
| 2903 | unsafe { Reg::from_ptr(self.0.add(8usize + n * 4usize)) } | ||
| 2904 | } | ||
| 2905 | #[doc = "SCSR"] | ||
| 2906 | pub fn scsr(self) -> Reg<regs::Scsr, RW> { | ||
| 2907 | unsafe { Reg::from_ptr(self.0.add(24usize)) } | ||
| 2908 | } | ||
| 2909 | #[doc = "CFGR2"] | ||
| 2910 | pub fn cfgr2(self) -> Reg<regs::Cfgr2, RW> { | ||
| 2911 | unsafe { Reg::from_ptr(self.0.add(28usize)) } | ||
| 2912 | } | ||
| 2913 | #[doc = "SWPR"] | ||
| 2914 | pub fn swpr(self) -> Reg<regs::Swpr, W> { | ||
| 2915 | unsafe { Reg::from_ptr(self.0.add(32usize)) } | ||
| 2916 | } | ||
| 2917 | #[doc = "SKR"] | ||
| 2918 | pub fn skr(self) -> Reg<regs::Skr, W> { | ||
| 2919 | unsafe { Reg::from_ptr(self.0.add(36usize)) } | ||
| 2920 | } | ||
| 2921 | } | ||
| 2922 | pub mod regs { | ||
| 2923 | use crate::generic::*; | ||
| 2924 | #[doc = "external interrupt configuration register 4"] | ||
| 2925 | #[repr(transparent)] | 3921 | #[repr(transparent)] |
| 2926 | #[derive(Copy, Clone, Eq, PartialEq)] | 3922 | #[derive(Copy, Clone, Eq, PartialEq)] |
| 2927 | pub struct Exticr(pub u32); | 3923 | pub struct Cr2Basic(pub u32); |
| 2928 | impl Exticr { | 3924 | impl Cr2Basic { |
| 2929 | #[doc = "EXTI12 configuration bits"] | 3925 | #[doc = "Master mode selection"] |
| 2930 | pub fn exti(&self, n: usize) -> u8 { | 3926 | pub const fn mms(&self) -> super::vals::Mms { |
| 2931 | assert!(n < 4usize); | 3927 | let val = (self.0 >> 4usize) & 0x07; |
| 2932 | let offs = 0usize + n * 4usize; | 3928 | super::vals::Mms(val as u8) |
| 2933 | let val = (self.0 >> offs) & 0x0f; | ||
| 2934 | val as u8 | ||
| 2935 | } | 3929 | } |
| 2936 | #[doc = "EXTI12 configuration bits"] | 3930 | #[doc = "Master mode selection"] |
| 2937 | pub fn set_exti(&mut self, n: usize, val: u8) { | 3931 | pub fn set_mms(&mut self, val: super::vals::Mms) { |
| 2938 | assert!(n < 4usize); | 3932 | self.0 = (self.0 & !(0x07 << 4usize)) | (((val.0 as u32) & 0x07) << 4usize); |
| 2939 | let offs = 0usize + n * 4usize; | ||
| 2940 | self.0 = (self.0 & !(0x0f << offs)) | (((val as u32) & 0x0f) << offs); | ||
| 2941 | } | 3933 | } |
| 2942 | } | 3934 | } |
| 2943 | impl Default for Exticr { | 3935 | impl Default for Cr2Basic { |
| 2944 | fn default() -> Exticr { | 3936 | fn default() -> Cr2Basic { |
| 2945 | Exticr(0) | 3937 | Cr2Basic(0) |
| 2946 | } | 3938 | } |
| 2947 | } | 3939 | } |
| 2948 | #[doc = "SWPR"] | 3940 | #[doc = "DMA address for full transfer"] |
| 2949 | #[repr(transparent)] | 3941 | #[repr(transparent)] |
| 2950 | #[derive(Copy, Clone, Eq, PartialEq)] | 3942 | #[derive(Copy, Clone, Eq, PartialEq)] |
| 2951 | pub struct Swpr(pub u32); | 3943 | pub struct Dmar(pub u32); |
| 2952 | impl Swpr { | 3944 | impl Dmar { |
| 2953 | #[doc = "SRAWM2 write protection."] | 3945 | #[doc = "DMA register for burst accesses"] |
| 2954 | pub fn pwp(&self, n: usize) -> bool { | 3946 | pub const fn dmab(&self) -> u16 { |
| 2955 | assert!(n < 32usize); | 3947 | let val = (self.0 >> 0usize) & 0xffff; |
| 2956 | let offs = 0usize + n * 1usize; | 3948 | val as u16 |
| 2957 | let val = (self.0 >> offs) & 0x01; | ||
| 2958 | val != 0 | ||
| 2959 | } | 3949 | } |
| 2960 | #[doc = "SRAWM2 write protection."] | 3950 | #[doc = "DMA register for burst accesses"] |
| 2961 | pub fn set_pwp(&mut self, n: usize, val: bool) { | 3951 | pub fn set_dmab(&mut self, val: u16) { |
| 2962 | assert!(n < 32usize); | 3952 | self.0 = (self.0 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 0usize); |
| 2963 | let offs = 0usize + n * 1usize; | ||
| 2964 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | ||
| 2965 | } | 3953 | } |
| 2966 | } | 3954 | } |
| 2967 | impl Default for Swpr { | 3955 | impl Default for Dmar { |
| 2968 | fn default() -> Swpr { | 3956 | fn default() -> Dmar { |
| 2969 | Swpr(0) | 3957 | Dmar(0) |
| 2970 | } | 3958 | } |
| 2971 | } | 3959 | } |
| 2972 | #[doc = "SCSR"] | 3960 | #[doc = "capture/compare register 1"] |
| 2973 | #[repr(transparent)] | 3961 | #[repr(transparent)] |
| 2974 | #[derive(Copy, Clone, Eq, PartialEq)] | 3962 | #[derive(Copy, Clone, Eq, PartialEq)] |
| 2975 | pub struct Scsr(pub u32); | 3963 | pub struct Ccr16(pub u32); |
| 2976 | impl Scsr { | 3964 | impl Ccr16 { |
| 2977 | #[doc = "SRAM2 Erase"] | 3965 | #[doc = "Capture/Compare 1 value"] |
| 2978 | pub const fn sram2er(&self) -> bool { | 3966 | pub const fn ccr(&self) -> u16 { |
| 2979 | let val = (self.0 >> 0usize) & 0x01; | 3967 | let val = (self.0 >> 0usize) & 0xffff; |
| 2980 | val != 0 | 3968 | val as u16 |
| 2981 | } | ||
| 2982 | #[doc = "SRAM2 Erase"] | ||
| 2983 | pub fn set_sram2er(&mut self, val: bool) { | ||
| 2984 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); | ||
| 2985 | } | ||
| 2986 | #[doc = "SRAM2 busy by erase operation"] | ||
| 2987 | pub const fn sram2bsy(&self) -> bool { | ||
| 2988 | let val = (self.0 >> 1usize) & 0x01; | ||
| 2989 | val != 0 | ||
| 2990 | } | 3969 | } |
| 2991 | #[doc = "SRAM2 busy by erase operation"] | 3970 | #[doc = "Capture/Compare 1 value"] |
| 2992 | pub fn set_sram2bsy(&mut self, val: bool) { | 3971 | pub fn set_ccr(&mut self, val: u16) { |
| 2993 | self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize); | 3972 | self.0 = (self.0 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 0usize); |
| 2994 | } | 3973 | } |
| 2995 | } | 3974 | } |
| 2996 | impl Default for Scsr { | 3975 | impl Default for Ccr16 { |
| 2997 | fn default() -> Scsr { | 3976 | fn default() -> Ccr16 { |
| 2998 | Scsr(0) | 3977 | Ccr16(0) |
| 2999 | } | 3978 | } |
| 3000 | } | 3979 | } |
| 3001 | #[doc = "SKR"] | 3980 | #[doc = "capture/compare mode register 1 (input mode)"] |
| 3002 | #[repr(transparent)] | 3981 | #[repr(transparent)] |
| 3003 | #[derive(Copy, Clone, Eq, PartialEq)] | 3982 | #[derive(Copy, Clone, Eq, PartialEq)] |
| 3004 | pub struct Skr(pub u32); | 3983 | pub struct CcmrInput(pub u32); |
| 3005 | impl Skr { | 3984 | impl CcmrInput { |
| 3006 | #[doc = "SRAM2 write protection key for software erase"] | 3985 | #[doc = "Capture/Compare 1 selection"] |
| 3007 | pub const fn key(&self) -> u8 { | 3986 | pub fn ccs(&self, n: usize) -> super::vals::CcmrInputCcs { |
| 3008 | let val = (self.0 >> 0usize) & 0xff; | 3987 | assert!(n < 2usize); |
| 3009 | val as u8 | 3988 | let offs = 0usize + n * 8usize; |
| 3010 | } | 3989 | let val = (self.0 >> offs) & 0x03; |
| 3011 | #[doc = "SRAM2 write protection key for software erase"] | 3990 | super::vals::CcmrInputCcs(val as u8) |
| 3012 | pub fn set_key(&mut self, val: u8) { | ||
| 3013 | self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize); | ||
| 3014 | } | 3991 | } |
| 3015 | } | 3992 | #[doc = "Capture/Compare 1 selection"] |
| 3016 | impl Default for Skr { | 3993 | pub fn set_ccs(&mut self, n: usize, val: super::vals::CcmrInputCcs) { |
| 3017 | fn default() -> Skr { | 3994 | assert!(n < 2usize); |
| 3018 | Skr(0) | 3995 | let offs = 0usize + n * 8usize; |
| 3996 | self.0 = (self.0 & !(0x03 << offs)) | (((val.0 as u32) & 0x03) << offs); | ||
| 3019 | } | 3997 | } |
| 3020 | } | 3998 | #[doc = "Input capture 1 prescaler"] |
| 3021 | #[doc = "memory remap register"] | 3999 | pub fn icpsc(&self, n: usize) -> u8 { |
| 3022 | #[repr(transparent)] | 4000 | assert!(n < 2usize); |
| 3023 | #[derive(Copy, Clone, Eq, PartialEq)] | 4001 | let offs = 2usize + n * 8usize; |
| 3024 | pub struct Memrmp(pub u32); | 4002 | let val = (self.0 >> offs) & 0x03; |
| 3025 | impl Memrmp { | ||
| 3026 | #[doc = "Memory mapping selection"] | ||
| 3027 | pub const fn mem_mode(&self) -> u8 { | ||
| 3028 | let val = (self.0 >> 0usize) & 0x07; | ||
| 3029 | val as u8 | 4003 | val as u8 |
| 3030 | } | 4004 | } |
| 3031 | #[doc = "Memory mapping selection"] | 4005 | #[doc = "Input capture 1 prescaler"] |
| 3032 | pub fn set_mem_mode(&mut self, val: u8) { | 4006 | pub fn set_icpsc(&mut self, n: usize, val: u8) { |
| 3033 | self.0 = (self.0 & !(0x07 << 0usize)) | (((val as u32) & 0x07) << 0usize); | 4007 | assert!(n < 2usize); |
| 3034 | } | 4008 | let offs = 2usize + n * 8usize; |
| 3035 | #[doc = "QUADSPI memory mapping swap"] | 4009 | self.0 = (self.0 & !(0x03 << offs)) | (((val as u32) & 0x03) << offs); |
| 3036 | pub const fn qfs(&self) -> bool { | ||
| 3037 | let val = (self.0 >> 3usize) & 0x01; | ||
| 3038 | val != 0 | ||
| 3039 | } | ||
| 3040 | #[doc = "QUADSPI memory mapping swap"] | ||
| 3041 | pub fn set_qfs(&mut self, val: bool) { | ||
| 3042 | self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize); | ||
| 3043 | } | 4010 | } |
| 3044 | #[doc = "Flash Bank mode selection"] | 4011 | #[doc = "Input capture 1 filter"] |
| 3045 | pub const fn fb_mode(&self) -> bool { | 4012 | pub fn icf(&self, n: usize) -> super::vals::Icf { |
| 3046 | let val = (self.0 >> 8usize) & 0x01; | 4013 | assert!(n < 2usize); |
| 3047 | val != 0 | 4014 | let offs = 4usize + n * 8usize; |
| 4015 | let val = (self.0 >> offs) & 0x0f; | ||
| 4016 | super::vals::Icf(val as u8) | ||
| 3048 | } | 4017 | } |
| 3049 | #[doc = "Flash Bank mode selection"] | 4018 | #[doc = "Input capture 1 filter"] |
| 3050 | pub fn set_fb_mode(&mut self, val: bool) { | 4019 | pub fn set_icf(&mut self, n: usize, val: super::vals::Icf) { |
| 3051 | self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize); | 4020 | assert!(n < 2usize); |
| 4021 | let offs = 4usize + n * 8usize; | ||
| 4022 | self.0 = (self.0 & !(0x0f << offs)) | (((val.0 as u32) & 0x0f) << offs); | ||
| 3052 | } | 4023 | } |
| 3053 | } | 4024 | } |
| 3054 | impl Default for Memrmp { | 4025 | impl Default for CcmrInput { |
| 3055 | fn default() -> Memrmp { | 4026 | fn default() -> CcmrInput { |
| 3056 | Memrmp(0) | 4027 | CcmrInput(0) |
| 3057 | } | 4028 | } |
| 3058 | } | 4029 | } |
| 3059 | #[doc = "configuration register 1"] | 4030 | #[doc = "event generation register"] |
| 3060 | #[repr(transparent)] | 4031 | #[repr(transparent)] |
| 3061 | #[derive(Copy, Clone, Eq, PartialEq)] | 4032 | #[derive(Copy, Clone, Eq, PartialEq)] |
| 3062 | pub struct Cfgr1(pub u32); | 4033 | pub struct EgrAdv(pub u32); |
| 3063 | impl Cfgr1 { | 4034 | impl EgrAdv { |
| 3064 | #[doc = "Firewall disable"] | 4035 | #[doc = "Update generation"] |
| 3065 | pub const fn fwdis(&self) -> bool { | 4036 | pub const fn ug(&self) -> bool { |
| 3066 | let val = (self.0 >> 0usize) & 0x01; | 4037 | let val = (self.0 >> 0usize) & 0x01; |
| 3067 | val != 0 | 4038 | val != 0 |
| 3068 | } | 4039 | } |
| 3069 | #[doc = "Firewall disable"] | 4040 | #[doc = "Update generation"] |
| 3070 | pub fn set_fwdis(&mut self, val: bool) { | 4041 | pub fn set_ug(&mut self, val: bool) { |
| 3071 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); | 4042 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); |
| 3072 | } | 4043 | } |
| 3073 | #[doc = "I/O analog switch voltage booster enable"] | 4044 | #[doc = "Capture/compare 1 generation"] |
| 3074 | pub const fn boosten(&self) -> bool { | 4045 | pub fn ccg(&self, n: usize) -> bool { |
| 3075 | let val = (self.0 >> 8usize) & 0x01; | 4046 | assert!(n < 4usize); |
| 4047 | let offs = 1usize + n * 1usize; | ||
| 4048 | let val = (self.0 >> offs) & 0x01; | ||
| 3076 | val != 0 | 4049 | val != 0 |
| 3077 | } | 4050 | } |
| 3078 | #[doc = "I/O analog switch voltage booster enable"] | 4051 | #[doc = "Capture/compare 1 generation"] |
| 3079 | pub fn set_boosten(&mut self, val: bool) { | 4052 | pub fn set_ccg(&mut self, n: usize, val: bool) { |
| 3080 | self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize); | 4053 | assert!(n < 4usize); |
| 4054 | let offs = 1usize + n * 1usize; | ||
| 4055 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | ||
| 3081 | } | 4056 | } |
| 3082 | #[doc = "Fast-mode Plus (Fm+) driving capability activation on PB6"] | 4057 | #[doc = "Capture/Compare control update generation"] |
| 3083 | pub const fn i2c_pb6_fmp(&self) -> bool { | 4058 | pub const fn comg(&self) -> bool { |
| 3084 | let val = (self.0 >> 16usize) & 0x01; | 4059 | let val = (self.0 >> 5usize) & 0x01; |
| 3085 | val != 0 | 4060 | val != 0 |
| 3086 | } | 4061 | } |
| 3087 | #[doc = "Fast-mode Plus (Fm+) driving capability activation on PB6"] | 4062 | #[doc = "Capture/Compare control update generation"] |
| 3088 | pub fn set_i2c_pb6_fmp(&mut self, val: bool) { | 4063 | pub fn set_comg(&mut self, val: bool) { |
| 3089 | self.0 = (self.0 & !(0x01 << 16usize)) | (((val as u32) & 0x01) << 16usize); | 4064 | self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize); |
| 3090 | } | 4065 | } |
| 3091 | #[doc = "Fast-mode Plus (Fm+) driving capability activation on PB7"] | 4066 | #[doc = "Trigger generation"] |
| 3092 | pub const fn i2c_pb7_fmp(&self) -> bool { | 4067 | pub const fn tg(&self) -> bool { |
| 3093 | let val = (self.0 >> 17usize) & 0x01; | 4068 | let val = (self.0 >> 6usize) & 0x01; |
| 3094 | val != 0 | 4069 | val != 0 |
| 3095 | } | 4070 | } |
| 3096 | #[doc = "Fast-mode Plus (Fm+) driving capability activation on PB7"] | 4071 | #[doc = "Trigger generation"] |
| 3097 | pub fn set_i2c_pb7_fmp(&mut self, val: bool) { | 4072 | pub fn set_tg(&mut self, val: bool) { |
| 3098 | self.0 = (self.0 & !(0x01 << 17usize)) | (((val as u32) & 0x01) << 17usize); | 4073 | self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize); |
| 3099 | } | 4074 | } |
| 3100 | #[doc = "Fast-mode Plus (Fm+) driving capability activation on PB8"] | 4075 | #[doc = "Break generation"] |
| 3101 | pub const fn i2c_pb8_fmp(&self) -> bool { | 4076 | pub const fn bg(&self) -> bool { |
| 3102 | let val = (self.0 >> 18usize) & 0x01; | 4077 | let val = (self.0 >> 7usize) & 0x01; |
| 3103 | val != 0 | 4078 | val != 0 |
| 3104 | } | 4079 | } |
| 3105 | #[doc = "Fast-mode Plus (Fm+) driving capability activation on PB8"] | 4080 | #[doc = "Break generation"] |
| 3106 | pub fn set_i2c_pb8_fmp(&mut self, val: bool) { | 4081 | pub fn set_bg(&mut self, val: bool) { |
| 3107 | self.0 = (self.0 & !(0x01 << 18usize)) | (((val as u32) & 0x01) << 18usize); | 4082 | self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize); |
| 3108 | } | 4083 | } |
| 3109 | #[doc = "Fast-mode Plus (Fm+) driving capability activation on PB9"] | 4084 | } |
| 3110 | pub const fn i2c_pb9_fmp(&self) -> bool { | 4085 | impl Default for EgrAdv { |
| 3111 | let val = (self.0 >> 19usize) & 0x01; | 4086 | fn default() -> EgrAdv { |
| 4087 | EgrAdv(0) | ||
| 4088 | } | ||
| 4089 | } | ||
| 4090 | #[doc = "control register 1"] | ||
| 4091 | #[repr(transparent)] | ||
| 4092 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 4093 | pub struct Cr1Basic(pub u32); | ||
| 4094 | impl Cr1Basic { | ||
| 4095 | #[doc = "Counter enable"] | ||
| 4096 | pub const fn cen(&self) -> bool { | ||
| 4097 | let val = (self.0 >> 0usize) & 0x01; | ||
| 3112 | val != 0 | 4098 | val != 0 |
| 3113 | } | 4099 | } |
| 3114 | #[doc = "Fast-mode Plus (Fm+) driving capability activation on PB9"] | 4100 | #[doc = "Counter enable"] |
| 3115 | pub fn set_i2c_pb9_fmp(&mut self, val: bool) { | 4101 | pub fn set_cen(&mut self, val: bool) { |
| 3116 | self.0 = (self.0 & !(0x01 << 19usize)) | (((val as u32) & 0x01) << 19usize); | 4102 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); |
| 3117 | } | 4103 | } |
| 3118 | #[doc = "I2C1 Fast-mode Plus driving capability activation"] | 4104 | #[doc = "Update disable"] |
| 3119 | pub const fn i2c1_fmp(&self) -> bool { | 4105 | pub const fn udis(&self) -> bool { |
| 3120 | let val = (self.0 >> 20usize) & 0x01; | 4106 | let val = (self.0 >> 1usize) & 0x01; |
| 3121 | val != 0 | 4107 | val != 0 |
| 3122 | } | 4108 | } |
| 3123 | #[doc = "I2C1 Fast-mode Plus driving capability activation"] | 4109 | #[doc = "Update disable"] |
| 3124 | pub fn set_i2c1_fmp(&mut self, val: bool) { | 4110 | pub fn set_udis(&mut self, val: bool) { |
| 3125 | self.0 = (self.0 & !(0x01 << 20usize)) | (((val as u32) & 0x01) << 20usize); | 4111 | self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize); |
| 3126 | } | 4112 | } |
| 3127 | #[doc = "I2C2 Fast-mode Plus driving capability activation"] | 4113 | #[doc = "Update request source"] |
| 3128 | pub const fn i2c2_fmp(&self) -> bool { | 4114 | pub const fn urs(&self) -> super::vals::Urs { |
| 3129 | let val = (self.0 >> 21usize) & 0x01; | 4115 | let val = (self.0 >> 2usize) & 0x01; |
| 3130 | val != 0 | 4116 | super::vals::Urs(val as u8) |
| 3131 | } | 4117 | } |
| 3132 | #[doc = "I2C2 Fast-mode Plus driving capability activation"] | 4118 | #[doc = "Update request source"] |
| 3133 | pub fn set_i2c2_fmp(&mut self, val: bool) { | 4119 | pub fn set_urs(&mut self, val: super::vals::Urs) { |
| 3134 | self.0 = (self.0 & !(0x01 << 21usize)) | (((val as u32) & 0x01) << 21usize); | 4120 | self.0 = (self.0 & !(0x01 << 2usize)) | (((val.0 as u32) & 0x01) << 2usize); |
| 3135 | } | 4121 | } |
| 3136 | #[doc = "I2C3 Fast-mode Plus driving capability activation"] | 4122 | #[doc = "One-pulse mode"] |
| 3137 | pub const fn i2c3_fmp(&self) -> bool { | 4123 | pub const fn opm(&self) -> super::vals::Opm { |
| 3138 | let val = (self.0 >> 22usize) & 0x01; | 4124 | let val = (self.0 >> 3usize) & 0x01; |
| 3139 | val != 0 | 4125 | super::vals::Opm(val as u8) |
| 3140 | } | 4126 | } |
| 3141 | #[doc = "I2C3 Fast-mode Plus driving capability activation"] | 4127 | #[doc = "One-pulse mode"] |
| 3142 | pub fn set_i2c3_fmp(&mut self, val: bool) { | 4128 | pub fn set_opm(&mut self, val: super::vals::Opm) { |
| 3143 | self.0 = (self.0 & !(0x01 << 22usize)) | (((val as u32) & 0x01) << 22usize); | 4129 | self.0 = (self.0 & !(0x01 << 3usize)) | (((val.0 as u32) & 0x01) << 3usize); |
| 3144 | } | 4130 | } |
| 3145 | #[doc = "Floating Point Unit interrupts enable bits"] | 4131 | #[doc = "Auto-reload preload enable"] |
| 3146 | pub const fn fpu_ie(&self) -> u8 { | 4132 | pub const fn arpe(&self) -> super::vals::Arpe { |
| 3147 | let val = (self.0 >> 26usize) & 0x3f; | 4133 | let val = (self.0 >> 7usize) & 0x01; |
| 3148 | val as u8 | 4134 | super::vals::Arpe(val as u8) |
| 3149 | } | 4135 | } |
| 3150 | #[doc = "Floating Point Unit interrupts enable bits"] | 4136 | #[doc = "Auto-reload preload enable"] |
| 3151 | pub fn set_fpu_ie(&mut self, val: u8) { | 4137 | pub fn set_arpe(&mut self, val: super::vals::Arpe) { |
| 3152 | self.0 = (self.0 & !(0x3f << 26usize)) | (((val as u32) & 0x3f) << 26usize); | 4138 | self.0 = (self.0 & !(0x01 << 7usize)) | (((val.0 as u32) & 0x01) << 7usize); |
| 3153 | } | 4139 | } |
| 3154 | } | 4140 | } |
| 3155 | impl Default for Cfgr1 { | 4141 | impl Default for Cr1Basic { |
| 3156 | fn default() -> Cfgr1 { | 4142 | fn default() -> Cr1Basic { |
| 3157 | Cfgr1(0) | 4143 | Cr1Basic(0) |
| 3158 | } | 4144 | } |
| 3159 | } | 4145 | } |
| 3160 | #[doc = "CFGR2"] | 4146 | #[doc = "capture/compare register 1"] |
| 3161 | #[repr(transparent)] | 4147 | #[repr(transparent)] |
| 3162 | #[derive(Copy, Clone, Eq, PartialEq)] | 4148 | #[derive(Copy, Clone, Eq, PartialEq)] |
| 3163 | pub struct Cfgr2(pub u32); | 4149 | pub struct Ccr32(pub u32); |
| 3164 | impl Cfgr2 { | 4150 | impl Ccr32 { |
| 3165 | #[doc = "Cortex LOCKUP (Hardfault) output enable bit"] | 4151 | #[doc = "Capture/Compare 1 value"] |
| 3166 | pub const fn cll(&self) -> bool { | 4152 | pub const fn ccr(&self) -> u32 { |
| 4153 | let val = (self.0 >> 0usize) & 0xffff_ffff; | ||
| 4154 | val as u32 | ||
| 4155 | } | ||
| 4156 | #[doc = "Capture/Compare 1 value"] | ||
| 4157 | pub fn set_ccr(&mut self, val: u32) { | ||
| 4158 | self.0 = | ||
| 4159 | (self.0 & !(0xffff_ffff << 0usize)) | (((val as u32) & 0xffff_ffff) << 0usize); | ||
| 4160 | } | ||
| 4161 | } | ||
| 4162 | impl Default for Ccr32 { | ||
| 4163 | fn default() -> Ccr32 { | ||
| 4164 | Ccr32(0) | ||
| 4165 | } | ||
| 4166 | } | ||
| 4167 | #[doc = "status register"] | ||
| 4168 | #[repr(transparent)] | ||
| 4169 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 4170 | pub struct SrGp(pub u32); | ||
| 4171 | impl SrGp { | ||
| 4172 | #[doc = "Update interrupt flag"] | ||
| 4173 | pub const fn uif(&self) -> bool { | ||
| 3167 | let val = (self.0 >> 0usize) & 0x01; | 4174 | let val = (self.0 >> 0usize) & 0x01; |
| 3168 | val != 0 | 4175 | val != 0 |
| 3169 | } | 4176 | } |
| 3170 | #[doc = "Cortex LOCKUP (Hardfault) output enable bit"] | 4177 | #[doc = "Update interrupt flag"] |
| 3171 | pub fn set_cll(&mut self, val: bool) { | 4178 | pub fn set_uif(&mut self, val: bool) { |
| 3172 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); | 4179 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); |
| 3173 | } | 4180 | } |
| 3174 | #[doc = "SRAM2 parity lock bit"] | 4181 | #[doc = "Capture/compare 1 interrupt flag"] |
| 3175 | pub const fn spl(&self) -> bool { | 4182 | pub fn ccif(&self, n: usize) -> bool { |
| 3176 | let val = (self.0 >> 1usize) & 0x01; | 4183 | assert!(n < 4usize); |
| 4184 | let offs = 1usize + n * 1usize; | ||
| 4185 | let val = (self.0 >> offs) & 0x01; | ||
| 3177 | val != 0 | 4186 | val != 0 |
| 3178 | } | 4187 | } |
| 3179 | #[doc = "SRAM2 parity lock bit"] | 4188 | #[doc = "Capture/compare 1 interrupt flag"] |
| 3180 | pub fn set_spl(&mut self, val: bool) { | 4189 | pub fn set_ccif(&mut self, n: usize, val: bool) { |
| 3181 | self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize); | 4190 | assert!(n < 4usize); |
| 4191 | let offs = 1usize + n * 1usize; | ||
| 4192 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | ||
| 3182 | } | 4193 | } |
| 3183 | #[doc = "PVD lock enable bit"] | 4194 | #[doc = "COM interrupt flag"] |
| 3184 | pub const fn pvdl(&self) -> bool { | 4195 | pub const fn comif(&self) -> bool { |
| 3185 | let val = (self.0 >> 2usize) & 0x01; | 4196 | let val = (self.0 >> 5usize) & 0x01; |
| 3186 | val != 0 | 4197 | val != 0 |
| 3187 | } | 4198 | } |
| 3188 | #[doc = "PVD lock enable bit"] | 4199 | #[doc = "COM interrupt flag"] |
| 3189 | pub fn set_pvdl(&mut self, val: bool) { | 4200 | pub fn set_comif(&mut self, val: bool) { |
| 3190 | self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize); | 4201 | self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize); |
| 3191 | } | 4202 | } |
| 3192 | #[doc = "ECC Lock"] | 4203 | #[doc = "Trigger interrupt flag"] |
| 3193 | pub const fn eccl(&self) -> bool { | 4204 | pub const fn tif(&self) -> bool { |
| 3194 | let val = (self.0 >> 3usize) & 0x01; | 4205 | let val = (self.0 >> 6usize) & 0x01; |
| 3195 | val != 0 | 4206 | val != 0 |
| 3196 | } | 4207 | } |
| 3197 | #[doc = "ECC Lock"] | 4208 | #[doc = "Trigger interrupt flag"] |
| 3198 | pub fn set_eccl(&mut self, val: bool) { | 4209 | pub fn set_tif(&mut self, val: bool) { |
| 3199 | self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize); | 4210 | self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize); |
| 3200 | } | 4211 | } |
| 3201 | #[doc = "SRAM2 parity error flag"] | 4212 | #[doc = "Break interrupt flag"] |
| 3202 | pub const fn spf(&self) -> bool { | 4213 | pub const fn bif(&self) -> bool { |
| 3203 | let val = (self.0 >> 8usize) & 0x01; | 4214 | let val = (self.0 >> 7usize) & 0x01; |
| 3204 | val != 0 | 4215 | val != 0 |
| 3205 | } | 4216 | } |
| 3206 | #[doc = "SRAM2 parity error flag"] | 4217 | #[doc = "Break interrupt flag"] |
| 3207 | pub fn set_spf(&mut self, val: bool) { | 4218 | pub fn set_bif(&mut self, val: bool) { |
| 3208 | self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize); | 4219 | self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize); |
| 4220 | } | ||
| 4221 | #[doc = "Capture/Compare 1 overcapture flag"] | ||
| 4222 | pub fn ccof(&self, n: usize) -> bool { | ||
| 4223 | assert!(n < 4usize); | ||
| 4224 | let offs = 9usize + n * 1usize; | ||
| 4225 | let val = (self.0 >> offs) & 0x01; | ||
| 4226 | val != 0 | ||
| 4227 | } | ||
| 4228 | #[doc = "Capture/Compare 1 overcapture flag"] | ||
| 4229 | pub fn set_ccof(&mut self, n: usize, val: bool) { | ||
| 4230 | assert!(n < 4usize); | ||
| 4231 | let offs = 9usize + n * 1usize; | ||
| 4232 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | ||
| 3209 | } | 4233 | } |
| 3210 | } | 4234 | } |
| 3211 | impl Default for Cfgr2 { | 4235 | impl Default for SrGp { |
| 3212 | fn default() -> Cfgr2 { | 4236 | fn default() -> SrGp { |
| 3213 | Cfgr2(0) | 4237 | SrGp(0) |
| 3214 | } | 4238 | } |
| 3215 | } | 4239 | } |
| 3216 | } | 4240 | } |
| 3217 | } | 4241 | } |
| 3218 | pub mod gpio_v1 { | 4242 | pub mod exti_v1 { |
| 3219 | use crate::generic::*; | 4243 | use crate::generic::*; |
| 3220 | #[doc = "General purpose I/O"] | 4244 | #[doc = "External interrupt/event controller"] |
| 3221 | #[derive(Copy, Clone)] | 4245 | #[derive(Copy, Clone)] |
| 3222 | pub struct Gpio(pub *mut u8); | 4246 | pub struct Exti(pub *mut u8); |
| 3223 | unsafe impl Send for Gpio {} | 4247 | unsafe impl Send for Exti {} |
| 3224 | unsafe impl Sync for Gpio {} | 4248 | unsafe impl Sync for Exti {} |
| 3225 | impl Gpio { | 4249 | impl Exti { |
| 3226 | #[doc = "Port configuration register low (GPIOn_CRL)"] | 4250 | #[doc = "Interrupt mask register (EXTI_IMR)"] |
| 3227 | pub fn cr(self, n: usize) -> Reg<regs::Cr, RW> { | 4251 | pub fn imr(self) -> Reg<regs::Imr, RW> { |
| 3228 | assert!(n < 2usize); | 4252 | unsafe { Reg::from_ptr(self.0.add(0usize)) } |
| 3229 | unsafe { Reg::from_ptr(self.0.add(0usize + n * 4usize)) } | ||
| 3230 | } | 4253 | } |
| 3231 | #[doc = "Port input data register (GPIOn_IDR)"] | 4254 | #[doc = "Event mask register (EXTI_EMR)"] |
| 3232 | pub fn idr(self) -> Reg<regs::Idr, R> { | 4255 | pub fn emr(self) -> Reg<regs::Emr, RW> { |
| 4256 | unsafe { Reg::from_ptr(self.0.add(4usize)) } | ||
| 4257 | } | ||
| 4258 | #[doc = "Rising Trigger selection register (EXTI_RTSR)"] | ||
| 4259 | pub fn rtsr(self) -> Reg<regs::Rtsr, RW> { | ||
| 3233 | unsafe { Reg::from_ptr(self.0.add(8usize)) } | 4260 | unsafe { Reg::from_ptr(self.0.add(8usize)) } |
| 3234 | } | 4261 | } |
| 3235 | #[doc = "Port output data register (GPIOn_ODR)"] | 4262 | #[doc = "Falling Trigger selection register (EXTI_FTSR)"] |
| 3236 | pub fn odr(self) -> Reg<regs::Odr, RW> { | 4263 | pub fn ftsr(self) -> Reg<regs::Ftsr, RW> { |
| 3237 | unsafe { Reg::from_ptr(self.0.add(12usize)) } | 4264 | unsafe { Reg::from_ptr(self.0.add(12usize)) } |
| 3238 | } | 4265 | } |
| 3239 | #[doc = "Port bit set/reset register (GPIOn_BSRR)"] | 4266 | #[doc = "Software interrupt event register (EXTI_SWIER)"] |
| 3240 | pub fn bsrr(self) -> Reg<regs::Bsrr, W> { | 4267 | pub fn swier(self) -> Reg<regs::Swier, RW> { |
| 3241 | unsafe { Reg::from_ptr(self.0.add(16usize)) } | 4268 | unsafe { Reg::from_ptr(self.0.add(16usize)) } |
| 3242 | } | 4269 | } |
| 3243 | #[doc = "Port bit reset register (GPIOn_BRR)"] | 4270 | #[doc = "Pending register (EXTI_PR)"] |
| 3244 | pub fn brr(self) -> Reg<regs::Brr, W> { | 4271 | pub fn pr(self) -> Reg<regs::Pr, RW> { |
| 3245 | unsafe { Reg::from_ptr(self.0.add(20usize)) } | 4272 | unsafe { Reg::from_ptr(self.0.add(20usize)) } |
| 3246 | } | 4273 | } |
| 3247 | #[doc = "Port configuration lock register"] | ||
| 3248 | pub fn lckr(self) -> Reg<regs::Lckr, RW> { | ||
| 3249 | unsafe { Reg::from_ptr(self.0.add(24usize)) } | ||
| 3250 | } | ||
| 3251 | } | 4274 | } |
| 3252 | pub mod regs { | 4275 | pub mod regs { |
| 3253 | use crate::generic::*; | 4276 | use crate::generic::*; |
| 3254 | #[doc = "Port bit set/reset register (GPIOn_BSRR)"] | 4277 | #[doc = "Interrupt mask register (EXTI_IMR)"] |
| 3255 | #[repr(transparent)] | 4278 | #[repr(transparent)] |
| 3256 | #[derive(Copy, Clone, Eq, PartialEq)] | 4279 | #[derive(Copy, Clone, Eq, PartialEq)] |
| 3257 | pub struct Bsrr(pub u32); | 4280 | pub struct Imr(pub u32); |
| 3258 | impl Bsrr { | 4281 | impl Imr { |
| 3259 | #[doc = "Set bit"] | 4282 | #[doc = "Interrupt Mask on line 0"] |
| 3260 | pub fn bs(&self, n: usize) -> bool { | 4283 | pub fn mr(&self, n: usize) -> super::vals::Mr { |
| 3261 | assert!(n < 16usize); | 4284 | assert!(n < 23usize); |
| 3262 | let offs = 0usize + n * 1usize; | 4285 | let offs = 0usize + n * 1usize; |
| 3263 | let val = (self.0 >> offs) & 0x01; | 4286 | let val = (self.0 >> offs) & 0x01; |
| 3264 | val != 0 | 4287 | super::vals::Mr(val as u8) |
| 3265 | } | 4288 | } |
| 3266 | #[doc = "Set bit"] | 4289 | #[doc = "Interrupt Mask on line 0"] |
| 3267 | pub fn set_bs(&mut self, n: usize, val: bool) { | 4290 | pub fn set_mr(&mut self, n: usize, val: super::vals::Mr) { |
| 3268 | assert!(n < 16usize); | 4291 | assert!(n < 23usize); |
| 3269 | let offs = 0usize + n * 1usize; | 4292 | let offs = 0usize + n * 1usize; |
| 3270 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | 4293 | self.0 = (self.0 & !(0x01 << offs)) | (((val.0 as u32) & 0x01) << offs); |
| 3271 | } | ||
| 3272 | #[doc = "Reset bit"] | ||
| 3273 | pub fn br(&self, n: usize) -> bool { | ||
| 3274 | assert!(n < 16usize); | ||
| 3275 | let offs = 16usize + n * 1usize; | ||
| 3276 | let val = (self.0 >> offs) & 0x01; | ||
| 3277 | val != 0 | ||
| 3278 | } | ||
| 3279 | #[doc = "Reset bit"] | ||
| 3280 | pub fn set_br(&mut self, n: usize, val: bool) { | ||
| 3281 | assert!(n < 16usize); | ||
| 3282 | let offs = 16usize + n * 1usize; | ||
| 3283 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | ||
| 3284 | } | 4294 | } |
| 3285 | } | 4295 | } |
| 3286 | impl Default for Bsrr { | 4296 | impl Default for Imr { |
| 3287 | fn default() -> Bsrr { | 4297 | fn default() -> Imr { |
| 3288 | Bsrr(0) | 4298 | Imr(0) |
| 3289 | } | 4299 | } |
| 3290 | } | 4300 | } |
| 3291 | #[doc = "Port configuration lock register"] | 4301 | #[doc = "Falling Trigger selection register (EXTI_FTSR)"] |
| 3292 | #[repr(transparent)] | 4302 | #[repr(transparent)] |
| 3293 | #[derive(Copy, Clone, Eq, PartialEq)] | 4303 | #[derive(Copy, Clone, Eq, PartialEq)] |
| 3294 | pub struct Lckr(pub u32); | 4304 | pub struct Ftsr(pub u32); |
| 3295 | impl Lckr { | 4305 | impl Ftsr { |
| 3296 | #[doc = "Port A Lock bit"] | 4306 | #[doc = "Falling trigger event configuration of line 0"] |
| 3297 | pub fn lck(&self, n: usize) -> super::vals::Lck { | 4307 | pub fn tr(&self, n: usize) -> super::vals::Tr { |
| 3298 | assert!(n < 16usize); | 4308 | assert!(n < 23usize); |
| 3299 | let offs = 0usize + n * 1usize; | 4309 | let offs = 0usize + n * 1usize; |
| 3300 | let val = (self.0 >> offs) & 0x01; | 4310 | let val = (self.0 >> offs) & 0x01; |
| 3301 | super::vals::Lck(val as u8) | 4311 | super::vals::Tr(val as u8) |
| 3302 | } | 4312 | } |
| 3303 | #[doc = "Port A Lock bit"] | 4313 | #[doc = "Falling trigger event configuration of line 0"] |
| 3304 | pub fn set_lck(&mut self, n: usize, val: super::vals::Lck) { | 4314 | pub fn set_tr(&mut self, n: usize, val: super::vals::Tr) { |
| 3305 | assert!(n < 16usize); | 4315 | assert!(n < 23usize); |
| 3306 | let offs = 0usize + n * 1usize; | 4316 | let offs = 0usize + n * 1usize; |
| 3307 | self.0 = (self.0 & !(0x01 << offs)) | (((val.0 as u32) & 0x01) << offs); | 4317 | self.0 = (self.0 & !(0x01 << offs)) | (((val.0 as u32) & 0x01) << offs); |
| 3308 | } | 4318 | } |
| 3309 | #[doc = "Lock key"] | ||
| 3310 | pub const fn lckk(&self) -> super::vals::Lckk { | ||
| 3311 | let val = (self.0 >> 16usize) & 0x01; | ||
| 3312 | super::vals::Lckk(val as u8) | ||
| 3313 | } | ||
| 3314 | #[doc = "Lock key"] | ||
| 3315 | pub fn set_lckk(&mut self, val: super::vals::Lckk) { | ||
| 3316 | self.0 = (self.0 & !(0x01 << 16usize)) | (((val.0 as u32) & 0x01) << 16usize); | ||
| 3317 | } | ||
| 3318 | } | 4319 | } |
| 3319 | impl Default for Lckr { | 4320 | impl Default for Ftsr { |
| 3320 | fn default() -> Lckr { | 4321 | fn default() -> Ftsr { |
| 3321 | Lckr(0) | 4322 | Ftsr(0) |
| 3322 | } | 4323 | } |
| 3323 | } | 4324 | } |
| 3324 | #[doc = "Port output data register (GPIOn_ODR)"] | 4325 | #[doc = "Software interrupt event register (EXTI_SWIER)"] |
| 3325 | #[repr(transparent)] | 4326 | #[repr(transparent)] |
| 3326 | #[derive(Copy, Clone, Eq, PartialEq)] | 4327 | #[derive(Copy, Clone, Eq, PartialEq)] |
| 3327 | pub struct Odr(pub u32); | 4328 | pub struct Swier(pub u32); |
| 3328 | impl Odr { | 4329 | impl Swier { |
| 3329 | #[doc = "Port output data"] | 4330 | #[doc = "Software Interrupt on line 0"] |
| 3330 | pub fn odr(&self, n: usize) -> super::vals::Odr { | 4331 | pub fn swier(&self, n: usize) -> bool { |
| 3331 | assert!(n < 16usize); | 4332 | assert!(n < 23usize); |
| 3332 | let offs = 0usize + n * 1usize; | 4333 | let offs = 0usize + n * 1usize; |
| 3333 | let val = (self.0 >> offs) & 0x01; | 4334 | let val = (self.0 >> offs) & 0x01; |
| 3334 | super::vals::Odr(val as u8) | 4335 | val != 0 |
| 3335 | } | 4336 | } |
| 3336 | #[doc = "Port output data"] | 4337 | #[doc = "Software Interrupt on line 0"] |
| 3337 | pub fn set_odr(&mut self, n: usize, val: super::vals::Odr) { | 4338 | pub fn set_swier(&mut self, n: usize, val: bool) { |
| 3338 | assert!(n < 16usize); | 4339 | assert!(n < 23usize); |
| 3339 | let offs = 0usize + n * 1usize; | 4340 | let offs = 0usize + n * 1usize; |
| 3340 | self.0 = (self.0 & !(0x01 << offs)) | (((val.0 as u32) & 0x01) << offs); | 4341 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); |
| 3341 | } | 4342 | } |
| 3342 | } | 4343 | } |
| 3343 | impl Default for Odr { | 4344 | impl Default for Swier { |
| 3344 | fn default() -> Odr { | 4345 | fn default() -> Swier { |
| 3345 | Odr(0) | 4346 | Swier(0) |
| 3346 | } | 4347 | } |
| 3347 | } | 4348 | } |
| 3348 | #[doc = "Port configuration register (GPIOn_CRx)"] | 4349 | #[doc = "Pending register (EXTI_PR)"] |
| 3349 | #[repr(transparent)] | 4350 | #[repr(transparent)] |
| 3350 | #[derive(Copy, Clone, Eq, PartialEq)] | 4351 | #[derive(Copy, Clone, Eq, PartialEq)] |
| 3351 | pub struct Cr(pub u32); | 4352 | pub struct Pr(pub u32); |
| 3352 | impl Cr { | 4353 | impl Pr { |
| 3353 | #[doc = "Port n mode bits"] | 4354 | #[doc = "Pending bit 0"] |
| 3354 | pub fn mode(&self, n: usize) -> super::vals::Mode { | 4355 | pub fn pr(&self, n: usize) -> bool { |
| 3355 | assert!(n < 8usize); | 4356 | assert!(n < 23usize); |
| 3356 | let offs = 0usize + n * 4usize; | 4357 | let offs = 0usize + n * 1usize; |
| 3357 | let val = (self.0 >> offs) & 0x03; | 4358 | let val = (self.0 >> offs) & 0x01; |
| 3358 | super::vals::Mode(val as u8) | 4359 | val != 0 |
| 3359 | } | ||
| 3360 | #[doc = "Port n mode bits"] | ||
| 3361 | pub fn set_mode(&mut self, n: usize, val: super::vals::Mode) { | ||
| 3362 | assert!(n < 8usize); | ||
| 3363 | let offs = 0usize + n * 4usize; | ||
| 3364 | self.0 = (self.0 & !(0x03 << offs)) | (((val.0 as u32) & 0x03) << offs); | ||
| 3365 | } | ||
| 3366 | #[doc = "Port n configuration bits"] | ||
| 3367 | pub fn cnf(&self, n: usize) -> super::vals::Cnf { | ||
| 3368 | assert!(n < 8usize); | ||
| 3369 | let offs = 2usize + n * 4usize; | ||
| 3370 | let val = (self.0 >> offs) & 0x03; | ||
| 3371 | super::vals::Cnf(val as u8) | ||
| 3372 | } | 4360 | } |
| 3373 | #[doc = "Port n configuration bits"] | 4361 | #[doc = "Pending bit 0"] |
| 3374 | pub fn set_cnf(&mut self, n: usize, val: super::vals::Cnf) { | 4362 | pub fn set_pr(&mut self, n: usize, val: bool) { |
| 3375 | assert!(n < 8usize); | 4363 | assert!(n < 23usize); |
| 3376 | let offs = 2usize + n * 4usize; | 4364 | let offs = 0usize + n * 1usize; |
| 3377 | self.0 = (self.0 & !(0x03 << offs)) | (((val.0 as u32) & 0x03) << offs); | 4365 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); |
| 3378 | } | 4366 | } |
| 3379 | } | 4367 | } |
| 3380 | impl Default for Cr { | 4368 | impl Default for Pr { |
| 3381 | fn default() -> Cr { | 4369 | fn default() -> Pr { |
| 3382 | Cr(0) | 4370 | Pr(0) |
| 3383 | } | 4371 | } |
| 3384 | } | 4372 | } |
| 3385 | #[doc = "Port bit reset register (GPIOn_BRR)"] | 4373 | #[doc = "Event mask register (EXTI_EMR)"] |
| 3386 | #[repr(transparent)] | 4374 | #[repr(transparent)] |
| 3387 | #[derive(Copy, Clone, Eq, PartialEq)] | 4375 | #[derive(Copy, Clone, Eq, PartialEq)] |
| 3388 | pub struct Brr(pub u32); | 4376 | pub struct Emr(pub u32); |
| 3389 | impl Brr { | 4377 | impl Emr { |
| 3390 | #[doc = "Reset bit"] | 4378 | #[doc = "Event Mask on line 0"] |
| 3391 | pub fn br(&self, n: usize) -> bool { | 4379 | pub fn mr(&self, n: usize) -> super::vals::Mr { |
| 3392 | assert!(n < 16usize); | 4380 | assert!(n < 23usize); |
| 3393 | let offs = 0usize + n * 1usize; | 4381 | let offs = 0usize + n * 1usize; |
| 3394 | let val = (self.0 >> offs) & 0x01; | 4382 | let val = (self.0 >> offs) & 0x01; |
| 3395 | val != 0 | 4383 | super::vals::Mr(val as u8) |
| 3396 | } | 4384 | } |
| 3397 | #[doc = "Reset bit"] | 4385 | #[doc = "Event Mask on line 0"] |
| 3398 | pub fn set_br(&mut self, n: usize, val: bool) { | 4386 | pub fn set_mr(&mut self, n: usize, val: super::vals::Mr) { |
| 3399 | assert!(n < 16usize); | 4387 | assert!(n < 23usize); |
| 3400 | let offs = 0usize + n * 1usize; | 4388 | let offs = 0usize + n * 1usize; |
| 3401 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | 4389 | self.0 = (self.0 & !(0x01 << offs)) | (((val.0 as u32) & 0x01) << offs); |
| 3402 | } | 4390 | } |
| 3403 | } | 4391 | } |
| 3404 | impl Default for Brr { | 4392 | impl Default for Emr { |
| 3405 | fn default() -> Brr { | 4393 | fn default() -> Emr { |
| 3406 | Brr(0) | 4394 | Emr(0) |
| 3407 | } | 4395 | } |
| 3408 | } | 4396 | } |
| 3409 | #[doc = "Port input data register (GPIOn_IDR)"] | 4397 | #[doc = "Rising Trigger selection register (EXTI_RTSR)"] |
| 3410 | #[repr(transparent)] | 4398 | #[repr(transparent)] |
| 3411 | #[derive(Copy, Clone, Eq, PartialEq)] | 4399 | #[derive(Copy, Clone, Eq, PartialEq)] |
| 3412 | pub struct Idr(pub u32); | 4400 | pub struct Rtsr(pub u32); |
| 3413 | impl Idr { | 4401 | impl Rtsr { |
| 3414 | #[doc = "Port input data"] | 4402 | #[doc = "Rising trigger event configuration of line 0"] |
| 3415 | pub fn idr(&self, n: usize) -> super::vals::Idr { | 4403 | pub fn tr(&self, n: usize) -> super::vals::Tr { |
| 3416 | assert!(n < 16usize); | 4404 | assert!(n < 23usize); |
| 3417 | let offs = 0usize + n * 1usize; | 4405 | let offs = 0usize + n * 1usize; |
| 3418 | let val = (self.0 >> offs) & 0x01; | 4406 | let val = (self.0 >> offs) & 0x01; |
| 3419 | super::vals::Idr(val as u8) | 4407 | super::vals::Tr(val as u8) |
| 3420 | } | 4408 | } |
| 3421 | #[doc = "Port input data"] | 4409 | #[doc = "Rising trigger event configuration of line 0"] |
| 3422 | pub fn set_idr(&mut self, n: usize, val: super::vals::Idr) { | 4410 | pub fn set_tr(&mut self, n: usize, val: super::vals::Tr) { |
| 3423 | assert!(n < 16usize); | 4411 | assert!(n < 23usize); |
| 3424 | let offs = 0usize + n * 1usize; | 4412 | let offs = 0usize + n * 1usize; |
| 3425 | self.0 = (self.0 & !(0x01 << offs)) | (((val.0 as u32) & 0x01) << offs); | 4413 | self.0 = (self.0 & !(0x01 << offs)) | (((val.0 as u32) & 0x01) << offs); |
| 3426 | } | 4414 | } |
| 3427 | } | 4415 | } |
| 3428 | impl Default for Idr { | 4416 | impl Default for Rtsr { |
| 3429 | fn default() -> Idr { | 4417 | fn default() -> Rtsr { |
| 3430 | Idr(0) | 4418 | Rtsr(0) |
| 3431 | } | 4419 | } |
| 3432 | } | 4420 | } |
| 3433 | } | 4421 | } |
| @@ -3435,1473 +4423,513 @@ pub mod gpio_v1 { | |||
| 3435 | use crate::generic::*; | 4423 | use crate::generic::*; |
| 3436 | #[repr(transparent)] | 4424 | #[repr(transparent)] |
| 3437 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 4425 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 3438 | pub struct Lckk(pub u8); | 4426 | pub struct Mr(pub u8); |
| 3439 | impl Lckk { | 4427 | impl Mr { |
| 3440 | #[doc = "Port configuration lock key not active"] | 4428 | #[doc = "Interrupt request line is masked"] |
| 3441 | pub const NOTACTIVE: Self = Self(0); | 4429 | pub const MASKED: Self = Self(0); |
| 3442 | #[doc = "Port configuration lock key active"] | 4430 | #[doc = "Interrupt request line is unmasked"] |
| 3443 | pub const ACTIVE: Self = Self(0x01); | 4431 | pub const UNMASKED: Self = Self(0x01); |
| 3444 | } | ||
| 3445 | #[repr(transparent)] | ||
| 3446 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 3447 | pub struct Odr(pub u8); | ||
| 3448 | impl Odr { | ||
| 3449 | #[doc = "Set output to logic low"] | ||
| 3450 | pub const LOW: Self = Self(0); | ||
| 3451 | #[doc = "Set output to logic high"] | ||
| 3452 | pub const HIGH: Self = Self(0x01); | ||
| 3453 | } | ||
| 3454 | #[repr(transparent)] | ||
| 3455 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 3456 | pub struct Lck(pub u8); | ||
| 3457 | impl Lck { | ||
| 3458 | #[doc = "Port configuration not locked"] | ||
| 3459 | pub const UNLOCKED: Self = Self(0); | ||
| 3460 | #[doc = "Port configuration locked"] | ||
| 3461 | pub const LOCKED: Self = Self(0x01); | ||
| 3462 | } | ||
| 3463 | #[repr(transparent)] | ||
| 3464 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 3465 | pub struct Bsw(pub u8); | ||
| 3466 | impl Bsw { | ||
| 3467 | #[doc = "No action on the corresponding ODx bit"] | ||
| 3468 | pub const NOACTION: Self = Self(0); | ||
| 3469 | #[doc = "Sets the corresponding ODRx bit"] | ||
| 3470 | pub const SET: Self = Self(0x01); | ||
| 3471 | } | 4432 | } |
| 3472 | #[repr(transparent)] | 4433 | #[repr(transparent)] |
| 3473 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 4434 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 3474 | pub struct Brw(pub u8); | 4435 | pub struct Tr(pub u8); |
| 3475 | impl Brw { | 4436 | impl Tr { |
| 3476 | #[doc = "No action on the corresponding ODx bit"] | 4437 | #[doc = "Falling edge trigger is disabled"] |
| 3477 | pub const NOACTION: Self = Self(0); | 4438 | pub const DISABLED: Self = Self(0); |
| 3478 | #[doc = "Reset the ODx bit"] | 4439 | #[doc = "Falling edge trigger is enabled"] |
| 3479 | pub const RESET: Self = Self(0x01); | 4440 | pub const ENABLED: Self = Self(0x01); |
| 3480 | } | 4441 | } |
| 3481 | #[repr(transparent)] | 4442 | #[repr(transparent)] |
| 3482 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 4443 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 3483 | pub struct Idr(pub u8); | 4444 | pub struct Prr(pub u8); |
| 3484 | impl Idr { | 4445 | impl Prr { |
| 3485 | #[doc = "Input is logic low"] | 4446 | #[doc = "No trigger request occurred"] |
| 3486 | pub const LOW: Self = Self(0); | 4447 | pub const NOTPENDING: Self = Self(0); |
| 3487 | #[doc = "Input is logic high"] | 4448 | #[doc = "Selected trigger request occurred"] |
| 3488 | pub const HIGH: Self = Self(0x01); | 4449 | pub const PENDING: Self = Self(0x01); |
| 3489 | } | 4450 | } |
| 3490 | #[repr(transparent)] | 4451 | #[repr(transparent)] |
| 3491 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 4452 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 3492 | pub struct Mode(pub u8); | 4453 | pub struct Swierw(pub u8); |
| 3493 | impl Mode { | 4454 | impl Swierw { |
| 3494 | #[doc = "Input mode (reset state)"] | 4455 | #[doc = "Generates an interrupt request"] |
| 3495 | pub const INPUT: Self = Self(0); | 4456 | pub const PEND: Self = Self(0x01); |
| 3496 | #[doc = "Output mode 10 MHz"] | ||
| 3497 | pub const OUTPUT: Self = Self(0x01); | ||
| 3498 | #[doc = "Output mode 2 MHz"] | ||
| 3499 | pub const OUTPUT2: Self = Self(0x02); | ||
| 3500 | #[doc = "Output mode 50 MHz"] | ||
| 3501 | pub const OUTPUT50: Self = Self(0x03); | ||
| 3502 | } | 4457 | } |
| 3503 | #[repr(transparent)] | 4458 | #[repr(transparent)] |
| 3504 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 4459 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 3505 | pub struct Cnf(pub u8); | 4460 | pub struct Prw(pub u8); |
| 3506 | impl Cnf { | 4461 | impl Prw { |
| 3507 | #[doc = "Analog mode / Push-Pull mode"] | 4462 | #[doc = "Clears pending bit"] |
| 3508 | pub const PUSHPULL: Self = Self(0); | 4463 | pub const CLEAR: Self = Self(0x01); |
| 3509 | #[doc = "Floating input (reset state) / Open Drain-Mode"] | ||
| 3510 | pub const OPENDRAIN: Self = Self(0x01); | ||
| 3511 | #[doc = "Input with pull-up/pull-down / Alternate Function Push-Pull Mode"] | ||
| 3512 | pub const ALTPUSHPULL: Self = Self(0x02); | ||
| 3513 | #[doc = "Alternate Function Open-Drain Mode"] | ||
| 3514 | pub const ALTOPENDRAIN: Self = Self(0x03); | ||
| 3515 | } | 4464 | } |
| 3516 | } | 4465 | } |
| 3517 | } | 4466 | } |
| 3518 | pub mod usart_v1 { | 4467 | pub mod generic { |
| 3519 | use crate::generic::*; | 4468 | use core::marker::PhantomData; |
| 3520 | #[doc = "Universal synchronous asynchronous receiver transmitter"] | ||
| 3521 | #[derive(Copy, Clone)] | 4469 | #[derive(Copy, Clone)] |
| 3522 | pub struct Usart(pub *mut u8); | 4470 | pub struct RW; |
| 3523 | unsafe impl Send for Usart {} | 4471 | #[derive(Copy, Clone)] |
| 3524 | unsafe impl Sync for Usart {} | 4472 | pub struct R; |
| 3525 | impl Usart { | 4473 | #[derive(Copy, Clone)] |
| 3526 | #[doc = "Status register"] | 4474 | pub struct W; |
| 3527 | pub fn sr(self) -> Reg<regs::Sr, RW> { | 4475 | mod sealed { |
| 3528 | unsafe { Reg::from_ptr(self.0.add(0usize)) } | 4476 | use super::*; |
| 4477 | pub trait Access {} | ||
| 4478 | impl Access for R {} | ||
| 4479 | impl Access for W {} | ||
| 4480 | impl Access for RW {} | ||
| 4481 | } | ||
| 4482 | pub trait Access: sealed::Access + Copy {} | ||
| 4483 | impl Access for R {} | ||
| 4484 | impl Access for W {} | ||
| 4485 | impl Access for RW {} | ||
| 4486 | pub trait Read: Access {} | ||
| 4487 | impl Read for RW {} | ||
| 4488 | impl Read for R {} | ||
| 4489 | pub trait Write: Access {} | ||
| 4490 | impl Write for RW {} | ||
| 4491 | impl Write for W {} | ||
| 4492 | #[derive(Copy, Clone)] | ||
| 4493 | pub struct Reg<T: Copy, A: Access> { | ||
| 4494 | ptr: *mut u8, | ||
| 4495 | phantom: PhantomData<*mut (T, A)>, | ||
| 4496 | } | ||
| 4497 | unsafe impl<T: Copy, A: Access> Send for Reg<T, A> {} | ||
| 4498 | unsafe impl<T: Copy, A: Access> Sync for Reg<T, A> {} | ||
| 4499 | impl<T: Copy, A: Access> Reg<T, A> { | ||
| 4500 | pub fn from_ptr(ptr: *mut u8) -> Self { | ||
| 4501 | Self { | ||
| 4502 | ptr, | ||
| 4503 | phantom: PhantomData, | ||
| 4504 | } | ||
| 3529 | } | 4505 | } |
| 3530 | #[doc = "Data register"] | 4506 | pub fn ptr(&self) -> *mut T { |
| 3531 | pub fn dr(self) -> Reg<regs::Dr, RW> { | 4507 | self.ptr as _ |
| 3532 | unsafe { Reg::from_ptr(self.0.add(4usize)) } | ||
| 3533 | } | 4508 | } |
| 3534 | #[doc = "Baud rate register"] | 4509 | } |
| 3535 | pub fn brr(self) -> Reg<regs::Brr, RW> { | 4510 | impl<T: Copy, A: Read> Reg<T, A> { |
| 3536 | unsafe { Reg::from_ptr(self.0.add(8usize)) } | 4511 | pub unsafe fn read(&self) -> T { |
| 4512 | (self.ptr as *mut T).read_volatile() | ||
| 3537 | } | 4513 | } |
| 3538 | #[doc = "Control register 1"] | 4514 | } |
| 3539 | pub fn cr1(self) -> Reg<regs::Cr1, RW> { | 4515 | impl<T: Copy, A: Write> Reg<T, A> { |
| 3540 | unsafe { Reg::from_ptr(self.0.add(12usize)) } | 4516 | pub unsafe fn write_value(&self, val: T) { |
| 4517 | (self.ptr as *mut T).write_volatile(val) | ||
| 3541 | } | 4518 | } |
| 3542 | #[doc = "Control register 2"] | 4519 | } |
| 3543 | pub fn cr2(self) -> Reg<regs::Cr2Usart, RW> { | 4520 | impl<T: Default + Copy, A: Write> Reg<T, A> { |
| 3544 | unsafe { Reg::from_ptr(self.0.add(16usize)) } | 4521 | pub unsafe fn write<R>(&self, f: impl FnOnce(&mut T) -> R) -> R { |
| 4522 | let mut val = Default::default(); | ||
| 4523 | let res = f(&mut val); | ||
| 4524 | self.write_value(val); | ||
| 4525 | res | ||
| 3545 | } | 4526 | } |
| 3546 | #[doc = "Control register 3"] | 4527 | } |
| 3547 | pub fn cr3(self) -> Reg<regs::Cr3Usart, RW> { | 4528 | impl<T: Copy, A: Read + Write> Reg<T, A> { |
| 3548 | unsafe { Reg::from_ptr(self.0.add(20usize)) } | 4529 | pub unsafe fn modify<R>(&self, f: impl FnOnce(&mut T) -> R) -> R { |
| 4530 | let mut val = self.read(); | ||
| 4531 | let res = f(&mut val); | ||
| 4532 | self.write_value(val); | ||
| 4533 | res | ||
| 3549 | } | 4534 | } |
| 3550 | #[doc = "Guard time and prescaler register"] | 4535 | } |
| 3551 | pub fn gtpr(self) -> Reg<regs::Gtpr, RW> { | 4536 | } |
| 3552 | unsafe { Reg::from_ptr(self.0.add(24usize)) } | 4537 | pub mod dma_v2 { |
| 4538 | use crate::generic::*; | ||
| 4539 | #[doc = "DMA controller"] | ||
| 4540 | #[derive(Copy, Clone)] | ||
| 4541 | pub struct Dma(pub *mut u8); | ||
| 4542 | unsafe impl Send for Dma {} | ||
| 4543 | unsafe impl Sync for Dma {} | ||
| 4544 | impl Dma { | ||
| 4545 | #[doc = "low interrupt status register"] | ||
| 4546 | pub fn isr(self, n: usize) -> Reg<regs::Isr, R> { | ||
| 4547 | assert!(n < 2usize); | ||
| 4548 | unsafe { Reg::from_ptr(self.0.add(0usize + n * 4usize)) } | ||
| 4549 | } | ||
| 4550 | #[doc = "low interrupt flag clear register"] | ||
| 4551 | pub fn ifcr(self, n: usize) -> Reg<regs::Ifcr, W> { | ||
| 4552 | assert!(n < 2usize); | ||
| 4553 | unsafe { Reg::from_ptr(self.0.add(8usize + n * 4usize)) } | ||
| 4554 | } | ||
| 4555 | #[doc = "Stream cluster: S?CR, S?NDTR, S?M0AR, S?M1AR and S?FCR registers"] | ||
| 4556 | pub fn st(self, n: usize) -> St { | ||
| 4557 | assert!(n < 8usize); | ||
| 4558 | unsafe { St(self.0.add(16usize + n * 24usize)) } | ||
| 3553 | } | 4559 | } |
| 3554 | } | 4560 | } |
| 3555 | #[doc = "Universal asynchronous receiver transmitter"] | 4561 | #[doc = "Stream cluster: S?CR, S?NDTR, S?M0AR, S?M1AR and S?FCR registers"] |
| 3556 | #[derive(Copy, Clone)] | 4562 | #[derive(Copy, Clone)] |
| 3557 | pub struct Uart(pub *mut u8); | 4563 | pub struct St(pub *mut u8); |
| 3558 | unsafe impl Send for Uart {} | 4564 | unsafe impl Send for St {} |
| 3559 | unsafe impl Sync for Uart {} | 4565 | unsafe impl Sync for St {} |
| 3560 | impl Uart { | 4566 | impl St { |
| 3561 | #[doc = "Status register"] | 4567 | #[doc = "stream x configuration register"] |
| 3562 | pub fn sr(self) -> Reg<regs::Sr, RW> { | 4568 | pub fn cr(self) -> Reg<regs::Cr, RW> { |
| 3563 | unsafe { Reg::from_ptr(self.0.add(0usize)) } | 4569 | unsafe { Reg::from_ptr(self.0.add(0usize)) } |
| 3564 | } | 4570 | } |
| 3565 | #[doc = "Data register"] | 4571 | #[doc = "stream x number of data register"] |
| 3566 | pub fn dr(self) -> Reg<regs::Dr, RW> { | 4572 | pub fn ndtr(self) -> Reg<regs::Ndtr, RW> { |
| 3567 | unsafe { Reg::from_ptr(self.0.add(4usize)) } | 4573 | unsafe { Reg::from_ptr(self.0.add(4usize)) } |
| 3568 | } | 4574 | } |
| 3569 | #[doc = "Baud rate register"] | 4575 | #[doc = "stream x peripheral address register"] |
| 3570 | pub fn brr(self) -> Reg<regs::Brr, RW> { | 4576 | pub fn par(self) -> Reg<u32, RW> { |
| 3571 | unsafe { Reg::from_ptr(self.0.add(8usize)) } | 4577 | unsafe { Reg::from_ptr(self.0.add(8usize)) } |
| 3572 | } | 4578 | } |
| 3573 | #[doc = "Control register 1"] | 4579 | #[doc = "stream x memory 0 address register"] |
| 3574 | pub fn cr1(self) -> Reg<regs::Cr1, RW> { | 4580 | pub fn m0ar(self) -> Reg<u32, RW> { |
| 3575 | unsafe { Reg::from_ptr(self.0.add(12usize)) } | 4581 | unsafe { Reg::from_ptr(self.0.add(12usize)) } |
| 3576 | } | 4582 | } |
| 3577 | #[doc = "Control register 2"] | 4583 | #[doc = "stream x memory 1 address register"] |
| 3578 | pub fn cr2(self) -> Reg<regs::Cr2, RW> { | 4584 | pub fn m1ar(self) -> Reg<u32, RW> { |
| 3579 | unsafe { Reg::from_ptr(self.0.add(16usize)) } | 4585 | unsafe { Reg::from_ptr(self.0.add(16usize)) } |
| 3580 | } | 4586 | } |
| 3581 | #[doc = "Control register 3"] | 4587 | #[doc = "stream x FIFO control register"] |
| 3582 | pub fn cr3(self) -> Reg<regs::Cr3, RW> { | 4588 | pub fn fcr(self) -> Reg<regs::Fcr, RW> { |
| 3583 | unsafe { Reg::from_ptr(self.0.add(20usize)) } | 4589 | unsafe { Reg::from_ptr(self.0.add(20usize)) } |
| 3584 | } | 4590 | } |
| 3585 | } | 4591 | } |
| 3586 | pub mod regs { | ||
| 3587 | use crate::generic::*; | ||
| 3588 | #[doc = "Baud rate register"] | ||
| 3589 | #[repr(transparent)] | ||
| 3590 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 3591 | pub struct Brr(pub u32); | ||
| 3592 | impl Brr { | ||
| 3593 | #[doc = "fraction of USARTDIV"] | ||
| 3594 | pub const fn div_fraction(&self) -> u8 { | ||
| 3595 | let val = (self.0 >> 0usize) & 0x0f; | ||
| 3596 | val as u8 | ||
| 3597 | } | ||
| 3598 | #[doc = "fraction of USARTDIV"] | ||
| 3599 | pub fn set_div_fraction(&mut self, val: u8) { | ||
| 3600 | self.0 = (self.0 & !(0x0f << 0usize)) | (((val as u32) & 0x0f) << 0usize); | ||
| 3601 | } | ||
| 3602 | #[doc = "mantissa of USARTDIV"] | ||
| 3603 | pub const fn div_mantissa(&self) -> u16 { | ||
| 3604 | let val = (self.0 >> 4usize) & 0x0fff; | ||
| 3605 | val as u16 | ||
| 3606 | } | ||
| 3607 | #[doc = "mantissa of USARTDIV"] | ||
| 3608 | pub fn set_div_mantissa(&mut self, val: u16) { | ||
| 3609 | self.0 = (self.0 & !(0x0fff << 4usize)) | (((val as u32) & 0x0fff) << 4usize); | ||
| 3610 | } | ||
| 3611 | } | ||
| 3612 | impl Default for Brr { | ||
| 3613 | fn default() -> Brr { | ||
| 3614 | Brr(0) | ||
| 3615 | } | ||
| 3616 | } | ||
| 3617 | #[doc = "Data register"] | ||
| 3618 | #[repr(transparent)] | ||
| 3619 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 3620 | pub struct Dr(pub u32); | ||
| 3621 | impl Dr { | ||
| 3622 | #[doc = "Data value"] | ||
| 3623 | pub const fn dr(&self) -> u16 { | ||
| 3624 | let val = (self.0 >> 0usize) & 0x01ff; | ||
| 3625 | val as u16 | ||
| 3626 | } | ||
| 3627 | #[doc = "Data value"] | ||
| 3628 | pub fn set_dr(&mut self, val: u16) { | ||
| 3629 | self.0 = (self.0 & !(0x01ff << 0usize)) | (((val as u32) & 0x01ff) << 0usize); | ||
| 3630 | } | ||
| 3631 | } | ||
| 3632 | impl Default for Dr { | ||
| 3633 | fn default() -> Dr { | ||
| 3634 | Dr(0) | ||
| 3635 | } | ||
| 3636 | } | ||
| 3637 | #[doc = "Control register 3"] | ||
| 3638 | #[repr(transparent)] | ||
| 3639 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 3640 | pub struct Cr3(pub u32); | ||
| 3641 | impl Cr3 { | ||
| 3642 | #[doc = "Error interrupt enable"] | ||
| 3643 | pub const fn eie(&self) -> bool { | ||
| 3644 | let val = (self.0 >> 0usize) & 0x01; | ||
| 3645 | val != 0 | ||
| 3646 | } | ||
| 3647 | #[doc = "Error interrupt enable"] | ||
| 3648 | pub fn set_eie(&mut self, val: bool) { | ||
| 3649 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); | ||
| 3650 | } | ||
| 3651 | #[doc = "IrDA mode enable"] | ||
| 3652 | pub const fn iren(&self) -> bool { | ||
| 3653 | let val = (self.0 >> 1usize) & 0x01; | ||
| 3654 | val != 0 | ||
| 3655 | } | ||
| 3656 | #[doc = "IrDA mode enable"] | ||
| 3657 | pub fn set_iren(&mut self, val: bool) { | ||
| 3658 | self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize); | ||
| 3659 | } | ||
| 3660 | #[doc = "IrDA low-power"] | ||
| 3661 | pub const fn irlp(&self) -> super::vals::Irlp { | ||
| 3662 | let val = (self.0 >> 2usize) & 0x01; | ||
| 3663 | super::vals::Irlp(val as u8) | ||
| 3664 | } | ||
| 3665 | #[doc = "IrDA low-power"] | ||
| 3666 | pub fn set_irlp(&mut self, val: super::vals::Irlp) { | ||
| 3667 | self.0 = (self.0 & !(0x01 << 2usize)) | (((val.0 as u32) & 0x01) << 2usize); | ||
| 3668 | } | ||
| 3669 | #[doc = "Half-duplex selection"] | ||
| 3670 | pub const fn hdsel(&self) -> super::vals::Hdsel { | ||
| 3671 | let val = (self.0 >> 3usize) & 0x01; | ||
| 3672 | super::vals::Hdsel(val as u8) | ||
| 3673 | } | ||
| 3674 | #[doc = "Half-duplex selection"] | ||
| 3675 | pub fn set_hdsel(&mut self, val: super::vals::Hdsel) { | ||
| 3676 | self.0 = (self.0 & !(0x01 << 3usize)) | (((val.0 as u32) & 0x01) << 3usize); | ||
| 3677 | } | ||
| 3678 | #[doc = "DMA enable receiver"] | ||
| 3679 | pub const fn dmar(&self) -> bool { | ||
| 3680 | let val = (self.0 >> 6usize) & 0x01; | ||
| 3681 | val != 0 | ||
| 3682 | } | ||
| 3683 | #[doc = "DMA enable receiver"] | ||
| 3684 | pub fn set_dmar(&mut self, val: bool) { | ||
| 3685 | self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize); | ||
| 3686 | } | ||
| 3687 | #[doc = "DMA enable transmitter"] | ||
| 3688 | pub const fn dmat(&self) -> bool { | ||
| 3689 | let val = (self.0 >> 7usize) & 0x01; | ||
| 3690 | val != 0 | ||
| 3691 | } | ||
| 3692 | #[doc = "DMA enable transmitter"] | ||
| 3693 | pub fn set_dmat(&mut self, val: bool) { | ||
| 3694 | self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize); | ||
| 3695 | } | ||
| 3696 | } | ||
| 3697 | impl Default for Cr3 { | ||
| 3698 | fn default() -> Cr3 { | ||
| 3699 | Cr3(0) | ||
| 3700 | } | ||
| 3701 | } | ||
| 3702 | #[doc = "Status register"] | ||
| 3703 | #[repr(transparent)] | ||
| 3704 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 3705 | pub struct SrUsart(pub u32); | ||
| 3706 | impl SrUsart { | ||
| 3707 | #[doc = "Parity error"] | ||
| 3708 | pub const fn pe(&self) -> bool { | ||
| 3709 | let val = (self.0 >> 0usize) & 0x01; | ||
| 3710 | val != 0 | ||
| 3711 | } | ||
| 3712 | #[doc = "Parity error"] | ||
| 3713 | pub fn set_pe(&mut self, val: bool) { | ||
| 3714 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); | ||
| 3715 | } | ||
| 3716 | #[doc = "Framing error"] | ||
| 3717 | pub const fn fe(&self) -> bool { | ||
| 3718 | let val = (self.0 >> 1usize) & 0x01; | ||
| 3719 | val != 0 | ||
| 3720 | } | ||
| 3721 | #[doc = "Framing error"] | ||
| 3722 | pub fn set_fe(&mut self, val: bool) { | ||
| 3723 | self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize); | ||
| 3724 | } | ||
| 3725 | #[doc = "Noise error flag"] | ||
| 3726 | pub const fn ne(&self) -> bool { | ||
| 3727 | let val = (self.0 >> 2usize) & 0x01; | ||
| 3728 | val != 0 | ||
| 3729 | } | ||
| 3730 | #[doc = "Noise error flag"] | ||
| 3731 | pub fn set_ne(&mut self, val: bool) { | ||
| 3732 | self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize); | ||
| 3733 | } | ||
| 3734 | #[doc = "Overrun error"] | ||
| 3735 | pub const fn ore(&self) -> bool { | ||
| 3736 | let val = (self.0 >> 3usize) & 0x01; | ||
| 3737 | val != 0 | ||
| 3738 | } | ||
| 3739 | #[doc = "Overrun error"] | ||
| 3740 | pub fn set_ore(&mut self, val: bool) { | ||
| 3741 | self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize); | ||
| 3742 | } | ||
| 3743 | #[doc = "IDLE line detected"] | ||
| 3744 | pub const fn idle(&self) -> bool { | ||
| 3745 | let val = (self.0 >> 4usize) & 0x01; | ||
| 3746 | val != 0 | ||
| 3747 | } | ||
| 3748 | #[doc = "IDLE line detected"] | ||
| 3749 | pub fn set_idle(&mut self, val: bool) { | ||
| 3750 | self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize); | ||
| 3751 | } | ||
| 3752 | #[doc = "Read data register not empty"] | ||
| 3753 | pub const fn rxne(&self) -> bool { | ||
| 3754 | let val = (self.0 >> 5usize) & 0x01; | ||
| 3755 | val != 0 | ||
| 3756 | } | ||
| 3757 | #[doc = "Read data register not empty"] | ||
| 3758 | pub fn set_rxne(&mut self, val: bool) { | ||
| 3759 | self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize); | ||
| 3760 | } | ||
| 3761 | #[doc = "Transmission complete"] | ||
| 3762 | pub const fn tc(&self) -> bool { | ||
| 3763 | let val = (self.0 >> 6usize) & 0x01; | ||
| 3764 | val != 0 | ||
| 3765 | } | ||
| 3766 | #[doc = "Transmission complete"] | ||
| 3767 | pub fn set_tc(&mut self, val: bool) { | ||
| 3768 | self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize); | ||
| 3769 | } | ||
| 3770 | #[doc = "Transmit data register empty"] | ||
| 3771 | pub const fn txe(&self) -> bool { | ||
| 3772 | let val = (self.0 >> 7usize) & 0x01; | ||
| 3773 | val != 0 | ||
| 3774 | } | ||
| 3775 | #[doc = "Transmit data register empty"] | ||
| 3776 | pub fn set_txe(&mut self, val: bool) { | ||
| 3777 | self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize); | ||
| 3778 | } | ||
| 3779 | #[doc = "LIN break detection flag"] | ||
| 3780 | pub const fn lbd(&self) -> bool { | ||
| 3781 | let val = (self.0 >> 8usize) & 0x01; | ||
| 3782 | val != 0 | ||
| 3783 | } | ||
| 3784 | #[doc = "LIN break detection flag"] | ||
| 3785 | pub fn set_lbd(&mut self, val: bool) { | ||
| 3786 | self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize); | ||
| 3787 | } | ||
| 3788 | #[doc = "CTS flag"] | ||
| 3789 | pub const fn cts(&self) -> bool { | ||
| 3790 | let val = (self.0 >> 9usize) & 0x01; | ||
| 3791 | val != 0 | ||
| 3792 | } | ||
| 3793 | #[doc = "CTS flag"] | ||
| 3794 | pub fn set_cts(&mut self, val: bool) { | ||
| 3795 | self.0 = (self.0 & !(0x01 << 9usize)) | (((val as u32) & 0x01) << 9usize); | ||
| 3796 | } | ||
| 3797 | } | ||
| 3798 | impl Default for SrUsart { | ||
| 3799 | fn default() -> SrUsart { | ||
| 3800 | SrUsart(0) | ||
| 3801 | } | ||
| 3802 | } | ||
| 3803 | #[doc = "Guard time and prescaler register"] | ||
| 3804 | #[repr(transparent)] | ||
| 3805 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 3806 | pub struct Gtpr(pub u32); | ||
| 3807 | impl Gtpr { | ||
| 3808 | #[doc = "Prescaler value"] | ||
| 3809 | pub const fn psc(&self) -> u8 { | ||
| 3810 | let val = (self.0 >> 0usize) & 0xff; | ||
| 3811 | val as u8 | ||
| 3812 | } | ||
| 3813 | #[doc = "Prescaler value"] | ||
| 3814 | pub fn set_psc(&mut self, val: u8) { | ||
| 3815 | self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize); | ||
| 3816 | } | ||
| 3817 | #[doc = "Guard time value"] | ||
| 3818 | pub const fn gt(&self) -> u8 { | ||
| 3819 | let val = (self.0 >> 8usize) & 0xff; | ||
| 3820 | val as u8 | ||
| 3821 | } | ||
| 3822 | #[doc = "Guard time value"] | ||
| 3823 | pub fn set_gt(&mut self, val: u8) { | ||
| 3824 | self.0 = (self.0 & !(0xff << 8usize)) | (((val as u32) & 0xff) << 8usize); | ||
| 3825 | } | ||
| 3826 | } | ||
| 3827 | impl Default for Gtpr { | ||
| 3828 | fn default() -> Gtpr { | ||
| 3829 | Gtpr(0) | ||
| 3830 | } | ||
| 3831 | } | ||
| 3832 | #[doc = "Control register 2"] | ||
| 3833 | #[repr(transparent)] | ||
| 3834 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 3835 | pub struct Cr2Usart(pub u32); | ||
| 3836 | impl Cr2Usart { | ||
| 3837 | #[doc = "Address of the USART node"] | ||
| 3838 | pub const fn add(&self) -> u8 { | ||
| 3839 | let val = (self.0 >> 0usize) & 0x0f; | ||
| 3840 | val as u8 | ||
| 3841 | } | ||
| 3842 | #[doc = "Address of the USART node"] | ||
| 3843 | pub fn set_add(&mut self, val: u8) { | ||
| 3844 | self.0 = (self.0 & !(0x0f << 0usize)) | (((val as u32) & 0x0f) << 0usize); | ||
| 3845 | } | ||
| 3846 | #[doc = "lin break detection length"] | ||
| 3847 | pub const fn lbdl(&self) -> super::vals::Lbdl { | ||
| 3848 | let val = (self.0 >> 5usize) & 0x01; | ||
| 3849 | super::vals::Lbdl(val as u8) | ||
| 3850 | } | ||
| 3851 | #[doc = "lin break detection length"] | ||
| 3852 | pub fn set_lbdl(&mut self, val: super::vals::Lbdl) { | ||
| 3853 | self.0 = (self.0 & !(0x01 << 5usize)) | (((val.0 as u32) & 0x01) << 5usize); | ||
| 3854 | } | ||
| 3855 | #[doc = "LIN break detection interrupt enable"] | ||
| 3856 | pub const fn lbdie(&self) -> bool { | ||
| 3857 | let val = (self.0 >> 6usize) & 0x01; | ||
| 3858 | val != 0 | ||
| 3859 | } | ||
| 3860 | #[doc = "LIN break detection interrupt enable"] | ||
| 3861 | pub fn set_lbdie(&mut self, val: bool) { | ||
| 3862 | self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize); | ||
| 3863 | } | ||
| 3864 | #[doc = "Last bit clock pulse"] | ||
| 3865 | pub const fn lbcl(&self) -> bool { | ||
| 3866 | let val = (self.0 >> 8usize) & 0x01; | ||
| 3867 | val != 0 | ||
| 3868 | } | ||
| 3869 | #[doc = "Last bit clock pulse"] | ||
| 3870 | pub fn set_lbcl(&mut self, val: bool) { | ||
| 3871 | self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize); | ||
| 3872 | } | ||
| 3873 | #[doc = "Clock phase"] | ||
| 3874 | pub const fn cpha(&self) -> super::vals::Cpha { | ||
| 3875 | let val = (self.0 >> 9usize) & 0x01; | ||
| 3876 | super::vals::Cpha(val as u8) | ||
| 3877 | } | ||
| 3878 | #[doc = "Clock phase"] | ||
| 3879 | pub fn set_cpha(&mut self, val: super::vals::Cpha) { | ||
| 3880 | self.0 = (self.0 & !(0x01 << 9usize)) | (((val.0 as u32) & 0x01) << 9usize); | ||
| 3881 | } | ||
| 3882 | #[doc = "Clock polarity"] | ||
| 3883 | pub const fn cpol(&self) -> super::vals::Cpol { | ||
| 3884 | let val = (self.0 >> 10usize) & 0x01; | ||
| 3885 | super::vals::Cpol(val as u8) | ||
| 3886 | } | ||
| 3887 | #[doc = "Clock polarity"] | ||
| 3888 | pub fn set_cpol(&mut self, val: super::vals::Cpol) { | ||
| 3889 | self.0 = (self.0 & !(0x01 << 10usize)) | (((val.0 as u32) & 0x01) << 10usize); | ||
| 3890 | } | ||
| 3891 | #[doc = "Clock enable"] | ||
| 3892 | pub const fn clken(&self) -> bool { | ||
| 3893 | let val = (self.0 >> 11usize) & 0x01; | ||
| 3894 | val != 0 | ||
| 3895 | } | ||
| 3896 | #[doc = "Clock enable"] | ||
| 3897 | pub fn set_clken(&mut self, val: bool) { | ||
| 3898 | self.0 = (self.0 & !(0x01 << 11usize)) | (((val as u32) & 0x01) << 11usize); | ||
| 3899 | } | ||
| 3900 | #[doc = "STOP bits"] | ||
| 3901 | pub const fn stop(&self) -> super::vals::Stop { | ||
| 3902 | let val = (self.0 >> 12usize) & 0x03; | ||
| 3903 | super::vals::Stop(val as u8) | ||
| 3904 | } | ||
| 3905 | #[doc = "STOP bits"] | ||
| 3906 | pub fn set_stop(&mut self, val: super::vals::Stop) { | ||
| 3907 | self.0 = (self.0 & !(0x03 << 12usize)) | (((val.0 as u32) & 0x03) << 12usize); | ||
| 3908 | } | ||
| 3909 | #[doc = "LIN mode enable"] | ||
| 3910 | pub const fn linen(&self) -> bool { | ||
| 3911 | let val = (self.0 >> 14usize) & 0x01; | ||
| 3912 | val != 0 | ||
| 3913 | } | ||
| 3914 | #[doc = "LIN mode enable"] | ||
| 3915 | pub fn set_linen(&mut self, val: bool) { | ||
| 3916 | self.0 = (self.0 & !(0x01 << 14usize)) | (((val as u32) & 0x01) << 14usize); | ||
| 3917 | } | ||
| 3918 | } | ||
| 3919 | impl Default for Cr2Usart { | ||
| 3920 | fn default() -> Cr2Usart { | ||
| 3921 | Cr2Usart(0) | ||
| 3922 | } | ||
| 3923 | } | ||
| 3924 | #[doc = "Control register 1"] | ||
| 3925 | #[repr(transparent)] | ||
| 3926 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 3927 | pub struct Cr1(pub u32); | ||
| 3928 | impl Cr1 { | ||
| 3929 | #[doc = "Send break"] | ||
| 3930 | pub const fn sbk(&self) -> super::vals::Sbk { | ||
| 3931 | let val = (self.0 >> 0usize) & 0x01; | ||
| 3932 | super::vals::Sbk(val as u8) | ||
| 3933 | } | ||
| 3934 | #[doc = "Send break"] | ||
| 3935 | pub fn set_sbk(&mut self, val: super::vals::Sbk) { | ||
| 3936 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val.0 as u32) & 0x01) << 0usize); | ||
| 3937 | } | ||
| 3938 | #[doc = "Receiver wakeup"] | ||
| 3939 | pub const fn rwu(&self) -> super::vals::Rwu { | ||
| 3940 | let val = (self.0 >> 1usize) & 0x01; | ||
| 3941 | super::vals::Rwu(val as u8) | ||
| 3942 | } | ||
| 3943 | #[doc = "Receiver wakeup"] | ||
| 3944 | pub fn set_rwu(&mut self, val: super::vals::Rwu) { | ||
| 3945 | self.0 = (self.0 & !(0x01 << 1usize)) | (((val.0 as u32) & 0x01) << 1usize); | ||
| 3946 | } | ||
| 3947 | #[doc = "Receiver enable"] | ||
| 3948 | pub const fn re(&self) -> bool { | ||
| 3949 | let val = (self.0 >> 2usize) & 0x01; | ||
| 3950 | val != 0 | ||
| 3951 | } | ||
| 3952 | #[doc = "Receiver enable"] | ||
| 3953 | pub fn set_re(&mut self, val: bool) { | ||
| 3954 | self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize); | ||
| 3955 | } | ||
| 3956 | #[doc = "Transmitter enable"] | ||
| 3957 | pub const fn te(&self) -> bool { | ||
| 3958 | let val = (self.0 >> 3usize) & 0x01; | ||
| 3959 | val != 0 | ||
| 3960 | } | ||
| 3961 | #[doc = "Transmitter enable"] | ||
| 3962 | pub fn set_te(&mut self, val: bool) { | ||
| 3963 | self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize); | ||
| 3964 | } | ||
| 3965 | #[doc = "IDLE interrupt enable"] | ||
| 3966 | pub const fn idleie(&self) -> bool { | ||
| 3967 | let val = (self.0 >> 4usize) & 0x01; | ||
| 3968 | val != 0 | ||
| 3969 | } | ||
| 3970 | #[doc = "IDLE interrupt enable"] | ||
| 3971 | pub fn set_idleie(&mut self, val: bool) { | ||
| 3972 | self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize); | ||
| 3973 | } | ||
| 3974 | #[doc = "RXNE interrupt enable"] | ||
| 3975 | pub const fn rxneie(&self) -> bool { | ||
| 3976 | let val = (self.0 >> 5usize) & 0x01; | ||
| 3977 | val != 0 | ||
| 3978 | } | ||
| 3979 | #[doc = "RXNE interrupt enable"] | ||
| 3980 | pub fn set_rxneie(&mut self, val: bool) { | ||
| 3981 | self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize); | ||
| 3982 | } | ||
| 3983 | #[doc = "Transmission complete interrupt enable"] | ||
| 3984 | pub const fn tcie(&self) -> bool { | ||
| 3985 | let val = (self.0 >> 6usize) & 0x01; | ||
| 3986 | val != 0 | ||
| 3987 | } | ||
| 3988 | #[doc = "Transmission complete interrupt enable"] | ||
| 3989 | pub fn set_tcie(&mut self, val: bool) { | ||
| 3990 | self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize); | ||
| 3991 | } | ||
| 3992 | #[doc = "TXE interrupt enable"] | ||
| 3993 | pub const fn txeie(&self) -> bool { | ||
| 3994 | let val = (self.0 >> 7usize) & 0x01; | ||
| 3995 | val != 0 | ||
| 3996 | } | ||
| 3997 | #[doc = "TXE interrupt enable"] | ||
| 3998 | pub fn set_txeie(&mut self, val: bool) { | ||
| 3999 | self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize); | ||
| 4000 | } | ||
| 4001 | #[doc = "PE interrupt enable"] | ||
| 4002 | pub const fn peie(&self) -> bool { | ||
| 4003 | let val = (self.0 >> 8usize) & 0x01; | ||
| 4004 | val != 0 | ||
| 4005 | } | ||
| 4006 | #[doc = "PE interrupt enable"] | ||
| 4007 | pub fn set_peie(&mut self, val: bool) { | ||
| 4008 | self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize); | ||
| 4009 | } | ||
| 4010 | #[doc = "Parity selection"] | ||
| 4011 | pub const fn ps(&self) -> super::vals::Ps { | ||
| 4012 | let val = (self.0 >> 9usize) & 0x01; | ||
| 4013 | super::vals::Ps(val as u8) | ||
| 4014 | } | ||
| 4015 | #[doc = "Parity selection"] | ||
| 4016 | pub fn set_ps(&mut self, val: super::vals::Ps) { | ||
| 4017 | self.0 = (self.0 & !(0x01 << 9usize)) | (((val.0 as u32) & 0x01) << 9usize); | ||
| 4018 | } | ||
| 4019 | #[doc = "Parity control enable"] | ||
| 4020 | pub const fn pce(&self) -> bool { | ||
| 4021 | let val = (self.0 >> 10usize) & 0x01; | ||
| 4022 | val != 0 | ||
| 4023 | } | ||
| 4024 | #[doc = "Parity control enable"] | ||
| 4025 | pub fn set_pce(&mut self, val: bool) { | ||
| 4026 | self.0 = (self.0 & !(0x01 << 10usize)) | (((val as u32) & 0x01) << 10usize); | ||
| 4027 | } | ||
| 4028 | #[doc = "Wakeup method"] | ||
| 4029 | pub const fn wake(&self) -> super::vals::Wake { | ||
| 4030 | let val = (self.0 >> 11usize) & 0x01; | ||
| 4031 | super::vals::Wake(val as u8) | ||
| 4032 | } | ||
| 4033 | #[doc = "Wakeup method"] | ||
| 4034 | pub fn set_wake(&mut self, val: super::vals::Wake) { | ||
| 4035 | self.0 = (self.0 & !(0x01 << 11usize)) | (((val.0 as u32) & 0x01) << 11usize); | ||
| 4036 | } | ||
| 4037 | #[doc = "Word length"] | ||
| 4038 | pub const fn m(&self) -> super::vals::M { | ||
| 4039 | let val = (self.0 >> 12usize) & 0x01; | ||
| 4040 | super::vals::M(val as u8) | ||
| 4041 | } | ||
| 4042 | #[doc = "Word length"] | ||
| 4043 | pub fn set_m(&mut self, val: super::vals::M) { | ||
| 4044 | self.0 = (self.0 & !(0x01 << 12usize)) | (((val.0 as u32) & 0x01) << 12usize); | ||
| 4045 | } | ||
| 4046 | #[doc = "USART enable"] | ||
| 4047 | pub const fn ue(&self) -> bool { | ||
| 4048 | let val = (self.0 >> 13usize) & 0x01; | ||
| 4049 | val != 0 | ||
| 4050 | } | ||
| 4051 | #[doc = "USART enable"] | ||
| 4052 | pub fn set_ue(&mut self, val: bool) { | ||
| 4053 | self.0 = (self.0 & !(0x01 << 13usize)) | (((val as u32) & 0x01) << 13usize); | ||
| 4054 | } | ||
| 4055 | } | ||
| 4056 | impl Default for Cr1 { | ||
| 4057 | fn default() -> Cr1 { | ||
| 4058 | Cr1(0) | ||
| 4059 | } | ||
| 4060 | } | ||
| 4061 | #[doc = "Control register 3"] | ||
| 4062 | #[repr(transparent)] | ||
| 4063 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 4064 | pub struct Cr3Usart(pub u32); | ||
| 4065 | impl Cr3Usart { | ||
| 4066 | #[doc = "Error interrupt enable"] | ||
| 4067 | pub const fn eie(&self) -> bool { | ||
| 4068 | let val = (self.0 >> 0usize) & 0x01; | ||
| 4069 | val != 0 | ||
| 4070 | } | ||
| 4071 | #[doc = "Error interrupt enable"] | ||
| 4072 | pub fn set_eie(&mut self, val: bool) { | ||
| 4073 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); | ||
| 4074 | } | ||
| 4075 | #[doc = "IrDA mode enable"] | ||
| 4076 | pub const fn iren(&self) -> bool { | ||
| 4077 | let val = (self.0 >> 1usize) & 0x01; | ||
| 4078 | val != 0 | ||
| 4079 | } | ||
| 4080 | #[doc = "IrDA mode enable"] | ||
| 4081 | pub fn set_iren(&mut self, val: bool) { | ||
| 4082 | self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize); | ||
| 4083 | } | ||
| 4084 | #[doc = "IrDA low-power"] | ||
| 4085 | pub const fn irlp(&self) -> super::vals::Irlp { | ||
| 4086 | let val = (self.0 >> 2usize) & 0x01; | ||
| 4087 | super::vals::Irlp(val as u8) | ||
| 4088 | } | ||
| 4089 | #[doc = "IrDA low-power"] | ||
| 4090 | pub fn set_irlp(&mut self, val: super::vals::Irlp) { | ||
| 4091 | self.0 = (self.0 & !(0x01 << 2usize)) | (((val.0 as u32) & 0x01) << 2usize); | ||
| 4092 | } | ||
| 4093 | #[doc = "Half-duplex selection"] | ||
| 4094 | pub const fn hdsel(&self) -> super::vals::Hdsel { | ||
| 4095 | let val = (self.0 >> 3usize) & 0x01; | ||
| 4096 | super::vals::Hdsel(val as u8) | ||
| 4097 | } | ||
| 4098 | #[doc = "Half-duplex selection"] | ||
| 4099 | pub fn set_hdsel(&mut self, val: super::vals::Hdsel) { | ||
| 4100 | self.0 = (self.0 & !(0x01 << 3usize)) | (((val.0 as u32) & 0x01) << 3usize); | ||
| 4101 | } | ||
| 4102 | #[doc = "Smartcard NACK enable"] | ||
| 4103 | pub const fn nack(&self) -> bool { | ||
| 4104 | let val = (self.0 >> 4usize) & 0x01; | ||
| 4105 | val != 0 | ||
| 4106 | } | ||
| 4107 | #[doc = "Smartcard NACK enable"] | ||
| 4108 | pub fn set_nack(&mut self, val: bool) { | ||
| 4109 | self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize); | ||
| 4110 | } | ||
| 4111 | #[doc = "Smartcard mode enable"] | ||
| 4112 | pub const fn scen(&self) -> bool { | ||
| 4113 | let val = (self.0 >> 5usize) & 0x01; | ||
| 4114 | val != 0 | ||
| 4115 | } | ||
| 4116 | #[doc = "Smartcard mode enable"] | ||
| 4117 | pub fn set_scen(&mut self, val: bool) { | ||
| 4118 | self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize); | ||
| 4119 | } | ||
| 4120 | #[doc = "DMA enable receiver"] | ||
| 4121 | pub const fn dmar(&self) -> bool { | ||
| 4122 | let val = (self.0 >> 6usize) & 0x01; | ||
| 4123 | val != 0 | ||
| 4124 | } | ||
| 4125 | #[doc = "DMA enable receiver"] | ||
| 4126 | pub fn set_dmar(&mut self, val: bool) { | ||
| 4127 | self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize); | ||
| 4128 | } | ||
| 4129 | #[doc = "DMA enable transmitter"] | ||
| 4130 | pub const fn dmat(&self) -> bool { | ||
| 4131 | let val = (self.0 >> 7usize) & 0x01; | ||
| 4132 | val != 0 | ||
| 4133 | } | ||
| 4134 | #[doc = "DMA enable transmitter"] | ||
| 4135 | pub fn set_dmat(&mut self, val: bool) { | ||
| 4136 | self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize); | ||
| 4137 | } | ||
| 4138 | #[doc = "RTS enable"] | ||
| 4139 | pub const fn rtse(&self) -> bool { | ||
| 4140 | let val = (self.0 >> 8usize) & 0x01; | ||
| 4141 | val != 0 | ||
| 4142 | } | ||
| 4143 | #[doc = "RTS enable"] | ||
| 4144 | pub fn set_rtse(&mut self, val: bool) { | ||
| 4145 | self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize); | ||
| 4146 | } | ||
| 4147 | #[doc = "CTS enable"] | ||
| 4148 | pub const fn ctse(&self) -> bool { | ||
| 4149 | let val = (self.0 >> 9usize) & 0x01; | ||
| 4150 | val != 0 | ||
| 4151 | } | ||
| 4152 | #[doc = "CTS enable"] | ||
| 4153 | pub fn set_ctse(&mut self, val: bool) { | ||
| 4154 | self.0 = (self.0 & !(0x01 << 9usize)) | (((val as u32) & 0x01) << 9usize); | ||
| 4155 | } | ||
| 4156 | #[doc = "CTS interrupt enable"] | ||
| 4157 | pub const fn ctsie(&self) -> bool { | ||
| 4158 | let val = (self.0 >> 10usize) & 0x01; | ||
| 4159 | val != 0 | ||
| 4160 | } | ||
| 4161 | #[doc = "CTS interrupt enable"] | ||
| 4162 | pub fn set_ctsie(&mut self, val: bool) { | ||
| 4163 | self.0 = (self.0 & !(0x01 << 10usize)) | (((val as u32) & 0x01) << 10usize); | ||
| 4164 | } | ||
| 4165 | } | ||
| 4166 | impl Default for Cr3Usart { | ||
| 4167 | fn default() -> Cr3Usart { | ||
| 4168 | Cr3Usart(0) | ||
| 4169 | } | ||
| 4170 | } | ||
| 4171 | #[doc = "Control register 2"] | ||
| 4172 | #[repr(transparent)] | ||
| 4173 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 4174 | pub struct Cr2(pub u32); | ||
| 4175 | impl Cr2 { | ||
| 4176 | #[doc = "Address of the USART node"] | ||
| 4177 | pub const fn add(&self) -> u8 { | ||
| 4178 | let val = (self.0 >> 0usize) & 0x0f; | ||
| 4179 | val as u8 | ||
| 4180 | } | ||
| 4181 | #[doc = "Address of the USART node"] | ||
| 4182 | pub fn set_add(&mut self, val: u8) { | ||
| 4183 | self.0 = (self.0 & !(0x0f << 0usize)) | (((val as u32) & 0x0f) << 0usize); | ||
| 4184 | } | ||
| 4185 | #[doc = "lin break detection length"] | ||
| 4186 | pub const fn lbdl(&self) -> super::vals::Lbdl { | ||
| 4187 | let val = (self.0 >> 5usize) & 0x01; | ||
| 4188 | super::vals::Lbdl(val as u8) | ||
| 4189 | } | ||
| 4190 | #[doc = "lin break detection length"] | ||
| 4191 | pub fn set_lbdl(&mut self, val: super::vals::Lbdl) { | ||
| 4192 | self.0 = (self.0 & !(0x01 << 5usize)) | (((val.0 as u32) & 0x01) << 5usize); | ||
| 4193 | } | ||
| 4194 | #[doc = "LIN break detection interrupt enable"] | ||
| 4195 | pub const fn lbdie(&self) -> bool { | ||
| 4196 | let val = (self.0 >> 6usize) & 0x01; | ||
| 4197 | val != 0 | ||
| 4198 | } | ||
| 4199 | #[doc = "LIN break detection interrupt enable"] | ||
| 4200 | pub fn set_lbdie(&mut self, val: bool) { | ||
| 4201 | self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize); | ||
| 4202 | } | ||
| 4203 | #[doc = "STOP bits"] | ||
| 4204 | pub const fn stop(&self) -> super::vals::Stop { | ||
| 4205 | let val = (self.0 >> 12usize) & 0x03; | ||
| 4206 | super::vals::Stop(val as u8) | ||
| 4207 | } | ||
| 4208 | #[doc = "STOP bits"] | ||
| 4209 | pub fn set_stop(&mut self, val: super::vals::Stop) { | ||
| 4210 | self.0 = (self.0 & !(0x03 << 12usize)) | (((val.0 as u32) & 0x03) << 12usize); | ||
| 4211 | } | ||
| 4212 | #[doc = "LIN mode enable"] | ||
| 4213 | pub const fn linen(&self) -> bool { | ||
| 4214 | let val = (self.0 >> 14usize) & 0x01; | ||
| 4215 | val != 0 | ||
| 4216 | } | ||
| 4217 | #[doc = "LIN mode enable"] | ||
| 4218 | pub fn set_linen(&mut self, val: bool) { | ||
| 4219 | self.0 = (self.0 & !(0x01 << 14usize)) | (((val as u32) & 0x01) << 14usize); | ||
| 4220 | } | ||
| 4221 | } | ||
| 4222 | impl Default for Cr2 { | ||
| 4223 | fn default() -> Cr2 { | ||
| 4224 | Cr2(0) | ||
| 4225 | } | ||
| 4226 | } | ||
| 4227 | #[doc = "Status register"] | ||
| 4228 | #[repr(transparent)] | ||
| 4229 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 4230 | pub struct Sr(pub u32); | ||
| 4231 | impl Sr { | ||
| 4232 | #[doc = "Parity error"] | ||
| 4233 | pub const fn pe(&self) -> bool { | ||
| 4234 | let val = (self.0 >> 0usize) & 0x01; | ||
| 4235 | val != 0 | ||
| 4236 | } | ||
| 4237 | #[doc = "Parity error"] | ||
| 4238 | pub fn set_pe(&mut self, val: bool) { | ||
| 4239 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); | ||
| 4240 | } | ||
| 4241 | #[doc = "Framing error"] | ||
| 4242 | pub const fn fe(&self) -> bool { | ||
| 4243 | let val = (self.0 >> 1usize) & 0x01; | ||
| 4244 | val != 0 | ||
| 4245 | } | ||
| 4246 | #[doc = "Framing error"] | ||
| 4247 | pub fn set_fe(&mut self, val: bool) { | ||
| 4248 | self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize); | ||
| 4249 | } | ||
| 4250 | #[doc = "Noise error flag"] | ||
| 4251 | pub const fn ne(&self) -> bool { | ||
| 4252 | let val = (self.0 >> 2usize) & 0x01; | ||
| 4253 | val != 0 | ||
| 4254 | } | ||
| 4255 | #[doc = "Noise error flag"] | ||
| 4256 | pub fn set_ne(&mut self, val: bool) { | ||
| 4257 | self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize); | ||
| 4258 | } | ||
| 4259 | #[doc = "Overrun error"] | ||
| 4260 | pub const fn ore(&self) -> bool { | ||
| 4261 | let val = (self.0 >> 3usize) & 0x01; | ||
| 4262 | val != 0 | ||
| 4263 | } | ||
| 4264 | #[doc = "Overrun error"] | ||
| 4265 | pub fn set_ore(&mut self, val: bool) { | ||
| 4266 | self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize); | ||
| 4267 | } | ||
| 4268 | #[doc = "IDLE line detected"] | ||
| 4269 | pub const fn idle(&self) -> bool { | ||
| 4270 | let val = (self.0 >> 4usize) & 0x01; | ||
| 4271 | val != 0 | ||
| 4272 | } | ||
| 4273 | #[doc = "IDLE line detected"] | ||
| 4274 | pub fn set_idle(&mut self, val: bool) { | ||
| 4275 | self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize); | ||
| 4276 | } | ||
| 4277 | #[doc = "Read data register not empty"] | ||
| 4278 | pub const fn rxne(&self) -> bool { | ||
| 4279 | let val = (self.0 >> 5usize) & 0x01; | ||
| 4280 | val != 0 | ||
| 4281 | } | ||
| 4282 | #[doc = "Read data register not empty"] | ||
| 4283 | pub fn set_rxne(&mut self, val: bool) { | ||
| 4284 | self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize); | ||
| 4285 | } | ||
| 4286 | #[doc = "Transmission complete"] | ||
| 4287 | pub const fn tc(&self) -> bool { | ||
| 4288 | let val = (self.0 >> 6usize) & 0x01; | ||
| 4289 | val != 0 | ||
| 4290 | } | ||
| 4291 | #[doc = "Transmission complete"] | ||
| 4292 | pub fn set_tc(&mut self, val: bool) { | ||
| 4293 | self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize); | ||
| 4294 | } | ||
| 4295 | #[doc = "Transmit data register empty"] | ||
| 4296 | pub const fn txe(&self) -> bool { | ||
| 4297 | let val = (self.0 >> 7usize) & 0x01; | ||
| 4298 | val != 0 | ||
| 4299 | } | ||
| 4300 | #[doc = "Transmit data register empty"] | ||
| 4301 | pub fn set_txe(&mut self, val: bool) { | ||
| 4302 | self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize); | ||
| 4303 | } | ||
| 4304 | #[doc = "LIN break detection flag"] | ||
| 4305 | pub const fn lbd(&self) -> bool { | ||
| 4306 | let val = (self.0 >> 8usize) & 0x01; | ||
| 4307 | val != 0 | ||
| 4308 | } | ||
| 4309 | #[doc = "LIN break detection flag"] | ||
| 4310 | pub fn set_lbd(&mut self, val: bool) { | ||
| 4311 | self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize); | ||
| 4312 | } | ||
| 4313 | } | ||
| 4314 | impl Default for Sr { | ||
| 4315 | fn default() -> Sr { | ||
| 4316 | Sr(0) | ||
| 4317 | } | ||
| 4318 | } | ||
| 4319 | } | ||
| 4320 | pub mod vals { | 4592 | pub mod vals { |
| 4321 | use crate::generic::*; | 4593 | use crate::generic::*; |
| 4322 | #[repr(transparent)] | 4594 | #[repr(transparent)] |
| 4323 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 4595 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 4324 | pub struct Stop(pub u8); | 4596 | pub struct Inc(pub u8); |
| 4325 | impl Stop { | 4597 | impl Inc { |
| 4326 | #[doc = "1 stop bit"] | 4598 | #[doc = "Address pointer is fixed"] |
| 4327 | pub const STOP1: Self = Self(0); | 4599 | pub const FIXED: Self = Self(0); |
| 4328 | #[doc = "0.5 stop bits"] | 4600 | #[doc = "Address pointer is incremented after each data transfer"] |
| 4329 | pub const STOP0P5: Self = Self(0x01); | 4601 | pub const INCREMENTED: Self = Self(0x01); |
| 4330 | #[doc = "2 stop bits"] | ||
| 4331 | pub const STOP2: Self = Self(0x02); | ||
| 4332 | #[doc = "1.5 stop bits"] | ||
| 4333 | pub const STOP1P5: Self = Self(0x03); | ||
| 4334 | } | ||
| 4335 | #[repr(transparent)] | ||
| 4336 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 4337 | pub struct Irlp(pub u8); | ||
| 4338 | impl Irlp { | ||
| 4339 | #[doc = "Normal mode"] | ||
| 4340 | pub const NORMAL: Self = Self(0); | ||
| 4341 | #[doc = "Low-power mode"] | ||
| 4342 | pub const LOWPOWER: Self = Self(0x01); | ||
| 4343 | } | ||
| 4344 | #[repr(transparent)] | ||
| 4345 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 4346 | pub struct Hdsel(pub u8); | ||
| 4347 | impl Hdsel { | ||
| 4348 | #[doc = "Half duplex mode is not selected"] | ||
| 4349 | pub const FULLDUPLEX: Self = Self(0); | ||
| 4350 | #[doc = "Half duplex mode is selected"] | ||
| 4351 | pub const HALFDUPLEX: Self = Self(0x01); | ||
| 4352 | } | 4602 | } |
| 4353 | #[repr(transparent)] | 4603 | #[repr(transparent)] |
| 4354 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 4604 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 4355 | pub struct Lbdl(pub u8); | 4605 | pub struct Dbm(pub u8); |
| 4356 | impl Lbdl { | 4606 | impl Dbm { |
| 4357 | #[doc = "10-bit break detection"] | 4607 | #[doc = "No buffer switching at the end of transfer"] |
| 4358 | pub const LBDL10: Self = Self(0); | 4608 | pub const DISABLED: Self = Self(0); |
| 4359 | #[doc = "11-bit break detection"] | 4609 | #[doc = "Memory target switched at the end of the DMA transfer"] |
| 4360 | pub const LBDL11: Self = Self(0x01); | 4610 | pub const ENABLED: Self = Self(0x01); |
| 4361 | } | 4611 | } |
| 4362 | #[repr(transparent)] | 4612 | #[repr(transparent)] |
| 4363 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 4613 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 4364 | pub struct M(pub u8); | 4614 | pub struct Pfctrl(pub u8); |
| 4365 | impl M { | 4615 | impl Pfctrl { |
| 4366 | #[doc = "8 data bits"] | 4616 | #[doc = "The DMA is the flow controller"] |
| 4367 | pub const M8: Self = Self(0); | 4617 | pub const DMA: Self = Self(0); |
| 4368 | #[doc = "9 data bits"] | 4618 | #[doc = "The peripheral is the flow controller"] |
| 4369 | pub const M9: Self = Self(0x01); | 4619 | pub const PERIPHERAL: Self = Self(0x01); |
| 4370 | } | 4620 | } |
| 4371 | #[repr(transparent)] | 4621 | #[repr(transparent)] |
| 4372 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 4622 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 4373 | pub struct Cpha(pub u8); | 4623 | pub struct Pl(pub u8); |
| 4374 | impl Cpha { | 4624 | impl Pl { |
| 4375 | #[doc = "The first clock transition is the first data capture edge"] | 4625 | #[doc = "Low"] |
| 4376 | pub const FIRST: Self = Self(0); | 4626 | pub const LOW: Self = Self(0); |
| 4377 | #[doc = "The second clock transition is the first data capture edge"] | 4627 | #[doc = "Medium"] |
| 4378 | pub const SECOND: Self = Self(0x01); | 4628 | pub const MEDIUM: Self = Self(0x01); |
| 4629 | #[doc = "High"] | ||
| 4630 | pub const HIGH: Self = Self(0x02); | ||
| 4631 | #[doc = "Very high"] | ||
| 4632 | pub const VERYHIGH: Self = Self(0x03); | ||
| 4379 | } | 4633 | } |
| 4380 | #[repr(transparent)] | 4634 | #[repr(transparent)] |
| 4381 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 4635 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 4382 | pub struct Rwu(pub u8); | 4636 | pub struct Fth(pub u8); |
| 4383 | impl Rwu { | 4637 | impl Fth { |
| 4384 | #[doc = "Receiver in active mode"] | 4638 | #[doc = "1/4 full FIFO"] |
| 4385 | pub const ACTIVE: Self = Self(0); | 4639 | pub const QUARTER: Self = Self(0); |
| 4386 | #[doc = "Receiver in mute mode"] | 4640 | #[doc = "1/2 full FIFO"] |
| 4387 | pub const MUTE: Self = Self(0x01); | 4641 | pub const HALF: Self = Self(0x01); |
| 4642 | #[doc = "3/4 full FIFO"] | ||
| 4643 | pub const THREEQUARTERS: Self = Self(0x02); | ||
| 4644 | #[doc = "Full FIFO"] | ||
| 4645 | pub const FULL: Self = Self(0x03); | ||
| 4388 | } | 4646 | } |
| 4389 | #[repr(transparent)] | 4647 | #[repr(transparent)] |
| 4390 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 4648 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 4391 | pub struct Cpol(pub u8); | 4649 | pub struct Burst(pub u8); |
| 4392 | impl Cpol { | 4650 | impl Burst { |
| 4393 | #[doc = "Steady low value on CK pin outside transmission window"] | 4651 | #[doc = "Single transfer"] |
| 4394 | pub const LOW: Self = Self(0); | 4652 | pub const SINGLE: Self = Self(0); |
| 4395 | #[doc = "Steady high value on CK pin outside transmission window"] | 4653 | #[doc = "Incremental burst of 4 beats"] |
| 4396 | pub const HIGH: Self = Self(0x01); | 4654 | pub const INCR4: Self = Self(0x01); |
| 4655 | #[doc = "Incremental burst of 8 beats"] | ||
| 4656 | pub const INCR8: Self = Self(0x02); | ||
| 4657 | #[doc = "Incremental burst of 16 beats"] | ||
| 4658 | pub const INCR16: Self = Self(0x03); | ||
| 4397 | } | 4659 | } |
| 4398 | #[repr(transparent)] | 4660 | #[repr(transparent)] |
| 4399 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 4661 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 4400 | pub struct Wake(pub u8); | 4662 | pub struct Dmdis(pub u8); |
| 4401 | impl Wake { | 4663 | impl Dmdis { |
| 4402 | #[doc = "USART wakeup on idle line"] | 4664 | #[doc = "Direct mode is enabled"] |
| 4403 | pub const IDLELINE: Self = Self(0); | 4665 | pub const ENABLED: Self = Self(0); |
| 4404 | #[doc = "USART wakeup on address mark"] | 4666 | #[doc = "Direct mode is disabled"] |
| 4405 | pub const ADDRESSMARK: Self = Self(0x01); | 4667 | pub const DISABLED: Self = Self(0x01); |
| 4406 | } | 4668 | } |
| 4407 | #[repr(transparent)] | 4669 | #[repr(transparent)] |
| 4408 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 4670 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 4409 | pub struct Sbk(pub u8); | 4671 | pub struct Dir(pub u8); |
| 4410 | impl Sbk { | 4672 | impl Dir { |
| 4411 | #[doc = "No break character is transmitted"] | 4673 | #[doc = "Peripheral-to-memory"] |
| 4412 | pub const NOBREAK: Self = Self(0); | 4674 | pub const PERIPHERALTOMEMORY: Self = Self(0); |
| 4413 | #[doc = "Break character transmitted"] | 4675 | #[doc = "Memory-to-peripheral"] |
| 4414 | pub const BREAK: Self = Self(0x01); | 4676 | pub const MEMORYTOPERIPHERAL: Self = Self(0x01); |
| 4677 | #[doc = "Memory-to-memory"] | ||
| 4678 | pub const MEMORYTOMEMORY: Self = Self(0x02); | ||
| 4415 | } | 4679 | } |
| 4416 | #[repr(transparent)] | 4680 | #[repr(transparent)] |
| 4417 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 4681 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 4418 | pub struct Ps(pub u8); | 4682 | pub struct Pincos(pub u8); |
| 4419 | impl Ps { | 4683 | impl Pincos { |
| 4420 | #[doc = "Even parity"] | 4684 | #[doc = "The offset size for the peripheral address calculation is linked to the PSIZE"] |
| 4421 | pub const EVEN: Self = Self(0); | 4685 | pub const PSIZE: Self = Self(0); |
| 4422 | #[doc = "Odd parity"] | 4686 | #[doc = "The offset size for the peripheral address calculation is fixed to 4 (32-bit alignment)"] |
| 4423 | pub const ODD: Self = Self(0x01); | 4687 | pub const FIXED4: Self = Self(0x01); |
| 4424 | } | ||
| 4425 | } | ||
| 4426 | } | ||
| 4427 | pub mod dma_v1 { | ||
| 4428 | use crate::generic::*; | ||
| 4429 | #[doc = "Channel cluster: CCR?, CNDTR?, CPAR?, and CMAR? registers"] | ||
| 4430 | #[derive(Copy, Clone)] | ||
| 4431 | pub struct Ch(pub *mut u8); | ||
| 4432 | unsafe impl Send for Ch {} | ||
| 4433 | unsafe impl Sync for Ch {} | ||
| 4434 | impl Ch { | ||
| 4435 | #[doc = "DMA channel configuration register (DMA_CCR)"] | ||
| 4436 | pub fn cr(self) -> Reg<regs::Cr, RW> { | ||
| 4437 | unsafe { Reg::from_ptr(self.0.add(0usize)) } | ||
| 4438 | } | ||
| 4439 | #[doc = "DMA channel 1 number of data register"] | ||
| 4440 | pub fn ndtr(self) -> Reg<regs::Ndtr, RW> { | ||
| 4441 | unsafe { Reg::from_ptr(self.0.add(4usize)) } | ||
| 4442 | } | ||
| 4443 | #[doc = "DMA channel 1 peripheral address register"] | ||
| 4444 | pub fn par(self) -> Reg<u32, RW> { | ||
| 4445 | unsafe { Reg::from_ptr(self.0.add(8usize)) } | ||
| 4446 | } | ||
| 4447 | #[doc = "DMA channel 1 memory address register"] | ||
| 4448 | pub fn mar(self) -> Reg<u32, RW> { | ||
| 4449 | unsafe { Reg::from_ptr(self.0.add(12usize)) } | ||
| 4450 | } | ||
| 4451 | } | ||
| 4452 | #[doc = "DMA controller"] | ||
| 4453 | #[derive(Copy, Clone)] | ||
| 4454 | pub struct Dma(pub *mut u8); | ||
| 4455 | unsafe impl Send for Dma {} | ||
| 4456 | unsafe impl Sync for Dma {} | ||
| 4457 | impl Dma { | ||
| 4458 | #[doc = "DMA interrupt status register (DMA_ISR)"] | ||
| 4459 | pub fn isr(self) -> Reg<regs::Isr, R> { | ||
| 4460 | unsafe { Reg::from_ptr(self.0.add(0usize)) } | ||
| 4461 | } | ||
| 4462 | #[doc = "DMA interrupt flag clear register (DMA_IFCR)"] | ||
| 4463 | pub fn ifcr(self) -> Reg<regs::Ifcr, W> { | ||
| 4464 | unsafe { Reg::from_ptr(self.0.add(4usize)) } | ||
| 4465 | } | ||
| 4466 | #[doc = "Channel cluster: CCR?, CNDTR?, CPAR?, and CMAR? registers"] | ||
| 4467 | pub fn ch(self, n: usize) -> Ch { | ||
| 4468 | assert!(n < 7usize); | ||
| 4469 | unsafe { Ch(self.0.add(8usize + n * 20usize)) } | ||
| 4470 | } | 4688 | } |
| 4471 | } | ||
| 4472 | pub mod vals { | ||
| 4473 | use crate::generic::*; | ||
| 4474 | #[repr(transparent)] | 4689 | #[repr(transparent)] |
| 4475 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 4690 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 4476 | pub struct Memmem(pub u8); | 4691 | pub struct Size(pub u8); |
| 4477 | impl Memmem { | 4692 | impl Size { |
| 4478 | #[doc = "Memory to memory mode disabled"] | 4693 | #[doc = "Byte (8-bit)"] |
| 4479 | pub const DISABLED: Self = Self(0); | 4694 | pub const BITS8: Self = Self(0); |
| 4480 | #[doc = "Memory to memory mode enabled"] | 4695 | #[doc = "Half-word (16-bit)"] |
| 4481 | pub const ENABLED: Self = Self(0x01); | 4696 | pub const BITS16: Self = Self(0x01); |
| 4697 | #[doc = "Word (32-bit)"] | ||
| 4698 | pub const BITS32: Self = Self(0x02); | ||
| 4482 | } | 4699 | } |
| 4483 | #[repr(transparent)] | 4700 | #[repr(transparent)] |
| 4484 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 4701 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 4485 | pub struct Inc(pub u8); | 4702 | pub struct Ct(pub u8); |
| 4486 | impl Inc { | 4703 | impl Ct { |
| 4487 | #[doc = "Increment mode disabled"] | 4704 | #[doc = "The current target memory is Memory 0"] |
| 4488 | pub const DISABLED: Self = Self(0); | 4705 | pub const MEMORY0: Self = Self(0); |
| 4489 | #[doc = "Increment mode enabled"] | 4706 | #[doc = "The current target memory is Memory 1"] |
| 4490 | pub const ENABLED: Self = Self(0x01); | 4707 | pub const MEMORY1: Self = Self(0x01); |
| 4491 | } | 4708 | } |
| 4492 | #[repr(transparent)] | 4709 | #[repr(transparent)] |
| 4493 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 4710 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 4494 | pub struct Dir(pub u8); | 4711 | pub struct Fs(pub u8); |
| 4495 | impl Dir { | 4712 | impl Fs { |
| 4496 | #[doc = "Read from peripheral"] | 4713 | #[doc = "0 < fifo_level < 1/4"] |
| 4497 | pub const FROMPERIPHERAL: Self = Self(0); | 4714 | pub const QUARTER1: Self = Self(0); |
| 4498 | #[doc = "Read from memory"] | 4715 | #[doc = "1/4 <= fifo_level < 1/2"] |
| 4499 | pub const FROMMEMORY: Self = Self(0x01); | 4716 | pub const QUARTER2: Self = Self(0x01); |
| 4717 | #[doc = "1/2 <= fifo_level < 3/4"] | ||
| 4718 | pub const QUARTER3: Self = Self(0x02); | ||
| 4719 | #[doc = "3/4 <= fifo_level < full"] | ||
| 4720 | pub const QUARTER4: Self = Self(0x03); | ||
| 4721 | #[doc = "FIFO is empty"] | ||
| 4722 | pub const EMPTY: Self = Self(0x04); | ||
| 4723 | #[doc = "FIFO is full"] | ||
| 4724 | pub const FULL: Self = Self(0x05); | ||
| 4500 | } | 4725 | } |
| 4501 | #[repr(transparent)] | 4726 | #[repr(transparent)] |
| 4502 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 4727 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 4503 | pub struct Circ(pub u8); | 4728 | pub struct Circ(pub u8); |
| 4504 | impl Circ { | 4729 | impl Circ { |
| 4505 | #[doc = "Circular buffer disabled"] | 4730 | #[doc = "Circular mode disabled"] |
| 4506 | pub const DISABLED: Self = Self(0); | 4731 | pub const DISABLED: Self = Self(0); |
| 4507 | #[doc = "Circular buffer enabled"] | 4732 | #[doc = "Circular mode enabled"] |
| 4508 | pub const ENABLED: Self = Self(0x01); | 4733 | pub const ENABLED: Self = Self(0x01); |
| 4509 | } | 4734 | } |
| 4510 | #[repr(transparent)] | ||
| 4511 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 4512 | pub struct Size(pub u8); | ||
| 4513 | impl Size { | ||
| 4514 | #[doc = "8-bit size"] | ||
| 4515 | pub const BITS8: Self = Self(0); | ||
| 4516 | #[doc = "16-bit size"] | ||
| 4517 | pub const BITS16: Self = Self(0x01); | ||
| 4518 | #[doc = "32-bit size"] | ||
| 4519 | pub const BITS32: Self = Self(0x02); | ||
| 4520 | } | ||
| 4521 | #[repr(transparent)] | ||
| 4522 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 4523 | pub struct Pl(pub u8); | ||
| 4524 | impl Pl { | ||
| 4525 | #[doc = "Low priority"] | ||
| 4526 | pub const LOW: Self = Self(0); | ||
| 4527 | #[doc = "Medium priority"] | ||
| 4528 | pub const MEDIUM: Self = Self(0x01); | ||
| 4529 | #[doc = "High priority"] | ||
| 4530 | pub const HIGH: Self = Self(0x02); | ||
| 4531 | #[doc = "Very high priority"] | ||
| 4532 | pub const VERYHIGH: Self = Self(0x03); | ||
| 4533 | } | ||
| 4534 | } | 4735 | } |
| 4535 | pub mod regs { | 4736 | pub mod regs { |
| 4536 | use crate::generic::*; | 4737 | use crate::generic::*; |
| 4537 | #[doc = "DMA channel configuration register (DMA_CCR)"] | 4738 | #[doc = "stream x number of data register"] |
| 4739 | #[repr(transparent)] | ||
| 4740 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 4741 | pub struct Ndtr(pub u32); | ||
| 4742 | impl Ndtr { | ||
| 4743 | #[doc = "Number of data items to transfer"] | ||
| 4744 | pub const fn ndt(&self) -> u16 { | ||
| 4745 | let val = (self.0 >> 0usize) & 0xffff; | ||
| 4746 | val as u16 | ||
| 4747 | } | ||
| 4748 | #[doc = "Number of data items to transfer"] | ||
| 4749 | pub fn set_ndt(&mut self, val: u16) { | ||
| 4750 | self.0 = (self.0 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 0usize); | ||
| 4751 | } | ||
| 4752 | } | ||
| 4753 | impl Default for Ndtr { | ||
| 4754 | fn default() -> Ndtr { | ||
| 4755 | Ndtr(0) | ||
| 4756 | } | ||
| 4757 | } | ||
| 4758 | #[doc = "stream x configuration register"] | ||
| 4538 | #[repr(transparent)] | 4759 | #[repr(transparent)] |
| 4539 | #[derive(Copy, Clone, Eq, PartialEq)] | 4760 | #[derive(Copy, Clone, Eq, PartialEq)] |
| 4540 | pub struct Cr(pub u32); | 4761 | pub struct Cr(pub u32); |
| 4541 | impl Cr { | 4762 | impl Cr { |
| 4542 | #[doc = "Channel enable"] | 4763 | #[doc = "Stream enable / flag stream ready when read low"] |
| 4543 | pub const fn en(&self) -> bool { | 4764 | pub const fn en(&self) -> bool { |
| 4544 | let val = (self.0 >> 0usize) & 0x01; | 4765 | let val = (self.0 >> 0usize) & 0x01; |
| 4545 | val != 0 | 4766 | val != 0 |
| 4546 | } | 4767 | } |
| 4547 | #[doc = "Channel enable"] | 4768 | #[doc = "Stream enable / flag stream ready when read low"] |
| 4548 | pub fn set_en(&mut self, val: bool) { | 4769 | pub fn set_en(&mut self, val: bool) { |
| 4549 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); | 4770 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); |
| 4550 | } | 4771 | } |
| 4551 | #[doc = "Transfer complete interrupt enable"] | 4772 | #[doc = "Direct mode error interrupt enable"] |
| 4552 | pub const fn tcie(&self) -> bool { | 4773 | pub const fn dmeie(&self) -> bool { |
| 4553 | let val = (self.0 >> 1usize) & 0x01; | 4774 | let val = (self.0 >> 1usize) & 0x01; |
| 4554 | val != 0 | 4775 | val != 0 |
| 4555 | } | 4776 | } |
| 4556 | #[doc = "Transfer complete interrupt enable"] | 4777 | #[doc = "Direct mode error interrupt enable"] |
| 4557 | pub fn set_tcie(&mut self, val: bool) { | 4778 | pub fn set_dmeie(&mut self, val: bool) { |
| 4558 | self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize); | 4779 | self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize); |
| 4559 | } | 4780 | } |
| 4560 | #[doc = "Half Transfer interrupt enable"] | 4781 | #[doc = "Transfer error interrupt enable"] |
| 4561 | pub const fn htie(&self) -> bool { | 4782 | pub const fn teie(&self) -> bool { |
| 4562 | let val = (self.0 >> 2usize) & 0x01; | 4783 | let val = (self.0 >> 2usize) & 0x01; |
| 4563 | val != 0 | 4784 | val != 0 |
| 4564 | } | 4785 | } |
| 4565 | #[doc = "Half Transfer interrupt enable"] | 4786 | #[doc = "Transfer error interrupt enable"] |
| 4566 | pub fn set_htie(&mut self, val: bool) { | 4787 | pub fn set_teie(&mut self, val: bool) { |
| 4567 | self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize); | 4788 | self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize); |
| 4568 | } | 4789 | } |
| 4569 | #[doc = "Transfer error interrupt enable"] | 4790 | #[doc = "Half transfer interrupt enable"] |
| 4570 | pub const fn teie(&self) -> bool { | 4791 | pub const fn htie(&self) -> bool { |
| 4571 | let val = (self.0 >> 3usize) & 0x01; | 4792 | let val = (self.0 >> 3usize) & 0x01; |
| 4572 | val != 0 | 4793 | val != 0 |
| 4573 | } | 4794 | } |
| 4574 | #[doc = "Transfer error interrupt enable"] | 4795 | #[doc = "Half transfer interrupt enable"] |
| 4575 | pub fn set_teie(&mut self, val: bool) { | 4796 | pub fn set_htie(&mut self, val: bool) { |
| 4576 | self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize); | 4797 | self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize); |
| 4577 | } | 4798 | } |
| 4799 | #[doc = "Transfer complete interrupt enable"] | ||
| 4800 | pub const fn tcie(&self) -> bool { | ||
| 4801 | let val = (self.0 >> 4usize) & 0x01; | ||
| 4802 | val != 0 | ||
| 4803 | } | ||
| 4804 | #[doc = "Transfer complete interrupt enable"] | ||
| 4805 | pub fn set_tcie(&mut self, val: bool) { | ||
| 4806 | self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize); | ||
| 4807 | } | ||
| 4808 | #[doc = "Peripheral flow controller"] | ||
| 4809 | pub const fn pfctrl(&self) -> super::vals::Pfctrl { | ||
| 4810 | let val = (self.0 >> 5usize) & 0x01; | ||
| 4811 | super::vals::Pfctrl(val as u8) | ||
| 4812 | } | ||
| 4813 | #[doc = "Peripheral flow controller"] | ||
| 4814 | pub fn set_pfctrl(&mut self, val: super::vals::Pfctrl) { | ||
| 4815 | self.0 = (self.0 & !(0x01 << 5usize)) | (((val.0 as u32) & 0x01) << 5usize); | ||
| 4816 | } | ||
| 4578 | #[doc = "Data transfer direction"] | 4817 | #[doc = "Data transfer direction"] |
| 4579 | pub const fn dir(&self) -> super::vals::Dir { | 4818 | pub const fn dir(&self) -> super::vals::Dir { |
| 4580 | let val = (self.0 >> 4usize) & 0x01; | 4819 | let val = (self.0 >> 6usize) & 0x03; |
| 4581 | super::vals::Dir(val as u8) | 4820 | super::vals::Dir(val as u8) |
| 4582 | } | 4821 | } |
| 4583 | #[doc = "Data transfer direction"] | 4822 | #[doc = "Data transfer direction"] |
| 4584 | pub fn set_dir(&mut self, val: super::vals::Dir) { | 4823 | pub fn set_dir(&mut self, val: super::vals::Dir) { |
| 4585 | self.0 = (self.0 & !(0x01 << 4usize)) | (((val.0 as u32) & 0x01) << 4usize); | 4824 | self.0 = (self.0 & !(0x03 << 6usize)) | (((val.0 as u32) & 0x03) << 6usize); |
| 4586 | } | 4825 | } |
| 4587 | #[doc = "Circular mode"] | 4826 | #[doc = "Circular mode"] |
| 4588 | pub const fn circ(&self) -> super::vals::Circ { | 4827 | pub const fn circ(&self) -> super::vals::Circ { |
| 4589 | let val = (self.0 >> 5usize) & 0x01; | 4828 | let val = (self.0 >> 8usize) & 0x01; |
| 4590 | super::vals::Circ(val as u8) | 4829 | super::vals::Circ(val as u8) |
| 4591 | } | 4830 | } |
| 4592 | #[doc = "Circular mode"] | 4831 | #[doc = "Circular mode"] |
| 4593 | pub fn set_circ(&mut self, val: super::vals::Circ) { | 4832 | pub fn set_circ(&mut self, val: super::vals::Circ) { |
| 4594 | self.0 = (self.0 & !(0x01 << 5usize)) | (((val.0 as u32) & 0x01) << 5usize); | 4833 | self.0 = (self.0 & !(0x01 << 8usize)) | (((val.0 as u32) & 0x01) << 8usize); |
| 4595 | } | 4834 | } |
| 4596 | #[doc = "Peripheral increment mode"] | 4835 | #[doc = "Peripheral increment mode"] |
| 4597 | pub const fn pinc(&self) -> super::vals::Inc { | 4836 | pub const fn pinc(&self) -> super::vals::Inc { |
| 4598 | let val = (self.0 >> 6usize) & 0x01; | 4837 | let val = (self.0 >> 9usize) & 0x01; |
| 4599 | super::vals::Inc(val as u8) | 4838 | super::vals::Inc(val as u8) |
| 4600 | } | 4839 | } |
| 4601 | #[doc = "Peripheral increment mode"] | 4840 | #[doc = "Peripheral increment mode"] |
| 4602 | pub fn set_pinc(&mut self, val: super::vals::Inc) { | 4841 | pub fn set_pinc(&mut self, val: super::vals::Inc) { |
| 4603 | self.0 = (self.0 & !(0x01 << 6usize)) | (((val.0 as u32) & 0x01) << 6usize); | 4842 | self.0 = (self.0 & !(0x01 << 9usize)) | (((val.0 as u32) & 0x01) << 9usize); |
| 4604 | } | 4843 | } |
| 4605 | #[doc = "Memory increment mode"] | 4844 | #[doc = "Memory increment mode"] |
| 4606 | pub const fn minc(&self) -> super::vals::Inc { | 4845 | pub const fn minc(&self) -> super::vals::Inc { |
| 4607 | let val = (self.0 >> 7usize) & 0x01; | 4846 | let val = (self.0 >> 10usize) & 0x01; |
| 4608 | super::vals::Inc(val as u8) | 4847 | super::vals::Inc(val as u8) |
| 4609 | } | 4848 | } |
| 4610 | #[doc = "Memory increment mode"] | 4849 | #[doc = "Memory increment mode"] |
| 4611 | pub fn set_minc(&mut self, val: super::vals::Inc) { | 4850 | pub fn set_minc(&mut self, val: super::vals::Inc) { |
| 4612 | self.0 = (self.0 & !(0x01 << 7usize)) | (((val.0 as u32) & 0x01) << 7usize); | 4851 | self.0 = (self.0 & !(0x01 << 10usize)) | (((val.0 as u32) & 0x01) << 10usize); |
| 4613 | } | 4852 | } |
| 4614 | #[doc = "Peripheral size"] | 4853 | #[doc = "Peripheral data size"] |
| 4615 | pub const fn psize(&self) -> super::vals::Size { | 4854 | pub const fn psize(&self) -> super::vals::Size { |
| 4616 | let val = (self.0 >> 8usize) & 0x03; | 4855 | let val = (self.0 >> 11usize) & 0x03; |
| 4617 | super::vals::Size(val as u8) | 4856 | super::vals::Size(val as u8) |
| 4618 | } | 4857 | } |
| 4619 | #[doc = "Peripheral size"] | 4858 | #[doc = "Peripheral data size"] |
| 4620 | pub fn set_psize(&mut self, val: super::vals::Size) { | 4859 | pub fn set_psize(&mut self, val: super::vals::Size) { |
| 4621 | self.0 = (self.0 & !(0x03 << 8usize)) | (((val.0 as u32) & 0x03) << 8usize); | 4860 | self.0 = (self.0 & !(0x03 << 11usize)) | (((val.0 as u32) & 0x03) << 11usize); |
| 4622 | } | 4861 | } |
| 4623 | #[doc = "Memory size"] | 4862 | #[doc = "Memory data size"] |
| 4624 | pub const fn msize(&self) -> super::vals::Size { | 4863 | pub const fn msize(&self) -> super::vals::Size { |
| 4625 | let val = (self.0 >> 10usize) & 0x03; | 4864 | let val = (self.0 >> 13usize) & 0x03; |
| 4626 | super::vals::Size(val as u8) | 4865 | super::vals::Size(val as u8) |
| 4627 | } | 4866 | } |
| 4628 | #[doc = "Memory size"] | 4867 | #[doc = "Memory data size"] |
| 4629 | pub fn set_msize(&mut self, val: super::vals::Size) { | 4868 | pub fn set_msize(&mut self, val: super::vals::Size) { |
| 4630 | self.0 = (self.0 & !(0x03 << 10usize)) | (((val.0 as u32) & 0x03) << 10usize); | 4869 | self.0 = (self.0 & !(0x03 << 13usize)) | (((val.0 as u32) & 0x03) << 13usize); |
| 4631 | } | 4870 | } |
| 4632 | #[doc = "Channel Priority level"] | 4871 | #[doc = "Peripheral increment offset size"] |
| 4872 | pub const fn pincos(&self) -> super::vals::Pincos { | ||
| 4873 | let val = (self.0 >> 15usize) & 0x01; | ||
| 4874 | super::vals::Pincos(val as u8) | ||
| 4875 | } | ||
| 4876 | #[doc = "Peripheral increment offset size"] | ||
| 4877 | pub fn set_pincos(&mut self, val: super::vals::Pincos) { | ||
| 4878 | self.0 = (self.0 & !(0x01 << 15usize)) | (((val.0 as u32) & 0x01) << 15usize); | ||
| 4879 | } | ||
| 4880 | #[doc = "Priority level"] | ||
| 4633 | pub const fn pl(&self) -> super::vals::Pl { | 4881 | pub const fn pl(&self) -> super::vals::Pl { |
| 4634 | let val = (self.0 >> 12usize) & 0x03; | 4882 | let val = (self.0 >> 16usize) & 0x03; |
| 4635 | super::vals::Pl(val as u8) | 4883 | super::vals::Pl(val as u8) |
| 4636 | } | 4884 | } |
| 4637 | #[doc = "Channel Priority level"] | 4885 | #[doc = "Priority level"] |
| 4638 | pub fn set_pl(&mut self, val: super::vals::Pl) { | 4886 | pub fn set_pl(&mut self, val: super::vals::Pl) { |
| 4639 | self.0 = (self.0 & !(0x03 << 12usize)) | (((val.0 as u32) & 0x03) << 12usize); | 4887 | self.0 = (self.0 & !(0x03 << 16usize)) | (((val.0 as u32) & 0x03) << 16usize); |
| 4640 | } | ||
| 4641 | #[doc = "Memory to memory mode"] | ||
| 4642 | pub const fn mem2mem(&self) -> super::vals::Memmem { | ||
| 4643 | let val = (self.0 >> 14usize) & 0x01; | ||
| 4644 | super::vals::Memmem(val as u8) | ||
| 4645 | } | ||
| 4646 | #[doc = "Memory to memory mode"] | ||
| 4647 | pub fn set_mem2mem(&mut self, val: super::vals::Memmem) { | ||
| 4648 | self.0 = (self.0 & !(0x01 << 14usize)) | (((val.0 as u32) & 0x01) << 14usize); | ||
| 4649 | } | ||
| 4650 | } | ||
| 4651 | impl Default for Cr { | ||
| 4652 | fn default() -> Cr { | ||
| 4653 | Cr(0) | ||
| 4654 | } | ||
| 4655 | } | ||
| 4656 | #[doc = "DMA interrupt flag clear register (DMA_IFCR)"] | ||
| 4657 | #[repr(transparent)] | ||
| 4658 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 4659 | pub struct Ifcr(pub u32); | ||
| 4660 | impl Ifcr { | ||
| 4661 | #[doc = "Channel 1 Global interrupt clear"] | ||
| 4662 | pub fn cgif(&self, n: usize) -> bool { | ||
| 4663 | assert!(n < 7usize); | ||
| 4664 | let offs = 0usize + n * 4usize; | ||
| 4665 | let val = (self.0 >> offs) & 0x01; | ||
| 4666 | val != 0 | ||
| 4667 | } | ||
| 4668 | #[doc = "Channel 1 Global interrupt clear"] | ||
| 4669 | pub fn set_cgif(&mut self, n: usize, val: bool) { | ||
| 4670 | assert!(n < 7usize); | ||
| 4671 | let offs = 0usize + n * 4usize; | ||
| 4672 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | ||
| 4673 | } | ||
| 4674 | #[doc = "Channel 1 Transfer Complete clear"] | ||
| 4675 | pub fn ctcif(&self, n: usize) -> bool { | ||
| 4676 | assert!(n < 7usize); | ||
| 4677 | let offs = 1usize + n * 4usize; | ||
| 4678 | let val = (self.0 >> offs) & 0x01; | ||
| 4679 | val != 0 | ||
| 4680 | } | ||
| 4681 | #[doc = "Channel 1 Transfer Complete clear"] | ||
| 4682 | pub fn set_ctcif(&mut self, n: usize, val: bool) { | ||
| 4683 | assert!(n < 7usize); | ||
| 4684 | let offs = 1usize + n * 4usize; | ||
| 4685 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | ||
| 4686 | } | ||
| 4687 | #[doc = "Channel 1 Half Transfer clear"] | ||
| 4688 | pub fn chtif(&self, n: usize) -> bool { | ||
| 4689 | assert!(n < 7usize); | ||
| 4690 | let offs = 2usize + n * 4usize; | ||
| 4691 | let val = (self.0 >> offs) & 0x01; | ||
| 4692 | val != 0 | ||
| 4693 | } | ||
| 4694 | #[doc = "Channel 1 Half Transfer clear"] | ||
| 4695 | pub fn set_chtif(&mut self, n: usize, val: bool) { | ||
| 4696 | assert!(n < 7usize); | ||
| 4697 | let offs = 2usize + n * 4usize; | ||
| 4698 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | ||
| 4699 | } | ||
| 4700 | #[doc = "Channel 1 Transfer Error clear"] | ||
| 4701 | pub fn cteif(&self, n: usize) -> bool { | ||
| 4702 | assert!(n < 7usize); | ||
| 4703 | let offs = 3usize + n * 4usize; | ||
| 4704 | let val = (self.0 >> offs) & 0x01; | ||
| 4705 | val != 0 | ||
| 4706 | } | ||
| 4707 | #[doc = "Channel 1 Transfer Error clear"] | ||
| 4708 | pub fn set_cteif(&mut self, n: usize, val: bool) { | ||
| 4709 | assert!(n < 7usize); | ||
| 4710 | let offs = 3usize + n * 4usize; | ||
| 4711 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | ||
| 4712 | } | ||
| 4713 | } | ||
| 4714 | impl Default for Ifcr { | ||
| 4715 | fn default() -> Ifcr { | ||
| 4716 | Ifcr(0) | ||
| 4717 | } | ||
| 4718 | } | ||
| 4719 | #[doc = "DMA channel 1 number of data register"] | ||
| 4720 | #[repr(transparent)] | ||
| 4721 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 4722 | pub struct Ndtr(pub u32); | ||
| 4723 | impl Ndtr { | ||
| 4724 | #[doc = "Number of data to transfer"] | ||
| 4725 | pub const fn ndt(&self) -> u16 { | ||
| 4726 | let val = (self.0 >> 0usize) & 0xffff; | ||
| 4727 | val as u16 | ||
| 4728 | } | ||
| 4729 | #[doc = "Number of data to transfer"] | ||
| 4730 | pub fn set_ndt(&mut self, val: u16) { | ||
| 4731 | self.0 = (self.0 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 0usize); | ||
| 4732 | } | ||
| 4733 | } | ||
| 4734 | impl Default for Ndtr { | ||
| 4735 | fn default() -> Ndtr { | ||
| 4736 | Ndtr(0) | ||
| 4737 | } | ||
| 4738 | } | ||
| 4739 | #[doc = "DMA interrupt status register (DMA_ISR)"] | ||
| 4740 | #[repr(transparent)] | ||
| 4741 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 4742 | pub struct Isr(pub u32); | ||
| 4743 | impl Isr { | ||
| 4744 | #[doc = "Channel 1 Global interrupt flag"] | ||
| 4745 | pub fn gif(&self, n: usize) -> bool { | ||
| 4746 | assert!(n < 7usize); | ||
| 4747 | let offs = 0usize + n * 4usize; | ||
| 4748 | let val = (self.0 >> offs) & 0x01; | ||
| 4749 | val != 0 | ||
| 4750 | } | ||
| 4751 | #[doc = "Channel 1 Global interrupt flag"] | ||
| 4752 | pub fn set_gif(&mut self, n: usize, val: bool) { | ||
| 4753 | assert!(n < 7usize); | ||
| 4754 | let offs = 0usize + n * 4usize; | ||
| 4755 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | ||
| 4756 | } | ||
| 4757 | #[doc = "Channel 1 Transfer Complete flag"] | ||
| 4758 | pub fn tcif(&self, n: usize) -> bool { | ||
| 4759 | assert!(n < 7usize); | ||
| 4760 | let offs = 1usize + n * 4usize; | ||
| 4761 | let val = (self.0 >> offs) & 0x01; | ||
| 4762 | val != 0 | ||
| 4763 | } | ||
| 4764 | #[doc = "Channel 1 Transfer Complete flag"] | ||
| 4765 | pub fn set_tcif(&mut self, n: usize, val: bool) { | ||
| 4766 | assert!(n < 7usize); | ||
| 4767 | let offs = 1usize + n * 4usize; | ||
| 4768 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | ||
| 4769 | } | ||
| 4770 | #[doc = "Channel 1 Half Transfer Complete flag"] | ||
| 4771 | pub fn htif(&self, n: usize) -> bool { | ||
| 4772 | assert!(n < 7usize); | ||
| 4773 | let offs = 2usize + n * 4usize; | ||
| 4774 | let val = (self.0 >> offs) & 0x01; | ||
| 4775 | val != 0 | ||
| 4776 | } | ||
| 4777 | #[doc = "Channel 1 Half Transfer Complete flag"] | ||
| 4778 | pub fn set_htif(&mut self, n: usize, val: bool) { | ||
| 4779 | assert!(n < 7usize); | ||
| 4780 | let offs = 2usize + n * 4usize; | ||
| 4781 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | ||
| 4782 | } | ||
| 4783 | #[doc = "Channel 1 Transfer Error flag"] | ||
| 4784 | pub fn teif(&self, n: usize) -> bool { | ||
| 4785 | assert!(n < 7usize); | ||
| 4786 | let offs = 3usize + n * 4usize; | ||
| 4787 | let val = (self.0 >> offs) & 0x01; | ||
| 4788 | val != 0 | ||
| 4789 | } | ||
| 4790 | #[doc = "Channel 1 Transfer Error flag"] | ||
| 4791 | pub fn set_teif(&mut self, n: usize, val: bool) { | ||
| 4792 | assert!(n < 7usize); | ||
| 4793 | let offs = 3usize + n * 4usize; | ||
| 4794 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | ||
| 4795 | } | ||
| 4796 | } | ||
| 4797 | impl Default for Isr { | ||
| 4798 | fn default() -> Isr { | ||
| 4799 | Isr(0) | ||
| 4800 | } | ||
| 4801 | } | ||
| 4802 | } | ||
| 4803 | } | ||
| 4804 | pub mod rng_v1 { | ||
| 4805 | use crate::generic::*; | ||
| 4806 | #[doc = "Random number generator"] | ||
| 4807 | #[derive(Copy, Clone)] | ||
| 4808 | pub struct Rng(pub *mut u8); | ||
| 4809 | unsafe impl Send for Rng {} | ||
| 4810 | unsafe impl Sync for Rng {} | ||
| 4811 | impl Rng { | ||
| 4812 | #[doc = "control register"] | ||
| 4813 | pub fn cr(self) -> Reg<regs::Cr, RW> { | ||
| 4814 | unsafe { Reg::from_ptr(self.0.add(0usize)) } | ||
| 4815 | } | ||
| 4816 | #[doc = "status register"] | ||
| 4817 | pub fn sr(self) -> Reg<regs::Sr, RW> { | ||
| 4818 | unsafe { Reg::from_ptr(self.0.add(4usize)) } | ||
| 4819 | } | ||
| 4820 | #[doc = "data register"] | ||
| 4821 | pub fn dr(self) -> Reg<u32, R> { | ||
| 4822 | unsafe { Reg::from_ptr(self.0.add(8usize)) } | ||
| 4823 | } | ||
| 4824 | } | ||
| 4825 | pub mod regs { | ||
| 4826 | use crate::generic::*; | ||
| 4827 | #[doc = "status register"] | ||
| 4828 | #[repr(transparent)] | ||
| 4829 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 4830 | pub struct Sr(pub u32); | ||
| 4831 | impl Sr { | ||
| 4832 | #[doc = "Data ready"] | ||
| 4833 | pub const fn drdy(&self) -> bool { | ||
| 4834 | let val = (self.0 >> 0usize) & 0x01; | ||
| 4835 | val != 0 | ||
| 4836 | } | ||
| 4837 | #[doc = "Data ready"] | ||
| 4838 | pub fn set_drdy(&mut self, val: bool) { | ||
| 4839 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); | ||
| 4840 | } | ||
| 4841 | #[doc = "Clock error current status"] | ||
| 4842 | pub const fn cecs(&self) -> bool { | ||
| 4843 | let val = (self.0 >> 1usize) & 0x01; | ||
| 4844 | val != 0 | ||
| 4845 | } | ||
| 4846 | #[doc = "Clock error current status"] | ||
| 4847 | pub fn set_cecs(&mut self, val: bool) { | ||
| 4848 | self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize); | ||
| 4849 | } | ||
| 4850 | #[doc = "Seed error current status"] | ||
| 4851 | pub const fn secs(&self) -> bool { | ||
| 4852 | let val = (self.0 >> 2usize) & 0x01; | ||
| 4853 | val != 0 | ||
| 4854 | } | 4888 | } |
| 4855 | #[doc = "Seed error current status"] | 4889 | #[doc = "Double buffer mode"] |
| 4856 | pub fn set_secs(&mut self, val: bool) { | 4890 | pub const fn dbm(&self) -> super::vals::Dbm { |
| 4857 | self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize); | 4891 | let val = (self.0 >> 18usize) & 0x01; |
| 4892 | super::vals::Dbm(val as u8) | ||
| 4858 | } | 4893 | } |
| 4859 | #[doc = "Clock error interrupt status"] | 4894 | #[doc = "Double buffer mode"] |
| 4860 | pub const fn ceis(&self) -> bool { | 4895 | pub fn set_dbm(&mut self, val: super::vals::Dbm) { |
| 4861 | let val = (self.0 >> 5usize) & 0x01; | 4896 | self.0 = (self.0 & !(0x01 << 18usize)) | (((val.0 as u32) & 0x01) << 18usize); |
| 4862 | val != 0 | ||
| 4863 | } | 4897 | } |
| 4864 | #[doc = "Clock error interrupt status"] | 4898 | #[doc = "Current target (only in double buffer mode)"] |
| 4865 | pub fn set_ceis(&mut self, val: bool) { | 4899 | pub const fn ct(&self) -> super::vals::Ct { |
| 4866 | self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize); | 4900 | let val = (self.0 >> 19usize) & 0x01; |
| 4901 | super::vals::Ct(val as u8) | ||
| 4867 | } | 4902 | } |
| 4868 | #[doc = "Seed error interrupt status"] | 4903 | #[doc = "Current target (only in double buffer mode)"] |
| 4869 | pub const fn seis(&self) -> bool { | 4904 | pub fn set_ct(&mut self, val: super::vals::Ct) { |
| 4870 | let val = (self.0 >> 6usize) & 0x01; | 4905 | self.0 = (self.0 & !(0x01 << 19usize)) | (((val.0 as u32) & 0x01) << 19usize); |
| 4871 | val != 0 | ||
| 4872 | } | 4906 | } |
| 4873 | #[doc = "Seed error interrupt status"] | 4907 | #[doc = "Peripheral burst transfer configuration"] |
| 4874 | pub fn set_seis(&mut self, val: bool) { | 4908 | pub const fn pburst(&self) -> super::vals::Burst { |
| 4875 | self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize); | 4909 | let val = (self.0 >> 21usize) & 0x03; |
| 4910 | super::vals::Burst(val as u8) | ||
| 4876 | } | 4911 | } |
| 4877 | } | 4912 | #[doc = "Peripheral burst transfer configuration"] |
| 4878 | impl Default for Sr { | 4913 | pub fn set_pburst(&mut self, val: super::vals::Burst) { |
| 4879 | fn default() -> Sr { | 4914 | self.0 = (self.0 & !(0x03 << 21usize)) | (((val.0 as u32) & 0x03) << 21usize); |
| 4880 | Sr(0) | ||
| 4881 | } | 4915 | } |
| 4882 | } | 4916 | #[doc = "Memory burst transfer configuration"] |
| 4883 | #[doc = "control register"] | 4917 | pub const fn mburst(&self) -> super::vals::Burst { |
| 4884 | #[repr(transparent)] | 4918 | let val = (self.0 >> 23usize) & 0x03; |
| 4885 | #[derive(Copy, Clone, Eq, PartialEq)] | 4919 | super::vals::Burst(val as u8) |
| 4886 | pub struct Cr(pub u32); | ||
| 4887 | impl Cr { | ||
| 4888 | #[doc = "Random number generator enable"] | ||
| 4889 | pub const fn rngen(&self) -> bool { | ||
| 4890 | let val = (self.0 >> 2usize) & 0x01; | ||
| 4891 | val != 0 | ||
| 4892 | } | 4920 | } |
| 4893 | #[doc = "Random number generator enable"] | 4921 | #[doc = "Memory burst transfer configuration"] |
| 4894 | pub fn set_rngen(&mut self, val: bool) { | 4922 | pub fn set_mburst(&mut self, val: super::vals::Burst) { |
| 4895 | self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize); | 4923 | self.0 = (self.0 & !(0x03 << 23usize)) | (((val.0 as u32) & 0x03) << 23usize); |
| 4896 | } | 4924 | } |
| 4897 | #[doc = "Interrupt enable"] | 4925 | #[doc = "Channel selection"] |
| 4898 | pub const fn ie(&self) -> bool { | 4926 | pub const fn chsel(&self) -> u8 { |
| 4899 | let val = (self.0 >> 3usize) & 0x01; | 4927 | let val = (self.0 >> 25usize) & 0x0f; |
| 4900 | val != 0 | 4928 | val as u8 |
| 4901 | } | 4929 | } |
| 4902 | #[doc = "Interrupt enable"] | 4930 | #[doc = "Channel selection"] |
| 4903 | pub fn set_ie(&mut self, val: bool) { | 4931 | pub fn set_chsel(&mut self, val: u8) { |
| 4904 | self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize); | 4932 | self.0 = (self.0 & !(0x0f << 25usize)) | (((val as u32) & 0x0f) << 25usize); |
| 4905 | } | 4933 | } |
| 4906 | } | 4934 | } |
| 4907 | impl Default for Cr { | 4935 | impl Default for Cr { |
| @@ -4909,65 +4937,6 @@ pub mod rng_v1 { | |||
| 4909 | Cr(0) | 4937 | Cr(0) |
| 4910 | } | 4938 | } |
| 4911 | } | 4939 | } |
| 4912 | } | ||
| 4913 | } | ||
| 4914 | pub mod dma_v2 { | ||
| 4915 | use crate::generic::*; | ||
| 4916 | #[doc = "Stream cluster: S?CR, S?NDTR, S?M0AR, S?M1AR and S?FCR registers"] | ||
| 4917 | #[derive(Copy, Clone)] | ||
| 4918 | pub struct St(pub *mut u8); | ||
| 4919 | unsafe impl Send for St {} | ||
| 4920 | unsafe impl Sync for St {} | ||
| 4921 | impl St { | ||
| 4922 | #[doc = "stream x configuration register"] | ||
| 4923 | pub fn cr(self) -> Reg<regs::Cr, RW> { | ||
| 4924 | unsafe { Reg::from_ptr(self.0.add(0usize)) } | ||
| 4925 | } | ||
| 4926 | #[doc = "stream x number of data register"] | ||
| 4927 | pub fn ndtr(self) -> Reg<regs::Ndtr, RW> { | ||
| 4928 | unsafe { Reg::from_ptr(self.0.add(4usize)) } | ||
| 4929 | } | ||
| 4930 | #[doc = "stream x peripheral address register"] | ||
| 4931 | pub fn par(self) -> Reg<u32, RW> { | ||
| 4932 | unsafe { Reg::from_ptr(self.0.add(8usize)) } | ||
| 4933 | } | ||
| 4934 | #[doc = "stream x memory 0 address register"] | ||
| 4935 | pub fn m0ar(self) -> Reg<u32, RW> { | ||
| 4936 | unsafe { Reg::from_ptr(self.0.add(12usize)) } | ||
| 4937 | } | ||
| 4938 | #[doc = "stream x memory 1 address register"] | ||
| 4939 | pub fn m1ar(self) -> Reg<u32, RW> { | ||
| 4940 | unsafe { Reg::from_ptr(self.0.add(16usize)) } | ||
| 4941 | } | ||
| 4942 | #[doc = "stream x FIFO control register"] | ||
| 4943 | pub fn fcr(self) -> Reg<regs::Fcr, RW> { | ||
| 4944 | unsafe { Reg::from_ptr(self.0.add(20usize)) } | ||
| 4945 | } | ||
| 4946 | } | ||
| 4947 | #[doc = "DMA controller"] | ||
| 4948 | #[derive(Copy, Clone)] | ||
| 4949 | pub struct Dma(pub *mut u8); | ||
| 4950 | unsafe impl Send for Dma {} | ||
| 4951 | unsafe impl Sync for Dma {} | ||
| 4952 | impl Dma { | ||
| 4953 | #[doc = "low interrupt status register"] | ||
| 4954 | pub fn isr(self, n: usize) -> Reg<regs::Isr, R> { | ||
| 4955 | assert!(n < 2usize); | ||
| 4956 | unsafe { Reg::from_ptr(self.0.add(0usize + n * 4usize)) } | ||
| 4957 | } | ||
| 4958 | #[doc = "low interrupt flag clear register"] | ||
| 4959 | pub fn ifcr(self, n: usize) -> Reg<regs::Ifcr, W> { | ||
| 4960 | assert!(n < 2usize); | ||
| 4961 | unsafe { Reg::from_ptr(self.0.add(8usize + n * 4usize)) } | ||
| 4962 | } | ||
| 4963 | #[doc = "Stream cluster: S?CR, S?NDTR, S?M0AR, S?M1AR and S?FCR registers"] | ||
| 4964 | pub fn st(self, n: usize) -> St { | ||
| 4965 | assert!(n < 8usize); | ||
| 4966 | unsafe { St(self.0.add(16usize + n * 24usize)) } | ||
| 4967 | } | ||
| 4968 | } | ||
| 4969 | pub mod regs { | ||
| 4970 | use crate::generic::*; | ||
| 4971 | #[doc = "stream x FIFO control register"] | 4940 | #[doc = "stream x FIFO control register"] |
| 4972 | #[repr(transparent)] | 4941 | #[repr(transparent)] |
| 4973 | #[derive(Copy, Clone, Eq, PartialEq)] | 4942 | #[derive(Copy, Clone, Eq, PartialEq)] |
| @@ -5015,6 +4984,82 @@ pub mod dma_v2 { | |||
| 5015 | Fcr(0) | 4984 | Fcr(0) |
| 5016 | } | 4985 | } |
| 5017 | } | 4986 | } |
| 4987 | #[doc = "low interrupt flag clear register"] | ||
| 4988 | #[repr(transparent)] | ||
| 4989 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 4990 | pub struct Ifcr(pub u32); | ||
| 4991 | impl Ifcr { | ||
| 4992 | #[doc = "Stream x clear FIFO error interrupt flag (x = 3..0)"] | ||
| 4993 | pub fn cfeif(&self, n: usize) -> bool { | ||
| 4994 | assert!(n < 4usize); | ||
| 4995 | let offs = 0usize + ([0usize, 6usize, 16usize, 22usize][n] as usize); | ||
| 4996 | let val = (self.0 >> offs) & 0x01; | ||
| 4997 | val != 0 | ||
| 4998 | } | ||
| 4999 | #[doc = "Stream x clear FIFO error interrupt flag (x = 3..0)"] | ||
| 5000 | pub fn set_cfeif(&mut self, n: usize, val: bool) { | ||
| 5001 | assert!(n < 4usize); | ||
| 5002 | let offs = 0usize + ([0usize, 6usize, 16usize, 22usize][n] as usize); | ||
| 5003 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | ||
| 5004 | } | ||
| 5005 | #[doc = "Stream x clear direct mode error interrupt flag (x = 3..0)"] | ||
| 5006 | pub fn cdmeif(&self, n: usize) -> bool { | ||
| 5007 | assert!(n < 4usize); | ||
| 5008 | let offs = 2usize + ([0usize, 6usize, 16usize, 22usize][n] as usize); | ||
| 5009 | let val = (self.0 >> offs) & 0x01; | ||
| 5010 | val != 0 | ||
| 5011 | } | ||
| 5012 | #[doc = "Stream x clear direct mode error interrupt flag (x = 3..0)"] | ||
| 5013 | pub fn set_cdmeif(&mut self, n: usize, val: bool) { | ||
| 5014 | assert!(n < 4usize); | ||
| 5015 | let offs = 2usize + ([0usize, 6usize, 16usize, 22usize][n] as usize); | ||
| 5016 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | ||
| 5017 | } | ||
| 5018 | #[doc = "Stream x clear transfer error interrupt flag (x = 3..0)"] | ||
| 5019 | pub fn cteif(&self, n: usize) -> bool { | ||
| 5020 | assert!(n < 4usize); | ||
| 5021 | let offs = 3usize + ([0usize, 6usize, 16usize, 22usize][n] as usize); | ||
| 5022 | let val = (self.0 >> offs) & 0x01; | ||
| 5023 | val != 0 | ||
| 5024 | } | ||
| 5025 | #[doc = "Stream x clear transfer error interrupt flag (x = 3..0)"] | ||
| 5026 | pub fn set_cteif(&mut self, n: usize, val: bool) { | ||
| 5027 | assert!(n < 4usize); | ||
| 5028 | let offs = 3usize + ([0usize, 6usize, 16usize, 22usize][n] as usize); | ||
| 5029 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | ||
| 5030 | } | ||
| 5031 | #[doc = "Stream x clear half transfer interrupt flag (x = 3..0)"] | ||
| 5032 | pub fn chtif(&self, n: usize) -> bool { | ||
| 5033 | assert!(n < 4usize); | ||
| 5034 | let offs = 4usize + ([0usize, 6usize, 16usize, 22usize][n] as usize); | ||
| 5035 | let val = (self.0 >> offs) & 0x01; | ||
| 5036 | val != 0 | ||
| 5037 | } | ||
| 5038 | #[doc = "Stream x clear half transfer interrupt flag (x = 3..0)"] | ||
| 5039 | pub fn set_chtif(&mut self, n: usize, val: bool) { | ||
| 5040 | assert!(n < 4usize); | ||
| 5041 | let offs = 4usize + ([0usize, 6usize, 16usize, 22usize][n] as usize); | ||
| 5042 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | ||
| 5043 | } | ||
| 5044 | #[doc = "Stream x clear transfer complete interrupt flag (x = 3..0)"] | ||
| 5045 | pub fn ctcif(&self, n: usize) -> bool { | ||
| 5046 | assert!(n < 4usize); | ||
| 5047 | let offs = 5usize + ([0usize, 6usize, 16usize, 22usize][n] as usize); | ||
| 5048 | let val = (self.0 >> offs) & 0x01; | ||
| 5049 | val != 0 | ||
| 5050 | } | ||
| 5051 | #[doc = "Stream x clear transfer complete interrupt flag (x = 3..0)"] | ||
| 5052 | pub fn set_ctcif(&mut self, n: usize, val: bool) { | ||
| 5053 | assert!(n < 4usize); | ||
| 5054 | let offs = 5usize + ([0usize, 6usize, 16usize, 22usize][n] as usize); | ||
| 5055 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | ||
| 5056 | } | ||
| 5057 | } | ||
| 5058 | impl Default for Ifcr { | ||
| 5059 | fn default() -> Ifcr { | ||
| 5060 | Ifcr(0) | ||
| 5061 | } | ||
| 5062 | } | ||
| 5018 | #[doc = "low interrupt status register"] | 5063 | #[doc = "low interrupt status register"] |
| 5019 | #[repr(transparent)] | 5064 | #[repr(transparent)] |
| 5020 | #[derive(Copy, Clone, Eq, PartialEq)] | 5065 | #[derive(Copy, Clone, Eq, PartialEq)] |
| @@ -5091,17 +5136,66 @@ pub mod dma_v2 { | |||
| 5091 | Isr(0) | 5136 | Isr(0) |
| 5092 | } | 5137 | } |
| 5093 | } | 5138 | } |
| 5094 | #[doc = "stream x number of data register"] | 5139 | } |
| 5140 | } | ||
| 5141 | pub mod dma_v1 { | ||
| 5142 | use crate::generic::*; | ||
| 5143 | #[doc = "DMA controller"] | ||
| 5144 | #[derive(Copy, Clone)] | ||
| 5145 | pub struct Dma(pub *mut u8); | ||
| 5146 | unsafe impl Send for Dma {} | ||
| 5147 | unsafe impl Sync for Dma {} | ||
| 5148 | impl Dma { | ||
| 5149 | #[doc = "DMA interrupt status register (DMA_ISR)"] | ||
| 5150 | pub fn isr(self) -> Reg<regs::Isr, R> { | ||
| 5151 | unsafe { Reg::from_ptr(self.0.add(0usize)) } | ||
| 5152 | } | ||
| 5153 | #[doc = "DMA interrupt flag clear register (DMA_IFCR)"] | ||
| 5154 | pub fn ifcr(self) -> Reg<regs::Ifcr, W> { | ||
| 5155 | unsafe { Reg::from_ptr(self.0.add(4usize)) } | ||
| 5156 | } | ||
| 5157 | #[doc = "Channel cluster: CCR?, CNDTR?, CPAR?, and CMAR? registers"] | ||
| 5158 | pub fn ch(self, n: usize) -> Ch { | ||
| 5159 | assert!(n < 7usize); | ||
| 5160 | unsafe { Ch(self.0.add(8usize + n * 20usize)) } | ||
| 5161 | } | ||
| 5162 | } | ||
| 5163 | #[doc = "Channel cluster: CCR?, CNDTR?, CPAR?, and CMAR? registers"] | ||
| 5164 | #[derive(Copy, Clone)] | ||
| 5165 | pub struct Ch(pub *mut u8); | ||
| 5166 | unsafe impl Send for Ch {} | ||
| 5167 | unsafe impl Sync for Ch {} | ||
| 5168 | impl Ch { | ||
| 5169 | #[doc = "DMA channel configuration register (DMA_CCR)"] | ||
| 5170 | pub fn cr(self) -> Reg<regs::Cr, RW> { | ||
| 5171 | unsafe { Reg::from_ptr(self.0.add(0usize)) } | ||
| 5172 | } | ||
| 5173 | #[doc = "DMA channel 1 number of data register"] | ||
| 5174 | pub fn ndtr(self) -> Reg<regs::Ndtr, RW> { | ||
| 5175 | unsafe { Reg::from_ptr(self.0.add(4usize)) } | ||
| 5176 | } | ||
| 5177 | #[doc = "DMA channel 1 peripheral address register"] | ||
| 5178 | pub fn par(self) -> Reg<u32, RW> { | ||
| 5179 | unsafe { Reg::from_ptr(self.0.add(8usize)) } | ||
| 5180 | } | ||
| 5181 | #[doc = "DMA channel 1 memory address register"] | ||
| 5182 | pub fn mar(self) -> Reg<u32, RW> { | ||
| 5183 | unsafe { Reg::from_ptr(self.0.add(12usize)) } | ||
| 5184 | } | ||
| 5185 | } | ||
| 5186 | pub mod regs { | ||
| 5187 | use crate::generic::*; | ||
| 5188 | #[doc = "DMA channel 1 number of data register"] | ||
| 5095 | #[repr(transparent)] | 5189 | #[repr(transparent)] |
| 5096 | #[derive(Copy, Clone, Eq, PartialEq)] | 5190 | #[derive(Copy, Clone, Eq, PartialEq)] |
| 5097 | pub struct Ndtr(pub u32); | 5191 | pub struct Ndtr(pub u32); |
| 5098 | impl Ndtr { | 5192 | impl Ndtr { |
| 5099 | #[doc = "Number of data items to transfer"] | 5193 | #[doc = "Number of data to transfer"] |
| 5100 | pub const fn ndt(&self) -> u16 { | 5194 | pub const fn ndt(&self) -> u16 { |
| 5101 | let val = (self.0 >> 0usize) & 0xffff; | 5195 | let val = (self.0 >> 0usize) & 0xffff; |
| 5102 | val as u16 | 5196 | val as u16 |
| 5103 | } | 5197 | } |
| 5104 | #[doc = "Number of data items to transfer"] | 5198 | #[doc = "Number of data to transfer"] |
| 5105 | pub fn set_ndt(&mut self, val: u16) { | 5199 | pub fn set_ndt(&mut self, val: u16) { |
| 5106 | self.0 = (self.0 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 0usize); | 5200 | self.0 = (self.0 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 0usize); |
| 5107 | } | 5201 | } |
| @@ -5111,256 +5205,243 @@ pub mod dma_v2 { | |||
| 5111 | Ndtr(0) | 5205 | Ndtr(0) |
| 5112 | } | 5206 | } |
| 5113 | } | 5207 | } |
| 5114 | #[doc = "stream x configuration register"] | 5208 | #[doc = "DMA channel configuration register (DMA_CCR)"] |
| 5115 | #[repr(transparent)] | 5209 | #[repr(transparent)] |
| 5116 | #[derive(Copy, Clone, Eq, PartialEq)] | 5210 | #[derive(Copy, Clone, Eq, PartialEq)] |
| 5117 | pub struct Cr(pub u32); | 5211 | pub struct Cr(pub u32); |
| 5118 | impl Cr { | 5212 | impl Cr { |
| 5119 | #[doc = "Stream enable / flag stream ready when read low"] | 5213 | #[doc = "Channel enable"] |
| 5120 | pub const fn en(&self) -> bool { | 5214 | pub const fn en(&self) -> bool { |
| 5121 | let val = (self.0 >> 0usize) & 0x01; | 5215 | let val = (self.0 >> 0usize) & 0x01; |
| 5122 | val != 0 | 5216 | val != 0 |
| 5123 | } | 5217 | } |
| 5124 | #[doc = "Stream enable / flag stream ready when read low"] | 5218 | #[doc = "Channel enable"] |
| 5125 | pub fn set_en(&mut self, val: bool) { | 5219 | pub fn set_en(&mut self, val: bool) { |
| 5126 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); | 5220 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); |
| 5127 | } | 5221 | } |
| 5128 | #[doc = "Direct mode error interrupt enable"] | 5222 | #[doc = "Transfer complete interrupt enable"] |
| 5129 | pub const fn dmeie(&self) -> bool { | 5223 | pub const fn tcie(&self) -> bool { |
| 5130 | let val = (self.0 >> 1usize) & 0x01; | 5224 | let val = (self.0 >> 1usize) & 0x01; |
| 5131 | val != 0 | 5225 | val != 0 |
| 5132 | } | 5226 | } |
| 5133 | #[doc = "Direct mode error interrupt enable"] | 5227 | #[doc = "Transfer complete interrupt enable"] |
| 5134 | pub fn set_dmeie(&mut self, val: bool) { | 5228 | pub fn set_tcie(&mut self, val: bool) { |
| 5135 | self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize); | 5229 | self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize); |
| 5136 | } | 5230 | } |
| 5137 | #[doc = "Transfer error interrupt enable"] | 5231 | #[doc = "Half Transfer interrupt enable"] |
| 5138 | pub const fn teie(&self) -> bool { | 5232 | pub const fn htie(&self) -> bool { |
| 5139 | let val = (self.0 >> 2usize) & 0x01; | 5233 | let val = (self.0 >> 2usize) & 0x01; |
| 5140 | val != 0 | 5234 | val != 0 |
| 5141 | } | 5235 | } |
| 5142 | #[doc = "Transfer error interrupt enable"] | 5236 | #[doc = "Half Transfer interrupt enable"] |
| 5143 | pub fn set_teie(&mut self, val: bool) { | 5237 | pub fn set_htie(&mut self, val: bool) { |
| 5144 | self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize); | 5238 | self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize); |
| 5145 | } | 5239 | } |
| 5146 | #[doc = "Half transfer interrupt enable"] | 5240 | #[doc = "Transfer error interrupt enable"] |
| 5147 | pub const fn htie(&self) -> bool { | 5241 | pub const fn teie(&self) -> bool { |
| 5148 | let val = (self.0 >> 3usize) & 0x01; | 5242 | let val = (self.0 >> 3usize) & 0x01; |
| 5149 | val != 0 | 5243 | val != 0 |
| 5150 | } | 5244 | } |
| 5151 | #[doc = "Half transfer interrupt enable"] | 5245 | #[doc = "Transfer error interrupt enable"] |
| 5152 | pub fn set_htie(&mut self, val: bool) { | 5246 | pub fn set_teie(&mut self, val: bool) { |
| 5153 | self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize); | 5247 | self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize); |
| 5154 | } | 5248 | } |
| 5155 | #[doc = "Transfer complete interrupt enable"] | ||
| 5156 | pub const fn tcie(&self) -> bool { | ||
| 5157 | let val = (self.0 >> 4usize) & 0x01; | ||
| 5158 | val != 0 | ||
| 5159 | } | ||
| 5160 | #[doc = "Transfer complete interrupt enable"] | ||
| 5161 | pub fn set_tcie(&mut self, val: bool) { | ||
| 5162 | self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize); | ||
| 5163 | } | ||
| 5164 | #[doc = "Peripheral flow controller"] | ||
| 5165 | pub const fn pfctrl(&self) -> super::vals::Pfctrl { | ||
| 5166 | let val = (self.0 >> 5usize) & 0x01; | ||
| 5167 | super::vals::Pfctrl(val as u8) | ||
| 5168 | } | ||
| 5169 | #[doc = "Peripheral flow controller"] | ||
| 5170 | pub fn set_pfctrl(&mut self, val: super::vals::Pfctrl) { | ||
| 5171 | self.0 = (self.0 & !(0x01 << 5usize)) | (((val.0 as u32) & 0x01) << 5usize); | ||
| 5172 | } | ||
| 5173 | #[doc = "Data transfer direction"] | 5249 | #[doc = "Data transfer direction"] |
| 5174 | pub const fn dir(&self) -> super::vals::Dir { | 5250 | pub const fn dir(&self) -> super::vals::Dir { |
| 5175 | let val = (self.0 >> 6usize) & 0x03; | 5251 | let val = (self.0 >> 4usize) & 0x01; |
| 5176 | super::vals::Dir(val as u8) | 5252 | super::vals::Dir(val as u8) |
| 5177 | } | 5253 | } |
| 5178 | #[doc = "Data transfer direction"] | 5254 | #[doc = "Data transfer direction"] |
| 5179 | pub fn set_dir(&mut self, val: super::vals::Dir) { | 5255 | pub fn set_dir(&mut self, val: super::vals::Dir) { |
| 5180 | self.0 = (self.0 & !(0x03 << 6usize)) | (((val.0 as u32) & 0x03) << 6usize); | 5256 | self.0 = (self.0 & !(0x01 << 4usize)) | (((val.0 as u32) & 0x01) << 4usize); |
| 5181 | } | 5257 | } |
| 5182 | #[doc = "Circular mode"] | 5258 | #[doc = "Circular mode"] |
| 5183 | pub const fn circ(&self) -> super::vals::Circ { | 5259 | pub const fn circ(&self) -> super::vals::Circ { |
| 5184 | let val = (self.0 >> 8usize) & 0x01; | 5260 | let val = (self.0 >> 5usize) & 0x01; |
| 5185 | super::vals::Circ(val as u8) | 5261 | super::vals::Circ(val as u8) |
| 5186 | } | 5262 | } |
| 5187 | #[doc = "Circular mode"] | 5263 | #[doc = "Circular mode"] |
| 5188 | pub fn set_circ(&mut self, val: super::vals::Circ) { | 5264 | pub fn set_circ(&mut self, val: super::vals::Circ) { |
| 5189 | self.0 = (self.0 & !(0x01 << 8usize)) | (((val.0 as u32) & 0x01) << 8usize); | 5265 | self.0 = (self.0 & !(0x01 << 5usize)) | (((val.0 as u32) & 0x01) << 5usize); |
| 5190 | } | 5266 | } |
| 5191 | #[doc = "Peripheral increment mode"] | 5267 | #[doc = "Peripheral increment mode"] |
| 5192 | pub const fn pinc(&self) -> super::vals::Inc { | 5268 | pub const fn pinc(&self) -> super::vals::Inc { |
| 5193 | let val = (self.0 >> 9usize) & 0x01; | 5269 | let val = (self.0 >> 6usize) & 0x01; |
| 5194 | super::vals::Inc(val as u8) | 5270 | super::vals::Inc(val as u8) |
| 5195 | } | 5271 | } |
| 5196 | #[doc = "Peripheral increment mode"] | 5272 | #[doc = "Peripheral increment mode"] |
| 5197 | pub fn set_pinc(&mut self, val: super::vals::Inc) { | 5273 | pub fn set_pinc(&mut self, val: super::vals::Inc) { |
| 5198 | self.0 = (self.0 & !(0x01 << 9usize)) | (((val.0 as u32) & 0x01) << 9usize); | 5274 | self.0 = (self.0 & !(0x01 << 6usize)) | (((val.0 as u32) & 0x01) << 6usize); |
| 5199 | } | 5275 | } |
| 5200 | #[doc = "Memory increment mode"] | 5276 | #[doc = "Memory increment mode"] |
| 5201 | pub const fn minc(&self) -> super::vals::Inc { | 5277 | pub const fn minc(&self) -> super::vals::Inc { |
| 5202 | let val = (self.0 >> 10usize) & 0x01; | 5278 | let val = (self.0 >> 7usize) & 0x01; |
| 5203 | super::vals::Inc(val as u8) | 5279 | super::vals::Inc(val as u8) |
| 5204 | } | 5280 | } |
| 5205 | #[doc = "Memory increment mode"] | 5281 | #[doc = "Memory increment mode"] |
| 5206 | pub fn set_minc(&mut self, val: super::vals::Inc) { | 5282 | pub fn set_minc(&mut self, val: super::vals::Inc) { |
| 5207 | self.0 = (self.0 & !(0x01 << 10usize)) | (((val.0 as u32) & 0x01) << 10usize); | 5283 | self.0 = (self.0 & !(0x01 << 7usize)) | (((val.0 as u32) & 0x01) << 7usize); |
| 5208 | } | 5284 | } |
| 5209 | #[doc = "Peripheral data size"] | 5285 | #[doc = "Peripheral size"] |
| 5210 | pub const fn psize(&self) -> super::vals::Size { | 5286 | pub const fn psize(&self) -> super::vals::Size { |
| 5211 | let val = (self.0 >> 11usize) & 0x03; | 5287 | let val = (self.0 >> 8usize) & 0x03; |
| 5212 | super::vals::Size(val as u8) | 5288 | super::vals::Size(val as u8) |
| 5213 | } | 5289 | } |
| 5214 | #[doc = "Peripheral data size"] | 5290 | #[doc = "Peripheral size"] |
| 5215 | pub fn set_psize(&mut self, val: super::vals::Size) { | 5291 | pub fn set_psize(&mut self, val: super::vals::Size) { |
| 5216 | self.0 = (self.0 & !(0x03 << 11usize)) | (((val.0 as u32) & 0x03) << 11usize); | 5292 | self.0 = (self.0 & !(0x03 << 8usize)) | (((val.0 as u32) & 0x03) << 8usize); |
| 5217 | } | 5293 | } |
| 5218 | #[doc = "Memory data size"] | 5294 | #[doc = "Memory size"] |
| 5219 | pub const fn msize(&self) -> super::vals::Size { | 5295 | pub const fn msize(&self) -> super::vals::Size { |
| 5220 | let val = (self.0 >> 13usize) & 0x03; | 5296 | let val = (self.0 >> 10usize) & 0x03; |
| 5221 | super::vals::Size(val as u8) | 5297 | super::vals::Size(val as u8) |
| 5222 | } | 5298 | } |
| 5223 | #[doc = "Memory data size"] | 5299 | #[doc = "Memory size"] |
| 5224 | pub fn set_msize(&mut self, val: super::vals::Size) { | 5300 | pub fn set_msize(&mut self, val: super::vals::Size) { |
| 5225 | self.0 = (self.0 & !(0x03 << 13usize)) | (((val.0 as u32) & 0x03) << 13usize); | 5301 | self.0 = (self.0 & !(0x03 << 10usize)) | (((val.0 as u32) & 0x03) << 10usize); |
| 5226 | } | ||
| 5227 | #[doc = "Peripheral increment offset size"] | ||
| 5228 | pub const fn pincos(&self) -> super::vals::Pincos { | ||
| 5229 | let val = (self.0 >> 15usize) & 0x01; | ||
| 5230 | super::vals::Pincos(val as u8) | ||
| 5231 | } | ||
| 5232 | #[doc = "Peripheral increment offset size"] | ||
| 5233 | pub fn set_pincos(&mut self, val: super::vals::Pincos) { | ||
| 5234 | self.0 = (self.0 & !(0x01 << 15usize)) | (((val.0 as u32) & 0x01) << 15usize); | ||
| 5235 | } | 5302 | } |
| 5236 | #[doc = "Priority level"] | 5303 | #[doc = "Channel Priority level"] |
| 5237 | pub const fn pl(&self) -> super::vals::Pl { | 5304 | pub const fn pl(&self) -> super::vals::Pl { |
| 5238 | let val = (self.0 >> 16usize) & 0x03; | 5305 | let val = (self.0 >> 12usize) & 0x03; |
| 5239 | super::vals::Pl(val as u8) | 5306 | super::vals::Pl(val as u8) |
| 5240 | } | 5307 | } |
| 5241 | #[doc = "Priority level"] | 5308 | #[doc = "Channel Priority level"] |
| 5242 | pub fn set_pl(&mut self, val: super::vals::Pl) { | 5309 | pub fn set_pl(&mut self, val: super::vals::Pl) { |
| 5243 | self.0 = (self.0 & !(0x03 << 16usize)) | (((val.0 as u32) & 0x03) << 16usize); | 5310 | self.0 = (self.0 & !(0x03 << 12usize)) | (((val.0 as u32) & 0x03) << 12usize); |
| 5244 | } | 5311 | } |
| 5245 | #[doc = "Double buffer mode"] | 5312 | #[doc = "Memory to memory mode"] |
| 5246 | pub const fn dbm(&self) -> super::vals::Dbm { | 5313 | pub const fn mem2mem(&self) -> super::vals::Memmem { |
| 5247 | let val = (self.0 >> 18usize) & 0x01; | 5314 | let val = (self.0 >> 14usize) & 0x01; |
| 5248 | super::vals::Dbm(val as u8) | 5315 | super::vals::Memmem(val as u8) |
| 5249 | } | 5316 | } |
| 5250 | #[doc = "Double buffer mode"] | 5317 | #[doc = "Memory to memory mode"] |
| 5251 | pub fn set_dbm(&mut self, val: super::vals::Dbm) { | 5318 | pub fn set_mem2mem(&mut self, val: super::vals::Memmem) { |
| 5252 | self.0 = (self.0 & !(0x01 << 18usize)) | (((val.0 as u32) & 0x01) << 18usize); | 5319 | self.0 = (self.0 & !(0x01 << 14usize)) | (((val.0 as u32) & 0x01) << 14usize); |
| 5253 | } | 5320 | } |
| 5254 | #[doc = "Current target (only in double buffer mode)"] | 5321 | } |
| 5255 | pub const fn ct(&self) -> super::vals::Ct { | 5322 | impl Default for Cr { |
| 5256 | let val = (self.0 >> 19usize) & 0x01; | 5323 | fn default() -> Cr { |
| 5257 | super::vals::Ct(val as u8) | 5324 | Cr(0) |
| 5258 | } | 5325 | } |
| 5259 | #[doc = "Current target (only in double buffer mode)"] | 5326 | } |
| 5260 | pub fn set_ct(&mut self, val: super::vals::Ct) { | 5327 | #[doc = "DMA interrupt status register (DMA_ISR)"] |
| 5261 | self.0 = (self.0 & !(0x01 << 19usize)) | (((val.0 as u32) & 0x01) << 19usize); | 5328 | #[repr(transparent)] |
| 5329 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
| 5330 | pub struct Isr(pub u32); | ||
| 5331 | impl Isr { | ||
| 5332 | #[doc = "Channel 1 Global interrupt flag"] | ||
| 5333 | pub fn gif(&self, n: usize) -> bool { | ||
| 5334 | assert!(n < 7usize); | ||
| 5335 | let offs = 0usize + n * 4usize; | ||
| 5336 | let val = (self.0 >> offs) & 0x01; | ||
| 5337 | val != 0 | ||
| 5262 | } | 5338 | } |
| 5263 | #[doc = "Peripheral burst transfer configuration"] | 5339 | #[doc = "Channel 1 Global interrupt flag"] |
| 5264 | pub const fn pburst(&self) -> super::vals::Burst { | 5340 | pub fn set_gif(&mut self, n: usize, val: bool) { |
| 5265 | let val = (self.0 >> 21usize) & 0x03; | 5341 | assert!(n < 7usize); |
| 5266 | super::vals::Burst(val as u8) | 5342 | let offs = 0usize + n * 4usize; |
| 5343 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | ||
| 5267 | } | 5344 | } |
| 5268 | #[doc = "Peripheral burst transfer configuration"] | 5345 | #[doc = "Channel 1 Transfer Complete flag"] |
| 5269 | pub fn set_pburst(&mut self, val: super::vals::Burst) { | 5346 | pub fn tcif(&self, n: usize) -> bool { |
| 5270 | self.0 = (self.0 & !(0x03 << 21usize)) | (((val.0 as u32) & 0x03) << 21usize); | 5347 | assert!(n < 7usize); |
| 5348 | let offs = 1usize + n * 4usize; | ||
| 5349 | let val = (self.0 >> offs) & 0x01; | ||
| 5350 | val != 0 | ||
| 5271 | } | 5351 | } |
| 5272 | #[doc = "Memory burst transfer configuration"] | 5352 | #[doc = "Channel 1 Transfer Complete flag"] |
| 5273 | pub const fn mburst(&self) -> super::vals::Burst { | 5353 | pub fn set_tcif(&mut self, n: usize, val: bool) { |
| 5274 | let val = (self.0 >> 23usize) & 0x03; | 5354 | assert!(n < 7usize); |
| 5275 | super::vals::Burst(val as u8) | 5355 | let offs = 1usize + n * 4usize; |
| 5356 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | ||
| 5276 | } | 5357 | } |
| 5277 | #[doc = "Memory burst transfer configuration"] | 5358 | #[doc = "Channel 1 Half Transfer Complete flag"] |
| 5278 | pub fn set_mburst(&mut self, val: super::vals::Burst) { | 5359 | pub fn htif(&self, n: usize) -> bool { |
| 5279 | self.0 = (self.0 & !(0x03 << 23usize)) | (((val.0 as u32) & 0x03) << 23usize); | 5360 | assert!(n < 7usize); |
| 5361 | let offs = 2usize + n * 4usize; | ||
| 5362 | let val = (self.0 >> offs) & 0x01; | ||
| 5363 | val != 0 | ||
| 5280 | } | 5364 | } |
| 5281 | #[doc = "Channel selection"] | 5365 | #[doc = "Channel 1 Half Transfer Complete flag"] |
| 5282 | pub const fn chsel(&self) -> u8 { | 5366 | pub fn set_htif(&mut self, n: usize, val: bool) { |
| 5283 | let val = (self.0 >> 25usize) & 0x0f; | 5367 | assert!(n < 7usize); |
| 5284 | val as u8 | 5368 | let offs = 2usize + n * 4usize; |
| 5369 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | ||
| 5285 | } | 5370 | } |
| 5286 | #[doc = "Channel selection"] | 5371 | #[doc = "Channel 1 Transfer Error flag"] |
| 5287 | pub fn set_chsel(&mut self, val: u8) { | 5372 | pub fn teif(&self, n: usize) -> bool { |
| 5288 | self.0 = (self.0 & !(0x0f << 25usize)) | (((val as u32) & 0x0f) << 25usize); | 5373 | assert!(n < 7usize); |
| 5374 | let offs = 3usize + n * 4usize; | ||
| 5375 | let val = (self.0 >> offs) & 0x01; | ||
| 5376 | val != 0 | ||
| 5377 | } | ||
| 5378 | #[doc = "Channel 1 Transfer Error flag"] | ||
| 5379 | pub fn set_teif(&mut self, n: usize, val: bool) { | ||
| 5380 | assert!(n < 7usize); | ||
| 5381 | let offs = 3usize + n * 4usize; | ||
| 5382 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | ||
| 5289 | } | 5383 | } |
| 5290 | } | 5384 | } |
| 5291 | impl Default for Cr { | 5385 | impl Default for Isr { |
| 5292 | fn default() -> Cr { | 5386 | fn default() -> Isr { |
| 5293 | Cr(0) | 5387 | Isr(0) |
| 5294 | } | 5388 | } |
| 5295 | } | 5389 | } |
| 5296 | #[doc = "low interrupt flag clear register"] | 5390 | #[doc = "DMA interrupt flag clear register (DMA_IFCR)"] |
| 5297 | #[repr(transparent)] | 5391 | #[repr(transparent)] |
| 5298 | #[derive(Copy, Clone, Eq, PartialEq)] | 5392 | #[derive(Copy, Clone, Eq, PartialEq)] |
| 5299 | pub struct Ifcr(pub u32); | 5393 | pub struct Ifcr(pub u32); |
| 5300 | impl Ifcr { | 5394 | impl Ifcr { |
| 5301 | #[doc = "Stream x clear FIFO error interrupt flag (x = 3..0)"] | 5395 | #[doc = "Channel 1 Global interrupt clear"] |
| 5302 | pub fn cfeif(&self, n: usize) -> bool { | 5396 | pub fn cgif(&self, n: usize) -> bool { |
| 5303 | assert!(n < 4usize); | 5397 | assert!(n < 7usize); |
| 5304 | let offs = 0usize + ([0usize, 6usize, 16usize, 22usize][n] as usize); | 5398 | let offs = 0usize + n * 4usize; |
| 5305 | let val = (self.0 >> offs) & 0x01; | ||
| 5306 | val != 0 | ||
| 5307 | } | ||
| 5308 | #[doc = "Stream x clear FIFO error interrupt flag (x = 3..0)"] | ||
| 5309 | pub fn set_cfeif(&mut self, n: usize, val: bool) { | ||
| 5310 | assert!(n < 4usize); | ||
| 5311 | let offs = 0usize + ([0usize, 6usize, 16usize, 22usize][n] as usize); | ||
| 5312 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | ||
| 5313 | } | ||
| 5314 | #[doc = "Stream x clear direct mode error interrupt flag (x = 3..0)"] | ||
| 5315 | pub fn cdmeif(&self, n: usize) -> bool { | ||
| 5316 | assert!(n < 4usize); | ||
| 5317 | let offs = 2usize + ([0usize, 6usize, 16usize, 22usize][n] as usize); | ||
| 5318 | let val = (self.0 >> offs) & 0x01; | 5399 | let val = (self.0 >> offs) & 0x01; |
| 5319 | val != 0 | 5400 | val != 0 |
| 5320 | } | 5401 | } |
| 5321 | #[doc = "Stream x clear direct mode error interrupt flag (x = 3..0)"] | 5402 | #[doc = "Channel 1 Global interrupt clear"] |
| 5322 | pub fn set_cdmeif(&mut self, n: usize, val: bool) { | 5403 | pub fn set_cgif(&mut self, n: usize, val: bool) { |
| 5323 | assert!(n < 4usize); | 5404 | assert!(n < 7usize); |
| 5324 | let offs = 2usize + ([0usize, 6usize, 16usize, 22usize][n] as usize); | 5405 | let offs = 0usize + n * 4usize; |
| 5325 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | 5406 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); |
| 5326 | } | 5407 | } |
| 5327 | #[doc = "Stream x clear transfer error interrupt flag (x = 3..0)"] | 5408 | #[doc = "Channel 1 Transfer Complete clear"] |
| 5328 | pub fn cteif(&self, n: usize) -> bool { | 5409 | pub fn ctcif(&self, n: usize) -> bool { |
| 5329 | assert!(n < 4usize); | 5410 | assert!(n < 7usize); |
| 5330 | let offs = 3usize + ([0usize, 6usize, 16usize, 22usize][n] as usize); | 5411 | let offs = 1usize + n * 4usize; |
| 5331 | let val = (self.0 >> offs) & 0x01; | 5412 | let val = (self.0 >> offs) & 0x01; |
| 5332 | val != 0 | 5413 | val != 0 |
| 5333 | } | 5414 | } |
| 5334 | #[doc = "Stream x clear transfer error interrupt flag (x = 3..0)"] | 5415 | #[doc = "Channel 1 Transfer Complete clear"] |
| 5335 | pub fn set_cteif(&mut self, n: usize, val: bool) { | 5416 | pub fn set_ctcif(&mut self, n: usize, val: bool) { |
| 5336 | assert!(n < 4usize); | 5417 | assert!(n < 7usize); |
| 5337 | let offs = 3usize + ([0usize, 6usize, 16usize, 22usize][n] as usize); | 5418 | let offs = 1usize + n * 4usize; |
| 5338 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | 5419 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); |
| 5339 | } | 5420 | } |
| 5340 | #[doc = "Stream x clear half transfer interrupt flag (x = 3..0)"] | 5421 | #[doc = "Channel 1 Half Transfer clear"] |
| 5341 | pub fn chtif(&self, n: usize) -> bool { | 5422 | pub fn chtif(&self, n: usize) -> bool { |
| 5342 | assert!(n < 4usize); | 5423 | assert!(n < 7usize); |
| 5343 | let offs = 4usize + ([0usize, 6usize, 16usize, 22usize][n] as usize); | 5424 | let offs = 2usize + n * 4usize; |
| 5344 | let val = (self.0 >> offs) & 0x01; | 5425 | let val = (self.0 >> offs) & 0x01; |
| 5345 | val != 0 | 5426 | val != 0 |
| 5346 | } | 5427 | } |
| 5347 | #[doc = "Stream x clear half transfer interrupt flag (x = 3..0)"] | 5428 | #[doc = "Channel 1 Half Transfer clear"] |
| 5348 | pub fn set_chtif(&mut self, n: usize, val: bool) { | 5429 | pub fn set_chtif(&mut self, n: usize, val: bool) { |
| 5349 | assert!(n < 4usize); | 5430 | assert!(n < 7usize); |
| 5350 | let offs = 4usize + ([0usize, 6usize, 16usize, 22usize][n] as usize); | 5431 | let offs = 2usize + n * 4usize; |
| 5351 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | 5432 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); |
| 5352 | } | 5433 | } |
| 5353 | #[doc = "Stream x clear transfer complete interrupt flag (x = 3..0)"] | 5434 | #[doc = "Channel 1 Transfer Error clear"] |
| 5354 | pub fn ctcif(&self, n: usize) -> bool { | 5435 | pub fn cteif(&self, n: usize) -> bool { |
| 5355 | assert!(n < 4usize); | 5436 | assert!(n < 7usize); |
| 5356 | let offs = 5usize + ([0usize, 6usize, 16usize, 22usize][n] as usize); | 5437 | let offs = 3usize + n * 4usize; |
| 5357 | let val = (self.0 >> offs) & 0x01; | 5438 | let val = (self.0 >> offs) & 0x01; |
| 5358 | val != 0 | 5439 | val != 0 |
| 5359 | } | 5440 | } |
| 5360 | #[doc = "Stream x clear transfer complete interrupt flag (x = 3..0)"] | 5441 | #[doc = "Channel 1 Transfer Error clear"] |
| 5361 | pub fn set_ctcif(&mut self, n: usize, val: bool) { | 5442 | pub fn set_cteif(&mut self, n: usize, val: bool) { |
| 5362 | assert!(n < 4usize); | 5443 | assert!(n < 7usize); |
| 5363 | let offs = 5usize + ([0usize, 6usize, 16usize, 22usize][n] as usize); | 5444 | let offs = 3usize + n * 4usize; |
| 5364 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); | 5445 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); |
| 5365 | } | 5446 | } |
| 5366 | } | 5447 | } |
| @@ -5374,144 +5455,63 @@ pub mod dma_v2 { | |||
| 5374 | use crate::generic::*; | 5455 | use crate::generic::*; |
| 5375 | #[repr(transparent)] | 5456 | #[repr(transparent)] |
| 5376 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 5457 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 5377 | pub struct Pfctrl(pub u8); | ||
| 5378 | impl Pfctrl { | ||
| 5379 | #[doc = "The DMA is the flow controller"] | ||
| 5380 | pub const DMA: Self = Self(0); | ||
| 5381 | #[doc = "The peripheral is the flow controller"] | ||
| 5382 | pub const PERIPHERAL: Self = Self(0x01); | ||
| 5383 | } | ||
| 5384 | #[repr(transparent)] | ||
| 5385 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 5386 | pub struct Size(pub u8); | ||
| 5387 | impl Size { | ||
| 5388 | #[doc = "Byte (8-bit)"] | ||
| 5389 | pub const BITS8: Self = Self(0); | ||
| 5390 | #[doc = "Half-word (16-bit)"] | ||
| 5391 | pub const BITS16: Self = Self(0x01); | ||
| 5392 | #[doc = "Word (32-bit)"] | ||
| 5393 | pub const BITS32: Self = Self(0x02); | ||
| 5394 | } | ||
| 5395 | #[repr(transparent)] | ||
| 5396 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 5397 | pub struct Dbm(pub u8); | ||
| 5398 | impl Dbm { | ||
| 5399 | #[doc = "No buffer switching at the end of transfer"] | ||
| 5400 | pub const DISABLED: Self = Self(0); | ||
| 5401 | #[doc = "Memory target switched at the end of the DMA transfer"] | ||
| 5402 | pub const ENABLED: Self = Self(0x01); | ||
| 5403 | } | ||
| 5404 | #[repr(transparent)] | ||
| 5405 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 5406 | pub struct Dir(pub u8); | 5458 | pub struct Dir(pub u8); |
| 5407 | impl Dir { | 5459 | impl Dir { |
| 5408 | #[doc = "Peripheral-to-memory"] | 5460 | #[doc = "Read from peripheral"] |
| 5409 | pub const PERIPHERALTOMEMORY: Self = Self(0); | 5461 | pub const FROMPERIPHERAL: Self = Self(0); |
| 5410 | #[doc = "Memory-to-peripheral"] | 5462 | #[doc = "Read from memory"] |
| 5411 | pub const MEMORYTOPERIPHERAL: Self = Self(0x01); | 5463 | pub const FROMMEMORY: Self = Self(0x01); |
| 5412 | #[doc = "Memory-to-memory"] | ||
| 5413 | pub const MEMORYTOMEMORY: Self = Self(0x02); | ||
| 5414 | } | ||
| 5415 | #[repr(transparent)] | ||
| 5416 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 5417 | pub struct Pincos(pub u8); | ||
| 5418 | impl Pincos { | ||
| 5419 | #[doc = "The offset size for the peripheral address calculation is linked to the PSIZE"] | ||
| 5420 | pub const PSIZE: Self = Self(0); | ||
| 5421 | #[doc = "The offset size for the peripheral address calculation is fixed to 4 (32-bit alignment)"] | ||
| 5422 | pub const FIXED4: Self = Self(0x01); | ||
| 5423 | } | ||
| 5424 | #[repr(transparent)] | ||
| 5425 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 5426 | pub struct Burst(pub u8); | ||
| 5427 | impl Burst { | ||
| 5428 | #[doc = "Single transfer"] | ||
| 5429 | pub const SINGLE: Self = Self(0); | ||
| 5430 | #[doc = "Incremental burst of 4 beats"] | ||
| 5431 | pub const INCR4: Self = Self(0x01); | ||
| 5432 | #[doc = "Incremental burst of 8 beats"] | ||
| 5433 | pub const INCR8: Self = Self(0x02); | ||
| 5434 | #[doc = "Incremental burst of 16 beats"] | ||
| 5435 | pub const INCR16: Self = Self(0x03); | ||
| 5436 | } | ||
| 5437 | #[repr(transparent)] | ||
| 5438 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 5439 | pub struct Ct(pub u8); | ||
| 5440 | impl Ct { | ||
| 5441 | #[doc = "The current target memory is Memory 0"] | ||
| 5442 | pub const MEMORY0: Self = Self(0); | ||
| 5443 | #[doc = "The current target memory is Memory 1"] | ||
| 5444 | pub const MEMORY1: Self = Self(0x01); | ||
| 5445 | } | 5464 | } |
| 5446 | #[repr(transparent)] | 5465 | #[repr(transparent)] |
| 5447 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 5466 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 5448 | pub struct Fs(pub u8); | 5467 | pub struct Inc(pub u8); |
| 5449 | impl Fs { | 5468 | impl Inc { |
| 5450 | #[doc = "0 < fifo_level < 1/4"] | 5469 | #[doc = "Increment mode disabled"] |
| 5451 | pub const QUARTER1: Self = Self(0); | 5470 | pub const DISABLED: Self = Self(0); |
| 5452 | #[doc = "1/4 <= fifo_level < 1/2"] | 5471 | #[doc = "Increment mode enabled"] |
| 5453 | pub const QUARTER2: Self = Self(0x01); | 5472 | pub const ENABLED: Self = Self(0x01); |
| 5454 | #[doc = "1/2 <= fifo_level < 3/4"] | ||
| 5455 | pub const QUARTER3: Self = Self(0x02); | ||
| 5456 | #[doc = "3/4 <= fifo_level < full"] | ||
| 5457 | pub const QUARTER4: Self = Self(0x03); | ||
| 5458 | #[doc = "FIFO is empty"] | ||
| 5459 | pub const EMPTY: Self = Self(0x04); | ||
| 5460 | #[doc = "FIFO is full"] | ||
| 5461 | pub const FULL: Self = Self(0x05); | ||
| 5462 | } | 5473 | } |
| 5463 | #[repr(transparent)] | 5474 | #[repr(transparent)] |
| 5464 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 5475 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 5465 | pub struct Fth(pub u8); | 5476 | pub struct Memmem(pub u8); |
| 5466 | impl Fth { | 5477 | impl Memmem { |
| 5467 | #[doc = "1/4 full FIFO"] | 5478 | #[doc = "Memory to memory mode disabled"] |
| 5468 | pub const QUARTER: Self = Self(0); | 5479 | pub const DISABLED: Self = Self(0); |
| 5469 | #[doc = "1/2 full FIFO"] | 5480 | #[doc = "Memory to memory mode enabled"] |
| 5470 | pub const HALF: Self = Self(0x01); | 5481 | pub const ENABLED: Self = Self(0x01); |
| 5471 | #[doc = "3/4 full FIFO"] | ||
| 5472 | pub const THREEQUARTERS: Self = Self(0x02); | ||
| 5473 | #[doc = "Full FIFO"] | ||
| 5474 | pub const FULL: Self = Self(0x03); | ||
| 5475 | } | 5482 | } |
| 5476 | #[repr(transparent)] | 5483 | #[repr(transparent)] |
| 5477 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 5484 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 5478 | pub struct Inc(pub u8); | 5485 | pub struct Size(pub u8); |
| 5479 | impl Inc { | 5486 | impl Size { |
| 5480 | #[doc = "Address pointer is fixed"] | 5487 | #[doc = "8-bit size"] |
| 5481 | pub const FIXED: Self = Self(0); | 5488 | pub const BITS8: Self = Self(0); |
| 5482 | #[doc = "Address pointer is incremented after each data transfer"] | 5489 | #[doc = "16-bit size"] |
| 5483 | pub const INCREMENTED: Self = Self(0x01); | 5490 | pub const BITS16: Self = Self(0x01); |
| 5491 | #[doc = "32-bit size"] | ||
| 5492 | pub const BITS32: Self = Self(0x02); | ||
| 5484 | } | 5493 | } |
| 5485 | #[repr(transparent)] | 5494 | #[repr(transparent)] |
| 5486 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 5495 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 5487 | pub struct Pl(pub u8); | 5496 | pub struct Pl(pub u8); |
| 5488 | impl Pl { | 5497 | impl Pl { |
| 5489 | #[doc = "Low"] | 5498 | #[doc = "Low priority"] |
| 5490 | pub const LOW: Self = Self(0); | 5499 | pub const LOW: Self = Self(0); |
| 5491 | #[doc = "Medium"] | 5500 | #[doc = "Medium priority"] |
| 5492 | pub const MEDIUM: Self = Self(0x01); | 5501 | pub const MEDIUM: Self = Self(0x01); |
| 5493 | #[doc = "High"] | 5502 | #[doc = "High priority"] |
| 5494 | pub const HIGH: Self = Self(0x02); | 5503 | pub const HIGH: Self = Self(0x02); |
| 5495 | #[doc = "Very high"] | 5504 | #[doc = "Very high priority"] |
| 5496 | pub const VERYHIGH: Self = Self(0x03); | 5505 | pub const VERYHIGH: Self = Self(0x03); |
| 5497 | } | 5506 | } |
| 5498 | #[repr(transparent)] | 5507 | #[repr(transparent)] |
| 5499 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 5508 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| 5500 | pub struct Circ(pub u8); | 5509 | pub struct Circ(pub u8); |
| 5501 | impl Circ { | 5510 | impl Circ { |
| 5502 | #[doc = "Circular mode disabled"] | 5511 | #[doc = "Circular buffer disabled"] |
| 5503 | pub const DISABLED: Self = Self(0); | 5512 | pub const DISABLED: Self = Self(0); |
| 5504 | #[doc = "Circular mode enabled"] | 5513 | #[doc = "Circular buffer enabled"] |
| 5505 | pub const ENABLED: Self = Self(0x01); | 5514 | pub const ENABLED: Self = Self(0x01); |
| 5506 | } | 5515 | } |
| 5507 | #[repr(transparent)] | ||
| 5508 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 5509 | pub struct Dmdis(pub u8); | ||
| 5510 | impl Dmdis { | ||
| 5511 | #[doc = "Direct mode is enabled"] | ||
| 5512 | pub const ENABLED: Self = Self(0); | ||
| 5513 | #[doc = "Direct mode is disabled"] | ||
| 5514 | pub const DISABLED: Self = Self(0x01); | ||
| 5515 | } | ||
| 5516 | } | 5516 | } |
| 5517 | } | 5517 | } |
diff --git a/embassy-stm32/src/rng.rs b/embassy-stm32/src/rng.rs index d1419dfd7..9eedcb17d 100644 --- a/embassy-stm32/src/rng.rs +++ b/embassy-stm32/src/rng.rs | |||
| @@ -1,31 +1,140 @@ | |||
| 1 | #![macro_use] | 1 | #![macro_use] |
| 2 | use crate::pac::rng::{regs, Rng}; | 2 | |
| 3 | //use crate::pac::rng::{regs, Rng}; | ||
| 4 | use crate::pac; | ||
| 3 | use crate::peripherals; | 5 | use crate::peripherals; |
| 4 | use embassy::util::Unborrow; | 6 | use crate::interrupt; |
| 7 | use futures::future::poll_fn; | ||
| 8 | use embassy::util::{Unborrow, AtomicWaker}; | ||
| 5 | use embassy_extras::unborrow; | 9 | use embassy_extras::unborrow; |
| 10 | use rand_core::{RngCore, CryptoRng}; | ||
| 11 | |||
| 12 | use defmt::*; | ||
| 13 | |||
| 14 | static RNG_WAKER: AtomicWaker = AtomicWaker::new(); | ||
| 15 | |||
| 16 | #[interrupt] | ||
| 17 | unsafe fn RNG() { | ||
| 18 | let bits = crate::pac::RNG.sr().read(); | ||
| 19 | if bits.drdy() || bits.seis() || bits.ceis() { | ||
| 20 | crate::pac::RNG.cr().write(|reg| reg.set_ie(false)); | ||
| 21 | RNG_WAKER.wake(); | ||
| 22 | } | ||
| 23 | } | ||
| 6 | 24 | ||
| 7 | pub struct Random<T: Instance> { | 25 | pub struct Random<T: Instance> { |
| 8 | inner: T, | 26 | inner: T, |
| 9 | } | 27 | } |
| 10 | 28 | ||
| 11 | impl<T: Instance> Random<T> { | 29 | impl<T: Instance> Random<T> { |
| 12 | pub fn new(inner: impl Unborrow<Target = T>) -> Self { | 30 | pub fn new(inner: impl Unborrow<Target=T>) -> Self { |
| 13 | unborrow!(inner); | 31 | unborrow!(inner); |
| 14 | Self { inner } | 32 | let mut random = Self { inner }; |
| 33 | random.reset(); | ||
| 34 | random | ||
| 35 | } | ||
| 36 | |||
| 37 | pub fn reset(&mut self) { | ||
| 38 | unsafe { | ||
| 39 | T::regs().cr().modify(|reg| { | ||
| 40 | reg.set_rngen(true); | ||
| 41 | reg.set_ie(true); | ||
| 42 | }); | ||
| 43 | T::regs().sr().modify(|reg| { | ||
| 44 | reg.set_seis(false); | ||
| 45 | reg.set_ceis(false); | ||
| 46 | }); | ||
| 47 | } | ||
| 48 | // Reference manual says to discard the first. | ||
| 49 | let _ = self.next_u32(); | ||
| 50 | } | ||
| 51 | } | ||
| 52 | |||
| 53 | impl<T: Instance> RngCore for Random<T> { | ||
| 54 | fn next_u32(&mut self) -> u32 { | ||
| 55 | loop { | ||
| 56 | let bits = unsafe { T::regs().sr().read() }; | ||
| 57 | if bits.drdy() { | ||
| 58 | return unsafe{ T::regs().dr().read() } | ||
| 59 | } | ||
| 60 | } | ||
| 61 | } | ||
| 62 | |||
| 63 | fn next_u64(&mut self) -> u64 { | ||
| 64 | let mut rand = self.next_u32() as u64; | ||
| 65 | rand |= (self.next_u32() as u64) << 32; | ||
| 66 | rand | ||
| 67 | } | ||
| 68 | |||
| 69 | fn fill_bytes(&mut self, dest: &mut [u8]) { | ||
| 70 | for chunk in dest.chunks_mut(4) { | ||
| 71 | let rand = self.next_u32(); | ||
| 72 | for (slot, num) in chunk.iter_mut().zip(rand.to_be_bytes().iter()) { | ||
| 73 | *slot = *num | ||
| 74 | } | ||
| 75 | } | ||
| 76 | } | ||
| 77 | |||
| 78 | fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand_core::Error> { | ||
| 79 | self.fill_bytes( dest ); | ||
| 80 | Ok(()) | ||
| 15 | } | 81 | } |
| 16 | } | 82 | } |
| 17 | 83 | ||
| 84 | impl<T: Instance> CryptoRng for Random<T> { } | ||
| 85 | |||
| 18 | use core::future::Future; | 86 | use core::future::Future; |
| 19 | use core::marker::PhantomData; | 87 | use core::marker::PhantomData; |
| 20 | use embassy::traits::rng::Rng as RngTrait; | 88 | use embassy::traits; |
| 89 | use core::task::{Poll, Context}; | ||
| 90 | use core::pin::Pin; | ||
| 21 | 91 | ||
| 22 | impl<T: Instance> RngTrait for Random<T> { | 92 | pub enum Error { |
| 23 | type Error = (); | 93 | SeedError, |
| 24 | #[rustfmt::skip] | 94 | ClockError, |
| 25 | type RngFuture<'a> where Self: 'a = impl Future<Output = Result<(), Self::Error>>; | 95 | } |
| 96 | |||
| 97 | impl<T: Instance> traits::rng::Rng for Random<T> { | ||
| 98 | type Error = Error; | ||
| 99 | type RngFuture<'a> where Self: 'a = impl Future<Output=Result<(), Self::Error>>; | ||
| 100 | |||
| 101 | fn fill_bytes<'a>(&'a mut self, dest: &'a mut [u8]) -> Self::RngFuture<'a> { | ||
| 102 | unsafe { | ||
| 103 | T::regs().cr().modify(|reg| { | ||
| 104 | reg.set_rngen(true); | ||
| 105 | }); | ||
| 106 | } | ||
| 107 | async move { | ||
| 108 | for chunk in dest.chunks_mut(4) { | ||
| 109 | poll_fn(|cx| { | ||
| 110 | RNG_WAKER.register(cx.waker()); | ||
| 111 | unsafe { | ||
| 112 | T::regs().cr().modify(|reg| { | ||
| 113 | reg.set_ie(true); | ||
| 114 | }); | ||
| 115 | } | ||
| 26 | 116 | ||
| 27 | fn fill<'a>(&'a mut self, dest: &'a mut [u8]) -> Self::RngFuture<'a> { | 117 | let bits = unsafe { T::regs().sr().read() }; |
| 28 | async move { Ok(()) } | 118 | |
| 119 | if bits.drdy() { | ||
| 120 | Poll::Ready(Ok(())) | ||
| 121 | } else if bits.seis() { | ||
| 122 | self.reset(); | ||
| 123 | Poll::Ready(Err(Error::SeedError)) | ||
| 124 | } else if bits.ceis() { | ||
| 125 | self.reset(); | ||
| 126 | Poll::Ready(Err(Error::ClockError)) | ||
| 127 | } else { | ||
| 128 | Poll::Pending | ||
| 129 | } | ||
| 130 | } ).await?; | ||
| 131 | let random_bytes = unsafe { T::regs().dr().read() }.to_be_bytes(); | ||
| 132 | for (dest, src) in chunk.iter_mut().zip(random_bytes.iter()) { | ||
| 133 | *dest = *src | ||
| 134 | } | ||
| 135 | } | ||
| 136 | Ok(()) | ||
| 137 | } | ||
| 29 | } | 138 | } |
| 30 | } | 139 | } |
| 31 | 140 | ||
| @@ -33,7 +142,7 @@ pub(crate) mod sealed { | |||
| 33 | use super::*; | 142 | use super::*; |
| 34 | 143 | ||
| 35 | pub trait Instance { | 144 | pub trait Instance { |
| 36 | fn regs(&self) -> Rng; | 145 | fn regs() -> pac::rng::Rng; |
| 37 | } | 146 | } |
| 38 | } | 147 | } |
| 39 | 148 | ||
| @@ -41,12 +150,12 @@ pub trait Instance: sealed::Instance {} | |||
| 41 | 150 | ||
| 42 | macro_rules! impl_rng { | 151 | macro_rules! impl_rng { |
| 43 | ($inst:ident) => { | 152 | ($inst:ident) => { |
| 44 | impl crate::rng::sealed::Instance for peripherals::$inst { | 153 | impl crate::rng::sealed::Instance for peripherals::RNG { |
| 45 | fn regs(&self) -> crate::pac::rng::Rng { | 154 | fn regs() -> crate::pac::chip::rng::Rng { |
| 46 | crate::pac::$inst | 155 | crate::pac::RNG |
| 47 | } | 156 | } |
| 48 | } | 157 | } |
| 49 | 158 | ||
| 50 | impl crate::rng::Instance for peripherals::$inst {} | 159 | impl crate::rng::Instance for peripherals::RNG {} |
| 51 | }; | 160 | }; |
| 52 | } | 161 | } |
diff --git a/embassy-traits/src/rng.rs b/embassy-traits/src/rng.rs index af786bd4a..ddc4c20e0 100644 --- a/embassy-traits/src/rng.rs +++ b/embassy-traits/src/rng.rs | |||
| @@ -13,5 +13,5 @@ pub trait Rng { | |||
| 13 | /// May result in delays if entropy is exhausted prior to completely | 13 | /// May result in delays if entropy is exhausted prior to completely |
| 14 | /// filling the buffer. Upon completion, the buffer will be completely | 14 | /// filling the buffer. Upon completion, the buffer will be completely |
| 15 | /// filled or an error will have been reported. | 15 | /// filled or an error will have been reported. |
| 16 | fn fill<'a>(&'a mut self, dest: &'a mut [u8]) -> Self::RngFuture<'a>; | 16 | fn fill_bytes<'a>(&'a mut self, dest: &'a mut [u8]) -> Self::RngFuture<'a>; |
| 17 | } | 17 | } |
