diff options
33 files changed, 8667 insertions, 0 deletions
diff --git a/embassy-stm32/src/can/bx/filter.rs b/embassy-stm32/src/can/bx/filter.rs new file mode 100644 index 000000000..acd2e4688 --- /dev/null +++ b/embassy-stm32/src/can/bx/filter.rs | |||
| @@ -0,0 +1,510 @@ | |||
| 1 | //! Filter bank API. | ||
| 2 | |||
| 3 | use core::marker::PhantomData; | ||
| 4 | |||
| 5 | use crate::pac::can::RegisterBlock; | ||
| 6 | use crate::{ExtendedId, Fifo, FilterOwner, Id, Instance, MasterInstance, StandardId}; | ||
| 7 | |||
| 8 | const F32_RTR: u32 = 0b010; // set the RTR bit to match remote frames | ||
| 9 | const F32_IDE: u32 = 0b100; // set the IDE bit to match extended identifiers | ||
| 10 | const F16_RTR: u16 = 0b10000; | ||
| 11 | const F16_IDE: u16 = 0b01000; | ||
| 12 | |||
| 13 | /// A 16-bit filter list entry. | ||
| 14 | /// | ||
| 15 | /// This can match data and remote frames using standard IDs. | ||
| 16 | #[derive(Debug, Copy, Clone, Eq, PartialEq)] | ||
| 17 | #[cfg_attr(feature = "unstable-defmt", derive(defmt::Format))] | ||
| 18 | pub struct ListEntry16(u16); | ||
| 19 | |||
| 20 | /// A 32-bit filter list entry. | ||
| 21 | /// | ||
| 22 | /// This can match data and remote frames using extended or standard IDs. | ||
| 23 | #[derive(Debug, Copy, Clone, Eq, PartialEq)] | ||
| 24 | #[cfg_attr(feature = "unstable-defmt", derive(defmt::Format))] | ||
| 25 | pub struct ListEntry32(u32); | ||
| 26 | |||
| 27 | /// A 16-bit identifier mask. | ||
| 28 | #[derive(Debug, Copy, Clone)] | ||
| 29 | #[cfg_attr(feature = "unstable-defmt", derive(defmt::Format))] | ||
| 30 | pub struct Mask16 { | ||
| 31 | id: u16, | ||
| 32 | mask: u16, | ||
| 33 | } | ||
| 34 | |||
| 35 | /// A 32-bit identifier mask. | ||
| 36 | #[derive(Debug, Copy, Clone)] | ||
| 37 | #[cfg_attr(feature = "unstable-defmt", derive(defmt::Format))] | ||
| 38 | pub struct Mask32 { | ||
| 39 | id: u32, | ||
| 40 | mask: u32, | ||
| 41 | } | ||
| 42 | |||
| 43 | impl ListEntry16 { | ||
| 44 | /// Creates a filter list entry that accepts data frames with the given standard ID. | ||
| 45 | /// | ||
| 46 | /// This entry will *not* accept remote frames with the same ID. | ||
| 47 | pub fn data_frames_with_id(id: StandardId) -> Self { | ||
| 48 | Self(id.as_raw() << 5) | ||
| 49 | } | ||
| 50 | |||
| 51 | /// Creates a filter list entry that accepts remote frames with the given standard ID. | ||
| 52 | pub fn remote_frames_with_id(id: StandardId) -> Self { | ||
| 53 | Self(id.as_raw() << 5 | F16_RTR) | ||
| 54 | } | ||
| 55 | } | ||
| 56 | |||
| 57 | impl ListEntry32 { | ||
| 58 | /// Creates a filter list entry that accepts data frames with the given ID. | ||
| 59 | /// | ||
| 60 | /// This entry will *not* accept remote frames with the same ID. | ||
| 61 | /// | ||
| 62 | /// The filter will only accept *either* standard *or* extended frames, depending on `id`. | ||
| 63 | pub fn data_frames_with_id(id: impl Into<Id>) -> Self { | ||
| 64 | match id.into() { | ||
| 65 | Id::Standard(id) => Self(u32::from(id.as_raw()) << 21), | ||
| 66 | Id::Extended(id) => Self(id.as_raw() << 3 | F32_IDE), | ||
| 67 | } | ||
| 68 | } | ||
| 69 | |||
| 70 | /// Creates a filter list entry that accepts remote frames with the given ID. | ||
| 71 | pub fn remote_frames_with_id(id: impl Into<Id>) -> Self { | ||
| 72 | match id.into() { | ||
| 73 | Id::Standard(id) => Self(u32::from(id.as_raw()) << 21 | F32_RTR), | ||
| 74 | Id::Extended(id) => Self(id.as_raw() << 3 | F32_IDE | F32_RTR), | ||
| 75 | } | ||
| 76 | } | ||
| 77 | } | ||
| 78 | |||
| 79 | impl Mask16 { | ||
| 80 | /// Creates a 16-bit identifier mask that accepts all frames. | ||
| 81 | /// | ||
| 82 | /// This will accept both standard and extended data and remote frames with any ID. | ||
| 83 | pub fn accept_all() -> Self { | ||
| 84 | Self { id: 0, mask: 0 } | ||
| 85 | } | ||
| 86 | |||
| 87 | /// Creates a 16-bit identifier mask that accepts all frames with the given standard | ||
| 88 | /// ID and mask combination. | ||
| 89 | /// | ||
| 90 | /// Filter logic: `frame_accepted = (incoming_id & mask) == (id & mask)` | ||
| 91 | /// | ||
| 92 | /// A mask of all all ones (`0x7FF`) matches an exact ID, a mask of 0 matches all IDs. | ||
| 93 | /// | ||
| 94 | /// Both data and remote frames with `id` will be accepted. Any extended frames will be | ||
| 95 | /// rejected. | ||
| 96 | pub fn frames_with_std_id(id: StandardId, mask: StandardId) -> Self { | ||
| 97 | Self { | ||
| 98 | id: id.as_raw() << 5, | ||
| 99 | mask: mask.as_raw() << 5 | F16_IDE, // also require IDE = 0 | ||
| 100 | } | ||
| 101 | } | ||
| 102 | |||
| 103 | /// Make the filter accept data frames only. | ||
| 104 | pub fn data_frames_only(&mut self) -> &mut Self { | ||
| 105 | self.id &= !F16_RTR; // RTR = 0 | ||
| 106 | self.mask |= F16_RTR; | ||
| 107 | self | ||
| 108 | } | ||
| 109 | |||
| 110 | /// Make the filter accept remote frames only. | ||
| 111 | pub fn remote_frames_only(&mut self) -> &mut Self { | ||
| 112 | self.id |= F16_RTR; // RTR = 1 | ||
| 113 | self.mask |= F16_RTR; | ||
| 114 | self | ||
| 115 | } | ||
| 116 | } | ||
| 117 | |||
| 118 | impl Mask32 { | ||
| 119 | /// Creates a 32-bit identifier mask that accepts all frames. | ||
| 120 | /// | ||
| 121 | /// This will accept both standard and extended data and remote frames with any ID. | ||
| 122 | pub fn accept_all() -> Self { | ||
| 123 | Self { id: 0, mask: 0 } | ||
| 124 | } | ||
| 125 | |||
| 126 | /// Creates a 32-bit identifier mask that accepts all frames with the given extended | ||
| 127 | /// ID and mask combination. | ||
| 128 | /// | ||
| 129 | /// Filter logic: `frame_accepted = (incoming_id & mask) == (id & mask)` | ||
| 130 | /// | ||
| 131 | /// A mask of all all ones (`0x1FFF_FFFF`) matches an exact ID, a mask of 0 matches all IDs. | ||
| 132 | /// | ||
| 133 | /// Both data and remote frames with `id` will be accepted. Standard frames will be rejected. | ||
| 134 | pub fn frames_with_ext_id(id: ExtendedId, mask: ExtendedId) -> Self { | ||
| 135 | Self { | ||
| 136 | id: id.as_raw() << 3 | F32_IDE, | ||
| 137 | mask: mask.as_raw() << 3 | F32_IDE, // also require IDE = 1 | ||
| 138 | } | ||
| 139 | } | ||
| 140 | |||
| 141 | /// Creates a 32-bit identifier mask that accepts all frames with the given standard | ||
| 142 | /// ID and mask combination. | ||
| 143 | /// | ||
| 144 | /// Filter logic: `frame_accepted = (incoming_id & mask) == (id & mask)` | ||
| 145 | /// | ||
| 146 | /// A mask of all all ones (`0x7FF`) matches the exact ID, a mask of 0 matches all IDs. | ||
| 147 | /// | ||
| 148 | /// Both data and remote frames with `id` will be accepted. Extended frames will be rejected. | ||
| 149 | pub fn frames_with_std_id(id: StandardId, mask: StandardId) -> Self { | ||
| 150 | Self { | ||
| 151 | id: u32::from(id.as_raw()) << 21, | ||
| 152 | mask: u32::from(mask.as_raw()) << 21 | F32_IDE, // also require IDE = 0 | ||
| 153 | } | ||
| 154 | } | ||
| 155 | |||
| 156 | /// Make the filter accept data frames only. | ||
| 157 | pub fn data_frames_only(&mut self) -> &mut Self { | ||
| 158 | self.id &= !F32_RTR; // RTR = 0 | ||
| 159 | self.mask |= F32_RTR; | ||
| 160 | self | ||
| 161 | } | ||
| 162 | |||
| 163 | /// Make the filter accept remote frames only. | ||
| 164 | pub fn remote_frames_only(&mut self) -> &mut Self { | ||
| 165 | self.id |= F32_RTR; // RTR = 1 | ||
| 166 | self.mask |= F32_RTR; | ||
| 167 | self | ||
| 168 | } | ||
| 169 | } | ||
| 170 | |||
| 171 | /// The configuration of a filter bank. | ||
| 172 | #[derive(Debug, Copy, Clone)] | ||
| 173 | #[cfg_attr(feature = "unstable-defmt", derive(defmt::Format))] | ||
| 174 | pub enum BankConfig { | ||
| 175 | List16([ListEntry16; 4]), | ||
| 176 | List32([ListEntry32; 2]), | ||
| 177 | Mask16([Mask16; 2]), | ||
| 178 | Mask32(Mask32), | ||
| 179 | } | ||
| 180 | |||
| 181 | impl From<[ListEntry16; 4]> for BankConfig { | ||
| 182 | #[inline] | ||
| 183 | fn from(entries: [ListEntry16; 4]) -> Self { | ||
| 184 | Self::List16(entries) | ||
| 185 | } | ||
| 186 | } | ||
| 187 | |||
| 188 | impl From<[ListEntry32; 2]> for BankConfig { | ||
| 189 | #[inline] | ||
| 190 | fn from(entries: [ListEntry32; 2]) -> Self { | ||
| 191 | Self::List32(entries) | ||
| 192 | } | ||
| 193 | } | ||
| 194 | |||
| 195 | impl From<[Mask16; 2]> for BankConfig { | ||
| 196 | #[inline] | ||
| 197 | fn from(entries: [Mask16; 2]) -> Self { | ||
| 198 | Self::Mask16(entries) | ||
| 199 | } | ||
| 200 | } | ||
| 201 | |||
| 202 | impl From<Mask32> for BankConfig { | ||
| 203 | #[inline] | ||
| 204 | fn from(filter: Mask32) -> Self { | ||
| 205 | Self::Mask32(filter) | ||
| 206 | } | ||
| 207 | } | ||
| 208 | |||
| 209 | /// Interface to the filter banks of a CAN peripheral. | ||
| 210 | pub struct MasterFilters<'a, I: FilterOwner> { | ||
| 211 | /// Number of assigned filter banks. | ||
| 212 | /// | ||
| 213 | /// On chips with splittable filter banks, this value can be dynamic. | ||
| 214 | bank_count: u8, | ||
| 215 | _can: PhantomData<&'a mut I>, | ||
| 216 | } | ||
| 217 | |||
| 218 | // NOTE: This type mutably borrows the CAN instance and has unique access to the registers while it | ||
| 219 | // exists. | ||
| 220 | impl<I: FilterOwner> MasterFilters<'_, I> { | ||
| 221 | pub(crate) unsafe fn new() -> Self { | ||
| 222 | let can = &*I::REGISTERS; | ||
| 223 | |||
| 224 | // Enable initialization mode. | ||
| 225 | can.fmr.modify(|_, w| w.finit().set_bit()); | ||
| 226 | |||
| 227 | // Read the filter split value. | ||
| 228 | let bank_count = can.fmr.read().can2sb().bits(); | ||
| 229 | |||
| 230 | // (Reset value of CAN2SB is 0x0E, 14, which, in devices with 14 filter banks, assigns all | ||
| 231 | // of them to the master peripheral, and in devices with 28, assigns them 50/50 to | ||
| 232 | // master/slave instances) | ||
| 233 | |||
| 234 | Self { | ||
| 235 | bank_count, | ||
| 236 | _can: PhantomData, | ||
| 237 | } | ||
| 238 | } | ||
| 239 | |||
| 240 | fn registers(&self) -> &RegisterBlock { | ||
| 241 | unsafe { &*I::REGISTERS } | ||
| 242 | } | ||
| 243 | |||
| 244 | fn banks_imm(&self) -> FilterBanks<'_> { | ||
| 245 | FilterBanks { | ||
| 246 | start_idx: 0, | ||
| 247 | bank_count: self.bank_count, | ||
| 248 | can: self.registers(), | ||
| 249 | } | ||
| 250 | } | ||
| 251 | |||
| 252 | /// Returns the number of filter banks currently assigned to this instance. | ||
| 253 | /// | ||
| 254 | /// Chips with splittable filter banks may start out with some banks assigned to the master | ||
| 255 | /// instance and some assigned to the slave instance. | ||
| 256 | pub fn num_banks(&self) -> u8 { | ||
| 257 | self.bank_count | ||
| 258 | } | ||
| 259 | |||
| 260 | /// Disables all enabled filter banks. | ||
| 261 | /// | ||
| 262 | /// This causes all incoming frames to be disposed. | ||
| 263 | pub fn clear(&mut self) -> &mut Self { | ||
| 264 | self.banks_imm().clear(); | ||
| 265 | self | ||
| 266 | } | ||
| 267 | |||
| 268 | /// Disables a filter bank. | ||
| 269 | /// | ||
| 270 | /// If `index` is out of bounds, this will panic. | ||
| 271 | pub fn disable_bank(&mut self, index: u8) -> &mut Self { | ||
| 272 | self.banks_imm().disable(index); | ||
| 273 | self | ||
| 274 | } | ||
| 275 | |||
| 276 | /// Configures a filter bank according to `config` and enables it. | ||
| 277 | /// | ||
| 278 | /// Each filter bank is associated with one of the two RX FIFOs, configured by the [`Fifo`] | ||
| 279 | /// passed to this function. In the event that both FIFOs are configured to accept an incoming | ||
| 280 | /// frame, the accepting filter bank with the lowest index wins. The FIFO state is ignored, so | ||
| 281 | /// if the FIFO is full, it will overflow, even if the other FIFO is also configured to accept | ||
| 282 | /// the frame. | ||
| 283 | /// | ||
| 284 | /// # Parameters | ||
| 285 | /// | ||
| 286 | /// - `index`: the filter index. | ||
| 287 | /// - `fifo`: the receive FIFO the filter should pass accepted messages to. | ||
| 288 | /// - `config`: the filter configuration. | ||
| 289 | pub fn enable_bank( | ||
| 290 | &mut self, | ||
| 291 | index: u8, | ||
| 292 | fifo: Fifo, | ||
| 293 | config: impl Into<BankConfig>, | ||
| 294 | ) -> &mut Self { | ||
| 295 | self.banks_imm().enable(index, fifo, config.into()); | ||
| 296 | self | ||
| 297 | } | ||
| 298 | } | ||
| 299 | |||
| 300 | impl<I: MasterInstance> MasterFilters<'_, I> { | ||
| 301 | /// Sets the index at which the filter banks owned by the slave peripheral start. | ||
| 302 | pub fn set_split(&mut self, split_index: u8) -> &mut Self { | ||
| 303 | assert!(split_index <= I::NUM_FILTER_BANKS); | ||
| 304 | self.registers() | ||
| 305 | .fmr | ||
| 306 | .modify(|_, w| unsafe { w.can2sb().bits(split_index) }); | ||
| 307 | self.bank_count = split_index; | ||
| 308 | self | ||
| 309 | } | ||
| 310 | |||
| 311 | /// Accesses the filters assigned to the slave peripheral. | ||
| 312 | pub fn slave_filters(&mut self) -> SlaveFilters<'_, I> { | ||
| 313 | // NB: This mutably borrows `self`, so it has full access to the filter bank registers. | ||
| 314 | SlaveFilters { | ||
| 315 | start_idx: self.bank_count, | ||
| 316 | bank_count: I::NUM_FILTER_BANKS - self.bank_count, | ||
| 317 | _can: PhantomData, | ||
| 318 | } | ||
| 319 | } | ||
| 320 | } | ||
| 321 | |||
| 322 | impl<I: FilterOwner> Drop for MasterFilters<'_, I> { | ||
| 323 | #[inline] | ||
| 324 | fn drop(&mut self) { | ||
| 325 | let can = self.registers(); | ||
| 326 | |||
| 327 | // Leave initialization mode. | ||
| 328 | can.fmr.modify(|_, w| w.finit().clear_bit()); | ||
| 329 | } | ||
| 330 | } | ||
| 331 | |||
| 332 | /// Interface to the filter banks assigned to a slave peripheral. | ||
| 333 | pub struct SlaveFilters<'a, I: Instance> { | ||
| 334 | start_idx: u8, | ||
| 335 | bank_count: u8, | ||
| 336 | _can: PhantomData<&'a mut I>, | ||
| 337 | } | ||
| 338 | |||
| 339 | impl<I: Instance> SlaveFilters<'_, I> { | ||
| 340 | fn registers(&self) -> &RegisterBlock { | ||
| 341 | unsafe { &*I::REGISTERS } | ||
| 342 | } | ||
| 343 | |||
| 344 | fn banks_imm(&self) -> FilterBanks<'_> { | ||
| 345 | FilterBanks { | ||
| 346 | start_idx: self.start_idx, | ||
| 347 | bank_count: self.bank_count, | ||
| 348 | can: self.registers(), | ||
| 349 | } | ||
| 350 | } | ||
| 351 | |||
| 352 | /// Returns the number of filter banks currently assigned to this instance. | ||
| 353 | /// | ||
| 354 | /// Chips with splittable filter banks may start out with some banks assigned to the master | ||
| 355 | /// instance and some assigned to the slave instance. | ||
| 356 | pub fn num_banks(&self) -> u8 { | ||
| 357 | self.bank_count | ||
| 358 | } | ||
| 359 | |||
| 360 | /// Disables all enabled filter banks. | ||
| 361 | /// | ||
| 362 | /// This causes all incoming frames to be disposed. | ||
| 363 | pub fn clear(&mut self) -> &mut Self { | ||
| 364 | self.banks_imm().clear(); | ||
| 365 | self | ||
| 366 | } | ||
| 367 | |||
| 368 | /// Disables a filter bank. | ||
| 369 | /// | ||
| 370 | /// If `index` is out of bounds, this will panic. | ||
| 371 | pub fn disable_bank(&mut self, index: u8) -> &mut Self { | ||
| 372 | self.banks_imm().disable(index); | ||
| 373 | self | ||
| 374 | } | ||
| 375 | |||
| 376 | /// Configures a filter bank according to `config` and enables it. | ||
| 377 | /// | ||
| 378 | /// # Parameters | ||
| 379 | /// | ||
| 380 | /// - `index`: the filter index. | ||
| 381 | /// - `fifo`: the receive FIFO the filter should pass accepted messages to. | ||
| 382 | /// - `config`: the filter configuration. | ||
| 383 | pub fn enable_bank( | ||
| 384 | &mut self, | ||
| 385 | index: u8, | ||
| 386 | fifo: Fifo, | ||
| 387 | config: impl Into<BankConfig>, | ||
| 388 | ) -> &mut Self { | ||
| 389 | self.banks_imm().enable(index, fifo, config.into()); | ||
| 390 | self | ||
| 391 | } | ||
| 392 | } | ||
| 393 | |||
| 394 | struct FilterBanks<'a> { | ||
| 395 | start_idx: u8, | ||
| 396 | bank_count: u8, | ||
| 397 | can: &'a RegisterBlock, | ||
| 398 | } | ||
| 399 | |||
| 400 | impl FilterBanks<'_> { | ||
| 401 | fn clear(&mut self) { | ||
| 402 | let mask = filter_bitmask(self.start_idx, self.bank_count); | ||
| 403 | |||
| 404 | self.can.fa1r.modify(|r, w| { | ||
| 405 | let bits = r.bits(); | ||
| 406 | // Clear all bits in `mask`. | ||
| 407 | unsafe { w.bits(bits & !mask) } | ||
| 408 | }); | ||
| 409 | } | ||
| 410 | |||
| 411 | fn assert_bank_index(&self, index: u8) { | ||
| 412 | assert!((self.start_idx..self.start_idx + self.bank_count).contains(&index)); | ||
| 413 | } | ||
| 414 | |||
| 415 | fn disable(&mut self, index: u8) { | ||
| 416 | self.assert_bank_index(index); | ||
| 417 | |||
| 418 | self.can | ||
| 419 | .fa1r | ||
| 420 | .modify(|r, w| unsafe { w.bits(r.bits() & !(1 << index)) }) | ||
| 421 | } | ||
| 422 | |||
| 423 | fn enable(&mut self, index: u8, fifo: Fifo, config: BankConfig) { | ||
| 424 | self.assert_bank_index(index); | ||
| 425 | |||
| 426 | // Configure mode. | ||
| 427 | let mode = matches!(config, BankConfig::List16(_) | BankConfig::List32(_)); | ||
| 428 | self.can.fm1r.modify(|r, w| { | ||
| 429 | let mut bits = r.bits(); | ||
| 430 | if mode { | ||
| 431 | bits |= 1 << index; | ||
| 432 | } else { | ||
| 433 | bits &= !(1 << index); | ||
| 434 | } | ||
| 435 | unsafe { w.bits(bits) } | ||
| 436 | }); | ||
| 437 | |||
| 438 | // Configure scale. | ||
| 439 | let scale = matches!(config, BankConfig::List32(_) | BankConfig::Mask32(_)); | ||
| 440 | self.can.fs1r.modify(|r, w| { | ||
| 441 | let mut bits = r.bits(); | ||
| 442 | if scale { | ||
| 443 | bits |= 1 << index; | ||
| 444 | } else { | ||
| 445 | bits &= !(1 << index); | ||
| 446 | } | ||
| 447 | unsafe { w.bits(bits) } | ||
| 448 | }); | ||
| 449 | |||
| 450 | // Configure filter register. | ||
| 451 | let (fxr1, fxr2); | ||
| 452 | match config { | ||
| 453 | BankConfig::List16([a, b, c, d]) => { | ||
| 454 | fxr1 = (u32::from(b.0) << 16) | u32::from(a.0); | ||
| 455 | fxr2 = (u32::from(d.0) << 16) | u32::from(c.0); | ||
| 456 | } | ||
| 457 | BankConfig::List32([a, b]) => { | ||
| 458 | fxr1 = a.0; | ||
| 459 | fxr2 = b.0; | ||
| 460 | } | ||
| 461 | BankConfig::Mask16([a, b]) => { | ||
| 462 | fxr1 = (u32::from(a.mask) << 16) | u32::from(a.id); | ||
| 463 | fxr2 = (u32::from(b.mask) << 16) | u32::from(b.id); | ||
| 464 | } | ||
| 465 | BankConfig::Mask32(a) => { | ||
| 466 | fxr1 = a.id; | ||
| 467 | fxr2 = a.mask; | ||
| 468 | } | ||
| 469 | }; | ||
| 470 | let bank = &self.can.fb[usize::from(index)]; | ||
| 471 | bank.fr1.write(|w| unsafe { w.bits(fxr1) }); | ||
| 472 | bank.fr2.write(|w| unsafe { w.bits(fxr2) }); | ||
| 473 | |||
| 474 | // Assign to the right FIFO | ||
| 475 | self.can.ffa1r.modify(|r, w| unsafe { | ||
| 476 | let mut bits = r.bits(); | ||
| 477 | match fifo { | ||
| 478 | Fifo::Fifo0 => bits &= !(1 << index), | ||
| 479 | Fifo::Fifo1 => bits |= 1 << index, | ||
| 480 | } | ||
| 481 | w.bits(bits) | ||
| 482 | }); | ||
| 483 | |||
| 484 | // Set active. | ||
| 485 | self.can | ||
| 486 | .fa1r | ||
| 487 | .modify(|r, w| unsafe { w.bits(r.bits() | (1 << index)) }) | ||
| 488 | } | ||
| 489 | } | ||
| 490 | |||
| 491 | /// Computes a bitmask for per-filter-bank registers that only includes filters in the given range. | ||
| 492 | fn filter_bitmask(start_idx: u8, bank_count: u8) -> u32 { | ||
| 493 | let count_mask = (1 << bank_count) - 1; // `bank_count` 1-bits | ||
| 494 | count_mask << start_idx | ||
| 495 | } | ||
| 496 | |||
| 497 | #[cfg(test)] | ||
| 498 | mod tests { | ||
| 499 | use super::*; | ||
| 500 | |||
| 501 | #[test] | ||
| 502 | fn test_filter_bitmask() { | ||
| 503 | assert_eq!(filter_bitmask(0, 1), 0x1); | ||
| 504 | assert_eq!(filter_bitmask(1, 1), 0b10); | ||
| 505 | assert_eq!(filter_bitmask(0, 4), 0xf); | ||
| 506 | assert_eq!(filter_bitmask(1, 3), 0xe); | ||
| 507 | assert_eq!(filter_bitmask(8, 1), 0x100); | ||
| 508 | assert_eq!(filter_bitmask(8, 4), 0xf00); | ||
| 509 | } | ||
| 510 | } | ||
diff --git a/embassy-stm32/src/can/bx/frame.rs b/embassy-stm32/src/can/bx/frame.rs new file mode 100644 index 000000000..c1089b044 --- /dev/null +++ b/embassy-stm32/src/can/bx/frame.rs | |||
| @@ -0,0 +1,255 @@ | |||
| 1 | #[cfg(test)] | ||
| 2 | mod tests; | ||
| 3 | |||
| 4 | use core::cmp::Ordering; | ||
| 5 | use core::ops::{Deref, DerefMut}; | ||
| 6 | |||
| 7 | use crate::{Id, IdReg}; | ||
| 8 | |||
| 9 | /// A CAN data or remote frame. | ||
| 10 | #[derive(Clone, Debug, Eq)] | ||
| 11 | #[cfg_attr(feature = "unstable-defmt", derive(defmt::Format))] | ||
| 12 | pub struct Frame { | ||
| 13 | pub(crate) id: IdReg, | ||
| 14 | pub(crate) data: Data, | ||
| 15 | } | ||
| 16 | |||
| 17 | impl Frame { | ||
| 18 | /// Creates a new data frame. | ||
| 19 | pub fn new_data(id: impl Into<Id>, data: impl Into<Data>) -> Self { | ||
| 20 | let id = match id.into() { | ||
| 21 | Id::Standard(id) => IdReg::new_standard(id), | ||
| 22 | Id::Extended(id) => IdReg::new_extended(id), | ||
| 23 | }; | ||
| 24 | |||
| 25 | Self { | ||
| 26 | id, | ||
| 27 | data: data.into(), | ||
| 28 | } | ||
| 29 | } | ||
| 30 | |||
| 31 | /// Creates a new remote frame with configurable data length code (DLC). | ||
| 32 | /// | ||
| 33 | /// # Panics | ||
| 34 | /// | ||
| 35 | /// This function will panic if `dlc` is not inside the valid range `0..=8`. | ||
| 36 | pub fn new_remote(id: impl Into<Id>, dlc: u8) -> Self { | ||
| 37 | assert!(dlc <= 8); | ||
| 38 | |||
| 39 | let mut frame = Self::new_data(id, []); | ||
| 40 | // Just extend the data length, even with no data present. The API does not hand out this | ||
| 41 | // `Data` object. | ||
| 42 | frame.data.len = dlc; | ||
| 43 | frame.id = frame.id.with_rtr(true); | ||
| 44 | frame | ||
| 45 | } | ||
| 46 | |||
| 47 | /// Returns true if this frame is an extended frame. | ||
| 48 | #[inline] | ||
| 49 | pub fn is_extended(&self) -> bool { | ||
| 50 | self.id.is_extended() | ||
| 51 | } | ||
| 52 | |||
| 53 | /// Returns true if this frame is a standard frame. | ||
| 54 | #[inline] | ||
| 55 | pub fn is_standard(&self) -> bool { | ||
| 56 | self.id.is_standard() | ||
| 57 | } | ||
| 58 | |||
| 59 | /// Returns true if this frame is a remote frame. | ||
| 60 | #[inline] | ||
| 61 | pub fn is_remote_frame(&self) -> bool { | ||
| 62 | self.id.rtr() | ||
| 63 | } | ||
| 64 | |||
| 65 | /// Returns true if this frame is a data frame. | ||
| 66 | #[inline] | ||
| 67 | pub fn is_data_frame(&self) -> bool { | ||
| 68 | !self.is_remote_frame() | ||
| 69 | } | ||
| 70 | |||
| 71 | /// Returns the frame identifier. | ||
| 72 | #[inline] | ||
| 73 | pub fn id(&self) -> Id { | ||
| 74 | self.id.to_id() | ||
| 75 | } | ||
| 76 | |||
| 77 | /// Returns the priority of this frame. | ||
| 78 | #[inline] | ||
| 79 | pub fn priority(&self) -> FramePriority { | ||
| 80 | FramePriority(self.id) | ||
| 81 | } | ||
| 82 | |||
| 83 | /// Returns the data length code (DLC) which is in the range 0..8. | ||
| 84 | /// | ||
| 85 | /// For data frames the DLC value always matches the length of the data. | ||
| 86 | /// Remote frames do not carry any data, yet the DLC can be greater than 0. | ||
| 87 | #[inline] | ||
| 88 | pub fn dlc(&self) -> u8 { | ||
| 89 | self.data.len() as u8 | ||
| 90 | } | ||
| 91 | |||
| 92 | /// Returns the frame data (0..8 bytes in length) if this is a data frame. | ||
| 93 | /// | ||
| 94 | /// If this is a remote frame, returns `None`. | ||
| 95 | pub fn data(&self) -> Option<&Data> { | ||
| 96 | if self.is_data_frame() { | ||
| 97 | Some(&self.data) | ||
| 98 | } else { | ||
| 99 | None | ||
| 100 | } | ||
| 101 | } | ||
| 102 | } | ||
| 103 | |||
| 104 | impl PartialEq for Frame { | ||
| 105 | fn eq(&self, other: &Self) -> bool { | ||
| 106 | match (self.data(), other.data()) { | ||
| 107 | (None, None) => self.id.eq(&other.id), | ||
| 108 | (Some(a), Some(b)) => self.id.eq(&other.id) && a.eq(b), | ||
| 109 | (None, Some(_)) | (Some(_), None) => false, | ||
| 110 | } | ||
| 111 | } | ||
| 112 | } | ||
| 113 | |||
| 114 | /// Priority of a CAN frame. | ||
| 115 | /// | ||
| 116 | /// Returned by [`Frame::priority`]. | ||
| 117 | /// | ||
| 118 | /// The priority of a frame is determined by the bits that are part of the *arbitration field*. | ||
| 119 | /// These consist of the frame identifier bits (including the *IDE* bit, which is 0 for extended | ||
| 120 | /// frames and 1 for standard frames), as well as the *RTR* bit, which determines whether a frame | ||
| 121 | /// is a data or remote frame. Lower values of the *arbitration field* have higher priority. | ||
| 122 | /// | ||
| 123 | /// This struct wraps the *arbitration field* and implements `PartialOrd` and `Ord` accordingly, | ||
| 124 | /// ordering higher priorities greater than lower ones. | ||
| 125 | #[derive(Debug, Copy, Clone)] | ||
| 126 | pub struct FramePriority(IdReg); | ||
| 127 | |||
| 128 | /// Ordering is based on the Identifier and frame type (data vs. remote) and can be used to sort | ||
| 129 | /// frames by priority. | ||
| 130 | impl Ord for FramePriority { | ||
| 131 | fn cmp(&self, other: &Self) -> Ordering { | ||
| 132 | self.0.cmp(&other.0) | ||
| 133 | } | ||
| 134 | } | ||
| 135 | |||
| 136 | impl PartialOrd for FramePriority { | ||
| 137 | fn partial_cmp(&self, other: &Self) -> Option<Ordering> { | ||
| 138 | Some(self.cmp(other)) | ||
| 139 | } | ||
| 140 | } | ||
| 141 | |||
| 142 | impl PartialEq for FramePriority { | ||
| 143 | fn eq(&self, other: &Self) -> bool { | ||
| 144 | self.cmp(other) == Ordering::Equal | ||
| 145 | } | ||
| 146 | } | ||
| 147 | |||
| 148 | impl Eq for FramePriority {} | ||
| 149 | |||
| 150 | /// Payload of a CAN data frame. | ||
| 151 | /// | ||
| 152 | /// Contains 0 to 8 Bytes of data. | ||
| 153 | /// | ||
| 154 | /// `Data` implements `From<[u8; N]>` for all `N` up to 8, which provides a convenient lossless | ||
| 155 | /// conversion from fixed-length arrays. | ||
| 156 | #[derive(Debug, Copy, Clone)] | ||
| 157 | pub struct Data { | ||
| 158 | pub(crate) len: u8, | ||
| 159 | pub(crate) bytes: [u8; 8], | ||
| 160 | } | ||
| 161 | |||
| 162 | impl Data { | ||
| 163 | /// Creates a data payload from a raw byte slice. | ||
| 164 | /// | ||
| 165 | /// Returns `None` if `data` contains more than 8 Bytes (which is the maximum). | ||
| 166 | /// | ||
| 167 | /// `Data` can also be constructed from fixed-length arrays up to length 8 via `From`/`Into`. | ||
| 168 | pub fn new(data: &[u8]) -> Option<Self> { | ||
| 169 | if data.len() > 8 { | ||
| 170 | return None; | ||
| 171 | } | ||
| 172 | |||
| 173 | let mut bytes = [0; 8]; | ||
| 174 | bytes[..data.len()].copy_from_slice(data); | ||
| 175 | |||
| 176 | Some(Self { | ||
| 177 | len: data.len() as u8, | ||
| 178 | bytes, | ||
| 179 | }) | ||
| 180 | } | ||
| 181 | |||
| 182 | /// Creates an empty data payload containing 0 bytes. | ||
| 183 | #[inline] | ||
| 184 | pub const fn empty() -> Self { | ||
| 185 | Self { | ||
| 186 | len: 0, | ||
| 187 | bytes: [0; 8], | ||
| 188 | } | ||
| 189 | } | ||
| 190 | } | ||
| 191 | |||
| 192 | impl Deref for Data { | ||
| 193 | type Target = [u8]; | ||
| 194 | |||
| 195 | #[inline] | ||
| 196 | fn deref(&self) -> &[u8] { | ||
| 197 | &self.bytes[..usize::from(self.len)] | ||
| 198 | } | ||
| 199 | } | ||
| 200 | |||
| 201 | impl DerefMut for Data { | ||
| 202 | #[inline] | ||
| 203 | fn deref_mut(&mut self) -> &mut [u8] { | ||
| 204 | &mut self.bytes[..usize::from(self.len)] | ||
| 205 | } | ||
| 206 | } | ||
| 207 | |||
| 208 | impl AsRef<[u8]> for Data { | ||
| 209 | #[inline] | ||
| 210 | fn as_ref(&self) -> &[u8] { | ||
| 211 | self.deref() | ||
| 212 | } | ||
| 213 | } | ||
| 214 | |||
| 215 | impl AsMut<[u8]> for Data { | ||
| 216 | #[inline] | ||
| 217 | fn as_mut(&mut self) -> &mut [u8] { | ||
| 218 | self.deref_mut() | ||
| 219 | } | ||
| 220 | } | ||
| 221 | |||
| 222 | impl PartialEq for Data { | ||
| 223 | fn eq(&self, other: &Self) -> bool { | ||
| 224 | self.as_ref() == other.as_ref() | ||
| 225 | } | ||
| 226 | } | ||
| 227 | |||
| 228 | impl Eq for Data {} | ||
| 229 | |||
| 230 | #[cfg(feature = "unstable-defmt")] | ||
| 231 | impl defmt::Format for Data { | ||
| 232 | fn format(&self, fmt: defmt::Formatter<'_>) { | ||
| 233 | self.as_ref().format(fmt) | ||
| 234 | } | ||
| 235 | } | ||
| 236 | |||
| 237 | macro_rules! data_from_array { | ||
| 238 | ( $($len:literal),+ ) => { | ||
| 239 | $( | ||
| 240 | impl From<[u8; $len]> for Data { | ||
| 241 | #[inline] | ||
| 242 | fn from(arr: [u8; $len]) -> Self { | ||
| 243 | let mut bytes = [0; 8]; | ||
| 244 | bytes[..$len].copy_from_slice(&arr); | ||
| 245 | Self { | ||
| 246 | len: $len, | ||
| 247 | bytes, | ||
| 248 | } | ||
| 249 | } | ||
| 250 | } | ||
| 251 | )+ | ||
| 252 | }; | ||
| 253 | } | ||
| 254 | |||
| 255 | data_from_array!(0, 1, 2, 3, 4, 5, 6, 7, 8); | ||
diff --git a/embassy-stm32/src/can/bx/id.rs b/embassy-stm32/src/can/bx/id.rs new file mode 100644 index 000000000..9fdcd8319 --- /dev/null +++ b/embassy-stm32/src/can/bx/id.rs | |||
| @@ -0,0 +1,113 @@ | |||
| 1 | //! CAN Identifiers. | ||
| 2 | |||
| 3 | /// Standard 11-bit CAN Identifier (`0..=0x7FF`). | ||
| 4 | #[derive(Debug, Copy, Clone, Eq, PartialEq)] | ||
| 5 | pub struct StandardId(u16); | ||
| 6 | |||
| 7 | impl StandardId { | ||
| 8 | /// CAN ID `0`, the highest priority. | ||
| 9 | pub const ZERO: Self = Self(0); | ||
| 10 | |||
| 11 | /// CAN ID `0x7FF`, the lowest priority. | ||
| 12 | pub const MAX: Self = Self(0x7FF); | ||
| 13 | |||
| 14 | /// Tries to create a `StandardId` from a raw 16-bit integer. | ||
| 15 | /// | ||
| 16 | /// This will return `None` if `raw` is out of range of an 11-bit integer (`> 0x7FF`). | ||
| 17 | #[inline] | ||
| 18 | pub const fn new(raw: u16) -> Option<Self> { | ||
| 19 | if raw <= 0x7FF { | ||
| 20 | Some(Self(raw)) | ||
| 21 | } else { | ||
| 22 | None | ||
| 23 | } | ||
| 24 | } | ||
| 25 | |||
| 26 | /// Creates a new `StandardId` without checking if it is inside the valid range. | ||
| 27 | /// | ||
| 28 | /// # Safety | ||
| 29 | /// | ||
| 30 | /// The caller must ensure that `raw` is in the valid range, otherwise the behavior is | ||
| 31 | /// undefined. | ||
| 32 | #[inline] | ||
| 33 | pub const unsafe fn new_unchecked(raw: u16) -> Self { | ||
| 34 | Self(raw) | ||
| 35 | } | ||
| 36 | |||
| 37 | /// Returns this CAN Identifier as a raw 16-bit integer. | ||
| 38 | #[inline] | ||
| 39 | pub fn as_raw(&self) -> u16 { | ||
| 40 | self.0 | ||
| 41 | } | ||
| 42 | } | ||
| 43 | |||
| 44 | /// Extended 29-bit CAN Identifier (`0..=1FFF_FFFF`). | ||
| 45 | #[derive(Debug, Copy, Clone, Eq, PartialEq)] | ||
| 46 | pub struct ExtendedId(u32); | ||
| 47 | |||
| 48 | impl ExtendedId { | ||
| 49 | /// CAN ID `0`, the highest priority. | ||
| 50 | pub const ZERO: Self = Self(0); | ||
| 51 | |||
| 52 | /// CAN ID `0x1FFFFFFF`, the lowest priority. | ||
| 53 | pub const MAX: Self = Self(0x1FFF_FFFF); | ||
| 54 | |||
| 55 | /// Tries to create a `ExtendedId` from a raw 32-bit integer. | ||
| 56 | /// | ||
| 57 | /// This will return `None` if `raw` is out of range of an 29-bit integer (`> 0x1FFF_FFFF`). | ||
| 58 | #[inline] | ||
| 59 | pub const fn new(raw: u32) -> Option<Self> { | ||
| 60 | if raw <= 0x1FFF_FFFF { | ||
| 61 | Some(Self(raw)) | ||
| 62 | } else { | ||
| 63 | None | ||
| 64 | } | ||
| 65 | } | ||
| 66 | |||
| 67 | /// Creates a new `ExtendedId` without checking if it is inside the valid range. | ||
| 68 | /// | ||
| 69 | /// # Safety | ||
| 70 | /// | ||
| 71 | /// The caller must ensure that `raw` is in the valid range, otherwise the behavior is | ||
| 72 | /// undefined. | ||
| 73 | #[inline] | ||
| 74 | pub const unsafe fn new_unchecked(raw: u32) -> Self { | ||
| 75 | Self(raw) | ||
| 76 | } | ||
| 77 | |||
| 78 | /// Returns this CAN Identifier as a raw 32-bit integer. | ||
| 79 | #[inline] | ||
| 80 | pub fn as_raw(&self) -> u32 { | ||
| 81 | self.0 | ||
| 82 | } | ||
| 83 | |||
| 84 | /// Returns the Base ID part of this extended identifier. | ||
| 85 | pub fn standard_id(&self) -> StandardId { | ||
| 86 | // ID-28 to ID-18 | ||
| 87 | StandardId((self.0 >> 18) as u16) | ||
| 88 | } | ||
| 89 | } | ||
| 90 | |||
| 91 | /// A CAN Identifier (standard or extended). | ||
| 92 | #[derive(Debug, Copy, Clone, Eq, PartialEq)] | ||
| 93 | pub enum Id { | ||
| 94 | /// Standard 11-bit Identifier (`0..=0x7FF`). | ||
| 95 | Standard(StandardId), | ||
| 96 | |||
| 97 | /// Extended 29-bit Identifier (`0..=0x1FFF_FFFF`). | ||
| 98 | Extended(ExtendedId), | ||
| 99 | } | ||
| 100 | |||
| 101 | impl From<StandardId> for Id { | ||
| 102 | #[inline] | ||
| 103 | fn from(id: StandardId) -> Self { | ||
| 104 | Id::Standard(id) | ||
| 105 | } | ||
| 106 | } | ||
| 107 | |||
| 108 | impl From<ExtendedId> for Id { | ||
| 109 | #[inline] | ||
| 110 | fn from(id: ExtendedId) -> Self { | ||
| 111 | Id::Extended(id) | ||
| 112 | } | ||
| 113 | } | ||
diff --git a/embassy-stm32/src/can/bx/interrupt.rs b/embassy-stm32/src/can/bx/interrupt.rs new file mode 100644 index 000000000..17aacf8e0 --- /dev/null +++ b/embassy-stm32/src/can/bx/interrupt.rs | |||
| @@ -0,0 +1,130 @@ | |||
| 1 | //! Interrupt types. | ||
| 2 | |||
| 3 | use core::ops; | ||
| 4 | |||
| 5 | #[allow(unused_imports)] // for intra-doc links only | ||
| 6 | use crate::{Can, Rx0}; | ||
| 7 | |||
| 8 | /// bxCAN interrupt sources. | ||
| 9 | /// | ||
| 10 | /// These can be individually enabled and disabled in the bxCAN peripheral. Note that the bxCAN | ||
| 11 | /// peripheral only exposes 4 interrupts to the microcontroller: | ||
| 12 | /// | ||
| 13 | /// * TX | ||
| 14 | /// * RX FIFO 1 | ||
| 15 | /// * RX FIFO 2 | ||
| 16 | /// * SCE (Status Change Error) | ||
| 17 | /// | ||
| 18 | /// This means that some of the interrupts listed here will result in the same interrupt handler | ||
| 19 | /// being invoked. | ||
| 20 | #[derive(Debug, Copy, Clone, Eq, PartialEq)] | ||
| 21 | #[cfg_attr(feature = "unstable-defmt", derive(defmt::Format))] | ||
| 22 | #[non_exhaustive] | ||
| 23 | pub enum Interrupt { | ||
| 24 | /// Fires the **TX** interrupt when one of the transmit mailboxes returns to empty state. | ||
| 25 | /// | ||
| 26 | /// This usually happens because its message was either transmitted successfully, or | ||
| 27 | /// transmission was aborted successfully. | ||
| 28 | /// | ||
| 29 | /// The interrupt handler must clear the interrupt condition by calling | ||
| 30 | /// [`Can::clear_request_completed_flag`] or [`Can::clear_tx_interrupt`]. | ||
| 31 | TransmitMailboxEmpty = 1 << 0, | ||
| 32 | |||
| 33 | /// Fires the **RX FIFO 0** interrupt when FIFO 0 holds a message. | ||
| 34 | /// | ||
| 35 | /// The interrupt handler must clear the interrupt condition by receiving all messages from the | ||
| 36 | /// FIFO by calling [`Can::receive`] or [`Rx0::receive`]. | ||
| 37 | Fifo0MessagePending = 1 << 1, | ||
| 38 | |||
| 39 | /// Fires the **RX FIFO 0** interrupt when FIFO 0 holds 3 incoming messages. | ||
| 40 | /// | ||
| 41 | /// The interrupt handler must clear the interrupt condition by receiving at least one message | ||
| 42 | /// from the FIFO (making it no longer "full"). This can be done by calling [`Can::receive`] or | ||
| 43 | /// [`Rx0::receive`]. | ||
| 44 | Fifo0Full = 1 << 2, | ||
| 45 | |||
| 46 | /// Fires the **RX FIFO 0** interrupt when FIFO 0 drops an incoming message. | ||
| 47 | /// | ||
| 48 | /// The interrupt handler must clear the interrupt condition by calling [`Can::receive`] or | ||
| 49 | /// [`Rx0::receive`] (which will return an error). | ||
| 50 | Fifo0Overrun = 1 << 3, | ||
| 51 | |||
| 52 | /// Fires the **RX FIFO 1** interrupt when FIFO 1 holds a message. | ||
| 53 | /// | ||
| 54 | /// Behavior is otherwise identical to [`Self::Fifo0MessagePending`]. | ||
| 55 | Fifo1MessagePending = 1 << 4, | ||
| 56 | |||
| 57 | /// Fires the **RX FIFO 1** interrupt when FIFO 1 holds 3 incoming messages. | ||
| 58 | /// | ||
| 59 | /// Behavior is otherwise identical to [`Self::Fifo0Full`]. | ||
| 60 | Fifo1Full = 1 << 5, | ||
| 61 | |||
| 62 | /// Fires the **RX FIFO 1** interrupt when FIFO 1 drops an incoming message. | ||
| 63 | /// | ||
| 64 | /// Behavior is otherwise identical to [`Self::Fifo0Overrun`]. | ||
| 65 | Fifo1Overrun = 1 << 6, | ||
| 66 | |||
| 67 | Error = 1 << 15, | ||
| 68 | |||
| 69 | /// Fires the **SCE** interrupt when an incoming CAN frame is detected while the peripheral is | ||
| 70 | /// in sleep mode. | ||
| 71 | /// | ||
| 72 | /// The interrupt handler must clear the interrupt condition by calling | ||
| 73 | /// [`Can::clear_wakeup_interrupt`]. | ||
| 74 | Wakeup = 1 << 16, | ||
| 75 | |||
| 76 | /// Fires the **SCE** interrupt when the peripheral enters sleep mode. | ||
| 77 | /// | ||
| 78 | /// The interrupt handler must clear the interrupt condition by calling | ||
| 79 | /// [`Can::clear_sleep_interrupt`]. | ||
| 80 | Sleep = 1 << 17, | ||
| 81 | } | ||
| 82 | |||
| 83 | bitflags::bitflags! { | ||
| 84 | /// A set of bxCAN interrupts. | ||
| 85 | pub struct Interrupts: u32 { | ||
| 86 | const TRANSMIT_MAILBOX_EMPTY = 1 << 0; | ||
| 87 | const FIFO0_MESSAGE_PENDING = 1 << 1; | ||
| 88 | const FIFO0_FULL = 1 << 2; | ||
| 89 | const FIFO0_OVERRUN = 1 << 3; | ||
| 90 | const FIFO1_MESSAGE_PENDING = 1 << 4; | ||
| 91 | const FIFO1_FULL = 1 << 5; | ||
| 92 | const FIFO1_OVERRUN = 1 << 6; | ||
| 93 | const ERROR = 1 << 15; | ||
| 94 | const WAKEUP = 1 << 16; | ||
| 95 | const SLEEP = 1 << 17; | ||
| 96 | } | ||
| 97 | } | ||
| 98 | |||
| 99 | impl From<Interrupt> for Interrupts { | ||
| 100 | #[inline] | ||
| 101 | fn from(i: Interrupt) -> Self { | ||
| 102 | Self::from_bits_truncate(i as u32) | ||
| 103 | } | ||
| 104 | } | ||
| 105 | |||
| 106 | /// Adds an interrupt to the interrupt set. | ||
| 107 | impl ops::BitOrAssign<Interrupt> for Interrupts { | ||
| 108 | #[inline] | ||
| 109 | fn bitor_assign(&mut self, rhs: Interrupt) { | ||
| 110 | *self |= Self::from(rhs); | ||
| 111 | } | ||
| 112 | } | ||
| 113 | |||
| 114 | #[cfg(test)] | ||
| 115 | mod tests { | ||
| 116 | use super::*; | ||
| 117 | |||
| 118 | #[test] | ||
| 119 | fn interrupt_flags() { | ||
| 120 | assert_eq!(Interrupts::from(Interrupt::Sleep), Interrupts::SLEEP); | ||
| 121 | assert_eq!( | ||
| 122 | Interrupts::from(Interrupt::TransmitMailboxEmpty), | ||
| 123 | Interrupts::TRANSMIT_MAILBOX_EMPTY | ||
| 124 | ); | ||
| 125 | |||
| 126 | let mut ints = Interrupts::FIFO0_FULL; | ||
| 127 | ints |= Interrupt::Fifo1Full; | ||
| 128 | assert_eq!(ints, Interrupts::FIFO0_FULL | Interrupts::FIFO1_FULL); | ||
| 129 | } | ||
| 130 | } | ||
diff --git a/embassy-stm32/src/can/bx/mod.rs b/embassy-stm32/src/can/bx/mod.rs new file mode 100644 index 000000000..3cfc09c85 --- /dev/null +++ b/embassy-stm32/src/can/bx/mod.rs | |||
| @@ -0,0 +1,1100 @@ | |||
| 1 | //! Driver for the STM32 bxCAN peripheral. | ||
| 2 | //! | ||
| 3 | //! This crate provides a reusable driver for the bxCAN peripheral found in many low- to middle-end | ||
| 4 | //! STM32 microcontrollers. HALs for compatible chips can reexport this crate and implement its | ||
| 5 | //! traits to easily expose a featureful CAN driver. | ||
| 6 | //! | ||
| 7 | //! # Features | ||
| 8 | //! | ||
| 9 | //! - Supports both single- and dual-peripheral configurations (where one bxCAN instance manages the | ||
| 10 | //! filters of a secondary instance). | ||
| 11 | //! - Handles standard and extended frames, and data and remote frames. | ||
| 12 | //! - Support for interrupts emitted by the bxCAN peripheral. | ||
| 13 | //! - Transmission respects CAN IDs and protects against priority inversion (a lower-priority frame | ||
| 14 | //! may be dequeued when enqueueing a higher-priority one). | ||
| 15 | //! - Implements the [`embedded-hal`] traits for interoperability. | ||
| 16 | //! - Support for both RX FIFOs (as [`Rx0`] and [`Rx1`]). | ||
| 17 | //! | ||
| 18 | //! # Limitations | ||
| 19 | //! | ||
| 20 | //! - Support for querying error states and handling error interrupts is incomplete. | ||
| 21 | //! | ||
| 22 | //! # Cargo Features | ||
| 23 | //! | ||
| 24 | //! | Feature | Description | | ||
| 25 | //! |---------|-------------| | ||
| 26 | //! | `unstable-defmt` | Implements [`defmt`]'s `Format` trait for the types in this crate.[^1] | | ||
| 27 | //! | ||
| 28 | //! [^1]: The specific version of defmt is unspecified and may be updated in a patch release. | ||
| 29 | //! | ||
| 30 | //! [`defmt`]: https://docs.rs/defmt | ||
| 31 | //! [`embedded-hal`]: https://docs.rs/embedded-hal | ||
| 32 | |||
| 33 | #![doc(html_root_url = "https://docs.rs/bxcan/0.7.0")] | ||
| 34 | // Deny a few warnings in doctests, since rustdoc `allow`s many warnings by default | ||
| 35 | #![doc(test(attr(deny(unused_imports, unused_must_use))))] | ||
| 36 | #![no_std] | ||
| 37 | #![allow(clippy::unnecessary_operation)] // lint is bugged | ||
| 38 | |||
| 39 | mod embedded_hal; | ||
| 40 | pub mod filter; | ||
| 41 | mod frame; | ||
| 42 | mod id; | ||
| 43 | mod interrupt; | ||
| 44 | |||
| 45 | #[allow(clippy::all)] // generated code | ||
| 46 | mod pac; | ||
| 47 | |||
| 48 | pub use id::{ExtendedId, Id, StandardId}; | ||
| 49 | |||
| 50 | pub use crate::frame::{Data, Frame, FramePriority}; | ||
| 51 | pub use crate::interrupt::{Interrupt, Interrupts}; | ||
| 52 | pub use crate::pac::can::RegisterBlock; | ||
| 53 | |||
| 54 | use crate::filter::MasterFilters; | ||
| 55 | use core::cmp::{Ord, Ordering}; | ||
| 56 | use core::convert::{Infallible, TryInto}; | ||
| 57 | use core::marker::PhantomData; | ||
| 58 | use core::mem; | ||
| 59 | use core::ptr::NonNull; | ||
| 60 | |||
| 61 | use self::pac::generic::*; // To make the PAC extraction build | ||
| 62 | |||
| 63 | /// A bxCAN peripheral instance. | ||
| 64 | /// | ||
| 65 | /// This trait is meant to be implemented for a HAL-specific type that represent ownership of | ||
| 66 | /// the CAN peripheral (and any pins required by it, although that is entirely up to the HAL). | ||
| 67 | /// | ||
| 68 | /// # Safety | ||
| 69 | /// | ||
| 70 | /// It is only safe to implement this trait, when: | ||
| 71 | /// | ||
| 72 | /// * The implementing type has ownership of the peripheral, preventing any other accesses to the | ||
| 73 | /// register block. | ||
| 74 | /// * `REGISTERS` is a pointer to that peripheral's register block and can be safely accessed for as | ||
| 75 | /// long as ownership or a borrow of the implementing type is present. | ||
| 76 | pub unsafe trait Instance { | ||
| 77 | /// Pointer to the instance's register block. | ||
| 78 | const REGISTERS: *mut RegisterBlock; | ||
| 79 | } | ||
| 80 | |||
| 81 | /// A bxCAN instance that owns filter banks. | ||
| 82 | /// | ||
| 83 | /// In master-slave-instance setups, only the master instance owns the filter banks, and needs to | ||
| 84 | /// split some of them off for use by the slave instance. In that case, the master instance should | ||
| 85 | /// implement [`FilterOwner`] and [`MasterInstance`], while the slave instance should only implement | ||
| 86 | /// [`Instance`]. | ||
| 87 | /// | ||
| 88 | /// In single-instance configurations, the instance owns all filter banks and they can not be split | ||
| 89 | /// off. In that case, the instance should implement [`Instance`] and [`FilterOwner`]. | ||
| 90 | /// | ||
| 91 | /// # Safety | ||
| 92 | /// | ||
| 93 | /// This trait must only be implemented if the instance does, in fact, own its associated filter | ||
| 94 | /// banks, and `NUM_FILTER_BANKS` must be correct. | ||
| 95 | pub unsafe trait FilterOwner: Instance { | ||
| 96 | /// The total number of filter banks available to the instance. | ||
| 97 | /// | ||
| 98 | /// This is usually either 14 or 28, and should be specified in the chip's reference manual or | ||
| 99 | /// datasheet. | ||
| 100 | const NUM_FILTER_BANKS: u8; | ||
| 101 | } | ||
| 102 | |||
| 103 | /// A bxCAN master instance that shares filter banks with a slave instance. | ||
| 104 | /// | ||
| 105 | /// In master-slave-instance setups, this trait should be implemented for the master instance. | ||
| 106 | /// | ||
| 107 | /// # Safety | ||
| 108 | /// | ||
| 109 | /// This trait must only be implemented when there is actually an associated slave instance. | ||
| 110 | pub unsafe trait MasterInstance: FilterOwner {} | ||
| 111 | |||
| 112 | // TODO: what to do with these? | ||
| 113 | /* | ||
| 114 | #[derive(Debug, Copy, Clone, Eq, PartialEq, Format)] | ||
| 115 | pub enum Error { | ||
| 116 | Stuff, | ||
| 117 | Form, | ||
| 118 | Acknowledgement, | ||
| 119 | BitRecessive, | ||
| 120 | BitDominant, | ||
| 121 | Crc, | ||
| 122 | Software, | ||
| 123 | }*/ | ||
| 124 | |||
| 125 | /// Error that indicates that an incoming message has been lost due to buffer overrun. | ||
| 126 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] | ||
| 127 | #[cfg_attr(feature = "unstable-defmt", derive(defmt::Format))] | ||
| 128 | pub struct OverrunError { | ||
| 129 | _priv: (), | ||
| 130 | } | ||
| 131 | |||
| 132 | /// Identifier of a CAN message. | ||
| 133 | /// | ||
| 134 | /// Can be either a standard identifier (11bit, Range: 0..0x3FF) or a | ||
| 135 | /// extendended identifier (29bit , Range: 0..0x1FFFFFFF). | ||
| 136 | /// | ||
| 137 | /// The `Ord` trait can be used to determine the frame’s priority this ID | ||
| 138 | /// belongs to. | ||
| 139 | /// Lower identifier values have a higher priority. Additionally standard frames | ||
| 140 | /// have a higher priority than extended frames and data frames have a higher | ||
| 141 | /// priority than remote frames. | ||
| 142 | #[derive(Clone, Copy, Debug, PartialEq, Eq)] | ||
| 143 | #[cfg_attr(feature = "unstable-defmt", derive(defmt::Format))] | ||
| 144 | struct IdReg(u32); | ||
| 145 | |||
| 146 | impl IdReg { | ||
| 147 | const STANDARD_SHIFT: u32 = 21; | ||
| 148 | |||
| 149 | const EXTENDED_SHIFT: u32 = 3; | ||
| 150 | |||
| 151 | const IDE_MASK: u32 = 0x0000_0004; | ||
| 152 | |||
| 153 | const RTR_MASK: u32 = 0x0000_0002; | ||
| 154 | |||
| 155 | /// Creates a new standard identifier (11bit, Range: 0..0x7FF) | ||
| 156 | /// | ||
| 157 | /// Panics for IDs outside the allowed range. | ||
| 158 | fn new_standard(id: StandardId) -> Self { | ||
| 159 | Self(u32::from(id.as_raw()) << Self::STANDARD_SHIFT) | ||
| 160 | } | ||
| 161 | |||
| 162 | /// Creates a new extendended identifier (29bit , Range: 0..0x1FFFFFFF). | ||
| 163 | /// | ||
| 164 | /// Panics for IDs outside the allowed range. | ||
| 165 | fn new_extended(id: ExtendedId) -> IdReg { | ||
| 166 | Self(id.as_raw() << Self::EXTENDED_SHIFT | Self::IDE_MASK) | ||
| 167 | } | ||
| 168 | |||
| 169 | fn from_register(reg: u32) -> IdReg { | ||
| 170 | Self(reg & 0xFFFF_FFFE) | ||
| 171 | } | ||
| 172 | |||
| 173 | /// Sets the remote transmission (RTR) flag. This marks the identifier as | ||
| 174 | /// being part of a remote frame. | ||
| 175 | #[must_use = "returns a new IdReg without modifying `self`"] | ||
| 176 | fn with_rtr(self, rtr: bool) -> IdReg { | ||
| 177 | if rtr { | ||
| 178 | Self(self.0 | Self::RTR_MASK) | ||
| 179 | } else { | ||
| 180 | Self(self.0 & !Self::RTR_MASK) | ||
| 181 | } | ||
| 182 | } | ||
| 183 | |||
| 184 | /// Returns the identifier. | ||
| 185 | fn to_id(self) -> Id { | ||
| 186 | if self.is_extended() { | ||
| 187 | Id::Extended(unsafe { ExtendedId::new_unchecked(self.0 >> Self::EXTENDED_SHIFT) }) | ||
| 188 | } else { | ||
| 189 | Id::Standard(unsafe { | ||
| 190 | StandardId::new_unchecked((self.0 >> Self::STANDARD_SHIFT) as u16) | ||
| 191 | }) | ||
| 192 | } | ||
| 193 | } | ||
| 194 | |||
| 195 | /// Returns `true` if the identifier is an extended identifier. | ||
| 196 | fn is_extended(self) -> bool { | ||
| 197 | self.0 & Self::IDE_MASK != 0 | ||
| 198 | } | ||
| 199 | |||
| 200 | /// Returns `true` if the identifier is a standard identifier. | ||
| 201 | fn is_standard(self) -> bool { | ||
| 202 | !self.is_extended() | ||
| 203 | } | ||
| 204 | |||
| 205 | /// Returns `true` if the identifer is part of a remote frame (RTR bit set). | ||
| 206 | fn rtr(self) -> bool { | ||
| 207 | self.0 & Self::RTR_MASK != 0 | ||
| 208 | } | ||
| 209 | } | ||
| 210 | |||
| 211 | /// `IdReg` is ordered by priority. | ||
| 212 | impl Ord for IdReg { | ||
| 213 | fn cmp(&self, other: &Self) -> Ordering { | ||
| 214 | // When the IDs match, data frames have priority over remote frames. | ||
| 215 | let rtr = self.rtr().cmp(&other.rtr()).reverse(); | ||
| 216 | |||
| 217 | let id_a = self.to_id(); | ||
| 218 | let id_b = other.to_id(); | ||
| 219 | match (id_a, id_b) { | ||
| 220 | (Id::Standard(a), Id::Standard(b)) => { | ||
| 221 | // Lower IDs have priority over higher IDs. | ||
| 222 | a.as_raw().cmp(&b.as_raw()).reverse().then(rtr) | ||
| 223 | } | ||
| 224 | (Id::Extended(a), Id::Extended(b)) => a.as_raw().cmp(&b.as_raw()).reverse().then(rtr), | ||
| 225 | (Id::Standard(a), Id::Extended(b)) => { | ||
| 226 | // Standard frames have priority over extended frames if their Base IDs match. | ||
| 227 | a.as_raw() | ||
| 228 | .cmp(&b.standard_id().as_raw()) | ||
| 229 | .reverse() | ||
| 230 | .then(Ordering::Greater) | ||
| 231 | } | ||
| 232 | (Id::Extended(a), Id::Standard(b)) => a | ||
| 233 | .standard_id() | ||
| 234 | .as_raw() | ||
| 235 | .cmp(&b.as_raw()) | ||
| 236 | .reverse() | ||
| 237 | .then(Ordering::Less), | ||
| 238 | } | ||
| 239 | } | ||
| 240 | } | ||
| 241 | |||
| 242 | impl PartialOrd for IdReg { | ||
| 243 | fn partial_cmp(&self, other: &Self) -> Option<Ordering> { | ||
| 244 | Some(self.cmp(other)) | ||
| 245 | } | ||
| 246 | } | ||
| 247 | |||
| 248 | /// Configuration proxy returned by [`Can::modify_config`]. | ||
| 249 | #[must_use = "`CanConfig` leaves the peripheral in uninitialized state, call `CanConfig::enable` or explicitly drop the value"] | ||
| 250 | pub struct CanConfig<'a, I: Instance> { | ||
| 251 | can: &'a mut Can<I>, | ||
| 252 | } | ||
| 253 | |||
| 254 | impl<I: Instance> CanConfig<'_, I> { | ||
| 255 | /// Configures the bit timings. | ||
| 256 | /// | ||
| 257 | /// You can use <http://www.bittiming.can-wiki.info/> to calculate the `btr` parameter. Enter | ||
| 258 | /// parameters as follows: | ||
| 259 | /// | ||
| 260 | /// - *Clock Rate*: The input clock speed to the CAN peripheral (*not* the CPU clock speed). | ||
| 261 | /// This is the clock rate of the peripheral bus the CAN peripheral is attached to (eg. APB1). | ||
| 262 | /// - *Sample Point*: Should normally be left at the default value of 87.5%. | ||
| 263 | /// - *SJW*: Should normally be left at the default value of 1. | ||
| 264 | /// | ||
| 265 | /// Then copy the `CAN_BUS_TIME` register value from the table and pass it as the `btr` | ||
| 266 | /// parameter to this method. | ||
| 267 | pub fn set_bit_timing(self, btr: u32) -> Self { | ||
| 268 | self.can.set_bit_timing(btr); | ||
| 269 | self | ||
| 270 | } | ||
| 271 | |||
| 272 | /// Enables or disables loopback mode: Internally connects the TX and RX | ||
| 273 | /// signals together. | ||
| 274 | pub fn set_loopback(self, enabled: bool) -> Self { | ||
| 275 | let can = self.can.registers(); | ||
| 276 | can.btr.modify(|_, w| w.lbkm().bit(enabled)); | ||
| 277 | self | ||
| 278 | } | ||
| 279 | |||
| 280 | /// Enables or disables silent mode: Disconnects the TX signal from the pin. | ||
| 281 | pub fn set_silent(self, enabled: bool) -> Self { | ||
| 282 | let can = self.can.registers(); | ||
| 283 | can.btr.modify(|_, w| w.silm().bit(enabled)); | ||
| 284 | self | ||
| 285 | } | ||
| 286 | |||
| 287 | /// Enables or disables automatic retransmission of messages. | ||
| 288 | /// | ||
| 289 | /// If this is enabled, the CAN peripheral will automatically try to retransmit each frame | ||
| 290 | /// until it can be sent. Otherwise, it will try only once to send each frame. | ||
| 291 | /// | ||
| 292 | /// Automatic retransmission is enabled by default. | ||
| 293 | pub fn set_automatic_retransmit(self, enabled: bool) -> Self { | ||
| 294 | let can = self.can.registers(); | ||
| 295 | can.mcr.modify(|_, w| w.nart().bit(!enabled)); | ||
| 296 | self | ||
| 297 | } | ||
| 298 | |||
| 299 | /// Leaves initialization mode and enables the peripheral. | ||
| 300 | /// | ||
| 301 | /// To sync with the CAN bus, this will block until 11 consecutive recessive bits are detected | ||
| 302 | /// on the bus. | ||
| 303 | /// | ||
| 304 | /// If you want to finish configuration without enabling the peripheral, you can call | ||
| 305 | /// [`CanConfig::leave_disabled`] or [`drop`] the [`CanConfig`] instead. | ||
| 306 | pub fn enable(mut self) { | ||
| 307 | self.leave_init_mode(); | ||
| 308 | |||
| 309 | match nb::block!(self.can.enable_non_blocking()) { | ||
| 310 | Ok(()) => {} | ||
| 311 | Err(void) => match void {}, | ||
| 312 | } | ||
| 313 | |||
| 314 | // Don't run the destructor. | ||
| 315 | mem::forget(self); | ||
| 316 | } | ||
| 317 | |||
| 318 | /// Leaves initialization mode, but keeps the peripheral in sleep mode. | ||
| 319 | /// | ||
| 320 | /// Before the [`Can`] instance can be used, you have to enable it by calling | ||
| 321 | /// [`Can::enable_non_blocking`]. | ||
| 322 | pub fn leave_disabled(mut self) { | ||
| 323 | self.leave_init_mode(); | ||
| 324 | } | ||
| 325 | |||
| 326 | /// Leaves initialization mode, enters sleep mode. | ||
| 327 | fn leave_init_mode(&mut self) { | ||
| 328 | let can = self.can.registers(); | ||
| 329 | can.mcr | ||
| 330 | .modify(|_, w| w.sleep().set_bit().inrq().clear_bit()); | ||
| 331 | loop { | ||
| 332 | let msr = can.msr.read(); | ||
| 333 | if msr.slak().bit_is_set() && msr.inak().bit_is_clear() { | ||
| 334 | break; | ||
| 335 | } | ||
| 336 | } | ||
| 337 | } | ||
| 338 | } | ||
| 339 | |||
| 340 | impl<I: Instance> Drop for CanConfig<'_, I> { | ||
| 341 | #[inline] | ||
| 342 | fn drop(&mut self) { | ||
| 343 | self.leave_init_mode(); | ||
| 344 | } | ||
| 345 | } | ||
| 346 | |||
| 347 | /// Builder returned by [`Can::builder`]. | ||
| 348 | #[must_use = "`CanBuilder` leaves the peripheral in uninitialized state, call `CanBuilder::enable` or `CanBuilder::leave_disabled`"] | ||
| 349 | pub struct CanBuilder<I: Instance> { | ||
| 350 | can: Can<I>, | ||
| 351 | } | ||
| 352 | |||
| 353 | impl<I: Instance> CanBuilder<I> { | ||
| 354 | /// Configures the bit timings. | ||
| 355 | /// | ||
| 356 | /// You can use <http://www.bittiming.can-wiki.info/> to calculate the `btr` parameter. Enter | ||
| 357 | /// parameters as follows: | ||
| 358 | /// | ||
| 359 | /// - *Clock Rate*: The input clock speed to the CAN peripheral (*not* the CPU clock speed). | ||
| 360 | /// This is the clock rate of the peripheral bus the CAN peripheral is attached to (eg. APB1). | ||
| 361 | /// - *Sample Point*: Should normally be left at the default value of 87.5%. | ||
| 362 | /// - *SJW*: Should normally be left at the default value of 1. | ||
| 363 | /// | ||
| 364 | /// Then copy the `CAN_BUS_TIME` register value from the table and pass it as the `btr` | ||
| 365 | /// parameter to this method. | ||
| 366 | pub fn set_bit_timing(mut self, btr: u32) -> Self { | ||
| 367 | self.can.set_bit_timing(btr); | ||
| 368 | self | ||
| 369 | } | ||
| 370 | |||
| 371 | /// Enables or disables loopback mode: Internally connects the TX and RX | ||
| 372 | /// signals together. | ||
| 373 | pub fn set_loopback(self, enabled: bool) -> Self { | ||
| 374 | let can = self.can.registers(); | ||
| 375 | can.btr.modify(|_, w| w.lbkm().bit(enabled)); | ||
| 376 | self | ||
| 377 | } | ||
| 378 | |||
| 379 | /// Enables or disables silent mode: Disconnects the TX signal from the pin. | ||
| 380 | pub fn set_silent(self, enabled: bool) -> Self { | ||
| 381 | let can = self.can.registers(); | ||
| 382 | can.btr.modify(|_, w| w.silm().bit(enabled)); | ||
| 383 | self | ||
| 384 | } | ||
| 385 | |||
| 386 | /// Enables or disables automatic retransmission of messages. | ||
| 387 | /// | ||
| 388 | /// If this is enabled, the CAN peripheral will automatically try to retransmit each frame | ||
| 389 | /// until it can be sent. Otherwise, it will try only once to send each frame. | ||
| 390 | /// | ||
| 391 | /// Automatic retransmission is enabled by default. | ||
| 392 | pub fn set_automatic_retransmit(self, enabled: bool) -> Self { | ||
| 393 | let can = self.can.registers(); | ||
| 394 | can.mcr.modify(|_, w| w.nart().bit(!enabled)); | ||
| 395 | self | ||
| 396 | } | ||
| 397 | |||
| 398 | /// Leaves initialization mode and enables the peripheral. | ||
| 399 | /// | ||
| 400 | /// To sync with the CAN bus, this will block until 11 consecutive recessive bits are detected | ||
| 401 | /// on the bus. | ||
| 402 | /// | ||
| 403 | /// If you want to finish configuration without enabling the peripheral, you can call | ||
| 404 | /// [`CanBuilder::leave_disabled`] instead. | ||
| 405 | pub fn enable(mut self) -> Can<I> { | ||
| 406 | self.leave_init_mode(); | ||
| 407 | |||
| 408 | match nb::block!(self.can.enable_non_blocking()) { | ||
| 409 | Ok(()) => self.can, | ||
| 410 | Err(void) => match void {}, | ||
| 411 | } | ||
| 412 | } | ||
| 413 | |||
| 414 | /// Returns the [`Can`] interface without enabling it. | ||
| 415 | /// | ||
| 416 | /// This leaves initialization mode, but keeps the peripheral in sleep mode instead of enabling | ||
| 417 | /// it. | ||
| 418 | /// | ||
| 419 | /// Before the [`Can`] instance can be used, you have to enable it by calling | ||
| 420 | /// [`Can::enable_non_blocking`]. | ||
| 421 | pub fn leave_disabled(mut self) -> Can<I> { | ||
| 422 | self.leave_init_mode(); | ||
| 423 | self.can | ||
| 424 | } | ||
| 425 | |||
| 426 | /// Leaves initialization mode, enters sleep mode. | ||
| 427 | fn leave_init_mode(&mut self) { | ||
| 428 | let can = self.can.registers(); | ||
| 429 | can.mcr | ||
| 430 | .modify(|_, w| w.sleep().set_bit().inrq().clear_bit()); | ||
| 431 | loop { | ||
| 432 | let msr = can.msr.read(); | ||
| 433 | if msr.slak().bit_is_set() && msr.inak().bit_is_clear() { | ||
| 434 | break; | ||
| 435 | } | ||
| 436 | } | ||
| 437 | } | ||
| 438 | } | ||
| 439 | |||
| 440 | /// Interface to a bxCAN peripheral. | ||
| 441 | pub struct Can<I: Instance> { | ||
| 442 | instance: I, | ||
| 443 | } | ||
| 444 | |||
| 445 | impl<I> Can<I> | ||
| 446 | where | ||
| 447 | I: Instance, | ||
| 448 | { | ||
| 449 | /// Creates a [`CanBuilder`] for constructing a CAN interface. | ||
| 450 | pub fn builder(instance: I) -> CanBuilder<I> { | ||
| 451 | let can_builder = CanBuilder { | ||
| 452 | can: Can { instance }, | ||
| 453 | }; | ||
| 454 | |||
| 455 | let can_reg = can_builder.can.registers(); | ||
| 456 | // Enter init mode. | ||
| 457 | can_reg | ||
| 458 | .mcr | ||
| 459 | .modify(|_, w| w.sleep().clear_bit().inrq().set_bit()); | ||
| 460 | loop { | ||
| 461 | let msr = can_reg.msr.read(); | ||
| 462 | if msr.slak().bit_is_clear() && msr.inak().bit_is_set() { | ||
| 463 | break; | ||
| 464 | } | ||
| 465 | } | ||
| 466 | |||
| 467 | can_builder | ||
| 468 | } | ||
| 469 | |||
| 470 | fn registers(&self) -> &RegisterBlock { | ||
| 471 | unsafe { &*I::REGISTERS } | ||
| 472 | } | ||
| 473 | |||
| 474 | fn set_bit_timing(&mut self, btr: u32) { | ||
| 475 | // Mask of all non-reserved BTR bits, except the mode flags. | ||
| 476 | const MASK: u32 = 0x037F_03FF; | ||
| 477 | |||
| 478 | let can = self.registers(); | ||
| 479 | can.btr.modify(|r, w| unsafe { | ||
| 480 | let mode_bits = r.bits() & 0xC000_0000; | ||
| 481 | w.bits(mode_bits | (btr & MASK)) | ||
| 482 | }); | ||
| 483 | } | ||
| 484 | |||
| 485 | /// Returns a reference to the peripheral instance. | ||
| 486 | /// | ||
| 487 | /// This allows accessing HAL-specific data stored in the instance type. | ||
| 488 | pub fn instance(&mut self) -> &mut I { | ||
| 489 | &mut self.instance | ||
| 490 | } | ||
| 491 | |||
| 492 | /// Disables the CAN interface and returns back the raw peripheral it was created from. | ||
| 493 | /// | ||
| 494 | /// The peripheral is disabled by setting `RESET` in `CAN_MCR`, which causes the peripheral to | ||
| 495 | /// enter sleep mode. | ||
| 496 | pub fn free(self) -> I { | ||
| 497 | self.registers().mcr.write(|w| w.reset().set_bit()); | ||
| 498 | self.instance | ||
| 499 | } | ||
| 500 | |||
| 501 | /// Configure bit timings and silent/loop-back mode. | ||
| 502 | /// | ||
| 503 | /// Calling this method will enter initialization mode. | ||
| 504 | pub fn modify_config(&mut self) -> CanConfig<'_, I> { | ||
| 505 | let can = self.registers(); | ||
| 506 | |||
| 507 | // Enter init mode. | ||
| 508 | can.mcr | ||
| 509 | .modify(|_, w| w.sleep().clear_bit().inrq().set_bit()); | ||
| 510 | loop { | ||
| 511 | let msr = can.msr.read(); | ||
| 512 | if msr.slak().bit_is_clear() && msr.inak().bit_is_set() { | ||
| 513 | break; | ||
| 514 | } | ||
| 515 | } | ||
| 516 | |||
| 517 | CanConfig { can: self } | ||
| 518 | } | ||
| 519 | |||
| 520 | /// Configures the automatic wake-up feature. | ||
| 521 | /// | ||
| 522 | /// This is turned off by default. | ||
| 523 | /// | ||
| 524 | /// When turned on, an incoming frame will cause the peripheral to wake up from sleep and | ||
| 525 | /// receive the frame. If enabled, [`Interrupt::Wakeup`] will also be triggered by the incoming | ||
| 526 | /// frame. | ||
| 527 | pub fn set_automatic_wakeup(&mut self, enabled: bool) { | ||
| 528 | let can = self.registers(); | ||
| 529 | can.mcr.modify(|_, w| w.awum().bit(enabled)); | ||
| 530 | } | ||
| 531 | |||
| 532 | /// Leaves initialization mode and enables the peripheral (non-blocking version). | ||
| 533 | /// | ||
| 534 | /// Usually, it is recommended to call [`CanConfig::enable`] instead. This method is only needed | ||
| 535 | /// if you want non-blocking initialization. | ||
| 536 | /// | ||
| 537 | /// If this returns [`WouldBlock`][nb::Error::WouldBlock], the peripheral will enable itself | ||
| 538 | /// in the background. The peripheral is enabled and ready to use when this method returns | ||
| 539 | /// successfully. | ||
| 540 | pub fn enable_non_blocking(&mut self) -> nb::Result<(), Infallible> { | ||
| 541 | let can = self.registers(); | ||
| 542 | let msr = can.msr.read(); | ||
| 543 | if msr.slak().bit_is_set() { | ||
| 544 | can.mcr | ||
| 545 | .modify(|_, w| w.abom().set_bit().sleep().clear_bit()); | ||
| 546 | Err(nb::Error::WouldBlock) | ||
| 547 | } else { | ||
| 548 | Ok(()) | ||
| 549 | } | ||
| 550 | } | ||
| 551 | |||
| 552 | /// Puts the peripheral in a sleep mode to save power. | ||
| 553 | /// | ||
| 554 | /// While in sleep mode, an incoming CAN frame will trigger [`Interrupt::Wakeup`] if enabled. | ||
| 555 | pub fn sleep(&mut self) { | ||
| 556 | let can = self.registers(); | ||
| 557 | can.mcr | ||
| 558 | .modify(|_, w| w.sleep().set_bit().inrq().clear_bit()); | ||
| 559 | loop { | ||
| 560 | let msr = can.msr.read(); | ||
| 561 | if msr.slak().bit_is_set() && msr.inak().bit_is_clear() { | ||
| 562 | break; | ||
| 563 | } | ||
| 564 | } | ||
| 565 | } | ||
| 566 | |||
| 567 | /// Wakes up from sleep mode. | ||
| 568 | /// | ||
| 569 | /// Note that this will not trigger [`Interrupt::Wakeup`], only reception of an incoming CAN | ||
| 570 | /// frame will cause that interrupt. | ||
| 571 | pub fn wakeup(&mut self) { | ||
| 572 | let can = self.registers(); | ||
| 573 | can.mcr | ||
| 574 | .modify(|_, w| w.sleep().clear_bit().inrq().clear_bit()); | ||
| 575 | loop { | ||
| 576 | let msr = can.msr.read(); | ||
| 577 | if msr.slak().bit_is_clear() && msr.inak().bit_is_clear() { | ||
| 578 | break; | ||
| 579 | } | ||
| 580 | } | ||
| 581 | } | ||
| 582 | |||
| 583 | /// Starts listening for a CAN interrupt. | ||
| 584 | pub fn enable_interrupt(&mut self, interrupt: Interrupt) { | ||
| 585 | self.enable_interrupts(Interrupts::from_bits_truncate(interrupt as u32)) | ||
| 586 | } | ||
| 587 | |||
| 588 | /// Starts listening for a set of CAN interrupts. | ||
| 589 | pub fn enable_interrupts(&mut self, interrupts: Interrupts) { | ||
| 590 | self.registers() | ||
| 591 | .ier | ||
| 592 | .modify(|r, w| unsafe { w.bits(r.bits() | interrupts.bits()) }) | ||
| 593 | } | ||
| 594 | |||
| 595 | /// Stops listening for a CAN interrupt. | ||
| 596 | pub fn disable_interrupt(&mut self, interrupt: Interrupt) { | ||
| 597 | self.disable_interrupts(Interrupts::from_bits_truncate(interrupt as u32)) | ||
| 598 | } | ||
| 599 | |||
| 600 | /// Stops listening for a set of CAN interrupts. | ||
| 601 | pub fn disable_interrupts(&mut self, interrupts: Interrupts) { | ||
| 602 | self.registers() | ||
| 603 | .ier | ||
| 604 | .modify(|r, w| unsafe { w.bits(r.bits() & !interrupts.bits()) }) | ||
| 605 | } | ||
| 606 | |||
| 607 | /// Clears the pending flag of [`Interrupt::Sleep`]. | ||
| 608 | pub fn clear_sleep_interrupt(&self) { | ||
| 609 | let can = self.registers(); | ||
| 610 | // Read-only register with write-1-to-clear, so `&self` is sufficient. | ||
| 611 | can.msr.write(|w| w.slaki().set_bit()); | ||
| 612 | } | ||
| 613 | |||
| 614 | /// Clears the pending flag of [`Interrupt::Wakeup`]. | ||
| 615 | pub fn clear_wakeup_interrupt(&self) { | ||
| 616 | let can = self.registers(); | ||
| 617 | // Read-only register with write-1-to-clear, so `&self` is sufficient. | ||
| 618 | can.msr.write(|w| w.wkui().set_bit()); | ||
| 619 | } | ||
| 620 | |||
| 621 | /// Clears the "Request Completed" (RQCP) flag of a transmit mailbox. | ||
| 622 | /// | ||
| 623 | /// Returns the [`Mailbox`] whose flag was cleared. If no mailbox has the flag set, returns | ||
| 624 | /// `None`. | ||
| 625 | /// | ||
| 626 | /// Once this function returns `None`, a pending [`Interrupt::TransmitMailboxEmpty`] is | ||
| 627 | /// considered acknowledged. | ||
| 628 | pub fn clear_request_completed_flag(&mut self) -> Option<Mailbox> { | ||
| 629 | let can = self.registers(); | ||
| 630 | let tsr = can.tsr.read(); | ||
| 631 | if tsr.rqcp0().bit_is_set() { | ||
| 632 | can.tsr.modify(|_, w| w.rqcp0().set_bit()); | ||
| 633 | Some(Mailbox::Mailbox0) | ||
| 634 | } else if tsr.rqcp1().bit_is_set() { | ||
| 635 | can.tsr.modify(|_, w| w.rqcp1().set_bit()); | ||
| 636 | Some(Mailbox::Mailbox1) | ||
| 637 | } else if tsr.rqcp2().bit_is_set() { | ||
| 638 | can.tsr.modify(|_, w| w.rqcp2().set_bit()); | ||
| 639 | Some(Mailbox::Mailbox2) | ||
| 640 | } else { | ||
| 641 | None | ||
| 642 | } | ||
| 643 | } | ||
| 644 | |||
| 645 | /// Clears a pending TX interrupt ([`Interrupt::TransmitMailboxEmpty`]). | ||
| 646 | /// | ||
| 647 | /// This does not return the mailboxes that have finished tranmission. If you need that | ||
| 648 | /// information, call [`Can::clear_request_completed_flag`] instead. | ||
| 649 | pub fn clear_tx_interrupt(&mut self) { | ||
| 650 | while self.clear_request_completed_flag().is_some() {} | ||
| 651 | } | ||
| 652 | |||
| 653 | /// Puts a CAN frame in a free transmit mailbox for transmission on the bus. | ||
| 654 | /// | ||
| 655 | /// Frames are transmitted to the bus based on their priority (see [`FramePriority`]). | ||
| 656 | /// Transmit order is preserved for frames with identical priority. | ||
| 657 | /// | ||
| 658 | /// If all transmit mailboxes are full, and `frame` has a higher priority than the | ||
| 659 | /// lowest-priority message in the transmit mailboxes, transmission of the enqueued frame is | ||
| 660 | /// cancelled and `frame` is enqueued instead. The frame that was replaced is returned as | ||
| 661 | /// [`TransmitStatus::dequeued_frame`]. | ||
| 662 | pub fn transmit(&mut self, frame: &Frame) -> nb::Result<TransmitStatus, Infallible> { | ||
| 663 | // Safety: We have a `&mut self` and have unique access to the peripheral. | ||
| 664 | unsafe { Tx::<I>::conjure().transmit(frame) } | ||
| 665 | } | ||
| 666 | |||
| 667 | /// Returns `true` if no frame is pending for transmission. | ||
| 668 | pub fn is_transmitter_idle(&self) -> bool { | ||
| 669 | // Safety: Read-only operation. | ||
| 670 | unsafe { Tx::<I>::conjure().is_idle() } | ||
| 671 | } | ||
| 672 | |||
| 673 | /// Attempts to abort the sending of a frame that is pending in a mailbox. | ||
| 674 | /// | ||
| 675 | /// If there is no frame in the provided mailbox, or its transmission succeeds before it can be | ||
| 676 | /// aborted, this function has no effect and returns `false`. | ||
| 677 | /// | ||
| 678 | /// If there is a frame in the provided mailbox, and it is canceled successfully, this function | ||
| 679 | /// returns `true`. | ||
| 680 | pub fn abort(&mut self, mailbox: Mailbox) -> bool { | ||
| 681 | // Safety: We have a `&mut self` and have unique access to the peripheral. | ||
| 682 | unsafe { Tx::<I>::conjure().abort(mailbox) } | ||
| 683 | } | ||
| 684 | |||
| 685 | /// Returns a received frame if available. | ||
| 686 | /// | ||
| 687 | /// This will first check FIFO 0 for a message or error. If none are available, FIFO 1 is | ||
| 688 | /// checked. | ||
| 689 | /// | ||
| 690 | /// Returns `Err` when a frame was lost due to buffer overrun. | ||
| 691 | pub fn receive(&mut self) -> nb::Result<Frame, OverrunError> { | ||
| 692 | // Safety: We have a `&mut self` and have unique access to the peripheral. | ||
| 693 | let mut rx0 = unsafe { Rx0::<I>::conjure() }; | ||
| 694 | let mut rx1 = unsafe { Rx1::<I>::conjure() }; | ||
| 695 | |||
| 696 | match rx0.receive() { | ||
| 697 | Err(nb::Error::WouldBlock) => rx1.receive(), | ||
| 698 | result => result, | ||
| 699 | } | ||
| 700 | } | ||
| 701 | |||
| 702 | /// Returns a reference to the RX FIFO 0. | ||
| 703 | pub fn rx0(&mut self) -> &mut Rx0<I> { | ||
| 704 | // Safety: We take `&mut self` and the return value lifetimes are tied to `self`'s lifetime. | ||
| 705 | unsafe { Rx0::conjure_by_ref() } | ||
| 706 | } | ||
| 707 | |||
| 708 | /// Returns a reference to the RX FIFO 1. | ||
| 709 | pub fn rx1(&mut self) -> &mut Rx1<I> { | ||
| 710 | // Safety: We take `&mut self` and the return value lifetimes are tied to `self`'s lifetime. | ||
| 711 | unsafe { Rx1::conjure_by_ref() } | ||
| 712 | } | ||
| 713 | |||
| 714 | /// Splits this `Can` instance into transmitting and receiving halves, by reference. | ||
| 715 | pub fn split_by_ref(&mut self) -> (&mut Tx<I>, &mut Rx0<I>, &mut Rx1<I>) { | ||
| 716 | // Safety: We take `&mut self` and the return value lifetimes are tied to `self`'s lifetime. | ||
| 717 | let tx = unsafe { Tx::conjure_by_ref() }; | ||
| 718 | let rx0 = unsafe { Rx0::conjure_by_ref() }; | ||
| 719 | let rx1 = unsafe { Rx1::conjure_by_ref() }; | ||
| 720 | (tx, rx0, rx1) | ||
| 721 | } | ||
| 722 | |||
| 723 | /// Consumes this `Can` instance and splits it into transmitting and receiving halves. | ||
| 724 | pub fn split(self) -> (Tx<I>, Rx0<I>, Rx1<I>) { | ||
| 725 | // Safety: `Self` is not `Copy` and is destroyed by moving it into this method. | ||
| 726 | unsafe { (Tx::conjure(), Rx0::conjure(), Rx1::conjure()) } | ||
| 727 | } | ||
| 728 | } | ||
| 729 | |||
| 730 | impl<I: FilterOwner> Can<I> { | ||
| 731 | /// Accesses the filter banks owned by this CAN peripheral. | ||
| 732 | /// | ||
| 733 | /// To modify filters of a slave peripheral, `modify_filters` has to be called on the master | ||
| 734 | /// peripheral instead. | ||
| 735 | pub fn modify_filters(&mut self) -> MasterFilters<'_, I> { | ||
| 736 | unsafe { MasterFilters::new() } | ||
| 737 | } | ||
| 738 | } | ||
| 739 | |||
| 740 | /// Interface to the CAN transmitter part. | ||
| 741 | pub struct Tx<I> { | ||
| 742 | _can: PhantomData<I>, | ||
| 743 | } | ||
| 744 | |||
| 745 | #[inline] | ||
| 746 | const fn ok_mask(idx: usize) -> u32 { | ||
| 747 | 0x02 << (8 * idx) | ||
| 748 | } | ||
| 749 | |||
| 750 | #[inline] | ||
| 751 | const fn abort_mask(idx: usize) -> u32 { | ||
| 752 | 0x80 << (8 * idx) | ||
| 753 | } | ||
| 754 | |||
| 755 | impl<I> Tx<I> | ||
| 756 | where | ||
| 757 | I: Instance, | ||
| 758 | { | ||
| 759 | unsafe fn conjure() -> Self { | ||
| 760 | Self { _can: PhantomData } | ||
| 761 | } | ||
| 762 | |||
| 763 | /// Creates a `&mut Self` out of thin air. | ||
| 764 | /// | ||
| 765 | /// This is only safe if it is the only way to access a `Tx<I>`. | ||
| 766 | unsafe fn conjure_by_ref<'a>() -> &'a mut Self { | ||
| 767 | // Cause out of bounds access when `Self` is not zero-sized. | ||
| 768 | [()][core::mem::size_of::<Self>()]; | ||
| 769 | |||
| 770 | // Any aligned pointer is valid for ZSTs. | ||
| 771 | &mut *NonNull::dangling().as_ptr() | ||
| 772 | } | ||
| 773 | |||
| 774 | fn registers(&self) -> &RegisterBlock { | ||
| 775 | unsafe { &*I::REGISTERS } | ||
| 776 | } | ||
| 777 | |||
| 778 | /// Puts a CAN frame in a transmit mailbox for transmission on the bus. | ||
| 779 | /// | ||
| 780 | /// Frames are transmitted to the bus based on their priority (see [`FramePriority`]). | ||
| 781 | /// Transmit order is preserved for frames with identical priority. | ||
| 782 | /// | ||
| 783 | /// If all transmit mailboxes are full, and `frame` has a higher priority than the | ||
| 784 | /// lowest-priority message in the transmit mailboxes, transmission of the enqueued frame is | ||
| 785 | /// cancelled and `frame` is enqueued instead. The frame that was replaced is returned as | ||
| 786 | /// [`TransmitStatus::dequeued_frame`]. | ||
| 787 | pub fn transmit(&mut self, frame: &Frame) -> nb::Result<TransmitStatus, Infallible> { | ||
| 788 | let can = self.registers(); | ||
| 789 | |||
| 790 | // Get the index of the next free mailbox or the one with the lowest priority. | ||
| 791 | let tsr = can.tsr.read(); | ||
| 792 | let idx = tsr.code().bits() as usize; | ||
| 793 | |||
| 794 | let frame_is_pending = | ||
| 795 | tsr.tme0().bit_is_clear() || tsr.tme1().bit_is_clear() || tsr.tme2().bit_is_clear(); | ||
| 796 | let pending_frame = if frame_is_pending { | ||
| 797 | // High priority frames are transmitted first by the mailbox system. | ||
| 798 | // Frames with identical identifier shall be transmitted in FIFO order. | ||
| 799 | // The controller schedules pending frames of same priority based on the | ||
| 800 | // mailbox index instead. As a workaround check all pending mailboxes | ||
| 801 | // and only accept higher priority frames. | ||
| 802 | self.check_priority(0, frame.id)?; | ||
| 803 | self.check_priority(1, frame.id)?; | ||
| 804 | self.check_priority(2, frame.id)?; | ||
| 805 | |||
| 806 | let all_frames_are_pending = | ||
| 807 | tsr.tme0().bit_is_clear() && tsr.tme1().bit_is_clear() && tsr.tme2().bit_is_clear(); | ||
| 808 | if all_frames_are_pending { | ||
| 809 | // No free mailbox is available. This can only happen when three frames with | ||
| 810 | // ascending priority (descending IDs) were requested for transmission and all | ||
| 811 | // of them are blocked by bus traffic with even higher priority. | ||
| 812 | // To prevent a priority inversion abort and replace the lowest priority frame. | ||
| 813 | self.read_pending_mailbox(idx) | ||
| 814 | } else { | ||
| 815 | // There was a free mailbox. | ||
| 816 | None | ||
| 817 | } | ||
| 818 | } else { | ||
| 819 | // All mailboxes are available: Send frame without performing any checks. | ||
| 820 | None | ||
| 821 | }; | ||
| 822 | |||
| 823 | self.write_mailbox(idx, frame); | ||
| 824 | |||
| 825 | let mailbox = match idx { | ||
| 826 | 0 => Mailbox::Mailbox0, | ||
| 827 | 1 => Mailbox::Mailbox1, | ||
| 828 | 2 => Mailbox::Mailbox2, | ||
| 829 | _ => unreachable!(), | ||
| 830 | }; | ||
| 831 | Ok(TransmitStatus { | ||
| 832 | dequeued_frame: pending_frame, | ||
| 833 | mailbox, | ||
| 834 | }) | ||
| 835 | } | ||
| 836 | |||
| 837 | /// Returns `Ok` when the mailbox is free or if it contains pending frame with a | ||
| 838 | /// lower priority (higher ID) than the identifier `id`. | ||
| 839 | fn check_priority(&self, idx: usize, id: IdReg) -> nb::Result<(), Infallible> { | ||
| 840 | let can = self.registers(); | ||
| 841 | |||
| 842 | // Read the pending frame's id to check its priority. | ||
| 843 | assert!(idx < 3); | ||
| 844 | let tir = &can.tx[idx].tir.read(); | ||
| 845 | |||
| 846 | // Check the priority by comparing the identifiers. But first make sure the | ||
| 847 | // frame has not finished the transmission (`TXRQ` == 0) in the meantime. | ||
| 848 | if tir.txrq().bit_is_set() && id <= IdReg::from_register(tir.bits()) { | ||
| 849 | // There's a mailbox whose priority is higher or equal | ||
| 850 | // the priority of the new frame. | ||
| 851 | return Err(nb::Error::WouldBlock); | ||
| 852 | } | ||
| 853 | |||
| 854 | Ok(()) | ||
| 855 | } | ||
| 856 | |||
| 857 | fn write_mailbox(&mut self, idx: usize, frame: &Frame) { | ||
| 858 | let can = self.registers(); | ||
| 859 | |||
| 860 | debug_assert!(idx < 3); | ||
| 861 | let mb = unsafe { &can.tx.get_unchecked(idx) }; | ||
| 862 | |||
| 863 | mb.tdtr | ||
| 864 | .write(|w| unsafe { w.dlc().bits(frame.dlc() as u8) }); | ||
| 865 | mb.tdlr.write(|w| unsafe { | ||
| 866 | w.bits(u32::from_ne_bytes( | ||
| 867 | frame.data.bytes[0..4].try_into().unwrap(), | ||
| 868 | )) | ||
| 869 | }); | ||
| 870 | mb.tdhr.write(|w| unsafe { | ||
| 871 | w.bits(u32::from_ne_bytes( | ||
| 872 | frame.data.bytes[4..8].try_into().unwrap(), | ||
| 873 | )) | ||
| 874 | }); | ||
| 875 | mb.tir | ||
| 876 | .write(|w| unsafe { w.bits(frame.id.0).txrq().set_bit() }); | ||
| 877 | } | ||
| 878 | |||
| 879 | fn read_pending_mailbox(&mut self, idx: usize) -> Option<Frame> { | ||
| 880 | if self.abort_by_index(idx) { | ||
| 881 | let can = self.registers(); | ||
| 882 | debug_assert!(idx < 3); | ||
| 883 | let mb = unsafe { &can.tx.get_unchecked(idx) }; | ||
| 884 | |||
| 885 | // Read back the pending frame. | ||
| 886 | let mut pending_frame = Frame { | ||
| 887 | id: IdReg(mb.tir.read().bits()), | ||
| 888 | data: Data::empty(), | ||
| 889 | }; | ||
| 890 | pending_frame.data.bytes[0..4].copy_from_slice(&mb.tdlr.read().bits().to_ne_bytes()); | ||
| 891 | pending_frame.data.bytes[4..8].copy_from_slice(&mb.tdhr.read().bits().to_ne_bytes()); | ||
| 892 | pending_frame.data.len = mb.tdtr.read().dlc().bits(); | ||
| 893 | |||
| 894 | Some(pending_frame) | ||
| 895 | } else { | ||
| 896 | // Abort request failed because the frame was already sent (or being sent) on | ||
| 897 | // the bus. All mailboxes are now free. This can happen for small prescaler | ||
| 898 | // values (e.g. 1MBit/s bit timing with a source clock of 8MHz) or when an ISR | ||
| 899 | // has preempted the execution. | ||
| 900 | None | ||
| 901 | } | ||
| 902 | } | ||
| 903 | |||
| 904 | /// Tries to abort a pending frame. Returns `true` when aborted. | ||
| 905 | fn abort_by_index(&mut self, idx: usize) -> bool { | ||
| 906 | let can = self.registers(); | ||
| 907 | |||
| 908 | can.tsr.write(|w| unsafe { w.bits(abort_mask(idx)) }); | ||
| 909 | |||
| 910 | // Wait for the abort request to be finished. | ||
| 911 | loop { | ||
| 912 | let tsr = can.tsr.read().bits(); | ||
| 913 | if tsr & abort_mask(idx) == 0 { | ||
| 914 | break tsr & ok_mask(idx) == 0; | ||
| 915 | } | ||
| 916 | } | ||
| 917 | } | ||
| 918 | |||
| 919 | /// Attempts to abort the sending of a frame that is pending in a mailbox. | ||
| 920 | /// | ||
| 921 | /// If there is no frame in the provided mailbox, or its transmission succeeds before it can be | ||
| 922 | /// aborted, this function has no effect and returns `false`. | ||
| 923 | /// | ||
| 924 | /// If there is a frame in the provided mailbox, and it is canceled successfully, this function | ||
| 925 | /// returns `true`. | ||
| 926 | pub fn abort(&mut self, mailbox: Mailbox) -> bool { | ||
| 927 | // If the mailbox is empty, the value of TXOKx depends on what happened with the previous | ||
| 928 | // frame in that mailbox. Only call abort_by_index() if the mailbox is not empty. | ||
| 929 | let tsr = self.registers().tsr.read(); | ||
| 930 | let mailbox_empty = match mailbox { | ||
| 931 | Mailbox::Mailbox0 => tsr.tme0().bit_is_set(), | ||
| 932 | Mailbox::Mailbox1 => tsr.tme1().bit_is_set(), | ||
| 933 | Mailbox::Mailbox2 => tsr.tme2().bit_is_set(), | ||
| 934 | }; | ||
| 935 | if mailbox_empty { | ||
| 936 | false | ||
| 937 | } else { | ||
| 938 | self.abort_by_index(mailbox as usize) | ||
| 939 | } | ||
| 940 | } | ||
| 941 | |||
| 942 | /// Returns `true` if no frame is pending for transmission. | ||
| 943 | pub fn is_idle(&self) -> bool { | ||
| 944 | let can = self.registers(); | ||
| 945 | let tsr = can.tsr.read(); | ||
| 946 | tsr.tme0().bit_is_set() && tsr.tme1().bit_is_set() && tsr.tme2().bit_is_set() | ||
| 947 | } | ||
| 948 | |||
| 949 | /// Clears the request complete flag for all mailboxes. | ||
| 950 | pub fn clear_interrupt_flags(&mut self) { | ||
| 951 | let can = self.registers(); | ||
| 952 | can.tsr | ||
| 953 | .write(|w| w.rqcp2().set_bit().rqcp1().set_bit().rqcp0().set_bit()); | ||
| 954 | } | ||
| 955 | } | ||
| 956 | |||
| 957 | /// Interface to receiver FIFO 0. | ||
| 958 | pub struct Rx0<I> { | ||
| 959 | _can: PhantomData<I>, | ||
| 960 | } | ||
| 961 | |||
| 962 | impl<I> Rx0<I> | ||
| 963 | where | ||
| 964 | I: Instance, | ||
| 965 | { | ||
| 966 | unsafe fn conjure() -> Self { | ||
| 967 | Self { _can: PhantomData } | ||
| 968 | } | ||
| 969 | |||
| 970 | /// Creates a `&mut Self` out of thin air. | ||
| 971 | /// | ||
| 972 | /// This is only safe if it is the only way to access an `Rx<I>`. | ||
| 973 | unsafe fn conjure_by_ref<'a>() -> &'a mut Self { | ||
| 974 | // Cause out of bounds access when `Self` is not zero-sized. | ||
| 975 | [()][core::mem::size_of::<Self>()]; | ||
| 976 | |||
| 977 | // Any aligned pointer is valid for ZSTs. | ||
| 978 | &mut *NonNull::dangling().as_ptr() | ||
| 979 | } | ||
| 980 | |||
| 981 | /// Returns a received frame if available. | ||
| 982 | /// | ||
| 983 | /// Returns `Err` when a frame was lost due to buffer overrun. | ||
| 984 | pub fn receive(&mut self) -> nb::Result<Frame, OverrunError> { | ||
| 985 | receive_fifo(self.registers(), 0) | ||
| 986 | } | ||
| 987 | |||
| 988 | fn registers(&self) -> &RegisterBlock { | ||
| 989 | unsafe { &*I::REGISTERS } | ||
| 990 | } | ||
| 991 | } | ||
| 992 | |||
| 993 | /// Interface to receiver FIFO 1. | ||
| 994 | pub struct Rx1<I> { | ||
| 995 | _can: PhantomData<I>, | ||
| 996 | } | ||
| 997 | |||
| 998 | impl<I> Rx1<I> | ||
| 999 | where | ||
| 1000 | I: Instance, | ||
| 1001 | { | ||
| 1002 | unsafe fn conjure() -> Self { | ||
| 1003 | Self { _can: PhantomData } | ||
| 1004 | } | ||
| 1005 | |||
| 1006 | /// Creates a `&mut Self` out of thin air. | ||
| 1007 | /// | ||
| 1008 | /// This is only safe if it is the only way to access an `Rx<I>`. | ||
| 1009 | unsafe fn conjure_by_ref<'a>() -> &'a mut Self { | ||
| 1010 | // Cause out of bounds access when `Self` is not zero-sized. | ||
| 1011 | [()][core::mem::size_of::<Self>()]; | ||
| 1012 | |||
| 1013 | // Any aligned pointer is valid for ZSTs. | ||
| 1014 | &mut *NonNull::dangling().as_ptr() | ||
| 1015 | } | ||
| 1016 | |||
| 1017 | /// Returns a received frame if available. | ||
| 1018 | /// | ||
| 1019 | /// Returns `Err` when a frame was lost due to buffer overrun. | ||
| 1020 | pub fn receive(&mut self) -> nb::Result<Frame, OverrunError> { | ||
| 1021 | receive_fifo(self.registers(), 1) | ||
| 1022 | } | ||
| 1023 | |||
| 1024 | fn registers(&self) -> &RegisterBlock { | ||
| 1025 | unsafe { &*I::REGISTERS } | ||
| 1026 | } | ||
| 1027 | } | ||
| 1028 | |||
| 1029 | fn receive_fifo(can: &RegisterBlock, fifo_nr: usize) -> nb::Result<Frame, OverrunError> { | ||
| 1030 | assert!(fifo_nr < 2); | ||
| 1031 | let rfr = &can.rfr[fifo_nr]; | ||
| 1032 | let rx = &can.rx[fifo_nr]; | ||
| 1033 | |||
| 1034 | // Check if a frame is available in the mailbox. | ||
| 1035 | let rfr_read = rfr.read(); | ||
| 1036 | if rfr_read.fmp().bits() == 0 { | ||
| 1037 | return Err(nb::Error::WouldBlock); | ||
| 1038 | } | ||
| 1039 | |||
| 1040 | // Check for RX FIFO overrun. | ||
| 1041 | if rfr_read.fovr().bit_is_set() { | ||
| 1042 | rfr.write(|w| w.fovr().set_bit()); | ||
| 1043 | return Err(nb::Error::Other(OverrunError { _priv: () })); | ||
| 1044 | } | ||
| 1045 | |||
| 1046 | // Read the frame. | ||
| 1047 | let mut frame = Frame { | ||
| 1048 | id: IdReg(rx.rir.read().bits()), | ||
| 1049 | data: [0; 8].into(), | ||
| 1050 | }; | ||
| 1051 | frame.data[0..4].copy_from_slice(&rx.rdlr.read().bits().to_ne_bytes()); | ||
| 1052 | frame.data[4..8].copy_from_slice(&rx.rdhr.read().bits().to_ne_bytes()); | ||
| 1053 | frame.data.len = rx.rdtr.read().dlc().bits(); | ||
| 1054 | |||
| 1055 | // Release the mailbox. | ||
| 1056 | rfr.write(|w| w.rfom().set_bit()); | ||
| 1057 | |||
| 1058 | Ok(frame) | ||
| 1059 | } | ||
| 1060 | |||
| 1061 | /// Identifies one of the two receive FIFOs. | ||
| 1062 | #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] | ||
| 1063 | #[cfg_attr(feature = "unstable-defmt", derive(defmt::Format))] | ||
| 1064 | pub enum Fifo { | ||
| 1065 | Fifo0 = 0, | ||
| 1066 | Fifo1 = 1, | ||
| 1067 | } | ||
| 1068 | |||
| 1069 | /// Identifies one of the three transmit mailboxes. | ||
| 1070 | #[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)] | ||
| 1071 | #[cfg_attr(feature = "unstable-defmt", derive(defmt::Format))] | ||
| 1072 | pub enum Mailbox { | ||
| 1073 | /// Transmit mailbox 0 | ||
| 1074 | Mailbox0 = 0, | ||
| 1075 | /// Transmit mailbox 1 | ||
| 1076 | Mailbox1 = 1, | ||
| 1077 | /// Transmit mailbox 2 | ||
| 1078 | Mailbox2 = 2, | ||
| 1079 | } | ||
| 1080 | |||
| 1081 | /// Contains information about a frame enqueued for transmission via [`Can::transmit`] or | ||
| 1082 | /// [`Tx::transmit`]. | ||
| 1083 | pub struct TransmitStatus { | ||
| 1084 | dequeued_frame: Option<Frame>, | ||
| 1085 | mailbox: Mailbox, | ||
| 1086 | } | ||
| 1087 | |||
| 1088 | impl TransmitStatus { | ||
| 1089 | /// Returns the lower-priority frame that was dequeued to make space for the new frame. | ||
| 1090 | #[inline] | ||
| 1091 | pub fn dequeued_frame(&self) -> Option<&Frame> { | ||
| 1092 | self.dequeued_frame.as_ref() | ||
| 1093 | } | ||
| 1094 | |||
| 1095 | /// Returns the [`Mailbox`] the frame was enqueued in. | ||
| 1096 | #[inline] | ||
| 1097 | pub fn mailbox(&self) -> Mailbox { | ||
| 1098 | self.mailbox | ||
| 1099 | } | ||
| 1100 | } | ||
diff --git a/embassy-stm32/src/can/bx/pac/can.rs b/embassy-stm32/src/can/bx/pac/can.rs new file mode 100644 index 000000000..f190fdff4 --- /dev/null +++ b/embassy-stm32/src/can/bx/pac/can.rs | |||
| @@ -0,0 +1,213 @@ | |||
| 1 | /// Register block of bxCAN peripherals. | ||
| 2 | #[repr(C)] | ||
| 3 | pub struct RegisterBlock { | ||
| 4 | #[doc = "0x00 - CAN_MCR"] | ||
| 5 | pub(crate) mcr: MCR, | ||
| 6 | #[doc = "0x04 - CAN_MSR"] | ||
| 7 | pub(crate) msr: MSR, | ||
| 8 | #[doc = "0x08 - CAN_TSR"] | ||
| 9 | pub(crate) tsr: TSR, | ||
| 10 | #[doc = "0x0c - CAN_RF0R"] | ||
| 11 | pub(crate) rfr: [RFR; 2], | ||
| 12 | #[doc = "0x14 - CAN_IER"] | ||
| 13 | pub(crate) ier: IER, | ||
| 14 | #[doc = "0x18 - CAN_ESR"] | ||
| 15 | pub(crate) esr: ESR, | ||
| 16 | #[doc = "0x1c - CAN_BTR"] | ||
| 17 | pub(crate) btr: BTR, | ||
| 18 | _reserved7: [u8; 352usize], | ||
| 19 | #[doc = "0x180 - CAN Transmit cluster"] | ||
| 20 | pub(crate) tx: [TX; 3], | ||
| 21 | #[doc = "0x1b0 - CAN Receive cluster"] | ||
| 22 | pub(crate) rx: [RX; 2], | ||
| 23 | _reserved9: [u8; 48usize], | ||
| 24 | #[doc = "0x200 - CAN_FMR"] | ||
| 25 | pub(crate) fmr: FMR, | ||
| 26 | #[doc = "0x204 - CAN_FM1R"] | ||
| 27 | pub(crate) fm1r: FM1R, | ||
| 28 | _reserved11: [u8; 4usize], | ||
| 29 | #[doc = "0x20c - CAN_FS1R"] | ||
| 30 | pub(crate) fs1r: FS1R, | ||
| 31 | _reserved12: [u8; 4usize], | ||
| 32 | #[doc = "0x214 - CAN_FFA1R"] | ||
| 33 | pub(crate) ffa1r: FFA1R, | ||
| 34 | _reserved13: [u8; 4usize], | ||
| 35 | #[doc = "0x21c - CAN_FA1R"] | ||
| 36 | pub(crate) fa1r: FA1R, | ||
| 37 | _reserved14: [u8; 32usize], | ||
| 38 | #[doc = "0x240 - CAN Filter Bank cluster"] | ||
| 39 | pub(crate) fb: [FB; 28], // UP TO 28, but 14 in some devices | ||
| 40 | } | ||
| 41 | #[doc = r"Register block"] | ||
| 42 | #[repr(C)] | ||
| 43 | pub struct TX { | ||
| 44 | #[doc = "0x00 - CAN_TI0R"] | ||
| 45 | pub tir: self::tx::TIR, | ||
| 46 | #[doc = "0x04 - CAN_TDT0R"] | ||
| 47 | pub tdtr: self::tx::TDTR, | ||
| 48 | #[doc = "0x08 - CAN_TDL0R"] | ||
| 49 | pub tdlr: self::tx::TDLR, | ||
| 50 | #[doc = "0x0c - CAN_TDH0R"] | ||
| 51 | pub tdhr: self::tx::TDHR, | ||
| 52 | } | ||
| 53 | #[doc = r"Register block"] | ||
| 54 | #[doc = "CAN Transmit cluster"] | ||
| 55 | pub mod tx; | ||
| 56 | #[doc = r"Register block"] | ||
| 57 | #[repr(C)] | ||
| 58 | pub struct RX { | ||
| 59 | #[doc = "0x00 - CAN_RI0R"] | ||
| 60 | pub rir: self::rx::RIR, | ||
| 61 | #[doc = "0x04 - CAN_RDT0R"] | ||
| 62 | pub rdtr: self::rx::RDTR, | ||
| 63 | #[doc = "0x08 - CAN_RDL0R"] | ||
| 64 | pub rdlr: self::rx::RDLR, | ||
| 65 | #[doc = "0x0c - CAN_RDH0R"] | ||
| 66 | pub rdhr: self::rx::RDHR, | ||
| 67 | } | ||
| 68 | #[doc = r"Register block"] | ||
| 69 | #[doc = "CAN Receive cluster"] | ||
| 70 | pub mod rx; | ||
| 71 | #[doc = r"Register block"] | ||
| 72 | #[repr(C)] | ||
| 73 | pub struct FB { | ||
| 74 | #[doc = "0x00 - Filter bank 0 register 1"] | ||
| 75 | pub fr1: self::fb::FR1, | ||
| 76 | #[doc = "0x04 - Filter bank 0 register 2"] | ||
| 77 | pub fr2: self::fb::FR2, | ||
| 78 | } | ||
| 79 | #[doc = r"Register block"] | ||
| 80 | #[doc = "CAN Filter Bank cluster"] | ||
| 81 | pub mod fb; | ||
| 82 | #[doc = "CAN_MCR\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [mcr](mcr) module"] | ||
| 83 | pub type MCR = crate::Reg<u32, _MCR>; | ||
| 84 | #[allow(missing_docs)] | ||
| 85 | #[doc(hidden)] | ||
| 86 | pub struct _MCR; | ||
| 87 | #[doc = "`read()` method returns [mcr::R](mcr::R) reader structure"] | ||
| 88 | impl crate::Readable for MCR {} | ||
| 89 | #[doc = "`write(|w| ..)` method takes [mcr::W](mcr::W) writer structure"] | ||
| 90 | impl crate::Writable for MCR {} | ||
| 91 | #[doc = "CAN_MCR"] | ||
| 92 | pub mod mcr; | ||
| 93 | #[doc = "CAN_MSR\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [msr](msr) module"] | ||
| 94 | pub type MSR = crate::Reg<u32, _MSR>; | ||
| 95 | #[allow(missing_docs)] | ||
| 96 | #[doc(hidden)] | ||
| 97 | pub struct _MSR; | ||
| 98 | #[doc = "`read()` method returns [msr::R](msr::R) reader structure"] | ||
| 99 | impl crate::Readable for MSR {} | ||
| 100 | #[doc = "`write(|w| ..)` method takes [msr::W](msr::W) writer structure"] | ||
| 101 | impl crate::Writable for MSR {} | ||
| 102 | #[doc = "CAN_MSR"] | ||
| 103 | pub mod msr; | ||
| 104 | #[doc = "CAN_TSR\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [tsr](tsr) module"] | ||
| 105 | pub type TSR = crate::Reg<u32, _TSR>; | ||
| 106 | #[allow(missing_docs)] | ||
| 107 | #[doc(hidden)] | ||
| 108 | pub struct _TSR; | ||
| 109 | #[doc = "`read()` method returns [tsr::R](tsr::R) reader structure"] | ||
| 110 | impl crate::Readable for TSR {} | ||
| 111 | #[doc = "`write(|w| ..)` method takes [tsr::W](tsr::W) writer structure"] | ||
| 112 | impl crate::Writable for TSR {} | ||
| 113 | #[doc = "CAN_TSR"] | ||
| 114 | pub mod tsr; | ||
| 115 | #[doc = "CAN_RF0R\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [rfr](rfr) module"] | ||
| 116 | pub type RFR = crate::Reg<u32, _RFR>; | ||
| 117 | #[allow(missing_docs)] | ||
| 118 | #[doc(hidden)] | ||
| 119 | pub struct _RFR; | ||
| 120 | #[doc = "`read()` method returns [rfr::R](rfr::R) reader structure"] | ||
| 121 | impl crate::Readable for RFR {} | ||
| 122 | #[doc = "`write(|w| ..)` method takes [rfr::W](rfr::W) writer structure"] | ||
| 123 | impl crate::Writable for RFR {} | ||
| 124 | #[doc = "CAN_RF0R"] | ||
| 125 | pub mod rfr; | ||
| 126 | #[doc = "CAN_IER\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [ier](ier) module"] | ||
| 127 | pub type IER = crate::Reg<u32, _IER>; | ||
| 128 | #[allow(missing_docs)] | ||
| 129 | #[doc(hidden)] | ||
| 130 | pub struct _IER; | ||
| 131 | #[doc = "`read()` method returns [ier::R](ier::R) reader structure"] | ||
| 132 | impl crate::Readable for IER {} | ||
| 133 | #[doc = "`write(|w| ..)` method takes [ier::W](ier::W) writer structure"] | ||
| 134 | impl crate::Writable for IER {} | ||
| 135 | #[doc = "CAN_IER"] | ||
| 136 | pub mod ier; | ||
| 137 | #[doc = "CAN_ESR\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [esr](esr) module"] | ||
| 138 | pub type ESR = crate::Reg<u32, _ESR>; | ||
| 139 | #[allow(missing_docs)] | ||
| 140 | #[doc(hidden)] | ||
| 141 | pub struct _ESR; | ||
| 142 | #[doc = "`read()` method returns [esr::R](esr::R) reader structure"] | ||
| 143 | impl crate::Readable for ESR {} | ||
| 144 | #[doc = "`write(|w| ..)` method takes [esr::W](esr::W) writer structure"] | ||
| 145 | impl crate::Writable for ESR {} | ||
| 146 | #[doc = "CAN_ESR"] | ||
| 147 | pub mod esr; | ||
| 148 | #[doc = "CAN_BTR\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [btr](btr) module"] | ||
| 149 | pub type BTR = crate::Reg<u32, _BTR>; | ||
| 150 | #[allow(missing_docs)] | ||
| 151 | #[doc(hidden)] | ||
| 152 | pub struct _BTR; | ||
| 153 | #[doc = "`read()` method returns [btr::R](btr::R) reader structure"] | ||
| 154 | impl crate::Readable for BTR {} | ||
| 155 | #[doc = "`write(|w| ..)` method takes [btr::W](btr::W) writer structure"] | ||
| 156 | impl crate::Writable for BTR {} | ||
| 157 | #[doc = "CAN_BTR"] | ||
| 158 | pub mod btr; | ||
| 159 | #[doc = "CAN_FMR\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [fmr](fmr) module"] | ||
| 160 | pub type FMR = crate::Reg<u32, _FMR>; | ||
| 161 | #[allow(missing_docs)] | ||
| 162 | #[doc(hidden)] | ||
| 163 | pub struct _FMR; | ||
| 164 | #[doc = "`read()` method returns [fmr::R](fmr::R) reader structure"] | ||
| 165 | impl crate::Readable for FMR {} | ||
| 166 | #[doc = "`write(|w| ..)` method takes [fmr::W](fmr::W) writer structure"] | ||
| 167 | impl crate::Writable for FMR {} | ||
| 168 | #[doc = "CAN_FMR"] | ||
| 169 | pub mod fmr; | ||
| 170 | #[doc = "CAN_FM1R\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [fm1r](fm1r) module"] | ||
| 171 | pub type FM1R = crate::Reg<u32, _FM1R>; | ||
| 172 | #[allow(missing_docs)] | ||
| 173 | #[doc(hidden)] | ||
| 174 | pub struct _FM1R; | ||
| 175 | #[doc = "`read()` method returns [fm1r::R](fm1r::R) reader structure"] | ||
| 176 | impl crate::Readable for FM1R {} | ||
| 177 | #[doc = "`write(|w| ..)` method takes [fm1r::W](fm1r::W) writer structure"] | ||
| 178 | impl crate::Writable for FM1R {} | ||
| 179 | #[doc = "CAN_FM1R"] | ||
| 180 | pub mod fm1r; | ||
| 181 | #[doc = "CAN_FS1R\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [fs1r](fs1r) module"] | ||
| 182 | pub type FS1R = crate::Reg<u32, _FS1R>; | ||
| 183 | #[allow(missing_docs)] | ||
| 184 | #[doc(hidden)] | ||
| 185 | pub struct _FS1R; | ||
| 186 | #[doc = "`read()` method returns [fs1r::R](fs1r::R) reader structure"] | ||
| 187 | impl crate::Readable for FS1R {} | ||
| 188 | #[doc = "`write(|w| ..)` method takes [fs1r::W](fs1r::W) writer structure"] | ||
| 189 | impl crate::Writable for FS1R {} | ||
| 190 | #[doc = "CAN_FS1R"] | ||
| 191 | pub mod fs1r; | ||
| 192 | #[doc = "CAN_FFA1R\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [ffa1r](ffa1r) module"] | ||
| 193 | pub type FFA1R = crate::Reg<u32, _FFA1R>; | ||
| 194 | #[allow(missing_docs)] | ||
| 195 | #[doc(hidden)] | ||
| 196 | pub struct _FFA1R; | ||
| 197 | #[doc = "`read()` method returns [ffa1r::R](ffa1r::R) reader structure"] | ||
| 198 | impl crate::Readable for FFA1R {} | ||
| 199 | #[doc = "`write(|w| ..)` method takes [ffa1r::W](ffa1r::W) writer structure"] | ||
| 200 | impl crate::Writable for FFA1R {} | ||
| 201 | #[doc = "CAN_FFA1R"] | ||
| 202 | pub mod ffa1r; | ||
| 203 | #[doc = "CAN_FA1R\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [fa1r](fa1r) module"] | ||
| 204 | pub type FA1R = crate::Reg<u32, _FA1R>; | ||
| 205 | #[allow(missing_docs)] | ||
| 206 | #[doc(hidden)] | ||
| 207 | pub struct _FA1R; | ||
| 208 | #[doc = "`read()` method returns [fa1r::R](fa1r::R) reader structure"] | ||
| 209 | impl crate::Readable for FA1R {} | ||
| 210 | #[doc = "`write(|w| ..)` method takes [fa1r::W](fa1r::W) writer structure"] | ||
| 211 | impl crate::Writable for FA1R {} | ||
| 212 | #[doc = "CAN_FA1R"] | ||
| 213 | pub mod fa1r; | ||
diff --git a/embassy-stm32/src/can/bx/pac/can/btr.rs b/embassy-stm32/src/can/bx/pac/can/btr.rs new file mode 100644 index 000000000..0a801c50e --- /dev/null +++ b/embassy-stm32/src/can/bx/pac/can/btr.rs | |||
| @@ -0,0 +1,282 @@ | |||
| 1 | #[doc = "Reader of register BTR"] | ||
| 2 | pub type R = crate::R<u32, super::BTR>; | ||
| 3 | #[doc = "Writer for register BTR"] | ||
| 4 | pub type W = crate::W<u32, super::BTR>; | ||
| 5 | #[doc = "Register BTR `reset()`'s with value 0"] | ||
| 6 | impl crate::ResetValue for super::BTR { | ||
| 7 | type Type = u32; | ||
| 8 | #[inline(always)] | ||
| 9 | fn reset_value() -> Self::Type { | ||
| 10 | 0 | ||
| 11 | } | ||
| 12 | } | ||
| 13 | #[doc = "SILM\n\nValue on reset: 0"] | ||
| 14 | #[derive(Clone, Copy, Debug, PartialEq)] | ||
| 15 | pub enum SILM_A { | ||
| 16 | #[doc = "0: Normal operation"] | ||
| 17 | NORMAL = 0, | ||
| 18 | #[doc = "1: Silent Mode"] | ||
| 19 | SILENT = 1, | ||
| 20 | } | ||
| 21 | impl From<SILM_A> for bool { | ||
| 22 | #[inline(always)] | ||
| 23 | fn from(variant: SILM_A) -> Self { | ||
| 24 | variant as u8 != 0 | ||
| 25 | } | ||
| 26 | } | ||
| 27 | #[doc = "Reader of field `SILM`"] | ||
| 28 | pub type SILM_R = crate::R<bool, SILM_A>; | ||
| 29 | impl SILM_R { | ||
| 30 | #[doc = r"Get enumerated values variant"] | ||
| 31 | #[inline(always)] | ||
| 32 | pub fn variant(&self) -> SILM_A { | ||
| 33 | match self.bits { | ||
| 34 | false => SILM_A::NORMAL, | ||
| 35 | true => SILM_A::SILENT, | ||
| 36 | } | ||
| 37 | } | ||
| 38 | #[doc = "Checks if the value of the field is `NORMAL`"] | ||
| 39 | #[inline(always)] | ||
| 40 | pub fn is_normal(&self) -> bool { | ||
| 41 | *self == SILM_A::NORMAL | ||
| 42 | } | ||
| 43 | #[doc = "Checks if the value of the field is `SILENT`"] | ||
| 44 | #[inline(always)] | ||
| 45 | pub fn is_silent(&self) -> bool { | ||
| 46 | *self == SILM_A::SILENT | ||
| 47 | } | ||
| 48 | } | ||
| 49 | #[doc = "Write proxy for field `SILM`"] | ||
| 50 | pub struct SILM_W<'a> { | ||
| 51 | w: &'a mut W, | ||
| 52 | } | ||
| 53 | impl<'a> SILM_W<'a> { | ||
| 54 | #[doc = r"Writes `variant` to the field"] | ||
| 55 | #[inline(always)] | ||
| 56 | pub fn variant(self, variant: SILM_A) -> &'a mut W { | ||
| 57 | { | ||
| 58 | self.bit(variant.into()) | ||
| 59 | } | ||
| 60 | } | ||
| 61 | #[doc = "Normal operation"] | ||
| 62 | #[inline(always)] | ||
| 63 | pub fn normal(self) -> &'a mut W { | ||
| 64 | self.variant(SILM_A::NORMAL) | ||
| 65 | } | ||
| 66 | #[doc = "Silent Mode"] | ||
| 67 | #[inline(always)] | ||
| 68 | pub fn silent(self) -> &'a mut W { | ||
| 69 | self.variant(SILM_A::SILENT) | ||
| 70 | } | ||
| 71 | #[doc = r"Sets the field bit"] | ||
| 72 | #[inline(always)] | ||
| 73 | pub fn set_bit(self) -> &'a mut W { | ||
| 74 | self.bit(true) | ||
| 75 | } | ||
| 76 | #[doc = r"Clears the field bit"] | ||
| 77 | #[inline(always)] | ||
| 78 | pub fn clear_bit(self) -> &'a mut W { | ||
| 79 | self.bit(false) | ||
| 80 | } | ||
| 81 | #[doc = r"Writes raw bits to the field"] | ||
| 82 | #[inline(always)] | ||
| 83 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 84 | self.w.bits = (self.w.bits & !(0x01 << 31)) | (((value as u32) & 0x01) << 31); | ||
| 85 | self.w | ||
| 86 | } | ||
| 87 | } | ||
| 88 | #[doc = "LBKM\n\nValue on reset: 0"] | ||
| 89 | #[derive(Clone, Copy, Debug, PartialEq)] | ||
| 90 | pub enum LBKM_A { | ||
| 91 | #[doc = "0: Loop Back Mode disabled"] | ||
| 92 | DISABLED = 0, | ||
| 93 | #[doc = "1: Loop Back Mode enabled"] | ||
| 94 | ENABLED = 1, | ||
| 95 | } | ||
| 96 | impl From<LBKM_A> for bool { | ||
| 97 | #[inline(always)] | ||
| 98 | fn from(variant: LBKM_A) -> Self { | ||
| 99 | variant as u8 != 0 | ||
| 100 | } | ||
| 101 | } | ||
| 102 | #[doc = "Reader of field `LBKM`"] | ||
| 103 | pub type LBKM_R = crate::R<bool, LBKM_A>; | ||
| 104 | impl LBKM_R { | ||
| 105 | #[doc = r"Get enumerated values variant"] | ||
| 106 | #[inline(always)] | ||
| 107 | pub fn variant(&self) -> LBKM_A { | ||
| 108 | match self.bits { | ||
| 109 | false => LBKM_A::DISABLED, | ||
| 110 | true => LBKM_A::ENABLED, | ||
| 111 | } | ||
| 112 | } | ||
| 113 | #[doc = "Checks if the value of the field is `DISABLED`"] | ||
| 114 | #[inline(always)] | ||
| 115 | pub fn is_disabled(&self) -> bool { | ||
| 116 | *self == LBKM_A::DISABLED | ||
| 117 | } | ||
| 118 | #[doc = "Checks if the value of the field is `ENABLED`"] | ||
| 119 | #[inline(always)] | ||
| 120 | pub fn is_enabled(&self) -> bool { | ||
| 121 | *self == LBKM_A::ENABLED | ||
| 122 | } | ||
| 123 | } | ||
| 124 | #[doc = "Write proxy for field `LBKM`"] | ||
| 125 | pub struct LBKM_W<'a> { | ||
| 126 | w: &'a mut W, | ||
| 127 | } | ||
| 128 | impl<'a> LBKM_W<'a> { | ||
| 129 | #[doc = r"Writes `variant` to the field"] | ||
| 130 | #[inline(always)] | ||
| 131 | pub fn variant(self, variant: LBKM_A) -> &'a mut W { | ||
| 132 | { | ||
| 133 | self.bit(variant.into()) | ||
| 134 | } | ||
| 135 | } | ||
| 136 | #[doc = "Loop Back Mode disabled"] | ||
| 137 | #[inline(always)] | ||
| 138 | pub fn disabled(self) -> &'a mut W { | ||
| 139 | self.variant(LBKM_A::DISABLED) | ||
| 140 | } | ||
| 141 | #[doc = "Loop Back Mode enabled"] | ||
| 142 | #[inline(always)] | ||
| 143 | pub fn enabled(self) -> &'a mut W { | ||
| 144 | self.variant(LBKM_A::ENABLED) | ||
| 145 | } | ||
| 146 | #[doc = r"Sets the field bit"] | ||
| 147 | #[inline(always)] | ||
| 148 | pub fn set_bit(self) -> &'a mut W { | ||
| 149 | self.bit(true) | ||
| 150 | } | ||
| 151 | #[doc = r"Clears the field bit"] | ||
| 152 | #[inline(always)] | ||
| 153 | pub fn clear_bit(self) -> &'a mut W { | ||
| 154 | self.bit(false) | ||
| 155 | } | ||
| 156 | #[doc = r"Writes raw bits to the field"] | ||
| 157 | #[inline(always)] | ||
| 158 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 159 | self.w.bits = (self.w.bits & !(0x01 << 30)) | (((value as u32) & 0x01) << 30); | ||
| 160 | self.w | ||
| 161 | } | ||
| 162 | } | ||
| 163 | #[doc = "Reader of field `SJW`"] | ||
| 164 | pub type SJW_R = crate::R<u8, u8>; | ||
| 165 | #[doc = "Write proxy for field `SJW`"] | ||
| 166 | pub struct SJW_W<'a> { | ||
| 167 | w: &'a mut W, | ||
| 168 | } | ||
| 169 | impl<'a> SJW_W<'a> { | ||
| 170 | #[doc = r"Writes raw bits to the field"] | ||
| 171 | #[inline(always)] | ||
| 172 | pub unsafe fn bits(self, value: u8) -> &'a mut W { | ||
| 173 | self.w.bits = (self.w.bits & !(0x03 << 24)) | (((value as u32) & 0x03) << 24); | ||
| 174 | self.w | ||
| 175 | } | ||
| 176 | } | ||
| 177 | #[doc = "Reader of field `TS2`"] | ||
| 178 | pub type TS2_R = crate::R<u8, u8>; | ||
| 179 | #[doc = "Write proxy for field `TS2`"] | ||
| 180 | pub struct TS2_W<'a> { | ||
| 181 | w: &'a mut W, | ||
| 182 | } | ||
| 183 | impl<'a> TS2_W<'a> { | ||
| 184 | #[doc = r"Writes raw bits to the field"] | ||
| 185 | #[inline(always)] | ||
| 186 | pub unsafe fn bits(self, value: u8) -> &'a mut W { | ||
| 187 | self.w.bits = (self.w.bits & !(0x07 << 20)) | (((value as u32) & 0x07) << 20); | ||
| 188 | self.w | ||
| 189 | } | ||
| 190 | } | ||
| 191 | #[doc = "Reader of field `TS1`"] | ||
| 192 | pub type TS1_R = crate::R<u8, u8>; | ||
| 193 | #[doc = "Write proxy for field `TS1`"] | ||
| 194 | pub struct TS1_W<'a> { | ||
| 195 | w: &'a mut W, | ||
| 196 | } | ||
| 197 | impl<'a> TS1_W<'a> { | ||
| 198 | #[doc = r"Writes raw bits to the field"] | ||
| 199 | #[inline(always)] | ||
| 200 | pub unsafe fn bits(self, value: u8) -> &'a mut W { | ||
| 201 | self.w.bits = (self.w.bits & !(0x0f << 16)) | (((value as u32) & 0x0f) << 16); | ||
| 202 | self.w | ||
| 203 | } | ||
| 204 | } | ||
| 205 | #[doc = "Reader of field `BRP`"] | ||
| 206 | pub type BRP_R = crate::R<u16, u16>; | ||
| 207 | #[doc = "Write proxy for field `BRP`"] | ||
| 208 | pub struct BRP_W<'a> { | ||
| 209 | w: &'a mut W, | ||
| 210 | } | ||
| 211 | impl<'a> BRP_W<'a> { | ||
| 212 | #[doc = r"Writes raw bits to the field"] | ||
| 213 | #[inline(always)] | ||
| 214 | pub unsafe fn bits(self, value: u16) -> &'a mut W { | ||
| 215 | self.w.bits = (self.w.bits & !0x03ff) | ((value as u32) & 0x03ff); | ||
| 216 | self.w | ||
| 217 | } | ||
| 218 | } | ||
| 219 | impl R { | ||
| 220 | #[doc = "Bit 31 - SILM"] | ||
| 221 | #[inline(always)] | ||
| 222 | pub fn silm(&self) -> SILM_R { | ||
| 223 | SILM_R::new(((self.bits >> 31) & 0x01) != 0) | ||
| 224 | } | ||
| 225 | #[doc = "Bit 30 - LBKM"] | ||
| 226 | #[inline(always)] | ||
| 227 | pub fn lbkm(&self) -> LBKM_R { | ||
| 228 | LBKM_R::new(((self.bits >> 30) & 0x01) != 0) | ||
| 229 | } | ||
| 230 | #[doc = "Bits 24:25 - SJW"] | ||
| 231 | #[inline(always)] | ||
| 232 | pub fn sjw(&self) -> SJW_R { | ||
| 233 | SJW_R::new(((self.bits >> 24) & 0x03) as u8) | ||
| 234 | } | ||
| 235 | #[doc = "Bits 20:22 - TS2"] | ||
| 236 | #[inline(always)] | ||
| 237 | pub fn ts2(&self) -> TS2_R { | ||
| 238 | TS2_R::new(((self.bits >> 20) & 0x07) as u8) | ||
| 239 | } | ||
| 240 | #[doc = "Bits 16:19 - TS1"] | ||
| 241 | #[inline(always)] | ||
| 242 | pub fn ts1(&self) -> TS1_R { | ||
| 243 | TS1_R::new(((self.bits >> 16) & 0x0f) as u8) | ||
| 244 | } | ||
| 245 | #[doc = "Bits 0:9 - BRP"] | ||
| 246 | #[inline(always)] | ||
| 247 | pub fn brp(&self) -> BRP_R { | ||
| 248 | BRP_R::new((self.bits & 0x03ff) as u16) | ||
| 249 | } | ||
| 250 | } | ||
| 251 | impl W { | ||
| 252 | #[doc = "Bit 31 - SILM"] | ||
| 253 | #[inline(always)] | ||
| 254 | pub fn silm(&mut self) -> SILM_W { | ||
| 255 | SILM_W { w: self } | ||
| 256 | } | ||
| 257 | #[doc = "Bit 30 - LBKM"] | ||
| 258 | #[inline(always)] | ||
| 259 | pub fn lbkm(&mut self) -> LBKM_W { | ||
| 260 | LBKM_W { w: self } | ||
| 261 | } | ||
| 262 | #[doc = "Bits 24:25 - SJW"] | ||
| 263 | #[inline(always)] | ||
| 264 | pub fn sjw(&mut self) -> SJW_W { | ||
| 265 | SJW_W { w: self } | ||
| 266 | } | ||
| 267 | #[doc = "Bits 20:22 - TS2"] | ||
| 268 | #[inline(always)] | ||
| 269 | pub fn ts2(&mut self) -> TS2_W { | ||
| 270 | TS2_W { w: self } | ||
| 271 | } | ||
| 272 | #[doc = "Bits 16:19 - TS1"] | ||
| 273 | #[inline(always)] | ||
| 274 | pub fn ts1(&mut self) -> TS1_W { | ||
| 275 | TS1_W { w: self } | ||
| 276 | } | ||
| 277 | #[doc = "Bits 0:9 - BRP"] | ||
| 278 | #[inline(always)] | ||
| 279 | pub fn brp(&mut self) -> BRP_W { | ||
| 280 | BRP_W { w: self } | ||
| 281 | } | ||
| 282 | } | ||
diff --git a/embassy-stm32/src/can/bx/pac/can/esr.rs b/embassy-stm32/src/can/bx/pac/can/esr.rs new file mode 100644 index 000000000..9ea7c5a24 --- /dev/null +++ b/embassy-stm32/src/can/bx/pac/can/esr.rs | |||
| @@ -0,0 +1,206 @@ | |||
| 1 | #[doc = "Reader of register ESR"] | ||
| 2 | pub type R = crate::R<u32, super::ESR>; | ||
| 3 | #[doc = "Writer for register ESR"] | ||
| 4 | pub type W = crate::W<u32, super::ESR>; | ||
| 5 | #[doc = "Register ESR `reset()`'s with value 0"] | ||
| 6 | impl crate::ResetValue for super::ESR { | ||
| 7 | type Type = u32; | ||
| 8 | #[inline(always)] | ||
| 9 | fn reset_value() -> Self::Type { | ||
| 10 | 0 | ||
| 11 | } | ||
| 12 | } | ||
| 13 | #[doc = "Reader of field `REC`"] | ||
| 14 | pub type REC_R = crate::R<u8, u8>; | ||
| 15 | #[doc = "Reader of field `TEC`"] | ||
| 16 | pub type TEC_R = crate::R<u8, u8>; | ||
| 17 | #[doc = "LEC\n\nValue on reset: 0"] | ||
| 18 | #[derive(Clone, Copy, Debug, PartialEq)] | ||
| 19 | #[repr(u8)] | ||
| 20 | pub enum LEC_A { | ||
| 21 | #[doc = "0: No Error"] | ||
| 22 | NOERROR = 0, | ||
| 23 | #[doc = "1: Stuff Error"] | ||
| 24 | STUFF = 1, | ||
| 25 | #[doc = "2: Form Error"] | ||
| 26 | FORM = 2, | ||
| 27 | #[doc = "3: Acknowledgment Error"] | ||
| 28 | ACK = 3, | ||
| 29 | #[doc = "4: Bit recessive Error"] | ||
| 30 | BITRECESSIVE = 4, | ||
| 31 | #[doc = "5: Bit dominant Error"] | ||
| 32 | BITDOMINANT = 5, | ||
| 33 | #[doc = "6: CRC Error"] | ||
| 34 | CRC = 6, | ||
| 35 | #[doc = "7: Set by software"] | ||
| 36 | CUSTOM = 7, | ||
| 37 | } | ||
| 38 | impl From<LEC_A> for u8 { | ||
| 39 | #[inline(always)] | ||
| 40 | fn from(variant: LEC_A) -> Self { | ||
| 41 | variant as _ | ||
| 42 | } | ||
| 43 | } | ||
| 44 | #[doc = "Reader of field `LEC`"] | ||
| 45 | pub type LEC_R = crate::R<u8, LEC_A>; | ||
| 46 | impl LEC_R { | ||
| 47 | #[doc = r"Get enumerated values variant"] | ||
| 48 | #[inline(always)] | ||
| 49 | pub fn variant(&self) -> LEC_A { | ||
| 50 | match self.bits { | ||
| 51 | 0 => LEC_A::NOERROR, | ||
| 52 | 1 => LEC_A::STUFF, | ||
| 53 | 2 => LEC_A::FORM, | ||
| 54 | 3 => LEC_A::ACK, | ||
| 55 | 4 => LEC_A::BITRECESSIVE, | ||
| 56 | 5 => LEC_A::BITDOMINANT, | ||
| 57 | 6 => LEC_A::CRC, | ||
| 58 | 7 => LEC_A::CUSTOM, | ||
| 59 | _ => unreachable!(), | ||
| 60 | } | ||
| 61 | } | ||
| 62 | #[doc = "Checks if the value of the field is `NOERROR`"] | ||
| 63 | #[inline(always)] | ||
| 64 | pub fn is_no_error(&self) -> bool { | ||
| 65 | *self == LEC_A::NOERROR | ||
| 66 | } | ||
| 67 | #[doc = "Checks if the value of the field is `STUFF`"] | ||
| 68 | #[inline(always)] | ||
| 69 | pub fn is_stuff(&self) -> bool { | ||
| 70 | *self == LEC_A::STUFF | ||
| 71 | } | ||
| 72 | #[doc = "Checks if the value of the field is `FORM`"] | ||
| 73 | #[inline(always)] | ||
| 74 | pub fn is_form(&self) -> bool { | ||
| 75 | *self == LEC_A::FORM | ||
| 76 | } | ||
| 77 | #[doc = "Checks if the value of the field is `ACK`"] | ||
| 78 | #[inline(always)] | ||
| 79 | pub fn is_ack(&self) -> bool { | ||
| 80 | *self == LEC_A::ACK | ||
| 81 | } | ||
| 82 | #[doc = "Checks if the value of the field is `BITRECESSIVE`"] | ||
| 83 | #[inline(always)] | ||
| 84 | pub fn is_bit_recessive(&self) -> bool { | ||
| 85 | *self == LEC_A::BITRECESSIVE | ||
| 86 | } | ||
| 87 | #[doc = "Checks if the value of the field is `BITDOMINANT`"] | ||
| 88 | #[inline(always)] | ||
| 89 | pub fn is_bit_dominant(&self) -> bool { | ||
| 90 | *self == LEC_A::BITDOMINANT | ||
| 91 | } | ||
| 92 | #[doc = "Checks if the value of the field is `CRC`"] | ||
| 93 | #[inline(always)] | ||
| 94 | pub fn is_crc(&self) -> bool { | ||
| 95 | *self == LEC_A::CRC | ||
| 96 | } | ||
| 97 | #[doc = "Checks if the value of the field is `CUSTOM`"] | ||
| 98 | #[inline(always)] | ||
| 99 | pub fn is_custom(&self) -> bool { | ||
| 100 | *self == LEC_A::CUSTOM | ||
| 101 | } | ||
| 102 | } | ||
| 103 | #[doc = "Write proxy for field `LEC`"] | ||
| 104 | pub struct LEC_W<'a> { | ||
| 105 | w: &'a mut W, | ||
| 106 | } | ||
| 107 | impl<'a> LEC_W<'a> { | ||
| 108 | #[doc = r"Writes `variant` to the field"] | ||
| 109 | #[inline(always)] | ||
| 110 | pub fn variant(self, variant: LEC_A) -> &'a mut W { | ||
| 111 | { | ||
| 112 | self.bits(variant.into()) | ||
| 113 | } | ||
| 114 | } | ||
| 115 | #[doc = "No Error"] | ||
| 116 | #[inline(always)] | ||
| 117 | pub fn no_error(self) -> &'a mut W { | ||
| 118 | self.variant(LEC_A::NOERROR) | ||
| 119 | } | ||
| 120 | #[doc = "Stuff Error"] | ||
| 121 | #[inline(always)] | ||
| 122 | pub fn stuff(self) -> &'a mut W { | ||
| 123 | self.variant(LEC_A::STUFF) | ||
| 124 | } | ||
| 125 | #[doc = "Form Error"] | ||
| 126 | #[inline(always)] | ||
| 127 | pub fn form(self) -> &'a mut W { | ||
| 128 | self.variant(LEC_A::FORM) | ||
| 129 | } | ||
| 130 | #[doc = "Acknowledgment Error"] | ||
| 131 | #[inline(always)] | ||
| 132 | pub fn ack(self) -> &'a mut W { | ||
| 133 | self.variant(LEC_A::ACK) | ||
| 134 | } | ||
| 135 | #[doc = "Bit recessive Error"] | ||
| 136 | #[inline(always)] | ||
| 137 | pub fn bit_recessive(self) -> &'a mut W { | ||
| 138 | self.variant(LEC_A::BITRECESSIVE) | ||
| 139 | } | ||
| 140 | #[doc = "Bit dominant Error"] | ||
| 141 | #[inline(always)] | ||
| 142 | pub fn bit_dominant(self) -> &'a mut W { | ||
| 143 | self.variant(LEC_A::BITDOMINANT) | ||
| 144 | } | ||
| 145 | #[doc = "CRC Error"] | ||
| 146 | #[inline(always)] | ||
| 147 | pub fn crc(self) -> &'a mut W { | ||
| 148 | self.variant(LEC_A::CRC) | ||
| 149 | } | ||
| 150 | #[doc = "Set by software"] | ||
| 151 | #[inline(always)] | ||
| 152 | pub fn custom(self) -> &'a mut W { | ||
| 153 | self.variant(LEC_A::CUSTOM) | ||
| 154 | } | ||
| 155 | #[doc = r"Writes raw bits to the field"] | ||
| 156 | #[inline(always)] | ||
| 157 | pub fn bits(self, value: u8) -> &'a mut W { | ||
| 158 | self.w.bits = (self.w.bits & !(0x07 << 4)) | (((value as u32) & 0x07) << 4); | ||
| 159 | self.w | ||
| 160 | } | ||
| 161 | } | ||
| 162 | #[doc = "Reader of field `BOFF`"] | ||
| 163 | pub type BOFF_R = crate::R<bool, bool>; | ||
| 164 | #[doc = "Reader of field `EPVF`"] | ||
| 165 | pub type EPVF_R = crate::R<bool, bool>; | ||
| 166 | #[doc = "Reader of field `EWGF`"] | ||
| 167 | pub type EWGF_R = crate::R<bool, bool>; | ||
| 168 | impl R { | ||
| 169 | #[doc = "Bits 24:31 - REC"] | ||
| 170 | #[inline(always)] | ||
| 171 | pub fn rec(&self) -> REC_R { | ||
| 172 | REC_R::new(((self.bits >> 24) & 0xff) as u8) | ||
| 173 | } | ||
| 174 | #[doc = "Bits 16:23 - TEC"] | ||
| 175 | #[inline(always)] | ||
| 176 | pub fn tec(&self) -> TEC_R { | ||
| 177 | TEC_R::new(((self.bits >> 16) & 0xff) as u8) | ||
| 178 | } | ||
| 179 | #[doc = "Bits 4:6 - LEC"] | ||
| 180 | #[inline(always)] | ||
| 181 | pub fn lec(&self) -> LEC_R { | ||
| 182 | LEC_R::new(((self.bits >> 4) & 0x07) as u8) | ||
| 183 | } | ||
| 184 | #[doc = "Bit 2 - BOFF"] | ||
| 185 | #[inline(always)] | ||
| 186 | pub fn boff(&self) -> BOFF_R { | ||
| 187 | BOFF_R::new(((self.bits >> 2) & 0x01) != 0) | ||
| 188 | } | ||
| 189 | #[doc = "Bit 1 - EPVF"] | ||
| 190 | #[inline(always)] | ||
| 191 | pub fn epvf(&self) -> EPVF_R { | ||
| 192 | EPVF_R::new(((self.bits >> 1) & 0x01) != 0) | ||
| 193 | } | ||
| 194 | #[doc = "Bit 0 - EWGF"] | ||
| 195 | #[inline(always)] | ||
| 196 | pub fn ewgf(&self) -> EWGF_R { | ||
| 197 | EWGF_R::new((self.bits & 0x01) != 0) | ||
| 198 | } | ||
| 199 | } | ||
| 200 | impl W { | ||
| 201 | #[doc = "Bits 4:6 - LEC"] | ||
| 202 | #[inline(always)] | ||
| 203 | pub fn lec(&mut self) -> LEC_W { | ||
| 204 | LEC_W { w: self } | ||
| 205 | } | ||
| 206 | } | ||
diff --git a/embassy-stm32/src/can/bx/pac/can/fa1r.rs b/embassy-stm32/src/can/bx/pac/can/fa1r.rs new file mode 100644 index 000000000..797e4e074 --- /dev/null +++ b/embassy-stm32/src/can/bx/pac/can/fa1r.rs | |||
| @@ -0,0 +1,492 @@ | |||
| 1 | #[doc = "Reader of register FA1R"] | ||
| 2 | pub type R = crate::R<u32, super::FA1R>; | ||
| 3 | #[doc = "Writer for register FA1R"] | ||
| 4 | pub type W = crate::W<u32, super::FA1R>; | ||
| 5 | #[doc = "Register FA1R `reset()`'s with value 0"] | ||
| 6 | impl crate::ResetValue for super::FA1R { | ||
| 7 | type Type = u32; | ||
| 8 | #[inline(always)] | ||
| 9 | fn reset_value() -> Self::Type { | ||
| 10 | 0 | ||
| 11 | } | ||
| 12 | } | ||
| 13 | #[doc = "Reader of field `FACT0`"] | ||
| 14 | pub type FACT0_R = crate::R<bool, bool>; | ||
| 15 | #[doc = "Write proxy for field `FACT0`"] | ||
| 16 | pub struct FACT0_W<'a> { | ||
| 17 | w: &'a mut W, | ||
| 18 | } | ||
| 19 | impl<'a> FACT0_W<'a> { | ||
| 20 | #[doc = r"Sets the field bit"] | ||
| 21 | #[inline(always)] | ||
| 22 | pub fn set_bit(self) -> &'a mut W { | ||
| 23 | self.bit(true) | ||
| 24 | } | ||
| 25 | #[doc = r"Clears the field bit"] | ||
| 26 | #[inline(always)] | ||
| 27 | pub fn clear_bit(self) -> &'a mut W { | ||
| 28 | self.bit(false) | ||
| 29 | } | ||
| 30 | #[doc = r"Writes raw bits to the field"] | ||
| 31 | #[inline(always)] | ||
| 32 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 33 | self.w.bits = (self.w.bits & !0x01) | ((value as u32) & 0x01); | ||
| 34 | self.w | ||
| 35 | } | ||
| 36 | } | ||
| 37 | #[doc = "Reader of field `FACT1`"] | ||
| 38 | pub type FACT1_R = crate::R<bool, bool>; | ||
| 39 | #[doc = "Write proxy for field `FACT1`"] | ||
| 40 | pub struct FACT1_W<'a> { | ||
| 41 | w: &'a mut W, | ||
| 42 | } | ||
| 43 | impl<'a> FACT1_W<'a> { | ||
| 44 | #[doc = r"Sets the field bit"] | ||
| 45 | #[inline(always)] | ||
| 46 | pub fn set_bit(self) -> &'a mut W { | ||
| 47 | self.bit(true) | ||
| 48 | } | ||
| 49 | #[doc = r"Clears the field bit"] | ||
| 50 | #[inline(always)] | ||
| 51 | pub fn clear_bit(self) -> &'a mut W { | ||
| 52 | self.bit(false) | ||
| 53 | } | ||
| 54 | #[doc = r"Writes raw bits to the field"] | ||
| 55 | #[inline(always)] | ||
| 56 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 57 | self.w.bits = (self.w.bits & !(0x01 << 1)) | (((value as u32) & 0x01) << 1); | ||
| 58 | self.w | ||
| 59 | } | ||
| 60 | } | ||
| 61 | #[doc = "Reader of field `FACT2`"] | ||
| 62 | pub type FACT2_R = crate::R<bool, bool>; | ||
| 63 | #[doc = "Write proxy for field `FACT2`"] | ||
| 64 | pub struct FACT2_W<'a> { | ||
| 65 | w: &'a mut W, | ||
| 66 | } | ||
| 67 | impl<'a> FACT2_W<'a> { | ||
| 68 | #[doc = r"Sets the field bit"] | ||
| 69 | #[inline(always)] | ||
| 70 | pub fn set_bit(self) -> &'a mut W { | ||
| 71 | self.bit(true) | ||
| 72 | } | ||
| 73 | #[doc = r"Clears the field bit"] | ||
| 74 | #[inline(always)] | ||
| 75 | pub fn clear_bit(self) -> &'a mut W { | ||
| 76 | self.bit(false) | ||
| 77 | } | ||
| 78 | #[doc = r"Writes raw bits to the field"] | ||
| 79 | #[inline(always)] | ||
| 80 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 81 | self.w.bits = (self.w.bits & !(0x01 << 2)) | (((value as u32) & 0x01) << 2); | ||
| 82 | self.w | ||
| 83 | } | ||
| 84 | } | ||
| 85 | #[doc = "Reader of field `FACT3`"] | ||
| 86 | pub type FACT3_R = crate::R<bool, bool>; | ||
| 87 | #[doc = "Write proxy for field `FACT3`"] | ||
| 88 | pub struct FACT3_W<'a> { | ||
| 89 | w: &'a mut W, | ||
| 90 | } | ||
| 91 | impl<'a> FACT3_W<'a> { | ||
| 92 | #[doc = r"Sets the field bit"] | ||
| 93 | #[inline(always)] | ||
| 94 | pub fn set_bit(self) -> &'a mut W { | ||
| 95 | self.bit(true) | ||
| 96 | } | ||
| 97 | #[doc = r"Clears the field bit"] | ||
| 98 | #[inline(always)] | ||
| 99 | pub fn clear_bit(self) -> &'a mut W { | ||
| 100 | self.bit(false) | ||
| 101 | } | ||
| 102 | #[doc = r"Writes raw bits to the field"] | ||
| 103 | #[inline(always)] | ||
| 104 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 105 | self.w.bits = (self.w.bits & !(0x01 << 3)) | (((value as u32) & 0x01) << 3); | ||
| 106 | self.w | ||
| 107 | } | ||
| 108 | } | ||
| 109 | #[doc = "Reader of field `FACT4`"] | ||
| 110 | pub type FACT4_R = crate::R<bool, bool>; | ||
| 111 | #[doc = "Write proxy for field `FACT4`"] | ||
| 112 | pub struct FACT4_W<'a> { | ||
| 113 | w: &'a mut W, | ||
| 114 | } | ||
| 115 | impl<'a> FACT4_W<'a> { | ||
| 116 | #[doc = r"Sets the field bit"] | ||
| 117 | #[inline(always)] | ||
| 118 | pub fn set_bit(self) -> &'a mut W { | ||
| 119 | self.bit(true) | ||
| 120 | } | ||
| 121 | #[doc = r"Clears the field bit"] | ||
| 122 | #[inline(always)] | ||
| 123 | pub fn clear_bit(self) -> &'a mut W { | ||
| 124 | self.bit(false) | ||
| 125 | } | ||
| 126 | #[doc = r"Writes raw bits to the field"] | ||
| 127 | #[inline(always)] | ||
| 128 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 129 | self.w.bits = (self.w.bits & !(0x01 << 4)) | (((value as u32) & 0x01) << 4); | ||
| 130 | self.w | ||
| 131 | } | ||
| 132 | } | ||
| 133 | #[doc = "Reader of field `FACT5`"] | ||
| 134 | pub type FACT5_R = crate::R<bool, bool>; | ||
| 135 | #[doc = "Write proxy for field `FACT5`"] | ||
| 136 | pub struct FACT5_W<'a> { | ||
| 137 | w: &'a mut W, | ||
| 138 | } | ||
| 139 | impl<'a> FACT5_W<'a> { | ||
| 140 | #[doc = r"Sets the field bit"] | ||
| 141 | #[inline(always)] | ||
| 142 | pub fn set_bit(self) -> &'a mut W { | ||
| 143 | self.bit(true) | ||
| 144 | } | ||
| 145 | #[doc = r"Clears the field bit"] | ||
| 146 | #[inline(always)] | ||
| 147 | pub fn clear_bit(self) -> &'a mut W { | ||
| 148 | self.bit(false) | ||
| 149 | } | ||
| 150 | #[doc = r"Writes raw bits to the field"] | ||
| 151 | #[inline(always)] | ||
| 152 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 153 | self.w.bits = (self.w.bits & !(0x01 << 5)) | (((value as u32) & 0x01) << 5); | ||
| 154 | self.w | ||
| 155 | } | ||
| 156 | } | ||
| 157 | #[doc = "Reader of field `FACT6`"] | ||
| 158 | pub type FACT6_R = crate::R<bool, bool>; | ||
| 159 | #[doc = "Write proxy for field `FACT6`"] | ||
| 160 | pub struct FACT6_W<'a> { | ||
| 161 | w: &'a mut W, | ||
| 162 | } | ||
| 163 | impl<'a> FACT6_W<'a> { | ||
| 164 | #[doc = r"Sets the field bit"] | ||
| 165 | #[inline(always)] | ||
| 166 | pub fn set_bit(self) -> &'a mut W { | ||
| 167 | self.bit(true) | ||
| 168 | } | ||
| 169 | #[doc = r"Clears the field bit"] | ||
| 170 | #[inline(always)] | ||
| 171 | pub fn clear_bit(self) -> &'a mut W { | ||
| 172 | self.bit(false) | ||
| 173 | } | ||
| 174 | #[doc = r"Writes raw bits to the field"] | ||
| 175 | #[inline(always)] | ||
| 176 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 177 | self.w.bits = (self.w.bits & !(0x01 << 6)) | (((value as u32) & 0x01) << 6); | ||
| 178 | self.w | ||
| 179 | } | ||
| 180 | } | ||
| 181 | #[doc = "Reader of field `FACT7`"] | ||
| 182 | pub type FACT7_R = crate::R<bool, bool>; | ||
| 183 | #[doc = "Write proxy for field `FACT7`"] | ||
| 184 | pub struct FACT7_W<'a> { | ||
| 185 | w: &'a mut W, | ||
| 186 | } | ||
| 187 | impl<'a> FACT7_W<'a> { | ||
| 188 | #[doc = r"Sets the field bit"] | ||
| 189 | #[inline(always)] | ||
| 190 | pub fn set_bit(self) -> &'a mut W { | ||
| 191 | self.bit(true) | ||
| 192 | } | ||
| 193 | #[doc = r"Clears the field bit"] | ||
| 194 | #[inline(always)] | ||
| 195 | pub fn clear_bit(self) -> &'a mut W { | ||
| 196 | self.bit(false) | ||
| 197 | } | ||
| 198 | #[doc = r"Writes raw bits to the field"] | ||
| 199 | #[inline(always)] | ||
| 200 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 201 | self.w.bits = (self.w.bits & !(0x01 << 7)) | (((value as u32) & 0x01) << 7); | ||
| 202 | self.w | ||
| 203 | } | ||
| 204 | } | ||
| 205 | #[doc = "Reader of field `FACT8`"] | ||
| 206 | pub type FACT8_R = crate::R<bool, bool>; | ||
| 207 | #[doc = "Write proxy for field `FACT8`"] | ||
| 208 | pub struct FACT8_W<'a> { | ||
| 209 | w: &'a mut W, | ||
| 210 | } | ||
| 211 | impl<'a> FACT8_W<'a> { | ||
| 212 | #[doc = r"Sets the field bit"] | ||
| 213 | #[inline(always)] | ||
| 214 | pub fn set_bit(self) -> &'a mut W { | ||
| 215 | self.bit(true) | ||
| 216 | } | ||
| 217 | #[doc = r"Clears the field bit"] | ||
| 218 | #[inline(always)] | ||
| 219 | pub fn clear_bit(self) -> &'a mut W { | ||
| 220 | self.bit(false) | ||
| 221 | } | ||
| 222 | #[doc = r"Writes raw bits to the field"] | ||
| 223 | #[inline(always)] | ||
| 224 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 225 | self.w.bits = (self.w.bits & !(0x01 << 8)) | (((value as u32) & 0x01) << 8); | ||
| 226 | self.w | ||
| 227 | } | ||
| 228 | } | ||
| 229 | #[doc = "Reader of field `FACT9`"] | ||
| 230 | pub type FACT9_R = crate::R<bool, bool>; | ||
| 231 | #[doc = "Write proxy for field `FACT9`"] | ||
| 232 | pub struct FACT9_W<'a> { | ||
| 233 | w: &'a mut W, | ||
| 234 | } | ||
| 235 | impl<'a> FACT9_W<'a> { | ||
| 236 | #[doc = r"Sets the field bit"] | ||
| 237 | #[inline(always)] | ||
| 238 | pub fn set_bit(self) -> &'a mut W { | ||
| 239 | self.bit(true) | ||
| 240 | } | ||
| 241 | #[doc = r"Clears the field bit"] | ||
| 242 | #[inline(always)] | ||
| 243 | pub fn clear_bit(self) -> &'a mut W { | ||
| 244 | self.bit(false) | ||
| 245 | } | ||
| 246 | #[doc = r"Writes raw bits to the field"] | ||
| 247 | #[inline(always)] | ||
| 248 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 249 | self.w.bits = (self.w.bits & !(0x01 << 9)) | (((value as u32) & 0x01) << 9); | ||
| 250 | self.w | ||
| 251 | } | ||
| 252 | } | ||
| 253 | #[doc = "Reader of field `FACT10`"] | ||
| 254 | pub type FACT10_R = crate::R<bool, bool>; | ||
| 255 | #[doc = "Write proxy for field `FACT10`"] | ||
| 256 | pub struct FACT10_W<'a> { | ||
| 257 | w: &'a mut W, | ||
| 258 | } | ||
| 259 | impl<'a> FACT10_W<'a> { | ||
| 260 | #[doc = r"Sets the field bit"] | ||
| 261 | #[inline(always)] | ||
| 262 | pub fn set_bit(self) -> &'a mut W { | ||
| 263 | self.bit(true) | ||
| 264 | } | ||
| 265 | #[doc = r"Clears the field bit"] | ||
| 266 | #[inline(always)] | ||
| 267 | pub fn clear_bit(self) -> &'a mut W { | ||
| 268 | self.bit(false) | ||
| 269 | } | ||
| 270 | #[doc = r"Writes raw bits to the field"] | ||
| 271 | #[inline(always)] | ||
| 272 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 273 | self.w.bits = (self.w.bits & !(0x01 << 10)) | (((value as u32) & 0x01) << 10); | ||
| 274 | self.w | ||
| 275 | } | ||
| 276 | } | ||
| 277 | #[doc = "Reader of field `FACT11`"] | ||
| 278 | pub type FACT11_R = crate::R<bool, bool>; | ||
| 279 | #[doc = "Write proxy for field `FACT11`"] | ||
| 280 | pub struct FACT11_W<'a> { | ||
| 281 | w: &'a mut W, | ||
| 282 | } | ||
| 283 | impl<'a> FACT11_W<'a> { | ||
| 284 | #[doc = r"Sets the field bit"] | ||
| 285 | #[inline(always)] | ||
| 286 | pub fn set_bit(self) -> &'a mut W { | ||
| 287 | self.bit(true) | ||
| 288 | } | ||
| 289 | #[doc = r"Clears the field bit"] | ||
| 290 | #[inline(always)] | ||
| 291 | pub fn clear_bit(self) -> &'a mut W { | ||
| 292 | self.bit(false) | ||
| 293 | } | ||
| 294 | #[doc = r"Writes raw bits to the field"] | ||
| 295 | #[inline(always)] | ||
| 296 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 297 | self.w.bits = (self.w.bits & !(0x01 << 11)) | (((value as u32) & 0x01) << 11); | ||
| 298 | self.w | ||
| 299 | } | ||
| 300 | } | ||
| 301 | #[doc = "Reader of field `FACT12`"] | ||
| 302 | pub type FACT12_R = crate::R<bool, bool>; | ||
| 303 | #[doc = "Write proxy for field `FACT12`"] | ||
| 304 | pub struct FACT12_W<'a> { | ||
| 305 | w: &'a mut W, | ||
| 306 | } | ||
| 307 | impl<'a> FACT12_W<'a> { | ||
| 308 | #[doc = r"Sets the field bit"] | ||
| 309 | #[inline(always)] | ||
| 310 | pub fn set_bit(self) -> &'a mut W { | ||
| 311 | self.bit(true) | ||
| 312 | } | ||
| 313 | #[doc = r"Clears the field bit"] | ||
| 314 | #[inline(always)] | ||
| 315 | pub fn clear_bit(self) -> &'a mut W { | ||
| 316 | self.bit(false) | ||
| 317 | } | ||
| 318 | #[doc = r"Writes raw bits to the field"] | ||
| 319 | #[inline(always)] | ||
| 320 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 321 | self.w.bits = (self.w.bits & !(0x01 << 12)) | (((value as u32) & 0x01) << 12); | ||
| 322 | self.w | ||
| 323 | } | ||
| 324 | } | ||
| 325 | #[doc = "Reader of field `FACT13`"] | ||
| 326 | pub type FACT13_R = crate::R<bool, bool>; | ||
| 327 | #[doc = "Write proxy for field `FACT13`"] | ||
| 328 | pub struct FACT13_W<'a> { | ||
| 329 | w: &'a mut W, | ||
| 330 | } | ||
| 331 | impl<'a> FACT13_W<'a> { | ||
| 332 | #[doc = r"Sets the field bit"] | ||
| 333 | #[inline(always)] | ||
| 334 | pub fn set_bit(self) -> &'a mut W { | ||
| 335 | self.bit(true) | ||
| 336 | } | ||
| 337 | #[doc = r"Clears the field bit"] | ||
| 338 | #[inline(always)] | ||
| 339 | pub fn clear_bit(self) -> &'a mut W { | ||
| 340 | self.bit(false) | ||
| 341 | } | ||
| 342 | #[doc = r"Writes raw bits to the field"] | ||
| 343 | #[inline(always)] | ||
| 344 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 345 | self.w.bits = (self.w.bits & !(0x01 << 13)) | (((value as u32) & 0x01) << 13); | ||
| 346 | self.w | ||
| 347 | } | ||
| 348 | } | ||
| 349 | impl R { | ||
| 350 | #[doc = "Bit 0 - Filter active"] | ||
| 351 | #[inline(always)] | ||
| 352 | pub fn fact0(&self) -> FACT0_R { | ||
| 353 | FACT0_R::new((self.bits & 0x01) != 0) | ||
| 354 | } | ||
| 355 | #[doc = "Bit 1 - Filter active"] | ||
| 356 | #[inline(always)] | ||
| 357 | pub fn fact1(&self) -> FACT1_R { | ||
| 358 | FACT1_R::new(((self.bits >> 1) & 0x01) != 0) | ||
| 359 | } | ||
| 360 | #[doc = "Bit 2 - Filter active"] | ||
| 361 | #[inline(always)] | ||
| 362 | pub fn fact2(&self) -> FACT2_R { | ||
| 363 | FACT2_R::new(((self.bits >> 2) & 0x01) != 0) | ||
| 364 | } | ||
| 365 | #[doc = "Bit 3 - Filter active"] | ||
| 366 | #[inline(always)] | ||
| 367 | pub fn fact3(&self) -> FACT3_R { | ||
| 368 | FACT3_R::new(((self.bits >> 3) & 0x01) != 0) | ||
| 369 | } | ||
| 370 | #[doc = "Bit 4 - Filter active"] | ||
| 371 | #[inline(always)] | ||
| 372 | pub fn fact4(&self) -> FACT4_R { | ||
| 373 | FACT4_R::new(((self.bits >> 4) & 0x01) != 0) | ||
| 374 | } | ||
| 375 | #[doc = "Bit 5 - Filter active"] | ||
| 376 | #[inline(always)] | ||
| 377 | pub fn fact5(&self) -> FACT5_R { | ||
| 378 | FACT5_R::new(((self.bits >> 5) & 0x01) != 0) | ||
| 379 | } | ||
| 380 | #[doc = "Bit 6 - Filter active"] | ||
| 381 | #[inline(always)] | ||
| 382 | pub fn fact6(&self) -> FACT6_R { | ||
| 383 | FACT6_R::new(((self.bits >> 6) & 0x01) != 0) | ||
| 384 | } | ||
| 385 | #[doc = "Bit 7 - Filter active"] | ||
| 386 | #[inline(always)] | ||
| 387 | pub fn fact7(&self) -> FACT7_R { | ||
| 388 | FACT7_R::new(((self.bits >> 7) & 0x01) != 0) | ||
| 389 | } | ||
| 390 | #[doc = "Bit 8 - Filter active"] | ||
| 391 | #[inline(always)] | ||
| 392 | pub fn fact8(&self) -> FACT8_R { | ||
| 393 | FACT8_R::new(((self.bits >> 8) & 0x01) != 0) | ||
| 394 | } | ||
| 395 | #[doc = "Bit 9 - Filter active"] | ||
| 396 | #[inline(always)] | ||
| 397 | pub fn fact9(&self) -> FACT9_R { | ||
| 398 | FACT9_R::new(((self.bits >> 9) & 0x01) != 0) | ||
| 399 | } | ||
| 400 | #[doc = "Bit 10 - Filter active"] | ||
| 401 | #[inline(always)] | ||
| 402 | pub fn fact10(&self) -> FACT10_R { | ||
| 403 | FACT10_R::new(((self.bits >> 10) & 0x01) != 0) | ||
| 404 | } | ||
| 405 | #[doc = "Bit 11 - Filter active"] | ||
| 406 | #[inline(always)] | ||
| 407 | pub fn fact11(&self) -> FACT11_R { | ||
| 408 | FACT11_R::new(((self.bits >> 11) & 0x01) != 0) | ||
| 409 | } | ||
| 410 | #[doc = "Bit 12 - Filter active"] | ||
| 411 | #[inline(always)] | ||
| 412 | pub fn fact12(&self) -> FACT12_R { | ||
| 413 | FACT12_R::new(((self.bits >> 12) & 0x01) != 0) | ||
| 414 | } | ||
| 415 | #[doc = "Bit 13 - Filter active"] | ||
| 416 | #[inline(always)] | ||
| 417 | pub fn fact13(&self) -> FACT13_R { | ||
| 418 | FACT13_R::new(((self.bits >> 13) & 0x01) != 0) | ||
| 419 | } | ||
| 420 | } | ||
| 421 | impl W { | ||
| 422 | #[doc = "Bit 0 - Filter active"] | ||
| 423 | #[inline(always)] | ||
| 424 | pub fn fact0(&mut self) -> FACT0_W { | ||
| 425 | FACT0_W { w: self } | ||
| 426 | } | ||
| 427 | #[doc = "Bit 1 - Filter active"] | ||
| 428 | #[inline(always)] | ||
| 429 | pub fn fact1(&mut self) -> FACT1_W { | ||
| 430 | FACT1_W { w: self } | ||
| 431 | } | ||
| 432 | #[doc = "Bit 2 - Filter active"] | ||
| 433 | #[inline(always)] | ||
| 434 | pub fn fact2(&mut self) -> FACT2_W { | ||
| 435 | FACT2_W { w: self } | ||
| 436 | } | ||
| 437 | #[doc = "Bit 3 - Filter active"] | ||
| 438 | #[inline(always)] | ||
| 439 | pub fn fact3(&mut self) -> FACT3_W { | ||
| 440 | FACT3_W { w: self } | ||
| 441 | } | ||
| 442 | #[doc = "Bit 4 - Filter active"] | ||
| 443 | #[inline(always)] | ||
| 444 | pub fn fact4(&mut self) -> FACT4_W { | ||
| 445 | FACT4_W { w: self } | ||
| 446 | } | ||
| 447 | #[doc = "Bit 5 - Filter active"] | ||
| 448 | #[inline(always)] | ||
| 449 | pub fn fact5(&mut self) -> FACT5_W { | ||
| 450 | FACT5_W { w: self } | ||
| 451 | } | ||
| 452 | #[doc = "Bit 6 - Filter active"] | ||
| 453 | #[inline(always)] | ||
| 454 | pub fn fact6(&mut self) -> FACT6_W { | ||
| 455 | FACT6_W { w: self } | ||
| 456 | } | ||
| 457 | #[doc = "Bit 7 - Filter active"] | ||
| 458 | #[inline(always)] | ||
| 459 | pub fn fact7(&mut self) -> FACT7_W { | ||
| 460 | FACT7_W { w: self } | ||
| 461 | } | ||
| 462 | #[doc = "Bit 8 - Filter active"] | ||
| 463 | #[inline(always)] | ||
| 464 | pub fn fact8(&mut self) -> FACT8_W { | ||
| 465 | FACT8_W { w: self } | ||
| 466 | } | ||
| 467 | #[doc = "Bit 9 - Filter active"] | ||
| 468 | #[inline(always)] | ||
| 469 | pub fn fact9(&mut self) -> FACT9_W { | ||
| 470 | FACT9_W { w: self } | ||
| 471 | } | ||
| 472 | #[doc = "Bit 10 - Filter active"] | ||
| 473 | #[inline(always)] | ||
| 474 | pub fn fact10(&mut self) -> FACT10_W { | ||
| 475 | FACT10_W { w: self } | ||
| 476 | } | ||
| 477 | #[doc = "Bit 11 - Filter active"] | ||
| 478 | #[inline(always)] | ||
| 479 | pub fn fact11(&mut self) -> FACT11_W { | ||
| 480 | FACT11_W { w: self } | ||
| 481 | } | ||
| 482 | #[doc = "Bit 12 - Filter active"] | ||
| 483 | #[inline(always)] | ||
| 484 | pub fn fact12(&mut self) -> FACT12_W { | ||
| 485 | FACT12_W { w: self } | ||
| 486 | } | ||
| 487 | #[doc = "Bit 13 - Filter active"] | ||
| 488 | #[inline(always)] | ||
| 489 | pub fn fact13(&mut self) -> FACT13_W { | ||
| 490 | FACT13_W { w: self } | ||
| 491 | } | ||
| 492 | } | ||
diff --git a/embassy-stm32/src/can/bx/pac/can/fb.rs b/embassy-stm32/src/can/bx/pac/can/fb.rs new file mode 100644 index 000000000..1b31e37c5 --- /dev/null +++ b/embassy-stm32/src/can/bx/pac/can/fb.rs | |||
| @@ -0,0 +1,22 @@ | |||
| 1 | #[doc = "Filter bank 0 register 1\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [fr1](fr1) module"] | ||
| 2 | pub type FR1 = crate::Reg<u32, _FR1>; | ||
| 3 | #[allow(missing_docs)] | ||
| 4 | #[doc(hidden)] | ||
| 5 | pub struct _FR1; | ||
| 6 | #[doc = "`read()` method returns [fr1::R](fr1::R) reader structure"] | ||
| 7 | impl crate::Readable for FR1 {} | ||
| 8 | #[doc = "`write(|w| ..)` method takes [fr1::W](fr1::W) writer structure"] | ||
| 9 | impl crate::Writable for FR1 {} | ||
| 10 | #[doc = "Filter bank 0 register 1"] | ||
| 11 | pub mod fr1; | ||
| 12 | #[doc = "Filter bank 0 register 2\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [fr2](fr2) module"] | ||
| 13 | pub type FR2 = crate::Reg<u32, _FR2>; | ||
| 14 | #[allow(missing_docs)] | ||
| 15 | #[doc(hidden)] | ||
| 16 | pub struct _FR2; | ||
| 17 | #[doc = "`read()` method returns [fr2::R](fr2::R) reader structure"] | ||
| 18 | impl crate::Readable for FR2 {} | ||
| 19 | #[doc = "`write(|w| ..)` method takes [fr2::W](fr2::W) writer structure"] | ||
| 20 | impl crate::Writable for FR2 {} | ||
| 21 | #[doc = "Filter bank 0 register 2"] | ||
| 22 | pub mod fr2; | ||
diff --git a/embassy-stm32/src/can/bx/pac/can/fb/fr1.rs b/embassy-stm32/src/can/bx/pac/can/fb/fr1.rs new file mode 100644 index 000000000..b39d5e8fb --- /dev/null +++ b/embassy-stm32/src/can/bx/pac/can/fb/fr1.rs | |||
| @@ -0,0 +1,40 @@ | |||
| 1 | #[doc = "Reader of register FR1"] | ||
| 2 | pub type R = crate::R<u32, super::FR1>; | ||
| 3 | #[doc = "Writer for register FR1"] | ||
| 4 | pub type W = crate::W<u32, super::FR1>; | ||
| 5 | #[doc = "Register FR1 `reset()`'s with value 0"] | ||
| 6 | impl crate::ResetValue for super::FR1 { | ||
| 7 | type Type = u32; | ||
| 8 | #[inline(always)] | ||
| 9 | fn reset_value() -> Self::Type { | ||
| 10 | 0 | ||
| 11 | } | ||
| 12 | } | ||
| 13 | #[doc = "Reader of field `FB`"] | ||
| 14 | pub type FB_R = crate::R<u32, u32>; | ||
| 15 | #[doc = "Write proxy for field `FB`"] | ||
| 16 | pub struct FB_W<'a> { | ||
| 17 | w: &'a mut W, | ||
| 18 | } | ||
| 19 | impl<'a> FB_W<'a> { | ||
| 20 | #[doc = r"Writes raw bits to the field"] | ||
| 21 | #[inline(always)] | ||
| 22 | pub unsafe fn bits(self, value: u32) -> &'a mut W { | ||
| 23 | self.w.bits = (self.w.bits & !0xffff_ffff) | ((value as u32) & 0xffff_ffff); | ||
| 24 | self.w | ||
| 25 | } | ||
| 26 | } | ||
| 27 | impl R { | ||
| 28 | #[doc = "Bits 0:31 - Filter bits"] | ||
| 29 | #[inline(always)] | ||
| 30 | pub fn fb(&self) -> FB_R { | ||
| 31 | FB_R::new((self.bits & 0xffff_ffff) as u32) | ||
| 32 | } | ||
| 33 | } | ||
| 34 | impl W { | ||
| 35 | #[doc = "Bits 0:31 - Filter bits"] | ||
| 36 | #[inline(always)] | ||
| 37 | pub fn fb(&mut self) -> FB_W { | ||
| 38 | FB_W { w: self } | ||
| 39 | } | ||
| 40 | } | ||
diff --git a/embassy-stm32/src/can/bx/pac/can/fb/fr2.rs b/embassy-stm32/src/can/bx/pac/can/fb/fr2.rs new file mode 100644 index 000000000..1f318894e --- /dev/null +++ b/embassy-stm32/src/can/bx/pac/can/fb/fr2.rs | |||
| @@ -0,0 +1,40 @@ | |||
| 1 | #[doc = "Reader of register FR2"] | ||
| 2 | pub type R = crate::R<u32, super::FR2>; | ||
| 3 | #[doc = "Writer for register FR2"] | ||
| 4 | pub type W = crate::W<u32, super::FR2>; | ||
| 5 | #[doc = "Register FR2 `reset()`'s with value 0"] | ||
| 6 | impl crate::ResetValue for super::FR2 { | ||
| 7 | type Type = u32; | ||
| 8 | #[inline(always)] | ||
| 9 | fn reset_value() -> Self::Type { | ||
| 10 | 0 | ||
| 11 | } | ||
| 12 | } | ||
| 13 | #[doc = "Reader of field `FB`"] | ||
| 14 | pub type FB_R = crate::R<u32, u32>; | ||
| 15 | #[doc = "Write proxy for field `FB`"] | ||
| 16 | pub struct FB_W<'a> { | ||
| 17 | w: &'a mut W, | ||
| 18 | } | ||
| 19 | impl<'a> FB_W<'a> { | ||
| 20 | #[doc = r"Writes raw bits to the field"] | ||
| 21 | #[inline(always)] | ||
| 22 | pub unsafe fn bits(self, value: u32) -> &'a mut W { | ||
| 23 | self.w.bits = (self.w.bits & !0xffff_ffff) | ((value as u32) & 0xffff_ffff); | ||
| 24 | self.w | ||
| 25 | } | ||
| 26 | } | ||
| 27 | impl R { | ||
| 28 | #[doc = "Bits 0:31 - Filter bits"] | ||
| 29 | #[inline(always)] | ||
| 30 | pub fn fb(&self) -> FB_R { | ||
| 31 | FB_R::new((self.bits & 0xffff_ffff) as u32) | ||
| 32 | } | ||
| 33 | } | ||
| 34 | impl W { | ||
| 35 | #[doc = "Bits 0:31 - Filter bits"] | ||
| 36 | #[inline(always)] | ||
| 37 | pub fn fb(&mut self) -> FB_W { | ||
| 38 | FB_W { w: self } | ||
| 39 | } | ||
| 40 | } | ||
diff --git a/embassy-stm32/src/can/bx/pac/can/ffa1r.rs b/embassy-stm32/src/can/bx/pac/can/ffa1r.rs new file mode 100644 index 000000000..bc3ab0eb9 --- /dev/null +++ b/embassy-stm32/src/can/bx/pac/can/ffa1r.rs | |||
| @@ -0,0 +1,492 @@ | |||
| 1 | #[doc = "Reader of register FFA1R"] | ||
| 2 | pub type R = crate::R<u32, super::FFA1R>; | ||
| 3 | #[doc = "Writer for register FFA1R"] | ||
| 4 | pub type W = crate::W<u32, super::FFA1R>; | ||
| 5 | #[doc = "Register FFA1R `reset()`'s with value 0"] | ||
| 6 | impl crate::ResetValue for super::FFA1R { | ||
| 7 | type Type = u32; | ||
| 8 | #[inline(always)] | ||
| 9 | fn reset_value() -> Self::Type { | ||
| 10 | 0 | ||
| 11 | } | ||
| 12 | } | ||
| 13 | #[doc = "Reader of field `FFA0`"] | ||
| 14 | pub type FFA0_R = crate::R<bool, bool>; | ||
| 15 | #[doc = "Write proxy for field `FFA0`"] | ||
| 16 | pub struct FFA0_W<'a> { | ||
| 17 | w: &'a mut W, | ||
| 18 | } | ||
| 19 | impl<'a> FFA0_W<'a> { | ||
| 20 | #[doc = r"Sets the field bit"] | ||
| 21 | #[inline(always)] | ||
| 22 | pub fn set_bit(self) -> &'a mut W { | ||
| 23 | self.bit(true) | ||
| 24 | } | ||
| 25 | #[doc = r"Clears the field bit"] | ||
| 26 | #[inline(always)] | ||
| 27 | pub fn clear_bit(self) -> &'a mut W { | ||
| 28 | self.bit(false) | ||
| 29 | } | ||
| 30 | #[doc = r"Writes raw bits to the field"] | ||
| 31 | #[inline(always)] | ||
| 32 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 33 | self.w.bits = (self.w.bits & !0x01) | ((value as u32) & 0x01); | ||
| 34 | self.w | ||
| 35 | } | ||
| 36 | } | ||
| 37 | #[doc = "Reader of field `FFA1`"] | ||
| 38 | pub type FFA1_R = crate::R<bool, bool>; | ||
| 39 | #[doc = "Write proxy for field `FFA1`"] | ||
| 40 | pub struct FFA1_W<'a> { | ||
| 41 | w: &'a mut W, | ||
| 42 | } | ||
| 43 | impl<'a> FFA1_W<'a> { | ||
| 44 | #[doc = r"Sets the field bit"] | ||
| 45 | #[inline(always)] | ||
| 46 | pub fn set_bit(self) -> &'a mut W { | ||
| 47 | self.bit(true) | ||
| 48 | } | ||
| 49 | #[doc = r"Clears the field bit"] | ||
| 50 | #[inline(always)] | ||
| 51 | pub fn clear_bit(self) -> &'a mut W { | ||
| 52 | self.bit(false) | ||
| 53 | } | ||
| 54 | #[doc = r"Writes raw bits to the field"] | ||
| 55 | #[inline(always)] | ||
| 56 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 57 | self.w.bits = (self.w.bits & !(0x01 << 1)) | (((value as u32) & 0x01) << 1); | ||
| 58 | self.w | ||
| 59 | } | ||
| 60 | } | ||
| 61 | #[doc = "Reader of field `FFA2`"] | ||
| 62 | pub type FFA2_R = crate::R<bool, bool>; | ||
| 63 | #[doc = "Write proxy for field `FFA2`"] | ||
| 64 | pub struct FFA2_W<'a> { | ||
| 65 | w: &'a mut W, | ||
| 66 | } | ||
| 67 | impl<'a> FFA2_W<'a> { | ||
| 68 | #[doc = r"Sets the field bit"] | ||
| 69 | #[inline(always)] | ||
| 70 | pub fn set_bit(self) -> &'a mut W { | ||
| 71 | self.bit(true) | ||
| 72 | } | ||
| 73 | #[doc = r"Clears the field bit"] | ||
| 74 | #[inline(always)] | ||
| 75 | pub fn clear_bit(self) -> &'a mut W { | ||
| 76 | self.bit(false) | ||
| 77 | } | ||
| 78 | #[doc = r"Writes raw bits to the field"] | ||
| 79 | #[inline(always)] | ||
| 80 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 81 | self.w.bits = (self.w.bits & !(0x01 << 2)) | (((value as u32) & 0x01) << 2); | ||
| 82 | self.w | ||
| 83 | } | ||
| 84 | } | ||
| 85 | #[doc = "Reader of field `FFA3`"] | ||
| 86 | pub type FFA3_R = crate::R<bool, bool>; | ||
| 87 | #[doc = "Write proxy for field `FFA3`"] | ||
| 88 | pub struct FFA3_W<'a> { | ||
| 89 | w: &'a mut W, | ||
| 90 | } | ||
| 91 | impl<'a> FFA3_W<'a> { | ||
| 92 | #[doc = r"Sets the field bit"] | ||
| 93 | #[inline(always)] | ||
| 94 | pub fn set_bit(self) -> &'a mut W { | ||
| 95 | self.bit(true) | ||
| 96 | } | ||
| 97 | #[doc = r"Clears the field bit"] | ||
| 98 | #[inline(always)] | ||
| 99 | pub fn clear_bit(self) -> &'a mut W { | ||
| 100 | self.bit(false) | ||
| 101 | } | ||
| 102 | #[doc = r"Writes raw bits to the field"] | ||
| 103 | #[inline(always)] | ||
| 104 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 105 | self.w.bits = (self.w.bits & !(0x01 << 3)) | (((value as u32) & 0x01) << 3); | ||
| 106 | self.w | ||
| 107 | } | ||
| 108 | } | ||
| 109 | #[doc = "Reader of field `FFA4`"] | ||
| 110 | pub type FFA4_R = crate::R<bool, bool>; | ||
| 111 | #[doc = "Write proxy for field `FFA4`"] | ||
| 112 | pub struct FFA4_W<'a> { | ||
| 113 | w: &'a mut W, | ||
| 114 | } | ||
| 115 | impl<'a> FFA4_W<'a> { | ||
| 116 | #[doc = r"Sets the field bit"] | ||
| 117 | #[inline(always)] | ||
| 118 | pub fn set_bit(self) -> &'a mut W { | ||
| 119 | self.bit(true) | ||
| 120 | } | ||
| 121 | #[doc = r"Clears the field bit"] | ||
| 122 | #[inline(always)] | ||
| 123 | pub fn clear_bit(self) -> &'a mut W { | ||
| 124 | self.bit(false) | ||
| 125 | } | ||
| 126 | #[doc = r"Writes raw bits to the field"] | ||
| 127 | #[inline(always)] | ||
| 128 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 129 | self.w.bits = (self.w.bits & !(0x01 << 4)) | (((value as u32) & 0x01) << 4); | ||
| 130 | self.w | ||
| 131 | } | ||
| 132 | } | ||
| 133 | #[doc = "Reader of field `FFA5`"] | ||
| 134 | pub type FFA5_R = crate::R<bool, bool>; | ||
| 135 | #[doc = "Write proxy for field `FFA5`"] | ||
| 136 | pub struct FFA5_W<'a> { | ||
| 137 | w: &'a mut W, | ||
| 138 | } | ||
| 139 | impl<'a> FFA5_W<'a> { | ||
| 140 | #[doc = r"Sets the field bit"] | ||
| 141 | #[inline(always)] | ||
| 142 | pub fn set_bit(self) -> &'a mut W { | ||
| 143 | self.bit(true) | ||
| 144 | } | ||
| 145 | #[doc = r"Clears the field bit"] | ||
| 146 | #[inline(always)] | ||
| 147 | pub fn clear_bit(self) -> &'a mut W { | ||
| 148 | self.bit(false) | ||
| 149 | } | ||
| 150 | #[doc = r"Writes raw bits to the field"] | ||
| 151 | #[inline(always)] | ||
| 152 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 153 | self.w.bits = (self.w.bits & !(0x01 << 5)) | (((value as u32) & 0x01) << 5); | ||
| 154 | self.w | ||
| 155 | } | ||
| 156 | } | ||
| 157 | #[doc = "Reader of field `FFA6`"] | ||
| 158 | pub type FFA6_R = crate::R<bool, bool>; | ||
| 159 | #[doc = "Write proxy for field `FFA6`"] | ||
| 160 | pub struct FFA6_W<'a> { | ||
| 161 | w: &'a mut W, | ||
| 162 | } | ||
| 163 | impl<'a> FFA6_W<'a> { | ||
| 164 | #[doc = r"Sets the field bit"] | ||
| 165 | #[inline(always)] | ||
| 166 | pub fn set_bit(self) -> &'a mut W { | ||
| 167 | self.bit(true) | ||
| 168 | } | ||
| 169 | #[doc = r"Clears the field bit"] | ||
| 170 | #[inline(always)] | ||
| 171 | pub fn clear_bit(self) -> &'a mut W { | ||
| 172 | self.bit(false) | ||
| 173 | } | ||
| 174 | #[doc = r"Writes raw bits to the field"] | ||
| 175 | #[inline(always)] | ||
| 176 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 177 | self.w.bits = (self.w.bits & !(0x01 << 6)) | (((value as u32) & 0x01) << 6); | ||
| 178 | self.w | ||
| 179 | } | ||
| 180 | } | ||
| 181 | #[doc = "Reader of field `FFA7`"] | ||
| 182 | pub type FFA7_R = crate::R<bool, bool>; | ||
| 183 | #[doc = "Write proxy for field `FFA7`"] | ||
| 184 | pub struct FFA7_W<'a> { | ||
| 185 | w: &'a mut W, | ||
| 186 | } | ||
| 187 | impl<'a> FFA7_W<'a> { | ||
| 188 | #[doc = r"Sets the field bit"] | ||
| 189 | #[inline(always)] | ||
| 190 | pub fn set_bit(self) -> &'a mut W { | ||
| 191 | self.bit(true) | ||
| 192 | } | ||
| 193 | #[doc = r"Clears the field bit"] | ||
| 194 | #[inline(always)] | ||
| 195 | pub fn clear_bit(self) -> &'a mut W { | ||
| 196 | self.bit(false) | ||
| 197 | } | ||
| 198 | #[doc = r"Writes raw bits to the field"] | ||
| 199 | #[inline(always)] | ||
| 200 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 201 | self.w.bits = (self.w.bits & !(0x01 << 7)) | (((value as u32) & 0x01) << 7); | ||
| 202 | self.w | ||
| 203 | } | ||
| 204 | } | ||
| 205 | #[doc = "Reader of field `FFA8`"] | ||
| 206 | pub type FFA8_R = crate::R<bool, bool>; | ||
| 207 | #[doc = "Write proxy for field `FFA8`"] | ||
| 208 | pub struct FFA8_W<'a> { | ||
| 209 | w: &'a mut W, | ||
| 210 | } | ||
| 211 | impl<'a> FFA8_W<'a> { | ||
| 212 | #[doc = r"Sets the field bit"] | ||
| 213 | #[inline(always)] | ||
| 214 | pub fn set_bit(self) -> &'a mut W { | ||
| 215 | self.bit(true) | ||
| 216 | } | ||
| 217 | #[doc = r"Clears the field bit"] | ||
| 218 | #[inline(always)] | ||
| 219 | pub fn clear_bit(self) -> &'a mut W { | ||
| 220 | self.bit(false) | ||
| 221 | } | ||
| 222 | #[doc = r"Writes raw bits to the field"] | ||
| 223 | #[inline(always)] | ||
| 224 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 225 | self.w.bits = (self.w.bits & !(0x01 << 8)) | (((value as u32) & 0x01) << 8); | ||
| 226 | self.w | ||
| 227 | } | ||
| 228 | } | ||
| 229 | #[doc = "Reader of field `FFA9`"] | ||
| 230 | pub type FFA9_R = crate::R<bool, bool>; | ||
| 231 | #[doc = "Write proxy for field `FFA9`"] | ||
| 232 | pub struct FFA9_W<'a> { | ||
| 233 | w: &'a mut W, | ||
| 234 | } | ||
| 235 | impl<'a> FFA9_W<'a> { | ||
| 236 | #[doc = r"Sets the field bit"] | ||
| 237 | #[inline(always)] | ||
| 238 | pub fn set_bit(self) -> &'a mut W { | ||
| 239 | self.bit(true) | ||
| 240 | } | ||
| 241 | #[doc = r"Clears the field bit"] | ||
| 242 | #[inline(always)] | ||
| 243 | pub fn clear_bit(self) -> &'a mut W { | ||
| 244 | self.bit(false) | ||
| 245 | } | ||
| 246 | #[doc = r"Writes raw bits to the field"] | ||
| 247 | #[inline(always)] | ||
| 248 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 249 | self.w.bits = (self.w.bits & !(0x01 << 9)) | (((value as u32) & 0x01) << 9); | ||
| 250 | self.w | ||
| 251 | } | ||
| 252 | } | ||
| 253 | #[doc = "Reader of field `FFA10`"] | ||
| 254 | pub type FFA10_R = crate::R<bool, bool>; | ||
| 255 | #[doc = "Write proxy for field `FFA10`"] | ||
| 256 | pub struct FFA10_W<'a> { | ||
| 257 | w: &'a mut W, | ||
| 258 | } | ||
| 259 | impl<'a> FFA10_W<'a> { | ||
| 260 | #[doc = r"Sets the field bit"] | ||
| 261 | #[inline(always)] | ||
| 262 | pub fn set_bit(self) -> &'a mut W { | ||
| 263 | self.bit(true) | ||
| 264 | } | ||
| 265 | #[doc = r"Clears the field bit"] | ||
| 266 | #[inline(always)] | ||
| 267 | pub fn clear_bit(self) -> &'a mut W { | ||
| 268 | self.bit(false) | ||
| 269 | } | ||
| 270 | #[doc = r"Writes raw bits to the field"] | ||
| 271 | #[inline(always)] | ||
| 272 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 273 | self.w.bits = (self.w.bits & !(0x01 << 10)) | (((value as u32) & 0x01) << 10); | ||
| 274 | self.w | ||
| 275 | } | ||
| 276 | } | ||
| 277 | #[doc = "Reader of field `FFA11`"] | ||
| 278 | pub type FFA11_R = crate::R<bool, bool>; | ||
| 279 | #[doc = "Write proxy for field `FFA11`"] | ||
| 280 | pub struct FFA11_W<'a> { | ||
| 281 | w: &'a mut W, | ||
| 282 | } | ||
| 283 | impl<'a> FFA11_W<'a> { | ||
| 284 | #[doc = r"Sets the field bit"] | ||
| 285 | #[inline(always)] | ||
| 286 | pub fn set_bit(self) -> &'a mut W { | ||
| 287 | self.bit(true) | ||
| 288 | } | ||
| 289 | #[doc = r"Clears the field bit"] | ||
| 290 | #[inline(always)] | ||
| 291 | pub fn clear_bit(self) -> &'a mut W { | ||
| 292 | self.bit(false) | ||
| 293 | } | ||
| 294 | #[doc = r"Writes raw bits to the field"] | ||
| 295 | #[inline(always)] | ||
| 296 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 297 | self.w.bits = (self.w.bits & !(0x01 << 11)) | (((value as u32) & 0x01) << 11); | ||
| 298 | self.w | ||
| 299 | } | ||
| 300 | } | ||
| 301 | #[doc = "Reader of field `FFA12`"] | ||
| 302 | pub type FFA12_R = crate::R<bool, bool>; | ||
| 303 | #[doc = "Write proxy for field `FFA12`"] | ||
| 304 | pub struct FFA12_W<'a> { | ||
| 305 | w: &'a mut W, | ||
| 306 | } | ||
| 307 | impl<'a> FFA12_W<'a> { | ||
| 308 | #[doc = r"Sets the field bit"] | ||
| 309 | #[inline(always)] | ||
| 310 | pub fn set_bit(self) -> &'a mut W { | ||
| 311 | self.bit(true) | ||
| 312 | } | ||
| 313 | #[doc = r"Clears the field bit"] | ||
| 314 | #[inline(always)] | ||
| 315 | pub fn clear_bit(self) -> &'a mut W { | ||
| 316 | self.bit(false) | ||
| 317 | } | ||
| 318 | #[doc = r"Writes raw bits to the field"] | ||
| 319 | #[inline(always)] | ||
| 320 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 321 | self.w.bits = (self.w.bits & !(0x01 << 12)) | (((value as u32) & 0x01) << 12); | ||
| 322 | self.w | ||
| 323 | } | ||
| 324 | } | ||
| 325 | #[doc = "Reader of field `FFA13`"] | ||
| 326 | pub type FFA13_R = crate::R<bool, bool>; | ||
| 327 | #[doc = "Write proxy for field `FFA13`"] | ||
| 328 | pub struct FFA13_W<'a> { | ||
| 329 | w: &'a mut W, | ||
| 330 | } | ||
| 331 | impl<'a> FFA13_W<'a> { | ||
| 332 | #[doc = r"Sets the field bit"] | ||
| 333 | #[inline(always)] | ||
| 334 | pub fn set_bit(self) -> &'a mut W { | ||
| 335 | self.bit(true) | ||
| 336 | } | ||
| 337 | #[doc = r"Clears the field bit"] | ||
| 338 | #[inline(always)] | ||
| 339 | pub fn clear_bit(self) -> &'a mut W { | ||
| 340 | self.bit(false) | ||
| 341 | } | ||
| 342 | #[doc = r"Writes raw bits to the field"] | ||
| 343 | #[inline(always)] | ||
| 344 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 345 | self.w.bits = (self.w.bits & !(0x01 << 13)) | (((value as u32) & 0x01) << 13); | ||
| 346 | self.w | ||
| 347 | } | ||
| 348 | } | ||
| 349 | impl R { | ||
| 350 | #[doc = "Bit 0 - Filter FIFO assignment for filter 0"] | ||
| 351 | #[inline(always)] | ||
| 352 | pub fn ffa0(&self) -> FFA0_R { | ||
| 353 | FFA0_R::new((self.bits & 0x01) != 0) | ||
| 354 | } | ||
| 355 | #[doc = "Bit 1 - Filter FIFO assignment for filter 1"] | ||
| 356 | #[inline(always)] | ||
| 357 | pub fn ffa1(&self) -> FFA1_R { | ||
| 358 | FFA1_R::new(((self.bits >> 1) & 0x01) != 0) | ||
| 359 | } | ||
| 360 | #[doc = "Bit 2 - Filter FIFO assignment for filter 2"] | ||
| 361 | #[inline(always)] | ||
| 362 | pub fn ffa2(&self) -> FFA2_R { | ||
| 363 | FFA2_R::new(((self.bits >> 2) & 0x01) != 0) | ||
| 364 | } | ||
| 365 | #[doc = "Bit 3 - Filter FIFO assignment for filter 3"] | ||
| 366 | #[inline(always)] | ||
| 367 | pub fn ffa3(&self) -> FFA3_R { | ||
| 368 | FFA3_R::new(((self.bits >> 3) & 0x01) != 0) | ||
| 369 | } | ||
| 370 | #[doc = "Bit 4 - Filter FIFO assignment for filter 4"] | ||
| 371 | #[inline(always)] | ||
| 372 | pub fn ffa4(&self) -> FFA4_R { | ||
| 373 | FFA4_R::new(((self.bits >> 4) & 0x01) != 0) | ||
| 374 | } | ||
| 375 | #[doc = "Bit 5 - Filter FIFO assignment for filter 5"] | ||
| 376 | #[inline(always)] | ||
| 377 | pub fn ffa5(&self) -> FFA5_R { | ||
| 378 | FFA5_R::new(((self.bits >> 5) & 0x01) != 0) | ||
| 379 | } | ||
| 380 | #[doc = "Bit 6 - Filter FIFO assignment for filter 6"] | ||
| 381 | #[inline(always)] | ||
| 382 | pub fn ffa6(&self) -> FFA6_R { | ||
| 383 | FFA6_R::new(((self.bits >> 6) & 0x01) != 0) | ||
| 384 | } | ||
| 385 | #[doc = "Bit 7 - Filter FIFO assignment for filter 7"] | ||
| 386 | #[inline(always)] | ||
| 387 | pub fn ffa7(&self) -> FFA7_R { | ||
| 388 | FFA7_R::new(((self.bits >> 7) & 0x01) != 0) | ||
| 389 | } | ||
| 390 | #[doc = "Bit 8 - Filter FIFO assignment for filter 8"] | ||
| 391 | #[inline(always)] | ||
| 392 | pub fn ffa8(&self) -> FFA8_R { | ||
| 393 | FFA8_R::new(((self.bits >> 8) & 0x01) != 0) | ||
| 394 | } | ||
| 395 | #[doc = "Bit 9 - Filter FIFO assignment for filter 9"] | ||
| 396 | #[inline(always)] | ||
| 397 | pub fn ffa9(&self) -> FFA9_R { | ||
| 398 | FFA9_R::new(((self.bits >> 9) & 0x01) != 0) | ||
| 399 | } | ||
| 400 | #[doc = "Bit 10 - Filter FIFO assignment for filter 10"] | ||
| 401 | #[inline(always)] | ||
| 402 | pub fn ffa10(&self) -> FFA10_R { | ||
| 403 | FFA10_R::new(((self.bits >> 10) & 0x01) != 0) | ||
| 404 | } | ||
| 405 | #[doc = "Bit 11 - Filter FIFO assignment for filter 11"] | ||
| 406 | #[inline(always)] | ||
| 407 | pub fn ffa11(&self) -> FFA11_R { | ||
| 408 | FFA11_R::new(((self.bits >> 11) & 0x01) != 0) | ||
| 409 | } | ||
| 410 | #[doc = "Bit 12 - Filter FIFO assignment for filter 12"] | ||
| 411 | #[inline(always)] | ||
| 412 | pub fn ffa12(&self) -> FFA12_R { | ||
| 413 | FFA12_R::new(((self.bits >> 12) & 0x01) != 0) | ||
| 414 | } | ||
| 415 | #[doc = "Bit 13 - Filter FIFO assignment for filter 13"] | ||
| 416 | #[inline(always)] | ||
| 417 | pub fn ffa13(&self) -> FFA13_R { | ||
| 418 | FFA13_R::new(((self.bits >> 13) & 0x01) != 0) | ||
| 419 | } | ||
| 420 | } | ||
| 421 | impl W { | ||
| 422 | #[doc = "Bit 0 - Filter FIFO assignment for filter 0"] | ||
| 423 | #[inline(always)] | ||
| 424 | pub fn ffa0(&mut self) -> FFA0_W { | ||
| 425 | FFA0_W { w: self } | ||
| 426 | } | ||
| 427 | #[doc = "Bit 1 - Filter FIFO assignment for filter 1"] | ||
| 428 | #[inline(always)] | ||
| 429 | pub fn ffa1(&mut self) -> FFA1_W { | ||
| 430 | FFA1_W { w: self } | ||
| 431 | } | ||
| 432 | #[doc = "Bit 2 - Filter FIFO assignment for filter 2"] | ||
| 433 | #[inline(always)] | ||
| 434 | pub fn ffa2(&mut self) -> FFA2_W { | ||
| 435 | FFA2_W { w: self } | ||
| 436 | } | ||
| 437 | #[doc = "Bit 3 - Filter FIFO assignment for filter 3"] | ||
| 438 | #[inline(always)] | ||
| 439 | pub fn ffa3(&mut self) -> FFA3_W { | ||
| 440 | FFA3_W { w: self } | ||
| 441 | } | ||
| 442 | #[doc = "Bit 4 - Filter FIFO assignment for filter 4"] | ||
| 443 | #[inline(always)] | ||
| 444 | pub fn ffa4(&mut self) -> FFA4_W { | ||
| 445 | FFA4_W { w: self } | ||
| 446 | } | ||
| 447 | #[doc = "Bit 5 - Filter FIFO assignment for filter 5"] | ||
| 448 | #[inline(always)] | ||
| 449 | pub fn ffa5(&mut self) -> FFA5_W { | ||
| 450 | FFA5_W { w: self } | ||
| 451 | } | ||
| 452 | #[doc = "Bit 6 - Filter FIFO assignment for filter 6"] | ||
| 453 | #[inline(always)] | ||
| 454 | pub fn ffa6(&mut self) -> FFA6_W { | ||
| 455 | FFA6_W { w: self } | ||
| 456 | } | ||
| 457 | #[doc = "Bit 7 - Filter FIFO assignment for filter 7"] | ||
| 458 | #[inline(always)] | ||
| 459 | pub fn ffa7(&mut self) -> FFA7_W { | ||
| 460 | FFA7_W { w: self } | ||
| 461 | } | ||
| 462 | #[doc = "Bit 8 - Filter FIFO assignment for filter 8"] | ||
| 463 | #[inline(always)] | ||
| 464 | pub fn ffa8(&mut self) -> FFA8_W { | ||
| 465 | FFA8_W { w: self } | ||
| 466 | } | ||
| 467 | #[doc = "Bit 9 - Filter FIFO assignment for filter 9"] | ||
| 468 | #[inline(always)] | ||
| 469 | pub fn ffa9(&mut self) -> FFA9_W { | ||
| 470 | FFA9_W { w: self } | ||
| 471 | } | ||
| 472 | #[doc = "Bit 10 - Filter FIFO assignment for filter 10"] | ||
| 473 | #[inline(always)] | ||
| 474 | pub fn ffa10(&mut self) -> FFA10_W { | ||
| 475 | FFA10_W { w: self } | ||
| 476 | } | ||
| 477 | #[doc = "Bit 11 - Filter FIFO assignment for filter 11"] | ||
| 478 | #[inline(always)] | ||
| 479 | pub fn ffa11(&mut self) -> FFA11_W { | ||
| 480 | FFA11_W { w: self } | ||
| 481 | } | ||
| 482 | #[doc = "Bit 12 - Filter FIFO assignment for filter 12"] | ||
| 483 | #[inline(always)] | ||
| 484 | pub fn ffa12(&mut self) -> FFA12_W { | ||
| 485 | FFA12_W { w: self } | ||
| 486 | } | ||
| 487 | #[doc = "Bit 13 - Filter FIFO assignment for filter 13"] | ||
| 488 | #[inline(always)] | ||
| 489 | pub fn ffa13(&mut self) -> FFA13_W { | ||
| 490 | FFA13_W { w: self } | ||
| 491 | } | ||
| 492 | } | ||
diff --git a/embassy-stm32/src/can/bx/pac/can/fm1r.rs b/embassy-stm32/src/can/bx/pac/can/fm1r.rs new file mode 100644 index 000000000..e0a8dc648 --- /dev/null +++ b/embassy-stm32/src/can/bx/pac/can/fm1r.rs | |||
| @@ -0,0 +1,492 @@ | |||
| 1 | #[doc = "Reader of register FM1R"] | ||
| 2 | pub type R = crate::R<u32, super::FM1R>; | ||
| 3 | #[doc = "Writer for register FM1R"] | ||
| 4 | pub type W = crate::W<u32, super::FM1R>; | ||
| 5 | #[doc = "Register FM1R `reset()`'s with value 0"] | ||
| 6 | impl crate::ResetValue for super::FM1R { | ||
| 7 | type Type = u32; | ||
| 8 | #[inline(always)] | ||
| 9 | fn reset_value() -> Self::Type { | ||
| 10 | 0 | ||
| 11 | } | ||
| 12 | } | ||
| 13 | #[doc = "Reader of field `FBM0`"] | ||
| 14 | pub type FBM0_R = crate::R<bool, bool>; | ||
| 15 | #[doc = "Write proxy for field `FBM0`"] | ||
| 16 | pub struct FBM0_W<'a> { | ||
| 17 | w: &'a mut W, | ||
| 18 | } | ||
| 19 | impl<'a> FBM0_W<'a> { | ||
| 20 | #[doc = r"Sets the field bit"] | ||
| 21 | #[inline(always)] | ||
| 22 | pub fn set_bit(self) -> &'a mut W { | ||
| 23 | self.bit(true) | ||
| 24 | } | ||
| 25 | #[doc = r"Clears the field bit"] | ||
| 26 | #[inline(always)] | ||
| 27 | pub fn clear_bit(self) -> &'a mut W { | ||
| 28 | self.bit(false) | ||
| 29 | } | ||
| 30 | #[doc = r"Writes raw bits to the field"] | ||
| 31 | #[inline(always)] | ||
| 32 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 33 | self.w.bits = (self.w.bits & !0x01) | ((value as u32) & 0x01); | ||
| 34 | self.w | ||
| 35 | } | ||
| 36 | } | ||
| 37 | #[doc = "Reader of field `FBM1`"] | ||
| 38 | pub type FBM1_R = crate::R<bool, bool>; | ||
| 39 | #[doc = "Write proxy for field `FBM1`"] | ||
| 40 | pub struct FBM1_W<'a> { | ||
| 41 | w: &'a mut W, | ||
| 42 | } | ||
| 43 | impl<'a> FBM1_W<'a> { | ||
| 44 | #[doc = r"Sets the field bit"] | ||
| 45 | #[inline(always)] | ||
| 46 | pub fn set_bit(self) -> &'a mut W { | ||
| 47 | self.bit(true) | ||
| 48 | } | ||
| 49 | #[doc = r"Clears the field bit"] | ||
| 50 | #[inline(always)] | ||
| 51 | pub fn clear_bit(self) -> &'a mut W { | ||
| 52 | self.bit(false) | ||
| 53 | } | ||
| 54 | #[doc = r"Writes raw bits to the field"] | ||
| 55 | #[inline(always)] | ||
| 56 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 57 | self.w.bits = (self.w.bits & !(0x01 << 1)) | (((value as u32) & 0x01) << 1); | ||
| 58 | self.w | ||
| 59 | } | ||
| 60 | } | ||
| 61 | #[doc = "Reader of field `FBM2`"] | ||
| 62 | pub type FBM2_R = crate::R<bool, bool>; | ||
| 63 | #[doc = "Write proxy for field `FBM2`"] | ||
| 64 | pub struct FBM2_W<'a> { | ||
| 65 | w: &'a mut W, | ||
| 66 | } | ||
| 67 | impl<'a> FBM2_W<'a> { | ||
| 68 | #[doc = r"Sets the field bit"] | ||
| 69 | #[inline(always)] | ||
| 70 | pub fn set_bit(self) -> &'a mut W { | ||
| 71 | self.bit(true) | ||
| 72 | } | ||
| 73 | #[doc = r"Clears the field bit"] | ||
| 74 | #[inline(always)] | ||
| 75 | pub fn clear_bit(self) -> &'a mut W { | ||
| 76 | self.bit(false) | ||
| 77 | } | ||
| 78 | #[doc = r"Writes raw bits to the field"] | ||
| 79 | #[inline(always)] | ||
| 80 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 81 | self.w.bits = (self.w.bits & !(0x01 << 2)) | (((value as u32) & 0x01) << 2); | ||
| 82 | self.w | ||
| 83 | } | ||
| 84 | } | ||
| 85 | #[doc = "Reader of field `FBM3`"] | ||
| 86 | pub type FBM3_R = crate::R<bool, bool>; | ||
| 87 | #[doc = "Write proxy for field `FBM3`"] | ||
| 88 | pub struct FBM3_W<'a> { | ||
| 89 | w: &'a mut W, | ||
| 90 | } | ||
| 91 | impl<'a> FBM3_W<'a> { | ||
| 92 | #[doc = r"Sets the field bit"] | ||
| 93 | #[inline(always)] | ||
| 94 | pub fn set_bit(self) -> &'a mut W { | ||
| 95 | self.bit(true) | ||
| 96 | } | ||
| 97 | #[doc = r"Clears the field bit"] | ||
| 98 | #[inline(always)] | ||
| 99 | pub fn clear_bit(self) -> &'a mut W { | ||
| 100 | self.bit(false) | ||
| 101 | } | ||
| 102 | #[doc = r"Writes raw bits to the field"] | ||
| 103 | #[inline(always)] | ||
| 104 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 105 | self.w.bits = (self.w.bits & !(0x01 << 3)) | (((value as u32) & 0x01) << 3); | ||
| 106 | self.w | ||
| 107 | } | ||
| 108 | } | ||
| 109 | #[doc = "Reader of field `FBM4`"] | ||
| 110 | pub type FBM4_R = crate::R<bool, bool>; | ||
| 111 | #[doc = "Write proxy for field `FBM4`"] | ||
| 112 | pub struct FBM4_W<'a> { | ||
| 113 | w: &'a mut W, | ||
| 114 | } | ||
| 115 | impl<'a> FBM4_W<'a> { | ||
| 116 | #[doc = r"Sets the field bit"] | ||
| 117 | #[inline(always)] | ||
| 118 | pub fn set_bit(self) -> &'a mut W { | ||
| 119 | self.bit(true) | ||
| 120 | } | ||
| 121 | #[doc = r"Clears the field bit"] | ||
| 122 | #[inline(always)] | ||
| 123 | pub fn clear_bit(self) -> &'a mut W { | ||
| 124 | self.bit(false) | ||
| 125 | } | ||
| 126 | #[doc = r"Writes raw bits to the field"] | ||
| 127 | #[inline(always)] | ||
| 128 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 129 | self.w.bits = (self.w.bits & !(0x01 << 4)) | (((value as u32) & 0x01) << 4); | ||
| 130 | self.w | ||
| 131 | } | ||
| 132 | } | ||
| 133 | #[doc = "Reader of field `FBM5`"] | ||
| 134 | pub type FBM5_R = crate::R<bool, bool>; | ||
| 135 | #[doc = "Write proxy for field `FBM5`"] | ||
| 136 | pub struct FBM5_W<'a> { | ||
| 137 | w: &'a mut W, | ||
| 138 | } | ||
| 139 | impl<'a> FBM5_W<'a> { | ||
| 140 | #[doc = r"Sets the field bit"] | ||
| 141 | #[inline(always)] | ||
| 142 | pub fn set_bit(self) -> &'a mut W { | ||
| 143 | self.bit(true) | ||
| 144 | } | ||
| 145 | #[doc = r"Clears the field bit"] | ||
| 146 | #[inline(always)] | ||
| 147 | pub fn clear_bit(self) -> &'a mut W { | ||
| 148 | self.bit(false) | ||
| 149 | } | ||
| 150 | #[doc = r"Writes raw bits to the field"] | ||
| 151 | #[inline(always)] | ||
| 152 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 153 | self.w.bits = (self.w.bits & !(0x01 << 5)) | (((value as u32) & 0x01) << 5); | ||
| 154 | self.w | ||
| 155 | } | ||
| 156 | } | ||
| 157 | #[doc = "Reader of field `FBM6`"] | ||
| 158 | pub type FBM6_R = crate::R<bool, bool>; | ||
| 159 | #[doc = "Write proxy for field `FBM6`"] | ||
| 160 | pub struct FBM6_W<'a> { | ||
| 161 | w: &'a mut W, | ||
| 162 | } | ||
| 163 | impl<'a> FBM6_W<'a> { | ||
| 164 | #[doc = r"Sets the field bit"] | ||
| 165 | #[inline(always)] | ||
| 166 | pub fn set_bit(self) -> &'a mut W { | ||
| 167 | self.bit(true) | ||
| 168 | } | ||
| 169 | #[doc = r"Clears the field bit"] | ||
| 170 | #[inline(always)] | ||
| 171 | pub fn clear_bit(self) -> &'a mut W { | ||
| 172 | self.bit(false) | ||
| 173 | } | ||
| 174 | #[doc = r"Writes raw bits to the field"] | ||
| 175 | #[inline(always)] | ||
| 176 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 177 | self.w.bits = (self.w.bits & !(0x01 << 6)) | (((value as u32) & 0x01) << 6); | ||
| 178 | self.w | ||
| 179 | } | ||
| 180 | } | ||
| 181 | #[doc = "Reader of field `FBM7`"] | ||
| 182 | pub type FBM7_R = crate::R<bool, bool>; | ||
| 183 | #[doc = "Write proxy for field `FBM7`"] | ||
| 184 | pub struct FBM7_W<'a> { | ||
| 185 | w: &'a mut W, | ||
| 186 | } | ||
| 187 | impl<'a> FBM7_W<'a> { | ||
| 188 | #[doc = r"Sets the field bit"] | ||
| 189 | #[inline(always)] | ||
| 190 | pub fn set_bit(self) -> &'a mut W { | ||
| 191 | self.bit(true) | ||
| 192 | } | ||
| 193 | #[doc = r"Clears the field bit"] | ||
| 194 | #[inline(always)] | ||
| 195 | pub fn clear_bit(self) -> &'a mut W { | ||
| 196 | self.bit(false) | ||
| 197 | } | ||
| 198 | #[doc = r"Writes raw bits to the field"] | ||
| 199 | #[inline(always)] | ||
| 200 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 201 | self.w.bits = (self.w.bits & !(0x01 << 7)) | (((value as u32) & 0x01) << 7); | ||
| 202 | self.w | ||
| 203 | } | ||
| 204 | } | ||
| 205 | #[doc = "Reader of field `FBM8`"] | ||
| 206 | pub type FBM8_R = crate::R<bool, bool>; | ||
| 207 | #[doc = "Write proxy for field `FBM8`"] | ||
| 208 | pub struct FBM8_W<'a> { | ||
| 209 | w: &'a mut W, | ||
| 210 | } | ||
| 211 | impl<'a> FBM8_W<'a> { | ||
| 212 | #[doc = r"Sets the field bit"] | ||
| 213 | #[inline(always)] | ||
| 214 | pub fn set_bit(self) -> &'a mut W { | ||
| 215 | self.bit(true) | ||
| 216 | } | ||
| 217 | #[doc = r"Clears the field bit"] | ||
| 218 | #[inline(always)] | ||
| 219 | pub fn clear_bit(self) -> &'a mut W { | ||
| 220 | self.bit(false) | ||
| 221 | } | ||
| 222 | #[doc = r"Writes raw bits to the field"] | ||
| 223 | #[inline(always)] | ||
| 224 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 225 | self.w.bits = (self.w.bits & !(0x01 << 8)) | (((value as u32) & 0x01) << 8); | ||
| 226 | self.w | ||
| 227 | } | ||
| 228 | } | ||
| 229 | #[doc = "Reader of field `FBM9`"] | ||
| 230 | pub type FBM9_R = crate::R<bool, bool>; | ||
| 231 | #[doc = "Write proxy for field `FBM9`"] | ||
| 232 | pub struct FBM9_W<'a> { | ||
| 233 | w: &'a mut W, | ||
| 234 | } | ||
| 235 | impl<'a> FBM9_W<'a> { | ||
| 236 | #[doc = r"Sets the field bit"] | ||
| 237 | #[inline(always)] | ||
| 238 | pub fn set_bit(self) -> &'a mut W { | ||
| 239 | self.bit(true) | ||
| 240 | } | ||
| 241 | #[doc = r"Clears the field bit"] | ||
| 242 | #[inline(always)] | ||
| 243 | pub fn clear_bit(self) -> &'a mut W { | ||
| 244 | self.bit(false) | ||
| 245 | } | ||
| 246 | #[doc = r"Writes raw bits to the field"] | ||
| 247 | #[inline(always)] | ||
| 248 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 249 | self.w.bits = (self.w.bits & !(0x01 << 9)) | (((value as u32) & 0x01) << 9); | ||
| 250 | self.w | ||
| 251 | } | ||
| 252 | } | ||
| 253 | #[doc = "Reader of field `FBM10`"] | ||
| 254 | pub type FBM10_R = crate::R<bool, bool>; | ||
| 255 | #[doc = "Write proxy for field `FBM10`"] | ||
| 256 | pub struct FBM10_W<'a> { | ||
| 257 | w: &'a mut W, | ||
| 258 | } | ||
| 259 | impl<'a> FBM10_W<'a> { | ||
| 260 | #[doc = r"Sets the field bit"] | ||
| 261 | #[inline(always)] | ||
| 262 | pub fn set_bit(self) -> &'a mut W { | ||
| 263 | self.bit(true) | ||
| 264 | } | ||
| 265 | #[doc = r"Clears the field bit"] | ||
| 266 | #[inline(always)] | ||
| 267 | pub fn clear_bit(self) -> &'a mut W { | ||
| 268 | self.bit(false) | ||
| 269 | } | ||
| 270 | #[doc = r"Writes raw bits to the field"] | ||
| 271 | #[inline(always)] | ||
| 272 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 273 | self.w.bits = (self.w.bits & !(0x01 << 10)) | (((value as u32) & 0x01) << 10); | ||
| 274 | self.w | ||
| 275 | } | ||
| 276 | } | ||
| 277 | #[doc = "Reader of field `FBM11`"] | ||
| 278 | pub type FBM11_R = crate::R<bool, bool>; | ||
| 279 | #[doc = "Write proxy for field `FBM11`"] | ||
| 280 | pub struct FBM11_W<'a> { | ||
| 281 | w: &'a mut W, | ||
| 282 | } | ||
| 283 | impl<'a> FBM11_W<'a> { | ||
| 284 | #[doc = r"Sets the field bit"] | ||
| 285 | #[inline(always)] | ||
| 286 | pub fn set_bit(self) -> &'a mut W { | ||
| 287 | self.bit(true) | ||
| 288 | } | ||
| 289 | #[doc = r"Clears the field bit"] | ||
| 290 | #[inline(always)] | ||
| 291 | pub fn clear_bit(self) -> &'a mut W { | ||
| 292 | self.bit(false) | ||
| 293 | } | ||
| 294 | #[doc = r"Writes raw bits to the field"] | ||
| 295 | #[inline(always)] | ||
| 296 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 297 | self.w.bits = (self.w.bits & !(0x01 << 11)) | (((value as u32) & 0x01) << 11); | ||
| 298 | self.w | ||
| 299 | } | ||
| 300 | } | ||
| 301 | #[doc = "Reader of field `FBM12`"] | ||
| 302 | pub type FBM12_R = crate::R<bool, bool>; | ||
| 303 | #[doc = "Write proxy for field `FBM12`"] | ||
| 304 | pub struct FBM12_W<'a> { | ||
| 305 | w: &'a mut W, | ||
| 306 | } | ||
| 307 | impl<'a> FBM12_W<'a> { | ||
| 308 | #[doc = r"Sets the field bit"] | ||
| 309 | #[inline(always)] | ||
| 310 | pub fn set_bit(self) -> &'a mut W { | ||
| 311 | self.bit(true) | ||
| 312 | } | ||
| 313 | #[doc = r"Clears the field bit"] | ||
| 314 | #[inline(always)] | ||
| 315 | pub fn clear_bit(self) -> &'a mut W { | ||
| 316 | self.bit(false) | ||
| 317 | } | ||
| 318 | #[doc = r"Writes raw bits to the field"] | ||
| 319 | #[inline(always)] | ||
| 320 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 321 | self.w.bits = (self.w.bits & !(0x01 << 12)) | (((value as u32) & 0x01) << 12); | ||
| 322 | self.w | ||
| 323 | } | ||
| 324 | } | ||
| 325 | #[doc = "Reader of field `FBM13`"] | ||
| 326 | pub type FBM13_R = crate::R<bool, bool>; | ||
| 327 | #[doc = "Write proxy for field `FBM13`"] | ||
| 328 | pub struct FBM13_W<'a> { | ||
| 329 | w: &'a mut W, | ||
| 330 | } | ||
| 331 | impl<'a> FBM13_W<'a> { | ||
| 332 | #[doc = r"Sets the field bit"] | ||
| 333 | #[inline(always)] | ||
| 334 | pub fn set_bit(self) -> &'a mut W { | ||
| 335 | self.bit(true) | ||
| 336 | } | ||
| 337 | #[doc = r"Clears the field bit"] | ||
| 338 | #[inline(always)] | ||
| 339 | pub fn clear_bit(self) -> &'a mut W { | ||
| 340 | self.bit(false) | ||
| 341 | } | ||
| 342 | #[doc = r"Writes raw bits to the field"] | ||
| 343 | #[inline(always)] | ||
| 344 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 345 | self.w.bits = (self.w.bits & !(0x01 << 13)) | (((value as u32) & 0x01) << 13); | ||
| 346 | self.w | ||
| 347 | } | ||
| 348 | } | ||
| 349 | impl R { | ||
| 350 | #[doc = "Bit 0 - Filter mode"] | ||
| 351 | #[inline(always)] | ||
| 352 | pub fn fbm0(&self) -> FBM0_R { | ||
| 353 | FBM0_R::new((self.bits & 0x01) != 0) | ||
| 354 | } | ||
| 355 | #[doc = "Bit 1 - Filter mode"] | ||
| 356 | #[inline(always)] | ||
| 357 | pub fn fbm1(&self) -> FBM1_R { | ||
| 358 | FBM1_R::new(((self.bits >> 1) & 0x01) != 0) | ||
| 359 | } | ||
| 360 | #[doc = "Bit 2 - Filter mode"] | ||
| 361 | #[inline(always)] | ||
| 362 | pub fn fbm2(&self) -> FBM2_R { | ||
| 363 | FBM2_R::new(((self.bits >> 2) & 0x01) != 0) | ||
| 364 | } | ||
| 365 | #[doc = "Bit 3 - Filter mode"] | ||
| 366 | #[inline(always)] | ||
| 367 | pub fn fbm3(&self) -> FBM3_R { | ||
| 368 | FBM3_R::new(((self.bits >> 3) & 0x01) != 0) | ||
| 369 | } | ||
| 370 | #[doc = "Bit 4 - Filter mode"] | ||
| 371 | #[inline(always)] | ||
| 372 | pub fn fbm4(&self) -> FBM4_R { | ||
| 373 | FBM4_R::new(((self.bits >> 4) & 0x01) != 0) | ||
| 374 | } | ||
| 375 | #[doc = "Bit 5 - Filter mode"] | ||
| 376 | #[inline(always)] | ||
| 377 | pub fn fbm5(&self) -> FBM5_R { | ||
| 378 | FBM5_R::new(((self.bits >> 5) & 0x01) != 0) | ||
| 379 | } | ||
| 380 | #[doc = "Bit 6 - Filter mode"] | ||
| 381 | #[inline(always)] | ||
| 382 | pub fn fbm6(&self) -> FBM6_R { | ||
| 383 | FBM6_R::new(((self.bits >> 6) & 0x01) != 0) | ||
| 384 | } | ||
| 385 | #[doc = "Bit 7 - Filter mode"] | ||
| 386 | #[inline(always)] | ||
| 387 | pub fn fbm7(&self) -> FBM7_R { | ||
| 388 | FBM7_R::new(((self.bits >> 7) & 0x01) != 0) | ||
| 389 | } | ||
| 390 | #[doc = "Bit 8 - Filter mode"] | ||
| 391 | #[inline(always)] | ||
| 392 | pub fn fbm8(&self) -> FBM8_R { | ||
| 393 | FBM8_R::new(((self.bits >> 8) & 0x01) != 0) | ||
| 394 | } | ||
| 395 | #[doc = "Bit 9 - Filter mode"] | ||
| 396 | #[inline(always)] | ||
| 397 | pub fn fbm9(&self) -> FBM9_R { | ||
| 398 | FBM9_R::new(((self.bits >> 9) & 0x01) != 0) | ||
| 399 | } | ||
| 400 | #[doc = "Bit 10 - Filter mode"] | ||
| 401 | #[inline(always)] | ||
| 402 | pub fn fbm10(&self) -> FBM10_R { | ||
| 403 | FBM10_R::new(((self.bits >> 10) & 0x01) != 0) | ||
| 404 | } | ||
| 405 | #[doc = "Bit 11 - Filter mode"] | ||
| 406 | #[inline(always)] | ||
| 407 | pub fn fbm11(&self) -> FBM11_R { | ||
| 408 | FBM11_R::new(((self.bits >> 11) & 0x01) != 0) | ||
| 409 | } | ||
| 410 | #[doc = "Bit 12 - Filter mode"] | ||
| 411 | #[inline(always)] | ||
| 412 | pub fn fbm12(&self) -> FBM12_R { | ||
| 413 | FBM12_R::new(((self.bits >> 12) & 0x01) != 0) | ||
| 414 | } | ||
| 415 | #[doc = "Bit 13 - Filter mode"] | ||
| 416 | #[inline(always)] | ||
| 417 | pub fn fbm13(&self) -> FBM13_R { | ||
| 418 | FBM13_R::new(((self.bits >> 13) & 0x01) != 0) | ||
| 419 | } | ||
| 420 | } | ||
| 421 | impl W { | ||
| 422 | #[doc = "Bit 0 - Filter mode"] | ||
| 423 | #[inline(always)] | ||
| 424 | pub fn fbm0(&mut self) -> FBM0_W { | ||
| 425 | FBM0_W { w: self } | ||
| 426 | } | ||
| 427 | #[doc = "Bit 1 - Filter mode"] | ||
| 428 | #[inline(always)] | ||
| 429 | pub fn fbm1(&mut self) -> FBM1_W { | ||
| 430 | FBM1_W { w: self } | ||
| 431 | } | ||
| 432 | #[doc = "Bit 2 - Filter mode"] | ||
| 433 | #[inline(always)] | ||
| 434 | pub fn fbm2(&mut self) -> FBM2_W { | ||
| 435 | FBM2_W { w: self } | ||
| 436 | } | ||
| 437 | #[doc = "Bit 3 - Filter mode"] | ||
| 438 | #[inline(always)] | ||
| 439 | pub fn fbm3(&mut self) -> FBM3_W { | ||
| 440 | FBM3_W { w: self } | ||
| 441 | } | ||
| 442 | #[doc = "Bit 4 - Filter mode"] | ||
| 443 | #[inline(always)] | ||
| 444 | pub fn fbm4(&mut self) -> FBM4_W { | ||
| 445 | FBM4_W { w: self } | ||
| 446 | } | ||
| 447 | #[doc = "Bit 5 - Filter mode"] | ||
| 448 | #[inline(always)] | ||
| 449 | pub fn fbm5(&mut self) -> FBM5_W { | ||
| 450 | FBM5_W { w: self } | ||
| 451 | } | ||
| 452 | #[doc = "Bit 6 - Filter mode"] | ||
| 453 | #[inline(always)] | ||
| 454 | pub fn fbm6(&mut self) -> FBM6_W { | ||
| 455 | FBM6_W { w: self } | ||
| 456 | } | ||
| 457 | #[doc = "Bit 7 - Filter mode"] | ||
| 458 | #[inline(always)] | ||
| 459 | pub fn fbm7(&mut self) -> FBM7_W { | ||
| 460 | FBM7_W { w: self } | ||
| 461 | } | ||
| 462 | #[doc = "Bit 8 - Filter mode"] | ||
| 463 | #[inline(always)] | ||
| 464 | pub fn fbm8(&mut self) -> FBM8_W { | ||
| 465 | FBM8_W { w: self } | ||
| 466 | } | ||
| 467 | #[doc = "Bit 9 - Filter mode"] | ||
| 468 | #[inline(always)] | ||
| 469 | pub fn fbm9(&mut self) -> FBM9_W { | ||
| 470 | FBM9_W { w: self } | ||
| 471 | } | ||
| 472 | #[doc = "Bit 10 - Filter mode"] | ||
| 473 | #[inline(always)] | ||
| 474 | pub fn fbm10(&mut self) -> FBM10_W { | ||
| 475 | FBM10_W { w: self } | ||
| 476 | } | ||
| 477 | #[doc = "Bit 11 - Filter mode"] | ||
| 478 | #[inline(always)] | ||
| 479 | pub fn fbm11(&mut self) -> FBM11_W { | ||
| 480 | FBM11_W { w: self } | ||
| 481 | } | ||
| 482 | #[doc = "Bit 12 - Filter mode"] | ||
| 483 | #[inline(always)] | ||
| 484 | pub fn fbm12(&mut self) -> FBM12_W { | ||
| 485 | FBM12_W { w: self } | ||
| 486 | } | ||
| 487 | #[doc = "Bit 13 - Filter mode"] | ||
| 488 | #[inline(always)] | ||
| 489 | pub fn fbm13(&mut self) -> FBM13_W { | ||
| 490 | FBM13_W { w: self } | ||
| 491 | } | ||
| 492 | } | ||
diff --git a/embassy-stm32/src/can/bx/pac/can/fmr.rs b/embassy-stm32/src/can/bx/pac/can/fmr.rs new file mode 100644 index 000000000..5701af452 --- /dev/null +++ b/embassy-stm32/src/can/bx/pac/can/fmr.rs | |||
| @@ -0,0 +1,74 @@ | |||
| 1 | #[doc = "Reader of register FMR"] | ||
| 2 | pub type R = crate::R<u32, super::FMR>; | ||
| 3 | #[doc = "Writer for register FMR"] | ||
| 4 | pub type W = crate::W<u32, super::FMR>; | ||
| 5 | #[doc = "Register FMR `reset()`'s with value 0"] | ||
| 6 | impl crate::ResetValue for super::FMR { | ||
| 7 | type Type = u32; | ||
| 8 | #[inline(always)] | ||
| 9 | fn reset_value() -> Self::Type { | ||
| 10 | 0 | ||
| 11 | } | ||
| 12 | } | ||
| 13 | #[doc = "Reader of field `CAN2SB`"] | ||
| 14 | pub type CAN2SB_R = crate::R<u8, u8>; | ||
| 15 | #[doc = "Write proxy for field `CAN2SB`"] | ||
| 16 | pub struct CAN2SB_W<'a> { | ||
| 17 | w: &'a mut W, | ||
| 18 | } | ||
| 19 | impl<'a> CAN2SB_W<'a> { | ||
| 20 | #[doc = r"Writes raw bits to the field"] | ||
| 21 | #[inline(always)] | ||
| 22 | pub unsafe fn bits(self, value: u8) -> &'a mut W { | ||
| 23 | self.w.bits = (self.w.bits & !(0x3f << 8)) | (((value as u32) & 0x3f) << 8); | ||
| 24 | self.w | ||
| 25 | } | ||
| 26 | } | ||
| 27 | #[doc = "Reader of field `FINIT`"] | ||
| 28 | pub type FINIT_R = crate::R<bool, bool>; | ||
| 29 | #[doc = "Write proxy for field `FINIT`"] | ||
| 30 | pub struct FINIT_W<'a> { | ||
| 31 | w: &'a mut W, | ||
| 32 | } | ||
| 33 | impl<'a> FINIT_W<'a> { | ||
| 34 | #[doc = r"Sets the field bit"] | ||
| 35 | #[inline(always)] | ||
| 36 | pub fn set_bit(self) -> &'a mut W { | ||
| 37 | self.bit(true) | ||
| 38 | } | ||
| 39 | #[doc = r"Clears the field bit"] | ||
| 40 | #[inline(always)] | ||
| 41 | pub fn clear_bit(self) -> &'a mut W { | ||
| 42 | self.bit(false) | ||
| 43 | } | ||
| 44 | #[doc = r"Writes raw bits to the field"] | ||
| 45 | #[inline(always)] | ||
| 46 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 47 | self.w.bits = (self.w.bits & !0x01) | ((value as u32) & 0x01); | ||
| 48 | self.w | ||
| 49 | } | ||
| 50 | } | ||
| 51 | impl R { | ||
| 52 | #[doc = "Bits 8:13 - CAN2SB"] | ||
| 53 | #[inline(always)] | ||
| 54 | pub fn can2sb(&self) -> CAN2SB_R { | ||
| 55 | CAN2SB_R::new(((self.bits >> 8) & 0x3f) as u8) | ||
| 56 | } | ||
| 57 | #[doc = "Bit 0 - FINIT"] | ||
| 58 | #[inline(always)] | ||
| 59 | pub fn finit(&self) -> FINIT_R { | ||
| 60 | FINIT_R::new((self.bits & 0x01) != 0) | ||
| 61 | } | ||
| 62 | } | ||
| 63 | impl W { | ||
| 64 | #[doc = "Bits 8:13 - CAN2SB"] | ||
| 65 | #[inline(always)] | ||
| 66 | pub fn can2sb(&mut self) -> CAN2SB_W { | ||
| 67 | CAN2SB_W { w: self } | ||
| 68 | } | ||
| 69 | #[doc = "Bit 0 - FINIT"] | ||
| 70 | #[inline(always)] | ||
| 71 | pub fn finit(&mut self) -> FINIT_W { | ||
| 72 | FINIT_W { w: self } | ||
| 73 | } | ||
| 74 | } | ||
diff --git a/embassy-stm32/src/can/bx/pac/can/fs1r.rs b/embassy-stm32/src/can/bx/pac/can/fs1r.rs new file mode 100644 index 000000000..7bff8197d --- /dev/null +++ b/embassy-stm32/src/can/bx/pac/can/fs1r.rs | |||
| @@ -0,0 +1,492 @@ | |||
| 1 | #[doc = "Reader of register FS1R"] | ||
| 2 | pub type R = crate::R<u32, super::FS1R>; | ||
| 3 | #[doc = "Writer for register FS1R"] | ||
| 4 | pub type W = crate::W<u32, super::FS1R>; | ||
| 5 | #[doc = "Register FS1R `reset()`'s with value 0"] | ||
| 6 | impl crate::ResetValue for super::FS1R { | ||
| 7 | type Type = u32; | ||
| 8 | #[inline(always)] | ||
| 9 | fn reset_value() -> Self::Type { | ||
| 10 | 0 | ||
| 11 | } | ||
| 12 | } | ||
| 13 | #[doc = "Reader of field `FSC0`"] | ||
| 14 | pub type FSC0_R = crate::R<bool, bool>; | ||
| 15 | #[doc = "Write proxy for field `FSC0`"] | ||
| 16 | pub struct FSC0_W<'a> { | ||
| 17 | w: &'a mut W, | ||
| 18 | } | ||
| 19 | impl<'a> FSC0_W<'a> { | ||
| 20 | #[doc = r"Sets the field bit"] | ||
| 21 | #[inline(always)] | ||
| 22 | pub fn set_bit(self) -> &'a mut W { | ||
| 23 | self.bit(true) | ||
| 24 | } | ||
| 25 | #[doc = r"Clears the field bit"] | ||
| 26 | #[inline(always)] | ||
| 27 | pub fn clear_bit(self) -> &'a mut W { | ||
| 28 | self.bit(false) | ||
| 29 | } | ||
| 30 | #[doc = r"Writes raw bits to the field"] | ||
| 31 | #[inline(always)] | ||
| 32 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 33 | self.w.bits = (self.w.bits & !0x01) | ((value as u32) & 0x01); | ||
| 34 | self.w | ||
| 35 | } | ||
| 36 | } | ||
| 37 | #[doc = "Reader of field `FSC1`"] | ||
| 38 | pub type FSC1_R = crate::R<bool, bool>; | ||
| 39 | #[doc = "Write proxy for field `FSC1`"] | ||
| 40 | pub struct FSC1_W<'a> { | ||
| 41 | w: &'a mut W, | ||
| 42 | } | ||
| 43 | impl<'a> FSC1_W<'a> { | ||
| 44 | #[doc = r"Sets the field bit"] | ||
| 45 | #[inline(always)] | ||
| 46 | pub fn set_bit(self) -> &'a mut W { | ||
| 47 | self.bit(true) | ||
| 48 | } | ||
| 49 | #[doc = r"Clears the field bit"] | ||
| 50 | #[inline(always)] | ||
| 51 | pub fn clear_bit(self) -> &'a mut W { | ||
| 52 | self.bit(false) | ||
| 53 | } | ||
| 54 | #[doc = r"Writes raw bits to the field"] | ||
| 55 | #[inline(always)] | ||
| 56 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 57 | self.w.bits = (self.w.bits & !(0x01 << 1)) | (((value as u32) & 0x01) << 1); | ||
| 58 | self.w | ||
| 59 | } | ||
| 60 | } | ||
| 61 | #[doc = "Reader of field `FSC2`"] | ||
| 62 | pub type FSC2_R = crate::R<bool, bool>; | ||
| 63 | #[doc = "Write proxy for field `FSC2`"] | ||
| 64 | pub struct FSC2_W<'a> { | ||
| 65 | w: &'a mut W, | ||
| 66 | } | ||
| 67 | impl<'a> FSC2_W<'a> { | ||
| 68 | #[doc = r"Sets the field bit"] | ||
| 69 | #[inline(always)] | ||
| 70 | pub fn set_bit(self) -> &'a mut W { | ||
| 71 | self.bit(true) | ||
| 72 | } | ||
| 73 | #[doc = r"Clears the field bit"] | ||
| 74 | #[inline(always)] | ||
| 75 | pub fn clear_bit(self) -> &'a mut W { | ||
| 76 | self.bit(false) | ||
| 77 | } | ||
| 78 | #[doc = r"Writes raw bits to the field"] | ||
| 79 | #[inline(always)] | ||
| 80 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 81 | self.w.bits = (self.w.bits & !(0x01 << 2)) | (((value as u32) & 0x01) << 2); | ||
| 82 | self.w | ||
| 83 | } | ||
| 84 | } | ||
| 85 | #[doc = "Reader of field `FSC3`"] | ||
| 86 | pub type FSC3_R = crate::R<bool, bool>; | ||
| 87 | #[doc = "Write proxy for field `FSC3`"] | ||
| 88 | pub struct FSC3_W<'a> { | ||
| 89 | w: &'a mut W, | ||
| 90 | } | ||
| 91 | impl<'a> FSC3_W<'a> { | ||
| 92 | #[doc = r"Sets the field bit"] | ||
| 93 | #[inline(always)] | ||
| 94 | pub fn set_bit(self) -> &'a mut W { | ||
| 95 | self.bit(true) | ||
| 96 | } | ||
| 97 | #[doc = r"Clears the field bit"] | ||
| 98 | #[inline(always)] | ||
| 99 | pub fn clear_bit(self) -> &'a mut W { | ||
| 100 | self.bit(false) | ||
| 101 | } | ||
| 102 | #[doc = r"Writes raw bits to the field"] | ||
| 103 | #[inline(always)] | ||
| 104 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 105 | self.w.bits = (self.w.bits & !(0x01 << 3)) | (((value as u32) & 0x01) << 3); | ||
| 106 | self.w | ||
| 107 | } | ||
| 108 | } | ||
| 109 | #[doc = "Reader of field `FSC4`"] | ||
| 110 | pub type FSC4_R = crate::R<bool, bool>; | ||
| 111 | #[doc = "Write proxy for field `FSC4`"] | ||
| 112 | pub struct FSC4_W<'a> { | ||
| 113 | w: &'a mut W, | ||
| 114 | } | ||
| 115 | impl<'a> FSC4_W<'a> { | ||
| 116 | #[doc = r"Sets the field bit"] | ||
| 117 | #[inline(always)] | ||
| 118 | pub fn set_bit(self) -> &'a mut W { | ||
| 119 | self.bit(true) | ||
| 120 | } | ||
| 121 | #[doc = r"Clears the field bit"] | ||
| 122 | #[inline(always)] | ||
| 123 | pub fn clear_bit(self) -> &'a mut W { | ||
| 124 | self.bit(false) | ||
| 125 | } | ||
| 126 | #[doc = r"Writes raw bits to the field"] | ||
| 127 | #[inline(always)] | ||
| 128 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 129 | self.w.bits = (self.w.bits & !(0x01 << 4)) | (((value as u32) & 0x01) << 4); | ||
| 130 | self.w | ||
| 131 | } | ||
| 132 | } | ||
| 133 | #[doc = "Reader of field `FSC5`"] | ||
| 134 | pub type FSC5_R = crate::R<bool, bool>; | ||
| 135 | #[doc = "Write proxy for field `FSC5`"] | ||
| 136 | pub struct FSC5_W<'a> { | ||
| 137 | w: &'a mut W, | ||
| 138 | } | ||
| 139 | impl<'a> FSC5_W<'a> { | ||
| 140 | #[doc = r"Sets the field bit"] | ||
| 141 | #[inline(always)] | ||
| 142 | pub fn set_bit(self) -> &'a mut W { | ||
| 143 | self.bit(true) | ||
| 144 | } | ||
| 145 | #[doc = r"Clears the field bit"] | ||
| 146 | #[inline(always)] | ||
| 147 | pub fn clear_bit(self) -> &'a mut W { | ||
| 148 | self.bit(false) | ||
| 149 | } | ||
| 150 | #[doc = r"Writes raw bits to the field"] | ||
| 151 | #[inline(always)] | ||
| 152 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 153 | self.w.bits = (self.w.bits & !(0x01 << 5)) | (((value as u32) & 0x01) << 5); | ||
| 154 | self.w | ||
| 155 | } | ||
| 156 | } | ||
| 157 | #[doc = "Reader of field `FSC6`"] | ||
| 158 | pub type FSC6_R = crate::R<bool, bool>; | ||
| 159 | #[doc = "Write proxy for field `FSC6`"] | ||
| 160 | pub struct FSC6_W<'a> { | ||
| 161 | w: &'a mut W, | ||
| 162 | } | ||
| 163 | impl<'a> FSC6_W<'a> { | ||
| 164 | #[doc = r"Sets the field bit"] | ||
| 165 | #[inline(always)] | ||
| 166 | pub fn set_bit(self) -> &'a mut W { | ||
| 167 | self.bit(true) | ||
| 168 | } | ||
| 169 | #[doc = r"Clears the field bit"] | ||
| 170 | #[inline(always)] | ||
| 171 | pub fn clear_bit(self) -> &'a mut W { | ||
| 172 | self.bit(false) | ||
| 173 | } | ||
| 174 | #[doc = r"Writes raw bits to the field"] | ||
| 175 | #[inline(always)] | ||
| 176 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 177 | self.w.bits = (self.w.bits & !(0x01 << 6)) | (((value as u32) & 0x01) << 6); | ||
| 178 | self.w | ||
| 179 | } | ||
| 180 | } | ||
| 181 | #[doc = "Reader of field `FSC7`"] | ||
| 182 | pub type FSC7_R = crate::R<bool, bool>; | ||
| 183 | #[doc = "Write proxy for field `FSC7`"] | ||
| 184 | pub struct FSC7_W<'a> { | ||
| 185 | w: &'a mut W, | ||
| 186 | } | ||
| 187 | impl<'a> FSC7_W<'a> { | ||
| 188 | #[doc = r"Sets the field bit"] | ||
| 189 | #[inline(always)] | ||
| 190 | pub fn set_bit(self) -> &'a mut W { | ||
| 191 | self.bit(true) | ||
| 192 | } | ||
| 193 | #[doc = r"Clears the field bit"] | ||
| 194 | #[inline(always)] | ||
| 195 | pub fn clear_bit(self) -> &'a mut W { | ||
| 196 | self.bit(false) | ||
| 197 | } | ||
| 198 | #[doc = r"Writes raw bits to the field"] | ||
| 199 | #[inline(always)] | ||
| 200 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 201 | self.w.bits = (self.w.bits & !(0x01 << 7)) | (((value as u32) & 0x01) << 7); | ||
| 202 | self.w | ||
| 203 | } | ||
| 204 | } | ||
| 205 | #[doc = "Reader of field `FSC8`"] | ||
| 206 | pub type FSC8_R = crate::R<bool, bool>; | ||
| 207 | #[doc = "Write proxy for field `FSC8`"] | ||
| 208 | pub struct FSC8_W<'a> { | ||
| 209 | w: &'a mut W, | ||
| 210 | } | ||
| 211 | impl<'a> FSC8_W<'a> { | ||
| 212 | #[doc = r"Sets the field bit"] | ||
| 213 | #[inline(always)] | ||
| 214 | pub fn set_bit(self) -> &'a mut W { | ||
| 215 | self.bit(true) | ||
| 216 | } | ||
| 217 | #[doc = r"Clears the field bit"] | ||
| 218 | #[inline(always)] | ||
| 219 | pub fn clear_bit(self) -> &'a mut W { | ||
| 220 | self.bit(false) | ||
| 221 | } | ||
| 222 | #[doc = r"Writes raw bits to the field"] | ||
| 223 | #[inline(always)] | ||
| 224 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 225 | self.w.bits = (self.w.bits & !(0x01 << 8)) | (((value as u32) & 0x01) << 8); | ||
| 226 | self.w | ||
| 227 | } | ||
| 228 | } | ||
| 229 | #[doc = "Reader of field `FSC9`"] | ||
| 230 | pub type FSC9_R = crate::R<bool, bool>; | ||
| 231 | #[doc = "Write proxy for field `FSC9`"] | ||
| 232 | pub struct FSC9_W<'a> { | ||
| 233 | w: &'a mut W, | ||
| 234 | } | ||
| 235 | impl<'a> FSC9_W<'a> { | ||
| 236 | #[doc = r"Sets the field bit"] | ||
| 237 | #[inline(always)] | ||
| 238 | pub fn set_bit(self) -> &'a mut W { | ||
| 239 | self.bit(true) | ||
| 240 | } | ||
| 241 | #[doc = r"Clears the field bit"] | ||
| 242 | #[inline(always)] | ||
| 243 | pub fn clear_bit(self) -> &'a mut W { | ||
| 244 | self.bit(false) | ||
| 245 | } | ||
| 246 | #[doc = r"Writes raw bits to the field"] | ||
| 247 | #[inline(always)] | ||
| 248 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 249 | self.w.bits = (self.w.bits & !(0x01 << 9)) | (((value as u32) & 0x01) << 9); | ||
| 250 | self.w | ||
| 251 | } | ||
| 252 | } | ||
| 253 | #[doc = "Reader of field `FSC10`"] | ||
| 254 | pub type FSC10_R = crate::R<bool, bool>; | ||
| 255 | #[doc = "Write proxy for field `FSC10`"] | ||
| 256 | pub struct FSC10_W<'a> { | ||
| 257 | w: &'a mut W, | ||
| 258 | } | ||
| 259 | impl<'a> FSC10_W<'a> { | ||
| 260 | #[doc = r"Sets the field bit"] | ||
| 261 | #[inline(always)] | ||
| 262 | pub fn set_bit(self) -> &'a mut W { | ||
| 263 | self.bit(true) | ||
| 264 | } | ||
| 265 | #[doc = r"Clears the field bit"] | ||
| 266 | #[inline(always)] | ||
| 267 | pub fn clear_bit(self) -> &'a mut W { | ||
| 268 | self.bit(false) | ||
| 269 | } | ||
| 270 | #[doc = r"Writes raw bits to the field"] | ||
| 271 | #[inline(always)] | ||
| 272 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 273 | self.w.bits = (self.w.bits & !(0x01 << 10)) | (((value as u32) & 0x01) << 10); | ||
| 274 | self.w | ||
| 275 | } | ||
| 276 | } | ||
| 277 | #[doc = "Reader of field `FSC11`"] | ||
| 278 | pub type FSC11_R = crate::R<bool, bool>; | ||
| 279 | #[doc = "Write proxy for field `FSC11`"] | ||
| 280 | pub struct FSC11_W<'a> { | ||
| 281 | w: &'a mut W, | ||
| 282 | } | ||
| 283 | impl<'a> FSC11_W<'a> { | ||
| 284 | #[doc = r"Sets the field bit"] | ||
| 285 | #[inline(always)] | ||
| 286 | pub fn set_bit(self) -> &'a mut W { | ||
| 287 | self.bit(true) | ||
| 288 | } | ||
| 289 | #[doc = r"Clears the field bit"] | ||
| 290 | #[inline(always)] | ||
| 291 | pub fn clear_bit(self) -> &'a mut W { | ||
| 292 | self.bit(false) | ||
| 293 | } | ||
| 294 | #[doc = r"Writes raw bits to the field"] | ||
| 295 | #[inline(always)] | ||
| 296 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 297 | self.w.bits = (self.w.bits & !(0x01 << 11)) | (((value as u32) & 0x01) << 11); | ||
| 298 | self.w | ||
| 299 | } | ||
| 300 | } | ||
| 301 | #[doc = "Reader of field `FSC12`"] | ||
| 302 | pub type FSC12_R = crate::R<bool, bool>; | ||
| 303 | #[doc = "Write proxy for field `FSC12`"] | ||
| 304 | pub struct FSC12_W<'a> { | ||
| 305 | w: &'a mut W, | ||
| 306 | } | ||
| 307 | impl<'a> FSC12_W<'a> { | ||
| 308 | #[doc = r"Sets the field bit"] | ||
| 309 | #[inline(always)] | ||
| 310 | pub fn set_bit(self) -> &'a mut W { | ||
| 311 | self.bit(true) | ||
| 312 | } | ||
| 313 | #[doc = r"Clears the field bit"] | ||
| 314 | #[inline(always)] | ||
| 315 | pub fn clear_bit(self) -> &'a mut W { | ||
| 316 | self.bit(false) | ||
| 317 | } | ||
| 318 | #[doc = r"Writes raw bits to the field"] | ||
| 319 | #[inline(always)] | ||
| 320 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 321 | self.w.bits = (self.w.bits & !(0x01 << 12)) | (((value as u32) & 0x01) << 12); | ||
| 322 | self.w | ||
| 323 | } | ||
| 324 | } | ||
| 325 | #[doc = "Reader of field `FSC13`"] | ||
| 326 | pub type FSC13_R = crate::R<bool, bool>; | ||
| 327 | #[doc = "Write proxy for field `FSC13`"] | ||
| 328 | pub struct FSC13_W<'a> { | ||
| 329 | w: &'a mut W, | ||
| 330 | } | ||
| 331 | impl<'a> FSC13_W<'a> { | ||
| 332 | #[doc = r"Sets the field bit"] | ||
| 333 | #[inline(always)] | ||
| 334 | pub fn set_bit(self) -> &'a mut W { | ||
| 335 | self.bit(true) | ||
| 336 | } | ||
| 337 | #[doc = r"Clears the field bit"] | ||
| 338 | #[inline(always)] | ||
| 339 | pub fn clear_bit(self) -> &'a mut W { | ||
| 340 | self.bit(false) | ||
| 341 | } | ||
| 342 | #[doc = r"Writes raw bits to the field"] | ||
| 343 | #[inline(always)] | ||
| 344 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 345 | self.w.bits = (self.w.bits & !(0x01 << 13)) | (((value as u32) & 0x01) << 13); | ||
| 346 | self.w | ||
| 347 | } | ||
| 348 | } | ||
| 349 | impl R { | ||
| 350 | #[doc = "Bit 0 - Filter scale configuration"] | ||
| 351 | #[inline(always)] | ||
| 352 | pub fn fsc0(&self) -> FSC0_R { | ||
| 353 | FSC0_R::new((self.bits & 0x01) != 0) | ||
| 354 | } | ||
| 355 | #[doc = "Bit 1 - Filter scale configuration"] | ||
| 356 | #[inline(always)] | ||
| 357 | pub fn fsc1(&self) -> FSC1_R { | ||
| 358 | FSC1_R::new(((self.bits >> 1) & 0x01) != 0) | ||
| 359 | } | ||
| 360 | #[doc = "Bit 2 - Filter scale configuration"] | ||
| 361 | #[inline(always)] | ||
| 362 | pub fn fsc2(&self) -> FSC2_R { | ||
| 363 | FSC2_R::new(((self.bits >> 2) & 0x01) != 0) | ||
| 364 | } | ||
| 365 | #[doc = "Bit 3 - Filter scale configuration"] | ||
| 366 | #[inline(always)] | ||
| 367 | pub fn fsc3(&self) -> FSC3_R { | ||
| 368 | FSC3_R::new(((self.bits >> 3) & 0x01) != 0) | ||
| 369 | } | ||
| 370 | #[doc = "Bit 4 - Filter scale configuration"] | ||
| 371 | #[inline(always)] | ||
| 372 | pub fn fsc4(&self) -> FSC4_R { | ||
| 373 | FSC4_R::new(((self.bits >> 4) & 0x01) != 0) | ||
| 374 | } | ||
| 375 | #[doc = "Bit 5 - Filter scale configuration"] | ||
| 376 | #[inline(always)] | ||
| 377 | pub fn fsc5(&self) -> FSC5_R { | ||
| 378 | FSC5_R::new(((self.bits >> 5) & 0x01) != 0) | ||
| 379 | } | ||
| 380 | #[doc = "Bit 6 - Filter scale configuration"] | ||
| 381 | #[inline(always)] | ||
| 382 | pub fn fsc6(&self) -> FSC6_R { | ||
| 383 | FSC6_R::new(((self.bits >> 6) & 0x01) != 0) | ||
| 384 | } | ||
| 385 | #[doc = "Bit 7 - Filter scale configuration"] | ||
| 386 | #[inline(always)] | ||
| 387 | pub fn fsc7(&self) -> FSC7_R { | ||
| 388 | FSC7_R::new(((self.bits >> 7) & 0x01) != 0) | ||
| 389 | } | ||
| 390 | #[doc = "Bit 8 - Filter scale configuration"] | ||
| 391 | #[inline(always)] | ||
| 392 | pub fn fsc8(&self) -> FSC8_R { | ||
| 393 | FSC8_R::new(((self.bits >> 8) & 0x01) != 0) | ||
| 394 | } | ||
| 395 | #[doc = "Bit 9 - Filter scale configuration"] | ||
| 396 | #[inline(always)] | ||
| 397 | pub fn fsc9(&self) -> FSC9_R { | ||
| 398 | FSC9_R::new(((self.bits >> 9) & 0x01) != 0) | ||
| 399 | } | ||
| 400 | #[doc = "Bit 10 - Filter scale configuration"] | ||
| 401 | #[inline(always)] | ||
| 402 | pub fn fsc10(&self) -> FSC10_R { | ||
| 403 | FSC10_R::new(((self.bits >> 10) & 0x01) != 0) | ||
| 404 | } | ||
| 405 | #[doc = "Bit 11 - Filter scale configuration"] | ||
| 406 | #[inline(always)] | ||
| 407 | pub fn fsc11(&self) -> FSC11_R { | ||
| 408 | FSC11_R::new(((self.bits >> 11) & 0x01) != 0) | ||
| 409 | } | ||
| 410 | #[doc = "Bit 12 - Filter scale configuration"] | ||
| 411 | #[inline(always)] | ||
| 412 | pub fn fsc12(&self) -> FSC12_R { | ||
| 413 | FSC12_R::new(((self.bits >> 12) & 0x01) != 0) | ||
| 414 | } | ||
| 415 | #[doc = "Bit 13 - Filter scale configuration"] | ||
| 416 | #[inline(always)] | ||
| 417 | pub fn fsc13(&self) -> FSC13_R { | ||
| 418 | FSC13_R::new(((self.bits >> 13) & 0x01) != 0) | ||
| 419 | } | ||
| 420 | } | ||
| 421 | impl W { | ||
| 422 | #[doc = "Bit 0 - Filter scale configuration"] | ||
| 423 | #[inline(always)] | ||
| 424 | pub fn fsc0(&mut self) -> FSC0_W { | ||
| 425 | FSC0_W { w: self } | ||
| 426 | } | ||
| 427 | #[doc = "Bit 1 - Filter scale configuration"] | ||
| 428 | #[inline(always)] | ||
| 429 | pub fn fsc1(&mut self) -> FSC1_W { | ||
| 430 | FSC1_W { w: self } | ||
| 431 | } | ||
| 432 | #[doc = "Bit 2 - Filter scale configuration"] | ||
| 433 | #[inline(always)] | ||
| 434 | pub fn fsc2(&mut self) -> FSC2_W { | ||
| 435 | FSC2_W { w: self } | ||
| 436 | } | ||
| 437 | #[doc = "Bit 3 - Filter scale configuration"] | ||
| 438 | #[inline(always)] | ||
| 439 | pub fn fsc3(&mut self) -> FSC3_W { | ||
| 440 | FSC3_W { w: self } | ||
| 441 | } | ||
| 442 | #[doc = "Bit 4 - Filter scale configuration"] | ||
| 443 | #[inline(always)] | ||
| 444 | pub fn fsc4(&mut self) -> FSC4_W { | ||
| 445 | FSC4_W { w: self } | ||
| 446 | } | ||
| 447 | #[doc = "Bit 5 - Filter scale configuration"] | ||
| 448 | #[inline(always)] | ||
| 449 | pub fn fsc5(&mut self) -> FSC5_W { | ||
| 450 | FSC5_W { w: self } | ||
| 451 | } | ||
| 452 | #[doc = "Bit 6 - Filter scale configuration"] | ||
| 453 | #[inline(always)] | ||
| 454 | pub fn fsc6(&mut self) -> FSC6_W { | ||
| 455 | FSC6_W { w: self } | ||
| 456 | } | ||
| 457 | #[doc = "Bit 7 - Filter scale configuration"] | ||
| 458 | #[inline(always)] | ||
| 459 | pub fn fsc7(&mut self) -> FSC7_W { | ||
| 460 | FSC7_W { w: self } | ||
| 461 | } | ||
| 462 | #[doc = "Bit 8 - Filter scale configuration"] | ||
| 463 | #[inline(always)] | ||
| 464 | pub fn fsc8(&mut self) -> FSC8_W { | ||
| 465 | FSC8_W { w: self } | ||
| 466 | } | ||
| 467 | #[doc = "Bit 9 - Filter scale configuration"] | ||
| 468 | #[inline(always)] | ||
| 469 | pub fn fsc9(&mut self) -> FSC9_W { | ||
| 470 | FSC9_W { w: self } | ||
| 471 | } | ||
| 472 | #[doc = "Bit 10 - Filter scale configuration"] | ||
| 473 | #[inline(always)] | ||
| 474 | pub fn fsc10(&mut self) -> FSC10_W { | ||
| 475 | FSC10_W { w: self } | ||
| 476 | } | ||
| 477 | #[doc = "Bit 11 - Filter scale configuration"] | ||
| 478 | #[inline(always)] | ||
| 479 | pub fn fsc11(&mut self) -> FSC11_W { | ||
| 480 | FSC11_W { w: self } | ||
| 481 | } | ||
| 482 | #[doc = "Bit 12 - Filter scale configuration"] | ||
| 483 | #[inline(always)] | ||
| 484 | pub fn fsc12(&mut self) -> FSC12_W { | ||
| 485 | FSC12_W { w: self } | ||
| 486 | } | ||
| 487 | #[doc = "Bit 13 - Filter scale configuration"] | ||
| 488 | #[inline(always)] | ||
| 489 | pub fn fsc13(&mut self) -> FSC13_W { | ||
| 490 | FSC13_W { w: self } | ||
| 491 | } | ||
| 492 | } | ||
diff --git a/embassy-stm32/src/can/bx/pac/can/ier.rs b/embassy-stm32/src/can/bx/pac/can/ier.rs new file mode 100644 index 000000000..3c57331b7 --- /dev/null +++ b/embassy-stm32/src/can/bx/pac/can/ier.rs | |||
| @@ -0,0 +1,1218 @@ | |||
| 1 | #[doc = "Reader of register IER"] | ||
| 2 | pub type R = crate::R<u32, super::IER>; | ||
| 3 | #[doc = "Writer for register IER"] | ||
| 4 | pub type W = crate::W<u32, super::IER>; | ||
| 5 | #[doc = "Register IER `reset()`'s with value 0"] | ||
| 6 | impl crate::ResetValue for super::IER { | ||
| 7 | type Type = u32; | ||
| 8 | #[inline(always)] | ||
| 9 | fn reset_value() -> Self::Type { | ||
| 10 | 0 | ||
| 11 | } | ||
| 12 | } | ||
| 13 | #[doc = "SLKIE\n\nValue on reset: 0"] | ||
| 14 | #[derive(Clone, Copy, Debug, PartialEq)] | ||
| 15 | pub enum SLKIE_A { | ||
| 16 | #[doc = "0: No interrupt when SLAKI bit is set"] | ||
| 17 | DISABLED = 0, | ||
| 18 | #[doc = "1: Interrupt generated when SLAKI bit is set"] | ||
| 19 | ENABLED = 1, | ||
| 20 | } | ||
| 21 | impl From<SLKIE_A> for bool { | ||
| 22 | #[inline(always)] | ||
| 23 | fn from(variant: SLKIE_A) -> Self { | ||
| 24 | variant as u8 != 0 | ||
| 25 | } | ||
| 26 | } | ||
| 27 | #[doc = "Reader of field `SLKIE`"] | ||
| 28 | pub type SLKIE_R = crate::R<bool, SLKIE_A>; | ||
| 29 | impl SLKIE_R { | ||
| 30 | #[doc = r"Get enumerated values variant"] | ||
| 31 | #[inline(always)] | ||
| 32 | pub fn variant(&self) -> SLKIE_A { | ||
| 33 | match self.bits { | ||
| 34 | false => SLKIE_A::DISABLED, | ||
| 35 | true => SLKIE_A::ENABLED, | ||
| 36 | } | ||
| 37 | } | ||
| 38 | #[doc = "Checks if the value of the field is `DISABLED`"] | ||
| 39 | #[inline(always)] | ||
| 40 | pub fn is_disabled(&self) -> bool { | ||
| 41 | *self == SLKIE_A::DISABLED | ||
| 42 | } | ||
| 43 | #[doc = "Checks if the value of the field is `ENABLED`"] | ||
| 44 | #[inline(always)] | ||
| 45 | pub fn is_enabled(&self) -> bool { | ||
| 46 | *self == SLKIE_A::ENABLED | ||
| 47 | } | ||
| 48 | } | ||
| 49 | #[doc = "Write proxy for field `SLKIE`"] | ||
| 50 | pub struct SLKIE_W<'a> { | ||
| 51 | w: &'a mut W, | ||
| 52 | } | ||
| 53 | impl<'a> SLKIE_W<'a> { | ||
| 54 | #[doc = r"Writes `variant` to the field"] | ||
| 55 | #[inline(always)] | ||
| 56 | pub fn variant(self, variant: SLKIE_A) -> &'a mut W { | ||
| 57 | { | ||
| 58 | self.bit(variant.into()) | ||
| 59 | } | ||
| 60 | } | ||
| 61 | #[doc = "No interrupt when SLAKI bit is set"] | ||
| 62 | #[inline(always)] | ||
| 63 | pub fn disabled(self) -> &'a mut W { | ||
| 64 | self.variant(SLKIE_A::DISABLED) | ||
| 65 | } | ||
| 66 | #[doc = "Interrupt generated when SLAKI bit is set"] | ||
| 67 | #[inline(always)] | ||
| 68 | pub fn enabled(self) -> &'a mut W { | ||
| 69 | self.variant(SLKIE_A::ENABLED) | ||
| 70 | } | ||
| 71 | #[doc = r"Sets the field bit"] | ||
| 72 | #[inline(always)] | ||
| 73 | pub fn set_bit(self) -> &'a mut W { | ||
| 74 | self.bit(true) | ||
| 75 | } | ||
| 76 | #[doc = r"Clears the field bit"] | ||
| 77 | #[inline(always)] | ||
| 78 | pub fn clear_bit(self) -> &'a mut W { | ||
| 79 | self.bit(false) | ||
| 80 | } | ||
| 81 | #[doc = r"Writes raw bits to the field"] | ||
| 82 | #[inline(always)] | ||
| 83 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 84 | self.w.bits = (self.w.bits & !(0x01 << 17)) | (((value as u32) & 0x01) << 17); | ||
| 85 | self.w | ||
| 86 | } | ||
| 87 | } | ||
| 88 | #[doc = "WKUIE\n\nValue on reset: 0"] | ||
| 89 | #[derive(Clone, Copy, Debug, PartialEq)] | ||
| 90 | pub enum WKUIE_A { | ||
| 91 | #[doc = "0: No interrupt when WKUI is set"] | ||
| 92 | DISABLED = 0, | ||
| 93 | #[doc = "1: Interrupt generated when WKUI bit is set"] | ||
| 94 | ENABLED = 1, | ||
| 95 | } | ||
| 96 | impl From<WKUIE_A> for bool { | ||
| 97 | #[inline(always)] | ||
| 98 | fn from(variant: WKUIE_A) -> Self { | ||
| 99 | variant as u8 != 0 | ||
| 100 | } | ||
| 101 | } | ||
| 102 | #[doc = "Reader of field `WKUIE`"] | ||
| 103 | pub type WKUIE_R = crate::R<bool, WKUIE_A>; | ||
| 104 | impl WKUIE_R { | ||
| 105 | #[doc = r"Get enumerated values variant"] | ||
| 106 | #[inline(always)] | ||
| 107 | pub fn variant(&self) -> WKUIE_A { | ||
| 108 | match self.bits { | ||
| 109 | false => WKUIE_A::DISABLED, | ||
| 110 | true => WKUIE_A::ENABLED, | ||
| 111 | } | ||
| 112 | } | ||
| 113 | #[doc = "Checks if the value of the field is `DISABLED`"] | ||
| 114 | #[inline(always)] | ||
| 115 | pub fn is_disabled(&self) -> bool { | ||
| 116 | *self == WKUIE_A::DISABLED | ||
| 117 | } | ||
| 118 | #[doc = "Checks if the value of the field is `ENABLED`"] | ||
| 119 | #[inline(always)] | ||
| 120 | pub fn is_enabled(&self) -> bool { | ||
| 121 | *self == WKUIE_A::ENABLED | ||
| 122 | } | ||
| 123 | } | ||
| 124 | #[doc = "Write proxy for field `WKUIE`"] | ||
| 125 | pub struct WKUIE_W<'a> { | ||
| 126 | w: &'a mut W, | ||
| 127 | } | ||
| 128 | impl<'a> WKUIE_W<'a> { | ||
| 129 | #[doc = r"Writes `variant` to the field"] | ||
| 130 | #[inline(always)] | ||
| 131 | pub fn variant(self, variant: WKUIE_A) -> &'a mut W { | ||
| 132 | { | ||
| 133 | self.bit(variant.into()) | ||
| 134 | } | ||
| 135 | } | ||
| 136 | #[doc = "No interrupt when WKUI is set"] | ||
| 137 | #[inline(always)] | ||
| 138 | pub fn disabled(self) -> &'a mut W { | ||
| 139 | self.variant(WKUIE_A::DISABLED) | ||
| 140 | } | ||
| 141 | #[doc = "Interrupt generated when WKUI bit is set"] | ||
| 142 | #[inline(always)] | ||
| 143 | pub fn enabled(self) -> &'a mut W { | ||
| 144 | self.variant(WKUIE_A::ENABLED) | ||
| 145 | } | ||
| 146 | #[doc = r"Sets the field bit"] | ||
| 147 | #[inline(always)] | ||
| 148 | pub fn set_bit(self) -> &'a mut W { | ||
| 149 | self.bit(true) | ||
| 150 | } | ||
| 151 | #[doc = r"Clears the field bit"] | ||
| 152 | #[inline(always)] | ||
| 153 | pub fn clear_bit(self) -> &'a mut W { | ||
| 154 | self.bit(false) | ||
| 155 | } | ||
| 156 | #[doc = r"Writes raw bits to the field"] | ||
| 157 | #[inline(always)] | ||
| 158 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 159 | self.w.bits = (self.w.bits & !(0x01 << 16)) | (((value as u32) & 0x01) << 16); | ||
| 160 | self.w | ||
| 161 | } | ||
| 162 | } | ||
| 163 | #[doc = "ERRIE\n\nValue on reset: 0"] | ||
| 164 | #[derive(Clone, Copy, Debug, PartialEq)] | ||
| 165 | pub enum ERRIE_A { | ||
| 166 | #[doc = "0: No interrupt will be generated when an error condition is pending in the CAN_ESR"] | ||
| 167 | DISABLED = 0, | ||
| 168 | #[doc = "1: An interrupt will be generation when an error condition is pending in the CAN_ESR"] | ||
| 169 | ENABLED = 1, | ||
| 170 | } | ||
| 171 | impl From<ERRIE_A> for bool { | ||
| 172 | #[inline(always)] | ||
| 173 | fn from(variant: ERRIE_A) -> Self { | ||
| 174 | variant as u8 != 0 | ||
| 175 | } | ||
| 176 | } | ||
| 177 | #[doc = "Reader of field `ERRIE`"] | ||
| 178 | pub type ERRIE_R = crate::R<bool, ERRIE_A>; | ||
| 179 | impl ERRIE_R { | ||
| 180 | #[doc = r"Get enumerated values variant"] | ||
| 181 | #[inline(always)] | ||
| 182 | pub fn variant(&self) -> ERRIE_A { | ||
| 183 | match self.bits { | ||
| 184 | false => ERRIE_A::DISABLED, | ||
| 185 | true => ERRIE_A::ENABLED, | ||
| 186 | } | ||
| 187 | } | ||
| 188 | #[doc = "Checks if the value of the field is `DISABLED`"] | ||
| 189 | #[inline(always)] | ||
| 190 | pub fn is_disabled(&self) -> bool { | ||
| 191 | *self == ERRIE_A::DISABLED | ||
| 192 | } | ||
| 193 | #[doc = "Checks if the value of the field is `ENABLED`"] | ||
| 194 | #[inline(always)] | ||
| 195 | pub fn is_enabled(&self) -> bool { | ||
| 196 | *self == ERRIE_A::ENABLED | ||
| 197 | } | ||
| 198 | } | ||
| 199 | #[doc = "Write proxy for field `ERRIE`"] | ||
| 200 | pub struct ERRIE_W<'a> { | ||
| 201 | w: &'a mut W, | ||
| 202 | } | ||
| 203 | impl<'a> ERRIE_W<'a> { | ||
| 204 | #[doc = r"Writes `variant` to the field"] | ||
| 205 | #[inline(always)] | ||
| 206 | pub fn variant(self, variant: ERRIE_A) -> &'a mut W { | ||
| 207 | { | ||
| 208 | self.bit(variant.into()) | ||
| 209 | } | ||
| 210 | } | ||
| 211 | #[doc = "No interrupt will be generated when an error condition is pending in the CAN_ESR"] | ||
| 212 | #[inline(always)] | ||
| 213 | pub fn disabled(self) -> &'a mut W { | ||
| 214 | self.variant(ERRIE_A::DISABLED) | ||
| 215 | } | ||
| 216 | #[doc = "An interrupt will be generation when an error condition is pending in the CAN_ESR"] | ||
| 217 | #[inline(always)] | ||
| 218 | pub fn enabled(self) -> &'a mut W { | ||
| 219 | self.variant(ERRIE_A::ENABLED) | ||
| 220 | } | ||
| 221 | #[doc = r"Sets the field bit"] | ||
| 222 | #[inline(always)] | ||
| 223 | pub fn set_bit(self) -> &'a mut W { | ||
| 224 | self.bit(true) | ||
| 225 | } | ||
| 226 | #[doc = r"Clears the field bit"] | ||
| 227 | #[inline(always)] | ||
| 228 | pub fn clear_bit(self) -> &'a mut W { | ||
| 229 | self.bit(false) | ||
| 230 | } | ||
| 231 | #[doc = r"Writes raw bits to the field"] | ||
| 232 | #[inline(always)] | ||
| 233 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 234 | self.w.bits = (self.w.bits & !(0x01 << 15)) | (((value as u32) & 0x01) << 15); | ||
| 235 | self.w | ||
| 236 | } | ||
| 237 | } | ||
| 238 | #[doc = "LECIE\n\nValue on reset: 0"] | ||
| 239 | #[derive(Clone, Copy, Debug, PartialEq)] | ||
| 240 | pub enum LECIE_A { | ||
| 241 | #[doc = "0: ERRI bit will not be set when the error code in LEC\\[2:0\\] | ||
| 242 | is set by hardware on error detection"] | ||
| 243 | DISABLED = 0, | ||
| 244 | #[doc = "1: ERRI bit will be set when the error code in LEC\\[2:0\\] | ||
| 245 | is set by hardware on error detection"] | ||
| 246 | ENABLED = 1, | ||
| 247 | } | ||
| 248 | impl From<LECIE_A> for bool { | ||
| 249 | #[inline(always)] | ||
| 250 | fn from(variant: LECIE_A) -> Self { | ||
| 251 | variant as u8 != 0 | ||
| 252 | } | ||
| 253 | } | ||
| 254 | #[doc = "Reader of field `LECIE`"] | ||
| 255 | pub type LECIE_R = crate::R<bool, LECIE_A>; | ||
| 256 | impl LECIE_R { | ||
| 257 | #[doc = r"Get enumerated values variant"] | ||
| 258 | #[inline(always)] | ||
| 259 | pub fn variant(&self) -> LECIE_A { | ||
| 260 | match self.bits { | ||
| 261 | false => LECIE_A::DISABLED, | ||
| 262 | true => LECIE_A::ENABLED, | ||
| 263 | } | ||
| 264 | } | ||
| 265 | #[doc = "Checks if the value of the field is `DISABLED`"] | ||
| 266 | #[inline(always)] | ||
| 267 | pub fn is_disabled(&self) -> bool { | ||
| 268 | *self == LECIE_A::DISABLED | ||
| 269 | } | ||
| 270 | #[doc = "Checks if the value of the field is `ENABLED`"] | ||
| 271 | #[inline(always)] | ||
| 272 | pub fn is_enabled(&self) -> bool { | ||
| 273 | *self == LECIE_A::ENABLED | ||
| 274 | } | ||
| 275 | } | ||
| 276 | #[doc = "Write proxy for field `LECIE`"] | ||
| 277 | pub struct LECIE_W<'a> { | ||
| 278 | w: &'a mut W, | ||
| 279 | } | ||
| 280 | impl<'a> LECIE_W<'a> { | ||
| 281 | #[doc = r"Writes `variant` to the field"] | ||
| 282 | #[inline(always)] | ||
| 283 | pub fn variant(self, variant: LECIE_A) -> &'a mut W { | ||
| 284 | { | ||
| 285 | self.bit(variant.into()) | ||
| 286 | } | ||
| 287 | } | ||
| 288 | #[doc = "ERRI bit will not be set when the error code in LEC\\[2:0\\] | ||
| 289 | is set by hardware on error detection"] | ||
| 290 | #[inline(always)] | ||
| 291 | pub fn disabled(self) -> &'a mut W { | ||
| 292 | self.variant(LECIE_A::DISABLED) | ||
| 293 | } | ||
| 294 | #[doc = "ERRI bit will be set when the error code in LEC\\[2:0\\] | ||
| 295 | is set by hardware on error detection"] | ||
| 296 | #[inline(always)] | ||
| 297 | pub fn enabled(self) -> &'a mut W { | ||
| 298 | self.variant(LECIE_A::ENABLED) | ||
| 299 | } | ||
| 300 | #[doc = r"Sets the field bit"] | ||
| 301 | #[inline(always)] | ||
| 302 | pub fn set_bit(self) -> &'a mut W { | ||
| 303 | self.bit(true) | ||
| 304 | } | ||
| 305 | #[doc = r"Clears the field bit"] | ||
| 306 | #[inline(always)] | ||
| 307 | pub fn clear_bit(self) -> &'a mut W { | ||
| 308 | self.bit(false) | ||
| 309 | } | ||
| 310 | #[doc = r"Writes raw bits to the field"] | ||
| 311 | #[inline(always)] | ||
| 312 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 313 | self.w.bits = (self.w.bits & !(0x01 << 11)) | (((value as u32) & 0x01) << 11); | ||
| 314 | self.w | ||
| 315 | } | ||
| 316 | } | ||
| 317 | #[doc = "BOFIE\n\nValue on reset: 0"] | ||
| 318 | #[derive(Clone, Copy, Debug, PartialEq)] | ||
| 319 | pub enum BOFIE_A { | ||
| 320 | #[doc = "0: ERRI bit will not be set when BOFF is set"] | ||
| 321 | DISABLED = 0, | ||
| 322 | #[doc = "1: ERRI bit will be set when BOFF is set"] | ||
| 323 | ENABLED = 1, | ||
| 324 | } | ||
| 325 | impl From<BOFIE_A> for bool { | ||
| 326 | #[inline(always)] | ||
| 327 | fn from(variant: BOFIE_A) -> Self { | ||
| 328 | variant as u8 != 0 | ||
| 329 | } | ||
| 330 | } | ||
| 331 | #[doc = "Reader of field `BOFIE`"] | ||
| 332 | pub type BOFIE_R = crate::R<bool, BOFIE_A>; | ||
| 333 | impl BOFIE_R { | ||
| 334 | #[doc = r"Get enumerated values variant"] | ||
| 335 | #[inline(always)] | ||
| 336 | pub fn variant(&self) -> BOFIE_A { | ||
| 337 | match self.bits { | ||
| 338 | false => BOFIE_A::DISABLED, | ||
| 339 | true => BOFIE_A::ENABLED, | ||
| 340 | } | ||
| 341 | } | ||
| 342 | #[doc = "Checks if the value of the field is `DISABLED`"] | ||
| 343 | #[inline(always)] | ||
| 344 | pub fn is_disabled(&self) -> bool { | ||
| 345 | *self == BOFIE_A::DISABLED | ||
| 346 | } | ||
| 347 | #[doc = "Checks if the value of the field is `ENABLED`"] | ||
| 348 | #[inline(always)] | ||
| 349 | pub fn is_enabled(&self) -> bool { | ||
| 350 | *self == BOFIE_A::ENABLED | ||
| 351 | } | ||
| 352 | } | ||
| 353 | #[doc = "Write proxy for field `BOFIE`"] | ||
| 354 | pub struct BOFIE_W<'a> { | ||
| 355 | w: &'a mut W, | ||
| 356 | } | ||
| 357 | impl<'a> BOFIE_W<'a> { | ||
| 358 | #[doc = r"Writes `variant` to the field"] | ||
| 359 | #[inline(always)] | ||
| 360 | pub fn variant(self, variant: BOFIE_A) -> &'a mut W { | ||
| 361 | { | ||
| 362 | self.bit(variant.into()) | ||
| 363 | } | ||
| 364 | } | ||
| 365 | #[doc = "ERRI bit will not be set when BOFF is set"] | ||
| 366 | #[inline(always)] | ||
| 367 | pub fn disabled(self) -> &'a mut W { | ||
| 368 | self.variant(BOFIE_A::DISABLED) | ||
| 369 | } | ||
| 370 | #[doc = "ERRI bit will be set when BOFF is set"] | ||
| 371 | #[inline(always)] | ||
| 372 | pub fn enabled(self) -> &'a mut W { | ||
| 373 | self.variant(BOFIE_A::ENABLED) | ||
| 374 | } | ||
| 375 | #[doc = r"Sets the field bit"] | ||
| 376 | #[inline(always)] | ||
| 377 | pub fn set_bit(self) -> &'a mut W { | ||
| 378 | self.bit(true) | ||
| 379 | } | ||
| 380 | #[doc = r"Clears the field bit"] | ||
| 381 | #[inline(always)] | ||
| 382 | pub fn clear_bit(self) -> &'a mut W { | ||
| 383 | self.bit(false) | ||
| 384 | } | ||
| 385 | #[doc = r"Writes raw bits to the field"] | ||
| 386 | #[inline(always)] | ||
| 387 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 388 | self.w.bits = (self.w.bits & !(0x01 << 10)) | (((value as u32) & 0x01) << 10); | ||
| 389 | self.w | ||
| 390 | } | ||
| 391 | } | ||
| 392 | #[doc = "EPVIE\n\nValue on reset: 0"] | ||
| 393 | #[derive(Clone, Copy, Debug, PartialEq)] | ||
| 394 | pub enum EPVIE_A { | ||
| 395 | #[doc = "0: ERRI bit will not be set when EPVF is set"] | ||
| 396 | DISABLED = 0, | ||
| 397 | #[doc = "1: ERRI bit will be set when EPVF is set"] | ||
| 398 | ENABLED = 1, | ||
| 399 | } | ||
| 400 | impl From<EPVIE_A> for bool { | ||
| 401 | #[inline(always)] | ||
| 402 | fn from(variant: EPVIE_A) -> Self { | ||
| 403 | variant as u8 != 0 | ||
| 404 | } | ||
| 405 | } | ||
| 406 | #[doc = "Reader of field `EPVIE`"] | ||
| 407 | pub type EPVIE_R = crate::R<bool, EPVIE_A>; | ||
| 408 | impl EPVIE_R { | ||
| 409 | #[doc = r"Get enumerated values variant"] | ||
| 410 | #[inline(always)] | ||
| 411 | pub fn variant(&self) -> EPVIE_A { | ||
| 412 | match self.bits { | ||
| 413 | false => EPVIE_A::DISABLED, | ||
| 414 | true => EPVIE_A::ENABLED, | ||
| 415 | } | ||
| 416 | } | ||
| 417 | #[doc = "Checks if the value of the field is `DISABLED`"] | ||
| 418 | #[inline(always)] | ||
| 419 | pub fn is_disabled(&self) -> bool { | ||
| 420 | *self == EPVIE_A::DISABLED | ||
| 421 | } | ||
| 422 | #[doc = "Checks if the value of the field is `ENABLED`"] | ||
| 423 | #[inline(always)] | ||
| 424 | pub fn is_enabled(&self) -> bool { | ||
| 425 | *self == EPVIE_A::ENABLED | ||
| 426 | } | ||
| 427 | } | ||
| 428 | #[doc = "Write proxy for field `EPVIE`"] | ||
| 429 | pub struct EPVIE_W<'a> { | ||
| 430 | w: &'a mut W, | ||
| 431 | } | ||
| 432 | impl<'a> EPVIE_W<'a> { | ||
| 433 | #[doc = r"Writes `variant` to the field"] | ||
| 434 | #[inline(always)] | ||
| 435 | pub fn variant(self, variant: EPVIE_A) -> &'a mut W { | ||
| 436 | { | ||
| 437 | self.bit(variant.into()) | ||
| 438 | } | ||
| 439 | } | ||
| 440 | #[doc = "ERRI bit will not be set when EPVF is set"] | ||
| 441 | #[inline(always)] | ||
| 442 | pub fn disabled(self) -> &'a mut W { | ||
| 443 | self.variant(EPVIE_A::DISABLED) | ||
| 444 | } | ||
| 445 | #[doc = "ERRI bit will be set when EPVF is set"] | ||
| 446 | #[inline(always)] | ||
| 447 | pub fn enabled(self) -> &'a mut W { | ||
| 448 | self.variant(EPVIE_A::ENABLED) | ||
| 449 | } | ||
| 450 | #[doc = r"Sets the field bit"] | ||
| 451 | #[inline(always)] | ||
| 452 | pub fn set_bit(self) -> &'a mut W { | ||
| 453 | self.bit(true) | ||
| 454 | } | ||
| 455 | #[doc = r"Clears the field bit"] | ||
| 456 | #[inline(always)] | ||
| 457 | pub fn clear_bit(self) -> &'a mut W { | ||
| 458 | self.bit(false) | ||
| 459 | } | ||
| 460 | #[doc = r"Writes raw bits to the field"] | ||
| 461 | #[inline(always)] | ||
| 462 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 463 | self.w.bits = (self.w.bits & !(0x01 << 9)) | (((value as u32) & 0x01) << 9); | ||
| 464 | self.w | ||
| 465 | } | ||
| 466 | } | ||
| 467 | #[doc = "EWGIE\n\nValue on reset: 0"] | ||
| 468 | #[derive(Clone, Copy, Debug, PartialEq)] | ||
| 469 | pub enum EWGIE_A { | ||
| 470 | #[doc = "0: ERRI bit will not be set when EWGF is set"] | ||
| 471 | DISABLED = 0, | ||
| 472 | #[doc = "1: ERRI bit will be set when EWGF is set"] | ||
| 473 | ENABLED = 1, | ||
| 474 | } | ||
| 475 | impl From<EWGIE_A> for bool { | ||
| 476 | #[inline(always)] | ||
| 477 | fn from(variant: EWGIE_A) -> Self { | ||
| 478 | variant as u8 != 0 | ||
| 479 | } | ||
| 480 | } | ||
| 481 | #[doc = "Reader of field `EWGIE`"] | ||
| 482 | pub type EWGIE_R = crate::R<bool, EWGIE_A>; | ||
| 483 | impl EWGIE_R { | ||
| 484 | #[doc = r"Get enumerated values variant"] | ||
| 485 | #[inline(always)] | ||
| 486 | pub fn variant(&self) -> EWGIE_A { | ||
| 487 | match self.bits { | ||
| 488 | false => EWGIE_A::DISABLED, | ||
| 489 | true => EWGIE_A::ENABLED, | ||
| 490 | } | ||
| 491 | } | ||
| 492 | #[doc = "Checks if the value of the field is `DISABLED`"] | ||
| 493 | #[inline(always)] | ||
| 494 | pub fn is_disabled(&self) -> bool { | ||
| 495 | *self == EWGIE_A::DISABLED | ||
| 496 | } | ||
| 497 | #[doc = "Checks if the value of the field is `ENABLED`"] | ||
| 498 | #[inline(always)] | ||
| 499 | pub fn is_enabled(&self) -> bool { | ||
| 500 | *self == EWGIE_A::ENABLED | ||
| 501 | } | ||
| 502 | } | ||
| 503 | #[doc = "Write proxy for field `EWGIE`"] | ||
| 504 | pub struct EWGIE_W<'a> { | ||
| 505 | w: &'a mut W, | ||
| 506 | } | ||
| 507 | impl<'a> EWGIE_W<'a> { | ||
| 508 | #[doc = r"Writes `variant` to the field"] | ||
| 509 | #[inline(always)] | ||
| 510 | pub fn variant(self, variant: EWGIE_A) -> &'a mut W { | ||
| 511 | { | ||
| 512 | self.bit(variant.into()) | ||
| 513 | } | ||
| 514 | } | ||
| 515 | #[doc = "ERRI bit will not be set when EWGF is set"] | ||
| 516 | #[inline(always)] | ||
| 517 | pub fn disabled(self) -> &'a mut W { | ||
| 518 | self.variant(EWGIE_A::DISABLED) | ||
| 519 | } | ||
| 520 | #[doc = "ERRI bit will be set when EWGF is set"] | ||
| 521 | #[inline(always)] | ||
| 522 | pub fn enabled(self) -> &'a mut W { | ||
| 523 | self.variant(EWGIE_A::ENABLED) | ||
| 524 | } | ||
| 525 | #[doc = r"Sets the field bit"] | ||
| 526 | #[inline(always)] | ||
| 527 | pub fn set_bit(self) -> &'a mut W { | ||
| 528 | self.bit(true) | ||
| 529 | } | ||
| 530 | #[doc = r"Clears the field bit"] | ||
| 531 | #[inline(always)] | ||
| 532 | pub fn clear_bit(self) -> &'a mut W { | ||
| 533 | self.bit(false) | ||
| 534 | } | ||
| 535 | #[doc = r"Writes raw bits to the field"] | ||
| 536 | #[inline(always)] | ||
| 537 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 538 | self.w.bits = (self.w.bits & !(0x01 << 8)) | (((value as u32) & 0x01) << 8); | ||
| 539 | self.w | ||
| 540 | } | ||
| 541 | } | ||
| 542 | #[doc = "FOVIE1\n\nValue on reset: 0"] | ||
| 543 | #[derive(Clone, Copy, Debug, PartialEq)] | ||
| 544 | pub enum FOVIE1_A { | ||
| 545 | #[doc = "0: No interrupt when FOVR is set"] | ||
| 546 | DISABLED = 0, | ||
| 547 | #[doc = "1: Interrupt generation when FOVR is set"] | ||
| 548 | ENABLED = 1, | ||
| 549 | } | ||
| 550 | impl From<FOVIE1_A> for bool { | ||
| 551 | #[inline(always)] | ||
| 552 | fn from(variant: FOVIE1_A) -> Self { | ||
| 553 | variant as u8 != 0 | ||
| 554 | } | ||
| 555 | } | ||
| 556 | #[doc = "Reader of field `FOVIE1`"] | ||
| 557 | pub type FOVIE1_R = crate::R<bool, FOVIE1_A>; | ||
| 558 | impl FOVIE1_R { | ||
| 559 | #[doc = r"Get enumerated values variant"] | ||
| 560 | #[inline(always)] | ||
| 561 | pub fn variant(&self) -> FOVIE1_A { | ||
| 562 | match self.bits { | ||
| 563 | false => FOVIE1_A::DISABLED, | ||
| 564 | true => FOVIE1_A::ENABLED, | ||
| 565 | } | ||
| 566 | } | ||
| 567 | #[doc = "Checks if the value of the field is `DISABLED`"] | ||
| 568 | #[inline(always)] | ||
| 569 | pub fn is_disabled(&self) -> bool { | ||
| 570 | *self == FOVIE1_A::DISABLED | ||
| 571 | } | ||
| 572 | #[doc = "Checks if the value of the field is `ENABLED`"] | ||
| 573 | #[inline(always)] | ||
| 574 | pub fn is_enabled(&self) -> bool { | ||
| 575 | *self == FOVIE1_A::ENABLED | ||
| 576 | } | ||
| 577 | } | ||
| 578 | #[doc = "Write proxy for field `FOVIE1`"] | ||
| 579 | pub struct FOVIE1_W<'a> { | ||
| 580 | w: &'a mut W, | ||
| 581 | } | ||
| 582 | impl<'a> FOVIE1_W<'a> { | ||
| 583 | #[doc = r"Writes `variant` to the field"] | ||
| 584 | #[inline(always)] | ||
| 585 | pub fn variant(self, variant: FOVIE1_A) -> &'a mut W { | ||
| 586 | { | ||
| 587 | self.bit(variant.into()) | ||
| 588 | } | ||
| 589 | } | ||
| 590 | #[doc = "No interrupt when FOVR is set"] | ||
| 591 | #[inline(always)] | ||
| 592 | pub fn disabled(self) -> &'a mut W { | ||
| 593 | self.variant(FOVIE1_A::DISABLED) | ||
| 594 | } | ||
| 595 | #[doc = "Interrupt generation when FOVR is set"] | ||
| 596 | #[inline(always)] | ||
| 597 | pub fn enabled(self) -> &'a mut W { | ||
| 598 | self.variant(FOVIE1_A::ENABLED) | ||
| 599 | } | ||
| 600 | #[doc = r"Sets the field bit"] | ||
| 601 | #[inline(always)] | ||
| 602 | pub fn set_bit(self) -> &'a mut W { | ||
| 603 | self.bit(true) | ||
| 604 | } | ||
| 605 | #[doc = r"Clears the field bit"] | ||
| 606 | #[inline(always)] | ||
| 607 | pub fn clear_bit(self) -> &'a mut W { | ||
| 608 | self.bit(false) | ||
| 609 | } | ||
| 610 | #[doc = r"Writes raw bits to the field"] | ||
| 611 | #[inline(always)] | ||
| 612 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 613 | self.w.bits = (self.w.bits & !(0x01 << 6)) | (((value as u32) & 0x01) << 6); | ||
| 614 | self.w | ||
| 615 | } | ||
| 616 | } | ||
| 617 | #[doc = "FFIE1\n\nValue on reset: 0"] | ||
| 618 | #[derive(Clone, Copy, Debug, PartialEq)] | ||
| 619 | pub enum FFIE1_A { | ||
| 620 | #[doc = "0: No interrupt when FULL bit is set"] | ||
| 621 | DISABLED = 0, | ||
| 622 | #[doc = "1: Interrupt generated when FULL bit is set"] | ||
| 623 | ENABLED = 1, | ||
| 624 | } | ||
| 625 | impl From<FFIE1_A> for bool { | ||
| 626 | #[inline(always)] | ||
| 627 | fn from(variant: FFIE1_A) -> Self { | ||
| 628 | variant as u8 != 0 | ||
| 629 | } | ||
| 630 | } | ||
| 631 | #[doc = "Reader of field `FFIE1`"] | ||
| 632 | pub type FFIE1_R = crate::R<bool, FFIE1_A>; | ||
| 633 | impl FFIE1_R { | ||
| 634 | #[doc = r"Get enumerated values variant"] | ||
| 635 | #[inline(always)] | ||
| 636 | pub fn variant(&self) -> FFIE1_A { | ||
| 637 | match self.bits { | ||
| 638 | false => FFIE1_A::DISABLED, | ||
| 639 | true => FFIE1_A::ENABLED, | ||
| 640 | } | ||
| 641 | } | ||
| 642 | #[doc = "Checks if the value of the field is `DISABLED`"] | ||
| 643 | #[inline(always)] | ||
| 644 | pub fn is_disabled(&self) -> bool { | ||
| 645 | *self == FFIE1_A::DISABLED | ||
| 646 | } | ||
| 647 | #[doc = "Checks if the value of the field is `ENABLED`"] | ||
| 648 | #[inline(always)] | ||
| 649 | pub fn is_enabled(&self) -> bool { | ||
| 650 | *self == FFIE1_A::ENABLED | ||
| 651 | } | ||
| 652 | } | ||
| 653 | #[doc = "Write proxy for field `FFIE1`"] | ||
| 654 | pub struct FFIE1_W<'a> { | ||
| 655 | w: &'a mut W, | ||
| 656 | } | ||
| 657 | impl<'a> FFIE1_W<'a> { | ||
| 658 | #[doc = r"Writes `variant` to the field"] | ||
| 659 | #[inline(always)] | ||
| 660 | pub fn variant(self, variant: FFIE1_A) -> &'a mut W { | ||
| 661 | { | ||
| 662 | self.bit(variant.into()) | ||
| 663 | } | ||
| 664 | } | ||
| 665 | #[doc = "No interrupt when FULL bit is set"] | ||
| 666 | #[inline(always)] | ||
| 667 | pub fn disabled(self) -> &'a mut W { | ||
| 668 | self.variant(FFIE1_A::DISABLED) | ||
| 669 | } | ||
| 670 | #[doc = "Interrupt generated when FULL bit is set"] | ||
| 671 | #[inline(always)] | ||
| 672 | pub fn enabled(self) -> &'a mut W { | ||
| 673 | self.variant(FFIE1_A::ENABLED) | ||
| 674 | } | ||
| 675 | #[doc = r"Sets the field bit"] | ||
| 676 | #[inline(always)] | ||
| 677 | pub fn set_bit(self) -> &'a mut W { | ||
| 678 | self.bit(true) | ||
| 679 | } | ||
| 680 | #[doc = r"Clears the field bit"] | ||
| 681 | #[inline(always)] | ||
| 682 | pub fn clear_bit(self) -> &'a mut W { | ||
| 683 | self.bit(false) | ||
| 684 | } | ||
| 685 | #[doc = r"Writes raw bits to the field"] | ||
| 686 | #[inline(always)] | ||
| 687 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 688 | self.w.bits = (self.w.bits & !(0x01 << 5)) | (((value as u32) & 0x01) << 5); | ||
| 689 | self.w | ||
| 690 | } | ||
| 691 | } | ||
| 692 | #[doc = "FMPIE1\n\nValue on reset: 0"] | ||
| 693 | #[derive(Clone, Copy, Debug, PartialEq)] | ||
| 694 | pub enum FMPIE1_A { | ||
| 695 | #[doc = "0: No interrupt generated when state of FMP\\[1:0\\] | ||
| 696 | bits are not 00b"] | ||
| 697 | DISABLED = 0, | ||
| 698 | #[doc = "1: Interrupt generated when state of FMP\\[1:0\\] | ||
| 699 | bits are not 00b"] | ||
| 700 | ENABLED = 1, | ||
| 701 | } | ||
| 702 | impl From<FMPIE1_A> for bool { | ||
| 703 | #[inline(always)] | ||
| 704 | fn from(variant: FMPIE1_A) -> Self { | ||
| 705 | variant as u8 != 0 | ||
| 706 | } | ||
| 707 | } | ||
| 708 | #[doc = "Reader of field `FMPIE1`"] | ||
| 709 | pub type FMPIE1_R = crate::R<bool, FMPIE1_A>; | ||
| 710 | impl FMPIE1_R { | ||
| 711 | #[doc = r"Get enumerated values variant"] | ||
| 712 | #[inline(always)] | ||
| 713 | pub fn variant(&self) -> FMPIE1_A { | ||
| 714 | match self.bits { | ||
| 715 | false => FMPIE1_A::DISABLED, | ||
| 716 | true => FMPIE1_A::ENABLED, | ||
| 717 | } | ||
| 718 | } | ||
| 719 | #[doc = "Checks if the value of the field is `DISABLED`"] | ||
| 720 | #[inline(always)] | ||
| 721 | pub fn is_disabled(&self) -> bool { | ||
| 722 | *self == FMPIE1_A::DISABLED | ||
| 723 | } | ||
| 724 | #[doc = "Checks if the value of the field is `ENABLED`"] | ||
| 725 | #[inline(always)] | ||
| 726 | pub fn is_enabled(&self) -> bool { | ||
| 727 | *self == FMPIE1_A::ENABLED | ||
| 728 | } | ||
| 729 | } | ||
| 730 | #[doc = "Write proxy for field `FMPIE1`"] | ||
| 731 | pub struct FMPIE1_W<'a> { | ||
| 732 | w: &'a mut W, | ||
| 733 | } | ||
| 734 | impl<'a> FMPIE1_W<'a> { | ||
| 735 | #[doc = r"Writes `variant` to the field"] | ||
| 736 | #[inline(always)] | ||
| 737 | pub fn variant(self, variant: FMPIE1_A) -> &'a mut W { | ||
| 738 | { | ||
| 739 | self.bit(variant.into()) | ||
| 740 | } | ||
| 741 | } | ||
| 742 | #[doc = "No interrupt generated when state of FMP\\[1:0\\] | ||
| 743 | bits are not 00b"] | ||
| 744 | #[inline(always)] | ||
| 745 | pub fn disabled(self) -> &'a mut W { | ||
| 746 | self.variant(FMPIE1_A::DISABLED) | ||
| 747 | } | ||
| 748 | #[doc = "Interrupt generated when state of FMP\\[1:0\\] | ||
| 749 | bits are not 00b"] | ||
| 750 | #[inline(always)] | ||
| 751 | pub fn enabled(self) -> &'a mut W { | ||
| 752 | self.variant(FMPIE1_A::ENABLED) | ||
| 753 | } | ||
| 754 | #[doc = r"Sets the field bit"] | ||
| 755 | #[inline(always)] | ||
| 756 | pub fn set_bit(self) -> &'a mut W { | ||
| 757 | self.bit(true) | ||
| 758 | } | ||
| 759 | #[doc = r"Clears the field bit"] | ||
| 760 | #[inline(always)] | ||
| 761 | pub fn clear_bit(self) -> &'a mut W { | ||
| 762 | self.bit(false) | ||
| 763 | } | ||
| 764 | #[doc = r"Writes raw bits to the field"] | ||
| 765 | #[inline(always)] | ||
| 766 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 767 | self.w.bits = (self.w.bits & !(0x01 << 4)) | (((value as u32) & 0x01) << 4); | ||
| 768 | self.w | ||
| 769 | } | ||
| 770 | } | ||
| 771 | #[doc = "FOVIE0\n\nValue on reset: 0"] | ||
| 772 | #[derive(Clone, Copy, Debug, PartialEq)] | ||
| 773 | pub enum FOVIE0_A { | ||
| 774 | #[doc = "0: No interrupt when FOVR bit is set"] | ||
| 775 | DISABLED = 0, | ||
| 776 | #[doc = "1: Interrupt generated when FOVR bit is set"] | ||
| 777 | ENABLED = 1, | ||
| 778 | } | ||
| 779 | impl From<FOVIE0_A> for bool { | ||
| 780 | #[inline(always)] | ||
| 781 | fn from(variant: FOVIE0_A) -> Self { | ||
| 782 | variant as u8 != 0 | ||
| 783 | } | ||
| 784 | } | ||
| 785 | #[doc = "Reader of field `FOVIE0`"] | ||
| 786 | pub type FOVIE0_R = crate::R<bool, FOVIE0_A>; | ||
| 787 | impl FOVIE0_R { | ||
| 788 | #[doc = r"Get enumerated values variant"] | ||
| 789 | #[inline(always)] | ||
| 790 | pub fn variant(&self) -> FOVIE0_A { | ||
| 791 | match self.bits { | ||
| 792 | false => FOVIE0_A::DISABLED, | ||
| 793 | true => FOVIE0_A::ENABLED, | ||
| 794 | } | ||
| 795 | } | ||
| 796 | #[doc = "Checks if the value of the field is `DISABLED`"] | ||
| 797 | #[inline(always)] | ||
| 798 | pub fn is_disabled(&self) -> bool { | ||
| 799 | *self == FOVIE0_A::DISABLED | ||
| 800 | } | ||
| 801 | #[doc = "Checks if the value of the field is `ENABLED`"] | ||
| 802 | #[inline(always)] | ||
| 803 | pub fn is_enabled(&self) -> bool { | ||
| 804 | *self == FOVIE0_A::ENABLED | ||
| 805 | } | ||
| 806 | } | ||
| 807 | #[doc = "Write proxy for field `FOVIE0`"] | ||
| 808 | pub struct FOVIE0_W<'a> { | ||
| 809 | w: &'a mut W, | ||
| 810 | } | ||
| 811 | impl<'a> FOVIE0_W<'a> { | ||
| 812 | #[doc = r"Writes `variant` to the field"] | ||
| 813 | #[inline(always)] | ||
| 814 | pub fn variant(self, variant: FOVIE0_A) -> &'a mut W { | ||
| 815 | { | ||
| 816 | self.bit(variant.into()) | ||
| 817 | } | ||
| 818 | } | ||
| 819 | #[doc = "No interrupt when FOVR bit is set"] | ||
| 820 | #[inline(always)] | ||
| 821 | pub fn disabled(self) -> &'a mut W { | ||
| 822 | self.variant(FOVIE0_A::DISABLED) | ||
| 823 | } | ||
| 824 | #[doc = "Interrupt generated when FOVR bit is set"] | ||
| 825 | #[inline(always)] | ||
| 826 | pub fn enabled(self) -> &'a mut W { | ||
| 827 | self.variant(FOVIE0_A::ENABLED) | ||
| 828 | } | ||
| 829 | #[doc = r"Sets the field bit"] | ||
| 830 | #[inline(always)] | ||
| 831 | pub fn set_bit(self) -> &'a mut W { | ||
| 832 | self.bit(true) | ||
| 833 | } | ||
| 834 | #[doc = r"Clears the field bit"] | ||
| 835 | #[inline(always)] | ||
| 836 | pub fn clear_bit(self) -> &'a mut W { | ||
| 837 | self.bit(false) | ||
| 838 | } | ||
| 839 | #[doc = r"Writes raw bits to the field"] | ||
| 840 | #[inline(always)] | ||
| 841 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 842 | self.w.bits = (self.w.bits & !(0x01 << 3)) | (((value as u32) & 0x01) << 3); | ||
| 843 | self.w | ||
| 844 | } | ||
| 845 | } | ||
| 846 | #[doc = "FFIE0\n\nValue on reset: 0"] | ||
| 847 | #[derive(Clone, Copy, Debug, PartialEq)] | ||
| 848 | pub enum FFIE0_A { | ||
| 849 | #[doc = "0: No interrupt when FULL bit is set"] | ||
| 850 | DISABLED = 0, | ||
| 851 | #[doc = "1: Interrupt generated when FULL bit is set"] | ||
| 852 | ENABLED = 1, | ||
| 853 | } | ||
| 854 | impl From<FFIE0_A> for bool { | ||
| 855 | #[inline(always)] | ||
| 856 | fn from(variant: FFIE0_A) -> Self { | ||
| 857 | variant as u8 != 0 | ||
| 858 | } | ||
| 859 | } | ||
| 860 | #[doc = "Reader of field `FFIE0`"] | ||
| 861 | pub type FFIE0_R = crate::R<bool, FFIE0_A>; | ||
| 862 | impl FFIE0_R { | ||
| 863 | #[doc = r"Get enumerated values variant"] | ||
| 864 | #[inline(always)] | ||
| 865 | pub fn variant(&self) -> FFIE0_A { | ||
| 866 | match self.bits { | ||
| 867 | false => FFIE0_A::DISABLED, | ||
| 868 | true => FFIE0_A::ENABLED, | ||
| 869 | } | ||
| 870 | } | ||
| 871 | #[doc = "Checks if the value of the field is `DISABLED`"] | ||
| 872 | #[inline(always)] | ||
| 873 | pub fn is_disabled(&self) -> bool { | ||
| 874 | *self == FFIE0_A::DISABLED | ||
| 875 | } | ||
| 876 | #[doc = "Checks if the value of the field is `ENABLED`"] | ||
| 877 | #[inline(always)] | ||
| 878 | pub fn is_enabled(&self) -> bool { | ||
| 879 | *self == FFIE0_A::ENABLED | ||
| 880 | } | ||
| 881 | } | ||
| 882 | #[doc = "Write proxy for field `FFIE0`"] | ||
| 883 | pub struct FFIE0_W<'a> { | ||
| 884 | w: &'a mut W, | ||
| 885 | } | ||
| 886 | impl<'a> FFIE0_W<'a> { | ||
| 887 | #[doc = r"Writes `variant` to the field"] | ||
| 888 | #[inline(always)] | ||
| 889 | pub fn variant(self, variant: FFIE0_A) -> &'a mut W { | ||
| 890 | { | ||
| 891 | self.bit(variant.into()) | ||
| 892 | } | ||
| 893 | } | ||
| 894 | #[doc = "No interrupt when FULL bit is set"] | ||
| 895 | #[inline(always)] | ||
| 896 | pub fn disabled(self) -> &'a mut W { | ||
| 897 | self.variant(FFIE0_A::DISABLED) | ||
| 898 | } | ||
| 899 | #[doc = "Interrupt generated when FULL bit is set"] | ||
| 900 | #[inline(always)] | ||
| 901 | pub fn enabled(self) -> &'a mut W { | ||
| 902 | self.variant(FFIE0_A::ENABLED) | ||
| 903 | } | ||
| 904 | #[doc = r"Sets the field bit"] | ||
| 905 | #[inline(always)] | ||
| 906 | pub fn set_bit(self) -> &'a mut W { | ||
| 907 | self.bit(true) | ||
| 908 | } | ||
| 909 | #[doc = r"Clears the field bit"] | ||
| 910 | #[inline(always)] | ||
| 911 | pub fn clear_bit(self) -> &'a mut W { | ||
| 912 | self.bit(false) | ||
| 913 | } | ||
| 914 | #[doc = r"Writes raw bits to the field"] | ||
| 915 | #[inline(always)] | ||
| 916 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 917 | self.w.bits = (self.w.bits & !(0x01 << 2)) | (((value as u32) & 0x01) << 2); | ||
| 918 | self.w | ||
| 919 | } | ||
| 920 | } | ||
| 921 | #[doc = "FMPIE0\n\nValue on reset: 0"] | ||
| 922 | #[derive(Clone, Copy, Debug, PartialEq)] | ||
| 923 | pub enum FMPIE0_A { | ||
| 924 | #[doc = "0: No interrupt generated when state of FMP\\[1:0\\] | ||
| 925 | bits are not 00"] | ||
| 926 | DISABLED = 0, | ||
| 927 | #[doc = "1: Interrupt generated when state of FMP\\[1:0\\] | ||
| 928 | bits are not 00b"] | ||
| 929 | ENABLED = 1, | ||
| 930 | } | ||
| 931 | impl From<FMPIE0_A> for bool { | ||
| 932 | #[inline(always)] | ||
| 933 | fn from(variant: FMPIE0_A) -> Self { | ||
| 934 | variant as u8 != 0 | ||
| 935 | } | ||
| 936 | } | ||
| 937 | #[doc = "Reader of field `FMPIE0`"] | ||
| 938 | pub type FMPIE0_R = crate::R<bool, FMPIE0_A>; | ||
| 939 | impl FMPIE0_R { | ||
| 940 | #[doc = r"Get enumerated values variant"] | ||
| 941 | #[inline(always)] | ||
| 942 | pub fn variant(&self) -> FMPIE0_A { | ||
| 943 | match self.bits { | ||
| 944 | false => FMPIE0_A::DISABLED, | ||
| 945 | true => FMPIE0_A::ENABLED, | ||
| 946 | } | ||
| 947 | } | ||
| 948 | #[doc = "Checks if the value of the field is `DISABLED`"] | ||
| 949 | #[inline(always)] | ||
| 950 | pub fn is_disabled(&self) -> bool { | ||
| 951 | *self == FMPIE0_A::DISABLED | ||
| 952 | } | ||
| 953 | #[doc = "Checks if the value of the field is `ENABLED`"] | ||
| 954 | #[inline(always)] | ||
| 955 | pub fn is_enabled(&self) -> bool { | ||
| 956 | *self == FMPIE0_A::ENABLED | ||
| 957 | } | ||
| 958 | } | ||
| 959 | #[doc = "Write proxy for field `FMPIE0`"] | ||
| 960 | pub struct FMPIE0_W<'a> { | ||
| 961 | w: &'a mut W, | ||
| 962 | } | ||
| 963 | impl<'a> FMPIE0_W<'a> { | ||
| 964 | #[doc = r"Writes `variant` to the field"] | ||
| 965 | #[inline(always)] | ||
| 966 | pub fn variant(self, variant: FMPIE0_A) -> &'a mut W { | ||
| 967 | { | ||
| 968 | self.bit(variant.into()) | ||
| 969 | } | ||
| 970 | } | ||
| 971 | #[doc = "No interrupt generated when state of FMP\\[1:0\\] | ||
| 972 | bits are not 00"] | ||
| 973 | #[inline(always)] | ||
| 974 | pub fn disabled(self) -> &'a mut W { | ||
| 975 | self.variant(FMPIE0_A::DISABLED) | ||
| 976 | } | ||
| 977 | #[doc = "Interrupt generated when state of FMP\\[1:0\\] | ||
| 978 | bits are not 00b"] | ||
| 979 | #[inline(always)] | ||
| 980 | pub fn enabled(self) -> &'a mut W { | ||
| 981 | self.variant(FMPIE0_A::ENABLED) | ||
| 982 | } | ||
| 983 | #[doc = r"Sets the field bit"] | ||
| 984 | #[inline(always)] | ||
| 985 | pub fn set_bit(self) -> &'a mut W { | ||
| 986 | self.bit(true) | ||
| 987 | } | ||
| 988 | #[doc = r"Clears the field bit"] | ||
| 989 | #[inline(always)] | ||
| 990 | pub fn clear_bit(self) -> &'a mut W { | ||
| 991 | self.bit(false) | ||
| 992 | } | ||
| 993 | #[doc = r"Writes raw bits to the field"] | ||
| 994 | #[inline(always)] | ||
| 995 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 996 | self.w.bits = (self.w.bits & !(0x01 << 1)) | (((value as u32) & 0x01) << 1); | ||
| 997 | self.w | ||
| 998 | } | ||
| 999 | } | ||
| 1000 | #[doc = "TMEIE\n\nValue on reset: 0"] | ||
| 1001 | #[derive(Clone, Copy, Debug, PartialEq)] | ||
| 1002 | pub enum TMEIE_A { | ||
| 1003 | #[doc = "0: No interrupt when RQCPx bit is set"] | ||
| 1004 | DISABLED = 0, | ||
| 1005 | #[doc = "1: Interrupt generated when RQCPx bit is set"] | ||
| 1006 | ENABLED = 1, | ||
| 1007 | } | ||
| 1008 | impl From<TMEIE_A> for bool { | ||
| 1009 | #[inline(always)] | ||
| 1010 | fn from(variant: TMEIE_A) -> Self { | ||
| 1011 | variant as u8 != 0 | ||
| 1012 | } | ||
| 1013 | } | ||
| 1014 | #[doc = "Reader of field `TMEIE`"] | ||
| 1015 | pub type TMEIE_R = crate::R<bool, TMEIE_A>; | ||
| 1016 | impl TMEIE_R { | ||
| 1017 | #[doc = r"Get enumerated values variant"] | ||
| 1018 | #[inline(always)] | ||
| 1019 | pub fn variant(&self) -> TMEIE_A { | ||
| 1020 | match self.bits { | ||
| 1021 | false => TMEIE_A::DISABLED, | ||
| 1022 | true => TMEIE_A::ENABLED, | ||
| 1023 | } | ||
| 1024 | } | ||
| 1025 | #[doc = "Checks if the value of the field is `DISABLED`"] | ||
| 1026 | #[inline(always)] | ||
| 1027 | pub fn is_disabled(&self) -> bool { | ||
| 1028 | *self == TMEIE_A::DISABLED | ||
| 1029 | } | ||
| 1030 | #[doc = "Checks if the value of the field is `ENABLED`"] | ||
| 1031 | #[inline(always)] | ||
| 1032 | pub fn is_enabled(&self) -> bool { | ||
| 1033 | *self == TMEIE_A::ENABLED | ||
| 1034 | } | ||
| 1035 | } | ||
| 1036 | #[doc = "Write proxy for field `TMEIE`"] | ||
| 1037 | pub struct TMEIE_W<'a> { | ||
| 1038 | w: &'a mut W, | ||
| 1039 | } | ||
| 1040 | impl<'a> TMEIE_W<'a> { | ||
| 1041 | #[doc = r"Writes `variant` to the field"] | ||
| 1042 | #[inline(always)] | ||
| 1043 | pub fn variant(self, variant: TMEIE_A) -> &'a mut W { | ||
| 1044 | { | ||
| 1045 | self.bit(variant.into()) | ||
| 1046 | } | ||
| 1047 | } | ||
| 1048 | #[doc = "No interrupt when RQCPx bit is set"] | ||
| 1049 | #[inline(always)] | ||
| 1050 | pub fn disabled(self) -> &'a mut W { | ||
| 1051 | self.variant(TMEIE_A::DISABLED) | ||
| 1052 | } | ||
| 1053 | #[doc = "Interrupt generated when RQCPx bit is set"] | ||
| 1054 | #[inline(always)] | ||
| 1055 | pub fn enabled(self) -> &'a mut W { | ||
| 1056 | self.variant(TMEIE_A::ENABLED) | ||
| 1057 | } | ||
| 1058 | #[doc = r"Sets the field bit"] | ||
| 1059 | #[inline(always)] | ||
| 1060 | pub fn set_bit(self) -> &'a mut W { | ||
| 1061 | self.bit(true) | ||
| 1062 | } | ||
| 1063 | #[doc = r"Clears the field bit"] | ||
| 1064 | #[inline(always)] | ||
| 1065 | pub fn clear_bit(self) -> &'a mut W { | ||
| 1066 | self.bit(false) | ||
| 1067 | } | ||
| 1068 | #[doc = r"Writes raw bits to the field"] | ||
| 1069 | #[inline(always)] | ||
| 1070 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 1071 | self.w.bits = (self.w.bits & !0x01) | ((value as u32) & 0x01); | ||
| 1072 | self.w | ||
| 1073 | } | ||
| 1074 | } | ||
| 1075 | impl R { | ||
| 1076 | #[doc = "Bit 17 - SLKIE"] | ||
| 1077 | #[inline(always)] | ||
| 1078 | pub fn slkie(&self) -> SLKIE_R { | ||
| 1079 | SLKIE_R::new(((self.bits >> 17) & 0x01) != 0) | ||
| 1080 | } | ||
| 1081 | #[doc = "Bit 16 - WKUIE"] | ||
| 1082 | #[inline(always)] | ||
| 1083 | pub fn wkuie(&self) -> WKUIE_R { | ||
| 1084 | WKUIE_R::new(((self.bits >> 16) & 0x01) != 0) | ||
| 1085 | } | ||
| 1086 | #[doc = "Bit 15 - ERRIE"] | ||
| 1087 | #[inline(always)] | ||
| 1088 | pub fn errie(&self) -> ERRIE_R { | ||
| 1089 | ERRIE_R::new(((self.bits >> 15) & 0x01) != 0) | ||
| 1090 | } | ||
| 1091 | #[doc = "Bit 11 - LECIE"] | ||
| 1092 | #[inline(always)] | ||
| 1093 | pub fn lecie(&self) -> LECIE_R { | ||
| 1094 | LECIE_R::new(((self.bits >> 11) & 0x01) != 0) | ||
| 1095 | } | ||
| 1096 | #[doc = "Bit 10 - BOFIE"] | ||
| 1097 | #[inline(always)] | ||
| 1098 | pub fn bofie(&self) -> BOFIE_R { | ||
| 1099 | BOFIE_R::new(((self.bits >> 10) & 0x01) != 0) | ||
| 1100 | } | ||
| 1101 | #[doc = "Bit 9 - EPVIE"] | ||
| 1102 | #[inline(always)] | ||
| 1103 | pub fn epvie(&self) -> EPVIE_R { | ||
| 1104 | EPVIE_R::new(((self.bits >> 9) & 0x01) != 0) | ||
| 1105 | } | ||
| 1106 | #[doc = "Bit 8 - EWGIE"] | ||
| 1107 | #[inline(always)] | ||
| 1108 | pub fn ewgie(&self) -> EWGIE_R { | ||
| 1109 | EWGIE_R::new(((self.bits >> 8) & 0x01) != 0) | ||
| 1110 | } | ||
| 1111 | #[doc = "Bit 6 - FOVIE1"] | ||
| 1112 | #[inline(always)] | ||
| 1113 | pub fn fovie1(&self) -> FOVIE1_R { | ||
| 1114 | FOVIE1_R::new(((self.bits >> 6) & 0x01) != 0) | ||
| 1115 | } | ||
| 1116 | #[doc = "Bit 5 - FFIE1"] | ||
| 1117 | #[inline(always)] | ||
| 1118 | pub fn ffie1(&self) -> FFIE1_R { | ||
| 1119 | FFIE1_R::new(((self.bits >> 5) & 0x01) != 0) | ||
| 1120 | } | ||
| 1121 | #[doc = "Bit 4 - FMPIE1"] | ||
| 1122 | #[inline(always)] | ||
| 1123 | pub fn fmpie1(&self) -> FMPIE1_R { | ||
| 1124 | FMPIE1_R::new(((self.bits >> 4) & 0x01) != 0) | ||
| 1125 | } | ||
| 1126 | #[doc = "Bit 3 - FOVIE0"] | ||
| 1127 | #[inline(always)] | ||
| 1128 | pub fn fovie0(&self) -> FOVIE0_R { | ||
| 1129 | FOVIE0_R::new(((self.bits >> 3) & 0x01) != 0) | ||
| 1130 | } | ||
| 1131 | #[doc = "Bit 2 - FFIE0"] | ||
| 1132 | #[inline(always)] | ||
| 1133 | pub fn ffie0(&self) -> FFIE0_R { | ||
| 1134 | FFIE0_R::new(((self.bits >> 2) & 0x01) != 0) | ||
| 1135 | } | ||
| 1136 | #[doc = "Bit 1 - FMPIE0"] | ||
| 1137 | #[inline(always)] | ||
| 1138 | pub fn fmpie0(&self) -> FMPIE0_R { | ||
| 1139 | FMPIE0_R::new(((self.bits >> 1) & 0x01) != 0) | ||
| 1140 | } | ||
| 1141 | #[doc = "Bit 0 - TMEIE"] | ||
| 1142 | #[inline(always)] | ||
| 1143 | pub fn tmeie(&self) -> TMEIE_R { | ||
| 1144 | TMEIE_R::new((self.bits & 0x01) != 0) | ||
| 1145 | } | ||
| 1146 | } | ||
| 1147 | impl W { | ||
| 1148 | #[doc = "Bit 17 - SLKIE"] | ||
| 1149 | #[inline(always)] | ||
| 1150 | pub fn slkie(&mut self) -> SLKIE_W { | ||
| 1151 | SLKIE_W { w: self } | ||
| 1152 | } | ||
| 1153 | #[doc = "Bit 16 - WKUIE"] | ||
| 1154 | #[inline(always)] | ||
| 1155 | pub fn wkuie(&mut self) -> WKUIE_W { | ||
| 1156 | WKUIE_W { w: self } | ||
| 1157 | } | ||
| 1158 | #[doc = "Bit 15 - ERRIE"] | ||
| 1159 | #[inline(always)] | ||
| 1160 | pub fn errie(&mut self) -> ERRIE_W { | ||
| 1161 | ERRIE_W { w: self } | ||
| 1162 | } | ||
| 1163 | #[doc = "Bit 11 - LECIE"] | ||
| 1164 | #[inline(always)] | ||
| 1165 | pub fn lecie(&mut self) -> LECIE_W { | ||
| 1166 | LECIE_W { w: self } | ||
| 1167 | } | ||
| 1168 | #[doc = "Bit 10 - BOFIE"] | ||
| 1169 | #[inline(always)] | ||
| 1170 | pub fn bofie(&mut self) -> BOFIE_W { | ||
| 1171 | BOFIE_W { w: self } | ||
| 1172 | } | ||
| 1173 | #[doc = "Bit 9 - EPVIE"] | ||
| 1174 | #[inline(always)] | ||
| 1175 | pub fn epvie(&mut self) -> EPVIE_W { | ||
| 1176 | EPVIE_W { w: self } | ||
| 1177 | } | ||
| 1178 | #[doc = "Bit 8 - EWGIE"] | ||
| 1179 | #[inline(always)] | ||
| 1180 | pub fn ewgie(&mut self) -> EWGIE_W { | ||
| 1181 | EWGIE_W { w: self } | ||
| 1182 | } | ||
| 1183 | #[doc = "Bit 6 - FOVIE1"] | ||
| 1184 | #[inline(always)] | ||
| 1185 | pub fn fovie1(&mut self) -> FOVIE1_W { | ||
| 1186 | FOVIE1_W { w: self } | ||
| 1187 | } | ||
| 1188 | #[doc = "Bit 5 - FFIE1"] | ||
| 1189 | #[inline(always)] | ||
| 1190 | pub fn ffie1(&mut self) -> FFIE1_W { | ||
| 1191 | FFIE1_W { w: self } | ||
| 1192 | } | ||
| 1193 | #[doc = "Bit 4 - FMPIE1"] | ||
| 1194 | #[inline(always)] | ||
| 1195 | pub fn fmpie1(&mut self) -> FMPIE1_W { | ||
| 1196 | FMPIE1_W { w: self } | ||
| 1197 | } | ||
| 1198 | #[doc = "Bit 3 - FOVIE0"] | ||
| 1199 | #[inline(always)] | ||
| 1200 | pub fn fovie0(&mut self) -> FOVIE0_W { | ||
| 1201 | FOVIE0_W { w: self } | ||
| 1202 | } | ||
| 1203 | #[doc = "Bit 2 - FFIE0"] | ||
| 1204 | #[inline(always)] | ||
| 1205 | pub fn ffie0(&mut self) -> FFIE0_W { | ||
| 1206 | FFIE0_W { w: self } | ||
| 1207 | } | ||
| 1208 | #[doc = "Bit 1 - FMPIE0"] | ||
| 1209 | #[inline(always)] | ||
| 1210 | pub fn fmpie0(&mut self) -> FMPIE0_W { | ||
| 1211 | FMPIE0_W { w: self } | ||
| 1212 | } | ||
| 1213 | #[doc = "Bit 0 - TMEIE"] | ||
| 1214 | #[inline(always)] | ||
| 1215 | pub fn tmeie(&mut self) -> TMEIE_W { | ||
| 1216 | TMEIE_W { w: self } | ||
| 1217 | } | ||
| 1218 | } | ||
diff --git a/embassy-stm32/src/can/bx/pac/can/mcr.rs b/embassy-stm32/src/can/bx/pac/can/mcr.rs new file mode 100644 index 000000000..5e47c0901 --- /dev/null +++ b/embassy-stm32/src/can/bx/pac/can/mcr.rs | |||
| @@ -0,0 +1,356 @@ | |||
| 1 | #[doc = "Reader of register MCR"] | ||
| 2 | pub type R = crate::R<u32, super::MCR>; | ||
| 3 | #[doc = "Writer for register MCR"] | ||
| 4 | pub type W = crate::W<u32, super::MCR>; | ||
| 5 | #[doc = "Register MCR `reset()`'s with value 0"] | ||
| 6 | impl crate::ResetValue for super::MCR { | ||
| 7 | type Type = u32; | ||
| 8 | #[inline(always)] | ||
| 9 | fn reset_value() -> Self::Type { | ||
| 10 | 0 | ||
| 11 | } | ||
| 12 | } | ||
| 13 | #[doc = "Reader of field `DBF`"] | ||
| 14 | pub type DBF_R = crate::R<bool, bool>; | ||
| 15 | #[doc = "Write proxy for field `DBF`"] | ||
| 16 | pub struct DBF_W<'a> { | ||
| 17 | w: &'a mut W, | ||
| 18 | } | ||
| 19 | impl<'a> DBF_W<'a> { | ||
| 20 | #[doc = r"Sets the field bit"] | ||
| 21 | #[inline(always)] | ||
| 22 | pub fn set_bit(self) -> &'a mut W { | ||
| 23 | self.bit(true) | ||
| 24 | } | ||
| 25 | #[doc = r"Clears the field bit"] | ||
| 26 | #[inline(always)] | ||
| 27 | pub fn clear_bit(self) -> &'a mut W { | ||
| 28 | self.bit(false) | ||
| 29 | } | ||
| 30 | #[doc = r"Writes raw bits to the field"] | ||
| 31 | #[inline(always)] | ||
| 32 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 33 | self.w.bits = (self.w.bits & !(0x01 << 16)) | (((value as u32) & 0x01) << 16); | ||
| 34 | self.w | ||
| 35 | } | ||
| 36 | } | ||
| 37 | #[doc = "Reader of field `RESET`"] | ||
| 38 | pub type RESET_R = crate::R<bool, bool>; | ||
| 39 | #[doc = "Write proxy for field `RESET`"] | ||
| 40 | pub struct RESET_W<'a> { | ||
| 41 | w: &'a mut W, | ||
| 42 | } | ||
| 43 | impl<'a> RESET_W<'a> { | ||
| 44 | #[doc = r"Sets the field bit"] | ||
| 45 | #[inline(always)] | ||
| 46 | pub fn set_bit(self) -> &'a mut W { | ||
| 47 | self.bit(true) | ||
| 48 | } | ||
| 49 | #[doc = r"Clears the field bit"] | ||
| 50 | #[inline(always)] | ||
| 51 | pub fn clear_bit(self) -> &'a mut W { | ||
| 52 | self.bit(false) | ||
| 53 | } | ||
| 54 | #[doc = r"Writes raw bits to the field"] | ||
| 55 | #[inline(always)] | ||
| 56 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 57 | self.w.bits = (self.w.bits & !(0x01 << 15)) | (((value as u32) & 0x01) << 15); | ||
| 58 | self.w | ||
| 59 | } | ||
| 60 | } | ||
| 61 | #[doc = "Reader of field `TTCM`"] | ||
| 62 | pub type TTCM_R = crate::R<bool, bool>; | ||
| 63 | #[doc = "Write proxy for field `TTCM`"] | ||
| 64 | pub struct TTCM_W<'a> { | ||
| 65 | w: &'a mut W, | ||
| 66 | } | ||
| 67 | impl<'a> TTCM_W<'a> { | ||
| 68 | #[doc = r"Sets the field bit"] | ||
| 69 | #[inline(always)] | ||
| 70 | pub fn set_bit(self) -> &'a mut W { | ||
| 71 | self.bit(true) | ||
| 72 | } | ||
| 73 | #[doc = r"Clears the field bit"] | ||
| 74 | #[inline(always)] | ||
| 75 | pub fn clear_bit(self) -> &'a mut W { | ||
| 76 | self.bit(false) | ||
| 77 | } | ||
| 78 | #[doc = r"Writes raw bits to the field"] | ||
| 79 | #[inline(always)] | ||
| 80 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 81 | self.w.bits = (self.w.bits & !(0x01 << 7)) | (((value as u32) & 0x01) << 7); | ||
| 82 | self.w | ||
| 83 | } | ||
| 84 | } | ||
| 85 | #[doc = "Reader of field `ABOM`"] | ||
| 86 | pub type ABOM_R = crate::R<bool, bool>; | ||
| 87 | #[doc = "Write proxy for field `ABOM`"] | ||
| 88 | pub struct ABOM_W<'a> { | ||
| 89 | w: &'a mut W, | ||
| 90 | } | ||
| 91 | impl<'a> ABOM_W<'a> { | ||
| 92 | #[doc = r"Sets the field bit"] | ||
| 93 | #[inline(always)] | ||
| 94 | pub fn set_bit(self) -> &'a mut W { | ||
| 95 | self.bit(true) | ||
| 96 | } | ||
| 97 | #[doc = r"Clears the field bit"] | ||
| 98 | #[inline(always)] | ||
| 99 | pub fn clear_bit(self) -> &'a mut W { | ||
| 100 | self.bit(false) | ||
| 101 | } | ||
| 102 | #[doc = r"Writes raw bits to the field"] | ||
| 103 | #[inline(always)] | ||
| 104 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 105 | self.w.bits = (self.w.bits & !(0x01 << 6)) | (((value as u32) & 0x01) << 6); | ||
| 106 | self.w | ||
| 107 | } | ||
| 108 | } | ||
| 109 | #[doc = "Reader of field `AWUM`"] | ||
| 110 | pub type AWUM_R = crate::R<bool, bool>; | ||
| 111 | #[doc = "Write proxy for field `AWUM`"] | ||
| 112 | pub struct AWUM_W<'a> { | ||
| 113 | w: &'a mut W, | ||
| 114 | } | ||
| 115 | impl<'a> AWUM_W<'a> { | ||
| 116 | #[doc = r"Sets the field bit"] | ||
| 117 | #[inline(always)] | ||
| 118 | pub fn set_bit(self) -> &'a mut W { | ||
| 119 | self.bit(true) | ||
| 120 | } | ||
| 121 | #[doc = r"Clears the field bit"] | ||
| 122 | #[inline(always)] | ||
| 123 | pub fn clear_bit(self) -> &'a mut W { | ||
| 124 | self.bit(false) | ||
| 125 | } | ||
| 126 | #[doc = r"Writes raw bits to the field"] | ||
| 127 | #[inline(always)] | ||
| 128 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 129 | self.w.bits = (self.w.bits & !(0x01 << 5)) | (((value as u32) & 0x01) << 5); | ||
| 130 | self.w | ||
| 131 | } | ||
| 132 | } | ||
| 133 | #[doc = "Reader of field `NART`"] | ||
| 134 | pub type NART_R = crate::R<bool, bool>; | ||
| 135 | #[doc = "Write proxy for field `NART`"] | ||
| 136 | pub struct NART_W<'a> { | ||
| 137 | w: &'a mut W, | ||
| 138 | } | ||
| 139 | impl<'a> NART_W<'a> { | ||
| 140 | #[doc = r"Sets the field bit"] | ||
| 141 | #[inline(always)] | ||
| 142 | pub fn set_bit(self) -> &'a mut W { | ||
| 143 | self.bit(true) | ||
| 144 | } | ||
| 145 | #[doc = r"Clears the field bit"] | ||
| 146 | #[inline(always)] | ||
| 147 | pub fn clear_bit(self) -> &'a mut W { | ||
| 148 | self.bit(false) | ||
| 149 | } | ||
| 150 | #[doc = r"Writes raw bits to the field"] | ||
| 151 | #[inline(always)] | ||
| 152 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 153 | self.w.bits = (self.w.bits & !(0x01 << 4)) | (((value as u32) & 0x01) << 4); | ||
| 154 | self.w | ||
| 155 | } | ||
| 156 | } | ||
| 157 | #[doc = "Reader of field `RFLM`"] | ||
| 158 | pub type RFLM_R = crate::R<bool, bool>; | ||
| 159 | #[doc = "Write proxy for field `RFLM`"] | ||
| 160 | pub struct RFLM_W<'a> { | ||
| 161 | w: &'a mut W, | ||
| 162 | } | ||
| 163 | impl<'a> RFLM_W<'a> { | ||
| 164 | #[doc = r"Sets the field bit"] | ||
| 165 | #[inline(always)] | ||
| 166 | pub fn set_bit(self) -> &'a mut W { | ||
| 167 | self.bit(true) | ||
| 168 | } | ||
| 169 | #[doc = r"Clears the field bit"] | ||
| 170 | #[inline(always)] | ||
| 171 | pub fn clear_bit(self) -> &'a mut W { | ||
| 172 | self.bit(false) | ||
| 173 | } | ||
| 174 | #[doc = r"Writes raw bits to the field"] | ||
| 175 | #[inline(always)] | ||
| 176 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 177 | self.w.bits = (self.w.bits & !(0x01 << 3)) | (((value as u32) & 0x01) << 3); | ||
| 178 | self.w | ||
| 179 | } | ||
| 180 | } | ||
| 181 | #[doc = "Reader of field `TXFP`"] | ||
| 182 | pub type TXFP_R = crate::R<bool, bool>; | ||
| 183 | #[doc = "Write proxy for field `TXFP`"] | ||
| 184 | pub struct TXFP_W<'a> { | ||
| 185 | w: &'a mut W, | ||
| 186 | } | ||
| 187 | impl<'a> TXFP_W<'a> { | ||
| 188 | #[doc = r"Sets the field bit"] | ||
| 189 | #[inline(always)] | ||
| 190 | pub fn set_bit(self) -> &'a mut W { | ||
| 191 | self.bit(true) | ||
| 192 | } | ||
| 193 | #[doc = r"Clears the field bit"] | ||
| 194 | #[inline(always)] | ||
| 195 | pub fn clear_bit(self) -> &'a mut W { | ||
| 196 | self.bit(false) | ||
| 197 | } | ||
| 198 | #[doc = r"Writes raw bits to the field"] | ||
| 199 | #[inline(always)] | ||
| 200 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 201 | self.w.bits = (self.w.bits & !(0x01 << 2)) | (((value as u32) & 0x01) << 2); | ||
| 202 | self.w | ||
| 203 | } | ||
| 204 | } | ||
| 205 | #[doc = "Reader of field `SLEEP`"] | ||
| 206 | pub type SLEEP_R = crate::R<bool, bool>; | ||
| 207 | #[doc = "Write proxy for field `SLEEP`"] | ||
| 208 | pub struct SLEEP_W<'a> { | ||
| 209 | w: &'a mut W, | ||
| 210 | } | ||
| 211 | impl<'a> SLEEP_W<'a> { | ||
| 212 | #[doc = r"Sets the field bit"] | ||
| 213 | #[inline(always)] | ||
| 214 | pub fn set_bit(self) -> &'a mut W { | ||
| 215 | self.bit(true) | ||
| 216 | } | ||
| 217 | #[doc = r"Clears the field bit"] | ||
| 218 | #[inline(always)] | ||
| 219 | pub fn clear_bit(self) -> &'a mut W { | ||
| 220 | self.bit(false) | ||
| 221 | } | ||
| 222 | #[doc = r"Writes raw bits to the field"] | ||
| 223 | #[inline(always)] | ||
| 224 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 225 | self.w.bits = (self.w.bits & !(0x01 << 1)) | (((value as u32) & 0x01) << 1); | ||
| 226 | self.w | ||
| 227 | } | ||
| 228 | } | ||
| 229 | #[doc = "Reader of field `INRQ`"] | ||
| 230 | pub type INRQ_R = crate::R<bool, bool>; | ||
| 231 | #[doc = "Write proxy for field `INRQ`"] | ||
| 232 | pub struct INRQ_W<'a> { | ||
| 233 | w: &'a mut W, | ||
| 234 | } | ||
| 235 | impl<'a> INRQ_W<'a> { | ||
| 236 | #[doc = r"Sets the field bit"] | ||
| 237 | #[inline(always)] | ||
| 238 | pub fn set_bit(self) -> &'a mut W { | ||
| 239 | self.bit(true) | ||
| 240 | } | ||
| 241 | #[doc = r"Clears the field bit"] | ||
| 242 | #[inline(always)] | ||
| 243 | pub fn clear_bit(self) -> &'a mut W { | ||
| 244 | self.bit(false) | ||
| 245 | } | ||
| 246 | #[doc = r"Writes raw bits to the field"] | ||
| 247 | #[inline(always)] | ||
| 248 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 249 | self.w.bits = (self.w.bits & !0x01) | ((value as u32) & 0x01); | ||
| 250 | self.w | ||
| 251 | } | ||
| 252 | } | ||
| 253 | impl R { | ||
| 254 | #[doc = "Bit 16 - DBF"] | ||
| 255 | #[inline(always)] | ||
| 256 | pub fn dbf(&self) -> DBF_R { | ||
| 257 | DBF_R::new(((self.bits >> 16) & 0x01) != 0) | ||
| 258 | } | ||
| 259 | #[doc = "Bit 15 - RESET"] | ||
| 260 | #[inline(always)] | ||
| 261 | pub fn reset(&self) -> RESET_R { | ||
| 262 | RESET_R::new(((self.bits >> 15) & 0x01) != 0) | ||
| 263 | } | ||
| 264 | #[doc = "Bit 7 - TTCM"] | ||
| 265 | #[inline(always)] | ||
| 266 | pub fn ttcm(&self) -> TTCM_R { | ||
| 267 | TTCM_R::new(((self.bits >> 7) & 0x01) != 0) | ||
| 268 | } | ||
| 269 | #[doc = "Bit 6 - ABOM"] | ||
| 270 | #[inline(always)] | ||
| 271 | pub fn abom(&self) -> ABOM_R { | ||
| 272 | ABOM_R::new(((self.bits >> 6) & 0x01) != 0) | ||
| 273 | } | ||
| 274 | #[doc = "Bit 5 - AWUM"] | ||
| 275 | #[inline(always)] | ||
| 276 | pub fn awum(&self) -> AWUM_R { | ||
| 277 | AWUM_R::new(((self.bits >> 5) & 0x01) != 0) | ||
| 278 | } | ||
| 279 | #[doc = "Bit 4 - NART"] | ||
| 280 | #[inline(always)] | ||
| 281 | pub fn nart(&self) -> NART_R { | ||
| 282 | NART_R::new(((self.bits >> 4) & 0x01) != 0) | ||
| 283 | } | ||
| 284 | #[doc = "Bit 3 - RFLM"] | ||
| 285 | #[inline(always)] | ||
| 286 | pub fn rflm(&self) -> RFLM_R { | ||
| 287 | RFLM_R::new(((self.bits >> 3) & 0x01) != 0) | ||
| 288 | } | ||
| 289 | #[doc = "Bit 2 - TXFP"] | ||
| 290 | #[inline(always)] | ||
| 291 | pub fn txfp(&self) -> TXFP_R { | ||
| 292 | TXFP_R::new(((self.bits >> 2) & 0x01) != 0) | ||
| 293 | } | ||
| 294 | #[doc = "Bit 1 - SLEEP"] | ||
| 295 | #[inline(always)] | ||
| 296 | pub fn sleep(&self) -> SLEEP_R { | ||
| 297 | SLEEP_R::new(((self.bits >> 1) & 0x01) != 0) | ||
| 298 | } | ||
| 299 | #[doc = "Bit 0 - INRQ"] | ||
| 300 | #[inline(always)] | ||
| 301 | pub fn inrq(&self) -> INRQ_R { | ||
| 302 | INRQ_R::new((self.bits & 0x01) != 0) | ||
| 303 | } | ||
| 304 | } | ||
| 305 | impl W { | ||
| 306 | #[doc = "Bit 16 - DBF"] | ||
| 307 | #[inline(always)] | ||
| 308 | pub fn dbf(&mut self) -> DBF_W { | ||
| 309 | DBF_W { w: self } | ||
| 310 | } | ||
| 311 | #[doc = "Bit 15 - RESET"] | ||
| 312 | #[inline(always)] | ||
| 313 | pub fn reset(&mut self) -> RESET_W { | ||
| 314 | RESET_W { w: self } | ||
| 315 | } | ||
| 316 | #[doc = "Bit 7 - TTCM"] | ||
| 317 | #[inline(always)] | ||
| 318 | pub fn ttcm(&mut self) -> TTCM_W { | ||
| 319 | TTCM_W { w: self } | ||
| 320 | } | ||
| 321 | #[doc = "Bit 6 - ABOM"] | ||
| 322 | #[inline(always)] | ||
| 323 | pub fn abom(&mut self) -> ABOM_W { | ||
| 324 | ABOM_W { w: self } | ||
| 325 | } | ||
| 326 | #[doc = "Bit 5 - AWUM"] | ||
| 327 | #[inline(always)] | ||
| 328 | pub fn awum(&mut self) -> AWUM_W { | ||
| 329 | AWUM_W { w: self } | ||
| 330 | } | ||
| 331 | #[doc = "Bit 4 - NART"] | ||
| 332 | #[inline(always)] | ||
| 333 | pub fn nart(&mut self) -> NART_W { | ||
| 334 | NART_W { w: self } | ||
| 335 | } | ||
| 336 | #[doc = "Bit 3 - RFLM"] | ||
| 337 | #[inline(always)] | ||
| 338 | pub fn rflm(&mut self) -> RFLM_W { | ||
| 339 | RFLM_W { w: self } | ||
| 340 | } | ||
| 341 | #[doc = "Bit 2 - TXFP"] | ||
| 342 | #[inline(always)] | ||
| 343 | pub fn txfp(&mut self) -> TXFP_W { | ||
| 344 | TXFP_W { w: self } | ||
| 345 | } | ||
| 346 | #[doc = "Bit 1 - SLEEP"] | ||
| 347 | #[inline(always)] | ||
| 348 | pub fn sleep(&mut self) -> SLEEP_W { | ||
| 349 | SLEEP_W { w: self } | ||
| 350 | } | ||
| 351 | #[doc = "Bit 0 - INRQ"] | ||
| 352 | #[inline(always)] | ||
| 353 | pub fn inrq(&mut self) -> INRQ_W { | ||
| 354 | INRQ_W { w: self } | ||
| 355 | } | ||
| 356 | } | ||
diff --git a/embassy-stm32/src/can/bx/pac/can/msr.rs b/embassy-stm32/src/can/bx/pac/can/msr.rs new file mode 100644 index 000000000..18e21c844 --- /dev/null +++ b/embassy-stm32/src/can/bx/pac/can/msr.rs | |||
| @@ -0,0 +1,160 @@ | |||
| 1 | #[doc = "Reader of register MSR"] | ||
| 2 | pub type R = crate::R<u32, super::MSR>; | ||
| 3 | #[doc = "Writer for register MSR"] | ||
| 4 | pub type W = crate::W<u32, super::MSR>; | ||
| 5 | #[doc = "Register MSR `reset()`'s with value 0"] | ||
| 6 | impl crate::ResetValue for super::MSR { | ||
| 7 | type Type = u32; | ||
| 8 | #[inline(always)] | ||
| 9 | fn reset_value() -> Self::Type { | ||
| 10 | 0 | ||
| 11 | } | ||
| 12 | } | ||
| 13 | #[doc = "Reader of field `RX`"] | ||
| 14 | pub type RX_R = crate::R<bool, bool>; | ||
| 15 | #[doc = "Reader of field `SAMP`"] | ||
| 16 | pub type SAMP_R = crate::R<bool, bool>; | ||
| 17 | #[doc = "Reader of field `RXM`"] | ||
| 18 | pub type RXM_R = crate::R<bool, bool>; | ||
| 19 | #[doc = "Reader of field `TXM`"] | ||
| 20 | pub type TXM_R = crate::R<bool, bool>; | ||
| 21 | #[doc = "Reader of field `SLAKI`"] | ||
| 22 | pub type SLAKI_R = crate::R<bool, bool>; | ||
| 23 | #[doc = "Write proxy for field `SLAKI`"] | ||
| 24 | pub struct SLAKI_W<'a> { | ||
| 25 | w: &'a mut W, | ||
| 26 | } | ||
| 27 | impl<'a> SLAKI_W<'a> { | ||
| 28 | #[doc = r"Sets the field bit"] | ||
| 29 | #[inline(always)] | ||
| 30 | pub fn set_bit(self) -> &'a mut W { | ||
| 31 | self.bit(true) | ||
| 32 | } | ||
| 33 | #[doc = r"Clears the field bit"] | ||
| 34 | #[inline(always)] | ||
| 35 | pub fn clear_bit(self) -> &'a mut W { | ||
| 36 | self.bit(false) | ||
| 37 | } | ||
| 38 | #[doc = r"Writes raw bits to the field"] | ||
| 39 | #[inline(always)] | ||
| 40 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 41 | self.w.bits = (self.w.bits & !(0x01 << 4)) | (((value as u32) & 0x01) << 4); | ||
| 42 | self.w | ||
| 43 | } | ||
| 44 | } | ||
| 45 | #[doc = "Reader of field `WKUI`"] | ||
| 46 | pub type WKUI_R = crate::R<bool, bool>; | ||
| 47 | #[doc = "Write proxy for field `WKUI`"] | ||
| 48 | pub struct WKUI_W<'a> { | ||
| 49 | w: &'a mut W, | ||
| 50 | } | ||
| 51 | impl<'a> WKUI_W<'a> { | ||
| 52 | #[doc = r"Sets the field bit"] | ||
| 53 | #[inline(always)] | ||
| 54 | pub fn set_bit(self) -> &'a mut W { | ||
| 55 | self.bit(true) | ||
| 56 | } | ||
| 57 | #[doc = r"Clears the field bit"] | ||
| 58 | #[inline(always)] | ||
| 59 | pub fn clear_bit(self) -> &'a mut W { | ||
| 60 | self.bit(false) | ||
| 61 | } | ||
| 62 | #[doc = r"Writes raw bits to the field"] | ||
| 63 | #[inline(always)] | ||
| 64 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 65 | self.w.bits = (self.w.bits & !(0x01 << 3)) | (((value as u32) & 0x01) << 3); | ||
| 66 | self.w | ||
| 67 | } | ||
| 68 | } | ||
| 69 | #[doc = "Reader of field `ERRI`"] | ||
| 70 | pub type ERRI_R = crate::R<bool, bool>; | ||
| 71 | #[doc = "Write proxy for field `ERRI`"] | ||
| 72 | pub struct ERRI_W<'a> { | ||
| 73 | w: &'a mut W, | ||
| 74 | } | ||
| 75 | impl<'a> ERRI_W<'a> { | ||
| 76 | #[doc = r"Sets the field bit"] | ||
| 77 | #[inline(always)] | ||
| 78 | pub fn set_bit(self) -> &'a mut W { | ||
| 79 | self.bit(true) | ||
| 80 | } | ||
| 81 | #[doc = r"Clears the field bit"] | ||
| 82 | #[inline(always)] | ||
| 83 | pub fn clear_bit(self) -> &'a mut W { | ||
| 84 | self.bit(false) | ||
| 85 | } | ||
| 86 | #[doc = r"Writes raw bits to the field"] | ||
| 87 | #[inline(always)] | ||
| 88 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 89 | self.w.bits = (self.w.bits & !(0x01 << 2)) | (((value as u32) & 0x01) << 2); | ||
| 90 | self.w | ||
| 91 | } | ||
| 92 | } | ||
| 93 | #[doc = "Reader of field `SLAK`"] | ||
| 94 | pub type SLAK_R = crate::R<bool, bool>; | ||
| 95 | #[doc = "Reader of field `INAK`"] | ||
| 96 | pub type INAK_R = crate::R<bool, bool>; | ||
| 97 | impl R { | ||
| 98 | #[doc = "Bit 11 - RX"] | ||
| 99 | #[inline(always)] | ||
| 100 | pub fn rx(&self) -> RX_R { | ||
| 101 | RX_R::new(((self.bits >> 11) & 0x01) != 0) | ||
| 102 | } | ||
| 103 | #[doc = "Bit 10 - SAMP"] | ||
| 104 | #[inline(always)] | ||
| 105 | pub fn samp(&self) -> SAMP_R { | ||
| 106 | SAMP_R::new(((self.bits >> 10) & 0x01) != 0) | ||
| 107 | } | ||
| 108 | #[doc = "Bit 9 - RXM"] | ||
| 109 | #[inline(always)] | ||
| 110 | pub fn rxm(&self) -> RXM_R { | ||
| 111 | RXM_R::new(((self.bits >> 9) & 0x01) != 0) | ||
| 112 | } | ||
| 113 | #[doc = "Bit 8 - TXM"] | ||
| 114 | #[inline(always)] | ||
| 115 | pub fn txm(&self) -> TXM_R { | ||
| 116 | TXM_R::new(((self.bits >> 8) & 0x01) != 0) | ||
| 117 | } | ||
| 118 | #[doc = "Bit 4 - SLAKI"] | ||
| 119 | #[inline(always)] | ||
| 120 | pub fn slaki(&self) -> SLAKI_R { | ||
| 121 | SLAKI_R::new(((self.bits >> 4) & 0x01) != 0) | ||
| 122 | } | ||
| 123 | #[doc = "Bit 3 - WKUI"] | ||
| 124 | #[inline(always)] | ||
| 125 | pub fn wkui(&self) -> WKUI_R { | ||
| 126 | WKUI_R::new(((self.bits >> 3) & 0x01) != 0) | ||
| 127 | } | ||
| 128 | #[doc = "Bit 2 - ERRI"] | ||
| 129 | #[inline(always)] | ||
| 130 | pub fn erri(&self) -> ERRI_R { | ||
| 131 | ERRI_R::new(((self.bits >> 2) & 0x01) != 0) | ||
| 132 | } | ||
| 133 | #[doc = "Bit 1 - SLAK"] | ||
| 134 | #[inline(always)] | ||
| 135 | pub fn slak(&self) -> SLAK_R { | ||
| 136 | SLAK_R::new(((self.bits >> 1) & 0x01) != 0) | ||
| 137 | } | ||
| 138 | #[doc = "Bit 0 - INAK"] | ||
| 139 | #[inline(always)] | ||
| 140 | pub fn inak(&self) -> INAK_R { | ||
| 141 | INAK_R::new((self.bits & 0x01) != 0) | ||
| 142 | } | ||
| 143 | } | ||
| 144 | impl W { | ||
| 145 | #[doc = "Bit 4 - SLAKI"] | ||
| 146 | #[inline(always)] | ||
| 147 | pub fn slaki(&mut self) -> SLAKI_W { | ||
| 148 | SLAKI_W { w: self } | ||
| 149 | } | ||
| 150 | #[doc = "Bit 3 - WKUI"] | ||
| 151 | #[inline(always)] | ||
| 152 | pub fn wkui(&mut self) -> WKUI_W { | ||
| 153 | WKUI_W { w: self } | ||
| 154 | } | ||
| 155 | #[doc = "Bit 2 - ERRI"] | ||
| 156 | #[inline(always)] | ||
| 157 | pub fn erri(&mut self) -> ERRI_W { | ||
| 158 | ERRI_W { w: self } | ||
| 159 | } | ||
| 160 | } | ||
diff --git a/embassy-stm32/src/can/bx/pac/can/rfr.rs b/embassy-stm32/src/can/bx/pac/can/rfr.rs new file mode 100644 index 000000000..6f5a960d1 --- /dev/null +++ b/embassy-stm32/src/can/bx/pac/can/rfr.rs | |||
| @@ -0,0 +1,281 @@ | |||
| 1 | #[doc = "Reader of register RF%sR"] | ||
| 2 | pub type R = crate::R<u32, super::RFR>; | ||
| 3 | #[doc = "Writer for register RF%sR"] | ||
| 4 | pub type W = crate::W<u32, super::RFR>; | ||
| 5 | #[doc = "Register RF%sR `reset()`'s with value 0"] | ||
| 6 | impl crate::ResetValue for super::RFR { | ||
| 7 | type Type = u32; | ||
| 8 | #[inline(always)] | ||
| 9 | fn reset_value() -> Self::Type { | ||
| 10 | 0 | ||
| 11 | } | ||
| 12 | } | ||
| 13 | #[doc = "RFOM0\n\nValue on reset: 0"] | ||
| 14 | #[derive(Clone, Copy, Debug, PartialEq)] | ||
| 15 | pub enum RFOM_A { | ||
| 16 | #[doc = "1: Set by software to release the output mailbox of the FIFO"] | ||
| 17 | RELEASE = 1, | ||
| 18 | } | ||
| 19 | impl From<RFOM_A> for bool { | ||
| 20 | #[inline(always)] | ||
| 21 | fn from(variant: RFOM_A) -> Self { | ||
| 22 | variant as u8 != 0 | ||
| 23 | } | ||
| 24 | } | ||
| 25 | #[doc = "Reader of field `RFOM`"] | ||
| 26 | pub type RFOM_R = crate::R<bool, RFOM_A>; | ||
| 27 | impl RFOM_R { | ||
| 28 | #[doc = r"Get enumerated values variant"] | ||
| 29 | #[inline(always)] | ||
| 30 | pub fn variant(&self) -> crate::Variant<bool, RFOM_A> { | ||
| 31 | use crate::Variant::*; | ||
| 32 | match self.bits { | ||
| 33 | true => Val(RFOM_A::RELEASE), | ||
| 34 | i => Res(i), | ||
| 35 | } | ||
| 36 | } | ||
| 37 | #[doc = "Checks if the value of the field is `RELEASE`"] | ||
| 38 | #[inline(always)] | ||
| 39 | pub fn is_release(&self) -> bool { | ||
| 40 | *self == RFOM_A::RELEASE | ||
| 41 | } | ||
| 42 | } | ||
| 43 | #[doc = "Write proxy for field `RFOM`"] | ||
| 44 | pub struct RFOM_W<'a> { | ||
| 45 | w: &'a mut W, | ||
| 46 | } | ||
| 47 | impl<'a> RFOM_W<'a> { | ||
| 48 | #[doc = r"Writes `variant` to the field"] | ||
| 49 | #[inline(always)] | ||
| 50 | pub fn variant(self, variant: RFOM_A) -> &'a mut W { | ||
| 51 | { | ||
| 52 | self.bit(variant.into()) | ||
| 53 | } | ||
| 54 | } | ||
| 55 | #[doc = "Set by software to release the output mailbox of the FIFO"] | ||
| 56 | #[inline(always)] | ||
| 57 | pub fn release(self) -> &'a mut W { | ||
| 58 | self.variant(RFOM_A::RELEASE) | ||
| 59 | } | ||
| 60 | #[doc = r"Sets the field bit"] | ||
| 61 | #[inline(always)] | ||
| 62 | pub fn set_bit(self) -> &'a mut W { | ||
| 63 | self.bit(true) | ||
| 64 | } | ||
| 65 | #[doc = r"Clears the field bit"] | ||
| 66 | #[inline(always)] | ||
| 67 | pub fn clear_bit(self) -> &'a mut W { | ||
| 68 | self.bit(false) | ||
| 69 | } | ||
| 70 | #[doc = r"Writes raw bits to the field"] | ||
| 71 | #[inline(always)] | ||
| 72 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 73 | self.w.bits = (self.w.bits & !(0x01 << 5)) | (((value as u32) & 0x01) << 5); | ||
| 74 | self.w | ||
| 75 | } | ||
| 76 | } | ||
| 77 | #[doc = "FOVR0\n\nValue on reset: 0"] | ||
| 78 | #[derive(Clone, Copy, Debug, PartialEq)] | ||
| 79 | pub enum FOVR_A { | ||
| 80 | #[doc = "0: No FIFO x overrun"] | ||
| 81 | NOOVERRUN = 0, | ||
| 82 | #[doc = "1: FIFO x overrun"] | ||
| 83 | OVERRUN = 1, | ||
| 84 | } | ||
| 85 | impl From<FOVR_A> for bool { | ||
| 86 | #[inline(always)] | ||
| 87 | fn from(variant: FOVR_A) -> Self { | ||
| 88 | variant as u8 != 0 | ||
| 89 | } | ||
| 90 | } | ||
| 91 | #[doc = "Reader of field `FOVR`"] | ||
| 92 | pub type FOVR_R = crate::R<bool, FOVR_A>; | ||
| 93 | impl FOVR_R { | ||
| 94 | #[doc = r"Get enumerated values variant"] | ||
| 95 | #[inline(always)] | ||
| 96 | pub fn variant(&self) -> FOVR_A { | ||
| 97 | match self.bits { | ||
| 98 | false => FOVR_A::NOOVERRUN, | ||
| 99 | true => FOVR_A::OVERRUN, | ||
| 100 | } | ||
| 101 | } | ||
| 102 | #[doc = "Checks if the value of the field is `NOOVERRUN`"] | ||
| 103 | #[inline(always)] | ||
| 104 | pub fn is_no_overrun(&self) -> bool { | ||
| 105 | *self == FOVR_A::NOOVERRUN | ||
| 106 | } | ||
| 107 | #[doc = "Checks if the value of the field is `OVERRUN`"] | ||
| 108 | #[inline(always)] | ||
| 109 | pub fn is_overrun(&self) -> bool { | ||
| 110 | *self == FOVR_A::OVERRUN | ||
| 111 | } | ||
| 112 | } | ||
| 113 | #[doc = "FOVR0\n\nValue on reset: 0"] | ||
| 114 | #[derive(Clone, Copy, Debug, PartialEq)] | ||
| 115 | pub enum FOVR_AW { | ||
| 116 | #[doc = "1: Clear flag"] | ||
| 117 | CLEAR = 1, | ||
| 118 | } | ||
| 119 | impl From<FOVR_AW> for bool { | ||
| 120 | #[inline(always)] | ||
| 121 | fn from(variant: FOVR_AW) -> Self { | ||
| 122 | variant as u8 != 0 | ||
| 123 | } | ||
| 124 | } | ||
| 125 | #[doc = "Write proxy for field `FOVR`"] | ||
| 126 | pub struct FOVR_W<'a> { | ||
| 127 | w: &'a mut W, | ||
| 128 | } | ||
| 129 | impl<'a> FOVR_W<'a> { | ||
| 130 | #[doc = r"Writes `variant` to the field"] | ||
| 131 | #[inline(always)] | ||
| 132 | pub fn variant(self, variant: FOVR_AW) -> &'a mut W { | ||
| 133 | { | ||
| 134 | self.bit(variant.into()) | ||
| 135 | } | ||
| 136 | } | ||
| 137 | #[doc = "Clear flag"] | ||
| 138 | #[inline(always)] | ||
| 139 | pub fn clear(self) -> &'a mut W { | ||
| 140 | self.variant(FOVR_AW::CLEAR) | ||
| 141 | } | ||
| 142 | #[doc = r"Sets the field bit"] | ||
| 143 | #[inline(always)] | ||
| 144 | pub fn set_bit(self) -> &'a mut W { | ||
| 145 | self.bit(true) | ||
| 146 | } | ||
| 147 | #[doc = r"Clears the field bit"] | ||
| 148 | #[inline(always)] | ||
| 149 | pub fn clear_bit(self) -> &'a mut W { | ||
| 150 | self.bit(false) | ||
| 151 | } | ||
| 152 | #[doc = r"Writes raw bits to the field"] | ||
| 153 | #[inline(always)] | ||
| 154 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 155 | self.w.bits = (self.w.bits & !(0x01 << 4)) | (((value as u32) & 0x01) << 4); | ||
| 156 | self.w | ||
| 157 | } | ||
| 158 | } | ||
| 159 | #[doc = "FULL0\n\nValue on reset: 0"] | ||
| 160 | #[derive(Clone, Copy, Debug, PartialEq)] | ||
| 161 | pub enum FULL_A { | ||
| 162 | #[doc = "0: FIFO x is not full"] | ||
| 163 | NOTFULL = 0, | ||
| 164 | #[doc = "1: FIFO x is full"] | ||
| 165 | FULL = 1, | ||
| 166 | } | ||
| 167 | impl From<FULL_A> for bool { | ||
| 168 | #[inline(always)] | ||
| 169 | fn from(variant: FULL_A) -> Self { | ||
| 170 | variant as u8 != 0 | ||
| 171 | } | ||
| 172 | } | ||
| 173 | #[doc = "Reader of field `FULL`"] | ||
| 174 | pub type FULL_R = crate::R<bool, FULL_A>; | ||
| 175 | impl FULL_R { | ||
| 176 | #[doc = r"Get enumerated values variant"] | ||
| 177 | #[inline(always)] | ||
| 178 | pub fn variant(&self) -> FULL_A { | ||
| 179 | match self.bits { | ||
| 180 | false => FULL_A::NOTFULL, | ||
| 181 | true => FULL_A::FULL, | ||
| 182 | } | ||
| 183 | } | ||
| 184 | #[doc = "Checks if the value of the field is `NOTFULL`"] | ||
| 185 | #[inline(always)] | ||
| 186 | pub fn is_not_full(&self) -> bool { | ||
| 187 | *self == FULL_A::NOTFULL | ||
| 188 | } | ||
| 189 | #[doc = "Checks if the value of the field is `FULL`"] | ||
| 190 | #[inline(always)] | ||
| 191 | pub fn is_full(&self) -> bool { | ||
| 192 | *self == FULL_A::FULL | ||
| 193 | } | ||
| 194 | } | ||
| 195 | #[doc = "FULL0\n\nValue on reset: 0"] | ||
| 196 | #[derive(Clone, Copy, Debug, PartialEq)] | ||
| 197 | pub enum FULL_AW { | ||
| 198 | #[doc = "1: Clear flag"] | ||
| 199 | CLEAR = 1, | ||
| 200 | } | ||
| 201 | impl From<FULL_AW> for bool { | ||
| 202 | #[inline(always)] | ||
| 203 | fn from(variant: FULL_AW) -> Self { | ||
| 204 | variant as u8 != 0 | ||
| 205 | } | ||
| 206 | } | ||
| 207 | #[doc = "Write proxy for field `FULL`"] | ||
| 208 | pub struct FULL_W<'a> { | ||
| 209 | w: &'a mut W, | ||
| 210 | } | ||
| 211 | impl<'a> FULL_W<'a> { | ||
| 212 | #[doc = r"Writes `variant` to the field"] | ||
| 213 | #[inline(always)] | ||
| 214 | pub fn variant(self, variant: FULL_AW) -> &'a mut W { | ||
| 215 | { | ||
| 216 | self.bit(variant.into()) | ||
| 217 | } | ||
| 218 | } | ||
| 219 | #[doc = "Clear flag"] | ||
| 220 | #[inline(always)] | ||
| 221 | pub fn clear(self) -> &'a mut W { | ||
| 222 | self.variant(FULL_AW::CLEAR) | ||
| 223 | } | ||
| 224 | #[doc = r"Sets the field bit"] | ||
| 225 | #[inline(always)] | ||
| 226 | pub fn set_bit(self) -> &'a mut W { | ||
| 227 | self.bit(true) | ||
| 228 | } | ||
| 229 | #[doc = r"Clears the field bit"] | ||
| 230 | #[inline(always)] | ||
| 231 | pub fn clear_bit(self) -> &'a mut W { | ||
| 232 | self.bit(false) | ||
| 233 | } | ||
| 234 | #[doc = r"Writes raw bits to the field"] | ||
| 235 | #[inline(always)] | ||
| 236 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 237 | self.w.bits = (self.w.bits & !(0x01 << 3)) | (((value as u32) & 0x01) << 3); | ||
| 238 | self.w | ||
| 239 | } | ||
| 240 | } | ||
| 241 | #[doc = "Reader of field `FMP`"] | ||
| 242 | pub type FMP_R = crate::R<u8, u8>; | ||
| 243 | impl R { | ||
| 244 | #[doc = "Bit 5 - RFOM0"] | ||
| 245 | #[inline(always)] | ||
| 246 | pub fn rfom(&self) -> RFOM_R { | ||
| 247 | RFOM_R::new(((self.bits >> 5) & 0x01) != 0) | ||
| 248 | } | ||
| 249 | #[doc = "Bit 4 - FOVR0"] | ||
| 250 | #[inline(always)] | ||
| 251 | pub fn fovr(&self) -> FOVR_R { | ||
| 252 | FOVR_R::new(((self.bits >> 4) & 0x01) != 0) | ||
| 253 | } | ||
| 254 | #[doc = "Bit 3 - FULL0"] | ||
| 255 | #[inline(always)] | ||
| 256 | pub fn full(&self) -> FULL_R { | ||
| 257 | FULL_R::new(((self.bits >> 3) & 0x01) != 0) | ||
| 258 | } | ||
| 259 | #[doc = "Bits 0:1 - FMP0"] | ||
| 260 | #[inline(always)] | ||
| 261 | pub fn fmp(&self) -> FMP_R { | ||
| 262 | FMP_R::new((self.bits & 0x03) as u8) | ||
| 263 | } | ||
| 264 | } | ||
| 265 | impl W { | ||
| 266 | #[doc = "Bit 5 - RFOM0"] | ||
| 267 | #[inline(always)] | ||
| 268 | pub fn rfom(&mut self) -> RFOM_W { | ||
| 269 | RFOM_W { w: self } | ||
| 270 | } | ||
| 271 | #[doc = "Bit 4 - FOVR0"] | ||
| 272 | #[inline(always)] | ||
| 273 | pub fn fovr(&mut self) -> FOVR_W { | ||
| 274 | FOVR_W { w: self } | ||
| 275 | } | ||
| 276 | #[doc = "Bit 3 - FULL0"] | ||
| 277 | #[inline(always)] | ||
| 278 | pub fn full(&mut self) -> FULL_W { | ||
| 279 | FULL_W { w: self } | ||
| 280 | } | ||
| 281 | } | ||
diff --git a/embassy-stm32/src/can/bx/pac/can/rx.rs b/embassy-stm32/src/can/bx/pac/can/rx.rs new file mode 100644 index 000000000..dba344e7c --- /dev/null +++ b/embassy-stm32/src/can/bx/pac/can/rx.rs | |||
| @@ -0,0 +1,36 @@ | |||
| 1 | #[doc = "CAN_RI0R\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [rir](rir) module"] | ||
| 2 | pub type RIR = crate::Reg<u32, _RIR>; | ||
| 3 | #[allow(missing_docs)] | ||
| 4 | #[doc(hidden)] | ||
| 5 | pub struct _RIR; | ||
| 6 | #[doc = "`read()` method returns [rir::R](rir::R) reader structure"] | ||
| 7 | impl crate::Readable for RIR {} | ||
| 8 | #[doc = "CAN_RI0R"] | ||
| 9 | pub mod rir; | ||
| 10 | #[doc = "CAN_RDT0R\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [rdtr](rdtr) module"] | ||
| 11 | pub type RDTR = crate::Reg<u32, _RDTR>; | ||
| 12 | #[allow(missing_docs)] | ||
| 13 | #[doc(hidden)] | ||
| 14 | pub struct _RDTR; | ||
| 15 | #[doc = "`read()` method returns [rdtr::R](rdtr::R) reader structure"] | ||
| 16 | impl crate::Readable for RDTR {} | ||
| 17 | #[doc = "CAN_RDT0R"] | ||
| 18 | pub mod rdtr; | ||
| 19 | #[doc = "CAN_RDL0R\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [rdlr](rdlr) module"] | ||
| 20 | pub type RDLR = crate::Reg<u32, _RDLR>; | ||
| 21 | #[allow(missing_docs)] | ||
| 22 | #[doc(hidden)] | ||
| 23 | pub struct _RDLR; | ||
| 24 | #[doc = "`read()` method returns [rdlr::R](rdlr::R) reader structure"] | ||
| 25 | impl crate::Readable for RDLR {} | ||
| 26 | #[doc = "CAN_RDL0R"] | ||
| 27 | pub mod rdlr; | ||
| 28 | #[doc = "CAN_RDH0R\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [rdhr](rdhr) module"] | ||
| 29 | pub type RDHR = crate::Reg<u32, _RDHR>; | ||
| 30 | #[allow(missing_docs)] | ||
| 31 | #[doc(hidden)] | ||
| 32 | pub struct _RDHR; | ||
| 33 | #[doc = "`read()` method returns [rdhr::R](rdhr::R) reader structure"] | ||
| 34 | impl crate::Readable for RDHR {} | ||
| 35 | #[doc = "CAN_RDH0R"] | ||
| 36 | pub mod rdhr; | ||
diff --git a/embassy-stm32/src/can/bx/pac/can/rx/rdhr.rs b/embassy-stm32/src/can/bx/pac/can/rx/rdhr.rs new file mode 100644 index 000000000..a0e6a52d0 --- /dev/null +++ b/embassy-stm32/src/can/bx/pac/can/rx/rdhr.rs | |||
| @@ -0,0 +1,32 @@ | |||
| 1 | #[doc = "Reader of register RDHR"] | ||
| 2 | pub type R = crate::R<u32, super::RDHR>; | ||
| 3 | #[doc = "Reader of field `DATA7`"] | ||
| 4 | pub type DATA7_R = crate::R<u8, u8>; | ||
| 5 | #[doc = "Reader of field `DATA6`"] | ||
| 6 | pub type DATA6_R = crate::R<u8, u8>; | ||
| 7 | #[doc = "Reader of field `DATA5`"] | ||
| 8 | pub type DATA5_R = crate::R<u8, u8>; | ||
| 9 | #[doc = "Reader of field `DATA4`"] | ||
| 10 | pub type DATA4_R = crate::R<u8, u8>; | ||
| 11 | impl R { | ||
| 12 | #[doc = "Bits 24:31 - DATA7"] | ||
| 13 | #[inline(always)] | ||
| 14 | pub fn data7(&self) -> DATA7_R { | ||
| 15 | DATA7_R::new(((self.bits >> 24) & 0xff) as u8) | ||
| 16 | } | ||
| 17 | #[doc = "Bits 16:23 - DATA6"] | ||
| 18 | #[inline(always)] | ||
| 19 | pub fn data6(&self) -> DATA6_R { | ||
| 20 | DATA6_R::new(((self.bits >> 16) & 0xff) as u8) | ||
| 21 | } | ||
| 22 | #[doc = "Bits 8:15 - DATA5"] | ||
| 23 | #[inline(always)] | ||
| 24 | pub fn data5(&self) -> DATA5_R { | ||
| 25 | DATA5_R::new(((self.bits >> 8) & 0xff) as u8) | ||
| 26 | } | ||
| 27 | #[doc = "Bits 0:7 - DATA4"] | ||
| 28 | #[inline(always)] | ||
| 29 | pub fn data4(&self) -> DATA4_R { | ||
| 30 | DATA4_R::new((self.bits & 0xff) as u8) | ||
| 31 | } | ||
| 32 | } | ||
diff --git a/embassy-stm32/src/can/bx/pac/can/rx/rdlr.rs b/embassy-stm32/src/can/bx/pac/can/rx/rdlr.rs new file mode 100644 index 000000000..e61746669 --- /dev/null +++ b/embassy-stm32/src/can/bx/pac/can/rx/rdlr.rs | |||
| @@ -0,0 +1,32 @@ | |||
| 1 | #[doc = "Reader of register RDLR"] | ||
| 2 | pub type R = crate::R<u32, super::RDLR>; | ||
| 3 | #[doc = "Reader of field `DATA3`"] | ||
| 4 | pub type DATA3_R = crate::R<u8, u8>; | ||
| 5 | #[doc = "Reader of field `DATA2`"] | ||
| 6 | pub type DATA2_R = crate::R<u8, u8>; | ||
| 7 | #[doc = "Reader of field `DATA1`"] | ||
| 8 | pub type DATA1_R = crate::R<u8, u8>; | ||
| 9 | #[doc = "Reader of field `DATA0`"] | ||
| 10 | pub type DATA0_R = crate::R<u8, u8>; | ||
| 11 | impl R { | ||
| 12 | #[doc = "Bits 24:31 - DATA3"] | ||
| 13 | #[inline(always)] | ||
| 14 | pub fn data3(&self) -> DATA3_R { | ||
| 15 | DATA3_R::new(((self.bits >> 24) & 0xff) as u8) | ||
| 16 | } | ||
| 17 | #[doc = "Bits 16:23 - DATA2"] | ||
| 18 | #[inline(always)] | ||
| 19 | pub fn data2(&self) -> DATA2_R { | ||
| 20 | DATA2_R::new(((self.bits >> 16) & 0xff) as u8) | ||
| 21 | } | ||
| 22 | #[doc = "Bits 8:15 - DATA1"] | ||
| 23 | #[inline(always)] | ||
| 24 | pub fn data1(&self) -> DATA1_R { | ||
| 25 | DATA1_R::new(((self.bits >> 8) & 0xff) as u8) | ||
| 26 | } | ||
| 27 | #[doc = "Bits 0:7 - DATA0"] | ||
| 28 | #[inline(always)] | ||
| 29 | pub fn data0(&self) -> DATA0_R { | ||
| 30 | DATA0_R::new((self.bits & 0xff) as u8) | ||
| 31 | } | ||
| 32 | } | ||
diff --git a/embassy-stm32/src/can/bx/pac/can/rx/rdtr.rs b/embassy-stm32/src/can/bx/pac/can/rx/rdtr.rs new file mode 100644 index 000000000..6778a7b4a --- /dev/null +++ b/embassy-stm32/src/can/bx/pac/can/rx/rdtr.rs | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | #[doc = "Reader of register RDTR"] | ||
| 2 | pub type R = crate::R<u32, super::RDTR>; | ||
| 3 | #[doc = "Reader of field `TIME`"] | ||
| 4 | pub type TIME_R = crate::R<u16, u16>; | ||
| 5 | #[doc = "Reader of field `FMI`"] | ||
| 6 | pub type FMI_R = crate::R<u8, u8>; | ||
| 7 | #[doc = "Reader of field `DLC`"] | ||
| 8 | pub type DLC_R = crate::R<u8, u8>; | ||
| 9 | impl R { | ||
| 10 | #[doc = "Bits 16:31 - TIME"] | ||
| 11 | #[inline(always)] | ||
| 12 | pub fn time(&self) -> TIME_R { | ||
| 13 | TIME_R::new(((self.bits >> 16) & 0xffff) as u16) | ||
| 14 | } | ||
| 15 | #[doc = "Bits 8:15 - FMI"] | ||
| 16 | #[inline(always)] | ||
| 17 | pub fn fmi(&self) -> FMI_R { | ||
| 18 | FMI_R::new(((self.bits >> 8) & 0xff) as u8) | ||
| 19 | } | ||
| 20 | #[doc = "Bits 0:3 - DLC"] | ||
| 21 | #[inline(always)] | ||
| 22 | pub fn dlc(&self) -> DLC_R { | ||
| 23 | DLC_R::new((self.bits & 0x0f) as u8) | ||
| 24 | } | ||
| 25 | } | ||
diff --git a/embassy-stm32/src/can/bx/pac/can/rx/rir.rs b/embassy-stm32/src/can/bx/pac/can/rx/rir.rs new file mode 100644 index 000000000..c0e4248f4 --- /dev/null +++ b/embassy-stm32/src/can/bx/pac/can/rx/rir.rs | |||
| @@ -0,0 +1,100 @@ | |||
| 1 | #[doc = "Reader of register RIR"] | ||
| 2 | pub type R = crate::R<u32, super::RIR>; | ||
| 3 | #[doc = "Reader of field `STID`"] | ||
| 4 | pub type STID_R = crate::R<u16, u16>; | ||
| 5 | #[doc = "Reader of field `EXID`"] | ||
| 6 | pub type EXID_R = crate::R<u32, u32>; | ||
| 7 | #[doc = "IDE\n\nValue on reset: 0"] | ||
| 8 | #[derive(Clone, Copy, Debug, PartialEq)] | ||
| 9 | pub enum IDE_A { | ||
| 10 | #[doc = "0: Standard identifier"] | ||
| 11 | STANDARD = 0, | ||
| 12 | #[doc = "1: Extended identifier"] | ||
| 13 | EXTENDED = 1, | ||
| 14 | } | ||
| 15 | impl From<IDE_A> for bool { | ||
| 16 | #[inline(always)] | ||
| 17 | fn from(variant: IDE_A) -> Self { | ||
| 18 | variant as u8 != 0 | ||
| 19 | } | ||
| 20 | } | ||
| 21 | #[doc = "Reader of field `IDE`"] | ||
| 22 | pub type IDE_R = crate::R<bool, IDE_A>; | ||
| 23 | impl IDE_R { | ||
| 24 | #[doc = r"Get enumerated values variant"] | ||
| 25 | #[inline(always)] | ||
| 26 | pub fn variant(&self) -> IDE_A { | ||
| 27 | match self.bits { | ||
| 28 | false => IDE_A::STANDARD, | ||
| 29 | true => IDE_A::EXTENDED, | ||
| 30 | } | ||
| 31 | } | ||
| 32 | #[doc = "Checks if the value of the field is `STANDARD`"] | ||
| 33 | #[inline(always)] | ||
| 34 | pub fn is_standard(&self) -> bool { | ||
| 35 | *self == IDE_A::STANDARD | ||
| 36 | } | ||
| 37 | #[doc = "Checks if the value of the field is `EXTENDED`"] | ||
| 38 | #[inline(always)] | ||
| 39 | pub fn is_extended(&self) -> bool { | ||
| 40 | *self == IDE_A::EXTENDED | ||
| 41 | } | ||
| 42 | } | ||
| 43 | #[doc = "RTR\n\nValue on reset: 0"] | ||
| 44 | #[derive(Clone, Copy, Debug, PartialEq)] | ||
| 45 | pub enum RTR_A { | ||
| 46 | #[doc = "0: Data frame"] | ||
| 47 | DATA = 0, | ||
| 48 | #[doc = "1: Remote frame"] | ||
| 49 | REMOTE = 1, | ||
| 50 | } | ||
| 51 | impl From<RTR_A> for bool { | ||
| 52 | #[inline(always)] | ||
| 53 | fn from(variant: RTR_A) -> Self { | ||
| 54 | variant as u8 != 0 | ||
| 55 | } | ||
| 56 | } | ||
| 57 | #[doc = "Reader of field `RTR`"] | ||
| 58 | pub type RTR_R = crate::R<bool, RTR_A>; | ||
| 59 | impl RTR_R { | ||
| 60 | #[doc = r"Get enumerated values variant"] | ||
| 61 | #[inline(always)] | ||
| 62 | pub fn variant(&self) -> RTR_A { | ||
| 63 | match self.bits { | ||
| 64 | false => RTR_A::DATA, | ||
| 65 | true => RTR_A::REMOTE, | ||
| 66 | } | ||
| 67 | } | ||
| 68 | #[doc = "Checks if the value of the field is `DATA`"] | ||
| 69 | #[inline(always)] | ||
| 70 | pub fn is_data(&self) -> bool { | ||
| 71 | *self == RTR_A::DATA | ||
| 72 | } | ||
| 73 | #[doc = "Checks if the value of the field is `REMOTE`"] | ||
| 74 | #[inline(always)] | ||
| 75 | pub fn is_remote(&self) -> bool { | ||
| 76 | *self == RTR_A::REMOTE | ||
| 77 | } | ||
| 78 | } | ||
| 79 | impl R { | ||
| 80 | #[doc = "Bits 21:31 - STID"] | ||
| 81 | #[inline(always)] | ||
| 82 | pub fn stid(&self) -> STID_R { | ||
| 83 | STID_R::new(((self.bits >> 21) & 0x07ff) as u16) | ||
| 84 | } | ||
| 85 | #[doc = "Bits 3:20 - EXID"] | ||
| 86 | #[inline(always)] | ||
| 87 | pub fn exid(&self) -> EXID_R { | ||
| 88 | EXID_R::new(((self.bits >> 3) & 0x0003_ffff) as u32) | ||
| 89 | } | ||
| 90 | #[doc = "Bit 2 - IDE"] | ||
| 91 | #[inline(always)] | ||
| 92 | pub fn ide(&self) -> IDE_R { | ||
| 93 | IDE_R::new(((self.bits >> 2) & 0x01) != 0) | ||
| 94 | } | ||
| 95 | #[doc = "Bit 1 - RTR"] | ||
| 96 | #[inline(always)] | ||
| 97 | pub fn rtr(&self) -> RTR_R { | ||
| 98 | RTR_R::new(((self.bits >> 1) & 0x01) != 0) | ||
| 99 | } | ||
| 100 | } | ||
diff --git a/embassy-stm32/src/can/bx/pac/can/tsr.rs b/embassy-stm32/src/can/bx/pac/can/tsr.rs new file mode 100644 index 000000000..2527b36a5 --- /dev/null +++ b/embassy-stm32/src/can/bx/pac/can/tsr.rs | |||
| @@ -0,0 +1,575 @@ | |||
| 1 | #[doc = "Reader of register TSR"] | ||
| 2 | pub type R = crate::R<u32, super::TSR>; | ||
| 3 | #[doc = "Writer for register TSR"] | ||
| 4 | pub type W = crate::W<u32, super::TSR>; | ||
| 5 | #[doc = "Register TSR `reset()`'s with value 0"] | ||
| 6 | impl crate::ResetValue for super::TSR { | ||
| 7 | type Type = u32; | ||
| 8 | #[inline(always)] | ||
| 9 | fn reset_value() -> Self::Type { | ||
| 10 | 0 | ||
| 11 | } | ||
| 12 | } | ||
| 13 | #[doc = "Reader of field `LOW2`"] | ||
| 14 | pub type LOW2_R = crate::R<bool, bool>; | ||
| 15 | #[doc = "Reader of field `LOW1`"] | ||
| 16 | pub type LOW1_R = crate::R<bool, bool>; | ||
| 17 | #[doc = "Reader of field `LOW0`"] | ||
| 18 | pub type LOW0_R = crate::R<bool, bool>; | ||
| 19 | #[doc = "Reader of field `TME2`"] | ||
| 20 | pub type TME2_R = crate::R<bool, bool>; | ||
| 21 | #[doc = "Reader of field `TME1`"] | ||
| 22 | pub type TME1_R = crate::R<bool, bool>; | ||
| 23 | #[doc = "Reader of field `TME0`"] | ||
| 24 | pub type TME0_R = crate::R<bool, bool>; | ||
| 25 | #[doc = "Reader of field `CODE`"] | ||
| 26 | pub type CODE_R = crate::R<u8, u8>; | ||
| 27 | #[doc = "Reader of field `ABRQ2`"] | ||
| 28 | pub type ABRQ2_R = crate::R<bool, bool>; | ||
| 29 | #[doc = "Write proxy for field `ABRQ2`"] | ||
| 30 | pub struct ABRQ2_W<'a> { | ||
| 31 | w: &'a mut W, | ||
| 32 | } | ||
| 33 | impl<'a> ABRQ2_W<'a> { | ||
| 34 | #[doc = r"Sets the field bit"] | ||
| 35 | #[inline(always)] | ||
| 36 | pub fn set_bit(self) -> &'a mut W { | ||
| 37 | self.bit(true) | ||
| 38 | } | ||
| 39 | #[doc = r"Clears the field bit"] | ||
| 40 | #[inline(always)] | ||
| 41 | pub fn clear_bit(self) -> &'a mut W { | ||
| 42 | self.bit(false) | ||
| 43 | } | ||
| 44 | #[doc = r"Writes raw bits to the field"] | ||
| 45 | #[inline(always)] | ||
| 46 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 47 | self.w.bits = (self.w.bits & !(0x01 << 23)) | (((value as u32) & 0x01) << 23); | ||
| 48 | self.w | ||
| 49 | } | ||
| 50 | } | ||
| 51 | #[doc = "Reader of field `TERR2`"] | ||
| 52 | pub type TERR2_R = crate::R<bool, bool>; | ||
| 53 | #[doc = "Write proxy for field `TERR2`"] | ||
| 54 | pub struct TERR2_W<'a> { | ||
| 55 | w: &'a mut W, | ||
| 56 | } | ||
| 57 | impl<'a> TERR2_W<'a> { | ||
| 58 | #[doc = r"Sets the field bit"] | ||
| 59 | #[inline(always)] | ||
| 60 | pub fn set_bit(self) -> &'a mut W { | ||
| 61 | self.bit(true) | ||
| 62 | } | ||
| 63 | #[doc = r"Clears the field bit"] | ||
| 64 | #[inline(always)] | ||
| 65 | pub fn clear_bit(self) -> &'a mut W { | ||
| 66 | self.bit(false) | ||
| 67 | } | ||
| 68 | #[doc = r"Writes raw bits to the field"] | ||
| 69 | #[inline(always)] | ||
| 70 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 71 | self.w.bits = (self.w.bits & !(0x01 << 19)) | (((value as u32) & 0x01) << 19); | ||
| 72 | self.w | ||
| 73 | } | ||
| 74 | } | ||
| 75 | #[doc = "Reader of field `ALST2`"] | ||
| 76 | pub type ALST2_R = crate::R<bool, bool>; | ||
| 77 | #[doc = "Write proxy for field `ALST2`"] | ||
| 78 | pub struct ALST2_W<'a> { | ||
| 79 | w: &'a mut W, | ||
| 80 | } | ||
| 81 | impl<'a> ALST2_W<'a> { | ||
| 82 | #[doc = r"Sets the field bit"] | ||
| 83 | #[inline(always)] | ||
| 84 | pub fn set_bit(self) -> &'a mut W { | ||
| 85 | self.bit(true) | ||
| 86 | } | ||
| 87 | #[doc = r"Clears the field bit"] | ||
| 88 | #[inline(always)] | ||
| 89 | pub fn clear_bit(self) -> &'a mut W { | ||
| 90 | self.bit(false) | ||
| 91 | } | ||
| 92 | #[doc = r"Writes raw bits to the field"] | ||
| 93 | #[inline(always)] | ||
| 94 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 95 | self.w.bits = (self.w.bits & !(0x01 << 18)) | (((value as u32) & 0x01) << 18); | ||
| 96 | self.w | ||
| 97 | } | ||
| 98 | } | ||
| 99 | #[doc = "Reader of field `TXOK2`"] | ||
| 100 | pub type TXOK2_R = crate::R<bool, bool>; | ||
| 101 | #[doc = "Write proxy for field `TXOK2`"] | ||
| 102 | pub struct TXOK2_W<'a> { | ||
| 103 | w: &'a mut W, | ||
| 104 | } | ||
| 105 | impl<'a> TXOK2_W<'a> { | ||
| 106 | #[doc = r"Sets the field bit"] | ||
| 107 | #[inline(always)] | ||
| 108 | pub fn set_bit(self) -> &'a mut W { | ||
| 109 | self.bit(true) | ||
| 110 | } | ||
| 111 | #[doc = r"Clears the field bit"] | ||
| 112 | #[inline(always)] | ||
| 113 | pub fn clear_bit(self) -> &'a mut W { | ||
| 114 | self.bit(false) | ||
| 115 | } | ||
| 116 | #[doc = r"Writes raw bits to the field"] | ||
| 117 | #[inline(always)] | ||
| 118 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 119 | self.w.bits = (self.w.bits & !(0x01 << 17)) | (((value as u32) & 0x01) << 17); | ||
| 120 | self.w | ||
| 121 | } | ||
| 122 | } | ||
| 123 | #[doc = "Reader of field `RQCP2`"] | ||
| 124 | pub type RQCP2_R = crate::R<bool, bool>; | ||
| 125 | #[doc = "Write proxy for field `RQCP2`"] | ||
| 126 | pub struct RQCP2_W<'a> { | ||
| 127 | w: &'a mut W, | ||
| 128 | } | ||
| 129 | impl<'a> RQCP2_W<'a> { | ||
| 130 | #[doc = r"Sets the field bit"] | ||
| 131 | #[inline(always)] | ||
| 132 | pub fn set_bit(self) -> &'a mut W { | ||
| 133 | self.bit(true) | ||
| 134 | } | ||
| 135 | #[doc = r"Clears the field bit"] | ||
| 136 | #[inline(always)] | ||
| 137 | pub fn clear_bit(self) -> &'a mut W { | ||
| 138 | self.bit(false) | ||
| 139 | } | ||
| 140 | #[doc = r"Writes raw bits to the field"] | ||
| 141 | #[inline(always)] | ||
| 142 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 143 | self.w.bits = (self.w.bits & !(0x01 << 16)) | (((value as u32) & 0x01) << 16); | ||
| 144 | self.w | ||
| 145 | } | ||
| 146 | } | ||
| 147 | #[doc = "Reader of field `ABRQ1`"] | ||
| 148 | pub type ABRQ1_R = crate::R<bool, bool>; | ||
| 149 | #[doc = "Write proxy for field `ABRQ1`"] | ||
| 150 | pub struct ABRQ1_W<'a> { | ||
| 151 | w: &'a mut W, | ||
| 152 | } | ||
| 153 | impl<'a> ABRQ1_W<'a> { | ||
| 154 | #[doc = r"Sets the field bit"] | ||
| 155 | #[inline(always)] | ||
| 156 | pub fn set_bit(self) -> &'a mut W { | ||
| 157 | self.bit(true) | ||
| 158 | } | ||
| 159 | #[doc = r"Clears the field bit"] | ||
| 160 | #[inline(always)] | ||
| 161 | pub fn clear_bit(self) -> &'a mut W { | ||
| 162 | self.bit(false) | ||
| 163 | } | ||
| 164 | #[doc = r"Writes raw bits to the field"] | ||
| 165 | #[inline(always)] | ||
| 166 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 167 | self.w.bits = (self.w.bits & !(0x01 << 15)) | (((value as u32) & 0x01) << 15); | ||
| 168 | self.w | ||
| 169 | } | ||
| 170 | } | ||
| 171 | #[doc = "Reader of field `TERR1`"] | ||
| 172 | pub type TERR1_R = crate::R<bool, bool>; | ||
| 173 | #[doc = "Write proxy for field `TERR1`"] | ||
| 174 | pub struct TERR1_W<'a> { | ||
| 175 | w: &'a mut W, | ||
| 176 | } | ||
| 177 | impl<'a> TERR1_W<'a> { | ||
| 178 | #[doc = r"Sets the field bit"] | ||
| 179 | #[inline(always)] | ||
| 180 | pub fn set_bit(self) -> &'a mut W { | ||
| 181 | self.bit(true) | ||
| 182 | } | ||
| 183 | #[doc = r"Clears the field bit"] | ||
| 184 | #[inline(always)] | ||
| 185 | pub fn clear_bit(self) -> &'a mut W { | ||
| 186 | self.bit(false) | ||
| 187 | } | ||
| 188 | #[doc = r"Writes raw bits to the field"] | ||
| 189 | #[inline(always)] | ||
| 190 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 191 | self.w.bits = (self.w.bits & !(0x01 << 11)) | (((value as u32) & 0x01) << 11); | ||
| 192 | self.w | ||
| 193 | } | ||
| 194 | } | ||
| 195 | #[doc = "Reader of field `ALST1`"] | ||
| 196 | pub type ALST1_R = crate::R<bool, bool>; | ||
| 197 | #[doc = "Write proxy for field `ALST1`"] | ||
| 198 | pub struct ALST1_W<'a> { | ||
| 199 | w: &'a mut W, | ||
| 200 | } | ||
| 201 | impl<'a> ALST1_W<'a> { | ||
| 202 | #[doc = r"Sets the field bit"] | ||
| 203 | #[inline(always)] | ||
| 204 | pub fn set_bit(self) -> &'a mut W { | ||
| 205 | self.bit(true) | ||
| 206 | } | ||
| 207 | #[doc = r"Clears the field bit"] | ||
| 208 | #[inline(always)] | ||
| 209 | pub fn clear_bit(self) -> &'a mut W { | ||
| 210 | self.bit(false) | ||
| 211 | } | ||
| 212 | #[doc = r"Writes raw bits to the field"] | ||
| 213 | #[inline(always)] | ||
| 214 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 215 | self.w.bits = (self.w.bits & !(0x01 << 10)) | (((value as u32) & 0x01) << 10); | ||
| 216 | self.w | ||
| 217 | } | ||
| 218 | } | ||
| 219 | #[doc = "Reader of field `TXOK1`"] | ||
| 220 | pub type TXOK1_R = crate::R<bool, bool>; | ||
| 221 | #[doc = "Write proxy for field `TXOK1`"] | ||
| 222 | pub struct TXOK1_W<'a> { | ||
| 223 | w: &'a mut W, | ||
| 224 | } | ||
| 225 | impl<'a> TXOK1_W<'a> { | ||
| 226 | #[doc = r"Sets the field bit"] | ||
| 227 | #[inline(always)] | ||
| 228 | pub fn set_bit(self) -> &'a mut W { | ||
| 229 | self.bit(true) | ||
| 230 | } | ||
| 231 | #[doc = r"Clears the field bit"] | ||
| 232 | #[inline(always)] | ||
| 233 | pub fn clear_bit(self) -> &'a mut W { | ||
| 234 | self.bit(false) | ||
| 235 | } | ||
| 236 | #[doc = r"Writes raw bits to the field"] | ||
| 237 | #[inline(always)] | ||
| 238 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 239 | self.w.bits = (self.w.bits & !(0x01 << 9)) | (((value as u32) & 0x01) << 9); | ||
| 240 | self.w | ||
| 241 | } | ||
| 242 | } | ||
| 243 | #[doc = "Reader of field `RQCP1`"] | ||
| 244 | pub type RQCP1_R = crate::R<bool, bool>; | ||
| 245 | #[doc = "Write proxy for field `RQCP1`"] | ||
| 246 | pub struct RQCP1_W<'a> { | ||
| 247 | w: &'a mut W, | ||
| 248 | } | ||
| 249 | impl<'a> RQCP1_W<'a> { | ||
| 250 | #[doc = r"Sets the field bit"] | ||
| 251 | #[inline(always)] | ||
| 252 | pub fn set_bit(self) -> &'a mut W { | ||
| 253 | self.bit(true) | ||
| 254 | } | ||
| 255 | #[doc = r"Clears the field bit"] | ||
| 256 | #[inline(always)] | ||
| 257 | pub fn clear_bit(self) -> &'a mut W { | ||
| 258 | self.bit(false) | ||
| 259 | } | ||
| 260 | #[doc = r"Writes raw bits to the field"] | ||
| 261 | #[inline(always)] | ||
| 262 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 263 | self.w.bits = (self.w.bits & !(0x01 << 8)) | (((value as u32) & 0x01) << 8); | ||
| 264 | self.w | ||
| 265 | } | ||
| 266 | } | ||
| 267 | #[doc = "Reader of field `ABRQ0`"] | ||
| 268 | pub type ABRQ0_R = crate::R<bool, bool>; | ||
| 269 | #[doc = "Write proxy for field `ABRQ0`"] | ||
| 270 | pub struct ABRQ0_W<'a> { | ||
| 271 | w: &'a mut W, | ||
| 272 | } | ||
| 273 | impl<'a> ABRQ0_W<'a> { | ||
| 274 | #[doc = r"Sets the field bit"] | ||
| 275 | #[inline(always)] | ||
| 276 | pub fn set_bit(self) -> &'a mut W { | ||
| 277 | self.bit(true) | ||
| 278 | } | ||
| 279 | #[doc = r"Clears the field bit"] | ||
| 280 | #[inline(always)] | ||
| 281 | pub fn clear_bit(self) -> &'a mut W { | ||
| 282 | self.bit(false) | ||
| 283 | } | ||
| 284 | #[doc = r"Writes raw bits to the field"] | ||
| 285 | #[inline(always)] | ||
| 286 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 287 | self.w.bits = (self.w.bits & !(0x01 << 7)) | (((value as u32) & 0x01) << 7); | ||
| 288 | self.w | ||
| 289 | } | ||
| 290 | } | ||
| 291 | #[doc = "Reader of field `TERR0`"] | ||
| 292 | pub type TERR0_R = crate::R<bool, bool>; | ||
| 293 | #[doc = "Write proxy for field `TERR0`"] | ||
| 294 | pub struct TERR0_W<'a> { | ||
| 295 | w: &'a mut W, | ||
| 296 | } | ||
| 297 | impl<'a> TERR0_W<'a> { | ||
| 298 | #[doc = r"Sets the field bit"] | ||
| 299 | #[inline(always)] | ||
| 300 | pub fn set_bit(self) -> &'a mut W { | ||
| 301 | self.bit(true) | ||
| 302 | } | ||
| 303 | #[doc = r"Clears the field bit"] | ||
| 304 | #[inline(always)] | ||
| 305 | pub fn clear_bit(self) -> &'a mut W { | ||
| 306 | self.bit(false) | ||
| 307 | } | ||
| 308 | #[doc = r"Writes raw bits to the field"] | ||
| 309 | #[inline(always)] | ||
| 310 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 311 | self.w.bits = (self.w.bits & !(0x01 << 3)) | (((value as u32) & 0x01) << 3); | ||
| 312 | self.w | ||
| 313 | } | ||
| 314 | } | ||
| 315 | #[doc = "Reader of field `ALST0`"] | ||
| 316 | pub type ALST0_R = crate::R<bool, bool>; | ||
| 317 | #[doc = "Write proxy for field `ALST0`"] | ||
| 318 | pub struct ALST0_W<'a> { | ||
| 319 | w: &'a mut W, | ||
| 320 | } | ||
| 321 | impl<'a> ALST0_W<'a> { | ||
| 322 | #[doc = r"Sets the field bit"] | ||
| 323 | #[inline(always)] | ||
| 324 | pub fn set_bit(self) -> &'a mut W { | ||
| 325 | self.bit(true) | ||
| 326 | } | ||
| 327 | #[doc = r"Clears the field bit"] | ||
| 328 | #[inline(always)] | ||
| 329 | pub fn clear_bit(self) -> &'a mut W { | ||
| 330 | self.bit(false) | ||
| 331 | } | ||
| 332 | #[doc = r"Writes raw bits to the field"] | ||
| 333 | #[inline(always)] | ||
| 334 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 335 | self.w.bits = (self.w.bits & !(0x01 << 2)) | (((value as u32) & 0x01) << 2); | ||
| 336 | self.w | ||
| 337 | } | ||
| 338 | } | ||
| 339 | #[doc = "Reader of field `TXOK0`"] | ||
| 340 | pub type TXOK0_R = crate::R<bool, bool>; | ||
| 341 | #[doc = "Write proxy for field `TXOK0`"] | ||
| 342 | pub struct TXOK0_W<'a> { | ||
| 343 | w: &'a mut W, | ||
| 344 | } | ||
| 345 | impl<'a> TXOK0_W<'a> { | ||
| 346 | #[doc = r"Sets the field bit"] | ||
| 347 | #[inline(always)] | ||
| 348 | pub fn set_bit(self) -> &'a mut W { | ||
| 349 | self.bit(true) | ||
| 350 | } | ||
| 351 | #[doc = r"Clears the field bit"] | ||
| 352 | #[inline(always)] | ||
| 353 | pub fn clear_bit(self) -> &'a mut W { | ||
| 354 | self.bit(false) | ||
| 355 | } | ||
| 356 | #[doc = r"Writes raw bits to the field"] | ||
| 357 | #[inline(always)] | ||
| 358 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 359 | self.w.bits = (self.w.bits & !(0x01 << 1)) | (((value as u32) & 0x01) << 1); | ||
| 360 | self.w | ||
| 361 | } | ||
| 362 | } | ||
| 363 | #[doc = "Reader of field `RQCP0`"] | ||
| 364 | pub type RQCP0_R = crate::R<bool, bool>; | ||
| 365 | #[doc = "Write proxy for field `RQCP0`"] | ||
| 366 | pub struct RQCP0_W<'a> { | ||
| 367 | w: &'a mut W, | ||
| 368 | } | ||
| 369 | impl<'a> RQCP0_W<'a> { | ||
| 370 | #[doc = r"Sets the field bit"] | ||
| 371 | #[inline(always)] | ||
| 372 | pub fn set_bit(self) -> &'a mut W { | ||
| 373 | self.bit(true) | ||
| 374 | } | ||
| 375 | #[doc = r"Clears the field bit"] | ||
| 376 | #[inline(always)] | ||
| 377 | pub fn clear_bit(self) -> &'a mut W { | ||
| 378 | self.bit(false) | ||
| 379 | } | ||
| 380 | #[doc = r"Writes raw bits to the field"] | ||
| 381 | #[inline(always)] | ||
| 382 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 383 | self.w.bits = (self.w.bits & !0x01) | ((value as u32) & 0x01); | ||
| 384 | self.w | ||
| 385 | } | ||
| 386 | } | ||
| 387 | impl R { | ||
| 388 | #[doc = "Bit 31 - Lowest priority flag for mailbox 2"] | ||
| 389 | #[inline(always)] | ||
| 390 | pub fn low2(&self) -> LOW2_R { | ||
| 391 | LOW2_R::new(((self.bits >> 31) & 0x01) != 0) | ||
| 392 | } | ||
| 393 | #[doc = "Bit 30 - Lowest priority flag for mailbox 1"] | ||
| 394 | #[inline(always)] | ||
| 395 | pub fn low1(&self) -> LOW1_R { | ||
| 396 | LOW1_R::new(((self.bits >> 30) & 0x01) != 0) | ||
| 397 | } | ||
| 398 | #[doc = "Bit 29 - Lowest priority flag for mailbox 0"] | ||
| 399 | #[inline(always)] | ||
| 400 | pub fn low0(&self) -> LOW0_R { | ||
| 401 | LOW0_R::new(((self.bits >> 29) & 0x01) != 0) | ||
| 402 | } | ||
| 403 | #[doc = "Bit 28 - Lowest priority flag for mailbox 2"] | ||
| 404 | #[inline(always)] | ||
| 405 | pub fn tme2(&self) -> TME2_R { | ||
| 406 | TME2_R::new(((self.bits >> 28) & 0x01) != 0) | ||
| 407 | } | ||
| 408 | #[doc = "Bit 27 - Lowest priority flag for mailbox 1"] | ||
| 409 | #[inline(always)] | ||
| 410 | pub fn tme1(&self) -> TME1_R { | ||
| 411 | TME1_R::new(((self.bits >> 27) & 0x01) != 0) | ||
| 412 | } | ||
| 413 | #[doc = "Bit 26 - Lowest priority flag for mailbox 0"] | ||
| 414 | #[inline(always)] | ||
| 415 | pub fn tme0(&self) -> TME0_R { | ||
| 416 | TME0_R::new(((self.bits >> 26) & 0x01) != 0) | ||
| 417 | } | ||
| 418 | #[doc = "Bits 24:25 - CODE"] | ||
| 419 | #[inline(always)] | ||
| 420 | pub fn code(&self) -> CODE_R { | ||
| 421 | CODE_R::new(((self.bits >> 24) & 0x03) as u8) | ||
| 422 | } | ||
| 423 | #[doc = "Bit 23 - ABRQ2"] | ||
| 424 | #[inline(always)] | ||
| 425 | pub fn abrq2(&self) -> ABRQ2_R { | ||
| 426 | ABRQ2_R::new(((self.bits >> 23) & 0x01) != 0) | ||
| 427 | } | ||
| 428 | #[doc = "Bit 19 - TERR2"] | ||
| 429 | #[inline(always)] | ||
| 430 | pub fn terr2(&self) -> TERR2_R { | ||
| 431 | TERR2_R::new(((self.bits >> 19) & 0x01) != 0) | ||
| 432 | } | ||
| 433 | #[doc = "Bit 18 - ALST2"] | ||
| 434 | #[inline(always)] | ||
| 435 | pub fn alst2(&self) -> ALST2_R { | ||
| 436 | ALST2_R::new(((self.bits >> 18) & 0x01) != 0) | ||
| 437 | } | ||
| 438 | #[doc = "Bit 17 - TXOK2"] | ||
| 439 | #[inline(always)] | ||
| 440 | pub fn txok2(&self) -> TXOK2_R { | ||
| 441 | TXOK2_R::new(((self.bits >> 17) & 0x01) != 0) | ||
| 442 | } | ||
| 443 | #[doc = "Bit 16 - RQCP2"] | ||
| 444 | #[inline(always)] | ||
| 445 | pub fn rqcp2(&self) -> RQCP2_R { | ||
| 446 | RQCP2_R::new(((self.bits >> 16) & 0x01) != 0) | ||
| 447 | } | ||
| 448 | #[doc = "Bit 15 - ABRQ1"] | ||
| 449 | #[inline(always)] | ||
| 450 | pub fn abrq1(&self) -> ABRQ1_R { | ||
| 451 | ABRQ1_R::new(((self.bits >> 15) & 0x01) != 0) | ||
| 452 | } | ||
| 453 | #[doc = "Bit 11 - TERR1"] | ||
| 454 | #[inline(always)] | ||
| 455 | pub fn terr1(&self) -> TERR1_R { | ||
| 456 | TERR1_R::new(((self.bits >> 11) & 0x01) != 0) | ||
| 457 | } | ||
| 458 | #[doc = "Bit 10 - ALST1"] | ||
| 459 | #[inline(always)] | ||
| 460 | pub fn alst1(&self) -> ALST1_R { | ||
| 461 | ALST1_R::new(((self.bits >> 10) & 0x01) != 0) | ||
| 462 | } | ||
| 463 | #[doc = "Bit 9 - TXOK1"] | ||
| 464 | #[inline(always)] | ||
| 465 | pub fn txok1(&self) -> TXOK1_R { | ||
| 466 | TXOK1_R::new(((self.bits >> 9) & 0x01) != 0) | ||
| 467 | } | ||
| 468 | #[doc = "Bit 8 - RQCP1"] | ||
| 469 | #[inline(always)] | ||
| 470 | pub fn rqcp1(&self) -> RQCP1_R { | ||
| 471 | RQCP1_R::new(((self.bits >> 8) & 0x01) != 0) | ||
| 472 | } | ||
| 473 | #[doc = "Bit 7 - ABRQ0"] | ||
| 474 | #[inline(always)] | ||
| 475 | pub fn abrq0(&self) -> ABRQ0_R { | ||
| 476 | ABRQ0_R::new(((self.bits >> 7) & 0x01) != 0) | ||
| 477 | } | ||
| 478 | #[doc = "Bit 3 - TERR0"] | ||
| 479 | #[inline(always)] | ||
| 480 | pub fn terr0(&self) -> TERR0_R { | ||
| 481 | TERR0_R::new(((self.bits >> 3) & 0x01) != 0) | ||
| 482 | } | ||
| 483 | #[doc = "Bit 2 - ALST0"] | ||
| 484 | #[inline(always)] | ||
| 485 | pub fn alst0(&self) -> ALST0_R { | ||
| 486 | ALST0_R::new(((self.bits >> 2) & 0x01) != 0) | ||
| 487 | } | ||
| 488 | #[doc = "Bit 1 - TXOK0"] | ||
| 489 | #[inline(always)] | ||
| 490 | pub fn txok0(&self) -> TXOK0_R { | ||
| 491 | TXOK0_R::new(((self.bits >> 1) & 0x01) != 0) | ||
| 492 | } | ||
| 493 | #[doc = "Bit 0 - RQCP0"] | ||
| 494 | #[inline(always)] | ||
| 495 | pub fn rqcp0(&self) -> RQCP0_R { | ||
| 496 | RQCP0_R::new((self.bits & 0x01) != 0) | ||
| 497 | } | ||
| 498 | } | ||
| 499 | impl W { | ||
| 500 | #[doc = "Bit 23 - ABRQ2"] | ||
| 501 | #[inline(always)] | ||
| 502 | pub fn abrq2(&mut self) -> ABRQ2_W { | ||
| 503 | ABRQ2_W { w: self } | ||
| 504 | } | ||
| 505 | #[doc = "Bit 19 - TERR2"] | ||
| 506 | #[inline(always)] | ||
| 507 | pub fn terr2(&mut self) -> TERR2_W { | ||
| 508 | TERR2_W { w: self } | ||
| 509 | } | ||
| 510 | #[doc = "Bit 18 - ALST2"] | ||
| 511 | #[inline(always)] | ||
| 512 | pub fn alst2(&mut self) -> ALST2_W { | ||
| 513 | ALST2_W { w: self } | ||
| 514 | } | ||
| 515 | #[doc = "Bit 17 - TXOK2"] | ||
| 516 | #[inline(always)] | ||
| 517 | pub fn txok2(&mut self) -> TXOK2_W { | ||
| 518 | TXOK2_W { w: self } | ||
| 519 | } | ||
| 520 | #[doc = "Bit 16 - RQCP2"] | ||
| 521 | #[inline(always)] | ||
| 522 | pub fn rqcp2(&mut self) -> RQCP2_W { | ||
| 523 | RQCP2_W { w: self } | ||
| 524 | } | ||
| 525 | #[doc = "Bit 15 - ABRQ1"] | ||
| 526 | #[inline(always)] | ||
| 527 | pub fn abrq1(&mut self) -> ABRQ1_W { | ||
| 528 | ABRQ1_W { w: self } | ||
| 529 | } | ||
| 530 | #[doc = "Bit 11 - TERR1"] | ||
| 531 | #[inline(always)] | ||
| 532 | pub fn terr1(&mut self) -> TERR1_W { | ||
| 533 | TERR1_W { w: self } | ||
| 534 | } | ||
| 535 | #[doc = "Bit 10 - ALST1"] | ||
| 536 | #[inline(always)] | ||
| 537 | pub fn alst1(&mut self) -> ALST1_W { | ||
| 538 | ALST1_W { w: self } | ||
| 539 | } | ||
| 540 | #[doc = "Bit 9 - TXOK1"] | ||
| 541 | #[inline(always)] | ||
| 542 | pub fn txok1(&mut self) -> TXOK1_W { | ||
| 543 | TXOK1_W { w: self } | ||
| 544 | } | ||
| 545 | #[doc = "Bit 8 - RQCP1"] | ||
| 546 | #[inline(always)] | ||
| 547 | pub fn rqcp1(&mut self) -> RQCP1_W { | ||
| 548 | RQCP1_W { w: self } | ||
| 549 | } | ||
| 550 | #[doc = "Bit 7 - ABRQ0"] | ||
| 551 | #[inline(always)] | ||
| 552 | pub fn abrq0(&mut self) -> ABRQ0_W { | ||
| 553 | ABRQ0_W { w: self } | ||
| 554 | } | ||
| 555 | #[doc = "Bit 3 - TERR0"] | ||
| 556 | #[inline(always)] | ||
| 557 | pub fn terr0(&mut self) -> TERR0_W { | ||
| 558 | TERR0_W { w: self } | ||
| 559 | } | ||
| 560 | #[doc = "Bit 2 - ALST0"] | ||
| 561 | #[inline(always)] | ||
| 562 | pub fn alst0(&mut self) -> ALST0_W { | ||
| 563 | ALST0_W { w: self } | ||
| 564 | } | ||
| 565 | #[doc = "Bit 1 - TXOK0"] | ||
| 566 | #[inline(always)] | ||
| 567 | pub fn txok0(&mut self) -> TXOK0_W { | ||
| 568 | TXOK0_W { w: self } | ||
| 569 | } | ||
| 570 | #[doc = "Bit 0 - RQCP0"] | ||
| 571 | #[inline(always)] | ||
| 572 | pub fn rqcp0(&mut self) -> RQCP0_W { | ||
| 573 | RQCP0_W { w: self } | ||
| 574 | } | ||
| 575 | } | ||
diff --git a/embassy-stm32/src/can/bx/pac/can/tx.rs b/embassy-stm32/src/can/bx/pac/can/tx.rs new file mode 100644 index 000000000..7b926bd14 --- /dev/null +++ b/embassy-stm32/src/can/bx/pac/can/tx.rs | |||
| @@ -0,0 +1,44 @@ | |||
| 1 | #[doc = "CAN_TI0R\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [tir](tir) module"] | ||
| 2 | pub type TIR = crate::Reg<u32, _TIR>; | ||
| 3 | #[allow(missing_docs)] | ||
| 4 | #[doc(hidden)] | ||
| 5 | pub struct _TIR; | ||
| 6 | #[doc = "`read()` method returns [tir::R](tir::R) reader structure"] | ||
| 7 | impl crate::Readable for TIR {} | ||
| 8 | #[doc = "`write(|w| ..)` method takes [tir::W](tir::W) writer structure"] | ||
| 9 | impl crate::Writable for TIR {} | ||
| 10 | #[doc = "CAN_TI0R"] | ||
| 11 | pub mod tir; | ||
| 12 | #[doc = "CAN_TDT0R\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [tdtr](tdtr) module"] | ||
| 13 | pub type TDTR = crate::Reg<u32, _TDTR>; | ||
| 14 | #[allow(missing_docs)] | ||
| 15 | #[doc(hidden)] | ||
| 16 | pub struct _TDTR; | ||
| 17 | #[doc = "`read()` method returns [tdtr::R](tdtr::R) reader structure"] | ||
| 18 | impl crate::Readable for TDTR {} | ||
| 19 | #[doc = "`write(|w| ..)` method takes [tdtr::W](tdtr::W) writer structure"] | ||
| 20 | impl crate::Writable for TDTR {} | ||
| 21 | #[doc = "CAN_TDT0R"] | ||
| 22 | pub mod tdtr; | ||
| 23 | #[doc = "CAN_TDL0R\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [tdlr](tdlr) module"] | ||
| 24 | pub type TDLR = crate::Reg<u32, _TDLR>; | ||
| 25 | #[allow(missing_docs)] | ||
| 26 | #[doc(hidden)] | ||
| 27 | pub struct _TDLR; | ||
| 28 | #[doc = "`read()` method returns [tdlr::R](tdlr::R) reader structure"] | ||
| 29 | impl crate::Readable for TDLR {} | ||
| 30 | #[doc = "`write(|w| ..)` method takes [tdlr::W](tdlr::W) writer structure"] | ||
| 31 | impl crate::Writable for TDLR {} | ||
| 32 | #[doc = "CAN_TDL0R"] | ||
| 33 | pub mod tdlr; | ||
| 34 | #[doc = "CAN_TDH0R\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [tdhr](tdhr) module"] | ||
| 35 | pub type TDHR = crate::Reg<u32, _TDHR>; | ||
| 36 | #[allow(missing_docs)] | ||
| 37 | #[doc(hidden)] | ||
| 38 | pub struct _TDHR; | ||
| 39 | #[doc = "`read()` method returns [tdhr::R](tdhr::R) reader structure"] | ||
| 40 | impl crate::Readable for TDHR {} | ||
| 41 | #[doc = "`write(|w| ..)` method takes [tdhr::W](tdhr::W) writer structure"] | ||
| 42 | impl crate::Writable for TDHR {} | ||
| 43 | #[doc = "CAN_TDH0R"] | ||
| 44 | pub mod tdhr; | ||
diff --git a/embassy-stm32/src/can/bx/pac/can/tx/tdhr.rs b/embassy-stm32/src/can/bx/pac/can/tx/tdhr.rs new file mode 100644 index 000000000..240fa94f0 --- /dev/null +++ b/embassy-stm32/src/can/bx/pac/can/tx/tdhr.rs | |||
| @@ -0,0 +1,112 @@ | |||
| 1 | #[doc = "Reader of register TDHR"] | ||
| 2 | pub type R = crate::R<u32, super::TDHR>; | ||
| 3 | #[doc = "Writer for register TDHR"] | ||
| 4 | pub type W = crate::W<u32, super::TDHR>; | ||
| 5 | #[doc = "Register TDHR `reset()`'s with value 0"] | ||
| 6 | impl crate::ResetValue for super::TDHR { | ||
| 7 | type Type = u32; | ||
| 8 | #[inline(always)] | ||
| 9 | fn reset_value() -> Self::Type { | ||
| 10 | 0 | ||
| 11 | } | ||
| 12 | } | ||
| 13 | #[doc = "Reader of field `DATA7`"] | ||
| 14 | pub type DATA7_R = crate::R<u8, u8>; | ||
| 15 | #[doc = "Write proxy for field `DATA7`"] | ||
| 16 | pub struct DATA7_W<'a> { | ||
| 17 | w: &'a mut W, | ||
| 18 | } | ||
| 19 | impl<'a> DATA7_W<'a> { | ||
| 20 | #[doc = r"Writes raw bits to the field"] | ||
| 21 | #[inline(always)] | ||
| 22 | pub unsafe fn bits(self, value: u8) -> &'a mut W { | ||
| 23 | self.w.bits = (self.w.bits & !(0xff << 24)) | (((value as u32) & 0xff) << 24); | ||
| 24 | self.w | ||
| 25 | } | ||
| 26 | } | ||
| 27 | #[doc = "Reader of field `DATA6`"] | ||
| 28 | pub type DATA6_R = crate::R<u8, u8>; | ||
| 29 | #[doc = "Write proxy for field `DATA6`"] | ||
| 30 | pub struct DATA6_W<'a> { | ||
| 31 | w: &'a mut W, | ||
| 32 | } | ||
| 33 | impl<'a> DATA6_W<'a> { | ||
| 34 | #[doc = r"Writes raw bits to the field"] | ||
| 35 | #[inline(always)] | ||
| 36 | pub unsafe fn bits(self, value: u8) -> &'a mut W { | ||
| 37 | self.w.bits = (self.w.bits & !(0xff << 16)) | (((value as u32) & 0xff) << 16); | ||
| 38 | self.w | ||
| 39 | } | ||
| 40 | } | ||
| 41 | #[doc = "Reader of field `DATA5`"] | ||
| 42 | pub type DATA5_R = crate::R<u8, u8>; | ||
| 43 | #[doc = "Write proxy for field `DATA5`"] | ||
| 44 | pub struct DATA5_W<'a> { | ||
| 45 | w: &'a mut W, | ||
| 46 | } | ||
| 47 | impl<'a> DATA5_W<'a> { | ||
| 48 | #[doc = r"Writes raw bits to the field"] | ||
| 49 | #[inline(always)] | ||
| 50 | pub unsafe fn bits(self, value: u8) -> &'a mut W { | ||
| 51 | self.w.bits = (self.w.bits & !(0xff << 8)) | (((value as u32) & 0xff) << 8); | ||
| 52 | self.w | ||
| 53 | } | ||
| 54 | } | ||
| 55 | #[doc = "Reader of field `DATA4`"] | ||
| 56 | pub type DATA4_R = crate::R<u8, u8>; | ||
| 57 | #[doc = "Write proxy for field `DATA4`"] | ||
| 58 | pub struct DATA4_W<'a> { | ||
| 59 | w: &'a mut W, | ||
| 60 | } | ||
| 61 | impl<'a> DATA4_W<'a> { | ||
| 62 | #[doc = r"Writes raw bits to the field"] | ||
| 63 | #[inline(always)] | ||
| 64 | pub unsafe fn bits(self, value: u8) -> &'a mut W { | ||
| 65 | self.w.bits = (self.w.bits & !0xff) | ((value as u32) & 0xff); | ||
| 66 | self.w | ||
| 67 | } | ||
| 68 | } | ||
| 69 | impl R { | ||
| 70 | #[doc = "Bits 24:31 - DATA7"] | ||
| 71 | #[inline(always)] | ||
| 72 | pub fn data7(&self) -> DATA7_R { | ||
| 73 | DATA7_R::new(((self.bits >> 24) & 0xff) as u8) | ||
| 74 | } | ||
| 75 | #[doc = "Bits 16:23 - DATA6"] | ||
| 76 | #[inline(always)] | ||
| 77 | pub fn data6(&self) -> DATA6_R { | ||
| 78 | DATA6_R::new(((self.bits >> 16) & 0xff) as u8) | ||
| 79 | } | ||
| 80 | #[doc = "Bits 8:15 - DATA5"] | ||
| 81 | #[inline(always)] | ||
| 82 | pub fn data5(&self) -> DATA5_R { | ||
| 83 | DATA5_R::new(((self.bits >> 8) & 0xff) as u8) | ||
| 84 | } | ||
| 85 | #[doc = "Bits 0:7 - DATA4"] | ||
| 86 | #[inline(always)] | ||
| 87 | pub fn data4(&self) -> DATA4_R { | ||
| 88 | DATA4_R::new((self.bits & 0xff) as u8) | ||
| 89 | } | ||
| 90 | } | ||
| 91 | impl W { | ||
| 92 | #[doc = "Bits 24:31 - DATA7"] | ||
| 93 | #[inline(always)] | ||
| 94 | pub fn data7(&mut self) -> DATA7_W { | ||
| 95 | DATA7_W { w: self } | ||
| 96 | } | ||
| 97 | #[doc = "Bits 16:23 - DATA6"] | ||
| 98 | #[inline(always)] | ||
| 99 | pub fn data6(&mut self) -> DATA6_W { | ||
| 100 | DATA6_W { w: self } | ||
| 101 | } | ||
| 102 | #[doc = "Bits 8:15 - DATA5"] | ||
| 103 | #[inline(always)] | ||
| 104 | pub fn data5(&mut self) -> DATA5_W { | ||
| 105 | DATA5_W { w: self } | ||
| 106 | } | ||
| 107 | #[doc = "Bits 0:7 - DATA4"] | ||
| 108 | #[inline(always)] | ||
| 109 | pub fn data4(&mut self) -> DATA4_W { | ||
| 110 | DATA4_W { w: self } | ||
| 111 | } | ||
| 112 | } | ||
diff --git a/embassy-stm32/src/can/bx/pac/can/tx/tdlr.rs b/embassy-stm32/src/can/bx/pac/can/tx/tdlr.rs new file mode 100644 index 000000000..c4c855d46 --- /dev/null +++ b/embassy-stm32/src/can/bx/pac/can/tx/tdlr.rs | |||
| @@ -0,0 +1,112 @@ | |||
| 1 | #[doc = "Reader of register TDLR"] | ||
| 2 | pub type R = crate::R<u32, super::TDLR>; | ||
| 3 | #[doc = "Writer for register TDLR"] | ||
| 4 | pub type W = crate::W<u32, super::TDLR>; | ||
| 5 | #[doc = "Register TDLR `reset()`'s with value 0"] | ||
| 6 | impl crate::ResetValue for super::TDLR { | ||
| 7 | type Type = u32; | ||
| 8 | #[inline(always)] | ||
| 9 | fn reset_value() -> Self::Type { | ||
| 10 | 0 | ||
| 11 | } | ||
| 12 | } | ||
| 13 | #[doc = "Reader of field `DATA3`"] | ||
| 14 | pub type DATA3_R = crate::R<u8, u8>; | ||
| 15 | #[doc = "Write proxy for field `DATA3`"] | ||
| 16 | pub struct DATA3_W<'a> { | ||
| 17 | w: &'a mut W, | ||
| 18 | } | ||
| 19 | impl<'a> DATA3_W<'a> { | ||
| 20 | #[doc = r"Writes raw bits to the field"] | ||
| 21 | #[inline(always)] | ||
| 22 | pub unsafe fn bits(self, value: u8) -> &'a mut W { | ||
| 23 | self.w.bits = (self.w.bits & !(0xff << 24)) | (((value as u32) & 0xff) << 24); | ||
| 24 | self.w | ||
| 25 | } | ||
| 26 | } | ||
| 27 | #[doc = "Reader of field `DATA2`"] | ||
| 28 | pub type DATA2_R = crate::R<u8, u8>; | ||
| 29 | #[doc = "Write proxy for field `DATA2`"] | ||
| 30 | pub struct DATA2_W<'a> { | ||
| 31 | w: &'a mut W, | ||
| 32 | } | ||
| 33 | impl<'a> DATA2_W<'a> { | ||
| 34 | #[doc = r"Writes raw bits to the field"] | ||
| 35 | #[inline(always)] | ||
| 36 | pub unsafe fn bits(self, value: u8) -> &'a mut W { | ||
| 37 | self.w.bits = (self.w.bits & !(0xff << 16)) | (((value as u32) & 0xff) << 16); | ||
| 38 | self.w | ||
| 39 | } | ||
| 40 | } | ||
| 41 | #[doc = "Reader of field `DATA1`"] | ||
| 42 | pub type DATA1_R = crate::R<u8, u8>; | ||
| 43 | #[doc = "Write proxy for field `DATA1`"] | ||
| 44 | pub struct DATA1_W<'a> { | ||
| 45 | w: &'a mut W, | ||
| 46 | } | ||
| 47 | impl<'a> DATA1_W<'a> { | ||
| 48 | #[doc = r"Writes raw bits to the field"] | ||
| 49 | #[inline(always)] | ||
| 50 | pub unsafe fn bits(self, value: u8) -> &'a mut W { | ||
| 51 | self.w.bits = (self.w.bits & !(0xff << 8)) | (((value as u32) & 0xff) << 8); | ||
| 52 | self.w | ||
| 53 | } | ||
| 54 | } | ||
| 55 | #[doc = "Reader of field `DATA0`"] | ||
| 56 | pub type DATA0_R = crate::R<u8, u8>; | ||
| 57 | #[doc = "Write proxy for field `DATA0`"] | ||
| 58 | pub struct DATA0_W<'a> { | ||
| 59 | w: &'a mut W, | ||
| 60 | } | ||
| 61 | impl<'a> DATA0_W<'a> { | ||
| 62 | #[doc = r"Writes raw bits to the field"] | ||
| 63 | #[inline(always)] | ||
| 64 | pub unsafe fn bits(self, value: u8) -> &'a mut W { | ||
| 65 | self.w.bits = (self.w.bits & !0xff) | ((value as u32) & 0xff); | ||
| 66 | self.w | ||
| 67 | } | ||
| 68 | } | ||
| 69 | impl R { | ||
| 70 | #[doc = "Bits 24:31 - DATA3"] | ||
| 71 | #[inline(always)] | ||
| 72 | pub fn data3(&self) -> DATA3_R { | ||
| 73 | DATA3_R::new(((self.bits >> 24) & 0xff) as u8) | ||
| 74 | } | ||
| 75 | #[doc = "Bits 16:23 - DATA2"] | ||
| 76 | #[inline(always)] | ||
| 77 | pub fn data2(&self) -> DATA2_R { | ||
| 78 | DATA2_R::new(((self.bits >> 16) & 0xff) as u8) | ||
| 79 | } | ||
| 80 | #[doc = "Bits 8:15 - DATA1"] | ||
| 81 | #[inline(always)] | ||
| 82 | pub fn data1(&self) -> DATA1_R { | ||
| 83 | DATA1_R::new(((self.bits >> 8) & 0xff) as u8) | ||
| 84 | } | ||
| 85 | #[doc = "Bits 0:7 - DATA0"] | ||
| 86 | #[inline(always)] | ||
| 87 | pub fn data0(&self) -> DATA0_R { | ||
| 88 | DATA0_R::new((self.bits & 0xff) as u8) | ||
| 89 | } | ||
| 90 | } | ||
| 91 | impl W { | ||
| 92 | #[doc = "Bits 24:31 - DATA3"] | ||
| 93 | #[inline(always)] | ||
| 94 | pub fn data3(&mut self) -> DATA3_W { | ||
| 95 | DATA3_W { w: self } | ||
| 96 | } | ||
| 97 | #[doc = "Bits 16:23 - DATA2"] | ||
| 98 | #[inline(always)] | ||
| 99 | pub fn data2(&mut self) -> DATA2_W { | ||
| 100 | DATA2_W { w: self } | ||
| 101 | } | ||
| 102 | #[doc = "Bits 8:15 - DATA1"] | ||
| 103 | #[inline(always)] | ||
| 104 | pub fn data1(&mut self) -> DATA1_W { | ||
| 105 | DATA1_W { w: self } | ||
| 106 | } | ||
| 107 | #[doc = "Bits 0:7 - DATA0"] | ||
| 108 | #[inline(always)] | ||
| 109 | pub fn data0(&mut self) -> DATA0_W { | ||
| 110 | DATA0_W { w: self } | ||
| 111 | } | ||
| 112 | } | ||
diff --git a/embassy-stm32/src/can/bx/pac/can/tx/tdtr.rs b/embassy-stm32/src/can/bx/pac/can/tx/tdtr.rs new file mode 100644 index 000000000..310bca497 --- /dev/null +++ b/embassy-stm32/src/can/bx/pac/can/tx/tdtr.rs | |||
| @@ -0,0 +1,98 @@ | |||
| 1 | #[doc = "Reader of register TDTR"] | ||
| 2 | pub type R = crate::R<u32, super::TDTR>; | ||
| 3 | #[doc = "Writer for register TDTR"] | ||
| 4 | pub type W = crate::W<u32, super::TDTR>; | ||
| 5 | #[doc = "Register TDTR `reset()`'s with value 0"] | ||
| 6 | impl crate::ResetValue for super::TDTR { | ||
| 7 | type Type = u32; | ||
| 8 | #[inline(always)] | ||
| 9 | fn reset_value() -> Self::Type { | ||
| 10 | 0 | ||
| 11 | } | ||
| 12 | } | ||
| 13 | #[doc = "Reader of field `TIME`"] | ||
| 14 | pub type TIME_R = crate::R<u16, u16>; | ||
| 15 | #[doc = "Write proxy for field `TIME`"] | ||
| 16 | pub struct TIME_W<'a> { | ||
| 17 | w: &'a mut W, | ||
| 18 | } | ||
| 19 | impl<'a> TIME_W<'a> { | ||
| 20 | #[doc = r"Writes raw bits to the field"] | ||
| 21 | #[inline(always)] | ||
| 22 | pub unsafe fn bits(self, value: u16) -> &'a mut W { | ||
| 23 | self.w.bits = (self.w.bits & !(0xffff << 16)) | (((value as u32) & 0xffff) << 16); | ||
| 24 | self.w | ||
| 25 | } | ||
| 26 | } | ||
| 27 | #[doc = "Reader of field `TGT`"] | ||
| 28 | pub type TGT_R = crate::R<bool, bool>; | ||
| 29 | #[doc = "Write proxy for field `TGT`"] | ||
| 30 | pub struct TGT_W<'a> { | ||
| 31 | w: &'a mut W, | ||
| 32 | } | ||
| 33 | impl<'a> TGT_W<'a> { | ||
| 34 | #[doc = r"Sets the field bit"] | ||
| 35 | #[inline(always)] | ||
| 36 | pub fn set_bit(self) -> &'a mut W { | ||
| 37 | self.bit(true) | ||
| 38 | } | ||
| 39 | #[doc = r"Clears the field bit"] | ||
| 40 | #[inline(always)] | ||
| 41 | pub fn clear_bit(self) -> &'a mut W { | ||
| 42 | self.bit(false) | ||
| 43 | } | ||
| 44 | #[doc = r"Writes raw bits to the field"] | ||
| 45 | #[inline(always)] | ||
| 46 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 47 | self.w.bits = (self.w.bits & !(0x01 << 8)) | (((value as u32) & 0x01) << 8); | ||
| 48 | self.w | ||
| 49 | } | ||
| 50 | } | ||
| 51 | #[doc = "Reader of field `DLC`"] | ||
| 52 | pub type DLC_R = crate::R<u8, u8>; | ||
| 53 | #[doc = "Write proxy for field `DLC`"] | ||
| 54 | pub struct DLC_W<'a> { | ||
| 55 | w: &'a mut W, | ||
| 56 | } | ||
| 57 | impl<'a> DLC_W<'a> { | ||
| 58 | #[doc = r"Writes raw bits to the field"] | ||
| 59 | #[inline(always)] | ||
| 60 | pub unsafe fn bits(self, value: u8) -> &'a mut W { | ||
| 61 | self.w.bits = (self.w.bits & !0x0f) | ((value as u32) & 0x0f); | ||
| 62 | self.w | ||
| 63 | } | ||
| 64 | } | ||
| 65 | impl R { | ||
| 66 | #[doc = "Bits 16:31 - TIME"] | ||
| 67 | #[inline(always)] | ||
| 68 | pub fn time(&self) -> TIME_R { | ||
| 69 | TIME_R::new(((self.bits >> 16) & 0xffff) as u16) | ||
| 70 | } | ||
| 71 | #[doc = "Bit 8 - TGT"] | ||
| 72 | #[inline(always)] | ||
| 73 | pub fn tgt(&self) -> TGT_R { | ||
| 74 | TGT_R::new(((self.bits >> 8) & 0x01) != 0) | ||
| 75 | } | ||
| 76 | #[doc = "Bits 0:3 - DLC"] | ||
| 77 | #[inline(always)] | ||
| 78 | pub fn dlc(&self) -> DLC_R { | ||
| 79 | DLC_R::new((self.bits & 0x0f) as u8) | ||
| 80 | } | ||
| 81 | } | ||
| 82 | impl W { | ||
| 83 | #[doc = "Bits 16:31 - TIME"] | ||
| 84 | #[inline(always)] | ||
| 85 | pub fn time(&mut self) -> TIME_W { | ||
| 86 | TIME_W { w: self } | ||
| 87 | } | ||
| 88 | #[doc = "Bit 8 - TGT"] | ||
| 89 | #[inline(always)] | ||
| 90 | pub fn tgt(&mut self) -> TGT_W { | ||
| 91 | TGT_W { w: self } | ||
| 92 | } | ||
| 93 | #[doc = "Bits 0:3 - DLC"] | ||
| 94 | #[inline(always)] | ||
| 95 | pub fn dlc(&mut self) -> DLC_W { | ||
| 96 | DLC_W { w: self } | ||
| 97 | } | ||
| 98 | } | ||
diff --git a/embassy-stm32/src/can/bx/pac/can/tx/tir.rs b/embassy-stm32/src/can/bx/pac/can/tx/tir.rs new file mode 100644 index 000000000..12bc3d1f3 --- /dev/null +++ b/embassy-stm32/src/can/bx/pac/can/tx/tir.rs | |||
| @@ -0,0 +1,268 @@ | |||
| 1 | #[doc = "Reader of register TIR"] | ||
| 2 | pub type R = crate::R<u32, super::TIR>; | ||
| 3 | #[doc = "Writer for register TIR"] | ||
| 4 | pub type W = crate::W<u32, super::TIR>; | ||
| 5 | #[doc = "Register TIR `reset()`'s with value 0"] | ||
| 6 | impl crate::ResetValue for super::TIR { | ||
| 7 | type Type = u32; | ||
| 8 | #[inline(always)] | ||
| 9 | fn reset_value() -> Self::Type { | ||
| 10 | 0 | ||
| 11 | } | ||
| 12 | } | ||
| 13 | #[doc = "Reader of field `STID`"] | ||
| 14 | pub type STID_R = crate::R<u16, u16>; | ||
| 15 | #[doc = "Write proxy for field `STID`"] | ||
| 16 | pub struct STID_W<'a> { | ||
| 17 | w: &'a mut W, | ||
| 18 | } | ||
| 19 | impl<'a> STID_W<'a> { | ||
| 20 | #[doc = r"Writes raw bits to the field"] | ||
| 21 | #[inline(always)] | ||
| 22 | pub unsafe fn bits(self, value: u16) -> &'a mut W { | ||
| 23 | self.w.bits = (self.w.bits & !(0x07ff << 21)) | (((value as u32) & 0x07ff) << 21); | ||
| 24 | self.w | ||
| 25 | } | ||
| 26 | } | ||
| 27 | #[doc = "Reader of field `EXID`"] | ||
| 28 | pub type EXID_R = crate::R<u32, u32>; | ||
| 29 | #[doc = "Write proxy for field `EXID`"] | ||
| 30 | pub struct EXID_W<'a> { | ||
| 31 | w: &'a mut W, | ||
| 32 | } | ||
| 33 | impl<'a> EXID_W<'a> { | ||
| 34 | #[doc = r"Writes raw bits to the field"] | ||
| 35 | #[inline(always)] | ||
| 36 | pub unsafe fn bits(self, value: u32) -> &'a mut W { | ||
| 37 | self.w.bits = (self.w.bits & !(0x0003_ffff << 3)) | (((value as u32) & 0x0003_ffff) << 3); | ||
| 38 | self.w | ||
| 39 | } | ||
| 40 | } | ||
| 41 | #[doc = "IDE\n\nValue on reset: 0"] | ||
| 42 | #[derive(Clone, Copy, Debug, PartialEq)] | ||
| 43 | pub enum IDE_A { | ||
| 44 | #[doc = "0: Standard identifier"] | ||
| 45 | STANDARD = 0, | ||
| 46 | #[doc = "1: Extended identifier"] | ||
| 47 | EXTENDED = 1, | ||
| 48 | } | ||
| 49 | impl From<IDE_A> for bool { | ||
| 50 | #[inline(always)] | ||
| 51 | fn from(variant: IDE_A) -> Self { | ||
| 52 | variant as u8 != 0 | ||
| 53 | } | ||
| 54 | } | ||
| 55 | #[doc = "Reader of field `IDE`"] | ||
| 56 | pub type IDE_R = crate::R<bool, IDE_A>; | ||
| 57 | impl IDE_R { | ||
| 58 | #[doc = r"Get enumerated values variant"] | ||
| 59 | #[inline(always)] | ||
| 60 | pub fn variant(&self) -> IDE_A { | ||
| 61 | match self.bits { | ||
| 62 | false => IDE_A::STANDARD, | ||
| 63 | true => IDE_A::EXTENDED, | ||
| 64 | } | ||
| 65 | } | ||
| 66 | #[doc = "Checks if the value of the field is `STANDARD`"] | ||
| 67 | #[inline(always)] | ||
| 68 | pub fn is_standard(&self) -> bool { | ||
| 69 | *self == IDE_A::STANDARD | ||
| 70 | } | ||
| 71 | #[doc = "Checks if the value of the field is `EXTENDED`"] | ||
| 72 | #[inline(always)] | ||
| 73 | pub fn is_extended(&self) -> bool { | ||
| 74 | *self == IDE_A::EXTENDED | ||
| 75 | } | ||
| 76 | } | ||
| 77 | #[doc = "Write proxy for field `IDE`"] | ||
| 78 | pub struct IDE_W<'a> { | ||
| 79 | w: &'a mut W, | ||
| 80 | } | ||
| 81 | impl<'a> IDE_W<'a> { | ||
| 82 | #[doc = r"Writes `variant` to the field"] | ||
| 83 | #[inline(always)] | ||
| 84 | pub fn variant(self, variant: IDE_A) -> &'a mut W { | ||
| 85 | { | ||
| 86 | self.bit(variant.into()) | ||
| 87 | } | ||
| 88 | } | ||
| 89 | #[doc = "Standard identifier"] | ||
| 90 | #[inline(always)] | ||
| 91 | pub fn standard(self) -> &'a mut W { | ||
| 92 | self.variant(IDE_A::STANDARD) | ||
| 93 | } | ||
| 94 | #[doc = "Extended identifier"] | ||
| 95 | #[inline(always)] | ||
| 96 | pub fn extended(self) -> &'a mut W { | ||
| 97 | self.variant(IDE_A::EXTENDED) | ||
| 98 | } | ||
| 99 | #[doc = r"Sets the field bit"] | ||
| 100 | #[inline(always)] | ||
| 101 | pub fn set_bit(self) -> &'a mut W { | ||
| 102 | self.bit(true) | ||
| 103 | } | ||
| 104 | #[doc = r"Clears the field bit"] | ||
| 105 | #[inline(always)] | ||
| 106 | pub fn clear_bit(self) -> &'a mut W { | ||
| 107 | self.bit(false) | ||
| 108 | } | ||
| 109 | #[doc = r"Writes raw bits to the field"] | ||
| 110 | #[inline(always)] | ||
| 111 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 112 | self.w.bits = (self.w.bits & !(0x01 << 2)) | (((value as u32) & 0x01) << 2); | ||
| 113 | self.w | ||
| 114 | } | ||
| 115 | } | ||
| 116 | #[doc = "RTR\n\nValue on reset: 0"] | ||
| 117 | #[derive(Clone, Copy, Debug, PartialEq)] | ||
| 118 | pub enum RTR_A { | ||
| 119 | #[doc = "0: Data frame"] | ||
| 120 | DATA = 0, | ||
| 121 | #[doc = "1: Remote frame"] | ||
| 122 | REMOTE = 1, | ||
| 123 | } | ||
| 124 | impl From<RTR_A> for bool { | ||
| 125 | #[inline(always)] | ||
| 126 | fn from(variant: RTR_A) -> Self { | ||
| 127 | variant as u8 != 0 | ||
| 128 | } | ||
| 129 | } | ||
| 130 | #[doc = "Reader of field `RTR`"] | ||
| 131 | pub type RTR_R = crate::R<bool, RTR_A>; | ||
| 132 | impl RTR_R { | ||
| 133 | #[doc = r"Get enumerated values variant"] | ||
| 134 | #[inline(always)] | ||
| 135 | pub fn variant(&self) -> RTR_A { | ||
| 136 | match self.bits { | ||
| 137 | false => RTR_A::DATA, | ||
| 138 | true => RTR_A::REMOTE, | ||
| 139 | } | ||
| 140 | } | ||
| 141 | #[doc = "Checks if the value of the field is `DATA`"] | ||
| 142 | #[inline(always)] | ||
| 143 | pub fn is_data(&self) -> bool { | ||
| 144 | *self == RTR_A::DATA | ||
| 145 | } | ||
| 146 | #[doc = "Checks if the value of the field is `REMOTE`"] | ||
| 147 | #[inline(always)] | ||
| 148 | pub fn is_remote(&self) -> bool { | ||
| 149 | *self == RTR_A::REMOTE | ||
| 150 | } | ||
| 151 | } | ||
| 152 | #[doc = "Write proxy for field `RTR`"] | ||
| 153 | pub struct RTR_W<'a> { | ||
| 154 | w: &'a mut W, | ||
| 155 | } | ||
| 156 | impl<'a> RTR_W<'a> { | ||
| 157 | #[doc = r"Writes `variant` to the field"] | ||
| 158 | #[inline(always)] | ||
| 159 | pub fn variant(self, variant: RTR_A) -> &'a mut W { | ||
| 160 | { | ||
| 161 | self.bit(variant.into()) | ||
| 162 | } | ||
| 163 | } | ||
| 164 | #[doc = "Data frame"] | ||
| 165 | #[inline(always)] | ||
| 166 | pub fn data(self) -> &'a mut W { | ||
| 167 | self.variant(RTR_A::DATA) | ||
| 168 | } | ||
| 169 | #[doc = "Remote frame"] | ||
| 170 | #[inline(always)] | ||
| 171 | pub fn remote(self) -> &'a mut W { | ||
| 172 | self.variant(RTR_A::REMOTE) | ||
| 173 | } | ||
| 174 | #[doc = r"Sets the field bit"] | ||
| 175 | #[inline(always)] | ||
| 176 | pub fn set_bit(self) -> &'a mut W { | ||
| 177 | self.bit(true) | ||
| 178 | } | ||
| 179 | #[doc = r"Clears the field bit"] | ||
| 180 | #[inline(always)] | ||
| 181 | pub fn clear_bit(self) -> &'a mut W { | ||
| 182 | self.bit(false) | ||
| 183 | } | ||
| 184 | #[doc = r"Writes raw bits to the field"] | ||
| 185 | #[inline(always)] | ||
| 186 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 187 | self.w.bits = (self.w.bits & !(0x01 << 1)) | (((value as u32) & 0x01) << 1); | ||
| 188 | self.w | ||
| 189 | } | ||
| 190 | } | ||
| 191 | #[doc = "Reader of field `TXRQ`"] | ||
| 192 | pub type TXRQ_R = crate::R<bool, bool>; | ||
| 193 | #[doc = "Write proxy for field `TXRQ`"] | ||
| 194 | pub struct TXRQ_W<'a> { | ||
| 195 | w: &'a mut W, | ||
| 196 | } | ||
| 197 | impl<'a> TXRQ_W<'a> { | ||
| 198 | #[doc = r"Sets the field bit"] | ||
| 199 | #[inline(always)] | ||
| 200 | pub fn set_bit(self) -> &'a mut W { | ||
| 201 | self.bit(true) | ||
| 202 | } | ||
| 203 | #[doc = r"Clears the field bit"] | ||
| 204 | #[inline(always)] | ||
| 205 | pub fn clear_bit(self) -> &'a mut W { | ||
| 206 | self.bit(false) | ||
| 207 | } | ||
| 208 | #[doc = r"Writes raw bits to the field"] | ||
| 209 | #[inline(always)] | ||
| 210 | pub fn bit(self, value: bool) -> &'a mut W { | ||
| 211 | self.w.bits = (self.w.bits & !0x01) | ((value as u32) & 0x01); | ||
| 212 | self.w | ||
| 213 | } | ||
| 214 | } | ||
| 215 | impl R { | ||
| 216 | #[doc = "Bits 21:31 - STID"] | ||
| 217 | #[inline(always)] | ||
| 218 | pub fn stid(&self) -> STID_R { | ||
| 219 | STID_R::new(((self.bits >> 21) & 0x07ff) as u16) | ||
| 220 | } | ||
| 221 | #[doc = "Bits 3:20 - EXID"] | ||
| 222 | #[inline(always)] | ||
| 223 | pub fn exid(&self) -> EXID_R { | ||
| 224 | EXID_R::new(((self.bits >> 3) & 0x0003_ffff) as u32) | ||
| 225 | } | ||
| 226 | #[doc = "Bit 2 - IDE"] | ||
| 227 | #[inline(always)] | ||
| 228 | pub fn ide(&self) -> IDE_R { | ||
| 229 | IDE_R::new(((self.bits >> 2) & 0x01) != 0) | ||
| 230 | } | ||
| 231 | #[doc = "Bit 1 - RTR"] | ||
| 232 | #[inline(always)] | ||
| 233 | pub fn rtr(&self) -> RTR_R { | ||
| 234 | RTR_R::new(((self.bits >> 1) & 0x01) != 0) | ||
| 235 | } | ||
| 236 | #[doc = "Bit 0 - TXRQ"] | ||
| 237 | #[inline(always)] | ||
| 238 | pub fn txrq(&self) -> TXRQ_R { | ||
| 239 | TXRQ_R::new((self.bits & 0x01) != 0) | ||
| 240 | } | ||
| 241 | } | ||
| 242 | impl W { | ||
| 243 | #[doc = "Bits 21:31 - STID"] | ||
| 244 | #[inline(always)] | ||
| 245 | pub fn stid(&mut self) -> STID_W { | ||
| 246 | STID_W { w: self } | ||
| 247 | } | ||
| 248 | #[doc = "Bits 3:20 - EXID"] | ||
| 249 | #[inline(always)] | ||
| 250 | pub fn exid(&mut self) -> EXID_W { | ||
| 251 | EXID_W { w: self } | ||
| 252 | } | ||
| 253 | #[doc = "Bit 2 - IDE"] | ||
| 254 | #[inline(always)] | ||
| 255 | pub fn ide(&mut self) -> IDE_W { | ||
| 256 | IDE_W { w: self } | ||
| 257 | } | ||
| 258 | #[doc = "Bit 1 - RTR"] | ||
| 259 | #[inline(always)] | ||
| 260 | pub fn rtr(&mut self) -> RTR_W { | ||
| 261 | RTR_W { w: self } | ||
| 262 | } | ||
| 263 | #[doc = "Bit 0 - TXRQ"] | ||
| 264 | #[inline(always)] | ||
| 265 | pub fn txrq(&mut self) -> TXRQ_W { | ||
| 266 | TXRQ_W { w: self } | ||
| 267 | } | ||
| 268 | } | ||
diff --git a/embassy-stm32/src/can/bx/pac/generic.rs b/embassy-stm32/src/can/bx/pac/generic.rs new file mode 100644 index 000000000..749e7e204 --- /dev/null +++ b/embassy-stm32/src/can/bx/pac/generic.rs | |||
| @@ -0,0 +1,256 @@ | |||
| 1 | use core::marker; | ||
| 2 | |||
| 3 | ///This trait shows that register has `read` method | ||
| 4 | /// | ||
| 5 | ///Registers marked with `Writable` can be also `modify`'ed | ||
| 6 | pub trait Readable {} | ||
| 7 | |||
| 8 | ///This trait shows that register has `write`, `write_with_zero` and `reset` method | ||
| 9 | /// | ||
| 10 | ///Registers marked with `Readable` can be also `modify`'ed | ||
| 11 | pub trait Writable {} | ||
| 12 | |||
| 13 | ///Reset value of the register | ||
| 14 | /// | ||
| 15 | ///This value is initial value for `write` method. | ||
| 16 | ///It can be also directly writed to register by `reset` method. | ||
| 17 | pub trait ResetValue { | ||
| 18 | ///Register size | ||
| 19 | type Type; | ||
| 20 | ///Reset value of the register | ||
| 21 | fn reset_value() -> Self::Type; | ||
| 22 | } | ||
| 23 | |||
| 24 | ///This structure provides volatile access to register | ||
| 25 | pub struct Reg<U, REG> { | ||
| 26 | register: vcell::VolatileCell<U>, | ||
| 27 | _marker: marker::PhantomData<REG>, | ||
| 28 | } | ||
| 29 | |||
| 30 | unsafe impl<U: Send, REG> Send for Reg<U, REG> {} | ||
| 31 | |||
| 32 | impl<U, REG> Reg<U, REG> | ||
| 33 | where | ||
| 34 | Self: Readable, | ||
| 35 | U: Copy, | ||
| 36 | { | ||
| 37 | ///Reads the contents of `Readable` register | ||
| 38 | /// | ||
| 39 | ///You can read the contents of a register in such way: | ||
| 40 | ///```ignore | ||
| 41 | ///let bits = periph.reg.read().bits(); | ||
| 42 | ///``` | ||
| 43 | ///or get the content of a particular field of a register. | ||
| 44 | ///```ignore | ||
| 45 | ///let reader = periph.reg.read(); | ||
| 46 | ///let bits = reader.field1().bits(); | ||
| 47 | ///let flag = reader.field2().bit_is_set(); | ||
| 48 | ///``` | ||
| 49 | #[inline(always)] | ||
| 50 | pub fn read(&self) -> R<U, Self> { | ||
| 51 | R { | ||
| 52 | bits: self.register.get(), | ||
| 53 | _reg: marker::PhantomData, | ||
| 54 | } | ||
| 55 | } | ||
| 56 | } | ||
| 57 | |||
| 58 | impl<U, REG> Reg<U, REG> | ||
| 59 | where | ||
| 60 | Self: ResetValue<Type = U> + Writable, | ||
| 61 | U: Copy, | ||
| 62 | { | ||
| 63 | ///Writes the reset value to `Writable` register | ||
| 64 | /// | ||
| 65 | ///Resets the register to its initial state | ||
| 66 | #[inline(always)] | ||
| 67 | pub fn reset(&self) { | ||
| 68 | self.register.set(Self::reset_value()) | ||
| 69 | } | ||
| 70 | } | ||
| 71 | |||
| 72 | impl<U, REG> Reg<U, REG> | ||
| 73 | where | ||
| 74 | Self: ResetValue<Type = U> + Writable, | ||
| 75 | U: Copy, | ||
| 76 | { | ||
| 77 | ///Writes bits to `Writable` register | ||
| 78 | /// | ||
| 79 | ///You can write raw bits into a register: | ||
| 80 | ///```ignore | ||
| 81 | ///periph.reg.write(|w| unsafe { w.bits(rawbits) }); | ||
| 82 | ///``` | ||
| 83 | ///or write only the fields you need: | ||
| 84 | ///```ignore | ||
| 85 | ///periph.reg.write(|w| w | ||
| 86 | /// .field1().bits(newfield1bits) | ||
| 87 | /// .field2().set_bit() | ||
| 88 | /// .field3().variant(VARIANT) | ||
| 89 | ///); | ||
| 90 | ///``` | ||
| 91 | ///Other fields will have reset value. | ||
| 92 | #[inline(always)] | ||
| 93 | pub fn write<F>(&self, f: F) | ||
| 94 | where | ||
| 95 | F: FnOnce(&mut W<U, Self>) -> &mut W<U, Self>, | ||
| 96 | { | ||
| 97 | self.register.set( | ||
| 98 | f(&mut W { | ||
| 99 | bits: Self::reset_value(), | ||
| 100 | _reg: marker::PhantomData, | ||
| 101 | }) | ||
| 102 | .bits, | ||
| 103 | ); | ||
| 104 | } | ||
| 105 | } | ||
| 106 | |||
| 107 | impl<U, REG> Reg<U, REG> | ||
| 108 | where | ||
| 109 | Self: Writable, | ||
| 110 | U: Copy + Default, | ||
| 111 | { | ||
| 112 | ///Writes Zero to `Writable` register | ||
| 113 | /// | ||
| 114 | ///Similar to `write`, but unused bits will contain 0. | ||
| 115 | #[inline(always)] | ||
| 116 | pub fn write_with_zero<F>(&self, f: F) | ||
| 117 | where | ||
| 118 | F: FnOnce(&mut W<U, Self>) -> &mut W<U, Self>, | ||
| 119 | { | ||
| 120 | self.register.set( | ||
| 121 | f(&mut W { | ||
| 122 | bits: U::default(), | ||
| 123 | _reg: marker::PhantomData, | ||
| 124 | }) | ||
| 125 | .bits, | ||
| 126 | ); | ||
| 127 | } | ||
| 128 | } | ||
| 129 | |||
| 130 | impl<U, REG> Reg<U, REG> | ||
| 131 | where | ||
| 132 | Self: Readable + Writable, | ||
| 133 | U: Copy, | ||
| 134 | { | ||
| 135 | ///Modifies the contents of the register | ||
| 136 | /// | ||
| 137 | ///E.g. to do a read-modify-write sequence to change parts of a register: | ||
| 138 | ///```ignore | ||
| 139 | ///periph.reg.modify(|r, w| unsafe { w.bits( | ||
| 140 | /// r.bits() | 3 | ||
| 141 | ///) }); | ||
| 142 | ///``` | ||
| 143 | ///or | ||
| 144 | ///```ignore | ||
| 145 | ///periph.reg.modify(|_, w| w | ||
| 146 | /// .field1().bits(newfield1bits) | ||
| 147 | /// .field2().set_bit() | ||
| 148 | /// .field3().variant(VARIANT) | ||
| 149 | ///); | ||
| 150 | ///``` | ||
| 151 | ///Other fields will have value they had before call `modify`. | ||
| 152 | #[inline(always)] | ||
| 153 | pub fn modify<F>(&self, f: F) | ||
| 154 | where | ||
| 155 | for<'w> F: FnOnce(&R<U, Self>, &'w mut W<U, Self>) -> &'w mut W<U, Self>, | ||
| 156 | { | ||
| 157 | let bits = self.register.get(); | ||
| 158 | self.register.set( | ||
| 159 | f( | ||
| 160 | &R { | ||
| 161 | bits, | ||
| 162 | _reg: marker::PhantomData, | ||
| 163 | }, | ||
| 164 | &mut W { | ||
| 165 | bits, | ||
| 166 | _reg: marker::PhantomData, | ||
| 167 | }, | ||
| 168 | ) | ||
| 169 | .bits, | ||
| 170 | ); | ||
| 171 | } | ||
| 172 | } | ||
| 173 | |||
| 174 | ///Register/field reader | ||
| 175 | /// | ||
| 176 | ///Result of the [`read`](Reg::read) method of a register. | ||
| 177 | ///Also it can be used in the [`modify`](Reg::read) method | ||
| 178 | pub struct R<U, T> { | ||
| 179 | pub(crate) bits: U, | ||
| 180 | _reg: marker::PhantomData<T>, | ||
| 181 | } | ||
| 182 | |||
| 183 | impl<U, T> R<U, T> | ||
| 184 | where | ||
| 185 | U: Copy, | ||
| 186 | { | ||
| 187 | ///Create new instance of reader | ||
| 188 | #[inline(always)] | ||
| 189 | pub(crate) fn new(bits: U) -> Self { | ||
| 190 | Self { | ||
| 191 | bits, | ||
| 192 | _reg: marker::PhantomData, | ||
| 193 | } | ||
| 194 | } | ||
| 195 | ///Read raw bits from register/field | ||
| 196 | #[inline(always)] | ||
| 197 | pub fn bits(&self) -> U { | ||
| 198 | self.bits | ||
| 199 | } | ||
| 200 | } | ||
| 201 | |||
| 202 | impl<U, T, FI> PartialEq<FI> for R<U, T> | ||
| 203 | where | ||
| 204 | U: PartialEq, | ||
| 205 | FI: Copy + Into<U>, | ||
| 206 | { | ||
| 207 | #[inline(always)] | ||
| 208 | fn eq(&self, other: &FI) -> bool { | ||
| 209 | self.bits.eq(&(*other).into()) | ||
| 210 | } | ||
| 211 | } | ||
| 212 | |||
| 213 | impl<FI> R<bool, FI> { | ||
| 214 | ///Value of the field as raw bits | ||
| 215 | #[inline(always)] | ||
| 216 | pub fn bit(&self) -> bool { | ||
| 217 | self.bits | ||
| 218 | } | ||
| 219 | ///Returns `true` if the bit is clear (0) | ||
| 220 | #[inline(always)] | ||
| 221 | pub fn bit_is_clear(&self) -> bool { | ||
| 222 | !self.bit() | ||
| 223 | } | ||
| 224 | ///Returns `true` if the bit is set (1) | ||
| 225 | #[inline(always)] | ||
| 226 | pub fn bit_is_set(&self) -> bool { | ||
| 227 | self.bit() | ||
| 228 | } | ||
| 229 | } | ||
| 230 | |||
| 231 | ///Register writer | ||
| 232 | /// | ||
| 233 | ///Used as an argument to the closures in the [`write`](Reg::write) and [`modify`](Reg::modify) methods of the register | ||
| 234 | pub struct W<U, REG> { | ||
| 235 | ///Writable bits | ||
| 236 | pub(crate) bits: U, | ||
| 237 | _reg: marker::PhantomData<REG>, | ||
| 238 | } | ||
| 239 | |||
| 240 | impl<U, REG> W<U, REG> { | ||
| 241 | ///Writes raw bits to the register | ||
| 242 | #[inline(always)] | ||
| 243 | pub unsafe fn bits(&mut self, bits: U) -> &mut Self { | ||
| 244 | self.bits = bits; | ||
| 245 | self | ||
| 246 | } | ||
| 247 | } | ||
| 248 | |||
| 249 | ///Used if enumerated values cover not the whole range | ||
| 250 | #[derive(Clone, Copy, PartialEq)] | ||
| 251 | pub enum Variant<U, T> { | ||
| 252 | ///Expected variant | ||
| 253 | Val(T), | ||
| 254 | ///Raw bits | ||
| 255 | Res(U), | ||
| 256 | } | ||
diff --git a/embassy-stm32/src/can/bx/pac/mod.rs b/embassy-stm32/src/can/bx/pac/mod.rs new file mode 100644 index 000000000..4360c2c73 --- /dev/null +++ b/embassy-stm32/src/can/bx/pac/mod.rs | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | #![allow(non_camel_case_types)] | ||
| 2 | #![allow(non_snake_case)] | ||
| 3 | #![allow(unused)] | ||
| 4 | use core::marker::PhantomData; | ||
| 5 | use core::ops::Deref; | ||
| 6 | |||
| 7 | #[doc = "Controller area network"] | ||
| 8 | pub mod can; | ||
| 9 | pub mod generic; | ||
