fix usage of @ptrCast and other fooToBar stuff, run with zig fmt (#18)

wch-ch32v003
binarycraft007 1 year ago committed by GitHub
parent 7afd50f1a8
commit c9e394c58d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -112,139 +112,139 @@ pub const devices = struct {
pub const peripherals = struct {
/// General purpose timer
pub const TIM2 = @ptrCast(*volatile types.TIM2, 0x40000000);
pub const TIM2 = @as(*volatile types.TIM2, @ptrFromInt(0x40000000));
/// General purpose timer
pub const TIM3 = @ptrCast(*volatile types.TIM2, 0x40000400);
pub const TIM3 = @as(*volatile types.TIM2, @ptrFromInt(0x40000400));
/// General purpose timer
pub const TIM4 = @ptrCast(*volatile types.TIM2, 0x40000800);
pub const TIM4 = @as(*volatile types.TIM2, @ptrFromInt(0x40000800));
/// General purpose timer
pub const TIM5 = @ptrCast(*volatile types.TIM2, 0x40000c00);
pub const TIM5 = @as(*volatile types.TIM2, @ptrFromInt(0x40000c00));
/// Basic timer
pub const TIM6 = @ptrCast(*volatile types.TIM6, 0x40001000);
pub const TIM6 = @as(*volatile types.TIM6, @ptrFromInt(0x40001000));
/// Basic timer
pub const TIM7 = @ptrCast(*volatile types.TIM6, 0x40001400);
pub const TIM7 = @as(*volatile types.TIM6, @ptrFromInt(0x40001400));
/// General purpose timer
pub const TIM12 = @ptrCast(*volatile types.TIM9, 0x40001800);
pub const TIM12 = @as(*volatile types.TIM9, @ptrFromInt(0x40001800));
/// General purpose timer
pub const TIM13 = @ptrCast(*volatile types.TIM10, 0x40001c00);
pub const TIM13 = @as(*volatile types.TIM10, @ptrFromInt(0x40001c00));
/// General purpose timer
pub const TIM14 = @ptrCast(*volatile types.TIM10, 0x40002000);
pub const TIM14 = @as(*volatile types.TIM10, @ptrFromInt(0x40002000));
/// Real time clock
pub const RTC = @ptrCast(*volatile types.RTC, 0x40002800);
pub const RTC = @as(*volatile types.RTC, @ptrFromInt(0x40002800));
/// Window watchdog
pub const WWDG = @ptrCast(*volatile types.WWDG, 0x40002c00);
pub const WWDG = @as(*volatile types.WWDG, @ptrFromInt(0x40002c00));
/// Independent watchdog
pub const IWDG = @ptrCast(*volatile types.IWDG, 0x40003000);
pub const IWDG = @as(*volatile types.IWDG, @ptrFromInt(0x40003000));
/// Serial peripheral interface
pub const SPI2 = @ptrCast(*volatile types.SPI1, 0x40003800);
pub const SPI2 = @as(*volatile types.SPI1, @ptrFromInt(0x40003800));
/// Serial peripheral interface
pub const SPI3 = @ptrCast(*volatile types.SPI1, 0x40003c00);
pub const SPI3 = @as(*volatile types.SPI1, @ptrFromInt(0x40003c00));
/// Universal synchronous asynchronous receiver transmitter
pub const USART2 = @ptrCast(*volatile types.USART1, 0x40004400);
pub const USART2 = @as(*volatile types.USART1, @ptrFromInt(0x40004400));
/// Universal synchronous asynchronous receiver transmitter
pub const USART3 = @ptrCast(*volatile types.USART1, 0x40004800);
pub const USART3 = @as(*volatile types.USART1, @ptrFromInt(0x40004800));
/// Universal asynchronous receiver transmitter
pub const UART4 = @ptrCast(*volatile types.UART4, 0x40004c00);
pub const UART4 = @as(*volatile types.UART4, @ptrFromInt(0x40004c00));
/// Universal asynchronous receiver transmitter
pub const UART5 = @ptrCast(*volatile types.UART5, 0x40005000);
pub const UART5 = @as(*volatile types.UART5, @ptrFromInt(0x40005000));
/// Inter integrated circuit
pub const I2C1 = @ptrCast(*volatile types.I2C1, 0x40005400);
pub const I2C1 = @as(*volatile types.I2C1, @ptrFromInt(0x40005400));
/// Inter integrated circuit
pub const I2C2 = @ptrCast(*volatile types.I2C1, 0x40005800);
pub const I2C2 = @as(*volatile types.I2C1, @ptrFromInt(0x40005800));
/// Universal serial bus full-speed device interface
pub const USB = @ptrCast(*volatile types.USB, 0x40005c00);
pub const USB = @as(*volatile types.USB, @ptrFromInt(0x40005c00));
/// Controller area network
pub const CAN1 = @ptrCast(*volatile types.CAN1, 0x40006400);
pub const CAN1 = @as(*volatile types.CAN1, @ptrFromInt(0x40006400));
/// Controller area network
pub const CAN2 = @ptrCast(*volatile types.CAN1, 0x40006800);
pub const CAN2 = @as(*volatile types.CAN1, @ptrFromInt(0x40006800));
/// Backup registers
pub const BKP = @ptrCast(*volatile types.BKP, 0x40006c00);
pub const BKP = @as(*volatile types.BKP, @ptrFromInt(0x40006c00));
/// Power control
pub const PWR = @ptrCast(*volatile types.PWR, 0x40007000);
pub const PWR = @as(*volatile types.PWR, @ptrFromInt(0x40007000));
/// Digital to analog converter
pub const DAC = @ptrCast(*volatile types.DAC, 0x40007400);
pub const DAC = @as(*volatile types.DAC, @ptrFromInt(0x40007400));
/// Alternate function I/O
pub const AFIO = @ptrCast(*volatile types.AFIO, 0x40010000);
pub const AFIO = @as(*volatile types.AFIO, @ptrFromInt(0x40010000));
/// EXTI
pub const EXTI = @ptrCast(*volatile types.EXTI, 0x40010400);
pub const EXTI = @as(*volatile types.EXTI, @ptrFromInt(0x40010400));
/// General purpose I/O
pub const GPIOA = @ptrCast(*volatile types.GPIOA, 0x40010800);
pub const GPIOA = @as(*volatile types.GPIOA, @ptrFromInt(0x40010800));
/// General purpose I/O
pub const GPIOB = @ptrCast(*volatile types.GPIOA, 0x40010c00);
pub const GPIOB = @as(*volatile types.GPIOA, @ptrFromInt(0x40010c00));
/// General purpose I/O
pub const GPIOC = @ptrCast(*volatile types.GPIOA, 0x40011000);
pub const GPIOC = @as(*volatile types.GPIOA, @ptrFromInt(0x40011000));
/// General purpose I/O
pub const GPIOD = @ptrCast(*volatile types.GPIOA, 0x40011400);
pub const GPIOD = @as(*volatile types.GPIOA, @ptrFromInt(0x40011400));
/// General purpose I/O
pub const GPIOE = @ptrCast(*volatile types.GPIOA, 0x40011800);
pub const GPIOE = @as(*volatile types.GPIOA, @ptrFromInt(0x40011800));
/// General purpose I/O
pub const GPIOF = @ptrCast(*volatile types.GPIOA, 0x40011c00);
pub const GPIOF = @as(*volatile types.GPIOA, @ptrFromInt(0x40011c00));
/// General purpose I/O
pub const GPIOG = @ptrCast(*volatile types.GPIOA, 0x40012000);
pub const GPIOG = @as(*volatile types.GPIOA, @ptrFromInt(0x40012000));
/// Analog to digital converter
pub const ADC1 = @ptrCast(*volatile types.ADC1, 0x40012400);
pub const ADC1 = @as(*volatile types.ADC1, @ptrFromInt(0x40012400));
/// Analog to digital converter
pub const ADC2 = @ptrCast(*volatile types.ADC2, 0x40012800);
pub const ADC2 = @as(*volatile types.ADC2, @ptrFromInt(0x40012800));
/// Advanced timer
pub const TIM1 = @ptrCast(*volatile types.TIM1, 0x40012c00);
pub const TIM1 = @as(*volatile types.TIM1, @ptrFromInt(0x40012c00));
/// Serial peripheral interface
pub const SPI1 = @ptrCast(*volatile types.SPI1, 0x40013000);
pub const SPI1 = @as(*volatile types.SPI1, @ptrFromInt(0x40013000));
/// Advanced timer
pub const TIM8 = @ptrCast(*volatile types.TIM1, 0x40013400);
pub const TIM8 = @as(*volatile types.TIM1, @ptrFromInt(0x40013400));
/// Universal synchronous asynchronous receiver transmitter
pub const USART1 = @ptrCast(*volatile types.USART1, 0x40013800);
pub const USART1 = @as(*volatile types.USART1, @ptrFromInt(0x40013800));
/// Analog to digital converter
pub const ADC3 = @ptrCast(*volatile types.ADC2, 0x40013c00);
pub const ADC3 = @as(*volatile types.ADC2, @ptrFromInt(0x40013c00));
/// General purpose timer
pub const TIM9 = @ptrCast(*volatile types.TIM9, 0x40014c00);
pub const TIM9 = @as(*volatile types.TIM9, @ptrFromInt(0x40014c00));
/// General purpose timer
pub const TIM10 = @ptrCast(*volatile types.TIM10, 0x40015000);
pub const TIM10 = @as(*volatile types.TIM10, @ptrFromInt(0x40015000));
/// General purpose timer
pub const TIM11 = @ptrCast(*volatile types.TIM10, 0x40015400);
pub const TIM11 = @as(*volatile types.TIM10, @ptrFromInt(0x40015400));
/// Secure digital input/output interface
pub const SDIO = @ptrCast(*volatile types.SDIO, 0x40018000);
pub const SDIO = @as(*volatile types.SDIO, @ptrFromInt(0x40018000));
/// DMA controller
pub const DMA1 = @ptrCast(*volatile types.DMA1, 0x40020000);
pub const DMA1 = @as(*volatile types.DMA1, @ptrFromInt(0x40020000));
/// DMA controller
pub const DMA2 = @ptrCast(*volatile types.DMA1, 0x40020400);
pub const DMA2 = @as(*volatile types.DMA1, @ptrFromInt(0x40020400));
/// Reset and clock control
pub const RCC = @ptrCast(*volatile types.RCC, 0x40021000);
pub const RCC = @as(*volatile types.RCC, @ptrFromInt(0x40021000));
/// FLASH
pub const FLASH = @ptrCast(*volatile types.FLASH, 0x40022000);
pub const FLASH = @as(*volatile types.FLASH, @ptrFromInt(0x40022000));
/// CRC calculation unit
pub const CRC = @ptrCast(*volatile types.CRC, 0x40023000);
pub const CRC = @as(*volatile types.CRC, @ptrFromInt(0x40023000));
/// Ethernet: media access control
pub const ETHERNET_MAC = @ptrCast(*volatile types.ETHERNET_MAC, 0x40028000);
pub const ETHERNET_MAC = @as(*volatile types.ETHERNET_MAC, @ptrFromInt(0x40028000));
/// Ethernet: MAC management counters
pub const ETHERNET_MMC = @ptrCast(*volatile types.ETHERNET_MMC, 0x40028100);
pub const ETHERNET_MMC = @as(*volatile types.ETHERNET_MMC, @ptrFromInt(0x40028100));
/// Ethernet: Precision time protocol
pub const ETHERNET_PTP = @ptrCast(*volatile types.ETHERNET_PTP, 0x40028700);
pub const ETHERNET_PTP = @as(*volatile types.ETHERNET_PTP, @ptrFromInt(0x40028700));
/// Ethernet: DMA controller operation
pub const ETHERNET_DMA = @ptrCast(*volatile types.ETHERNET_DMA, 0x40029000);
pub const ETHERNET_DMA = @as(*volatile types.ETHERNET_DMA, @ptrFromInt(0x40029000));
/// USB on the go full speed
pub const OTG_FS_GLOBAL = @ptrCast(*volatile types.OTG_FS_GLOBAL, 0x50000000);
pub const OTG_FS_GLOBAL = @as(*volatile types.OTG_FS_GLOBAL, @ptrFromInt(0x50000000));
/// USB on the go full speed
pub const OTG_FS_HOST = @ptrCast(*volatile types.OTG_FS_HOST, 0x50000400);
pub const OTG_FS_HOST = @as(*volatile types.OTG_FS_HOST, @ptrFromInt(0x50000400));
/// USB on the go full speed
pub const OTG_FS_DEVICE = @ptrCast(*volatile types.OTG_FS_DEVICE, 0x50000800);
pub const OTG_FS_DEVICE = @as(*volatile types.OTG_FS_DEVICE, @ptrFromInt(0x50000800));
/// USB on the go full speed
pub const OTG_FS_PWRCLK = @ptrCast(*volatile types.OTG_FS_PWRCLK, 0x50000e00);
pub const OTG_FS_PWRCLK = @as(*volatile types.OTG_FS_PWRCLK, @ptrFromInt(0x50000e00));
/// Flexible static memory controller
pub const FSMC = @ptrCast(*volatile types.FSMC, 0xa0000000);
pub const FSMC = @as(*volatile types.FSMC, @ptrFromInt(0xa0000000));
/// System control block ACTLR
pub const SCB_ACTRL = @ptrCast(*volatile types.SCB_ACTRL, 0xe000e008);
pub const SCB_ACTRL = @as(*volatile types.SCB_ACTRL, @ptrFromInt(0xe000e008));
/// SysTick timer
pub const STK = @ptrCast(*volatile types.STK, 0xe000e010);
pub const STK = @as(*volatile types.STK, @ptrFromInt(0xe000e010));
/// Nested Vectored Interrupt Controller
pub const NVIC = @ptrCast(*volatile types.NVIC, 0xe000e100);
pub const NVIC = @as(*volatile types.NVIC, @ptrFromInt(0xe000e100));
/// System control block
pub const SCB = @ptrCast(*volatile types.SCB, 0xe000ed00);
pub const SCB = @as(*volatile types.SCB, @ptrFromInt(0xe000ed00));
/// Memory protection unit
pub const MPU = @ptrCast(*volatile types.MPU, 0xe000ed90);
pub const MPU = @as(*volatile types.MPU, @ptrFromInt(0xe000ed90));
/// Nested vectored interrupt controller
pub const NVIC_STIR = @ptrCast(*volatile types.NVIC_STIR, 0xe000ef00);
pub const NVIC_STIR = @as(*volatile types.NVIC_STIR, @ptrFromInt(0xe000ef00));
/// Debug support
pub const DBG = @ptrCast(*volatile types.DBG, 0xe0042000);
pub const DBG = @as(*volatile types.DBG, @ptrFromInt(0xe0042000));
};
};
};

@ -121,133 +121,133 @@ pub const devices = struct {
pub const peripherals = struct {
/// General purpose timer
pub const TIM2 = @ptrCast(*volatile types.TIM2, 0x40000000);
pub const TIM2 = @as(*volatile types.TIM2, @ptrFromInt(0x40000000));
/// General purpose timer
pub const TIM3 = @ptrCast(*volatile types.TIM2, 0x40000400);
pub const TIM3 = @as(*volatile types.TIM2, @ptrFromInt(0x40000400));
/// General purpose timer
pub const TIM4 = @ptrCast(*volatile types.TIM2, 0x40000800);
pub const TIM4 = @as(*volatile types.TIM2, @ptrFromInt(0x40000800));
/// Basic timers
pub const TIM6 = @ptrCast(*volatile types.TIM6, 0x40001000);
pub const TIM6 = @as(*volatile types.TIM6, @ptrFromInt(0x40001000));
/// Basic timers
pub const TIM7 = @ptrCast(*volatile types.TIM6, 0x40001400);
pub const TIM7 = @as(*volatile types.TIM6, @ptrFromInt(0x40001400));
/// Real-time clock
pub const RTC = @ptrCast(*volatile types.RTC, 0x40002800);
pub const RTC = @as(*volatile types.RTC, @ptrFromInt(0x40002800));
/// Window watchdog
pub const WWDG = @ptrCast(*volatile types.WWDG, 0x40002c00);
pub const WWDG = @as(*volatile types.WWDG, @ptrFromInt(0x40002c00));
/// Independent watchdog
pub const IWDG = @ptrCast(*volatile types.IWDG, 0x40003000);
pub const IWDG = @as(*volatile types.IWDG, @ptrFromInt(0x40003000));
/// Serial peripheral interface/Inter-IC sound
pub const I2S2ext = @ptrCast(*volatile types.SPI1, 0x40003400);
pub const I2S2ext = @as(*volatile types.SPI1, @ptrFromInt(0x40003400));
/// Serial peripheral interface/Inter-IC sound
pub const SPI2 = @ptrCast(*volatile types.SPI1, 0x40003800);
pub const SPI2 = @as(*volatile types.SPI1, @ptrFromInt(0x40003800));
/// Serial peripheral interface/Inter-IC sound
pub const SPI3 = @ptrCast(*volatile types.SPI1, 0x40003c00);
pub const SPI3 = @as(*volatile types.SPI1, @ptrFromInt(0x40003c00));
/// Serial peripheral interface/Inter-IC sound
pub const I2S3ext = @ptrCast(*volatile types.SPI1, 0x40004000);
pub const I2S3ext = @as(*volatile types.SPI1, @ptrFromInt(0x40004000));
/// Universal synchronous asynchronous receiver transmitter
pub const USART2 = @ptrCast(*volatile types.USART1, 0x40004400);
pub const USART2 = @as(*volatile types.USART1, @ptrFromInt(0x40004400));
/// Universal synchronous asynchronous receiver transmitter
pub const USART3 = @ptrCast(*volatile types.USART1, 0x40004800);
pub const USART3 = @as(*volatile types.USART1, @ptrFromInt(0x40004800));
/// Universal synchronous asynchronous receiver transmitter
pub const UART4 = @ptrCast(*volatile types.USART1, 0x40004c00);
pub const UART4 = @as(*volatile types.USART1, @ptrFromInt(0x40004c00));
/// Universal synchronous asynchronous receiver transmitter
pub const UART5 = @ptrCast(*volatile types.USART1, 0x40005000);
pub const UART5 = @as(*volatile types.USART1, @ptrFromInt(0x40005000));
/// Inter-integrated circuit
pub const I2C1 = @ptrCast(*volatile types.I2C1, 0x40005400);
pub const I2C1 = @as(*volatile types.I2C1, @ptrFromInt(0x40005400));
/// Inter-integrated circuit
pub const I2C2 = @ptrCast(*volatile types.I2C1, 0x40005800);
pub const I2C2 = @as(*volatile types.I2C1, @ptrFromInt(0x40005800));
/// Universal serial bus full-speed device interface
pub const USB_FS = @ptrCast(*volatile types.USB_FS, 0x40005c00);
pub const USB_FS = @as(*volatile types.USB_FS, @ptrFromInt(0x40005c00));
/// Controller area network
pub const CAN = @ptrCast(*volatile types.CAN, 0x40006400);
pub const CAN = @as(*volatile types.CAN, @ptrFromInt(0x40006400));
/// Power control
pub const PWR = @ptrCast(*volatile types.PWR, 0x40007000);
pub const PWR = @as(*volatile types.PWR, @ptrFromInt(0x40007000));
/// Digital-to-analog converter
pub const DAC = @ptrCast(*volatile types.DAC, 0x40007400);
pub const DAC = @as(*volatile types.DAC, @ptrFromInt(0x40007400));
/// Inter-integrated circuit
pub const I2C3 = @ptrCast(*volatile types.I2C1, 0x40007800);
pub const I2C3 = @as(*volatile types.I2C1, @ptrFromInt(0x40007800));
/// System configuration controller _Comparator and Operational amplifier
pub const SYSCFG_COMP_OPAMP = @ptrCast(*volatile types.SYSCFG_COMP_OPAMP, 0x40010000);
pub const SYSCFG_COMP_OPAMP = @as(*volatile types.SYSCFG_COMP_OPAMP, @ptrFromInt(0x40010000));
/// External interrupt/event controller
pub const EXTI = @ptrCast(*volatile types.EXTI, 0x40010400);
pub const EXTI = @as(*volatile types.EXTI, @ptrFromInt(0x40010400));
/// Advanced timer
pub const TIM1 = @ptrCast(*volatile types.TIM1, 0x40012c00);
pub const TIM1 = @as(*volatile types.TIM1, @ptrFromInt(0x40012c00));
/// Serial peripheral interface/Inter-IC sound
pub const SPI1 = @ptrCast(*volatile types.SPI1, 0x40013000);
pub const SPI1 = @as(*volatile types.SPI1, @ptrFromInt(0x40013000));
/// Advanced-timers
pub const TIM8 = @ptrCast(*volatile types.TIM8, 0x40013400);
pub const TIM8 = @as(*volatile types.TIM8, @ptrFromInt(0x40013400));
/// Universal synchronous asynchronous receiver transmitter
pub const USART1 = @ptrCast(*volatile types.USART1, 0x40013800);
pub const USART1 = @as(*volatile types.USART1, @ptrFromInt(0x40013800));
/// Serial peripheral interface/Inter-IC sound
pub const SPI4 = @ptrCast(*volatile types.SPI1, 0x40013c00);
pub const SPI4 = @as(*volatile types.SPI1, @ptrFromInt(0x40013c00));
/// General purpose timers
pub const TIM15 = @ptrCast(*volatile types.TIM15, 0x40014000);
pub const TIM15 = @as(*volatile types.TIM15, @ptrFromInt(0x40014000));
/// General-purpose-timers
pub const TIM16 = @ptrCast(*volatile types.TIM16, 0x40014400);
pub const TIM16 = @as(*volatile types.TIM16, @ptrFromInt(0x40014400));
/// General purpose timer
pub const TIM17 = @ptrCast(*volatile types.TIM17, 0x40014800);
pub const TIM17 = @as(*volatile types.TIM17, @ptrFromInt(0x40014800));
/// Advanced timer
pub const TIM20 = @ptrCast(*volatile types.TIM1, 0x40015000);
pub const TIM20 = @as(*volatile types.TIM1, @ptrFromInt(0x40015000));
/// DMA controller 1
pub const DMA1 = @ptrCast(*volatile types.DMA1, 0x40020000);
pub const DMA1 = @as(*volatile types.DMA1, @ptrFromInt(0x40020000));
/// DMA controller 1
pub const DMA2 = @ptrCast(*volatile types.DMA1, 0x40020400);
pub const DMA2 = @as(*volatile types.DMA1, @ptrFromInt(0x40020400));
/// Reset and clock control
pub const RCC = @ptrCast(*volatile types.RCC, 0x40021000);
pub const RCC = @as(*volatile types.RCC, @ptrFromInt(0x40021000));
/// Flash
pub const Flash = @ptrCast(*volatile types.Flash, 0x40022000);
pub const Flash = @as(*volatile types.Flash, @ptrFromInt(0x40022000));
/// cyclic redundancy check calculation unit
pub const CRC = @ptrCast(*volatile types.CRC, 0x40023000);
pub const CRC = @as(*volatile types.CRC, @ptrFromInt(0x40023000));
/// Touch sensing controller
pub const TSC = @ptrCast(*volatile types.TSC, 0x40024000);
pub const TSC = @as(*volatile types.TSC, @ptrFromInt(0x40024000));
/// General-purpose I/Os
pub const GPIOA = @ptrCast(*volatile types.GPIOA, 0x48000000);
pub const GPIOA = @as(*volatile types.GPIOA, @ptrFromInt(0x48000000));
/// General-purpose I/Os
pub const GPIOB = @ptrCast(*volatile types.GPIOB, 0x48000400);
pub const GPIOB = @as(*volatile types.GPIOB, @ptrFromInt(0x48000400));
/// General-purpose I/Os
pub const GPIOC = @ptrCast(*volatile types.GPIOB, 0x48000800);
pub const GPIOC = @as(*volatile types.GPIOB, @ptrFromInt(0x48000800));
/// General-purpose I/Os
pub const GPIOD = @ptrCast(*volatile types.GPIOB, 0x48000c00);
pub const GPIOD = @as(*volatile types.GPIOB, @ptrFromInt(0x48000c00));
/// General-purpose I/Os
pub const GPIOE = @ptrCast(*volatile types.GPIOB, 0x48001000);
pub const GPIOE = @as(*volatile types.GPIOB, @ptrFromInt(0x48001000));
/// General-purpose I/Os
pub const GPIOF = @ptrCast(*volatile types.GPIOB, 0x48001400);
pub const GPIOF = @as(*volatile types.GPIOB, @ptrFromInt(0x48001400));
/// General-purpose I/Os
pub const GPIOG = @ptrCast(*volatile types.GPIOB, 0x48001800);
pub const GPIOG = @as(*volatile types.GPIOB, @ptrFromInt(0x48001800));
/// General-purpose I/Os
pub const GPIOH = @ptrCast(*volatile types.GPIOB, 0x48001c00);
pub const GPIOH = @as(*volatile types.GPIOB, @ptrFromInt(0x48001c00));
/// Analog-to-Digital Converter
pub const ADC1 = @ptrCast(*volatile types.ADC1, 0x50000000);
pub const ADC1 = @as(*volatile types.ADC1, @ptrFromInt(0x50000000));
/// Analog-to-Digital Converter
pub const ADC2 = @ptrCast(*volatile types.ADC1, 0x50000100);
pub const ADC2 = @as(*volatile types.ADC1, @ptrFromInt(0x50000100));
/// Analog-to-Digital Converter
pub const ADC1_2 = @ptrCast(*volatile types.ADC1_2, 0x50000300);
pub const ADC1_2 = @as(*volatile types.ADC1_2, @ptrFromInt(0x50000300));
/// Analog-to-Digital Converter
pub const ADC3 = @ptrCast(*volatile types.ADC1, 0x50000400);
pub const ADC3 = @as(*volatile types.ADC1, @ptrFromInt(0x50000400));
/// Analog-to-Digital Converter
pub const ADC4 = @ptrCast(*volatile types.ADC1, 0x50000500);
pub const ADC4 = @as(*volatile types.ADC1, @ptrFromInt(0x50000500));
/// Analog-to-Digital Converter
pub const ADC3_4 = @ptrCast(*volatile types.ADC1_2, 0x50000700);
pub const ADC3_4 = @as(*volatile types.ADC1_2, @ptrFromInt(0x50000700));
/// Flexible memory controller
pub const FMC = @ptrCast(*volatile types.FMC, 0xa0000400);
pub const FMC = @as(*volatile types.FMC, @ptrFromInt(0xa0000400));
/// System control block ACTLR
pub const SCB_ACTRL = @ptrCast(*volatile types.SCB_ACTRL, 0xe000e008);
pub const SCB_ACTRL = @as(*volatile types.SCB_ACTRL, @ptrFromInt(0xe000e008));
/// SysTick timer
pub const STK = @ptrCast(*volatile types.STK, 0xe000e010);
pub const STK = @as(*volatile types.STK, @ptrFromInt(0xe000e010));
/// Nested Vectored Interrupt Controller
pub const NVIC = @ptrCast(*volatile types.NVIC, 0xe000e100);
pub const NVIC = @as(*volatile types.NVIC, @ptrFromInt(0xe000e100));
/// System control block
pub const SCB = @ptrCast(*volatile types.SCB, 0xe000ed00);
pub const SCB = @as(*volatile types.SCB, @ptrFromInt(0xe000ed00));
/// Floating point unit CPACR
pub const FPU_CPACR = @ptrCast(*volatile types.FPU_CPACR, 0xe000ed88);
pub const FPU_CPACR = @as(*volatile types.FPU_CPACR, @ptrFromInt(0xe000ed88));
/// Memory protection unit
pub const MPU = @ptrCast(*volatile types.MPU, 0xe000ed90);
pub const MPU = @as(*volatile types.MPU, @ptrFromInt(0xe000ed90));
/// Nested vectored interrupt controller
pub const NVIC_STIR = @ptrCast(*volatile types.NVIC_STIR, 0xe000ef00);
pub const NVIC_STIR = @as(*volatile types.NVIC_STIR, @ptrFromInt(0xe000ef00));
/// Floting point unit
pub const FPU = @ptrCast(*volatile types.FPU, 0xe000ef34);
pub const FPU = @as(*volatile types.FPU, @ptrFromInt(0xe000ef34));
/// Debug support
pub const DBGMCU = @ptrCast(*volatile types.DBGMCU, 0xe0042000);
pub const DBGMCU = @as(*volatile types.DBGMCU, @ptrFromInt(0xe0042000));
};
};
};

@ -138,187 +138,187 @@ pub const devices = struct {
pub const peripherals = struct {
/// General purpose timers
pub const TIM2 = @ptrCast(*volatile types.TIM2, 0x40000000);
pub const TIM2 = @as(*volatile types.TIM2, @ptrFromInt(0x40000000));
/// General purpose timers
pub const TIM3 = @ptrCast(*volatile types.TIM3, 0x40000400);
pub const TIM3 = @as(*volatile types.TIM3, @ptrFromInt(0x40000400));
/// General purpose timers
pub const TIM4 = @ptrCast(*volatile types.TIM3, 0x40000800);
pub const TIM4 = @as(*volatile types.TIM3, @ptrFromInt(0x40000800));
/// General-purpose-timers
pub const TIM5 = @ptrCast(*volatile types.TIM5, 0x40000c00);
pub const TIM5 = @as(*volatile types.TIM5, @ptrFromInt(0x40000c00));
/// Basic timers
pub const TIM6 = @ptrCast(*volatile types.TIM6, 0x40001000);
pub const TIM6 = @as(*volatile types.TIM6, @ptrFromInt(0x40001000));
/// Basic timers
pub const TIM7 = @ptrCast(*volatile types.TIM6, 0x40001400);
pub const TIM7 = @as(*volatile types.TIM6, @ptrFromInt(0x40001400));
/// General purpose timers
pub const TIM12 = @ptrCast(*volatile types.TIM9, 0x40001800);
pub const TIM12 = @as(*volatile types.TIM9, @ptrFromInt(0x40001800));
/// General-purpose-timers
pub const TIM13 = @ptrCast(*volatile types.TIM10, 0x40001c00);
pub const TIM13 = @as(*volatile types.TIM10, @ptrFromInt(0x40001c00));
/// General-purpose-timers
pub const TIM14 = @ptrCast(*volatile types.TIM10, 0x40002000);
pub const TIM14 = @as(*volatile types.TIM10, @ptrFromInt(0x40002000));
/// Real-time clock
pub const RTC = @ptrCast(*volatile types.RTC, 0x40002800);
pub const RTC = @as(*volatile types.RTC, @ptrFromInt(0x40002800));
/// Window watchdog
pub const WWDG = @ptrCast(*volatile types.WWDG, 0x40002c00);
pub const WWDG = @as(*volatile types.WWDG, @ptrFromInt(0x40002c00));
/// Independent watchdog
pub const IWDG = @ptrCast(*volatile types.IWDG, 0x40003000);
pub const IWDG = @as(*volatile types.IWDG, @ptrFromInt(0x40003000));
/// Serial peripheral interface
pub const I2S2ext = @ptrCast(*volatile types.SPI1, 0x40003400);
pub const I2S2ext = @as(*volatile types.SPI1, @ptrFromInt(0x40003400));
/// Serial peripheral interface
pub const SPI2 = @ptrCast(*volatile types.SPI1, 0x40003800);
pub const SPI2 = @as(*volatile types.SPI1, @ptrFromInt(0x40003800));
/// Serial peripheral interface
pub const SPI3 = @ptrCast(*volatile types.SPI1, 0x40003c00);
pub const SPI3 = @as(*volatile types.SPI1, @ptrFromInt(0x40003c00));
/// Serial peripheral interface
pub const I2S3ext = @ptrCast(*volatile types.SPI1, 0x40004000);
pub const I2S3ext = @as(*volatile types.SPI1, @ptrFromInt(0x40004000));
/// Universal synchronous asynchronous receiver transmitter
pub const USART2 = @ptrCast(*volatile types.USART6, 0x40004400);
pub const USART2 = @as(*volatile types.USART6, @ptrFromInt(0x40004400));
/// Universal synchronous asynchronous receiver transmitter
pub const USART3 = @ptrCast(*volatile types.USART6, 0x40004800);
pub const USART3 = @as(*volatile types.USART6, @ptrFromInt(0x40004800));
/// Universal synchronous asynchronous receiver transmitter
pub const UART4 = @ptrCast(*volatile types.UART4, 0x40004c00);
pub const UART4 = @as(*volatile types.UART4, @ptrFromInt(0x40004c00));
/// Universal synchronous asynchronous receiver transmitter
pub const UART5 = @ptrCast(*volatile types.UART4, 0x40005000);
pub const UART5 = @as(*volatile types.UART4, @ptrFromInt(0x40005000));
/// Inter-integrated circuit
pub const I2C1 = @ptrCast(*volatile types.I2C3, 0x40005400);
pub const I2C1 = @as(*volatile types.I2C3, @ptrFromInt(0x40005400));
/// Inter-integrated circuit
pub const I2C2 = @ptrCast(*volatile types.I2C3, 0x40005800);
pub const I2C2 = @as(*volatile types.I2C3, @ptrFromInt(0x40005800));
/// Inter-integrated circuit
pub const I2C3 = @ptrCast(*volatile types.I2C3, 0x40005c00);
pub const I2C3 = @as(*volatile types.I2C3, @ptrFromInt(0x40005c00));
/// Controller area network
pub const CAN1 = @ptrCast(*volatile types.CAN1, 0x40006400);
pub const CAN1 = @as(*volatile types.CAN1, @ptrFromInt(0x40006400));
/// Controller area network
pub const CAN2 = @ptrCast(*volatile types.CAN1, 0x40006800);
pub const CAN2 = @as(*volatile types.CAN1, @ptrFromInt(0x40006800));
/// Power control
pub const PWR = @ptrCast(*volatile types.PWR, 0x40007000);
pub const PWR = @as(*volatile types.PWR, @ptrFromInt(0x40007000));
/// Digital-to-analog converter
pub const DAC = @ptrCast(*volatile types.DAC, 0x40007400);
pub const DAC = @as(*volatile types.DAC, @ptrFromInt(0x40007400));
/// Universal synchronous asynchronous receiver transmitter
pub const UART7 = @ptrCast(*volatile types.UART4, 0x40007800);
pub const UART7 = @as(*volatile types.UART4, @ptrFromInt(0x40007800));
/// Universal synchronous asynchronous receiver transmitter
pub const UART8 = @ptrCast(*volatile types.UART4, 0x40007c00);
pub const UART8 = @as(*volatile types.UART4, @ptrFromInt(0x40007c00));
/// Advanced-timers
pub const TIM1 = @ptrCast(*volatile types.TIM1, 0x40010000);
pub const TIM1 = @as(*volatile types.TIM1, @ptrFromInt(0x40010000));
/// Advanced-timers
pub const TIM8 = @ptrCast(*volatile types.TIM1, 0x40010400);
pub const TIM8 = @as(*volatile types.TIM1, @ptrFromInt(0x40010400));
/// Universal synchronous asynchronous receiver transmitter
pub const USART1 = @ptrCast(*volatile types.USART6, 0x40011000);
pub const USART1 = @as(*volatile types.USART6, @ptrFromInt(0x40011000));
/// Universal synchronous asynchronous receiver transmitter
pub const USART6 = @ptrCast(*volatile types.USART6, 0x40011400);
pub const USART6 = @as(*volatile types.USART6, @ptrFromInt(0x40011400));
/// Analog-to-digital converter
pub const ADC1 = @ptrCast(*volatile types.ADC1, 0x40012000);
pub const ADC1 = @as(*volatile types.ADC1, @ptrFromInt(0x40012000));
/// Analog-to-digital converter
pub const ADC2 = @ptrCast(*volatile types.ADC1, 0x40012100);
pub const ADC2 = @as(*volatile types.ADC1, @ptrFromInt(0x40012100));
/// Analog-to-digital converter
pub const ADC3 = @ptrCast(*volatile types.ADC1, 0x40012200);
pub const ADC3 = @as(*volatile types.ADC1, @ptrFromInt(0x40012200));
/// Common ADC registers
pub const C_ADC = @ptrCast(*volatile types.C_ADC, 0x40012300);
pub const C_ADC = @as(*volatile types.C_ADC, @ptrFromInt(0x40012300));
/// Secure digital input/output interface
pub const SDIO = @ptrCast(*volatile types.SDIO, 0x40012c00);
pub const SDIO = @as(*volatile types.SDIO, @ptrFromInt(0x40012c00));
/// Serial peripheral interface
pub const SPI1 = @ptrCast(*volatile types.SPI1, 0x40013000);
pub const SPI1 = @as(*volatile types.SPI1, @ptrFromInt(0x40013000));
/// Serial peripheral interface
pub const SPI4 = @ptrCast(*volatile types.SPI1, 0x40013400);
pub const SPI4 = @as(*volatile types.SPI1, @ptrFromInt(0x40013400));
/// System configuration controller
pub const SYSCFG = @ptrCast(*volatile types.SYSCFG, 0x40013800);
pub const SYSCFG = @as(*volatile types.SYSCFG, @ptrFromInt(0x40013800));
/// External interrupt/event controller
pub const EXTI = @ptrCast(*volatile types.EXTI, 0x40013c00);
pub const EXTI = @as(*volatile types.EXTI, @ptrFromInt(0x40013c00));
/// General purpose timers
pub const TIM9 = @ptrCast(*volatile types.TIM9, 0x40014000);
pub const TIM9 = @as(*volatile types.TIM9, @ptrFromInt(0x40014000));
/// General-purpose-timers
pub const TIM10 = @ptrCast(*volatile types.TIM10, 0x40014400);
pub const TIM10 = @as(*volatile types.TIM10, @ptrFromInt(0x40014400));
/// General-purpose-timers
pub const TIM11 = @ptrCast(*volatile types.TIM11, 0x40014800);
pub const TIM11 = @as(*volatile types.TIM11, @ptrFromInt(0x40014800));
/// Serial peripheral interface
pub const SPI5 = @ptrCast(*volatile types.SPI1, 0x40015000);
pub const SPI5 = @as(*volatile types.SPI1, @ptrFromInt(0x40015000));
/// Serial peripheral interface
pub const SPI6 = @ptrCast(*volatile types.SPI1, 0x40015400);
pub const SPI6 = @as(*volatile types.SPI1, @ptrFromInt(0x40015400));
/// Serial audio interface
pub const SAI1 = @ptrCast(*volatile types.SAI1, 0x40015800);
pub const SAI1 = @as(*volatile types.SAI1, @ptrFromInt(0x40015800));
/// LCD-TFT Controller
pub const LTDC = @ptrCast(*volatile types.LTDC, 0x40016800);
pub const LTDC = @as(*volatile types.LTDC, @ptrFromInt(0x40016800));
/// General-purpose I/Os
pub const GPIOA = @ptrCast(*volatile types.GPIOA, 0x40020000);
pub const GPIOA = @as(*volatile types.GPIOA, @ptrFromInt(0x40020000));
/// General-purpose I/Os
pub const GPIOB = @ptrCast(*volatile types.GPIOB, 0x40020400);
pub const GPIOB = @as(*volatile types.GPIOB, @ptrFromInt(0x40020400));
/// General-purpose I/Os
pub const GPIOC = @ptrCast(*volatile types.GPIOI, 0x40020800);
pub const GPIOC = @as(*volatile types.GPIOI, @ptrFromInt(0x40020800));
/// General-purpose I/Os
pub const GPIOD = @ptrCast(*volatile types.GPIOI, 0x40020c00);
pub const GPIOD = @as(*volatile types.GPIOI, @ptrFromInt(0x40020c00));
/// General-purpose I/Os
pub const GPIOE = @ptrCast(*volatile types.GPIOI, 0x40021000);
pub const GPIOE = @as(*volatile types.GPIOI, @ptrFromInt(0x40021000));
/// General-purpose I/Os
pub const GPIOF = @ptrCast(*volatile types.GPIOI, 0x40021400);
pub const GPIOF = @as(*volatile types.GPIOI, @ptrFromInt(0x40021400));
/// General-purpose I/Os
pub const GPIOG = @ptrCast(*volatile types.GPIOI, 0x40021800);
pub const GPIOG = @as(*volatile types.GPIOI, @ptrFromInt(0x40021800));
/// General-purpose I/Os
pub const GPIOH = @ptrCast(*volatile types.GPIOI, 0x40021c00);
pub const GPIOH = @as(*volatile types.GPIOI, @ptrFromInt(0x40021c00));
/// General-purpose I/Os
pub const GPIOI = @ptrCast(*volatile types.GPIOI, 0x40022000);
pub const GPIOI = @as(*volatile types.GPIOI, @ptrFromInt(0x40022000));
/// General-purpose I/Os
pub const GPIOJ = @ptrCast(*volatile types.GPIOI, 0x40022400);
pub const GPIOJ = @as(*volatile types.GPIOI, @ptrFromInt(0x40022400));
/// General-purpose I/Os
pub const GPIOK = @ptrCast(*volatile types.GPIOI, 0x40022800);
pub const GPIOK = @as(*volatile types.GPIOI, @ptrFromInt(0x40022800));
/// Cryptographic processor
pub const CRC = @ptrCast(*volatile types.CRC, 0x40023000);
pub const CRC = @as(*volatile types.CRC, @ptrFromInt(0x40023000));
/// Reset and clock control
pub const RCC = @ptrCast(*volatile types.RCC, 0x40023800);
pub const RCC = @as(*volatile types.RCC, @ptrFromInt(0x40023800));
/// FLASH
pub const FLASH = @ptrCast(*volatile types.FLASH, 0x40023c00);
pub const FLASH = @as(*volatile types.FLASH, @ptrFromInt(0x40023c00));
/// DMA controller
pub const DMA1 = @ptrCast(*volatile types.DMA2, 0x40026000);
pub const DMA1 = @as(*volatile types.DMA2, @ptrFromInt(0x40026000));
/// DMA controller
pub const DMA2 = @ptrCast(*volatile types.DMA2, 0x40026400);
pub const DMA2 = @as(*volatile types.DMA2, @ptrFromInt(0x40026400));
/// Ethernet: media access control (MAC)
pub const Ethernet_MAC = @ptrCast(*volatile types.Ethernet_MAC, 0x40028000);
pub const Ethernet_MAC = @as(*volatile types.Ethernet_MAC, @ptrFromInt(0x40028000));
/// Ethernet: MAC management counters
pub const Ethernet_MMC = @ptrCast(*volatile types.Ethernet_MMC, 0x40028100);
pub const Ethernet_MMC = @as(*volatile types.Ethernet_MMC, @ptrFromInt(0x40028100));
/// Ethernet: Precision time protocol
pub const Ethernet_PTP = @ptrCast(*volatile types.Ethernet_PTP, 0x40028700);
pub const Ethernet_PTP = @as(*volatile types.Ethernet_PTP, @ptrFromInt(0x40028700));
/// Ethernet: DMA controller operation
pub const Ethernet_DMA = @ptrCast(*volatile types.Ethernet_DMA, 0x40029000);
pub const Ethernet_DMA = @as(*volatile types.Ethernet_DMA, @ptrFromInt(0x40029000));
/// USB on the go high speed
pub const OTG_HS_GLOBAL = @ptrCast(*volatile types.OTG_HS_GLOBAL, 0x40040000);
pub const OTG_HS_GLOBAL = @as(*volatile types.OTG_HS_GLOBAL, @ptrFromInt(0x40040000));
/// USB on the go high speed
pub const OTG_HS_HOST = @ptrCast(*volatile types.OTG_HS_HOST, 0x40040400);
pub const OTG_HS_HOST = @as(*volatile types.OTG_HS_HOST, @ptrFromInt(0x40040400));
/// USB on the go high speed
pub const OTG_HS_DEVICE = @ptrCast(*volatile types.OTG_HS_DEVICE, 0x40040800);
pub const OTG_HS_DEVICE = @as(*volatile types.OTG_HS_DEVICE, @ptrFromInt(0x40040800));
/// USB on the go high speed
pub const OTG_HS_PWRCLK = @ptrCast(*volatile types.OTG_HS_PWRCLK, 0x40040e00);
pub const OTG_HS_PWRCLK = @as(*volatile types.OTG_HS_PWRCLK, @ptrFromInt(0x40040e00));
/// USB on the go full speed
pub const OTG_FS_GLOBAL = @ptrCast(*volatile types.OTG_FS_GLOBAL, 0x50000000);
pub const OTG_FS_GLOBAL = @as(*volatile types.OTG_FS_GLOBAL, @ptrFromInt(0x50000000));
/// USB on the go full speed
pub const OTG_FS_HOST = @ptrCast(*volatile types.OTG_FS_HOST, 0x50000400);
pub const OTG_FS_HOST = @as(*volatile types.OTG_FS_HOST, @ptrFromInt(0x50000400));
/// USB on the go full speed
pub const OTG_FS_DEVICE = @ptrCast(*volatile types.OTG_FS_DEVICE, 0x50000800);
pub const OTG_FS_DEVICE = @as(*volatile types.OTG_FS_DEVICE, @ptrFromInt(0x50000800));
/// USB on the go full speed
pub const OTG_FS_PWRCLK = @ptrCast(*volatile types.OTG_FS_PWRCLK, 0x50000e00);
pub const OTG_FS_PWRCLK = @as(*volatile types.OTG_FS_PWRCLK, @ptrFromInt(0x50000e00));
/// Digital camera interface
pub const DCMI = @ptrCast(*volatile types.DCMI, 0x50050000);
pub const DCMI = @as(*volatile types.DCMI, @ptrFromInt(0x50050000));
/// Cryptographic processor
pub const CRYP = @ptrCast(*volatile types.CRYP, 0x50060000);
pub const CRYP = @as(*volatile types.CRYP, @ptrFromInt(0x50060000));
/// Hash processor
pub const HASH = @ptrCast(*volatile types.HASH, 0x50060400);
pub const HASH = @as(*volatile types.HASH, @ptrFromInt(0x50060400));
/// Random number generator
pub const RNG = @ptrCast(*volatile types.RNG, 0x50060800);
pub const RNG = @as(*volatile types.RNG, @ptrFromInt(0x50060800));
/// Flexible static memory controller
pub const FSMC = @ptrCast(*volatile types.FSMC, 0xa0000000);
pub const FSMC = @as(*volatile types.FSMC, @ptrFromInt(0xa0000000));
/// System control block ACTLR
pub const SCB_ACTRL = @ptrCast(*volatile types.SCB_ACTRL, 0xe000e008);
pub const SCB_ACTRL = @as(*volatile types.SCB_ACTRL, @ptrFromInt(0xe000e008));
/// SysTick timer
pub const STK = @ptrCast(*volatile types.STK, 0xe000e010);
pub const STK = @as(*volatile types.STK, @ptrFromInt(0xe000e010));
/// Nested Vectored Interrupt Controller
pub const NVIC = @ptrCast(*volatile types.NVIC, 0xe000e100);
pub const NVIC = @as(*volatile types.NVIC, @ptrFromInt(0xe000e100));
/// System control block
pub const SCB = @ptrCast(*volatile types.SCB, 0xe000ed00);
pub const SCB = @as(*volatile types.SCB, @ptrFromInt(0xe000ed00));
/// Floating point unit CPACR
pub const FPU_CPACR = @ptrCast(*volatile types.FPU_CPACR, 0xe000ed88);
pub const FPU_CPACR = @as(*volatile types.FPU_CPACR, @ptrFromInt(0xe000ed88));
/// Memory protection unit
pub const MPU = @ptrCast(*volatile types.MPU, 0xe000ed90);
pub const MPU = @as(*volatile types.MPU, @ptrFromInt(0xe000ed90));
/// Nested vectored interrupt controller
pub const NVIC_STIR = @ptrCast(*volatile types.NVIC_STIR, 0xe000ef00);
pub const NVIC_STIR = @as(*volatile types.NVIC_STIR, @ptrFromInt(0xe000ef00));
/// Floting point unit
pub const FPU = @ptrCast(*volatile types.FPU, 0xe000ef34);
pub const FPU = @as(*volatile types.FPU, @ptrFromInt(0xe000ef34));
/// Debug support
pub const DBG = @ptrCast(*volatile types.DBG, 0xe0042000);
pub const DBG = @as(*volatile types.DBG, @ptrFromInt(0xe0042000));
};
};
};

@ -149,189 +149,189 @@ pub const devices = struct {
pub const peripherals = struct {
/// General purpose timers
pub const TIM2 = @ptrCast(*volatile types.TIM2, 0x40000000);
pub const TIM2 = @as(*volatile types.TIM2, @ptrFromInt(0x40000000));
/// General purpose timers
pub const TIM3 = @ptrCast(*volatile types.TIM3, 0x40000400);
pub const TIM3 = @as(*volatile types.TIM3, @ptrFromInt(0x40000400));
/// General purpose timers
pub const TIM4 = @ptrCast(*volatile types.TIM3, 0x40000800);
pub const TIM4 = @as(*volatile types.TIM3, @ptrFromInt(0x40000800));
/// General-purpose-timers
pub const TIM5 = @ptrCast(*volatile types.TIM5, 0x40000c00);
pub const TIM5 = @as(*volatile types.TIM5, @ptrFromInt(0x40000c00));
/// Basic timers
pub const TIM6 = @ptrCast(*volatile types.TIM6, 0x40001000);
pub const TIM6 = @as(*volatile types.TIM6, @ptrFromInt(0x40001000));
/// Basic timers
pub const TIM7 = @ptrCast(*volatile types.TIM6, 0x40001400);
pub const TIM7 = @as(*volatile types.TIM6, @ptrFromInt(0x40001400));
/// General purpose timers
pub const TIM12 = @ptrCast(*volatile types.TIM9, 0x40001800);
pub const TIM12 = @as(*volatile types.TIM9, @ptrFromInt(0x40001800));
/// General-purpose-timers
pub const TIM13 = @ptrCast(*volatile types.TIM10, 0x40001c00);
pub const TIM13 = @as(*volatile types.TIM10, @ptrFromInt(0x40001c00));
/// General-purpose-timers
pub const TIM14 = @ptrCast(*volatile types.TIM10, 0x40002000);
pub const TIM14 = @as(*volatile types.TIM10, @ptrFromInt(0x40002000));
/// Real-time clock
pub const RTC = @ptrCast(*volatile types.RTC, 0x40002800);
pub const RTC = @as(*volatile types.RTC, @ptrFromInt(0x40002800));
/// Window watchdog
pub const WWDG = @ptrCast(*volatile types.WWDG, 0x40002c00);
pub const WWDG = @as(*volatile types.WWDG, @ptrFromInt(0x40002c00));
/// Independent watchdog
pub const IWDG = @ptrCast(*volatile types.IWDG, 0x40003000);
pub const IWDG = @as(*volatile types.IWDG, @ptrFromInt(0x40003000));
/// Serial peripheral interface
pub const I2S2ext = @ptrCast(*volatile types.SPI1, 0x40003400);
pub const I2S2ext = @as(*volatile types.SPI1, @ptrFromInt(0x40003400));
/// Serial peripheral interface
pub const SPI2 = @ptrCast(*volatile types.SPI1, 0x40003800);
pub const SPI2 = @as(*volatile types.SPI1, @ptrFromInt(0x40003800));
/// Serial peripheral interface
pub const SPI3 = @ptrCast(*volatile types.SPI1, 0x40003c00);
pub const SPI3 = @as(*volatile types.SPI1, @ptrFromInt(0x40003c00));
/// Serial peripheral interface
pub const I2S3ext = @ptrCast(*volatile types.SPI1, 0x40004000);
pub const I2S3ext = @as(*volatile types.SPI1, @ptrFromInt(0x40004000));
/// Universal synchronous asynchronous receiver transmitter
pub const USART2 = @ptrCast(*volatile types.USART6, 0x40004400);
pub const USART2 = @as(*volatile types.USART6, @ptrFromInt(0x40004400));
/// Universal synchronous asynchronous receiver transmitter
pub const USART3 = @ptrCast(*volatile types.USART6, 0x40004800);
pub const USART3 = @as(*volatile types.USART6, @ptrFromInt(0x40004800));
/// Universal synchronous asynchronous receiver transmitter
pub const UART4 = @ptrCast(*volatile types.UART4, 0x40004c00);
pub const UART4 = @as(*volatile types.UART4, @ptrFromInt(0x40004c00));
/// Universal synchronous asynchronous receiver transmitter
pub const UART5 = @ptrCast(*volatile types.UART4, 0x40005000);
pub const UART5 = @as(*volatile types.UART4, @ptrFromInt(0x40005000));
/// Inter-integrated circuit
pub const I2C1 = @ptrCast(*volatile types.I2C3, 0x40005400);
pub const I2C1 = @as(*volatile types.I2C3, @ptrFromInt(0x40005400));
/// Inter-integrated circuit
pub const I2C2 = @ptrCast(*volatile types.I2C3, 0x40005800);
pub const I2C2 = @as(*volatile types.I2C3, @ptrFromInt(0x40005800));
/// Inter-integrated circuit
pub const I2C3 = @ptrCast(*volatile types.I2C3, 0x40005c00);
pub const I2C3 = @as(*volatile types.I2C3, @ptrFromInt(0x40005c00));
/// Controller area network
pub const CAN1 = @ptrCast(*volatile types.CAN1, 0x40006400);
pub const CAN1 = @as(*volatile types.CAN1, @ptrFromInt(0x40006400));
/// Controller area network
pub const CAN2 = @ptrCast(*volatile types.CAN1, 0x40006800);
pub const CAN2 = @as(*volatile types.CAN1, @ptrFromInt(0x40006800));
/// Power control
pub const PWR = @ptrCast(*volatile types.PWR, 0x40007000);
pub const PWR = @as(*volatile types.PWR, @ptrFromInt(0x40007000));
/// Digital-to-analog converter
pub const DAC = @ptrCast(*volatile types.DAC, 0x40007400);
pub const DAC = @as(*volatile types.DAC, @ptrFromInt(0x40007400));
/// Universal synchronous asynchronous receiver transmitter
pub const UART7 = @ptrCast(*volatile types.USART6, 0x40007800);
pub const UART7 = @as(*volatile types.USART6, @ptrFromInt(0x40007800));
/// Universal synchronous asynchronous receiver transmitter
pub const UART8 = @ptrCast(*volatile types.USART6, 0x40007c00);
pub const UART8 = @as(*volatile types.USART6, @ptrFromInt(0x40007c00));
/// Advanced-timers
pub const TIM1 = @ptrCast(*volatile types.TIM1, 0x40010000);
pub const TIM1 = @as(*volatile types.TIM1, @ptrFromInt(0x40010000));
/// Advanced-timers
pub const TIM8 = @ptrCast(*volatile types.TIM1, 0x40010400);
pub const TIM8 = @as(*volatile types.TIM1, @ptrFromInt(0x40010400));
/// Universal synchronous asynchronous receiver transmitter
pub const USART1 = @ptrCast(*volatile types.USART6, 0x40011000);
pub const USART1 = @as(*volatile types.USART6, @ptrFromInt(0x40011000));
/// Universal synchronous asynchronous receiver transmitter
pub const USART6 = @ptrCast(*volatile types.USART6, 0x40011400);
pub const USART6 = @as(*volatile types.USART6, @ptrFromInt(0x40011400));
/// Analog-to-digital converter
pub const ADC1 = @ptrCast(*volatile types.ADC1, 0x40012000);
pub const ADC1 = @as(*volatile types.ADC1, @ptrFromInt(0x40012000));
/// Analog-to-digital converter
pub const ADC2 = @ptrCast(*volatile types.ADC1, 0x40012100);
pub const ADC2 = @as(*volatile types.ADC1, @ptrFromInt(0x40012100));
/// Analog-to-digital converter
pub const ADC3 = @ptrCast(*volatile types.ADC1, 0x40012200);
pub const ADC3 = @as(*volatile types.ADC1, @ptrFromInt(0x40012200));
/// Common ADC registers
pub const C_ADC = @ptrCast(*volatile types.C_ADC, 0x40012300);
pub const C_ADC = @as(*volatile types.C_ADC, @ptrFromInt(0x40012300));
/// Secure digital input/output interface
pub const SDIO = @ptrCast(*volatile types.SDIO, 0x40012c00);
pub const SDIO = @as(*volatile types.SDIO, @ptrFromInt(0x40012c00));
/// Serial peripheral interface
pub const SPI1 = @ptrCast(*volatile types.SPI1, 0x40013000);
pub const SPI1 = @as(*volatile types.SPI1, @ptrFromInt(0x40013000));
/// Serial peripheral interface
pub const SPI4 = @ptrCast(*volatile types.SPI1, 0x40013400);
pub const SPI4 = @as(*volatile types.SPI1, @ptrFromInt(0x40013400));
/// System configuration controller
pub const SYSCFG = @ptrCast(*volatile types.SYSCFG, 0x40013800);
pub const SYSCFG = @as(*volatile types.SYSCFG, @ptrFromInt(0x40013800));
/// External interrupt/event controller
pub const EXTI = @ptrCast(*volatile types.EXTI, 0x40013c00);
pub const EXTI = @as(*volatile types.EXTI, @ptrFromInt(0x40013c00));
/// General purpose timers
pub const TIM9 = @ptrCast(*volatile types.TIM9, 0x40014000);
pub const TIM9 = @as(*volatile types.TIM9, @ptrFromInt(0x40014000));
/// General-purpose-timers
pub const TIM10 = @ptrCast(*volatile types.TIM10, 0x40014400);
pub const TIM10 = @as(*volatile types.TIM10, @ptrFromInt(0x40014400));
/// General-purpose-timers
pub const TIM11 = @ptrCast(*volatile types.TIM11, 0x40014800);
pub const TIM11 = @as(*volatile types.TIM11, @ptrFromInt(0x40014800));
/// Serial peripheral interface
pub const SPI5 = @ptrCast(*volatile types.SPI1, 0x40015000);
pub const SPI5 = @as(*volatile types.SPI1, @ptrFromInt(0x40015000));
/// Serial peripheral interface
pub const SPI6 = @ptrCast(*volatile types.SPI1, 0x40015400);
pub const SPI6 = @as(*volatile types.SPI1, @ptrFromInt(0x40015400));
/// Serial audio interface
pub const SAI = @ptrCast(*volatile types.SAI, 0x40015800);
pub const SAI = @as(*volatile types.SAI, @ptrFromInt(0x40015800));
/// LCD-TFT Controller
pub const LTDC = @ptrCast(*volatile types.LTDC, 0x40016800);
pub const LTDC = @as(*volatile types.LTDC, @ptrFromInt(0x40016800));
/// General-purpose I/Os
pub const GPIOA = @ptrCast(*volatile types.GPIOA, 0x40020000);
pub const GPIOA = @as(*volatile types.GPIOA, @ptrFromInt(0x40020000));
/// General-purpose I/Os
pub const GPIOB = @ptrCast(*volatile types.GPIOB, 0x40020400);
pub const GPIOB = @as(*volatile types.GPIOB, @ptrFromInt(0x40020400));
/// General-purpose I/Os
pub const GPIOC = @ptrCast(*volatile types.GPIOK, 0x40020800);
pub const GPIOC = @as(*volatile types.GPIOK, @ptrFromInt(0x40020800));
/// General-purpose I/Os
pub const GPIOD = @ptrCast(*volatile types.GPIOK, 0x40020c00);
pub const GPIOD = @as(*volatile types.GPIOK, @ptrFromInt(0x40020c00));
/// General-purpose I/Os
pub const GPIOE = @ptrCast(*volatile types.GPIOK, 0x40021000);
pub const GPIOE = @as(*volatile types.GPIOK, @ptrFromInt(0x40021000));
/// General-purpose I/Os
pub const GPIOF = @ptrCast(*volatile types.GPIOK, 0x40021400);
pub const GPIOF = @as(*volatile types.GPIOK, @ptrFromInt(0x40021400));
/// General-purpose I/Os
pub const GPIOG = @ptrCast(*volatile types.GPIOK, 0x40021800);
pub const GPIOG = @as(*volatile types.GPIOK, @ptrFromInt(0x40021800));
/// General-purpose I/Os
pub const GPIOH = @ptrCast(*volatile types.GPIOK, 0x40021c00);
pub const GPIOH = @as(*volatile types.GPIOK, @ptrFromInt(0x40021c00));
/// General-purpose I/Os
pub const GPIOI = @ptrCast(*volatile types.GPIOK, 0x40022000);
pub const GPIOI = @as(*volatile types.GPIOK, @ptrFromInt(0x40022000));
/// General-purpose I/Os
pub const GPIOJ = @ptrCast(*volatile types.GPIOK, 0x40022400);
pub const GPIOJ = @as(*volatile types.GPIOK, @ptrFromInt(0x40022400));
/// General-purpose I/Os
pub const GPIOK = @ptrCast(*volatile types.GPIOK, 0x40022800);
pub const GPIOK = @as(*volatile types.GPIOK, @ptrFromInt(0x40022800));
/// Cryptographic processor
pub const CRC = @ptrCast(*volatile types.CRC, 0x40023000);
pub const CRC = @as(*volatile types.CRC, @ptrFromInt(0x40023000));
/// Reset and clock control
pub const RCC = @ptrCast(*volatile types.RCC, 0x40023800);
pub const RCC = @as(*volatile types.RCC, @ptrFromInt(0x40023800));
/// FLASH
pub const FLASH = @ptrCast(*volatile types.FLASH, 0x40023c00);
pub const FLASH = @as(*volatile types.FLASH, @ptrFromInt(0x40023c00));
/// DMA controller
pub const DMA1 = @ptrCast(*volatile types.DMA2, 0x40026000);
pub const DMA1 = @as(*volatile types.DMA2, @ptrFromInt(0x40026000));
/// DMA controller
pub const DMA2 = @ptrCast(*volatile types.DMA2, 0x40026400);
pub const DMA2 = @as(*volatile types.DMA2, @ptrFromInt(0x40026400));
/// Ethernet: media access control (MAC)
pub const Ethernet_MAC = @ptrCast(*volatile types.Ethernet_MAC, 0x40028000);
pub const Ethernet_MAC = @as(*volatile types.Ethernet_MAC, @ptrFromInt(0x40028000));
/// Ethernet: MAC management counters
pub const Ethernet_MMC = @ptrCast(*volatile types.Ethernet_MMC, 0x40028100);
pub const Ethernet_MMC = @as(*volatile types.Ethernet_MMC, @ptrFromInt(0x40028100));
/// Ethernet: Precision time protocol
pub const Ethernet_PTP = @ptrCast(*volatile types.Ethernet_PTP, 0x40028700);
pub const Ethernet_PTP = @as(*volatile types.Ethernet_PTP, @ptrFromInt(0x40028700));
/// Ethernet: DMA controller operation
pub const Ethernet_DMA = @ptrCast(*volatile types.Ethernet_DMA, 0x40029000);
pub const Ethernet_DMA = @as(*volatile types.Ethernet_DMA, @ptrFromInt(0x40029000));
/// DMA2D controller
pub const DMA2D = @ptrCast(*volatile types.DMA2D, 0x4002b000);
pub const DMA2D = @as(*volatile types.DMA2D, @ptrFromInt(0x4002b000));
/// USB on the go high speed
pub const OTG_HS_GLOBAL = @ptrCast(*volatile types.OTG_HS_GLOBAL, 0x40040000);
pub const OTG_HS_GLOBAL = @as(*volatile types.OTG_HS_GLOBAL, @ptrFromInt(0x40040000));
/// USB on the go high speed
pub const OTG_HS_HOST = @ptrCast(*volatile types.OTG_HS_HOST, 0x40040400);
pub const OTG_HS_HOST = @as(*volatile types.OTG_HS_HOST, @ptrFromInt(0x40040400));
/// USB on the go high speed
pub const OTG_HS_DEVICE = @ptrCast(*volatile types.OTG_HS_DEVICE, 0x40040800);
pub const OTG_HS_DEVICE = @as(*volatile types.OTG_HS_DEVICE, @ptrFromInt(0x40040800));
/// USB on the go high speed
pub const OTG_HS_PWRCLK = @ptrCast(*volatile types.OTG_HS_PWRCLK, 0x40040e00);
pub const OTG_HS_PWRCLK = @as(*volatile types.OTG_HS_PWRCLK, @ptrFromInt(0x40040e00));
/// USB on the go full speed
pub const OTG_FS_GLOBAL = @ptrCast(*volatile types.OTG_FS_GLOBAL, 0x50000000);
pub const OTG_FS_GLOBAL = @as(*volatile types.OTG_FS_GLOBAL, @ptrFromInt(0x50000000));
/// USB on the go full speed
pub const OTG_FS_HOST = @ptrCast(*volatile types.OTG_FS_HOST, 0x50000400);
pub const OTG_FS_HOST = @as(*volatile types.OTG_FS_HOST, @ptrFromInt(0x50000400));
/// USB on the go full speed
pub const OTG_FS_DEVICE = @ptrCast(*volatile types.OTG_FS_DEVICE, 0x50000800);
pub const OTG_FS_DEVICE = @as(*volatile types.OTG_FS_DEVICE, @ptrFromInt(0x50000800));
/// USB on the go full speed
pub const OTG_FS_PWRCLK = @ptrCast(*volatile types.OTG_FS_PWRCLK, 0x50000e00);
pub const OTG_FS_PWRCLK = @as(*volatile types.OTG_FS_PWRCLK, @ptrFromInt(0x50000e00));
/// Digital camera interface
pub const DCMI = @ptrCast(*volatile types.DCMI, 0x50050000);
pub const DCMI = @as(*volatile types.DCMI, @ptrFromInt(0x50050000));
/// Cryptographic processor
pub const CRYP = @ptrCast(*volatile types.CRYP, 0x50060000);
pub const CRYP = @as(*volatile types.CRYP, @ptrFromInt(0x50060000));
/// Hash processor
pub const HASH = @ptrCast(*volatile types.HASH, 0x50060400);
pub const HASH = @as(*volatile types.HASH, @ptrFromInt(0x50060400));
/// Random number generator
pub const RNG = @ptrCast(*volatile types.RNG, 0x50060800);
pub const RNG = @as(*volatile types.RNG, @ptrFromInt(0x50060800));
/// Flexible memory controller
pub const FMC = @ptrCast(*volatile types.FMC, 0xa0000000);
pub const FMC = @as(*volatile types.FMC, @ptrFromInt(0xa0000000));
/// System control block ACTLR
pub const SCB_ACTRL = @ptrCast(*volatile types.SCB_ACTRL, 0xe000e008);
pub const SCB_ACTRL = @as(*volatile types.SCB_ACTRL, @ptrFromInt(0xe000e008));
/// SysTick timer
pub const STK = @ptrCast(*volatile types.STK, 0xe000e010);
pub const STK = @as(*volatile types.STK, @ptrFromInt(0xe000e010));
/// Nested Vectored Interrupt Controller
pub const NVIC = @ptrCast(*volatile types.NVIC, 0xe000e100);
pub const NVIC = @as(*volatile types.NVIC, @ptrFromInt(0xe000e100));
/// System control block
pub const SCB = @ptrCast(*volatile types.SCB, 0xe000ed00);
pub const SCB = @as(*volatile types.SCB, @ptrFromInt(0xe000ed00));
/// Floating point unit CPACR
pub const FPU_CPACR = @ptrCast(*volatile types.FPU_CPACR, 0xe000ed88);
pub const FPU_CPACR = @as(*volatile types.FPU_CPACR, @ptrFromInt(0xe000ed88));
/// Memory protection unit
pub const MPU = @ptrCast(*volatile types.MPU, 0xe000ed90);
pub const MPU = @as(*volatile types.MPU, @ptrFromInt(0xe000ed90));
/// Nested vectored interrupt controller
pub const NVIC_STIR = @ptrCast(*volatile types.NVIC_STIR, 0xe000ef00);
pub const NVIC_STIR = @as(*volatile types.NVIC_STIR, @ptrFromInt(0xe000ef00));
/// Floting point unit
pub const FPU = @ptrCast(*volatile types.FPU, 0xe000ef34);
pub const FPU = @as(*volatile types.FPU, @ptrFromInt(0xe000ef34));
/// Debug support
pub const DBG = @ptrCast(*volatile types.DBG, 0xe0042000);
pub const DBG = @as(*volatile types.DBG, @ptrFromInt(0xe0042000));
};
};
};

@ -103,7 +103,7 @@ pub const gpio = struct {
pub fn read(comptime pin: type) micro.gpio.State {
const idr_reg = pin.gpio_port.IDR;
const reg_value = @field(idr_reg.read(), "IDR" ++ pin.suffix); // TODO extract to getRegField()?
return @intToEnum(micro.gpio.State, reg_value);
return @as(micro.gpio.State, @enumFromInt(reg_value));
}
pub fn write(comptime pin: type, state: micro.gpio.State) void {
@ -180,11 +180,11 @@ pub fn Uart(comptime index: usize, comptime pins: micro.uart.Pins) type {
// set parity
if (config.parity) |parity| {
USART1.CR1.modify(.{ .PCE = 1, .PS = @enumToInt(parity) });
USART1.CR1.modify(.{ .PCE = 1, .PS = @intFromEnum(parity) });
} else USART1.CR1.modify(.{ .PCE = 0 }); // no parity, probably the chip default
// set number of stop bits
USART1.CR2.modify(.{ .STOP = @enumToInt(config.stop_bits) });
USART1.CR2.modify(.{ .STOP = @intFromEnum(config.stop_bits) });
// set the baud rate
// TODO: Do not use the _board_'s frequency, but the _U(S)ARTx_ frequency
@ -193,7 +193,7 @@ pub fn Uart(comptime index: usize, comptime pins: micro.uart.Pins) type {
// if the board doesn't configure e.g. an HSE external crystal.
// TODO: Do some checks to see if the baud rate is too high (or perhaps too low)
// TODO: Do a rounding div, instead of a truncating div?
const usartdiv = @intCast(u16, @divTrunc(micro.clock.get().apb1, config.baud_rate));
const usartdiv = @as(u16, @intCast(@divTrunc(micro.clock.get().apb1, config.baud_rate)));
USART1.BRR.raw = usartdiv;
// Above, ignore the BRR struct fields DIV_Mantissa and DIV_Fraction,
// those seem to be for another chipset; .svd file bug?
@ -254,7 +254,7 @@ pub fn Uart(comptime index: usize, comptime pins: micro.uart.Pins) type {
pub fn rx(self: Self) u8 {
while (!self.can_read()) {} // Wait till the data is received
const data_with_parity_bit: u9 = USART1.RDR.read().RDR;
return @intCast(u8, data_with_parity_bit & self.parity_read_mask);
return @as(u8, @intCast(data_with_parity_bit & self.parity_read_mask));
}
};
}
@ -429,7 +429,7 @@ pub fn I2CController(comptime index: usize, comptime pins: micro.i2c.Pins) type
.ADD10 = 0,
.SADD1 = self.address,
.RD_WRN = 1, // read
.NBYTES = @intCast(u8, buffer.len),
.NBYTES = @as(u8, @intCast(buffer.len)),
});
debug_print("I2C1 prepared for read of {} byte(s) from 0b{b:0<7}\r\n", .{ buffer.len, self.address });
@ -556,7 +556,7 @@ pub fn SpiBus(comptime index: usize) type {
// write
const write_byte = if (optional_write_byte) |b| b else undefined; // dummy value
@bitCast([dr_byte_size]u8, SPI1.DR.*)[0] = write_byte;
@as([dr_byte_size]u8, @bitCast(SPI1.DR.*))[0] = write_byte;
debug_print("Sent: {X:2}.\r\n", .{write_byte});
// wait until read processed
@ -568,7 +568,7 @@ pub fn SpiBus(comptime index: usize) type {
// read
var data_read = SPI1.DR.raw;
_ = SPI1.SR.read(); // clear overrun flag
const dr_lsb = @bitCast([dr_byte_size]u8, data_read)[0];
const dr_lsb = @as([dr_byte_size]u8, @bitCast(data_read))[0];
debug_print("Received: {X:2} (DR = {X:8}).\r\n", .{ dr_lsb, data_read });
if (optional_read_pointer) |read_pointer| read_pointer.* = dr_lsb;
}

@ -111,16 +111,16 @@ pub const gpio = struct {
set_reg_field(RCC.AHB1ENR, "GPIO" ++ pin.gpio_port_name ++ "EN", 1);
set_reg_field(@field(pin.gpio_port, "MODER"), "MODER" ++ pin.suffix, 0b10);
if (pin.pin_number < 8) {
set_reg_field(@field(pin.gpio_port, "AFRL"), "AFRL" ++ pin.suffix, @enumToInt(af));
set_reg_field(@field(pin.gpio_port, "AFRL"), "AFRL" ++ pin.suffix, @intFromEnum(af));
} else {
set_reg_field(@field(pin.gpio_port, "AFRH"), "AFRH" ++ pin.suffix, @enumToInt(af));
set_reg_field(@field(pin.gpio_port, "AFRH"), "AFRH" ++ pin.suffix, @intFromEnum(af));
}
}
pub fn read(comptime pin: type) micro.gpio.State {
const idr_reg = pin.gpio_port.IDR;
const reg_value = @field(idr_reg.read(), "IDR" ++ pin.suffix); // TODO extract to getRegField()?
return @intToEnum(micro.gpio.State, reg_value);
return @as(micro.gpio.State, @enumFromInt(reg_value));
}
pub fn write(comptime pin: type, state: micro.gpio.State) void {
@ -278,11 +278,11 @@ pub fn Uart(comptime index: usize, comptime pins: micro.uart.Pins) type {
// set parity
if (config.parity) |parity| {
@field(peripherals, usart_name).CR1.modify(.{ .PCE = 1, .PS = @enumToInt(parity) });
@field(peripherals, usart_name).CR1.modify(.{ .PCE = 1, .PS = @intFromEnum(parity) });
} // otherwise, no need to set no parity since we reset Control Registers above, and it's the default
// set number of stop bits
@field(peripherals, usart_name).CR2.modify(.{ .STOP = @enumToInt(config.stop_bits) });
@field(peripherals, usart_name).CR2.modify(.{ .STOP = @intFromEnum(config.stop_bits) });
// set the baud rate
// Despite the reference manual talking about fractional calculation and other buzzwords,
@ -297,7 +297,7 @@ pub fn Uart(comptime index: usize, comptime pins: micro.uart.Pins) type {
2...5 => clocks.apb1,
else => unreachable,
};
const usartdiv = @intCast(u16, @divTrunc(bus_frequency, config.baud_rate));
const usartdiv = @as(u16, @intCast(@divTrunc(bus_frequency, config.baud_rate)));
@field(peripherals, usart_name).BRR.raw = usartdiv;
// enable USART, and its transmitter and receiver
@ -355,7 +355,7 @@ pub fn Uart(comptime index: usize, comptime pins: micro.uart.Pins) type {
pub fn rx(self: Self) u8 {
while (!self.can_read()) {} // Wait till the data is received
const data_with_parity_bit: u9 = @field(peripherals, usart_name).DR.read();
return @intCast(u8, data_with_parity_bit & self.parity_read_mask);
return @as(u8, @intCast(data_with_parity_bit & self.parity_read_mask));
}
};
}
@ -463,7 +463,7 @@ pub fn I2CController(comptime index: usize, comptime pins: micro.i2c.Pins) type
// 4. Configure I2C timing
const bus_frequency_hz = micro.clock.get().apb1;
const bus_frequency_mhz: u6 = @intCast(u6, @divExact(bus_frequency_hz, 1_000_000));
const bus_frequency_mhz: u6 = @as(u6, @intCast(@divExact(bus_frequency_hz, 1_000_000)));
if (bus_frequency_mhz < 2 or bus_frequency_mhz > 50) {
return error.InvalidBusFrequency;
@ -475,7 +475,7 @@ pub fn I2CController(comptime index: usize, comptime pins: micro.i2c.Pins) type
switch (config.target_speed) {
10_000...100_000 => {
// CCR is bus_freq / (target_speed * 2). We use floor to avoid exceeding the target speed.
const ccr = @intCast(u12, @divFloor(bus_frequency_hz, config.target_speed * 2));
const ccr = @as(u12, @intCast(@divFloor(bus_frequency_hz, config.target_speed * 2)));
i2c_base.CCR.modify(.{ .CCR = ccr });
// Trise is bus frequency in Mhz + 1
i2c_base.TRISE.modify(bus_frequency_mhz + 1);
@ -529,7 +529,7 @@ pub fn I2CController(comptime index: usize, comptime pins: micro.i2c.Pins) type
{}
// Write the address to bits 7..1, bit 0 stays at 0 to indicate write operation
i2c_base.DR.modify(@intCast(u8, self.address) << 1);
i2c_base.DR.modify(@as(u8, @intCast(self.address)) << 1);
// Wait for address confirmation
while (i2c_base.SR1.read().ADDR == 0) {}
@ -584,7 +584,7 @@ pub fn I2CController(comptime index: usize, comptime pins: micro.i2c.Pins) type
{}
// Write the address to bits 7..1, bit 0 set to 1 to indicate read operation
i2c_base.DR.modify((@intCast(u8, self.address) << 1) | 1);
i2c_base.DR.modify((@as(u8, @intCast(self.address)) << 1) | 1);
// Wait for address confirmation
while (i2c_base.SR1.read().ADDR == 0) {}

@ -80,7 +80,7 @@ pub const gpio = struct {
pub fn read(comptime pin: type) micro.gpio.State {
const idr_reg = pin.gpio_port.IDR;
const reg_value = @field(idr_reg.read(), "IDR" ++ pin.suffix); // TODO extract to getRegField()?
return @intToEnum(micro.gpio.State, reg_value);
return @as(micro.gpio.State, @enumFromInt(reg_value));
}
pub fn write(comptime pin: type, state: micro.gpio.State) void {

Loading…
Cancel
Save