|
| 1 | +const microzig = @import("microzig"); |
| 2 | +const mmio = microzig.mmio; |
| 3 | + |
| 4 | +pub const types = @import("types.zig"); |
| 5 | + |
| 6 | +pub const Interrupt = struct { |
| 7 | + name: [:0]const u8, |
| 8 | + index: i16, |
| 9 | + description: ?[:0]const u8, |
| 10 | +}; |
| 11 | + |
| 12 | +pub const interrupts: []const Interrupt = &.{ |
| 13 | + .{ .name = "NMI", .index = -14, .description = null }, |
| 14 | + .{ .name = "HardFault", .index = -13, .description = null }, |
| 15 | + .{ .name = "SVCall", .index = -5, .description = null }, |
| 16 | + .{ .name = "PendSV", .index = -2, .description = null }, |
| 17 | + .{ .name = "SysTick", .index = -1, .description = null }, |
| 18 | + .{ .name = "WWDG", .index = 0, .description = null }, |
| 19 | + .{ .name = "RTC", .index = 2, .description = null }, |
| 20 | + .{ .name = "FLASH", .index = 3, .description = null }, |
| 21 | + .{ .name = "RCC", .index = 4, .description = null }, |
| 22 | + .{ .name = "EXTI0_1", .index = 5, .description = null }, |
| 23 | + .{ .name = "EXTI2_3", .index = 6, .description = null }, |
| 24 | + .{ .name = "EXTI4_15", .index = 7, .description = null }, |
| 25 | + .{ .name = "DMA1_Channel1", .index = 9, .description = null }, |
| 26 | + .{ .name = "DMA1_Channel2_3", .index = 10, .description = null }, |
| 27 | + .{ .name = "DMAMUX1", .index = 11, .description = null }, |
| 28 | + .{ .name = "ADC1", .index = 12, .description = null }, |
| 29 | + .{ .name = "TIM1_BRK_UP_TRG_COM", .index = 13, .description = null }, |
| 30 | + .{ .name = "TIM1_CC", .index = 14, .description = null }, |
| 31 | + .{ .name = "TIM3", .index = 16, .description = null }, |
| 32 | + .{ .name = "TIM14", .index = 19, .description = null }, |
| 33 | + .{ .name = "TIM16", .index = 21, .description = null }, |
| 34 | + .{ .name = "TIM17", .index = 22, .description = null }, |
| 35 | + .{ .name = "I2C1", .index = 23, .description = null }, |
| 36 | + .{ .name = "SPI1", .index = 25, .description = null }, |
| 37 | + .{ .name = "USART1", .index = 27, .description = null }, |
| 38 | + .{ .name = "USART2", .index = 28, .description = null }, |
| 39 | +}; |
| 40 | + |
| 41 | +pub const VectorTable = extern struct { |
| 42 | + const Handler = microzig.interrupt.Handler; |
| 43 | + const unhandled = microzig.interrupt.unhandled; |
| 44 | + |
| 45 | + initial_stack_pointer: u32, |
| 46 | + Reset: Handler, |
| 47 | + NMI: Handler = unhandled, |
| 48 | + HardFault: Handler = unhandled, |
| 49 | + reserved2: [7]u32 = undefined, |
| 50 | + SVCall: Handler = unhandled, |
| 51 | + reserved10: [2]u32 = undefined, |
| 52 | + PendSV: Handler = unhandled, |
| 53 | + SysTick: Handler = unhandled, |
| 54 | + WWDG: Handler = unhandled, |
| 55 | + reserved15: [1]u32 = undefined, |
| 56 | + RTC: Handler = unhandled, |
| 57 | + FLASH: Handler = unhandled, |
| 58 | + RCC: Handler = unhandled, |
| 59 | + EXTI0_1: Handler = unhandled, |
| 60 | + EXTI2_3: Handler = unhandled, |
| 61 | + EXTI4_15: Handler = unhandled, |
| 62 | + reserved22: [1]u32 = undefined, |
| 63 | + DMA1_Channel1: Handler = unhandled, |
| 64 | + DMA1_Channel2_3: Handler = unhandled, |
| 65 | + DMAMUX1: Handler = unhandled, |
| 66 | + ADC1: Handler = unhandled, |
| 67 | + TIM1_BRK_UP_TRG_COM: Handler = unhandled, |
| 68 | + TIM1_CC: Handler = unhandled, |
| 69 | + reserved29: [1]u32 = undefined, |
| 70 | + TIM3: Handler = unhandled, |
| 71 | + reserved31: [2]u32 = undefined, |
| 72 | + TIM14: Handler = unhandled, |
| 73 | + reserved34: [1]u32 = undefined, |
| 74 | + TIM16: Handler = unhandled, |
| 75 | + TIM17: Handler = unhandled, |
| 76 | + I2C1: Handler = unhandled, |
| 77 | + reserved38: [1]u32 = undefined, |
| 78 | + SPI1: Handler = unhandled, |
| 79 | + reserved40: [1]u32 = undefined, |
| 80 | + USART1: Handler = unhandled, |
| 81 | + USART2: Handler = unhandled, |
| 82 | +}; |
| 83 | + |
| 84 | +pub const peripherals = struct { |
| 85 | + /// Device Factory programmed 96-bit unique device identifier |
| 86 | + pub const UID: *volatile types.peripherals.uid_v1.UID = @ptrFromInt(0x1fff7550); |
| 87 | + /// General purpose 16-bit timers |
| 88 | + pub const TIM3: *volatile types.peripherals.timer_v1.TIM_GP16 = @ptrFromInt(0x40000400); |
| 89 | + /// 1-channel timers |
| 90 | + pub const TIM14: *volatile types.peripherals.timer_v1.TIM_1CH = @ptrFromInt(0x40002000); |
| 91 | + /// Window watchdog |
| 92 | + pub const WWDG: *volatile types.peripherals.wwdg_v2.WWDG = @ptrFromInt(0x40002c00); |
| 93 | + /// Independent watchdog |
| 94 | + pub const IWDG: *volatile types.peripherals.iwdg_v2.IWDG = @ptrFromInt(0x40003000); |
| 95 | + /// Universal synchronous asynchronous receiver transmitter |
| 96 | + pub const USART2: *volatile types.peripherals.usart_v4.USART = @ptrFromInt(0x40004400); |
| 97 | + /// Inter-integrated circuit |
| 98 | + pub const I2C1: *volatile types.peripherals.i2c_v2.I2C = @ptrFromInt(0x40005400); |
| 99 | + /// PWR address block description |
| 100 | + pub const PWR: *volatile types.peripherals.pwr_c0.PWR = @ptrFromInt(0x40007000); |
| 101 | + /// register block |
| 102 | + pub const SYSCFG: *volatile types.peripherals.syscfg_c0.SYSCFG = @ptrFromInt(0x40010000); |
| 103 | + /// Advanced Control timers |
| 104 | + pub const TIM1: *volatile types.peripherals.timer_v1.TIM_ADV = @ptrFromInt(0x40012c00); |
| 105 | + /// Serial peripheral interface |
| 106 | + pub const SPI1: *volatile types.peripherals.spi_v2.SPI = @ptrFromInt(0x40013000); |
| 107 | + /// Universal synchronous asynchronous receiver transmitter |
| 108 | + pub const USART1: *volatile types.peripherals.usart_v4.USART = @ptrFromInt(0x40013800); |
| 109 | + /// 1-channel with one complementary output timers |
| 110 | + pub const TIM16: *volatile types.peripherals.timer_v1.TIM_1CH_CMP = @ptrFromInt(0x40014400); |
| 111 | + /// 1-channel with one complementary output timers |
| 112 | + pub const TIM17: *volatile types.peripherals.timer_v1.TIM_1CH_CMP = @ptrFromInt(0x40014800); |
| 113 | + /// Debug support |
| 114 | + pub const DBGMCU: *volatile types.peripherals.dbgmcu_c0.DBGMCU = @ptrFromInt(0x40015800); |
| 115 | + /// DMA controller |
| 116 | + pub const DMA1: *volatile types.peripherals.bdma_v1.DMA = @ptrFromInt(0x40020000); |
| 117 | + /// DMAMUX |
| 118 | + pub const DMAMUX1: *volatile types.peripherals.dmamux_v1.DMAMUX = @ptrFromInt(0x40020800); |
| 119 | + /// RCC address block description |
| 120 | + pub const RCC: *volatile types.peripherals.rcc_c0.RCC = @ptrFromInt(0x40021000); |
| 121 | + /// External interrupt/event controller |
| 122 | + pub const EXTI: *volatile types.peripherals.exti_c0.EXTI = @ptrFromInt(0x40021800); |
| 123 | + /// Flash |
| 124 | + pub const FLASH: *volatile types.peripherals.flash_c0.FLASH = @ptrFromInt(0x40022000); |
| 125 | + /// Cyclic Redundancy Check calculation unit |
| 126 | + pub const CRC: *volatile types.peripherals.crc_v3.CRC = @ptrFromInt(0x40023000); |
| 127 | + /// General-purpose I/Os |
| 128 | + pub const GPIOA: *volatile types.peripherals.gpio_v2.GPIO = @ptrFromInt(0x50000000); |
| 129 | + /// General-purpose I/Os |
| 130 | + pub const GPIOB: *volatile types.peripherals.gpio_v2.GPIO = @ptrFromInt(0x50000400); |
| 131 | + /// General-purpose I/Os |
| 132 | + pub const GPIOC: *volatile types.peripherals.gpio_v2.GPIO = @ptrFromInt(0x50000800); |
| 133 | + /// General-purpose I/Os |
| 134 | + pub const GPIOF: *volatile types.peripherals.gpio_v2.GPIO = @ptrFromInt(0x50001400); |
| 135 | +}; |
0 commit comments