diff --git a/.swiftformatignore b/.swiftformatignore index 0797cc97..d4dc651b 100644 --- a/.swiftformatignore +++ b/.swiftformatignore @@ -1,3 +1,4 @@ ./harmony/* +./stm32-lcd-logo/Sources/Application/Registers/* ./stm32-neopixel/Sources/Application/Registers/* ./stm32-uart-echo/Sources/Application/Registers/* diff --git a/stm32-lcd-logo/Package.resolved b/stm32-lcd-logo/Package.resolved new file mode 100644 index 00000000..a1112472 --- /dev/null +++ b/stm32-lcd-logo/Package.resolved @@ -0,0 +1,33 @@ +{ + "originHash" : "5728b1ec253c3300a921ee6ddc3c43ff685abaa7f6ca8d86433af91b7883bf79", + "pins" : [ + { + "identity" : "swift-argument-parser", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-argument-parser.git", + "state" : { + "revision" : "41982a3656a71c768319979febd796c6fd111d5c", + "version" : "1.5.0" + } + }, + { + "identity" : "swift-mmio", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-mmio", + "state" : { + "branch" : "main", + "revision" : "daf25ecacc0d9b71036c6af32cb7786a01802799" + } + }, + { + "identity" : "swift-syntax", + "kind" : "remoteSourceControl", + "location" : "https://github.com/swiftlang/swift-syntax.git", + "state" : { + "revision" : "0687f71944021d616d34d922343dcef086855920", + "version" : "600.0.1" + } + } + ], + "version" : 3 +} diff --git a/stm32-lcd-logo/Package.swift b/stm32-lcd-logo/Package.swift index 796e1779..846e699b 100644 --- a/stm32-lcd-logo/Package.swift +++ b/stm32-lcd-logo/Package.swift @@ -11,18 +11,18 @@ let package = Package( .executable(name: "Application", targets: ["Application"]) ], dependencies: [ - // .package(url: "https://github.com/apple/swift-mmio", branch: "main") + .package(url: "https://github.com/apple/swift-mmio", branch: "main") ], targets: [ // SVD2Swift \ // --input Tools/SVDs/stm32f7x6.patched.svd \ // --output stm32-lcd-logo/Sources/STM32F7x6 \ - // --peripherals LTDC RCC GPIOA GPIOB GPIOC GPIOD GPIOE GPIOF GPIOG GPIOH GPIOI GPIOJ GPIOK + // --peripherals FLASH GPIOA GPIOB GPIOC GPIOD GPIOE GPIOF GPIOG GPIOH GPIOI GPIOJ GPIOK LTDC RCC .executableTarget( name: "Application", dependencies: [ - // .product(name: "MMIO", package: "swift-mmio"), - "Support" + .product(name: "MMIO", package: "swift-mmio"), + "Support", ]), .target(name: "Support"), ]) diff --git a/stm32-lcd-logo/Sources/Application/Board.swift b/stm32-lcd-logo/Sources/Application/Board.swift deleted file mode 100644 index 33f92bb3..00000000 --- a/stm32-lcd-logo/Sources/Application/Board.swift +++ /dev/null @@ -1,81 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// This source file is part of the Swift open source project -// -// Copyright (c) 2023 Apple Inc. and the Swift project authors. -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See https://swift.org/LICENSE.txt for license information -// -//===----------------------------------------------------------------------===// - -import Support - -struct STM32F746Board { - var led: HALGPIO - - init() { - // Configure LED on I1 - STM32F746.enableGPIOPortClock(.i) - led = HALGPIO(pin: .init(port: .i, number: 1)) - led.configure( - configuration: .init( - mode: .output, outputType: .pushPull, outputSpeed: .high, pull: .down, - alternateFunction: .none, activeHigh: true)) - led.deassert() - - STM32F746.initializeLTCD() - - STM32F746.configureFlash() - - STM32F746.configureLTCD() - } - - mutating func ledOn() { - led.assert() - } - - mutating func ledOff() { - led.deassert() - } - - mutating func delay(milliseconds: Int) { - for _ in 0..<100_000 * milliseconds { - nop() - } - } - - mutating func moveLogo(to point: Point) { - STM32F746.setLayer2Position(point) - } - - mutating func setBackgroundColor(color: Color) { - STM32F746.setBackgroundColor(color) - } - - var displaySize: Size { - Size( - width: STM32F746.LTDCConstants.displayWidth, - height: STM32F746.LTDCConstants.displayHeight) - } - - var logoLayerSize: Size { - Size(width: 50, height: 50) - } -} - -struct Point { - var x, y: Int - - func offset(by: Point) -> Point { - Point(x: x + by.x, y: y + by.y) - } -} - -struct Size { - var width, height: Int -} - -struct Color { - var r, g, b: Int -} diff --git a/stm32-lcd-logo/Sources/Application/GPIO.swift b/stm32-lcd-logo/Sources/Application/GPIO.swift deleted file mode 100644 index 5f5eb996..00000000 --- a/stm32-lcd-logo/Sources/Application/GPIO.swift +++ /dev/null @@ -1,2097 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// This source file is part of the Swift open source project -// -// Copyright (c) 2023 Apple Inc. and the Swift project authors. -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See https://swift.org/LICENSE.txt for license information -// -//===----------------------------------------------------------------------===// - -// swift-format-ignore-file - -/// General-purpose I/Os -struct GPIO { - var baseAddress: UnsafeMutableRawPointer - - enum Offsets { - static let MODER: Int32 = 0x0 - static let OTYPER: Int32 = 0x4 - static let OSPEEDR: Int32 = 0x8 - static let PUPDR: Int32 = 0xc - static let IDR: Int32 = 0x10 - static let ODR: Int32 = 0x14 - static let BSRR: Int32 = 0x18 - static let LCKR: Int32 = 0x1c - static let AFRL: Int32 = 0x20 - static let AFRH: Int32 = 0x24 - static let BRR: Int32 = 0x28 - } - - private func ld(_ offset: Int32) -> UInt32 { - UnsafeMutablePointer(bitPattern: UInt(bitPattern: UnsafeMutableRawPointer(baseAddress).advanced(by: Int(offset))))!.volatileLoad() - } - - private func st(_ offset: Int32, _ value: UInt32) { - UnsafeMutablePointer(bitPattern: UInt(bitPattern: UnsafeMutableRawPointer(baseAddress).advanced(by: Int(offset))))!.volatileStore(value) - } - - /// GPIO port mode register - var moder: MODER { - get { MODER(rawValue: ld(Offsets.MODER)) } - set { st(Offsets.MODER, newValue.rawValue) } - } - /// GPIO port output type register - var otyper: OTYPER { - get { OTYPER(rawValue: ld(Offsets.OTYPER)) } - set { st(Offsets.OTYPER, newValue.rawValue) } - } - /// GPIO port output speed register - var ospeedr: OSPEEDR { - get { OSPEEDR(rawValue: ld(Offsets.OSPEEDR)) } - set { st(Offsets.OSPEEDR, newValue.rawValue) } - } - /// GPIO port pull-up/pull-down register - var pupdr: PUPDR { - get { PUPDR(rawValue: ld(Offsets.PUPDR)) } - set { st(Offsets.PUPDR, newValue.rawValue) } - } - /// GPIO port input data register - var idr: IDR { - get { IDR(rawValue: ld(Offsets.IDR)) } - set { st(Offsets.IDR, newValue.rawValue) } - } - /// GPIO port output data register - var odr: ODR { - get { ODR(rawValue: ld(Offsets.ODR)) } - set { st(Offsets.ODR, newValue.rawValue) } - } - /// GPIO port bit set/reset register - var bsrr: BSRR { - get { BSRR(rawValue: ld(Offsets.BSRR)) } - set { st(Offsets.BSRR, newValue.rawValue) } - } - /// GPIO port configuration lock register - var lckr: LCKR { - get { LCKR(rawValue: ld(Offsets.LCKR)) } - set { st(Offsets.LCKR, newValue.rawValue) } - } - /// GPIO alternate function lowregister - var afrl: AFRL { - get { AFRL(rawValue: ld(Offsets.AFRL)) } - set { st(Offsets.AFRL, newValue.rawValue) } - } - /// GPIO alternate function high register - var afrh: AFRH { - get { AFRH(rawValue: ld(Offsets.AFRH)) } - set { st(Offsets.AFRH, newValue.rawValue) } - } - /// GPIO port bit reset register - var brr: BRR { - get { BRR(rawValue: ld(Offsets.BRR)) } - set { st(Offsets.BRR, newValue.rawValue) } - } -} - -extension GPIO { - struct MODER { - var rawValue: UInt32 - - static let moder15_offset = UInt32(30) - static let moder15_mask = UInt32(0b11) &<< moder15_offset - var moder15: UInt8 { - get { UInt8((self.rawValue & (GPIO.MODER.moder15_mask)) >> GPIO.MODER.moder15_offset) } - set { - let preserve = self.rawValue & ~GPIO.MODER.moder15_mask - let shift = (UInt32(newValue) << GPIO.MODER.moder15_offset) & GPIO.MODER.moder15_mask - self.rawValue = preserve | shift - } - } - - static let moder14_offset = UInt32(28) - static let moder14_mask = UInt32(0b11) &<< moder14_offset - var moder14: UInt8 { - get { UInt8((self.rawValue & (GPIO.MODER.moder14_mask)) >> GPIO.MODER.moder14_offset) } - set { - let preserve = self.rawValue & ~GPIO.MODER.moder14_mask - let shift = (UInt32(newValue) << GPIO.MODER.moder14_offset) & GPIO.MODER.moder14_mask - self.rawValue = preserve | shift - } - } - - static let moder13_offset = UInt32(26) - static let moder13_mask = UInt32(0b11) &<< moder13_offset - var moder13: UInt8 { - get { UInt8((self.rawValue & (GPIO.MODER.moder13_mask)) >> GPIO.MODER.moder13_offset) } - set { - let preserve = self.rawValue & ~GPIO.MODER.moder13_mask - let shift = (UInt32(newValue) << GPIO.MODER.moder13_offset) & GPIO.MODER.moder13_mask - self.rawValue = preserve | shift - } - } - - static let moder12_offset = UInt32(24) - static let moder12_mask = UInt32(0b11) &<< moder12_offset - var moder12: UInt8 { - get { UInt8((self.rawValue & (GPIO.MODER.moder12_mask)) >> GPIO.MODER.moder12_offset) } - set { - let preserve = self.rawValue & ~GPIO.MODER.moder12_mask - let shift = (UInt32(newValue) << GPIO.MODER.moder12_offset) & GPIO.MODER.moder12_mask - self.rawValue = preserve | shift - } - } - - static let moder11_offset = UInt32(22) - static let moder11_mask = UInt32(0b11) &<< moder11_offset - var moder11: UInt8 { - get { UInt8((self.rawValue & (GPIO.MODER.moder11_mask)) >> GPIO.MODER.moder11_offset) } - set { - let preserve = self.rawValue & ~GPIO.MODER.moder11_mask - let shift = (UInt32(newValue) << GPIO.MODER.moder11_offset) & GPIO.MODER.moder11_mask - self.rawValue = preserve | shift - } - } - - static let moder10_offset = UInt32(20) - static let moder10_mask = UInt32(0b11) &<< moder10_offset - var moder10: UInt8 { - get { UInt8((self.rawValue & (GPIO.MODER.moder10_mask)) >> GPIO.MODER.moder10_offset) } - set { - let preserve = self.rawValue & ~GPIO.MODER.moder10_mask - let shift = (UInt32(newValue) << GPIO.MODER.moder10_offset) & GPIO.MODER.moder10_mask - self.rawValue = preserve | shift - } - } - - static let moder9_offset = UInt32(18) - static let moder9_mask = UInt32(0b11) &<< moder9_offset - var moder9: UInt8 { - get { UInt8((self.rawValue & (GPIO.MODER.moder9_mask)) >> GPIO.MODER.moder9_offset) } - set { - let preserve = self.rawValue & ~GPIO.MODER.moder9_mask - let shift = (UInt32(newValue) << GPIO.MODER.moder9_offset) & GPIO.MODER.moder9_mask - self.rawValue = preserve | shift - } - } - - static let moder8_offset = UInt32(16) - static let moder8_mask = UInt32(0b11) &<< moder8_offset - var moder8: UInt8 { - get { UInt8((self.rawValue & (GPIO.MODER.moder8_mask)) >> GPIO.MODER.moder8_offset) } - set { - let preserve = self.rawValue & ~GPIO.MODER.moder8_mask - let shift = (UInt32(newValue) << GPIO.MODER.moder8_offset) & GPIO.MODER.moder8_mask - self.rawValue = preserve | shift - } - } - - static let moder7_offset = UInt32(14) - static let moder7_mask = UInt32(0b11) &<< moder7_offset - var moder7: UInt8 { - get { UInt8((self.rawValue & (GPIO.MODER.moder7_mask)) >> GPIO.MODER.moder7_offset) } - set { - let preserve = self.rawValue & ~GPIO.MODER.moder7_mask - let shift = (UInt32(newValue) << GPIO.MODER.moder7_offset) & GPIO.MODER.moder7_mask - self.rawValue = preserve | shift - } - } - - static let moder6_offset = UInt32(12) - static let moder6_mask = UInt32(0b11) &<< moder6_offset - var moder6: UInt8 { - get { UInt8((self.rawValue & (GPIO.MODER.moder6_mask)) >> GPIO.MODER.moder6_offset) } - set { - let preserve = self.rawValue & ~GPIO.MODER.moder6_mask - let shift = (UInt32(newValue) << GPIO.MODER.moder6_offset) & GPIO.MODER.moder6_mask - self.rawValue = preserve | shift - } - } - - static let moder5_offset = UInt32(10) - static let moder5_mask = UInt32(0b11) &<< moder5_offset - var moder5: UInt8 { - get { UInt8((self.rawValue & (GPIO.MODER.moder5_mask)) >> GPIO.MODER.moder5_offset) } - set { - let preserve = self.rawValue & ~GPIO.MODER.moder5_mask - let shift = (UInt32(newValue) << GPIO.MODER.moder5_offset) & GPIO.MODER.moder5_mask - self.rawValue = preserve | shift - } - } - - static let moder4_offset = UInt32(8) - static let moder4_mask = UInt32(0b11) &<< moder4_offset - var moder4: UInt8 { - get { UInt8((self.rawValue & (GPIO.MODER.moder4_mask)) >> GPIO.MODER.moder4_offset) } - set { - let preserve = self.rawValue & ~GPIO.MODER.moder4_mask - let shift = (UInt32(newValue) << GPIO.MODER.moder4_offset) & GPIO.MODER.moder4_mask - self.rawValue = preserve | shift - } - } - - static let moder3_offset = UInt32(6) - static let moder3_mask = UInt32(0b11) &<< moder3_offset - var moder3: UInt8 { - get { UInt8((self.rawValue & (GPIO.MODER.moder3_mask)) >> GPIO.MODER.moder3_offset) } - set { - let preserve = self.rawValue & ~GPIO.MODER.moder3_mask - let shift = (UInt32(newValue) << GPIO.MODER.moder3_offset) & GPIO.MODER.moder3_mask - self.rawValue = preserve | shift - } - } - - static let moder2_offset = UInt32(4) - static let moder2_mask = UInt32(0b11) &<< moder2_offset - var moder2: UInt8 { - get { UInt8((self.rawValue & (GPIO.MODER.moder2_mask)) >> GPIO.MODER.moder2_offset) } - set { - let preserve = self.rawValue & ~GPIO.MODER.moder2_mask - let shift = (UInt32(newValue) << GPIO.MODER.moder2_offset) & GPIO.MODER.moder2_mask - self.rawValue = preserve | shift - } - } - - static let moder1_offset = UInt32(2) - static let moder1_mask = UInt32(0b11) &<< moder1_offset - var moder1: UInt8 { - get { UInt8((self.rawValue & (GPIO.MODER.moder1_mask)) >> GPIO.MODER.moder1_offset) } - set { - let preserve = self.rawValue & ~GPIO.MODER.moder1_mask - let shift = (UInt32(newValue) << GPIO.MODER.moder1_offset) & GPIO.MODER.moder1_mask - self.rawValue = preserve | shift - } - } - - static let moder0_offset = UInt32(0) - static let moder0_mask = UInt32(0b11) &<< moder0_offset - var moder0: UInt8 { - get { UInt8((self.rawValue & (GPIO.MODER.moder0_mask)) >> GPIO.MODER.moder0_offset) } - set { - let preserve = self.rawValue & ~GPIO.MODER.moder0_mask - let shift = (UInt32(newValue) << GPIO.MODER.moder0_offset) & GPIO.MODER.moder0_mask - self.rawValue = preserve | shift - } - } - - func moder(n: Int) -> UInt8 { - precondition(n >= 0 && n < 16) - let moder_offset = n * 2 - let moder_mask = UInt32(0b11) &<< moder_offset - return UInt8((self.rawValue & (moder_mask)) &>> moder_offset) - } - - mutating func setModer(n: Int, value: UInt8) { - precondition(n >= 0 && n < 16) - precondition(value < 4) - let moder_offset = n * 2 - let moder_mask = UInt32(0b11) &<< moder_offset - let preserve = self.rawValue & ~moder_mask - let shift = (UInt32(value) << moder_offset) & moder_mask - self.rawValue = preserve | shift - } - - init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - struct OTYPER { - var rawValue: UInt32 - - static let ot15_offset = UInt32(15) - static let ot15_mask = UInt32(0b1) &<< ot15_offset - var ot15: UInt8 { - get { UInt8((self.rawValue & (GPIO.OTYPER.ot15_mask)) >> GPIO.OTYPER.ot15_offset) } - set { - let preserve = self.rawValue & ~GPIO.OTYPER.ot15_mask - let shift = (UInt32(newValue) << GPIO.OTYPER.ot15_offset) & GPIO.OTYPER.ot15_mask - self.rawValue = preserve | shift - } - } - - static let ot14_offset = UInt32(14) - static let ot14_mask = UInt32(0b1) &<< ot14_offset - var ot14: UInt8 { - get { UInt8((self.rawValue & (GPIO.OTYPER.ot14_mask)) >> GPIO.OTYPER.ot14_offset) } - set { - let preserve = self.rawValue & ~GPIO.OTYPER.ot14_mask - let shift = (UInt32(newValue) << GPIO.OTYPER.ot14_offset) & GPIO.OTYPER.ot14_mask - self.rawValue = preserve | shift - } - } - - static let ot13_offset = UInt32(13) - static let ot13_mask = UInt32(0b1) &<< ot13_offset - var ot13: UInt8 { - get { UInt8((self.rawValue & (GPIO.OTYPER.ot13_mask)) >> GPIO.OTYPER.ot13_offset) } - set { - let preserve = self.rawValue & ~GPIO.OTYPER.ot13_mask - let shift = (UInt32(newValue) << GPIO.OTYPER.ot13_offset) & GPIO.OTYPER.ot13_mask - self.rawValue = preserve | shift - } - } - - static let ot12_offset = UInt32(12) - static let ot12_mask = UInt32(0b1) &<< ot12_offset - var ot12: UInt8 { - get { UInt8((self.rawValue & (GPIO.OTYPER.ot12_mask)) >> GPIO.OTYPER.ot12_offset) } - set { - let preserve = self.rawValue & ~GPIO.OTYPER.ot12_mask - let shift = (UInt32(newValue) << GPIO.OTYPER.ot12_offset) & GPIO.OTYPER.ot12_mask - self.rawValue = preserve | shift - } - } - - static let ot11_offset = UInt32(11) - static let ot11_mask = UInt32(0b1) &<< ot11_offset - var ot11: UInt8 { - get { UInt8((self.rawValue & (GPIO.OTYPER.ot11_mask)) >> GPIO.OTYPER.ot11_offset) } - set { - let preserve = self.rawValue & ~GPIO.OTYPER.ot11_mask - let shift = (UInt32(newValue) << GPIO.OTYPER.ot11_offset) & GPIO.OTYPER.ot11_mask - self.rawValue = preserve | shift - } - } - - static let ot10_offset = UInt32(10) - static let ot10_mask = UInt32(0b1) &<< ot10_offset - var ot10: UInt8 { - get { UInt8((self.rawValue & (GPIO.OTYPER.ot10_mask)) >> GPIO.OTYPER.ot10_offset) } - set { - let preserve = self.rawValue & ~GPIO.OTYPER.ot10_mask - let shift = (UInt32(newValue) << GPIO.OTYPER.ot10_offset) & GPIO.OTYPER.ot10_mask - self.rawValue = preserve | shift - } - } - - static let ot9_offset = UInt32(9) - static let ot9_mask = UInt32(0b1) &<< ot9_offset - var ot9: UInt8 { - get { UInt8((self.rawValue & (GPIO.OTYPER.ot9_mask)) >> GPIO.OTYPER.ot9_offset) } - set { - let preserve = self.rawValue & ~GPIO.OTYPER.ot9_mask - let shift = (UInt32(newValue) << GPIO.OTYPER.ot9_offset) & GPIO.OTYPER.ot9_mask - self.rawValue = preserve | shift - } - } - - static let ot8_offset = UInt32(8) - static let ot8_mask = UInt32(0b1) &<< ot8_offset - var ot8: UInt8 { - get { UInt8((self.rawValue & (GPIO.OTYPER.ot8_mask)) >> GPIO.OTYPER.ot8_offset) } - set { - let preserve = self.rawValue & ~GPIO.OTYPER.ot8_mask - let shift = (UInt32(newValue) << GPIO.OTYPER.ot8_offset) & GPIO.OTYPER.ot8_mask - self.rawValue = preserve | shift - } - } - - static let ot7_offset = UInt32(7) - static let ot7_mask = UInt32(0b1) &<< ot7_offset - var ot7: UInt8 { - get { UInt8((self.rawValue & (GPIO.OTYPER.ot7_mask)) >> GPIO.OTYPER.ot7_offset) } - set { - let preserve = self.rawValue & ~GPIO.OTYPER.ot7_mask - let shift = (UInt32(newValue) << GPIO.OTYPER.ot7_offset) & GPIO.OTYPER.ot7_mask - self.rawValue = preserve | shift - } - } - - static let ot6_offset = UInt32(6) - static let ot6_mask = UInt32(0b1) &<< ot6_offset - var ot6: UInt8 { - get { UInt8((self.rawValue & (GPIO.OTYPER.ot6_mask)) >> GPIO.OTYPER.ot6_offset) } - set { - let preserve = self.rawValue & ~GPIO.OTYPER.ot6_mask - let shift = (UInt32(newValue) << GPIO.OTYPER.ot6_offset) & GPIO.OTYPER.ot6_mask - self.rawValue = preserve | shift - } - } - - static let ot5_offset = UInt32(5) - static let ot5_mask = UInt32(0b1) &<< ot5_offset - var ot5: UInt8 { - get { UInt8((self.rawValue & (GPIO.OTYPER.ot5_mask)) >> GPIO.OTYPER.ot5_offset) } - set { - let preserve = self.rawValue & ~GPIO.OTYPER.ot5_mask - let shift = (UInt32(newValue) << GPIO.OTYPER.ot5_offset) & GPIO.OTYPER.ot5_mask - self.rawValue = preserve | shift - } - } - - static let ot4_offset = UInt32(4) - static let ot4_mask = UInt32(0b1) &<< ot4_offset - var ot4: UInt8 { - get { UInt8((self.rawValue & (GPIO.OTYPER.ot4_mask)) >> GPIO.OTYPER.ot4_offset) } - set { - let preserve = self.rawValue & ~GPIO.OTYPER.ot4_mask - let shift = (UInt32(newValue) << GPIO.OTYPER.ot4_offset) & GPIO.OTYPER.ot4_mask - self.rawValue = preserve | shift - } - } - - static let ot3_offset = UInt32(3) - static let ot3_mask = UInt32(0b1) &<< ot3_offset - var ot3: UInt8 { - get { UInt8((self.rawValue & (GPIO.OTYPER.ot3_mask)) >> GPIO.OTYPER.ot3_offset) } - set { - let preserve = self.rawValue & ~GPIO.OTYPER.ot3_mask - let shift = (UInt32(newValue) << GPIO.OTYPER.ot3_offset) & GPIO.OTYPER.ot3_mask - self.rawValue = preserve | shift - } - } - - static let ot2_offset = UInt32(2) - static let ot2_mask = UInt32(0b1) &<< ot2_offset - var ot2: UInt8 { - get { UInt8((self.rawValue & (GPIO.OTYPER.ot2_mask)) >> GPIO.OTYPER.ot2_offset) } - set { - let preserve = self.rawValue & ~GPIO.OTYPER.ot2_mask - let shift = (UInt32(newValue) << GPIO.OTYPER.ot2_offset) & GPIO.OTYPER.ot2_mask - self.rawValue = preserve | shift - } - } - - static let ot1_offset = UInt32(1) - static let ot1_mask = UInt32(0b1) &<< ot1_offset - var ot1: UInt8 { - get { UInt8((self.rawValue & (GPIO.OTYPER.ot1_mask)) >> GPIO.OTYPER.ot1_offset) } - set { - let preserve = self.rawValue & ~GPIO.OTYPER.ot1_mask - let shift = (UInt32(newValue) << GPIO.OTYPER.ot1_offset) & GPIO.OTYPER.ot1_mask - self.rawValue = preserve | shift - } - } - - static let ot0_offset = UInt32(0) - static let ot0_mask = UInt32(0b1) &<< ot0_offset - var ot0: UInt8 { - get { UInt8((self.rawValue & (GPIO.OTYPER.ot0_mask)) >> GPIO.OTYPER.ot0_offset) } - set { - let preserve = self.rawValue & ~GPIO.OTYPER.ot0_mask - let shift = (UInt32(newValue) << GPIO.OTYPER.ot0_offset) & GPIO.OTYPER.ot0_mask - self.rawValue = preserve | shift - } - } - - func ot(n: Int) -> UInt8 { - precondition(n >= 0 && n < 16) - let ot_offset = n * 1 - let ot_mask = UInt32(0b1) &<< ot_offset - return UInt8((self.rawValue & (ot_mask)) &>> ot_offset) - } - - mutating func setOt(n: Int, value: UInt8) { - precondition(n >= 0 && n < 16) - precondition(value < 2) - let ot_offset = n * 1 - let ot_mask = UInt32(0b1) &<< ot_offset - let preserve = self.rawValue & ~ot_mask - let shift = (UInt32(value) << ot_offset) & ot_mask - self.rawValue = preserve | shift - } - - init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - struct OSPEEDR { - var rawValue: UInt32 - - static let ospeedr15_offset = UInt32(30) - static let ospeedr15_mask = UInt32(0b11) &<< ospeedr15_offset - var ospeedr15: UInt8 { - get { UInt8((self.rawValue & (GPIO.OSPEEDR.ospeedr15_mask)) >> GPIO.OSPEEDR.ospeedr15_offset) } - set { - let preserve = self.rawValue & ~GPIO.OSPEEDR.ospeedr15_mask - let shift = (UInt32(newValue) << GPIO.OSPEEDR.ospeedr15_offset) & GPIO.OSPEEDR.ospeedr15_mask - self.rawValue = preserve | shift - } - } - - static let ospeedr14_offset = UInt32(28) - static let ospeedr14_mask = UInt32(0b11) &<< ospeedr14_offset - var ospeedr14: UInt8 { - get { UInt8((self.rawValue & (GPIO.OSPEEDR.ospeedr14_mask)) >> GPIO.OSPEEDR.ospeedr14_offset) } - set { - let preserve = self.rawValue & ~GPIO.OSPEEDR.ospeedr14_mask - let shift = (UInt32(newValue) << GPIO.OSPEEDR.ospeedr14_offset) & GPIO.OSPEEDR.ospeedr14_mask - self.rawValue = preserve | shift - } - } - - static let ospeedr13_offset = UInt32(26) - static let ospeedr13_mask = UInt32(0b11) &<< ospeedr13_offset - var ospeedr13: UInt8 { - get { UInt8((self.rawValue & (GPIO.OSPEEDR.ospeedr13_mask)) >> GPIO.OSPEEDR.ospeedr13_offset) } - set { - let preserve = self.rawValue & ~GPIO.OSPEEDR.ospeedr13_mask - let shift = (UInt32(newValue) << GPIO.OSPEEDR.ospeedr13_offset) & GPIO.OSPEEDR.ospeedr13_mask - self.rawValue = preserve | shift - } - } - - static let ospeedr12_offset = UInt32(24) - static let ospeedr12_mask = UInt32(0b11) &<< ospeedr12_offset - var ospeedr12: UInt8 { - get { UInt8((self.rawValue & (GPIO.OSPEEDR.ospeedr12_mask)) >> GPIO.OSPEEDR.ospeedr12_offset) } - set { - let preserve = self.rawValue & ~GPIO.OSPEEDR.ospeedr12_mask - let shift = (UInt32(newValue) << GPIO.OSPEEDR.ospeedr12_offset) & GPIO.OSPEEDR.ospeedr12_mask - self.rawValue = preserve | shift - } - } - - static let ospeedr11_offset = UInt32(22) - static let ospeedr11_mask = UInt32(0b11) &<< ospeedr11_offset - var ospeedr11: UInt8 { - get { UInt8((self.rawValue & (GPIO.OSPEEDR.ospeedr11_mask)) >> GPIO.OSPEEDR.ospeedr11_offset) } - set { - let preserve = self.rawValue & ~GPIO.OSPEEDR.ospeedr11_mask - let shift = (UInt32(newValue) << GPIO.OSPEEDR.ospeedr11_offset) & GPIO.OSPEEDR.ospeedr11_mask - self.rawValue = preserve | shift - } - } - - static let ospeedr10_offset = UInt32(20) - static let ospeedr10_mask = UInt32(0b11) &<< ospeedr10_offset - var ospeedr10: UInt8 { - get { UInt8((self.rawValue & (GPIO.OSPEEDR.ospeedr10_mask)) >> GPIO.OSPEEDR.ospeedr10_offset) } - set { - let preserve = self.rawValue & ~GPIO.OSPEEDR.ospeedr10_mask - let shift = (UInt32(newValue) << GPIO.OSPEEDR.ospeedr10_offset) & GPIO.OSPEEDR.ospeedr10_mask - self.rawValue = preserve | shift - } - } - - static let ospeedr9_offset = UInt32(18) - static let ospeedr9_mask = UInt32(0b11) &<< ospeedr9_offset - var ospeedr9: UInt8 { - get { UInt8((self.rawValue & (GPIO.OSPEEDR.ospeedr9_mask)) >> GPIO.OSPEEDR.ospeedr9_offset) } - set { - let preserve = self.rawValue & ~GPIO.OSPEEDR.ospeedr9_mask - let shift = (UInt32(newValue) << GPIO.OSPEEDR.ospeedr9_offset) & GPIO.OSPEEDR.ospeedr9_mask - self.rawValue = preserve | shift - } - } - - static let ospeedr8_offset = UInt32(16) - static let ospeedr8_mask = UInt32(0b11) &<< ospeedr8_offset - var ospeedr8: UInt8 { - get { UInt8((self.rawValue & (GPIO.OSPEEDR.ospeedr8_mask)) >> GPIO.OSPEEDR.ospeedr8_offset) } - set { - let preserve = self.rawValue & ~GPIO.OSPEEDR.ospeedr8_mask - let shift = (UInt32(newValue) << GPIO.OSPEEDR.ospeedr8_offset) & GPIO.OSPEEDR.ospeedr8_mask - self.rawValue = preserve | shift - } - } - - static let ospeedr7_offset = UInt32(14) - static let ospeedr7_mask = UInt32(0b11) &<< ospeedr7_offset - var ospeedr7: UInt8 { - get { UInt8((self.rawValue & (GPIO.OSPEEDR.ospeedr7_mask)) >> GPIO.OSPEEDR.ospeedr7_offset) } - set { - let preserve = self.rawValue & ~GPIO.OSPEEDR.ospeedr7_mask - let shift = (UInt32(newValue) << GPIO.OSPEEDR.ospeedr7_offset) & GPIO.OSPEEDR.ospeedr7_mask - self.rawValue = preserve | shift - } - } - - static let ospeedr6_offset = UInt32(12) - static let ospeedr6_mask = UInt32(0b11) &<< ospeedr6_offset - var ospeedr6: UInt8 { - get { UInt8((self.rawValue & (GPIO.OSPEEDR.ospeedr6_mask)) >> GPIO.OSPEEDR.ospeedr6_offset) } - set { - let preserve = self.rawValue & ~GPIO.OSPEEDR.ospeedr6_mask - let shift = (UInt32(newValue) << GPIO.OSPEEDR.ospeedr6_offset) & GPIO.OSPEEDR.ospeedr6_mask - self.rawValue = preserve | shift - } - } - - static let ospeedr5_offset = UInt32(10) - static let ospeedr5_mask = UInt32(0b11) &<< ospeedr5_offset - var ospeedr5: UInt8 { - get { UInt8((self.rawValue & (GPIO.OSPEEDR.ospeedr5_mask)) >> GPIO.OSPEEDR.ospeedr5_offset) } - set { - let preserve = self.rawValue & ~GPIO.OSPEEDR.ospeedr5_mask - let shift = (UInt32(newValue) << GPIO.OSPEEDR.ospeedr5_offset) & GPIO.OSPEEDR.ospeedr5_mask - self.rawValue = preserve | shift - } - } - - static let ospeedr4_offset = UInt32(8) - static let ospeedr4_mask = UInt32(0b11) &<< ospeedr4_offset - var ospeedr4: UInt8 { - get { UInt8((self.rawValue & (GPIO.OSPEEDR.ospeedr4_mask)) >> GPIO.OSPEEDR.ospeedr4_offset) } - set { - let preserve = self.rawValue & ~GPIO.OSPEEDR.ospeedr4_mask - let shift = (UInt32(newValue) << GPIO.OSPEEDR.ospeedr4_offset) & GPIO.OSPEEDR.ospeedr4_mask - self.rawValue = preserve | shift - } - } - - static let ospeedr3_offset = UInt32(6) - static let ospeedr3_mask = UInt32(0b11) &<< ospeedr3_offset - var ospeedr3: UInt8 { - get { UInt8((self.rawValue & (GPIO.OSPEEDR.ospeedr3_mask)) >> GPIO.OSPEEDR.ospeedr3_offset) } - set { - let preserve = self.rawValue & ~GPIO.OSPEEDR.ospeedr3_mask - let shift = (UInt32(newValue) << GPIO.OSPEEDR.ospeedr3_offset) & GPIO.OSPEEDR.ospeedr3_mask - self.rawValue = preserve | shift - } - } - - static let ospeedr2_offset = UInt32(4) - static let ospeedr2_mask = UInt32(0b11) &<< ospeedr2_offset - var ospeedr2: UInt8 { - get { UInt8((self.rawValue & (GPIO.OSPEEDR.ospeedr2_mask)) >> GPIO.OSPEEDR.ospeedr2_offset) } - set { - let preserve = self.rawValue & ~GPIO.OSPEEDR.ospeedr2_mask - let shift = (UInt32(newValue) << GPIO.OSPEEDR.ospeedr2_offset) & GPIO.OSPEEDR.ospeedr2_mask - self.rawValue = preserve | shift - } - } - - static let ospeedr1_offset = UInt32(2) - static let ospeedr1_mask = UInt32(0b11) &<< ospeedr1_offset - var ospeedr1: UInt8 { - get { UInt8((self.rawValue & (GPIO.OSPEEDR.ospeedr1_mask)) >> GPIO.OSPEEDR.ospeedr1_offset) } - set { - let preserve = self.rawValue & ~GPIO.OSPEEDR.ospeedr1_mask - let shift = (UInt32(newValue) << GPIO.OSPEEDR.ospeedr1_offset) & GPIO.OSPEEDR.ospeedr1_mask - self.rawValue = preserve | shift - } - } - - static let ospeedr0_offset = UInt32(0) - static let ospeedr0_mask = UInt32(0b11) &<< ospeedr0_offset - var ospeedr0: UInt8 { - get { UInt8((self.rawValue & (GPIO.OSPEEDR.ospeedr0_mask)) >> GPIO.OSPEEDR.ospeedr0_offset) } - set { - let preserve = self.rawValue & ~GPIO.OSPEEDR.ospeedr0_mask - let shift = (UInt32(newValue) << GPIO.OSPEEDR.ospeedr0_offset) & GPIO.OSPEEDR.ospeedr0_mask - self.rawValue = preserve | shift - } - } - - func ospeed(n: Int) -> UInt8 { - precondition(n >= 0 && n < 16) - let ospeed_offset = n * 2 - let ospeed_mask = UInt32(0b11) &<< ospeed_offset - return UInt8((self.rawValue & (ospeed_mask)) &>> ospeed_offset) - } - - mutating func setOspeed(n: Int, value: UInt8) { - precondition(n >= 0 && n < 16) - precondition(value < 4) - let ospeed_offset = n * 2 - let ospeed_mask = UInt32(0b11) &<< ospeed_offset - let preserve = self.rawValue & ~ospeed_mask - let shift = (UInt32(value) << ospeed_offset) & ospeed_mask - self.rawValue = preserve | shift - } - - init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - struct PUPDR { - var rawValue: UInt32 - - static let pupdr15_offset = UInt32(30) - static let pupdr15_mask = UInt32(0b11) &<< pupdr15_offset - var pupdr15: UInt8 { - get { UInt8((self.rawValue & (GPIO.PUPDR.pupdr15_mask)) >> GPIO.PUPDR.pupdr15_offset) } - set { - let preserve = self.rawValue & ~GPIO.PUPDR.pupdr15_mask - let shift = (UInt32(newValue) << GPIO.PUPDR.pupdr15_offset) & GPIO.PUPDR.pupdr15_mask - self.rawValue = preserve | shift - } - } - - static let pupdr14_offset = UInt32(28) - static let pupdr14_mask = UInt32(0b11) &<< pupdr14_offset - var pupdr14: UInt8 { - get { UInt8((self.rawValue & (GPIO.PUPDR.pupdr14_mask)) >> GPIO.PUPDR.pupdr14_offset) } - set { - let preserve = self.rawValue & ~GPIO.PUPDR.pupdr14_mask - let shift = (UInt32(newValue) << GPIO.PUPDR.pupdr14_offset) & GPIO.PUPDR.pupdr14_mask - self.rawValue = preserve | shift - } - } - - static let pupdr13_offset = UInt32(26) - static let pupdr13_mask = UInt32(0b11) &<< pupdr13_offset - var pupdr13: UInt8 { - get { UInt8((self.rawValue & (GPIO.PUPDR.pupdr13_mask)) >> GPIO.PUPDR.pupdr13_offset) } - set { - let preserve = self.rawValue & ~GPIO.PUPDR.pupdr13_mask - let shift = (UInt32(newValue) << GPIO.PUPDR.pupdr13_offset) & GPIO.PUPDR.pupdr13_mask - self.rawValue = preserve | shift - } - } - - static let pupdr12_offset = UInt32(24) - static let pupdr12_mask = UInt32(0b11) &<< pupdr12_offset - var pupdr12: UInt8 { - get { UInt8((self.rawValue & (GPIO.PUPDR.pupdr12_mask)) >> GPIO.PUPDR.pupdr12_offset) } - set { - let preserve = self.rawValue & ~GPIO.PUPDR.pupdr12_mask - let shift = (UInt32(newValue) << GPIO.PUPDR.pupdr12_offset) & GPIO.PUPDR.pupdr12_mask - self.rawValue = preserve | shift - } - } - - static let pupdr11_offset = UInt32(22) - static let pupdr11_mask = UInt32(0b11) &<< pupdr11_offset - var pupdr11: UInt8 { - get { UInt8((self.rawValue & (GPIO.PUPDR.pupdr11_mask)) >> GPIO.PUPDR.pupdr11_offset) } - set { - let preserve = self.rawValue & ~GPIO.PUPDR.pupdr11_mask - let shift = (UInt32(newValue) << GPIO.PUPDR.pupdr11_offset) & GPIO.PUPDR.pupdr11_mask - self.rawValue = preserve | shift - } - } - - static let pupdr10_offset = UInt32(20) - static let pupdr10_mask = UInt32(0b11) &<< pupdr10_offset - var pupdr10: UInt8 { - get { UInt8((self.rawValue & (GPIO.PUPDR.pupdr10_mask)) >> GPIO.PUPDR.pupdr10_offset) } - set { - let preserve = self.rawValue & ~GPIO.PUPDR.pupdr10_mask - let shift = (UInt32(newValue) << GPIO.PUPDR.pupdr10_offset) & GPIO.PUPDR.pupdr10_mask - self.rawValue = preserve | shift - } - } - - static let pupdr9_offset = UInt32(18) - static let pupdr9_mask = UInt32(0b11) &<< pupdr9_offset - var pupdr9: UInt8 { - get { UInt8((self.rawValue & (GPIO.PUPDR.pupdr9_mask)) >> GPIO.PUPDR.pupdr9_offset) } - set { - let preserve = self.rawValue & ~GPIO.PUPDR.pupdr9_mask - let shift = (UInt32(newValue) << GPIO.PUPDR.pupdr9_offset) & GPIO.PUPDR.pupdr9_mask - self.rawValue = preserve | shift - } - } - - static let pupdr8_offset = UInt32(16) - static let pupdr8_mask = UInt32(0b11) &<< pupdr8_offset - var pupdr8: UInt8 { - get { UInt8((self.rawValue & (GPIO.PUPDR.pupdr8_mask)) >> GPIO.PUPDR.pupdr8_offset) } - set { - let preserve = self.rawValue & ~GPIO.PUPDR.pupdr8_mask - let shift = (UInt32(newValue) << GPIO.PUPDR.pupdr8_offset) & GPIO.PUPDR.pupdr8_mask - self.rawValue = preserve | shift - } - } - - static let pupdr7_offset = UInt32(14) - static let pupdr7_mask = UInt32(0b11) &<< pupdr7_offset - var pupdr7: UInt8 { - get { UInt8((self.rawValue & (GPIO.PUPDR.pupdr7_mask)) >> GPIO.PUPDR.pupdr7_offset) } - set { - let preserve = self.rawValue & ~GPIO.PUPDR.pupdr7_mask - let shift = (UInt32(newValue) << GPIO.PUPDR.pupdr7_offset) & GPIO.PUPDR.pupdr7_mask - self.rawValue = preserve | shift - } - } - - static let pupdr6_offset = UInt32(12) - static let pupdr6_mask = UInt32(0b11) &<< pupdr6_offset - var pupdr6: UInt8 { - get { UInt8((self.rawValue & (GPIO.PUPDR.pupdr6_mask)) >> GPIO.PUPDR.pupdr6_offset) } - set { - let preserve = self.rawValue & ~GPIO.PUPDR.pupdr6_mask - let shift = (UInt32(newValue) << GPIO.PUPDR.pupdr6_offset) & GPIO.PUPDR.pupdr6_mask - self.rawValue = preserve | shift - } - } - - static let pupdr5_offset = UInt32(10) - static let pupdr5_mask = UInt32(0b11) &<< pupdr5_offset - var pupdr5: UInt8 { - get { UInt8((self.rawValue & (GPIO.PUPDR.pupdr5_mask)) >> GPIO.PUPDR.pupdr5_offset) } - set { - let preserve = self.rawValue & ~GPIO.PUPDR.pupdr5_mask - let shift = (UInt32(newValue) << GPIO.PUPDR.pupdr5_offset) & GPIO.PUPDR.pupdr5_mask - self.rawValue = preserve | shift - } - } - - static let pupdr4_offset = UInt32(8) - static let pupdr4_mask = UInt32(0b11) &<< pupdr4_offset - var pupdr4: UInt8 { - get { UInt8((self.rawValue & (GPIO.PUPDR.pupdr4_mask)) >> GPIO.PUPDR.pupdr4_offset) } - set { - let preserve = self.rawValue & ~GPIO.PUPDR.pupdr4_mask - let shift = (UInt32(newValue) << GPIO.PUPDR.pupdr4_offset) & GPIO.PUPDR.pupdr4_mask - self.rawValue = preserve | shift - } - } - - static let pupdr3_offset = UInt32(6) - static let pupdr3_mask = UInt32(0b11) &<< pupdr3_offset - var pupdr3: UInt8 { - get { UInt8((self.rawValue & (GPIO.PUPDR.pupdr3_mask)) >> GPIO.PUPDR.pupdr3_offset) } - set { - let preserve = self.rawValue & ~GPIO.PUPDR.pupdr3_mask - let shift = (UInt32(newValue) << GPIO.PUPDR.pupdr3_offset) & GPIO.PUPDR.pupdr3_mask - self.rawValue = preserve | shift - } - } - - static let pupdr2_offset = UInt32(4) - static let pupdr2_mask = UInt32(0b11) &<< pupdr2_offset - var pupdr2: UInt8 { - get { UInt8((self.rawValue & (GPIO.PUPDR.pupdr2_mask)) >> GPIO.PUPDR.pupdr2_offset) } - set { - let preserve = self.rawValue & ~GPIO.PUPDR.pupdr2_mask - let shift = (UInt32(newValue) << GPIO.PUPDR.pupdr2_offset) & GPIO.PUPDR.pupdr2_mask - self.rawValue = preserve | shift - } - } - - static let pupdr1_offset = UInt32(2) - static let pupdr1_mask = UInt32(0b11) &<< pupdr1_offset - var pupdr1: UInt8 { - get { UInt8((self.rawValue & (GPIO.PUPDR.pupdr1_mask)) >> GPIO.PUPDR.pupdr1_offset) } - set { - let preserve = self.rawValue & ~GPIO.PUPDR.pupdr1_mask - let shift = (UInt32(newValue) << GPIO.PUPDR.pupdr1_offset) & GPIO.PUPDR.pupdr1_mask - self.rawValue = preserve | shift - } - } - - static let pupdr0_offset = UInt32(0) - static let pupdr0_mask = UInt32(0b11) &<< pupdr0_offset - var pupdr0: UInt8 { - get { UInt8((self.rawValue & (GPIO.PUPDR.pupdr0_mask)) >> GPIO.PUPDR.pupdr0_offset) } - set { - let preserve = self.rawValue & ~GPIO.PUPDR.pupdr0_mask - let shift = (UInt32(newValue) << GPIO.PUPDR.pupdr0_offset) & GPIO.PUPDR.pupdr0_mask - self.rawValue = preserve | shift - } - } - - func pupd(n: Int) -> UInt8 { - precondition(n >= 0 && n < 16) - let pupd_offset = n * 2 - let pupd_mask = UInt32(0b11) &<< pupd_offset - return UInt8((self.rawValue & (pupd_mask)) &>> pupd_offset) - } - - mutating func setPupd(n: Int, value: UInt8) { - precondition(n >= 0 && n < 16) - precondition(value < 4) - let pupd_offset = n * 2 - let pupd_mask = UInt32(0b11) &<< pupd_offset - let preserve = self.rawValue & ~pupd_mask - let shift = (UInt32(value) << pupd_offset) & pupd_mask - self.rawValue = preserve | shift - } - - init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - struct IDR { - var rawValue: UInt32 - - static let idr15_offset = UInt32(15) - static let idr15_mask = UInt32(0b1) &<< idr15_offset - var idr15: UInt8 { - UInt8((self.rawValue & (GPIO.IDR.idr15_mask)) >> GPIO.IDR.idr15_offset) - } - - static let idr14_offset = UInt32(14) - static let idr14_mask = UInt32(0b1) &<< idr14_offset - var idr14: UInt8 { - UInt8((self.rawValue & (GPIO.IDR.idr14_mask)) >> GPIO.IDR.idr14_offset) - } - - static let idr13_offset = UInt32(13) - static let idr13_mask = UInt32(0b1) &<< idr13_offset - var idr13: UInt8 { - UInt8((self.rawValue & (GPIO.IDR.idr13_mask)) >> GPIO.IDR.idr13_offset) - } - - static let idr12_offset = UInt32(12) - static let idr12_mask = UInt32(0b1) &<< idr12_offset - var idr12: UInt8 { - UInt8((self.rawValue & (GPIO.IDR.idr12_mask)) >> GPIO.IDR.idr12_offset) - } - - static let idr11_offset = UInt32(11) - static let idr11_mask = UInt32(0b1) &<< idr11_offset - var idr11: UInt8 { - UInt8((self.rawValue & (GPIO.IDR.idr11_mask)) >> GPIO.IDR.idr11_offset) - } - - static let idr10_offset = UInt32(10) - static let idr10_mask = UInt32(0b1) &<< idr10_offset - var idr10: UInt8 { - UInt8((self.rawValue & (GPIO.IDR.idr10_mask)) >> GPIO.IDR.idr10_offset) - } - - static let idr9_offset = UInt32(9) - static let idr9_mask = UInt32(0b1) &<< idr9_offset - var idr9: UInt8 { - UInt8((self.rawValue & (GPIO.IDR.idr9_mask)) >> GPIO.IDR.idr9_offset) - } - - static let idr8_offset = UInt32(8) - static let idr8_mask = UInt32(0b1) &<< idr8_offset - var idr8: UInt8 { - UInt8((self.rawValue & (GPIO.IDR.idr8_mask)) >> GPIO.IDR.idr8_offset) - } - - static let idr7_offset = UInt32(7) - static let idr7_mask = UInt32(0b1) &<< idr7_offset - var idr7: UInt8 { - UInt8((self.rawValue & (GPIO.IDR.idr7_mask)) >> GPIO.IDR.idr7_offset) - } - - static let idr6_offset = UInt32(6) - static let idr6_mask = UInt32(0b1) &<< idr6_offset - var idr6: UInt8 { - UInt8((self.rawValue & (GPIO.IDR.idr6_mask)) >> GPIO.IDR.idr6_offset) - } - - static let idr5_offset = UInt32(5) - static let idr5_mask = UInt32(0b1) &<< idr5_offset - var idr5: UInt8 { - UInt8((self.rawValue & (GPIO.IDR.idr5_mask)) >> GPIO.IDR.idr5_offset) - } - - static let idr4_offset = UInt32(4) - static let idr4_mask = UInt32(0b1) &<< idr4_offset - var idr4: UInt8 { - UInt8((self.rawValue & (GPIO.IDR.idr4_mask)) >> GPIO.IDR.idr4_offset) - } - - static let idr3_offset = UInt32(3) - static let idr3_mask = UInt32(0b1) &<< idr3_offset - var idr3: UInt8 { - UInt8((self.rawValue & (GPIO.IDR.idr3_mask)) >> GPIO.IDR.idr3_offset) - } - - static let idr2_offset = UInt32(2) - static let idr2_mask = UInt32(0b1) &<< idr2_offset - var idr2: UInt8 { - UInt8((self.rawValue & (GPIO.IDR.idr2_mask)) >> GPIO.IDR.idr2_offset) - } - - static let idr1_offset = UInt32(1) - static let idr1_mask = UInt32(0b1) &<< idr1_offset - var idr1: UInt8 { - UInt8((self.rawValue & (GPIO.IDR.idr1_mask)) >> GPIO.IDR.idr1_offset) - } - - static let idr0_offset = UInt32(0) - static let idr0_mask = UInt32(0b1) &<< idr0_offset - var idr0: UInt8 { - UInt8((self.rawValue & (GPIO.IDR.idr0_mask)) >> GPIO.IDR.idr0_offset) - } - - init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - struct ODR { - var rawValue: UInt32 - - static let odr15_offset = UInt32(15) - static let odr15_mask = UInt32(0b1) &<< odr15_offset - var odr15: UInt8 { - get { UInt8((self.rawValue & (GPIO.ODR.odr15_mask)) >> GPIO.ODR.odr15_offset) } - set { - let preserve = self.rawValue & ~GPIO.ODR.odr15_mask - let shift = (UInt32(newValue) << GPIO.ODR.odr15_offset) & GPIO.ODR.odr15_mask - self.rawValue = preserve | shift - } - } - - static let odr14_offset = UInt32(14) - static let odr14_mask = UInt32(0b1) &<< odr14_offset - var odr14: UInt8 { - get { UInt8((self.rawValue & (GPIO.ODR.odr14_mask)) >> GPIO.ODR.odr14_offset) } - set { - let preserve = self.rawValue & ~GPIO.ODR.odr14_mask - let shift = (UInt32(newValue) << GPIO.ODR.odr14_offset) & GPIO.ODR.odr14_mask - self.rawValue = preserve | shift - } - } - - static let odr13_offset = UInt32(13) - static let odr13_mask = UInt32(0b1) &<< odr13_offset - var odr13: UInt8 { - get { UInt8((self.rawValue & (GPIO.ODR.odr13_mask)) >> GPIO.ODR.odr13_offset) } - set { - let preserve = self.rawValue & ~GPIO.ODR.odr13_mask - let shift = (UInt32(newValue) << GPIO.ODR.odr13_offset) & GPIO.ODR.odr13_mask - self.rawValue = preserve | shift - } - } - - static let odr12_offset = UInt32(12) - static let odr12_mask = UInt32(0b1) &<< odr12_offset - var odr12: UInt8 { - get { UInt8((self.rawValue & (GPIO.ODR.odr12_mask)) >> GPIO.ODR.odr12_offset) } - set { - let preserve = self.rawValue & ~GPIO.ODR.odr12_mask - let shift = (UInt32(newValue) << GPIO.ODR.odr12_offset) & GPIO.ODR.odr12_mask - self.rawValue = preserve | shift - } - } - - static let odr11_offset = UInt32(11) - static let odr11_mask = UInt32(0b1) &<< odr11_offset - var odr11: UInt8 { - get { UInt8((self.rawValue & (GPIO.ODR.odr11_mask)) >> GPIO.ODR.odr11_offset) } - set { - let preserve = self.rawValue & ~GPIO.ODR.odr11_mask - let shift = (UInt32(newValue) << GPIO.ODR.odr11_offset) & GPIO.ODR.odr11_mask - self.rawValue = preserve | shift - } - } - - static let odr10_offset = UInt32(10) - static let odr10_mask = UInt32(0b1) &<< odr10_offset - var odr10: UInt8 { - get { UInt8((self.rawValue & (GPIO.ODR.odr10_mask)) >> GPIO.ODR.odr10_offset) } - set { - let preserve = self.rawValue & ~GPIO.ODR.odr10_mask - let shift = (UInt32(newValue) << GPIO.ODR.odr10_offset) & GPIO.ODR.odr10_mask - self.rawValue = preserve | shift - } - } - - static let odr9_offset = UInt32(9) - static let odr9_mask = UInt32(0b1) &<< odr9_offset - var odr9: UInt8 { - get { UInt8((self.rawValue & (GPIO.ODR.odr9_mask)) >> GPIO.ODR.odr9_offset) } - set { - let preserve = self.rawValue & ~GPIO.ODR.odr9_mask - let shift = (UInt32(newValue) << GPIO.ODR.odr9_offset) & GPIO.ODR.odr9_mask - self.rawValue = preserve | shift - } - } - - static let odr8_offset = UInt32(8) - static let odr8_mask = UInt32(0b1) &<< odr8_offset - var odr8: UInt8 { - get { UInt8((self.rawValue & (GPIO.ODR.odr8_mask)) >> GPIO.ODR.odr8_offset) } - set { - let preserve = self.rawValue & ~GPIO.ODR.odr8_mask - let shift = (UInt32(newValue) << GPIO.ODR.odr8_offset) & GPIO.ODR.odr8_mask - self.rawValue = preserve | shift - } - } - - static let odr7_offset = UInt32(7) - static let odr7_mask = UInt32(0b1) &<< odr7_offset - var odr7: UInt8 { - get { UInt8((self.rawValue & (GPIO.ODR.odr7_mask)) >> GPIO.ODR.odr7_offset) } - set { - let preserve = self.rawValue & ~GPIO.ODR.odr7_mask - let shift = (UInt32(newValue) << GPIO.ODR.odr7_offset) & GPIO.ODR.odr7_mask - self.rawValue = preserve | shift - } - } - - static let odr6_offset = UInt32(6) - static let odr6_mask = UInt32(0b1) &<< odr6_offset - var odr6: UInt8 { - get { UInt8((self.rawValue & (GPIO.ODR.odr6_mask)) >> GPIO.ODR.odr6_offset) } - set { - let preserve = self.rawValue & ~GPIO.ODR.odr6_mask - let shift = (UInt32(newValue) << GPIO.ODR.odr6_offset) & GPIO.ODR.odr6_mask - self.rawValue = preserve | shift - } - } - - static let odr5_offset = UInt32(5) - static let odr5_mask = UInt32(0b1) &<< odr5_offset - var odr5: UInt8 { - get { UInt8((self.rawValue & (GPIO.ODR.odr5_mask)) >> GPIO.ODR.odr5_offset) } - set { - let preserve = self.rawValue & ~GPIO.ODR.odr5_mask - let shift = (UInt32(newValue) << GPIO.ODR.odr5_offset) & GPIO.ODR.odr5_mask - self.rawValue = preserve | shift - } - } - - static let odr4_offset = UInt32(4) - static let odr4_mask = UInt32(0b1) &<< odr4_offset - var odr4: UInt8 { - get { UInt8((self.rawValue & (GPIO.ODR.odr4_mask)) >> GPIO.ODR.odr4_offset) } - set { - let preserve = self.rawValue & ~GPIO.ODR.odr4_mask - let shift = (UInt32(newValue) << GPIO.ODR.odr4_offset) & GPIO.ODR.odr4_mask - self.rawValue = preserve | shift - } - } - - static let odr3_offset = UInt32(3) - static let odr3_mask = UInt32(0b1) &<< odr3_offset - var odr3: UInt8 { - get { UInt8((self.rawValue & (GPIO.ODR.odr3_mask)) >> GPIO.ODR.odr3_offset) } - set { - let preserve = self.rawValue & ~GPIO.ODR.odr3_mask - let shift = (UInt32(newValue) << GPIO.ODR.odr3_offset) & GPIO.ODR.odr3_mask - self.rawValue = preserve | shift - } - } - - static let odr2_offset = UInt32(2) - static let odr2_mask = UInt32(0b1) &<< odr2_offset - var odr2: UInt8 { - get { UInt8((self.rawValue & (GPIO.ODR.odr2_mask)) >> GPIO.ODR.odr2_offset) } - set { - let preserve = self.rawValue & ~GPIO.ODR.odr2_mask - let shift = (UInt32(newValue) << GPIO.ODR.odr2_offset) & GPIO.ODR.odr2_mask - self.rawValue = preserve | shift - } - } - - static let odr1_offset = UInt32(1) - static let odr1_mask = UInt32(0b1) &<< odr1_offset - var odr1: UInt8 { - get { UInt8((self.rawValue & (GPIO.ODR.odr1_mask)) >> GPIO.ODR.odr1_offset) } - set { - let preserve = self.rawValue & ~GPIO.ODR.odr1_mask - let shift = (UInt32(newValue) << GPIO.ODR.odr1_offset) & GPIO.ODR.odr1_mask - self.rawValue = preserve | shift - } - } - - static let odr0_offset = UInt32(0) - static let odr0_mask = UInt32(0b1) &<< odr0_offset - var odr0: UInt8 { - get { UInt8((self.rawValue & (GPIO.ODR.odr0_mask)) >> GPIO.ODR.odr0_offset) } - set { - let preserve = self.rawValue & ~GPIO.ODR.odr0_mask - let shift = (UInt32(newValue) << GPIO.ODR.odr0_offset) & GPIO.ODR.odr0_mask - self.rawValue = preserve | shift - } - } - - func od(n: Int) -> UInt8 { - precondition(n >= 0 && n < 16) - let od_offset = n * 1 - let od_mask = UInt32(0b1) &<< od_offset - return UInt8((self.rawValue & (od_mask)) &>> od_offset) - } - - mutating func setOd(n: Int, value: UInt8) { - precondition(n >= 0 && n < 16) - precondition(value < 2) - let od_offset = n * 1 - let od_mask = UInt32(0b1) &<< od_offset - let preserve = self.rawValue & ~od_mask - let shift = (UInt32(value) << od_offset) & od_mask - self.rawValue = preserve | shift - } - - init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - struct BSRR { - var rawValue: UInt32 - - static let br15_offset = UInt32(31) - static let br15_mask = UInt32(0b1) &<< br15_offset - var br15: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << GPIO.BSRR.br15_offset) & GPIO.BSRR.br15_mask - } - } - - static let br14_offset = UInt32(30) - static let br14_mask = UInt32(0b1) &<< br14_offset - var br14: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << GPIO.BSRR.br14_offset) & GPIO.BSRR.br14_mask - } - } - - static let br13_offset = UInt32(29) - static let br13_mask = UInt32(0b1) &<< br13_offset - var br13: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << GPIO.BSRR.br13_offset) & GPIO.BSRR.br13_mask - } - } - - static let br12_offset = UInt32(28) - static let br12_mask = UInt32(0b1) &<< br12_offset - var br12: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << GPIO.BSRR.br12_offset) & GPIO.BSRR.br12_mask - } - } - - static let br11_offset = UInt32(27) - static let br11_mask = UInt32(0b1) &<< br11_offset - var br11: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << GPIO.BSRR.br11_offset) & GPIO.BSRR.br11_mask - } - } - - static let br10_offset = UInt32(26) - static let br10_mask = UInt32(0b1) &<< br10_offset - var br10: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << GPIO.BSRR.br10_offset) & GPIO.BSRR.br10_mask - } - } - - static let br9_offset = UInt32(25) - static let br9_mask = UInt32(0b1) &<< br9_offset - var br9: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << GPIO.BSRR.br9_offset) & GPIO.BSRR.br9_mask - } - } - - static let br8_offset = UInt32(24) - static let br8_mask = UInt32(0b1) &<< br8_offset - var br8: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << GPIO.BSRR.br8_offset) & GPIO.BSRR.br8_mask - } - } - - static let br7_offset = UInt32(23) - static let br7_mask = UInt32(0b1) &<< br7_offset - var br7: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << GPIO.BSRR.br7_offset) & GPIO.BSRR.br7_mask - } - } - - static let br6_offset = UInt32(22) - static let br6_mask = UInt32(0b1) &<< br6_offset - var br6: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << GPIO.BSRR.br6_offset) & GPIO.BSRR.br6_mask - } - } - - static let br5_offset = UInt32(21) - static let br5_mask = UInt32(0b1) &<< br5_offset - var br5: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << GPIO.BSRR.br5_offset) & GPIO.BSRR.br5_mask - } - } - - static let br4_offset = UInt32(20) - static let br4_mask = UInt32(0b1) &<< br4_offset - var br4: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << GPIO.BSRR.br4_offset) & GPIO.BSRR.br4_mask - } - } - - static let br3_offset = UInt32(19) - static let br3_mask = UInt32(0b1) &<< br3_offset - var br3: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << GPIO.BSRR.br3_offset) & GPIO.BSRR.br3_mask - } - } - - static let br2_offset = UInt32(18) - static let br2_mask = UInt32(0b1) &<< br2_offset - var br2: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << GPIO.BSRR.br2_offset) & GPIO.BSRR.br2_mask - } - } - - static let br1_offset = UInt32(17) - static let br1_mask = UInt32(0b1) &<< br1_offset - var br1: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << GPIO.BSRR.br1_offset) & GPIO.BSRR.br1_mask - } - } - - static let br0_offset = UInt32(16) - static let br0_mask = UInt32(0b1) &<< br0_offset - var br0: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << GPIO.BSRR.br0_offset) & GPIO.BSRR.br0_mask - } - } - - static let bs15_offset = UInt32(15) - static let bs15_mask = UInt32(0b1) &<< bs15_offset - var bs15: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << GPIO.BSRR.bs15_offset) & GPIO.BSRR.bs15_mask - } - } - - static let bs14_offset = UInt32(14) - static let bs14_mask = UInt32(0b1) &<< bs14_offset - var bs14: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << GPIO.BSRR.bs14_offset) & GPIO.BSRR.bs14_mask - } - } - - static let bs13_offset = UInt32(13) - static let bs13_mask = UInt32(0b1) &<< bs13_offset - var bs13: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << GPIO.BSRR.bs13_offset) & GPIO.BSRR.bs13_mask - } - } - - static let bs12_offset = UInt32(12) - static let bs12_mask = UInt32(0b1) &<< bs12_offset - var bs12: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << GPIO.BSRR.bs12_offset) & GPIO.BSRR.bs12_mask - } - } - - static let bs11_offset = UInt32(11) - static let bs11_mask = UInt32(0b1) &<< bs11_offset - var bs11: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << GPIO.BSRR.bs11_offset) & GPIO.BSRR.bs11_mask - } - } - - static let bs10_offset = UInt32(10) - static let bs10_mask = UInt32(0b1) &<< bs10_offset - var bs10: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << GPIO.BSRR.bs10_offset) & GPIO.BSRR.bs10_mask - } - } - - static let bs9_offset = UInt32(9) - static let bs9_mask = UInt32(0b1) &<< bs9_offset - var bs9: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << GPIO.BSRR.bs9_offset) & GPIO.BSRR.bs9_mask - } - } - - static let bs8_offset = UInt32(8) - static let bs8_mask = UInt32(0b1) &<< bs8_offset - var bs8: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << GPIO.BSRR.bs8_offset) & GPIO.BSRR.bs8_mask - } - } - - static let bs7_offset = UInt32(7) - static let bs7_mask = UInt32(0b1) &<< bs7_offset - var bs7: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << GPIO.BSRR.bs7_offset) & GPIO.BSRR.bs7_mask - } - } - - static let bs6_offset = UInt32(6) - static let bs6_mask = UInt32(0b1) &<< bs6_offset - var bs6: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << GPIO.BSRR.bs6_offset) & GPIO.BSRR.bs6_mask - } - } - - static let bs5_offset = UInt32(5) - static let bs5_mask = UInt32(0b1) &<< bs5_offset - var bs5: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << GPIO.BSRR.bs5_offset) & GPIO.BSRR.bs5_mask - } - } - - static let bs4_offset = UInt32(4) - static let bs4_mask = UInt32(0b1) &<< bs4_offset - var bs4: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << GPIO.BSRR.bs4_offset) & GPIO.BSRR.bs4_mask - } - } - - static let bs3_offset = UInt32(3) - static let bs3_mask = UInt32(0b1) &<< bs3_offset - var bs3: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << GPIO.BSRR.bs3_offset) & GPIO.BSRR.bs3_mask - } - } - - static let bs2_offset = UInt32(2) - static let bs2_mask = UInt32(0b1) &<< bs2_offset - var bs2: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << GPIO.BSRR.bs2_offset) & GPIO.BSRR.bs2_mask - } - } - - static let bs1_offset = UInt32(1) - static let bs1_mask = UInt32(0b1) &<< bs1_offset - var bs1: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << GPIO.BSRR.bs1_offset) & GPIO.BSRR.bs1_mask - } - } - - static let bs0_offset = UInt32(0) - static let bs0_mask = UInt32(0b1) &<< bs0_offset - var bs0: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << GPIO.BSRR.bs0_offset) & GPIO.BSRR.bs0_mask - } - } - - init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - struct LCKR { - var rawValue: UInt32 - - static let lckk_offset = UInt32(16) - static let lckk_mask = UInt32(0b1) &<< lckk_offset - var lckk: UInt8 { - get { UInt8((self.rawValue & (GPIO.LCKR.lckk_mask)) >> GPIO.LCKR.lckk_offset) } - set { - let preserve = self.rawValue & ~GPIO.LCKR.lckk_mask - let shift = (UInt32(newValue) << GPIO.LCKR.lckk_offset) & GPIO.LCKR.lckk_mask - self.rawValue = preserve | shift - } - } - - static let lck15_offset = UInt32(15) - static let lck15_mask = UInt32(0b1) &<< lck15_offset - var lck15: UInt8 { - get { UInt8((self.rawValue & (GPIO.LCKR.lck15_mask)) >> GPIO.LCKR.lck15_offset) } - set { - let preserve = self.rawValue & ~GPIO.LCKR.lck15_mask - let shift = (UInt32(newValue) << GPIO.LCKR.lck15_offset) & GPIO.LCKR.lck15_mask - self.rawValue = preserve | shift - } - } - - static let lck14_offset = UInt32(14) - static let lck14_mask = UInt32(0b1) &<< lck14_offset - var lck14: UInt8 { - get { UInt8((self.rawValue & (GPIO.LCKR.lck14_mask)) >> GPIO.LCKR.lck14_offset) } - set { - let preserve = self.rawValue & ~GPIO.LCKR.lck14_mask - let shift = (UInt32(newValue) << GPIO.LCKR.lck14_offset) & GPIO.LCKR.lck14_mask - self.rawValue = preserve | shift - } - } - - static let lck13_offset = UInt32(13) - static let lck13_mask = UInt32(0b1) &<< lck13_offset - var lck13: UInt8 { - get { UInt8((self.rawValue & (GPIO.LCKR.lck13_mask)) >> GPIO.LCKR.lck13_offset) } - set { - let preserve = self.rawValue & ~GPIO.LCKR.lck13_mask - let shift = (UInt32(newValue) << GPIO.LCKR.lck13_offset) & GPIO.LCKR.lck13_mask - self.rawValue = preserve | shift - } - } - - static let lck12_offset = UInt32(12) - static let lck12_mask = UInt32(0b1) &<< lck12_offset - var lck12: UInt8 { - get { UInt8((self.rawValue & (GPIO.LCKR.lck12_mask)) >> GPIO.LCKR.lck12_offset) } - set { - let preserve = self.rawValue & ~GPIO.LCKR.lck12_mask - let shift = (UInt32(newValue) << GPIO.LCKR.lck12_offset) & GPIO.LCKR.lck12_mask - self.rawValue = preserve | shift - } - } - - static let lck11_offset = UInt32(11) - static let lck11_mask = UInt32(0b1) &<< lck11_offset - var lck11: UInt8 { - get { UInt8((self.rawValue & (GPIO.LCKR.lck11_mask)) >> GPIO.LCKR.lck11_offset) } - set { - let preserve = self.rawValue & ~GPIO.LCKR.lck11_mask - let shift = (UInt32(newValue) << GPIO.LCKR.lck11_offset) & GPIO.LCKR.lck11_mask - self.rawValue = preserve | shift - } - } - - static let lck10_offset = UInt32(10) - static let lck10_mask = UInt32(0b1) &<< lck10_offset - var lck10: UInt8 { - get { UInt8((self.rawValue & (GPIO.LCKR.lck10_mask)) >> GPIO.LCKR.lck10_offset) } - set { - let preserve = self.rawValue & ~GPIO.LCKR.lck10_mask - let shift = (UInt32(newValue) << GPIO.LCKR.lck10_offset) & GPIO.LCKR.lck10_mask - self.rawValue = preserve | shift - } - } - - static let lck9_offset = UInt32(9) - static let lck9_mask = UInt32(0b1) &<< lck9_offset - var lck9: UInt8 { - get { UInt8((self.rawValue & (GPIO.LCKR.lck9_mask)) >> GPIO.LCKR.lck9_offset) } - set { - let preserve = self.rawValue & ~GPIO.LCKR.lck9_mask - let shift = (UInt32(newValue) << GPIO.LCKR.lck9_offset) & GPIO.LCKR.lck9_mask - self.rawValue = preserve | shift - } - } - - static let lck8_offset = UInt32(8) - static let lck8_mask = UInt32(0b1) &<< lck8_offset - var lck8: UInt8 { - get { UInt8((self.rawValue & (GPIO.LCKR.lck8_mask)) >> GPIO.LCKR.lck8_offset) } - set { - let preserve = self.rawValue & ~GPIO.LCKR.lck8_mask - let shift = (UInt32(newValue) << GPIO.LCKR.lck8_offset) & GPIO.LCKR.lck8_mask - self.rawValue = preserve | shift - } - } - - static let lck7_offset = UInt32(7) - static let lck7_mask = UInt32(0b1) &<< lck7_offset - var lck7: UInt8 { - get { UInt8((self.rawValue & (GPIO.LCKR.lck7_mask)) >> GPIO.LCKR.lck7_offset) } - set { - let preserve = self.rawValue & ~GPIO.LCKR.lck7_mask - let shift = (UInt32(newValue) << GPIO.LCKR.lck7_offset) & GPIO.LCKR.lck7_mask - self.rawValue = preserve | shift - } - } - - static let lck6_offset = UInt32(6) - static let lck6_mask = UInt32(0b1) &<< lck6_offset - var lck6: UInt8 { - get { UInt8((self.rawValue & (GPIO.LCKR.lck6_mask)) >> GPIO.LCKR.lck6_offset) } - set { - let preserve = self.rawValue & ~GPIO.LCKR.lck6_mask - let shift = (UInt32(newValue) << GPIO.LCKR.lck6_offset) & GPIO.LCKR.lck6_mask - self.rawValue = preserve | shift - } - } - - static let lck5_offset = UInt32(5) - static let lck5_mask = UInt32(0b1) &<< lck5_offset - var lck5: UInt8 { - get { UInt8((self.rawValue & (GPIO.LCKR.lck5_mask)) >> GPIO.LCKR.lck5_offset) } - set { - let preserve = self.rawValue & ~GPIO.LCKR.lck5_mask - let shift = (UInt32(newValue) << GPIO.LCKR.lck5_offset) & GPIO.LCKR.lck5_mask - self.rawValue = preserve | shift - } - } - - static let lck4_offset = UInt32(4) - static let lck4_mask = UInt32(0b1) &<< lck4_offset - var lck4: UInt8 { - get { UInt8((self.rawValue & (GPIO.LCKR.lck4_mask)) >> GPIO.LCKR.lck4_offset) } - set { - let preserve = self.rawValue & ~GPIO.LCKR.lck4_mask - let shift = (UInt32(newValue) << GPIO.LCKR.lck4_offset) & GPIO.LCKR.lck4_mask - self.rawValue = preserve | shift - } - } - - static let lck3_offset = UInt32(3) - static let lck3_mask = UInt32(0b1) &<< lck3_offset - var lck3: UInt8 { - get { UInt8((self.rawValue & (GPIO.LCKR.lck3_mask)) >> GPIO.LCKR.lck3_offset) } - set { - let preserve = self.rawValue & ~GPIO.LCKR.lck3_mask - let shift = (UInt32(newValue) << GPIO.LCKR.lck3_offset) & GPIO.LCKR.lck3_mask - self.rawValue = preserve | shift - } - } - - static let lck2_offset = UInt32(2) - static let lck2_mask = UInt32(0b1) &<< lck2_offset - var lck2: UInt8 { - get { UInt8((self.rawValue & (GPIO.LCKR.lck2_mask)) >> GPIO.LCKR.lck2_offset) } - set { - let preserve = self.rawValue & ~GPIO.LCKR.lck2_mask - let shift = (UInt32(newValue) << GPIO.LCKR.lck2_offset) & GPIO.LCKR.lck2_mask - self.rawValue = preserve | shift - } - } - - static let lck1_offset = UInt32(1) - static let lck1_mask = UInt32(0b1) &<< lck1_offset - var lck1: UInt8 { - get { UInt8((self.rawValue & (GPIO.LCKR.lck1_mask)) >> GPIO.LCKR.lck1_offset) } - set { - let preserve = self.rawValue & ~GPIO.LCKR.lck1_mask - let shift = (UInt32(newValue) << GPIO.LCKR.lck1_offset) & GPIO.LCKR.lck1_mask - self.rawValue = preserve | shift - } - } - - static let lck0_offset = UInt32(0) - static let lck0_mask = UInt32(0b1) &<< lck0_offset - var lck0: UInt8 { - get { UInt8((self.rawValue & (GPIO.LCKR.lck0_mask)) >> GPIO.LCKR.lck0_offset) } - set { - let preserve = self.rawValue & ~GPIO.LCKR.lck0_mask - let shift = (UInt32(newValue) << GPIO.LCKR.lck0_offset) & GPIO.LCKR.lck0_mask - self.rawValue = preserve | shift - } - } - - init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - struct AFRL { - var rawValue: UInt32 - - static let afrl7_offset = UInt32(28) - static let afrl7_mask = UInt32(0b1111) &<< afrl7_offset - var afrl7: UInt8 { - get { UInt8((self.rawValue & (GPIO.AFRL.afrl7_mask)) >> GPIO.AFRL.afrl7_offset) } - set { - let preserve = self.rawValue & ~GPIO.AFRL.afrl7_mask - let shift = (UInt32(newValue) << GPIO.AFRL.afrl7_offset) & GPIO.AFRL.afrl7_mask - self.rawValue = preserve | shift - } - } - - static let afrl6_offset = UInt32(24) - static let afrl6_mask = UInt32(0b1111) &<< afrl6_offset - var afrl6: UInt8 { - get { UInt8((self.rawValue & (GPIO.AFRL.afrl6_mask)) >> GPIO.AFRL.afrl6_offset) } - set { - let preserve = self.rawValue & ~GPIO.AFRL.afrl6_mask - let shift = (UInt32(newValue) << GPIO.AFRL.afrl6_offset) & GPIO.AFRL.afrl6_mask - self.rawValue = preserve | shift - } - } - - static let afrl5_offset = UInt32(20) - static let afrl5_mask = UInt32(0b1111) &<< afrl5_offset - var afrl5: UInt8 { - get { UInt8((self.rawValue & (GPIO.AFRL.afrl5_mask)) >> GPIO.AFRL.afrl5_offset) } - set { - let preserve = self.rawValue & ~GPIO.AFRL.afrl5_mask - let shift = (UInt32(newValue) << GPIO.AFRL.afrl5_offset) & GPIO.AFRL.afrl5_mask - self.rawValue = preserve | shift - } - } - - static let afrl4_offset = UInt32(16) - static let afrl4_mask = UInt32(0b1111) &<< afrl4_offset - var afrl4: UInt8 { - get { UInt8((self.rawValue & (GPIO.AFRL.afrl4_mask)) >> GPIO.AFRL.afrl4_offset) } - set { - let preserve = self.rawValue & ~GPIO.AFRL.afrl4_mask - let shift = (UInt32(newValue) << GPIO.AFRL.afrl4_offset) & GPIO.AFRL.afrl4_mask - self.rawValue = preserve | shift - } - } - - static let afrl3_offset = UInt32(12) - static let afrl3_mask = UInt32(0b1111) &<< afrl3_offset - var afrl3: UInt8 { - get { UInt8((self.rawValue & (GPIO.AFRL.afrl3_mask)) >> GPIO.AFRL.afrl3_offset) } - set { - let preserve = self.rawValue & ~GPIO.AFRL.afrl3_mask - let shift = (UInt32(newValue) << GPIO.AFRL.afrl3_offset) & GPIO.AFRL.afrl3_mask - self.rawValue = preserve | shift - } - } - - static let afrl2_offset = UInt32(8) - static let afrl2_mask = UInt32(0b1111) &<< afrl2_offset - var afrl2: UInt8 { - get { UInt8((self.rawValue & (GPIO.AFRL.afrl2_mask)) >> GPIO.AFRL.afrl2_offset) } - set { - let preserve = self.rawValue & ~GPIO.AFRL.afrl2_mask - let shift = (UInt32(newValue) << GPIO.AFRL.afrl2_offset) & GPIO.AFRL.afrl2_mask - self.rawValue = preserve | shift - } - } - - static let afrl1_offset = UInt32(4) - static let afrl1_mask = UInt32(0b1111) &<< afrl1_offset - var afrl1: UInt8 { - get { UInt8((self.rawValue & (GPIO.AFRL.afrl1_mask)) >> GPIO.AFRL.afrl1_offset) } - set { - let preserve = self.rawValue & ~GPIO.AFRL.afrl1_mask - let shift = (UInt32(newValue) << GPIO.AFRL.afrl1_offset) & GPIO.AFRL.afrl1_mask - self.rawValue = preserve | shift - } - } - - static let afrl0_offset = UInt32(0) - static let afrl0_mask = UInt32(0b1111) &<< afrl0_offset - var afrl0: UInt8 { - get { UInt8((self.rawValue & (GPIO.AFRL.afrl0_mask)) >> GPIO.AFRL.afrl0_offset) } - set { - let preserve = self.rawValue & ~GPIO.AFRL.afrl0_mask - let shift = (UInt32(newValue) << GPIO.AFRL.afrl0_offset) & GPIO.AFRL.afrl0_mask - self.rawValue = preserve | shift - } - } - - func af(n: Int) -> UInt8 { - precondition(n >= 0 && n < 8) - let af_offset = n * 4 - let af_mask = UInt32(0b1111) &<< af_offset - return UInt8((self.rawValue & (af_mask)) &>> af_offset) - } - - mutating func setAf(n: Int, value: UInt8) { - precondition(n >= 0 && n < 8) - precondition(value < 16) - let af_offset = n * 4 - let af_mask = UInt32(0b1111) &<< af_offset - let preserve = self.rawValue & ~af_mask - let shift = (UInt32(value) << af_offset) & af_mask - self.rawValue = preserve | shift - } - - init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - struct AFRH { - var rawValue: UInt32 - - static let afrh15_offset = UInt32(28) - static let afrh15_mask = UInt32(0b1111) &<< afrh15_offset - var afrh15: UInt8 { - get { UInt8((self.rawValue & (GPIO.AFRH.afrh15_mask)) >> GPIO.AFRH.afrh15_offset) } - set { - let preserve = self.rawValue & ~GPIO.AFRH.afrh15_mask - let shift = (UInt32(newValue) << GPIO.AFRH.afrh15_offset) & GPIO.AFRH.afrh15_mask - self.rawValue = preserve | shift - } - } - - static let afrh14_offset = UInt32(24) - static let afrh14_mask = UInt32(0b1111) &<< afrh14_offset - var afrh14: UInt8 { - get { UInt8((self.rawValue & (GPIO.AFRH.afrh14_mask)) >> GPIO.AFRH.afrh14_offset) } - set { - let preserve = self.rawValue & ~GPIO.AFRH.afrh14_mask - let shift = (UInt32(newValue) << GPIO.AFRH.afrh14_offset) & GPIO.AFRH.afrh14_mask - self.rawValue = preserve | shift - } - } - - static let afrh13_offset = UInt32(20) - static let afrh13_mask = UInt32(0b1111) &<< afrh13_offset - var afrh13: UInt8 { - get { UInt8((self.rawValue & (GPIO.AFRH.afrh13_mask)) >> GPIO.AFRH.afrh13_offset) } - set { - let preserve = self.rawValue & ~GPIO.AFRH.afrh13_mask - let shift = (UInt32(newValue) << GPIO.AFRH.afrh13_offset) & GPIO.AFRH.afrh13_mask - self.rawValue = preserve | shift - } - } - - static let afrh12_offset = UInt32(16) - static let afrh12_mask = UInt32(0b1111) &<< afrh12_offset - var afrh12: UInt8 { - get { UInt8((self.rawValue & (GPIO.AFRH.afrh12_mask)) >> GPIO.AFRH.afrh12_offset) } - set { - let preserve = self.rawValue & ~GPIO.AFRH.afrh12_mask - let shift = (UInt32(newValue) << GPIO.AFRH.afrh12_offset) & GPIO.AFRH.afrh12_mask - self.rawValue = preserve | shift - } - } - - static let afrh11_offset = UInt32(12) - static let afrh11_mask = UInt32(0b1111) &<< afrh11_offset - var afrh11: UInt8 { - get { UInt8((self.rawValue & (GPIO.AFRH.afrh11_mask)) >> GPIO.AFRH.afrh11_offset) } - set { - let preserve = self.rawValue & ~GPIO.AFRH.afrh11_mask - let shift = (UInt32(newValue) << GPIO.AFRH.afrh11_offset) & GPIO.AFRH.afrh11_mask - self.rawValue = preserve | shift - } - } - - static let afrh10_offset = UInt32(8) - static let afrh10_mask = UInt32(0b1111) &<< afrh10_offset - var afrh10: UInt8 { - get { UInt8((self.rawValue & (GPIO.AFRH.afrh10_mask)) >> GPIO.AFRH.afrh10_offset) } - set { - let preserve = self.rawValue & ~GPIO.AFRH.afrh10_mask - let shift = (UInt32(newValue) << GPIO.AFRH.afrh10_offset) & GPIO.AFRH.afrh10_mask - self.rawValue = preserve | shift - } - } - - static let afrh9_offset = UInt32(4) - static let afrh9_mask = UInt32(0b1111) &<< afrh9_offset - var afrh9: UInt8 { - get { UInt8((self.rawValue & (GPIO.AFRH.afrh9_mask)) >> GPIO.AFRH.afrh9_offset) } - set { - let preserve = self.rawValue & ~GPIO.AFRH.afrh9_mask - let shift = (UInt32(newValue) << GPIO.AFRH.afrh9_offset) & GPIO.AFRH.afrh9_mask - self.rawValue = preserve | shift - } - } - - static let afrh8_offset = UInt32(0) - static let afrh8_mask = UInt32(0b1111) &<< afrh8_offset - var afrh8: UInt8 { - get { UInt8((self.rawValue & (GPIO.AFRH.afrh8_mask)) >> GPIO.AFRH.afrh8_offset) } - set { - let preserve = self.rawValue & ~GPIO.AFRH.afrh8_mask - let shift = (UInt32(newValue) << GPIO.AFRH.afrh8_offset) & GPIO.AFRH.afrh8_mask - self.rawValue = preserve | shift - } - } - - func af(n: Int) -> UInt8 { - precondition(n >= 8 && n < 16) - let af_offset = (n - 8) * 4 - let af_mask = UInt32(0b1111) &<< af_offset - return UInt8((self.rawValue & (af_mask)) &>> af_offset) - } - - mutating func setAf(n: Int, value: UInt8) { - precondition(n >= 8 && n < 16) - precondition(value < 16) - let af_offset = (n - 8) * 4 - let af_mask = UInt32(0b1111) &<< af_offset - let preserve = self.rawValue & ~af_mask - let shift = (UInt32(value) << af_offset) & af_mask - self.rawValue = preserve | shift - } - - init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - struct BRR { - var rawValue: UInt32 - - static let br0_offset = UInt32(0) - static let br0_mask = UInt32(0b1) &<< br0_offset - var br0: UInt8 { - get { UInt8((self.rawValue & (GPIO.BRR.br0_mask)) >> GPIO.BRR.br0_offset) } - set { - let preserve = self.rawValue & ~GPIO.BRR.br0_mask - let shift = (UInt32(newValue) << GPIO.BRR.br0_offset) & GPIO.BRR.br0_mask - self.rawValue = preserve | shift - } - } - - static let br1_offset = UInt32(1) - static let br1_mask = UInt32(0b1) &<< br1_offset - var br1: UInt8 { - get { UInt8((self.rawValue & (GPIO.BRR.br1_mask)) >> GPIO.BRR.br1_offset) } - set { - let preserve = self.rawValue & ~GPIO.BRR.br1_mask - let shift = (UInt32(newValue) << GPIO.BRR.br1_offset) & GPIO.BRR.br1_mask - self.rawValue = preserve | shift - } - } - - static let br2_offset = UInt32(2) - static let br2_mask = UInt32(0b1) &<< br2_offset - var br2: UInt8 { - get { UInt8((self.rawValue & (GPIO.BRR.br2_mask)) >> GPIO.BRR.br2_offset) } - set { - let preserve = self.rawValue & ~GPIO.BRR.br2_mask - let shift = (UInt32(newValue) << GPIO.BRR.br2_offset) & GPIO.BRR.br2_mask - self.rawValue = preserve | shift - } - } - - static let br3_offset = UInt32(3) - static let br3_mask = UInt32(0b1) &<< br3_offset - var br3: UInt8 { - get { UInt8((self.rawValue & (GPIO.BRR.br3_mask)) >> GPIO.BRR.br3_offset) } - set { - let preserve = self.rawValue & ~GPIO.BRR.br3_mask - let shift = (UInt32(newValue) << GPIO.BRR.br3_offset) & GPIO.BRR.br3_mask - self.rawValue = preserve | shift - } - } - - static let br4_offset = UInt32(4) - static let br4_mask = UInt32(0b1) &<< br4_offset - var br4: UInt8 { - get { UInt8((self.rawValue & (GPIO.BRR.br4_mask)) >> GPIO.BRR.br4_offset) } - set { - let preserve = self.rawValue & ~GPIO.BRR.br4_mask - let shift = (UInt32(newValue) << GPIO.BRR.br4_offset) & GPIO.BRR.br4_mask - self.rawValue = preserve | shift - } - } - - static let br5_offset = UInt32(5) - static let br5_mask = UInt32(0b1) &<< br5_offset - var br5: UInt8 { - get { UInt8((self.rawValue & (GPIO.BRR.br5_mask)) >> GPIO.BRR.br5_offset) } - set { - let preserve = self.rawValue & ~GPIO.BRR.br5_mask - let shift = (UInt32(newValue) << GPIO.BRR.br5_offset) & GPIO.BRR.br5_mask - self.rawValue = preserve | shift - } - } - - static let br6_offset = UInt32(6) - static let br6_mask = UInt32(0b1) &<< br6_offset - var br6: UInt8 { - get { UInt8((self.rawValue & (GPIO.BRR.br6_mask)) >> GPIO.BRR.br6_offset) } - set { - let preserve = self.rawValue & ~GPIO.BRR.br6_mask - let shift = (UInt32(newValue) << GPIO.BRR.br6_offset) & GPIO.BRR.br6_mask - self.rawValue = preserve | shift - } - } - - static let br7_offset = UInt32(7) - static let br7_mask = UInt32(0b1) &<< br7_offset - var br7: UInt8 { - get { UInt8((self.rawValue & (GPIO.BRR.br7_mask)) >> GPIO.BRR.br7_offset) } - set { - let preserve = self.rawValue & ~GPIO.BRR.br7_mask - let shift = (UInt32(newValue) << GPIO.BRR.br7_offset) & GPIO.BRR.br7_mask - self.rawValue = preserve | shift - } - } - - static let br8_offset = UInt32(8) - static let br8_mask = UInt32(0b1) &<< br8_offset - var br8: UInt8 { - get { UInt8((self.rawValue & (GPIO.BRR.br8_mask)) >> GPIO.BRR.br8_offset) } - set { - let preserve = self.rawValue & ~GPIO.BRR.br8_mask - let shift = (UInt32(newValue) << GPIO.BRR.br8_offset) & GPIO.BRR.br8_mask - self.rawValue = preserve | shift - } - } - - static let br9_offset = UInt32(9) - static let br9_mask = UInt32(0b1) &<< br9_offset - var br9: UInt8 { - get { UInt8((self.rawValue & (GPIO.BRR.br9_mask)) >> GPIO.BRR.br9_offset) } - set { - let preserve = self.rawValue & ~GPIO.BRR.br9_mask - let shift = (UInt32(newValue) << GPIO.BRR.br9_offset) & GPIO.BRR.br9_mask - self.rawValue = preserve | shift - } - } - - static let br10_offset = UInt32(10) - static let br10_mask = UInt32(0b1) &<< br10_offset - var br10: UInt8 { - get { UInt8((self.rawValue & (GPIO.BRR.br10_mask)) >> GPIO.BRR.br10_offset) } - set { - let preserve = self.rawValue & ~GPIO.BRR.br10_mask - let shift = (UInt32(newValue) << GPIO.BRR.br10_offset) & GPIO.BRR.br10_mask - self.rawValue = preserve | shift - } - } - - static let br11_offset = UInt32(11) - static let br11_mask = UInt32(0b1) &<< br11_offset - var br11: UInt8 { - get { UInt8((self.rawValue & (GPIO.BRR.br11_mask)) >> GPIO.BRR.br11_offset) } - set { - let preserve = self.rawValue & ~GPIO.BRR.br11_mask - let shift = (UInt32(newValue) << GPIO.BRR.br11_offset) & GPIO.BRR.br11_mask - self.rawValue = preserve | shift - } - } - - static let br12_offset = UInt32(12) - static let br12_mask = UInt32(0b1) &<< br12_offset - var br12: UInt8 { - get { UInt8((self.rawValue & (GPIO.BRR.br12_mask)) >> GPIO.BRR.br12_offset) } - set { - let preserve = self.rawValue & ~GPIO.BRR.br12_mask - let shift = (UInt32(newValue) << GPIO.BRR.br12_offset) & GPIO.BRR.br12_mask - self.rawValue = preserve | shift - } - } - - static let br13_offset = UInt32(13) - static let br13_mask = UInt32(0b1) &<< br13_offset - var br13: UInt8 { - get { UInt8((self.rawValue & (GPIO.BRR.br13_mask)) >> GPIO.BRR.br13_offset) } - set { - let preserve = self.rawValue & ~GPIO.BRR.br13_mask - let shift = (UInt32(newValue) << GPIO.BRR.br13_offset) & GPIO.BRR.br13_mask - self.rawValue = preserve | shift - } - } - - static let br14_offset = UInt32(14) - static let br14_mask = UInt32(0b1) &<< br14_offset - var br14: UInt8 { - get { UInt8((self.rawValue & (GPIO.BRR.br14_mask)) >> GPIO.BRR.br14_offset) } - set { - let preserve = self.rawValue & ~GPIO.BRR.br14_mask - let shift = (UInt32(newValue) << GPIO.BRR.br14_offset) & GPIO.BRR.br14_mask - self.rawValue = preserve | shift - } - } - - static let br15_offset = UInt32(15) - static let br15_mask = UInt32(0b1) &<< br15_offset - var br15: UInt8 { - get { UInt8((self.rawValue & (GPIO.BRR.br15_mask)) >> GPIO.BRR.br15_offset) } - set { - let preserve = self.rawValue & ~GPIO.BRR.br15_mask - let shift = (UInt32(newValue) << GPIO.BRR.br15_offset) & GPIO.BRR.br15_mask - self.rawValue = preserve | shift - } - } - - init(rawValue: UInt32) { - self.rawValue = rawValue - } - } -} diff --git a/stm32-lcd-logo/Sources/Application/Geometry/Color.swift b/stm32-lcd-logo/Sources/Application/Geometry/Color.swift new file mode 100644 index 00000000..c553d8f2 --- /dev/null +++ b/stm32-lcd-logo/Sources/Application/Geometry/Color.swift @@ -0,0 +1,18 @@ +// +// Color.swift +// stm32-lcd-logo +// +// Created by Rauhul Varma on 3/12/25. +// + +struct Color { + var red: UInt8 + var green: UInt8 + var blue: UInt8 +} + +extension Color { + static func gray(_ value: UInt8) -> Color { + Color(red: value, green: value, blue: value) + } +} diff --git a/stm32-lcd-logo/Sources/Application/Geometry/Point.swift b/stm32-lcd-logo/Sources/Application/Geometry/Point.swift new file mode 100644 index 00000000..7f3a9944 --- /dev/null +++ b/stm32-lcd-logo/Sources/Application/Geometry/Point.swift @@ -0,0 +1,15 @@ +// +// Point.swift +// stm32-lcd-logo +// +// Created by Rauhul Varma on 3/12/25. +// + +struct Point { + var x: Int + var y: Int + + func offset(by: Point) -> Point { + Point(x: x + by.x, y: y + by.y) + } +} diff --git a/stm32-lcd-logo/Sources/Application/Geometry/Size.swift b/stm32-lcd-logo/Sources/Application/Geometry/Size.swift new file mode 100644 index 00000000..30688054 --- /dev/null +++ b/stm32-lcd-logo/Sources/Application/Geometry/Size.swift @@ -0,0 +1,11 @@ +// +// Size.swift +// stm32-lcd-logo +// +// Created by Rauhul Varma on 3/12/25. +// + +struct Size { + var width: Int + var height: Int +} diff --git a/stm32-lcd-logo/Sources/Application/HAL.swift b/stm32-lcd-logo/Sources/Application/HAL.swift deleted file mode 100644 index 7fe7e484..00000000 --- a/stm32-lcd-logo/Sources/Application/HAL.swift +++ /dev/null @@ -1,689 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// This source file is part of the Swift open source project -// -// Copyright (c) 2023 Apple Inc. and the Swift project authors. -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See https://swift.org/LICENSE.txt for license information -// -//===----------------------------------------------------------------------===// - -import Support - -public protocol GPIOPlatform { - associatedtype Pin - static func configure(_ pin: Pin, _ configuration: GPIOConfiguration) - static func assert(_ pin: Pin, _ configuration: GPIOConfiguration) - static func deassert(_ pin: Pin, _ configuration: GPIOConfiguration) - static func value(_ pin: Pin) -> Bool -} -public enum STM32F746 {} - -public enum Mode { - case input - case output - case alternateFunction - case analog -} - -public enum OutputType { - case pushPull - case openDrain -} - -public enum OutputSpeed { - case low - case medium - case high - case max -} - -public enum Pull { - case `none` - case up - case down -} - -public enum AlternateFunction { - case alternateFunction0 - case alternateFunction1 - case alternateFunction2 - case alternateFunction3 - case alternateFunction4 - case alternateFunction5 - case alternateFunction6 - case alternateFunction7 - case alternateFunction8 - case alternateFunction9 - case alternateFunction10 - case alternateFunction11 - case alternateFunction12 - case alternateFunction13 - case alternateFunction14 - case alternateFunction15 - case `none` -} - -public struct GPIOConfiguration { - public var mode: Mode - public var outputType: OutputType - public var outputSpeed: OutputSpeed - public var pull: Pull - public var alternateFunction: AlternateFunction - public var activeHigh: Bool - - public init( - mode: Mode, outputType: OutputType, outputSpeed: OutputSpeed, pull: Pull, - alternateFunction: AlternateFunction, activeHigh: Bool - ) { - self.mode = mode - self.outputType = outputType - self.outputSpeed = outputSpeed - self.pull = pull - self.alternateFunction = alternateFunction - self.activeHigh = activeHigh - } -} - -public struct HALGPIO { - let pin: Platform.Pin - var configuration: GPIOConfiguration? - - public init(pin: Platform.Pin) { - self.pin = pin - self.configuration = nil - } - - public mutating func configure(configuration: GPIOConfiguration) { - self.configuration = configuration - guard let configuration = self.configuration else { return } - Platform.configure(pin, configuration) - } - - public func assert() { - guard let configuration = self.configuration else { return } - Platform.assert(pin, configuration) - } - - public func deassert() { - guard let configuration = self.configuration else { return } - Platform.deassert(pin, configuration) - } - - public func value() -> Bool { - Platform.value(pin) - } -} - -// MARK: - Abstract GPIO -> Platform GPIO -extension Mode { - var rawValue: UInt8 { - switch self { - case .input: return 0x0 - case .output: return 0x1 - case .alternateFunction: return 0x2 - case .analog: return 0x3 - } - } -} - -extension OutputType { - var rawValue: UInt8 { - switch self { - case .pushPull: - return 0x0 - case .openDrain: - return 0x1 - } - } -} - -extension OutputSpeed { - var rawValue: UInt8 { - switch self { - case .low: return 0x0 - case .medium: return 0x1 - case .high: return 0x2 - case .max: return 0x3 - } - } -} - -extension Pull { - var rawValue: UInt8 { - switch self { - case .none: return 0x0 - case .up: return 0x1 - case .down: return 0x2 - } - } -} - -extension AlternateFunction { - var rawValue: UInt8 { - switch self { - case .alternateFunction0: return 0 - case .alternateFunction1: return 1 - case .alternateFunction2: return 2 - case .alternateFunction3: return 3 - case .alternateFunction4: return 4 - case .alternateFunction5: return 5 - case .alternateFunction6: return 6 - case .alternateFunction7: return 7 - case .alternateFunction8: return 8 - case .alternateFunction9: return 9 - case .alternateFunction10: return 10 - case .alternateFunction11: return 11 - case .alternateFunction12: return 12 - case .alternateFunction13: return 13 - case .alternateFunction14: return 14 - case .alternateFunction15: return 15 - case .none: return .max - } - } -} - -// MARK: - GPIOPlatform Conformance -extension STM32F746: GPIOPlatform { - public struct Pin { - var port: GPIOPort - var number: UInt8 - - public init(port: GPIOPort, number: UInt8) { - self.port = port - self.number = number - } - - func checkValidPin() { - if self.number < 0 || self.number > 16 { - fatalError("STM32F746: invalid GPIO pin number") - } - } - - func setMode(_ mode: Mode) { - var rawValue = self.port.port - rawValue.moder.setModer(n: Int(self.number), value: mode.rawValue) - } - - func setOutputType(_ outputType: OutputType) { - var rawValue = self.port.port - rawValue.otyper.setOt(n: Int(self.number), value: outputType.rawValue) - } - - func setOutputSpeed(_ outputSpeed: OutputSpeed) { - var rawValue = self.port.port - rawValue.ospeedr.setOspeed( - n: Int(self.number), value: outputSpeed.rawValue) - } - - func setPull(_ pull: Pull) { - var rawValue = self.port.port - rawValue.pupdr.setPupd(n: Int(self.number), value: pull.rawValue) - } - - func setAlternateFunction(_ alternateFunction: AlternateFunction) { - var rawValue = self.port.port - if self.number < 8 { - rawValue.afrl.setAf( - n: Int(self.number), value: alternateFunction.rawValue) - } else { - rawValue.afrh.setAf( - n: Int(self.number), value: alternateFunction.rawValue) - } - } - - func setOutputData(_ data: UInt8) { - var rawValue = self.port.port - rawValue.odr.setOd(n: Int(self.number), value: data) - } - - func getInputData() -> UInt8 { - let rawValue = self.port.port - switch self.number { - case 0: return rawValue.idr.idr0 - case 1: return rawValue.idr.idr1 - case 2: return rawValue.idr.idr2 - case 3: return rawValue.idr.idr3 - case 4: return rawValue.idr.idr4 - case 5: return rawValue.idr.idr5 - case 6: return rawValue.idr.idr6 - case 7: return rawValue.idr.idr7 - case 8: return rawValue.idr.idr8 - case 9: return rawValue.idr.idr9 - case 10: return rawValue.idr.idr10 - case 11: return rawValue.idr.idr11 - case 12: return rawValue.idr.idr12 - case 13: return rawValue.idr.idr13 - case 14: return rawValue.idr.idr14 - case 15: return rawValue.idr.idr15 - default: fatalError("STM32F746: invalid GPIO pin number") - } - } - } - - public static func configure(_ pin: Pin, _ configuration: GPIOConfiguration) { - pin.checkValidPin() - - pin.setMode(configuration.mode) - pin.setOutputType(configuration.outputType) - pin.setOutputSpeed(configuration.outputSpeed) - pin.setPull(configuration.pull) - - if configuration.mode == .alternateFunction { - pin.setAlternateFunction(configuration.alternateFunction) - } - - } - - public static func assert(_ pin: Pin, _ configuration: GPIOConfiguration) { - if configuration.activeHigh { - pin.setOutputData(1) - } else { - pin.setOutputData(0) - } - } - - public static func deassert(_ pin: Pin, _ configuration: GPIOConfiguration) { - if configuration.activeHigh { - pin.setOutputData(0) - } else { - pin.setOutputData(1) - } - } - - public static func value(_ pin: Pin) -> Bool { - (pin.getInputData() & 0x1) != 0 - } -} - -public enum GPIOPort: Int { - case a, b, c, d, e, f, g, h, i, j, k - - var port: GPIO { - // swift-format-ignore: NeverForceUnwrap - GPIO( - baseAddress: UnsafeMutableRawPointer( - bitPattern: (0x4002_0000 + 0x400 * UInt(self.rawValue - Self.a.rawValue)) - )!) - } -} - -extension STM32F746 { - public static func enableGPIOPortClock(_ port: GPIOPort) { - // swift-format-ignore: NeverForceUnwrap - var rcc = RCC( - baseAddress: UnsafeMutableRawPointer(bitPattern: 0x4002_3800)!) - switch port { - case .a: rcc.ahb1enr.gpioaen = 1 - case .b: rcc.ahb1enr.gpioben = 1 - case .c: rcc.ahb1enr.gpiocen = 1 - case .d: rcc.ahb1enr.gpioden = 1 - case .e: rcc.ahb1enr.gpioeen = 1 - case .f: rcc.ahb1enr.gpiofen = 1 - case .g: rcc.ahb1enr.gpiogen = 1 - case .h: rcc.ahb1enr.gpiohen = 1 - case .i: rcc.ahb1enr.gpioien = 1 - case .j: rcc.ahb1enr.gpiojen = 1 - case .k: rcc.ahb1enr.gpioken = 1 - } - } - - public static func enableUARTClock(_ uartNum: UInt8) { - // swift-format-ignore: NeverForceUnwrap - var rcc = RCC( - baseAddress: UnsafeMutableRawPointer(bitPattern: 0x4002_3800)!) - switch uartNum { - case 1: rcc.apb2enr.usart1en = 1 - case 2: rcc.apb1enr.usart2en = 1 - case 3: rcc.apb1enr.usart3en = 1 - case 4: rcc.apb1enr.uart4en = 1 - case 5: rcc.apb1enr.uart5en = 1 - case 6: rcc.apb2enr.usart6en = 1 - case 7: rcc.apb1enr.uart7enr = 1 - case 8: rcc.apb1enr.uart8enr = 1 - default: return - } - } - - public static func enableI2CClock(_ i2cNum: UInt8) { - // swift-format-ignore: NeverForceUnwrap - var rcc = RCC( - baseAddress: UnsafeMutableRawPointer(bitPattern: 0x4002_3800)!) - switch i2cNum { - case 1: rcc.apb1enr.i2c1en = 1 - case 2: rcc.apb1enr.i2c2en = 1 - case 3: rcc.apb1enr.i2c3en = 1 - case 4: rcc.apb1enr.i2c4en = 1 - default: return - } - } - - public static func enableSPIClock(_ spiNum: UInt8) { - // swift-format-ignore: NeverForceUnwrap - var rcc = RCC( - baseAddress: UnsafeMutableRawPointer(bitPattern: 0x4002_3800)!) - switch spiNum { - case 1: rcc.apb2enr.spi1en = 1 - case 2: rcc.apb1enr.spi2en = 1 - case 3: rcc.apb1enr.spi3en = 1 - case 4: rcc.apb2enr.spi4enr = 1 - case 5: rcc.apb2enr.spi5enr = 1 - case 6: rcc.apb2enr.spi6enr = 1 - default: return - } - } - - public static func configureFlash() { - let flash = UnsafeMutableRawPointer(bitPattern: (0x4002_3C00)) - // swift-format-ignore: NeverForceUnwrap - let flashAcr = UnsafeMutablePointer( - bitPattern: UInt(bitPattern: flash))! - // Set FLASH_ACR to 0x5 - flashAcr.volatileStore(0x5) - } - - public static func initializeLTCD() { - // swift-format-ignore: NeverForceUnwrap - var rcc = RCC( - baseAddress: UnsafeMutableRawPointer(bitPattern: 0x4002_3800)!) - rcc.cfgr.rawValue = 0 - rcc.cr.hsion = 1 - rcc.cr.csson = 0 - rcc.cr.pllon = 0 - rcc.cr.hsebyp = 0 - rcc.cr.hseon = 1 - while rcc.cr.hserdy == 0 {} - } - - enum LTDCConstants { - static let hsync = 30 - static let vsync = 10 - static let hbp = 13 - static let hfp = 32 - static let vbp = 2 - static let vfp = 2 - - static let pixelSize = 4 - - static let displayWidth = 480 - static let displayHeight = 272 - - static let layerWidth = 50 - static let layerHeight = 50 - } - - public static func configureLTCD() { - // swift-format-ignore: NeverForceUnwrap - var ltdc = LTDC( - baseAddress: UnsafeMutableRawPointer(bitPattern: 0x4001_6800)!) - // swift-format-ignore: NeverForceUnwrap - var rcc = RCC( - baseAddress: UnsafeMutableRawPointer(bitPattern: 0x4002_3800)!) - - rcc.pllcfgr.rawValue = 0 - rcc.pllcfgr.pllm0 = 1 - rcc.pllcfgr.pllm3 = 1 - rcc.pllcfgr.pllm4 = 1 - rcc.pllcfgr.plln4 = 1 - rcc.pllcfgr.plln5 = 1 - rcc.pllcfgr.plln7 = 1 - rcc.pllcfgr.plln8 = 1 - rcc.pllcfgr.pllsrc = 1 - - rcc.cr.pllon = 1 - while rcc.cr.pllrdy == 0 {} - - rcc.cfgr.rawValue &= 0b11 - rcc.cfgr.rawValue |= 0b10 - while rcc.cfgr.rawValue & 0b1100 != 0b1000 {} - - rcc.pllsaicfgr.pllsain = 192 - rcc.pllsaicfgr.pllsair = 5 - rcc.dkcfgr1.pllsaidivr = 1 - - rcc.cr.pllsaion = 1 - while rcc.cr.pllsairdy == 0 {} - - STM32F746.enableGPIOPortClock(.i) - - STM32F746.enableGPIOPortClock(.a) - STM32F746.enableGPIOPortClock(.b) - STM32F746.enableGPIOPortClock(.c) - STM32F746.enableGPIOPortClock(.d) - STM32F746.enableGPIOPortClock(.e) - STM32F746.enableGPIOPortClock(.f) - STM32F746.enableGPIOPortClock(.g) - STM32F746.enableGPIOPortClock(.h) - STM32F746.enableGPIOPortClock(.j) - STM32F746.enableGPIOPortClock(.k) - - var clkPin = HALGPIO(pin: .init(port: .i, number: 14)) - var dePin = HALGPIO(pin: .init(port: .k, number: 7)) - var hsyncPin = HALGPIO(pin: .init(port: .i, number: 10)) - var vsyncPin = HALGPIO(pin: .init(port: .i, number: 9)) - - clkPin.configure( - configuration: .init( - mode: .alternateFunction, outputType: .pushPull, outputSpeed: .high, - pull: .none, alternateFunction: .alternateFunction14, activeHigh: false) - ) - dePin.configure( - configuration: .init( - mode: .alternateFunction, outputType: .pushPull, outputSpeed: .high, - pull: .none, alternateFunction: .alternateFunction14, activeHigh: false) - ) - hsyncPin.configure( - configuration: .init( - mode: .alternateFunction, outputType: .pushPull, outputSpeed: .high, - pull: .none, alternateFunction: .alternateFunction14, activeHigh: false) - ) - vsyncPin.configure( - configuration: .init( - mode: .alternateFunction, outputType: .pushPull, outputSpeed: .high, - pull: .none, alternateFunction: .alternateFunction14, activeHigh: false) - ) - - var r0Pin = HALGPIO(pin: .init(port: .i, number: 15)) - var r1Pin = HALGPIO(pin: .init(port: .j, number: 0)) - var r2Pin = HALGPIO(pin: .init(port: .j, number: 1)) - var r3Pin = HALGPIO(pin: .init(port: .j, number: 2)) - var r4Pin = HALGPIO(pin: .init(port: .j, number: 3)) - var r5Pin = HALGPIO(pin: .init(port: .j, number: 4)) - var r6Pin = HALGPIO(pin: .init(port: .j, number: 5)) - var r7Pin = HALGPIO(pin: .init(port: .j, number: 6)) - - r0Pin.configure( - configuration: .init( - mode: .alternateFunction, outputType: .pushPull, outputSpeed: .high, - pull: .none, alternateFunction: .alternateFunction14, activeHigh: true)) - r1Pin.configure( - configuration: .init( - mode: .alternateFunction, outputType: .pushPull, outputSpeed: .high, - pull: .none, alternateFunction: .alternateFunction14, activeHigh: true)) - r2Pin.configure( - configuration: .init( - mode: .alternateFunction, outputType: .pushPull, outputSpeed: .high, - pull: .none, alternateFunction: .alternateFunction14, activeHigh: true)) - r3Pin.configure( - configuration: .init( - mode: .alternateFunction, outputType: .pushPull, outputSpeed: .high, - pull: .none, alternateFunction: .alternateFunction14, activeHigh: true)) - r4Pin.configure( - configuration: .init( - mode: .alternateFunction, outputType: .pushPull, outputSpeed: .high, - pull: .none, alternateFunction: .alternateFunction14, activeHigh: true)) - r5Pin.configure( - configuration: .init( - mode: .alternateFunction, outputType: .pushPull, outputSpeed: .high, - pull: .none, alternateFunction: .alternateFunction14, activeHigh: true)) - r6Pin.configure( - configuration: .init( - mode: .alternateFunction, outputType: .pushPull, outputSpeed: .high, - pull: .none, alternateFunction: .alternateFunction14, activeHigh: true)) - r7Pin.configure( - configuration: .init( - mode: .alternateFunction, outputType: .pushPull, outputSpeed: .high, - pull: .none, alternateFunction: .alternateFunction14, activeHigh: true)) - - var g0Pin = HALGPIO(pin: .init(port: .j, number: 7)) - var g1Pin = HALGPIO(pin: .init(port: .j, number: 8)) - var g2Pin = HALGPIO(pin: .init(port: .j, number: 9)) - var g3Pin = HALGPIO(pin: .init(port: .j, number: 10)) - var g4Pin = HALGPIO(pin: .init(port: .j, number: 11)) - var g5Pin = HALGPIO(pin: .init(port: .k, number: 0)) - var g6Pin = HALGPIO(pin: .init(port: .k, number: 1)) - var g7Pin = HALGPIO(pin: .init(port: .k, number: 2)) - - g0Pin.configure( - configuration: .init( - mode: .alternateFunction, outputType: .pushPull, outputSpeed: .high, - pull: .none, alternateFunction: .alternateFunction14, activeHigh: true)) - g1Pin.configure( - configuration: .init( - mode: .alternateFunction, outputType: .pushPull, outputSpeed: .high, - pull: .none, alternateFunction: .alternateFunction14, activeHigh: true)) - g2Pin.configure( - configuration: .init( - mode: .alternateFunction, outputType: .pushPull, outputSpeed: .high, - pull: .none, alternateFunction: .alternateFunction14, activeHigh: true)) - g3Pin.configure( - configuration: .init( - mode: .alternateFunction, outputType: .pushPull, outputSpeed: .high, - pull: .none, alternateFunction: .alternateFunction14, activeHigh: true)) - g4Pin.configure( - configuration: .init( - mode: .alternateFunction, outputType: .pushPull, outputSpeed: .high, - pull: .none, alternateFunction: .alternateFunction14, activeHigh: true)) - g5Pin.configure( - configuration: .init( - mode: .alternateFunction, outputType: .pushPull, outputSpeed: .high, - pull: .none, alternateFunction: .alternateFunction14, activeHigh: true)) - g6Pin.configure( - configuration: .init( - mode: .alternateFunction, outputType: .pushPull, outputSpeed: .high, - pull: .none, alternateFunction: .alternateFunction14, activeHigh: true)) - g7Pin.configure( - configuration: .init( - mode: .alternateFunction, outputType: .pushPull, outputSpeed: .high, - pull: .none, alternateFunction: .alternateFunction14, activeHigh: true)) - - var b0Pin = HALGPIO(pin: .init(port: .e, number: 4)) - var b1Pin = HALGPIO(pin: .init(port: .j, number: 13)) - var b2Pin = HALGPIO(pin: .init(port: .j, number: 14)) - var b3Pin = HALGPIO(pin: .init(port: .j, number: 15)) - var b4Pin = HALGPIO(pin: .init(port: .g, number: 12)) - var b5Pin = HALGPIO(pin: .init(port: .k, number: 4)) - var b6Pin = HALGPIO(pin: .init(port: .k, number: 5)) - var b7Pin = HALGPIO(pin: .init(port: .k, number: 6)) - - b0Pin.configure( - configuration: .init( - mode: .alternateFunction, outputType: .pushPull, outputSpeed: .high, - pull: .none, alternateFunction: .alternateFunction14, activeHigh: true)) - b1Pin.configure( - configuration: .init( - mode: .alternateFunction, outputType: .pushPull, outputSpeed: .high, - pull: .none, alternateFunction: .alternateFunction14, activeHigh: true)) - b2Pin.configure( - configuration: .init( - mode: .alternateFunction, outputType: .pushPull, outputSpeed: .high, - pull: .none, alternateFunction: .alternateFunction14, activeHigh: true)) - b3Pin.configure( - configuration: .init( - mode: .alternateFunction, outputType: .pushPull, outputSpeed: .high, - pull: .none, alternateFunction: .alternateFunction14, activeHigh: true)) - b4Pin.configure( - configuration: .init( - mode: .alternateFunction, outputType: .pushPull, outputSpeed: .high, - pull: .none, alternateFunction: .alternateFunction9, - activeHigh: true)) - b5Pin.configure( - configuration: .init( - mode: .alternateFunction, outputType: .pushPull, outputSpeed: .high, - pull: .none, alternateFunction: .alternateFunction14, activeHigh: true)) - b6Pin.configure( - configuration: .init( - mode: .alternateFunction, outputType: .pushPull, outputSpeed: .high, - pull: .none, alternateFunction: .alternateFunction14, activeHigh: true)) - b7Pin.configure( - configuration: .init( - mode: .alternateFunction, outputType: .pushPull, outputSpeed: .high, - pull: .none, alternateFunction: .alternateFunction14, activeHigh: true)) - - var backlightPin = HALGPIO(pin: .init(port: .k, number: 3)) - backlightPin.configure( - configuration: .init( - mode: .output, outputType: .pushPull, outputSpeed: .low, pull: .down, - alternateFunction: .none, activeHigh: true)) - - var lcdDispPin = HALGPIO(pin: .init(port: .i, number: 12)) - lcdDispPin.configure( - configuration: .init( - mode: .output, outputType: .pushPull, outputSpeed: .low, pull: .down, - alternateFunction: .none, activeHigh: true)) - - lcdDispPin.assert() - backlightPin.assert() - rcc.apb2enr.ltdcen = 1 - - ltdc.sscr.vsh = UInt16(LTDCConstants.vsync - 1) - ltdc.sscr.hsw = UInt16(LTDCConstants.hsync - 1) - ltdc.bpcr.ahbp = UInt16(LTDCConstants.hsync + LTDCConstants.hbp - 1) - ltdc.bpcr.avbp = UInt16(LTDCConstants.vsync + LTDCConstants.vbp - 1) - ltdc.awcr.aah = UInt16( - LTDCConstants.displayHeight + LTDCConstants.vsync + LTDCConstants.vbp - 1 - ) - ltdc.awcr.aav = UInt16( - LTDCConstants.displayWidth + LTDCConstants.hsync + LTDCConstants.hbp - 1) - ltdc.twcr.totalw = UInt16( - LTDCConstants.displayWidth + LTDCConstants.hsync + LTDCConstants.hbp - + LTDCConstants.hfp - 1) - ltdc.twcr.totalh = UInt16( - LTDCConstants.displayHeight + LTDCConstants.vsync + LTDCConstants.vbp - + LTDCConstants.vfp - 1) - - ltdc.bccr.rawValue = 0x00_00_00_00 // background color - - setLayer2Position(Point(x: 0, y: 0)) - - ltdc.l2pfcr.rawValue = 0 // Format ARGB8888 - ltdc.l2cfbar.rawValue = UInt32(UInt(bitPattern: logoPixelDataStartPointer)) - ltdc.l2cacr.consta = 255 - ltdc.l2bfcr.bf1 = 5 - ltdc.l2bfcr.bf2 = 4 - ltdc.l2cfblr.rawValue = - UInt32(UInt32(LTDCConstants.pixelSize * LTDCConstants.layerWidth) << 16) - | UInt32(LTDCConstants.pixelSize * LTDCConstants.layerWidth + 3) - ltdc.l2cfblnr.cfblnbr = UInt16(LTDCConstants.layerHeight) - ltdc.l2cr.len = 1 - - ltdc.srcr.vbr = 1 // reload - - ltdc.gcr.ltdcen = 1 - } - - static func setLayer2Position(_ point: Point) { - // swift-format-ignore: NeverForceUnwrap - var ltdc = LTDC( - baseAddress: UnsafeMutableRawPointer(bitPattern: 0x4001_6800)!) - - let i: Int = - ((LTDCConstants.layerWidth + LTDCConstants.hbp + LTDCConstants.hsync - 1 - + point.x) << 16) | (LTDCConstants.hbp + LTDCConstants.hsync + point.x) - ltdc.l2whpcr.rawValue = UInt32(i) - let j: Int = - ((LTDCConstants.layerHeight + LTDCConstants.vsync + LTDCConstants.vbp - 1 - + point.y) << 16) | (LTDCConstants.vsync + LTDCConstants.vbp + point.y) - ltdc.l2wvpcr.rawValue = UInt32(j) - ltdc.srcr.vbr = 1 - } - - static func setBackgroundColor(_ color: Color) { - // swift-format-ignore: NeverForceUnwrap - var ltdc = LTDC( - baseAddress: UnsafeMutableRawPointer(bitPattern: 0x4001_6800)!) - - ltdc.bccr.rawValue = UInt32(color.r | (color.g << 8) | (color.b << 16)) - } -} diff --git a/stm32-lcd-logo/Sources/Application/HAL/GPIOA+Helpers.swift b/stm32-lcd-logo/Sources/Application/HAL/GPIOA+Helpers.swift new file mode 100644 index 00000000..1348a90a --- /dev/null +++ b/stm32-lcd-logo/Sources/Application/HAL/GPIOA+Helpers.swift @@ -0,0 +1,122 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2024 Apple Inc. and the Swift project authors. +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// + +extension GPIOA { + public enum Port: Int { + case a, b, c, d, e, f, g, h, i, j, k + } + + enum Mode: UInt32 { + case input = 0x0 + case output = 0x1 + case alternateFunction = 0x2 + case analog = 0x3 + } + + enum OutputType: UInt32 { + case pushPull = 0x0 + case openDrain = 0x1 + } + + enum OutputSpeed: UInt32 { + case low = 0x0 + case medium = 0x1 + case high = 0x2 + case max = 0x3 + } + + enum Pull: UInt32 { + case `none` = 0x0 + case up = 0x1 + case down = 0x2 + } + + struct Configuration { + var mode: Mode + var outputType: OutputType + var outputSpeed: OutputSpeed + var pull: Pull + var alternateFunction: UInt32 + } + + func configure(pin: Int, as configuration: Configuration) { + self.moder.modify { rw in + rw.raw.storage.set( + value: configuration.mode.rawValue, + mask: 0b11, + offset: pin * 2) + } + + // Comprised of 16 x 1 bit fields. + self.otyper.modify { rw in + rw.raw.storage.set( + value: configuration.outputType.rawValue, + mask: 0b1, + offset: pin) + } + + // Comprised of 16 x 2 bit fields. + self.ospeedr.modify { rw in + rw.raw.storage.set( + value: configuration.outputSpeed.rawValue, + mask: 0b11, + offset: pin * 2) + } + + // Comprised of 16 x 2 bit fields. + self.pupdr.modify { rw in + rw.raw.storage.set( + value: configuration.pull.rawValue, + mask: 0b11, + offset: pin * 2) + } + + // Comprised of 16 x 4 bit fields, split across 2 registers. + if pin < 8 { + self.afrl.modify { rw in + rw.raw.storage.set( + value: configuration.alternateFunction, + mask: 0b1111, + offset: pin * 4) + } + } else { + self.afrh.modify { rw in + rw.raw.storage.set( + value: configuration.alternateFunction, + mask: 0b1111, + offset: (pin - 8) * 4) + } + } + } + + func set(pin: Int, to value: Bool) { + // Lower 16 bits are set, upper 16 bits are reset. + if value { + self.bsrr.write { $0.raw.storage = 1 << pin } + } else { + self.bsrr.write { $0.raw.storage = 1 << (pin + 16) } + } + } +} + +extension UInt32 { + fileprivate func get(mask: Self, offset: UInt8) -> Self { + let mask = mask &<< offset + return (self & mask) &>> offset + } + + fileprivate mutating func set(value: Self, mask: Self, offset: Int) { + let mask = mask &<< offset + let oldValue: UInt32 = self & ~mask + let newValue: UInt32 = (value &<< offset) & mask + self = oldValue | newValue + } +} diff --git a/stm32-lcd-logo/Sources/Application/HAL/LTDC+Helpers.swift b/stm32-lcd-logo/Sources/Application/HAL/LTDC+Helpers.swift new file mode 100644 index 00000000..b45019ca --- /dev/null +++ b/stm32-lcd-logo/Sources/Application/HAL/LTDC+Helpers.swift @@ -0,0 +1,227 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2024 Apple Inc. and the Swift project authors. +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// + +import Support + +extension LTDC { + enum Constants { + static let hsync = 30 + static let vsync = 10 + static let hbp = 13 + static let hfp = 32 + static let vbp = 2 + static let vfp = 2 + + static let pixelSize = 4 + + static let displayWidth = 480 + static let displayHeight = 272 + + static let layerWidth = 50 + static let layerHeight = 50 + } + + func configure() { + rcc.pllcfgr.write { + $0.raw.pllm = 25 + $0.raw.plln = 432 + $0.pllsrc = .HSE + } + + rcc.cr.modify { $1.raw.pllon = 1 } + while rcc.cr.read().raw.pllrdy != 1 {} + + // FIXME: use named fields + rcc.cfgr.modify { + $0.raw.storage &= 0b11 + $0.raw.storage |= 0b10 + } + while rcc.cfgr.read().raw.storage & 0b1100 != 0b1000 {} + + rcc.pllsaicfgr.modify { + $0.raw.pllsain = 192 + $0.raw.pllsair = 5 + } + rcc.dckcfgr1.modify { $0.pllsaidivr = .Div4 } + + rcc.cr.modify { $1.raw.pllsaion = 1 } + while rcc.cr.read().raw.pllsairdy != 1 {} + + rcc.enableGPIOPortClock(.a) + rcc.enableGPIOPortClock(.b) + rcc.enableGPIOPortClock(.c) + rcc.enableGPIOPortClock(.d) + rcc.enableGPIOPortClock(.e) + rcc.enableGPIOPortClock(.f) + rcc.enableGPIOPortClock(.g) + rcc.enableGPIOPortClock(.h) + rcc.enableGPIOPortClock(.i) + rcc.enableGPIOPortClock(.j) + rcc.enableGPIOPortClock(.k) + + let pinConfiguration = GPIOA.Configuration( + mode: .alternateFunction, + outputType: .pushPull, + outputSpeed: .high, + pull: .none, + alternateFunction: 14) + + let clkPin = 14 + let dePin = 7 + let hsyncPin = 10 + let vsyncPin = 9 + + gpioi.configure(pin: clkPin, as: pinConfiguration) + gpiok.configure(pin: dePin, as: pinConfiguration) + gpioi.configure(pin: hsyncPin, as: pinConfiguration) + gpioi.configure(pin: vsyncPin, as: pinConfiguration) + + let r0Pin = 15 + let r1Pin = 0 + let r2Pin = 1 + let r3Pin = 2 + let r4Pin = 3 + let r5Pin = 4 + let r6Pin = 5 + let r7Pin = 6 + + gpioi.configure(pin: r0Pin, as: pinConfiguration) + gpioj.configure(pin: r1Pin, as: pinConfiguration) + gpioj.configure(pin: r2Pin, as: pinConfiguration) + gpioj.configure(pin: r3Pin, as: pinConfiguration) + gpioj.configure(pin: r4Pin, as: pinConfiguration) + gpioj.configure(pin: r5Pin, as: pinConfiguration) + gpioj.configure(pin: r6Pin, as: pinConfiguration) + gpioj.configure(pin: r7Pin, as: pinConfiguration) + + let g0Pin = 7 + let g1Pin = 8 + let g2Pin = 9 + let g3Pin = 10 + let g4Pin = 11 + let g5Pin = 0 + let g6Pin = 1 + let g7Pin = 2 + + gpioj.configure(pin: g0Pin, as: pinConfiguration) + gpioj.configure(pin: g1Pin, as: pinConfiguration) + gpioj.configure(pin: g2Pin, as: pinConfiguration) + gpioj.configure(pin: g3Pin, as: pinConfiguration) + gpioj.configure(pin: g4Pin, as: pinConfiguration) + gpiok.configure(pin: g5Pin, as: pinConfiguration) + gpiok.configure(pin: g6Pin, as: pinConfiguration) + gpiok.configure(pin: g7Pin, as: pinConfiguration) + + let b0Pin = 4 + let b1Pin = 13 + let b2Pin = 14 + let b3Pin = 15 + let b4Pin = 12 + let b5Pin = 4 + let b6Pin = 5 + let b7Pin = 6 + + gpioe.configure(pin: b0Pin, as: pinConfiguration) + gpioj.configure(pin: b1Pin, as: pinConfiguration) + gpioj.configure(pin: b2Pin, as: pinConfiguration) + gpioj.configure(pin: b3Pin, as: pinConfiguration) + gpiog.configure(pin: b4Pin, as: pinConfiguration) + gpiok.configure(pin: b5Pin, as: pinConfiguration) + gpiok.configure(pin: b6Pin, as: pinConfiguration) + gpiok.configure(pin: b7Pin, as: pinConfiguration) + + let lcdPinConfiguration = GPIOA.Configuration( + mode: .output, + outputType: .pushPull, + outputSpeed: .low, + pull: .down, + alternateFunction: 0) + + let backlightPin = 3 + let lcdDispPin = 12 + + gpiok.configure(pin: backlightPin, as: lcdPinConfiguration) + gpioi.configure(pin: lcdDispPin, as: lcdPinConfiguration) + + gpioi.set(pin: lcdDispPin, to: true) + gpiok.set(pin: backlightPin, to: true) + + rcc.apb2enr.modify { $0.raw.ltdcen = 1 } + + self.sscr.modify { $0.raw.vsh = UInt32(Constants.vsync - 1) } + self.sscr.modify { $0.raw.hsw = UInt32(Constants.hsync - 1) } + self.bpcr.modify { + $0.raw.ahbp = UInt32(Constants.hsync + Constants.hbp - 1) + } + self.bpcr.modify { + $0.raw.avbp = UInt32(Constants.vsync + Constants.vbp - 1) + } + self.awcr.modify { + $0.raw.aah = UInt32( + Constants.displayHeight + Constants.vsync + Constants.vbp - 1) + } + self.awcr.modify { + $0.raw.aaw = UInt32( + Constants.displayWidth + Constants.hsync + Constants.hbp - 1) + } + self.twcr.modify { + $0.raw.totalw = UInt32( + Constants.displayWidth + Constants.hsync + Constants.hbp + Constants.hfp + - 1) + } + self.twcr.modify { + $0.raw.totalh = UInt32( + Constants.displayHeight + Constants.vsync + Constants.vbp + + Constants.vfp - 1) + } + + self.layer[1].pfcr.modify { $0.raw.storage = 0 } // Format ARGB8888 + self.layer[1].cfbar.modify { + $0.raw.storage = UInt32(UInt(bitPattern: logoPixelDataStartPointer)) + } + self.layer[1].cacr.modify { $0.raw.consta = 255 } + self.layer[1].bfcr.modify { $0.raw.bf1 = 5 } + self.layer[1].bfcr.modify { $0.raw.bf2 = 4 } + self.layer[1].cfblr.modify { + $0.raw.storage = + UInt32(UInt32(Constants.pixelSize * Constants.layerWidth) << 16) + | UInt32(Constants.pixelSize * Constants.layerWidth + 3) + } + self.layer[1].cfblnr.modify { + $0.raw.cfblnbr = UInt32(Constants.layerHeight) + } + self.layer[1].cr.modify { $0.raw.len = 1 } + + self.srcr.modify { $0.raw.vbr = 1 } // reload + + self.gcr.modify { $1.raw.ltdcen = 1 } + } + + func set(layer: Int, position point: Point) { + let i: Int = + ((Constants.layerWidth + Constants.hbp + Constants.hsync - 1 + + point.x) << 16) | (Constants.hbp + Constants.hsync + point.x) + self.layer[layer].whpcr.modify { $0.raw.storage = UInt32(i) } + let j: Int = + ((Constants.layerHeight + Constants.vsync + Constants.vbp - 1 + + point.y) << 16) | (Constants.vsync + Constants.vbp + point.y) + self.layer[layer].wvpcr.modify { $0.raw.storage = UInt32(j) } + self.srcr.modify { $0.raw.vbr = 1 } + } + + func set(backgroundColor: Color) { + self.bccr.modify { + $0.raw.bcred = UInt32(backgroundColor.red) + $0.raw.bcgreen = UInt32(backgroundColor.green) + $0.raw.bcblue = UInt32(backgroundColor.blue) + } + } +} diff --git a/stm32-lcd-logo/Sources/Application/HAL/RCC+Helpers.swift b/stm32-lcd-logo/Sources/Application/HAL/RCC+Helpers.swift new file mode 100644 index 00000000..84488921 --- /dev/null +++ b/stm32-lcd-logo/Sources/Application/HAL/RCC+Helpers.swift @@ -0,0 +1,53 @@ +extension RCC { + func enableGPIOPortClock(_ port: GPIOA.Port) { + switch port { + case .a: self.ahb1enr.modify { $0.raw.gpioaen = 1 } + case .b: self.ahb1enr.modify { $0.raw.gpioben = 1 } + case .c: self.ahb1enr.modify { $0.raw.gpiocen = 1 } + case .d: self.ahb1enr.modify { $0.raw.gpioden = 1 } + case .e: self.ahb1enr.modify { $0.raw.gpioeen = 1 } + case .f: self.ahb1enr.modify { $0.raw.gpiofen = 1 } + case .g: self.ahb1enr.modify { $0.raw.gpiogen = 1 } + case .h: self.ahb1enr.modify { $0.raw.gpiohen = 1 } + case .i: self.ahb1enr.modify { $0.raw.gpioien = 1 } + case .j: self.ahb1enr.modify { $0.raw.gpiojen = 1 } + case .k: self.ahb1enr.modify { $0.raw.gpioken = 1 } + } + } + + func enableUARTClock(_ uartNum: UInt8) { + switch uartNum { + case 1: self.apb2enr.modify { $0.raw.usart1en = 1 } + case 2: self.apb1enr.modify { $0.raw.usart2en = 1 } + case 3: self.apb1enr.modify { $0.raw.usart3en = 1 } + case 4: self.apb1enr.modify { $0.raw.uart4en = 1 } + case 5: self.apb1enr.modify { $0.raw.uart5en = 1 } + case 6: self.apb2enr.modify { $0.raw.usart6en = 1 } + case 7: self.apb1enr.modify { $0.raw.uart7en = 1 } + case 8: self.apb1enr.modify { $0.raw.uart8en = 1 } + default: fatalError("Invalid UART number") + } + } + + func enableI2CClock(_ i2cNum: UInt8) { + switch i2cNum { + case 1: self.apb1enr.modify { $0.raw.i2c1en = 1 } + case 2: self.apb1enr.modify { $0.raw.i2c2en = 1 } + case 3: self.apb1enr.modify { $0.raw.i2c3en = 1 } + case 4: self.apb1enr.modify { $0.raw.i2c4en = 1 } + default: fatalError("Invalid I2C number") + } + } + + func enableSPIClock(_ spiNum: UInt8) { + switch spiNum { + case 1: self.apb2enr.modify { $0.raw.spi1en = 1 } + case 2: self.apb1enr.modify { $0.raw.spi2en = 1 } + case 3: self.apb1enr.modify { $0.raw.spi3en = 1 } + case 4: self.apb2enr.modify { $0.raw.spi4en = 1 } + case 5: self.apb2enr.modify { $0.raw.spi5en = 1 } + case 6: self.apb2enr.modify { $0.raw.spi6en = 1 } + default: fatalError("Invalid SPI number") + } + } +} diff --git a/stm32-lcd-logo/Sources/Application/LTDC.swift b/stm32-lcd-logo/Sources/Application/LTDC.swift deleted file mode 100644 index 2a1446d6..00000000 --- a/stm32-lcd-logo/Sources/Application/LTDC.swift +++ /dev/null @@ -1,1425 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// This source file is part of the Swift open source project -// -// Copyright (c) 2023 Apple Inc. and the Swift project authors. -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See https://swift.org/LICENSE.txt for license information -// -//===----------------------------------------------------------------------===// - -// swift-format-ignore-file - -/// LCD-TFT Controller -public struct LTDC { - public var baseAddress: UnsafeMutableRawPointer - - enum Offsets { - static let SSCR: Int32 = 0x8 - static let BPCR: Int32 = 0xc - static let AWCR: Int32 = 0x10 - static let TWCR: Int32 = 0x14 - static let GCR: Int32 = 0x18 - static let SRCR: Int32 = 0x24 - static let BCCR: Int32 = 0x2c - static let IER: Int32 = 0x34 - static let ISR: Int32 = 0x38 - static let ICR: Int32 = 0x3c - static let LIPCR: Int32 = 0x40 - static let CPSR: Int32 = 0x44 - static let CDSR: Int32 = 0x48 - static let L1CR: Int32 = 0x84 - static let L1WHPCR: Int32 = 0x88 - static let L1WVPCR: Int32 = 0x8c - static let L1CKCR: Int32 = 0x90 - static let L1PFCR: Int32 = 0x94 - static let L1CACR: Int32 = 0x98 - static let L1DCCR: Int32 = 0x9c - static let L1BFCR: Int32 = 0xa0 - static let L1CFBAR: Int32 = 0xac - static let L1CFBLR: Int32 = 0xb0 - static let L1CFBLNR: Int32 = 0xb4 - static let L1CLUTWR: Int32 = 0xc4 - static let L2CR: Int32 = 0x104 - static let L2WHPCR: Int32 = 0x108 - static let L2WVPCR: Int32 = 0x10c - static let L2CKCR: Int32 = 0x110 - static let L2PFCR: Int32 = 0x114 - static let L2CACR: Int32 = 0x118 - static let L2DCCR: Int32 = 0x11c - static let L2BFCR: Int32 = 0x120 - static let L2CFBAR: Int32 = 0x12c - static let L2CFBLR: Int32 = 0x130 - static let L2CFBLNR: Int32 = 0x134 - static let L2CLUTWR: Int32 = 0x144 - } - - private func ld(_ offset: Int32) -> UInt32 { - UnsafeMutablePointer(bitPattern: UInt(bitPattern: UnsafeMutableRawPointer(baseAddress).advanced(by: Int(offset))))!.volatileLoad() - } - - private func st(_ offset: Int32, _ value: UInt32) { - UnsafeMutablePointer(bitPattern: UInt(bitPattern: UnsafeMutableRawPointer(baseAddress).advanced(by: Int(offset))))!.volatileStore(value) - } - - /// Synchronization Size Configuration Register - public var sscr: SSCR { - get { SSCR(rawValue: ld(Offsets.SSCR)) } - set { st(Offsets.SSCR, newValue.rawValue) } - } - /// Back Porch Configuration Register - public var bpcr: BPCR { - get { BPCR(rawValue: ld(Offsets.BPCR)) } - set { st(Offsets.BPCR, newValue.rawValue) } - } - /// Active Width Configuration Register - public var awcr: AWCR { - get { AWCR(rawValue: ld(Offsets.AWCR)) } - set { st(Offsets.AWCR, newValue.rawValue) } - } - /// Total Width Configuration Register - public var twcr: TWCR { - get { TWCR(rawValue: ld(Offsets.TWCR)) } - set { st(Offsets.TWCR, newValue.rawValue) } - } - /// Global Control Register - public var gcr: GCR { - get { GCR(rawValue: ld(Offsets.GCR)) } - set { st(Offsets.GCR, newValue.rawValue) } - } - /// Shadow Reload Configuration Register - public var srcr: SRCR { - get { SRCR(rawValue: ld(Offsets.SRCR)) } - set { st(Offsets.SRCR, newValue.rawValue) } - } - /// Background Color Configuration Register - public var bccr: BCCR { - get { BCCR(rawValue: ld(Offsets.BCCR)) } - set { st(Offsets.BCCR, newValue.rawValue) } - } - /// Interrupt Enable Register - public var ier: IER { - get { IER(rawValue: ld(Offsets.IER)) } - set { st(Offsets.IER, newValue.rawValue) } - } - /// Interrupt Status Register - public var isr: ISR { - get { ISR(rawValue: ld(Offsets.ISR)) } - set { st(Offsets.ISR, newValue.rawValue) } - } - /// Interrupt Clear Register - public var icr: ICR { - get { ICR(rawValue: ld(Offsets.ICR)) } - set { st(Offsets.ICR, newValue.rawValue) } - } - /// Line Interrupt Position Configuration Register - public var lipcr: LIPCR { - get { LIPCR(rawValue: ld(Offsets.LIPCR)) } - set { st(Offsets.LIPCR, newValue.rawValue) } - } - /// Current Position Status Register - public var cpsr: CPSR { - get { CPSR(rawValue: ld(Offsets.CPSR)) } - set { st(Offsets.CPSR, newValue.rawValue) } - } - /// Current Display Status Register - public var cdsr: CDSR { - get { CDSR(rawValue: ld(Offsets.CDSR)) } - set { st(Offsets.CDSR, newValue.rawValue) } - } - /// Layerx Control Register - public var l1cr: L1CR { - get { L1CR(rawValue: ld(Offsets.L1CR)) } - set { st(Offsets.L1CR, newValue.rawValue) } - } - /// Layerx Window Horizontal Position Configuration Register - public var l1whpcr: L1WHPCR { - get { L1WHPCR(rawValue: ld(Offsets.L1WHPCR)) } - set { st(Offsets.L1WHPCR, newValue.rawValue) } - } - /// Layerx Window Vertical Position Configuration Register - public var l1wvpcr: L1WVPCR { - get { L1WVPCR(rawValue: ld(Offsets.L1WVPCR)) } - set { st(Offsets.L1WVPCR, newValue.rawValue) } - } - /// Layerx Color Keying Configuration Register - public var l1ckcr: L1CKCR { - get { L1CKCR(rawValue: ld(Offsets.L1CKCR)) } - set { st(Offsets.L1CKCR, newValue.rawValue) } - } - /// Layerx Pixel Format Configuration Register - public var l1pfcr: L1PFCR { - get { L1PFCR(rawValue: ld(Offsets.L1PFCR)) } - set { st(Offsets.L1PFCR, newValue.rawValue) } - } - /// Layerx Constant Alpha Configuration Register - public var l1cacr: L1CACR { - get { L1CACR(rawValue: ld(Offsets.L1CACR)) } - set { st(Offsets.L1CACR, newValue.rawValue) } - } - /// Layerx Default Color Configuration Register - public var l1dccr: L1DCCR { - get { L1DCCR(rawValue: ld(Offsets.L1DCCR)) } - set { st(Offsets.L1DCCR, newValue.rawValue) } - } - /// Layerx Blending Factors Configuration Register - public var l1bfcr: L1BFCR { - get { L1BFCR(rawValue: ld(Offsets.L1BFCR)) } - set { st(Offsets.L1BFCR, newValue.rawValue) } - } - /// Layerx Color Frame Buffer Address Register - public var l1cfbar: L1CFBAR { - get { L1CFBAR(rawValue: ld(Offsets.L1CFBAR)) } - set { st(Offsets.L1CFBAR, newValue.rawValue) } - } - /// Layerx Color Frame Buffer Length Register - public var l1cfblr: L1CFBLR { - get { L1CFBLR(rawValue: ld(Offsets.L1CFBLR)) } - set { st(Offsets.L1CFBLR, newValue.rawValue) } - } - /// Layerx ColorFrame Buffer Line Number Register - public var l1cfblnr: L1CFBLNR { - get { L1CFBLNR(rawValue: ld(Offsets.L1CFBLNR)) } - set { st(Offsets.L1CFBLNR, newValue.rawValue) } - } - /// Layerx CLUT Write Register - public var l1clutwr: L1CLUTWR { - get { L1CLUTWR(rawValue: ld(Offsets.L1CLUTWR)) } - set { st(Offsets.L1CLUTWR, newValue.rawValue) } - } - /// Layerx Control Register - public var l2cr: L2CR { - get { L2CR(rawValue: ld(Offsets.L2CR)) } - set { st(Offsets.L2CR, newValue.rawValue) } - } - /// Layerx Window Horizontal Position Configuration Register - public var l2whpcr: L2WHPCR { - get { L2WHPCR(rawValue: ld(Offsets.L2WHPCR)) } - set { st(Offsets.L2WHPCR, newValue.rawValue) } - } - /// Layerx Window Vertical Position Configuration Register - public var l2wvpcr: L2WVPCR { - get { L2WVPCR(rawValue: ld(Offsets.L2WVPCR)) } - set { st(Offsets.L2WVPCR, newValue.rawValue) } - } - /// Layerx Color Keying Configuration Register - public var l2ckcr: L2CKCR { - get { L2CKCR(rawValue: ld(Offsets.L2CKCR)) } - set { st(Offsets.L2CKCR, newValue.rawValue) } - } - /// Layerx Pixel Format Configuration Register - public var l2pfcr: L2PFCR { - get { L2PFCR(rawValue: ld(Offsets.L2PFCR)) } - set { st(Offsets.L2PFCR, newValue.rawValue) } - } - /// Layerx Constant Alpha Configuration Register - public var l2cacr: L2CACR { - get { L2CACR(rawValue: ld(Offsets.L2CACR)) } - set { st(Offsets.L2CACR, newValue.rawValue) } - } - /// Layerx Default Color Configuration Register - public var l2dccr: L2DCCR { - get { L2DCCR(rawValue: ld(Offsets.L2DCCR)) } - set { st(Offsets.L2DCCR, newValue.rawValue) } - } - /// Layerx Blending Factors Configuration Register - public var l2bfcr: L2BFCR { - get { L2BFCR(rawValue: ld(Offsets.L2BFCR)) } - set { st(Offsets.L2BFCR, newValue.rawValue) } - } - /// Layerx Color Frame Buffer Address Register - public var l2cfbar: L2CFBAR { - get { L2CFBAR(rawValue: ld(Offsets.L2CFBAR)) } - set { st(Offsets.L2CFBAR, newValue.rawValue) } - } - /// Layerx Color Frame Buffer Length Register - public var l2cfblr: L2CFBLR { - get { L2CFBLR(rawValue: ld(Offsets.L2CFBLR)) } - set { st(Offsets.L2CFBLR, newValue.rawValue) } - } - /// Layerx ColorFrame Buffer Line Number Register - public var l2cfblnr: L2CFBLNR { - get { L2CFBLNR(rawValue: ld(Offsets.L2CFBLNR)) } - set { st(Offsets.L2CFBLNR, newValue.rawValue) } - } - /// Layerx CLUT Write Register - public var l2clutwr: L2CLUTWR { - get { L2CLUTWR(rawValue: ld(Offsets.L2CLUTWR)) } - set { st(Offsets.L2CLUTWR, newValue.rawValue) } - } -} - -extension LTDC { - public struct SSCR { - public var rawValue: UInt32 - - static let hsw_offset = UInt32(16) - static let hsw_mask = UInt32(0b1111111111) &<< hsw_offset - public var hsw: UInt16 { - get { UInt16((self.rawValue & (LTDC.SSCR.hsw_mask)) >> LTDC.SSCR.hsw_offset) } - set { - let preserve = self.rawValue & ~LTDC.SSCR.hsw_mask - let shift = (UInt32(newValue) << LTDC.SSCR.hsw_offset) & LTDC.SSCR.hsw_mask - self.rawValue = preserve | shift - } - } - - static let vsh_offset = UInt32(0) - static let vsh_mask = UInt32(0b11111111111) &<< vsh_offset - public var vsh: UInt16 { - get { UInt16((self.rawValue & (LTDC.SSCR.vsh_mask)) >> LTDC.SSCR.vsh_offset) } - set { - let preserve = self.rawValue & ~LTDC.SSCR.vsh_mask - let shift = (UInt32(newValue) << LTDC.SSCR.vsh_offset) & LTDC.SSCR.vsh_mask - self.rawValue = preserve | shift - } - } - - public init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - public struct BPCR { - public var rawValue: UInt32 - - static let ahbp_offset = UInt32(16) - static let ahbp_mask = UInt32(0b1111111111) &<< ahbp_offset - public var ahbp: UInt16 { - get { UInt16((self.rawValue & (LTDC.BPCR.ahbp_mask)) >> LTDC.BPCR.ahbp_offset) } - set { - let preserve = self.rawValue & ~LTDC.BPCR.ahbp_mask - let shift = (UInt32(newValue) << LTDC.BPCR.ahbp_offset) & LTDC.BPCR.ahbp_mask - self.rawValue = preserve | shift - } - } - - static let avbp_offset = UInt32(0) - static let avbp_mask = UInt32(0b11111111111) &<< avbp_offset - public var avbp: UInt16 { - get { UInt16((self.rawValue & (LTDC.BPCR.avbp_mask)) >> LTDC.BPCR.avbp_offset) } - set { - let preserve = self.rawValue & ~LTDC.BPCR.avbp_mask - let shift = (UInt32(newValue) << LTDC.BPCR.avbp_offset) & LTDC.BPCR.avbp_mask - self.rawValue = preserve | shift - } - } - - public init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - public struct AWCR { - public var rawValue: UInt32 - - static let aav_offset = UInt32(16) - static let aav_mask = UInt32(0b1111111111) &<< aav_offset - public var aav: UInt16 { - get { UInt16((self.rawValue & (LTDC.AWCR.aav_mask)) >> LTDC.AWCR.aav_offset) } - set { - let preserve = self.rawValue & ~LTDC.AWCR.aav_mask - let shift = (UInt32(newValue) << LTDC.AWCR.aav_offset) & LTDC.AWCR.aav_mask - self.rawValue = preserve | shift - } - } - - static let aah_offset = UInt32(0) - static let aah_mask = UInt32(0b11111111111) &<< aah_offset - public var aah: UInt16 { - get { UInt16((self.rawValue & (LTDC.AWCR.aah_mask)) >> LTDC.AWCR.aah_offset) } - set { - let preserve = self.rawValue & ~LTDC.AWCR.aah_mask - let shift = (UInt32(newValue) << LTDC.AWCR.aah_offset) & LTDC.AWCR.aah_mask - self.rawValue = preserve | shift - } - } - - public init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - public struct TWCR { - public var rawValue: UInt32 - - static let totalw_offset = UInt32(16) - static let totalw_mask = UInt32(0b1111111111) &<< totalw_offset - public var totalw: UInt16 { - get { UInt16((self.rawValue & (LTDC.TWCR.totalw_mask)) >> LTDC.TWCR.totalw_offset) } - set { - let preserve = self.rawValue & ~LTDC.TWCR.totalw_mask - let shift = (UInt32(newValue) << LTDC.TWCR.totalw_offset) & LTDC.TWCR.totalw_mask - self.rawValue = preserve | shift - } - } - - static let totalh_offset = UInt32(0) - static let totalh_mask = UInt32(0b11111111111) &<< totalh_offset - public var totalh: UInt16 { - get { UInt16((self.rawValue & (LTDC.TWCR.totalh_mask)) >> LTDC.TWCR.totalh_offset) } - set { - let preserve = self.rawValue & ~LTDC.TWCR.totalh_mask - let shift = (UInt32(newValue) << LTDC.TWCR.totalh_offset) & LTDC.TWCR.totalh_mask - self.rawValue = preserve | shift - } - } - - public init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - public struct GCR { - public var rawValue: UInt32 - - static let hspol_offset = UInt32(31) - static let hspol_mask = UInt32(0b1) &<< hspol_offset - public var hspol: UInt8 { - get { UInt8((self.rawValue & (LTDC.GCR.hspol_mask)) >> LTDC.GCR.hspol_offset) } - set { - let preserve = self.rawValue & ~LTDC.GCR.hspol_mask - let shift = (UInt32(newValue) << LTDC.GCR.hspol_offset) & LTDC.GCR.hspol_mask - self.rawValue = preserve | shift - } - } - - static let vspol_offset = UInt32(30) - static let vspol_mask = UInt32(0b1) &<< vspol_offset - public var vspol: UInt8 { - get { UInt8((self.rawValue & (LTDC.GCR.vspol_mask)) >> LTDC.GCR.vspol_offset) } - set { - let preserve = self.rawValue & ~LTDC.GCR.vspol_mask - let shift = (UInt32(newValue) << LTDC.GCR.vspol_offset) & LTDC.GCR.vspol_mask - self.rawValue = preserve | shift - } - } - - static let depol_offset = UInt32(29) - static let depol_mask = UInt32(0b1) &<< depol_offset - public var depol: UInt8 { - get { UInt8((self.rawValue & (LTDC.GCR.depol_mask)) >> LTDC.GCR.depol_offset) } - set { - let preserve = self.rawValue & ~LTDC.GCR.depol_mask - let shift = (UInt32(newValue) << LTDC.GCR.depol_offset) & LTDC.GCR.depol_mask - self.rawValue = preserve | shift - } - } - - static let pcpol_offset = UInt32(28) - static let pcpol_mask = UInt32(0b1) &<< pcpol_offset - public var pcpol: UInt8 { - get { UInt8((self.rawValue & (LTDC.GCR.pcpol_mask)) >> LTDC.GCR.pcpol_offset) } - set { - let preserve = self.rawValue & ~LTDC.GCR.pcpol_mask - let shift = (UInt32(newValue) << LTDC.GCR.pcpol_offset) & LTDC.GCR.pcpol_mask - self.rawValue = preserve | shift - } - } - - static let den_offset = UInt32(16) - static let den_mask = UInt32(0b1) &<< den_offset - public var den: UInt8 { - get { UInt8((self.rawValue & (LTDC.GCR.den_mask)) >> LTDC.GCR.den_offset) } - set { - let preserve = self.rawValue & ~LTDC.GCR.den_mask - let shift = (UInt32(newValue) << LTDC.GCR.den_offset) & LTDC.GCR.den_mask - self.rawValue = preserve | shift - } - } - - static let drw_offset = UInt32(12) - static let drw_mask = UInt32(0b111) &<< drw_offset - public var drw: UInt8 { - UInt8((self.rawValue & (LTDC.GCR.drw_mask)) >> LTDC.GCR.drw_offset) - } - - static let dgw_offset = UInt32(8) - static let dgw_mask = UInt32(0b111) &<< dgw_offset - public var dgw: UInt8 { - UInt8((self.rawValue & (LTDC.GCR.dgw_mask)) >> LTDC.GCR.dgw_offset) - } - - static let dbw_offset = UInt32(4) - static let dbw_mask = UInt32(0b111) &<< dbw_offset - public var dbw: UInt8 { - UInt8((self.rawValue & (LTDC.GCR.dbw_mask)) >> LTDC.GCR.dbw_offset) - } - - static let ltdcen_offset = UInt32(0) - static let ltdcen_mask = UInt32(0b1) &<< ltdcen_offset - public var ltdcen: UInt8 { - get { UInt8((self.rawValue & (LTDC.GCR.ltdcen_mask)) >> LTDC.GCR.ltdcen_offset) } - set { - let preserve = self.rawValue & ~LTDC.GCR.ltdcen_mask - let shift = (UInt32(newValue) << LTDC.GCR.ltdcen_offset) & LTDC.GCR.ltdcen_mask - self.rawValue = preserve | shift - } - } - - public init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - public struct SRCR { - public var rawValue: UInt32 - - static let vbr_offset = UInt32(1) - static let vbr_mask = UInt32(0b1) &<< vbr_offset - public var vbr: UInt8 { - get { UInt8((self.rawValue & (LTDC.SRCR.vbr_mask)) >> LTDC.SRCR.vbr_offset) } - set { - let preserve = self.rawValue & ~LTDC.SRCR.vbr_mask - let shift = (UInt32(newValue) << LTDC.SRCR.vbr_offset) & LTDC.SRCR.vbr_mask - self.rawValue = preserve | shift - } - } - - static let imr_offset = UInt32(0) - static let imr_mask = UInt32(0b1) &<< imr_offset - public var imr: UInt8 { - get { UInt8((self.rawValue & (LTDC.SRCR.imr_mask)) >> LTDC.SRCR.imr_offset) } - set { - let preserve = self.rawValue & ~LTDC.SRCR.imr_mask - let shift = (UInt32(newValue) << LTDC.SRCR.imr_offset) & LTDC.SRCR.imr_mask - self.rawValue = preserve | shift - } - } - - public init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - public struct BCCR { - public var rawValue: UInt32 - - static let bc_offset = UInt32(0) - static let bc_mask = UInt32(0b111111111111111111111111) &<< bc_offset - public var bc: UInt32 { - get { UInt32((self.rawValue & (LTDC.BCCR.bc_mask)) >> LTDC.BCCR.bc_offset) } - set { - let preserve = self.rawValue & ~LTDC.BCCR.bc_mask - let shift = (UInt32(newValue) << LTDC.BCCR.bc_offset) & LTDC.BCCR.bc_mask - self.rawValue = preserve | shift - } - } - - public init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - public struct IER { - public var rawValue: UInt32 - - static let rrie_offset = UInt32(3) - static let rrie_mask = UInt32(0b1) &<< rrie_offset - public var rrie: UInt8 { - get { UInt8((self.rawValue & (LTDC.IER.rrie_mask)) >> LTDC.IER.rrie_offset) } - set { - let preserve = self.rawValue & ~LTDC.IER.rrie_mask - let shift = (UInt32(newValue) << LTDC.IER.rrie_offset) & LTDC.IER.rrie_mask - self.rawValue = preserve | shift - } - } - - static let terrie_offset = UInt32(2) - static let terrie_mask = UInt32(0b1) &<< terrie_offset - public var terrie: UInt8 { - get { UInt8((self.rawValue & (LTDC.IER.terrie_mask)) >> LTDC.IER.terrie_offset) } - set { - let preserve = self.rawValue & ~LTDC.IER.terrie_mask - let shift = (UInt32(newValue) << LTDC.IER.terrie_offset) & LTDC.IER.terrie_mask - self.rawValue = preserve | shift - } - } - - static let fuie_offset = UInt32(1) - static let fuie_mask = UInt32(0b1) &<< fuie_offset - public var fuie: UInt8 { - get { UInt8((self.rawValue & (LTDC.IER.fuie_mask)) >> LTDC.IER.fuie_offset) } - set { - let preserve = self.rawValue & ~LTDC.IER.fuie_mask - let shift = (UInt32(newValue) << LTDC.IER.fuie_offset) & LTDC.IER.fuie_mask - self.rawValue = preserve | shift - } - } - - static let lie_offset = UInt32(0) - static let lie_mask = UInt32(0b1) &<< lie_offset - public var lie: UInt8 { - get { UInt8((self.rawValue & (LTDC.IER.lie_mask)) >> LTDC.IER.lie_offset) } - set { - let preserve = self.rawValue & ~LTDC.IER.lie_mask - let shift = (UInt32(newValue) << LTDC.IER.lie_offset) & LTDC.IER.lie_mask - self.rawValue = preserve | shift - } - } - - public init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - public struct ISR { - public var rawValue: UInt32 - - static let rrif_offset = UInt32(3) - static let rrif_mask = UInt32(0b1) &<< rrif_offset - public var rrif: UInt8 { - UInt8((self.rawValue & (LTDC.ISR.rrif_mask)) >> LTDC.ISR.rrif_offset) - } - - static let terrif_offset = UInt32(2) - static let terrif_mask = UInt32(0b1) &<< terrif_offset - public var terrif: UInt8 { - UInt8((self.rawValue & (LTDC.ISR.terrif_mask)) >> LTDC.ISR.terrif_offset) - } - - static let fuif_offset = UInt32(1) - static let fuif_mask = UInt32(0b1) &<< fuif_offset - public var fuif: UInt8 { - UInt8((self.rawValue & (LTDC.ISR.fuif_mask)) >> LTDC.ISR.fuif_offset) - } - - static let lif_offset = UInt32(0) - static let lif_mask = UInt32(0b1) &<< lif_offset - public var lif: UInt8 { - UInt8((self.rawValue & (LTDC.ISR.lif_mask)) >> LTDC.ISR.lif_offset) - } - - public init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - public struct ICR { - public var rawValue: UInt32 - - static let crrif_offset = UInt32(3) - static let crrif_mask = UInt32(0b1) &<< crrif_offset - public var crrif: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << LTDC.ICR.crrif_offset) & LTDC.ICR.crrif_mask - } - } - - static let cterrif_offset = UInt32(2) - static let cterrif_mask = UInt32(0b1) &<< cterrif_offset - public var cterrif: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << LTDC.ICR.cterrif_offset) & LTDC.ICR.cterrif_mask - } - } - - static let cfuif_offset = UInt32(1) - static let cfuif_mask = UInt32(0b1) &<< cfuif_offset - public var cfuif: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << LTDC.ICR.cfuif_offset) & LTDC.ICR.cfuif_mask - } - } - - static let clif_offset = UInt32(0) - static let clif_mask = UInt32(0b1) &<< clif_offset - public var clif: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << LTDC.ICR.clif_offset) & LTDC.ICR.clif_mask - } - } - - public init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - public struct LIPCR { - public var rawValue: UInt32 - - static let lipos_offset = UInt32(0) - static let lipos_mask = UInt32(0b11111111111) &<< lipos_offset - public var lipos: UInt16 { - get { UInt16((self.rawValue & (LTDC.LIPCR.lipos_mask)) >> LTDC.LIPCR.lipos_offset) } - set { - let preserve = self.rawValue & ~LTDC.LIPCR.lipos_mask - let shift = (UInt32(newValue) << LTDC.LIPCR.lipos_offset) & LTDC.LIPCR.lipos_mask - self.rawValue = preserve | shift - } - } - - public init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - public struct CPSR { - public var rawValue: UInt32 - - static let cxpos_offset = UInt32(16) - static let cxpos_mask = UInt32(0b1111111111111111) &<< cxpos_offset - public var cxpos: UInt16 { - UInt16((self.rawValue & (LTDC.CPSR.cxpos_mask)) >> LTDC.CPSR.cxpos_offset) - } - - static let cypos_offset = UInt32(0) - static let cypos_mask = UInt32(0b1111111111111111) &<< cypos_offset - public var cypos: UInt16 { - UInt16((self.rawValue & (LTDC.CPSR.cypos_mask)) >> LTDC.CPSR.cypos_offset) - } - - public init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - public struct CDSR { - public var rawValue: UInt32 - - static let hsyncs_offset = UInt32(3) - static let hsyncs_mask = UInt32(0b1) &<< hsyncs_offset - public var hsyncs: UInt8 { - UInt8((self.rawValue & (LTDC.CDSR.hsyncs_mask)) >> LTDC.CDSR.hsyncs_offset) - } - - static let vsyncs_offset = UInt32(2) - static let vsyncs_mask = UInt32(0b1) &<< vsyncs_offset - public var vsyncs: UInt8 { - UInt8((self.rawValue & (LTDC.CDSR.vsyncs_mask)) >> LTDC.CDSR.vsyncs_offset) - } - - static let hdes_offset = UInt32(1) - static let hdes_mask = UInt32(0b1) &<< hdes_offset - public var hdes: UInt8 { - UInt8((self.rawValue & (LTDC.CDSR.hdes_mask)) >> LTDC.CDSR.hdes_offset) - } - - static let vdes_offset = UInt32(0) - static let vdes_mask = UInt32(0b1) &<< vdes_offset - public var vdes: UInt8 { - UInt8((self.rawValue & (LTDC.CDSR.vdes_mask)) >> LTDC.CDSR.vdes_offset) - } - - public init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - public struct L1CR { - public var rawValue: UInt32 - - static let cluten_offset = UInt32(4) - static let cluten_mask = UInt32(0b1) &<< cluten_offset - public var cluten: UInt8 { - get { UInt8((self.rawValue & (LTDC.L1CR.cluten_mask)) >> LTDC.L1CR.cluten_offset) } - set { - let preserve = self.rawValue & ~LTDC.L1CR.cluten_mask - let shift = (UInt32(newValue) << LTDC.L1CR.cluten_offset) & LTDC.L1CR.cluten_mask - self.rawValue = preserve | shift - } - } - - static let colken_offset = UInt32(1) - static let colken_mask = UInt32(0b1) &<< colken_offset - public var colken: UInt8 { - get { UInt8((self.rawValue & (LTDC.L1CR.colken_mask)) >> LTDC.L1CR.colken_offset) } - set { - let preserve = self.rawValue & ~LTDC.L1CR.colken_mask - let shift = (UInt32(newValue) << LTDC.L1CR.colken_offset) & LTDC.L1CR.colken_mask - self.rawValue = preserve | shift - } - } - - static let len_offset = UInt32(0) - static let len_mask = UInt32(0b1) &<< len_offset - public var len: UInt8 { - get { UInt8((self.rawValue & (LTDC.L1CR.len_mask)) >> LTDC.L1CR.len_offset) } - set { - let preserve = self.rawValue & ~LTDC.L1CR.len_mask - let shift = (UInt32(newValue) << LTDC.L1CR.len_offset) & LTDC.L1CR.len_mask - self.rawValue = preserve | shift - } - } - - public init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - public struct L1WHPCR { - public var rawValue: UInt32 - - static let whsppos_offset = UInt32(16) - static let whsppos_mask = UInt32(0b111111111111) &<< whsppos_offset - public var whsppos: UInt16 { - get { UInt16((self.rawValue & (LTDC.L1WHPCR.whsppos_mask)) >> LTDC.L1WHPCR.whsppos_offset) } - set { - let preserve = self.rawValue & ~LTDC.L1WHPCR.whsppos_mask - let shift = (UInt32(newValue) << LTDC.L1WHPCR.whsppos_offset) & LTDC.L1WHPCR.whsppos_mask - self.rawValue = preserve | shift - } - } - - static let whstpos_offset = UInt32(0) - static let whstpos_mask = UInt32(0b111111111111) &<< whstpos_offset - public var whstpos: UInt16 { - get { UInt16((self.rawValue & (LTDC.L1WHPCR.whstpos_mask)) >> LTDC.L1WHPCR.whstpos_offset) } - set { - let preserve = self.rawValue & ~LTDC.L1WHPCR.whstpos_mask - let shift = (UInt32(newValue) << LTDC.L1WHPCR.whstpos_offset) & LTDC.L1WHPCR.whstpos_mask - self.rawValue = preserve | shift - } - } - - public init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - public struct L1WVPCR { - public var rawValue: UInt32 - - static let wvsppos_offset = UInt32(16) - static let wvsppos_mask = UInt32(0b11111111111) &<< wvsppos_offset - public var wvsppos: UInt16 { - get { UInt16((self.rawValue & (LTDC.L1WVPCR.wvsppos_mask)) >> LTDC.L1WVPCR.wvsppos_offset) } - set { - let preserve = self.rawValue & ~LTDC.L1WVPCR.wvsppos_mask - let shift = (UInt32(newValue) << LTDC.L1WVPCR.wvsppos_offset) & LTDC.L1WVPCR.wvsppos_mask - self.rawValue = preserve | shift - } - } - - static let wvstpos_offset = UInt32(0) - static let wvstpos_mask = UInt32(0b11111111111) &<< wvstpos_offset - public var wvstpos: UInt16 { - get { UInt16((self.rawValue & (LTDC.L1WVPCR.wvstpos_mask)) >> LTDC.L1WVPCR.wvstpos_offset) } - set { - let preserve = self.rawValue & ~LTDC.L1WVPCR.wvstpos_mask - let shift = (UInt32(newValue) << LTDC.L1WVPCR.wvstpos_offset) & LTDC.L1WVPCR.wvstpos_mask - self.rawValue = preserve | shift - } - } - - public init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - public struct L1CKCR { - public var rawValue: UInt32 - - static let ckred_offset = UInt32(16) - static let ckred_mask = UInt32(0b11111111) &<< ckred_offset - public var ckred: UInt8 { - get { UInt8((self.rawValue & (LTDC.L1CKCR.ckred_mask)) >> LTDC.L1CKCR.ckred_offset) } - set { - let preserve = self.rawValue & ~LTDC.L1CKCR.ckred_mask - let shift = (UInt32(newValue) << LTDC.L1CKCR.ckred_offset) & LTDC.L1CKCR.ckred_mask - self.rawValue = preserve | shift - } - } - - static let ckgreen_offset = UInt32(8) - static let ckgreen_mask = UInt32(0b11111111) &<< ckgreen_offset - public var ckgreen: UInt8 { - get { UInt8((self.rawValue & (LTDC.L1CKCR.ckgreen_mask)) >> LTDC.L1CKCR.ckgreen_offset) } - set { - let preserve = self.rawValue & ~LTDC.L1CKCR.ckgreen_mask - let shift = (UInt32(newValue) << LTDC.L1CKCR.ckgreen_offset) & LTDC.L1CKCR.ckgreen_mask - self.rawValue = preserve | shift - } - } - - static let ckblue_offset = UInt32(0) - static let ckblue_mask = UInt32(0b11111111) &<< ckblue_offset - public var ckblue: UInt8 { - get { UInt8((self.rawValue & (LTDC.L1CKCR.ckblue_mask)) >> LTDC.L1CKCR.ckblue_offset) } - set { - let preserve = self.rawValue & ~LTDC.L1CKCR.ckblue_mask - let shift = (UInt32(newValue) << LTDC.L1CKCR.ckblue_offset) & LTDC.L1CKCR.ckblue_mask - self.rawValue = preserve | shift - } - } - - public init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - public struct L1PFCR { - public var rawValue: UInt32 - - static let pf_offset = UInt32(0) - static let pf_mask = UInt32(0b111) &<< pf_offset - public var pf: UInt8 { - get { UInt8((self.rawValue & (LTDC.L1PFCR.pf_mask)) >> LTDC.L1PFCR.pf_offset) } - set { - let preserve = self.rawValue & ~LTDC.L1PFCR.pf_mask - let shift = (UInt32(newValue) << LTDC.L1PFCR.pf_offset) & LTDC.L1PFCR.pf_mask - self.rawValue = preserve | shift - } - } - - public init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - public struct L1CACR { - public var rawValue: UInt32 - - static let consta_offset = UInt32(0) - static let consta_mask = UInt32(0b11111111) &<< consta_offset - public var consta: UInt8 { - get { UInt8((self.rawValue & (LTDC.L1CACR.consta_mask)) >> LTDC.L1CACR.consta_offset) } - set { - let preserve = self.rawValue & ~LTDC.L1CACR.consta_mask - let shift = (UInt32(newValue) << LTDC.L1CACR.consta_offset) & LTDC.L1CACR.consta_mask - self.rawValue = preserve | shift - } - } - - public init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - public struct L1DCCR { - public var rawValue: UInt32 - - static let dcalpha_offset = UInt32(24) - static let dcalpha_mask = UInt32(0b11111111) &<< dcalpha_offset - public var dcalpha: UInt8 { - get { UInt8((self.rawValue & (LTDC.L1DCCR.dcalpha_mask)) >> LTDC.L1DCCR.dcalpha_offset) } - set { - let preserve = self.rawValue & ~LTDC.L1DCCR.dcalpha_mask - let shift = (UInt32(newValue) << LTDC.L1DCCR.dcalpha_offset) & LTDC.L1DCCR.dcalpha_mask - self.rawValue = preserve | shift - } - } - - static let dcred_offset = UInt32(16) - static let dcred_mask = UInt32(0b11111111) &<< dcred_offset - public var dcred: UInt8 { - get { UInt8((self.rawValue & (LTDC.L1DCCR.dcred_mask)) >> LTDC.L1DCCR.dcred_offset) } - set { - let preserve = self.rawValue & ~LTDC.L1DCCR.dcred_mask - let shift = (UInt32(newValue) << LTDC.L1DCCR.dcred_offset) & LTDC.L1DCCR.dcred_mask - self.rawValue = preserve | shift - } - } - - static let dcgreen_offset = UInt32(8) - static let dcgreen_mask = UInt32(0b11111111) &<< dcgreen_offset - public var dcgreen: UInt8 { - get { UInt8((self.rawValue & (LTDC.L1DCCR.dcgreen_mask)) >> LTDC.L1DCCR.dcgreen_offset) } - set { - let preserve = self.rawValue & ~LTDC.L1DCCR.dcgreen_mask - let shift = (UInt32(newValue) << LTDC.L1DCCR.dcgreen_offset) & LTDC.L1DCCR.dcgreen_mask - self.rawValue = preserve | shift - } - } - - static let dcblue_offset = UInt32(0) - static let dcblue_mask = UInt32(0b11111111) &<< dcblue_offset - public var dcblue: UInt8 { - get { UInt8((self.rawValue & (LTDC.L1DCCR.dcblue_mask)) >> LTDC.L1DCCR.dcblue_offset) } - set { - let preserve = self.rawValue & ~LTDC.L1DCCR.dcblue_mask - let shift = (UInt32(newValue) << LTDC.L1DCCR.dcblue_offset) & LTDC.L1DCCR.dcblue_mask - self.rawValue = preserve | shift - } - } - - public init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - public struct L1BFCR { - public var rawValue: UInt32 - - static let bf1_offset = UInt32(8) - static let bf1_mask = UInt32(0b111) &<< bf1_offset - public var bf1: UInt8 { - get { UInt8((self.rawValue & (LTDC.L1BFCR.bf1_mask)) >> LTDC.L1BFCR.bf1_offset) } - set { - let preserve = self.rawValue & ~LTDC.L1BFCR.bf1_mask - let shift = (UInt32(newValue) << LTDC.L1BFCR.bf1_offset) & LTDC.L1BFCR.bf1_mask - self.rawValue = preserve | shift - } - } - - static let bf2_offset = UInt32(0) - static let bf2_mask = UInt32(0b111) &<< bf2_offset - public var bf2: UInt8 { - get { UInt8((self.rawValue & (LTDC.L1BFCR.bf2_mask)) >> LTDC.L1BFCR.bf2_offset) } - set { - let preserve = self.rawValue & ~LTDC.L1BFCR.bf2_mask - let shift = (UInt32(newValue) << LTDC.L1BFCR.bf2_offset) & LTDC.L1BFCR.bf2_mask - self.rawValue = preserve | shift - } - } - - public init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - public struct L1CFBAR { - public var rawValue: UInt32 - - static let cfbadd_offset = UInt32(0) - static let cfbadd_mask = UInt32(0b11111111111111111111111111111111) &<< cfbadd_offset - public var cfbadd: UInt32 { - get { UInt32((self.rawValue & (LTDC.L1CFBAR.cfbadd_mask)) >> LTDC.L1CFBAR.cfbadd_offset) } - set { - let preserve = self.rawValue & ~LTDC.L1CFBAR.cfbadd_mask - let shift = (UInt32(newValue) << LTDC.L1CFBAR.cfbadd_offset) & LTDC.L1CFBAR.cfbadd_mask - self.rawValue = preserve | shift - } - } - - public init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - public struct L1CFBLR { - public var rawValue: UInt32 - - static let cfbp_offset = UInt32(16) - static let cfbp_mask = UInt32(0b1111111111111) &<< cfbp_offset - public var cfbp: UInt16 { - get { UInt16((self.rawValue & (LTDC.L1CFBLR.cfbp_mask)) >> LTDC.L1CFBLR.cfbp_offset) } - set { - let preserve = self.rawValue & ~LTDC.L1CFBLR.cfbp_mask - let shift = (UInt32(newValue) << LTDC.L1CFBLR.cfbp_offset) & LTDC.L1CFBLR.cfbp_mask - self.rawValue = preserve | shift - } - } - - static let cfbll_offset = UInt32(0) - static let cfbll_mask = UInt32(0b1111111111111) &<< cfbll_offset - public var cfbll: UInt16 { - get { UInt16((self.rawValue & (LTDC.L1CFBLR.cfbll_mask)) >> LTDC.L1CFBLR.cfbll_offset) } - set { - let preserve = self.rawValue & ~LTDC.L1CFBLR.cfbll_mask - let shift = (UInt32(newValue) << LTDC.L1CFBLR.cfbll_offset) & LTDC.L1CFBLR.cfbll_mask - self.rawValue = preserve | shift - } - } - - public init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - public struct L1CFBLNR { - public var rawValue: UInt32 - - static let cfblnbr_offset = UInt32(0) - static let cfblnbr_mask = UInt32(0b11111111111) &<< cfblnbr_offset - public var cfblnbr: UInt16 { - get { UInt16((self.rawValue & (LTDC.L1CFBLNR.cfblnbr_mask)) >> LTDC.L1CFBLNR.cfblnbr_offset) } - set { - let preserve = self.rawValue & ~LTDC.L1CFBLNR.cfblnbr_mask - let shift = (UInt32(newValue) << LTDC.L1CFBLNR.cfblnbr_offset) & LTDC.L1CFBLNR.cfblnbr_mask - self.rawValue = preserve | shift - } - } - - public init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - public struct L1CLUTWR { - public var rawValue: UInt32 - - static let clutadd_offset = UInt32(24) - static let clutadd_mask = UInt32(0b11111111) &<< clutadd_offset - public var clutadd: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << LTDC.L1CLUTWR.clutadd_offset) & LTDC.L1CLUTWR.clutadd_mask - } - } - - static let red_offset = UInt32(16) - static let red_mask = UInt32(0b11111111) &<< red_offset - public var red: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << LTDC.L1CLUTWR.red_offset) & LTDC.L1CLUTWR.red_mask - } - } - - static let green_offset = UInt32(8) - static let green_mask = UInt32(0b11111111) &<< green_offset - public var green: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << LTDC.L1CLUTWR.green_offset) & LTDC.L1CLUTWR.green_mask - } - } - - static let blue_offset = UInt32(0) - static let blue_mask = UInt32(0b11111111) &<< blue_offset - public var blue: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << LTDC.L1CLUTWR.blue_offset) & LTDC.L1CLUTWR.blue_mask - } - } - - public init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - public struct L2CR { - public var rawValue: UInt32 - - static let cluten_offset = UInt32(4) - static let cluten_mask = UInt32(0b1) &<< cluten_offset - public var cluten: UInt8 { - get { UInt8((self.rawValue & (LTDC.L2CR.cluten_mask)) >> LTDC.L2CR.cluten_offset) } - set { - let preserve = self.rawValue & ~LTDC.L2CR.cluten_mask - let shift = (UInt32(newValue) << LTDC.L2CR.cluten_offset) & LTDC.L2CR.cluten_mask - self.rawValue = preserve | shift - } - } - - static let colken_offset = UInt32(1) - static let colken_mask = UInt32(0b1) &<< colken_offset - public var colken: UInt8 { - get { UInt8((self.rawValue & (LTDC.L2CR.colken_mask)) >> LTDC.L2CR.colken_offset) } - set { - let preserve = self.rawValue & ~LTDC.L2CR.colken_mask - let shift = (UInt32(newValue) << LTDC.L2CR.colken_offset) & LTDC.L2CR.colken_mask - self.rawValue = preserve | shift - } - } - - static let len_offset = UInt32(0) - static let len_mask = UInt32(0b1) &<< len_offset - public var len: UInt8 { - get { UInt8((self.rawValue & (LTDC.L2CR.len_mask)) >> LTDC.L2CR.len_offset) } - set { - let preserve = self.rawValue & ~LTDC.L2CR.len_mask - let shift = (UInt32(newValue) << LTDC.L2CR.len_offset) & LTDC.L2CR.len_mask - self.rawValue = preserve | shift - } - } - - public init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - public struct L2WHPCR { - public var rawValue: UInt32 - - static let whsppos_offset = UInt32(16) - static let whsppos_mask = UInt32(0b111111111111) &<< whsppos_offset - public var whsppos: UInt16 { - get { UInt16((self.rawValue & (LTDC.L2WHPCR.whsppos_mask)) >> LTDC.L2WHPCR.whsppos_offset) } - set { - let preserve = self.rawValue & ~LTDC.L2WHPCR.whsppos_mask - let shift = (UInt32(newValue) << LTDC.L2WHPCR.whsppos_offset) & LTDC.L2WHPCR.whsppos_mask - self.rawValue = preserve | shift - } - } - - static let whstpos_offset = UInt32(0) - static let whstpos_mask = UInt32(0b111111111111) &<< whstpos_offset - public var whstpos: UInt16 { - get { UInt16((self.rawValue & (LTDC.L2WHPCR.whstpos_mask)) >> LTDC.L2WHPCR.whstpos_offset) } - set { - let preserve = self.rawValue & ~LTDC.L2WHPCR.whstpos_mask - let shift = (UInt32(newValue) << LTDC.L2WHPCR.whstpos_offset) & LTDC.L2WHPCR.whstpos_mask - self.rawValue = preserve | shift - } - } - - public init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - public struct L2WVPCR { - public var rawValue: UInt32 - - static let wvsppos_offset = UInt32(16) - static let wvsppos_mask = UInt32(0b11111111111) &<< wvsppos_offset - public var wvsppos: UInt16 { - get { UInt16((self.rawValue & (LTDC.L2WVPCR.wvsppos_mask)) >> LTDC.L2WVPCR.wvsppos_offset) } - set { - let preserve = self.rawValue & ~LTDC.L2WVPCR.wvsppos_mask - let shift = (UInt32(newValue) << LTDC.L2WVPCR.wvsppos_offset) & LTDC.L2WVPCR.wvsppos_mask - self.rawValue = preserve | shift - } - } - - static let wvstpos_offset = UInt32(0) - static let wvstpos_mask = UInt32(0b11111111111) &<< wvstpos_offset - public var wvstpos: UInt16 { - get { UInt16((self.rawValue & (LTDC.L2WVPCR.wvstpos_mask)) >> LTDC.L2WVPCR.wvstpos_offset) } - set { - let preserve = self.rawValue & ~LTDC.L2WVPCR.wvstpos_mask - let shift = (UInt32(newValue) << LTDC.L2WVPCR.wvstpos_offset) & LTDC.L2WVPCR.wvstpos_mask - self.rawValue = preserve | shift - } - } - - public init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - public struct L2CKCR { - public var rawValue: UInt32 - - static let ckred_offset = UInt32(15) - static let ckred_mask = UInt32(0b111111111) &<< ckred_offset - public var ckred: UInt16 { - get { UInt16((self.rawValue & (LTDC.L2CKCR.ckred_mask)) >> LTDC.L2CKCR.ckred_offset) } - set { - let preserve = self.rawValue & ~LTDC.L2CKCR.ckred_mask - let shift = (UInt32(newValue) << LTDC.L2CKCR.ckred_offset) & LTDC.L2CKCR.ckred_mask - self.rawValue = preserve | shift - } - } - - static let ckgreen_offset = UInt32(8) - static let ckgreen_mask = UInt32(0b1111111) &<< ckgreen_offset - public var ckgreen: UInt8 { - get { UInt8((self.rawValue & (LTDC.L2CKCR.ckgreen_mask)) >> LTDC.L2CKCR.ckgreen_offset) } - set { - let preserve = self.rawValue & ~LTDC.L2CKCR.ckgreen_mask - let shift = (UInt32(newValue) << LTDC.L2CKCR.ckgreen_offset) & LTDC.L2CKCR.ckgreen_mask - self.rawValue = preserve | shift - } - } - - static let ckblue_offset = UInt32(0) - static let ckblue_mask = UInt32(0b11111111) &<< ckblue_offset - public var ckblue: UInt8 { - get { UInt8((self.rawValue & (LTDC.L2CKCR.ckblue_mask)) >> LTDC.L2CKCR.ckblue_offset) } - set { - let preserve = self.rawValue & ~LTDC.L2CKCR.ckblue_mask - let shift = (UInt32(newValue) << LTDC.L2CKCR.ckblue_offset) & LTDC.L2CKCR.ckblue_mask - self.rawValue = preserve | shift - } - } - - public init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - public struct L2PFCR { - public var rawValue: UInt32 - - static let pf_offset = UInt32(0) - static let pf_mask = UInt32(0b111) &<< pf_offset - public var pf: UInt8 { - get { UInt8((self.rawValue & (LTDC.L2PFCR.pf_mask)) >> LTDC.L2PFCR.pf_offset) } - set { - let preserve = self.rawValue & ~LTDC.L2PFCR.pf_mask - let shift = (UInt32(newValue) << LTDC.L2PFCR.pf_offset) & LTDC.L2PFCR.pf_mask - self.rawValue = preserve | shift - } - } - - public init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - public struct L2CACR { - public var rawValue: UInt32 - - static let consta_offset = UInt32(0) - static let consta_mask = UInt32(0b11111111) &<< consta_offset - public var consta: UInt8 { - get { UInt8((self.rawValue & (LTDC.L2CACR.consta_mask)) >> LTDC.L2CACR.consta_offset) } - set { - let preserve = self.rawValue & ~LTDC.L2CACR.consta_mask - let shift = (UInt32(newValue) << LTDC.L2CACR.consta_offset) & LTDC.L2CACR.consta_mask - self.rawValue = preserve | shift - } - } - - public init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - public struct L2DCCR { - public var rawValue: UInt32 - - static let dcalpha_offset = UInt32(24) - static let dcalpha_mask = UInt32(0b11111111) &<< dcalpha_offset - public var dcalpha: UInt8 { - get { UInt8((self.rawValue & (LTDC.L2DCCR.dcalpha_mask)) >> LTDC.L2DCCR.dcalpha_offset) } - set { - let preserve = self.rawValue & ~LTDC.L2DCCR.dcalpha_mask - let shift = (UInt32(newValue) << LTDC.L2DCCR.dcalpha_offset) & LTDC.L2DCCR.dcalpha_mask - self.rawValue = preserve | shift - } - } - - static let dcred_offset = UInt32(16) - static let dcred_mask = UInt32(0b11111111) &<< dcred_offset - public var dcred: UInt8 { - get { UInt8((self.rawValue & (LTDC.L2DCCR.dcred_mask)) >> LTDC.L2DCCR.dcred_offset) } - set { - let preserve = self.rawValue & ~LTDC.L2DCCR.dcred_mask - let shift = (UInt32(newValue) << LTDC.L2DCCR.dcred_offset) & LTDC.L2DCCR.dcred_mask - self.rawValue = preserve | shift - } - } - - static let dcgreen_offset = UInt32(8) - static let dcgreen_mask = UInt32(0b11111111) &<< dcgreen_offset - public var dcgreen: UInt8 { - get { UInt8((self.rawValue & (LTDC.L2DCCR.dcgreen_mask)) >> LTDC.L2DCCR.dcgreen_offset) } - set { - let preserve = self.rawValue & ~LTDC.L2DCCR.dcgreen_mask - let shift = (UInt32(newValue) << LTDC.L2DCCR.dcgreen_offset) & LTDC.L2DCCR.dcgreen_mask - self.rawValue = preserve | shift - } - } - - static let dcblue_offset = UInt32(0) - static let dcblue_mask = UInt32(0b11111111) &<< dcblue_offset - public var dcblue: UInt8 { - get { UInt8((self.rawValue & (LTDC.L2DCCR.dcblue_mask)) >> LTDC.L2DCCR.dcblue_offset) } - set { - let preserve = self.rawValue & ~LTDC.L2DCCR.dcblue_mask - let shift = (UInt32(newValue) << LTDC.L2DCCR.dcblue_offset) & LTDC.L2DCCR.dcblue_mask - self.rawValue = preserve | shift - } - } - - public init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - public struct L2BFCR { - public var rawValue: UInt32 - - static let bf1_offset = UInt32(8) - static let bf1_mask = UInt32(0b111) &<< bf1_offset - public var bf1: UInt8 { - get { UInt8((self.rawValue & (LTDC.L2BFCR.bf1_mask)) >> LTDC.L2BFCR.bf1_offset) } - set { - let preserve = self.rawValue & ~LTDC.L2BFCR.bf1_mask - let shift = (UInt32(newValue) << LTDC.L2BFCR.bf1_offset) & LTDC.L2BFCR.bf1_mask - self.rawValue = preserve | shift - } - } - - static let bf2_offset = UInt32(0) - static let bf2_mask = UInt32(0b111) &<< bf2_offset - public var bf2: UInt8 { - get { UInt8((self.rawValue & (LTDC.L2BFCR.bf2_mask)) >> LTDC.L2BFCR.bf2_offset) } - set { - let preserve = self.rawValue & ~LTDC.L2BFCR.bf2_mask - let shift = (UInt32(newValue) << LTDC.L2BFCR.bf2_offset) & LTDC.L2BFCR.bf2_mask - self.rawValue = preserve | shift - } - } - - public init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - public struct L2CFBAR { - public var rawValue: UInt32 - - static let cfbadd_offset = UInt32(0) - static let cfbadd_mask = UInt32(0b11111111111111111111111111111111) &<< cfbadd_offset - public var cfbadd: UInt32 { - get { UInt32((self.rawValue & (LTDC.L2CFBAR.cfbadd_mask)) >> LTDC.L2CFBAR.cfbadd_offset) } - set { - let preserve = self.rawValue & ~LTDC.L2CFBAR.cfbadd_mask - let shift = (UInt32(newValue) << LTDC.L2CFBAR.cfbadd_offset) & LTDC.L2CFBAR.cfbadd_mask - self.rawValue = preserve | shift - } - } - - public init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - public struct L2CFBLR { - public var rawValue: UInt32 - - static let cfbp_offset = UInt32(16) - static let cfbp_mask = UInt32(0b1111111111111) &<< cfbp_offset - public var cfbp: UInt16 { - get { UInt16((self.rawValue & (LTDC.L2CFBLR.cfbp_mask)) >> LTDC.L2CFBLR.cfbp_offset) } - set { - let preserve = self.rawValue & ~LTDC.L2CFBLR.cfbp_mask - let shift = (UInt32(newValue) << LTDC.L2CFBLR.cfbp_offset) & LTDC.L2CFBLR.cfbp_mask - self.rawValue = preserve | shift - } - } - - static let cfbll_offset = UInt32(0) - static let cfbll_mask = UInt32(0b1111111111111) &<< cfbll_offset - public var cfbll: UInt16 { - get { UInt16((self.rawValue & (LTDC.L2CFBLR.cfbll_mask)) >> LTDC.L2CFBLR.cfbll_offset) } - set { - let preserve = self.rawValue & ~LTDC.L2CFBLR.cfbll_mask - let shift = (UInt32(newValue) << LTDC.L2CFBLR.cfbll_offset) & LTDC.L2CFBLR.cfbll_mask - self.rawValue = preserve | shift - } - } - - public init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - public struct L2CFBLNR { - public var rawValue: UInt32 - - static let cfblnbr_offset = UInt32(0) - static let cfblnbr_mask = UInt32(0b11111111111) &<< cfblnbr_offset - public var cfblnbr: UInt16 { - get { UInt16((self.rawValue & (LTDC.L2CFBLNR.cfblnbr_mask)) >> LTDC.L2CFBLNR.cfblnbr_offset) } - set { - let preserve = self.rawValue & ~LTDC.L2CFBLNR.cfblnbr_mask - let shift = (UInt32(newValue) << LTDC.L2CFBLNR.cfblnbr_offset) & LTDC.L2CFBLNR.cfblnbr_mask - self.rawValue = preserve | shift - } - } - - public init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - public struct L2CLUTWR { - public var rawValue: UInt32 - - static let clutadd_offset = UInt32(24) - static let clutadd_mask = UInt32(0b11111111) &<< clutadd_offset - public var clutadd: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << LTDC.L2CLUTWR.clutadd_offset) & LTDC.L2CLUTWR.clutadd_mask - } - } - - static let red_offset = UInt32(16) - static let red_mask = UInt32(0b11111111) &<< red_offset - public var red: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << LTDC.L2CLUTWR.red_offset) & LTDC.L2CLUTWR.red_mask - } - } - - static let green_offset = UInt32(8) - static let green_mask = UInt32(0b11111111) &<< green_offset - public var green: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << LTDC.L2CLUTWR.green_offset) & LTDC.L2CLUTWR.green_mask - } - } - - static let blue_offset = UInt32(0) - static let blue_mask = UInt32(0b11111111) &<< blue_offset - public var blue: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << LTDC.L2CLUTWR.blue_offset) & LTDC.L2CLUTWR.blue_mask - } - } - - public init(rawValue: UInt32) { - self.rawValue = rawValue - } - } -} diff --git a/stm32-lcd-logo/Sources/Application/Libc.swift b/stm32-lcd-logo/Sources/Application/Libc.swift deleted file mode 100644 index 4c7a346b..00000000 --- a/stm32-lcd-logo/Sources/Application/Libc.swift +++ /dev/null @@ -1,33 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// This source file is part of the Swift open source project -// -// Copyright (c) 2023 Apple Inc. and the Swift project authors. -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See https://swift.org/LICENSE.txt for license information -// -//===----------------------------------------------------------------------===// - -@_silgen_name("memset") -func memset(_ dst: UnsafeMutableRawPointer, _ val: CInt, _ len: Int) - -> UnsafeMutableRawPointer -{ - let dst = dst.bindMemory(to: UInt8.self, capacity: len) - for i in 0.. UnsafeMutableRawPointer -{ - let src = src.bindMemory(to: UInt8.self, capacity: len) - let dst = dst.bindMemory(to: UInt8.self, capacity: len) - for i in 0..= maxLogoPosition.x { logoDelta.x *= -1 @@ -46,21 +44,36 @@ struct Main { if logoPosition.y <= 0 || logoPosition.y >= maxLogoPosition.y { logoDelta.y *= -1 } + logoPosition = logoPosition.offset(by: logoDelta) + ltdc.set(layer: 1, position: logoPosition) - if iteration % 16 == 0 { blink() } - - let backgroundGray: Int - if iteration % 512 < 256 { - backgroundGray = iteration % 256 - } else if iteration % 512 == 256 { - backgroundGray = 255 - } else { - backgroundGray = (512 - (iteration % 512)) % 256 + if backgroundGray == .min || backgroundGray == .max { + backgroundDelta *= -1 } - board.setBackgroundColor( - color: Color(r: backgroundGray, g: backgroundGray, b: backgroundGray)) + backgroundGray = UInt8(Int16(backgroundGray) + Int16(backgroundDelta)) + ltdc.set(backgroundColor: .gray(backgroundGray)) + } + } + + static func delay(milliseconds: Int) { + for _ in 0..<100_000 * milliseconds { + nop() + } + } + + static func configureFlash() { + flash.acr.modify { $0.latency = .WS5 } + } - iteration += 1 + static func initializeLTCD() { + rcc.cfgr.write { $0.raw.storage = 0 } + rcc.cr.modify { r, w in + w.hsion = .On + w.csson = .Off + w.raw.hseon = 1 + w.raw.pllon = 0 + w.raw.hsebyp = 0 } + while rcc.cr.read().raw.hserdy == 0 {} } } diff --git a/stm32-lcd-logo/Sources/Application/RCC.swift b/stm32-lcd-logo/Sources/Application/RCC.swift deleted file mode 100644 index 9e3d8e51..00000000 --- a/stm32-lcd-logo/Sources/Application/RCC.swift +++ /dev/null @@ -1,4125 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// This source file is part of the Swift open source project -// -// Copyright (c) 2023 Apple Inc. and the Swift project authors. -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See https://swift.org/LICENSE.txt for license information -// -//===----------------------------------------------------------------------===// - -// swift-format-ignore-file - -/// Reset and clock control -struct RCC { - var baseAddress: UnsafeMutableRawPointer - - enum Offsets { - static let CR: Int32 = 0x0 - static let PLLCFGR: Int32 = 0x4 - static let CFGR: Int32 = 0x8 - static let CIR: Int32 = 0xc - static let AHB1RSTR: Int32 = 0x10 - static let AHB2RSTR: Int32 = 0x14 - static let AHB3RSTR: Int32 = 0x18 - static let APB1RSTR: Int32 = 0x20 - static let APB2RSTR: Int32 = 0x24 - static let AHB1ENR: Int32 = 0x30 - static let AHB2ENR: Int32 = 0x34 - static let AHB3ENR: Int32 = 0x38 - static let APB1ENR: Int32 = 0x40 - static let APB2ENR: Int32 = 0x44 - static let AHB1LPENR: Int32 = 0x50 - static let AHB2LPENR: Int32 = 0x54 - static let AHB3LPENR: Int32 = 0x58 - static let APB1LPENR: Int32 = 0x60 - static let APB2LPENR: Int32 = 0x64 - static let BDCR: Int32 = 0x70 - static let CSR: Int32 = 0x74 - static let SSCGR: Int32 = 0x80 - static let PLLI2SCFGR: Int32 = 0x84 - static let PLLSAICFGR: Int32 = 0x88 - static let DKCFGR1: Int32 = 0x8c - static let DKCFGR2: Int32 = 0x90 - } - - private func ld(_ offset: Int32) -> UInt32 { - UnsafeMutablePointer(bitPattern: UInt(bitPattern: UnsafeMutableRawPointer(baseAddress).advanced(by: Int(offset))))!.volatileLoad() - } - - private func st(_ offset: Int32, _ value: UInt32) { - UnsafeMutablePointer(bitPattern: UInt(bitPattern: UnsafeMutableRawPointer(baseAddress).advanced(by: Int(offset))))!.volatileStore(value) - } - - /// clock control register - var cr: CR { - get { CR(rawValue: ld(Offsets.CR)) } - set { st(Offsets.CR, newValue.rawValue) } - } - /// PLL configuration register - var pllcfgr: PLLCFGR { - get { PLLCFGR(rawValue: ld(Offsets.PLLCFGR)) } - set { st(Offsets.PLLCFGR, newValue.rawValue) } - } - /// clock configuration register - var cfgr: CFGR { - get { CFGR(rawValue: ld(Offsets.CFGR)) } - set { st(Offsets.CFGR, newValue.rawValue) } - } - /// clock interrupt register - var cir: CIR { - get { CIR(rawValue: ld(Offsets.CIR)) } - set { st(Offsets.CIR, newValue.rawValue) } - } - /// AHB1 peripheral reset register - var ahb1rstr: AHB1RSTR { - get { AHB1RSTR(rawValue: ld(Offsets.AHB1RSTR)) } - set { st(Offsets.AHB1RSTR, newValue.rawValue) } - } - /// AHB2 peripheral reset register - var ahb2rstr: AHB2RSTR { - get { AHB2RSTR(rawValue: ld(Offsets.AHB2RSTR)) } - set { st(Offsets.AHB2RSTR, newValue.rawValue) } - } - /// AHB3 peripheral reset register - var ahb3rstr: AHB3RSTR { - get { AHB3RSTR(rawValue: ld(Offsets.AHB3RSTR)) } - set { st(Offsets.AHB3RSTR, newValue.rawValue) } - } - /// APB1 peripheral reset register - var apb1rstr: APB1RSTR { - get { APB1RSTR(rawValue: ld(Offsets.APB1RSTR)) } - set { st(Offsets.APB1RSTR, newValue.rawValue) } - } - /// APB2 peripheral reset register - var apb2rstr: APB2RSTR { - get { APB2RSTR(rawValue: ld(Offsets.APB2RSTR)) } - set { st(Offsets.APB2RSTR, newValue.rawValue) } - } - /// AHB1 peripheral clock register - var ahb1enr: AHB1ENR { - get { AHB1ENR(rawValue: ld(Offsets.AHB1ENR)) } - set { st(Offsets.AHB1ENR, newValue.rawValue) } - } - /// AHB2 peripheral clock enable register - var ahb2enr: AHB2ENR { - get { AHB2ENR(rawValue: ld(Offsets.AHB2ENR)) } - set { st(Offsets.AHB2ENR, newValue.rawValue) } - } - /// AHB3 peripheral clock enable register - var ahb3enr: AHB3ENR { - get { AHB3ENR(rawValue: ld(Offsets.AHB3ENR)) } - set { st(Offsets.AHB3ENR, newValue.rawValue) } - } - /// APB1 peripheral clock enable register - var apb1enr: APB1ENR { - get { APB1ENR(rawValue: ld(Offsets.APB1ENR)) } - set { st(Offsets.APB1ENR, newValue.rawValue) } - } - /// APB2 peripheral clock enable register - var apb2enr: APB2ENR { - get { APB2ENR(rawValue: ld(Offsets.APB2ENR)) } - set { st(Offsets.APB2ENR, newValue.rawValue) } - } - /// AHB1 peripheral clock enable in low power mode register - var ahb1lpenr: AHB1LPENR { - get { AHB1LPENR(rawValue: ld(Offsets.AHB1LPENR)) } - set { st(Offsets.AHB1LPENR, newValue.rawValue) } - } - /// AHB2 peripheral clock enable in low power mode register - var ahb2lpenr: AHB2LPENR { - get { AHB2LPENR(rawValue: ld(Offsets.AHB2LPENR)) } - set { st(Offsets.AHB2LPENR, newValue.rawValue) } - } - /// AHB3 peripheral clock enable in low power mode register - var ahb3lpenr: AHB3LPENR { - get { AHB3LPENR(rawValue: ld(Offsets.AHB3LPENR)) } - set { st(Offsets.AHB3LPENR, newValue.rawValue) } - } - /// APB1 peripheral clock enable in low power mode register - var apb1lpenr: APB1LPENR { - get { APB1LPENR(rawValue: ld(Offsets.APB1LPENR)) } - set { st(Offsets.APB1LPENR, newValue.rawValue) } - } - /// APB2 peripheral clock enabled in low power mode register - var apb2lpenr: APB2LPENR { - get { APB2LPENR(rawValue: ld(Offsets.APB2LPENR)) } - set { st(Offsets.APB2LPENR, newValue.rawValue) } - } - /// Backup domain control register - var bdcr: BDCR { - get { BDCR(rawValue: ld(Offsets.BDCR)) } - set { st(Offsets.BDCR, newValue.rawValue) } - } - /// clock control & status register - var csr: CSR { - get { CSR(rawValue: ld(Offsets.CSR)) } - set { st(Offsets.CSR, newValue.rawValue) } - } - /// spread spectrum clock generation register - var sscgr: SSCGR { - get { SSCGR(rawValue: ld(Offsets.SSCGR)) } - set { st(Offsets.SSCGR, newValue.rawValue) } - } - /// PLLI2S configuration register - var plli2scfgr: PLLI2SCFGR { - get { PLLI2SCFGR(rawValue: ld(Offsets.PLLI2SCFGR)) } - set { st(Offsets.PLLI2SCFGR, newValue.rawValue) } - } - /// PLL configuration register - var pllsaicfgr: PLLSAICFGR { - get { PLLSAICFGR(rawValue: ld(Offsets.PLLSAICFGR)) } - set { st(Offsets.PLLSAICFGR, newValue.rawValue) } - } - /// dedicated clocks configuration register - var dkcfgr1: DKCFGR1 { - get { DKCFGR1(rawValue: ld(Offsets.DKCFGR1)) } - set { st(Offsets.DKCFGR1, newValue.rawValue) } - } - /// dedicated clocks configuration register - var dkcfgr2: DKCFGR2 { - get { DKCFGR2(rawValue: ld(Offsets.DKCFGR2)) } - set { st(Offsets.DKCFGR2, newValue.rawValue) } - } -} - -extension RCC { - struct CR { - var rawValue: UInt32 - - static let pllsairdy_offset = UInt32(29) - static let pllsairdy_mask = UInt32(0b1) &<< pllsairdy_offset - var pllsairdy: UInt8 { - UInt8((self.rawValue & (RCC.CR.pllsairdy_mask)) >> RCC.CR.pllsairdy_offset) - } - - static let pllsaion_offset = UInt32(28) - static let pllsaion_mask = UInt32(0b1) &<< pllsaion_offset - var pllsaion: UInt8 { - get { UInt8((self.rawValue & (RCC.CR.pllsaion_mask)) >> RCC.CR.pllsaion_offset) } - set { - let preserve = self.rawValue & ~RCC.CR.pllsaion_mask - let shift = (UInt32(newValue) << RCC.CR.pllsaion_offset) & RCC.CR.pllsaion_mask - self.rawValue = preserve | shift - } - } - - static let plli2srdy_offset = UInt32(27) - static let plli2srdy_mask = UInt32(0b1) &<< plli2srdy_offset - var plli2srdy: UInt8 { - UInt8((self.rawValue & (RCC.CR.plli2srdy_mask)) >> RCC.CR.plli2srdy_offset) - } - - static let plli2son_offset = UInt32(26) - static let plli2son_mask = UInt32(0b1) &<< plli2son_offset - var plli2son: UInt8 { - get { UInt8((self.rawValue & (RCC.CR.plli2son_mask)) >> RCC.CR.plli2son_offset) } - set { - let preserve = self.rawValue & ~RCC.CR.plli2son_mask - let shift = (UInt32(newValue) << RCC.CR.plli2son_offset) & RCC.CR.plli2son_mask - self.rawValue = preserve | shift - } - } - - static let pllrdy_offset = UInt32(25) - static let pllrdy_mask = UInt32(0b1) &<< pllrdy_offset - var pllrdy: UInt8 { - UInt8((self.rawValue & (RCC.CR.pllrdy_mask)) >> RCC.CR.pllrdy_offset) - } - - static let pllon_offset = UInt32(24) - static let pllon_mask = UInt32(0b1) &<< pllon_offset - var pllon: UInt8 { - get { UInt8((self.rawValue & (RCC.CR.pllon_mask)) >> RCC.CR.pllon_offset) } - set { - let preserve = self.rawValue & ~RCC.CR.pllon_mask - let shift = (UInt32(newValue) << RCC.CR.pllon_offset) & RCC.CR.pllon_mask - self.rawValue = preserve | shift - } - } - - static let csson_offset = UInt32(19) - static let csson_mask = UInt32(0b1) &<< csson_offset - var csson: UInt8 { - get { UInt8((self.rawValue & (RCC.CR.csson_mask)) >> RCC.CR.csson_offset) } - set { - let preserve = self.rawValue & ~RCC.CR.csson_mask - let shift = (UInt32(newValue) << RCC.CR.csson_offset) & RCC.CR.csson_mask - self.rawValue = preserve | shift - } - } - - static let hsebyp_offset = UInt32(18) - static let hsebyp_mask = UInt32(0b1) &<< hsebyp_offset - var hsebyp: UInt8 { - get { UInt8((self.rawValue & (RCC.CR.hsebyp_mask)) >> RCC.CR.hsebyp_offset) } - set { - let preserve = self.rawValue & ~RCC.CR.hsebyp_mask - let shift = (UInt32(newValue) << RCC.CR.hsebyp_offset) & RCC.CR.hsebyp_mask - self.rawValue = preserve | shift - } - } - - static let hserdy_offset = UInt32(17) - static let hserdy_mask = UInt32(0b1) &<< hserdy_offset - var hserdy: UInt8 { - UInt8((self.rawValue & (RCC.CR.hserdy_mask)) >> RCC.CR.hserdy_offset) - } - - static let hseon_offset = UInt32(16) - static let hseon_mask = UInt32(0b1) &<< hseon_offset - var hseon: UInt8 { - get { UInt8((self.rawValue & (RCC.CR.hseon_mask)) >> RCC.CR.hseon_offset) } - set { - let preserve = self.rawValue & ~RCC.CR.hseon_mask - let shift = (UInt32(newValue) << RCC.CR.hseon_offset) & RCC.CR.hseon_mask - self.rawValue = preserve | shift - } - } - - static let hsical_offset = UInt32(8) - static let hsical_mask = UInt32(0b11111111) &<< hsical_offset - var hsical: UInt8 { - UInt8((self.rawValue & (RCC.CR.hsical_mask)) >> RCC.CR.hsical_offset) - } - - static let hsitrim_offset = UInt32(3) - static let hsitrim_mask = UInt32(0b11111) &<< hsitrim_offset - var hsitrim: UInt8 { - get { UInt8((self.rawValue & (RCC.CR.hsitrim_mask)) >> RCC.CR.hsitrim_offset) } - set { - let preserve = self.rawValue & ~RCC.CR.hsitrim_mask - let shift = (UInt32(newValue) << RCC.CR.hsitrim_offset) & RCC.CR.hsitrim_mask - self.rawValue = preserve | shift - } - } - - static let hsirdy_offset = UInt32(1) - static let hsirdy_mask = UInt32(0b1) &<< hsirdy_offset - var hsirdy: UInt8 { - UInt8((self.rawValue & (RCC.CR.hsirdy_mask)) >> RCC.CR.hsirdy_offset) - } - - static let hsion_offset = UInt32(0) - static let hsion_mask = UInt32(0b1) &<< hsion_offset - var hsion: UInt8 { - get { UInt8((self.rawValue & (RCC.CR.hsion_mask)) >> RCC.CR.hsion_offset) } - set { - let preserve = self.rawValue & ~RCC.CR.hsion_mask - let shift = (UInt32(newValue) << RCC.CR.hsion_offset) & RCC.CR.hsion_mask - self.rawValue = preserve | shift - } - } - - init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - struct PLLCFGR { - var rawValue: UInt32 - - static let pllq3_offset = UInt32(27) - static let pllq3_mask = UInt32(0b1) &<< pllq3_offset - var pllq3: UInt8 { - get { UInt8((self.rawValue & (RCC.PLLCFGR.pllq3_mask)) >> RCC.PLLCFGR.pllq3_offset) } - set { - let preserve = self.rawValue & ~RCC.PLLCFGR.pllq3_mask - let shift = (UInt32(newValue) << RCC.PLLCFGR.pllq3_offset) & RCC.PLLCFGR.pllq3_mask - self.rawValue = preserve | shift - } - } - - static let pllq2_offset = UInt32(26) - static let pllq2_mask = UInt32(0b1) &<< pllq2_offset - var pllq2: UInt8 { - get { UInt8((self.rawValue & (RCC.PLLCFGR.pllq2_mask)) >> RCC.PLLCFGR.pllq2_offset) } - set { - let preserve = self.rawValue & ~RCC.PLLCFGR.pllq2_mask - let shift = (UInt32(newValue) << RCC.PLLCFGR.pllq2_offset) & RCC.PLLCFGR.pllq2_mask - self.rawValue = preserve | shift - } - } - - static let pllq1_offset = UInt32(25) - static let pllq1_mask = UInt32(0b1) &<< pllq1_offset - var pllq1: UInt8 { - get { UInt8((self.rawValue & (RCC.PLLCFGR.pllq1_mask)) >> RCC.PLLCFGR.pllq1_offset) } - set { - let preserve = self.rawValue & ~RCC.PLLCFGR.pllq1_mask - let shift = (UInt32(newValue) << RCC.PLLCFGR.pllq1_offset) & RCC.PLLCFGR.pllq1_mask - self.rawValue = preserve | shift - } - } - - static let pllq0_offset = UInt32(24) - static let pllq0_mask = UInt32(0b1) &<< pllq0_offset - var pllq0: UInt8 { - get { UInt8((self.rawValue & (RCC.PLLCFGR.pllq0_mask)) >> RCC.PLLCFGR.pllq0_offset) } - set { - let preserve = self.rawValue & ~RCC.PLLCFGR.pllq0_mask - let shift = (UInt32(newValue) << RCC.PLLCFGR.pllq0_offset) & RCC.PLLCFGR.pllq0_mask - self.rawValue = preserve | shift - } - } - - static let pllsrc_offset = UInt32(22) - static let pllsrc_mask = UInt32(0b1) &<< pllsrc_offset - var pllsrc: UInt8 { - get { UInt8((self.rawValue & (RCC.PLLCFGR.pllsrc_mask)) >> RCC.PLLCFGR.pllsrc_offset) } - set { - let preserve = self.rawValue & ~RCC.PLLCFGR.pllsrc_mask - let shift = (UInt32(newValue) << RCC.PLLCFGR.pllsrc_offset) & RCC.PLLCFGR.pllsrc_mask - self.rawValue = preserve | shift - } - } - - static let pllp1_offset = UInt32(17) - static let pllp1_mask = UInt32(0b1) &<< pllp1_offset - var pllp1: UInt8 { - get { UInt8((self.rawValue & (RCC.PLLCFGR.pllp1_mask)) >> RCC.PLLCFGR.pllp1_offset) } - set { - let preserve = self.rawValue & ~RCC.PLLCFGR.pllp1_mask - let shift = (UInt32(newValue) << RCC.PLLCFGR.pllp1_offset) & RCC.PLLCFGR.pllp1_mask - self.rawValue = preserve | shift - } - } - - static let pllp0_offset = UInt32(16) - static let pllp0_mask = UInt32(0b1) &<< pllp0_offset - var pllp0: UInt8 { - get { UInt8((self.rawValue & (RCC.PLLCFGR.pllp0_mask)) >> RCC.PLLCFGR.pllp0_offset) } - set { - let preserve = self.rawValue & ~RCC.PLLCFGR.pllp0_mask - let shift = (UInt32(newValue) << RCC.PLLCFGR.pllp0_offset) & RCC.PLLCFGR.pllp0_mask - self.rawValue = preserve | shift - } - } - - static let plln8_offset = UInt32(14) - static let plln8_mask = UInt32(0b1) &<< plln8_offset - var plln8: UInt8 { - get { UInt8((self.rawValue & (RCC.PLLCFGR.plln8_mask)) >> RCC.PLLCFGR.plln8_offset) } - set { - let preserve = self.rawValue & ~RCC.PLLCFGR.plln8_mask - let shift = (UInt32(newValue) << RCC.PLLCFGR.plln8_offset) & RCC.PLLCFGR.plln8_mask - self.rawValue = preserve | shift - } - } - - static let plln7_offset = UInt32(13) - static let plln7_mask = UInt32(0b1) &<< plln7_offset - var plln7: UInt8 { - get { UInt8((self.rawValue & (RCC.PLLCFGR.plln7_mask)) >> RCC.PLLCFGR.plln7_offset) } - set { - let preserve = self.rawValue & ~RCC.PLLCFGR.plln7_mask - let shift = (UInt32(newValue) << RCC.PLLCFGR.plln7_offset) & RCC.PLLCFGR.plln7_mask - self.rawValue = preserve | shift - } - } - - static let plln6_offset = UInt32(12) - static let plln6_mask = UInt32(0b1) &<< plln6_offset - var plln6: UInt8 { - get { UInt8((self.rawValue & (RCC.PLLCFGR.plln6_mask)) >> RCC.PLLCFGR.plln6_offset) } - set { - let preserve = self.rawValue & ~RCC.PLLCFGR.plln6_mask - let shift = (UInt32(newValue) << RCC.PLLCFGR.plln6_offset) & RCC.PLLCFGR.plln6_mask - self.rawValue = preserve | shift - } - } - - static let plln5_offset = UInt32(11) - static let plln5_mask = UInt32(0b1) &<< plln5_offset - var plln5: UInt8 { - get { UInt8((self.rawValue & (RCC.PLLCFGR.plln5_mask)) >> RCC.PLLCFGR.plln5_offset) } - set { - let preserve = self.rawValue & ~RCC.PLLCFGR.plln5_mask - let shift = (UInt32(newValue) << RCC.PLLCFGR.plln5_offset) & RCC.PLLCFGR.plln5_mask - self.rawValue = preserve | shift - } - } - - static let plln4_offset = UInt32(10) - static let plln4_mask = UInt32(0b1) &<< plln4_offset - var plln4: UInt8 { - get { UInt8((self.rawValue & (RCC.PLLCFGR.plln4_mask)) >> RCC.PLLCFGR.plln4_offset) } - set { - let preserve = self.rawValue & ~RCC.PLLCFGR.plln4_mask - let shift = (UInt32(newValue) << RCC.PLLCFGR.plln4_offset) & RCC.PLLCFGR.plln4_mask - self.rawValue = preserve | shift - } - } - - static let plln3_offset = UInt32(9) - static let plln3_mask = UInt32(0b1) &<< plln3_offset - var plln3: UInt8 { - get { UInt8((self.rawValue & (RCC.PLLCFGR.plln3_mask)) >> RCC.PLLCFGR.plln3_offset) } - set { - let preserve = self.rawValue & ~RCC.PLLCFGR.plln3_mask - let shift = (UInt32(newValue) << RCC.PLLCFGR.plln3_offset) & RCC.PLLCFGR.plln3_mask - self.rawValue = preserve | shift - } - } - - static let plln2_offset = UInt32(8) - static let plln2_mask = UInt32(0b1) &<< plln2_offset - var plln2: UInt8 { - get { UInt8((self.rawValue & (RCC.PLLCFGR.plln2_mask)) >> RCC.PLLCFGR.plln2_offset) } - set { - let preserve = self.rawValue & ~RCC.PLLCFGR.plln2_mask - let shift = (UInt32(newValue) << RCC.PLLCFGR.plln2_offset) & RCC.PLLCFGR.plln2_mask - self.rawValue = preserve | shift - } - } - - static let plln1_offset = UInt32(7) - static let plln1_mask = UInt32(0b1) &<< plln1_offset - var plln1: UInt8 { - get { UInt8((self.rawValue & (RCC.PLLCFGR.plln1_mask)) >> RCC.PLLCFGR.plln1_offset) } - set { - let preserve = self.rawValue & ~RCC.PLLCFGR.plln1_mask - let shift = (UInt32(newValue) << RCC.PLLCFGR.plln1_offset) & RCC.PLLCFGR.plln1_mask - self.rawValue = preserve | shift - } - } - - static let plln0_offset = UInt32(6) - static let plln0_mask = UInt32(0b1) &<< plln0_offset - var plln0: UInt8 { - get { UInt8((self.rawValue & (RCC.PLLCFGR.plln0_mask)) >> RCC.PLLCFGR.plln0_offset) } - set { - let preserve = self.rawValue & ~RCC.PLLCFGR.plln0_mask - let shift = (UInt32(newValue) << RCC.PLLCFGR.plln0_offset) & RCC.PLLCFGR.plln0_mask - self.rawValue = preserve | shift - } - } - - static let pllm5_offset = UInt32(5) - static let pllm5_mask = UInt32(0b1) &<< pllm5_offset - var pllm5: UInt8 { - get { UInt8((self.rawValue & (RCC.PLLCFGR.pllm5_mask)) >> RCC.PLLCFGR.pllm5_offset) } - set { - let preserve = self.rawValue & ~RCC.PLLCFGR.pllm5_mask - let shift = (UInt32(newValue) << RCC.PLLCFGR.pllm5_offset) & RCC.PLLCFGR.pllm5_mask - self.rawValue = preserve | shift - } - } - - static let pllm4_offset = UInt32(4) - static let pllm4_mask = UInt32(0b1) &<< pllm4_offset - var pllm4: UInt8 { - get { UInt8((self.rawValue & (RCC.PLLCFGR.pllm4_mask)) >> RCC.PLLCFGR.pllm4_offset) } - set { - let preserve = self.rawValue & ~RCC.PLLCFGR.pllm4_mask - let shift = (UInt32(newValue) << RCC.PLLCFGR.pllm4_offset) & RCC.PLLCFGR.pllm4_mask - self.rawValue = preserve | shift - } - } - - static let pllm3_offset = UInt32(3) - static let pllm3_mask = UInt32(0b1) &<< pllm3_offset - var pllm3: UInt8 { - get { UInt8((self.rawValue & (RCC.PLLCFGR.pllm3_mask)) >> RCC.PLLCFGR.pllm3_offset) } - set { - let preserve = self.rawValue & ~RCC.PLLCFGR.pllm3_mask - let shift = (UInt32(newValue) << RCC.PLLCFGR.pllm3_offset) & RCC.PLLCFGR.pllm3_mask - self.rawValue = preserve | shift - } - } - - static let pllm2_offset = UInt32(2) - static let pllm2_mask = UInt32(0b1) &<< pllm2_offset - var pllm2: UInt8 { - get { UInt8((self.rawValue & (RCC.PLLCFGR.pllm2_mask)) >> RCC.PLLCFGR.pllm2_offset) } - set { - let preserve = self.rawValue & ~RCC.PLLCFGR.pllm2_mask - let shift = (UInt32(newValue) << RCC.PLLCFGR.pllm2_offset) & RCC.PLLCFGR.pllm2_mask - self.rawValue = preserve | shift - } - } - - static let pllm1_offset = UInt32(1) - static let pllm1_mask = UInt32(0b1) &<< pllm1_offset - var pllm1: UInt8 { - get { UInt8((self.rawValue & (RCC.PLLCFGR.pllm1_mask)) >> RCC.PLLCFGR.pllm1_offset) } - set { - let preserve = self.rawValue & ~RCC.PLLCFGR.pllm1_mask - let shift = (UInt32(newValue) << RCC.PLLCFGR.pllm1_offset) & RCC.PLLCFGR.pllm1_mask - self.rawValue = preserve | shift - } - } - - static let pllm0_offset = UInt32(0) - static let pllm0_mask = UInt32(0b1) &<< pllm0_offset - var pllm0: UInt8 { - get { UInt8((self.rawValue & (RCC.PLLCFGR.pllm0_mask)) >> RCC.PLLCFGR.pllm0_offset) } - set { - let preserve = self.rawValue & ~RCC.PLLCFGR.pllm0_mask - let shift = (UInt32(newValue) << RCC.PLLCFGR.pllm0_offset) & RCC.PLLCFGR.pllm0_mask - self.rawValue = preserve | shift - } - } - - init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - struct CFGR { - var rawValue: UInt32 - - static let mco2_offset = UInt32(30) - static let mco2_mask = UInt32(0b11) &<< mco2_offset - var mco2: UInt8 { - get { UInt8((self.rawValue & (RCC.CFGR.mco2_mask)) >> RCC.CFGR.mco2_offset) } - set { - let preserve = self.rawValue & ~RCC.CFGR.mco2_mask - let shift = (UInt32(newValue) << RCC.CFGR.mco2_offset) & RCC.CFGR.mco2_mask - self.rawValue = preserve | shift - } - } - - static let mco2pre_offset = UInt32(27) - static let mco2pre_mask = UInt32(0b111) &<< mco2pre_offset - var mco2pre: UInt8 { - get { UInt8((self.rawValue & (RCC.CFGR.mco2pre_mask)) >> RCC.CFGR.mco2pre_offset) } - set { - let preserve = self.rawValue & ~RCC.CFGR.mco2pre_mask - let shift = (UInt32(newValue) << RCC.CFGR.mco2pre_offset) & RCC.CFGR.mco2pre_mask - self.rawValue = preserve | shift - } - } - - static let mco1pre_offset = UInt32(24) - static let mco1pre_mask = UInt32(0b111) &<< mco1pre_offset - var mco1pre: UInt8 { - get { UInt8((self.rawValue & (RCC.CFGR.mco1pre_mask)) >> RCC.CFGR.mco1pre_offset) } - set { - let preserve = self.rawValue & ~RCC.CFGR.mco1pre_mask - let shift = (UInt32(newValue) << RCC.CFGR.mco1pre_offset) & RCC.CFGR.mco1pre_mask - self.rawValue = preserve | shift - } - } - - static let i2ssrc_offset = UInt32(23) - static let i2ssrc_mask = UInt32(0b1) &<< i2ssrc_offset - var i2ssrc: UInt8 { - get { UInt8((self.rawValue & (RCC.CFGR.i2ssrc_mask)) >> RCC.CFGR.i2ssrc_offset) } - set { - let preserve = self.rawValue & ~RCC.CFGR.i2ssrc_mask - let shift = (UInt32(newValue) << RCC.CFGR.i2ssrc_offset) & RCC.CFGR.i2ssrc_mask - self.rawValue = preserve | shift - } - } - - static let mco1_offset = UInt32(21) - static let mco1_mask = UInt32(0b11) &<< mco1_offset - var mco1: UInt8 { - get { UInt8((self.rawValue & (RCC.CFGR.mco1_mask)) >> RCC.CFGR.mco1_offset) } - set { - let preserve = self.rawValue & ~RCC.CFGR.mco1_mask - let shift = (UInt32(newValue) << RCC.CFGR.mco1_offset) & RCC.CFGR.mco1_mask - self.rawValue = preserve | shift - } - } - - static let rtcpre_offset = UInt32(16) - static let rtcpre_mask = UInt32(0b11111) &<< rtcpre_offset - var rtcpre: UInt8 { - get { UInt8((self.rawValue & (RCC.CFGR.rtcpre_mask)) >> RCC.CFGR.rtcpre_offset) } - set { - let preserve = self.rawValue & ~RCC.CFGR.rtcpre_mask - let shift = (UInt32(newValue) << RCC.CFGR.rtcpre_offset) & RCC.CFGR.rtcpre_mask - self.rawValue = preserve | shift - } - } - - static let ppre2_offset = UInt32(13) - static let ppre2_mask = UInt32(0b111) &<< ppre2_offset - var ppre2: UInt8 { - get { UInt8((self.rawValue & (RCC.CFGR.ppre2_mask)) >> RCC.CFGR.ppre2_offset) } - set { - let preserve = self.rawValue & ~RCC.CFGR.ppre2_mask - let shift = (UInt32(newValue) << RCC.CFGR.ppre2_offset) & RCC.CFGR.ppre2_mask - self.rawValue = preserve | shift - } - } - - static let ppre1_offset = UInt32(10) - static let ppre1_mask = UInt32(0b111) &<< ppre1_offset - var ppre1: UInt8 { - get { UInt8((self.rawValue & (RCC.CFGR.ppre1_mask)) >> RCC.CFGR.ppre1_offset) } - set { - let preserve = self.rawValue & ~RCC.CFGR.ppre1_mask - let shift = (UInt32(newValue) << RCC.CFGR.ppre1_offset) & RCC.CFGR.ppre1_mask - self.rawValue = preserve | shift - } - } - - static let hpre_offset = UInt32(4) - static let hpre_mask = UInt32(0b1111) &<< hpre_offset - var hpre: UInt8 { - get { UInt8((self.rawValue & (RCC.CFGR.hpre_mask)) >> RCC.CFGR.hpre_offset) } - set { - let preserve = self.rawValue & ~RCC.CFGR.hpre_mask - let shift = (UInt32(newValue) << RCC.CFGR.hpre_offset) & RCC.CFGR.hpre_mask - self.rawValue = preserve | shift - } - } - - static let sws1_offset = UInt32(3) - static let sws1_mask = UInt32(0b1) &<< sws1_offset - var sws1: UInt8 { - UInt8((self.rawValue & (RCC.CFGR.sws1_mask)) >> RCC.CFGR.sws1_offset) - } - - static let sws0_offset = UInt32(2) - static let sws0_mask = UInt32(0b1) &<< sws0_offset - var sws0: UInt8 { - UInt8((self.rawValue & (RCC.CFGR.sws0_mask)) >> RCC.CFGR.sws0_offset) - } - - static let sw1_offset = UInt32(1) - static let sw1_mask = UInt32(0b1) &<< sw1_offset - var sw1: UInt8 { - get { UInt8((self.rawValue & (RCC.CFGR.sw1_mask)) >> RCC.CFGR.sw1_offset) } - set { - let preserve = self.rawValue & ~RCC.CFGR.sw1_mask - let shift = (UInt32(newValue) << RCC.CFGR.sw1_offset) & RCC.CFGR.sw1_mask - self.rawValue = preserve | shift - } - } - - static let sw0_offset = UInt32(0) - static let sw0_mask = UInt32(0b1) &<< sw0_offset - var sw0: UInt8 { - get { UInt8((self.rawValue & (RCC.CFGR.sw0_mask)) >> RCC.CFGR.sw0_offset) } - set { - let preserve = self.rawValue & ~RCC.CFGR.sw0_mask - let shift = (UInt32(newValue) << RCC.CFGR.sw0_offset) & RCC.CFGR.sw0_mask - self.rawValue = preserve | shift - } - } - - init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - struct CIR { - var rawValue: UInt32 - - static let cssc_offset = UInt32(23) - static let cssc_mask = UInt32(0b1) &<< cssc_offset - var cssc: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << RCC.CIR.cssc_offset) & RCC.CIR.cssc_mask - } - } - - static let pllsairdyc_offset = UInt32(22) - static let pllsairdyc_mask = UInt32(0b1) &<< pllsairdyc_offset - var pllsairdyc: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << RCC.CIR.pllsairdyc_offset) & RCC.CIR.pllsairdyc_mask - } - } - - static let plli2srdyc_offset = UInt32(21) - static let plli2srdyc_mask = UInt32(0b1) &<< plli2srdyc_offset - var plli2srdyc: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << RCC.CIR.plli2srdyc_offset) & RCC.CIR.plli2srdyc_mask - } - } - - static let pllrdyc_offset = UInt32(20) - static let pllrdyc_mask = UInt32(0b1) &<< pllrdyc_offset - var pllrdyc: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << RCC.CIR.pllrdyc_offset) & RCC.CIR.pllrdyc_mask - } - } - - static let hserdyc_offset = UInt32(19) - static let hserdyc_mask = UInt32(0b1) &<< hserdyc_offset - var hserdyc: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << RCC.CIR.hserdyc_offset) & RCC.CIR.hserdyc_mask - } - } - - static let hsirdyc_offset = UInt32(18) - static let hsirdyc_mask = UInt32(0b1) &<< hsirdyc_offset - var hsirdyc: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << RCC.CIR.hsirdyc_offset) & RCC.CIR.hsirdyc_mask - } - } - - static let lserdyc_offset = UInt32(17) - static let lserdyc_mask = UInt32(0b1) &<< lserdyc_offset - var lserdyc: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << RCC.CIR.lserdyc_offset) & RCC.CIR.lserdyc_mask - } - } - - static let lsirdyc_offset = UInt32(16) - static let lsirdyc_mask = UInt32(0b1) &<< lsirdyc_offset - var lsirdyc: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << RCC.CIR.lsirdyc_offset) & RCC.CIR.lsirdyc_mask - } - } - - static let pllsairdyie_offset = UInt32(14) - static let pllsairdyie_mask = UInt32(0b1) &<< pllsairdyie_offset - var pllsairdyie: UInt8 { - get { UInt8((self.rawValue & (RCC.CIR.pllsairdyie_mask)) >> RCC.CIR.pllsairdyie_offset) } - set { - let preserve = self.rawValue & ~RCC.CIR.pllsairdyie_mask - let shift = (UInt32(newValue) << RCC.CIR.pllsairdyie_offset) & RCC.CIR.pllsairdyie_mask - self.rawValue = preserve | shift - } - } - - static let plli2srdyie_offset = UInt32(13) - static let plli2srdyie_mask = UInt32(0b1) &<< plli2srdyie_offset - var plli2srdyie: UInt8 { - get { UInt8((self.rawValue & (RCC.CIR.plli2srdyie_mask)) >> RCC.CIR.plli2srdyie_offset) } - set { - let preserve = self.rawValue & ~RCC.CIR.plli2srdyie_mask - let shift = (UInt32(newValue) << RCC.CIR.plli2srdyie_offset) & RCC.CIR.plli2srdyie_mask - self.rawValue = preserve | shift - } - } - - static let pllrdyie_offset = UInt32(12) - static let pllrdyie_mask = UInt32(0b1) &<< pllrdyie_offset - var pllrdyie: UInt8 { - get { UInt8((self.rawValue & (RCC.CIR.pllrdyie_mask)) >> RCC.CIR.pllrdyie_offset) } - set { - let preserve = self.rawValue & ~RCC.CIR.pllrdyie_mask - let shift = (UInt32(newValue) << RCC.CIR.pllrdyie_offset) & RCC.CIR.pllrdyie_mask - self.rawValue = preserve | shift - } - } - - static let hserdyie_offset = UInt32(11) - static let hserdyie_mask = UInt32(0b1) &<< hserdyie_offset - var hserdyie: UInt8 { - get { UInt8((self.rawValue & (RCC.CIR.hserdyie_mask)) >> RCC.CIR.hserdyie_offset) } - set { - let preserve = self.rawValue & ~RCC.CIR.hserdyie_mask - let shift = (UInt32(newValue) << RCC.CIR.hserdyie_offset) & RCC.CIR.hserdyie_mask - self.rawValue = preserve | shift - } - } - - static let hsirdyie_offset = UInt32(10) - static let hsirdyie_mask = UInt32(0b1) &<< hsirdyie_offset - var hsirdyie: UInt8 { - get { UInt8((self.rawValue & (RCC.CIR.hsirdyie_mask)) >> RCC.CIR.hsirdyie_offset) } - set { - let preserve = self.rawValue & ~RCC.CIR.hsirdyie_mask - let shift = (UInt32(newValue) << RCC.CIR.hsirdyie_offset) & RCC.CIR.hsirdyie_mask - self.rawValue = preserve | shift - } - } - - static let lserdyie_offset = UInt32(9) - static let lserdyie_mask = UInt32(0b1) &<< lserdyie_offset - var lserdyie: UInt8 { - get { UInt8((self.rawValue & (RCC.CIR.lserdyie_mask)) >> RCC.CIR.lserdyie_offset) } - set { - let preserve = self.rawValue & ~RCC.CIR.lserdyie_mask - let shift = (UInt32(newValue) << RCC.CIR.lserdyie_offset) & RCC.CIR.lserdyie_mask - self.rawValue = preserve | shift - } - } - - static let lsirdyie_offset = UInt32(8) - static let lsirdyie_mask = UInt32(0b1) &<< lsirdyie_offset - var lsirdyie: UInt8 { - get { UInt8((self.rawValue & (RCC.CIR.lsirdyie_mask)) >> RCC.CIR.lsirdyie_offset) } - set { - let preserve = self.rawValue & ~RCC.CIR.lsirdyie_mask - let shift = (UInt32(newValue) << RCC.CIR.lsirdyie_offset) & RCC.CIR.lsirdyie_mask - self.rawValue = preserve | shift - } - } - - static let cssf_offset = UInt32(7) - static let cssf_mask = UInt32(0b1) &<< cssf_offset - var cssf: UInt8 { - UInt8((self.rawValue & (RCC.CIR.cssf_mask)) >> RCC.CIR.cssf_offset) - } - - static let pllsairdyf_offset = UInt32(6) - static let pllsairdyf_mask = UInt32(0b1) &<< pllsairdyf_offset - var pllsairdyf: UInt8 { - UInt8((self.rawValue & (RCC.CIR.pllsairdyf_mask)) >> RCC.CIR.pllsairdyf_offset) - } - - static let plli2srdyf_offset = UInt32(5) - static let plli2srdyf_mask = UInt32(0b1) &<< plli2srdyf_offset - var plli2srdyf: UInt8 { - UInt8((self.rawValue & (RCC.CIR.plli2srdyf_mask)) >> RCC.CIR.plli2srdyf_offset) - } - - static let pllrdyf_offset = UInt32(4) - static let pllrdyf_mask = UInt32(0b1) &<< pllrdyf_offset - var pllrdyf: UInt8 { - UInt8((self.rawValue & (RCC.CIR.pllrdyf_mask)) >> RCC.CIR.pllrdyf_offset) - } - - static let hserdyf_offset = UInt32(3) - static let hserdyf_mask = UInt32(0b1) &<< hserdyf_offset - var hserdyf: UInt8 { - UInt8((self.rawValue & (RCC.CIR.hserdyf_mask)) >> RCC.CIR.hserdyf_offset) - } - - static let hsirdyf_offset = UInt32(2) - static let hsirdyf_mask = UInt32(0b1) &<< hsirdyf_offset - var hsirdyf: UInt8 { - UInt8((self.rawValue & (RCC.CIR.hsirdyf_mask)) >> RCC.CIR.hsirdyf_offset) - } - - static let lserdyf_offset = UInt32(1) - static let lserdyf_mask = UInt32(0b1) &<< lserdyf_offset - var lserdyf: UInt8 { - UInt8((self.rawValue & (RCC.CIR.lserdyf_mask)) >> RCC.CIR.lserdyf_offset) - } - - static let lsirdyf_offset = UInt32(0) - static let lsirdyf_mask = UInt32(0b1) &<< lsirdyf_offset - var lsirdyf: UInt8 { - UInt8((self.rawValue & (RCC.CIR.lsirdyf_mask)) >> RCC.CIR.lsirdyf_offset) - } - - init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - struct AHB1RSTR { - var rawValue: UInt32 - - static let otghsrst_offset = UInt32(29) - static let otghsrst_mask = UInt32(0b1) &<< otghsrst_offset - var otghsrst: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1RSTR.otghsrst_mask)) >> RCC.AHB1RSTR.otghsrst_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1RSTR.otghsrst_mask - let shift = (UInt32(newValue) << RCC.AHB1RSTR.otghsrst_offset) & RCC.AHB1RSTR.otghsrst_mask - self.rawValue = preserve | shift - } - } - - static let ethmacrst_offset = UInt32(25) - static let ethmacrst_mask = UInt32(0b1) &<< ethmacrst_offset - var ethmacrst: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1RSTR.ethmacrst_mask)) >> RCC.AHB1RSTR.ethmacrst_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1RSTR.ethmacrst_mask - let shift = (UInt32(newValue) << RCC.AHB1RSTR.ethmacrst_offset) & RCC.AHB1RSTR.ethmacrst_mask - self.rawValue = preserve | shift - } - } - - static let dma2drst_offset = UInt32(23) - static let dma2drst_mask = UInt32(0b1) &<< dma2drst_offset - var dma2drst: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1RSTR.dma2drst_mask)) >> RCC.AHB1RSTR.dma2drst_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1RSTR.dma2drst_mask - let shift = (UInt32(newValue) << RCC.AHB1RSTR.dma2drst_offset) & RCC.AHB1RSTR.dma2drst_mask - self.rawValue = preserve | shift - } - } - - static let dma2rst_offset = UInt32(22) - static let dma2rst_mask = UInt32(0b1) &<< dma2rst_offset - var dma2rst: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1RSTR.dma2rst_mask)) >> RCC.AHB1RSTR.dma2rst_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1RSTR.dma2rst_mask - let shift = (UInt32(newValue) << RCC.AHB1RSTR.dma2rst_offset) & RCC.AHB1RSTR.dma2rst_mask - self.rawValue = preserve | shift - } - } - - static let dma1rst_offset = UInt32(21) - static let dma1rst_mask = UInt32(0b1) &<< dma1rst_offset - var dma1rst: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1RSTR.dma1rst_mask)) >> RCC.AHB1RSTR.dma1rst_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1RSTR.dma1rst_mask - let shift = (UInt32(newValue) << RCC.AHB1RSTR.dma1rst_offset) & RCC.AHB1RSTR.dma1rst_mask - self.rawValue = preserve | shift - } - } - - static let crcrst_offset = UInt32(12) - static let crcrst_mask = UInt32(0b1) &<< crcrst_offset - var crcrst: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1RSTR.crcrst_mask)) >> RCC.AHB1RSTR.crcrst_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1RSTR.crcrst_mask - let shift = (UInt32(newValue) << RCC.AHB1RSTR.crcrst_offset) & RCC.AHB1RSTR.crcrst_mask - self.rawValue = preserve | shift - } - } - - static let gpiokrst_offset = UInt32(10) - static let gpiokrst_mask = UInt32(0b1) &<< gpiokrst_offset - var gpiokrst: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1RSTR.gpiokrst_mask)) >> RCC.AHB1RSTR.gpiokrst_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1RSTR.gpiokrst_mask - let shift = (UInt32(newValue) << RCC.AHB1RSTR.gpiokrst_offset) & RCC.AHB1RSTR.gpiokrst_mask - self.rawValue = preserve | shift - } - } - - static let gpiojrst_offset = UInt32(9) - static let gpiojrst_mask = UInt32(0b1) &<< gpiojrst_offset - var gpiojrst: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1RSTR.gpiojrst_mask)) >> RCC.AHB1RSTR.gpiojrst_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1RSTR.gpiojrst_mask - let shift = (UInt32(newValue) << RCC.AHB1RSTR.gpiojrst_offset) & RCC.AHB1RSTR.gpiojrst_mask - self.rawValue = preserve | shift - } - } - - static let gpioirst_offset = UInt32(8) - static let gpioirst_mask = UInt32(0b1) &<< gpioirst_offset - var gpioirst: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1RSTR.gpioirst_mask)) >> RCC.AHB1RSTR.gpioirst_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1RSTR.gpioirst_mask - let shift = (UInt32(newValue) << RCC.AHB1RSTR.gpioirst_offset) & RCC.AHB1RSTR.gpioirst_mask - self.rawValue = preserve | shift - } - } - - static let gpiohrst_offset = UInt32(7) - static let gpiohrst_mask = UInt32(0b1) &<< gpiohrst_offset - var gpiohrst: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1RSTR.gpiohrst_mask)) >> RCC.AHB1RSTR.gpiohrst_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1RSTR.gpiohrst_mask - let shift = (UInt32(newValue) << RCC.AHB1RSTR.gpiohrst_offset) & RCC.AHB1RSTR.gpiohrst_mask - self.rawValue = preserve | shift - } - } - - static let gpiogrst_offset = UInt32(6) - static let gpiogrst_mask = UInt32(0b1) &<< gpiogrst_offset - var gpiogrst: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1RSTR.gpiogrst_mask)) >> RCC.AHB1RSTR.gpiogrst_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1RSTR.gpiogrst_mask - let shift = (UInt32(newValue) << RCC.AHB1RSTR.gpiogrst_offset) & RCC.AHB1RSTR.gpiogrst_mask - self.rawValue = preserve | shift - } - } - - static let gpiofrst_offset = UInt32(5) - static let gpiofrst_mask = UInt32(0b1) &<< gpiofrst_offset - var gpiofrst: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1RSTR.gpiofrst_mask)) >> RCC.AHB1RSTR.gpiofrst_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1RSTR.gpiofrst_mask - let shift = (UInt32(newValue) << RCC.AHB1RSTR.gpiofrst_offset) & RCC.AHB1RSTR.gpiofrst_mask - self.rawValue = preserve | shift - } - } - - static let gpioerst_offset = UInt32(4) - static let gpioerst_mask = UInt32(0b1) &<< gpioerst_offset - var gpioerst: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1RSTR.gpioerst_mask)) >> RCC.AHB1RSTR.gpioerst_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1RSTR.gpioerst_mask - let shift = (UInt32(newValue) << RCC.AHB1RSTR.gpioerst_offset) & RCC.AHB1RSTR.gpioerst_mask - self.rawValue = preserve | shift - } - } - - static let gpiodrst_offset = UInt32(3) - static let gpiodrst_mask = UInt32(0b1) &<< gpiodrst_offset - var gpiodrst: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1RSTR.gpiodrst_mask)) >> RCC.AHB1RSTR.gpiodrst_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1RSTR.gpiodrst_mask - let shift = (UInt32(newValue) << RCC.AHB1RSTR.gpiodrst_offset) & RCC.AHB1RSTR.gpiodrst_mask - self.rawValue = preserve | shift - } - } - - static let gpiocrst_offset = UInt32(2) - static let gpiocrst_mask = UInt32(0b1) &<< gpiocrst_offset - var gpiocrst: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1RSTR.gpiocrst_mask)) >> RCC.AHB1RSTR.gpiocrst_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1RSTR.gpiocrst_mask - let shift = (UInt32(newValue) << RCC.AHB1RSTR.gpiocrst_offset) & RCC.AHB1RSTR.gpiocrst_mask - self.rawValue = preserve | shift - } - } - - static let gpiobrst_offset = UInt32(1) - static let gpiobrst_mask = UInt32(0b1) &<< gpiobrst_offset - var gpiobrst: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1RSTR.gpiobrst_mask)) >> RCC.AHB1RSTR.gpiobrst_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1RSTR.gpiobrst_mask - let shift = (UInt32(newValue) << RCC.AHB1RSTR.gpiobrst_offset) & RCC.AHB1RSTR.gpiobrst_mask - self.rawValue = preserve | shift - } - } - - static let gpioarst_offset = UInt32(0) - static let gpioarst_mask = UInt32(0b1) &<< gpioarst_offset - var gpioarst: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1RSTR.gpioarst_mask)) >> RCC.AHB1RSTR.gpioarst_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1RSTR.gpioarst_mask - let shift = (UInt32(newValue) << RCC.AHB1RSTR.gpioarst_offset) & RCC.AHB1RSTR.gpioarst_mask - self.rawValue = preserve | shift - } - } - - init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - struct AHB2RSTR { - var rawValue: UInt32 - - static let otgfsrst_offset = UInt32(7) - static let otgfsrst_mask = UInt32(0b1) &<< otgfsrst_offset - var otgfsrst: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB2RSTR.otgfsrst_mask)) >> RCC.AHB2RSTR.otgfsrst_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB2RSTR.otgfsrst_mask - let shift = (UInt32(newValue) << RCC.AHB2RSTR.otgfsrst_offset) & RCC.AHB2RSTR.otgfsrst_mask - self.rawValue = preserve | shift - } - } - - static let rngrst_offset = UInt32(6) - static let rngrst_mask = UInt32(0b1) &<< rngrst_offset - var rngrst: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB2RSTR.rngrst_mask)) >> RCC.AHB2RSTR.rngrst_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB2RSTR.rngrst_mask - let shift = (UInt32(newValue) << RCC.AHB2RSTR.rngrst_offset) & RCC.AHB2RSTR.rngrst_mask - self.rawValue = preserve | shift - } - } - - static let hsahrst_offset = UInt32(5) - static let hsahrst_mask = UInt32(0b1) &<< hsahrst_offset - var hsahrst: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB2RSTR.hsahrst_mask)) >> RCC.AHB2RSTR.hsahrst_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB2RSTR.hsahrst_mask - let shift = (UInt32(newValue) << RCC.AHB2RSTR.hsahrst_offset) & RCC.AHB2RSTR.hsahrst_mask - self.rawValue = preserve | shift - } - } - - static let cryprst_offset = UInt32(4) - static let cryprst_mask = UInt32(0b1) &<< cryprst_offset - var cryprst: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB2RSTR.cryprst_mask)) >> RCC.AHB2RSTR.cryprst_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB2RSTR.cryprst_mask - let shift = (UInt32(newValue) << RCC.AHB2RSTR.cryprst_offset) & RCC.AHB2RSTR.cryprst_mask - self.rawValue = preserve | shift - } - } - - static let dcmirst_offset = UInt32(0) - static let dcmirst_mask = UInt32(0b1) &<< dcmirst_offset - var dcmirst: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB2RSTR.dcmirst_mask)) >> RCC.AHB2RSTR.dcmirst_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB2RSTR.dcmirst_mask - let shift = (UInt32(newValue) << RCC.AHB2RSTR.dcmirst_offset) & RCC.AHB2RSTR.dcmirst_mask - self.rawValue = preserve | shift - } - } - - init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - struct AHB3RSTR { - var rawValue: UInt32 - - static let fmcrst_offset = UInt32(0) - static let fmcrst_mask = UInt32(0b1) &<< fmcrst_offset - var fmcrst: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB3RSTR.fmcrst_mask)) >> RCC.AHB3RSTR.fmcrst_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB3RSTR.fmcrst_mask - let shift = (UInt32(newValue) << RCC.AHB3RSTR.fmcrst_offset) & RCC.AHB3RSTR.fmcrst_mask - self.rawValue = preserve | shift - } - } - - static let qspirst_offset = UInt32(1) - static let qspirst_mask = UInt32(0b1) &<< qspirst_offset - var qspirst: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB3RSTR.qspirst_mask)) >> RCC.AHB3RSTR.qspirst_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB3RSTR.qspirst_mask - let shift = (UInt32(newValue) << RCC.AHB3RSTR.qspirst_offset) & RCC.AHB3RSTR.qspirst_mask - self.rawValue = preserve | shift - } - } - - init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - struct APB1RSTR { - var rawValue: UInt32 - - static let tim2rst_offset = UInt32(0) - static let tim2rst_mask = UInt32(0b1) &<< tim2rst_offset - var tim2rst: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1RSTR.tim2rst_mask)) >> RCC.APB1RSTR.tim2rst_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1RSTR.tim2rst_mask - let shift = (UInt32(newValue) << RCC.APB1RSTR.tim2rst_offset) & RCC.APB1RSTR.tim2rst_mask - self.rawValue = preserve | shift - } - } - - static let tim3rst_offset = UInt32(1) - static let tim3rst_mask = UInt32(0b1) &<< tim3rst_offset - var tim3rst: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1RSTR.tim3rst_mask)) >> RCC.APB1RSTR.tim3rst_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1RSTR.tim3rst_mask - let shift = (UInt32(newValue) << RCC.APB1RSTR.tim3rst_offset) & RCC.APB1RSTR.tim3rst_mask - self.rawValue = preserve | shift - } - } - - static let tim4rst_offset = UInt32(2) - static let tim4rst_mask = UInt32(0b1) &<< tim4rst_offset - var tim4rst: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1RSTR.tim4rst_mask)) >> RCC.APB1RSTR.tim4rst_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1RSTR.tim4rst_mask - let shift = (UInt32(newValue) << RCC.APB1RSTR.tim4rst_offset) & RCC.APB1RSTR.tim4rst_mask - self.rawValue = preserve | shift - } - } - - static let tim5rst_offset = UInt32(3) - static let tim5rst_mask = UInt32(0b1) &<< tim5rst_offset - var tim5rst: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1RSTR.tim5rst_mask)) >> RCC.APB1RSTR.tim5rst_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1RSTR.tim5rst_mask - let shift = (UInt32(newValue) << RCC.APB1RSTR.tim5rst_offset) & RCC.APB1RSTR.tim5rst_mask - self.rawValue = preserve | shift - } - } - - static let tim6rst_offset = UInt32(4) - static let tim6rst_mask = UInt32(0b1) &<< tim6rst_offset - var tim6rst: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1RSTR.tim6rst_mask)) >> RCC.APB1RSTR.tim6rst_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1RSTR.tim6rst_mask - let shift = (UInt32(newValue) << RCC.APB1RSTR.tim6rst_offset) & RCC.APB1RSTR.tim6rst_mask - self.rawValue = preserve | shift - } - } - - static let tim7rst_offset = UInt32(5) - static let tim7rst_mask = UInt32(0b1) &<< tim7rst_offset - var tim7rst: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1RSTR.tim7rst_mask)) >> RCC.APB1RSTR.tim7rst_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1RSTR.tim7rst_mask - let shift = (UInt32(newValue) << RCC.APB1RSTR.tim7rst_offset) & RCC.APB1RSTR.tim7rst_mask - self.rawValue = preserve | shift - } - } - - static let tim12rst_offset = UInt32(6) - static let tim12rst_mask = UInt32(0b1) &<< tim12rst_offset - var tim12rst: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1RSTR.tim12rst_mask)) >> RCC.APB1RSTR.tim12rst_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1RSTR.tim12rst_mask - let shift = (UInt32(newValue) << RCC.APB1RSTR.tim12rst_offset) & RCC.APB1RSTR.tim12rst_mask - self.rawValue = preserve | shift - } - } - - static let tim13rst_offset = UInt32(7) - static let tim13rst_mask = UInt32(0b1) &<< tim13rst_offset - var tim13rst: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1RSTR.tim13rst_mask)) >> RCC.APB1RSTR.tim13rst_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1RSTR.tim13rst_mask - let shift = (UInt32(newValue) << RCC.APB1RSTR.tim13rst_offset) & RCC.APB1RSTR.tim13rst_mask - self.rawValue = preserve | shift - } - } - - static let tim14rst_offset = UInt32(8) - static let tim14rst_mask = UInt32(0b1) &<< tim14rst_offset - var tim14rst: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1RSTR.tim14rst_mask)) >> RCC.APB1RSTR.tim14rst_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1RSTR.tim14rst_mask - let shift = (UInt32(newValue) << RCC.APB1RSTR.tim14rst_offset) & RCC.APB1RSTR.tim14rst_mask - self.rawValue = preserve | shift - } - } - - static let wwdgrst_offset = UInt32(11) - static let wwdgrst_mask = UInt32(0b1) &<< wwdgrst_offset - var wwdgrst: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1RSTR.wwdgrst_mask)) >> RCC.APB1RSTR.wwdgrst_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1RSTR.wwdgrst_mask - let shift = (UInt32(newValue) << RCC.APB1RSTR.wwdgrst_offset) & RCC.APB1RSTR.wwdgrst_mask - self.rawValue = preserve | shift - } - } - - static let spi2rst_offset = UInt32(14) - static let spi2rst_mask = UInt32(0b1) &<< spi2rst_offset - var spi2rst: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1RSTR.spi2rst_mask)) >> RCC.APB1RSTR.spi2rst_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1RSTR.spi2rst_mask - let shift = (UInt32(newValue) << RCC.APB1RSTR.spi2rst_offset) & RCC.APB1RSTR.spi2rst_mask - self.rawValue = preserve | shift - } - } - - static let spi3rst_offset = UInt32(15) - static let spi3rst_mask = UInt32(0b1) &<< spi3rst_offset - var spi3rst: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1RSTR.spi3rst_mask)) >> RCC.APB1RSTR.spi3rst_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1RSTR.spi3rst_mask - let shift = (UInt32(newValue) << RCC.APB1RSTR.spi3rst_offset) & RCC.APB1RSTR.spi3rst_mask - self.rawValue = preserve | shift - } - } - - static let uart2rst_offset = UInt32(17) - static let uart2rst_mask = UInt32(0b1) &<< uart2rst_offset - var uart2rst: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1RSTR.uart2rst_mask)) >> RCC.APB1RSTR.uart2rst_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1RSTR.uart2rst_mask - let shift = (UInt32(newValue) << RCC.APB1RSTR.uart2rst_offset) & RCC.APB1RSTR.uart2rst_mask - self.rawValue = preserve | shift - } - } - - static let uart3rst_offset = UInt32(18) - static let uart3rst_mask = UInt32(0b1) &<< uart3rst_offset - var uart3rst: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1RSTR.uart3rst_mask)) >> RCC.APB1RSTR.uart3rst_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1RSTR.uart3rst_mask - let shift = (UInt32(newValue) << RCC.APB1RSTR.uart3rst_offset) & RCC.APB1RSTR.uart3rst_mask - self.rawValue = preserve | shift - } - } - - static let uart4rst_offset = UInt32(19) - static let uart4rst_mask = UInt32(0b1) &<< uart4rst_offset - var uart4rst: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1RSTR.uart4rst_mask)) >> RCC.APB1RSTR.uart4rst_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1RSTR.uart4rst_mask - let shift = (UInt32(newValue) << RCC.APB1RSTR.uart4rst_offset) & RCC.APB1RSTR.uart4rst_mask - self.rawValue = preserve | shift - } - } - - static let uart5rst_offset = UInt32(20) - static let uart5rst_mask = UInt32(0b1) &<< uart5rst_offset - var uart5rst: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1RSTR.uart5rst_mask)) >> RCC.APB1RSTR.uart5rst_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1RSTR.uart5rst_mask - let shift = (UInt32(newValue) << RCC.APB1RSTR.uart5rst_offset) & RCC.APB1RSTR.uart5rst_mask - self.rawValue = preserve | shift - } - } - - static let i2c1rst_offset = UInt32(21) - static let i2c1rst_mask = UInt32(0b1) &<< i2c1rst_offset - var i2c1rst: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1RSTR.i2c1rst_mask)) >> RCC.APB1RSTR.i2c1rst_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1RSTR.i2c1rst_mask - let shift = (UInt32(newValue) << RCC.APB1RSTR.i2c1rst_offset) & RCC.APB1RSTR.i2c1rst_mask - self.rawValue = preserve | shift - } - } - - static let i2c2rst_offset = UInt32(22) - static let i2c2rst_mask = UInt32(0b1) &<< i2c2rst_offset - var i2c2rst: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1RSTR.i2c2rst_mask)) >> RCC.APB1RSTR.i2c2rst_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1RSTR.i2c2rst_mask - let shift = (UInt32(newValue) << RCC.APB1RSTR.i2c2rst_offset) & RCC.APB1RSTR.i2c2rst_mask - self.rawValue = preserve | shift - } - } - - static let i2c3rst_offset = UInt32(23) - static let i2c3rst_mask = UInt32(0b1) &<< i2c3rst_offset - var i2c3rst: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1RSTR.i2c3rst_mask)) >> RCC.APB1RSTR.i2c3rst_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1RSTR.i2c3rst_mask - let shift = (UInt32(newValue) << RCC.APB1RSTR.i2c3rst_offset) & RCC.APB1RSTR.i2c3rst_mask - self.rawValue = preserve | shift - } - } - - static let can1rst_offset = UInt32(25) - static let can1rst_mask = UInt32(0b1) &<< can1rst_offset - var can1rst: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1RSTR.can1rst_mask)) >> RCC.APB1RSTR.can1rst_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1RSTR.can1rst_mask - let shift = (UInt32(newValue) << RCC.APB1RSTR.can1rst_offset) & RCC.APB1RSTR.can1rst_mask - self.rawValue = preserve | shift - } - } - - static let can2rst_offset = UInt32(26) - static let can2rst_mask = UInt32(0b1) &<< can2rst_offset - var can2rst: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1RSTR.can2rst_mask)) >> RCC.APB1RSTR.can2rst_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1RSTR.can2rst_mask - let shift = (UInt32(newValue) << RCC.APB1RSTR.can2rst_offset) & RCC.APB1RSTR.can2rst_mask - self.rawValue = preserve | shift - } - } - - static let pwrrst_offset = UInt32(28) - static let pwrrst_mask = UInt32(0b1) &<< pwrrst_offset - var pwrrst: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1RSTR.pwrrst_mask)) >> RCC.APB1RSTR.pwrrst_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1RSTR.pwrrst_mask - let shift = (UInt32(newValue) << RCC.APB1RSTR.pwrrst_offset) & RCC.APB1RSTR.pwrrst_mask - self.rawValue = preserve | shift - } - } - - static let dacrst_offset = UInt32(29) - static let dacrst_mask = UInt32(0b1) &<< dacrst_offset - var dacrst: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1RSTR.dacrst_mask)) >> RCC.APB1RSTR.dacrst_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1RSTR.dacrst_mask - let shift = (UInt32(newValue) << RCC.APB1RSTR.dacrst_offset) & RCC.APB1RSTR.dacrst_mask - self.rawValue = preserve | shift - } - } - - static let uart7rst_offset = UInt32(30) - static let uart7rst_mask = UInt32(0b1) &<< uart7rst_offset - var uart7rst: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1RSTR.uart7rst_mask)) >> RCC.APB1RSTR.uart7rst_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1RSTR.uart7rst_mask - let shift = (UInt32(newValue) << RCC.APB1RSTR.uart7rst_offset) & RCC.APB1RSTR.uart7rst_mask - self.rawValue = preserve | shift - } - } - - static let uart8rst_offset = UInt32(31) - static let uart8rst_mask = UInt32(0b1) &<< uart8rst_offset - var uart8rst: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1RSTR.uart8rst_mask)) >> RCC.APB1RSTR.uart8rst_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1RSTR.uart8rst_mask - let shift = (UInt32(newValue) << RCC.APB1RSTR.uart8rst_offset) & RCC.APB1RSTR.uart8rst_mask - self.rawValue = preserve | shift - } - } - - static let spdifrxrst_offset = UInt32(16) - static let spdifrxrst_mask = UInt32(0b1) &<< spdifrxrst_offset - var spdifrxrst: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1RSTR.spdifrxrst_mask)) >> RCC.APB1RSTR.spdifrxrst_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1RSTR.spdifrxrst_mask - let shift = (UInt32(newValue) << RCC.APB1RSTR.spdifrxrst_offset) & RCC.APB1RSTR.spdifrxrst_mask - self.rawValue = preserve | shift - } - } - - static let cecrst_offset = UInt32(27) - static let cecrst_mask = UInt32(0b1) &<< cecrst_offset - var cecrst: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1RSTR.cecrst_mask)) >> RCC.APB1RSTR.cecrst_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1RSTR.cecrst_mask - let shift = (UInt32(newValue) << RCC.APB1RSTR.cecrst_offset) & RCC.APB1RSTR.cecrst_mask - self.rawValue = preserve | shift - } - } - - static let lptim1rst_offset = UInt32(9) - static let lptim1rst_mask = UInt32(0b1) &<< lptim1rst_offset - var lptim1rst: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1RSTR.lptim1rst_mask)) >> RCC.APB1RSTR.lptim1rst_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1RSTR.lptim1rst_mask - let shift = (UInt32(newValue) << RCC.APB1RSTR.lptim1rst_offset) & RCC.APB1RSTR.lptim1rst_mask - self.rawValue = preserve | shift - } - } - - static let i2c4rst_offset = UInt32(24) - static let i2c4rst_mask = UInt32(0b1) &<< i2c4rst_offset - var i2c4rst: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1RSTR.i2c4rst_mask)) >> RCC.APB1RSTR.i2c4rst_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1RSTR.i2c4rst_mask - let shift = (UInt32(newValue) << RCC.APB1RSTR.i2c4rst_offset) & RCC.APB1RSTR.i2c4rst_mask - self.rawValue = preserve | shift - } - } - - init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - struct APB2RSTR { - var rawValue: UInt32 - - static let tim1rst_offset = UInt32(0) - static let tim1rst_mask = UInt32(0b1) &<< tim1rst_offset - var tim1rst: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2RSTR.tim1rst_mask)) >> RCC.APB2RSTR.tim1rst_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2RSTR.tim1rst_mask - let shift = (UInt32(newValue) << RCC.APB2RSTR.tim1rst_offset) & RCC.APB2RSTR.tim1rst_mask - self.rawValue = preserve | shift - } - } - - static let tim8rst_offset = UInt32(1) - static let tim8rst_mask = UInt32(0b1) &<< tim8rst_offset - var tim8rst: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2RSTR.tim8rst_mask)) >> RCC.APB2RSTR.tim8rst_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2RSTR.tim8rst_mask - let shift = (UInt32(newValue) << RCC.APB2RSTR.tim8rst_offset) & RCC.APB2RSTR.tim8rst_mask - self.rawValue = preserve | shift - } - } - - static let usart1rst_offset = UInt32(4) - static let usart1rst_mask = UInt32(0b1) &<< usart1rst_offset - var usart1rst: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2RSTR.usart1rst_mask)) >> RCC.APB2RSTR.usart1rst_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2RSTR.usart1rst_mask - let shift = (UInt32(newValue) << RCC.APB2RSTR.usart1rst_offset) & RCC.APB2RSTR.usart1rst_mask - self.rawValue = preserve | shift - } - } - - static let usart6rst_offset = UInt32(5) - static let usart6rst_mask = UInt32(0b1) &<< usart6rst_offset - var usart6rst: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2RSTR.usart6rst_mask)) >> RCC.APB2RSTR.usart6rst_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2RSTR.usart6rst_mask - let shift = (UInt32(newValue) << RCC.APB2RSTR.usart6rst_offset) & RCC.APB2RSTR.usart6rst_mask - self.rawValue = preserve | shift - } - } - - static let adcrst_offset = UInt32(8) - static let adcrst_mask = UInt32(0b1) &<< adcrst_offset - var adcrst: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2RSTR.adcrst_mask)) >> RCC.APB2RSTR.adcrst_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2RSTR.adcrst_mask - let shift = (UInt32(newValue) << RCC.APB2RSTR.adcrst_offset) & RCC.APB2RSTR.adcrst_mask - self.rawValue = preserve | shift - } - } - - static let spi1rst_offset = UInt32(12) - static let spi1rst_mask = UInt32(0b1) &<< spi1rst_offset - var spi1rst: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2RSTR.spi1rst_mask)) >> RCC.APB2RSTR.spi1rst_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2RSTR.spi1rst_mask - let shift = (UInt32(newValue) << RCC.APB2RSTR.spi1rst_offset) & RCC.APB2RSTR.spi1rst_mask - self.rawValue = preserve | shift - } - } - - static let spi4rst_offset = UInt32(13) - static let spi4rst_mask = UInt32(0b1) &<< spi4rst_offset - var spi4rst: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2RSTR.spi4rst_mask)) >> RCC.APB2RSTR.spi4rst_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2RSTR.spi4rst_mask - let shift = (UInt32(newValue) << RCC.APB2RSTR.spi4rst_offset) & RCC.APB2RSTR.spi4rst_mask - self.rawValue = preserve | shift - } - } - - static let syscfgrst_offset = UInt32(14) - static let syscfgrst_mask = UInt32(0b1) &<< syscfgrst_offset - var syscfgrst: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2RSTR.syscfgrst_mask)) >> RCC.APB2RSTR.syscfgrst_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2RSTR.syscfgrst_mask - let shift = (UInt32(newValue) << RCC.APB2RSTR.syscfgrst_offset) & RCC.APB2RSTR.syscfgrst_mask - self.rawValue = preserve | shift - } - } - - static let tim9rst_offset = UInt32(16) - static let tim9rst_mask = UInt32(0b1) &<< tim9rst_offset - var tim9rst: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2RSTR.tim9rst_mask)) >> RCC.APB2RSTR.tim9rst_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2RSTR.tim9rst_mask - let shift = (UInt32(newValue) << RCC.APB2RSTR.tim9rst_offset) & RCC.APB2RSTR.tim9rst_mask - self.rawValue = preserve | shift - } - } - - static let tim10rst_offset = UInt32(17) - static let tim10rst_mask = UInt32(0b1) &<< tim10rst_offset - var tim10rst: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2RSTR.tim10rst_mask)) >> RCC.APB2RSTR.tim10rst_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2RSTR.tim10rst_mask - let shift = (UInt32(newValue) << RCC.APB2RSTR.tim10rst_offset) & RCC.APB2RSTR.tim10rst_mask - self.rawValue = preserve | shift - } - } - - static let tim11rst_offset = UInt32(18) - static let tim11rst_mask = UInt32(0b1) &<< tim11rst_offset - var tim11rst: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2RSTR.tim11rst_mask)) >> RCC.APB2RSTR.tim11rst_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2RSTR.tim11rst_mask - let shift = (UInt32(newValue) << RCC.APB2RSTR.tim11rst_offset) & RCC.APB2RSTR.tim11rst_mask - self.rawValue = preserve | shift - } - } - - static let spi5rst_offset = UInt32(20) - static let spi5rst_mask = UInt32(0b1) &<< spi5rst_offset - var spi5rst: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2RSTR.spi5rst_mask)) >> RCC.APB2RSTR.spi5rst_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2RSTR.spi5rst_mask - let shift = (UInt32(newValue) << RCC.APB2RSTR.spi5rst_offset) & RCC.APB2RSTR.spi5rst_mask - self.rawValue = preserve | shift - } - } - - static let spi6rst_offset = UInt32(21) - static let spi6rst_mask = UInt32(0b1) &<< spi6rst_offset - var spi6rst: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2RSTR.spi6rst_mask)) >> RCC.APB2RSTR.spi6rst_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2RSTR.spi6rst_mask - let shift = (UInt32(newValue) << RCC.APB2RSTR.spi6rst_offset) & RCC.APB2RSTR.spi6rst_mask - self.rawValue = preserve | shift - } - } - - static let sai1rst_offset = UInt32(22) - static let sai1rst_mask = UInt32(0b1) &<< sai1rst_offset - var sai1rst: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2RSTR.sai1rst_mask)) >> RCC.APB2RSTR.sai1rst_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2RSTR.sai1rst_mask - let shift = (UInt32(newValue) << RCC.APB2RSTR.sai1rst_offset) & RCC.APB2RSTR.sai1rst_mask - self.rawValue = preserve | shift - } - } - - static let ltdcrst_offset = UInt32(26) - static let ltdcrst_mask = UInt32(0b1) &<< ltdcrst_offset - var ltdcrst: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2RSTR.ltdcrst_mask)) >> RCC.APB2RSTR.ltdcrst_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2RSTR.ltdcrst_mask - let shift = (UInt32(newValue) << RCC.APB2RSTR.ltdcrst_offset) & RCC.APB2RSTR.ltdcrst_mask - self.rawValue = preserve | shift - } - } - - static let sai2rst_offset = UInt32(23) - static let sai2rst_mask = UInt32(0b1) &<< sai2rst_offset - var sai2rst: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2RSTR.sai2rst_mask)) >> RCC.APB2RSTR.sai2rst_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2RSTR.sai2rst_mask - let shift = (UInt32(newValue) << RCC.APB2RSTR.sai2rst_offset) & RCC.APB2RSTR.sai2rst_mask - self.rawValue = preserve | shift - } - } - - static let sdmmc1rst_offset = UInt32(11) - static let sdmmc1rst_mask = UInt32(0b1) &<< sdmmc1rst_offset - var sdmmc1rst: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2RSTR.sdmmc1rst_mask)) >> RCC.APB2RSTR.sdmmc1rst_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2RSTR.sdmmc1rst_mask - let shift = (UInt32(newValue) << RCC.APB2RSTR.sdmmc1rst_offset) & RCC.APB2RSTR.sdmmc1rst_mask - self.rawValue = preserve | shift - } - } - - init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - struct AHB1ENR { - var rawValue: UInt32 - - static let otghsulpien_offset = UInt32(30) - static let otghsulpien_mask = UInt32(0b1) &<< otghsulpien_offset - var otghsulpien: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1ENR.otghsulpien_mask)) >> RCC.AHB1ENR.otghsulpien_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1ENR.otghsulpien_mask - let shift = (UInt32(newValue) << RCC.AHB1ENR.otghsulpien_offset) & RCC.AHB1ENR.otghsulpien_mask - self.rawValue = preserve | shift - } - } - - static let otghsen_offset = UInt32(29) - static let otghsen_mask = UInt32(0b1) &<< otghsen_offset - var otghsen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1ENR.otghsen_mask)) >> RCC.AHB1ENR.otghsen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1ENR.otghsen_mask - let shift = (UInt32(newValue) << RCC.AHB1ENR.otghsen_offset) & RCC.AHB1ENR.otghsen_mask - self.rawValue = preserve | shift - } - } - - static let ethmacptpen_offset = UInt32(28) - static let ethmacptpen_mask = UInt32(0b1) &<< ethmacptpen_offset - var ethmacptpen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1ENR.ethmacptpen_mask)) >> RCC.AHB1ENR.ethmacptpen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1ENR.ethmacptpen_mask - let shift = (UInt32(newValue) << RCC.AHB1ENR.ethmacptpen_offset) & RCC.AHB1ENR.ethmacptpen_mask - self.rawValue = preserve | shift - } - } - - static let ethmacrxen_offset = UInt32(27) - static let ethmacrxen_mask = UInt32(0b1) &<< ethmacrxen_offset - var ethmacrxen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1ENR.ethmacrxen_mask)) >> RCC.AHB1ENR.ethmacrxen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1ENR.ethmacrxen_mask - let shift = (UInt32(newValue) << RCC.AHB1ENR.ethmacrxen_offset) & RCC.AHB1ENR.ethmacrxen_mask - self.rawValue = preserve | shift - } - } - - static let ethmactxen_offset = UInt32(26) - static let ethmactxen_mask = UInt32(0b1) &<< ethmactxen_offset - var ethmactxen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1ENR.ethmactxen_mask)) >> RCC.AHB1ENR.ethmactxen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1ENR.ethmactxen_mask - let shift = (UInt32(newValue) << RCC.AHB1ENR.ethmactxen_offset) & RCC.AHB1ENR.ethmactxen_mask - self.rawValue = preserve | shift - } - } - - static let ethmacen_offset = UInt32(25) - static let ethmacen_mask = UInt32(0b1) &<< ethmacen_offset - var ethmacen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1ENR.ethmacen_mask)) >> RCC.AHB1ENR.ethmacen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1ENR.ethmacen_mask - let shift = (UInt32(newValue) << RCC.AHB1ENR.ethmacen_offset) & RCC.AHB1ENR.ethmacen_mask - self.rawValue = preserve | shift - } - } - - static let dma2den_offset = UInt32(23) - static let dma2den_mask = UInt32(0b1) &<< dma2den_offset - var dma2den: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1ENR.dma2den_mask)) >> RCC.AHB1ENR.dma2den_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1ENR.dma2den_mask - let shift = (UInt32(newValue) << RCC.AHB1ENR.dma2den_offset) & RCC.AHB1ENR.dma2den_mask - self.rawValue = preserve | shift - } - } - - static let dma2en_offset = UInt32(22) - static let dma2en_mask = UInt32(0b1) &<< dma2en_offset - var dma2en: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1ENR.dma2en_mask)) >> RCC.AHB1ENR.dma2en_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1ENR.dma2en_mask - let shift = (UInt32(newValue) << RCC.AHB1ENR.dma2en_offset) & RCC.AHB1ENR.dma2en_mask - self.rawValue = preserve | shift - } - } - - static let dma1en_offset = UInt32(21) - static let dma1en_mask = UInt32(0b1) &<< dma1en_offset - var dma1en: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1ENR.dma1en_mask)) >> RCC.AHB1ENR.dma1en_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1ENR.dma1en_mask - let shift = (UInt32(newValue) << RCC.AHB1ENR.dma1en_offset) & RCC.AHB1ENR.dma1en_mask - self.rawValue = preserve | shift - } - } - - static let ccmdataramen_offset = UInt32(20) - static let ccmdataramen_mask = UInt32(0b1) &<< ccmdataramen_offset - var ccmdataramen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1ENR.ccmdataramen_mask)) >> RCC.AHB1ENR.ccmdataramen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1ENR.ccmdataramen_mask - let shift = (UInt32(newValue) << RCC.AHB1ENR.ccmdataramen_offset) & RCC.AHB1ENR.ccmdataramen_mask - self.rawValue = preserve | shift - } - } - - static let bkpsramen_offset = UInt32(18) - static let bkpsramen_mask = UInt32(0b1) &<< bkpsramen_offset - var bkpsramen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1ENR.bkpsramen_mask)) >> RCC.AHB1ENR.bkpsramen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1ENR.bkpsramen_mask - let shift = (UInt32(newValue) << RCC.AHB1ENR.bkpsramen_offset) & RCC.AHB1ENR.bkpsramen_mask - self.rawValue = preserve | shift - } - } - - static let crcen_offset = UInt32(12) - static let crcen_mask = UInt32(0b1) &<< crcen_offset - var crcen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1ENR.crcen_mask)) >> RCC.AHB1ENR.crcen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1ENR.crcen_mask - let shift = (UInt32(newValue) << RCC.AHB1ENR.crcen_offset) & RCC.AHB1ENR.crcen_mask - self.rawValue = preserve | shift - } - } - - static let gpioken_offset = UInt32(10) - static let gpioken_mask = UInt32(0b1) &<< gpioken_offset - var gpioken: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1ENR.gpioken_mask)) >> RCC.AHB1ENR.gpioken_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1ENR.gpioken_mask - let shift = (UInt32(newValue) << RCC.AHB1ENR.gpioken_offset) & RCC.AHB1ENR.gpioken_mask - self.rawValue = preserve | shift - } - } - - static let gpiojen_offset = UInt32(9) - static let gpiojen_mask = UInt32(0b1) &<< gpiojen_offset - var gpiojen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1ENR.gpiojen_mask)) >> RCC.AHB1ENR.gpiojen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1ENR.gpiojen_mask - let shift = (UInt32(newValue) << RCC.AHB1ENR.gpiojen_offset) & RCC.AHB1ENR.gpiojen_mask - self.rawValue = preserve | shift - } - } - - static let gpioien_offset = UInt32(8) - static let gpioien_mask = UInt32(0b1) &<< gpioien_offset - var gpioien: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1ENR.gpioien_mask)) >> RCC.AHB1ENR.gpioien_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1ENR.gpioien_mask - let shift = (UInt32(newValue) << RCC.AHB1ENR.gpioien_offset) & RCC.AHB1ENR.gpioien_mask - self.rawValue = preserve | shift - } - } - - static let gpiohen_offset = UInt32(7) - static let gpiohen_mask = UInt32(0b1) &<< gpiohen_offset - var gpiohen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1ENR.gpiohen_mask)) >> RCC.AHB1ENR.gpiohen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1ENR.gpiohen_mask - let shift = (UInt32(newValue) << RCC.AHB1ENR.gpiohen_offset) & RCC.AHB1ENR.gpiohen_mask - self.rawValue = preserve | shift - } - } - - static let gpiogen_offset = UInt32(6) - static let gpiogen_mask = UInt32(0b1) &<< gpiogen_offset - var gpiogen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1ENR.gpiogen_mask)) >> RCC.AHB1ENR.gpiogen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1ENR.gpiogen_mask - let shift = (UInt32(newValue) << RCC.AHB1ENR.gpiogen_offset) & RCC.AHB1ENR.gpiogen_mask - self.rawValue = preserve | shift - } - } - - static let gpiofen_offset = UInt32(5) - static let gpiofen_mask = UInt32(0b1) &<< gpiofen_offset - var gpiofen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1ENR.gpiofen_mask)) >> RCC.AHB1ENR.gpiofen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1ENR.gpiofen_mask - let shift = (UInt32(newValue) << RCC.AHB1ENR.gpiofen_offset) & RCC.AHB1ENR.gpiofen_mask - self.rawValue = preserve | shift - } - } - - static let gpioeen_offset = UInt32(4) - static let gpioeen_mask = UInt32(0b1) &<< gpioeen_offset - var gpioeen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1ENR.gpioeen_mask)) >> RCC.AHB1ENR.gpioeen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1ENR.gpioeen_mask - let shift = (UInt32(newValue) << RCC.AHB1ENR.gpioeen_offset) & RCC.AHB1ENR.gpioeen_mask - self.rawValue = preserve | shift - } - } - - static let gpioden_offset = UInt32(3) - static let gpioden_mask = UInt32(0b1) &<< gpioden_offset - var gpioden: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1ENR.gpioden_mask)) >> RCC.AHB1ENR.gpioden_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1ENR.gpioden_mask - let shift = (UInt32(newValue) << RCC.AHB1ENR.gpioden_offset) & RCC.AHB1ENR.gpioden_mask - self.rawValue = preserve | shift - } - } - - static let gpiocen_offset = UInt32(2) - static let gpiocen_mask = UInt32(0b1) &<< gpiocen_offset - var gpiocen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1ENR.gpiocen_mask)) >> RCC.AHB1ENR.gpiocen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1ENR.gpiocen_mask - let shift = (UInt32(newValue) << RCC.AHB1ENR.gpiocen_offset) & RCC.AHB1ENR.gpiocen_mask - self.rawValue = preserve | shift - } - } - - static let gpioben_offset = UInt32(1) - static let gpioben_mask = UInt32(0b1) &<< gpioben_offset - var gpioben: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1ENR.gpioben_mask)) >> RCC.AHB1ENR.gpioben_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1ENR.gpioben_mask - let shift = (UInt32(newValue) << RCC.AHB1ENR.gpioben_offset) & RCC.AHB1ENR.gpioben_mask - self.rawValue = preserve | shift - } - } - - static let gpioaen_offset = UInt32(0) - static let gpioaen_mask = UInt32(0b1) &<< gpioaen_offset - var gpioaen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1ENR.gpioaen_mask)) >> RCC.AHB1ENR.gpioaen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1ENR.gpioaen_mask - let shift = (UInt32(newValue) << RCC.AHB1ENR.gpioaen_offset) & RCC.AHB1ENR.gpioaen_mask - self.rawValue = preserve | shift - } - } - - init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - struct AHB2ENR { - var rawValue: UInt32 - - static let otgfsen_offset = UInt32(7) - static let otgfsen_mask = UInt32(0b1) &<< otgfsen_offset - var otgfsen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB2ENR.otgfsen_mask)) >> RCC.AHB2ENR.otgfsen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB2ENR.otgfsen_mask - let shift = (UInt32(newValue) << RCC.AHB2ENR.otgfsen_offset) & RCC.AHB2ENR.otgfsen_mask - self.rawValue = preserve | shift - } - } - - static let rngen_offset = UInt32(6) - static let rngen_mask = UInt32(0b1) &<< rngen_offset - var rngen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB2ENR.rngen_mask)) >> RCC.AHB2ENR.rngen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB2ENR.rngen_mask - let shift = (UInt32(newValue) << RCC.AHB2ENR.rngen_offset) & RCC.AHB2ENR.rngen_mask - self.rawValue = preserve | shift - } - } - - static let hashen_offset = UInt32(5) - static let hashen_mask = UInt32(0b1) &<< hashen_offset - var hashen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB2ENR.hashen_mask)) >> RCC.AHB2ENR.hashen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB2ENR.hashen_mask - let shift = (UInt32(newValue) << RCC.AHB2ENR.hashen_offset) & RCC.AHB2ENR.hashen_mask - self.rawValue = preserve | shift - } - } - - static let crypen_offset = UInt32(4) - static let crypen_mask = UInt32(0b1) &<< crypen_offset - var crypen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB2ENR.crypen_mask)) >> RCC.AHB2ENR.crypen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB2ENR.crypen_mask - let shift = (UInt32(newValue) << RCC.AHB2ENR.crypen_offset) & RCC.AHB2ENR.crypen_mask - self.rawValue = preserve | shift - } - } - - static let dcmien_offset = UInt32(0) - static let dcmien_mask = UInt32(0b1) &<< dcmien_offset - var dcmien: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB2ENR.dcmien_mask)) >> RCC.AHB2ENR.dcmien_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB2ENR.dcmien_mask - let shift = (UInt32(newValue) << RCC.AHB2ENR.dcmien_offset) & RCC.AHB2ENR.dcmien_mask - self.rawValue = preserve | shift - } - } - - init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - struct AHB3ENR { - var rawValue: UInt32 - - static let fmcen_offset = UInt32(0) - static let fmcen_mask = UInt32(0b1) &<< fmcen_offset - var fmcen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB3ENR.fmcen_mask)) >> RCC.AHB3ENR.fmcen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB3ENR.fmcen_mask - let shift = (UInt32(newValue) << RCC.AHB3ENR.fmcen_offset) & RCC.AHB3ENR.fmcen_mask - self.rawValue = preserve | shift - } - } - - static let qspien_offset = UInt32(1) - static let qspien_mask = UInt32(0b1) &<< qspien_offset - var qspien: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB3ENR.qspien_mask)) >> RCC.AHB3ENR.qspien_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB3ENR.qspien_mask - let shift = (UInt32(newValue) << RCC.AHB3ENR.qspien_offset) & RCC.AHB3ENR.qspien_mask - self.rawValue = preserve | shift - } - } - - init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - struct APB1ENR { - var rawValue: UInt32 - - static let tim2en_offset = UInt32(0) - static let tim2en_mask = UInt32(0b1) &<< tim2en_offset - var tim2en: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1ENR.tim2en_mask)) >> RCC.APB1ENR.tim2en_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1ENR.tim2en_mask - let shift = (UInt32(newValue) << RCC.APB1ENR.tim2en_offset) & RCC.APB1ENR.tim2en_mask - self.rawValue = preserve | shift - } - } - - static let tim3en_offset = UInt32(1) - static let tim3en_mask = UInt32(0b1) &<< tim3en_offset - var tim3en: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1ENR.tim3en_mask)) >> RCC.APB1ENR.tim3en_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1ENR.tim3en_mask - let shift = (UInt32(newValue) << RCC.APB1ENR.tim3en_offset) & RCC.APB1ENR.tim3en_mask - self.rawValue = preserve | shift - } - } - - static let tim4en_offset = UInt32(2) - static let tim4en_mask = UInt32(0b1) &<< tim4en_offset - var tim4en: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1ENR.tim4en_mask)) >> RCC.APB1ENR.tim4en_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1ENR.tim4en_mask - let shift = (UInt32(newValue) << RCC.APB1ENR.tim4en_offset) & RCC.APB1ENR.tim4en_mask - self.rawValue = preserve | shift - } - } - - static let tim5en_offset = UInt32(3) - static let tim5en_mask = UInt32(0b1) &<< tim5en_offset - var tim5en: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1ENR.tim5en_mask)) >> RCC.APB1ENR.tim5en_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1ENR.tim5en_mask - let shift = (UInt32(newValue) << RCC.APB1ENR.tim5en_offset) & RCC.APB1ENR.tim5en_mask - self.rawValue = preserve | shift - } - } - - static let tim6en_offset = UInt32(4) - static let tim6en_mask = UInt32(0b1) &<< tim6en_offset - var tim6en: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1ENR.tim6en_mask)) >> RCC.APB1ENR.tim6en_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1ENR.tim6en_mask - let shift = (UInt32(newValue) << RCC.APB1ENR.tim6en_offset) & RCC.APB1ENR.tim6en_mask - self.rawValue = preserve | shift - } - } - - static let tim7en_offset = UInt32(5) - static let tim7en_mask = UInt32(0b1) &<< tim7en_offset - var tim7en: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1ENR.tim7en_mask)) >> RCC.APB1ENR.tim7en_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1ENR.tim7en_mask - let shift = (UInt32(newValue) << RCC.APB1ENR.tim7en_offset) & RCC.APB1ENR.tim7en_mask - self.rawValue = preserve | shift - } - } - - static let tim12en_offset = UInt32(6) - static let tim12en_mask = UInt32(0b1) &<< tim12en_offset - var tim12en: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1ENR.tim12en_mask)) >> RCC.APB1ENR.tim12en_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1ENR.tim12en_mask - let shift = (UInt32(newValue) << RCC.APB1ENR.tim12en_offset) & RCC.APB1ENR.tim12en_mask - self.rawValue = preserve | shift - } - } - - static let tim13en_offset = UInt32(7) - static let tim13en_mask = UInt32(0b1) &<< tim13en_offset - var tim13en: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1ENR.tim13en_mask)) >> RCC.APB1ENR.tim13en_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1ENR.tim13en_mask - let shift = (UInt32(newValue) << RCC.APB1ENR.tim13en_offset) & RCC.APB1ENR.tim13en_mask - self.rawValue = preserve | shift - } - } - - static let tim14en_offset = UInt32(8) - static let tim14en_mask = UInt32(0b1) &<< tim14en_offset - var tim14en: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1ENR.tim14en_mask)) >> RCC.APB1ENR.tim14en_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1ENR.tim14en_mask - let shift = (UInt32(newValue) << RCC.APB1ENR.tim14en_offset) & RCC.APB1ENR.tim14en_mask - self.rawValue = preserve | shift - } - } - - static let wwdgen_offset = UInt32(11) - static let wwdgen_mask = UInt32(0b1) &<< wwdgen_offset - var wwdgen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1ENR.wwdgen_mask)) >> RCC.APB1ENR.wwdgen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1ENR.wwdgen_mask - let shift = (UInt32(newValue) << RCC.APB1ENR.wwdgen_offset) & RCC.APB1ENR.wwdgen_mask - self.rawValue = preserve | shift - } - } - - static let spi2en_offset = UInt32(14) - static let spi2en_mask = UInt32(0b1) &<< spi2en_offset - var spi2en: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1ENR.spi2en_mask)) >> RCC.APB1ENR.spi2en_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1ENR.spi2en_mask - let shift = (UInt32(newValue) << RCC.APB1ENR.spi2en_offset) & RCC.APB1ENR.spi2en_mask - self.rawValue = preserve | shift - } - } - - static let spi3en_offset = UInt32(15) - static let spi3en_mask = UInt32(0b1) &<< spi3en_offset - var spi3en: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1ENR.spi3en_mask)) >> RCC.APB1ENR.spi3en_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1ENR.spi3en_mask - let shift = (UInt32(newValue) << RCC.APB1ENR.spi3en_offset) & RCC.APB1ENR.spi3en_mask - self.rawValue = preserve | shift - } - } - - static let usart2en_offset = UInt32(17) - static let usart2en_mask = UInt32(0b1) &<< usart2en_offset - var usart2en: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1ENR.usart2en_mask)) >> RCC.APB1ENR.usart2en_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1ENR.usart2en_mask - let shift = (UInt32(newValue) << RCC.APB1ENR.usart2en_offset) & RCC.APB1ENR.usart2en_mask - self.rawValue = preserve | shift - } - } - - static let usart3en_offset = UInt32(18) - static let usart3en_mask = UInt32(0b1) &<< usart3en_offset - var usart3en: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1ENR.usart3en_mask)) >> RCC.APB1ENR.usart3en_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1ENR.usart3en_mask - let shift = (UInt32(newValue) << RCC.APB1ENR.usart3en_offset) & RCC.APB1ENR.usart3en_mask - self.rawValue = preserve | shift - } - } - - static let uart4en_offset = UInt32(19) - static let uart4en_mask = UInt32(0b1) &<< uart4en_offset - var uart4en: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1ENR.uart4en_mask)) >> RCC.APB1ENR.uart4en_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1ENR.uart4en_mask - let shift = (UInt32(newValue) << RCC.APB1ENR.uart4en_offset) & RCC.APB1ENR.uart4en_mask - self.rawValue = preserve | shift - } - } - - static let uart5en_offset = UInt32(20) - static let uart5en_mask = UInt32(0b1) &<< uart5en_offset - var uart5en: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1ENR.uart5en_mask)) >> RCC.APB1ENR.uart5en_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1ENR.uart5en_mask - let shift = (UInt32(newValue) << RCC.APB1ENR.uart5en_offset) & RCC.APB1ENR.uart5en_mask - self.rawValue = preserve | shift - } - } - - static let i2c1en_offset = UInt32(21) - static let i2c1en_mask = UInt32(0b1) &<< i2c1en_offset - var i2c1en: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1ENR.i2c1en_mask)) >> RCC.APB1ENR.i2c1en_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1ENR.i2c1en_mask - let shift = (UInt32(newValue) << RCC.APB1ENR.i2c1en_offset) & RCC.APB1ENR.i2c1en_mask - self.rawValue = preserve | shift - } - } - - static let i2c2en_offset = UInt32(22) - static let i2c2en_mask = UInt32(0b1) &<< i2c2en_offset - var i2c2en: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1ENR.i2c2en_mask)) >> RCC.APB1ENR.i2c2en_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1ENR.i2c2en_mask - let shift = (UInt32(newValue) << RCC.APB1ENR.i2c2en_offset) & RCC.APB1ENR.i2c2en_mask - self.rawValue = preserve | shift - } - } - - static let i2c3en_offset = UInt32(23) - static let i2c3en_mask = UInt32(0b1) &<< i2c3en_offset - var i2c3en: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1ENR.i2c3en_mask)) >> RCC.APB1ENR.i2c3en_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1ENR.i2c3en_mask - let shift = (UInt32(newValue) << RCC.APB1ENR.i2c3en_offset) & RCC.APB1ENR.i2c3en_mask - self.rawValue = preserve | shift - } - } - - static let can1en_offset = UInt32(25) - static let can1en_mask = UInt32(0b1) &<< can1en_offset - var can1en: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1ENR.can1en_mask)) >> RCC.APB1ENR.can1en_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1ENR.can1en_mask - let shift = (UInt32(newValue) << RCC.APB1ENR.can1en_offset) & RCC.APB1ENR.can1en_mask - self.rawValue = preserve | shift - } - } - - static let can2en_offset = UInt32(26) - static let can2en_mask = UInt32(0b1) &<< can2en_offset - var can2en: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1ENR.can2en_mask)) >> RCC.APB1ENR.can2en_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1ENR.can2en_mask - let shift = (UInt32(newValue) << RCC.APB1ENR.can2en_offset) & RCC.APB1ENR.can2en_mask - self.rawValue = preserve | shift - } - } - - static let pwren_offset = UInt32(28) - static let pwren_mask = UInt32(0b1) &<< pwren_offset - var pwren: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1ENR.pwren_mask)) >> RCC.APB1ENR.pwren_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1ENR.pwren_mask - let shift = (UInt32(newValue) << RCC.APB1ENR.pwren_offset) & RCC.APB1ENR.pwren_mask - self.rawValue = preserve | shift - } - } - - static let dacen_offset = UInt32(29) - static let dacen_mask = UInt32(0b1) &<< dacen_offset - var dacen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1ENR.dacen_mask)) >> RCC.APB1ENR.dacen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1ENR.dacen_mask - let shift = (UInt32(newValue) << RCC.APB1ENR.dacen_offset) & RCC.APB1ENR.dacen_mask - self.rawValue = preserve | shift - } - } - - static let uart7enr_offset = UInt32(30) - static let uart7enr_mask = UInt32(0b1) &<< uart7enr_offset - var uart7enr: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1ENR.uart7enr_mask)) >> RCC.APB1ENR.uart7enr_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1ENR.uart7enr_mask - let shift = (UInt32(newValue) << RCC.APB1ENR.uart7enr_offset) & RCC.APB1ENR.uart7enr_mask - self.rawValue = preserve | shift - } - } - - static let uart8enr_offset = UInt32(31) - static let uart8enr_mask = UInt32(0b1) &<< uart8enr_offset - var uart8enr: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1ENR.uart8enr_mask)) >> RCC.APB1ENR.uart8enr_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1ENR.uart8enr_mask - let shift = (UInt32(newValue) << RCC.APB1ENR.uart8enr_offset) & RCC.APB1ENR.uart8enr_mask - self.rawValue = preserve | shift - } - } - - static let spdifrxen_offset = UInt32(16) - static let spdifrxen_mask = UInt32(0b1) &<< spdifrxen_offset - var spdifrxen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1ENR.spdifrxen_mask)) >> RCC.APB1ENR.spdifrxen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1ENR.spdifrxen_mask - let shift = (UInt32(newValue) << RCC.APB1ENR.spdifrxen_offset) & RCC.APB1ENR.spdifrxen_mask - self.rawValue = preserve | shift - } - } - - static let cecen_offset = UInt32(27) - static let cecen_mask = UInt32(0b1) &<< cecen_offset - var cecen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1ENR.cecen_mask)) >> RCC.APB1ENR.cecen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1ENR.cecen_mask - let shift = (UInt32(newValue) << RCC.APB1ENR.cecen_offset) & RCC.APB1ENR.cecen_mask - self.rawValue = preserve | shift - } - } - - static let lptmi1en_offset = UInt32(9) - static let lptmi1en_mask = UInt32(0b1) &<< lptmi1en_offset - var lptmi1en: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1ENR.lptmi1en_mask)) >> RCC.APB1ENR.lptmi1en_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1ENR.lptmi1en_mask - let shift = (UInt32(newValue) << RCC.APB1ENR.lptmi1en_offset) & RCC.APB1ENR.lptmi1en_mask - self.rawValue = preserve | shift - } - } - - static let i2c4en_offset = UInt32(24) - static let i2c4en_mask = UInt32(0b1) &<< i2c4en_offset - var i2c4en: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1ENR.i2c4en_mask)) >> RCC.APB1ENR.i2c4en_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1ENR.i2c4en_mask - let shift = (UInt32(newValue) << RCC.APB1ENR.i2c4en_offset) & RCC.APB1ENR.i2c4en_mask - self.rawValue = preserve | shift - } - } - - init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - struct APB2ENR { - var rawValue: UInt32 - - static let tim1en_offset = UInt32(0) - static let tim1en_mask = UInt32(0b1) &<< tim1en_offset - var tim1en: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2ENR.tim1en_mask)) >> RCC.APB2ENR.tim1en_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2ENR.tim1en_mask - let shift = (UInt32(newValue) << RCC.APB2ENR.tim1en_offset) & RCC.APB2ENR.tim1en_mask - self.rawValue = preserve | shift - } - } - - static let tim8en_offset = UInt32(1) - static let tim8en_mask = UInt32(0b1) &<< tim8en_offset - var tim8en: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2ENR.tim8en_mask)) >> RCC.APB2ENR.tim8en_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2ENR.tim8en_mask - let shift = (UInt32(newValue) << RCC.APB2ENR.tim8en_offset) & RCC.APB2ENR.tim8en_mask - self.rawValue = preserve | shift - } - } - - static let usart1en_offset = UInt32(4) - static let usart1en_mask = UInt32(0b1) &<< usart1en_offset - var usart1en: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2ENR.usart1en_mask)) >> RCC.APB2ENR.usart1en_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2ENR.usart1en_mask - let shift = (UInt32(newValue) << RCC.APB2ENR.usart1en_offset) & RCC.APB2ENR.usart1en_mask - self.rawValue = preserve | shift - } - } - - static let usart6en_offset = UInt32(5) - static let usart6en_mask = UInt32(0b1) &<< usart6en_offset - var usart6en: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2ENR.usart6en_mask)) >> RCC.APB2ENR.usart6en_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2ENR.usart6en_mask - let shift = (UInt32(newValue) << RCC.APB2ENR.usart6en_offset) & RCC.APB2ENR.usart6en_mask - self.rawValue = preserve | shift - } - } - - static let adc1en_offset = UInt32(8) - static let adc1en_mask = UInt32(0b1) &<< adc1en_offset - var adc1en: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2ENR.adc1en_mask)) >> RCC.APB2ENR.adc1en_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2ENR.adc1en_mask - let shift = (UInt32(newValue) << RCC.APB2ENR.adc1en_offset) & RCC.APB2ENR.adc1en_mask - self.rawValue = preserve | shift - } - } - - static let adc2en_offset = UInt32(9) - static let adc2en_mask = UInt32(0b1) &<< adc2en_offset - var adc2en: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2ENR.adc2en_mask)) >> RCC.APB2ENR.adc2en_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2ENR.adc2en_mask - let shift = (UInt32(newValue) << RCC.APB2ENR.adc2en_offset) & RCC.APB2ENR.adc2en_mask - self.rawValue = preserve | shift - } - } - - static let adc3en_offset = UInt32(10) - static let adc3en_mask = UInt32(0b1) &<< adc3en_offset - var adc3en: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2ENR.adc3en_mask)) >> RCC.APB2ENR.adc3en_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2ENR.adc3en_mask - let shift = (UInt32(newValue) << RCC.APB2ENR.adc3en_offset) & RCC.APB2ENR.adc3en_mask - self.rawValue = preserve | shift - } - } - - static let spi1en_offset = UInt32(12) - static let spi1en_mask = UInt32(0b1) &<< spi1en_offset - var spi1en: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2ENR.spi1en_mask)) >> RCC.APB2ENR.spi1en_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2ENR.spi1en_mask - let shift = (UInt32(newValue) << RCC.APB2ENR.spi1en_offset) & RCC.APB2ENR.spi1en_mask - self.rawValue = preserve | shift - } - } - - static let spi4enr_offset = UInt32(13) - static let spi4enr_mask = UInt32(0b1) &<< spi4enr_offset - var spi4enr: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2ENR.spi4enr_mask)) >> RCC.APB2ENR.spi4enr_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2ENR.spi4enr_mask - let shift = (UInt32(newValue) << RCC.APB2ENR.spi4enr_offset) & RCC.APB2ENR.spi4enr_mask - self.rawValue = preserve | shift - } - } - - static let syscfgen_offset = UInt32(14) - static let syscfgen_mask = UInt32(0b1) &<< syscfgen_offset - var syscfgen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2ENR.syscfgen_mask)) >> RCC.APB2ENR.syscfgen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2ENR.syscfgen_mask - let shift = (UInt32(newValue) << RCC.APB2ENR.syscfgen_offset) & RCC.APB2ENR.syscfgen_mask - self.rawValue = preserve | shift - } - } - - static let tim9en_offset = UInt32(16) - static let tim9en_mask = UInt32(0b1) &<< tim9en_offset - var tim9en: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2ENR.tim9en_mask)) >> RCC.APB2ENR.tim9en_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2ENR.tim9en_mask - let shift = (UInt32(newValue) << RCC.APB2ENR.tim9en_offset) & RCC.APB2ENR.tim9en_mask - self.rawValue = preserve | shift - } - } - - static let tim10en_offset = UInt32(17) - static let tim10en_mask = UInt32(0b1) &<< tim10en_offset - var tim10en: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2ENR.tim10en_mask)) >> RCC.APB2ENR.tim10en_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2ENR.tim10en_mask - let shift = (UInt32(newValue) << RCC.APB2ENR.tim10en_offset) & RCC.APB2ENR.tim10en_mask - self.rawValue = preserve | shift - } - } - - static let tim11en_offset = UInt32(18) - static let tim11en_mask = UInt32(0b1) &<< tim11en_offset - var tim11en: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2ENR.tim11en_mask)) >> RCC.APB2ENR.tim11en_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2ENR.tim11en_mask - let shift = (UInt32(newValue) << RCC.APB2ENR.tim11en_offset) & RCC.APB2ENR.tim11en_mask - self.rawValue = preserve | shift - } - } - - static let spi5enr_offset = UInt32(20) - static let spi5enr_mask = UInt32(0b1) &<< spi5enr_offset - var spi5enr: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2ENR.spi5enr_mask)) >> RCC.APB2ENR.spi5enr_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2ENR.spi5enr_mask - let shift = (UInt32(newValue) << RCC.APB2ENR.spi5enr_offset) & RCC.APB2ENR.spi5enr_mask - self.rawValue = preserve | shift - } - } - - static let spi6enr_offset = UInt32(21) - static let spi6enr_mask = UInt32(0b1) &<< spi6enr_offset - var spi6enr: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2ENR.spi6enr_mask)) >> RCC.APB2ENR.spi6enr_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2ENR.spi6enr_mask - let shift = (UInt32(newValue) << RCC.APB2ENR.spi6enr_offset) & RCC.APB2ENR.spi6enr_mask - self.rawValue = preserve | shift - } - } - - static let sai1en_offset = UInt32(22) - static let sai1en_mask = UInt32(0b1) &<< sai1en_offset - var sai1en: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2ENR.sai1en_mask)) >> RCC.APB2ENR.sai1en_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2ENR.sai1en_mask - let shift = (UInt32(newValue) << RCC.APB2ENR.sai1en_offset) & RCC.APB2ENR.sai1en_mask - self.rawValue = preserve | shift - } - } - - static let ltdcen_offset = UInt32(26) - static let ltdcen_mask = UInt32(0b1) &<< ltdcen_offset - var ltdcen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2ENR.ltdcen_mask)) >> RCC.APB2ENR.ltdcen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2ENR.ltdcen_mask - let shift = (UInt32(newValue) << RCC.APB2ENR.ltdcen_offset) & RCC.APB2ENR.ltdcen_mask - self.rawValue = preserve | shift - } - } - - static let sai2en_offset = UInt32(23) - static let sai2en_mask = UInt32(0b1) &<< sai2en_offset - var sai2en: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2ENR.sai2en_mask)) >> RCC.APB2ENR.sai2en_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2ENR.sai2en_mask - let shift = (UInt32(newValue) << RCC.APB2ENR.sai2en_offset) & RCC.APB2ENR.sai2en_mask - self.rawValue = preserve | shift - } - } - - static let sdmmc1en_offset = UInt32(11) - static let sdmmc1en_mask = UInt32(0b1) &<< sdmmc1en_offset - var sdmmc1en: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2ENR.sdmmc1en_mask)) >> RCC.APB2ENR.sdmmc1en_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2ENR.sdmmc1en_mask - let shift = (UInt32(newValue) << RCC.APB2ENR.sdmmc1en_offset) & RCC.APB2ENR.sdmmc1en_mask - self.rawValue = preserve | shift - } - } - - init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - struct AHB1LPENR { - var rawValue: UInt32 - - static let gpioalpen_offset = UInt32(0) - static let gpioalpen_mask = UInt32(0b1) &<< gpioalpen_offset - var gpioalpen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1LPENR.gpioalpen_mask)) >> RCC.AHB1LPENR.gpioalpen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1LPENR.gpioalpen_mask - let shift = (UInt32(newValue) << RCC.AHB1LPENR.gpioalpen_offset) & RCC.AHB1LPENR.gpioalpen_mask - self.rawValue = preserve | shift - } - } - - static let gpioblpen_offset = UInt32(1) - static let gpioblpen_mask = UInt32(0b1) &<< gpioblpen_offset - var gpioblpen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1LPENR.gpioblpen_mask)) >> RCC.AHB1LPENR.gpioblpen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1LPENR.gpioblpen_mask - let shift = (UInt32(newValue) << RCC.AHB1LPENR.gpioblpen_offset) & RCC.AHB1LPENR.gpioblpen_mask - self.rawValue = preserve | shift - } - } - - static let gpioclpen_offset = UInt32(2) - static let gpioclpen_mask = UInt32(0b1) &<< gpioclpen_offset - var gpioclpen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1LPENR.gpioclpen_mask)) >> RCC.AHB1LPENR.gpioclpen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1LPENR.gpioclpen_mask - let shift = (UInt32(newValue) << RCC.AHB1LPENR.gpioclpen_offset) & RCC.AHB1LPENR.gpioclpen_mask - self.rawValue = preserve | shift - } - } - - static let gpiodlpen_offset = UInt32(3) - static let gpiodlpen_mask = UInt32(0b1) &<< gpiodlpen_offset - var gpiodlpen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1LPENR.gpiodlpen_mask)) >> RCC.AHB1LPENR.gpiodlpen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1LPENR.gpiodlpen_mask - let shift = (UInt32(newValue) << RCC.AHB1LPENR.gpiodlpen_offset) & RCC.AHB1LPENR.gpiodlpen_mask - self.rawValue = preserve | shift - } - } - - static let gpioelpen_offset = UInt32(4) - static let gpioelpen_mask = UInt32(0b1) &<< gpioelpen_offset - var gpioelpen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1LPENR.gpioelpen_mask)) >> RCC.AHB1LPENR.gpioelpen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1LPENR.gpioelpen_mask - let shift = (UInt32(newValue) << RCC.AHB1LPENR.gpioelpen_offset) & RCC.AHB1LPENR.gpioelpen_mask - self.rawValue = preserve | shift - } - } - - static let gpioflpen_offset = UInt32(5) - static let gpioflpen_mask = UInt32(0b1) &<< gpioflpen_offset - var gpioflpen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1LPENR.gpioflpen_mask)) >> RCC.AHB1LPENR.gpioflpen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1LPENR.gpioflpen_mask - let shift = (UInt32(newValue) << RCC.AHB1LPENR.gpioflpen_offset) & RCC.AHB1LPENR.gpioflpen_mask - self.rawValue = preserve | shift - } - } - - static let gpioglpen_offset = UInt32(6) - static let gpioglpen_mask = UInt32(0b1) &<< gpioglpen_offset - var gpioglpen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1LPENR.gpioglpen_mask)) >> RCC.AHB1LPENR.gpioglpen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1LPENR.gpioglpen_mask - let shift = (UInt32(newValue) << RCC.AHB1LPENR.gpioglpen_offset) & RCC.AHB1LPENR.gpioglpen_mask - self.rawValue = preserve | shift - } - } - - static let gpiohlpen_offset = UInt32(7) - static let gpiohlpen_mask = UInt32(0b1) &<< gpiohlpen_offset - var gpiohlpen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1LPENR.gpiohlpen_mask)) >> RCC.AHB1LPENR.gpiohlpen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1LPENR.gpiohlpen_mask - let shift = (UInt32(newValue) << RCC.AHB1LPENR.gpiohlpen_offset) & RCC.AHB1LPENR.gpiohlpen_mask - self.rawValue = preserve | shift - } - } - - static let gpioilpen_offset = UInt32(8) - static let gpioilpen_mask = UInt32(0b1) &<< gpioilpen_offset - var gpioilpen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1LPENR.gpioilpen_mask)) >> RCC.AHB1LPENR.gpioilpen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1LPENR.gpioilpen_mask - let shift = (UInt32(newValue) << RCC.AHB1LPENR.gpioilpen_offset) & RCC.AHB1LPENR.gpioilpen_mask - self.rawValue = preserve | shift - } - } - - static let gpiojlpen_offset = UInt32(9) - static let gpiojlpen_mask = UInt32(0b1) &<< gpiojlpen_offset - var gpiojlpen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1LPENR.gpiojlpen_mask)) >> RCC.AHB1LPENR.gpiojlpen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1LPENR.gpiojlpen_mask - let shift = (UInt32(newValue) << RCC.AHB1LPENR.gpiojlpen_offset) & RCC.AHB1LPENR.gpiojlpen_mask - self.rawValue = preserve | shift - } - } - - static let gpioklpen_offset = UInt32(10) - static let gpioklpen_mask = UInt32(0b1) &<< gpioklpen_offset - var gpioklpen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1LPENR.gpioklpen_mask)) >> RCC.AHB1LPENR.gpioklpen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1LPENR.gpioklpen_mask - let shift = (UInt32(newValue) << RCC.AHB1LPENR.gpioklpen_offset) & RCC.AHB1LPENR.gpioklpen_mask - self.rawValue = preserve | shift - } - } - - static let crclpen_offset = UInt32(12) - static let crclpen_mask = UInt32(0b1) &<< crclpen_offset - var crclpen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1LPENR.crclpen_mask)) >> RCC.AHB1LPENR.crclpen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1LPENR.crclpen_mask - let shift = (UInt32(newValue) << RCC.AHB1LPENR.crclpen_offset) & RCC.AHB1LPENR.crclpen_mask - self.rawValue = preserve | shift - } - } - - static let flitflpen_offset = UInt32(15) - static let flitflpen_mask = UInt32(0b1) &<< flitflpen_offset - var flitflpen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1LPENR.flitflpen_mask)) >> RCC.AHB1LPENR.flitflpen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1LPENR.flitflpen_mask - let shift = (UInt32(newValue) << RCC.AHB1LPENR.flitflpen_offset) & RCC.AHB1LPENR.flitflpen_mask - self.rawValue = preserve | shift - } - } - - static let sram1lpen_offset = UInt32(16) - static let sram1lpen_mask = UInt32(0b1) &<< sram1lpen_offset - var sram1lpen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1LPENR.sram1lpen_mask)) >> RCC.AHB1LPENR.sram1lpen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1LPENR.sram1lpen_mask - let shift = (UInt32(newValue) << RCC.AHB1LPENR.sram1lpen_offset) & RCC.AHB1LPENR.sram1lpen_mask - self.rawValue = preserve | shift - } - } - - static let sram2lpen_offset = UInt32(17) - static let sram2lpen_mask = UInt32(0b1) &<< sram2lpen_offset - var sram2lpen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1LPENR.sram2lpen_mask)) >> RCC.AHB1LPENR.sram2lpen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1LPENR.sram2lpen_mask - let shift = (UInt32(newValue) << RCC.AHB1LPENR.sram2lpen_offset) & RCC.AHB1LPENR.sram2lpen_mask - self.rawValue = preserve | shift - } - } - - static let bkpsramlpen_offset = UInt32(18) - static let bkpsramlpen_mask = UInt32(0b1) &<< bkpsramlpen_offset - var bkpsramlpen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1LPENR.bkpsramlpen_mask)) >> RCC.AHB1LPENR.bkpsramlpen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1LPENR.bkpsramlpen_mask - let shift = (UInt32(newValue) << RCC.AHB1LPENR.bkpsramlpen_offset) & RCC.AHB1LPENR.bkpsramlpen_mask - self.rawValue = preserve | shift - } - } - - static let sram3lpen_offset = UInt32(19) - static let sram3lpen_mask = UInt32(0b1) &<< sram3lpen_offset - var sram3lpen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1LPENR.sram3lpen_mask)) >> RCC.AHB1LPENR.sram3lpen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1LPENR.sram3lpen_mask - let shift = (UInt32(newValue) << RCC.AHB1LPENR.sram3lpen_offset) & RCC.AHB1LPENR.sram3lpen_mask - self.rawValue = preserve | shift - } - } - - static let dma1lpen_offset = UInt32(21) - static let dma1lpen_mask = UInt32(0b1) &<< dma1lpen_offset - var dma1lpen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1LPENR.dma1lpen_mask)) >> RCC.AHB1LPENR.dma1lpen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1LPENR.dma1lpen_mask - let shift = (UInt32(newValue) << RCC.AHB1LPENR.dma1lpen_offset) & RCC.AHB1LPENR.dma1lpen_mask - self.rawValue = preserve | shift - } - } - - static let dma2lpen_offset = UInt32(22) - static let dma2lpen_mask = UInt32(0b1) &<< dma2lpen_offset - var dma2lpen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1LPENR.dma2lpen_mask)) >> RCC.AHB1LPENR.dma2lpen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1LPENR.dma2lpen_mask - let shift = (UInt32(newValue) << RCC.AHB1LPENR.dma2lpen_offset) & RCC.AHB1LPENR.dma2lpen_mask - self.rawValue = preserve | shift - } - } - - static let dma2dlpen_offset = UInt32(23) - static let dma2dlpen_mask = UInt32(0b1) &<< dma2dlpen_offset - var dma2dlpen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1LPENR.dma2dlpen_mask)) >> RCC.AHB1LPENR.dma2dlpen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1LPENR.dma2dlpen_mask - let shift = (UInt32(newValue) << RCC.AHB1LPENR.dma2dlpen_offset) & RCC.AHB1LPENR.dma2dlpen_mask - self.rawValue = preserve | shift - } - } - - static let ethmaclpen_offset = UInt32(25) - static let ethmaclpen_mask = UInt32(0b1) &<< ethmaclpen_offset - var ethmaclpen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1LPENR.ethmaclpen_mask)) >> RCC.AHB1LPENR.ethmaclpen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1LPENR.ethmaclpen_mask - let shift = (UInt32(newValue) << RCC.AHB1LPENR.ethmaclpen_offset) & RCC.AHB1LPENR.ethmaclpen_mask - self.rawValue = preserve | shift - } - } - - static let ethmactxlpen_offset = UInt32(26) - static let ethmactxlpen_mask = UInt32(0b1) &<< ethmactxlpen_offset - var ethmactxlpen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1LPENR.ethmactxlpen_mask)) >> RCC.AHB1LPENR.ethmactxlpen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1LPENR.ethmactxlpen_mask - let shift = (UInt32(newValue) << RCC.AHB1LPENR.ethmactxlpen_offset) & RCC.AHB1LPENR.ethmactxlpen_mask - self.rawValue = preserve | shift - } - } - - static let ethmacrxlpen_offset = UInt32(27) - static let ethmacrxlpen_mask = UInt32(0b1) &<< ethmacrxlpen_offset - var ethmacrxlpen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1LPENR.ethmacrxlpen_mask)) >> RCC.AHB1LPENR.ethmacrxlpen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1LPENR.ethmacrxlpen_mask - let shift = (UInt32(newValue) << RCC.AHB1LPENR.ethmacrxlpen_offset) & RCC.AHB1LPENR.ethmacrxlpen_mask - self.rawValue = preserve | shift - } - } - - static let ethmacptplpen_offset = UInt32(28) - static let ethmacptplpen_mask = UInt32(0b1) &<< ethmacptplpen_offset - var ethmacptplpen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1LPENR.ethmacptplpen_mask)) >> RCC.AHB1LPENR.ethmacptplpen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1LPENR.ethmacptplpen_mask - let shift = (UInt32(newValue) << RCC.AHB1LPENR.ethmacptplpen_offset) & RCC.AHB1LPENR.ethmacptplpen_mask - self.rawValue = preserve | shift - } - } - - static let otghslpen_offset = UInt32(29) - static let otghslpen_mask = UInt32(0b1) &<< otghslpen_offset - var otghslpen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1LPENR.otghslpen_mask)) >> RCC.AHB1LPENR.otghslpen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1LPENR.otghslpen_mask - let shift = (UInt32(newValue) << RCC.AHB1LPENR.otghslpen_offset) & RCC.AHB1LPENR.otghslpen_mask - self.rawValue = preserve | shift - } - } - - static let otghsulpilpen_offset = UInt32(30) - static let otghsulpilpen_mask = UInt32(0b1) &<< otghsulpilpen_offset - var otghsulpilpen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB1LPENR.otghsulpilpen_mask)) >> RCC.AHB1LPENR.otghsulpilpen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB1LPENR.otghsulpilpen_mask - let shift = (UInt32(newValue) << RCC.AHB1LPENR.otghsulpilpen_offset) & RCC.AHB1LPENR.otghsulpilpen_mask - self.rawValue = preserve | shift - } - } - - init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - struct AHB2LPENR { - var rawValue: UInt32 - - static let otgfslpen_offset = UInt32(7) - static let otgfslpen_mask = UInt32(0b1) &<< otgfslpen_offset - var otgfslpen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB2LPENR.otgfslpen_mask)) >> RCC.AHB2LPENR.otgfslpen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB2LPENR.otgfslpen_mask - let shift = (UInt32(newValue) << RCC.AHB2LPENR.otgfslpen_offset) & RCC.AHB2LPENR.otgfslpen_mask - self.rawValue = preserve | shift - } - } - - static let rnglpen_offset = UInt32(6) - static let rnglpen_mask = UInt32(0b1) &<< rnglpen_offset - var rnglpen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB2LPENR.rnglpen_mask)) >> RCC.AHB2LPENR.rnglpen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB2LPENR.rnglpen_mask - let shift = (UInt32(newValue) << RCC.AHB2LPENR.rnglpen_offset) & RCC.AHB2LPENR.rnglpen_mask - self.rawValue = preserve | shift - } - } - - static let hashlpen_offset = UInt32(5) - static let hashlpen_mask = UInt32(0b1) &<< hashlpen_offset - var hashlpen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB2LPENR.hashlpen_mask)) >> RCC.AHB2LPENR.hashlpen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB2LPENR.hashlpen_mask - let shift = (UInt32(newValue) << RCC.AHB2LPENR.hashlpen_offset) & RCC.AHB2LPENR.hashlpen_mask - self.rawValue = preserve | shift - } - } - - static let cryplpen_offset = UInt32(4) - static let cryplpen_mask = UInt32(0b1) &<< cryplpen_offset - var cryplpen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB2LPENR.cryplpen_mask)) >> RCC.AHB2LPENR.cryplpen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB2LPENR.cryplpen_mask - let shift = (UInt32(newValue) << RCC.AHB2LPENR.cryplpen_offset) & RCC.AHB2LPENR.cryplpen_mask - self.rawValue = preserve | shift - } - } - - static let dcmilpen_offset = UInt32(0) - static let dcmilpen_mask = UInt32(0b1) &<< dcmilpen_offset - var dcmilpen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB2LPENR.dcmilpen_mask)) >> RCC.AHB2LPENR.dcmilpen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB2LPENR.dcmilpen_mask - let shift = (UInt32(newValue) << RCC.AHB2LPENR.dcmilpen_offset) & RCC.AHB2LPENR.dcmilpen_mask - self.rawValue = preserve | shift - } - } - - init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - struct AHB3LPENR { - var rawValue: UInt32 - - static let fmclpen_offset = UInt32(0) - static let fmclpen_mask = UInt32(0b1) &<< fmclpen_offset - var fmclpen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB3LPENR.fmclpen_mask)) >> RCC.AHB3LPENR.fmclpen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB3LPENR.fmclpen_mask - let shift = (UInt32(newValue) << RCC.AHB3LPENR.fmclpen_offset) & RCC.AHB3LPENR.fmclpen_mask - self.rawValue = preserve | shift - } - } - - static let qspilpen_offset = UInt32(1) - static let qspilpen_mask = UInt32(0b1) &<< qspilpen_offset - var qspilpen: UInt8 { - get { UInt8((self.rawValue & (RCC.AHB3LPENR.qspilpen_mask)) >> RCC.AHB3LPENR.qspilpen_offset) } - set { - let preserve = self.rawValue & ~RCC.AHB3LPENR.qspilpen_mask - let shift = (UInt32(newValue) << RCC.AHB3LPENR.qspilpen_offset) & RCC.AHB3LPENR.qspilpen_mask - self.rawValue = preserve | shift - } - } - - init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - struct APB1LPENR { - var rawValue: UInt32 - - static let tim2lpen_offset = UInt32(0) - static let tim2lpen_mask = UInt32(0b1) &<< tim2lpen_offset - var tim2lpen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1LPENR.tim2lpen_mask)) >> RCC.APB1LPENR.tim2lpen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1LPENR.tim2lpen_mask - let shift = (UInt32(newValue) << RCC.APB1LPENR.tim2lpen_offset) & RCC.APB1LPENR.tim2lpen_mask - self.rawValue = preserve | shift - } - } - - static let tim3lpen_offset = UInt32(1) - static let tim3lpen_mask = UInt32(0b1) &<< tim3lpen_offset - var tim3lpen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1LPENR.tim3lpen_mask)) >> RCC.APB1LPENR.tim3lpen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1LPENR.tim3lpen_mask - let shift = (UInt32(newValue) << RCC.APB1LPENR.tim3lpen_offset) & RCC.APB1LPENR.tim3lpen_mask - self.rawValue = preserve | shift - } - } - - static let tim4lpen_offset = UInt32(2) - static let tim4lpen_mask = UInt32(0b1) &<< tim4lpen_offset - var tim4lpen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1LPENR.tim4lpen_mask)) >> RCC.APB1LPENR.tim4lpen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1LPENR.tim4lpen_mask - let shift = (UInt32(newValue) << RCC.APB1LPENR.tim4lpen_offset) & RCC.APB1LPENR.tim4lpen_mask - self.rawValue = preserve | shift - } - } - - static let tim5lpen_offset = UInt32(3) - static let tim5lpen_mask = UInt32(0b1) &<< tim5lpen_offset - var tim5lpen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1LPENR.tim5lpen_mask)) >> RCC.APB1LPENR.tim5lpen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1LPENR.tim5lpen_mask - let shift = (UInt32(newValue) << RCC.APB1LPENR.tim5lpen_offset) & RCC.APB1LPENR.tim5lpen_mask - self.rawValue = preserve | shift - } - } - - static let tim6lpen_offset = UInt32(4) - static let tim6lpen_mask = UInt32(0b1) &<< tim6lpen_offset - var tim6lpen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1LPENR.tim6lpen_mask)) >> RCC.APB1LPENR.tim6lpen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1LPENR.tim6lpen_mask - let shift = (UInt32(newValue) << RCC.APB1LPENR.tim6lpen_offset) & RCC.APB1LPENR.tim6lpen_mask - self.rawValue = preserve | shift - } - } - - static let tim7lpen_offset = UInt32(5) - static let tim7lpen_mask = UInt32(0b1) &<< tim7lpen_offset - var tim7lpen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1LPENR.tim7lpen_mask)) >> RCC.APB1LPENR.tim7lpen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1LPENR.tim7lpen_mask - let shift = (UInt32(newValue) << RCC.APB1LPENR.tim7lpen_offset) & RCC.APB1LPENR.tim7lpen_mask - self.rawValue = preserve | shift - } - } - - static let tim12lpen_offset = UInt32(6) - static let tim12lpen_mask = UInt32(0b1) &<< tim12lpen_offset - var tim12lpen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1LPENR.tim12lpen_mask)) >> RCC.APB1LPENR.tim12lpen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1LPENR.tim12lpen_mask - let shift = (UInt32(newValue) << RCC.APB1LPENR.tim12lpen_offset) & RCC.APB1LPENR.tim12lpen_mask - self.rawValue = preserve | shift - } - } - - static let tim13lpen_offset = UInt32(7) - static let tim13lpen_mask = UInt32(0b1) &<< tim13lpen_offset - var tim13lpen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1LPENR.tim13lpen_mask)) >> RCC.APB1LPENR.tim13lpen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1LPENR.tim13lpen_mask - let shift = (UInt32(newValue) << RCC.APB1LPENR.tim13lpen_offset) & RCC.APB1LPENR.tim13lpen_mask - self.rawValue = preserve | shift - } - } - - static let tim14lpen_offset = UInt32(8) - static let tim14lpen_mask = UInt32(0b1) &<< tim14lpen_offset - var tim14lpen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1LPENR.tim14lpen_mask)) >> RCC.APB1LPENR.tim14lpen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1LPENR.tim14lpen_mask - let shift = (UInt32(newValue) << RCC.APB1LPENR.tim14lpen_offset) & RCC.APB1LPENR.tim14lpen_mask - self.rawValue = preserve | shift - } - } - - static let wwdglpen_offset = UInt32(11) - static let wwdglpen_mask = UInt32(0b1) &<< wwdglpen_offset - var wwdglpen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1LPENR.wwdglpen_mask)) >> RCC.APB1LPENR.wwdglpen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1LPENR.wwdglpen_mask - let shift = (UInt32(newValue) << RCC.APB1LPENR.wwdglpen_offset) & RCC.APB1LPENR.wwdglpen_mask - self.rawValue = preserve | shift - } - } - - static let spi2lpen_offset = UInt32(14) - static let spi2lpen_mask = UInt32(0b1) &<< spi2lpen_offset - var spi2lpen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1LPENR.spi2lpen_mask)) >> RCC.APB1LPENR.spi2lpen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1LPENR.spi2lpen_mask - let shift = (UInt32(newValue) << RCC.APB1LPENR.spi2lpen_offset) & RCC.APB1LPENR.spi2lpen_mask - self.rawValue = preserve | shift - } - } - - static let spi3lpen_offset = UInt32(15) - static let spi3lpen_mask = UInt32(0b1) &<< spi3lpen_offset - var spi3lpen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1LPENR.spi3lpen_mask)) >> RCC.APB1LPENR.spi3lpen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1LPENR.spi3lpen_mask - let shift = (UInt32(newValue) << RCC.APB1LPENR.spi3lpen_offset) & RCC.APB1LPENR.spi3lpen_mask - self.rawValue = preserve | shift - } - } - - static let usart2lpen_offset = UInt32(17) - static let usart2lpen_mask = UInt32(0b1) &<< usart2lpen_offset - var usart2lpen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1LPENR.usart2lpen_mask)) >> RCC.APB1LPENR.usart2lpen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1LPENR.usart2lpen_mask - let shift = (UInt32(newValue) << RCC.APB1LPENR.usart2lpen_offset) & RCC.APB1LPENR.usart2lpen_mask - self.rawValue = preserve | shift - } - } - - static let usart3lpen_offset = UInt32(18) - static let usart3lpen_mask = UInt32(0b1) &<< usart3lpen_offset - var usart3lpen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1LPENR.usart3lpen_mask)) >> RCC.APB1LPENR.usart3lpen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1LPENR.usart3lpen_mask - let shift = (UInt32(newValue) << RCC.APB1LPENR.usart3lpen_offset) & RCC.APB1LPENR.usart3lpen_mask - self.rawValue = preserve | shift - } - } - - static let uart4lpen_offset = UInt32(19) - static let uart4lpen_mask = UInt32(0b1) &<< uart4lpen_offset - var uart4lpen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1LPENR.uart4lpen_mask)) >> RCC.APB1LPENR.uart4lpen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1LPENR.uart4lpen_mask - let shift = (UInt32(newValue) << RCC.APB1LPENR.uart4lpen_offset) & RCC.APB1LPENR.uart4lpen_mask - self.rawValue = preserve | shift - } - } - - static let uart5lpen_offset = UInt32(20) - static let uart5lpen_mask = UInt32(0b1) &<< uart5lpen_offset - var uart5lpen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1LPENR.uart5lpen_mask)) >> RCC.APB1LPENR.uart5lpen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1LPENR.uart5lpen_mask - let shift = (UInt32(newValue) << RCC.APB1LPENR.uart5lpen_offset) & RCC.APB1LPENR.uart5lpen_mask - self.rawValue = preserve | shift - } - } - - static let i2c1lpen_offset = UInt32(21) - static let i2c1lpen_mask = UInt32(0b1) &<< i2c1lpen_offset - var i2c1lpen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1LPENR.i2c1lpen_mask)) >> RCC.APB1LPENR.i2c1lpen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1LPENR.i2c1lpen_mask - let shift = (UInt32(newValue) << RCC.APB1LPENR.i2c1lpen_offset) & RCC.APB1LPENR.i2c1lpen_mask - self.rawValue = preserve | shift - } - } - - static let i2c2lpen_offset = UInt32(22) - static let i2c2lpen_mask = UInt32(0b1) &<< i2c2lpen_offset - var i2c2lpen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1LPENR.i2c2lpen_mask)) >> RCC.APB1LPENR.i2c2lpen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1LPENR.i2c2lpen_mask - let shift = (UInt32(newValue) << RCC.APB1LPENR.i2c2lpen_offset) & RCC.APB1LPENR.i2c2lpen_mask - self.rawValue = preserve | shift - } - } - - static let i2c3lpen_offset = UInt32(23) - static let i2c3lpen_mask = UInt32(0b1) &<< i2c3lpen_offset - var i2c3lpen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1LPENR.i2c3lpen_mask)) >> RCC.APB1LPENR.i2c3lpen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1LPENR.i2c3lpen_mask - let shift = (UInt32(newValue) << RCC.APB1LPENR.i2c3lpen_offset) & RCC.APB1LPENR.i2c3lpen_mask - self.rawValue = preserve | shift - } - } - - static let can1lpen_offset = UInt32(25) - static let can1lpen_mask = UInt32(0b1) &<< can1lpen_offset - var can1lpen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1LPENR.can1lpen_mask)) >> RCC.APB1LPENR.can1lpen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1LPENR.can1lpen_mask - let shift = (UInt32(newValue) << RCC.APB1LPENR.can1lpen_offset) & RCC.APB1LPENR.can1lpen_mask - self.rawValue = preserve | shift - } - } - - static let can2lpen_offset = UInt32(26) - static let can2lpen_mask = UInt32(0b1) &<< can2lpen_offset - var can2lpen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1LPENR.can2lpen_mask)) >> RCC.APB1LPENR.can2lpen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1LPENR.can2lpen_mask - let shift = (UInt32(newValue) << RCC.APB1LPENR.can2lpen_offset) & RCC.APB1LPENR.can2lpen_mask - self.rawValue = preserve | shift - } - } - - static let pwrlpen_offset = UInt32(28) - static let pwrlpen_mask = UInt32(0b1) &<< pwrlpen_offset - var pwrlpen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1LPENR.pwrlpen_mask)) >> RCC.APB1LPENR.pwrlpen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1LPENR.pwrlpen_mask - let shift = (UInt32(newValue) << RCC.APB1LPENR.pwrlpen_offset) & RCC.APB1LPENR.pwrlpen_mask - self.rawValue = preserve | shift - } - } - - static let daclpen_offset = UInt32(29) - static let daclpen_mask = UInt32(0b1) &<< daclpen_offset - var daclpen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1LPENR.daclpen_mask)) >> RCC.APB1LPENR.daclpen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1LPENR.daclpen_mask - let shift = (UInt32(newValue) << RCC.APB1LPENR.daclpen_offset) & RCC.APB1LPENR.daclpen_mask - self.rawValue = preserve | shift - } - } - - static let uart7lpen_offset = UInt32(30) - static let uart7lpen_mask = UInt32(0b1) &<< uart7lpen_offset - var uart7lpen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1LPENR.uart7lpen_mask)) >> RCC.APB1LPENR.uart7lpen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1LPENR.uart7lpen_mask - let shift = (UInt32(newValue) << RCC.APB1LPENR.uart7lpen_offset) & RCC.APB1LPENR.uart7lpen_mask - self.rawValue = preserve | shift - } - } - - static let uart8lpen_offset = UInt32(31) - static let uart8lpen_mask = UInt32(0b1) &<< uart8lpen_offset - var uart8lpen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1LPENR.uart8lpen_mask)) >> RCC.APB1LPENR.uart8lpen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1LPENR.uart8lpen_mask - let shift = (UInt32(newValue) << RCC.APB1LPENR.uart8lpen_offset) & RCC.APB1LPENR.uart8lpen_mask - self.rawValue = preserve | shift - } - } - - static let spdifrxlpen_offset = UInt32(16) - static let spdifrxlpen_mask = UInt32(0b1) &<< spdifrxlpen_offset - var spdifrxlpen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1LPENR.spdifrxlpen_mask)) >> RCC.APB1LPENR.spdifrxlpen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1LPENR.spdifrxlpen_mask - let shift = (UInt32(newValue) << RCC.APB1LPENR.spdifrxlpen_offset) & RCC.APB1LPENR.spdifrxlpen_mask - self.rawValue = preserve | shift - } - } - - static let ceclpen_offset = UInt32(27) - static let ceclpen_mask = UInt32(0b1) &<< ceclpen_offset - var ceclpen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1LPENR.ceclpen_mask)) >> RCC.APB1LPENR.ceclpen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1LPENR.ceclpen_mask - let shift = (UInt32(newValue) << RCC.APB1LPENR.ceclpen_offset) & RCC.APB1LPENR.ceclpen_mask - self.rawValue = preserve | shift - } - } - - static let lptim1lpen_offset = UInt32(9) - static let lptim1lpen_mask = UInt32(0b1) &<< lptim1lpen_offset - var lptim1lpen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1LPENR.lptim1lpen_mask)) >> RCC.APB1LPENR.lptim1lpen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1LPENR.lptim1lpen_mask - let shift = (UInt32(newValue) << RCC.APB1LPENR.lptim1lpen_offset) & RCC.APB1LPENR.lptim1lpen_mask - self.rawValue = preserve | shift - } - } - - static let i2c4lpen_offset = UInt32(24) - static let i2c4lpen_mask = UInt32(0b1) &<< i2c4lpen_offset - var i2c4lpen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB1LPENR.i2c4lpen_mask)) >> RCC.APB1LPENR.i2c4lpen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB1LPENR.i2c4lpen_mask - let shift = (UInt32(newValue) << RCC.APB1LPENR.i2c4lpen_offset) & RCC.APB1LPENR.i2c4lpen_mask - self.rawValue = preserve | shift - } - } - - init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - struct APB2LPENR { - var rawValue: UInt32 - - static let tim1lpen_offset = UInt32(0) - static let tim1lpen_mask = UInt32(0b1) &<< tim1lpen_offset - var tim1lpen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2LPENR.tim1lpen_mask)) >> RCC.APB2LPENR.tim1lpen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2LPENR.tim1lpen_mask - let shift = (UInt32(newValue) << RCC.APB2LPENR.tim1lpen_offset) & RCC.APB2LPENR.tim1lpen_mask - self.rawValue = preserve | shift - } - } - - static let tim8lpen_offset = UInt32(1) - static let tim8lpen_mask = UInt32(0b1) &<< tim8lpen_offset - var tim8lpen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2LPENR.tim8lpen_mask)) >> RCC.APB2LPENR.tim8lpen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2LPENR.tim8lpen_mask - let shift = (UInt32(newValue) << RCC.APB2LPENR.tim8lpen_offset) & RCC.APB2LPENR.tim8lpen_mask - self.rawValue = preserve | shift - } - } - - static let usart1lpen_offset = UInt32(4) - static let usart1lpen_mask = UInt32(0b1) &<< usart1lpen_offset - var usart1lpen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2LPENR.usart1lpen_mask)) >> RCC.APB2LPENR.usart1lpen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2LPENR.usart1lpen_mask - let shift = (UInt32(newValue) << RCC.APB2LPENR.usart1lpen_offset) & RCC.APB2LPENR.usart1lpen_mask - self.rawValue = preserve | shift - } - } - - static let usart6lpen_offset = UInt32(5) - static let usart6lpen_mask = UInt32(0b1) &<< usart6lpen_offset - var usart6lpen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2LPENR.usart6lpen_mask)) >> RCC.APB2LPENR.usart6lpen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2LPENR.usart6lpen_mask - let shift = (UInt32(newValue) << RCC.APB2LPENR.usart6lpen_offset) & RCC.APB2LPENR.usart6lpen_mask - self.rawValue = preserve | shift - } - } - - static let adc1lpen_offset = UInt32(8) - static let adc1lpen_mask = UInt32(0b1) &<< adc1lpen_offset - var adc1lpen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2LPENR.adc1lpen_mask)) >> RCC.APB2LPENR.adc1lpen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2LPENR.adc1lpen_mask - let shift = (UInt32(newValue) << RCC.APB2LPENR.adc1lpen_offset) & RCC.APB2LPENR.adc1lpen_mask - self.rawValue = preserve | shift - } - } - - static let adc2lpen_offset = UInt32(9) - static let adc2lpen_mask = UInt32(0b1) &<< adc2lpen_offset - var adc2lpen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2LPENR.adc2lpen_mask)) >> RCC.APB2LPENR.adc2lpen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2LPENR.adc2lpen_mask - let shift = (UInt32(newValue) << RCC.APB2LPENR.adc2lpen_offset) & RCC.APB2LPENR.adc2lpen_mask - self.rawValue = preserve | shift - } - } - - static let adc3lpen_offset = UInt32(10) - static let adc3lpen_mask = UInt32(0b1) &<< adc3lpen_offset - var adc3lpen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2LPENR.adc3lpen_mask)) >> RCC.APB2LPENR.adc3lpen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2LPENR.adc3lpen_mask - let shift = (UInt32(newValue) << RCC.APB2LPENR.adc3lpen_offset) & RCC.APB2LPENR.adc3lpen_mask - self.rawValue = preserve | shift - } - } - - static let spi1lpen_offset = UInt32(12) - static let spi1lpen_mask = UInt32(0b1) &<< spi1lpen_offset - var spi1lpen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2LPENR.spi1lpen_mask)) >> RCC.APB2LPENR.spi1lpen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2LPENR.spi1lpen_mask - let shift = (UInt32(newValue) << RCC.APB2LPENR.spi1lpen_offset) & RCC.APB2LPENR.spi1lpen_mask - self.rawValue = preserve | shift - } - } - - static let spi4lpen_offset = UInt32(13) - static let spi4lpen_mask = UInt32(0b1) &<< spi4lpen_offset - var spi4lpen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2LPENR.spi4lpen_mask)) >> RCC.APB2LPENR.spi4lpen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2LPENR.spi4lpen_mask - let shift = (UInt32(newValue) << RCC.APB2LPENR.spi4lpen_offset) & RCC.APB2LPENR.spi4lpen_mask - self.rawValue = preserve | shift - } - } - - static let syscfglpen_offset = UInt32(14) - static let syscfglpen_mask = UInt32(0b1) &<< syscfglpen_offset - var syscfglpen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2LPENR.syscfglpen_mask)) >> RCC.APB2LPENR.syscfglpen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2LPENR.syscfglpen_mask - let shift = (UInt32(newValue) << RCC.APB2LPENR.syscfglpen_offset) & RCC.APB2LPENR.syscfglpen_mask - self.rawValue = preserve | shift - } - } - - static let tim9lpen_offset = UInt32(16) - static let tim9lpen_mask = UInt32(0b1) &<< tim9lpen_offset - var tim9lpen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2LPENR.tim9lpen_mask)) >> RCC.APB2LPENR.tim9lpen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2LPENR.tim9lpen_mask - let shift = (UInt32(newValue) << RCC.APB2LPENR.tim9lpen_offset) & RCC.APB2LPENR.tim9lpen_mask - self.rawValue = preserve | shift - } - } - - static let tim10lpen_offset = UInt32(17) - static let tim10lpen_mask = UInt32(0b1) &<< tim10lpen_offset - var tim10lpen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2LPENR.tim10lpen_mask)) >> RCC.APB2LPENR.tim10lpen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2LPENR.tim10lpen_mask - let shift = (UInt32(newValue) << RCC.APB2LPENR.tim10lpen_offset) & RCC.APB2LPENR.tim10lpen_mask - self.rawValue = preserve | shift - } - } - - static let tim11lpen_offset = UInt32(18) - static let tim11lpen_mask = UInt32(0b1) &<< tim11lpen_offset - var tim11lpen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2LPENR.tim11lpen_mask)) >> RCC.APB2LPENR.tim11lpen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2LPENR.tim11lpen_mask - let shift = (UInt32(newValue) << RCC.APB2LPENR.tim11lpen_offset) & RCC.APB2LPENR.tim11lpen_mask - self.rawValue = preserve | shift - } - } - - static let spi5lpen_offset = UInt32(20) - static let spi5lpen_mask = UInt32(0b1) &<< spi5lpen_offset - var spi5lpen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2LPENR.spi5lpen_mask)) >> RCC.APB2LPENR.spi5lpen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2LPENR.spi5lpen_mask - let shift = (UInt32(newValue) << RCC.APB2LPENR.spi5lpen_offset) & RCC.APB2LPENR.spi5lpen_mask - self.rawValue = preserve | shift - } - } - - static let spi6lpen_offset = UInt32(21) - static let spi6lpen_mask = UInt32(0b1) &<< spi6lpen_offset - var spi6lpen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2LPENR.spi6lpen_mask)) >> RCC.APB2LPENR.spi6lpen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2LPENR.spi6lpen_mask - let shift = (UInt32(newValue) << RCC.APB2LPENR.spi6lpen_offset) & RCC.APB2LPENR.spi6lpen_mask - self.rawValue = preserve | shift - } - } - - static let sai1lpen_offset = UInt32(22) - static let sai1lpen_mask = UInt32(0b1) &<< sai1lpen_offset - var sai1lpen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2LPENR.sai1lpen_mask)) >> RCC.APB2LPENR.sai1lpen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2LPENR.sai1lpen_mask - let shift = (UInt32(newValue) << RCC.APB2LPENR.sai1lpen_offset) & RCC.APB2LPENR.sai1lpen_mask - self.rawValue = preserve | shift - } - } - - static let ltdclpen_offset = UInt32(26) - static let ltdclpen_mask = UInt32(0b1) &<< ltdclpen_offset - var ltdclpen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2LPENR.ltdclpen_mask)) >> RCC.APB2LPENR.ltdclpen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2LPENR.ltdclpen_mask - let shift = (UInt32(newValue) << RCC.APB2LPENR.ltdclpen_offset) & RCC.APB2LPENR.ltdclpen_mask - self.rawValue = preserve | shift - } - } - - static let sai2lpen_offset = UInt32(23) - static let sai2lpen_mask = UInt32(0b1) &<< sai2lpen_offset - var sai2lpen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2LPENR.sai2lpen_mask)) >> RCC.APB2LPENR.sai2lpen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2LPENR.sai2lpen_mask - let shift = (UInt32(newValue) << RCC.APB2LPENR.sai2lpen_offset) & RCC.APB2LPENR.sai2lpen_mask - self.rawValue = preserve | shift - } - } - - static let sdmmc1lpen_offset = UInt32(11) - static let sdmmc1lpen_mask = UInt32(0b1) &<< sdmmc1lpen_offset - var sdmmc1lpen: UInt8 { - get { UInt8((self.rawValue & (RCC.APB2LPENR.sdmmc1lpen_mask)) >> RCC.APB2LPENR.sdmmc1lpen_offset) } - set { - let preserve = self.rawValue & ~RCC.APB2LPENR.sdmmc1lpen_mask - let shift = (UInt32(newValue) << RCC.APB2LPENR.sdmmc1lpen_offset) & RCC.APB2LPENR.sdmmc1lpen_mask - self.rawValue = preserve | shift - } - } - - init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - struct BDCR { - var rawValue: UInt32 - - static let bdrst_offset = UInt32(16) - static let bdrst_mask = UInt32(0b1) &<< bdrst_offset - var bdrst: UInt8 { - get { UInt8((self.rawValue & (RCC.BDCR.bdrst_mask)) >> RCC.BDCR.bdrst_offset) } - set { - let preserve = self.rawValue & ~RCC.BDCR.bdrst_mask - let shift = (UInt32(newValue) << RCC.BDCR.bdrst_offset) & RCC.BDCR.bdrst_mask - self.rawValue = preserve | shift - } - } - - static let rtcen_offset = UInt32(15) - static let rtcen_mask = UInt32(0b1) &<< rtcen_offset - var rtcen: UInt8 { - get { UInt8((self.rawValue & (RCC.BDCR.rtcen_mask)) >> RCC.BDCR.rtcen_offset) } - set { - let preserve = self.rawValue & ~RCC.BDCR.rtcen_mask - let shift = (UInt32(newValue) << RCC.BDCR.rtcen_offset) & RCC.BDCR.rtcen_mask - self.rawValue = preserve | shift - } - } - - static let rtcsel1_offset = UInt32(9) - static let rtcsel1_mask = UInt32(0b1) &<< rtcsel1_offset - var rtcsel1: UInt8 { - get { UInt8((self.rawValue & (RCC.BDCR.rtcsel1_mask)) >> RCC.BDCR.rtcsel1_offset) } - set { - let preserve = self.rawValue & ~RCC.BDCR.rtcsel1_mask - let shift = (UInt32(newValue) << RCC.BDCR.rtcsel1_offset) & RCC.BDCR.rtcsel1_mask - self.rawValue = preserve | shift - } - } - - static let rtcsel0_offset = UInt32(8) - static let rtcsel0_mask = UInt32(0b1) &<< rtcsel0_offset - var rtcsel0: UInt8 { - get { UInt8((self.rawValue & (RCC.BDCR.rtcsel0_mask)) >> RCC.BDCR.rtcsel0_offset) } - set { - let preserve = self.rawValue & ~RCC.BDCR.rtcsel0_mask - let shift = (UInt32(newValue) << RCC.BDCR.rtcsel0_offset) & RCC.BDCR.rtcsel0_mask - self.rawValue = preserve | shift - } - } - - static let lsebyp_offset = UInt32(2) - static let lsebyp_mask = UInt32(0b1) &<< lsebyp_offset - var lsebyp: UInt8 { - get { UInt8((self.rawValue & (RCC.BDCR.lsebyp_mask)) >> RCC.BDCR.lsebyp_offset) } - set { - let preserve = self.rawValue & ~RCC.BDCR.lsebyp_mask - let shift = (UInt32(newValue) << RCC.BDCR.lsebyp_offset) & RCC.BDCR.lsebyp_mask - self.rawValue = preserve | shift - } - } - - static let lserdy_offset = UInt32(1) - static let lserdy_mask = UInt32(0b1) &<< lserdy_offset - var lserdy: UInt8 { - UInt8((self.rawValue & (RCC.BDCR.lserdy_mask)) >> RCC.BDCR.lserdy_offset) - } - - static let lseon_offset = UInt32(0) - static let lseon_mask = UInt32(0b1) &<< lseon_offset - var lseon: UInt8 { - get { UInt8((self.rawValue & (RCC.BDCR.lseon_mask)) >> RCC.BDCR.lseon_offset) } - set { - let preserve = self.rawValue & ~RCC.BDCR.lseon_mask - let shift = (UInt32(newValue) << RCC.BDCR.lseon_offset) & RCC.BDCR.lseon_mask - self.rawValue = preserve | shift - } - } - - init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - struct CSR { - var rawValue: UInt32 - - static let lpwrrstf_offset = UInt32(31) - static let lpwrrstf_mask = UInt32(0b1) &<< lpwrrstf_offset - var lpwrrstf: UInt8 { - get { UInt8((self.rawValue & (RCC.CSR.lpwrrstf_mask)) >> RCC.CSR.lpwrrstf_offset) } - set { - let preserve = self.rawValue & ~RCC.CSR.lpwrrstf_mask - let shift = (UInt32(newValue) << RCC.CSR.lpwrrstf_offset) & RCC.CSR.lpwrrstf_mask - self.rawValue = preserve | shift - } - } - - static let wwdgrstf_offset = UInt32(30) - static let wwdgrstf_mask = UInt32(0b1) &<< wwdgrstf_offset - var wwdgrstf: UInt8 { - get { UInt8((self.rawValue & (RCC.CSR.wwdgrstf_mask)) >> RCC.CSR.wwdgrstf_offset) } - set { - let preserve = self.rawValue & ~RCC.CSR.wwdgrstf_mask - let shift = (UInt32(newValue) << RCC.CSR.wwdgrstf_offset) & RCC.CSR.wwdgrstf_mask - self.rawValue = preserve | shift - } - } - - static let wdgrstf_offset = UInt32(29) - static let wdgrstf_mask = UInt32(0b1) &<< wdgrstf_offset - var wdgrstf: UInt8 { - get { UInt8((self.rawValue & (RCC.CSR.wdgrstf_mask)) >> RCC.CSR.wdgrstf_offset) } - set { - let preserve = self.rawValue & ~RCC.CSR.wdgrstf_mask - let shift = (UInt32(newValue) << RCC.CSR.wdgrstf_offset) & RCC.CSR.wdgrstf_mask - self.rawValue = preserve | shift - } - } - - static let sftrstf_offset = UInt32(28) - static let sftrstf_mask = UInt32(0b1) &<< sftrstf_offset - var sftrstf: UInt8 { - get { UInt8((self.rawValue & (RCC.CSR.sftrstf_mask)) >> RCC.CSR.sftrstf_offset) } - set { - let preserve = self.rawValue & ~RCC.CSR.sftrstf_mask - let shift = (UInt32(newValue) << RCC.CSR.sftrstf_offset) & RCC.CSR.sftrstf_mask - self.rawValue = preserve | shift - } - } - - static let porrstf_offset = UInt32(27) - static let porrstf_mask = UInt32(0b1) &<< porrstf_offset - var porrstf: UInt8 { - get { UInt8((self.rawValue & (RCC.CSR.porrstf_mask)) >> RCC.CSR.porrstf_offset) } - set { - let preserve = self.rawValue & ~RCC.CSR.porrstf_mask - let shift = (UInt32(newValue) << RCC.CSR.porrstf_offset) & RCC.CSR.porrstf_mask - self.rawValue = preserve | shift - } - } - - static let padrstf_offset = UInt32(26) - static let padrstf_mask = UInt32(0b1) &<< padrstf_offset - var padrstf: UInt8 { - get { UInt8((self.rawValue & (RCC.CSR.padrstf_mask)) >> RCC.CSR.padrstf_offset) } - set { - let preserve = self.rawValue & ~RCC.CSR.padrstf_mask - let shift = (UInt32(newValue) << RCC.CSR.padrstf_offset) & RCC.CSR.padrstf_mask - self.rawValue = preserve | shift - } - } - - static let borrstf_offset = UInt32(25) - static let borrstf_mask = UInt32(0b1) &<< borrstf_offset - var borrstf: UInt8 { - get { UInt8((self.rawValue & (RCC.CSR.borrstf_mask)) >> RCC.CSR.borrstf_offset) } - set { - let preserve = self.rawValue & ~RCC.CSR.borrstf_mask - let shift = (UInt32(newValue) << RCC.CSR.borrstf_offset) & RCC.CSR.borrstf_mask - self.rawValue = preserve | shift - } - } - - static let rmvf_offset = UInt32(24) - static let rmvf_mask = UInt32(0b1) &<< rmvf_offset - var rmvf: UInt8 { - get { UInt8((self.rawValue & (RCC.CSR.rmvf_mask)) >> RCC.CSR.rmvf_offset) } - set { - let preserve = self.rawValue & ~RCC.CSR.rmvf_mask - let shift = (UInt32(newValue) << RCC.CSR.rmvf_offset) & RCC.CSR.rmvf_mask - self.rawValue = preserve | shift - } - } - - static let lsirdy_offset = UInt32(1) - static let lsirdy_mask = UInt32(0b1) &<< lsirdy_offset - var lsirdy: UInt8 { - UInt8((self.rawValue & (RCC.CSR.lsirdy_mask)) >> RCC.CSR.lsirdy_offset) - } - - static let lsion_offset = UInt32(0) - static let lsion_mask = UInt32(0b1) &<< lsion_offset - var lsion: UInt8 { - get { UInt8((self.rawValue & (RCC.CSR.lsion_mask)) >> RCC.CSR.lsion_offset) } - set { - let preserve = self.rawValue & ~RCC.CSR.lsion_mask - let shift = (UInt32(newValue) << RCC.CSR.lsion_offset) & RCC.CSR.lsion_mask - self.rawValue = preserve | shift - } - } - - init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - struct SSCGR { - var rawValue: UInt32 - - static let sscgen_offset = UInt32(31) - static let sscgen_mask = UInt32(0b1) &<< sscgen_offset - var sscgen: UInt8 { - get { UInt8((self.rawValue & (RCC.SSCGR.sscgen_mask)) >> RCC.SSCGR.sscgen_offset) } - set { - let preserve = self.rawValue & ~RCC.SSCGR.sscgen_mask - let shift = (UInt32(newValue) << RCC.SSCGR.sscgen_offset) & RCC.SSCGR.sscgen_mask - self.rawValue = preserve | shift - } - } - - static let spreadsel_offset = UInt32(30) - static let spreadsel_mask = UInt32(0b1) &<< spreadsel_offset - var spreadsel: UInt8 { - get { UInt8((self.rawValue & (RCC.SSCGR.spreadsel_mask)) >> RCC.SSCGR.spreadsel_offset) } - set { - let preserve = self.rawValue & ~RCC.SSCGR.spreadsel_mask - let shift = (UInt32(newValue) << RCC.SSCGR.spreadsel_offset) & RCC.SSCGR.spreadsel_mask - self.rawValue = preserve | shift - } - } - - static let incstep_offset = UInt32(13) - static let incstep_mask = UInt32(0b111111111111111) &<< incstep_offset - var incstep: UInt16 { - get { UInt16((self.rawValue & (RCC.SSCGR.incstep_mask)) >> RCC.SSCGR.incstep_offset) } - set { - let preserve = self.rawValue & ~RCC.SSCGR.incstep_mask - let shift = (UInt32(newValue) << RCC.SSCGR.incstep_offset) & RCC.SSCGR.incstep_mask - self.rawValue = preserve | shift - } - } - - static let modper_offset = UInt32(0) - static let modper_mask = UInt32(0b1111111111111) &<< modper_offset - var modper: UInt16 { - get { UInt16((self.rawValue & (RCC.SSCGR.modper_mask)) >> RCC.SSCGR.modper_offset) } - set { - let preserve = self.rawValue & ~RCC.SSCGR.modper_mask - let shift = (UInt32(newValue) << RCC.SSCGR.modper_offset) & RCC.SSCGR.modper_mask - self.rawValue = preserve | shift - } - } - - init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - struct PLLI2SCFGR { - var rawValue: UInt32 - - static let plli2sr_offset = UInt32(28) - static let plli2sr_mask = UInt32(0b111) &<< plli2sr_offset - var plli2sr: UInt8 { - get { UInt8((self.rawValue & (RCC.PLLI2SCFGR.plli2sr_mask)) >> RCC.PLLI2SCFGR.plli2sr_offset) } - set { - let preserve = self.rawValue & ~RCC.PLLI2SCFGR.plli2sr_mask - let shift = (UInt32(newValue) << RCC.PLLI2SCFGR.plli2sr_offset) & RCC.PLLI2SCFGR.plli2sr_mask - self.rawValue = preserve | shift - } - } - - static let plli2sq_offset = UInt32(24) - static let plli2sq_mask = UInt32(0b1111) &<< plli2sq_offset - var plli2sq: UInt8 { - get { UInt8((self.rawValue & (RCC.PLLI2SCFGR.plli2sq_mask)) >> RCC.PLLI2SCFGR.plli2sq_offset) } - set { - let preserve = self.rawValue & ~RCC.PLLI2SCFGR.plli2sq_mask - let shift = (UInt32(newValue) << RCC.PLLI2SCFGR.plli2sq_offset) & RCC.PLLI2SCFGR.plli2sq_mask - self.rawValue = preserve | shift - } - } - - static let plli2sn_offset = UInt32(6) - static let plli2sn_mask = UInt32(0b111111111) &<< plli2sn_offset - var plli2sn: UInt16 { - get { UInt16((self.rawValue & (RCC.PLLI2SCFGR.plli2sn_mask)) >> RCC.PLLI2SCFGR.plli2sn_offset) } - set { - let preserve = self.rawValue & ~RCC.PLLI2SCFGR.plli2sn_mask - let shift = (UInt32(newValue) << RCC.PLLI2SCFGR.plli2sn_offset) & RCC.PLLI2SCFGR.plli2sn_mask - self.rawValue = preserve | shift - } - } - - init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - struct PLLSAICFGR { - var rawValue: UInt32 - - static let pllsain_offset = UInt32(6) - static let pllsain_mask = UInt32(0b111111111) &<< pllsain_offset - var pllsain: UInt16 { - get { UInt16((self.rawValue & (RCC.PLLSAICFGR.pllsain_mask)) >> RCC.PLLSAICFGR.pllsain_offset) } - set { - let preserve = self.rawValue & ~RCC.PLLSAICFGR.pllsain_mask - let shift = (UInt32(newValue) << RCC.PLLSAICFGR.pllsain_offset) & RCC.PLLSAICFGR.pllsain_mask - self.rawValue = preserve | shift - } - } - - static let pllsaip_offset = UInt32(16) - static let pllsaip_mask = UInt32(0b11) &<< pllsaip_offset - var pllsaip: UInt8 { - get { UInt8((self.rawValue & (RCC.PLLSAICFGR.pllsaip_mask)) >> RCC.PLLSAICFGR.pllsaip_offset) } - set { - let preserve = self.rawValue & ~RCC.PLLSAICFGR.pllsaip_mask - let shift = (UInt32(newValue) << RCC.PLLSAICFGR.pllsaip_offset) & RCC.PLLSAICFGR.pllsaip_mask - self.rawValue = preserve | shift - } - } - - static let pllsaiq_offset = UInt32(24) - static let pllsaiq_mask = UInt32(0b1111) &<< pllsaiq_offset - var pllsaiq: UInt8 { - get { UInt8((self.rawValue & (RCC.PLLSAICFGR.pllsaiq_mask)) >> RCC.PLLSAICFGR.pllsaiq_offset) } - set { - let preserve = self.rawValue & ~RCC.PLLSAICFGR.pllsaiq_mask - let shift = (UInt32(newValue) << RCC.PLLSAICFGR.pllsaiq_offset) & RCC.PLLSAICFGR.pllsaiq_mask - self.rawValue = preserve | shift - } - } - - static let pllsair_offset = UInt32(28) - static let pllsair_mask = UInt32(0b111) &<< pllsair_offset - var pllsair: UInt8 { - get { UInt8((self.rawValue & (RCC.PLLSAICFGR.pllsair_mask)) >> RCC.PLLSAICFGR.pllsair_offset) } - set { - let preserve = self.rawValue & ~RCC.PLLSAICFGR.pllsair_mask - let shift = (UInt32(newValue) << RCC.PLLSAICFGR.pllsair_offset) & RCC.PLLSAICFGR.pllsair_mask - self.rawValue = preserve | shift - } - } - - init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - struct DKCFGR1 { - var rawValue: UInt32 - - static let plli2sdiv_offset = UInt32(0) - static let plli2sdiv_mask = UInt32(0b11111) &<< plli2sdiv_offset - var plli2sdiv: UInt8 { - get { UInt8((self.rawValue & (RCC.DKCFGR1.plli2sdiv_mask)) >> RCC.DKCFGR1.plli2sdiv_offset) } - set { - let preserve = self.rawValue & ~RCC.DKCFGR1.plli2sdiv_mask - let shift = (UInt32(newValue) << RCC.DKCFGR1.plli2sdiv_offset) & RCC.DKCFGR1.plli2sdiv_mask - self.rawValue = preserve | shift - } - } - - static let pllsaidivq_offset = UInt32(8) - static let pllsaidivq_mask = UInt32(0b11111) &<< pllsaidivq_offset - var pllsaidivq: UInt8 { - get { UInt8((self.rawValue & (RCC.DKCFGR1.pllsaidivq_mask)) >> RCC.DKCFGR1.pllsaidivq_offset) } - set { - let preserve = self.rawValue & ~RCC.DKCFGR1.pllsaidivq_mask - let shift = (UInt32(newValue) << RCC.DKCFGR1.pllsaidivq_offset) & RCC.DKCFGR1.pllsaidivq_mask - self.rawValue = preserve | shift - } - } - - static let pllsaidivr_offset = UInt32(16) - static let pllsaidivr_mask = UInt32(0b11) &<< pllsaidivr_offset - var pllsaidivr: UInt8 { - get { UInt8((self.rawValue & (RCC.DKCFGR1.pllsaidivr_mask)) >> RCC.DKCFGR1.pllsaidivr_offset) } - set { - let preserve = self.rawValue & ~RCC.DKCFGR1.pllsaidivr_mask - let shift = (UInt32(newValue) << RCC.DKCFGR1.pllsaidivr_offset) & RCC.DKCFGR1.pllsaidivr_mask - self.rawValue = preserve | shift - } - } - - static let sai1sel_offset = UInt32(20) - static let sai1sel_mask = UInt32(0b11) &<< sai1sel_offset - var sai1sel: UInt8 { - get { UInt8((self.rawValue & (RCC.DKCFGR1.sai1sel_mask)) >> RCC.DKCFGR1.sai1sel_offset) } - set { - let preserve = self.rawValue & ~RCC.DKCFGR1.sai1sel_mask - let shift = (UInt32(newValue) << RCC.DKCFGR1.sai1sel_offset) & RCC.DKCFGR1.sai1sel_mask - self.rawValue = preserve | shift - } - } - - static let sai2sel_offset = UInt32(22) - static let sai2sel_mask = UInt32(0b11) &<< sai2sel_offset - var sai2sel: UInt8 { - get { UInt8((self.rawValue & (RCC.DKCFGR1.sai2sel_mask)) >> RCC.DKCFGR1.sai2sel_offset) } - set { - let preserve = self.rawValue & ~RCC.DKCFGR1.sai2sel_mask - let shift = (UInt32(newValue) << RCC.DKCFGR1.sai2sel_offset) & RCC.DKCFGR1.sai2sel_mask - self.rawValue = preserve | shift - } - } - - static let timpre_offset = UInt32(24) - static let timpre_mask = UInt32(0b1) &<< timpre_offset - var timpre: UInt8 { - get { UInt8((self.rawValue & (RCC.DKCFGR1.timpre_mask)) >> RCC.DKCFGR1.timpre_offset) } - set { - let preserve = self.rawValue & ~RCC.DKCFGR1.timpre_mask - let shift = (UInt32(newValue) << RCC.DKCFGR1.timpre_offset) & RCC.DKCFGR1.timpre_mask - self.rawValue = preserve | shift - } - } - - init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - struct DKCFGR2 { - var rawValue: UInt32 - - static let usart1sel_offset = UInt32(0) - static let usart1sel_mask = UInt32(0b11) &<< usart1sel_offset - var usart1sel: UInt8 { - get { UInt8((self.rawValue & (RCC.DKCFGR2.usart1sel_mask)) >> RCC.DKCFGR2.usart1sel_offset) } - set { - let preserve = self.rawValue & ~RCC.DKCFGR2.usart1sel_mask - let shift = (UInt32(newValue) << RCC.DKCFGR2.usart1sel_offset) & RCC.DKCFGR2.usart1sel_mask - self.rawValue = preserve | shift - } - } - - static let usart2sel_offset = UInt32(2) - static let usart2sel_mask = UInt32(0b11) &<< usart2sel_offset - var usart2sel: UInt8 { - get { UInt8((self.rawValue & (RCC.DKCFGR2.usart2sel_mask)) >> RCC.DKCFGR2.usart2sel_offset) } - set { - let preserve = self.rawValue & ~RCC.DKCFGR2.usart2sel_mask - let shift = (UInt32(newValue) << RCC.DKCFGR2.usart2sel_offset) & RCC.DKCFGR2.usart2sel_mask - self.rawValue = preserve | shift - } - } - - static let usart3sel_offset = UInt32(4) - static let usart3sel_mask = UInt32(0b11) &<< usart3sel_offset - var usart3sel: UInt8 { - get { UInt8((self.rawValue & (RCC.DKCFGR2.usart3sel_mask)) >> RCC.DKCFGR2.usart3sel_offset) } - set { - let preserve = self.rawValue & ~RCC.DKCFGR2.usart3sel_mask - let shift = (UInt32(newValue) << RCC.DKCFGR2.usart3sel_offset) & RCC.DKCFGR2.usart3sel_mask - self.rawValue = preserve | shift - } - } - - static let uart4sel_offset = UInt32(6) - static let uart4sel_mask = UInt32(0b11) &<< uart4sel_offset - var uart4sel: UInt8 { - get { UInt8((self.rawValue & (RCC.DKCFGR2.uart4sel_mask)) >> RCC.DKCFGR2.uart4sel_offset) } - set { - let preserve = self.rawValue & ~RCC.DKCFGR2.uart4sel_mask - let shift = (UInt32(newValue) << RCC.DKCFGR2.uart4sel_offset) & RCC.DKCFGR2.uart4sel_mask - self.rawValue = preserve | shift - } - } - - static let uart5sel_offset = UInt32(8) - static let uart5sel_mask = UInt32(0b11) &<< uart5sel_offset - var uart5sel: UInt8 { - get { UInt8((self.rawValue & (RCC.DKCFGR2.uart5sel_mask)) >> RCC.DKCFGR2.uart5sel_offset) } - set { - let preserve = self.rawValue & ~RCC.DKCFGR2.uart5sel_mask - let shift = (UInt32(newValue) << RCC.DKCFGR2.uart5sel_offset) & RCC.DKCFGR2.uart5sel_mask - self.rawValue = preserve | shift - } - } - - static let usart6sel_offset = UInt32(10) - static let usart6sel_mask = UInt32(0b11) &<< usart6sel_offset - var usart6sel: UInt8 { - get { UInt8((self.rawValue & (RCC.DKCFGR2.usart6sel_mask)) >> RCC.DKCFGR2.usart6sel_offset) } - set { - let preserve = self.rawValue & ~RCC.DKCFGR2.usart6sel_mask - let shift = (UInt32(newValue) << RCC.DKCFGR2.usart6sel_offset) & RCC.DKCFGR2.usart6sel_mask - self.rawValue = preserve | shift - } - } - - static let uart7sel_offset = UInt32(12) - static let uart7sel_mask = UInt32(0b11) &<< uart7sel_offset - var uart7sel: UInt8 { - get { UInt8((self.rawValue & (RCC.DKCFGR2.uart7sel_mask)) >> RCC.DKCFGR2.uart7sel_offset) } - set { - let preserve = self.rawValue & ~RCC.DKCFGR2.uart7sel_mask - let shift = (UInt32(newValue) << RCC.DKCFGR2.uart7sel_offset) & RCC.DKCFGR2.uart7sel_mask - self.rawValue = preserve | shift - } - } - - static let uart8sel_offset = UInt32(14) - static let uart8sel_mask = UInt32(0b11) &<< uart8sel_offset - var uart8sel: UInt8 { - get { UInt8((self.rawValue & (RCC.DKCFGR2.uart8sel_mask)) >> RCC.DKCFGR2.uart8sel_offset) } - set { - let preserve = self.rawValue & ~RCC.DKCFGR2.uart8sel_mask - let shift = (UInt32(newValue) << RCC.DKCFGR2.uart8sel_offset) & RCC.DKCFGR2.uart8sel_mask - self.rawValue = preserve | shift - } - } - - static let i2c1sel_offset = UInt32(16) - static let i2c1sel_mask = UInt32(0b11) &<< i2c1sel_offset - var i2c1sel: UInt8 { - get { UInt8((self.rawValue & (RCC.DKCFGR2.i2c1sel_mask)) >> RCC.DKCFGR2.i2c1sel_offset) } - set { - let preserve = self.rawValue & ~RCC.DKCFGR2.i2c1sel_mask - let shift = (UInt32(newValue) << RCC.DKCFGR2.i2c1sel_offset) & RCC.DKCFGR2.i2c1sel_mask - self.rawValue = preserve | shift - } - } - - static let i2c2sel_offset = UInt32(18) - static let i2c2sel_mask = UInt32(0b11) &<< i2c2sel_offset - var i2c2sel: UInt8 { - get { UInt8((self.rawValue & (RCC.DKCFGR2.i2c2sel_mask)) >> RCC.DKCFGR2.i2c2sel_offset) } - set { - let preserve = self.rawValue & ~RCC.DKCFGR2.i2c2sel_mask - let shift = (UInt32(newValue) << RCC.DKCFGR2.i2c2sel_offset) & RCC.DKCFGR2.i2c2sel_mask - self.rawValue = preserve | shift - } - } - - static let i2c3sel_offset = UInt32(20) - static let i2c3sel_mask = UInt32(0b11) &<< i2c3sel_offset - var i2c3sel: UInt8 { - get { UInt8((self.rawValue & (RCC.DKCFGR2.i2c3sel_mask)) >> RCC.DKCFGR2.i2c3sel_offset) } - set { - let preserve = self.rawValue & ~RCC.DKCFGR2.i2c3sel_mask - let shift = (UInt32(newValue) << RCC.DKCFGR2.i2c3sel_offset) & RCC.DKCFGR2.i2c3sel_mask - self.rawValue = preserve | shift - } - } - - static let i2c4sel_offset = UInt32(22) - static let i2c4sel_mask = UInt32(0b11) &<< i2c4sel_offset - var i2c4sel: UInt8 { - get { UInt8((self.rawValue & (RCC.DKCFGR2.i2c4sel_mask)) >> RCC.DKCFGR2.i2c4sel_offset) } - set { - let preserve = self.rawValue & ~RCC.DKCFGR2.i2c4sel_mask - let shift = (UInt32(newValue) << RCC.DKCFGR2.i2c4sel_offset) & RCC.DKCFGR2.i2c4sel_mask - self.rawValue = preserve | shift - } - } - - static let lptim1sel_offset = UInt32(24) - static let lptim1sel_mask = UInt32(0b11) &<< lptim1sel_offset - var lptim1sel: UInt8 { - get { UInt8((self.rawValue & (RCC.DKCFGR2.lptim1sel_mask)) >> RCC.DKCFGR2.lptim1sel_offset) } - set { - let preserve = self.rawValue & ~RCC.DKCFGR2.lptim1sel_mask - let shift = (UInt32(newValue) << RCC.DKCFGR2.lptim1sel_offset) & RCC.DKCFGR2.lptim1sel_mask - self.rawValue = preserve | shift - } - } - - static let cecsel_offset = UInt32(26) - static let cecsel_mask = UInt32(0b1) &<< cecsel_offset - var cecsel: UInt8 { - get { UInt8((self.rawValue & (RCC.DKCFGR2.cecsel_mask)) >> RCC.DKCFGR2.cecsel_offset) } - set { - let preserve = self.rawValue & ~RCC.DKCFGR2.cecsel_mask - let shift = (UInt32(newValue) << RCC.DKCFGR2.cecsel_offset) & RCC.DKCFGR2.cecsel_mask - self.rawValue = preserve | shift - } - } - - static let ck48msel_offset = UInt32(27) - static let ck48msel_mask = UInt32(0b1) &<< ck48msel_offset - var ck48msel: UInt8 { - get { UInt8((self.rawValue & (RCC.DKCFGR2.ck48msel_mask)) >> RCC.DKCFGR2.ck48msel_offset) } - set { - let preserve = self.rawValue & ~RCC.DKCFGR2.ck48msel_mask - let shift = (UInt32(newValue) << RCC.DKCFGR2.ck48msel_offset) & RCC.DKCFGR2.ck48msel_mask - self.rawValue = preserve | shift - } - } - - static let sdmmcsel_offset = UInt32(28) - static let sdmmcsel_mask = UInt32(0b1) &<< sdmmcsel_offset - var sdmmcsel: UInt8 { - get { UInt8((self.rawValue & (RCC.DKCFGR2.sdmmcsel_mask)) >> RCC.DKCFGR2.sdmmcsel_offset) } - set { - let preserve = self.rawValue & ~RCC.DKCFGR2.sdmmcsel_mask - let shift = (UInt32(newValue) << RCC.DKCFGR2.sdmmcsel_offset) & RCC.DKCFGR2.sdmmcsel_mask - self.rawValue = preserve | shift - } - } - - init(rawValue: UInt32) { - self.rawValue = rawValue - } - } -} diff --git a/stm32-lcd-logo/Sources/Application/Registers/Device.swift b/stm32-lcd-logo/Sources/Application/Registers/Device.swift new file mode 100644 index 00000000..992bf558 --- /dev/null +++ b/stm32-lcd-logo/Sources/Application/Registers/Device.swift @@ -0,0 +1,45 @@ +// Generated by svd2swift. + +import MMIO + +/// FLASH +let flash = FLASH(unsafeAddress: 0x40023c00) + +/// General-purpose I/Os +let gpioa = GPIOA(unsafeAddress: 0x40020000) + +/// General-purpose I/Os +let gpiob = GPIOB(unsafeAddress: 0x40020400) + +/// General-purpose I/Os +let gpioc = GPIOC(unsafeAddress: 0x40020800) + +/// General-purpose I/Os +let gpiod = GPIOD(unsafeAddress: 0x40020c00) + +/// General-purpose I/Os +let gpioe = GPIOE(unsafeAddress: 0x40021000) + +/// General-purpose I/Os +let gpiof = GPIOF(unsafeAddress: 0x40021400) + +/// General-purpose I/Os +let gpiog = GPIOG(unsafeAddress: 0x40021800) + +/// General-purpose I/Os +let gpioh = GPIOH(unsafeAddress: 0x40021c00) + +/// General-purpose I/Os +let gpioi = GPIOI(unsafeAddress: 0x40022000) + +/// General-purpose I/Os +let gpioj = GPIOJ(unsafeAddress: 0x40022400) + +/// General-purpose I/Os +let gpiok = GPIOK(unsafeAddress: 0x40022800) + +/// LCD-TFT Controller +let ltdc = LTDC(unsafeAddress: 0x40016800) + +/// Reset and clock control +let rcc = RCC(unsafeAddress: 0x40023800) diff --git a/stm32-lcd-logo/Sources/Application/Registers/FLASH.swift b/stm32-lcd-logo/Sources/Application/Registers/FLASH.swift new file mode 100644 index 00000000..ddca3de8 --- /dev/null +++ b/stm32-lcd-logo/Sources/Application/Registers/FLASH.swift @@ -0,0 +1,469 @@ +// Generated by svd2swift. + +import MMIO + +/// FLASH +@RegisterBlock +struct FLASH { + /// Flash access control register + @RegisterBlock(offset: 0x0) + var acr: Register + + /// Flash key register + @RegisterBlock(offset: 0x4) + var keyr: Register + + /// Flash option key register + @RegisterBlock(offset: 0x8) + var optkeyr: Register + + /// Status register + @RegisterBlock(offset: 0xc) + var sr: Register + + /// Control register + @RegisterBlock(offset: 0x10) + var cr: Register + + /// Flash option control register + @RegisterBlock(offset: 0x14) + var optcr: Register + + /// Flash option control register 1 + @RegisterBlock(offset: 0x18) + var optcr1: Register +} + +extension FLASH { + /// Flash access control register + @Register(bitWidth: 32) + struct ACR { + /// Latency + @ReadWrite(bits: 0..<4, as: LATENCYValues.self) + var latency: LATENCY + + /// Prefetch enable + @ReadWrite(bits: 8..<9, as: PRFTENValues.self) + var prften: PRFTEN + + /// ART Accelerator Enable + @ReadWrite(bits: 9..<10, as: ARTENValues.self) + var arten: ARTEN + + /// ART Accelerator reset + @ReadWrite(bits: 11..<12, as: ARTRSTValues.self) + var artrst: ARTRST + } + + /// Flash key register + @Register(bitWidth: 32) + struct KEYR { + /// FPEC key + @WriteOnly(bits: 0..<32) + var key: KEY + } + + /// Flash option key register + @Register(bitWidth: 32) + struct OPTKEYR { + /// Option byte key + @WriteOnly(bits: 0..<32) + var optkeyr_field: OPTKEYR_FIELD + } + + /// Status register + @Register(bitWidth: 32) + struct SR { + /// End of operation + @ReadWrite(bits: 0..<1) + var eop: EOP + + /// Operation error + @ReadWrite(bits: 1..<2) + var operr: OPERR + + /// Write protection error + @ReadWrite(bits: 4..<5) + var wrperr: WRPERR + + /// Programming alignment error + @ReadWrite(bits: 5..<6) + var pgaerr: PGAERR + + /// Programming parallelism error + @ReadWrite(bits: 6..<7) + var pgperr: PGPERR + + /// Programming sequence error + @ReadWrite(bits: 7..<8) + var erserr: ERSERR + + /// Busy + @ReadOnly(bits: 16..<17) + var bsy: BSY + } + + /// Control register + @Register(bitWidth: 32) + struct CR { + /// Programming + @ReadWrite(bits: 0..<1, as: PGValues.self) + var pg: PG + + /// Sector Erase + @ReadWrite(bits: 1..<2, as: SERValues.self) + var ser: SER + + /// Mass Erase of sectors 0 to 11 + @ReadWrite(bits: 2..<3, as: MERValues.self) + var mer: MER + + /// Sector number + @ReadWrite(bits: 3..<7) + var snb: SNB + + /// Program size + @ReadWrite(bits: 8..<10, as: PSIZEValues.self) + var psize: PSIZE + + /// Start + @ReadWrite(bits: 16..<17, as: STRTValues.self) + var strt: STRT + + /// End of operation interrupt enable + @ReadWrite(bits: 24..<25, as: EOPIEValues.self) + var eopie: EOPIE + + /// Error interrupt enable + @ReadWrite(bits: 25..<26, as: ERRIEValues.self) + var errie: ERRIE + + /// Lock + @ReadWrite(bits: 31..<32, as: LOCKValues.self) + var lock: LOCK + } + + /// Flash option control register + @Register(bitWidth: 32) + struct OPTCR { + /// Option lock + @ReadWrite(bits: 0..<1) + var optlock: OPTLOCK + + /// Option start + @ReadWrite(bits: 1..<2) + var optstrt: OPTSTRT + + /// BOR reset Level + @ReadWrite(bits: 2..<4) + var bor_lev: BOR_LEV + + /// User option bytes + @ReadWrite(bits: 4..<5) + var wwdg_sw: WWDG_SW + + /// User option bytes + @ReadWrite(bits: 5..<6) + var iwdg_sw: IWDG_SW + + /// User option bytes + @ReadWrite(bits: 6..<7) + var nrst_stop: nRST_STOP + + /// User option bytes + @ReadWrite(bits: 7..<8) + var nrst_stdby: nRST_STDBY + + /// Read protect + @ReadWrite(bits: 8..<16) + var rdp: RDP + + /// Not write protect + @ReadWrite(bits: 16..<24) + var nwrp: nWRP + + /// Independent watchdog counter freeze in standby mode + @ReadWrite(bits: 30..<31) + var iwdg_stdby: IWDG_STDBY + + /// Independent watchdog counter freeze in Stop mode + @ReadWrite(bits: 31..<32) + var iwdg_stop: IWDG_STOP + } + + /// Flash option control register 1 + @Register(bitWidth: 32) + struct OPTCR1 { + /// Boot base address when Boot pin =0 + @ReadWrite(bits: 0..<16) + var boot_add0: BOOT_ADD0 + + /// Boot base address when Boot pin =1 + @ReadWrite(bits: 16..<32) + var boot_add1: BOOT_ADD1 + } +} + +extension FLASH.ACR { + struct LATENCYValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 4 + + /// 0 wait states + static let WS0 = Self(rawValue: 0x0) + + /// 1 wait states + static let WS1 = Self(rawValue: 0x1) + + /// 2 wait states + static let WS2 = Self(rawValue: 0x2) + + /// 3 wait states + static let WS3 = Self(rawValue: 0x3) + + /// 4 wait states + static let WS4 = Self(rawValue: 0x4) + + /// 5 wait states + static let WS5 = Self(rawValue: 0x5) + + /// 6 wait states + static let WS6 = Self(rawValue: 0x6) + + /// 7 wait states + static let WS7 = Self(rawValue: 0x7) + + /// 8 wait states + static let WS8 = Self(rawValue: 0x8) + + /// 9 wait states + static let WS9 = Self(rawValue: 0x9) + + /// 10 wait states + static let WS10 = Self(rawValue: 0xa) + + /// 11 wait states + static let WS11 = Self(rawValue: 0xb) + + /// 12 wait states + static let WS12 = Self(rawValue: 0xc) + + /// 13 wait states + static let WS13 = Self(rawValue: 0xd) + + /// 14 wait states + static let WS14 = Self(rawValue: 0xe) + + /// 15 wait states + static let WS15 = Self(rawValue: 0xf) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension FLASH.ACR { + struct PRFTENValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// Prefetch is disabled + static let Disabled = Self(rawValue: 0x0) + + /// Prefetch is enabled + static let Enabled = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension FLASH.ACR { + struct ARTENValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// ART Accelerator is disabled + static let Disabled = Self(rawValue: 0x0) + + /// ART Accelerator is enabled + static let Enabled = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension FLASH.ACR { + struct ARTRSTValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// Accelerator is not reset + static let NotReset = Self(rawValue: 0x0) + + /// Accelerator is reset + static let Reset = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension FLASH.CR { + struct PGValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// Flash programming activated + static let Program = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension FLASH.CR { + struct SERValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// Erase activated for selected sector + static let SectorErase = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension FLASH.CR { + struct MERValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// Erase activated for all user sectors + static let MassErase = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension FLASH.CR { + struct PSIZEValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 2 + + /// Program x8 + static let PSIZE8 = Self(rawValue: 0x0) + + /// Program x16 + static let PSIZE16 = Self(rawValue: 0x1) + + /// Program x32 + static let PSIZE32 = Self(rawValue: 0x2) + + /// Program x64 + static let PSIZE64 = Self(rawValue: 0x3) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension FLASH.CR { + struct STRTValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// Trigger an erase operation + static let Start = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension FLASH.CR { + struct EOPIEValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// End of operation interrupt disabled + static let Disabled = Self(rawValue: 0x0) + + /// End of operation interrupt enabled + static let Enabled = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension FLASH.CR { + struct ERRIEValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// Error interrupt generation disabled + static let Disabled = Self(rawValue: 0x0) + + /// Error interrupt generation enabled + static let Enabled = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension FLASH.CR { + struct LOCKValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// FLASH_CR register is unlocked + static let Unlocked = Self(rawValue: 0x0) + + /// FLASH_CR register is locked + static let Locked = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} diff --git a/stm32-lcd-logo/Sources/Application/Registers/GPIOA.swift b/stm32-lcd-logo/Sources/Application/Registers/GPIOA.swift new file mode 100644 index 00000000..3bc4d2ff --- /dev/null +++ b/stm32-lcd-logo/Sources/Application/Registers/GPIOA.swift @@ -0,0 +1,1075 @@ +// Generated by svd2swift. + +import MMIO + +/// General-purpose I/Os +@RegisterBlock +struct GPIOA { + /// GPIO port mode register + @RegisterBlock(offset: 0x0) + var moder: Register + + /// GPIO port output type register + @RegisterBlock(offset: 0x4) + var otyper: Register + + /// GPIO port output speed register + @RegisterBlock(offset: 0x8) + var ospeedr: Register + + /// GPIO port pull-up/pull-down register + @RegisterBlock(offset: 0xc) + var pupdr: Register + + /// GPIO port input data register + @RegisterBlock(offset: 0x10) + var idr: Register + + /// GPIO port output data register + @RegisterBlock(offset: 0x14) + var odr: Register + + /// GPIO port bit set/reset register + @RegisterBlock(offset: 0x18) + var bsrr: Register + + /// GPIO port configuration lock register + @RegisterBlock(offset: 0x1c) + var lckr: Register + + /// GPIO alternate function low register + @RegisterBlock(offset: 0x20) + var afrl: Register + + /// GPIO alternate function high register + @RegisterBlock(offset: 0x24) + var afrh: Register + + /// GPIO port bit reset register + @RegisterBlock(offset: 0x28) + var brr: Register +} + +extension GPIOA { + /// GPIO port mode register + @Register(bitWidth: 32) + struct MODER { + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 30..<32) + var moder15: MODER15 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 28..<30) + var moder14: MODER14 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 26..<28) + var moder13: MODER13 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 24..<26) + var moder12: MODER12 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 22..<24) + var moder11: MODER11 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 20..<22) + var moder10: MODER10 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 18..<20) + var moder9: MODER9 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 16..<18) + var moder8: MODER8 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 14..<16) + var moder7: MODER7 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 12..<14) + var moder6: MODER6 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 10..<12) + var moder5: MODER5 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 8..<10) + var moder4: MODER4 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 6..<8) + var moder3: MODER3 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 4..<6) + var moder2: MODER2 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 2..<4) + var moder1: MODER1 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 0..<2, as: MODER0Values.self) + var moder0: MODER0 + } + + /// GPIO port output type register + @Register(bitWidth: 32) + struct OTYPER { + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 15..<16) + var ot15: OT15 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 14..<15) + var ot14: OT14 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 13..<14) + var ot13: OT13 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 12..<13) + var ot12: OT12 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 11..<12) + var ot11: OT11 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 10..<11) + var ot10: OT10 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 9..<10) + var ot9: OT9 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 8..<9) + var ot8: OT8 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 7..<8) + var ot7: OT7 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 6..<7) + var ot6: OT6 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 5..<6) + var ot5: OT5 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 4..<5) + var ot4: OT4 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 3..<4) + var ot3: OT3 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 2..<3) + var ot2: OT2 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 1..<2) + var ot1: OT1 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 0..<1, as: OT0Values.self) + var ot0: OT0 + } + + /// GPIO port output speed register + @Register(bitWidth: 32) + struct OSPEEDR { + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 30..<32) + var ospeedr15: OSPEEDR15 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 28..<30) + var ospeedr14: OSPEEDR14 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 26..<28) + var ospeedr13: OSPEEDR13 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 24..<26) + var ospeedr12: OSPEEDR12 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 22..<24) + var ospeedr11: OSPEEDR11 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 20..<22) + var ospeedr10: OSPEEDR10 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 18..<20) + var ospeedr9: OSPEEDR9 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 16..<18) + var ospeedr8: OSPEEDR8 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 14..<16) + var ospeedr7: OSPEEDR7 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 12..<14) + var ospeedr6: OSPEEDR6 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 10..<12) + var ospeedr5: OSPEEDR5 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 8..<10) + var ospeedr4: OSPEEDR4 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 6..<8) + var ospeedr3: OSPEEDR3 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 4..<6) + var ospeedr2: OSPEEDR2 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 2..<4) + var ospeedr1: OSPEEDR1 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 0..<2, as: OSPEEDR0Values.self) + var ospeedr0: OSPEEDR0 + } + + /// GPIO port pull-up/pull-down register + @Register(bitWidth: 32) + struct PUPDR { + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 30..<32) + var pupdr15: PUPDR15 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 28..<30) + var pupdr14: PUPDR14 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 26..<28) + var pupdr13: PUPDR13 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 24..<26) + var pupdr12: PUPDR12 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 22..<24) + var pupdr11: PUPDR11 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 20..<22) + var pupdr10: PUPDR10 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 18..<20) + var pupdr9: PUPDR9 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 16..<18) + var pupdr8: PUPDR8 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 14..<16) + var pupdr7: PUPDR7 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 12..<14) + var pupdr6: PUPDR6 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 10..<12) + var pupdr5: PUPDR5 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 8..<10) + var pupdr4: PUPDR4 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 6..<8) + var pupdr3: PUPDR3 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 4..<6) + var pupdr2: PUPDR2 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 2..<4) + var pupdr1: PUPDR1 + + /// Port x configuration bits (y = 0..15) + @ReadWrite(bits: 0..<2, as: PUPDR0Values.self) + var pupdr0: PUPDR0 + } + + /// GPIO port input data register + @Register(bitWidth: 32) + struct IDR { + /// Port input data (y = 0..15) + @ReadOnly(bits: 15..<16) + var idr15: IDR15 + + /// Port input data (y = 0..15) + @ReadOnly(bits: 14..<15) + var idr14: IDR14 + + /// Port input data (y = 0..15) + @ReadOnly(bits: 13..<14) + var idr13: IDR13 + + /// Port input data (y = 0..15) + @ReadOnly(bits: 12..<13) + var idr12: IDR12 + + /// Port input data (y = 0..15) + @ReadOnly(bits: 11..<12) + var idr11: IDR11 + + /// Port input data (y = 0..15) + @ReadOnly(bits: 10..<11) + var idr10: IDR10 + + /// Port input data (y = 0..15) + @ReadOnly(bits: 9..<10) + var idr9: IDR9 + + /// Port input data (y = 0..15) + @ReadOnly(bits: 8..<9) + var idr8: IDR8 + + /// Port input data (y = 0..15) + @ReadOnly(bits: 7..<8) + var idr7: IDR7 + + /// Port input data (y = 0..15) + @ReadOnly(bits: 6..<7) + var idr6: IDR6 + + /// Port input data (y = 0..15) + @ReadOnly(bits: 5..<6) + var idr5: IDR5 + + /// Port input data (y = 0..15) + @ReadOnly(bits: 4..<5) + var idr4: IDR4 + + /// Port input data (y = 0..15) + @ReadOnly(bits: 3..<4) + var idr3: IDR3 + + /// Port input data (y = 0..15) + @ReadOnly(bits: 2..<3) + var idr2: IDR2 + + /// Port input data (y = 0..15) + @ReadOnly(bits: 1..<2) + var idr1: IDR1 + + /// Port input data (y = 0..15) + @ReadOnly(bits: 0..<1) + var idr0: IDR0 + } + + /// GPIO port output data register + @Register(bitWidth: 32) + struct ODR { + /// Port output data (y = 0..15) + @ReadWrite(bits: 15..<16) + var odr15: ODR15 + + /// Port output data (y = 0..15) + @ReadWrite(bits: 14..<15) + var odr14: ODR14 + + /// Port output data (y = 0..15) + @ReadWrite(bits: 13..<14) + var odr13: ODR13 + + /// Port output data (y = 0..15) + @ReadWrite(bits: 12..<13) + var odr12: ODR12 + + /// Port output data (y = 0..15) + @ReadWrite(bits: 11..<12) + var odr11: ODR11 + + /// Port output data (y = 0..15) + @ReadWrite(bits: 10..<11) + var odr10: ODR10 + + /// Port output data (y = 0..15) + @ReadWrite(bits: 9..<10) + var odr9: ODR9 + + /// Port output data (y = 0..15) + @ReadWrite(bits: 8..<9) + var odr8: ODR8 + + /// Port output data (y = 0..15) + @ReadWrite(bits: 7..<8) + var odr7: ODR7 + + /// Port output data (y = 0..15) + @ReadWrite(bits: 6..<7) + var odr6: ODR6 + + /// Port output data (y = 0..15) + @ReadWrite(bits: 5..<6) + var odr5: ODR5 + + /// Port output data (y = 0..15) + @ReadWrite(bits: 4..<5) + var odr4: ODR4 + + /// Port output data (y = 0..15) + @ReadWrite(bits: 3..<4) + var odr3: ODR3 + + /// Port output data (y = 0..15) + @ReadWrite(bits: 2..<3) + var odr2: ODR2 + + /// Port output data (y = 0..15) + @ReadWrite(bits: 1..<2) + var odr1: ODR1 + + /// Port output data (y = 0..15) + @ReadWrite(bits: 0..<1, as: ODR0Values.self) + var odr0: ODR0 + } + + /// GPIO port bit set/reset register + @Register(bitWidth: 32) + struct BSRR { + /// Port x reset bit y (y = 0..15) + @WriteOnly(bits: 31..<32) + var br15: BR15 + + /// Port x reset bit y (y = 0..15) + @WriteOnly(bits: 30..<31) + var br14: BR14 + + /// Port x reset bit y (y = 0..15) + @WriteOnly(bits: 29..<30) + var br13: BR13 + + /// Port x reset bit y (y = 0..15) + @WriteOnly(bits: 28..<29) + var br12: BR12 + + /// Port x reset bit y (y = 0..15) + @WriteOnly(bits: 27..<28) + var br11: BR11 + + /// Port x reset bit y (y = 0..15) + @WriteOnly(bits: 26..<27) + var br10: BR10 + + /// Port x reset bit y (y = 0..15) + @WriteOnly(bits: 25..<26) + var br9: BR9 + + /// Port x reset bit y (y = 0..15) + @WriteOnly(bits: 24..<25) + var br8: BR8 + + /// Port x reset bit y (y = 0..15) + @WriteOnly(bits: 23..<24) + var br7: BR7 + + /// Port x reset bit y (y = 0..15) + @WriteOnly(bits: 22..<23) + var br6: BR6 + + /// Port x reset bit y (y = 0..15) + @WriteOnly(bits: 21..<22) + var br5: BR5 + + /// Port x reset bit y (y = 0..15) + @WriteOnly(bits: 20..<21) + var br4: BR4 + + /// Port x reset bit y (y = 0..15) + @WriteOnly(bits: 19..<20) + var br3: BR3 + + /// Port x reset bit y (y = 0..15) + @WriteOnly(bits: 18..<19) + var br2: BR2 + + /// Port x reset bit y (y = 0..15) + @WriteOnly(bits: 17..<18) + var br1: BR1 + + /// Port x set bit y (y= 0..15) + @WriteOnly(bits: 16..<17) + var br0: BR0 + + /// Port x set bit y (y= 0..15) + @WriteOnly(bits: 15..<16) + var bs15: BS15 + + /// Port x set bit y (y= 0..15) + @WriteOnly(bits: 14..<15) + var bs14: BS14 + + /// Port x set bit y (y= 0..15) + @WriteOnly(bits: 13..<14) + var bs13: BS13 + + /// Port x set bit y (y= 0..15) + @WriteOnly(bits: 12..<13) + var bs12: BS12 + + /// Port x set bit y (y= 0..15) + @WriteOnly(bits: 11..<12) + var bs11: BS11 + + /// Port x set bit y (y= 0..15) + @WriteOnly(bits: 10..<11) + var bs10: BS10 + + /// Port x set bit y (y= 0..15) + @WriteOnly(bits: 9..<10) + var bs9: BS9 + + /// Port x set bit y (y= 0..15) + @WriteOnly(bits: 8..<9) + var bs8: BS8 + + /// Port x set bit y (y= 0..15) + @WriteOnly(bits: 7..<8) + var bs7: BS7 + + /// Port x set bit y (y= 0..15) + @WriteOnly(bits: 6..<7) + var bs6: BS6 + + /// Port x set bit y (y= 0..15) + @WriteOnly(bits: 5..<6) + var bs5: BS5 + + /// Port x set bit y (y= 0..15) + @WriteOnly(bits: 4..<5) + var bs4: BS4 + + /// Port x set bit y (y= 0..15) + @WriteOnly(bits: 3..<4) + var bs3: BS3 + + /// Port x set bit y (y= 0..15) + @WriteOnly(bits: 2..<3) + var bs2: BS2 + + /// Port x set bit y (y= 0..15) + @WriteOnly(bits: 1..<2) + var bs1: BS1 + + /// Port x set bit y (y= 0..15) + @WriteOnly(bits: 0..<1) + var bs0: BS0 + } + + /// GPIO port configuration lock register + @Register(bitWidth: 32) + struct LCKR { + /// Port x lock bit y (y= 0..15) + @ReadWrite(bits: 16..<17, as: LCKKValues.self) + var lckk: LCKK + + /// Port x lock bit y (y= 0..15) + @ReadWrite(bits: 15..<16) + var lck15: LCK15 + + /// Port x lock bit y (y= 0..15) + @ReadWrite(bits: 14..<15) + var lck14: LCK14 + + /// Port x lock bit y (y= 0..15) + @ReadWrite(bits: 13..<14) + var lck13: LCK13 + + /// Port x lock bit y (y= 0..15) + @ReadWrite(bits: 12..<13) + var lck12: LCK12 + + /// Port x lock bit y (y= 0..15) + @ReadWrite(bits: 11..<12) + var lck11: LCK11 + + /// Port x lock bit y (y= 0..15) + @ReadWrite(bits: 10..<11) + var lck10: LCK10 + + /// Port x lock bit y (y= 0..15) + @ReadWrite(bits: 9..<10) + var lck9: LCK9 + + /// Port x lock bit y (y= 0..15) + @ReadWrite(bits: 8..<9) + var lck8: LCK8 + + /// Port x lock bit y (y= 0..15) + @ReadWrite(bits: 7..<8) + var lck7: LCK7 + + /// Port x lock bit y (y= 0..15) + @ReadWrite(bits: 6..<7) + var lck6: LCK6 + + /// Port x lock bit y (y= 0..15) + @ReadWrite(bits: 5..<6) + var lck5: LCK5 + + /// Port x lock bit y (y= 0..15) + @ReadWrite(bits: 4..<5) + var lck4: LCK4 + + /// Port x lock bit y (y= 0..15) + @ReadWrite(bits: 3..<4) + var lck3: LCK3 + + /// Port x lock bit y (y= 0..15) + @ReadWrite(bits: 2..<3) + var lck2: LCK2 + + /// Port x lock bit y (y= 0..15) + @ReadWrite(bits: 1..<2) + var lck1: LCK1 + + /// Port x lock bit y (y= 0..15) + @ReadWrite(bits: 0..<1, as: LCK0Values.self) + var lck0: LCK0 + } + + /// GPIO alternate function low register + @Register(bitWidth: 32) + struct AFRL { + /// Alternate function selection for port x bit y (y = 0..7) + @ReadWrite(bits: 28..<32) + var afrl7: AFRL7 + + /// Alternate function selection for port x bit y (y = 0..7) + @ReadWrite(bits: 24..<28) + var afrl6: AFRL6 + + /// Alternate function selection for port x bit y (y = 0..7) + @ReadWrite(bits: 20..<24) + var afrl5: AFRL5 + + /// Alternate function selection for port x bit y (y = 0..7) + @ReadWrite(bits: 16..<20) + var afrl4: AFRL4 + + /// Alternate function selection for port x bit y (y = 0..7) + @ReadWrite(bits: 12..<16) + var afrl3: AFRL3 + + /// Alternate function selection for port x bit y (y = 0..7) + @ReadWrite(bits: 8..<12) + var afrl2: AFRL2 + + /// Alternate function selection for port x bit y (y = 0..7) + @ReadWrite(bits: 4..<8) + var afrl1: AFRL1 + + /// Alternate function selection for port x bit y (y = 0..7) + @ReadWrite(bits: 0..<4, as: AFRL0Values.self) + var afrl0: AFRL0 + } + + /// GPIO alternate function high register + @Register(bitWidth: 32) + struct AFRH { + /// Alternate function selection for port x bit y (y = 8..15) + @ReadWrite(bits: 28..<32) + var afrh15: AFRH15 + + /// Alternate function selection for port x bit y (y = 8..15) + @ReadWrite(bits: 24..<28) + var afrh14: AFRH14 + + /// Alternate function selection for port x bit y (y = 8..15) + @ReadWrite(bits: 20..<24) + var afrh13: AFRH13 + + /// Alternate function selection for port x bit y (y = 8..15) + @ReadWrite(bits: 16..<20) + var afrh12: AFRH12 + + /// Alternate function selection for port x bit y (y = 8..15) + @ReadWrite(bits: 12..<16) + var afrh11: AFRH11 + + /// Alternate function selection for port x bit y (y = 8..15) + @ReadWrite(bits: 8..<12) + var afrh10: AFRH10 + + /// Alternate function selection for port x bit y (y = 8..15) + @ReadWrite(bits: 4..<8) + var afrh9: AFRH9 + + /// Alternate function selection for port x bit y (y = 8..15) + @ReadWrite(bits: 0..<4, as: AFRH8Values.self) + var afrh8: AFRH8 + } + + /// GPIO port bit reset register + @Register(bitWidth: 32) + struct BRR { + /// Port A Reset bit 0 + @ReadWrite(bits: 0..<1) + var br0: BR0 + + /// Port A Reset bit 1 + @ReadWrite(bits: 1..<2) + var br1: BR1 + + /// Port A Reset bit 2 + @ReadWrite(bits: 2..<3) + var br2: BR2 + + /// Port A Reset bit 3 + @ReadWrite(bits: 3..<4) + var br3: BR3 + + /// Port A Reset bit 4 + @ReadWrite(bits: 4..<5) + var br4: BR4 + + /// Port A Reset bit 5 + @ReadWrite(bits: 5..<6) + var br5: BR5 + + /// Port A Reset bit 6 + @ReadWrite(bits: 6..<7) + var br6: BR6 + + /// Port A Reset bit 7 + @ReadWrite(bits: 7..<8) + var br7: BR7 + + /// Port A Reset bit 8 + @ReadWrite(bits: 8..<9) + var br8: BR8 + + /// Port A Reset bit 9 + @ReadWrite(bits: 9..<10) + var br9: BR9 + + /// Port A Reset bit 10 + @ReadWrite(bits: 10..<11) + var br10: BR10 + + /// Port A Reset bit 11 + @ReadWrite(bits: 11..<12) + var br11: BR11 + + /// Port A Reset bit 12 + @ReadWrite(bits: 12..<13) + var br12: BR12 + + /// Port A Reset bit 13 + @ReadWrite(bits: 13..<14) + var br13: BR13 + + /// Port A Reset bit 14 + @ReadWrite(bits: 14..<15) + var br14: BR14 + + /// Port A Reset bit 15 + @ReadWrite(bits: 15..<16) + var br15: BR15 + } +} + +extension GPIOA.MODER { + struct MODER0Values: BitFieldProjectable, RawRepresentable { + static let bitWidth = 2 + + /// Input mode (reset state) + static let Input = Self(rawValue: 0x0) + + /// General purpose output mode + static let Output = Self(rawValue: 0x1) + + /// Alternate function mode + static let Alternate = Self(rawValue: 0x2) + + /// Analog mode + static let Analog = Self(rawValue: 0x3) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension GPIOA.OTYPER { + struct OT0Values: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// Output push-pull (reset state) + static let PushPull = Self(rawValue: 0x0) + + /// Output open-drain + static let OpenDrain = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension GPIOA.OSPEEDR { + struct OSPEEDR0Values: BitFieldProjectable, RawRepresentable { + static let bitWidth = 2 + + /// Low speed + static let LowSpeed = Self(rawValue: 0x0) + + /// Medium speed + static let MediumSpeed = Self(rawValue: 0x1) + + /// High speed + static let HighSpeed = Self(rawValue: 0x2) + + /// Very high speed + static let VeryHighSpeed = Self(rawValue: 0x3) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension GPIOA.PUPDR { + struct PUPDR0Values: BitFieldProjectable, RawRepresentable { + static let bitWidth = 2 + + /// No pull-up, pull-down + static let Floating = Self(rawValue: 0x0) + + /// Pull-up + static let PullUp = Self(rawValue: 0x1) + + /// Pull-down + static let PullDown = Self(rawValue: 0x2) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension GPIOA.ODR { + struct ODR0Values: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// Set output to logic low + static let Low = Self(rawValue: 0x0) + + /// Set output to logic high + static let High = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension GPIOA.LCKR { + struct LCKKValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// Port configuration lock key not active + static let NotActive = Self(rawValue: 0x0) + + /// Port configuration lock key active + static let Active = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension GPIOA.LCKR { + struct LCK0Values: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// Port configuration not locked + static let Unlocked = Self(rawValue: 0x0) + + /// Port configuration locked + static let Locked = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension GPIOA.AFRL { + struct AFRL0Values: BitFieldProjectable, RawRepresentable { + static let bitWidth = 4 + + /// AF0 + static let AF0 = Self(rawValue: 0x0) + + /// AF1 + static let AF1 = Self(rawValue: 0x1) + + /// AF2 + static let AF2 = Self(rawValue: 0x2) + + /// AF3 + static let AF3 = Self(rawValue: 0x3) + + /// AF4 + static let AF4 = Self(rawValue: 0x4) + + /// AF5 + static let AF5 = Self(rawValue: 0x5) + + /// AF6 + static let AF6 = Self(rawValue: 0x6) + + /// AF7 + static let AF7 = Self(rawValue: 0x7) + + /// AF8 + static let AF8 = Self(rawValue: 0x8) + + /// AF9 + static let AF9 = Self(rawValue: 0x9) + + /// AF10 + static let AF10 = Self(rawValue: 0xa) + + /// AF11 + static let AF11 = Self(rawValue: 0xb) + + /// AF12 + static let AF12 = Self(rawValue: 0xc) + + /// AF13 + static let AF13 = Self(rawValue: 0xd) + + /// AF14 + static let AF14 = Self(rawValue: 0xe) + + /// AF15 + static let AF15 = Self(rawValue: 0xf) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension GPIOA.AFRH { + struct AFRH8Values: BitFieldProjectable, RawRepresentable { + static let bitWidth = 4 + + /// AF0 + static let AF0 = Self(rawValue: 0x0) + + /// AF1 + static let AF1 = Self(rawValue: 0x1) + + /// AF2 + static let AF2 = Self(rawValue: 0x2) + + /// AF3 + static let AF3 = Self(rawValue: 0x3) + + /// AF4 + static let AF4 = Self(rawValue: 0x4) + + /// AF5 + static let AF5 = Self(rawValue: 0x5) + + /// AF6 + static let AF6 = Self(rawValue: 0x6) + + /// AF7 + static let AF7 = Self(rawValue: 0x7) + + /// AF8 + static let AF8 = Self(rawValue: 0x8) + + /// AF9 + static let AF9 = Self(rawValue: 0x9) + + /// AF10 + static let AF10 = Self(rawValue: 0xa) + + /// AF11 + static let AF11 = Self(rawValue: 0xb) + + /// AF12 + static let AF12 = Self(rawValue: 0xc) + + /// AF13 + static let AF13 = Self(rawValue: 0xd) + + /// AF14 + static let AF14 = Self(rawValue: 0xe) + + /// AF15 + static let AF15 = Self(rawValue: 0xf) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} diff --git a/stm32-lcd-logo/Sources/Application/Registers/GPIOB.swift b/stm32-lcd-logo/Sources/Application/Registers/GPIOB.swift new file mode 100644 index 00000000..c820355f --- /dev/null +++ b/stm32-lcd-logo/Sources/Application/Registers/GPIOB.swift @@ -0,0 +1,7 @@ +// Generated by svd2swift. + +import MMIO + +/// General-purpose I/Os +typealias GPIOB = GPIOA + diff --git a/stm32-lcd-logo/Sources/Application/Registers/GPIOC.swift b/stm32-lcd-logo/Sources/Application/Registers/GPIOC.swift new file mode 100644 index 00000000..76543eca --- /dev/null +++ b/stm32-lcd-logo/Sources/Application/Registers/GPIOC.swift @@ -0,0 +1,7 @@ +// Generated by svd2swift. + +import MMIO + +/// General-purpose I/Os +typealias GPIOC = GPIOA + diff --git a/stm32-lcd-logo/Sources/Application/Registers/GPIOD.swift b/stm32-lcd-logo/Sources/Application/Registers/GPIOD.swift new file mode 100644 index 00000000..d54a0d5b --- /dev/null +++ b/stm32-lcd-logo/Sources/Application/Registers/GPIOD.swift @@ -0,0 +1,7 @@ +// Generated by svd2swift. + +import MMIO + +/// General-purpose I/Os +typealias GPIOD = GPIOA + diff --git a/stm32-lcd-logo/Sources/Application/Registers/GPIOE.swift b/stm32-lcd-logo/Sources/Application/Registers/GPIOE.swift new file mode 100644 index 00000000..08b7facf --- /dev/null +++ b/stm32-lcd-logo/Sources/Application/Registers/GPIOE.swift @@ -0,0 +1,7 @@ +// Generated by svd2swift. + +import MMIO + +/// General-purpose I/Os +typealias GPIOE = GPIOA + diff --git a/stm32-lcd-logo/Sources/Application/Registers/GPIOF.swift b/stm32-lcd-logo/Sources/Application/Registers/GPIOF.swift new file mode 100644 index 00000000..a0502a12 --- /dev/null +++ b/stm32-lcd-logo/Sources/Application/Registers/GPIOF.swift @@ -0,0 +1,7 @@ +// Generated by svd2swift. + +import MMIO + +/// General-purpose I/Os +typealias GPIOF = GPIOA + diff --git a/stm32-lcd-logo/Sources/Application/Registers/GPIOG.swift b/stm32-lcd-logo/Sources/Application/Registers/GPIOG.swift new file mode 100644 index 00000000..1bfc7fd8 --- /dev/null +++ b/stm32-lcd-logo/Sources/Application/Registers/GPIOG.swift @@ -0,0 +1,7 @@ +// Generated by svd2swift. + +import MMIO + +/// General-purpose I/Os +typealias GPIOG = GPIOA + diff --git a/stm32-lcd-logo/Sources/Application/Registers/GPIOH.swift b/stm32-lcd-logo/Sources/Application/Registers/GPIOH.swift new file mode 100644 index 00000000..3384a586 --- /dev/null +++ b/stm32-lcd-logo/Sources/Application/Registers/GPIOH.swift @@ -0,0 +1,7 @@ +// Generated by svd2swift. + +import MMIO + +/// General-purpose I/Os +typealias GPIOH = GPIOA + diff --git a/stm32-lcd-logo/Sources/Application/Registers/GPIOI.swift b/stm32-lcd-logo/Sources/Application/Registers/GPIOI.swift new file mode 100644 index 00000000..f7e28cc8 --- /dev/null +++ b/stm32-lcd-logo/Sources/Application/Registers/GPIOI.swift @@ -0,0 +1,7 @@ +// Generated by svd2swift. + +import MMIO + +/// General-purpose I/Os +typealias GPIOI = GPIOA + diff --git a/stm32-lcd-logo/Sources/Application/Registers/GPIOJ.swift b/stm32-lcd-logo/Sources/Application/Registers/GPIOJ.swift new file mode 100644 index 00000000..6e349edb --- /dev/null +++ b/stm32-lcd-logo/Sources/Application/Registers/GPIOJ.swift @@ -0,0 +1,7 @@ +// Generated by svd2swift. + +import MMIO + +/// General-purpose I/Os +typealias GPIOJ = GPIOA + diff --git a/stm32-lcd-logo/Sources/Application/Registers/GPIOK.swift b/stm32-lcd-logo/Sources/Application/Registers/GPIOK.swift new file mode 100644 index 00000000..ca28ed7e --- /dev/null +++ b/stm32-lcd-logo/Sources/Application/Registers/GPIOK.swift @@ -0,0 +1,7 @@ +// Generated by svd2swift. + +import MMIO + +/// General-purpose I/Os +typealias GPIOK = GPIOA + diff --git a/stm32-lcd-logo/Sources/Application/Registers/LTDC.swift b/stm32-lcd-logo/Sources/Application/Registers/LTDC.swift new file mode 100644 index 00000000..bbbe2dbe --- /dev/null +++ b/stm32-lcd-logo/Sources/Application/Registers/LTDC.swift @@ -0,0 +1,847 @@ +// Generated by svd2swift. + +import MMIO + +/// LCD-TFT Controller +@RegisterBlock +struct LTDC { + /// Synchronization Size Configuration Register + @RegisterBlock(offset: 0x8) + var sscr: Register + + /// Back Porch Configuration Register + @RegisterBlock(offset: 0xc) + var bpcr: Register + + /// Active Width Configuration Register + @RegisterBlock(offset: 0x10) + var awcr: Register + + /// Total Width Configuration Register + @RegisterBlock(offset: 0x14) + var twcr: Register + + /// Global Control Register + @RegisterBlock(offset: 0x18) + var gcr: Register + + /// Shadow Reload Configuration Register + @RegisterBlock(offset: 0x24) + var srcr: Register + + /// Background Color Configuration Register + @RegisterBlock(offset: 0x2c) + var bccr: Register + + /// Interrupt Enable Register + @RegisterBlock(offset: 0x34) + var ier: Register + + /// Interrupt Status Register + @RegisterBlock(offset: 0x38) + var isr: Register + + /// Interrupt Clear Register + @RegisterBlock(offset: 0x3c) + var icr: Register + + /// Line Interrupt Position Configuration Register + @RegisterBlock(offset: 0x40) + var lipcr: Register + + /// Current Position Status Register + @RegisterBlock(offset: 0x44) + var cpsr: Register + + /// Current Display Status Register + @RegisterBlock(offset: 0x48) + var cdsr: Register + + /// Cluster LAYER%s, containing L?CR, L?WHPCR, L?WVPCR, L?CKCR, L?PFCR, L?CACR, L?DCCR, L?BFCR, L?CFBAR, L?CFBLR, L?CFBLNR, L?CLUTWR + @RegisterBlock(offset: 0x84, stride: 0x80, count: 2) + var layer: RegisterArray +} + +extension LTDC { + /// Synchronization Size Configuration Register + @Register(bitWidth: 32) + struct SSCR { + /// Horizontal Synchronization Width (in units of pixel clock period) + @ReadWrite(bits: 16..<28) + var hsw: HSW + + /// Vertical Synchronization Height (in units of horizontal scan line) + @ReadWrite(bits: 0..<11) + var vsh: VSH + } + + /// Back Porch Configuration Register + @Register(bitWidth: 32) + struct BPCR { + /// Accumulated Horizontal back porch (in units of pixel clock period) + @ReadWrite(bits: 16..<28) + var ahbp: AHBP + + /// Accumulated Vertical back porch (in units of horizontal scan line) + @ReadWrite(bits: 0..<11) + var avbp: AVBP + } + + /// Active Width Configuration Register + @Register(bitWidth: 32) + struct AWCR { + /// Accumulated Active Width (in units of pixel clock period) + @ReadWrite(bits: 16..<28) + var aaw: AAW + + /// Accumulated Active Height (in units of horizontal scan line) + @ReadWrite(bits: 0..<11) + var aah: AAH + } + + /// Total Width Configuration Register + @Register(bitWidth: 32) + struct TWCR { + /// Total Width (in units of pixel clock period) + @ReadWrite(bits: 16..<28) + var totalw: TOTALW + + /// Total Height (in units of horizontal scan line) + @ReadWrite(bits: 0..<11) + var totalh: TOTALH + } + + /// Global Control Register + @Register(bitWidth: 32) + struct GCR { + /// Horizontal Synchronization Polarity + @ReadWrite(bits: 31..<32, as: HSPOLValues.self) + var hspol: HSPOL + + /// Vertical Synchronization Polarity + @ReadWrite(bits: 30..<31, as: VSPOLValues.self) + var vspol: VSPOL + + /// Data Enable Polarity + @ReadWrite(bits: 29..<30, as: DEPOLValues.self) + var depol: DEPOL + + /// Pixel Clock Polarity + @ReadWrite(bits: 28..<29, as: PCPOLValues.self) + var pcpol: PCPOL + + /// Dither Enable + @ReadWrite(bits: 16..<17, as: DENValues.self) + var den: DEN + + /// Dither Red Width + @ReadOnly(bits: 12..<15) + var drw: DRW + + /// Dither Green Width + @ReadOnly(bits: 8..<11) + var dgw: DGW + + /// Dither Blue Width + @ReadOnly(bits: 4..<7) + var dbw: DBW + + /// LCD-TFT controller enable bit + @ReadWrite(bits: 0..<1, as: LTDCENValues.self) + var ltdcen: LTDCEN + } + + /// Shadow Reload Configuration Register + @Register(bitWidth: 32) + struct SRCR { + /// Vertical Blanking Reload + @ReadWrite(bits: 1..<2, as: VBRValues.self) + var vbr: VBR + + /// Immediate Reload + @ReadWrite(bits: 0..<1, as: IMRValues.self) + var imr: IMR + } + + /// Background Color Configuration Register + @Register(bitWidth: 32) + struct BCCR { + /// Background color blue value + @ReadWrite(bits: 0..<8) + var bcblue: BCBLUE + + /// Background color green value + @ReadWrite(bits: 8..<16) + var bcgreen: BCGREEN + + /// Background color red value + @ReadWrite(bits: 16..<24) + var bcred: BCRED + } + + /// Interrupt Enable Register + @Register(bitWidth: 32) + struct IER { + /// Register Reload interrupt enable + @ReadWrite(bits: 3..<4, as: RRIEValues.self) + var rrie: RRIE + + /// Transfer Error Interrupt Enable + @ReadWrite(bits: 2..<3, as: TERRIEValues.self) + var terrie: TERRIE + + /// FIFO Underrun Interrupt Enable + @ReadWrite(bits: 1..<2, as: FUIEValues.self) + var fuie: FUIE + + /// Line Interrupt Enable + @ReadWrite(bits: 0..<1, as: LIEValues.self) + var lie: LIE + } + + /// Interrupt Status Register + @Register(bitWidth: 32) + struct ISR { + /// Register Reload Interrupt Flag + @ReadOnly(bits: 3..<4) + var rrif: RRIF + + /// Transfer Error interrupt flag + @ReadOnly(bits: 2..<3) + var terrif: TERRIF + + /// FIFO Underrun Interrupt flag + @ReadOnly(bits: 1..<2) + var fuif: FUIF + + /// Line Interrupt flag + @ReadOnly(bits: 0..<1) + var lif: LIF + } + + /// Interrupt Clear Register + @Register(bitWidth: 32) + struct ICR { + /// Clears Register Reload Interrupt Flag + @WriteOnly(bits: 3..<4) + var crrif: CRRIF + + /// Clears the Transfer Error Interrupt Flag + @WriteOnly(bits: 2..<3) + var cterrif: CTERRIF + + /// Clears the FIFO Underrun Interrupt flag + @WriteOnly(bits: 1..<2) + var cfuif: CFUIF + + /// Clears the Line Interrupt Flag + @WriteOnly(bits: 0..<1) + var clif: CLIF + } + + /// Line Interrupt Position Configuration Register + @Register(bitWidth: 32) + struct LIPCR { + /// Line Interrupt Position + @ReadWrite(bits: 0..<11) + var lipos: LIPOS + } + + /// Current Position Status Register + @Register(bitWidth: 32) + struct CPSR { + /// Current X Position + @ReadOnly(bits: 16..<32) + var cxpos: CXPOS + + /// Current Y Position + @ReadOnly(bits: 0..<16) + var cypos: CYPOS + } + + /// Current Display Status Register + @Register(bitWidth: 32) + struct CDSR { + /// Horizontal Synchronization display Status + @ReadOnly(bits: 3..<4) + var hsyncs: HSYNCS + + /// Vertical Synchronization display Status + @ReadOnly(bits: 2..<3) + var vsyncs: VSYNCS + + /// Horizontal Data Enable display Status + @ReadOnly(bits: 1..<2) + var hdes: HDES + + /// Vertical Data Enable display Status + @ReadOnly(bits: 0..<1) + var vdes: VDES + } + + /// Cluster LAYER%s, containing L?CR, L?WHPCR, L?WVPCR, L?CKCR, L?PFCR, L?CACR, L?DCCR, L?BFCR, L?CFBAR, L?CFBLR, L?CFBLNR, L?CLUTWR + @RegisterBlock + struct LAYER { + /// Layerx Control Register + @RegisterBlock(offset: 0x0) + var cr: Register + + /// Layerx Window Horizontal Position Configuration Register + @RegisterBlock(offset: 0x4) + var whpcr: Register + + /// Layerx Window Vertical Position Configuration Register + @RegisterBlock(offset: 0x8) + var wvpcr: Register + + /// Layerx Color Keying Configuration Register + @RegisterBlock(offset: 0xc) + var ckcr: Register + + /// Layerx Pixel Format Configuration Register + @RegisterBlock(offset: 0x10) + var pfcr: Register + + /// Layerx Constant Alpha Configuration Register + @RegisterBlock(offset: 0x14) + var cacr: Register + + /// Layerx Default Color Configuration Register + @RegisterBlock(offset: 0x18) + var dccr: Register + + /// Layerx Blending Factors Configuration Register + @RegisterBlock(offset: 0x1c) + var bfcr: Register + + /// Layerx Color Frame Buffer Address Register + @RegisterBlock(offset: 0x28) + var cfbar: Register + + /// Layerx Color Frame Buffer Length Register + @RegisterBlock(offset: 0x2c) + var cfblr: Register + + /// Layerx ColorFrame Buffer Line Number Register + @RegisterBlock(offset: 0x30) + var cfblnr: Register + + /// Layerx CLUT Write Register + @RegisterBlock(offset: 0x40) + var clutwr: Register + } +} + +extension LTDC.LAYER { + /// Layerx Control Register + @Register(bitWidth: 32) + struct CR { + /// Color Look-Up Table Enable + @ReadWrite(bits: 4..<5, as: CLUTENValues.self) + var cluten: CLUTEN + + /// Color Keying Enable + @ReadWrite(bits: 1..<2, as: COLKENValues.self) + var colken: COLKEN + + /// Layer Enable + @ReadWrite(bits: 0..<1, as: LENValues.self) + var len: LEN + } + + /// Layerx Window Horizontal Position Configuration Register + @Register(bitWidth: 32) + struct WHPCR { + /// Window Horizontal Stop Position + @ReadWrite(bits: 16..<28) + var whsppos: WHSPPOS + + /// Window Horizontal Start Position + @ReadWrite(bits: 0..<12) + var whstpos: WHSTPOS + } + + /// Layerx Window Vertical Position Configuration Register + @Register(bitWidth: 32) + struct WVPCR { + /// Window Vertical Stop Position + @ReadWrite(bits: 16..<27) + var wvsppos: WVSPPOS + + /// Window Vertical Start Position + @ReadWrite(bits: 0..<11) + var wvstpos: WVSTPOS + } + + /// Layerx Color Keying Configuration Register + @Register(bitWidth: 32) + struct CKCR { + /// Color Key Red value + @ReadWrite(bits: 16..<24) + var ckred: CKRED + + /// Color Key Green value + @ReadWrite(bits: 8..<16) + var ckgreen: CKGREEN + + /// Color Key Blue value + @ReadWrite(bits: 0..<8) + var ckblue: CKBLUE + } + + /// Layerx Pixel Format Configuration Register + @Register(bitWidth: 32) + struct PFCR { + /// Pixel Format + @ReadWrite(bits: 0..<3, as: PFValues.self) + var pf: PF + } + + /// Layerx Constant Alpha Configuration Register + @Register(bitWidth: 32) + struct CACR { + /// Constant Alpha + @ReadWrite(bits: 0..<8) + var consta: CONSTA + } + + /// Layerx Default Color Configuration Register + @Register(bitWidth: 32) + struct DCCR { + /// Default Color Alpha + @ReadWrite(bits: 24..<32) + var dcalpha: DCALPHA + + /// Default Color Red + @ReadWrite(bits: 16..<24) + var dcred: DCRED + + /// Default Color Green + @ReadWrite(bits: 8..<16) + var dcgreen: DCGREEN + + /// Default Color Blue + @ReadWrite(bits: 0..<8) + var dcblue: DCBLUE + } + + /// Layerx Blending Factors Configuration Register + @Register(bitWidth: 32) + struct BFCR { + /// Blending Factor 1 + @ReadWrite(bits: 8..<11, as: BF1Values.self) + var bf1: BF1 + + /// Blending Factor 2 + @ReadWrite(bits: 0..<3, as: BF2Values.self) + var bf2: BF2 + } + + /// Layerx Color Frame Buffer Address Register + @Register(bitWidth: 32) + struct CFBAR { + /// Color Frame Buffer Start Address + @ReadWrite(bits: 0..<32) + var cfbadd: CFBADD + } + + /// Layerx Color Frame Buffer Length Register + @Register(bitWidth: 32) + struct CFBLR { + /// Color Frame Buffer Pitch in bytes + @ReadWrite(bits: 16..<29) + var cfbp: CFBP + + /// Color Frame Buffer Line Length + @ReadWrite(bits: 0..<13) + var cfbll: CFBLL + } + + /// Layerx ColorFrame Buffer Line Number Register + @Register(bitWidth: 32) + struct CFBLNR { + /// Frame Buffer Line Number + @ReadWrite(bits: 0..<11) + var cfblnbr: CFBLNBR + } + + /// Layerx CLUT Write Register + @Register(bitWidth: 32) + struct CLUTWR { + /// CLUT Address + @WriteOnly(bits: 24..<32) + var clutadd: CLUTADD + + /// Red value + @WriteOnly(bits: 16..<24) + var red: RED + + /// Green value + @WriteOnly(bits: 8..<16) + var green: GREEN + + /// Blue value + @WriteOnly(bits: 0..<8) + var blue: BLUE + } +} + +extension LTDC.GCR { + struct HSPOLValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// Horizontal synchronization polarity is active low + static let ActiveLow = Self(rawValue: 0x0) + + /// Horizontal synchronization polarity is active high + static let ActiveHigh = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension LTDC.GCR { + struct VSPOLValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// Vertical synchronization polarity is active low + static let ActiveLow = Self(rawValue: 0x0) + + /// Vertical synchronization polarity is active high + static let ActiveHigh = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension LTDC.GCR { + struct DEPOLValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// Data enable polarity is active low + static let ActiveLow = Self(rawValue: 0x0) + + /// Data enable polarity is active high + static let ActiveHigh = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension LTDC.GCR { + struct PCPOLValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// Pixel clock on rising edge + static let RisingEdge = Self(rawValue: 0x0) + + /// Pixel clock on falling edge + static let FallingEdge = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension LTDC.GCR { + struct DENValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// Dither disabled + static let Disabled = Self(rawValue: 0x0) + + /// Dither enabled + static let Enabled = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension LTDC.GCR { + struct LTDCENValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// LCD-TFT controller disabled + static let Disabled = Self(rawValue: 0x0) + + /// LCD-TFT controller enabled + static let Enabled = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension LTDC.SRCR { + struct VBRValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// This bit is set by software and cleared only by hardware after reload (it cannot be cleared through register write once it is set) + static let NoEffect = Self(rawValue: 0x0) + + /// The shadow registers are reloaded during the vertical blanking period (at the beginning of the first line after the active display area). + static let Reload = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension LTDC.SRCR { + struct IMRValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// This bit is set by software and cleared only by hardware after reload (it cannot be cleared through register write once it is set) + static let NoEffect = Self(rawValue: 0x0) + + /// The shadow registers are reloaded immediately. This bit is set by software and cleared only by hardware after reload + static let Reload = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension LTDC.IER { + struct RRIEValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// Register reload interrupt disabled + static let Disabled = Self(rawValue: 0x0) + + /// Register reload interrupt enabled + static let Enabled = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension LTDC.IER { + struct TERRIEValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// Transfer error interrupt disabled + static let Disabled = Self(rawValue: 0x0) + + /// Transfer error interrupt enabled + static let Enabled = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension LTDC.IER { + struct FUIEValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// FIFO underrun interrupt disabled + static let Disabled = Self(rawValue: 0x0) + + /// FIFO underrun interrupt enabled + static let Enabled = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension LTDC.IER { + struct LIEValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// Line interrupt disabled + static let Disabled = Self(rawValue: 0x0) + + /// Line interrupt enabled + static let Enabled = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension LTDC.LAYER.CR { + struct CLUTENValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// Color look-up table disabled + static let Disabled = Self(rawValue: 0x0) + + /// Color look-up table enabled + static let Enabled = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension LTDC.LAYER.CR { + struct COLKENValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// Color keying disabled + static let Disabled = Self(rawValue: 0x0) + + /// Color keying enabled + static let Enabled = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension LTDC.LAYER.CR { + struct LENValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// Layer disabled + static let Disabled = Self(rawValue: 0x0) + + /// Layer enabled + static let Enabled = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension LTDC.LAYER.PFCR { + struct PFValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 3 + + /// ARGB8888 + static let ARGB8888 = Self(rawValue: 0x0) + + /// RGB888 + static let RGB888 = Self(rawValue: 0x1) + + /// RGB565 + static let RGB565 = Self(rawValue: 0x2) + + /// ARGB1555 + static let ARGB1555 = Self(rawValue: 0x3) + + /// ARGB4444 + static let ARGB4444 = Self(rawValue: 0x4) + + /// L8 (8-bit luminance) + static let L8 = Self(rawValue: 0x5) + + /// AL44 (4-bit alpha, 4-bit luminance) + static let AL44 = Self(rawValue: 0x6) + + /// AL88 (8-bit alpha, 8-bit luminance) + static let AL88 = Self(rawValue: 0x7) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension LTDC.LAYER.BFCR { + struct BF1Values: BitFieldProjectable, RawRepresentable { + static let bitWidth = 3 + + /// BF1 = constant alpha + static let Constant = Self(rawValue: 0x4) + + /// BF1 = pixel alpha * constant alpha + static let Pixel = Self(rawValue: 0x6) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension LTDC.LAYER.BFCR { + struct BF2Values: BitFieldProjectable, RawRepresentable { + static let bitWidth = 3 + + /// BF2 = 1 - constant alpha + static let Constant = Self(rawValue: 0x5) + + /// BF2 = 1 - pixel alpha * constant alpha + static let Pixel = Self(rawValue: 0x7) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} diff --git a/stm32-lcd-logo/Sources/Application/Registers/RCC.swift b/stm32-lcd-logo/Sources/Application/Registers/RCC.swift new file mode 100644 index 00000000..4f5842ef --- /dev/null +++ b/stm32-lcd-logo/Sources/Application/Registers/RCC.swift @@ -0,0 +1,2833 @@ +// Generated by svd2swift. + +import MMIO + +/// Reset and clock control +@RegisterBlock +struct RCC { + /// clock control register + @RegisterBlock(offset: 0x0) + var cr: Register + + /// PLL configuration register + @RegisterBlock(offset: 0x4) + var pllcfgr: Register + + /// clock configuration register + @RegisterBlock(offset: 0x8) + var cfgr: Register + + /// clock interrupt register + @RegisterBlock(offset: 0xc) + var cir: Register + + /// AHB1 peripheral reset register + @RegisterBlock(offset: 0x10) + var ahb1rstr: Register + + /// AHB2 peripheral reset register + @RegisterBlock(offset: 0x14) + var ahb2rstr: Register + + /// AHB3 peripheral reset register + @RegisterBlock(offset: 0x18) + var ahb3rstr: Register + + /// APB1 peripheral reset register + @RegisterBlock(offset: 0x20) + var apb1rstr: Register + + /// APB2 peripheral reset register + @RegisterBlock(offset: 0x24) + var apb2rstr: Register + + /// AHB1 peripheral clock register + @RegisterBlock(offset: 0x30) + var ahb1enr: Register + + /// AHB2 peripheral clock enable register + @RegisterBlock(offset: 0x34) + var ahb2enr: Register + + /// AHB3 peripheral clock enable register + @RegisterBlock(offset: 0x38) + var ahb3enr: Register + + /// APB1 peripheral clock enable register + @RegisterBlock(offset: 0x40) + var apb1enr: Register + + /// APB2 peripheral clock enable register + @RegisterBlock(offset: 0x44) + var apb2enr: Register + + /// AHB1 peripheral clock enable in low power mode register + @RegisterBlock(offset: 0x50) + var ahb1lpenr: Register + + /// AHB2 peripheral clock enable in low power mode register + @RegisterBlock(offset: 0x54) + var ahb2lpenr: Register + + /// AHB3 peripheral clock enable in low power mode register + @RegisterBlock(offset: 0x58) + var ahb3lpenr: Register + + /// APB1 peripheral clock enable in low power mode register + @RegisterBlock(offset: 0x60) + var apb1lpenr: Register + + /// APB2 peripheral clock enabled in low power mode register + @RegisterBlock(offset: 0x64) + var apb2lpenr: Register + + /// Backup domain control register + @RegisterBlock(offset: 0x70) + var bdcr: Register + + /// clock control & status register + @RegisterBlock(offset: 0x74) + var csr: Register + + /// spread spectrum clock generation register + @RegisterBlock(offset: 0x80) + var sscgr: Register + + /// PLLI2S configuration register + @RegisterBlock(offset: 0x84) + var plli2scfgr: Register + + /// PLL configuration register + @RegisterBlock(offset: 0x88) + var pllsaicfgr: Register + + /// dedicated clocks configuration register + @RegisterBlock(offset: 0x8c) + var dckcfgr1: Register + + /// dedicated clocks configuration register + @RegisterBlock(offset: 0x90) + var dckcfgr2: Register +} + +extension RCC { + /// clock control register + @Register(bitWidth: 32) + struct CR { + /// PLLI2S clock ready flag + @ReadOnly(bits: 27..<28) + var plli2srdy: PLLI2SRDY + + /// PLLI2S enable + @ReadWrite(bits: 26..<27) + var plli2son: PLLI2SON + + /// Main PLL (PLL) clock ready flag + @ReadOnly(bits: 25..<26) + var pllrdy: PLLRDY + + /// Main PLL (PLL) enable + @ReadWrite(bits: 24..<25) + var pllon: PLLON + + /// Clock security system enable + @ReadWrite(bits: 19..<20, as: CSSONValues.self) + var csson: CSSON + + /// HSE clock bypass + @ReadWrite(bits: 18..<19, as: HSEBYPValues.self) + var hsebyp: HSEBYP + + /// HSE clock ready flag + @ReadOnly(bits: 17..<18) + var hserdy: HSERDY + + /// HSE clock enable + @ReadWrite(bits: 16..<17) + var hseon: HSEON + + /// Internal high-speed clock calibration + @ReadOnly(bits: 8..<16) + var hsical: HSICAL + + /// Internal high-speed clock trimming + @ReadWrite(bits: 3..<8) + var hsitrim: HSITRIM + + /// Internal high-speed clock ready flag + @ReadOnly(bits: 1..<2) + var hsirdy: HSIRDY + + /// Internal high-speed clock enable + @ReadWrite(bits: 0..<1, as: HSIONValues.self) + var hsion: HSION + + /// PLLSAI clock ready flag + @ReadOnly(bits: 29..<30) + var pllsairdy: PLLSAIRDY + + /// PLLSAI enable + @ReadWrite(bits: 28..<29) + var pllsaion: PLLSAION + } + + /// PLL configuration register + @Register(bitWidth: 32) + struct PLLCFGR { + /// Main PLL(PLL) and audio PLL (PLLI2S) entry clock source + @ReadWrite(bits: 22..<23, as: PLLSRCValues.self) + var pllsrc: PLLSRC + + /// Division factor for the main PLL (PLL) and audio PLL (PLLI2S) input clock + @ReadWrite(bits: 0..<6) + var pllm: PLLM + + /// Main PLL (PLL) multiplication factor for VCO + @ReadWrite(bits: 6..<15) + var plln: PLLN + + /// Main PLL (PLL) division factor for main system clock + @ReadWrite(bits: 16..<18, as: PLLPValues.self) + var pllp: PLLP + + /// Main PLL (PLL) division factor for USB OTG FS, SDIO and random number generator clocks + @ReadWrite(bits: 24..<28) + var pllq: PLLQ + } + + /// clock configuration register + @Register(bitWidth: 32) + struct CFGR { + /// Microcontroller clock output 2 + @ReadWrite(bits: 30..<32, as: MCO2Values.self) + var mco2: MCO2 + + /// MCO2 prescaler + @ReadWrite(bits: 27..<30) + var mco2pre: MCO2PRE + + /// MCO1 prescaler + @ReadWrite(bits: 24..<27, as: MCO1PREValues.self) + var mco1pre: MCO1PRE + + /// I2S clock selection + @ReadWrite(bits: 23..<24, as: I2SSRCValues.self) + var i2ssrc: I2SSRC + + /// Microcontroller clock output 1 + @ReadWrite(bits: 21..<23, as: MCO1Values.self) + var mco1: MCO1 + + /// HSE division factor for RTC clock + @ReadWrite(bits: 16..<21) + var rtcpre: RTCPRE + + /// APB high-speed prescaler (APB2) + @ReadWrite(bits: 13..<16) + var ppre2: PPRE2 + + /// APB Low speed prescaler (APB1) + @ReadWrite(bits: 10..<13, as: PPRE1Values.self) + var ppre1: PPRE1 + + /// AHB prescaler + @ReadWrite(bits: 4..<8, as: HPREValues.self) + var hpre: HPRE + + /// System clock switch + @Reserved(bits: 0..<2, as: SWValues.self) + var sw: SW + + /// System clock switch status + @Reserved(bits: 2..<4) + var sws: SWS + } + + /// clock interrupt register + @Register(bitWidth: 32) + struct CIR { + /// Clock security system interrupt clear + @WriteOnly(bits: 23..<24) + var cssc: CSSC + + /// PLLSAI Ready Interrupt Clear + @WriteOnly(bits: 22..<23) + var pllsairdyc: PLLSAIRDYC + + /// PLLI2S ready interrupt clear + @WriteOnly(bits: 21..<22) + var plli2srdyc: PLLI2SRDYC + + /// Main PLL(PLL) ready interrupt clear + @WriteOnly(bits: 20..<21) + var pllrdyc: PLLRDYC + + /// HSE ready interrupt clear + @WriteOnly(bits: 19..<20) + var hserdyc: HSERDYC + + /// HSI ready interrupt clear + @WriteOnly(bits: 18..<19) + var hsirdyc: HSIRDYC + + /// LSE ready interrupt clear + @WriteOnly(bits: 17..<18) + var lserdyc: LSERDYC + + /// LSI ready interrupt clear + @WriteOnly(bits: 16..<17) + var lsirdyc: LSIRDYC + + /// PLLSAI Ready Interrupt Enable + @ReadWrite(bits: 14..<15) + var pllsairdyie: PLLSAIRDYIE + + /// PLLI2S ready interrupt enable + @ReadWrite(bits: 13..<14) + var plli2srdyie: PLLI2SRDYIE + + /// Main PLL (PLL) ready interrupt enable + @ReadWrite(bits: 12..<13) + var pllrdyie: PLLRDYIE + + /// HSE ready interrupt enable + @ReadWrite(bits: 11..<12) + var hserdyie: HSERDYIE + + /// HSI ready interrupt enable + @ReadWrite(bits: 10..<11) + var hsirdyie: HSIRDYIE + + /// LSE ready interrupt enable + @ReadWrite(bits: 9..<10) + var lserdyie: LSERDYIE + + /// LSI ready interrupt enable + @ReadWrite(bits: 8..<9, as: LSIRDYIEValues.self) + var lsirdyie: LSIRDYIE + + /// Clock security system interrupt flag + @ReadOnly(bits: 7..<8) + var cssf: CSSF + + /// PLLSAI ready interrupt flag + @ReadOnly(bits: 6..<7) + var pllsairdyf: PLLSAIRDYF + + /// PLLI2S ready interrupt flag + @ReadOnly(bits: 5..<6) + var plli2srdyf: PLLI2SRDYF + + /// Main PLL (PLL) ready interrupt flag + @ReadOnly(bits: 4..<5) + var pllrdyf: PLLRDYF + + /// HSE ready interrupt flag + @ReadOnly(bits: 3..<4) + var hserdyf: HSERDYF + + /// HSI ready interrupt flag + @ReadOnly(bits: 2..<3) + var hsirdyf: HSIRDYF + + /// LSE ready interrupt flag + @ReadOnly(bits: 1..<2) + var lserdyf: LSERDYF + + /// LSI ready interrupt flag + @ReadOnly(bits: 0..<1) + var lsirdyf: LSIRDYF + } + + /// AHB1 peripheral reset register + @Register(bitWidth: 32) + struct AHB1RSTR { + /// USB OTG HS module reset + @ReadWrite(bits: 29..<30) + var otghsrst: OTGHSRST + + /// Ethernet MAC reset + @ReadWrite(bits: 25..<26) + var ethmacrst: ETHMACRST + + /// DMA2D reset + @ReadWrite(bits: 23..<24) + var dma2drst: DMA2DRST + + /// DMA2 reset + @ReadWrite(bits: 22..<23) + var dma2rst: DMA2RST + + /// DMA2 reset + @ReadWrite(bits: 21..<22) + var dma1rst: DMA1RST + + /// CRC reset + @ReadWrite(bits: 12..<13) + var crcrst: CRCRST + + /// IO port K reset + @ReadWrite(bits: 10..<11) + var gpiokrst: GPIOKRST + + /// IO port J reset + @ReadWrite(bits: 9..<10) + var gpiojrst: GPIOJRST + + /// IO port I reset + @ReadWrite(bits: 8..<9) + var gpioirst: GPIOIRST + + /// IO port H reset + @ReadWrite(bits: 7..<8) + var gpiohrst: GPIOHRST + + /// IO port G reset + @ReadWrite(bits: 6..<7) + var gpiogrst: GPIOGRST + + /// IO port F reset + @ReadWrite(bits: 5..<6) + var gpiofrst: GPIOFRST + + /// IO port E reset + @ReadWrite(bits: 4..<5) + var gpioerst: GPIOERST + + /// IO port D reset + @ReadWrite(bits: 3..<4) + var gpiodrst: GPIODRST + + /// IO port C reset + @ReadWrite(bits: 2..<3) + var gpiocrst: GPIOCRST + + /// IO port B reset + @ReadWrite(bits: 1..<2) + var gpiobrst: GPIOBRST + + /// IO port A reset + @ReadWrite(bits: 0..<1, as: GPIOARSTValues.self) + var gpioarst: GPIOARST + } + + /// AHB2 peripheral reset register + @Register(bitWidth: 32) + struct AHB2RSTR { + /// USB OTG FS module reset + @ReadWrite(bits: 7..<8) + var otgfsrst: OTGFSRST + + /// Random number generator module reset + @ReadWrite(bits: 6..<7) + var rngrst: RNGRST + + /// Hash module reset + @ReadWrite(bits: 5..<6) + var hsahrst: HSAHRST + + /// Cryptographic module reset + @ReadWrite(bits: 4..<5) + var cryprst: CRYPRST + + /// Camera interface reset + @ReadWrite(bits: 0..<1, as: DCMIRSTValues.self) + var dcmirst: DCMIRST + } + + /// AHB3 peripheral reset register + @Register(bitWidth: 32) + struct AHB3RSTR { + /// Flexible memory controller module reset + @ReadWrite(bits: 0..<1, as: FMCRSTValues.self) + var fmcrst: FMCRST + + /// Quad SPI memory controller reset + @ReadWrite(bits: 1..<2) + var qspirst: QSPIRST + } + + /// APB1 peripheral reset register + @Register(bitWidth: 32) + struct APB1RSTR { + /// TIM2 reset + @ReadWrite(bits: 0..<1, as: TIM2RSTValues.self) + var tim2rst: TIM2RST + + /// TIM3 reset + @ReadWrite(bits: 1..<2) + var tim3rst: TIM3RST + + /// TIM4 reset + @ReadWrite(bits: 2..<3) + var tim4rst: TIM4RST + + /// TIM5 reset + @ReadWrite(bits: 3..<4) + var tim5rst: TIM5RST + + /// TIM6 reset + @ReadWrite(bits: 4..<5) + var tim6rst: TIM6RST + + /// TIM7 reset + @ReadWrite(bits: 5..<6) + var tim7rst: TIM7RST + + /// TIM12 reset + @ReadWrite(bits: 6..<7) + var tim12rst: TIM12RST + + /// TIM13 reset + @ReadWrite(bits: 7..<8) + var tim13rst: TIM13RST + + /// TIM14 reset + @ReadWrite(bits: 8..<9) + var tim14rst: TIM14RST + + /// Window watchdog reset + @ReadWrite(bits: 11..<12) + var wwdgrst: WWDGRST + + /// SPI 2 reset + @ReadWrite(bits: 14..<15) + var spi2rst: SPI2RST + + /// SPI 3 reset + @ReadWrite(bits: 15..<16) + var spi3rst: SPI3RST + + /// USART 2 reset + @ReadWrite(bits: 17..<18) + var usart2rst: USART2RST + + /// USART 3 reset + @ReadWrite(bits: 18..<19) + var usart3rst: USART3RST + + /// USART 4 reset + @ReadWrite(bits: 19..<20) + var uart4rst: UART4RST + + /// USART 5 reset + @ReadWrite(bits: 20..<21) + var uart5rst: UART5RST + + /// I2C 1 reset + @ReadWrite(bits: 21..<22) + var i2c1rst: I2C1RST + + /// I2C 2 reset + @ReadWrite(bits: 22..<23) + var i2c2rst: I2C2RST + + /// I2C3 reset + @ReadWrite(bits: 23..<24) + var i2c3rst: I2C3RST + + /// CAN1 reset + @ReadWrite(bits: 25..<26) + var can1rst: CAN1RST + + /// CAN2 reset + @ReadWrite(bits: 26..<27) + var can2rst: CAN2RST + + /// Power interface reset + @ReadWrite(bits: 28..<29) + var pwrrst: PWRRST + + /// DAC reset + @ReadWrite(bits: 29..<30) + var dacrst: DACRST + + /// UART7 reset + @ReadWrite(bits: 30..<31) + var uart7rst: UART7RST + + /// UART8 reset + @ReadWrite(bits: 31..<32) + var uart8rst: UART8RST + + /// SPDIF-RX reset + @ReadWrite(bits: 16..<17) + var spdifrxrst: SPDIFRXRST + + /// HDMI-CEC reset + @ReadWrite(bits: 27..<28) + var cecrst: CECRST + + /// Low power timer 1 reset + @ReadWrite(bits: 9..<10) + var lptim1rst: LPTIM1RST + + /// I2C 4 reset + @ReadWrite(bits: 24..<25) + var i2c4rst: I2C4RST + } + + /// APB2 peripheral reset register + @Register(bitWidth: 32) + struct APB2RSTR { + /// TIM1 reset + @ReadWrite(bits: 0..<1, as: TIM1RSTValues.self) + var tim1rst: TIM1RST + + /// TIM8 reset + @ReadWrite(bits: 1..<2) + var tim8rst: TIM8RST + + /// USART1 reset + @ReadWrite(bits: 4..<5) + var usart1rst: USART1RST + + /// USART6 reset + @ReadWrite(bits: 5..<6) + var usart6rst: USART6RST + + /// ADC interface reset (common to all ADCs) + @ReadWrite(bits: 8..<9) + var adcrst: ADCRST + + /// SPI 1 reset + @ReadWrite(bits: 12..<13) + var spi1rst: SPI1RST + + /// SPI4 reset + @ReadWrite(bits: 13..<14) + var spi4rst: SPI4RST + + /// System configuration controller reset + @ReadWrite(bits: 14..<15) + var syscfgrst: SYSCFGRST + + /// TIM9 reset + @ReadWrite(bits: 16..<17) + var tim9rst: TIM9RST + + /// TIM10 reset + @ReadWrite(bits: 17..<18) + var tim10rst: TIM10RST + + /// TIM11 reset + @ReadWrite(bits: 18..<19) + var tim11rst: TIM11RST + + /// SPI5 reset + @ReadWrite(bits: 20..<21) + var spi5rst: SPI5RST + + /// SPI6 reset + @ReadWrite(bits: 21..<22) + var spi6rst: SPI6RST + + /// SAI1 reset + @ReadWrite(bits: 22..<23) + var sai1rst: SAI1RST + + /// LTDC reset + @ReadWrite(bits: 26..<27) + var ltdcrst: LTDCRST + + /// SAI2 reset + @ReadWrite(bits: 23..<24) + var sai2rst: SAI2RST + + /// SDMMC1 reset + @ReadWrite(bits: 11..<12) + var sdmmc1rst: SDMMC1RST + } + + /// AHB1 peripheral clock register + @Register(bitWidth: 32) + struct AHB1ENR { + /// USB OTG HSULPI clock enable + @ReadWrite(bits: 30..<31) + var otghsulpien: OTGHSULPIEN + + /// USB OTG HS clock enable + @ReadWrite(bits: 29..<30) + var otghsen: OTGHSEN + + /// Ethernet PTP clock enable + @ReadWrite(bits: 28..<29) + var ethmacptpen: ETHMACPTPEN + + /// Ethernet Reception clock enable + @ReadWrite(bits: 27..<28) + var ethmacrxen: ETHMACRXEN + + /// Ethernet Transmission clock enable + @ReadWrite(bits: 26..<27) + var ethmactxen: ETHMACTXEN + + /// Ethernet MAC clock enable + @ReadWrite(bits: 25..<26) + var ethmacen: ETHMACEN + + /// DMA2D clock enable + @ReadWrite(bits: 23..<24) + var dma2den: DMA2DEN + + /// DMA2 clock enable + @ReadWrite(bits: 22..<23) + var dma2en: DMA2EN + + /// DMA1 clock enable + @ReadWrite(bits: 21..<22) + var dma1en: DMA1EN + + /// CCM data RAM clock enable + @ReadWrite(bits: 20..<21) + var dtcmramen: DTCMRAMEN + + /// Backup SRAM interface clock enable + @ReadWrite(bits: 18..<19) + var bkpsramen: BKPSRAMEN + + /// CRC clock enable + @ReadWrite(bits: 12..<13) + var crcen: CRCEN + + /// IO port K clock enable + @ReadWrite(bits: 10..<11) + var gpioken: GPIOKEN + + /// IO port J clock enable + @ReadWrite(bits: 9..<10) + var gpiojen: GPIOJEN + + /// IO port I clock enable + @ReadWrite(bits: 8..<9) + var gpioien: GPIOIEN + + /// IO port H clock enable + @ReadWrite(bits: 7..<8) + var gpiohen: GPIOHEN + + /// IO port G clock enable + @ReadWrite(bits: 6..<7) + var gpiogen: GPIOGEN + + /// IO port F clock enable + @ReadWrite(bits: 5..<6) + var gpiofen: GPIOFEN + + /// IO port E clock enable + @ReadWrite(bits: 4..<5) + var gpioeen: GPIOEEN + + /// IO port D clock enable + @ReadWrite(bits: 3..<4) + var gpioden: GPIODEN + + /// IO port C clock enable + @ReadWrite(bits: 2..<3) + var gpiocen: GPIOCEN + + /// IO port B clock enable + @ReadWrite(bits: 1..<2) + var gpioben: GPIOBEN + + /// IO port A clock enable + @ReadWrite(bits: 0..<1, as: GPIOAENValues.self) + var gpioaen: GPIOAEN + } + + /// AHB2 peripheral clock enable register + @Register(bitWidth: 32) + struct AHB2ENR { + /// USB OTG FS clock enable + @ReadWrite(bits: 7..<8) + var otgfsen: OTGFSEN + + /// Random number generator clock enable + @ReadWrite(bits: 6..<7) + var rngen: RNGEN + + /// Hash modules clock enable + @ReadWrite(bits: 5..<6) + var hashen: HASHEN + + /// Cryptographic modules clock enable + @ReadWrite(bits: 4..<5) + var crypen: CRYPEN + + /// Camera interface enable + @ReadWrite(bits: 0..<1, as: DCMIENValues.self) + var dcmien: DCMIEN + } + + /// AHB3 peripheral clock enable register + @Register(bitWidth: 32) + struct AHB3ENR { + /// Flexible memory controller module clock enable + @ReadWrite(bits: 0..<1, as: FMCENValues.self) + var fmcen: FMCEN + + /// Quad SPI memory controller clock enable + @ReadWrite(bits: 1..<2) + var qspien: QSPIEN + } + + /// APB1 peripheral clock enable register + @Register(bitWidth: 32) + struct APB1ENR { + /// TIM2 clock enable + @ReadWrite(bits: 0..<1, as: TIM2ENValues.self) + var tim2en: TIM2EN + + /// TIM3 clock enable + @ReadWrite(bits: 1..<2) + var tim3en: TIM3EN + + /// TIM4 clock enable + @ReadWrite(bits: 2..<3) + var tim4en: TIM4EN + + /// TIM5 clock enable + @ReadWrite(bits: 3..<4) + var tim5en: TIM5EN + + /// TIM6 clock enable + @ReadWrite(bits: 4..<5) + var tim6en: TIM6EN + + /// TIM7 clock enable + @ReadWrite(bits: 5..<6) + var tim7en: TIM7EN + + /// TIM12 clock enable + @ReadWrite(bits: 6..<7) + var tim12en: TIM12EN + + /// TIM13 clock enable + @ReadWrite(bits: 7..<8) + var tim13en: TIM13EN + + /// TIM14 clock enable + @ReadWrite(bits: 8..<9) + var tim14en: TIM14EN + + /// Window watchdog clock enable + @ReadWrite(bits: 11..<12) + var wwdgen: WWDGEN + + /// SPI2 clock enable + @ReadWrite(bits: 14..<15) + var spi2en: SPI2EN + + /// SPI3 clock enable + @ReadWrite(bits: 15..<16) + var spi3en: SPI3EN + + /// USART 2 clock enable + @ReadWrite(bits: 17..<18) + var usart2en: USART2EN + + /// USART3 clock enable + @ReadWrite(bits: 18..<19) + var usart3en: USART3EN + + /// UART4 clock enable + @ReadWrite(bits: 19..<20) + var uart4en: UART4EN + + /// UART5 clock enable + @ReadWrite(bits: 20..<21) + var uart5en: UART5EN + + /// I2C1 clock enable + @ReadWrite(bits: 21..<22) + var i2c1en: I2C1EN + + /// I2C2 clock enable + @ReadWrite(bits: 22..<23) + var i2c2en: I2C2EN + + /// I2C3 clock enable + @ReadWrite(bits: 23..<24) + var i2c3en: I2C3EN + + /// CAN 1 clock enable + @ReadWrite(bits: 25..<26) + var can1en: CAN1EN + + /// CAN 2 clock enable + @ReadWrite(bits: 26..<27) + var can2en: CAN2EN + + /// Power interface clock enable + @ReadWrite(bits: 28..<29) + var pwren: PWREN + + /// DAC interface clock enable + @ReadWrite(bits: 29..<30) + var dacen: DACEN + + /// UART7 clock enable + @ReadWrite(bits: 30..<31) + var uart7en: UART7EN + + /// UART8 clock enable + @ReadWrite(bits: 31..<32) + var uart8en: UART8EN + + /// SPDIF-RX clock enable + @ReadWrite(bits: 16..<17) + var spdifrxen: SPDIFRXEN + + /// HDMI-CEN clock enable + @ReadWrite(bits: 27..<28) + var cecen: CECEN + + /// Low power timer 1 clock enable + @ReadWrite(bits: 9..<10) + var lptim1en: LPTIM1EN + + /// I2C4 clock enable + @ReadWrite(bits: 24..<25) + var i2c4en: I2C4EN + } + + /// APB2 peripheral clock enable register + @Register(bitWidth: 32) + struct APB2ENR { + /// TIM1 clock enable + @ReadWrite(bits: 0..<1, as: TIM1ENValues.self) + var tim1en: TIM1EN + + /// TIM8 clock enable + @ReadWrite(bits: 1..<2) + var tim8en: TIM8EN + + /// USART1 clock enable + @ReadWrite(bits: 4..<5) + var usart1en: USART1EN + + /// USART6 clock enable + @ReadWrite(bits: 5..<6) + var usart6en: USART6EN + + /// ADC1 clock enable + @ReadWrite(bits: 8..<9) + var adc1en: ADC1EN + + /// ADC2 clock enable + @ReadWrite(bits: 9..<10) + var adc2en: ADC2EN + + /// ADC3 clock enable + @ReadWrite(bits: 10..<11) + var adc3en: ADC3EN + + /// SPI1 clock enable + @ReadWrite(bits: 12..<13) + var spi1en: SPI1EN + + /// SPI4 clock enable + @ReadWrite(bits: 13..<14) + var spi4en: SPI4EN + + /// System configuration controller clock enable + @ReadWrite(bits: 14..<15) + var syscfgen: SYSCFGEN + + /// TIM9 clock enable + @ReadWrite(bits: 16..<17) + var tim9en: TIM9EN + + /// TIM10 clock enable + @ReadWrite(bits: 17..<18) + var tim10en: TIM10EN + + /// TIM11 clock enable + @ReadWrite(bits: 18..<19) + var tim11en: TIM11EN + + /// SPI5 clock enable + @ReadWrite(bits: 20..<21) + var spi5en: SPI5EN + + /// SPI6 clock enable + @ReadWrite(bits: 21..<22) + var spi6en: SPI6EN + + /// SAI1 clock enable + @ReadWrite(bits: 22..<23) + var sai1en: SAI1EN + + /// LTDC clock enable + @ReadWrite(bits: 26..<27) + var ltdcen: LTDCEN + + /// SAI2 clock enable + @ReadWrite(bits: 23..<24) + var sai2en: SAI2EN + + /// SDMMC1 clock enable + @ReadWrite(bits: 11..<12) + var sdmmc1en: SDMMC1EN + } + + /// AHB1 peripheral clock enable in low power mode register + @Register(bitWidth: 32) + struct AHB1LPENR { + /// IO port A clock enable during sleep mode + @ReadWrite(bits: 0..<1, as: GPIOALPENValues.self) + var gpioalpen: GPIOALPEN + + /// IO port B clock enable during Sleep mode + @ReadWrite(bits: 1..<2) + var gpioblpen: GPIOBLPEN + + /// IO port C clock enable during Sleep mode + @ReadWrite(bits: 2..<3) + var gpioclpen: GPIOCLPEN + + /// IO port D clock enable during Sleep mode + @ReadWrite(bits: 3..<4) + var gpiodlpen: GPIODLPEN + + /// IO port E clock enable during Sleep mode + @ReadWrite(bits: 4..<5) + var gpioelpen: GPIOELPEN + + /// IO port F clock enable during Sleep mode + @ReadWrite(bits: 5..<6) + var gpioflpen: GPIOFLPEN + + /// IO port G clock enable during Sleep mode + @ReadWrite(bits: 6..<7) + var gpioglpen: GPIOGLPEN + + /// IO port H clock enable during Sleep mode + @ReadWrite(bits: 7..<8) + var gpiohlpen: GPIOHLPEN + + /// IO port I clock enable during Sleep mode + @ReadWrite(bits: 8..<9) + var gpioilpen: GPIOILPEN + + /// IO port J clock enable during Sleep mode + @ReadWrite(bits: 9..<10) + var gpiojlpen: GPIOJLPEN + + /// IO port K clock enable during Sleep mode + @ReadWrite(bits: 10..<11) + var gpioklpen: GPIOKLPEN + + /// CRC clock enable during Sleep mode + @ReadWrite(bits: 12..<13) + var crclpen: CRCLPEN + + /// Flash interface clock enable during Sleep mode + @ReadWrite(bits: 15..<16) + var flitflpen: FLITFLPEN + + /// SRAM 1interface clock enable during Sleep mode + @ReadWrite(bits: 16..<17) + var sram1lpen: SRAM1LPEN + + /// SRAM 2 interface clock enable during Sleep mode + @ReadWrite(bits: 17..<18) + var sram2lpen: SRAM2LPEN + + /// Backup SRAM interface clock enable during Sleep mode + @ReadWrite(bits: 18..<19) + var bkpsramlpen: BKPSRAMLPEN + + /// SRAM 3 interface clock enable during Sleep mode + @ReadWrite(bits: 19..<20) + var sram3lpen: SRAM3LPEN + + /// DMA1 clock enable during Sleep mode + @ReadWrite(bits: 21..<22) + var dma1lpen: DMA1LPEN + + /// DMA2 clock enable during Sleep mode + @ReadWrite(bits: 22..<23) + var dma2lpen: DMA2LPEN + + /// DMA2D clock enable during Sleep mode + @ReadWrite(bits: 23..<24) + var dma2dlpen: DMA2DLPEN + + /// Ethernet MAC clock enable during Sleep mode + @ReadWrite(bits: 25..<26) + var ethmaclpen: ETHMACLPEN + + /// Ethernet transmission clock enable during Sleep mode + @ReadWrite(bits: 26..<27) + var ethmactxlpen: ETHMACTXLPEN + + /// Ethernet reception clock enable during Sleep mode + @ReadWrite(bits: 27..<28) + var ethmacrxlpen: ETHMACRXLPEN + + /// Ethernet PTP clock enable during Sleep mode + @ReadWrite(bits: 28..<29) + var ethmacptplpen: ETHMACPTPLPEN + + /// USB OTG HS clock enable during Sleep mode + @ReadWrite(bits: 29..<30) + var otghslpen: OTGHSLPEN + + /// USB OTG HS ULPI clock enable during Sleep mode + @ReadWrite(bits: 30..<31) + var otghsulpilpen: OTGHSULPILPEN + + /// AXI to AHB bridge clock enable during Sleep mode + @ReadWrite(bits: 13..<14) + var axilpen: AXILPEN + + /// DTCM RAM interface clock enable during Sleep mode + @ReadWrite(bits: 20..<21) + var dtcmlpen: DTCMLPEN + } + + /// AHB2 peripheral clock enable in low power mode register + @Register(bitWidth: 32) + struct AHB2LPENR { + /// USB OTG FS clock enable during Sleep mode + @ReadWrite(bits: 7..<8) + var otgfslpen: OTGFSLPEN + + /// Random number generator clock enable during Sleep mode + @ReadWrite(bits: 6..<7) + var rnglpen: RNGLPEN + + /// Hash modules clock enable during Sleep mode + @ReadWrite(bits: 5..<6) + var hashlpen: HASHLPEN + + /// Cryptography modules clock enable during Sleep mode + @ReadWrite(bits: 4..<5) + var cryplpen: CRYPLPEN + + /// Camera interface enable during Sleep mode + @ReadWrite(bits: 0..<1, as: DCMILPENValues.self) + var dcmilpen: DCMILPEN + } + + /// AHB3 peripheral clock enable in low power mode register + @Register(bitWidth: 32) + struct AHB3LPENR { + /// Flexible memory controller module clock enable during Sleep mode + @ReadWrite(bits: 0..<1, as: FMCLPENValues.self) + var fmclpen: FMCLPEN + + /// Quand SPI memory controller clock enable during Sleep mode + @ReadWrite(bits: 1..<2) + var qspilpen: QSPILPEN + } + + /// APB1 peripheral clock enable in low power mode register + @Register(bitWidth: 32) + struct APB1LPENR { + /// TIM2 clock enable during Sleep mode + @ReadWrite(bits: 0..<1, as: TIM2LPENValues.self) + var tim2lpen: TIM2LPEN + + /// TIM3 clock enable during Sleep mode + @ReadWrite(bits: 1..<2) + var tim3lpen: TIM3LPEN + + /// TIM4 clock enable during Sleep mode + @ReadWrite(bits: 2..<3) + var tim4lpen: TIM4LPEN + + /// TIM5 clock enable during Sleep mode + @ReadWrite(bits: 3..<4) + var tim5lpen: TIM5LPEN + + /// TIM6 clock enable during Sleep mode + @ReadWrite(bits: 4..<5) + var tim6lpen: TIM6LPEN + + /// TIM7 clock enable during Sleep mode + @ReadWrite(bits: 5..<6) + var tim7lpen: TIM7LPEN + + /// TIM12 clock enable during Sleep mode + @ReadWrite(bits: 6..<7) + var tim12lpen: TIM12LPEN + + /// TIM13 clock enable during Sleep mode + @ReadWrite(bits: 7..<8) + var tim13lpen: TIM13LPEN + + /// TIM14 clock enable during Sleep mode + @ReadWrite(bits: 8..<9) + var tim14lpen: TIM14LPEN + + /// Window watchdog clock enable during Sleep mode + @ReadWrite(bits: 11..<12) + var wwdglpen: WWDGLPEN + + /// SPI2 clock enable during Sleep mode + @ReadWrite(bits: 14..<15) + var spi2lpen: SPI2LPEN + + /// SPI3 clock enable during Sleep mode + @ReadWrite(bits: 15..<16) + var spi3lpen: SPI3LPEN + + /// USART2 clock enable during Sleep mode + @ReadWrite(bits: 17..<18) + var usart2lpen: USART2LPEN + + /// USART3 clock enable during Sleep mode + @ReadWrite(bits: 18..<19) + var usart3lpen: USART3LPEN + + /// UART4 clock enable during Sleep mode + @ReadWrite(bits: 19..<20) + var uart4lpen: UART4LPEN + + /// UART5 clock enable during Sleep mode + @ReadWrite(bits: 20..<21) + var uart5lpen: UART5LPEN + + /// I2C1 clock enable during Sleep mode + @ReadWrite(bits: 21..<22) + var i2c1lpen: I2C1LPEN + + /// I2C2 clock enable during Sleep mode + @ReadWrite(bits: 22..<23) + var i2c2lpen: I2C2LPEN + + /// I2C3 clock enable during Sleep mode + @ReadWrite(bits: 23..<24) + var i2c3lpen: I2C3LPEN + + /// CAN 1 clock enable during Sleep mode + @ReadWrite(bits: 25..<26) + var can1lpen: CAN1LPEN + + /// CAN 2 clock enable during Sleep mode + @ReadWrite(bits: 26..<27) + var can2lpen: CAN2LPEN + + /// Power interface clock enable during Sleep mode + @ReadWrite(bits: 28..<29) + var pwrlpen: PWRLPEN + + /// DAC interface clock enable during Sleep mode + @ReadWrite(bits: 29..<30) + var daclpen: DACLPEN + + /// UART7 clock enable during Sleep mode + @ReadWrite(bits: 30..<31) + var uart7lpen: UART7LPEN + + /// UART8 clock enable during Sleep mode + @ReadWrite(bits: 31..<32) + var uart8lpen: UART8LPEN + + /// SPDIF-RX clock enable during sleep mode + @ReadWrite(bits: 16..<17) + var spdifrxlpen: SPDIFRXLPEN + + /// HDMI-CEN clock enable during Sleep mode + @ReadWrite(bits: 27..<28) + var ceclpen: CECLPEN + + /// low power timer 1 clock enable during Sleep mode + @ReadWrite(bits: 9..<10) + var lptim1lpen: LPTIM1LPEN + + /// I2C4 clock enable during Sleep mode + @ReadWrite(bits: 24..<25) + var i2c4lpen: I2C4LPEN + } + + /// APB2 peripheral clock enabled in low power mode register + @Register(bitWidth: 32) + struct APB2LPENR { + /// TIM1 clock enable during Sleep mode + @ReadWrite(bits: 0..<1, as: TIM1LPENValues.self) + var tim1lpen: TIM1LPEN + + /// TIM8 clock enable during Sleep mode + @ReadWrite(bits: 1..<2) + var tim8lpen: TIM8LPEN + + /// USART1 clock enable during Sleep mode + @ReadWrite(bits: 4..<5) + var usart1lpen: USART1LPEN + + /// USART6 clock enable during Sleep mode + @ReadWrite(bits: 5..<6) + var usart6lpen: USART6LPEN + + /// ADC1 clock enable during Sleep mode + @ReadWrite(bits: 8..<9) + var adc1lpen: ADC1LPEN + + /// ADC2 clock enable during Sleep mode + @ReadWrite(bits: 9..<10) + var adc2lpen: ADC2LPEN + + /// ADC 3 clock enable during Sleep mode + @ReadWrite(bits: 10..<11) + var adc3lpen: ADC3LPEN + + /// SPI 1 clock enable during Sleep mode + @ReadWrite(bits: 12..<13) + var spi1lpen: SPI1LPEN + + /// SPI 4 clock enable during Sleep mode + @ReadWrite(bits: 13..<14) + var spi4lpen: SPI4LPEN + + /// System configuration controller clock enable during Sleep mode + @ReadWrite(bits: 14..<15) + var syscfglpen: SYSCFGLPEN + + /// TIM9 clock enable during sleep mode + @ReadWrite(bits: 16..<17) + var tim9lpen: TIM9LPEN + + /// TIM10 clock enable during Sleep mode + @ReadWrite(bits: 17..<18) + var tim10lpen: TIM10LPEN + + /// TIM11 clock enable during Sleep mode + @ReadWrite(bits: 18..<19) + var tim11lpen: TIM11LPEN + + /// SPI 5 clock enable during Sleep mode + @ReadWrite(bits: 20..<21) + var spi5lpen: SPI5LPEN + + /// SPI 6 clock enable during Sleep mode + @ReadWrite(bits: 21..<22) + var spi6lpen: SPI6LPEN + + /// SAI1 clock enable during sleep mode + @ReadWrite(bits: 22..<23) + var sai1lpen: SAI1LPEN + + /// LTDC clock enable during sleep mode + @ReadWrite(bits: 26..<27) + var ltdclpen: LTDCLPEN + + /// SAI2 clock enable during sleep mode + @ReadWrite(bits: 23..<24) + var sai2lpen: SAI2LPEN + + /// SDMMC1 clock enable during Sleep mode + @ReadWrite(bits: 11..<12) + var sdmmc1lpen: SDMMC1LPEN + } + + /// Backup domain control register + @Register(bitWidth: 32) + struct BDCR { + /// Backup domain software reset + @ReadWrite(bits: 16..<17, as: BDRSTValues.self) + var bdrst: BDRST + + /// RTC clock enable + @ReadWrite(bits: 15..<16, as: RTCENValues.self) + var rtcen: RTCEN + + /// External low-speed oscillator bypass + @ReadWrite(bits: 2..<3, as: LSEBYPValues.self) + var lsebyp: LSEBYP + + /// External low-speed oscillator ready + @ReadOnly(bits: 1..<2) + var lserdy: LSERDY + + /// External low-speed oscillator enable + @ReadWrite(bits: 0..<1, as: LSEONValues.self) + var lseon: LSEON + + /// LSE oscillator drive capability + @ReadWrite(bits: 3..<5, as: LSEDRVValues.self) + var lsedrv: LSEDRV + + /// RTC clock source selection + @Reserved(bits: 8..<10, as: RTCSELValues.self) + var rtcsel: RTCSEL + } + + /// clock control & status register + @Register(bitWidth: 32) + struct CSR { + /// Low-power reset flag + @ReadWrite(bits: 31..<32) + var lpwrrstf: LPWRRSTF + + /// Window watchdog reset flag + @ReadWrite(bits: 30..<31) + var wwdgrstf: WWDGRSTF + + /// Independent watchdog reset flag + @ReadWrite(bits: 29..<30) + var wdgrstf: WDGRSTF + + /// Software reset flag + @ReadWrite(bits: 28..<29) + var sftrstf: SFTRSTF + + /// POR/PDR reset flag + @ReadWrite(bits: 27..<28) + var porrstf: PORRSTF + + /// PIN reset flag + @ReadWrite(bits: 26..<27) + var padrstf: PADRSTF + + /// BOR reset flag + @ReadWrite(bits: 25..<26) + var borrstf: BORRSTF + + /// Remove reset flag + @ReadWrite(bits: 24..<25) + var rmvf: RMVF + + /// Internal low-speed oscillator ready + @ReadOnly(bits: 1..<2) + var lsirdy: LSIRDY + + /// Internal low-speed oscillator enable + @ReadWrite(bits: 0..<1, as: LSIONValues.self) + var lsion: LSION + } + + /// spread spectrum clock generation register + @Register(bitWidth: 32) + struct SSCGR { + /// Spread spectrum modulation enable + @ReadWrite(bits: 31..<32, as: SSCGENValues.self) + var sscgen: SSCGEN + + /// Spread Select + @ReadWrite(bits: 30..<31, as: SPREADSELValues.self) + var spreadsel: SPREADSEL + + /// Incrementation step + @ReadWrite(bits: 13..<28) + var incstep: INCSTEP + + /// Modulation period + @ReadWrite(bits: 0..<13) + var modper: MODPER + } + + /// PLLI2S configuration register + @Register(bitWidth: 32) + struct PLLI2SCFGR { + /// PLLI2S division factor for I2S clocks + @ReadWrite(bits: 28..<31) + var plli2sr: PLLI2SR + + /// PLLI2S division factor for SAI1 clock + @ReadWrite(bits: 24..<28) + var plli2sq: PLLI2SQ + + /// PLLI2S multiplication factor for VCO + @ReadWrite(bits: 6..<15) + var plli2sn: PLLI2SN + + /// PLLI2S division factor for SPDIFRX clock + @ReadWrite(bits: 16..<18, as: PLLI2SPValues.self) + var plli2sp: PLLI2SP + } + + /// PLL configuration register + @Register(bitWidth: 32) + struct PLLSAICFGR { + /// PLLSAI division factor for VCO + @ReadWrite(bits: 6..<15) + var pllsain: PLLSAIN + + /// PLLSAI division factor for 48MHz clock + @ReadWrite(bits: 16..<18, as: PLLSAIPValues.self) + var pllsaip: PLLSAIP + + /// PLLSAI division factor for SAI clock + @ReadWrite(bits: 24..<28) + var pllsaiq: PLLSAIQ + + /// PLLSAI division factor for LCD clock + @ReadWrite(bits: 28..<31) + var pllsair: PLLSAIR + } + + /// dedicated clocks configuration register + @Register(bitWidth: 32) + struct DCKCFGR1 { + /// PLLI2S division factor for SAI1 clock + @ReadWrite(bits: 0..<5, as: PLLI2SDIVQValues.self) + var plli2sdivq: PLLI2SDIVQ + + /// PLLSAI division factor for SAI1 clock + @ReadWrite(bits: 8..<13, as: PLLSAIDIVQValues.self) + var pllsaidivq: PLLSAIDIVQ + + /// division factor for LCD_CLK + @ReadWrite(bits: 16..<18, as: PLLSAIDIVRValues.self) + var pllsaidivr: PLLSAIDIVR + + /// SAI1 clock source selection + @ReadWrite(bits: 20..<22, as: SAI1SELValues.self) + var sai1sel: SAI1SEL + + /// SAI2 clock source selection + @ReadWrite(bits: 22..<24, as: SAI2SELValues.self) + var sai2sel: SAI2SEL + + /// Timers clocks prescalers selection + @ReadWrite(bits: 24..<25, as: TIMPREValues.self) + var timpre: TIMPRE + } + + /// dedicated clocks configuration register + @Register(bitWidth: 32) + struct DCKCFGR2 { + /// USART 1 clock source selection + @ReadWrite(bits: 0..<2, as: USART1SELValues.self) + var usart1sel: USART1SEL + + /// USART 2 clock source selection + @ReadWrite(bits: 2..<4, as: USART2SELValues.self) + var usart2sel: USART2SEL + + /// USART 3 clock source selection + @ReadWrite(bits: 4..<6) + var usart3sel: USART3SEL + + /// UART 4 clock source selection + @ReadWrite(bits: 6..<8) + var uart4sel: UART4SEL + + /// UART 5 clock source selection + @ReadWrite(bits: 8..<10) + var uart5sel: UART5SEL + + /// USART 6 clock source selection + @ReadWrite(bits: 10..<12) + var usart6sel: USART6SEL + + /// UART 7 clock source selection + @ReadWrite(bits: 12..<14) + var uart7sel: UART7SEL + + /// UART 8 clock source selection + @ReadWrite(bits: 14..<16) + var uart8sel: UART8SEL + + /// I2C1 clock source selection + @ReadWrite(bits: 16..<18, as: I2C1SELValues.self) + var i2c1sel: I2C1SEL + + /// I2C2 clock source selection + @ReadWrite(bits: 18..<20) + var i2c2sel: I2C2SEL + + /// I2C3 clock source selection + @ReadWrite(bits: 20..<22) + var i2c3sel: I2C3SEL + + /// I2C4 clock source selection + @ReadWrite(bits: 22..<24) + var i2c4sel: I2C4SEL + + /// Low power timer 1 clock source selection + @ReadWrite(bits: 24..<26, as: LPTIM1SELValues.self) + var lptim1sel: LPTIM1SEL + + /// HDMI-CEC clock source selection + @ReadWrite(bits: 26..<27, as: CECSELValues.self) + var cecsel: CECSEL + + /// 48MHz clock source selection + @ReadWrite(bits: 27..<28, as: CK48MSELValues.self) + var ck48msel: CK48MSEL + + /// SDMMC clock source selection + @ReadWrite(bits: 28..<29, as: SDMMC1SELValues.self) + var sdmmc1sel: SDMMC1SEL + } +} + +extension RCC.CR { + struct CSSONValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// Clock security system disabled (clock detector OFF) + static let Off = Self(rawValue: 0x0) + + /// Clock security system enable (clock detector ON if the HSE is ready, OFF if not) + static let On = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.CR { + struct HSEBYPValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// HSE crystal oscillator not bypassed + static let NotBypassed = Self(rawValue: 0x0) + + /// HSE crystal oscillator bypassed with external clock + static let Bypassed = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.CR { + struct HSIONValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// Clock Off + static let Off = Self(rawValue: 0x0) + + /// Clock On + static let On = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.PLLCFGR { + struct PLLSRCValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// HSI clock selected as PLL and PLLI2S clock entry + static let HSI = Self(rawValue: 0x0) + + /// HSE oscillator clock selected as PLL and PLLI2S clock entry + static let HSE = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.PLLCFGR { + struct PLLPValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 2 + + /// PLLP=2 + static let Div2 = Self(rawValue: 0x0) + + /// PLLP=4 + static let Div4 = Self(rawValue: 0x1) + + /// PLLP=6 + static let Div6 = Self(rawValue: 0x2) + + /// PLLP=8 + static let Div8 = Self(rawValue: 0x3) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.CFGR { + struct MCO2Values: BitFieldProjectable, RawRepresentable { + static let bitWidth = 2 + + /// System clock (SYSCLK) selected + static let SYSCLK = Self(rawValue: 0x0) + + /// PLLI2S clock selected + static let PLLI2S = Self(rawValue: 0x1) + + /// HSE oscillator clock selected + static let HSE = Self(rawValue: 0x2) + + /// PLL clock selected + static let PLL = Self(rawValue: 0x3) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.CFGR { + struct MCO1PREValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 3 + + /// No division + static let Div1 = Self(rawValue: 0x0) + + /// Division by 2 + static let Div2 = Self(rawValue: 0x4) + + /// Division by 3 + static let Div3 = Self(rawValue: 0x5) + + /// Division by 4 + static let Div4 = Self(rawValue: 0x6) + + /// Division by 5 + static let Div5 = Self(rawValue: 0x7) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.CFGR { + struct I2SSRCValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// PLLI2S clock used as I2S clock source + static let PLLI2S = Self(rawValue: 0x0) + + /// External clock mapped on the I2S_CKIN pin used as I2S clock source + static let CKIN = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.CFGR { + struct MCO1Values: BitFieldProjectable, RawRepresentable { + static let bitWidth = 2 + + /// HSI clock selected + static let HSI = Self(rawValue: 0x0) + + /// LSE oscillator selected + static let LSE = Self(rawValue: 0x1) + + /// HSE oscillator clock selected + static let HSE = Self(rawValue: 0x2) + + /// PLL clock selected + static let PLL = Self(rawValue: 0x3) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.CFGR { + struct PPRE1Values: BitFieldProjectable, RawRepresentable { + static let bitWidth = 3 + + /// HCLK not divided + static let Div1 = Self(rawValue: 0x0) + + /// HCLK divided by 2 + static let Div2 = Self(rawValue: 0x4) + + /// HCLK divided by 4 + static let Div4 = Self(rawValue: 0x5) + + /// HCLK divided by 8 + static let Div8 = Self(rawValue: 0x6) + + /// HCLK divided by 16 + static let Div16 = Self(rawValue: 0x7) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.CFGR { + struct HPREValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 4 + + /// SYSCLK not divided + static let Div1 = Self(rawValue: 0x0) + + /// SYSCLK divided by 2 + static let Div2 = Self(rawValue: 0x8) + + /// SYSCLK divided by 4 + static let Div4 = Self(rawValue: 0x9) + + /// SYSCLK divided by 8 + static let Div8 = Self(rawValue: 0xa) + + /// SYSCLK divided by 16 + static let Div16 = Self(rawValue: 0xb) + + /// SYSCLK divided by 64 + static let Div64 = Self(rawValue: 0xc) + + /// SYSCLK divided by 128 + static let Div128 = Self(rawValue: 0xd) + + /// SYSCLK divided by 256 + static let Div256 = Self(rawValue: 0xe) + + /// SYSCLK divided by 512 + static let Div512 = Self(rawValue: 0xf) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.CFGR { + struct SWValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 2 + + /// HSI selected as system clock + static let HSI = Self(rawValue: 0x0) + + /// HSE selected as system clock + static let HSE = Self(rawValue: 0x1) + + /// PLL selected as system clock + static let PLL = Self(rawValue: 0x2) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.CIR { + struct LSIRDYIEValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// Interrupt disabled + static let Disabled = Self(rawValue: 0x0) + + /// Interrupt enabled + static let Enabled = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.AHB1RSTR { + struct GPIOARSTValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// Reset the selected module + static let Reset = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.AHB2RSTR { + struct DCMIRSTValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// Reset the selected module + static let Reset = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.AHB3RSTR { + struct FMCRSTValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// Reset the selected module + static let Reset = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.APB1RSTR { + struct TIM2RSTValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// Reset the selected module + static let Reset = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.APB2RSTR { + struct TIM1RSTValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// Reset the selected module + static let Reset = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.AHB1ENR { + struct GPIOAENValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// The selected clock is disabled + static let Disabled = Self(rawValue: 0x0) + + /// The selected clock is enabled + static let Enabled = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.AHB2ENR { + struct DCMIENValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// The selected clock is disabled + static let Disabled = Self(rawValue: 0x0) + + /// The selected clock is enabled + static let Enabled = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.AHB3ENR { + struct FMCENValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// The selected clock is disabled + static let Disabled = Self(rawValue: 0x0) + + /// The selected clock is enabled + static let Enabled = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.APB1ENR { + struct TIM2ENValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// The selected clock is disabled + static let Disabled = Self(rawValue: 0x0) + + /// The selected clock is enabled + static let Enabled = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.APB2ENR { + struct TIM1ENValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// The selected clock is disabled + static let Disabled = Self(rawValue: 0x0) + + /// The selected clock is enabled + static let Enabled = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.AHB1LPENR { + struct GPIOALPENValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// Selected module is disabled during Sleep mode + static let DisabledInSleep = Self(rawValue: 0x0) + + /// Selected module is enabled during Sleep mode + static let EnabledInSleep = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.AHB2LPENR { + struct DCMILPENValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// Selected module is disabled during Sleep mode + static let DisabledInSleep = Self(rawValue: 0x0) + + /// Selected module is enabled during Sleep mode + static let EnabledInSleep = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.AHB3LPENR { + struct FMCLPENValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// Selected module is disabled during Sleep mode + static let DisabledInSleep = Self(rawValue: 0x0) + + /// Selected module is enabled during Sleep mode + static let EnabledInSleep = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.APB1LPENR { + struct TIM2LPENValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// Selected module is disabled during Sleep mode + static let DisabledInSleep = Self(rawValue: 0x0) + + /// Selected module is enabled during Sleep mode + static let EnabledInSleep = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.APB2LPENR { + struct TIM1LPENValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// Selected module is disabled during Sleep mode + static let DisabledInSleep = Self(rawValue: 0x0) + + /// Selected module is enabled during Sleep mode + static let EnabledInSleep = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.BDCR { + struct BDRSTValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// Reset not activated + static let Disabled = Self(rawValue: 0x0) + + /// Reset the entire RTC domain + static let Enabled = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.BDCR { + struct RTCENValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// RTC clock disabled + static let Disabled = Self(rawValue: 0x0) + + /// RTC clock enabled + static let Enabled = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.BDCR { + struct LSEBYPValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// LSE crystal oscillator not bypassed + static let NotBypassed = Self(rawValue: 0x0) + + /// LSE crystal oscillator bypassed with external clock + static let Bypassed = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.BDCR { + struct LSEONValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// LSE oscillator Off + static let Off = Self(rawValue: 0x0) + + /// LSE oscillator On + static let On = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.BDCR { + struct LSEDRVValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 2 + + /// Low drive capacity + static let Low = Self(rawValue: 0x0) + + /// Medium-high drive capacity + static let MediumHigh = Self(rawValue: 0x1) + + /// Medium-low drive capacity + static let MediumLow = Self(rawValue: 0x2) + + /// High drive capacity + static let High = Self(rawValue: 0x3) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.BDCR { + struct RTCSELValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 2 + + /// No clock + static let NoClock = Self(rawValue: 0x0) + + /// LSE oscillator clock used as RTC clock + static let LSE = Self(rawValue: 0x1) + + /// LSI oscillator clock used as RTC clock + static let LSI = Self(rawValue: 0x2) + + /// HSE oscillator clock divided by a prescaler used as RTC clock + static let HSE = Self(rawValue: 0x3) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.CSR { + struct LSIONValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// LSI oscillator Off + static let Off = Self(rawValue: 0x0) + + /// LSI oscillator On + static let On = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.SSCGR { + struct SSCGENValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// Spread spectrum modulation disabled + static let Disabled = Self(rawValue: 0x0) + + /// Spread spectrum modulation enabled + static let Enabled = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.SSCGR { + struct SPREADSELValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// Center spread + static let Center = Self(rawValue: 0x0) + + /// Down spread + static let Down = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.PLLI2SCFGR { + struct PLLI2SPValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 2 + + /// PLL*P=2 + static let Div2 = Self(rawValue: 0x0) + + /// PLL*P=4 + static let Div4 = Self(rawValue: 0x1) + + /// PLL*P=6 + static let Div6 = Self(rawValue: 0x2) + + /// PLL*P=8 + static let Div8 = Self(rawValue: 0x3) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.PLLSAICFGR { + struct PLLSAIPValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 2 + + /// PLL*P=2 + static let Div2 = Self(rawValue: 0x0) + + /// PLL*P=4 + static let Div4 = Self(rawValue: 0x1) + + /// PLL*P=6 + static let Div6 = Self(rawValue: 0x2) + + /// PLL*P=8 + static let Div8 = Self(rawValue: 0x3) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.DCKCFGR1 { + struct PLLI2SDIVQValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 5 + + /// PLLI2SDIVQ = /1 + static let Div1 = Self(rawValue: 0x0) + + /// PLLI2SDIVQ = /2 + static let Div2 = Self(rawValue: 0x1) + + /// PLLI2SDIVQ = /3 + static let Div3 = Self(rawValue: 0x2) + + /// PLLI2SDIVQ = /4 + static let Div4 = Self(rawValue: 0x3) + + /// PLLI2SDIVQ = /5 + static let Div5 = Self(rawValue: 0x4) + + /// PLLI2SDIVQ = /6 + static let Div6 = Self(rawValue: 0x5) + + /// PLLI2SDIVQ = /7 + static let Div7 = Self(rawValue: 0x6) + + /// PLLI2SDIVQ = /8 + static let Div8 = Self(rawValue: 0x7) + + /// PLLI2SDIVQ = /9 + static let Div9 = Self(rawValue: 0x8) + + /// PLLI2SDIVQ = /10 + static let Div10 = Self(rawValue: 0x9) + + /// PLLI2SDIVQ = /11 + static let Div11 = Self(rawValue: 0xa) + + /// PLLI2SDIVQ = /12 + static let Div12 = Self(rawValue: 0xb) + + /// PLLI2SDIVQ = /13 + static let Div13 = Self(rawValue: 0xc) + + /// PLLI2SDIVQ = /14 + static let Div14 = Self(rawValue: 0xd) + + /// PLLI2SDIVQ = /15 + static let Div15 = Self(rawValue: 0xe) + + /// PLLI2SDIVQ = /16 + static let Div16 = Self(rawValue: 0xf) + + /// PLLI2SDIVQ = /17 + static let Div17 = Self(rawValue: 0x10) + + /// PLLI2SDIVQ = /18 + static let Div18 = Self(rawValue: 0x11) + + /// PLLI2SDIVQ = /19 + static let Div19 = Self(rawValue: 0x12) + + /// PLLI2SDIVQ = /20 + static let Div20 = Self(rawValue: 0x13) + + /// PLLI2SDIVQ = /21 + static let Div21 = Self(rawValue: 0x14) + + /// PLLI2SDIVQ = /22 + static let Div22 = Self(rawValue: 0x15) + + /// PLLI2SDIVQ = /23 + static let Div23 = Self(rawValue: 0x16) + + /// PLLI2SDIVQ = /24 + static let Div24 = Self(rawValue: 0x17) + + /// PLLI2SDIVQ = /25 + static let Div25 = Self(rawValue: 0x18) + + /// PLLI2SDIVQ = /26 + static let Div26 = Self(rawValue: 0x19) + + /// PLLI2SDIVQ = /27 + static let Div27 = Self(rawValue: 0x1a) + + /// PLLI2SDIVQ = /28 + static let Div28 = Self(rawValue: 0x1b) + + /// PLLI2SDIVQ = /29 + static let Div29 = Self(rawValue: 0x1c) + + /// PLLI2SDIVQ = /30 + static let Div30 = Self(rawValue: 0x1d) + + /// PLLI2SDIVQ = /31 + static let Div31 = Self(rawValue: 0x1e) + + /// PLLI2SDIVQ = /32 + static let Div32 = Self(rawValue: 0x1f) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.DCKCFGR1 { + struct PLLSAIDIVQValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 5 + + /// PLLSAIDIVQ = /1 + static let Div1 = Self(rawValue: 0x0) + + /// PLLSAIDIVQ = /2 + static let Div2 = Self(rawValue: 0x1) + + /// PLLSAIDIVQ = /3 + static let Div3 = Self(rawValue: 0x2) + + /// PLLSAIDIVQ = /4 + static let Div4 = Self(rawValue: 0x3) + + /// PLLSAIDIVQ = /5 + static let Div5 = Self(rawValue: 0x4) + + /// PLLSAIDIVQ = /6 + static let Div6 = Self(rawValue: 0x5) + + /// PLLSAIDIVQ = /7 + static let Div7 = Self(rawValue: 0x6) + + /// PLLSAIDIVQ = /8 + static let Div8 = Self(rawValue: 0x7) + + /// PLLSAIDIVQ = /9 + static let Div9 = Self(rawValue: 0x8) + + /// PLLSAIDIVQ = /10 + static let Div10 = Self(rawValue: 0x9) + + /// PLLSAIDIVQ = /11 + static let Div11 = Self(rawValue: 0xa) + + /// PLLSAIDIVQ = /12 + static let Div12 = Self(rawValue: 0xb) + + /// PLLSAIDIVQ = /13 + static let Div13 = Self(rawValue: 0xc) + + /// PLLSAIDIVQ = /14 + static let Div14 = Self(rawValue: 0xd) + + /// PLLSAIDIVQ = /15 + static let Div15 = Self(rawValue: 0xe) + + /// PLLSAIDIVQ = /16 + static let Div16 = Self(rawValue: 0xf) + + /// PLLSAIDIVQ = /17 + static let Div17 = Self(rawValue: 0x10) + + /// PLLSAIDIVQ = /18 + static let Div18 = Self(rawValue: 0x11) + + /// PLLSAIDIVQ = /19 + static let Div19 = Self(rawValue: 0x12) + + /// PLLSAIDIVQ = /20 + static let Div20 = Self(rawValue: 0x13) + + /// PLLSAIDIVQ = /21 + static let Div21 = Self(rawValue: 0x14) + + /// PLLSAIDIVQ = /22 + static let Div22 = Self(rawValue: 0x15) + + /// PLLSAIDIVQ = /23 + static let Div23 = Self(rawValue: 0x16) + + /// PLLSAIDIVQ = /24 + static let Div24 = Self(rawValue: 0x17) + + /// PLLSAIDIVQ = /25 + static let Div25 = Self(rawValue: 0x18) + + /// PLLSAIDIVQ = /26 + static let Div26 = Self(rawValue: 0x19) + + /// PLLSAIDIVQ = /27 + static let Div27 = Self(rawValue: 0x1a) + + /// PLLSAIDIVQ = /28 + static let Div28 = Self(rawValue: 0x1b) + + /// PLLSAIDIVQ = /29 + static let Div29 = Self(rawValue: 0x1c) + + /// PLLSAIDIVQ = /30 + static let Div30 = Self(rawValue: 0x1d) + + /// PLLSAIDIVQ = /31 + static let Div31 = Self(rawValue: 0x1e) + + /// PLLSAIDIVQ = /32 + static let Div32 = Self(rawValue: 0x1f) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.DCKCFGR1 { + struct PLLSAIDIVRValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 2 + + /// PLLSAIDIVR = /2 + static let Div2 = Self(rawValue: 0x0) + + /// PLLSAIDIVR = /4 + static let Div4 = Self(rawValue: 0x1) + + /// PLLSAIDIVR = /8 + static let Div8 = Self(rawValue: 0x2) + + /// PLLSAIDIVR = /16 + static let Div16 = Self(rawValue: 0x3) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.DCKCFGR1 { + struct SAI1SELValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 2 + + /// SAI1 clock frequency = f(PLLSAI_Q) / PLLSAIDIVQ + static let PLLSAI = Self(rawValue: 0x0) + + /// SAI1 clock frequency = f(PLLI2S_Q) / PLLI2SDIVQ + static let PLLI2S = Self(rawValue: 0x1) + + /// SAI1 clock frequency = Alternate function input frequency + static let AFIF = Self(rawValue: 0x2) + + /// SAI1 clock frequency = HSI or HSE + static let HSI_HSE = Self(rawValue: 0x3) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.DCKCFGR1 { + struct SAI2SELValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 2 + + /// SAI2 clock frequency = f(PLLSAI_Q) / PLLSAIDIVQ + static let PLLSAI = Self(rawValue: 0x0) + + /// SAI2 clock frequency = f(PLLI2S_Q) / PLLI2SDIVQ + static let PLLI2S = Self(rawValue: 0x1) + + /// SAI2 clock frequency = Alternate function input frequency + static let AFIF = Self(rawValue: 0x2) + + /// SAI2 clock frequency = HSI or HSE + static let HSI_HSE = Self(rawValue: 0x3) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.DCKCFGR1 { + struct TIMPREValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// If the APB prescaler is configured 1, TIMxCLK = PCLKx. Otherwise, TIMxCLK = 2xPCLKx + static let Mul1Or2 = Self(rawValue: 0x0) + + /// If the APB prescaler is configured 1, 2 or 4, TIMxCLK = HCLK. Otherwise, TIMxCLK = 4xPCLKx + static let Mul1Or4 = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.DCKCFGR2 { + struct USART1SELValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 2 + + /// APB2 clock (PCLK2) is selected as USART clock + static let APB2 = Self(rawValue: 0x0) + + /// System clock is selected as USART clock + static let SYSCLK = Self(rawValue: 0x1) + + /// HSI clock is selected as USART clock + static let HSI = Self(rawValue: 0x2) + + /// LSE clock is selected as USART clock + static let LSE = Self(rawValue: 0x3) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.DCKCFGR2 { + struct USART2SELValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 2 + + /// APB1 clock (PCLK1) is selected as USART clock + static let APB1 = Self(rawValue: 0x0) + + /// System clock is selected as USART clock + static let SYSCLK = Self(rawValue: 0x1) + + /// HSI clock is selected as USART clock + static let HSI = Self(rawValue: 0x2) + + /// LSE clock is selected as USART clock + static let LSE = Self(rawValue: 0x3) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.DCKCFGR2 { + struct I2C1SELValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 2 + + /// APB clock selected as I2C clock + static let APB = Self(rawValue: 0x0) + + /// System clock selected as I2C clock + static let SYSCLK = Self(rawValue: 0x1) + + /// HSI clock selected as I2C clock + static let HSI = Self(rawValue: 0x2) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.DCKCFGR2 { + struct LPTIM1SELValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 2 + + /// APB1 clock (PCLK1) selected as LPTILM1 clock + static let APB1 = Self(rawValue: 0x0) + + /// LSI clock is selected as LPTILM1 clock + static let LSI = Self(rawValue: 0x1) + + /// HSI clock is selected as LPTILM1 clock + static let HSI = Self(rawValue: 0x2) + + /// LSE clock is selected as LPTILM1 clock + static let LSE = Self(rawValue: 0x3) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.DCKCFGR2 { + struct CECSELValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// LSE clock is selected as HDMI-CEC clock + static let LSE = Self(rawValue: 0x0) + + /// HSI divided by 488 clock is selected as HDMI-CEC clock + static let HSI_Div488 = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.DCKCFGR2 { + struct CK48MSELValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// 48MHz clock from PLL is selected + static let PLL = Self(rawValue: 0x0) + + /// 48MHz clock from PLLSAI is selected + static let PLLSAI = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} + +extension RCC.DCKCFGR2 { + struct SDMMC1SELValues: BitFieldProjectable, RawRepresentable { + static let bitWidth = 1 + + /// 48 MHz clock is selected as SD clock + static let CK48M = Self(rawValue: 0x0) + + /// System clock is selected as SD clock + static let SYSCLK = Self(rawValue: 0x1) + + var rawValue: UInt8 + + @inlinable @inline(__always) + init(rawValue: Self.RawValue) { + self.rawValue = rawValue + } + } +} diff --git a/stm32-lcd-logo/Sources/Application/USART.swift b/stm32-lcd-logo/Sources/Application/USART.swift deleted file mode 100644 index cba4e102..00000000 --- a/stm32-lcd-logo/Sources/Application/USART.swift +++ /dev/null @@ -1,1291 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// This source file is part of the Swift open source project -// -// Copyright (c) 2023 Apple Inc. and the Swift project authors. -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See https://swift.org/LICENSE.txt for license information -// -//===----------------------------------------------------------------------===// - -// swift-format-ignore-file - -/// Universal synchronous asynchronous receiver transmitter -struct USART { - var baseAddress: UnsafeMutableRawPointer - - enum Offsets { - static let CR1: Int32 = 0x0 - static let CR2: Int32 = 0x4 - static let CR3: Int32 = 0x8 - static let BRR: Int32 = 0xc - static let GTPR: Int32 = 0x10 - static let RTOR: Int32 = 0x14 - static let RQR: Int32 = 0x18 - static let ISR: Int32 = 0x1c - static let ICR: Int32 = 0x20 - static let RDR: Int32 = 0x24 - static let TDR: Int32 = 0x28 - } - - private func ld(_ offset: Int32) -> UInt32 { - UnsafeMutablePointer(bitPattern: UInt(bitPattern: UnsafeMutableRawPointer(baseAddress).advanced(by: Int(offset))))!.volatileLoad() - } - - private func st(_ offset: Int32, _ value: UInt32) { - UnsafeMutablePointer(bitPattern: UInt(bitPattern: UnsafeMutableRawPointer(baseAddress).advanced(by: Int(offset))))!.volatileStore(value) - } - - /// Control register 1 - var cr1: CR1 { - get { CR1(rawValue: ld(Offsets.CR1)) } - set { st(Offsets.CR1, newValue.rawValue) } - } - /// Control register 2 - var cr2: CR2 { - get { CR2(rawValue: ld(Offsets.CR2)) } - set { st(Offsets.CR2, newValue.rawValue) } - } - /// Control register 3 - var cr3: CR3 { - get { CR3(rawValue: ld(Offsets.CR3)) } - set { st(Offsets.CR3, newValue.rawValue) } - } - /// Baud rate register - var brr: BRR { - get { BRR(rawValue: ld(Offsets.BRR)) } - set { st(Offsets.BRR, newValue.rawValue) } - } - /// Guard time and prescaler register - var gtpr: GTPR { - get { GTPR(rawValue: ld(Offsets.GTPR)) } - set { st(Offsets.GTPR, newValue.rawValue) } - } - /// Receiver timeout register - var rtor: RTOR { - get { RTOR(rawValue: ld(Offsets.RTOR)) } - set { st(Offsets.RTOR, newValue.rawValue) } - } - /// Request register - var rqr: RQR { - get { RQR(rawValue: ld(Offsets.RQR)) } - set { st(Offsets.RQR, newValue.rawValue) } - } - /// Interrupt & status register - var isr: ISR { - get { ISR(rawValue: ld(Offsets.ISR)) } - set { st(Offsets.ISR, newValue.rawValue) } - } - /// Interrupt flag clear register - var icr: ICR { - get { ICR(rawValue: ld(Offsets.ICR)) } - set { st(Offsets.ICR, newValue.rawValue) } - } - /// Receive data register - var rdr: RDR { - get { RDR(rawValue: ld(Offsets.RDR)) } - set { st(Offsets.RDR, newValue.rawValue) } - } - /// Transmit data register - var tdr: TDR { - get { TDR(rawValue: ld(Offsets.TDR)) } - set { st(Offsets.TDR, newValue.rawValue) } - } -} - -extension USART { - struct CR1 { - var rawValue: UInt32 - - static let m1_offset = UInt32(28) - static let m1_mask = UInt32(0b1) &<< m1_offset - var m1: UInt8 { - get { UInt8((self.rawValue & (USART.CR1.m1_mask)) >> USART.CR1.m1_offset) } - set { - let preserve = self.rawValue & ~USART.CR1.m1_mask - let shift = (UInt32(newValue) << USART.CR1.m1_offset) & USART.CR1.m1_mask - self.rawValue = preserve | shift - } - } - - static let eobie_offset = UInt32(27) - static let eobie_mask = UInt32(0b1) &<< eobie_offset - var eobie: UInt8 { - get { UInt8((self.rawValue & (USART.CR1.eobie_mask)) >> USART.CR1.eobie_offset) } - set { - let preserve = self.rawValue & ~USART.CR1.eobie_mask - let shift = (UInt32(newValue) << USART.CR1.eobie_offset) & USART.CR1.eobie_mask - self.rawValue = preserve | shift - } - } - - static let rtoie_offset = UInt32(26) - static let rtoie_mask = UInt32(0b1) &<< rtoie_offset - var rtoie: UInt8 { - get { UInt8((self.rawValue & (USART.CR1.rtoie_mask)) >> USART.CR1.rtoie_offset) } - set { - let preserve = self.rawValue & ~USART.CR1.rtoie_mask - let shift = (UInt32(newValue) << USART.CR1.rtoie_offset) & USART.CR1.rtoie_mask - self.rawValue = preserve | shift - } - } - - static let deat4_offset = UInt32(25) - static let deat4_mask = UInt32(0b1) &<< deat4_offset - var deat4: UInt8 { - get { UInt8((self.rawValue & (USART.CR1.deat4_mask)) >> USART.CR1.deat4_offset) } - set { - let preserve = self.rawValue & ~USART.CR1.deat4_mask - let shift = (UInt32(newValue) << USART.CR1.deat4_offset) & USART.CR1.deat4_mask - self.rawValue = preserve | shift - } - } - - static let deat3_offset = UInt32(24) - static let deat3_mask = UInt32(0b1) &<< deat3_offset - var deat3: UInt8 { - get { UInt8((self.rawValue & (USART.CR1.deat3_mask)) >> USART.CR1.deat3_offset) } - set { - let preserve = self.rawValue & ~USART.CR1.deat3_mask - let shift = (UInt32(newValue) << USART.CR1.deat3_offset) & USART.CR1.deat3_mask - self.rawValue = preserve | shift - } - } - - static let deat2_offset = UInt32(23) - static let deat2_mask = UInt32(0b1) &<< deat2_offset - var deat2: UInt8 { - get { UInt8((self.rawValue & (USART.CR1.deat2_mask)) >> USART.CR1.deat2_offset) } - set { - let preserve = self.rawValue & ~USART.CR1.deat2_mask - let shift = (UInt32(newValue) << USART.CR1.deat2_offset) & USART.CR1.deat2_mask - self.rawValue = preserve | shift - } - } - - static let deat1_offset = UInt32(22) - static let deat1_mask = UInt32(0b1) &<< deat1_offset - var deat1: UInt8 { - get { UInt8((self.rawValue & (USART.CR1.deat1_mask)) >> USART.CR1.deat1_offset) } - set { - let preserve = self.rawValue & ~USART.CR1.deat1_mask - let shift = (UInt32(newValue) << USART.CR1.deat1_offset) & USART.CR1.deat1_mask - self.rawValue = preserve | shift - } - } - - static let deat0_offset = UInt32(21) - static let deat0_mask = UInt32(0b1) &<< deat0_offset - var deat0: UInt8 { - get { UInt8((self.rawValue & (USART.CR1.deat0_mask)) >> USART.CR1.deat0_offset) } - set { - let preserve = self.rawValue & ~USART.CR1.deat0_mask - let shift = (UInt32(newValue) << USART.CR1.deat0_offset) & USART.CR1.deat0_mask - self.rawValue = preserve | shift - } - } - - static let dedt4_offset = UInt32(20) - static let dedt4_mask = UInt32(0b1) &<< dedt4_offset - var dedt4: UInt8 { - get { UInt8((self.rawValue & (USART.CR1.dedt4_mask)) >> USART.CR1.dedt4_offset) } - set { - let preserve = self.rawValue & ~USART.CR1.dedt4_mask - let shift = (UInt32(newValue) << USART.CR1.dedt4_offset) & USART.CR1.dedt4_mask - self.rawValue = preserve | shift - } - } - - static let dedt3_offset = UInt32(19) - static let dedt3_mask = UInt32(0b1) &<< dedt3_offset - var dedt3: UInt8 { - get { UInt8((self.rawValue & (USART.CR1.dedt3_mask)) >> USART.CR1.dedt3_offset) } - set { - let preserve = self.rawValue & ~USART.CR1.dedt3_mask - let shift = (UInt32(newValue) << USART.CR1.dedt3_offset) & USART.CR1.dedt3_mask - self.rawValue = preserve | shift - } - } - - static let dedt2_offset = UInt32(18) - static let dedt2_mask = UInt32(0b1) &<< dedt2_offset - var dedt2: UInt8 { - get { UInt8((self.rawValue & (USART.CR1.dedt2_mask)) >> USART.CR1.dedt2_offset) } - set { - let preserve = self.rawValue & ~USART.CR1.dedt2_mask - let shift = (UInt32(newValue) << USART.CR1.dedt2_offset) & USART.CR1.dedt2_mask - self.rawValue = preserve | shift - } - } - - static let dedt1_offset = UInt32(17) - static let dedt1_mask = UInt32(0b1) &<< dedt1_offset - var dedt1: UInt8 { - get { UInt8((self.rawValue & (USART.CR1.dedt1_mask)) >> USART.CR1.dedt1_offset) } - set { - let preserve = self.rawValue & ~USART.CR1.dedt1_mask - let shift = (UInt32(newValue) << USART.CR1.dedt1_offset) & USART.CR1.dedt1_mask - self.rawValue = preserve | shift - } - } - - static let dedt0_offset = UInt32(16) - static let dedt0_mask = UInt32(0b1) &<< dedt0_offset - var dedt0: UInt8 { - get { UInt8((self.rawValue & (USART.CR1.dedt0_mask)) >> USART.CR1.dedt0_offset) } - set { - let preserve = self.rawValue & ~USART.CR1.dedt0_mask - let shift = (UInt32(newValue) << USART.CR1.dedt0_offset) & USART.CR1.dedt0_mask - self.rawValue = preserve | shift - } - } - - static let over8_offset = UInt32(15) - static let over8_mask = UInt32(0b1) &<< over8_offset - var over8: UInt8 { - get { UInt8((self.rawValue & (USART.CR1.over8_mask)) >> USART.CR1.over8_offset) } - set { - let preserve = self.rawValue & ~USART.CR1.over8_mask - let shift = (UInt32(newValue) << USART.CR1.over8_offset) & USART.CR1.over8_mask - self.rawValue = preserve | shift - } - } - - static let cmie_offset = UInt32(14) - static let cmie_mask = UInt32(0b1) &<< cmie_offset - var cmie: UInt8 { - get { UInt8((self.rawValue & (USART.CR1.cmie_mask)) >> USART.CR1.cmie_offset) } - set { - let preserve = self.rawValue & ~USART.CR1.cmie_mask - let shift = (UInt32(newValue) << USART.CR1.cmie_offset) & USART.CR1.cmie_mask - self.rawValue = preserve | shift - } - } - - static let mme_offset = UInt32(13) - static let mme_mask = UInt32(0b1) &<< mme_offset - var mme: UInt8 { - get { UInt8((self.rawValue & (USART.CR1.mme_mask)) >> USART.CR1.mme_offset) } - set { - let preserve = self.rawValue & ~USART.CR1.mme_mask - let shift = (UInt32(newValue) << USART.CR1.mme_offset) & USART.CR1.mme_mask - self.rawValue = preserve | shift - } - } - - static let m0_offset = UInt32(12) - static let m0_mask = UInt32(0b1) &<< m0_offset - var m0: UInt8 { - get { UInt8((self.rawValue & (USART.CR1.m0_mask)) >> USART.CR1.m0_offset) } - set { - let preserve = self.rawValue & ~USART.CR1.m0_mask - let shift = (UInt32(newValue) << USART.CR1.m0_offset) & USART.CR1.m0_mask - self.rawValue = preserve | shift - } - } - - static let wake_offset = UInt32(11) - static let wake_mask = UInt32(0b1) &<< wake_offset - var wake: UInt8 { - get { UInt8((self.rawValue & (USART.CR1.wake_mask)) >> USART.CR1.wake_offset) } - set { - let preserve = self.rawValue & ~USART.CR1.wake_mask - let shift = (UInt32(newValue) << USART.CR1.wake_offset) & USART.CR1.wake_mask - self.rawValue = preserve | shift - } - } - - static let pce_offset = UInt32(10) - static let pce_mask = UInt32(0b1) &<< pce_offset - var pce: UInt8 { - get { UInt8((self.rawValue & (USART.CR1.pce_mask)) >> USART.CR1.pce_offset) } - set { - let preserve = self.rawValue & ~USART.CR1.pce_mask - let shift = (UInt32(newValue) << USART.CR1.pce_offset) & USART.CR1.pce_mask - self.rawValue = preserve | shift - } - } - - static let ps_offset = UInt32(9) - static let ps_mask = UInt32(0b1) &<< ps_offset - var ps: UInt8 { - get { UInt8((self.rawValue & (USART.CR1.ps_mask)) >> USART.CR1.ps_offset) } - set { - let preserve = self.rawValue & ~USART.CR1.ps_mask - let shift = (UInt32(newValue) << USART.CR1.ps_offset) & USART.CR1.ps_mask - self.rawValue = preserve | shift - } - } - - static let peie_offset = UInt32(8) - static let peie_mask = UInt32(0b1) &<< peie_offset - var peie: UInt8 { - get { UInt8((self.rawValue & (USART.CR1.peie_mask)) >> USART.CR1.peie_offset) } - set { - let preserve = self.rawValue & ~USART.CR1.peie_mask - let shift = (UInt32(newValue) << USART.CR1.peie_offset) & USART.CR1.peie_mask - self.rawValue = preserve | shift - } - } - - static let txeie_offset = UInt32(7) - static let txeie_mask = UInt32(0b1) &<< txeie_offset - var txeie: UInt8 { - get { UInt8((self.rawValue & (USART.CR1.txeie_mask)) >> USART.CR1.txeie_offset) } - set { - let preserve = self.rawValue & ~USART.CR1.txeie_mask - let shift = (UInt32(newValue) << USART.CR1.txeie_offset) & USART.CR1.txeie_mask - self.rawValue = preserve | shift - } - } - - static let tcie_offset = UInt32(6) - static let tcie_mask = UInt32(0b1) &<< tcie_offset - var tcie: UInt8 { - get { UInt8((self.rawValue & (USART.CR1.tcie_mask)) >> USART.CR1.tcie_offset) } - set { - let preserve = self.rawValue & ~USART.CR1.tcie_mask - let shift = (UInt32(newValue) << USART.CR1.tcie_offset) & USART.CR1.tcie_mask - self.rawValue = preserve | shift - } - } - - static let rxneie_offset = UInt32(5) - static let rxneie_mask = UInt32(0b1) &<< rxneie_offset - var rxneie: UInt8 { - get { UInt8((self.rawValue & (USART.CR1.rxneie_mask)) >> USART.CR1.rxneie_offset) } - set { - let preserve = self.rawValue & ~USART.CR1.rxneie_mask - let shift = (UInt32(newValue) << USART.CR1.rxneie_offset) & USART.CR1.rxneie_mask - self.rawValue = preserve | shift - } - } - - static let idleie_offset = UInt32(4) - static let idleie_mask = UInt32(0b1) &<< idleie_offset - var idleie: UInt8 { - get { UInt8((self.rawValue & (USART.CR1.idleie_mask)) >> USART.CR1.idleie_offset) } - set { - let preserve = self.rawValue & ~USART.CR1.idleie_mask - let shift = (UInt32(newValue) << USART.CR1.idleie_offset) & USART.CR1.idleie_mask - self.rawValue = preserve | shift - } - } - - static let te_offset = UInt32(3) - static let te_mask = UInt32(0b1) &<< te_offset - var te: UInt8 { - get { UInt8((self.rawValue & (USART.CR1.te_mask)) >> USART.CR1.te_offset) } - set { - let preserve = self.rawValue & ~USART.CR1.te_mask - let shift = (UInt32(newValue) << USART.CR1.te_offset) & USART.CR1.te_mask - self.rawValue = preserve | shift - } - } - - static let re_offset = UInt32(2) - static let re_mask = UInt32(0b1) &<< re_offset - var re: UInt8 { - get { UInt8((self.rawValue & (USART.CR1.re_mask)) >> USART.CR1.re_offset) } - set { - let preserve = self.rawValue & ~USART.CR1.re_mask - let shift = (UInt32(newValue) << USART.CR1.re_offset) & USART.CR1.re_mask - self.rawValue = preserve | shift - } - } - - static let uesm_offset = UInt32(1) - static let uesm_mask = UInt32(0b1) &<< uesm_offset - var uesm: UInt8 { - get { UInt8((self.rawValue & (USART.CR1.uesm_mask)) >> USART.CR1.uesm_offset) } - set { - let preserve = self.rawValue & ~USART.CR1.uesm_mask - let shift = (UInt32(newValue) << USART.CR1.uesm_offset) & USART.CR1.uesm_mask - self.rawValue = preserve | shift - } - } - - static let ue_offset = UInt32(0) - static let ue_mask = UInt32(0b1) &<< ue_offset - var ue: UInt8 { - get { UInt8((self.rawValue & (USART.CR1.ue_mask)) >> USART.CR1.ue_offset) } - set { - let preserve = self.rawValue & ~USART.CR1.ue_mask - let shift = (UInt32(newValue) << USART.CR1.ue_offset) & USART.CR1.ue_mask - self.rawValue = preserve | shift - } - } - - init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - struct CR2 { - var rawValue: UInt32 - - static let add4_7_offset = UInt32(28) - static let add4_7_mask = UInt32(0b1111) &<< add4_7_offset - var add4_7: UInt8 { - get { UInt8((self.rawValue & (USART.CR2.add4_7_mask)) >> USART.CR2.add4_7_offset) } - set { - let preserve = self.rawValue & ~USART.CR2.add4_7_mask - let shift = (UInt32(newValue) << USART.CR2.add4_7_offset) & USART.CR2.add4_7_mask - self.rawValue = preserve | shift - } - } - - static let add0_3_offset = UInt32(24) - static let add0_3_mask = UInt32(0b1111) &<< add0_3_offset - var add0_3: UInt8 { - get { UInt8((self.rawValue & (USART.CR2.add0_3_mask)) >> USART.CR2.add0_3_offset) } - set { - let preserve = self.rawValue & ~USART.CR2.add0_3_mask - let shift = (UInt32(newValue) << USART.CR2.add0_3_offset) & USART.CR2.add0_3_mask - self.rawValue = preserve | shift - } - } - - static let rtoen_offset = UInt32(23) - static let rtoen_mask = UInt32(0b1) &<< rtoen_offset - var rtoen: UInt8 { - get { UInt8((self.rawValue & (USART.CR2.rtoen_mask)) >> USART.CR2.rtoen_offset) } - set { - let preserve = self.rawValue & ~USART.CR2.rtoen_mask - let shift = (UInt32(newValue) << USART.CR2.rtoen_offset) & USART.CR2.rtoen_mask - self.rawValue = preserve | shift - } - } - - static let abrmod1_offset = UInt32(22) - static let abrmod1_mask = UInt32(0b1) &<< abrmod1_offset - var abrmod1: UInt8 { - get { UInt8((self.rawValue & (USART.CR2.abrmod1_mask)) >> USART.CR2.abrmod1_offset) } - set { - let preserve = self.rawValue & ~USART.CR2.abrmod1_mask - let shift = (UInt32(newValue) << USART.CR2.abrmod1_offset) & USART.CR2.abrmod1_mask - self.rawValue = preserve | shift - } - } - - static let abrmod0_offset = UInt32(21) - static let abrmod0_mask = UInt32(0b1) &<< abrmod0_offset - var abrmod0: UInt8 { - get { UInt8((self.rawValue & (USART.CR2.abrmod0_mask)) >> USART.CR2.abrmod0_offset) } - set { - let preserve = self.rawValue & ~USART.CR2.abrmod0_mask - let shift = (UInt32(newValue) << USART.CR2.abrmod0_offset) & USART.CR2.abrmod0_mask - self.rawValue = preserve | shift - } - } - - static let abren_offset = UInt32(20) - static let abren_mask = UInt32(0b1) &<< abren_offset - var abren: UInt8 { - get { UInt8((self.rawValue & (USART.CR2.abren_mask)) >> USART.CR2.abren_offset) } - set { - let preserve = self.rawValue & ~USART.CR2.abren_mask - let shift = (UInt32(newValue) << USART.CR2.abren_offset) & USART.CR2.abren_mask - self.rawValue = preserve | shift - } - } - - static let msbfirst_offset = UInt32(19) - static let msbfirst_mask = UInt32(0b1) &<< msbfirst_offset - var msbfirst: UInt8 { - get { UInt8((self.rawValue & (USART.CR2.msbfirst_mask)) >> USART.CR2.msbfirst_offset) } - set { - let preserve = self.rawValue & ~USART.CR2.msbfirst_mask - let shift = (UInt32(newValue) << USART.CR2.msbfirst_offset) & USART.CR2.msbfirst_mask - self.rawValue = preserve | shift - } - } - - static let tainv_offset = UInt32(18) - static let tainv_mask = UInt32(0b1) &<< tainv_offset - var tainv: UInt8 { - get { UInt8((self.rawValue & (USART.CR2.tainv_mask)) >> USART.CR2.tainv_offset) } - set { - let preserve = self.rawValue & ~USART.CR2.tainv_mask - let shift = (UInt32(newValue) << USART.CR2.tainv_offset) & USART.CR2.tainv_mask - self.rawValue = preserve | shift - } - } - - static let txinv_offset = UInt32(17) - static let txinv_mask = UInt32(0b1) &<< txinv_offset - var txinv: UInt8 { - get { UInt8((self.rawValue & (USART.CR2.txinv_mask)) >> USART.CR2.txinv_offset) } - set { - let preserve = self.rawValue & ~USART.CR2.txinv_mask - let shift = (UInt32(newValue) << USART.CR2.txinv_offset) & USART.CR2.txinv_mask - self.rawValue = preserve | shift - } - } - - static let rxinv_offset = UInt32(16) - static let rxinv_mask = UInt32(0b1) &<< rxinv_offset - var rxinv: UInt8 { - get { UInt8((self.rawValue & (USART.CR2.rxinv_mask)) >> USART.CR2.rxinv_offset) } - set { - let preserve = self.rawValue & ~USART.CR2.rxinv_mask - let shift = (UInt32(newValue) << USART.CR2.rxinv_offset) & USART.CR2.rxinv_mask - self.rawValue = preserve | shift - } - } - - static let swap_offset = UInt32(15) - static let swap_mask = UInt32(0b1) &<< swap_offset - var swap: UInt8 { - get { UInt8((self.rawValue & (USART.CR2.swap_mask)) >> USART.CR2.swap_offset) } - set { - let preserve = self.rawValue & ~USART.CR2.swap_mask - let shift = (UInt32(newValue) << USART.CR2.swap_offset) & USART.CR2.swap_mask - self.rawValue = preserve | shift - } - } - - static let linen_offset = UInt32(14) - static let linen_mask = UInt32(0b1) &<< linen_offset - var linen: UInt8 { - get { UInt8((self.rawValue & (USART.CR2.linen_mask)) >> USART.CR2.linen_offset) } - set { - let preserve = self.rawValue & ~USART.CR2.linen_mask - let shift = (UInt32(newValue) << USART.CR2.linen_offset) & USART.CR2.linen_mask - self.rawValue = preserve | shift - } - } - - static let stop_offset = UInt32(12) - static let stop_mask = UInt32(0b11) &<< stop_offset - var stop: UInt8 { - get { UInt8((self.rawValue & (USART.CR2.stop_mask)) >> USART.CR2.stop_offset) } - set { - let preserve = self.rawValue & ~USART.CR2.stop_mask - let shift = (UInt32(newValue) << USART.CR2.stop_offset) & USART.CR2.stop_mask - self.rawValue = preserve | shift - } - } - - static let clken_offset = UInt32(11) - static let clken_mask = UInt32(0b1) &<< clken_offset - var clken: UInt8 { - get { UInt8((self.rawValue & (USART.CR2.clken_mask)) >> USART.CR2.clken_offset) } - set { - let preserve = self.rawValue & ~USART.CR2.clken_mask - let shift = (UInt32(newValue) << USART.CR2.clken_offset) & USART.CR2.clken_mask - self.rawValue = preserve | shift - } - } - - static let cpol_offset = UInt32(10) - static let cpol_mask = UInt32(0b1) &<< cpol_offset - var cpol: UInt8 { - get { UInt8((self.rawValue & (USART.CR2.cpol_mask)) >> USART.CR2.cpol_offset) } - set { - let preserve = self.rawValue & ~USART.CR2.cpol_mask - let shift = (UInt32(newValue) << USART.CR2.cpol_offset) & USART.CR2.cpol_mask - self.rawValue = preserve | shift - } - } - - static let cpha_offset = UInt32(9) - static let cpha_mask = UInt32(0b1) &<< cpha_offset - var cpha: UInt8 { - get { UInt8((self.rawValue & (USART.CR2.cpha_mask)) >> USART.CR2.cpha_offset) } - set { - let preserve = self.rawValue & ~USART.CR2.cpha_mask - let shift = (UInt32(newValue) << USART.CR2.cpha_offset) & USART.CR2.cpha_mask - self.rawValue = preserve | shift - } - } - - static let lbcl_offset = UInt32(8) - static let lbcl_mask = UInt32(0b1) &<< lbcl_offset - var lbcl: UInt8 { - get { UInt8((self.rawValue & (USART.CR2.lbcl_mask)) >> USART.CR2.lbcl_offset) } - set { - let preserve = self.rawValue & ~USART.CR2.lbcl_mask - let shift = (UInt32(newValue) << USART.CR2.lbcl_offset) & USART.CR2.lbcl_mask - self.rawValue = preserve | shift - } - } - - static let lbdie_offset = UInt32(6) - static let lbdie_mask = UInt32(0b1) &<< lbdie_offset - var lbdie: UInt8 { - get { UInt8((self.rawValue & (USART.CR2.lbdie_mask)) >> USART.CR2.lbdie_offset) } - set { - let preserve = self.rawValue & ~USART.CR2.lbdie_mask - let shift = (UInt32(newValue) << USART.CR2.lbdie_offset) & USART.CR2.lbdie_mask - self.rawValue = preserve | shift - } - } - - static let lbdl_offset = UInt32(5) - static let lbdl_mask = UInt32(0b1) &<< lbdl_offset - var lbdl: UInt8 { - get { UInt8((self.rawValue & (USART.CR2.lbdl_mask)) >> USART.CR2.lbdl_offset) } - set { - let preserve = self.rawValue & ~USART.CR2.lbdl_mask - let shift = (UInt32(newValue) << USART.CR2.lbdl_offset) & USART.CR2.lbdl_mask - self.rawValue = preserve | shift - } - } - - static let addm7_offset = UInt32(4) - static let addm7_mask = UInt32(0b1) &<< addm7_offset - var addm7: UInt8 { - get { UInt8((self.rawValue & (USART.CR2.addm7_mask)) >> USART.CR2.addm7_offset) } - set { - let preserve = self.rawValue & ~USART.CR2.addm7_mask - let shift = (UInt32(newValue) << USART.CR2.addm7_offset) & USART.CR2.addm7_mask - self.rawValue = preserve | shift - } - } - - init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - struct CR3 { - var rawValue: UInt32 - - static let wufie_offset = UInt32(22) - static let wufie_mask = UInt32(0b1) &<< wufie_offset - var wufie: UInt8 { - get { UInt8((self.rawValue & (USART.CR3.wufie_mask)) >> USART.CR3.wufie_offset) } - set { - let preserve = self.rawValue & ~USART.CR3.wufie_mask - let shift = (UInt32(newValue) << USART.CR3.wufie_offset) & USART.CR3.wufie_mask - self.rawValue = preserve | shift - } - } - - static let wus_offset = UInt32(20) - static let wus_mask = UInt32(0b11) &<< wus_offset - var wus: UInt8 { - get { UInt8((self.rawValue & (USART.CR3.wus_mask)) >> USART.CR3.wus_offset) } - set { - let preserve = self.rawValue & ~USART.CR3.wus_mask - let shift = (UInt32(newValue) << USART.CR3.wus_offset) & USART.CR3.wus_mask - self.rawValue = preserve | shift - } - } - - static let scarcnt_offset = UInt32(17) - static let scarcnt_mask = UInt32(0b111) &<< scarcnt_offset - var scarcnt: UInt8 { - get { UInt8((self.rawValue & (USART.CR3.scarcnt_mask)) >> USART.CR3.scarcnt_offset) } - set { - let preserve = self.rawValue & ~USART.CR3.scarcnt_mask - let shift = (UInt32(newValue) << USART.CR3.scarcnt_offset) & USART.CR3.scarcnt_mask - self.rawValue = preserve | shift - } - } - - static let dep_offset = UInt32(15) - static let dep_mask = UInt32(0b1) &<< dep_offset - var dep: UInt8 { - get { UInt8((self.rawValue & (USART.CR3.dep_mask)) >> USART.CR3.dep_offset) } - set { - let preserve = self.rawValue & ~USART.CR3.dep_mask - let shift = (UInt32(newValue) << USART.CR3.dep_offset) & USART.CR3.dep_mask - self.rawValue = preserve | shift - } - } - - static let dem_offset = UInt32(14) - static let dem_mask = UInt32(0b1) &<< dem_offset - var dem: UInt8 { - get { UInt8((self.rawValue & (USART.CR3.dem_mask)) >> USART.CR3.dem_offset) } - set { - let preserve = self.rawValue & ~USART.CR3.dem_mask - let shift = (UInt32(newValue) << USART.CR3.dem_offset) & USART.CR3.dem_mask - self.rawValue = preserve | shift - } - } - - static let ddre_offset = UInt32(13) - static let ddre_mask = UInt32(0b1) &<< ddre_offset - var ddre: UInt8 { - get { UInt8((self.rawValue & (USART.CR3.ddre_mask)) >> USART.CR3.ddre_offset) } - set { - let preserve = self.rawValue & ~USART.CR3.ddre_mask - let shift = (UInt32(newValue) << USART.CR3.ddre_offset) & USART.CR3.ddre_mask - self.rawValue = preserve | shift - } - } - - static let ovrdis_offset = UInt32(12) - static let ovrdis_mask = UInt32(0b1) &<< ovrdis_offset - var ovrdis: UInt8 { - get { UInt8((self.rawValue & (USART.CR3.ovrdis_mask)) >> USART.CR3.ovrdis_offset) } - set { - let preserve = self.rawValue & ~USART.CR3.ovrdis_mask - let shift = (UInt32(newValue) << USART.CR3.ovrdis_offset) & USART.CR3.ovrdis_mask - self.rawValue = preserve | shift - } - } - - static let onebit_offset = UInt32(11) - static let onebit_mask = UInt32(0b1) &<< onebit_offset - var onebit: UInt8 { - get { UInt8((self.rawValue & (USART.CR3.onebit_mask)) >> USART.CR3.onebit_offset) } - set { - let preserve = self.rawValue & ~USART.CR3.onebit_mask - let shift = (UInt32(newValue) << USART.CR3.onebit_offset) & USART.CR3.onebit_mask - self.rawValue = preserve | shift - } - } - - static let ctsie_offset = UInt32(10) - static let ctsie_mask = UInt32(0b1) &<< ctsie_offset - var ctsie: UInt8 { - get { UInt8((self.rawValue & (USART.CR3.ctsie_mask)) >> USART.CR3.ctsie_offset) } - set { - let preserve = self.rawValue & ~USART.CR3.ctsie_mask - let shift = (UInt32(newValue) << USART.CR3.ctsie_offset) & USART.CR3.ctsie_mask - self.rawValue = preserve | shift - } - } - - static let ctse_offset = UInt32(9) - static let ctse_mask = UInt32(0b1) &<< ctse_offset - var ctse: UInt8 { - get { UInt8((self.rawValue & (USART.CR3.ctse_mask)) >> USART.CR3.ctse_offset) } - set { - let preserve = self.rawValue & ~USART.CR3.ctse_mask - let shift = (UInt32(newValue) << USART.CR3.ctse_offset) & USART.CR3.ctse_mask - self.rawValue = preserve | shift - } - } - - static let rtse_offset = UInt32(8) - static let rtse_mask = UInt32(0b1) &<< rtse_offset - var rtse: UInt8 { - get { UInt8((self.rawValue & (USART.CR3.rtse_mask)) >> USART.CR3.rtse_offset) } - set { - let preserve = self.rawValue & ~USART.CR3.rtse_mask - let shift = (UInt32(newValue) << USART.CR3.rtse_offset) & USART.CR3.rtse_mask - self.rawValue = preserve | shift - } - } - - static let dmat_offset = UInt32(7) - static let dmat_mask = UInt32(0b1) &<< dmat_offset - var dmat: UInt8 { - get { UInt8((self.rawValue & (USART.CR3.dmat_mask)) >> USART.CR3.dmat_offset) } - set { - let preserve = self.rawValue & ~USART.CR3.dmat_mask - let shift = (UInt32(newValue) << USART.CR3.dmat_offset) & USART.CR3.dmat_mask - self.rawValue = preserve | shift - } - } - - static let dmar_offset = UInt32(6) - static let dmar_mask = UInt32(0b1) &<< dmar_offset - var dmar: UInt8 { - get { UInt8((self.rawValue & (USART.CR3.dmar_mask)) >> USART.CR3.dmar_offset) } - set { - let preserve = self.rawValue & ~USART.CR3.dmar_mask - let shift = (UInt32(newValue) << USART.CR3.dmar_offset) & USART.CR3.dmar_mask - self.rawValue = preserve | shift - } - } - - static let scen_offset = UInt32(5) - static let scen_mask = UInt32(0b1) &<< scen_offset - var scen: UInt8 { - get { UInt8((self.rawValue & (USART.CR3.scen_mask)) >> USART.CR3.scen_offset) } - set { - let preserve = self.rawValue & ~USART.CR3.scen_mask - let shift = (UInt32(newValue) << USART.CR3.scen_offset) & USART.CR3.scen_mask - self.rawValue = preserve | shift - } - } - - static let nack_offset = UInt32(4) - static let nack_mask = UInt32(0b1) &<< nack_offset - var nack: UInt8 { - get { UInt8((self.rawValue & (USART.CR3.nack_mask)) >> USART.CR3.nack_offset) } - set { - let preserve = self.rawValue & ~USART.CR3.nack_mask - let shift = (UInt32(newValue) << USART.CR3.nack_offset) & USART.CR3.nack_mask - self.rawValue = preserve | shift - } - } - - static let hdsel_offset = UInt32(3) - static let hdsel_mask = UInt32(0b1) &<< hdsel_offset - var hdsel: UInt8 { - get { UInt8((self.rawValue & (USART.CR3.hdsel_mask)) >> USART.CR3.hdsel_offset) } - set { - let preserve = self.rawValue & ~USART.CR3.hdsel_mask - let shift = (UInt32(newValue) << USART.CR3.hdsel_offset) & USART.CR3.hdsel_mask - self.rawValue = preserve | shift - } - } - - static let irlp_offset = UInt32(2) - static let irlp_mask = UInt32(0b1) &<< irlp_offset - var irlp: UInt8 { - get { UInt8((self.rawValue & (USART.CR3.irlp_mask)) >> USART.CR3.irlp_offset) } - set { - let preserve = self.rawValue & ~USART.CR3.irlp_mask - let shift = (UInt32(newValue) << USART.CR3.irlp_offset) & USART.CR3.irlp_mask - self.rawValue = preserve | shift - } - } - - static let iren_offset = UInt32(1) - static let iren_mask = UInt32(0b1) &<< iren_offset - var iren: UInt8 { - get { UInt8((self.rawValue & (USART.CR3.iren_mask)) >> USART.CR3.iren_offset) } - set { - let preserve = self.rawValue & ~USART.CR3.iren_mask - let shift = (UInt32(newValue) << USART.CR3.iren_offset) & USART.CR3.iren_mask - self.rawValue = preserve | shift - } - } - - static let eie_offset = UInt32(0) - static let eie_mask = UInt32(0b1) &<< eie_offset - var eie: UInt8 { - get { UInt8((self.rawValue & (USART.CR3.eie_mask)) >> USART.CR3.eie_offset) } - set { - let preserve = self.rawValue & ~USART.CR3.eie_mask - let shift = (UInt32(newValue) << USART.CR3.eie_offset) & USART.CR3.eie_mask - self.rawValue = preserve | shift - } - } - - init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - struct BRR { - var rawValue: UInt32 - - static let div_mantissa_offset = UInt32(4) - static let div_mantissa_mask = UInt32(0b111111111111) &<< div_mantissa_offset - var div_mantissa: UInt16 { - get { UInt16((self.rawValue & (USART.BRR.div_mantissa_mask)) >> USART.BRR.div_mantissa_offset) } - set { - let preserve = self.rawValue & ~USART.BRR.div_mantissa_mask - let shift = (UInt32(newValue) << USART.BRR.div_mantissa_offset) & USART.BRR.div_mantissa_mask - self.rawValue = preserve | shift - } - } - - static let div_fraction_offset = UInt32(0) - static let div_fraction_mask = UInt32(0b1111) &<< div_fraction_offset - var div_fraction: UInt8 { - get { UInt8((self.rawValue & (USART.BRR.div_fraction_mask)) >> USART.BRR.div_fraction_offset) } - set { - let preserve = self.rawValue & ~USART.BRR.div_fraction_mask - let shift = (UInt32(newValue) << USART.BRR.div_fraction_offset) & USART.BRR.div_fraction_mask - self.rawValue = preserve | shift - } - } - - init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - struct GTPR { - var rawValue: UInt32 - - static let gt_offset = UInt32(8) - static let gt_mask = UInt32(0b11111111) &<< gt_offset - var gt: UInt8 { - get { UInt8((self.rawValue & (USART.GTPR.gt_mask)) >> USART.GTPR.gt_offset) } - set { - let preserve = self.rawValue & ~USART.GTPR.gt_mask - let shift = (UInt32(newValue) << USART.GTPR.gt_offset) & USART.GTPR.gt_mask - self.rawValue = preserve | shift - } - } - - static let psc_offset = UInt32(0) - static let psc_mask = UInt32(0b11111111) &<< psc_offset - var psc: UInt8 { - get { UInt8((self.rawValue & (USART.GTPR.psc_mask)) >> USART.GTPR.psc_offset) } - set { - let preserve = self.rawValue & ~USART.GTPR.psc_mask - let shift = (UInt32(newValue) << USART.GTPR.psc_offset) & USART.GTPR.psc_mask - self.rawValue = preserve | shift - } - } - - init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - struct RTOR { - var rawValue: UInt32 - - static let blen_offset = UInt32(24) - static let blen_mask = UInt32(0b11111111) &<< blen_offset - var blen: UInt8 { - get { UInt8((self.rawValue & (USART.RTOR.blen_mask)) >> USART.RTOR.blen_offset) } - set { - let preserve = self.rawValue & ~USART.RTOR.blen_mask - let shift = (UInt32(newValue) << USART.RTOR.blen_offset) & USART.RTOR.blen_mask - self.rawValue = preserve | shift - } - } - - static let rto_offset = UInt32(0) - static let rto_mask = UInt32(0b111111111111111111111111) &<< rto_offset - var rto: UInt32 { - get { UInt32((self.rawValue & (USART.RTOR.rto_mask)) >> USART.RTOR.rto_offset) } - set { - let preserve = self.rawValue & ~USART.RTOR.rto_mask - let shift = (UInt32(newValue) << USART.RTOR.rto_offset) & USART.RTOR.rto_mask - self.rawValue = preserve | shift - } - } - - init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - struct RQR { - var rawValue: UInt32 - - static let txfrq_offset = UInt32(4) - static let txfrq_mask = UInt32(0b1) &<< txfrq_offset - var txfrq: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << USART.RQR.txfrq_offset) & USART.RQR.txfrq_mask - } - } - - static let rxfrq_offset = UInt32(3) - static let rxfrq_mask = UInt32(0b1) &<< rxfrq_offset - var rxfrq: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << USART.RQR.rxfrq_offset) & USART.RQR.rxfrq_mask - } - } - - static let mmrq_offset = UInt32(2) - static let mmrq_mask = UInt32(0b1) &<< mmrq_offset - var mmrq: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << USART.RQR.mmrq_offset) & USART.RQR.mmrq_mask - } - } - - static let sbkrq_offset = UInt32(1) - static let sbkrq_mask = UInt32(0b1) &<< sbkrq_offset - var sbkrq: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << USART.RQR.sbkrq_offset) & USART.RQR.sbkrq_mask - } - } - - static let abrrq_offset = UInt32(0) - static let abrrq_mask = UInt32(0b1) &<< abrrq_offset - var abrrq: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << USART.RQR.abrrq_offset) & USART.RQR.abrrq_mask - } - } - - init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - struct ISR { - var rawValue: UInt32 - - static let reack_offset = UInt32(22) - static let reack_mask = UInt32(0b1) &<< reack_offset - var reack: UInt8 { - UInt8((self.rawValue & (USART.ISR.reack_mask)) >> USART.ISR.reack_offset) - } - - static let teack_offset = UInt32(21) - static let teack_mask = UInt32(0b1) &<< teack_offset - var teack: UInt8 { - UInt8((self.rawValue & (USART.ISR.teack_mask)) >> USART.ISR.teack_offset) - } - - static let wuf_offset = UInt32(20) - static let wuf_mask = UInt32(0b1) &<< wuf_offset - var wuf: UInt8 { - UInt8((self.rawValue & (USART.ISR.wuf_mask)) >> USART.ISR.wuf_offset) - } - - static let rwu_offset = UInt32(19) - static let rwu_mask = UInt32(0b1) &<< rwu_offset - var rwu: UInt8 { - UInt8((self.rawValue & (USART.ISR.rwu_mask)) >> USART.ISR.rwu_offset) - } - - static let sbkf_offset = UInt32(18) - static let sbkf_mask = UInt32(0b1) &<< sbkf_offset - var sbkf: UInt8 { - UInt8((self.rawValue & (USART.ISR.sbkf_mask)) >> USART.ISR.sbkf_offset) - } - - static let cmf_offset = UInt32(17) - static let cmf_mask = UInt32(0b1) &<< cmf_offset - var cmf: UInt8 { - UInt8((self.rawValue & (USART.ISR.cmf_mask)) >> USART.ISR.cmf_offset) - } - - static let busy_offset = UInt32(16) - static let busy_mask = UInt32(0b1) &<< busy_offset - var busy: UInt8 { - UInt8((self.rawValue & (USART.ISR.busy_mask)) >> USART.ISR.busy_offset) - } - - static let abrf_offset = UInt32(15) - static let abrf_mask = UInt32(0b1) &<< abrf_offset - var abrf: UInt8 { - UInt8((self.rawValue & (USART.ISR.abrf_mask)) >> USART.ISR.abrf_offset) - } - - static let abre_offset = UInt32(14) - static let abre_mask = UInt32(0b1) &<< abre_offset - var abre: UInt8 { - UInt8((self.rawValue & (USART.ISR.abre_mask)) >> USART.ISR.abre_offset) - } - - static let eobf_offset = UInt32(12) - static let eobf_mask = UInt32(0b1) &<< eobf_offset - var eobf: UInt8 { - UInt8((self.rawValue & (USART.ISR.eobf_mask)) >> USART.ISR.eobf_offset) - } - - static let rtof_offset = UInt32(11) - static let rtof_mask = UInt32(0b1) &<< rtof_offset - var rtof: UInt8 { - UInt8((self.rawValue & (USART.ISR.rtof_mask)) >> USART.ISR.rtof_offset) - } - - static let cts_offset = UInt32(10) - static let cts_mask = UInt32(0b1) &<< cts_offset - var cts: UInt8 { - UInt8((self.rawValue & (USART.ISR.cts_mask)) >> USART.ISR.cts_offset) - } - - static let ctsif_offset = UInt32(9) - static let ctsif_mask = UInt32(0b1) &<< ctsif_offset - var ctsif: UInt8 { - UInt8((self.rawValue & (USART.ISR.ctsif_mask)) >> USART.ISR.ctsif_offset) - } - - static let lbdf_offset = UInt32(8) - static let lbdf_mask = UInt32(0b1) &<< lbdf_offset - var lbdf: UInt8 { - UInt8((self.rawValue & (USART.ISR.lbdf_mask)) >> USART.ISR.lbdf_offset) - } - - static let txe_offset = UInt32(7) - static let txe_mask = UInt32(0b1) &<< txe_offset - var txe: UInt8 { - UInt8((self.rawValue & (USART.ISR.txe_mask)) >> USART.ISR.txe_offset) - } - - static let tc_offset = UInt32(6) - static let tc_mask = UInt32(0b1) &<< tc_offset - var tc: UInt8 { - UInt8((self.rawValue & (USART.ISR.tc_mask)) >> USART.ISR.tc_offset) - } - - static let rxne_offset = UInt32(5) - static let rxne_mask = UInt32(0b1) &<< rxne_offset - var rxne: UInt8 { - UInt8((self.rawValue & (USART.ISR.rxne_mask)) >> USART.ISR.rxne_offset) - } - - static let idle_offset = UInt32(4) - static let idle_mask = UInt32(0b1) &<< idle_offset - var idle: UInt8 { - UInt8((self.rawValue & (USART.ISR.idle_mask)) >> USART.ISR.idle_offset) - } - - static let ore_offset = UInt32(3) - static let ore_mask = UInt32(0b1) &<< ore_offset - var ore: UInt8 { - UInt8((self.rawValue & (USART.ISR.ore_mask)) >> USART.ISR.ore_offset) - } - - static let nf_offset = UInt32(2) - static let nf_mask = UInt32(0b1) &<< nf_offset - var nf: UInt8 { - UInt8((self.rawValue & (USART.ISR.nf_mask)) >> USART.ISR.nf_offset) - } - - static let fe_offset = UInt32(1) - static let fe_mask = UInt32(0b1) &<< fe_offset - var fe: UInt8 { - UInt8((self.rawValue & (USART.ISR.fe_mask)) >> USART.ISR.fe_offset) - } - - static let pe_offset = UInt32(0) - static let pe_mask = UInt32(0b1) &<< pe_offset - var pe: UInt8 { - UInt8((self.rawValue & (USART.ISR.pe_mask)) >> USART.ISR.pe_offset) - } - - init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - struct ICR { - var rawValue: UInt32 - - static let wucf_offset = UInt32(20) - static let wucf_mask = UInt32(0b1) &<< wucf_offset - var wucf: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << USART.ICR.wucf_offset) & USART.ICR.wucf_mask - } - } - - static let cmcf_offset = UInt32(17) - static let cmcf_mask = UInt32(0b1) &<< cmcf_offset - var cmcf: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << USART.ICR.cmcf_offset) & USART.ICR.cmcf_mask - } - } - - static let eobcf_offset = UInt32(12) - static let eobcf_mask = UInt32(0b1) &<< eobcf_offset - var eobcf: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << USART.ICR.eobcf_offset) & USART.ICR.eobcf_mask - } - } - - static let rtocf_offset = UInt32(11) - static let rtocf_mask = UInt32(0b1) &<< rtocf_offset - var rtocf: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << USART.ICR.rtocf_offset) & USART.ICR.rtocf_mask - } - } - - static let ctscf_offset = UInt32(9) - static let ctscf_mask = UInt32(0b1) &<< ctscf_offset - var ctscf: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << USART.ICR.ctscf_offset) & USART.ICR.ctscf_mask - } - } - - static let lbdcf_offset = UInt32(8) - static let lbdcf_mask = UInt32(0b1) &<< lbdcf_offset - var lbdcf: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << USART.ICR.lbdcf_offset) & USART.ICR.lbdcf_mask - } - } - - static let tccf_offset = UInt32(6) - static let tccf_mask = UInt32(0b1) &<< tccf_offset - var tccf: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << USART.ICR.tccf_offset) & USART.ICR.tccf_mask - } - } - - static let idlecf_offset = UInt32(4) - static let idlecf_mask = UInt32(0b1) &<< idlecf_offset - var idlecf: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << USART.ICR.idlecf_offset) & USART.ICR.idlecf_mask - } - } - - static let orecf_offset = UInt32(3) - static let orecf_mask = UInt32(0b1) &<< orecf_offset - var orecf: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << USART.ICR.orecf_offset) & USART.ICR.orecf_mask - } - } - - static let ncf_offset = UInt32(2) - static let ncf_mask = UInt32(0b1) &<< ncf_offset - var ncf: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << USART.ICR.ncf_offset) & USART.ICR.ncf_mask - } - } - - static let fecf_offset = UInt32(1) - static let fecf_mask = UInt32(0b1) &<< fecf_offset - var fecf: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << USART.ICR.fecf_offset) & USART.ICR.fecf_mask - } - } - - static let pecf_offset = UInt32(0) - static let pecf_mask = UInt32(0b1) &<< pecf_offset - var pecf: UInt8 { - get { fatalError("Trying to read a write-only field") } - set { - self.rawValue = (UInt32(newValue) << USART.ICR.pecf_offset) & USART.ICR.pecf_mask - } - } - - init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - struct RDR { - var rawValue: UInt32 - - static let rdr_offset = UInt32(0) - static let rdr_mask = UInt32(0b111111111) &<< rdr_offset - var rdr: UInt16 { - UInt16((self.rawValue & (USART.RDR.rdr_mask)) >> USART.RDR.rdr_offset) - } - - init(rawValue: UInt32) { - self.rawValue = rawValue - } - } - struct TDR { - var rawValue: UInt32 - - static let tdr_offset = UInt32(0) - static let tdr_mask = UInt32(0b111111111) &<< tdr_offset - var tdr: UInt16 { - get { UInt16((self.rawValue & (USART.TDR.tdr_mask)) >> USART.TDR.tdr_offset) } - set { - let preserve = self.rawValue & ~USART.TDR.tdr_mask - let shift = (UInt32(newValue) << USART.TDR.tdr_offset) & USART.TDR.tdr_mask - self.rawValue = preserve | shift - } - } - - init(rawValue: UInt32) { - self.rawValue = rawValue - } - } -} diff --git a/stm32-lcd-logo/Sources/Application/Volatile.swift b/stm32-lcd-logo/Sources/Application/Volatile.swift deleted file mode 100644 index eae2274a..00000000 --- a/stm32-lcd-logo/Sources/Application/Volatile.swift +++ /dev/null @@ -1,22 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// This source file is part of the Swift open source project -// -// Copyright (c) 2023 Apple Inc. and the Swift project authors. -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See https://swift.org/LICENSE.txt for license information -// -//===----------------------------------------------------------------------===// - -import Support - -extension UnsafeMutablePointer where Pointee == UInt32 { - func volatileLoad() -> Pointee { - volatile_load_uint32_t(self) - } - - func volatileStore(_ value: Pointee) { - volatile_store_uint32_t(self, value) - } -} diff --git a/stm32-lcd-logo/Sources/Support/Startup.c b/stm32-lcd-logo/Sources/Support/Startup.c index 16ea6367..6838bdc0 100644 --- a/stm32-lcd-logo/Sources/Support/Startup.c +++ b/stm32-lcd-logo/Sources/Support/Startup.c @@ -14,6 +14,20 @@ extern int main(int argc, char *argv[]); +void *memset(void *b, int c, size_t len) { + for (int i = 0; i < len; i++) { + ((char *)b)[i] = c; + } + return b; +} + +void *memcpy(void *restrict dst, const void *restrict src, size_t n) { + for (int i = 0; i < n; i++) { + ((char *)dst)[i] = ((char *)src)[i]; + } + return dst; +} + void reset(void) { main(0, NULL); } diff --git a/stm32-lcd-logo/Sources/Support/include/Support.h b/stm32-lcd-logo/Sources/Support/include/Support.h index f962f6fa..3c103eae 100644 --- a/stm32-lcd-logo/Sources/Support/include/Support.h +++ b/stm32-lcd-logo/Sources/Support/include/Support.h @@ -13,14 +13,6 @@ #include -static inline uint32_t volatile_load_uint32_t(const volatile uint32_t * _Nonnull source) { - return *((const volatile uint32_t * _Nonnull) source); -} - -static inline void volatile_store_uint32_t(volatile uint32_t * _Nonnull destination, uint32_t value) { - *((volatile uint32_t * _Nonnull) destination) = value; -} - static inline void nop() { asm volatile("nop"); }