├── .gitignore ├── AUTHORS ├── LICENSE ├── dci ├── evedci │ ├── exti.go │ └── spi.go ├── owdci │ └── usart.go └── tftdci │ └── spi.go ├── devboard ├── az3166 │ ├── board │ │ ├── buttons │ │ │ └── button.go │ │ ├── leds │ │ │ └── led.go │ │ └── system │ │ │ └── init.go │ ├── doc │ │ ├── board.jpg │ │ └── connections.txt │ └── examples │ │ ├── blinky │ │ └── main.go │ │ ├── build.cfg │ │ ├── debug-oocd.sh │ │ ├── debug-stutil.sh │ │ ├── load-oocd.sh │ │ ├── load-stutil.sh │ │ └── swo-oocd.sh ├── devebox-h743 │ ├── board │ │ ├── buttons │ │ │ └── button.go │ │ ├── leds │ │ │ └── led.go │ │ └── system │ │ │ └── init.go │ ├── doc │ │ ├── board.jpg │ │ ├── schematics-20190801.pdf │ │ └── schematics-20191123.pdf │ └── examples │ │ ├── blinky │ │ └── main.go │ │ ├── build.cfg │ │ ├── debug-oocd.sh │ │ ├── debug-stutil.sh │ │ ├── dma │ │ └── main.go │ │ ├── fputest │ │ └── main.go │ │ ├── load-oocd.sh │ │ ├── load-stutil.sh │ │ ├── load-usb.sh │ │ ├── onewire │ │ └── main.go │ │ ├── swo-oocd.sh │ │ ├── usart │ │ └── main.go │ │ └── ws2812 │ │ └── main.go ├── emw3162 │ ├── board │ │ ├── leds │ │ │ └── led.go │ │ └── system │ │ │ └── init.go │ ├── doc │ │ ├── board.jpg │ │ └── datasheet.pdf │ └── examples │ │ ├── blinky │ │ └── main.go │ │ ├── build.cfg │ │ ├── debug-oocd.sh │ │ ├── debug-stutil.sh │ │ ├── dma │ │ └── main.go │ │ ├── helloworld │ │ └── main.go │ │ ├── load-oocd.sh │ │ ├── load-stutil.sh │ │ ├── spi │ │ └── main.go │ │ └── swo-oocd.sh ├── f4-discovery │ ├── board │ │ ├── buttons │ │ │ └── button.go │ │ ├── leds │ │ │ └── led.go │ │ └── system │ │ │ └── init.go │ ├── doc │ │ ├── accel_an.pdf │ │ ├── accel_ds.pdf │ │ ├── board.jpg │ │ └── user_manual.pdf │ └── examples │ │ ├── accel │ │ └── main.go │ │ ├── blinky │ │ └── main.go │ │ ├── build.cfg │ │ ├── debug-oocd.sh │ │ ├── debug-stutil.sh │ │ ├── display │ │ └── main.go │ │ ├── dma │ │ └── main.go │ │ ├── espat │ │ └── main.go │ │ ├── espnet │ │ └── main.go │ │ ├── evetest │ │ └── main.go │ │ ├── gctest │ │ └── main.go │ │ ├── goroutines │ │ └── main.go │ │ ├── guncon │ │ └── main.go │ │ ├── helloworld │ │ └── main.go │ │ ├── irqbtn │ │ └── main.go │ │ ├── load-oocd.sh │ │ ├── load-stutil.sh │ │ ├── onewire │ │ └── main.go │ │ ├── rawtasktest │ │ └── main.go │ │ ├── spi │ │ └── main.go │ │ ├── swo-oocd.sh │ │ └── usart │ │ └── main.go ├── minipro-f405 │ ├── board │ │ ├── buttons │ │ │ └── button.go │ │ ├── leds │ │ │ └── led.go │ │ └── system │ │ │ └── init.go │ ├── doc │ │ ├── board.jpg │ │ ├── picocom-reset.txt │ │ └── pinout.txt │ └── examples │ │ ├── blinky │ │ └── main.go │ │ ├── build.cfg │ │ ├── debug-oocd.sh │ │ ├── debug-stutil.sh │ │ ├── helloworld │ │ └── main.go │ │ ├── load-oocd.sh │ │ ├── load-stutil.sh │ │ ├── load-uart.sh │ │ ├── relay │ │ ├── date.go │ │ ├── lanterns.go │ │ ├── main.go │ │ ├── relay.go │ │ └── utils.go │ │ └── swo-oocd.sh ├── nucleo-l476rg │ ├── board │ │ ├── buttons │ │ │ └── button.go │ │ ├── leds │ │ │ └── led.go │ │ └── system │ │ │ └── setup.go │ ├── doc │ │ ├── board.jpg │ │ └── boot_config.txt │ └── examples │ │ ├── blinky │ │ └── main.go │ │ ├── blinky2 │ │ └── main.go │ │ ├── build.cfg │ │ ├── debug-oocd.sh │ │ ├── debug-stutil.sh │ │ ├── display │ │ └── main.go │ │ ├── dma │ │ └── main.go │ │ ├── espat │ │ └── main.go │ │ ├── espn │ │ └── main.go │ │ ├── evetest │ │ └── main.go │ │ ├── generator │ │ └── main.go │ │ ├── goroutines │ │ └── main.go │ │ ├── helloworld │ │ └── main.go │ │ ├── irqbtn │ │ └── main.go │ │ ├── load-oocd.sh │ │ ├── load-stm32flash.sh │ │ ├── load-stutil.sh │ │ ├── nightstrike │ │ └── main.go │ │ ├── pwm │ │ └── main.go │ │ ├── reboot │ │ └── main.go │ │ ├── rtc │ │ └── main.go │ │ ├── shell │ │ ├── cat.go │ │ ├── date.go │ │ ├── echo.go │ │ ├── ls.go │ │ ├── main.go │ │ ├── mkdir.go │ │ ├── mount.go │ │ ├── rename.go │ │ ├── rm.go │ │ └── utils.go │ │ ├── spi │ │ └── main.go │ │ ├── sprites │ │ └── main.go │ │ ├── swo-oocd.sh │ │ ├── upsexti │ │ └── main.go │ │ ├── upstim │ │ └── main.go │ │ └── usart │ │ └── main.go ├── nucleo-l496zg │ ├── board │ │ ├── buttons │ │ │ └── button.go │ │ ├── leds │ │ │ └── led.go │ │ └── system │ │ │ └── init.go │ ├── doc │ │ └── board.jpg │ └── examples │ │ ├── blinky │ │ └── main.go │ │ ├── build.cfg │ │ ├── debug-oocd.sh │ │ ├── debug-stutil.sh │ │ ├── dma │ │ └── main.go │ │ ├── gctest │ │ └── main.go │ │ ├── irqbtn │ │ └── main.go │ │ ├── load-oocd.sh │ │ ├── load-stutil.sh │ │ ├── spi │ │ └── main.go │ │ └── swo-oocd.sh └── readme.md ├── go.mod ├── go.sum ├── hal ├── dma │ ├── align.go │ ├── align_cache.go │ ├── align_nocache.go │ ├── allocchan.go │ ├── controller-f0f1f3l1l4.go │ ├── controller-f2f4f7h7.go │ ├── controller.go │ ├── dmairq │ │ ├── dmairq.go │ │ └── h7.go │ ├── doc.go │ ├── instances1.go │ ├── instances2.go │ ├── mux-h7.go │ ├── rcc-f0.go │ ├── rcc-f1f3l1.go │ ├── rcc-f2f4f7h7.go │ └── rcc-l4.go ├── exti │ ├── exti.go │ ├── exticr-f0.go │ ├── exticr-f1.go │ ├── exticr-f2f3f4f7l1l4.go │ ├── lines-f0.go │ ├── lines-f1.go │ ├── lines-f4f7.go │ ├── lines-h7.go │ ├── lines-l1.go │ ├── lines-l4.go │ ├── regs-f0f1f2f4f7l1.go │ └── regs-f3l4.go ├── gpio │ ├── conf.go │ ├── ctrl.go │ ├── doc.go │ ├── f0.go │ ├── f0f2f3f4f7h7l1l4.go │ ├── f1.go │ ├── f2f4.go │ ├── f2f4f7.go │ ├── f3.go │ ├── f7.go │ ├── h7.go │ ├── instances11.go │ ├── instances8.go │ ├── instances9.go │ ├── l1.go │ ├── l4.go │ ├── pin.go │ ├── port.go │ └── utils.go ├── internal │ ├── apb │ │ ├── common.go │ │ ├── f2f4f7.go │ │ ├── h7.go │ │ └── l4.go │ ├── f4.go │ ├── h7.go │ ├── l4.go │ ├── regbit.go │ └── utils.go ├── irq │ ├── stm32f215.go │ ├── stm32f407.go │ ├── stm32f412.go │ ├── stm32g471xx.go │ ├── stm32h7x3.go │ └── stm32l4x6.go ├── mem │ └── nocache │ │ ├── alloc.go │ │ ├── alloc_nocache.go │ │ └── alloc_normal.go ├── spi │ ├── bits.go │ ├── doc.go │ ├── driver.go │ ├── f0f3l4.go │ ├── f1f2f4f7l1.go │ ├── f2f4.go │ ├── instances3.go │ ├── instances4.go │ ├── instances6.go │ ├── l4.go │ ├── periph.go │ ├── spi1 │ │ ├── driver.go │ │ ├── f2f4.go │ │ └── l4.go │ ├── spi2 │ │ ├── driver.go │ │ ├── f2f4.go │ │ └── l4.go │ ├── spi3 │ │ ├── driver.go │ │ └── f2f4.go │ └── usepin.go ├── spih │ ├── bits.go │ └── periph.go ├── system │ ├── clk_stm32f215.go │ ├── clk_stm32f407.go │ ├── clk_stm32f412.go │ ├── clk_stm32h7x3.go │ ├── clk_stm32l4x6.go │ ├── console │ │ └── uartcon │ │ │ └── setup.go │ ├── rt0.s │ ├── setup_f2f4f7.go │ ├── setup_h7.go │ ├── setup_l4.go │ └── timer │ │ ├── rtcst │ │ ├── asm.s │ │ ├── monoday.go │ │ ├── monoday_test.go │ │ └── rtcst.go │ │ └── systick │ │ ├── systick.go │ │ ├── systim_h7.go │ │ └── systim_noh7.go └── usart │ ├── doc.go │ ├── driver.go │ ├── driverrx.go │ ├── drivertx.go │ ├── f2f4.go │ ├── h7l4.go │ ├── instances6.go │ ├── instances8.go │ ├── instances9.go │ ├── periph.go │ ├── uart4 │ ├── driver.go │ ├── f2f4.go │ ├── h7.go │ └── l4.go │ ├── usart1 │ ├── driver.go │ ├── f2f4.go │ ├── h7.go │ └── l4.go │ ├── usart2 │ ├── driver.go │ ├── f2f4.go │ ├── h7.go │ └── l4.go │ ├── usart6 │ ├── driver.go │ ├── f2f4.go │ └── h7.go │ └── usepin.go ├── p ├── adc │ ├── adc │ │ ├── stm32f215.go │ │ ├── stm32f407.go │ │ ├── stm32f412.go │ │ ├── stm32h7x3.go │ │ └── stm32l4x6.go │ ├── adc1 │ │ └── stm32g471xx.go │ ├── adc3 │ │ └── stm32g471xx.go │ ├── adc_common │ │ ├── stm32f215.go │ │ ├── stm32f412.go │ │ ├── stm32g471xx.go │ │ ├── stm32h7x3.go │ │ └── stm32l4x6.go │ └── c_adc │ │ └── stm32f407.go ├── aes │ ├── stm32g471xx.go │ └── stm32l4x6.go ├── axi │ └── stm32h7x3.go ├── bdma │ └── stm32h7x3.go ├── bus │ ├── stm32f215.go │ ├── stm32f407.go │ ├── stm32f412.go │ ├── stm32g471xx.go │ ├── stm32h7x3.go │ └── stm32l4x6.go ├── can │ ├── stm32f215.go │ ├── stm32f407.go │ ├── stm32f412.go │ └── stm32l4x6.go ├── cec │ └── stm32h7x3.go ├── comp │ ├── stm32g471xx.go │ ├── stm32h7x3.go │ └── stm32l4x6.go ├── cordic │ └── stm32g471xx.go ├── crc │ ├── stm32f215.go │ ├── stm32f407.go │ ├── stm32f412.go │ ├── stm32g471xx.go │ ├── stm32h7x3.go │ └── stm32l4x6.go ├── crs │ ├── stm32g471xx.go │ ├── stm32h7x3.go │ └── stm32l4x6.go ├── cryp │ ├── stm32f215.go │ ├── stm32f407.go │ └── stm32h7x3.go ├── dac │ ├── stm32f215.go │ ├── stm32f407.go │ ├── stm32g471xx.go │ ├── stm32h7x3.go │ └── stm32l4x6.go ├── dbg │ ├── stm32f215.go │ ├── stm32f407.go │ └── stm32f412.go ├── dbgmcu │ ├── stm32g471xx.go │ ├── stm32h7x3.go │ └── stm32l4x6.go ├── dcmi │ ├── stm32f215.go │ ├── stm32f407.go │ ├── stm32h7x3.go │ └── stm32l4x6.go ├── dfsdm │ ├── stm32f412.go │ ├── stm32h7x3.go │ └── stm32l4x6.go ├── dlyb │ └── stm32h7x3.go ├── dma │ ├── stm32f215.go │ ├── stm32f407.go │ ├── stm32f412.go │ ├── stm32g471xx.go │ ├── stm32h7x3.go │ ├── stm32l4x6.go │ ├── xstm32f215.go │ ├── xstm32f407.go │ ├── xstm32f412.go │ ├── xstm32g471xx.go │ ├── xstm32h7x3.go │ └── xstm32l4x6.go ├── dmad │ ├── stm32h7x3.go │ └── stm32l4x6.go ├── dmamux │ ├── dmamux1 │ │ ├── stm32h7x3.go │ │ └── xstm32h7x3.go │ ├── dmamux2 │ │ ├── stm32h7x3.go │ │ └── xstm32h7x3.go │ ├── stm32g471xx.go │ └── xstm32g471xx.go ├── ethernet │ ├── ethernet_dma │ │ ├── stm32f215.go │ │ ├── stm32f407.go │ │ └── stm32h7x3.go │ ├── ethernet_mac │ │ ├── stm32f215.go │ │ ├── stm32f407.go │ │ └── stm32h7x3.go │ ├── ethernet_mmc │ │ ├── stm32f215.go │ │ └── stm32f407.go │ ├── ethernet_mtl │ │ └── stm32h7x3.go │ └── ethernet_ptp │ │ ├── stm32f215.go │ │ └── stm32f407.go ├── exti │ ├── stm32f215.go │ ├── stm32f407.go │ ├── stm32f412.go │ ├── stm32g471xx.go │ ├── stm32h7x3.go │ ├── stm32l4x6.go │ ├── xstm32f215.go │ ├── xstm32f407.go │ ├── xstm32f412.go │ ├── xstm32g471xx.go │ ├── xstm32h7x3.go │ └── xstm32l4x6.go ├── fdcan │ ├── can_ccu │ │ └── stm32h7x3.go │ ├── fdcan │ │ └── stm32h7x3.go │ └── stm32g471xx.go ├── firewall │ └── stm32l4x6.go ├── flash │ ├── stm32f215.go │ ├── stm32f407.go │ ├── stm32f412.go │ ├── stm32g471xx.go │ ├── stm32h7x3.go │ ├── stm32l4x6.go │ ├── xstm32f215.go │ ├── xstm32f407.go │ ├── xstm32f412.go │ ├── xstm32g471xx.go │ ├── xstm32h7x3.go │ └── xstm32l4x6.go ├── fmac │ └── stm32g471xx.go ├── fmc │ ├── stm32h7x3.go │ └── stm32l4x6.go ├── fpu │ ├── fpu │ │ ├── stm32f407.go │ │ ├── stm32f412.go │ │ ├── stm32g471xx.go │ │ └── stm32l4x6.go │ └── fpu_cpacr │ │ ├── stm32f407.go │ │ ├── stm32f412.go │ │ ├── stm32g471xx.go │ │ └── stm32l4x6.go ├── fsmc │ ├── stm32f215.go │ ├── stm32f407.go │ └── stm32f412.go ├── gpio │ ├── stm32f215.go │ ├── stm32f407.go │ ├── stm32f412.go │ ├── stm32g471xx.go │ ├── stm32h7x3.go │ ├── stm32l4x6.go │ ├── xstm32f215.go │ ├── xstm32f407.go │ ├── xstm32f412.go │ ├── xstm32g471xx.go │ ├── xstm32h7x3.go │ └── xstm32l4x6.go ├── hash │ ├── stm32f215.go │ ├── stm32f407.go │ ├── stm32h7x3.go │ └── stm32l4x6.go ├── hrtim │ ├── hrtim_common │ │ └── stm32h7x3.go │ ├── hrtim_master │ │ └── stm32h7x3.go │ ├── hrtim_tima │ │ └── stm32h7x3.go │ ├── hrtim_timb │ │ └── stm32h7x3.go │ ├── hrtim_timc │ │ └── stm32h7x3.go │ ├── hrtim_timd │ │ └── stm32h7x3.go │ └── hrtim_time │ │ └── stm32h7x3.go ├── hsem │ └── stm32h7x3.go ├── i2c │ ├── i2c3 │ │ └── stm32f412.go │ ├── i2c4 │ │ └── stm32f412.go │ ├── stm32f215.go │ ├── stm32f407.go │ ├── stm32g471xx.go │ ├── stm32h7x3.go │ └── stm32l4x6.go ├── irq │ ├── stm32f215.go │ ├── stm32f407.go │ ├── stm32f412.go │ ├── stm32g471xx.go │ ├── stm32h7x3.go │ └── stm32l4x6.go ├── iwdg │ ├── stm32f215.go │ ├── stm32f407.go │ ├── stm32f412.go │ ├── stm32g471xx.go │ ├── stm32h7x3.go │ └── stm32l4x6.go ├── jpeg │ └── stm32h7x3.go ├── lcd │ └── stm32l4x6.go ├── lptim │ ├── lptim1 │ │ └── stm32h7x3.go │ ├── lptim3 │ │ └── stm32h7x3.go │ ├── stm32g471xx.go │ └── stm32l4x6.go ├── lpuart │ └── stm32h7x3.go ├── ltdc │ ├── stm32f407.go │ └── stm32h7x3.go ├── mdios │ └── stm32h7x3.go ├── mdma │ └── stm32h7x3.go ├── mmap │ ├── stm32f215.go │ ├── stm32f407.go │ ├── stm32f412.go │ ├── stm32g471xx.go │ ├── stm32h7x3.go │ └── stm32l4x6.go ├── mpu │ ├── stm32f215.go │ ├── stm32f407.go │ ├── stm32f412.go │ ├── stm32g471xx.go │ └── stm32l4x6.go ├── nvic │ ├── nvic │ │ ├── stm32f215.go │ │ ├── stm32f407.go │ │ ├── stm32f412.go │ │ └── stm32l4x6.go │ ├── nvic_stir │ │ ├── stm32f215.go │ │ ├── stm32f407.go │ │ ├── stm32f412.go │ │ └── stm32l4x6.go │ └── stm32g471xx.go ├── opamp │ ├── stm32g471xx.go │ ├── stm32h7x3.go │ └── stm32l4x6.go ├── pwr │ ├── stm32f215.go │ ├── stm32f407.go │ ├── stm32f412.go │ ├── stm32g471xx.go │ ├── stm32h7x3.go │ ├── stm32l4x6.go │ ├── xstm32f215.go │ ├── xstm32f407.go │ ├── xstm32f412.go │ ├── xstm32g471xx.go │ ├── xstm32h7x3.go │ └── xstm32l4x6.go ├── quadspi │ ├── stm32f412.go │ ├── stm32h7x3.go │ └── stm32l4x6.go ├── ramecc │ ├── ramecc1 │ │ └── stm32h7x3.go │ ├── ramecc2 │ │ └── stm32h7x3.go │ └── ramecc3 │ │ └── stm32h7x3.go ├── rcc │ ├── stm32f215.go │ ├── stm32f407.go │ ├── stm32f412.go │ ├── stm32g471xx.go │ ├── stm32h7x3.go │ ├── stm32l4x6.go │ ├── xstm32f215.go │ ├── xstm32f407.go │ ├── xstm32f412.go │ ├── xstm32g471xx.go │ ├── xstm32h7x3.go │ └── xstm32l4x6.go ├── rng │ ├── stm32f215.go │ ├── stm32f407.go │ ├── stm32f412.go │ ├── stm32g471xx.go │ ├── stm32h7x3.go │ └── stm32l4x6.go ├── rtc │ ├── stm32f215.go │ ├── stm32f407.go │ ├── stm32f412.go │ ├── stm32g471xx.go │ ├── stm32h7x3.go │ ├── stm32l4x6.go │ ├── xstm32f215.go │ ├── xstm32f407.go │ ├── xstm32f412.go │ ├── xstm32g471xx.go │ ├── xstm32h7x3.go │ └── xstm32l4x6.go ├── sai │ ├── stm32f407.go │ ├── stm32g471xx.go │ ├── stm32h7x3.go │ └── stm32l4x6.go ├── scb │ ├── scb │ │ ├── stm32f215.go │ │ ├── stm32f407.go │ │ ├── stm32f412.go │ │ ├── stm32g471xx.go │ │ └── stm32l4x6.go │ └── scb_actrl │ │ ├── stm32f215.go │ │ ├── stm32f407.go │ │ ├── stm32f412.go │ │ ├── stm32g471xx.go │ │ └── stm32l4x6.go ├── sdio │ ├── stm32f215.go │ ├── stm32f407.go │ ├── stm32f412.go │ └── stm32l4x6.go ├── sdmmc │ └── stm32h7x3.go ├── spdifrx │ └── stm32h7x3.go ├── spi │ ├── stm32f215.go │ ├── stm32f407.go │ ├── stm32f412.go │ ├── stm32g471xx.go │ ├── stm32h7x3.go │ ├── stm32l4x6.go │ ├── xstm32f215.go │ ├── xstm32f407.go │ ├── xstm32f412.go │ ├── xstm32g471xx.go │ ├── xstm32h7x3.go │ └── xstm32l4x6.go ├── stk │ ├── stm32f215.go │ ├── stm32f407.go │ ├── stm32f412.go │ ├── stm32g471xx.go │ └── stm32l4x6.go ├── swpmi │ ├── stm32h7x3.go │ └── stm32l4x6.go ├── syscfg │ ├── stm32f215.go │ ├── stm32f407.go │ ├── stm32f412.go │ ├── stm32g471xx.go │ ├── stm32h7x3.go │ ├── stm32l4x6.go │ ├── xstm32f215.go │ ├── xstm32f407.go │ ├── xstm32f412.go │ ├── xstm32g471xx.go │ ├── xstm32h7x3.go │ └── xstm32l4x6.go ├── tamp │ └── stm32g471xx.go ├── tim │ ├── stm32f215.go │ ├── stm32f407.go │ ├── stm32f412.go │ ├── stm32g471xx.go │ ├── stm32h7x3.go │ ├── stm32l4x6.go │ ├── xstm32f215.go │ ├── xstm32f407.go │ ├── xstm32f412.go │ ├── xstm32g471xx.go │ ├── xstm32h7x3.go │ └── xstm32l4x6.go ├── tims │ ├── tim15 │ │ └── stm32h7x3.go │ ├── tim16 │ │ └── stm32h7x3.go │ └── tim17 │ │ └── stm32h7x3.go ├── tsc │ └── stm32l4x6.go ├── ucpd │ └── stm32g471xx.go ├── usart │ ├── lpuart │ │ ├── stm32g471xx.go │ │ └── stm32l4x6.go │ ├── stm32f412.go │ ├── stm32h7x3.go │ ├── uart │ │ ├── stm32f407.go │ │ └── stm32g471xx.go │ ├── uart4 │ │ └── stm32f215.go │ ├── uart5 │ │ └── stm32f215.go │ └── usart │ │ ├── stm32f215.go │ │ ├── stm32f407.go │ │ ├── stm32g471xx.go │ │ └── stm32l4x6.go ├── usb │ └── stm32g471xx.go ├── usb_otg_fs │ ├── otg_fs_device │ │ ├── stm32f215.go │ │ ├── stm32f407.go │ │ ├── stm32f412.go │ │ └── stm32l4x6.go │ ├── otg_fs_global │ │ ├── stm32f215.go │ │ ├── stm32f407.go │ │ ├── stm32f412.go │ │ └── stm32l4x6.go │ ├── otg_fs_host │ │ ├── stm32f215.go │ │ ├── stm32f407.go │ │ ├── stm32f412.go │ │ └── stm32l4x6.go │ └── otg_fs_pwrclk │ │ ├── stm32f215.go │ │ ├── stm32f407.go │ │ ├── stm32f412.go │ │ └── stm32l4x6.go ├── usb_otg_hs │ ├── otg_hs_device │ │ ├── stm32f215.go │ │ ├── stm32f407.go │ │ └── stm32h7x3.go │ ├── otg_hs_global │ │ ├── stm32f215.go │ │ ├── stm32f407.go │ │ └── stm32h7x3.go │ ├── otg_hs_host │ │ ├── stm32f215.go │ │ ├── stm32f407.go │ │ └── stm32h7x3.go │ └── otg_hs_pwrclk │ │ ├── stm32f215.go │ │ ├── stm32f407.go │ │ └── stm32h7x3.go ├── vref │ └── stm32l4x6.go ├── vrefbuf │ ├── stm32g471xx.go │ └── stm32h7x3.go └── wwdg │ ├── stm32f215.go │ ├── stm32f407.go │ ├── stm32f412.go │ ├── stm32g471xx.go │ ├── stm32h7x3.go │ └── stm32l4x6.go ├── readme.md └── svd ├── STM32F215.svd ├── STM32F407.svd ├── STM32F412.svd ├── STM32G471xx.svd ├── STM32H7x3.svd ├── STM32L4x6.svd └── gen.sh /.gitignore: -------------------------------------------------------------------------------- 1 | *.elf 2 | *.bin 3 | zisrnames.go 4 | core 5 | oocd.log 6 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Michal Derkacz 2 | -------------------------------------------------------------------------------- /dci/evedci/exti.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package evedci 6 | 7 | import ( 8 | "github.com/embeddedgo/stm32/hal/exti" 9 | "github.com/embeddedgo/stm32/hal/gpio" 10 | ) 11 | 12 | // UseIntPin setups GPIO pin and EXTI peripheral to detect EVE interrupts. 13 | func UseIntPin(pin gpio.Pin) { 14 | pin.Setup(&gpio.Config{Mode: gpio.In}) 15 | line := exti.Lines(pin.Mask()) 16 | line.Connect(pin.Port()) 17 | line.EnableFallTrig() 18 | line.EnableIRQ() 19 | } 20 | -------------------------------------------------------------------------------- /devboard/az3166/board/buttons/button.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package buttons 6 | 7 | import ( 8 | "github.com/embeddedgo/stm32/hal/gpio" 9 | 10 | _ "github.com/embeddedgo/stm32/devboard/az3166/board/system" 11 | ) 12 | 13 | // Onboard buttons 14 | const ( 15 | A Button = 0x04 // PA4 16 | B Button = 0x0A // PA10 17 | 18 | User = A 19 | ) 20 | 21 | type Button uint8 22 | 23 | func (b Button) prt() int { return int(b) >> 4 } 24 | func (b Button) pin() uint { return uint(b) & 15 } 25 | 26 | func (b Button) Read() int { 27 | return int(gpio.P(b.prt()).Load()>>b.pin())&1 ^ 1 28 | } 29 | func (b Button) Pin() gpio.Pin { 30 | return gpio.P(b.prt()).Pin(int(b.pin())) 31 | } 32 | 33 | func init() { 34 | gpio.PA().EnableClock(true) 35 | A.Pin().Setup(&gpio.Config{Mode: gpio.In}) 36 | B.Pin().Setup(&gpio.Config{Mode: gpio.In}) 37 | } 38 | -------------------------------------------------------------------------------- /devboard/az3166/board/system/init.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package system 6 | 7 | import ( 8 | "github.com/embeddedgo/stm32/hal/system" 9 | "github.com/embeddedgo/stm32/hal/system/timer/rtcst" 10 | ) 11 | 12 | func init() { 13 | system.Setup96(26) 14 | rtcst.Setup(rtcst.LSE, 1, 32768) 15 | } 16 | -------------------------------------------------------------------------------- /devboard/az3166/doc/board.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/embeddedgo/stm32/c31c3df4c80b62aa50b3b0b1d9b35b32a8e696a0/devboard/az3166/doc/board.jpg -------------------------------------------------------------------------------- /devboard/az3166/doc/connections.txt: -------------------------------------------------------------------------------- 1 | AZ3166 edge connector 2 | 3 | --- Reset 4 | 0 PB0 5 | --- PA5 6 | --- PA4 (Buton A) 7 | --- PB4 (Red LED) 8 | --- PB3 (Green LED, SWO) 9 | 1 PB6 10 | --- PC13 (User LED) 11 | --- PB10 (IR LED) 12 | --- PC7 (Blue LED) 13 | --- PA10 (Button B) 14 | --- PB2 (WiFi lED) 15 | 2 PB7 16 | --- PB13 17 | --- PB14 18 | --- PB15 19 | --- PC6 20 | --- VDD 21 | 3V VDD 22 | --- VDD 23 | --- PB8 24 | --- PB9 25 | --- GND 26 | GND GND 27 | --- GND 28 | 29 | 30 | ST-LINK/V2-1 (STM32F103C8T6) to EMW3166 (STM32F412RG) 31 | 32 | PA2 (UART2 TX) -> PA12 (USART6_RX) 33 | PA3 (UART2 RX) -> PA11 (USART6_TX) 34 | PB0 -> RESET (also connected to the reset button) 35 | 36 | PB13 -> PA14 (SWCLK) 37 | PB14 -> PA13 (SWDIO) 38 | 39 | ST-LINK SWD test points, starting from reset button: 40 | 1: VDD 41 | 2: SWDIO (PA13) 42 | 3: SWCLK (PA14) 43 | 4: GND 44 | 45 | ST-LINK 46 | 47 | BOOT0 -> 10K resistor (number 5 from the programming LED) 48 | PA9 -> programming LED (active high) 49 | -------------------------------------------------------------------------------- /devboard/az3166/examples/blinky/main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // This example shows the basic usage of available LEDs. 6 | package main 7 | 8 | import ( 9 | "time" 10 | 11 | "github.com/embeddedgo/stm32/devboard/az3166/board/buttons" 12 | "github.com/embeddedgo/stm32/devboard/az3166/board/leds" 13 | ) 14 | 15 | func delay() { 16 | if buttons.User.Read() != 0 { 17 | time.Sleep(time.Second / 8) 18 | } else { 19 | time.Sleep(time.Second / 2) 20 | } 21 | } 22 | 23 | func main() { 24 | for { 25 | leds.Blue.SetOff() 26 | leds.User.SetOn() 27 | delay() 28 | 29 | leds.User.SetOff() 30 | leds.Azure.SetOn() 31 | delay() 32 | 33 | leds.Azure.SetOff() 34 | leds.WiFi.SetOn() 35 | delay() 36 | 37 | leds.WiFi.SetOff() 38 | leds.Red.SetOn() 39 | delay() 40 | 41 | leds.Red.SetOff() 42 | leds.Green.SetOn() 43 | delay() 44 | 45 | leds.Green.SetOff() 46 | leds.Blue.SetOn() 47 | delay() 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /devboard/az3166/examples/build.cfg: -------------------------------------------------------------------------------- 1 | GOTARGET = stm32f412 2 | GOMEM = 0x20000000:256K 3 | GOTEXT = 0x08000000:1M 4 | GOSTRIPFN = 1 5 | -------------------------------------------------------------------------------- /devboard/az3166/examples/debug-oocd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | TARGET=stm32f4x 4 | RESET=srst_only 5 | 6 | . $(emgo env GOROOT)/../scripts/debug-oocd.sh 7 | -------------------------------------------------------------------------------- /devboard/az3166/examples/debug-stutil.sh: -------------------------------------------------------------------------------- 1 | ../../../../scripts/debug-stutil.sh -------------------------------------------------------------------------------- /devboard/az3166/examples/load-oocd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | TARGET=stm32f4x 4 | RESET=srst_only 5 | TRACECLKIN=120000000 6 | 7 | . $(emgo env GOROOT)/../scripts/load-oocd.sh 8 | -------------------------------------------------------------------------------- /devboard/az3166/examples/load-stutil.sh: -------------------------------------------------------------------------------- 1 | ../../../../scripts/load-stutil.sh -------------------------------------------------------------------------------- /devboard/az3166/examples/swo-oocd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | TARGET=stm32f4x 4 | RESET=srst_only 5 | TRACECLKIN=120000000 6 | 7 | . $(emgo env GOROOT)/../scripts/swo-oocd.sh 8 | -------------------------------------------------------------------------------- /devboard/devebox-h743/board/buttons/button.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package buttons 6 | 7 | import ( 8 | "github.com/embeddedgo/stm32/hal/gpio" 9 | 10 | _ "github.com/embeddedgo/stm32/devboard/devebox-h743/board/system" 11 | ) 12 | 13 | // Onboard buttons 14 | const ( 15 | K1 Button = 0x43 // PE3 16 | K2 Button = 0x25 // PC5 17 | 18 | User = K1 19 | ) 20 | 21 | type Button uint8 22 | 23 | func (b Button) prt() int { return int(b) >> 4 } 24 | func (b Button) pin() uint { return uint(b) & 15 } 25 | 26 | func (b Button) Read() int { 27 | return int(gpio.P(b.prt()).Load()>>b.pin())&1 ^ 1 28 | } 29 | func (b Button) Pin() gpio.Pin { 30 | return gpio.P(b.prt()).Pin(int(b.pin())) 31 | } 32 | 33 | func init() { 34 | gpio.PC().EnableClock(true) 35 | gpio.PE().EnableClock(true) 36 | K1.Pin().Setup(&gpio.Config{Mode: gpio.In}) 37 | K2.Pin().Setup(&gpio.Config{Mode: gpio.In}) 38 | } 39 | -------------------------------------------------------------------------------- /devboard/devebox-h743/board/leds/led.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package leds 6 | 7 | import ( 8 | "github.com/embeddedgo/stm32/hal/gpio" 9 | 10 | _ "github.com/embeddedgo/stm32/devboard/devebox-h743/board/system" 11 | ) 12 | 13 | // Onboard LEDs 14 | const ( 15 | D2 LED = 0x01 // PA1 16 | 17 | User = D2 18 | ) 19 | 20 | type LED uint8 21 | 22 | func (d LED) prt() int { return int(d) >> 4 } 23 | func (d LED) pin() uint { return uint(d) & 15 } 24 | 25 | func (d LED) SetOn() { 26 | gpio.P(d.prt()).ClearPins(1 << d.pin()) 27 | } 28 | func (d LED) SetOff() { 29 | gpio.P(d.prt()).SetPins(1 << d.pin()) 30 | } 31 | func (d LED) Set(on int) { 32 | gpio.P(d.prt()).StorePins(1<>d.pin())&1 ^ 1 36 | } 37 | func (d LED) Toggle() { 38 | d.Set(d.Get() ^ 1) 39 | } 40 | func (d LED) Pin() gpio.Pin { 41 | return gpio.P(d.prt()).Pin(int(d.pin())) 42 | } 43 | 44 | func init() { 45 | gpio.PA().EnableClock(true) 46 | cfg := &gpio.Config{Mode: gpio.Out, Driver: gpio.OpenDrain, Speed: gpio.Low} 47 | D2.SetOff() 48 | D2.Pin().Setup(cfg) 49 | } 50 | -------------------------------------------------------------------------------- /devboard/devebox-h743/board/system/init.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package system 6 | 7 | import ( 8 | "github.com/embeddedgo/stm32/hal/system" 9 | "github.com/embeddedgo/stm32/hal/system/timer/systick" 10 | ) 11 | 12 | func init() { 13 | // 480 MHz CPU clock not supported, requires disabling Vcore overdrive 14 | // before any WFE instruction 15 | 16 | // PLL1 configuration (TODO: PLL2 and PLL3) 17 | const ( 18 | osc = 25 // MHz 19 | m = 5 // ref_ck = osc / 5 = 5 MHz 20 | n = 80 // Fvco = ref_ck * n = 400 MHz 21 | p = 1 // p_ck = Fvco / p = 400 MHz (CPU) 22 | q = 2 // q_ck = Fvco / q = 200 MHz (SPI(I2S)1,2,3, SAI) 23 | r = 2 // r_ck = Fvco / r = 200 MHz (trace port) 24 | ) 25 | system.SetupPLL(osc, m, n, p, q, r) 26 | systick.Setup(2e6) 27 | //rtcst.Setup(rtcst.LSE, 1, 32768) 28 | } 29 | -------------------------------------------------------------------------------- /devboard/devebox-h743/doc/board.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/embeddedgo/stm32/c31c3df4c80b62aa50b3b0b1d9b35b32a8e696a0/devboard/devebox-h743/doc/board.jpg -------------------------------------------------------------------------------- /devboard/devebox-h743/doc/schematics-20190801.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/embeddedgo/stm32/c31c3df4c80b62aa50b3b0b1d9b35b32a8e696a0/devboard/devebox-h743/doc/schematics-20190801.pdf -------------------------------------------------------------------------------- /devboard/devebox-h743/doc/schematics-20191123.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/embeddedgo/stm32/c31c3df4c80b62aa50b3b0b1d9b35b32a8e696a0/devboard/devebox-h743/doc/schematics-20191123.pdf -------------------------------------------------------------------------------- /devboard/devebox-h743/examples/blinky/main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package main 6 | 7 | import ( 8 | "time" 9 | 10 | "github.com/embeddedgo/stm32/devboard/devebox-h743/board/buttons" 11 | "github.com/embeddedgo/stm32/devboard/devebox-h743/board/leds" 12 | ) 13 | 14 | func delay() { 15 | if buttons.K1.Read() != 0 { 16 | time.Sleep(time.Second / 8) 17 | } else { 18 | time.Sleep(time.Second / 2) 19 | } 20 | } 21 | 22 | func main() { 23 | for { 24 | leds.User.SetOff() 25 | delay() 26 | leds.User.SetOn() 27 | delay() 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /devboard/devebox-h743/examples/build.cfg: -------------------------------------------------------------------------------- 1 | # DTCM: 0x20000000:128K MDMA 2 | # AXISRAM: 0x24000000:512K MDMA,DMA 3 | # AHBSRAM(1+2): 0x30000000:256K MDMA,DMA (used by hal/mem/nocache) 4 | # AHBSRAM3: 0x30040000:32K MDMA,DMA,Ethernet,USB 5 | # AHBSRAM4: 0x38000000:64K MDMA,DMA,BDMA 6 | # BKPSRAM: 0x38800000:4K MDMA,DMA,BDMA 7 | 8 | GOTARGET = stm32h7x3 9 | GOMEM = 0x24000000:512K,0x20000000:128K 10 | GOTEXT = 0x08000000:2M 11 | -------------------------------------------------------------------------------- /devboard/devebox-h743/examples/debug-oocd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | TARGET=stm32h7x_dual_bank 4 | RESET=none 5 | 6 | . $(emgo env GOROOT)/../scripts/debug-oocd.sh 7 | -------------------------------------------------------------------------------- /devboard/devebox-h743/examples/debug-stutil.sh: -------------------------------------------------------------------------------- 1 | ../../../../scripts/debug-stutil.sh -------------------------------------------------------------------------------- /devboard/devebox-h743/examples/load-oocd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | TARGET=stm32h7x_dual_bank 4 | TRACECLKIN=200000000 5 | RESET=none 6 | 7 | . $(emgo env GOROOT)/../scripts/load-oocd.sh 8 | -------------------------------------------------------------------------------- /devboard/devebox-h743/examples/load-stutil.sh: -------------------------------------------------------------------------------- 1 | ../../../../scripts/load-stutil.sh -------------------------------------------------------------------------------- /devboard/devebox-h743/examples/load-usb.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Connect BT0 and 3V3 pins to enable DFU bootloader 4 | 5 | set -e 6 | 7 | if [ -z "$OBJCOPY" ]; then 8 | OBJCOPY=objcopy 9 | fi 10 | 11 | name=$(basename $(pwd)) 12 | $OBJCOPY -O binary $name.elf $name.bin 13 | dfu-util -a 0 -s 0x8000000 -D $name.bin 14 | rm $name.bin 15 | -------------------------------------------------------------------------------- /devboard/devebox-h743/examples/swo-oocd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | TARGET=stm32h7x_dual_bank 4 | TRACECLKIN=200000000 5 | RESET=none 6 | 7 | . $(emgo env GOROOT)/../scripts/swo-oocd.sh 8 | -------------------------------------------------------------------------------- /devboard/devebox-h743/examples/ws2812/main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package main 6 | 7 | import ( 8 | "image/color" 9 | "time" 10 | 11 | "github.com/embeddedgo/rgbled/ws281x/wsuart" 12 | _ "github.com/embeddedgo/stm32/devboard/devebox-h743/board/system" 13 | "github.com/embeddedgo/stm32/hal/gpio" 14 | "github.com/embeddedgo/stm32/hal/usart" 15 | "github.com/embeddedgo/stm32/hal/usart/usart1" 16 | ) 17 | 18 | func main() { 19 | // GPIO pins assignment 20 | pa := gpio.PA() 21 | pa.EnableClock(true) 22 | tx := pa.Pin(9) // CN5 D8 23 | 24 | // Configure and enable USART 25 | u := usart1.Driver() 26 | u.UsePin(tx, usart.TXD) 27 | u.Setup(usart.Word8b|usart.InvTx, wsuart.BaudWS2812) 28 | u.EnableTx() 29 | 30 | colors := []color.RGBA{ 31 | {127, 0, 0, 255}, 32 | {255, 0, 0, 255}, 33 | {0, 127, 0, 255}, 34 | {0, 255, 0, 255}, 35 | {0, 0, 127, 255}, 36 | {0, 0, 255, 255}, 37 | {127, 127, 0, 255}, 38 | {255, 255, 0, 255}, 39 | {0, 127, 127, 255}, 40 | {0, 255, 255, 255}, 41 | {127, 0, 127, 255}, 42 | {255, 0, 255, 255}, 43 | {127, 127, 127, 255}, 44 | {255, 255, 255, 255}, 45 | } 46 | grb := wsuart.GRB 47 | strip := wsuart.Make(24) 48 | 49 | for i := 0; ; i++ { 50 | for k := range strip { 51 | strip.Clear() 52 | strip[k] = grb.Pixel(colors[i%len(colors)]) 53 | u.Write(strip.Bytes()) 54 | time.Sleep(time.Second / 2) 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /devboard/emw3162/board/system/init.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package system 6 | 7 | import ( 8 | "github.com/embeddedgo/stm32/hal/system" 9 | "github.com/embeddedgo/stm32/hal/system/timer/systick" 10 | ) 11 | 12 | func init() { 13 | system.Setup120(26) 14 | systick.Setup(2e6) 15 | } 16 | -------------------------------------------------------------------------------- /devboard/emw3162/doc/board.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/embeddedgo/stm32/c31c3df4c80b62aa50b3b0b1d9b35b32a8e696a0/devboard/emw3162/doc/board.jpg -------------------------------------------------------------------------------- /devboard/emw3162/doc/datasheet.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/embeddedgo/stm32/c31c3df4c80b62aa50b3b0b1d9b35b32a8e696a0/devboard/emw3162/doc/datasheet.pdf -------------------------------------------------------------------------------- /devboard/emw3162/examples/blinky/main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // This example shows the basic usage of available LEDs. 6 | package main 7 | 8 | import ( 9 | "time" 10 | 11 | "github.com/embeddedgo/stm32/devboard/emw3162/board/leds" 12 | ) 13 | 14 | func main() { 15 | for { 16 | leds.Green.SetOff() 17 | leds.Red.SetOn() 18 | time.Sleep(time.Second / 4) 19 | 20 | leds.Red.SetOff() 21 | leds.Green.SetOn() 22 | time.Sleep(time.Second / 4) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /devboard/emw3162/examples/build.cfg: -------------------------------------------------------------------------------- 1 | GOTARGET = stm32f215 2 | GOMEM = 0x20000000:128K 3 | GOTEXT = 0x08000000:1M 4 | GOSTRIPFN = 1 5 | -------------------------------------------------------------------------------- /devboard/emw3162/examples/debug-oocd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | TARGET=stm32f2x 4 | RESET=none 5 | 6 | . $(emgo env GOROOT)/../scripts/debug-oocd.sh 7 | -------------------------------------------------------------------------------- /devboard/emw3162/examples/debug-stutil.sh: -------------------------------------------------------------------------------- 1 | ../../../../scripts/debug-stutil.sh -------------------------------------------------------------------------------- /devboard/emw3162/examples/helloworld/main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package main 6 | 7 | import ( 8 | "time" 9 | 10 | _ "github.com/embeddedgo/stm32/devboard/emw3162/board/system" 11 | ) 12 | 13 | func main() { 14 | for { 15 | println("Hello World!") 16 | time.Sleep(time.Second / 4) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /devboard/emw3162/examples/load-oocd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | INTERFACE=stlink 4 | TARGET=stm32f2x 5 | TRACECLKIN=120000000 6 | RESET=none 7 | 8 | . $(emgo env GOROOT)/../scripts/load-oocd.sh 9 | -------------------------------------------------------------------------------- /devboard/emw3162/examples/load-stutil.sh: -------------------------------------------------------------------------------- 1 | ../../../../scripts/load-stutil.sh -------------------------------------------------------------------------------- /devboard/emw3162/examples/spi/main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // SPI loop test: wire PB14 and PB15 together. 6 | package main 7 | 8 | import ( 9 | "time" 10 | 11 | "github.com/embeddedgo/stm32/hal/gpio" 12 | "github.com/embeddedgo/stm32/hal/spi" 13 | "github.com/embeddedgo/stm32/hal/spi/spi2" 14 | 15 | _ "github.com/embeddedgo/stm32/devboard/emw3162/board/system" 16 | ) 17 | 18 | func main() { 19 | // Allocate GPIO pins 20 | 21 | pb := gpio.PB() 22 | pb.EnableClock(true) 23 | sck := pb.Pin(13) 24 | miso := pb.Pin(14) 25 | mosi := pb.Pin(15) 26 | 27 | // Configure SPI pins 28 | 29 | sd := spi2.Driver() 30 | sd.UsePinMaster(sck, spi.SCK) 31 | sd.UsePinMaster(mosi, spi.MOSI) 32 | sd.UsePinMaster(miso, spi.MISO) 33 | 34 | // Configure and enable SPI 35 | 36 | sd.Setup(spi.Master|spi.SoftSS|spi.ISSHigh, 1e6) 37 | sd.SetWordSize(8) 38 | sd.Enable() 39 | 40 | var buf [40]byte 41 | for i := 0; ; i++ { 42 | sd.WriteStringRead("Hello world!", buf[:]) 43 | println(string(buf[:])) 44 | time.Sleep(time.Second) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /devboard/emw3162/examples/swo-oocd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | TARGET=stm32f2x 4 | TRACECLKIN=120000000 5 | RESET=none 6 | 7 | . $(emgo env GOROOT)/../scripts/swo-oocd.sh 8 | -------------------------------------------------------------------------------- /devboard/f4-discovery/board/buttons/button.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package buttons 6 | 7 | import ( 8 | "github.com/embeddedgo/stm32/hal/gpio" 9 | 10 | _ "github.com/embeddedgo/stm32/devboard/f4-discovery/board/system" 11 | ) 12 | 13 | // Onboard buttons 14 | const ( 15 | B1 Button = 0x00 // PA0 16 | 17 | User = B1 18 | ) 19 | 20 | type Button uint8 21 | 22 | func (b Button) prt() int { return int(b) >> 4 } 23 | func (b Button) pin() uint { return uint(b) & 15 } 24 | 25 | func (b Button) Read() int { 26 | return int(gpio.P(b.prt()).Load()>>b.pin()) & 1 27 | } 28 | func (b Button) Pin() gpio.Pin { 29 | return gpio.P(b.prt()).Pin(int(b.pin())) 30 | } 31 | 32 | func init() { 33 | gpio.PA().EnableClock(true) 34 | B1.Pin().Setup(&gpio.Config{Mode: gpio.In}) 35 | } 36 | -------------------------------------------------------------------------------- /devboard/f4-discovery/board/leds/led.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package leds 6 | 7 | import ( 8 | "github.com/embeddedgo/stm32/hal/gpio" 9 | 10 | _ "github.com/embeddedgo/stm32/devboard/f4-discovery/board/system" 11 | ) 12 | 13 | // Onboard LEDs 14 | const ( 15 | LD3 LED = 0x3D // PD13 16 | LD4 LED = 0x3C // PD12 17 | LD5 LED = 0x3E // PD14 18 | LD6 LED = 0x3F // PD15 19 | 20 | Orange = LD3 21 | Green = LD4 22 | Red = LD5 23 | Blue = LD6 24 | 25 | User = LD3 26 | ) 27 | 28 | type LED uint8 29 | 30 | func prt(d LED) int { return int(d) >> 4 } 31 | func pin(d LED) uint { return uint(d) & 15 } 32 | 33 | func (d LED) SetOn() { 34 | gpio.P(prt(d)).SetPins(1 << pin(d)) 35 | } 36 | func (d LED) SetOff() { 37 | gpio.P(prt(d)).ClearPins(1 << pin(d)) 38 | } 39 | func (d LED) Set(on int) { 40 | gpio.P(prt(d)).StorePins(1<>pin(d)) & 1 44 | } 45 | func (d LED) Toggle() { 46 | d.Set(d.Get() ^ 1) 47 | } 48 | func (d LED) Pin() gpio.Pin { 49 | return gpio.P(prt(d)).Pin(int(pin(d))) 50 | } 51 | 52 | func init() { 53 | gpio.PD().EnableClock(true) 54 | cfg := &gpio.Config{Mode: gpio.Out, Speed: gpio.Low} 55 | LD3.Pin().Setup(cfg) 56 | LD4.Pin().Setup(cfg) 57 | LD5.Pin().Setup(cfg) 58 | LD6.Pin().Setup(cfg) 59 | } 60 | -------------------------------------------------------------------------------- /devboard/f4-discovery/board/system/init.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package system 6 | 7 | import ( 8 | "github.com/embeddedgo/stm32/hal/system" 9 | "github.com/embeddedgo/stm32/hal/system/timer/systick" 10 | ) 11 | 12 | func init() { 13 | system.Setup168(8) 14 | systick.Setup(2e6) 15 | } 16 | -------------------------------------------------------------------------------- /devboard/f4-discovery/doc/accel_an.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/embeddedgo/stm32/c31c3df4c80b62aa50b3b0b1d9b35b32a8e696a0/devboard/f4-discovery/doc/accel_an.pdf -------------------------------------------------------------------------------- /devboard/f4-discovery/doc/accel_ds.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/embeddedgo/stm32/c31c3df4c80b62aa50b3b0b1d9b35b32a8e696a0/devboard/f4-discovery/doc/accel_ds.pdf -------------------------------------------------------------------------------- /devboard/f4-discovery/doc/board.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/embeddedgo/stm32/c31c3df4c80b62aa50b3b0b1d9b35b32a8e696a0/devboard/f4-discovery/doc/board.jpg -------------------------------------------------------------------------------- /devboard/f4-discovery/doc/user_manual.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/embeddedgo/stm32/c31c3df4c80b62aa50b3b0b1d9b35b32a8e696a0/devboard/f4-discovery/doc/user_manual.pdf -------------------------------------------------------------------------------- /devboard/f4-discovery/examples/blinky/main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // This example shows the basic usage of available LEDs and button. 6 | package main 7 | 8 | import ( 9 | "time" 10 | 11 | "github.com/embeddedgo/stm32/devboard/f4-discovery/board/buttons" 12 | "github.com/embeddedgo/stm32/devboard/f4-discovery/board/leds" 13 | ) 14 | 15 | func delay() { 16 | if buttons.User.Read() != 0 { 17 | time.Sleep(time.Second / 8) 18 | } else { 19 | time.Sleep(time.Second / 2) 20 | } 21 | } 22 | 23 | func main() { 24 | for { 25 | leds.Green.SetOff() 26 | leds.Orange.SetOn() 27 | delay() 28 | 29 | leds.Orange.SetOff() 30 | leds.Red.SetOn() 31 | delay() 32 | 33 | leds.Red.SetOff() 34 | leds.Blue.SetOn() 35 | delay() 36 | 37 | leds.Blue.SetOff() 38 | leds.Green.SetOn() 39 | delay() 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /devboard/f4-discovery/examples/build.cfg: -------------------------------------------------------------------------------- 1 | GOTARGET = stm32f407 2 | GOMEM = 0x20000000:128K,0x10000000:64K 3 | GOTEXT = 0x08000000:1M 4 | GOSTRIPFN = 1 5 | -------------------------------------------------------------------------------- /devboard/f4-discovery/examples/debug-oocd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | INTERFACE=stlink 4 | TARGET=stm32f4x 5 | RESET=srst_only 6 | 7 | . $(emgo env GOROOT)/../scripts/debug-oocd.sh 8 | -------------------------------------------------------------------------------- /devboard/f4-discovery/examples/debug-stutil.sh: -------------------------------------------------------------------------------- 1 | ../../../../scripts/debug-stutil.sh -------------------------------------------------------------------------------- /devboard/f4-discovery/examples/goroutines/main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package main 6 | 7 | import ( 8 | "runtime" 9 | "time" 10 | 11 | "github.com/embeddedgo/stm32/devboard/f4-discovery/board/leds" 12 | ) 13 | 14 | func blink(led leds.LED, delay time.Duration) { 15 | //runtime.LockOSThread() 16 | for { 17 | led.SetOn() 18 | time.Sleep(delay) 19 | led.SetOff() 20 | time.Sleep(delay) 21 | } 22 | } 23 | 24 | func main() { 25 | runtime.GOMAXPROCS(2) 26 | go blink(leds.Red, time.Second*2) 27 | go blink(leds.Green, time.Second/3) 28 | go blink(leds.Blue, time.Second/7) 29 | blink(leds.Orange, time.Second/11) 30 | } 31 | -------------------------------------------------------------------------------- /devboard/f4-discovery/examples/helloworld/main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package main 6 | 7 | import _ "github.com/embeddedgo/stm32/devboard/f4-discovery/board/system" 8 | 9 | func main() { 10 | for { 11 | println("Hello, World!") 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /devboard/f4-discovery/examples/load-oocd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | TARGET=stm32f4x 4 | TRACECLKIN=168000000 5 | RESET='srst_only srst_nogate connect_assert_srst' 6 | 7 | . $(emgo env GOROOT)/../scripts/load-oocd.sh 8 | -------------------------------------------------------------------------------- /devboard/f4-discovery/examples/load-stutil.sh: -------------------------------------------------------------------------------- 1 | ../../../../scripts/load-stutil.sh -------------------------------------------------------------------------------- /devboard/f4-discovery/examples/rawtasktest/main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2025 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package main 6 | 7 | import ( 8 | "embedded/rtos" 9 | "time" 10 | 11 | "github.com/embeddedgo/stm32/hal/exti" 12 | "github.com/embeddedgo/stm32/hal/irq" 13 | 14 | "github.com/embeddedgo/stm32/devboard/f4-discovery/board/buttons" 15 | ) 16 | 17 | type LatM struct { 18 | t0 time.Duration 19 | note rtos.Note 20 | } 21 | 22 | var latm LatM 23 | 24 | func main() { 25 | pin := buttons.User.Pin() // PA0 26 | line := exti.Lines(1 << pin.Num()) 27 | line.Connect(pin.Port()) 28 | line.EnableRiseTrig() 29 | irq.EXTI0.Enable(rtos.IntPrioLow, 0) 30 | 31 | go waitBtn(&latm) 32 | //rtos.NewRawTask(func() { waitBtn(&latm) }) 33 | 34 | for { 35 | time.Sleep(time.Hour) 36 | } 37 | } 38 | 39 | //go:nowritebarrierrec 40 | func waitBtn(lm *LatM) { 41 | line := exti.Lines(1 << buttons.User.Pin().Num()) 42 | for { 43 | lm.note.Clear() 44 | line.ClearPending() 45 | line.EnableIRQ() 46 | lm.note.Sleep(-1) 47 | t1 := rtos.Nanotime() 48 | println(t1 - lm.t0) 49 | time.Sleep(time.Second / 2) 50 | } 51 | } 52 | 53 | //go:interrupthandler 54 | func EXTI0_Handler() { 55 | line := exti.Lines(1 << buttons.User.Pin().Num()) 56 | line.DisableIRQ() 57 | line.ClearPending() 58 | latm.t0 = rtos.Nanotime() 59 | latm.note.Wakeup() 60 | } 61 | -------------------------------------------------------------------------------- /devboard/f4-discovery/examples/spi/main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // SPI loop test: wire PB14 and PB15 together. 6 | package main 7 | 8 | import ( 9 | "time" 10 | 11 | "github.com/embeddedgo/stm32/hal/gpio" 12 | "github.com/embeddedgo/stm32/hal/spi" 13 | "github.com/embeddedgo/stm32/hal/spi/spi2" 14 | 15 | _ "github.com/embeddedgo/stm32/devboard/f4-discovery/board/system" 16 | ) 17 | 18 | func main() { 19 | // Allocate GPIO pins 20 | 21 | pb := gpio.PB() 22 | pb.EnableClock(true) 23 | sck := pb.Pin(13) 24 | miso := pb.Pin(14) 25 | mosi := pb.Pin(15) 26 | 27 | // Configure SPI pins 28 | 29 | sd := spi2.Driver() 30 | sd.UsePinMaster(sck, spi.SCK) 31 | sd.UsePinMaster(mosi, spi.MOSI) 32 | sd.UsePinMaster(miso, spi.MISO) 33 | 34 | // Configure and enable SPI 35 | 36 | sd.Setup(spi.Master|spi.SoftSS|spi.ISSHigh, 1e6) 37 | sd.SetWordSize(8) 38 | sd.Enable() 39 | 40 | var buf [40]byte 41 | for i := 0; ; i++ { 42 | sd.WriteStringRead("Hello world!", buf[:]) 43 | println(string(buf[:])) 44 | time.Sleep(time.Second) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /devboard/f4-discovery/examples/swo-oocd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | TARGET=stm32f4x 4 | TRACECLKIN=168000000 5 | RESET=srst_only 6 | 7 | . $(emgo env GOROOT)/../scripts/swo-oocd.sh 8 | -------------------------------------------------------------------------------- /devboard/minipro-f405/board/buttons/button.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package buttons 6 | 7 | import ( 8 | "github.com/embeddedgo/stm32/hal/gpio" 9 | 10 | _ "github.com/embeddedgo/stm32/devboard/minipro-f405/board/system" 11 | ) 12 | 13 | // Onboard buttons 14 | const ( 15 | K1 Button = 0x00 // PA0 16 | 17 | User = K1 18 | ) 19 | 20 | type Button uint8 21 | 22 | func prt(b Button) int { return int(b) >> 4 } 23 | func pin(b Button) uint { return uint(b) & 15 } 24 | 25 | func (b Button) Read() int { 26 | return int(gpio.P(prt(b)).Load()>>pin(b))&1 ^ 1 27 | } 28 | func (b Button) Pin() gpio.Pin { 29 | return gpio.P(prt(b)).Pin(int(pin(b))) 30 | } 31 | 32 | func init() { 33 | gpio.PA().EnableClock(true) 34 | K1.Pin().Setup(&gpio.Config{Mode: gpio.In}) 35 | } 36 | -------------------------------------------------------------------------------- /devboard/minipro-f405/board/leds/led.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package leds 6 | 7 | import ( 8 | "github.com/embeddedgo/stm32/hal/gpio" 9 | 10 | _ "github.com/embeddedgo/stm32/devboard/minipro-f405/board/system" 11 | ) 12 | 13 | // Onboard LEDs 14 | const ( 15 | D1 LED = 0x08 // PA8 16 | 17 | User = D1 18 | ) 19 | 20 | type LED uint8 21 | 22 | func prt(d LED) int { return int(d) >> 4 } 23 | func pin(d LED) uint { return uint(d) & 15 } 24 | 25 | func (d LED) SetOn() { 26 | gpio.P(prt(d)).ClearPins(1 << pin(d)) 27 | } 28 | func (d LED) SetOff() { 29 | gpio.P(prt(d)).SetPins(1 << pin(d)) 30 | } 31 | func (d LED) Set(on int) { 32 | gpio.P(prt(d)).StorePins(1<>pin(d))&1 ^ 1 36 | } 37 | func (d LED) Toggle() { 38 | d.Set(d.Get() ^ 1) 39 | } 40 | func (d LED) Pin() gpio.Pin { 41 | return gpio.P(prt(d)).Pin(int(pin(d))) 42 | } 43 | 44 | func init() { 45 | gpio.PA().EnableClock(true) 46 | cfg := &gpio.Config{Mode: gpio.Out, Driver: gpio.OpenDrain, Speed: gpio.Low} 47 | D1.SetOff() 48 | D1.Pin().Setup(cfg) 49 | } 50 | -------------------------------------------------------------------------------- /devboard/minipro-f405/board/system/init.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package system 6 | 7 | import ( 8 | "github.com/embeddedgo/stm32/hal/gpio" 9 | "github.com/embeddedgo/stm32/hal/system" 10 | "github.com/embeddedgo/stm32/hal/system/console/uartcon" 11 | "github.com/embeddedgo/stm32/hal/system/timer/rtcst" 12 | "github.com/embeddedgo/stm32/hal/usart" 13 | "github.com/embeddedgo/stm32/hal/usart/usart1" 14 | ) 15 | 16 | func init() { 17 | system.Setup168(8) 18 | rtcst.Setup(rtcst.LSE, 1, 32768) 19 | uart := usart1.Driver() 20 | rx := gpio.PA().Pin(9) 21 | tx := gpio.PA().Pin(10) 22 | uartcon.Setup(uart, rx, tx, usart.Word8b, 115200, "USART1") 23 | } 24 | -------------------------------------------------------------------------------- /devboard/minipro-f405/doc/board.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/embeddedgo/stm32/c31c3df4c80b62aa50b3b0b1d9b35b32a8e696a0/devboard/minipro-f405/doc/board.jpg -------------------------------------------------------------------------------- /devboard/minipro-f405/doc/picocom-reset.txt: -------------------------------------------------------------------------------- 1 | How to reset MiniPro board using picocom 2 | 3 | 1. Connect to the CH340 using picocom: 4 | 5 | $ picocom -b 115200 /dev/ttyUSB0 6 | 7 | The initial state is both DTR and RTS signals are asserted (CH340_DTR# low, CH340_RTS# low) which means STM32_RESET# high, STM32_BOOT0 high. 8 | 9 | 2. Deassert DTR signal (set CH340_DTR# high): 10 | 11 | C-a C-t 12 | 13 | It asserts STM32 RESET signal (STM32_RESET# low, STM32_BOOT0 high). Another C-a C-t sequence will deassert STM32 RESET but with BOOT0 high so the STM32 will enter bootloader mode. 14 | 15 | 3. Deassert RTS signal (set CH340_RTS# high): 16 | 17 | C-a C-g 18 | 19 | It deasserts both STM32 RESET and BOOT0 signals (STM32_RESET# high, STM32_BOOT0 low). The STM32 starts executing your program. 20 | 21 | From now you can use C-a C-g sequence to reset STM32 without interrupting the connection to its USART1. 22 | 23 | 24 | Control codes (can be generated using a, g, t keys with Ctrl key pressed) 25 | -------------------------------------------------------------------------------- /devboard/minipro-f405/examples/blinky/main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // This example shows the basic usage of available LEDs and button. 6 | package main 7 | 8 | import ( 9 | "time" 10 | 11 | "github.com/embeddedgo/stm32/devboard/minipro-f405/board/buttons" 12 | "github.com/embeddedgo/stm32/devboard/minipro-f405/board/leds" 13 | ) 14 | 15 | func delay() { 16 | if buttons.User.Read() != 0 { 17 | time.Sleep(time.Second / 7) 18 | } else { 19 | time.Sleep(time.Second / 2) 20 | } 21 | } 22 | 23 | func main() { 24 | for { 25 | leds.User.SetOff() 26 | delay() 27 | leds.User.SetOn() 28 | delay() 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /devboard/minipro-f405/examples/build.cfg: -------------------------------------------------------------------------------- 1 | GOTARGET = stm32f407 2 | GOMEM = 0x20000000:128K,0x10000000:64K 3 | GOTEXT = 0x08000000:1M 4 | GOSTRIPFN = 1 5 | -------------------------------------------------------------------------------- /devboard/minipro-f405/examples/debug-oocd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | TARGET=stm32f4x 4 | RESET=none 5 | 6 | . $(emgo env GOROOT)/../scripts/debug-oocd.sh 7 | -------------------------------------------------------------------------------- /devboard/minipro-f405/examples/debug-stutil.sh: -------------------------------------------------------------------------------- 1 | ../../../../scripts/debug-stutil.sh -------------------------------------------------------------------------------- /devboard/minipro-f405/examples/helloworld/main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // The helloworld program prints text in a loop to the standard output. The 6 | // standard output is configured to use UART1 peripheral conected to the onboard 7 | // CH340 USB<->UART converter and available on the left micro USB port (when you 8 | // are looking at the MCU chip and the USB ports are above it). 9 | package main 10 | 11 | import ( 12 | "fmt" 13 | 14 | _ "github.com/embeddedgo/stm32/devboard/minipro-f405/board/system" 15 | ) 16 | 17 | func main() { 18 | for { 19 | fmt.Println("Hello, World!") 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /devboard/minipro-f405/examples/load-oocd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | TARGET=stm32f4x 4 | TRACECLKIN=168000000 5 | RESET=none 6 | 7 | . $(emgo env GOROOT)/../scripts/load-oocd.sh 8 | -------------------------------------------------------------------------------- /devboard/minipro-f405/examples/load-stutil.sh: -------------------------------------------------------------------------------- 1 | ../../../../scripts/load-stutil.sh -------------------------------------------------------------------------------- /devboard/minipro-f405/examples/load-uart.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | if [ -z "$STM32TTY" ]; then 6 | STM32TTY=/dev/ttyUSB0 7 | fi 8 | 9 | if [ -z "$STM32BAUD" ]; then 10 | # Maximum officially supported speed is 115200 baud. 11 | # Flashing takes: 12 | # - 2m38s at 57600 (always works) 13 | # - 1m41s at 115200 (almost always works) 14 | # - 1m13s at 230400 (sometimes doesn't work) 15 | # - 0m58s at 460800 (works rarely) 16 | STM32BAUD=115200 17 | fi 18 | 19 | if [ -z "$OBJCOPY" ]; then 20 | OBJCOPY=objcopy 21 | fi 22 | 23 | name=$(basename $(pwd)) 24 | $OBJCOPY -O binary $name.elf $name.bin 25 | stm32flash -b $STM32BAUD -R -i rts,-dtr,dtr:-dtr,-rts -w $name.bin $STM32TTY 26 | rm $name.bin 27 | -------------------------------------------------------------------------------- /devboard/minipro-f405/examples/relay/utils.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package main 6 | 7 | import ( 8 | "fmt" 9 | "os" 10 | ) 11 | 12 | const timeLayout = "2006-01-02 15:04:05 MST" 13 | 14 | func isErr(err error) bool { 15 | if err == nil { 16 | return false 17 | } 18 | fmt.Fprintf(os.Stderr, "\n%v\n", err) 19 | return true 20 | } 21 | -------------------------------------------------------------------------------- /devboard/minipro-f405/examples/swo-oocd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | TARGET=stm32f4x 4 | TRACECLKIN=168000000 5 | RESET=none 6 | 7 | . $(emgo env GOROOT)/../scripts/swo-oocd.sh 8 | -------------------------------------------------------------------------------- /devboard/nucleo-l476rg/board/buttons/button.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package buttons 6 | 7 | import ( 8 | "github.com/embeddedgo/stm32/hal/gpio" 9 | 10 | _ "github.com/embeddedgo/stm32/devboard/nucleo-l476rg/board/system" 11 | ) 12 | 13 | // Onboard button 14 | const ( 15 | B1 Button = 0x2D // PC13 16 | 17 | User = B1 18 | ) 19 | 20 | type Button uint8 21 | 22 | func prt(b Button) int { return int(b) >> 4 } 23 | func pin(b Button) uint { return uint(b) & 15 } 24 | 25 | func (b Button) Read() int { 26 | return int(gpio.P(prt(b)).Load()>>pin(b))&1 ^ 1 27 | } 28 | func (b Button) Pin() gpio.Pin { 29 | return gpio.P(prt(b)).Pin(int(pin(b))) 30 | } 31 | 32 | func init() { 33 | gpio.PC().EnableClock(true) 34 | B1.Pin().Setup(&gpio.Config{Mode: gpio.In}) 35 | } 36 | -------------------------------------------------------------------------------- /devboard/nucleo-l476rg/board/leds/led.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package leds 6 | 7 | import ( 8 | "github.com/embeddedgo/stm32/hal/gpio" 9 | 10 | _ "github.com/embeddedgo/stm32/devboard/nucleo-l476rg/board/system" 11 | ) 12 | 13 | // Onboard LED 14 | const ( 15 | LD2 LED = 0x05 // PA5 16 | 17 | User = LD2 18 | ) 19 | 20 | type LED uint8 21 | 22 | func prt(d LED) int { return int(d) >> 4 } 23 | func pin(d LED) uint { return uint(d) & 15 } 24 | 25 | func (d LED) SetOn() { 26 | gpio.P(prt(d)).SetPins(1 << pin(d)) 27 | } 28 | func (d LED) SetOff() { 29 | gpio.P(prt(d)).ClearPins(1 << pin(d)) 30 | } 31 | func (d LED) Set(on int) { 32 | gpio.P(prt(d)).StorePins(1<>pin(d)) & 1 36 | } 37 | func (d LED) Toggle() { 38 | port := gpio.P(prt(d)) 39 | mask := gpio.Pins(1 << pin(d)) 40 | val := port.LoadOut() ^ mask 41 | port.StorePins(mask, val) 42 | } 43 | func (d LED) Pin() gpio.Pin { 44 | return gpio.P(prt(d)).Pin(int(pin(d))) 45 | } 46 | 47 | func init() { 48 | gpio.PA().EnableClock(true) 49 | LD2.Pin().Setup(&gpio.Config{Mode: gpio.Out, Speed: gpio.Low}) 50 | } 51 | -------------------------------------------------------------------------------- /devboard/nucleo-l476rg/board/system/setup.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package system 6 | 7 | import ( 8 | "github.com/embeddedgo/stm32/hal/gpio" 9 | "github.com/embeddedgo/stm32/hal/system" 10 | "github.com/embeddedgo/stm32/hal/system/console/uartcon" 11 | "github.com/embeddedgo/stm32/hal/system/timer/rtcst" 12 | "github.com/embeddedgo/stm32/hal/usart" 13 | "github.com/embeddedgo/stm32/hal/usart/usart2" 14 | ) 15 | 16 | func init() { 17 | system.Setup80(0, 0) 18 | rtcst.Setup(rtcst.LSE, 1, 32768) 19 | uart := usart2.Driver() 20 | rx := gpio.PA().Pin(3) 21 | tx := gpio.PA().Pin(2) 22 | // Use the "light" version of the console because of small RAM. 23 | uartcon.SetupLight(uart, rx, tx, usart.Word8b, 115200, "USART2") 24 | } 25 | -------------------------------------------------------------------------------- /devboard/nucleo-l476rg/doc/board.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/embeddedgo/stm32/c31c3df4c80b62aa50b3b0b1d9b35b32a8e696a0/devboard/nucleo-l476rg/doc/board.jpg -------------------------------------------------------------------------------- /devboard/nucleo-l476rg/examples/blinky/main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // This example shows the basic usage of the available LED and button. 6 | package main 7 | 8 | import ( 9 | "time" 10 | 11 | "github.com/embeddedgo/stm32/devboard/nucleo-l476rg/board/buttons" 12 | "github.com/embeddedgo/stm32/devboard/nucleo-l476rg/board/leds" 13 | ) 14 | 15 | func delay() { 16 | if buttons.User.Read() != 0 { 17 | time.Sleep(time.Second / 8) 18 | } else { 19 | time.Sleep(time.Second / 2) 20 | } 21 | } 22 | 23 | func main() { 24 | for { 25 | leds.User.SetOn() 26 | delay() 27 | leds.User.SetOff() 28 | delay() 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /devboard/nucleo-l476rg/examples/blinky2/main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Blinky2 shows the basic usage of the available LED and button. It differs 6 | // from blinky in that it uses time.Timer instead of more obvious time.Sleep. 7 | 8 | package main 9 | 10 | import ( 11 | "time" 12 | 13 | "github.com/embeddedgo/stm32/devboard/nucleo-l476rg/board/buttons" 14 | "github.com/embeddedgo/stm32/devboard/nucleo-l476rg/board/leds" 15 | ) 16 | 17 | func delay() time.Duration { 18 | if buttons.User.Read() != 0 { 19 | return time.Second / 8 20 | } 21 | return time.Second / 2 22 | } 23 | 24 | func main() { 25 | tim := time.NewTimer(delay()) 26 | for range tim.C { 27 | leds.User.Toggle() 28 | tim.Reset(delay()) 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /devboard/nucleo-l476rg/examples/build.cfg: -------------------------------------------------------------------------------- 1 | GOTARGET = stm32l4x6 2 | GOMEM = 0x20000000:96K,0x10000000:32K 3 | GOTEXT = 0x08000000:1M 4 | GOSTRIPFN = 1 5 | -------------------------------------------------------------------------------- /devboard/nucleo-l476rg/examples/debug-oocd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | TARGET=stm32l4x 4 | RESET=srst_only 5 | 6 | . $(emgo env GOROOT)/../scripts/debug-oocd.sh 7 | -------------------------------------------------------------------------------- /devboard/nucleo-l476rg/examples/debug-stutil.sh: -------------------------------------------------------------------------------- 1 | ../../../../scripts/debug-stutil.sh -------------------------------------------------------------------------------- /devboard/nucleo-l476rg/examples/goroutines/main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // This example runs two goroutines that set on/off the user LED concurently. 6 | package main 7 | 8 | import ( 9 | "math/rand" 10 | "time" 11 | 12 | "github.com/embeddedgo/stm32/devboard/nucleo-l476rg/board/leds" 13 | ) 14 | 15 | func randDelay() { 16 | time.Sleep(time.Second / 1024 * time.Duration(1024 + rand.Intn(1024))) 17 | } 18 | 19 | 20 | func ledOn() { 21 | for { 22 | randDelay() 23 | leds.User.SetOn() 24 | } 25 | } 26 | 27 | func main() { 28 | go ledOn() 29 | for { 30 | randDelay() 31 | leds.User.SetOff() 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /devboard/nucleo-l476rg/examples/helloworld/main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package main 6 | 7 | import ( 8 | "fmt" 9 | 10 | _ "github.com/embeddedgo/stm32/devboard/nucleo-l476rg/board/system" 11 | ) 12 | 13 | func main() { 14 | for { 15 | fmt.Print("Hello, World!\r\n") 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /devboard/nucleo-l476rg/examples/load-oocd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | TARGET=stm32l4x 4 | TRACECLKIN=80000000 5 | RESET='srst_only srst_nogate connect_assert_srst' 6 | 7 | . $(emgo env GOROOT)/../scripts/load-oocd.sh 8 | -------------------------------------------------------------------------------- /devboard/nucleo-l476rg/examples/load-stm32flash.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | if [ -z "$OBJCOPY" ]; then 6 | OBJCOPY=objcopy 7 | fi 8 | 9 | name=$(basename $(pwd)) 10 | $OBJCOPY -O binary $name.elf $name.bin 11 | stm32flash -R -w $name.bin -b 460800 /dev/ttyACM0 12 | 13 | # Example flashing speeds (binary size: 557912 bytes) 14 | # 15 | # 115200 baud: 72s 16 | # 230400 baud: 45s 17 | # 460800 baud: 32s 18 | -------------------------------------------------------------------------------- /devboard/nucleo-l476rg/examples/load-stutil.sh: -------------------------------------------------------------------------------- 1 | ../../../../scripts/load-stutil.sh -------------------------------------------------------------------------------- /devboard/nucleo-l476rg/examples/reboot/main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Reboot shows the way to perform unsafe reboot of the ST32L746 MCU. Unsafe 6 | // reboot simply restarts the software without reseting the hardware. 7 | package main 8 | 9 | import ( 10 | "embedded/rtos" 11 | "time" 12 | "unsafe" 13 | 14 | "github.com/embeddedgo/stm32/hal/gpio" 15 | "github.com/embeddedgo/stm32/hal/system" 16 | "github.com/embeddedgo/stm32/hal/system/timer/rtcst" 17 | "github.com/embeddedgo/stm32/p/rcc" 18 | "github.com/embeddedgo/stm32/p/syscfg" 19 | ) 20 | 21 | func main() { 22 | system.Setup80(0, 0) 23 | rtcst.Setup(rtcst.LSE, 1, 32768) 24 | 25 | pa := gpio.PA() 26 | pa.EnableClock(true) 27 | led := pa.Pin(5) 28 | 29 | led.Setup(&gpio.Config{Mode: gpio.Out, Speed: gpio.Low}) 30 | 31 | for i := 0; i < 10; i++ { 32 | led.Set() 33 | time.Sleep(time.Second / 8) 34 | led.Clear() 35 | time.Sleep(time.Second / 8) 36 | } 37 | RCC := rcc.RCC() 38 | RCC.APB2ENR.SetBits(rcc.SYSCFGEN) 39 | syscfg.SYSCFG().MEMRMP.StoreBits(syscfg.MEM_MODE, 1) 40 | RCC.APB2ENR.ClearBits(rcc.SYSCFGEN) 41 | rtos.Reset(rtos.UnsafeReboot, unsafe.Pointer(uintptr(0x1FFF0000))) 42 | } 43 | -------------------------------------------------------------------------------- /devboard/nucleo-l476rg/examples/rtc/main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package main 6 | 7 | import ( 8 | "time" 9 | 10 | "github.com/embeddedgo/stm32/hal/system/timer/rtcst" 11 | 12 | _ "github.com/embeddedgo/stm32/devboard/nucleo-l476rg/board/system" 13 | ) 14 | 15 | func main() { 16 | bi := 0 // index of the first RTC backup register used to save t0 17 | t0, _ := rtcst.LoadTime(bi) 18 | u0 := time.Unix(0, 0) 19 | if t0.Equal(u0) { 20 | // We have lost the time settings. Let's ask someone for the current 21 | // time and adjust the internal "wall clock". 22 | t0 = time.Set(askForTime()) 23 | rtcst.StoreTime(t0, bi) 24 | } else { 25 | // The RTC has survived the system reset. Let's adjust the wall clock 26 | // based on the saved t0. 27 | time.Set(u0, t0) 28 | } 29 | 30 | for { 31 | println(time.Now().String()) 32 | time.Sleep(time.Second) 33 | } 34 | } 35 | 36 | func askForTime() (old, new time.Time) { 37 | return time.Now(), time.Date(2020, 2, 28, 23, 59, 0, 0, time.UTC) 38 | } 39 | -------------------------------------------------------------------------------- /devboard/nucleo-l476rg/examples/shell/cat.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package main 6 | 7 | import ( 8 | "fmt" 9 | "io" 10 | "os" 11 | ) 12 | 13 | const catUsage = ` 14 | cat FILENAME1 [FILENAME2 ...] 15 | ` 16 | 17 | func cat(args []string) { 18 | if len(args) < 2 { 19 | fmt.Print(catUsage) 20 | return 21 | } 22 | for _, name := range args[1:] { 23 | f, err := os.Open(name) 24 | if isErr(err) { 25 | continue 26 | } 27 | buf := make([]byte, 64) 28 | for { 29 | n, err1 := f.Read(buf) 30 | _, err2 := os.Stdout.Write(buf[:n]) 31 | if isErr(err2) || err1 == io.EOF || isErr(err1) { 32 | break 33 | } 34 | } 35 | isErr(f.Close()) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /devboard/nucleo-l476rg/examples/shell/date.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package main 6 | 7 | import ( 8 | "errors" 9 | "fmt" 10 | "strconv" 11 | "strings" 12 | "time" 13 | 14 | "github.com/embeddedgo/stm32/hal/system/timer/rtcst" 15 | ) 16 | 17 | const dateUsage = ` 18 | date 19 | date YYYY-MM-DD hh:mm:ss 20 | ` 21 | 22 | // time.Parse is too heavy 23 | func parse(s, sep string) (v [3]int, err error) { 24 | fields := strings.Split(s, sep) 25 | if len(fields) != 3 { 26 | err = errors.New("bad layout") 27 | return 28 | } 29 | for i, f := range fields { 30 | var u uint64 31 | u, err = strconv.ParseUint(f, 10, 16) 32 | if err != nil { 33 | return 34 | } 35 | v[i] = int(u) 36 | } 37 | return 38 | } 39 | 40 | func date(args []string) { 41 | now := time.Now() 42 | switch len(args) { 43 | case 3: 44 | ymd, err := parse(args[1], "-") 45 | if isErr(err) { 46 | break 47 | } 48 | hms, err := parse(args[2], ":") 49 | if isErr(err) { 50 | break 51 | } 52 | t := time.Date( 53 | ymd[0], time.Month(ymd[1]), ymd[2], 54 | hms[0], hms[1], hms[2], 0, time.Local, 55 | ) 56 | t0 := time.Set(now, t) 57 | rtcst.StoreTime(t0, 0) 58 | prompt = "> " 59 | case 1: 60 | fmt.Println(now.Format(timeLayout)) 61 | default: 62 | fmt.Print(dateUsage) 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /devboard/nucleo-l476rg/examples/shell/echo.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package main 6 | 7 | import "fmt" 8 | 9 | const echoUsage = ` 10 | echo [TEXT ...] 11 | ` 12 | 13 | func echo(args []string) { 14 | if len(args) == 1 { 15 | fmt.Print(echoUsage) 16 | return 17 | } 18 | for _, arg := range args[1:] { 19 | fmt.Print(arg, " ") 20 | } 21 | fmt.Print("\n") 22 | } 23 | -------------------------------------------------------------------------------- /devboard/nucleo-l476rg/examples/shell/ls.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package main 6 | 7 | import ( 8 | "fmt" 9 | "io/fs" 10 | "os" 11 | ) 12 | 13 | const lsUsage = ` 14 | ls DIR 15 | ` 16 | 17 | func ls(args []string) { 18 | if len(args) != 2 { 19 | fmt.Print(lsUsage) 20 | return 21 | } 22 | f, err := os.Open(args[1]) 23 | if isErr(err) { 24 | return 25 | } 26 | { 27 | fi, err := f.Stat() 28 | if isErr(err) { 29 | goto close 30 | } 31 | var list []fs.FileInfo 32 | if fi.IsDir() { 33 | list, err = f.Readdir(-1) 34 | if isErr(err) { 35 | goto close 36 | } 37 | } else { 38 | list = []fs.FileInfo{fi} 39 | } 40 | for _, fi := range list { 41 | fmt.Printf("%v %7d %s %s\n", 42 | fi.Mode(), fi.Size(), 43 | fi.ModTime().Format(timeLayout), fi.Name(), 44 | ) 45 | } 46 | } 47 | close: 48 | isErr(f.Close()) 49 | } 50 | -------------------------------------------------------------------------------- /devboard/nucleo-l476rg/examples/shell/mkdir.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package main 6 | 7 | import ( 8 | "fmt" 9 | "os" 10 | ) 11 | 12 | const mkdirUsage = ` 13 | mkdir NAME 14 | ` 15 | 16 | func mkdir(args []string) { 17 | if len(args) != 2 { 18 | fmt.Print(mkdirUsage) 19 | return 20 | } 21 | isErr(os.Mkdir(args[1], 0755)) 22 | } 23 | -------------------------------------------------------------------------------- /devboard/nucleo-l476rg/examples/shell/rename.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package main 6 | 7 | import ( 8 | "fmt" 9 | "os" 10 | ) 11 | 12 | const renameUsage = ` 13 | rename OLDNAME NEWNAME 14 | 15 | Both OLDNAME and NEWNAME must be in the same filesystem. 16 | ` 17 | 18 | func rename(args []string) { 19 | if len(args) != 3 { 20 | fmt.Print(renameUsage) 21 | return 22 | } 23 | isErr(os.Rename(args[1], args[2])) 24 | } 25 | -------------------------------------------------------------------------------- /devboard/nucleo-l476rg/examples/shell/rm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package main 6 | 7 | import ( 8 | "fmt" 9 | "os" 10 | ) 11 | 12 | const rmUsage = ` 13 | rm NAME 14 | ` 15 | 16 | func rm(args []string) { 17 | if len(args) != 2 { 18 | fmt.Print(rmUsage) 19 | return 20 | } 21 | isErr(os.Remove(args[1])) 22 | } 23 | -------------------------------------------------------------------------------- /devboard/nucleo-l476rg/examples/shell/utils.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package main 6 | 7 | import ( 8 | "fmt" 9 | "os" 10 | ) 11 | 12 | const timeLayout = "2006-01-02 15:04:05 MST" 13 | 14 | func isErr(err error) bool { 15 | if err == nil { 16 | return false 17 | } 18 | fmt.Fprintf(os.Stderr, "\n%v\n", err) 19 | return true 20 | } 21 | -------------------------------------------------------------------------------- /devboard/nucleo-l476rg/examples/spi/main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // SPI loop test: wire PA6 and PA7 together. 6 | package main 7 | 8 | import ( 9 | "time" 10 | 11 | "github.com/embeddedgo/stm32/hal/gpio" 12 | "github.com/embeddedgo/stm32/hal/spi" 13 | "github.com/embeddedgo/stm32/hal/spi/spi1" 14 | 15 | _ "github.com/embeddedgo/stm32/devboard/nucleo-l476rg/board/system" 16 | ) 17 | 18 | func main() { 19 | // Allocate GPIO pins 20 | 21 | pa := gpio.PA() 22 | pa.EnableClock(true) 23 | sck := pa.Pin(5) 24 | miso := pa.Pin(6) 25 | mosi := pa.Pin(7) 26 | 27 | // Configure SPI pins 28 | 29 | sd := spi1.Driver() 30 | sd.UsePinMaster(sck, spi.SCK) 31 | sd.UsePinMaster(mosi, spi.MOSI) 32 | sd.UsePinMaster(miso, spi.MISO) 33 | 34 | // Configure and enable SPI 35 | 36 | sd.Setup(spi.Master|spi.SoftSS|spi.ISSHigh, 1e6) 37 | sd.SetWordSize(8) 38 | sd.Enable() 39 | 40 | var buf [40]byte 41 | for i := 0; ; i++ { 42 | sd.WriteStringRead("Hello world!", buf[:]) 43 | println(string(buf[:])) 44 | time.Sleep(time.Second) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /devboard/nucleo-l476rg/examples/swo-oocd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | TARGET=stm32l4x 4 | TRACECLKIN=80000000 5 | RESET='srst_only srst_nogate connect_assert_srst' 6 | 7 | . $(emgo env GOROOT)/../scripts/swo-oocd.sh 8 | -------------------------------------------------------------------------------- /devboard/nucleo-l496zg/board/buttons/button.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package buttons 6 | 7 | import ( 8 | "github.com/embeddedgo/stm32/hal/gpio" 9 | 10 | _ "github.com/embeddedgo/stm32/devboard/nucleo-l496zg/board/system" 11 | ) 12 | 13 | // Onboard buttons 14 | const ( 15 | B1 Button = 0x2D // PC13 16 | 17 | User = B1 18 | ) 19 | 20 | type Button uint8 21 | 22 | func prt(b Button) int { return int(b) >> 4 } 23 | func pin(b Button) uint { return uint(b) & 15 } 24 | 25 | func (b Button) Read() int { 26 | return int(gpio.P(prt(b)).Load()>>pin(b)) & 1 27 | } 28 | func (b Button) Pin() gpio.Pin { 29 | return gpio.P(prt(b)).Pin(int(pin(b))) 30 | } 31 | 32 | func init() { 33 | gpio.PC().EnableClock(true) 34 | B1.Pin().Setup(&gpio.Config{Mode: gpio.In}) 35 | } 36 | -------------------------------------------------------------------------------- /devboard/nucleo-l496zg/board/system/init.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package system 6 | 7 | import ( 8 | "github.com/embeddedgo/stm32/hal/system" 9 | "github.com/embeddedgo/stm32/hal/system/timer/rtcst" 10 | ) 11 | 12 | func init() { 13 | system.Setup80(0, 0) 14 | rtcst.Setup(rtcst.LSE, 1, 32768) 15 | } 16 | -------------------------------------------------------------------------------- /devboard/nucleo-l496zg/doc/board.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/embeddedgo/stm32/c31c3df4c80b62aa50b3b0b1d9b35b32a8e696a0/devboard/nucleo-l496zg/doc/board.jpg -------------------------------------------------------------------------------- /devboard/nucleo-l496zg/examples/blinky/main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // This example shows the basic usage of available LEDs and button. 6 | package main 7 | 8 | import ( 9 | "time" 10 | 11 | "github.com/embeddedgo/stm32/devboard/nucleo-l496zg/board/buttons" 12 | "github.com/embeddedgo/stm32/devboard/nucleo-l496zg/board/leds" 13 | ) 14 | 15 | func delay() { 16 | if buttons.User.Read() != 0 { 17 | time.Sleep(time.Second / 8) 18 | } else { 19 | time.Sleep(time.Second / 2) 20 | } 21 | } 22 | 23 | func main() { 24 | for { 25 | leds.Red.SetOff() 26 | leds.Green.SetOn() 27 | delay() 28 | 29 | leds.Green.SetOff() 30 | leds.Blue.SetOn() 31 | delay() 32 | 33 | leds.Blue.SetOff() 34 | leds.Red.SetOn() 35 | delay() 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /devboard/nucleo-l496zg/examples/build.cfg: -------------------------------------------------------------------------------- 1 | GOTARGET = stm32l4x6 2 | GOMEM = 0x20000000:320K 3 | GOTEXT = 0x08000000:1M 4 | GOSTRIPFN = 1 5 | -------------------------------------------------------------------------------- /devboard/nucleo-l496zg/examples/debug-oocd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | TARGET=stm32l4x 4 | RESET=srst_only 5 | 6 | . $(emgo env GOROOT)/../scripts/debug-oocd.sh 7 | -------------------------------------------------------------------------------- /devboard/nucleo-l496zg/examples/debug-stutil.sh: -------------------------------------------------------------------------------- 1 | ../../../../scripts/debug-stutil.sh -------------------------------------------------------------------------------- /devboard/nucleo-l496zg/examples/gctest/main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // This example forces the garbage collector to work hard and periodically 6 | // prints statistics of the memory allocator. 7 | package main 8 | 9 | import ( 10 | "math/rand" 11 | "runtime" 12 | 13 | _ "github.com/embeddedgo/stm32/devboard/nucleo-l496zg/board/system" 14 | ) 15 | 16 | func main() { 17 | runtime.GOMAXPROCS(2) 18 | 19 | c := make(chan []uint32, 3) 20 | 21 | go func() { 22 | for { 23 | c <- make([]uint32, rand.Intn(512)+1) 24 | } 25 | }() 26 | 27 | for i := 0; ; i++ { 28 | <-c 29 | if i&1023 == 0 { 30 | if i&32767 == 0 { 31 | printMemstatDescr() 32 | } 33 | printMemstat(i) 34 | } 35 | } 36 | } 37 | 38 | func printMemstatDescr() { 39 | print("#Recv Sys HeapSys StackSys GCSys OtherSys " + 40 | "HeapAlloc/HeapInuse StackInuse HeapIdle " + 41 | "MSpanInuse/MSpanSys MCacheInuse/MCacheSys\n") 42 | } 43 | 44 | var ms runtime.MemStats 45 | 46 | func printMemstat(i int) { 47 | runtime.ReadMemStats(&ms) 48 | print( 49 | i>>10, "K\t", 50 | ms.Sys, "\t", ms.HeapSys, "\t", ms.StackSys, "\t", ms.GCSys, "\t", 51 | ms.OtherSys, "\t\t", 52 | ms.HeapAlloc, " / ", ms.HeapInuse, "\t", ms.StackInuse, "\t", 53 | ms.HeapIdle, "\t\t", 54 | ms.MSpanInuse, " / ", ms.MSpanSys, "\t", ms.MCacheInuse, " / ", 55 | ms.MCacheSys, 56 | "\n", 57 | ) 58 | } 59 | -------------------------------------------------------------------------------- /devboard/nucleo-l496zg/examples/load-oocd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | TARGET=stm32l4x 4 | TRACECLKIN=80000000 5 | RESET='srst_only srst_nogate connect_assert_srst' 6 | 7 | . $(emgo env GOROOT)/../scripts/load-oocd.sh 8 | -------------------------------------------------------------------------------- /devboard/nucleo-l496zg/examples/load-stutil.sh: -------------------------------------------------------------------------------- 1 | ../../../../scripts/load-stutil.sh -------------------------------------------------------------------------------- /devboard/nucleo-l496zg/examples/spi/main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // SPI loop test: wire PA6 and PA7 together. 6 | package main 7 | 8 | import ( 9 | "time" 10 | 11 | "github.com/embeddedgo/stm32/hal/gpio" 12 | "github.com/embeddedgo/stm32/hal/spi" 13 | "github.com/embeddedgo/stm32/hal/spi/spi1" 14 | 15 | _ "github.com/embeddedgo/stm32/devboard/nucleo-l496zg/board/system" 16 | ) 17 | 18 | func main() { 19 | // Allocate GPIO pins 20 | 21 | pa := gpio.PA() 22 | pa.EnableClock(true) 23 | sck := pa.Pin(5) 24 | miso := pa.Pin(6) 25 | mosi := pa.Pin(7) 26 | 27 | // Configure SPI pins 28 | 29 | sd := spi1.Driver() 30 | sd.UsePinMaster(sck, spi.SCK) 31 | sd.UsePinMaster(mosi, spi.MOSI) 32 | sd.UsePinMaster(miso, spi.MISO) 33 | 34 | // Configure and enable SPI 35 | 36 | sd.Setup(spi.Master|spi.SoftSS|spi.ISSHigh, 1e6) 37 | sd.SetWordSize(8) 38 | sd.Enable() 39 | 40 | var buf [40]byte 41 | for i := 0; ; i++ { 42 | sd.WriteStringRead("Hello world!", buf[:]) 43 | println(string(buf[:])) 44 | time.Sleep(time.Second) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /devboard/nucleo-l496zg/examples/swo-oocd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | TARGET=stm32l4x 4 | TRACECLKIN=80000000 5 | RESET=srst_only 6 | 7 | . $(emgo env GOROOT)/../scripts/swo-oocd.sh 8 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/embeddedgo/stm32 2 | 3 | go 1.22 4 | 5 | require ( 6 | github.com/embeddedgo/display v1.2.1 7 | github.com/embeddedgo/espat v0.2.3 8 | github.com/embeddedgo/fs v0.1.3 9 | github.com/embeddedgo/onewire v0.0.2 10 | ) 11 | 12 | //GOTARGET=stm32h7x3 13 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/embeddedgo/display v1.2.1 h1:ZbUfDWNhNBwC+HgEEUw/WnnsqsXsPrctJtpK5hjtECY= 2 | github.com/embeddedgo/display v1.2.1/go.mod h1:0sxxBoklqMbA1uBqEAg8Plntmwvt7cNsgxaf7UaS4yw= 3 | github.com/embeddedgo/espat v0.2.3 h1:mHYd9b5WDOPwIPSj1ES/yPIDZ9gtv4Lc7ULrIfDCO18= 4 | github.com/embeddedgo/espat v0.2.3/go.mod h1:ymbAnBgrRht/G2FEAEBo20i8miBxHR9qdTpuQEJZxiw= 5 | github.com/embeddedgo/fs v0.1.3 h1:uKp26pruDzT/qi9K8HcV41JBdAgDTGIIagCZQ15GRzs= 6 | github.com/embeddedgo/fs v0.1.3/go.mod h1:iQRMLUL0YeL5Ou2ILYTlspw32A0BeoXs7O2fuTZoS1M= 7 | github.com/embeddedgo/onewire v0.0.2 h1:QbNgcjsQEtOs5MSU9gaTB82TULTMsXxWI3YbHe7R+Q4= 8 | github.com/embeddedgo/onewire v0.0.2/go.mod h1:mE7/0ViDHif2lcs55jkcGEzTXNGNFBfyWfB4K5eZHOU= 9 | -------------------------------------------------------------------------------- /hal/dma/align_cache.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build stm32h7x3 6 | 7 | package dma 8 | 9 | const ( 10 | cacheMaint = true 11 | cacheLineSize = 32 // Cortex-M7 12 | ) 13 | -------------------------------------------------------------------------------- /hal/dma/align_nocache.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build !stm32h7x3 6 | 7 | package dma 8 | 9 | const ( 10 | cacheMaint = false 11 | cacheLineSize = 1 12 | ) 13 | -------------------------------------------------------------------------------- /hal/dma/allocchan.go: -------------------------------------------------------------------------------- 1 | // Copyright 2025 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build stm32h7x3 6 | 7 | package dma 8 | 9 | import "sync" 10 | 11 | var chanAlloc = struct { 12 | mask [2]uint8 13 | mx sync.Mutex 14 | }{mask: [2]uint8{0xff, 0xff}} 15 | 16 | // AllocChannel allocates a free channel (stream) in the controller. It also 17 | // enables clock to the controller if it's the first channel allocated in the 18 | // controller. AllocChannel returns an invalid channel if there is no free 19 | // channel to be allocated. Use Channel.Free to free 20 | // an unused channel. 21 | func (d *Controller) AllocChannel() (ch Channel) { 22 | sn := 0 23 | cam := &chanAlloc.mask[dnum(d)] 24 | chanAlloc.mx.Lock() 25 | if *cam != 0 { 26 | mask := uint8(1) 27 | if *cam == 0xff { 28 | d.EnableClock(true) // first channel 29 | *cam = 0xfe 30 | } else { 31 | // Find a free channel. 32 | for *cam&mask == 0 { 33 | mask <<= 1 34 | sn++ 35 | } 36 | *cam &^= mask 37 | } 38 | ch = d.Channel(sn, 0) 39 | } 40 | chanAlloc.mx.Unlock() 41 | return 42 | } 43 | 44 | // Free 45 | func (c Channel) Free() { 46 | mask := uint8(1 << csnum(c)) 47 | d := cctrl(c) 48 | cam := &chanAlloc.mask[dnum(d)] 49 | chanAlloc.mx.Lock() 50 | *cam |= mask 51 | if *cam == 0xff { 52 | d.DisableClock() // disable unused controller 53 | } 54 | chanAlloc.mx.Unlock() 55 | } 56 | -------------------------------------------------------------------------------- /hal/dma/dmairq/dmairq.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package dmairq 6 | 7 | import ( 8 | "embedded/rtos" 9 | 10 | "github.com/embeddedgo/stm32/hal/dma" 11 | ) 12 | 13 | func SetISR(c dma.Channel, isr func()) { setISR(c, isr) } 14 | func SetPrio(prio int) { enableIRQs(prio) } 15 | 16 | func init() { enableIRQs(rtos.IntPrioLow) } 17 | -------------------------------------------------------------------------------- /hal/dma/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package dma provides uniform interface to the DMA controllers. 6 | package dma 7 | -------------------------------------------------------------------------------- /hal/dma/instances1.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build ignore 6 | 7 | package dma 8 | 9 | import ( 10 | "unsafe" 11 | 12 | "stm32/hal/raw/mmap" 13 | ) 14 | 15 | func dnum(d *Controller) int { return 0 } 16 | 17 | func controller(n int) *Controller { 18 | if uint(n) != 1 { 19 | panic("bad DMA number") 20 | } 21 | return (*Controller)(unsafe.Pointer(mmap.DMA1_BASE)) 22 | } 23 | -------------------------------------------------------------------------------- /hal/dma/instances2.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build stm32f215 || stm32f303 || stm32f407 || stm32f7x6 || stm32h7x3 || stm32l4x6 6 | 7 | package dma 8 | 9 | import ( 10 | "unsafe" 11 | 12 | "github.com/embeddedgo/stm32/p/mmap" 13 | ) 14 | 15 | func dnum(d *Controller) int { 16 | return int((uintptr(unsafe.Pointer(d)) - mmap.DMA1_BASE) / 0x400) 17 | } 18 | 19 | func controller(n int) *Controller { 20 | n-- 21 | if uint(n) > 1 { 22 | panic("bad DMA number") 23 | } 24 | return (*Controller)(unsafe.Pointer(mmap.DMA1_BASE + uintptr(n)*0x400)) 25 | } 26 | -------------------------------------------------------------------------------- /hal/dma/rcc-f0.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build ignore 6 | 7 | package dma 8 | 9 | import ( 10 | "github.com/embeddedgo/stm32/hal/internal" 11 | "github.com/embeddedgo/stm32/p/rcc" 12 | ) 13 | 14 | func (d *Controller) enableClock(_ bool) { 15 | internal.ExclusiveStoreBits(&rcc.RCC().AHBENR.U32, uint32(1)< 2.7 V) 19 | _ = 0 // 25 MHz (CL = 50 pF, VDD > 2.7 V) 20 | high = 1 // 50 MHz (CL = 40 pF, VDD > 2.7 V) 21 | veryHigh = 2 // 100 MHz (CL = 30 pF, VDD > 2.7 V) 22 | ) 23 | 24 | func enreg() *mmio.R32[rcc.AHB1ENR] { return &rcc.RCC().AHB1ENR } 25 | func rstreg() *mmio.R32[rcc.AHB1RSTR] { return &rcc.RCC().AHB1RSTR } 26 | 27 | func lpenaclk(pnum uint) { 28 | internal.ExclusiveStoreBits(&rcc.RCC().AHB1LPENR, rcc.GPIOALPEN< 2.7 V) 19 | _ = 0 // 60 MHz (CL = 50 pF, VDD > 2.7 V) 20 | high = 1 // 110 MHz (CL = 30 pF, VDD > 2.7 V) 21 | veryHigh = 2 // 133 MHz (CL = 30 pF, VDD > 2.7 V) 22 | ) 23 | 24 | func enreg() *mmio.R32[rcc.AHB4ENR] { return &rcc.RCC().AHB4ENR } 25 | func rstreg() *mmio.R32[rcc.AHB4RSTR] { return &rcc.RCC().AHB4RSTR } 26 | 27 | func lpenaclk(pnum uint) { 28 | internal.ExclusiveStoreBits(&rcc.RCC().AHB4LPENR, rcc.GPIOALPEN< 2.7 V) 16 | low = -1 // 2 MHz (CL = 50 pF, VDD > 2.7 V) 17 | _ = 0 // 10 MHz (CL = 50 pF, VDD > 2.7 V) 18 | high = 1 // 50 MHz (CL = 50 pF, VDD > 2.7 V) 19 | veryHigh = 1 // Not supported. 20 | ) 21 | 22 | func enreg() *rcc.RAHBENR { return &rcc.RCC().AHBENR } 23 | func rstreg() *rcc.RAHBRSTR { return &rcc.RCC().AHBRSTR } 24 | 25 | func lpenaclk(pnum uint) { 26 | internal.AtomicSetBits(&rcc.RCC().AHBLPENR.U32, uint32(rcc.GPIOALPEN<>2)&(len(locks)-1)] 16 | mt.Lock() 17 | r.StoreBits(mask, bits) 18 | mt.Unlock() 19 | } 20 | -------------------------------------------------------------------------------- /hal/internal/utils.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package internal 6 | 7 | import "unsafe" 8 | 9 | func BoolUint32(x bool) uint32 { 10 | return uint32(uint8(*(*uint8)(unsafe.Pointer(&x)))) 11 | } 12 | -------------------------------------------------------------------------------- /hal/mem/nocache/alloc_nocache.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build stm32h7x3 6 | 7 | package nocache 8 | 9 | import ( 10 | "embedded/arch/cortexm/mpu/mpu7" 11 | "embedded/rtos" 12 | "runtime" 13 | "sync/atomic" 14 | "unsafe" 15 | ) 16 | 17 | // AHBSRAM(1+2) in STM32H743 18 | const ( 19 | base uintptr = 0x3000_0000 20 | logSiz = 18 // log2(256 * 1024) 21 | end = base + 1< end { 44 | panic("out of noncacheable RAM") 45 | } 46 | if atomic.CompareAndSwapUintptr(&free, oldFree, ptr+size) { 47 | return unsafe.Pointer(ptr) 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /hal/mem/nocache/alloc_normal.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build !stm32h7x3 6 | 7 | package nocache 8 | 9 | import "unsafe" 10 | 11 | func alloc(align, size uintptr) unsafe.Pointer { 12 | mask := align - 1 13 | if mask < 3 { 14 | mask = 3 15 | } 16 | arr := make([]uint32, (size+mask)/4) 17 | p := unsafe.Pointer(&arr[0]) 18 | o := -uintptr(p) & mask 19 | return unsafe.Add(p, o) 20 | } 21 | -------------------------------------------------------------------------------- /hal/spi/bits.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package spi 6 | 7 | // CR1 8 | const ( 9 | cpha = 1 << 0 10 | cpol = 1 << 1 11 | mstr = 1 << 2 12 | br = 7 << 3 13 | brn = 3 14 | spe = 1 << 6 15 | lsbfirst = 1 << 7 16 | ssi = 1 << 8 17 | ssm = 1 << 9 18 | rxonly = 1 << 10 19 | dff = 1 << 11 // SPIv1 20 | crcl = 1 << 11 // SPIv2 21 | crcnext = 1 << 12 22 | crcen = 1 << 13 23 | bidioe = 1 << 14 24 | bidimode = 1 << 15 25 | ) 26 | 27 | // CR2 28 | const ( 29 | rxdmaen = 1 << 0 30 | txdmaen = 1 << 1 31 | ssoe = 1 << 2 32 | nssp = 1 << 3 // SPIv2 33 | frf = 1 << 4 34 | errie = 1 << 5 35 | errien = 5 36 | rxneie = 1 << 6 37 | txeie = 1 << 7 38 | ds = 15 << 8 // SPIv2 39 | dsn = 8 // SPIv2 40 | frxth = 1 << 12 // SPIv2 41 | ldmarx = 1 << 13 // SPIv2 42 | ldmatx = 1 << 14 // SPIv2 43 | ) 44 | 45 | // SR 46 | const ( 47 | rxne = 1 << 0 48 | txe = 1 << 1 49 | chside = 1 << 2 // SPIv1 50 | udr = 1 << 3 // SPIv1 51 | crcerr = 1 << 4 52 | modf = 1 << 5 53 | ovr = 1 << 6 54 | bsy = 1 << 7 55 | tifrfe = 1 << 8 56 | frlvl = 3 << 9 // SPIv2 57 | ftlvl = 3 << 11 // SPIv2 58 | ) 59 | -------------------------------------------------------------------------------- /hal/spi/doc.go: -------------------------------------------------------------------------------- 1 | // Package spi provides unified way to configure/use SPI peripherals. 2 | // It also provides a driver for synchronous I/O. 3 | package spi 4 | -------------------------------------------------------------------------------- /hal/spi/f0f3l4.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build stm32l4x6 6 | 7 | package spi 8 | 9 | func (p *Periph) setWordSize(size int) { 10 | dsfifo := uint32(size-1) & 15 << dsn 11 | if size <= 8 { 12 | dsfifo |= frxth 13 | } 14 | p.cr2.StoreBits(frxth|ds, dsfifo) 15 | } 16 | 17 | func (p *Periph) wordSize() int { 18 | return int(p.cr2.LoadBits(ds))>>dsn&15 + 1 19 | } 20 | -------------------------------------------------------------------------------- /hal/spi/f1f2f4f7l1.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build stm32f215 stm32f407 6 | 7 | package spi 8 | 9 | func (p *Periph) setWordSize(size int) { 10 | if size == 16 { 11 | p.cr1.SetBits(dff) 12 | } else { 13 | p.cr1.ClearBits(dff) 14 | } 15 | } 16 | 17 | func (p *Periph) wordSize() int { 18 | if p.cr1.LoadBits(dff) != 0 { 19 | return 16 20 | } 21 | return 8 22 | } 23 | -------------------------------------------------------------------------------- /hal/spi/f2f4.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build stm32f215 stm32f407 stm32f412 6 | 7 | package spi 8 | 9 | import ( 10 | "unsafe" 11 | 12 | "github.com/embeddedgo/stm32/hal/gpio" 13 | "github.com/embeddedgo/stm32/p/bus" 14 | "github.com/embeddedgo/stm32/p/mmap" 15 | ) 16 | 17 | func busForAddr(p *Periph) bus.Bus { 18 | switch uintptr(unsafe.Pointer(p)) { 19 | default: 20 | return bus.APB2 21 | case mmap.SPI2_BASE, mmap.SPI3_BASE: 22 | return bus.APB1 23 | } 24 | } 25 | 26 | func altFunc(p *Periph, pin gpio.Pin) gpio.AltFunc { 27 | switch p { 28 | case SPI3(): 29 | if pin.Port() == gpio.PD() { 30 | return gpio.AF5 31 | } 32 | return gpio.AF6 33 | default: // SPI1, SPI2, SPI4, SPI5, SPI6 34 | return gpio.AF5 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /hal/spi/instances3.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build stm32f215 stm32l4x6 6 | 7 | package spi 8 | 9 | import ( 10 | "unsafe" 11 | 12 | "github.com/embeddedgo/stm32/p/mmap" 13 | ) 14 | 15 | func SPI1() *Periph { return (*Periph)(unsafe.Pointer(mmap.SPI1_BASE)) } 16 | func SPI2() *Periph { return (*Periph)(unsafe.Pointer(mmap.SPI2_BASE)) } 17 | func SPI3() *Periph { return (*Periph)(unsafe.Pointer(mmap.SPI3_BASE)) } 18 | -------------------------------------------------------------------------------- /hal/spi/instances4.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build stm32g471xx 6 | 7 | package spi 8 | 9 | import ( 10 | "unsafe" 11 | 12 | "github.com/embeddedgo/stm32/p/mmap" 13 | ) 14 | 15 | func SPI1() *Periph { return (*Periph)(unsafe.Pointer(mmap.SPI1_BASE)) } 16 | func SPI2() *Periph { return (*Periph)(unsafe.Pointer(mmap.SPI2_BASE)) } 17 | func SPI3() *Periph { return (*Periph)(unsafe.Pointer(mmap.SPI3_BASE)) } 18 | func SPI4() *Periph { return (*Periph)(unsafe.Pointer(mmap.SPI4_BASE)) } 19 | -------------------------------------------------------------------------------- /hal/spi/instances6.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build stm32f407 6 | 7 | package spi 8 | 9 | import ( 10 | "unsafe" 11 | 12 | "github.com/embeddedgo/stm32/p/mmap" 13 | ) 14 | 15 | func SPI1() *Periph { return (*Periph)(unsafe.Pointer(mmap.SPI1_BASE)) } 16 | func SPI2() *Periph { return (*Periph)(unsafe.Pointer(mmap.SPI2_BASE)) } 17 | func SPI3() *Periph { return (*Periph)(unsafe.Pointer(mmap.SPI3_BASE)) } 18 | func SPI4() *Periph { return (*Periph)(unsafe.Pointer(mmap.SPI4_BASE)) } 19 | func SPI5() *Periph { return (*Periph)(unsafe.Pointer(mmap.SPI5_BASE)) } 20 | func SPI6() *Periph { return (*Periph)(unsafe.Pointer(mmap.SPI6_BASE)) } 21 | -------------------------------------------------------------------------------- /hal/spi/l4.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build stm32l4x6 6 | 7 | package spi 8 | 9 | import ( 10 | "unsafe" 11 | 12 | "github.com/embeddedgo/stm32/hal/gpio" 13 | "github.com/embeddedgo/stm32/p/bus" 14 | "github.com/embeddedgo/stm32/p/mmap" 15 | ) 16 | 17 | func busForAddr(p *Periph) bus.Bus { 18 | switch uintptr(unsafe.Pointer(p)) { 19 | default: 20 | return bus.APB1 21 | case mmap.SPI1_BASE: 22 | return bus.APB2 23 | } 24 | } 25 | 26 | func altFunc(p *Periph, pin gpio.Pin) gpio.AltFunc { 27 | switch p { 28 | case SPI1(): 29 | return gpio.AF5 30 | case SPI2(): 31 | if pin == gpio.PA().Pin(9) || pin == gpio.PC().Pin(1) { 32 | return gpio.AF3 33 | } 34 | return gpio.AF5 35 | default: // SPI3 36 | return gpio.AF6 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /hal/spi/spi1/driver.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package spi1 6 | 7 | import "github.com/embeddedgo/stm32/hal/spi" 8 | 9 | var driver *spi.Driver 10 | 11 | // Driver returns ready to use driver for SPI1 peripheral. 12 | func Driver() *spi.Driver { 13 | if driver == nil { 14 | setupDriver() 15 | } 16 | return driver 17 | } 18 | -------------------------------------------------------------------------------- /hal/spi/spi1/f2f4.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build stm32f215 stm32f407 6 | 7 | package spi1 8 | 9 | import ( 10 | "embedded/rtos" 11 | _ "unsafe" 12 | 13 | "github.com/embeddedgo/stm32/hal/dma" 14 | "github.com/embeddedgo/stm32/hal/irq" 15 | "github.com/embeddedgo/stm32/hal/spi" 16 | ) 17 | 18 | func setupDriver() { 19 | d := dma.DMA(2) 20 | d.EnableClock(true) 21 | driver = spi.NewDriver(spi.SPI1(), d.Channel(0, 3), d.Channel(3, 3)) 22 | irq.SPI1.Enable(rtos.IntPrioLow, 0) 23 | irq.DMA2_STREAM0.Enable(rtos.IntPrioLow, 0) 24 | irq.DMA2_STREAM3.Enable(rtos.IntPrioLow, 0) 25 | } 26 | 27 | //go:interrupthandler 28 | func _SPI1_Handler() { driver.ISR() } 29 | 30 | //go:interrupthandler 31 | func _DMA2_STREAM0_Handler() { driver.DMAISR(driver.RxDMA()) } 32 | 33 | //go:interrupthandler 34 | func _DMA2_STREAM3_Handler() { driver.DMAISR(driver.TxDMA()) } 35 | 36 | //go:linkname _SPI1_Handler IRQ35_Handler 37 | //go:linkname _DMA2_STREAM0_Handler IRQ56_Handler 38 | //go:linkname _DMA2_STREAM3_Handler IRQ59_Handler 39 | -------------------------------------------------------------------------------- /hal/spi/spi1/l4.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build stm32l4x6 6 | 7 | package spi1 8 | 9 | import ( 10 | "embedded/rtos" 11 | _ "unsafe" 12 | 13 | "github.com/embeddedgo/stm32/hal/dma" 14 | "github.com/embeddedgo/stm32/hal/irq" 15 | "github.com/embeddedgo/stm32/hal/spi" 16 | ) 17 | 18 | func setupDriver() { 19 | d := dma.DMA(1) 20 | d.EnableClock(true) 21 | driver = spi.NewDriver(spi.SPI1(), d.Channel(2, 1), d.Channel(3, 1)) 22 | irq.SPI1.Enable(rtos.IntPrioLow, 0) 23 | irq.DMA1_CH2.Enable(rtos.IntPrioLow, 0) 24 | irq.DMA1_CH3.Enable(rtos.IntPrioLow, 0) 25 | } 26 | 27 | //go:interrupthandler 28 | func _SPI1_Handler() { driver.ISR() } 29 | 30 | //go:interrupthandler 31 | func _DMA1_CH2_Handler() { driver.DMAISR(driver.RxDMA()) } 32 | 33 | //go:interrupthandler 34 | func _DMA1_CH3_Handler() { driver.DMAISR(driver.TxDMA()) } 35 | 36 | //go:linkname _SPI1_Handler IRQ35_Handler 37 | //go:linkname _DMA1_CH2_Handler IRQ12_Handler 38 | //go:linkname _DMA1_CH3_Handler IRQ13_Handler 39 | -------------------------------------------------------------------------------- /hal/spi/spi2/driver.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package spi2 6 | 7 | import "github.com/embeddedgo/stm32/hal/spi" 8 | 9 | var driver *spi.Driver 10 | 11 | // Driver returns ready to use driver for SPI2 peripheral. 12 | func Driver() *spi.Driver { 13 | if driver == nil { 14 | setupDriver() 15 | } 16 | return driver 17 | } 18 | -------------------------------------------------------------------------------- /hal/spi/spi2/f2f4.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build stm32f215 stm32f407 6 | 7 | package spi2 8 | 9 | import ( 10 | "embedded/rtos" 11 | _ "unsafe" 12 | 13 | "github.com/embeddedgo/stm32/hal/dma" 14 | "github.com/embeddedgo/stm32/hal/irq" 15 | "github.com/embeddedgo/stm32/hal/spi" 16 | ) 17 | 18 | func setupDriver() { 19 | d := dma.DMA(1) 20 | d.EnableClock(true) 21 | driver = spi.NewDriver(spi.SPI2(), d.Channel(3, 0), d.Channel(4, 0)) 22 | irq.SPI2.Enable(rtos.IntPrioLow, 0) 23 | irq.DMA1_STREAM3.Enable(rtos.IntPrioLow, 0) 24 | irq.DMA1_STREAM4.Enable(rtos.IntPrioLow, 0) 25 | } 26 | 27 | //go:interrupthandler 28 | func _SPI2_Handler() { driver.ISR() } 29 | 30 | //go:interrupthandler 31 | func _DMA1_STREAM3_Handler() { driver.DMAISR(driver.RxDMA()) } 32 | 33 | //go:interrupthandler 34 | func _DMA1_STREAM4_Handler() { driver.DMAISR(driver.TxDMA()) } 35 | 36 | //go:linkname _SPI2_Handler IRQ36_Handler 37 | //go:linkname _DMA1_STREAM3_Handler IRQ14_Handler 38 | //go:linkname _DMA1_STREAM4_Handler IRQ15_Handler 39 | -------------------------------------------------------------------------------- /hal/spi/spi2/l4.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build stm32l4x6 6 | 7 | package spi2 8 | 9 | import ( 10 | "embedded/rtos" 11 | _ "unsafe" 12 | 13 | "github.com/embeddedgo/stm32/hal/dma" 14 | "github.com/embeddedgo/stm32/hal/irq" 15 | "github.com/embeddedgo/stm32/hal/spi" 16 | ) 17 | 18 | func setupDriver() { 19 | d := dma.DMA(1) 20 | d.EnableClock(true) 21 | driver = spi.NewDriver(spi.SPI2(), d.Channel(4, 1), d.Channel(5, 1)) 22 | irq.SPI2.Enable(rtos.IntPrioLow, 0) 23 | irq.DMA1_CH4.Enable(rtos.IntPrioLow, 0) 24 | irq.DMA1_CH5.Enable(rtos.IntPrioLow, 0) 25 | } 26 | 27 | //go:interrupthandler 28 | func _SPI2_Handler() { driver.ISR() } 29 | 30 | //go:interrupthandler 31 | func _DMA1_CH4_Handler() { driver.DMAISR(driver.RxDMA()) } 32 | 33 | //go:interrupthandler 34 | func _DMA1_CH5_Handler() { driver.DMAISR(driver.TxDMA()) } 35 | 36 | //go:linkname _SPI2_Handler IRQ36_Handler 37 | //go:linkname _DMA1_CH4_Handler IRQ14_Handler 38 | //go:linkname _DMA1_CH5_Handler IRQ15_Handler 39 | -------------------------------------------------------------------------------- /hal/spi/spi3/driver.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package spi3 6 | 7 | import "github.com/embeddedgo/stm32/hal/spi" 8 | 9 | var driver *spi.Driver 10 | 11 | // Driver returns ready to use driver for SPI3 peripheral. 12 | func Driver() *spi.Driver { 13 | if driver == nil { 14 | setupDriver() 15 | } 16 | return driver 17 | } 18 | -------------------------------------------------------------------------------- /hal/spi/spi3/f2f4.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build stm32f215 stm32f407 6 | 7 | package spi3 8 | 9 | import ( 10 | "embedded/rtos" 11 | _ "unsafe" 12 | 13 | "github.com/embeddedgo/stm32/hal/dma" 14 | "github.com/embeddedgo/stm32/hal/irq" 15 | "github.com/embeddedgo/stm32/hal/spi" 16 | ) 17 | 18 | func setupDriver() { 19 | d := dma.DMA(1) 20 | d.EnableClock(true) 21 | driver = spi.NewDriver(spi.SPI3(), d.Channel(0, 0), d.Channel(7, 0)) 22 | irq.SPI3.Enable(rtos.IntPrioLow, 0) 23 | irq.DMA1_Stream0.Enable(rtos.IntPrioLow, 0) 24 | irq.DMA1_Stream7.Enable(rtos.IntPrioLow, 0) 25 | } 26 | 27 | //go:interrupthandler 28 | func _SPI3_Handler() { driver.ISR() } 29 | 30 | //go:interrupthandler 31 | func _DMA1_Stream0_Handler() { driver.DMAISR(driver.RxDMA()) } 32 | 33 | //go:interrupthandler 34 | func _DMA1_Stream7_Handler() { driver.DMAISR(driver.TxDMA()) } 35 | 36 | //go:linkname _SPI3_Handler IRQ51_Handler 37 | //go:linkname _DMA1_Stream0_Handler IRQ11_Handler 38 | //go:linkname _DMA1_Stream7_Handler IRQ47_Handler 39 | -------------------------------------------------------------------------------- /hal/spi/usepin.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package spi 6 | 7 | import "github.com/embeddedgo/stm32/hal/gpio" 8 | 9 | type Signal uint8 10 | 11 | const ( 12 | SCK Signal = iota 13 | MOSI 14 | MISO 15 | NSS 16 | ) 17 | 18 | // UsePinMaster is a helper function that can be used to configure GPIO pins as 19 | // required by SPI master device. Only certain pins can be used (see datasheet). 20 | func (d *Driver) UsePinMaster(pin gpio.Pin, sig Signal) { 21 | var cfg gpio.Config 22 | if sig == MISO { 23 | cfg.Mode = gpio.AltIn 24 | } else { 25 | if sig == NSS { 26 | cfg.Pull = gpio.PullUp 27 | } 28 | cfg.Mode = gpio.Alt 29 | cfg.Speed = gpio.VeryHigh 30 | } 31 | pin.Setup(&cfg) 32 | pin.SetAltFunc(altFunc(d.p, pin)) 33 | } 34 | 35 | // UsePinSlave is a helper function that can be used to configure GPIO pins as 36 | // required by SPI slave device. Only certain pins can be used (see datasheet). 37 | func (d *Driver) UsePinSlave(pin gpio.Pin, sig Signal) { 38 | var cfg gpio.Config 39 | if sig == MISO { 40 | cfg.Mode = gpio.Alt 41 | cfg.Speed = gpio.VeryHigh 42 | } else { 43 | cfg.Mode = gpio.AltIn 44 | } 45 | pin.Setup(&cfg) 46 | pin.SetAltFunc(altFunc(d.p, pin)) 47 | } 48 | -------------------------------------------------------------------------------- /hal/system/clk_stm32f215.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build stm32f215 6 | 7 | package system 8 | 9 | const HSIClk = 16e6 // Hz 10 | 11 | const ( 12 | maxAPB1Clk = 30e6 // Hz 13 | maxAPB2Clk = 60e6 // Hz 14 | ) 15 | -------------------------------------------------------------------------------- /hal/system/clk_stm32f407.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build stm32f407 6 | 7 | package system 8 | 9 | const HSIClk = 16e6 // Hz 10 | 11 | const ( 12 | maxAPB1Clk = 42e6 // Hz 13 | maxAPB2Clk = 84e6 // Hz 14 | ) 15 | -------------------------------------------------------------------------------- /hal/system/clk_stm32f412.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build stm32f412 6 | 7 | package system 8 | 9 | const HSIClk = 16e6 // Hz 10 | 11 | const ( 12 | maxAPB1Clk = 50e6 // Hz 13 | maxAPB2Clk = 100e6 // Hz 14 | ) 15 | -------------------------------------------------------------------------------- /hal/system/clk_stm32h7x3.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build stm32h7x3 6 | 7 | package system 8 | 9 | const ( 10 | HSIClk = 64e6 // Hz 11 | CSIClk = 4e6 // Hz 12 | ) 13 | 14 | const ( 15 | // VOS0 16 | maxSysClk0 = 480e6 // Hz 17 | maxAHBClk0 = 240e6 // Hz 18 | maxAPBClk0 = 120e6 // Hz 19 | 20 | // VOS1 21 | maxSysClk1 = 400e6 // Hz 22 | maxAHBClk1 = 200e6 // Hz 23 | maxAPBClk1 = 100e6 // Hz 24 | 25 | // VOS2 26 | maxSysClk2 = 300e6 // Hz 27 | maxAHBClk2 = 150e6 // Hz 28 | maxAPBClk2 = 75e6 // Hz 29 | 30 | // VOS3 31 | maxSysClk3 = 200e6 // Hz 32 | maxAHBClk3 = 100e6 // Hz 33 | maxAPBClk3 = 50e6 // Hz 34 | ) 35 | -------------------------------------------------------------------------------- /hal/system/clk_stm32l4x6.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build stm32l4x6 6 | 7 | package system 8 | 9 | const HSIClk = 16e6 // Hz 10 | 11 | const ( 12 | maxAPB1Clk = 80e6 // Hz 13 | maxAPB2Clk = 80e6 // Hz 14 | ) 15 | -------------------------------------------------------------------------------- /hal/system/timer/rtcst/asm.s: -------------------------------------------------------------------------------- 1 | // +build noos 2 | 3 | #include "textflag.h" 4 | 5 | #define ICSR_ADDR 0xE000ED04 6 | #define ICSR_PENDSVSET (1<<28) 7 | 8 | TEXT ·schedule(SB),NOSPLIT|NOFRAME,$0-0 9 | MOVW $ICSR_ADDR, R0 10 | MOVW $ICSR_PENDSVSET, R1 11 | MOVW R1, (R0) 12 | SEV // see ARM Errata 563915 13 | RET 14 | -------------------------------------------------------------------------------- /hal/system/timer/rtcst/monoday_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package rtcst 6 | 7 | import ( 8 | "testing" 9 | "time" 10 | ) 11 | 12 | func TestMonoday(t *testing.T) { 13 | date := time.Date(2000, 3, 1, 0, 0, 0, 0, time.UTC) 14 | start := date.Unix() 15 | for i := 0; i <= 100*365; i++ { 16 | y, m, d := date.Date() 17 | d1 := (date.Unix() - start) / (24 * 60 * 60) 18 | d2 := int64(monoday(uint(y-2000), uint(m), uint(d))) 19 | if d1 != d2 { 20 | t.Errorf("%v: %d != %d", date, d1, d2) 21 | } 22 | date = date.Add(24 * time.Hour) 23 | } 24 | } 25 | 26 | func TestDayofmonth(t *testing.T) { 27 | date := time.Date(2000, 3, 1, 0, 0, 0, 0, time.UTC) 28 | start := date.Unix() 29 | for i := 0; i < 100*365+24; i++ { 30 | d1 := uint(date.Day()) 31 | d2 := dayofmonth(uint(date.Unix()-start) / (24 * 60 * 60)) 32 | if d1 != d2 { 33 | t.Errorf("%v: %d != %d", date, d1, d2) 34 | } 35 | date = date.Add(24 * time.Hour) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /hal/system/timer/systick/systick.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Michal Derkacz. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package systick allows to setup ARMv7-M SysTick timer as ticking system timer. 6 | package systick 7 | 8 | import ( 9 | "embedded/arch/cortexm/systim" 10 | "embedded/rtos" 11 | "runtime" 12 | ) 13 | 14 | // Setup setups the SysTick as system timer. This is a ticking timer. Use tickless 15 | // timer (eg. RTC based) if available. SysTick runs the thread scheduler every 16 | // periodns nanoseconds. 17 | func Setup(periodns int64) { 18 | runtime.LockOSThread() 19 | pl, _ := rtos.SetPrivLevel(0) 20 | systimSetup(periodns) 21 | rtos.SetPrivLevel(pl) 22 | runtime.UnlockOSThread() 23 | rtos.SetSystemTimer(systim.Nanotime, nil) 24 | } 25 | -------------------------------------------------------------------------------- /hal/system/timer/systick/systim_h7.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build stm32h7x3 6 | 7 | package systick 8 | 9 | import ( 10 | "embedded/arch/cortexm/systim" 11 | 12 | "github.com/embeddedgo/stm32/p/bus" 13 | ) 14 | 15 | func systimSetup(periodns int64) { 16 | systim.Setup(periodns, bus.Core.Clock()/8, true) 17 | } 18 | -------------------------------------------------------------------------------- /hal/system/timer/systick/systim_noh7.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !stm32h7x3 6 | 7 | package systick 8 | 9 | import ( 10 | "embedded/arch/cortexm/systim" 11 | 12 | "github.com/embeddedgo/stm32/p/bus" 13 | ) 14 | 15 | func systimSetup(periodns int64) { 16 | systim.Setup(periodns, bus.AHB1.Clock()/8, true) 17 | } 18 | -------------------------------------------------------------------------------- /hal/usart/doc.go: -------------------------------------------------------------------------------- 1 | // Package spi provides unified way to configure/use USART peripherals. 2 | // It also provides a driver for synchronous I/O. 3 | package usart 4 | -------------------------------------------------------------------------------- /hal/usart/instances6.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build stm32l4x6 6 | 7 | package usart 8 | 9 | import ( 10 | "unsafe" 11 | 12 | "github.com/embeddedgo/stm32/p/mmap" 13 | ) 14 | 15 | func USART1() *Periph { return (*Periph)(unsafe.Pointer(mmap.USART1_BASE)) } 16 | func USART2() *Periph { return (*Periph)(unsafe.Pointer(mmap.USART2_BASE)) } 17 | func USART3() *Periph { return (*Periph)(unsafe.Pointer(mmap.USART3_BASE)) } 18 | func UART4() *Periph { return (*Periph)(unsafe.Pointer(mmap.UART4_BASE)) } 19 | func UART5() *Periph { return (*Periph)(unsafe.Pointer(mmap.UART5_BASE)) } 20 | func LPUART1() *Periph { return (*Periph)(unsafe.Pointer(mmap.LPUART1_BASE)) } 21 | -------------------------------------------------------------------------------- /hal/usart/instances8.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build stm32f407 6 | 7 | package usart 8 | 9 | import ( 10 | "unsafe" 11 | 12 | "github.com/embeddedgo/stm32/p/mmap" 13 | ) 14 | 15 | func USART1() *Periph { return (*Periph)(unsafe.Pointer(mmap.USART1_BASE)) } 16 | func USART2() *Periph { return (*Periph)(unsafe.Pointer(mmap.USART2_BASE)) } 17 | func USART3() *Periph { return (*Periph)(unsafe.Pointer(mmap.USART3_BASE)) } 18 | func UART4() *Periph { return (*Periph)(unsafe.Pointer(mmap.UART4_BASE)) } 19 | func UART5() *Periph { return (*Periph)(unsafe.Pointer(mmap.UART5_BASE)) } 20 | func USART6() *Periph { return (*Periph)(unsafe.Pointer(mmap.USART6_BASE)) } 21 | func UART7() *Periph { return (*Periph)(unsafe.Pointer(mmap.UART7_BASE)) } 22 | func UART8() *Periph { return (*Periph)(unsafe.Pointer(mmap.UART8_BASE)) } 23 | -------------------------------------------------------------------------------- /hal/usart/instances9.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build stm32h7x3 6 | 7 | package usart 8 | 9 | import ( 10 | "unsafe" 11 | 12 | "github.com/embeddedgo/stm32/p/mmap" 13 | ) 14 | 15 | func USART1() *Periph { return (*Periph)(unsafe.Pointer(mmap.USART1_BASE)) } 16 | func USART2() *Periph { return (*Periph)(unsafe.Pointer(mmap.USART2_BASE)) } 17 | func USART3() *Periph { return (*Periph)(unsafe.Pointer(mmap.USART3_BASE)) } 18 | func UART4() *Periph { return (*Periph)(unsafe.Pointer(mmap.UART4_BASE)) } 19 | func UART5() *Periph { return (*Periph)(unsafe.Pointer(mmap.UART5_BASE)) } 20 | func USART6() *Periph { return (*Periph)(unsafe.Pointer(mmap.USART6_BASE)) } 21 | func UART7() *Periph { return (*Periph)(unsafe.Pointer(mmap.UART7_BASE)) } 22 | func UART8() *Periph { return (*Periph)(unsafe.Pointer(mmap.UART8_BASE)) } 23 | func LPUART1() *Periph { return (*Periph)(unsafe.Pointer(mmap.LPUART1_BASE)) } 24 | -------------------------------------------------------------------------------- /hal/usart/uart4/driver.go: -------------------------------------------------------------------------------- 1 | // Copyright 2025 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package uart4 6 | 7 | import ( 8 | "github.com/embeddedgo/stm32/hal/usart" 9 | ) 10 | 11 | var driver *usart.Driver 12 | 13 | // Driver returns a ready to use driver for USART1 peripheral. 14 | func Driver() *usart.Driver { 15 | if driver == nil { 16 | setupDriver() 17 | } 18 | return driver 19 | } 20 | 21 | -------------------------------------------------------------------------------- /hal/usart/uart4/f2f4.go: -------------------------------------------------------------------------------- 1 | // Copyright 2025 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build stm32f215 || stm32f407 6 | 7 | package uart4 8 | 9 | import ( 10 | "embedded/rtos" 11 | _ "unsafe" 12 | 13 | "github.com/embeddedgo/stm32/hal/dma" 14 | "github.com/embeddedgo/stm32/hal/irq" 15 | "github.com/embeddedgo/stm32/hal/usart" 16 | ) 17 | 18 | func setupDriver() { 19 | d := dma.DMA(1 20 | d.EnableClock(true) 21 | driver = usart.NewDriver(usart.UART4(), d.Channel(2, 4), d.Channel(4, 4)) 22 | irq.UART4.Enable(rtos.IntPrioLow, 0) 23 | irq.DMA1_STREAM4.Enable(rtos.IntPrioLow, 0) 24 | } 25 | 26 | //go:interrupthandler 27 | func _UART4_Handler() { driver.RxISR() } 28 | 29 | //go:interrupthandler 30 | func _DMA1_STREAM4_Handler() { driver.TxDMAISR() } 31 | 32 | //go:linkname _UART4_Handler IRQ52_Handler 33 | //go:linkname _DMA1_STREAM4_Handler IRQ15_Handler 34 | -------------------------------------------------------------------------------- /hal/usart/uart4/h7.go: -------------------------------------------------------------------------------- 1 | // Copyright 2025 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build stm32h7x3 6 | 7 | package uart4 8 | 9 | import ( 10 | "embedded/rtos" 11 | _ "unsafe" 12 | 13 | "github.com/embeddedgo/stm32/hal/dma" 14 | "github.com/embeddedgo/stm32/hal/irq" 15 | "github.com/embeddedgo/stm32/hal/usart" 16 | ) 17 | 18 | func setupDriver() { 19 | d := dma.DMA(1) 20 | d.EnableClock(true) 21 | rxdma := d.AllocChannel() 22 | rxdma.SetMux(dma.UART4_RX) 23 | txdma := d.AllocChannel() 24 | txdma.SetMux(dma.UART4_TX) 25 | driver = usart.NewDriver(usart.UART4(), rxdma, txdma) 26 | irq.UART4.Enable(rtos.IntPrioLow, 0) 27 | dmairq.SetISR(txdma, driver.TxDMAISR) 28 | } 29 | 30 | //go:interrupthandler 31 | func _UART4_Handler() { driver.RxISR() } 32 | 33 | //go:linkname _UART4_Handler IRQ52_Handler 34 | -------------------------------------------------------------------------------- /hal/usart/uart4/l4.go: -------------------------------------------------------------------------------- 1 | // Copyright 2025 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build stm32l4x6 6 | 7 | package uart4 8 | 9 | import ( 10 | "embedded/rtos" 11 | _ "unsafe" 12 | 13 | "github.com/embeddedgo/stm32/hal/dma" 14 | "github.com/embeddedgo/stm32/hal/irq" 15 | "github.com/embeddedgo/stm32/hal/usart" 16 | ) 17 | func setupDriver() { 18 | d := dma.DMA(2) 19 | d.EnableClock(true) 20 | driver = usart.NewDriver(usart.UART4(), d.Channel(5, 2), d.Channel(3, 2)) 21 | irq.UART4.Enable(rtos.IntPrioLow, 0) 22 | irq.DMA2_CH3.Enable(rtos.IntPrioLow, 0) 23 | } 24 | 25 | //go:interrupthandler 26 | func _UART4_Handler() { driver.RxISR() } 27 | 28 | //go:interrupthandler 29 | func _DMA2_CH3_Handler() { driver.TxDMAISR() } 30 | 31 | //go:linkname _UART4_Handler IRQ52_Handler 32 | //go:linkname _DMA2_CH3_Handler IRQ58_Handler 33 | -------------------------------------------------------------------------------- /hal/usart/usart1/driver.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package usart1 6 | 7 | import ( 8 | "github.com/embeddedgo/stm32/hal/usart" 9 | ) 10 | 11 | var driver *usart.Driver 12 | 13 | // Driver returns a ready to use driver for USART1 peripheral. 14 | func Driver() *usart.Driver { 15 | if driver == nil { 16 | setupDriver() 17 | } 18 | return driver 19 | } 20 | 21 | -------------------------------------------------------------------------------- /hal/usart/usart1/f2f4.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build stm32f215 || stm32f407 6 | 7 | package usart1 8 | 9 | import ( 10 | "embedded/rtos" 11 | _ "unsafe" 12 | 13 | "github.com/embeddedgo/stm32/hal/dma" 14 | "github.com/embeddedgo/stm32/hal/irq" 15 | "github.com/embeddedgo/stm32/hal/usart" 16 | ) 17 | 18 | func setupDriver() { 19 | d := dma.DMA(2) 20 | d.EnableClock(true) 21 | driver = usart.NewDriver(usart.USART1(), d.Channel(2, 4), d.Channel(7, 4)) 22 | irq.USART1.Enable(rtos.IntPrioLow, 0) 23 | irq.DMA2_STREAM7.Enable(rtos.IntPrioLow, 0) 24 | } 25 | 26 | //go:interrupthandler 27 | func _USART1_Handler() { driver.RxISR() } 28 | 29 | //go:interrupthandler 30 | func _DMA2_STREAM7_Handler() { driver.TxDMAISR() } 31 | 32 | //go:linkname _USART1_Handler IRQ37_Handler 33 | //go:linkname _DMA2_STREAM7_Handler IRQ70_Handler 34 | -------------------------------------------------------------------------------- /hal/usart/usart1/h7.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build stm32h7x3 6 | 7 | package usart1 8 | 9 | import ( 10 | "embedded/rtos" 11 | _ "unsafe" 12 | 13 | "github.com/embeddedgo/stm32/hal/dma" 14 | "github.com/embeddedgo/stm32/hal/dma/dmairq" 15 | "github.com/embeddedgo/stm32/hal/irq" 16 | "github.com/embeddedgo/stm32/hal/usart" 17 | ) 18 | 19 | func setupDriver() { 20 | d := dma.DMA(1) 21 | d.EnableClock(true) 22 | rxdma := d.AllocChannel() 23 | rxdma.SetMux(dma.USART1_RX) 24 | txdma := d.AllocChannel() 25 | txdma.SetMux(dma.USART1_TX) 26 | driver = usart.NewDriver(usart.USART1(), rxdma, txdma) 27 | irq.USART1.Enable(rtos.IntPrioLow, 0) 28 | dmairq.SetISR(txdma, driver.TxDMAISR) 29 | } 30 | 31 | //go:interrupthandler 32 | func _USART1_Handler() { driver.RxISR() } 33 | 34 | //go:linkname _USART1_Handler IRQ37_Handler 35 | -------------------------------------------------------------------------------- /hal/usart/usart1/l4.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build stm32l4x6 6 | 7 | package usart1 8 | 9 | import ( 10 | "embedded/rtos" 11 | _ "unsafe" 12 | 13 | "github.com/embeddedgo/stm32/hal/dma" 14 | "github.com/embeddedgo/stm32/hal/irq" 15 | "github.com/embeddedgo/stm32/hal/usart" 16 | ) 17 | func setupDriver() { 18 | d := dma.DMA(2) 19 | d.EnableClock(true) 20 | driver = usart.NewDriver(usart.USART1(), d.Channel(7, 2), d.Channel(6, 2)) 21 | irq.USART1.Enable(rtos.IntPrioLow, 0) 22 | irq.DMA2_CH6.Enable(rtos.IntPrioLow, 0) 23 | } 24 | 25 | //go:interrupthandler 26 | func _USART1_Handler() { driver.RxISR() } 27 | 28 | //go:interrupthandler 29 | func _DMA2_CH6_Handler() { driver.TxDMAISR() } 30 | 31 | //go:linkname _USART1_Handler IRQ37_Handler 32 | //go:linkname _DMA2_CH6_Handler IRQ68_Handler 33 | -------------------------------------------------------------------------------- /hal/usart/usart2/driver.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package usart2 6 | 7 | import ( 8 | "github.com/embeddedgo/stm32/hal/usart" 9 | ) 10 | 11 | var driver *usart.Driver 12 | 13 | // Driver returns a ready to use driver for USART2 peripheral. 14 | func Driver() *usart.Driver { 15 | if driver == nil { 16 | setupDriver() 17 | } 18 | return driver 19 | } 20 | 21 | -------------------------------------------------------------------------------- /hal/usart/usart2/f2f4.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build stm32f215 stm32f407 6 | 7 | package usart2 8 | 9 | import ( 10 | "embedded/rtos" 11 | _ "unsafe" 12 | 13 | "github.com/embeddedgo/stm32/hal/dma" 14 | "github.com/embeddedgo/stm32/hal/irq" 15 | "github.com/embeddedgo/stm32/hal/usart" 16 | ) 17 | 18 | func setupDriver() { 19 | d := dma.DMA(1) 20 | d.EnableClock(true) 21 | driver = usart.NewDriver(usart.USART2(), d.Channel(5, 4), d.Channel(6, 4)) 22 | irq.USART2.Enable(rtos.IntPrioLow, 0) 23 | irq.DMA1_STREAM6.Enable(rtos.IntPrioLow, 0) 24 | } 25 | 26 | //go:interrupthandler 27 | func _USART2_Handler() { driver.RxISR() } 28 | 29 | //go:interrupthandler 30 | func _DMA1_STREAM6_Handler() { driver.TxDMAISR() } 31 | 32 | //go:linkname _USART2_Handler IRQ38_Handler 33 | //go:linkname _DMA1_STREAM6_Handler IRQ17_Handler 34 | -------------------------------------------------------------------------------- /hal/usart/usart2/h7.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build stm32h7x3 6 | 7 | package usart2 8 | 9 | import ( 10 | "embedded/rtos" 11 | _ "unsafe" 12 | 13 | "github.com/embeddedgo/stm32/hal/dma" 14 | "github.com/embeddedgo/stm32/hal/dma/dmairq" 15 | "github.com/embeddedgo/stm32/hal/irq" 16 | "github.com/embeddedgo/stm32/hal/usart" 17 | ) 18 | 19 | func setupDriver() { 20 | d := dma.DMA(1) 21 | d.EnableClock(true) 22 | rxdma := d.AllocChannel() 23 | rxdma.SetMux(dma.USART2_RX) 24 | txdma := d.AllocChannel() 25 | txdma.SetMux(dma.USART2_TX) 26 | driver = usart.NewDriver(usart.USART2(), rxdma, txdma) 27 | irq.USART2.Enable(rtos.IntPrioLow, 0) 28 | dmairq.SetISR(txdma, driver.TxDMAISR) 29 | } 30 | 31 | //go:interrupthandler 32 | func _USART2_Handler() { driver.RxISR() } 33 | 34 | //go:linkname _USART2_Handler IRQ38_Handler 35 | -------------------------------------------------------------------------------- /hal/usart/usart2/l4.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build stm32l4x6 6 | 7 | package usart2 8 | 9 | import ( 10 | "embedded/rtos" 11 | _ "unsafe" 12 | 13 | "github.com/embeddedgo/stm32/hal/dma" 14 | "github.com/embeddedgo/stm32/hal/irq" 15 | "github.com/embeddedgo/stm32/hal/usart" 16 | ) 17 | 18 | func setupDriver() { 19 | d := dma.DMA(1) 20 | d.EnableClock(true) 21 | driver = usart.NewDriver(usart.USART2(), d.Channel(6, 2), d.Channel(7, 2)) 22 | irq.USART2.Enable(rtos.IntPrioLow, 0) 23 | irq.DMA1_CH7.Enable(rtos.IntPrioLow, 0) 24 | } 25 | 26 | //go:interrupthandler 27 | func _USART2_Handler() { driver.RxISR() } 28 | 29 | //go:interrupthandler 30 | func _DMA1_CH7_Handler() { driver.TxDMAISR() } 31 | 32 | //go:linkname _USART2_Handler IRQ38_Handler 33 | //go:linkname _DMA1_CH7_Handler IRQ17_Handler 34 | -------------------------------------------------------------------------------- /hal/usart/usart6/driver.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package usart6 6 | 7 | import ( 8 | "github.com/embeddedgo/stm32/hal/usart" 9 | ) 10 | 11 | var driver *usart.Driver 12 | 13 | // Driver returns a ready to use driver for USART1 peripheral. 14 | func Driver() *usart.Driver { 15 | if driver == nil { 16 | setupDriver() 17 | } 18 | return driver 19 | } 20 | 21 | -------------------------------------------------------------------------------- /hal/usart/usart6/f2f4.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build stm32f215 stm32f407 6 | 7 | package usart6 8 | 9 | import ( 10 | "embedded/rtos" 11 | _ "unsafe" 12 | 13 | "github.com/embeddedgo/stm32/hal/dma" 14 | "github.com/embeddedgo/stm32/hal/irq" 15 | "github.com/embeddedgo/stm32/hal/usart" 16 | ) 17 | 18 | func setupDriver() { 19 | d := dma.DMA(2) 20 | d.EnableClock(true) 21 | driver = usart.NewDriver(usart.USART6(), d.Channel(1, 5), d.Channel(7, 5)) 22 | irq.USART6.Enable(rtos.IntPrioLow, 0) 23 | irq.DMA2_STREAM7.Enable(rtos.IntPrioLow, 0) 24 | } 25 | 26 | //go:interrupthandler 27 | func _USART6_Handler() { driver.RxISR() } 28 | 29 | //go:interrupthandler 30 | func _DMA2_STREAM7_Handler() { driver.TxDMAISR() } 31 | 32 | //go:linkname _USART6_Handler IRQ71_Handler 33 | //go:linkname _DMA2_STREAM7_Handler IRQ70_Handler 34 | -------------------------------------------------------------------------------- /hal/usart/usart6/h7.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build stm32h7x3 6 | 7 | package usart6 8 | 9 | import ( 10 | "embedded/rtos" 11 | _ "unsafe" 12 | 13 | "github.com/embeddedgo/stm32/hal/dma" 14 | "github.com/embeddedgo/stm32/hal/dma/dmairq" 15 | "github.com/embeddedgo/stm32/hal/irq" 16 | "github.com/embeddedgo/stm32/hal/usart" 17 | ) 18 | 19 | func setupDriver() { 20 | d := dma.DMA(1) 21 | d.EnableClock(true) 22 | rxdma := d.AllocChannel() 23 | rxdma.SetMux(dma.USART6_RX) 24 | txdma := d.AllocChannel() 25 | txdma.SetMux(dma.USART6_TX) 26 | driver = usart.NewDriver(usart.USART6(), rxdma, txdma) 27 | irq.USART6.Enable(rtos.IntPrioLow, 0) 28 | dmairq.SetISR(txdma, driver.TxDMAISR) 29 | } 30 | 31 | //go:interrupthandler 32 | func _USART6_Handler() { driver.RxISR() } 33 | 34 | //go:linkname _USART6_Handler IRQ71_Handler 35 | -------------------------------------------------------------------------------- /hal/usart/usepin.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Embedded Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package usart 6 | 7 | import "github.com/embeddedgo/stm32/hal/gpio" 8 | 9 | type Signal uint8 10 | 11 | const ( 12 | RTSn Signal = iota 13 | TXD 14 | CTSn 15 | RXD 16 | ) 17 | 18 | // UsePin is a helper function that can be used to configure GPIO pins as 19 | // required by USART peripheral. Only certain pins can be used (see datasheet). 20 | func (d *Driver) UsePin(pin gpio.Pin, sig Signal) { 21 | var cfg gpio.Config 22 | if sig <= TXD { 23 | cfg.Mode = gpio.Alt 24 | cfg.Speed = gpio.VeryHigh 25 | } else { 26 | cfg.Mode = gpio.AltIn 27 | } 28 | pin.Setup(&cfg) 29 | pin.SetAltFunc(altFunc(d.p, pin)) 30 | } 31 | -------------------------------------------------------------------------------- /p/bus/stm32f215.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32f215 4 | 5 | package bus 6 | 7 | const ( 8 | Core Bus = iota 9 | AHB1 10 | AHB2 11 | AHB3 12 | APB1 13 | APB2 14 | 15 | AHBLast = AHB3 16 | APBLast = APB2 17 | ) 18 | 19 | type Bus uint8 20 | 21 | func (b Bus) String() string { 22 | i := int(b) * 4 23 | return "CoreAHB1AHB2AHB3APB1APB2"[i : i+4] 24 | } 25 | 26 | var buses [6]struct{ clockHz int64 } 27 | 28 | func (b Bus) Clock() int64 { return buses[b].clockHz } 29 | func (b Bus) SetClock(Hz int64) { buses[b].clockHz = Hz } 30 | -------------------------------------------------------------------------------- /p/bus/stm32f407.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32f407 4 | 5 | package bus 6 | 7 | const ( 8 | Core Bus = iota 9 | AHB1 10 | AHB2 11 | AHB3 12 | APB1 13 | APB2 14 | 15 | AHBLast = AHB3 16 | APBLast = APB2 17 | ) 18 | 19 | type Bus uint8 20 | 21 | func (b Bus) String() string { 22 | i := int(b) * 4 23 | return "CoreAHB1AHB2AHB3APB1APB2"[i : i+4] 24 | } 25 | 26 | var buses [6]struct{ clockHz int64 } 27 | 28 | func (b Bus) Clock() int64 { return buses[b].clockHz } 29 | func (b Bus) SetClock(Hz int64) { buses[b].clockHz = Hz } 30 | -------------------------------------------------------------------------------- /p/bus/stm32f412.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32f412 4 | 5 | package bus 6 | 7 | const ( 8 | Core Bus = iota 9 | AHB1 10 | AHB2 11 | APB1 12 | APB2 13 | 14 | AHBLast = AHB2 15 | APBLast = APB2 16 | ) 17 | 18 | type Bus uint8 19 | 20 | func (b Bus) String() string { 21 | i := int(b) * 4 22 | return "CoreAHB1AHB2APB1APB2"[i : i+4] 23 | } 24 | 25 | var buses [5]struct{ clockHz int64 } 26 | 27 | func (b Bus) Clock() int64 { return buses[b].clockHz } 28 | func (b Bus) SetClock(Hz int64) { buses[b].clockHz = Hz } 29 | -------------------------------------------------------------------------------- /p/bus/stm32g471xx.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32g471xx 4 | 5 | package bus 6 | 7 | const ( 8 | Core Bus = iota 9 | AHB1 10 | AHB2 11 | AHB3 12 | APB1 13 | APB2 14 | 15 | AHBLast = AHB3 16 | APBLast = APB2 17 | ) 18 | 19 | type Bus uint8 20 | 21 | func (b Bus) String() string { 22 | i := int(b) * 4 23 | return "CoreAHB1AHB2AHB3APB1APB2"[i : i+4] 24 | } 25 | 26 | var buses [6]struct{ clockHz int64 } 27 | 28 | func (b Bus) Clock() int64 { return buses[b].clockHz } 29 | func (b Bus) SetClock(Hz int64) { buses[b].clockHz = Hz } 30 | -------------------------------------------------------------------------------- /p/bus/stm32h7x3.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32h7x3 4 | 5 | package bus 6 | 7 | const ( 8 | Core Bus = iota 9 | AHB1 10 | AHB2 11 | AHB3 12 | AHB4 13 | APB1 14 | APB2 15 | APB3 16 | APB4 17 | 18 | AHBLast = AHB4 19 | APBLast = APB4 20 | ) 21 | 22 | type Bus uint8 23 | 24 | func (b Bus) String() string { 25 | i := int(b) * 4 26 | return "CoreAHB1AHB2AHB3AHB4APB1APB2APB3APB4"[i : i+4] 27 | } 28 | 29 | var buses [9]struct{ clockHz int64 } 30 | 31 | func (b Bus) Clock() int64 { return buses[b].clockHz } 32 | func (b Bus) SetClock(Hz int64) { buses[b].clockHz = Hz } 33 | -------------------------------------------------------------------------------- /p/bus/stm32l4x6.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32l4x6 4 | 5 | package bus 6 | 7 | const ( 8 | Core Bus = iota 9 | AHB1 10 | AHB2 11 | AHB3 12 | APB1 13 | APB2 14 | 15 | AHBLast = AHB3 16 | APBLast = APB2 17 | ) 18 | 19 | type Bus uint8 20 | 21 | func (b Bus) String() string { 22 | i := int(b) * 4 23 | return "CoreAHB1AHB2AHB3APB1APB2"[i : i+4] 24 | } 25 | 26 | var buses [6]struct{ clockHz int64 } 27 | 28 | func (b Bus) Clock() int64 { return buses[b].clockHz } 29 | func (b Bus) SetClock(Hz int64) { buses[b].clockHz = Hz } 30 | -------------------------------------------------------------------------------- /p/crc/stm32f215.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32f215 4 | 5 | // Package crc provides access to the registers of the CRC peripheral. 6 | // 7 | // Instances: 8 | // 9 | // CRC CRC_BASE AHB1 - cyclic redundancy check calculation unit 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 DR Data register 14 | // 0x004 32 IDR Independent data register 15 | // 0x008 32 CR Control register 16 | // 17 | // Import: 18 | // 19 | // github.com/embeddedgo/stm32/p/bus 20 | // github.com/embeddedgo/stm32/p/mmap 21 | package crc 22 | 23 | const ( 24 | DR DR = 0xFFFFFFFF << 0 //+ Data register bits 25 | ) 26 | 27 | const ( 28 | DRn = 0 29 | ) 30 | 31 | const ( 32 | IDR IDR = 0xFF << 0 //+ General-purpose 8-bit data register bits 33 | ) 34 | 35 | const ( 36 | IDRn = 0 37 | ) 38 | 39 | const ( 40 | RESET CR = 0x01 << 0 //+ reset bit 41 | ) 42 | 43 | const ( 44 | RESETn = 0 45 | ) 46 | -------------------------------------------------------------------------------- /p/crc/stm32f407.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32f407 4 | 5 | // Package crc provides access to the registers of the CRC peripheral. 6 | // 7 | // Instances: 8 | // 9 | // CRC CRC_BASE AHB1 - Cryptographic processor 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 DR Data register 14 | // 0x004 32 IDR Independent Data register 15 | // 0x008 32 CR Control register 16 | // 17 | // Import: 18 | // 19 | // github.com/embeddedgo/stm32/p/bus 20 | // github.com/embeddedgo/stm32/p/mmap 21 | package crc 22 | 23 | const ( 24 | DR DR = 0xFFFFFFFF << 0 //+ Data Register 25 | ) 26 | 27 | const ( 28 | DRn = 0 29 | ) 30 | 31 | const ( 32 | IDR IDR = 0xFF << 0 //+ Independent Data register 33 | ) 34 | 35 | const ( 36 | IDRn = 0 37 | ) 38 | 39 | const ( 40 | CR CR = 0x01 << 0 //+ Control regidter 41 | ) 42 | 43 | const ( 44 | CRn = 0 45 | ) 46 | -------------------------------------------------------------------------------- /p/crc/stm32f412.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32f412 4 | 5 | // Package crc provides access to the registers of the CRC peripheral. 6 | // 7 | // Instances: 8 | // 9 | // CRC CRC_BASE AHB1 - Cryptographic processor 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 DR Data register 14 | // 0x004 32 IDR Independent Data register 15 | // 0x008 32 CR Control register 16 | // 17 | // Import: 18 | // 19 | // github.com/embeddedgo/stm32/p/bus 20 | // github.com/embeddedgo/stm32/p/mmap 21 | package crc 22 | 23 | const ( 24 | DR DR = 0xFFFFFFFF << 0 //+ Data Register 25 | ) 26 | 27 | const ( 28 | DRn = 0 29 | ) 30 | 31 | const ( 32 | IDR IDR = 0xFF << 0 //+ Independent Data register 33 | ) 34 | 35 | const ( 36 | IDRn = 0 37 | ) 38 | 39 | const ( 40 | CR CR = 0x01 << 0 //+ Control regidter 41 | ) 42 | 43 | const ( 44 | CRn = 0 45 | ) 46 | -------------------------------------------------------------------------------- /p/crc/stm32g471xx.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32g471xx 4 | 5 | // Package crc provides access to the registers of the CRC peripheral. 6 | // 7 | // Instances: 8 | // 9 | // CRC CRC_BASE AHB1 - Cyclic redundancy check calculation unit 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 DR Data register 14 | // 0x004 32 IDR Independent data register 15 | // 0x008 32 CR Control register 16 | // 0x010 32 INIT Initial CRC value 17 | // 0x014 32 POL polynomial 18 | // 19 | // Import: 20 | // 21 | // github.com/embeddedgo/stm32/p/bus 22 | // github.com/embeddedgo/stm32/p/mmap 23 | package crc 24 | 25 | const ( 26 | DR DR = 0xFFFFFFFF << 0 //+ Data register bits 27 | ) 28 | 29 | const ( 30 | DRn = 0 31 | ) 32 | 33 | const ( 34 | IDR IDR = 0xFFFFFFFF << 0 //+ General-purpose 8-bit data register bits 35 | ) 36 | 37 | const ( 38 | IDRn = 0 39 | ) 40 | 41 | const ( 42 | RESET CR = 0x01 << 0 //+ RESET bit 43 | POLYSIZE CR = 0x03 << 3 //+ Polynomial size 44 | REV_IN CR = 0x03 << 5 //+ Reverse input data 45 | REV_OUT CR = 0x01 << 7 //+ Reverse output data 46 | ) 47 | 48 | const ( 49 | RESETn = 0 50 | POLYSIZEn = 3 51 | REV_INn = 5 52 | REV_OUTn = 7 53 | ) 54 | 55 | const ( 56 | CRC_INIT INIT = 0xFFFFFFFF << 0 //+ Programmable initial CRC value 57 | ) 58 | 59 | const ( 60 | CRC_INITn = 0 61 | ) 62 | 63 | const ( 64 | POL POL = 0xFFFFFFFF << 0 //+ Programmable polynomial 65 | ) 66 | 67 | const ( 68 | POLn = 0 69 | ) 70 | -------------------------------------------------------------------------------- /p/crc/stm32h7x3.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32h7x3 4 | 5 | // Package crc provides access to the registers of the CRC peripheral. 6 | // 7 | // Instances: 8 | // 9 | // CRC CRC_BASE AHB4 - Cryptographic processor 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 DR Data register 14 | // 0x004 32 IDR Independent Data register 15 | // 0x008 32 CR Control register 16 | // 0x010 32 INIT Initial CRC value 17 | // 0x014 32 POL CRC polynomial 18 | // 19 | // Import: 20 | // 21 | // github.com/embeddedgo/stm32/p/bus 22 | // github.com/embeddedgo/stm32/p/mmap 23 | package crc 24 | 25 | const ( 26 | DR DR = 0xFFFFFFFF << 0 //+ Data Register 27 | ) 28 | 29 | const ( 30 | DRn = 0 31 | ) 32 | 33 | const ( 34 | IDR IDR = 0xFFFFFFFF << 0 //+ Independent Data register 35 | ) 36 | 37 | const ( 38 | IDRn = 0 39 | ) 40 | 41 | const ( 42 | RESET CR = 0x01 << 0 //+ RESET bit 43 | POLYSIZE CR = 0x03 << 3 //+ Polynomial size 44 | REV_IN CR = 0x03 << 5 //+ Reverse input data 45 | REV_OUT CR = 0x01 << 7 //+ Reverse output data 46 | ) 47 | 48 | const ( 49 | RESETn = 0 50 | POLYSIZEn = 3 51 | REV_INn = 5 52 | REV_OUTn = 7 53 | ) 54 | 55 | const ( 56 | CRC_INIT INIT = 0xFFFFFFFF << 0 //+ Programmable initial CRC value 57 | ) 58 | 59 | const ( 60 | CRC_INITn = 0 61 | ) 62 | 63 | const ( 64 | POL POL = 0xFFFFFFFF << 0 //+ Programmable polynomial 65 | ) 66 | 67 | const ( 68 | POLn = 0 69 | ) 70 | -------------------------------------------------------------------------------- /p/crc/stm32l4x6.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32l4x6 4 | 5 | // Package crc provides access to the registers of the CRC peripheral. 6 | // 7 | // Instances: 8 | // 9 | // CRC CRC_BASE AHB1 - Cyclic redundancy check calculation unit 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 DR Data register 14 | // 0x004 32 IDR Independent data register 15 | // 0x008 32 CR Control register 16 | // 0x010 32 INIT Initial CRC value 17 | // 0x014 32 POL polynomial 18 | // 19 | // Import: 20 | // 21 | // github.com/embeddedgo/stm32/p/bus 22 | // github.com/embeddedgo/stm32/p/mmap 23 | package crc 24 | 25 | const ( 26 | DR DR = 0xFFFFFFFF << 0 //+ Data register bits 27 | ) 28 | 29 | const ( 30 | DRn = 0 31 | ) 32 | 33 | const ( 34 | IDR IDR = 0xFF << 0 //+ General-purpose 8-bit data register bits 35 | ) 36 | 37 | const ( 38 | IDRn = 0 39 | ) 40 | 41 | const ( 42 | RESET CR = 0x01 << 0 //+ RESET bit 43 | POLYSIZE CR = 0x03 << 3 //+ Polynomial size 44 | REV_IN CR = 0x03 << 5 //+ Reverse input data 45 | REV_OUT CR = 0x01 << 7 //+ Reverse output data 46 | ) 47 | 48 | const ( 49 | RESETn = 0 50 | POLYSIZEn = 3 51 | REV_INn = 5 52 | REV_OUTn = 7 53 | ) 54 | 55 | const ( 56 | CRC_INIT INIT = 0xFFFFFFFF << 0 //+ Programmable initial CRC value 57 | ) 58 | 59 | const ( 60 | CRC_INITn = 0 61 | ) 62 | 63 | const ( 64 | Polynomialcoefficients POL = 0xFFFFFFFF << 0 //+ Programmable polynomial 65 | ) 66 | 67 | const ( 68 | Polynomialcoefficientsn = 0 69 | ) 70 | -------------------------------------------------------------------------------- /p/dlyb/stm32h7x3.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32h7x3 4 | 5 | // Package dlyb provides access to the registers of the DELAY_Block_SDMMC peripheral. 6 | // 7 | // Instances: 8 | // 9 | // DELAY_Block_QUADSPI DELAY_Block_QUADSPI_BASE - WKUP+ DELAY_Block_SDMMC1 10 | // DELAY_Block_SDMMC1 DELAY_Block_SDMMC1_BASE - WKUP+ DELAY_Block_SDMMC1 11 | // DELAY_Block_SDMMC2 DELAY_Block_SDMMC2_BASE - WKUP+ DELAY_Block_SDMMC1 12 | // 13 | // Registers: 14 | // 15 | // 0x000 32 CR DLYB control register 16 | // 0x004 32 CFGR DLYB configuration register 17 | // 18 | // Import: 19 | // 20 | // github.com/embeddedgo/stm32/p/mmap 21 | package dlyb 22 | 23 | const ( 24 | DEN CR = 0x01 << 0 //+ Delay block enable bit 25 | SEN CR = 0x01 << 1 //+ Sampler length enable bit 26 | ) 27 | 28 | const ( 29 | DENn = 0 30 | SENn = 1 31 | ) 32 | 33 | const ( 34 | SEL CFGR = 0x0F << 0 //+ Select the phase for the Output clock 35 | UNIT CFGR = 0x7F << 8 //+ Delay Defines the delay of a Unit delay cell 36 | LNG CFGR = 0xFFF << 16 //+ Delay line length value 37 | LNGF CFGR = 0x01 << 31 //+ Length valid flag 38 | ) 39 | 40 | const ( 41 | SELn = 0 42 | UNITn = 8 43 | LNGn = 16 44 | LNGFn = 31 45 | ) 46 | -------------------------------------------------------------------------------- /p/exti/stm32f215.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32f215 4 | 5 | // Package exti provides access to the registers of the EXTI peripheral. 6 | // 7 | // Instances: 8 | // 9 | // EXTI EXTI_BASE - TAMP_STAMP,EXTI0,EXTI1,EXTI2,EXTI3,EXTI4,EXTI9_5,EXTI15_10 External interrupt/event controller 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 IMR Interrupt mask register (EXTI_IMR) 14 | // 0x004 32 EMR Event mask register (EXTI_EMR) 15 | // 0x008 32 RTSR Rising Trigger selection register (EXTI_RTSR) 16 | // 0x00C 32 FTSR Falling Trigger selection register (EXTI_FTSR) 17 | // 0x010 32 SWIER Software interrupt event register (EXTI_SWIER) 18 | // 0x014 32 PR Pending register (EXTI_PR) 19 | // 20 | // Import: 21 | // 22 | // github.com/embeddedgo/stm32/p/mmap 23 | package exti 24 | -------------------------------------------------------------------------------- /p/exti/stm32f407.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32f407 4 | 5 | // Package exti provides access to the registers of the EXTI peripheral. 6 | // 7 | // Instances: 8 | // 9 | // EXTI EXTI_BASE - TAMP_STAMP,EXTI0,EXTI1,EXTI2,EXTI3,EXTI4,EXTI9_5+,EXTI9_5+,EXTI15_10 External interrupt/event controller 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 IMR Interrupt mask register (EXTI_IMR) 14 | // 0x004 32 EMR Event mask register (EXTI_EMR) 15 | // 0x008 32 RTSR Rising Trigger selection register (EXTI_RTSR) 16 | // 0x00C 32 FTSR Falling Trigger selection register (EXTI_FTSR) 17 | // 0x010 32 SWIER Software interrupt event register (EXTI_SWIER) 18 | // 0x014 32 PR Pending register (EXTI_PR) 19 | // 20 | // Import: 21 | // 22 | // github.com/embeddedgo/stm32/p/mmap 23 | package exti 24 | -------------------------------------------------------------------------------- /p/exti/stm32f412.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32f412 4 | 5 | // Package exti provides access to the registers of the EXTI peripheral. 6 | // 7 | // Instances: 8 | // 9 | // EXTI EXTI_BASE - TAMP_STAMP,EXTI0,EXTI1,EXTI2,EXTI3,EXTI4,EXTI9_5,EXTI15_10 External interrupt/event controller 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 IMR Interrupt mask register (EXTI_IMR) 14 | // 0x004 32 EMR Event mask register (EXTI_EMR) 15 | // 0x008 32 RTSR Rising Trigger selection register (EXTI_RTSR) 16 | // 0x00C 32 FTSR Falling Trigger selection register (EXTI_FTSR) 17 | // 0x010 32 SWIER Software interrupt event register (EXTI_SWIER) 18 | // 0x014 32 PR Pending register (EXTI_PR) 19 | // 20 | // Import: 21 | // 22 | // github.com/embeddedgo/stm32/p/mmap 23 | package exti 24 | -------------------------------------------------------------------------------- /p/exti/stm32g471xx.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32g471xx 4 | 5 | // Package exti provides access to the registers of the EXTI peripheral. 6 | // 7 | // Instances: 8 | // 9 | // EXTI EXTI_BASE - PVD_PVM,EXTI0,EXTI1,EXTI2,EXTI3,EXTI4,USB_HP,USB_LP,FDCAN1_INTR1_IT,FDCAN1_INTR0_IT,EXTI9_5,EXTI15_10,USBWAKEUP,CRS External interrupt/event controller 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 IMR1 Interrupt mask register 14 | // 0x004 32 EMR1 Event mask register 15 | // 0x008 32 RTSR1 Rising Trigger selection register 16 | // 0x00C 32 FTSR1 Falling Trigger selection register 17 | // 0x010 32 SWIER1 Software interrupt event register 18 | // 0x014 32 PR1 Pending register 19 | // 0x020 32 IMR2 Interrupt mask register 20 | // 0x024 32 EMR2 Event mask register 21 | // 0x028 32 RTSR2 Rising Trigger selection register 22 | // 0x02C 32 FTSR2 Falling Trigger selection register 23 | // 0x030 32 SWIER2 Software interrupt event register 24 | // 0x034 32 PR2 Pending register 25 | // 26 | // Import: 27 | // 28 | // github.com/embeddedgo/stm32/p/mmap 29 | package exti 30 | -------------------------------------------------------------------------------- /p/exti/stm32l4x6.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32l4x6 4 | 5 | // Package exti provides access to the registers of the EXTI peripheral. 6 | // 7 | // Instances: 8 | // 9 | // EXTI EXTI_BASE - PVD_PVM,EXTI0,EXTI1,EXTI2,EXTI3,EXTI4,EXTI9_5,EXTI15_10 External interrupt/event controller 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 IMR1 Interrupt mask register 14 | // 0x004 32 EMR1 Event mask register 15 | // 0x008 32 RTSR1 Rising Trigger selection register 16 | // 0x00C 32 FTSR1 Falling Trigger selection register 17 | // 0x010 32 SWIER1 Software interrupt event register 18 | // 0x014 32 PR1 Pending register 19 | // 0x020 32 IMR2 Interrupt mask register 20 | // 0x024 32 EMR2 Event mask register 21 | // 0x028 32 RTSR2 Rising Trigger selection register 22 | // 0x02C 32 FTSR2 Falling Trigger selection register 23 | // 0x030 32 SWIER2 Software interrupt event register 24 | // 0x034 32 PR2 Pending register 25 | // 26 | // Import: 27 | // 28 | // github.com/embeddedgo/stm32/p/mmap 29 | package exti 30 | -------------------------------------------------------------------------------- /p/exti/xstm32f215.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY xgen. 2 | 3 | //go:build stm32f215 4 | 5 | package exti 6 | 7 | import ( 8 | "embedded/mmio" 9 | "unsafe" 10 | 11 | "github.com/embeddedgo/stm32/p/mmap" 12 | ) 13 | 14 | type Periph struct { 15 | IMR mmio.R32[uint32] 16 | EMR mmio.R32[uint32] 17 | RTSR mmio.R32[uint32] 18 | FTSR mmio.R32[uint32] 19 | SWIER mmio.R32[uint32] 20 | PR mmio.R32[uint32] 21 | } 22 | 23 | func EXTI() *Periph { return (*Periph)(unsafe.Pointer(uintptr(mmap.EXTI_BASE))) } 24 | 25 | func (p *Periph) BaseAddr() uintptr { 26 | return uintptr(unsafe.Pointer(p)) 27 | } 28 | -------------------------------------------------------------------------------- /p/exti/xstm32f407.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY xgen. 2 | 3 | //go:build stm32f407 4 | 5 | package exti 6 | 7 | import ( 8 | "embedded/mmio" 9 | "unsafe" 10 | 11 | "github.com/embeddedgo/stm32/p/mmap" 12 | ) 13 | 14 | type Periph struct { 15 | IMR mmio.R32[uint32] 16 | EMR mmio.R32[uint32] 17 | RTSR mmio.R32[uint32] 18 | FTSR mmio.R32[uint32] 19 | SWIER mmio.R32[uint32] 20 | PR mmio.R32[uint32] 21 | } 22 | 23 | func EXTI() *Periph { return (*Periph)(unsafe.Pointer(uintptr(mmap.EXTI_BASE))) } 24 | 25 | func (p *Periph) BaseAddr() uintptr { 26 | return uintptr(unsafe.Pointer(p)) 27 | } 28 | -------------------------------------------------------------------------------- /p/exti/xstm32f412.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY xgen. 2 | 3 | //go:build stm32f412 4 | 5 | package exti 6 | 7 | import ( 8 | "embedded/mmio" 9 | "unsafe" 10 | 11 | "github.com/embeddedgo/stm32/p/mmap" 12 | ) 13 | 14 | type Periph struct { 15 | IMR mmio.R32[uint32] 16 | EMR mmio.R32[uint32] 17 | RTSR mmio.R32[uint32] 18 | FTSR mmio.R32[uint32] 19 | SWIER mmio.R32[uint32] 20 | PR mmio.R32[uint32] 21 | } 22 | 23 | func EXTI() *Periph { return (*Periph)(unsafe.Pointer(uintptr(mmap.EXTI_BASE))) } 24 | 25 | func (p *Periph) BaseAddr() uintptr { 26 | return uintptr(unsafe.Pointer(p)) 27 | } 28 | -------------------------------------------------------------------------------- /p/exti/xstm32g471xx.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY xgen. 2 | 3 | //go:build stm32g471xx 4 | 5 | package exti 6 | 7 | import ( 8 | "embedded/mmio" 9 | "unsafe" 10 | 11 | "github.com/embeddedgo/stm32/p/mmap" 12 | ) 13 | 14 | type Periph struct { 15 | IMR1 mmio.R32[uint32] 16 | EMR1 mmio.R32[uint32] 17 | RTSR1 mmio.R32[uint32] 18 | FTSR1 mmio.R32[uint32] 19 | SWIER1 mmio.R32[uint32] 20 | PR1 mmio.R32[uint32] 21 | _ [2]uint32 22 | IMR2 mmio.R32[uint32] 23 | EMR2 mmio.R32[uint32] 24 | RTSR2 mmio.R32[uint32] 25 | FTSR2 mmio.R32[uint32] 26 | SWIER2 mmio.R32[uint32] 27 | PR2 mmio.R32[uint32] 28 | } 29 | 30 | func EXTI() *Periph { return (*Periph)(unsafe.Pointer(uintptr(mmap.EXTI_BASE))) } 31 | 32 | func (p *Periph) BaseAddr() uintptr { 33 | return uintptr(unsafe.Pointer(p)) 34 | } 35 | -------------------------------------------------------------------------------- /p/exti/xstm32h7x3.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY xgen. 2 | 3 | //go:build stm32h7x3 4 | 5 | package exti 6 | 7 | import ( 8 | "embedded/mmio" 9 | "unsafe" 10 | 11 | "github.com/embeddedgo/stm32/p/mmap" 12 | ) 13 | 14 | type Periph struct { 15 | RTSR1 mmio.R32[uint32] 16 | FTSR1 mmio.R32[uint32] 17 | SWIER1 mmio.R32[uint32] 18 | D3PMR1 mmio.R32[uint32] 19 | D3PCR1L mmio.R32[uint32] 20 | D3PCR1H mmio.R32[uint32] 21 | _ [2]uint32 22 | RTSR2 mmio.R32[uint32] 23 | FTSR2 mmio.R32[uint32] 24 | SWIER2 mmio.R32[uint32] 25 | D3PMR2 mmio.R32[uint32] 26 | D3PCR2L mmio.R32[uint32] 27 | D3PCR2H mmio.R32[uint32] 28 | _ [2]uint32 29 | RTSR3 mmio.R32[uint32] 30 | FTSR3 mmio.R32[uint32] 31 | SWIER3 mmio.R32[uint32] 32 | D3PMR3 mmio.R32[uint32] 33 | _ uint32 34 | D3PCR3H mmio.R32[uint32] 35 | _ [10]uint32 36 | CPUIMR1 mmio.R32[uint32] 37 | CPUEMR1 mmio.R32[uint32] 38 | CPUPR1 mmio.R32[uint32] 39 | _ uint32 40 | CPUIMR2 mmio.R32[uint32] 41 | CPUEMR2 mmio.R32[uint32] 42 | CPUPR2 mmio.R32[uint32] 43 | _ uint32 44 | CPUIMR3 mmio.R32[uint32] 45 | CPUEMR3 mmio.R32[uint32] 46 | CPUPR3 mmio.R32[uint32] 47 | } 48 | 49 | func EXTI() *Periph { return (*Periph)(unsafe.Pointer(uintptr(mmap.EXTI_BASE))) } 50 | 51 | func (p *Periph) BaseAddr() uintptr { 52 | return uintptr(unsafe.Pointer(p)) 53 | } 54 | -------------------------------------------------------------------------------- /p/exti/xstm32l4x6.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY xgen. 2 | 3 | //go:build stm32l4x6 4 | 5 | package exti 6 | 7 | import ( 8 | "embedded/mmio" 9 | "unsafe" 10 | 11 | "github.com/embeddedgo/stm32/p/mmap" 12 | ) 13 | 14 | type Periph struct { 15 | IMR1 mmio.R32[uint32] 16 | EMR1 mmio.R32[uint32] 17 | RTSR1 mmio.R32[uint32] 18 | FTSR1 mmio.R32[uint32] 19 | SWIER1 mmio.R32[uint32] 20 | PR1 mmio.R32[uint32] 21 | _ [2]uint32 22 | IMR2 mmio.R32[uint32] 23 | EMR2 mmio.R32[uint32] 24 | RTSR2 mmio.R32[uint32] 25 | FTSR2 mmio.R32[uint32] 26 | SWIER2 mmio.R32[uint32] 27 | PR2 mmio.R32[uint32] 28 | } 29 | 30 | func EXTI() *Periph { return (*Periph)(unsafe.Pointer(uintptr(mmap.EXTI_BASE))) } 31 | 32 | func (p *Periph) BaseAddr() uintptr { 33 | return uintptr(unsafe.Pointer(p)) 34 | } 35 | -------------------------------------------------------------------------------- /p/fpu/fpu_cpacr/stm32f407.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32f407 4 | 5 | // Package fpu_cpacr provides access to the registers of the FPU_CPACR peripheral. 6 | // 7 | // Instances: 8 | // 9 | // FPU_CPACR FPU_CPACR_BASE - - Floating point unit CPACR 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 CPACR Coprocessor access control register 14 | // 15 | // Import: 16 | // 17 | // github.com/embeddedgo/stm32/p/mmap 18 | package fpu_cpacr 19 | 20 | const ( 21 | CP CPACR = 0x0F << 20 //+ CP 22 | ) 23 | 24 | const ( 25 | CPn = 20 26 | ) 27 | -------------------------------------------------------------------------------- /p/fpu/fpu_cpacr/stm32f412.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32f412 4 | 5 | // Package fpu_cpacr provides access to the registers of the FPU_CPACR peripheral. 6 | // 7 | // Instances: 8 | // 9 | // FPU_CPACR FPU_CPACR_BASE - - Floating point unit CPACR 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 CPACR Coprocessor access control register 14 | // 15 | // Import: 16 | // 17 | // github.com/embeddedgo/stm32/p/mmap 18 | package fpu_cpacr 19 | 20 | const ( 21 | CP CPACR = 0x0F << 20 //+ CP 22 | ) 23 | 24 | const ( 25 | CPn = 20 26 | ) 27 | -------------------------------------------------------------------------------- /p/fpu/fpu_cpacr/stm32g471xx.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32g471xx 4 | 5 | // Package fpu_cpacr provides access to the registers of the FPU_CPACR peripheral. 6 | // 7 | // Instances: 8 | // 9 | // FPU_CPACR FPU_CPACR_BASE - - Floating point unit CPACR 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 CPACR Coprocessor access control register 14 | // 15 | // Import: 16 | // 17 | // github.com/embeddedgo/stm32/p/mmap 18 | package fpu_cpacr 19 | 20 | const ( 21 | CP CPACR = 0x0F << 20 //+ CP 22 | ) 23 | 24 | const ( 25 | CPn = 20 26 | ) 27 | -------------------------------------------------------------------------------- /p/fpu/fpu_cpacr/stm32l4x6.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32l4x6 4 | 5 | // Package fpu_cpacr provides access to the registers of the FPU_CPACR peripheral. 6 | // 7 | // Instances: 8 | // 9 | // FPU_CPACR FPU_CPACR_BASE - - Floating point unit CPACR 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 CPACR Coprocessor access control register 14 | // 15 | // Import: 16 | // 17 | // github.com/embeddedgo/stm32/p/mmap 18 | package fpu_cpacr 19 | 20 | const ( 21 | CP CPACR = 0x0F << 20 //+ CP 22 | ) 23 | 24 | const ( 25 | CPn = 20 26 | ) 27 | -------------------------------------------------------------------------------- /p/iwdg/stm32f215.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32f215 4 | 5 | // Package iwdg provides access to the registers of the IWDG peripheral. 6 | // 7 | // Instances: 8 | // 9 | // IWDG IWDG_BASE - - Independent watchdog 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 KR Key register 14 | // 0x004 32 PR Prescaler register 15 | // 0x008 32 RLR Reload register 16 | // 0x00C 32 SR Status register 17 | // 18 | // Import: 19 | // 20 | // github.com/embeddedgo/stm32/p/mmap 21 | package iwdg 22 | 23 | const ( 24 | KEY KR = 0xFFFF << 0 //+ Key value (write only, read 0000h) 25 | ) 26 | 27 | const ( 28 | KEYn = 0 29 | ) 30 | 31 | const ( 32 | PR PR = 0x07 << 0 //+ Prescaler divider 33 | ) 34 | 35 | const ( 36 | PRn = 0 37 | ) 38 | 39 | const ( 40 | RL RLR = 0xFFF << 0 //+ Watchdog counter reload value 41 | ) 42 | 43 | const ( 44 | RLn = 0 45 | ) 46 | 47 | const ( 48 | PVU SR = 0x01 << 0 //+ Watchdog prescaler value update 49 | RVU SR = 0x01 << 1 //+ Watchdog counter reload value update 50 | ) 51 | 52 | const ( 53 | PVUn = 0 54 | RVUn = 1 55 | ) 56 | -------------------------------------------------------------------------------- /p/iwdg/stm32f407.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32f407 4 | 5 | // Package iwdg provides access to the registers of the IWDG peripheral. 6 | // 7 | // Instances: 8 | // 9 | // IWDG IWDG_BASE - - Independent watchdog 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 KR Key register 14 | // 0x004 32 PR Prescaler register 15 | // 0x008 32 RLR Reload register 16 | // 0x00C 32 SR Status register 17 | // 18 | // Import: 19 | // 20 | // github.com/embeddedgo/stm32/p/mmap 21 | package iwdg 22 | 23 | const ( 24 | KEY KR = 0xFFFF << 0 //+ Key value (write only, read 0000h) 25 | ) 26 | 27 | const ( 28 | KEYn = 0 29 | ) 30 | 31 | const ( 32 | PR PR = 0x07 << 0 //+ Prescaler divider 33 | ) 34 | 35 | const ( 36 | PRn = 0 37 | ) 38 | 39 | const ( 40 | RL RLR = 0xFFF << 0 //+ Watchdog counter reload value 41 | ) 42 | 43 | const ( 44 | RLn = 0 45 | ) 46 | 47 | const ( 48 | PVU SR = 0x01 << 0 //+ Watchdog prescaler value update 49 | RVU SR = 0x01 << 1 //+ Watchdog counter reload value update 50 | ) 51 | 52 | const ( 53 | PVUn = 0 54 | RVUn = 1 55 | ) 56 | -------------------------------------------------------------------------------- /p/iwdg/stm32f412.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32f412 4 | 5 | // Package iwdg provides access to the registers of the IWDG peripheral. 6 | // 7 | // Instances: 8 | // 9 | // IWDG IWDG_BASE - - Independent watchdog 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 KR Key register 14 | // 0x004 32 PR Prescaler register 15 | // 0x008 32 RLR Reload register 16 | // 0x00C 32 SR Status register 17 | // 18 | // Import: 19 | // 20 | // github.com/embeddedgo/stm32/p/mmap 21 | package iwdg 22 | 23 | const ( 24 | KEY KR = 0xFFFF << 0 //+ Key value 25 | ) 26 | 27 | const ( 28 | KEYn = 0 29 | ) 30 | 31 | const ( 32 | PR PR = 0x07 << 0 //+ Prescaler divider 33 | ) 34 | 35 | const ( 36 | PRn = 0 37 | ) 38 | 39 | const ( 40 | RL RLR = 0xFFF << 0 //+ Watchdog counter reload value 41 | ) 42 | 43 | const ( 44 | RLn = 0 45 | ) 46 | 47 | const ( 48 | PVU SR = 0x01 << 0 //+ Watchdog prescaler value update 49 | RVU SR = 0x01 << 1 //+ Watchdog counter reload value update 50 | ) 51 | 52 | const ( 53 | PVUn = 0 54 | RVUn = 1 55 | ) 56 | -------------------------------------------------------------------------------- /p/iwdg/stm32g471xx.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32g471xx 4 | 5 | // Package iwdg provides access to the registers of the WWDG peripheral. 6 | // 7 | // Instances: 8 | // 9 | // WWDG WWDG_BASE APB1 - WinWATCHDOG 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 KR Key register 14 | // 0x004 32 PR Prescaler register 15 | // 0x008 32 RLR Reload register 16 | // 0x00C 32 SR Status register 17 | // 0x010 32 WINR Window register 18 | // 19 | // Import: 20 | // 21 | // github.com/embeddedgo/stm32/p/bus 22 | // github.com/embeddedgo/stm32/p/mmap 23 | package iwdg 24 | 25 | const ( 26 | KEY KR = 0xFFFF << 0 //+ Key value (write only, read 0x0000) 27 | ) 28 | 29 | const ( 30 | KEYn = 0 31 | ) 32 | 33 | const ( 34 | PR PR = 0x07 << 0 //+ Prescaler divider 35 | ) 36 | 37 | const ( 38 | PRn = 0 39 | ) 40 | 41 | const ( 42 | RL RLR = 0xFFF << 0 //+ Watchdog counter reload value 43 | ) 44 | 45 | const ( 46 | RLn = 0 47 | ) 48 | 49 | const ( 50 | PVU SR = 0x01 << 0 //+ Watchdog prescaler value update 51 | RVU SR = 0x01 << 1 //+ Watchdog counter reload value update 52 | WVU SR = 0x01 << 2 //+ Watchdog counter window value update 53 | ) 54 | 55 | const ( 56 | PVUn = 0 57 | RVUn = 1 58 | WVUn = 2 59 | ) 60 | 61 | const ( 62 | WIN WINR = 0xFFF << 0 //+ Watchdog counter window value 63 | ) 64 | 65 | const ( 66 | WINn = 0 67 | ) 68 | -------------------------------------------------------------------------------- /p/iwdg/stm32l4x6.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32l4x6 4 | 5 | // Package iwdg provides access to the registers of the IWDG peripheral. 6 | // 7 | // Instances: 8 | // 9 | // IWDG IWDG_BASE - - Independent watchdog 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 KR Key register 14 | // 0x004 32 PR Prescaler register 15 | // 0x008 32 RLR Reload register 16 | // 0x00C 32 SR Status register 17 | // 0x010 32 WINR Window register 18 | // 19 | // Import: 20 | // 21 | // github.com/embeddedgo/stm32/p/mmap 22 | package iwdg 23 | 24 | const ( 25 | KEY KR = 0xFFFF << 0 //+ Key value (write only, read 0x0000) 26 | ) 27 | 28 | const ( 29 | KEYn = 0 30 | ) 31 | 32 | const ( 33 | PR PR = 0x07 << 0 //+ Prescaler divider 34 | ) 35 | 36 | const ( 37 | PRn = 0 38 | ) 39 | 40 | const ( 41 | RL RLR = 0xFFF << 0 //+ Watchdog counter reload value 42 | ) 43 | 44 | const ( 45 | RLn = 0 46 | ) 47 | 48 | const ( 49 | PVU SR = 0x01 << 0 //+ Watchdog prescaler value update 50 | RVU SR = 0x01 << 1 //+ Watchdog counter reload value update 51 | WVU SR = 0x01 << 2 //+ Watchdog counter window value update 52 | ) 53 | 54 | const ( 55 | PVUn = 0 56 | RVUn = 1 57 | WVUn = 2 58 | ) 59 | 60 | const ( 61 | WIN WINR = 0xFFF << 0 //+ Watchdog counter window value 62 | ) 63 | 64 | const ( 65 | WINn = 0 66 | ) 67 | -------------------------------------------------------------------------------- /p/nvic/nvic_stir/stm32f215.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32f215 4 | 5 | // Package nvic_stir provides access to the registers of the NVIC_STIR peripheral. 6 | // 7 | // Instances: 8 | // 9 | // NVIC_STIR NVIC_STIR_BASE - - Nested vectored interrupt controller 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 STIR Software trigger interrupt register 14 | // 15 | // Import: 16 | // 17 | // github.com/embeddedgo/stm32/p/mmap 18 | package nvic_stir 19 | 20 | const ( 21 | INTID STIR = 0x1FF << 0 //+ Software generated interrupt ID 22 | ) 23 | 24 | const ( 25 | INTIDn = 0 26 | ) 27 | -------------------------------------------------------------------------------- /p/nvic/nvic_stir/stm32f407.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32f407 4 | 5 | // Package nvic_stir provides access to the registers of the NVIC_STIR peripheral. 6 | // 7 | // Instances: 8 | // 9 | // NVIC_STIR NVIC_STIR_BASE - - Nested vectored interrupt controller 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 STIR Software trigger interrupt register 14 | // 15 | // Import: 16 | // 17 | // github.com/embeddedgo/stm32/p/mmap 18 | package nvic_stir 19 | 20 | const ( 21 | INTID STIR = 0x1FF << 0 //+ Software generated interrupt ID 22 | ) 23 | 24 | const ( 25 | INTIDn = 0 26 | ) 27 | -------------------------------------------------------------------------------- /p/nvic/nvic_stir/stm32f412.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32f412 4 | 5 | // Package nvic_stir provides access to the registers of the NVIC_STIR peripheral. 6 | // 7 | // Instances: 8 | // 9 | // NVIC_STIR NVIC_STIR_BASE - - Nested vectored interrupt controller 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 STIR Software trigger interrupt register 14 | // 15 | // Import: 16 | // 17 | // github.com/embeddedgo/stm32/p/mmap 18 | package nvic_stir 19 | 20 | const ( 21 | INTID STIR = 0x1FF << 0 //+ Software generated interrupt ID 22 | ) 23 | 24 | const ( 25 | INTIDn = 0 26 | ) 27 | -------------------------------------------------------------------------------- /p/nvic/nvic_stir/stm32l4x6.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32l4x6 4 | 5 | // Package nvic_stir provides access to the registers of the NVIC_STIR peripheral. 6 | // 7 | // Instances: 8 | // 9 | // NVIC_STIR NVIC_STIR_BASE - - Nested vectored interrupt controller 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 STIR Software trigger interrupt register 14 | // 15 | // Import: 16 | // 17 | // github.com/embeddedgo/stm32/p/mmap 18 | package nvic_stir 19 | 20 | const ( 21 | INTID STIR = 0x1FF << 0 //+ Software generated interrupt ID 22 | ) 23 | 24 | const ( 25 | INTIDn = 0 26 | ) 27 | -------------------------------------------------------------------------------- /p/pwr/stm32f215.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32f215 4 | 5 | // Package pwr provides access to the registers of the PWR peripheral. 6 | // 7 | // Instances: 8 | // 9 | // PWR PWR_BASE APB1 PVD Power control 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 CR power control register 14 | // 0x004 32 CSR power control/status register 15 | // 16 | // Import: 17 | // 18 | // github.com/embeddedgo/stm32/p/bus 19 | // github.com/embeddedgo/stm32/p/mmap 20 | package pwr 21 | 22 | const ( 23 | LPDS CR = 0x01 << 0 //+ Low-power deep sleep 24 | PDDS CR = 0x01 << 1 //+ Power down deepsleep 25 | CWUF CR = 0x01 << 2 //+ Clear wakeup flag 26 | CSBF CR = 0x01 << 3 //+ Clear standby flag 27 | PVDE CR = 0x01 << 4 //+ Power voltage detector enable 28 | PLS CR = 0x07 << 5 //+ PVD level selection 29 | DBP CR = 0x01 << 8 //+ Disable backup domain write protection 30 | FPDS CR = 0x01 << 9 //+ Flash power down in Stop mode 31 | ) 32 | 33 | const ( 34 | LPDSn = 0 35 | PDDSn = 1 36 | CWUFn = 2 37 | CSBFn = 3 38 | PVDEn = 4 39 | PLSn = 5 40 | DBPn = 8 41 | FPDSn = 9 42 | ) 43 | 44 | const ( 45 | WUF CSR = 0x01 << 0 //+ Wakeup flag 46 | SBF CSR = 0x01 << 1 //+ Standby flag 47 | PVDO CSR = 0x01 << 2 //+ PVD output 48 | BRR CSR = 0x01 << 3 //+ Backup regulator ready 49 | EWUP CSR = 0x01 << 8 //+ Enable WKUP pin 50 | BRE CSR = 0x01 << 9 //+ Backup regulator enable 51 | ) 52 | 53 | const ( 54 | WUFn = 0 55 | SBFn = 1 56 | PVDOn = 2 57 | BRRn = 3 58 | EWUPn = 8 59 | BREn = 9 60 | ) 61 | -------------------------------------------------------------------------------- /p/rng/stm32f215.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32f215 4 | 5 | // Package rng provides access to the registers of the RNG peripheral. 6 | // 7 | // Instances: 8 | // 9 | // RNG RNG_BASE AHB2 HASH_RNG* Random number generator 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 CR control register 14 | // 0x004 32 SR status register 15 | // 0x008 32 DR data register 16 | // 17 | // Import: 18 | // 19 | // github.com/embeddedgo/stm32/p/bus 20 | // github.com/embeddedgo/stm32/p/mmap 21 | package rng 22 | 23 | const ( 24 | RNGEN CR = 0x01 << 2 //+ Random number generator enable 25 | IE CR = 0x01 << 3 //+ Interrupt enable 26 | ) 27 | 28 | const ( 29 | RNGENn = 2 30 | IEn = 3 31 | ) 32 | 33 | const ( 34 | DRDY SR = 0x01 << 0 //+ Data ready 35 | CECS SR = 0x01 << 1 //+ Clock error current status 36 | SECS SR = 0x01 << 2 //+ Seed error current status 37 | CEIS SR = 0x01 << 5 //+ Clock error interrupt status 38 | SEIS SR = 0x01 << 6 //+ Seed error interrupt status 39 | ) 40 | 41 | const ( 42 | DRDYn = 0 43 | CECSn = 1 44 | SECSn = 2 45 | CEISn = 5 46 | SEISn = 6 47 | ) 48 | 49 | const ( 50 | RNDATA DR = 0xFFFFFFFF << 0 //+ Random data 51 | ) 52 | 53 | const ( 54 | RNDATAn = 0 55 | ) 56 | -------------------------------------------------------------------------------- /p/rng/stm32f407.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32f407 4 | 5 | // Package rng provides access to the registers of the RNG peripheral. 6 | // 7 | // Instances: 8 | // 9 | // RNG RNG_BASE AHB2 FPU* Random number generator 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 CR control register 14 | // 0x004 32 SR status register 15 | // 0x008 32 DR data register 16 | // 17 | // Import: 18 | // 19 | // github.com/embeddedgo/stm32/p/bus 20 | // github.com/embeddedgo/stm32/p/mmap 21 | package rng 22 | 23 | const ( 24 | RNGEN CR = 0x01 << 2 //+ Random number generator enable 25 | IE CR = 0x01 << 3 //+ Interrupt enable 26 | ) 27 | 28 | const ( 29 | RNGENn = 2 30 | IEn = 3 31 | ) 32 | 33 | const ( 34 | DRDY SR = 0x01 << 0 //+ Data ready 35 | CECS SR = 0x01 << 1 //+ Clock error current status 36 | SECS SR = 0x01 << 2 //+ Seed error current status 37 | CEIS SR = 0x01 << 5 //+ Clock error interrupt status 38 | SEIS SR = 0x01 << 6 //+ Seed error interrupt status 39 | ) 40 | 41 | const ( 42 | DRDYn = 0 43 | CECSn = 1 44 | SECSn = 2 45 | CEISn = 5 46 | SEISn = 6 47 | ) 48 | 49 | const ( 50 | RNDATA DR = 0xFFFFFFFF << 0 //+ Random data 51 | ) 52 | 53 | const ( 54 | RNDATAn = 0 55 | ) 56 | -------------------------------------------------------------------------------- /p/rng/stm32f412.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32f412 4 | 5 | // Package rng provides access to the registers of the RNG peripheral. 6 | // 7 | // Instances: 8 | // 9 | // RNG RNG_BASE AHB2 HASH_RNG Random number generator 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 CR control register 14 | // 0x004 32 SR status register 15 | // 0x008 32 DR data register 16 | // 17 | // Import: 18 | // 19 | // github.com/embeddedgo/stm32/p/bus 20 | // github.com/embeddedgo/stm32/p/mmap 21 | package rng 22 | 23 | const ( 24 | RNGEN CR = 0x01 << 2 //+ Random number generator enable 25 | IE CR = 0x01 << 3 //+ Interrupt enable 26 | ) 27 | 28 | const ( 29 | RNGENn = 2 30 | IEn = 3 31 | ) 32 | 33 | const ( 34 | DRDY SR = 0x01 << 0 //+ Data ready 35 | CECS SR = 0x01 << 1 //+ Clock error current status 36 | SECS SR = 0x01 << 2 //+ Seed error current status 37 | CEIS SR = 0x01 << 5 //+ Clock error interrupt status 38 | SEIS SR = 0x01 << 6 //+ Seed error interrupt status 39 | ) 40 | 41 | const ( 42 | DRDYn = 0 43 | CECSn = 1 44 | SECSn = 2 45 | CEISn = 5 46 | SEISn = 6 47 | ) 48 | 49 | const ( 50 | RNDATA DR = 0xFFFFFFFF << 0 //+ Random data 51 | ) 52 | 53 | const ( 54 | RNDATAn = 0 55 | ) 56 | -------------------------------------------------------------------------------- /p/rng/stm32g471xx.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32g471xx 4 | 5 | // Package rng provides access to the registers of the RNG peripheral. 6 | // 7 | // Instances: 8 | // 9 | // RNG RNG_BASE AHB2 RNG Random number generator 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 CR control register 14 | // 0x004 32 SR status register 15 | // 0x008 32 DR data register 16 | // 17 | // Import: 18 | // 19 | // github.com/embeddedgo/stm32/p/bus 20 | // github.com/embeddedgo/stm32/p/mmap 21 | package rng 22 | 23 | const ( 24 | RNGEN CR = 0x01 << 2 //+ Random number generator enable 25 | IE CR = 0x01 << 3 //+ Interrupt enable 26 | CED CR = 0x01 << 5 //+ Clock error detection 27 | ) 28 | 29 | const ( 30 | RNGENn = 2 31 | IEn = 3 32 | CEDn = 5 33 | ) 34 | 35 | const ( 36 | DRDY SR = 0x01 << 0 //+ Data ready 37 | CECS SR = 0x01 << 1 //+ Clock error current status 38 | SECS SR = 0x01 << 2 //+ Seed error current status 39 | CEIS SR = 0x01 << 5 //+ Clock error interrupt status 40 | SEIS SR = 0x01 << 6 //+ Seed error interrupt status 41 | ) 42 | 43 | const ( 44 | DRDYn = 0 45 | CECSn = 1 46 | SECSn = 2 47 | CEISn = 5 48 | SEISn = 6 49 | ) 50 | 51 | const ( 52 | RNDATA DR = 0xFFFFFFFF << 0 //+ Random data 53 | ) 54 | 55 | const ( 56 | RNDATAn = 0 57 | ) 58 | -------------------------------------------------------------------------------- /p/rng/stm32l4x6.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32l4x6 4 | 5 | // Package rng provides access to the registers of the RNG peripheral. 6 | // 7 | // Instances: 8 | // 9 | // RNG RNG_BASE AHB2 RNG_HASH Random number generator 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 CR control register 14 | // 0x004 32 SR status register 15 | // 0x008 32 DR data register 16 | // 17 | // Import: 18 | // 19 | // github.com/embeddedgo/stm32/p/bus 20 | // github.com/embeddedgo/stm32/p/mmap 21 | package rng 22 | 23 | const ( 24 | RNGEN CR = 0x01 << 2 //+ Random number generator enable 25 | IE CR = 0x01 << 3 //+ Interrupt enable 26 | ) 27 | 28 | const ( 29 | RNGENn = 2 30 | IEn = 3 31 | ) 32 | 33 | const ( 34 | DRDY SR = 0x01 << 0 //+ Data ready 35 | CECS SR = 0x01 << 1 //+ Clock error current status 36 | SECS SR = 0x01 << 2 //+ Seed error current status 37 | CEIS SR = 0x01 << 5 //+ Clock error interrupt status 38 | SEIS SR = 0x01 << 6 //+ Seed error interrupt status 39 | ) 40 | 41 | const ( 42 | DRDYn = 0 43 | CECSn = 1 44 | SECSn = 2 45 | CEISn = 5 46 | SEISn = 6 47 | ) 48 | 49 | const ( 50 | RNDATA DR = 0xFFFFFFFF << 0 //+ Random data 51 | ) 52 | 53 | const ( 54 | RNDATAn = 0 55 | ) 56 | -------------------------------------------------------------------------------- /p/scb/scb_actrl/stm32f215.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32f215 4 | 5 | // Package scb_actrl provides access to the registers of the SCB_ACTRL peripheral. 6 | // 7 | // Instances: 8 | // 9 | // SCB_ACTRL SCB_ACTRL_BASE - - System control block ACTLR 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 ACTRL Auxiliary control register 14 | // 15 | // Import: 16 | // 17 | // github.com/embeddedgo/stm32/p/mmap 18 | package scb_actrl 19 | 20 | const ( 21 | DISFOLD ACTRL = 0x01 << 2 //+ DISFOLD 22 | FPEXCODIS ACTRL = 0x01 << 10 //+ FPEXCODIS 23 | DISRAMODE ACTRL = 0x01 << 11 //+ DISRAMODE 24 | DISITMATBFLUSH ACTRL = 0x01 << 12 //+ DISITMATBFLUSH 25 | ) 26 | 27 | const ( 28 | DISFOLDn = 2 29 | FPEXCODISn = 10 30 | DISRAMODEn = 11 31 | DISITMATBFLUSHn = 12 32 | ) 33 | -------------------------------------------------------------------------------- /p/scb/scb_actrl/stm32f407.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32f407 4 | 5 | // Package scb_actrl provides access to the registers of the SCB_ACTRL peripheral. 6 | // 7 | // Instances: 8 | // 9 | // SCB_ACTRL SCB_ACTRL_BASE - - System control block ACTLR 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 ACTRL Auxiliary control register 14 | // 15 | // Import: 16 | // 17 | // github.com/embeddedgo/stm32/p/mmap 18 | package scb_actrl 19 | 20 | const ( 21 | DISMCYCINT ACTRL = 0x01 << 0 //+ DISMCYCINT 22 | DISDEFWBUF ACTRL = 0x01 << 1 //+ DISDEFWBUF 23 | DISFOLD ACTRL = 0x01 << 2 //+ DISFOLD 24 | DISFPCA ACTRL = 0x01 << 8 //+ DISFPCA 25 | DISOOFP ACTRL = 0x01 << 9 //+ DISOOFP 26 | ) 27 | 28 | const ( 29 | DISMCYCINTn = 0 30 | DISDEFWBUFn = 1 31 | DISFOLDn = 2 32 | DISFPCAn = 8 33 | DISOOFPn = 9 34 | ) 35 | -------------------------------------------------------------------------------- /p/scb/scb_actrl/stm32f412.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32f412 4 | 5 | // Package scb_actrl provides access to the registers of the SCB_ACTRL peripheral. 6 | // 7 | // Instances: 8 | // 9 | // SCB_ACTRL SCB_ACTRL_BASE - - System control block ACTLR 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 ACTRL Auxiliary control register 14 | // 15 | // Import: 16 | // 17 | // github.com/embeddedgo/stm32/p/mmap 18 | package scb_actrl 19 | 20 | const ( 21 | DISMCYCINT ACTRL = 0x01 << 0 //+ DISMCYCINT 22 | DISDEFWBUF ACTRL = 0x01 << 1 //+ DISDEFWBUF 23 | DISFOLD ACTRL = 0x01 << 2 //+ DISFOLD 24 | DISFPCA ACTRL = 0x01 << 8 //+ DISFPCA 25 | DISOOFP ACTRL = 0x01 << 9 //+ DISOOFP 26 | ) 27 | 28 | const ( 29 | DISMCYCINTn = 0 30 | DISDEFWBUFn = 1 31 | DISFOLDn = 2 32 | DISFPCAn = 8 33 | DISOOFPn = 9 34 | ) 35 | -------------------------------------------------------------------------------- /p/scb/scb_actrl/stm32g471xx.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32g471xx 4 | 5 | // Package scb_actrl provides access to the registers of the SCB_ACTRL peripheral. 6 | // 7 | // Instances: 8 | // 9 | // SCB_ACTRL SCB_ACTRL_BASE - - System control block ACTLR 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 ACTRL Auxiliary control register 14 | // 15 | // Import: 16 | // 17 | // github.com/embeddedgo/stm32/p/mmap 18 | package scb_actrl 19 | 20 | const ( 21 | DISMCYCINT ACTRL = 0x01 << 0 //+ DISMCYCINT 22 | DISDEFWBUF ACTRL = 0x01 << 1 //+ DISDEFWBUF 23 | DISFOLD ACTRL = 0x01 << 2 //+ DISFOLD 24 | DISFPCA ACTRL = 0x01 << 8 //+ DISFPCA 25 | DISOOFP ACTRL = 0x01 << 9 //+ DISOOFP 26 | ) 27 | 28 | const ( 29 | DISMCYCINTn = 0 30 | DISDEFWBUFn = 1 31 | DISFOLDn = 2 32 | DISFPCAn = 8 33 | DISOOFPn = 9 34 | ) 35 | -------------------------------------------------------------------------------- /p/scb/scb_actrl/stm32l4x6.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32l4x6 4 | 5 | // Package scb_actrl provides access to the registers of the SCB_ACTRL peripheral. 6 | // 7 | // Instances: 8 | // 9 | // SCB_ACTRL SCB_ACTRL_BASE - - System control block ACTLR 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 ACTRL Auxiliary control register 14 | // 15 | // Import: 16 | // 17 | // github.com/embeddedgo/stm32/p/mmap 18 | package scb_actrl 19 | 20 | const ( 21 | DISMCYCINT ACTRL = 0x01 << 0 //+ DISMCYCINT 22 | DISDEFWBUF ACTRL = 0x01 << 1 //+ DISDEFWBUF 23 | DISFOLD ACTRL = 0x01 << 2 //+ DISFOLD 24 | DISFPCA ACTRL = 0x01 << 8 //+ DISFPCA 25 | DISOOFP ACTRL = 0x01 << 9 //+ DISOOFP 26 | ) 27 | 28 | const ( 29 | DISMCYCINTn = 0 30 | DISDEFWBUFn = 1 31 | DISFOLDn = 2 32 | DISFPCAn = 8 33 | DISOOFPn = 9 34 | ) 35 | -------------------------------------------------------------------------------- /p/stk/stm32f215.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32f215 4 | 5 | // Package stk provides access to the registers of the STK peripheral. 6 | // 7 | // Instances: 8 | // 9 | // STK STK_BASE - - SysTick timer 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 CTRL SysTick control and status register 14 | // 0x004 32 LOAD_ SysTick reload value register 15 | // 0x008 32 VAL SysTick current value register 16 | // 0x00C 32 CALIB SysTick calibration value register 17 | // 18 | // Import: 19 | // 20 | // github.com/embeddedgo/stm32/p/mmap 21 | package stk 22 | 23 | const ( 24 | ENABLE CTRL = 0x01 << 0 //+ Counter enable 25 | TICKINT CTRL = 0x01 << 1 //+ SysTick exception request enable 26 | CLKSOURCE CTRL = 0x01 << 2 //+ Clock source selection 27 | COUNTFLAG CTRL = 0x01 << 16 //+ COUNTFLAG 28 | ) 29 | 30 | const ( 31 | ENABLEn = 0 32 | TICKINTn = 1 33 | CLKSOURCEn = 2 34 | COUNTFLAGn = 16 35 | ) 36 | 37 | const ( 38 | RELOAD LOAD_ = 0xFFFFFF << 0 //+ RELOAD value 39 | ) 40 | 41 | const ( 42 | RELOADn = 0 43 | ) 44 | 45 | const ( 46 | CURRENT VAL = 0xFFFFFF << 0 //+ Current counter value 47 | ) 48 | 49 | const ( 50 | CURRENTn = 0 51 | ) 52 | 53 | const ( 54 | TENMS CALIB = 0xFFFFFF << 0 //+ Calibration value 55 | ) 56 | 57 | const ( 58 | TENMSn = 0 59 | ) 60 | -------------------------------------------------------------------------------- /p/stk/stm32f407.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32f407 4 | 5 | // Package stk provides access to the registers of the STK peripheral. 6 | // 7 | // Instances: 8 | // 9 | // STK STK_BASE - - SysTick timer 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 CTRL SysTick control and status register 14 | // 0x004 32 LOAD SysTick reload value register 15 | // 0x008 32 VAL SysTick current value register 16 | // 0x00C 32 CALIB SysTick calibration value register 17 | // 18 | // Import: 19 | // 20 | // github.com/embeddedgo/stm32/p/mmap 21 | package stk 22 | 23 | const ( 24 | ENABLE CTRL = 0x01 << 0 //+ Counter enable 25 | TICKINT CTRL = 0x01 << 1 //+ SysTick exception request enable 26 | CLKSOURCE CTRL = 0x01 << 2 //+ Clock source selection 27 | COUNTFLAG CTRL = 0x01 << 16 //+ COUNTFLAG 28 | ) 29 | 30 | const ( 31 | ENABLEn = 0 32 | TICKINTn = 1 33 | CLKSOURCEn = 2 34 | COUNTFLAGn = 16 35 | ) 36 | 37 | const ( 38 | RELOAD LOAD = 0xFFFFFF << 0 //+ RELOAD value 39 | ) 40 | 41 | const ( 42 | RELOADn = 0 43 | ) 44 | 45 | const ( 46 | CURRENT VAL = 0xFFFFFF << 0 //+ Current counter value 47 | ) 48 | 49 | const ( 50 | CURRENTn = 0 51 | ) 52 | 53 | const ( 54 | TENMS CALIB = 0xFFFFFF << 0 //+ Calibration value 55 | SKEW CALIB = 0x01 << 30 //+ SKEW flag: Indicates whether the TENMS value is exact 56 | NOREF CALIB = 0x01 << 31 //+ NOREF flag. Reads as zero 57 | ) 58 | 59 | const ( 60 | TENMSn = 0 61 | SKEWn = 30 62 | NOREFn = 31 63 | ) 64 | -------------------------------------------------------------------------------- /p/stk/stm32f412.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32f412 4 | 5 | // Package stk provides access to the registers of the STK peripheral. 6 | // 7 | // Instances: 8 | // 9 | // STK STK_BASE - - SysTick timer 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 CTRL SysTick control and status register 14 | // 0x004 32 LOAD SysTick reload value register 15 | // 0x008 32 VAL SysTick current value register 16 | // 0x00C 32 CALIB SysTick calibration value register 17 | // 18 | // Import: 19 | // 20 | // github.com/embeddedgo/stm32/p/mmap 21 | package stk 22 | 23 | const ( 24 | ENABLE CTRL = 0x01 << 0 //+ Counter enable 25 | TICKINT CTRL = 0x01 << 1 //+ SysTick exception request enable 26 | CLKSOURCE CTRL = 0x01 << 2 //+ Clock source selection 27 | COUNTFLAG CTRL = 0x01 << 16 //+ COUNTFLAG 28 | ) 29 | 30 | const ( 31 | ENABLEn = 0 32 | TICKINTn = 1 33 | CLKSOURCEn = 2 34 | COUNTFLAGn = 16 35 | ) 36 | 37 | const ( 38 | RELOAD LOAD = 0xFFFFFF << 0 //+ RELOAD value 39 | ) 40 | 41 | const ( 42 | RELOADn = 0 43 | ) 44 | 45 | const ( 46 | CURRENT VAL = 0xFFFFFF << 0 //+ Current counter value 47 | ) 48 | 49 | const ( 50 | CURRENTn = 0 51 | ) 52 | 53 | const ( 54 | TENMS CALIB = 0xFFFFFF << 0 //+ Calibration value 55 | SKEW CALIB = 0x01 << 30 //+ SKEW flag: Indicates whether the TENMS value is exact 56 | NOREF CALIB = 0x01 << 31 //+ NOREF flag. Reads as zero 57 | ) 58 | 59 | const ( 60 | TENMSn = 0 61 | SKEWn = 30 62 | NOREFn = 31 63 | ) 64 | -------------------------------------------------------------------------------- /p/stk/stm32g471xx.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32g471xx 4 | 5 | // Package stk provides access to the registers of the STK peripheral. 6 | // 7 | // Instances: 8 | // 9 | // STK STK_BASE - - SysTick timer 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 CTRL SysTick control and status register 14 | // 0x004 32 LOAD SysTick reload value register 15 | // 0x008 32 VAL SysTick current value register 16 | // 0x00C 32 CALIB SysTick calibration value register 17 | // 18 | // Import: 19 | // 20 | // github.com/embeddedgo/stm32/p/mmap 21 | package stk 22 | 23 | const ( 24 | ENABLE CTRL = 0x01 << 0 //+ Counter enable 25 | TICKINT CTRL = 0x01 << 1 //+ SysTick exception request enable 26 | CLKSOURCE CTRL = 0x01 << 2 //+ Clock source selection 27 | COUNTFLAG CTRL = 0x01 << 16 //+ COUNTFLAG 28 | ) 29 | 30 | const ( 31 | ENABLEn = 0 32 | TICKINTn = 1 33 | CLKSOURCEn = 2 34 | COUNTFLAGn = 16 35 | ) 36 | 37 | const ( 38 | RELOAD LOAD = 0xFFFFFF << 0 //+ RELOAD value 39 | ) 40 | 41 | const ( 42 | RELOADn = 0 43 | ) 44 | 45 | const ( 46 | CURRENT VAL = 0xFFFFFF << 0 //+ Current counter value 47 | ) 48 | 49 | const ( 50 | CURRENTn = 0 51 | ) 52 | 53 | const ( 54 | TENMS CALIB = 0xFFFFFF << 0 //+ Calibration value 55 | SKEW CALIB = 0x01 << 30 //+ SKEW flag: Indicates whether the TENMS value is exact 56 | NOREF CALIB = 0x01 << 31 //+ NOREF flag. Reads as zero 57 | ) 58 | 59 | const ( 60 | TENMSn = 0 61 | SKEWn = 30 62 | NOREFn = 31 63 | ) 64 | -------------------------------------------------------------------------------- /p/stk/stm32l4x6.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32l4x6 4 | 5 | // Package stk provides access to the registers of the STK peripheral. 6 | // 7 | // Instances: 8 | // 9 | // STK STK_BASE - - SysTick timer 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 CTRL SysTick control and status register 14 | // 0x004 32 LOAD SysTick reload value register 15 | // 0x008 32 VAL SysTick current value register 16 | // 0x00C 32 CALIB SysTick calibration value register 17 | // 18 | // Import: 19 | // 20 | // github.com/embeddedgo/stm32/p/mmap 21 | package stk 22 | 23 | const ( 24 | ENABLE CTRL = 0x01 << 0 //+ Counter enable 25 | TICKINT CTRL = 0x01 << 1 //+ SysTick exception request enable 26 | CLKSOURCE CTRL = 0x01 << 2 //+ Clock source selection 27 | COUNTFLAG CTRL = 0x01 << 16 //+ COUNTFLAG 28 | ) 29 | 30 | const ( 31 | ENABLEn = 0 32 | TICKINTn = 1 33 | CLKSOURCEn = 2 34 | COUNTFLAGn = 16 35 | ) 36 | 37 | const ( 38 | RELOAD LOAD = 0xFFFFFF << 0 //+ RELOAD value 39 | ) 40 | 41 | const ( 42 | RELOADn = 0 43 | ) 44 | 45 | const ( 46 | CURRENT VAL = 0xFFFFFF << 0 //+ Current counter value 47 | ) 48 | 49 | const ( 50 | CURRENTn = 0 51 | ) 52 | 53 | const ( 54 | TENMS CALIB = 0xFFFFFF << 0 //+ Calibration value 55 | SKEW CALIB = 0x01 << 30 //+ SKEW flag: Indicates whether the TENMS value is exact 56 | NOREF CALIB = 0x01 << 31 //+ NOREF flag. Reads as zero 57 | ) 58 | 59 | const ( 60 | TENMSn = 0 61 | SKEWn = 30 62 | NOREFn = 31 63 | ) 64 | -------------------------------------------------------------------------------- /p/syscfg/stm32f215.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32f215 4 | 5 | // Package syscfg provides access to the registers of the SYSCFG peripheral. 6 | // 7 | // Instances: 8 | // 9 | // SYSCFG SYSCFG_BASE APB2 - System configuration controller 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 MEMRM memory remap register 14 | // 0x004 32 PMC peripheral mode configuration register 15 | // 0x008 32 EXTICR[4] select GPIO port for EXTI line (4 x 4bit) 16 | // 0x020 32 CMPCR Compensation cell control register 17 | // 18 | // Import: 19 | // 20 | // github.com/embeddedgo/stm32/p/bus 21 | // github.com/embeddedgo/stm32/p/mmap 22 | package syscfg 23 | 24 | const ( 25 | MEM_MODE MEMRM = 0x03 << 0 //+ MEM_MODE 26 | ) 27 | 28 | const ( 29 | MEM_MODEn = 0 30 | ) 31 | 32 | const ( 33 | MII_RMII_SEL PMC = 0x01 << 23 //+ Ethernet PHY interface selection 34 | ) 35 | 36 | const ( 37 | MII_RMII_SELn = 23 38 | ) 39 | 40 | const ( 41 | CMP_PD CMPCR = 0x01 << 0 //+ Compensation cell power-down 42 | READY CMPCR = 0x01 << 7 //+ READY 43 | ) 44 | 45 | const ( 46 | CMP_PDn = 0 47 | READYn = 7 48 | ) 49 | -------------------------------------------------------------------------------- /p/syscfg/stm32f407.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32f407 4 | 5 | // Package syscfg provides access to the registers of the SYSCFG peripheral. 6 | // 7 | // Instances: 8 | // 9 | // SYSCFG SYSCFG_BASE APB2 - System configuration controller 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 MEMRM memory remap register 14 | // 0x004 32 PMC peripheral mode configuration register 15 | // 0x008 32 EXTICR[4] select GPIO port for EXTI line (4 x 4bit) 16 | // 0x020 32 CMPCR Compensation cell control register 17 | // 18 | // Import: 19 | // 20 | // github.com/embeddedgo/stm32/p/bus 21 | // github.com/embeddedgo/stm32/p/mmap 22 | package syscfg 23 | 24 | const ( 25 | MEM_MODE MEMRM = 0x03 << 0 //+ MEM_MODE 26 | ) 27 | 28 | const ( 29 | MEM_MODEn = 0 30 | ) 31 | 32 | const ( 33 | MII_RMII_SEL PMC = 0x01 << 23 //+ Ethernet PHY interface selection 34 | ) 35 | 36 | const ( 37 | MII_RMII_SELn = 23 38 | ) 39 | 40 | const ( 41 | CMP_PD CMPCR = 0x01 << 0 //+ Compensation cell power-down 42 | READY CMPCR = 0x01 << 8 //+ READY 43 | ) 44 | 45 | const ( 46 | CMP_PDn = 0 47 | READYn = 8 48 | ) 49 | -------------------------------------------------------------------------------- /p/syscfg/stm32f412.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32f412 4 | 5 | // Package syscfg provides access to the registers of the SYSCFG peripheral. 6 | // 7 | // Instances: 8 | // 9 | // SYSCFG SYSCFG_BASE APB2 - System configuration controller 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 MEMRM memory remap register 14 | // 0x004 32 PMC peripheral mode configuration register 15 | // 0x008 32 EXTICR[4] select GPIO port for EXTI line (4 x 4bit) 16 | // 0x020 32 CMPCR Compensation cell control register 17 | // 0x02C 32 I2C_BUFOUT I2C_BUFOUT 18 | // 19 | // Import: 20 | // 21 | // github.com/embeddedgo/stm32/p/bus 22 | // github.com/embeddedgo/stm32/p/mmap 23 | package syscfg 24 | 25 | const ( 26 | MEM_MODE MEMRM = 0x03 << 0 //+ MEM_MODE 27 | ) 28 | 29 | const ( 30 | MEM_MODEn = 0 31 | ) 32 | 33 | const ( 34 | ADC1DC2 PMC = 0x01 << 16 //+ ADC1DC2 35 | ) 36 | 37 | const ( 38 | ADC1DC2n = 16 39 | ) 40 | 41 | const ( 42 | CMP_PD CMPCR = 0x01 << 0 //+ Compensation cell power-down 43 | READY CMPCR = 0x01 << 8 //+ READY 44 | ) 45 | 46 | const ( 47 | CMP_PDn = 0 48 | READYn = 8 49 | ) 50 | 51 | const ( 52 | I2C4SCL I2C_BUFOUT = 0x01 << 0 //+ I2C4SCL 53 | I2C4SDA I2C_BUFOUT = 0x01 << 1 //+ I2C4SDA 54 | ) 55 | 56 | const ( 57 | I2C4SCLn = 0 58 | I2C4SDAn = 1 59 | ) 60 | -------------------------------------------------------------------------------- /p/syscfg/xstm32f215.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY xgen. 2 | 3 | //go:build stm32f215 4 | 5 | package syscfg 6 | 7 | import ( 8 | "embedded/mmio" 9 | "unsafe" 10 | 11 | "github.com/embeddedgo/stm32/p/bus" 12 | "github.com/embeddedgo/stm32/p/mmap" 13 | ) 14 | 15 | type Periph struct { 16 | MEMRM mmio.R32[MEMRM] 17 | PMC mmio.R32[PMC] 18 | EXTICR [4]mmio.R32[uint32] 19 | _ [2]uint32 20 | CMPCR mmio.R32[CMPCR] 21 | } 22 | 23 | func SYSCFG() *Periph { return (*Periph)(unsafe.Pointer(uintptr(mmap.SYSCFG_BASE))) } 24 | 25 | func (p *Periph) BaseAddr() uintptr { 26 | return uintptr(unsafe.Pointer(p)) 27 | } 28 | 29 | func (p *Periph) Bus() bus.Bus { 30 | return bus.APB2 31 | } 32 | 33 | type MEMRM uint32 34 | 35 | func MEM_MODE_(p *Periph) mmio.RM32[MEMRM] { return mmio.RM32[MEMRM]{&p.MEMRM, MEM_MODE} } 36 | 37 | type PMC uint32 38 | 39 | func MII_RMII_SEL_(p *Periph) mmio.RM32[PMC] { return mmio.RM32[PMC]{&p.PMC, MII_RMII_SEL} } 40 | 41 | type CMPCR uint32 42 | 43 | func CMP_PD_(p *Periph) mmio.RM32[CMPCR] { return mmio.RM32[CMPCR]{&p.CMPCR, CMP_PD} } 44 | func READY_(p *Periph) mmio.RM32[CMPCR] { return mmio.RM32[CMPCR]{&p.CMPCR, READY} } 45 | -------------------------------------------------------------------------------- /p/syscfg/xstm32f407.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY xgen. 2 | 3 | //go:build stm32f407 4 | 5 | package syscfg 6 | 7 | import ( 8 | "embedded/mmio" 9 | "unsafe" 10 | 11 | "github.com/embeddedgo/stm32/p/bus" 12 | "github.com/embeddedgo/stm32/p/mmap" 13 | ) 14 | 15 | type Periph struct { 16 | MEMRM mmio.R32[MEMRM] 17 | PMC mmio.R32[PMC] 18 | EXTICR [4]mmio.R32[uint32] 19 | _ [2]uint32 20 | CMPCR mmio.R32[CMPCR] 21 | } 22 | 23 | func SYSCFG() *Periph { return (*Periph)(unsafe.Pointer(uintptr(mmap.SYSCFG_BASE))) } 24 | 25 | func (p *Periph) BaseAddr() uintptr { 26 | return uintptr(unsafe.Pointer(p)) 27 | } 28 | 29 | func (p *Periph) Bus() bus.Bus { 30 | return bus.APB2 31 | } 32 | 33 | type MEMRM uint32 34 | 35 | func MEM_MODE_(p *Periph) mmio.RM32[MEMRM] { return mmio.RM32[MEMRM]{&p.MEMRM, MEM_MODE} } 36 | 37 | type PMC uint32 38 | 39 | func MII_RMII_SEL_(p *Periph) mmio.RM32[PMC] { return mmio.RM32[PMC]{&p.PMC, MII_RMII_SEL} } 40 | 41 | type CMPCR uint32 42 | 43 | func CMP_PD_(p *Periph) mmio.RM32[CMPCR] { return mmio.RM32[CMPCR]{&p.CMPCR, CMP_PD} } 44 | func READY_(p *Periph) mmio.RM32[CMPCR] { return mmio.RM32[CMPCR]{&p.CMPCR, READY} } 45 | -------------------------------------------------------------------------------- /p/syscfg/xstm32f412.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY xgen. 2 | 3 | //go:build stm32f412 4 | 5 | package syscfg 6 | 7 | import ( 8 | "embedded/mmio" 9 | "unsafe" 10 | 11 | "github.com/embeddedgo/stm32/p/bus" 12 | "github.com/embeddedgo/stm32/p/mmap" 13 | ) 14 | 15 | type Periph struct { 16 | MEMRM mmio.R32[MEMRM] 17 | PMC mmio.R32[PMC] 18 | EXTICR [4]mmio.R32[uint32] 19 | _ [2]uint32 20 | CMPCR mmio.R32[CMPCR] 21 | _ [2]uint32 22 | I2C_BUFOUT mmio.R32[I2C_BUFOUT] 23 | } 24 | 25 | func SYSCFG() *Periph { return (*Periph)(unsafe.Pointer(uintptr(mmap.SYSCFG_BASE))) } 26 | 27 | func (p *Periph) BaseAddr() uintptr { 28 | return uintptr(unsafe.Pointer(p)) 29 | } 30 | 31 | func (p *Periph) Bus() bus.Bus { 32 | return bus.APB2 33 | } 34 | 35 | type MEMRM uint32 36 | 37 | func MEM_MODE_(p *Periph) mmio.RM32[MEMRM] { return mmio.RM32[MEMRM]{&p.MEMRM, MEM_MODE} } 38 | 39 | type PMC uint32 40 | 41 | func ADC1DC2_(p *Periph) mmio.RM32[PMC] { return mmio.RM32[PMC]{&p.PMC, ADC1DC2} } 42 | 43 | type CMPCR uint32 44 | 45 | func CMP_PD_(p *Periph) mmio.RM32[CMPCR] { return mmio.RM32[CMPCR]{&p.CMPCR, CMP_PD} } 46 | func READY_(p *Periph) mmio.RM32[CMPCR] { return mmio.RM32[CMPCR]{&p.CMPCR, READY} } 47 | 48 | type I2C_BUFOUT uint32 49 | 50 | func I2C4SCL_(p *Periph) mmio.RM32[I2C_BUFOUT] { return mmio.RM32[I2C_BUFOUT]{&p.I2C_BUFOUT, I2C4SCL} } 51 | func I2C4SDA_(p *Periph) mmio.RM32[I2C_BUFOUT] { return mmio.RM32[I2C_BUFOUT]{&p.I2C_BUFOUT, I2C4SDA} } 52 | -------------------------------------------------------------------------------- /p/usb_otg_fs/otg_fs_pwrclk/stm32f215.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32f215 4 | 5 | // Package otg_fs_pwrclk provides access to the registers of the OTG_FS_PWRCLK peripheral. 6 | // 7 | // Instances: 8 | // 9 | // OTG_FS_PWRCLK OTG_FS_PWRCLK_BASE - - USB on the go full speed 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 FS_PCGCCTL OTG_FS power and clock gating control register (OTG_FS_PCGCCTL) 14 | // 15 | // Import: 16 | // 17 | // github.com/embeddedgo/stm32/p/mmap 18 | package otg_fs_pwrclk 19 | 20 | const ( 21 | STPPCLK FS_PCGCCTL = 0x01 << 0 //+ Stop PHY clock 22 | GATEHCLK FS_PCGCCTL = 0x01 << 1 //+ Gate HCLK 23 | PHYSUSP FS_PCGCCTL = 0x01 << 4 //+ PHY Suspended 24 | ) 25 | 26 | const ( 27 | STPPCLKn = 0 28 | GATEHCLKn = 1 29 | PHYSUSPn = 4 30 | ) 31 | -------------------------------------------------------------------------------- /p/usb_otg_fs/otg_fs_pwrclk/stm32f407.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32f407 4 | 5 | // Package otg_fs_pwrclk provides access to the registers of the OTG_FS_PWRCLK peripheral. 6 | // 7 | // Instances: 8 | // 9 | // OTG_FS_PWRCLK OTG_FS_PWRCLK_BASE - - USB on the go full speed 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 FS_PCGCCTL OTG_FS power and clock gating control register 14 | // 15 | // Import: 16 | // 17 | // github.com/embeddedgo/stm32/p/mmap 18 | package otg_fs_pwrclk 19 | 20 | const ( 21 | STPPCLK FS_PCGCCTL = 0x01 << 0 //+ Stop PHY clock 22 | GATEHCLK FS_PCGCCTL = 0x01 << 1 //+ Gate HCLK 23 | PHYSUSP FS_PCGCCTL = 0x01 << 4 //+ PHY Suspended 24 | ) 25 | 26 | const ( 27 | STPPCLKn = 0 28 | GATEHCLKn = 1 29 | PHYSUSPn = 4 30 | ) 31 | -------------------------------------------------------------------------------- /p/usb_otg_fs/otg_fs_pwrclk/stm32f412.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32f412 4 | 5 | // Package otg_fs_pwrclk provides access to the registers of the OTG_FS_PWRCLK peripheral. 6 | // 7 | // Instances: 8 | // 9 | // OTG_FS_PWRCLK OTG_FS_PWRCLK_BASE - - USB on the go full speed 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 FS_PCGCCTL OTG_FS power and clock gating control register (OTG_FS_PCGCCTL) 14 | // 15 | // Import: 16 | // 17 | // github.com/embeddedgo/stm32/p/mmap 18 | package otg_fs_pwrclk 19 | 20 | const ( 21 | STPPCLK FS_PCGCCTL = 0x01 << 0 //+ Stop PHY clock 22 | GATEHCLK FS_PCGCCTL = 0x01 << 1 //+ Gate HCLK 23 | PHYSUSP FS_PCGCCTL = 0x01 << 4 //+ PHY Suspended 24 | ) 25 | 26 | const ( 27 | STPPCLKn = 0 28 | GATEHCLKn = 1 29 | PHYSUSPn = 4 30 | ) 31 | -------------------------------------------------------------------------------- /p/usb_otg_fs/otg_fs_pwrclk/stm32l4x6.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32l4x6 4 | 5 | // Package otg_fs_pwrclk provides access to the registers of the OTG_FS_PWRCLK peripheral. 6 | // 7 | // Instances: 8 | // 9 | // OTG_FS_PWRCLK OTG_FS_PWRCLK_BASE - - USB on the go full speed 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 FS_PCGCCTL OTG_FS power and clock gating control register (OTG_FS_PCGCCTL) 14 | // 15 | // Import: 16 | // 17 | // github.com/embeddedgo/stm32/p/mmap 18 | package otg_fs_pwrclk 19 | 20 | const ( 21 | STPPCLK FS_PCGCCTL = 0x01 << 0 //+ Stop PHY clock 22 | GATEHCLK FS_PCGCCTL = 0x01 << 1 //+ Gate HCLK 23 | PHYSUSP FS_PCGCCTL = 0x01 << 4 //+ PHY Suspended 24 | ) 25 | 26 | const ( 27 | STPPCLKn = 0 28 | GATEHCLKn = 1 29 | PHYSUSPn = 4 30 | ) 31 | -------------------------------------------------------------------------------- /p/usb_otg_hs/otg_hs_pwrclk/stm32f215.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32f215 4 | 5 | // Package otg_hs_pwrclk provides access to the registers of the OTG_HS_PWRCLK peripheral. 6 | // 7 | // Instances: 8 | // 9 | // OTG_HS_PWRCLK OTG_HS_PWRCLK_BASE - - USB on the go high speed 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 OTG_HS_PCGCR Power and clock gating control register 14 | // 15 | // Import: 16 | // 17 | // github.com/embeddedgo/stm32/p/mmap 18 | package otg_hs_pwrclk 19 | 20 | const ( 21 | STPPCLK OTG_HS_PCGCR = 0x01 << 0 //+ Stop PHY clock 22 | GATEHCLK OTG_HS_PCGCR = 0x01 << 1 //+ Gate HCLK 23 | PHYSUSP OTG_HS_PCGCR = 0x01 << 4 //+ PHY suspended 24 | ) 25 | 26 | const ( 27 | STPPCLKn = 0 28 | GATEHCLKn = 1 29 | PHYSUSPn = 4 30 | ) 31 | -------------------------------------------------------------------------------- /p/usb_otg_hs/otg_hs_pwrclk/stm32f407.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32f407 4 | 5 | // Package otg_hs_pwrclk provides access to the registers of the OTG_HS_PWRCLK peripheral. 6 | // 7 | // Instances: 8 | // 9 | // OTG_HS_PWRCLK OTG_HS_PWRCLK_BASE - - USB on the go high speed 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 OTG_HS_PCGCR Power and clock gating control register 14 | // 15 | // Import: 16 | // 17 | // github.com/embeddedgo/stm32/p/mmap 18 | package otg_hs_pwrclk 19 | 20 | const ( 21 | STPPCLK OTG_HS_PCGCR = 0x01 << 0 //+ Stop PHY clock 22 | GATEHCLK OTG_HS_PCGCR = 0x01 << 1 //+ Gate HCLK 23 | PHYSUSP OTG_HS_PCGCR = 0x01 << 4 //+ PHY suspended 24 | ) 25 | 26 | const ( 27 | STPPCLKn = 0 28 | GATEHCLKn = 1 29 | PHYSUSPn = 4 30 | ) 31 | -------------------------------------------------------------------------------- /p/usb_otg_hs/otg_hs_pwrclk/stm32h7x3.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32h7x3 4 | 5 | // Package otg_hs_pwrclk provides access to the registers of the OTG1_HS_PWRCLK peripheral. 6 | // 7 | // Instances: 8 | // 9 | // OTG1_HS_PWRCLK OTG1_HS_PWRCLK_BASE - - USB 1 on the go high speed 10 | // OTG2_HS_PWRCLK OTG2_HS_PWRCLK_BASE - - USB 1 on the go high speed 11 | // 12 | // Registers: 13 | // 14 | // 0x000 32 OTG_HS_PCGCR Power and clock gating control register 15 | // 16 | // Import: 17 | // 18 | // github.com/embeddedgo/stm32/p/mmap 19 | package otg_hs_pwrclk 20 | 21 | const ( 22 | STPPCLK OTG_HS_PCGCR = 0x01 << 0 //+ Stop PHY clock 23 | GATEHCLK OTG_HS_PCGCR = 0x01 << 1 //+ Gate HCLK 24 | PHYSUSP OTG_HS_PCGCR = 0x01 << 4 //+ PHY suspended 25 | ) 26 | 27 | const ( 28 | STPPCLKn = 0 29 | GATEHCLKn = 1 30 | PHYSUSPn = 4 31 | ) 32 | -------------------------------------------------------------------------------- /p/vref/stm32l4x6.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32l4x6 4 | 5 | // Package vref provides access to the registers of the VREFBUF peripheral. 6 | // 7 | // Instances: 8 | // 9 | // VREFBUF VREFBUF_BASE - - Voltage reference buffer 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 CSR VREF control and status register 14 | // 0x004 32 CCR calibration control register 15 | // 16 | // Import: 17 | // 18 | // github.com/embeddedgo/stm32/p/mmap 19 | package vref 20 | 21 | const ( 22 | ENVR CSR = 0x01 << 0 //+ Voltage reference buffer enable 23 | HIZ CSR = 0x01 << 1 //+ High impedance mode 24 | VRS CSR = 0x01 << 2 //+ Voltage reference scale 25 | VRR CSR = 0x01 << 3 //+ Voltage reference buffer ready 26 | ) 27 | 28 | const ( 29 | ENVRn = 0 30 | HIZn = 1 31 | VRSn = 2 32 | VRRn = 3 33 | ) 34 | 35 | const ( 36 | TRIM CCR = 0x3F << 0 //+ Trimming code 37 | ) 38 | 39 | const ( 40 | TRIMn = 0 41 | ) 42 | -------------------------------------------------------------------------------- /p/vrefbuf/stm32g471xx.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32g471xx 4 | 5 | // Package vrefbuf provides access to the registers of the VREFBUF peripheral. 6 | // 7 | // Instances: 8 | // 9 | // VREFBUF VREFBUF_BASE - - Voltage reference buffer 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 VREFBUF_CSR VREF_BUF Control and Status Register 14 | // 0x004 32 VREFBUF_CCR VREF_BUF Calibration Control Register 15 | // 16 | // Import: 17 | // 18 | // github.com/embeddedgo/stm32/p/mmap 19 | package vrefbuf 20 | 21 | const ( 22 | ENVR VREFBUF_CSR = 0x01 << 0 //+ Enable Voltage Reference 23 | HIZ VREFBUF_CSR = 0x01 << 1 //+ High impedence mode for the VREF_BUF 24 | VRR VREFBUF_CSR = 0x01 << 3 //+ Voltage reference buffer ready 25 | VRS VREFBUF_CSR = 0x03 << 4 //+ Voltage reference scale 26 | ) 27 | 28 | const ( 29 | ENVRn = 0 30 | HIZn = 1 31 | VRRn = 3 32 | VRSn = 4 33 | ) 34 | 35 | const ( 36 | TRIM VREFBUF_CCR = 0x3F << 0 //+ Trimming code 37 | ) 38 | 39 | const ( 40 | TRIMn = 0 41 | ) 42 | -------------------------------------------------------------------------------- /p/vrefbuf/stm32h7x3.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32h7x3 4 | 5 | // Package vrefbuf provides access to the registers of the VREFBUF peripheral. 6 | // 7 | // Instances: 8 | // 9 | // VREFBUF VREFBUF_BASE - - 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 CSR VREFBUF control and status register 14 | // 0x004 32 CCR VREFBUF calibration control register 15 | // 16 | // Import: 17 | // 18 | // github.com/embeddedgo/stm32/p/mmap 19 | package vrefbuf 20 | 21 | const ( 22 | ENVR CSR = 0x01 << 0 //+ Voltage reference buffer mode enable This bit is used to enable the voltage reference buffer mode. 23 | HIZ CSR = 0x01 << 1 //+ High impedance mode This bit controls the analog switch to connect or not the VREF+ pin. Refer to Table196: VREF buffer modes for the mode descriptions depending on ENVR bit configuration. 24 | VRR CSR = 0x01 << 3 //+ Voltage reference buffer ready 25 | VRS CSR = 0x07 << 4 //+ Voltage reference scale These bits select the value generated by the voltage reference buffer. Other: Reserved 26 | ) 27 | 28 | const ( 29 | ENVRn = 0 30 | HIZn = 1 31 | VRRn = 3 32 | VRSn = 4 33 | ) 34 | 35 | const ( 36 | TRIM CCR = 0x3F << 0 //+ Trimming code These bits are automatically initialized after reset with the trimming value stored in the Flash memory during the production test. Writing into these bits allows to tune the internal reference buffer voltage. 37 | ) 38 | 39 | const ( 40 | TRIMn = 0 41 | ) 42 | -------------------------------------------------------------------------------- /p/wwdg/stm32f215.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32f215 4 | 5 | // Package wwdg provides access to the registers of the WWDG peripheral. 6 | // 7 | // Instances: 8 | // 9 | // WWDG WWDG_BASE APB1 WWDG Window watchdog 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 CR Control register 14 | // 0x004 32 CFR Configuration register 15 | // 0x008 32 SR Status register 16 | // 17 | // Import: 18 | // 19 | // github.com/embeddedgo/stm32/p/bus 20 | // github.com/embeddedgo/stm32/p/mmap 21 | package wwdg 22 | 23 | const ( 24 | T CR = 0x7F << 0 //+ 7-bit counter (MSB to LSB) 25 | WDGA CR = 0x01 << 7 //+ Activation bit 26 | ) 27 | 28 | const ( 29 | Tn = 0 30 | WDGAn = 7 31 | ) 32 | 33 | const ( 34 | W CFR = 0x7F << 0 //+ 7-bit window value 35 | WDGTB CFR = 0x03 << 7 //+ Timer base 36 | EWI CFR = 0x01 << 9 //+ Early wakeup interrupt 37 | ) 38 | 39 | const ( 40 | Wn = 0 41 | WDGTBn = 7 42 | EWIn = 9 43 | ) 44 | 45 | const ( 46 | EWIF SR = 0x01 << 0 //+ Early wakeup interrupt flag 47 | ) 48 | 49 | const ( 50 | EWIFn = 0 51 | ) 52 | -------------------------------------------------------------------------------- /p/wwdg/stm32f407.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32f407 4 | 5 | // Package wwdg provides access to the registers of the WWDG peripheral. 6 | // 7 | // Instances: 8 | // 9 | // WWDG WWDG_BASE APB1 WWDG Window watchdog 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 CR Control register 14 | // 0x004 32 CFR Configuration register 15 | // 0x008 32 SR Status register 16 | // 17 | // Import: 18 | // 19 | // github.com/embeddedgo/stm32/p/bus 20 | // github.com/embeddedgo/stm32/p/mmap 21 | package wwdg 22 | 23 | const ( 24 | T CR = 0x7F << 0 //+ 7-bit counter (MSB to LSB) 25 | WDGA CR = 0x01 << 7 //+ Activation bit 26 | ) 27 | 28 | const ( 29 | Tn = 0 30 | WDGAn = 7 31 | ) 32 | 33 | const ( 34 | W CFR = 0x7F << 0 //+ 7-bit window value 35 | WDGTB0 CFR = 0x01 << 7 //+ Timer base 36 | WDGTB1 CFR = 0x01 << 8 //+ Timer base 37 | EWI CFR = 0x01 << 9 //+ Early wakeup interrupt 38 | ) 39 | 40 | const ( 41 | Wn = 0 42 | WDGTB0n = 7 43 | WDGTB1n = 8 44 | EWIn = 9 45 | ) 46 | 47 | const ( 48 | EWIF SR = 0x01 << 0 //+ Early wakeup interrupt flag 49 | ) 50 | 51 | const ( 52 | EWIFn = 0 53 | ) 54 | -------------------------------------------------------------------------------- /p/wwdg/stm32f412.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32f412 4 | 5 | // Package wwdg provides access to the registers of the WWDG peripheral. 6 | // 7 | // Instances: 8 | // 9 | // WWDG WWDG_BASE APB1 - Window watchdog 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 CR Control register 14 | // 0x004 32 CFR Configuration register 15 | // 0x008 32 SR Status register 16 | // 17 | // Import: 18 | // 19 | // github.com/embeddedgo/stm32/p/bus 20 | // github.com/embeddedgo/stm32/p/mmap 21 | package wwdg 22 | 23 | const ( 24 | T CR = 0x7F << 0 //+ 7-bit counter (MSB to LSB) 25 | WDGA CR = 0x01 << 7 //+ Activation bit 26 | ) 27 | 28 | const ( 29 | Tn = 0 30 | WDGAn = 7 31 | ) 32 | 33 | const ( 34 | W CFR = 0x7F << 0 //+ 7-bit window value 35 | WDGTB0 CFR = 0x01 << 7 //+ Timer base 36 | WDGTB1 CFR = 0x01 << 8 //+ Timer base 37 | EWI CFR = 0x01 << 9 //+ Early wakeup interrupt 38 | ) 39 | 40 | const ( 41 | Wn = 0 42 | WDGTB0n = 7 43 | WDGTB1n = 8 44 | EWIn = 9 45 | ) 46 | 47 | const ( 48 | EWIF SR = 0x01 << 0 //+ Early wakeup interrupt flag 49 | ) 50 | 51 | const ( 52 | EWIFn = 0 53 | ) 54 | -------------------------------------------------------------------------------- /p/wwdg/stm32g471xx.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32g471xx 4 | 5 | // Package wwdg provides access to the registers of the IWDG peripheral. 6 | // 7 | // Instances: 8 | // 9 | // IWDG IWDG_BASE - - System window watchdog 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 CR Control register 14 | // 0x004 32 CFR Configuration register 15 | // 0x008 32 SR Status register 16 | // 17 | // Import: 18 | // 19 | // github.com/embeddedgo/stm32/p/mmap 20 | package wwdg 21 | 22 | const ( 23 | T CR = 0x7F << 0 //+ 7-bit counter (MSB to LSB) 24 | WDGA CR = 0x01 << 7 //+ Activation bit 25 | ) 26 | 27 | const ( 28 | Tn = 0 29 | WDGAn = 7 30 | ) 31 | 32 | const ( 33 | W CFR = 0x7F << 0 //+ 7-bit window value 34 | EWI CFR = 0x01 << 9 //+ Early wakeup interrupt 35 | WDGTB CFR = 0x07 << 11 //+ Timer base 36 | ) 37 | 38 | const ( 39 | Wn = 0 40 | EWIn = 9 41 | WDGTBn = 11 42 | ) 43 | 44 | const ( 45 | EWIF SR = 0x01 << 0 //+ Early wakeup interrupt flag 46 | ) 47 | 48 | const ( 49 | EWIFn = 0 50 | ) 51 | -------------------------------------------------------------------------------- /p/wwdg/stm32l4x6.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE. GENERATED BY svdxgen. 2 | 3 | //go:build stm32l4x6 4 | 5 | // Package wwdg provides access to the registers of the WWDG peripheral. 6 | // 7 | // Instances: 8 | // 9 | // WWDG WWDG_BASE APB1 WWDG System window watchdog 10 | // 11 | // Registers: 12 | // 13 | // 0x000 32 CR Control register 14 | // 0x004 32 CFR Configuration register 15 | // 0x008 32 SR Status register 16 | // 17 | // Import: 18 | // 19 | // github.com/embeddedgo/stm32/p/bus 20 | // github.com/embeddedgo/stm32/p/mmap 21 | package wwdg 22 | 23 | const ( 24 | T CR = 0x7F << 0 //+ 7-bit counter (MSB to LSB) 25 | WDGA CR = 0x01 << 7 //+ Activation bit 26 | ) 27 | 28 | const ( 29 | Tn = 0 30 | WDGAn = 7 31 | ) 32 | 33 | const ( 34 | W CFR = 0x7F << 0 //+ 7-bit window value 35 | WDGTB CFR = 0x03 << 7 //+ Timer base 36 | EWI CFR = 0x01 << 9 //+ Early wakeup interrupt 37 | ) 38 | 39 | const ( 40 | Wn = 0 41 | WDGTBn = 7 42 | EWIn = 9 43 | ) 44 | 45 | const ( 46 | EWIF SR = 0x01 << 0 //+ Early wakeup interrupt flag 47 | ) 48 | 49 | const ( 50 | EWIFn = 0 51 | ) 52 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | Support for [STM32 microcontrollers](https://www.st.com/en/microcontrollers-microprocessors/stm32-32-bit-arm-cortex-mcus.html). 2 | 3 | Contains examples you can run on [supported develompent boards](devboard). 4 | -------------------------------------------------------------------------------- /svd/gen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | cd ../../../embeddedgo/stm32/p 6 | rm -rf * 7 | 8 | svdxgen github.com/embeddedgo/stm32/p ../svd/*.svd 9 | 10 | for p in dma dmamux dmamux/dmamux1 dmamux/dmamux2 exti flash gpio pwr rcc rtc spi syscfg tim; do 11 | cd $p 12 | xgen -g *.go 13 | for f in *.go; do 14 | GOTARGET=$(basename $f .go) 15 | case $GOTARGET in 16 | stm32f*|stm32l*|stm32h*) 17 | GOOS=noos GOARCH=thumb $(emgo env GOROOT)/bin/go build -tags $GOTARGET 18 | ;; 19 | esac 20 | done 21 | cd $OLDPWD 22 | done 23 | 24 | rm -f ../hal/irq/* 25 | 26 | awkscript='{ 27 | gsub("package irq", "package irq\n\nimport \"embedded/rtos\"", $0) 28 | gsub(" = ", " rtos.IRQ = ", $0) 29 | print 30 | }' 31 | cd irq 32 | for f in *; do 33 | awk "$awkscript" $f >../../hal/irq/$f 34 | done 35 | 36 | 37 | --------------------------------------------------------------------------------