├── .gitattributes ├── .gitignore ├── Doc ├── DS12991 STM32G030x6_x8 Datasheet.pdf ├── DS12992 STM32G031x4_x6_x8 Datasheet.pdf ├── DS13866 STM32C0x1 Datasheet.pdf ├── ES0569 STM32C0x1 Errata sheet.pdf ├── RM0444 STM32G0x1 Reference manual.pdf ├── RM0454 STM32G0x0 Reference manual.pdf └── RM0490 STM32C0x1 Reference manual.pdf ├── Examples ├── STM32C011 │ └── 01-RTC │ │ ├── 01-RTC.ioc │ │ ├── Bsp │ │ ├── board.c │ │ └── board.h │ │ ├── Core │ │ ├── Inc │ │ │ ├── gpio.h │ │ │ ├── main.h │ │ │ ├── rtc.h │ │ │ ├── stm32c0xx_hal_conf.h │ │ │ ├── stm32c0xx_it.h │ │ │ └── usart.h │ │ └── Src │ │ │ ├── gpio.c │ │ │ ├── main.c │ │ │ ├── rtc.c │ │ │ ├── stm32c0xx_hal_msp.c │ │ │ ├── stm32c0xx_it.c │ │ │ ├── system_stm32c0xx.c │ │ │ └── usart.c │ │ ├── Drivers │ │ ├── CMSIS │ │ │ ├── Device │ │ │ │ └── ST │ │ │ │ │ └── STM32C0xx │ │ │ │ │ ├── Include │ │ │ │ │ ├── stm32c011xx.h │ │ │ │ │ ├── stm32c0xx.h │ │ │ │ │ └── system_stm32c0xx.h │ │ │ │ │ ├── LICENSE.md │ │ │ │ │ └── LICENSE.txt │ │ │ ├── Include │ │ │ │ ├── cmsis_armcc.h │ │ │ │ ├── cmsis_armclang.h │ │ │ │ ├── cmsis_armclang_ltm.h │ │ │ │ ├── cmsis_compiler.h │ │ │ │ ├── cmsis_gcc.h │ │ │ │ ├── cmsis_iccarm.h │ │ │ │ ├── cmsis_version.h │ │ │ │ ├── core_armv81mml.h │ │ │ │ ├── core_armv8mbl.h │ │ │ │ ├── core_armv8mml.h │ │ │ │ ├── core_cm0.h │ │ │ │ ├── core_cm0plus.h │ │ │ │ ├── core_cm1.h │ │ │ │ ├── core_cm23.h │ │ │ │ ├── core_cm3.h │ │ │ │ ├── core_cm33.h │ │ │ │ ├── core_cm35p.h │ │ │ │ ├── core_cm4.h │ │ │ │ ├── core_cm7.h │ │ │ │ ├── core_sc000.h │ │ │ │ ├── core_sc300.h │ │ │ │ ├── mpu_armv7.h │ │ │ │ ├── mpu_armv8.h │ │ │ │ └── tz_context.h │ │ │ └── LICENSE.txt │ │ └── STM32C0xx_HAL_Driver │ │ │ ├── Inc │ │ │ ├── Legacy │ │ │ │ └── stm32_hal_legacy.h │ │ │ ├── stm32c0xx_hal.h │ │ │ ├── stm32c0xx_hal_cortex.h │ │ │ ├── stm32c0xx_hal_def.h │ │ │ ├── stm32c0xx_hal_dma.h │ │ │ ├── stm32c0xx_hal_dma_ex.h │ │ │ ├── stm32c0xx_hal_exti.h │ │ │ ├── stm32c0xx_hal_flash.h │ │ │ ├── stm32c0xx_hal_flash_ex.h │ │ │ ├── stm32c0xx_hal_gpio.h │ │ │ ├── stm32c0xx_hal_gpio_ex.h │ │ │ ├── stm32c0xx_hal_pwr.h │ │ │ ├── stm32c0xx_hal_pwr_ex.h │ │ │ ├── stm32c0xx_hal_rcc.h │ │ │ ├── stm32c0xx_hal_rcc_ex.h │ │ │ ├── stm32c0xx_hal_rtc.h │ │ │ ├── stm32c0xx_hal_rtc_ex.h │ │ │ ├── stm32c0xx_hal_uart.h │ │ │ ├── stm32c0xx_hal_uart_ex.h │ │ │ ├── stm32c0xx_ll_bus.h │ │ │ ├── stm32c0xx_ll_cortex.h │ │ │ ├── stm32c0xx_ll_dma.h │ │ │ ├── stm32c0xx_ll_dmamux.h │ │ │ ├── stm32c0xx_ll_exti.h │ │ │ ├── stm32c0xx_ll_gpio.h │ │ │ ├── stm32c0xx_ll_pwr.h │ │ │ ├── stm32c0xx_ll_rcc.h │ │ │ ├── stm32c0xx_ll_rtc.h │ │ │ ├── stm32c0xx_ll_system.h │ │ │ ├── stm32c0xx_ll_usart.h │ │ │ └── stm32c0xx_ll_utils.h │ │ │ ├── LICENSE.md │ │ │ ├── LICENSE.txt │ │ │ └── Src │ │ │ ├── stm32c0xx_hal.c │ │ │ ├── stm32c0xx_hal_cortex.c │ │ │ ├── stm32c0xx_hal_dma.c │ │ │ ├── stm32c0xx_hal_dma_ex.c │ │ │ ├── stm32c0xx_hal_exti.c │ │ │ ├── stm32c0xx_hal_flash.c │ │ │ ├── stm32c0xx_hal_flash_ex.c │ │ │ ├── stm32c0xx_hal_gpio.c │ │ │ ├── stm32c0xx_hal_pwr.c │ │ │ ├── stm32c0xx_hal_pwr_ex.c │ │ │ ├── stm32c0xx_hal_rcc.c │ │ │ ├── stm32c0xx_hal_rcc_ex.c │ │ │ ├── stm32c0xx_hal_rtc.c │ │ │ ├── stm32c0xx_hal_rtc_ex.c │ │ │ ├── stm32c0xx_hal_uart.c │ │ │ └── stm32c0xx_hal_uart_ex.c │ │ └── MDK-ARM │ │ ├── 01-RTC.uvoptx │ │ ├── 01-RTC.uvprojx │ │ ├── 01-RTC │ │ ├── 01-RTC.axf │ │ └── 01-RTC.hex │ │ ├── RTE │ │ └── _01-RTC │ │ │ └── RTE_Components.h │ │ └── startup_stm32c011xx.s ├── STM32G030 │ └── 01-RTC │ │ ├── 01-RTC.ioc │ │ ├── Bsp │ │ ├── board.c │ │ └── board.h │ │ ├── Core │ │ ├── Inc │ │ │ ├── gpio.h │ │ │ ├── main.h │ │ │ ├── rtc.h │ │ │ ├── stm32g0xx_hal_conf.h │ │ │ ├── stm32g0xx_it.h │ │ │ └── usart.h │ │ └── Src │ │ │ ├── gpio.c │ │ │ ├── main.c │ │ │ ├── rtc.c │ │ │ ├── stm32g0xx_hal_msp.c │ │ │ ├── stm32g0xx_it.c │ │ │ ├── system_stm32g0xx.c │ │ │ └── usart.c │ │ ├── Drivers │ │ ├── CMSIS │ │ │ ├── Device │ │ │ │ └── ST │ │ │ │ │ └── STM32G0xx │ │ │ │ │ ├── Include │ │ │ │ │ ├── stm32g030xx.h │ │ │ │ │ ├── stm32g0xx.h │ │ │ │ │ └── system_stm32g0xx.h │ │ │ │ │ └── LICENSE.txt │ │ │ ├── Include │ │ │ │ ├── cmsis_armcc.h │ │ │ │ ├── cmsis_armclang.h │ │ │ │ ├── cmsis_armclang_ltm.h │ │ │ │ ├── cmsis_compiler.h │ │ │ │ ├── cmsis_gcc.h │ │ │ │ ├── cmsis_iccarm.h │ │ │ │ ├── cmsis_version.h │ │ │ │ ├── core_armv81mml.h │ │ │ │ ├── core_armv8mbl.h │ │ │ │ ├── core_armv8mml.h │ │ │ │ ├── core_cm0.h │ │ │ │ ├── core_cm0plus.h │ │ │ │ ├── core_cm1.h │ │ │ │ ├── core_cm23.h │ │ │ │ ├── core_cm3.h │ │ │ │ ├── core_cm33.h │ │ │ │ ├── core_cm35p.h │ │ │ │ ├── core_cm4.h │ │ │ │ ├── core_cm7.h │ │ │ │ ├── core_sc000.h │ │ │ │ ├── core_sc300.h │ │ │ │ ├── mpu_armv7.h │ │ │ │ ├── mpu_armv8.h │ │ │ │ └── tz_context.h │ │ │ └── LICENSE.txt │ │ └── STM32G0xx_HAL_Driver │ │ │ ├── Inc │ │ │ ├── Legacy │ │ │ │ └── stm32_hal_legacy.h │ │ │ ├── stm32g0xx_hal.h │ │ │ ├── stm32g0xx_hal_cortex.h │ │ │ ├── stm32g0xx_hal_def.h │ │ │ ├── stm32g0xx_hal_dma.h │ │ │ ├── stm32g0xx_hal_dma_ex.h │ │ │ ├── stm32g0xx_hal_exti.h │ │ │ ├── stm32g0xx_hal_flash.h │ │ │ ├── stm32g0xx_hal_flash_ex.h │ │ │ ├── stm32g0xx_hal_gpio.h │ │ │ ├── stm32g0xx_hal_gpio_ex.h │ │ │ ├── stm32g0xx_hal_pwr.h │ │ │ ├── stm32g0xx_hal_pwr_ex.h │ │ │ ├── stm32g0xx_hal_rcc.h │ │ │ ├── stm32g0xx_hal_rcc_ex.h │ │ │ ├── stm32g0xx_hal_rtc.h │ │ │ ├── stm32g0xx_hal_rtc_ex.h │ │ │ ├── stm32g0xx_hal_tim.h │ │ │ ├── stm32g0xx_hal_tim_ex.h │ │ │ ├── stm32g0xx_hal_uart.h │ │ │ ├── stm32g0xx_hal_uart_ex.h │ │ │ ├── stm32g0xx_ll_bus.h │ │ │ ├── stm32g0xx_ll_cortex.h │ │ │ ├── stm32g0xx_ll_dma.h │ │ │ ├── stm32g0xx_ll_dmamux.h │ │ │ ├── stm32g0xx_ll_exti.h │ │ │ ├── stm32g0xx_ll_gpio.h │ │ │ ├── stm32g0xx_ll_lpuart.h │ │ │ ├── stm32g0xx_ll_pwr.h │ │ │ ├── stm32g0xx_ll_rcc.h │ │ │ ├── stm32g0xx_ll_rtc.h │ │ │ ├── stm32g0xx_ll_system.h │ │ │ ├── stm32g0xx_ll_usart.h │ │ │ └── stm32g0xx_ll_utils.h │ │ │ ├── LICENSE.txt │ │ │ └── Src │ │ │ ├── stm32g0xx_hal.c │ │ │ ├── stm32g0xx_hal_cortex.c │ │ │ ├── stm32g0xx_hal_dma.c │ │ │ ├── stm32g0xx_hal_dma_ex.c │ │ │ ├── stm32g0xx_hal_exti.c │ │ │ ├── stm32g0xx_hal_flash.c │ │ │ ├── stm32g0xx_hal_flash_ex.c │ │ │ ├── stm32g0xx_hal_gpio.c │ │ │ ├── stm32g0xx_hal_pwr.c │ │ │ ├── stm32g0xx_hal_pwr_ex.c │ │ │ ├── stm32g0xx_hal_rcc.c │ │ │ ├── stm32g0xx_hal_rcc_ex.c │ │ │ ├── stm32g0xx_hal_rtc.c │ │ │ ├── stm32g0xx_hal_rtc_ex.c │ │ │ ├── stm32g0xx_hal_tim.c │ │ │ ├── stm32g0xx_hal_tim_ex.c │ │ │ ├── stm32g0xx_hal_uart.c │ │ │ ├── stm32g0xx_hal_uart_ex.c │ │ │ ├── stm32g0xx_ll_dma.c │ │ │ └── stm32g0xx_ll_rcc.c │ │ └── MDK-ARM │ │ ├── 01-RTC.uvoptx │ │ ├── 01-RTC.uvprojx │ │ ├── 01-RTC │ │ ├── 01-RTC.axf │ │ └── 01-RTC.hex │ │ ├── DebugConfig │ │ └── 01-RTC_STM32G030F6Px_1.0.0.dbgconf │ │ ├── EventRecorderStub.scvd │ │ ├── RTE │ │ └── _01-RTC │ │ │ └── RTE_Components.h │ │ └── startup_stm32g030xx.s ├── STM32G031 │ └── 01-RTC │ │ ├── 01-RTC.ioc │ │ ├── Bsp │ │ ├── board.c │ │ └── board.h │ │ ├── Core │ │ ├── Inc │ │ │ ├── gpio.h │ │ │ ├── main.h │ │ │ ├── rtc.h │ │ │ ├── stm32g0xx_hal_conf.h │ │ │ ├── stm32g0xx_it.h │ │ │ └── usart.h │ │ └── Src │ │ │ ├── gpio.c │ │ │ ├── main.c │ │ │ ├── rtc.c │ │ │ ├── stm32g0xx_hal_msp.c │ │ │ ├── stm32g0xx_it.c │ │ │ ├── system_stm32g0xx.c │ │ │ └── usart.c │ │ ├── Drivers │ │ ├── CMSIS │ │ │ ├── Device │ │ │ │ └── ST │ │ │ │ │ └── STM32G0xx │ │ │ │ │ ├── Include │ │ │ │ │ ├── stm32g031xx.h │ │ │ │ │ ├── stm32g0xx.h │ │ │ │ │ └── system_stm32g0xx.h │ │ │ │ │ └── LICENSE.txt │ │ │ ├── Include │ │ │ │ ├── cmsis_armcc.h │ │ │ │ ├── cmsis_armclang.h │ │ │ │ ├── cmsis_armclang_ltm.h │ │ │ │ ├── cmsis_compiler.h │ │ │ │ ├── cmsis_gcc.h │ │ │ │ ├── cmsis_iccarm.h │ │ │ │ ├── cmsis_version.h │ │ │ │ ├── core_armv81mml.h │ │ │ │ ├── core_armv8mbl.h │ │ │ │ ├── core_armv8mml.h │ │ │ │ ├── core_cm0.h │ │ │ │ ├── core_cm0plus.h │ │ │ │ ├── core_cm1.h │ │ │ │ ├── core_cm23.h │ │ │ │ ├── core_cm3.h │ │ │ │ ├── core_cm33.h │ │ │ │ ├── core_cm35p.h │ │ │ │ ├── core_cm4.h │ │ │ │ ├── core_cm7.h │ │ │ │ ├── core_sc000.h │ │ │ │ ├── core_sc300.h │ │ │ │ ├── mpu_armv7.h │ │ │ │ ├── mpu_armv8.h │ │ │ │ └── tz_context.h │ │ │ └── LICENSE.txt │ │ └── STM32G0xx_HAL_Driver │ │ │ ├── Inc │ │ │ ├── Legacy │ │ │ │ └── stm32_hal_legacy.h │ │ │ ├── stm32g0xx_hal.h │ │ │ ├── stm32g0xx_hal_cortex.h │ │ │ ├── stm32g0xx_hal_def.h │ │ │ ├── stm32g0xx_hal_dma.h │ │ │ ├── stm32g0xx_hal_dma_ex.h │ │ │ ├── stm32g0xx_hal_exti.h │ │ │ ├── stm32g0xx_hal_flash.h │ │ │ ├── stm32g0xx_hal_flash_ex.h │ │ │ ├── stm32g0xx_hal_gpio.h │ │ │ ├── stm32g0xx_hal_gpio_ex.h │ │ │ ├── stm32g0xx_hal_pwr.h │ │ │ ├── stm32g0xx_hal_pwr_ex.h │ │ │ ├── stm32g0xx_hal_rcc.h │ │ │ ├── stm32g0xx_hal_rcc_ex.h │ │ │ ├── stm32g0xx_hal_rtc.h │ │ │ ├── stm32g0xx_hal_rtc_ex.h │ │ │ ├── stm32g0xx_hal_tim.h │ │ │ ├── stm32g0xx_hal_tim_ex.h │ │ │ ├── stm32g0xx_hal_uart.h │ │ │ ├── stm32g0xx_hal_uart_ex.h │ │ │ ├── stm32g0xx_ll_bus.h │ │ │ ├── stm32g0xx_ll_cortex.h │ │ │ ├── stm32g0xx_ll_dma.h │ │ │ ├── stm32g0xx_ll_dmamux.h │ │ │ ├── stm32g0xx_ll_exti.h │ │ │ ├── stm32g0xx_ll_gpio.h │ │ │ ├── stm32g0xx_ll_lpuart.h │ │ │ ├── stm32g0xx_ll_pwr.h │ │ │ ├── stm32g0xx_ll_rcc.h │ │ │ ├── stm32g0xx_ll_rtc.h │ │ │ ├── stm32g0xx_ll_system.h │ │ │ ├── stm32g0xx_ll_usart.h │ │ │ └── stm32g0xx_ll_utils.h │ │ │ ├── LICENSE.txt │ │ │ └── Src │ │ │ ├── stm32g0xx_hal.c │ │ │ ├── stm32g0xx_hal_cortex.c │ │ │ ├── stm32g0xx_hal_dma.c │ │ │ ├── stm32g0xx_hal_dma_ex.c │ │ │ ├── stm32g0xx_hal_exti.c │ │ │ ├── stm32g0xx_hal_flash.c │ │ │ ├── stm32g0xx_hal_flash_ex.c │ │ │ ├── stm32g0xx_hal_gpio.c │ │ │ ├── stm32g0xx_hal_pwr.c │ │ │ ├── stm32g0xx_hal_pwr_ex.c │ │ │ ├── stm32g0xx_hal_rcc.c │ │ │ ├── stm32g0xx_hal_rcc_ex.c │ │ │ ├── stm32g0xx_hal_rtc.c │ │ │ ├── stm32g0xx_hal_rtc_ex.c │ │ │ ├── stm32g0xx_hal_tim.c │ │ │ ├── stm32g0xx_hal_tim_ex.c │ │ │ ├── stm32g0xx_hal_uart.c │ │ │ ├── stm32g0xx_hal_uart_ex.c │ │ │ ├── stm32g0xx_ll_dma.c │ │ │ └── stm32g0xx_ll_rcc.c │ │ └── MDK-ARM │ │ ├── 01-RTC.uvoptx │ │ ├── 01-RTC.uvprojx │ │ ├── 01-RTC │ │ ├── 01-RTC.axf │ │ └── 01-RTC.hex │ │ ├── DebugConfig │ │ └── 01-RTC_STM32G031F8Px_1.0.0.dbgconf │ │ ├── EventRecorderStub.scvd │ │ ├── RTE │ │ └── _01-RTC │ │ │ └── RTE_Components.h │ │ └── startup_stm32g031xx.s └── buildclean.bat ├── Hardware ├── WeAct-STM32G0xxC0xxCoreBoard_V10 Board Shape 外形.pdf └── WeAct-STM32G0xxC0xxCoreBoard_V10 SchDoc.pdf ├── Images └── 1.png ├── README.md └── README_zh.md /.gitattributes: -------------------------------------------------------------------------------- 1 | *.hex binary -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.psd 2 | *.o 3 | .DS_Store 4 | *~ 5 | .~lock* 6 | *.uvopt 7 | *.dep 8 | *.bak 9 | *.uvgui.* 10 | *.uvguix.* 11 | 12 | UNSupport/ 13 | 14 | *.swp 15 | *.save 16 | .project 17 | .settings 18 | .cproject 19 | obj/ 20 | patches/ 21 | .idea 22 | *.crf 23 | *.d 24 | *.lnp 25 | 26 | # artefacts of top-level Makefile 27 | /downloads/ 28 | /build/ 29 | # local changes only 30 | make/local.mk 31 | 32 | # artefacts for VisualGDB (running in Visual Studio) 33 | mcu.mak 34 | mcu.mak.old 35 | stm32.mak 36 | 37 | # eclipse launch configurations 38 | /support/eclipse 39 | 40 | # ozone launch configurations 41 | /support/ozone 42 | 43 | # artefacts for Visual Studio Code 44 | /.vscode/ 45 | 46 | # artefacts for CLion 47 | /cmake-build-debug/ 48 | 49 | .vagrant 50 | ubuntu*.log 51 | /.vs 52 | -------------------------------------------------------------------------------- /Doc/DS12991 STM32G030x6_x8 Datasheet.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeActStudio/WeActStudio.STM32G0xxC0xxCoreBoard/f692e4e2e853ae9610aa337e2222c6d6d73416d8/Doc/DS12991 STM32G030x6_x8 Datasheet.pdf -------------------------------------------------------------------------------- /Doc/DS12992 STM32G031x4_x6_x8 Datasheet.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeActStudio/WeActStudio.STM32G0xxC0xxCoreBoard/f692e4e2e853ae9610aa337e2222c6d6d73416d8/Doc/DS12992 STM32G031x4_x6_x8 Datasheet.pdf -------------------------------------------------------------------------------- /Doc/DS13866 STM32C0x1 Datasheet.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeActStudio/WeActStudio.STM32G0xxC0xxCoreBoard/f692e4e2e853ae9610aa337e2222c6d6d73416d8/Doc/DS13866 STM32C0x1 Datasheet.pdf -------------------------------------------------------------------------------- /Doc/ES0569 STM32C0x1 Errata sheet.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeActStudio/WeActStudio.STM32G0xxC0xxCoreBoard/f692e4e2e853ae9610aa337e2222c6d6d73416d8/Doc/ES0569 STM32C0x1 Errata sheet.pdf -------------------------------------------------------------------------------- /Doc/RM0444 STM32G0x1 Reference manual.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeActStudio/WeActStudio.STM32G0xxC0xxCoreBoard/f692e4e2e853ae9610aa337e2222c6d6d73416d8/Doc/RM0444 STM32G0x1 Reference manual.pdf -------------------------------------------------------------------------------- /Doc/RM0454 STM32G0x0 Reference manual.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeActStudio/WeActStudio.STM32G0xxC0xxCoreBoard/f692e4e2e853ae9610aa337e2222c6d6d73416d8/Doc/RM0454 STM32G0x0 Reference manual.pdf -------------------------------------------------------------------------------- /Doc/RM0490 STM32C0x1 Reference manual.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeActStudio/WeActStudio.STM32G0xxC0xxCoreBoard/f692e4e2e853ae9610aa337e2222c6d6d73416d8/Doc/RM0490 STM32C0x1 Reference manual.pdf -------------------------------------------------------------------------------- /Examples/STM32C011/01-RTC/01-RTC.ioc: -------------------------------------------------------------------------------- 1 | #MicroXplorer Configuration settings - do not modify 2 | CAD.formats= 3 | CAD.pinconfig= 4 | CAD.provider= 5 | File.Version=6 6 | GPIO.groupedBy= 7 | KeepUserPlacement=false 8 | Mcu.CPN=STM32C011F6P6 9 | Mcu.Family=STM32C0 10 | Mcu.IP0=CORTEX_M0+ 11 | Mcu.IP1=DEBUG 12 | Mcu.IP2=NVIC 13 | Mcu.IP3=RCC 14 | Mcu.IP4=RTC 15 | Mcu.IP5=SYS 16 | Mcu.IP6=USART1 17 | Mcu.IPNb=7 18 | Mcu.Name=STM32C011F(4-6)Px 19 | Mcu.Package=TSSOP20 20 | Mcu.Pin0=PC14-OSCX_IN (PC14) 21 | Mcu.Pin1=PC15-OSCX_OUT (PC15) 22 | Mcu.Pin10=VP_SYS_VS_PINREMAP_10_12 23 | Mcu.Pin2=PA9 [PA11] 24 | Mcu.Pin3=PA10 [PA12] 25 | Mcu.Pin4=PA13 26 | Mcu.Pin5=PA14-BOOT0 27 | Mcu.Pin6=VP_RTC_VS_RTC_Activate 28 | Mcu.Pin7=VP_RTC_VS_RTC_Calendar 29 | Mcu.Pin8=VP_SYS_VS_Systick 30 | Mcu.Pin9=VP_SYS_VS_PINREMAP 31 | Mcu.PinsNb=11 32 | Mcu.ThirdPartyNb=0 33 | Mcu.UserConstants= 34 | Mcu.UserName=STM32C011F6Px 35 | MxCube.Version=6.7.0 36 | MxDb.Version=DB.6.0.70 37 | NVIC.ForceEnableDMAVector=true 38 | NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false 39 | NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false 40 | NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false 41 | NVIC.SVC_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:true 42 | NVIC.SysTick_IRQn=true\:3\:0\:false\:false\:true\:false\:true\:false 43 | PA10\ [PA12].Locked=true 44 | PA10\ [PA12].Mode=Asynchronous 45 | PA10\ [PA12].Signal=USART1_RX 46 | PA13.Mode=Serial_Wire 47 | PA13.Signal=DEBUG_SWDIO 48 | PA14-BOOT0.Mode=Serial_Wire 49 | PA14-BOOT0.Signal=DEBUG_SWCLK 50 | PA9\ [PA11].Locked=true 51 | PA9\ [PA11].Mode=Asynchronous 52 | PA9\ [PA11].Signal=USART1_TX 53 | PC14-OSCX_IN\ (PC14).Mode=LSE-External-Oscillator 54 | PC14-OSCX_IN\ (PC14).Signal=RCC_OSCX_IN 55 | PC15-OSCX_OUT\ (PC15).Mode=LSE-External-Oscillator 56 | PC15-OSCX_OUT\ (PC15).Signal=RCC_OSCX_OUT 57 | PinOutPanel.RotationAngle=0 58 | ProjectManager.AskForMigrate=true 59 | ProjectManager.BackupPrevious=false 60 | ProjectManager.CompilerOptimize=6 61 | ProjectManager.ComputerToolchain=false 62 | ProjectManager.CoupleFile=true 63 | ProjectManager.CustomerFirmwarePackage= 64 | ProjectManager.DefaultFWLocation=true 65 | ProjectManager.DeletePrevious=true 66 | ProjectManager.DeviceId=STM32C011F6Px 67 | ProjectManager.FirmwarePackage=STM32Cube FW_C0 V1.0.1 68 | ProjectManager.FreePins=false 69 | ProjectManager.HalAssertFull=false 70 | ProjectManager.HeapSize=0x200 71 | ProjectManager.KeepUserCode=true 72 | ProjectManager.LastFirmware=true 73 | ProjectManager.LibraryCopy=1 74 | ProjectManager.MainLocation=Core/Src 75 | ProjectManager.NoMain=false 76 | ProjectManager.PreviousToolchain= 77 | ProjectManager.ProjectBuild=false 78 | ProjectManager.ProjectFileName=01-RTC.ioc 79 | ProjectManager.ProjectName=01-RTC 80 | ProjectManager.RegisterCallBack= 81 | ProjectManager.StackSize=0x400 82 | ProjectManager.TargetToolchain=MDK-ARM V5.32 83 | ProjectManager.ToolChainLocation= 84 | ProjectManager.UnderRoot=false 85 | ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_RTC_Init-RTC-false-HAL-true,0-MX_CORTEX_M0+_Init-CORTEX_M0+-false-HAL-true 86 | RCC.ADCFreq_Value=48000000 87 | RCC.AHBFreq_Value=48000000 88 | RCC.APBFreq_Value=48000000 89 | RCC.APBTimFreq_Value=48000000 90 | RCC.CortexFreq_Value=48000000 91 | RCC.EXTERNAL_CLOCK_VALUE=12288000 92 | RCC.FCLKCortexFreq_Value=48000000 93 | RCC.FamilyName=M 94 | RCC.HCLKFreq_Value=48000000 95 | RCC.HSE_VALUE=8000000 96 | RCC.HSISYSCLKDivider=RCC_HSI_DIV1 97 | RCC.HSI_VALUE=48000000 98 | RCC.I2C1Freq_Value=48000000 99 | RCC.I2S1Freq_Value=48000000 100 | RCC.IPParameters=ADCFreq_Value,AHBFreq_Value,APBFreq_Value,APBTimFreq_Value,CortexFreq_Value,EXTERNAL_CLOCK_VALUE,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,HSISYSCLKDivider,HSI_VALUE,I2C1Freq_Value,I2S1Freq_Value,LSCOPinFreq_Value,LSI_VALUE,MCO1PinFreq_Value,MCO2PinFreq_Value,PWRFreq_Value,RTCClockSelection,RTCFreq_Value,SYSCLKFreq_VALUE,USART1Freq_Value 101 | RCC.LSCOPinFreq_Value=32000 102 | RCC.LSI_VALUE=32000 103 | RCC.MCO1PinFreq_Value=48000000 104 | RCC.MCO2PinFreq_Value=48000000 105 | RCC.PWRFreq_Value=48000000 106 | RCC.RTCClockSelection=RCC_RTCCLKSOURCE_LSE 107 | RCC.RTCFreq_Value=32768 108 | RCC.SYSCLKFreq_VALUE=48000000 109 | RCC.USART1Freq_Value=48000000 110 | RTC.Format=RTC_FORMAT_BIN 111 | RTC.IPParameters=Year,Format 112 | RTC.Year=23 113 | USART1.IPParameters=VirtualMode-Asynchronous 114 | USART1.VirtualMode-Asynchronous=VM_ASYNC 115 | VP_RTC_VS_RTC_Activate.Mode=RTC_Enabled 116 | VP_RTC_VS_RTC_Activate.Signal=RTC_VS_RTC_Activate 117 | VP_RTC_VS_RTC_Calendar.Mode=RTC_Calendar 118 | VP_RTC_VS_RTC_Calendar.Signal=RTC_VS_RTC_Calendar 119 | VP_SYS_VS_PINREMAP.Mode=PINREMAP 120 | VP_SYS_VS_PINREMAP.Signal=SYS_VS_PINREMAP 121 | VP_SYS_VS_PINREMAP_10_12.Mode=PINREMAP_10_12 122 | VP_SYS_VS_PINREMAP_10_12.Signal=SYS_VS_PINREMAP_10_12 123 | VP_SYS_VS_Systick.Mode=SysTick 124 | VP_SYS_VS_Systick.Signal=SYS_VS_Systick 125 | board=custom 126 | -------------------------------------------------------------------------------- /Examples/STM32C011/01-RTC/Bsp/board.c: -------------------------------------------------------------------------------- 1 | /*--------------------------------------- 2 | - WeAct Studio Official Link 3 | - taobao: weactstudio.taobao.com 4 | - aliexpress: weactstudio.aliexpress.com 5 | - github: github.com/WeActTC 6 | - gitee: gitee.com/WeAct-TC 7 | - blog: www.weact-tc.cn 8 | ---------------------------------------*/ 9 | 10 | #include "board.h" 11 | 12 | void board_button_init(void) 13 | { 14 | GPIO_InitTypeDef GPIO_InitStruct = {0}; 15 | 16 | /* GPIO Ports Clock Enable */ 17 | __HAL_RCC_GPIOA_CLK_ENABLE(); 18 | 19 | /*Configure GPIO pin : PtPin */ 20 | GPIO_InitStruct.Pin = KEY_Pin; 21 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT; 22 | GPIO_InitStruct.Pull = GPIO_PULLDOWN; 23 | HAL_GPIO_Init(KEY_GPIO_Port, &GPIO_InitStruct); 24 | } 25 | 26 | uint8_t board_button_getstate(void) 27 | { 28 | return HAL_GPIO_ReadPin(KEY_GPIO_Port,KEY_Pin)==GPIO_PIN_SET?1:0; 29 | } 30 | 31 | void board_led_init(void) 32 | { 33 | GPIO_InitTypeDef GPIO_InitStruct = {0}; 34 | 35 | /* GPIO Ports Clock Enable */ 36 | __HAL_RCC_GPIOA_CLK_ENABLE(); 37 | 38 | /*Configure GPIO pin Output Level */ 39 | HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_SET); 40 | 41 | /*Configure GPIO pin : PtPin */ 42 | GPIO_InitStruct.Pin = LED_Pin; 43 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 44 | GPIO_InitStruct.Pull = GPIO_NOPULL; 45 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 46 | HAL_GPIO_Init(LED_GPIO_Port, &GPIO_InitStruct); 47 | } 48 | 49 | void board_led_toggle(void) 50 | { 51 | HAL_GPIO_TogglePin(LED_GPIO_Port,LED_Pin); 52 | } 53 | 54 | void board_led_set(uint8_t set) 55 | { 56 | if (set) 57 | HAL_GPIO_WritePin(LED_GPIO_Port,LED_Pin,GPIO_PIN_SET); 58 | else 59 | HAL_GPIO_WritePin(LED_GPIO_Port,LED_Pin,GPIO_PIN_RESET); 60 | } 61 | -------------------------------------------------------------------------------- /Examples/STM32C011/01-RTC/Bsp/board.h: -------------------------------------------------------------------------------- 1 | #ifndef __BOARD_H 2 | #define __BOARD_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" 6 | { 7 | #endif 8 | 9 | #include "main.h" 10 | 11 | #ifndef KEY_Pin 12 | #define KEY_Pin GPIO_PIN_14 13 | #endif 14 | #ifndef KEY_GPIO_Port 15 | #define KEY_GPIO_Port GPIOA 16 | #endif 17 | #ifndef LED_Pin 18 | #define LED_Pin GPIO_PIN_4 19 | #endif 20 | #ifndef LED_GPIO_Port 21 | #define LED_GPIO_Port GPIOA 22 | #endif 23 | 24 | void board_button_init(void); 25 | uint8_t board_button_getstate(void); 26 | void board_led_init(void); 27 | void board_led_toggle(void); 28 | void board_led_set(uint8_t set); 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /Examples/STM32C011/01-RTC/Core/Inc/gpio.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file gpio.h 5 | * @brief This file contains all the function prototypes for 6 | * the gpio.c file 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2023 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __GPIO_H__ 22 | #define __GPIO_H__ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "main.h" 30 | 31 | /* USER CODE BEGIN Includes */ 32 | 33 | /* USER CODE END Includes */ 34 | 35 | /* USER CODE BEGIN Private defines */ 36 | 37 | /* USER CODE END Private defines */ 38 | 39 | void MX_GPIO_Init(void); 40 | 41 | /* USER CODE BEGIN Prototypes */ 42 | 43 | /* USER CODE END Prototypes */ 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | #endif /*__ GPIO_H__ */ 49 | 50 | -------------------------------------------------------------------------------- /Examples/STM32C011/01-RTC/Core/Inc/main.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : main.h 5 | * @brief : Header for main.c file. 6 | * This file contains the common defines of the application. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2023 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __MAIN_H 23 | #define __MAIN_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | #include "stm32c0xx_hal.h" 31 | 32 | /* Private includes ----------------------------------------------------------*/ 33 | /* USER CODE BEGIN Includes */ 34 | 35 | /* USER CODE END Includes */ 36 | 37 | /* Exported types ------------------------------------------------------------*/ 38 | /* USER CODE BEGIN ET */ 39 | 40 | /* USER CODE END ET */ 41 | 42 | /* Exported constants --------------------------------------------------------*/ 43 | /* USER CODE BEGIN EC */ 44 | 45 | /* USER CODE END EC */ 46 | 47 | /* Exported macro ------------------------------------------------------------*/ 48 | /* USER CODE BEGIN EM */ 49 | 50 | /* USER CODE END EM */ 51 | 52 | /* Exported functions prototypes ---------------------------------------------*/ 53 | void Error_Handler(void); 54 | 55 | /* USER CODE BEGIN EFP */ 56 | 57 | /* USER CODE END EFP */ 58 | 59 | /* Private defines -----------------------------------------------------------*/ 60 | 61 | /* USER CODE BEGIN Private defines */ 62 | 63 | /* USER CODE END Private defines */ 64 | 65 | #ifdef __cplusplus 66 | } 67 | #endif 68 | 69 | #endif /* __MAIN_H */ 70 | -------------------------------------------------------------------------------- /Examples/STM32C011/01-RTC/Core/Inc/rtc.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file rtc.h 5 | * @brief This file contains all the function prototypes for 6 | * the rtc.c file 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2023 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __RTC_H__ 22 | #define __RTC_H__ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "main.h" 30 | 31 | /* USER CODE BEGIN Includes */ 32 | 33 | /* USER CODE END Includes */ 34 | 35 | extern RTC_HandleTypeDef hrtc; 36 | 37 | /* USER CODE BEGIN Private defines */ 38 | 39 | /* USER CODE END Private defines */ 40 | 41 | void MX_RTC_Init(void); 42 | 43 | /* USER CODE BEGIN Prototypes */ 44 | 45 | /* USER CODE END Prototypes */ 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | 51 | #endif /* __RTC_H__ */ 52 | 53 | -------------------------------------------------------------------------------- /Examples/STM32C011/01-RTC/Core/Inc/stm32c0xx_it.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32c0xx_it.h 5 | * @brief This file contains the headers of the interrupt handlers. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2023 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | /* USER CODE END Header */ 19 | 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __STM32C0xx_IT_H 22 | #define __STM32C0xx_IT_H 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Private includes ----------------------------------------------------------*/ 29 | /* USER CODE BEGIN Includes */ 30 | 31 | /* USER CODE END Includes */ 32 | 33 | /* Exported types ------------------------------------------------------------*/ 34 | /* USER CODE BEGIN ET */ 35 | 36 | /* USER CODE END ET */ 37 | 38 | /* Exported constants --------------------------------------------------------*/ 39 | /* USER CODE BEGIN EC */ 40 | 41 | /* USER CODE END EC */ 42 | 43 | /* Exported macro ------------------------------------------------------------*/ 44 | /* USER CODE BEGIN EM */ 45 | 46 | /* USER CODE END EM */ 47 | 48 | /* Exported functions prototypes ---------------------------------------------*/ 49 | void NMI_Handler(void); 50 | void HardFault_Handler(void); 51 | void SVC_Handler(void); 52 | void PendSV_Handler(void); 53 | void SysTick_Handler(void); 54 | /* USER CODE BEGIN EFP */ 55 | 56 | /* USER CODE END EFP */ 57 | 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | 62 | #endif /* __STM32C0xx_IT_H */ 63 | -------------------------------------------------------------------------------- /Examples/STM32C011/01-RTC/Core/Inc/usart.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file usart.h 5 | * @brief This file contains all the function prototypes for 6 | * the usart.c file 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2023 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __USART_H__ 22 | #define __USART_H__ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "main.h" 30 | 31 | /* USER CODE BEGIN Includes */ 32 | 33 | /* USER CODE END Includes */ 34 | 35 | extern UART_HandleTypeDef huart1; 36 | 37 | /* USER CODE BEGIN Private defines */ 38 | 39 | /* USER CODE END Private defines */ 40 | 41 | void MX_USART1_UART_Init(void); 42 | 43 | /* USER CODE BEGIN Prototypes */ 44 | 45 | /* USER CODE END Prototypes */ 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | 51 | #endif /* __USART_H__ */ 52 | 53 | -------------------------------------------------------------------------------- /Examples/STM32C011/01-RTC/Core/Src/gpio.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file gpio.c 5 | * @brief This file provides code for the configuration 6 | * of all used GPIO pins. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2023 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | #include "gpio.h" 23 | 24 | /* USER CODE BEGIN 0 */ 25 | 26 | /* USER CODE END 0 */ 27 | 28 | /*----------------------------------------------------------------------------*/ 29 | /* Configure GPIO */ 30 | /*----------------------------------------------------------------------------*/ 31 | /* USER CODE BEGIN 1 */ 32 | 33 | /* USER CODE END 1 */ 34 | 35 | /** Configure pins as 36 | * Analog 37 | * Input 38 | * Output 39 | * EVENT_OUT 40 | * EXTI 41 | */ 42 | void MX_GPIO_Init(void) 43 | { 44 | 45 | /* GPIO Ports Clock Enable */ 46 | __HAL_RCC_GPIOC_CLK_ENABLE(); 47 | __HAL_RCC_GPIOA_CLK_ENABLE(); 48 | 49 | } 50 | 51 | /* USER CODE BEGIN 2 */ 52 | 53 | /* USER CODE END 2 */ 54 | -------------------------------------------------------------------------------- /Examples/STM32C011/01-RTC/Core/Src/main.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : main.c 5 | * @brief : Main program body 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2023 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | /* USER CODE END Header */ 19 | /* Includes ------------------------------------------------------------------*/ 20 | #include "main.h" 21 | #include "rtc.h" 22 | #include "usart.h" 23 | #include "gpio.h" 24 | 25 | /* Private includes ----------------------------------------------------------*/ 26 | /* USER CODE BEGIN Includes */ 27 | #include 28 | /* USER CODE END Includes */ 29 | 30 | /* Private typedef -----------------------------------------------------------*/ 31 | /* USER CODE BEGIN PTD */ 32 | 33 | /* USER CODE END PTD */ 34 | 35 | /* Private define ------------------------------------------------------------*/ 36 | /* USER CODE BEGIN PD */ 37 | #if defined (__ICCARM__) || defined (__ARMCC_VERSION) 38 | #define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f) 39 | #elif defined(__GNUC__) 40 | /* With GCC, small printf (option LD Linker->Libraries->Small printf 41 | set to 'Yes') calls __io_putchar() */ 42 | #define PUTCHAR_PROTOTYPE int __io_putchar(int ch) 43 | #endif /* __ICCARM__ || __ARMCC_VERSION */ 44 | /* USER CODE END PD */ 45 | 46 | /* Private macro -------------------------------------------------------------*/ 47 | /* USER CODE BEGIN PM */ 48 | 49 | /* USER CODE END PM */ 50 | 51 | /* Private variables ---------------------------------------------------------*/ 52 | 53 | /* USER CODE BEGIN PV */ 54 | 55 | /* USER CODE END PV */ 56 | 57 | /* Private function prototypes -----------------------------------------------*/ 58 | void SystemClock_Config(void); 59 | /* USER CODE BEGIN PFP */ 60 | 61 | /* USER CODE END PFP */ 62 | 63 | /* Private user code ---------------------------------------------------------*/ 64 | /* USER CODE BEGIN 0 */ 65 | /** 66 | * @brief Retargets the C library printf function to the USART. 67 | * @param None 68 | * @retval None 69 | */ 70 | PUTCHAR_PROTOTYPE 71 | { 72 | /* Place your implementation of fputc here */ 73 | /* e.g. write a character to the USART2 and Loop until the end of transmission */ 74 | HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, 0xFFFF); 75 | 76 | return ch; 77 | } 78 | /* USER CODE END 0 */ 79 | 80 | /** 81 | * @brief The application entry point. 82 | * @retval int 83 | */ 84 | int main(void) 85 | { 86 | /* USER CODE BEGIN 1 */ 87 | 88 | /* USER CODE END 1 */ 89 | 90 | /* MCU Configuration--------------------------------------------------------*/ 91 | 92 | /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ 93 | HAL_Init(); 94 | 95 | /* USER CODE BEGIN Init */ 96 | 97 | /* USER CODE END Init */ 98 | 99 | /* Configure the system clock */ 100 | SystemClock_Config(); 101 | 102 | /* USER CODE BEGIN SysInit */ 103 | 104 | /* USER CODE END SysInit */ 105 | 106 | /* Initialize all configured peripherals */ 107 | MX_GPIO_Init(); 108 | MX_RTC_Init(); 109 | MX_USART1_UART_Init(); 110 | /* USER CODE BEGIN 2 */ 111 | #include "board.h" 112 | //board_button_init(); 113 | board_led_init(); 114 | 115 | uint32_t tick,tick_now; 116 | tick = HAL_GetTick() + 200; 117 | tick_now = HAL_GetTick(); 118 | /* USER CODE END 2 */ 119 | 120 | /* Infinite loop */ 121 | /* USER CODE BEGIN WHILE */ 122 | while (1) 123 | { 124 | /* USER CODE END WHILE */ 125 | 126 | /* USER CODE BEGIN 3 */ 127 | tick_now = HAL_GetTick(); 128 | if(board_button_getstate()) 129 | { 130 | if(tick_now >= tick) 131 | { 132 | tick = tick_now + 200; 133 | board_led_toggle(); 134 | } 135 | } 136 | else 137 | { 138 | if(tick_now >= tick) 139 | { 140 | tick = tick_now + 50; 141 | 142 | RTC_DateTypeDef sdatestructureget; 143 | RTC_TimeTypeDef stimestructureget; 144 | uint8_t text[30]; 145 | static uint8_t Seconds_o; 146 | 147 | /* Get the RTC current Time */ 148 | HAL_RTC_GetTime(&hrtc, &stimestructureget, RTC_FORMAT_BIN); 149 | /* Get the RTC current Date */ 150 | HAL_RTC_GetDate(&hrtc, &sdatestructureget, RTC_FORMAT_BIN); 151 | 152 | if(Seconds_o != stimestructureget.Seconds) 153 | { 154 | Seconds_o = stimestructureget.Seconds; 155 | 156 | printf("20%02d.%02d.%02d %02d:%02d %02d\r\n",sdatestructureget.Year,sdatestructureget.Month,sdatestructureget.Date, \ 157 | stimestructureget.Hours,stimestructureget.Minutes,stimestructureget.Seconds); 158 | board_led_set(0); 159 | } 160 | else 161 | { 162 | board_led_set(1); 163 | } 164 | } 165 | } 166 | } 167 | /* USER CODE END 3 */ 168 | } 169 | 170 | /** 171 | * @brief System Clock Configuration 172 | * @retval None 173 | */ 174 | void SystemClock_Config(void) 175 | { 176 | RCC_OscInitTypeDef RCC_OscInitStruct = {0}; 177 | RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; 178 | 179 | /** Configure LSE Drive Capability 180 | */ 181 | __HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_LOW); 182 | 183 | /** Initializes the RCC Oscillators according to the specified parameters 184 | * in the RCC_OscInitTypeDef structure. 185 | */ 186 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_LSE; 187 | RCC_OscInitStruct.LSEState = RCC_LSE_ON; 188 | RCC_OscInitStruct.HSIState = RCC_HSI_ON; 189 | RCC_OscInitStruct.HSIDiv = RCC_HSI_DIV1; 190 | RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; 191 | if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) 192 | { 193 | Error_Handler(); 194 | } 195 | 196 | /** Initializes the CPU, AHB and APB buses clocks 197 | */ 198 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK 199 | |RCC_CLOCKTYPE_PCLK1; 200 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI; 201 | RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1; 202 | RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV1; 203 | RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV1; 204 | 205 | if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK) 206 | { 207 | Error_Handler(); 208 | } 209 | } 210 | 211 | /* USER CODE BEGIN 4 */ 212 | 213 | /* USER CODE END 4 */ 214 | 215 | /** 216 | * @brief This function is executed in case of error occurrence. 217 | * @retval None 218 | */ 219 | void Error_Handler(void) 220 | { 221 | /* USER CODE BEGIN Error_Handler_Debug */ 222 | /* User can add his own implementation to report the HAL error return state */ 223 | __disable_irq(); 224 | while (1) 225 | { 226 | } 227 | /* USER CODE END Error_Handler_Debug */ 228 | } 229 | 230 | #ifdef USE_FULL_ASSERT 231 | /** 232 | * @brief Reports the name of the source file and the source line number 233 | * where the assert_param error has occurred. 234 | * @param file: pointer to the source file name 235 | * @param line: assert_param error line source number 236 | * @retval None 237 | */ 238 | void assert_failed(uint8_t *file, uint32_t line) 239 | { 240 | /* USER CODE BEGIN 6 */ 241 | /* User can add his own implementation to report the file name and line number, 242 | ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ 243 | /* USER CODE END 6 */ 244 | } 245 | #endif /* USE_FULL_ASSERT */ 246 | -------------------------------------------------------------------------------- /Examples/STM32C011/01-RTC/Core/Src/rtc.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file rtc.c 5 | * @brief This file provides code for the configuration 6 | * of the RTC instances. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2023 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | /* Includes ------------------------------------------------------------------*/ 21 | #include "rtc.h" 22 | 23 | /* USER CODE BEGIN 0 */ 24 | 25 | /* USER CODE END 0 */ 26 | 27 | RTC_HandleTypeDef hrtc; 28 | 29 | /* RTC init function */ 30 | void MX_RTC_Init(void) 31 | { 32 | 33 | /* USER CODE BEGIN RTC_Init 0 */ 34 | 35 | /* USER CODE END RTC_Init 0 */ 36 | 37 | RTC_TimeTypeDef sTime = {0}; 38 | RTC_DateTypeDef sDate = {0}; 39 | 40 | /* USER CODE BEGIN RTC_Init 1 */ 41 | 42 | /* USER CODE END RTC_Init 1 */ 43 | 44 | /** Initialize RTC Only 45 | */ 46 | hrtc.Instance = RTC; 47 | hrtc.Init.HourFormat = RTC_HOURFORMAT_24; 48 | hrtc.Init.AsynchPrediv = 127; 49 | hrtc.Init.SynchPrediv = 255; 50 | hrtc.Init.OutPut = RTC_OUTPUT_DISABLE; 51 | hrtc.Init.OutPutRemap = RTC_OUTPUT_REMAP_NONE; 52 | hrtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH; 53 | hrtc.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN; 54 | hrtc.Init.OutPutPullUp = RTC_OUTPUT_PULLUP_NONE; 55 | if (HAL_RTC_Init(&hrtc) != HAL_OK) 56 | { 57 | Error_Handler(); 58 | } 59 | 60 | /* USER CODE BEGIN Check_RTC_BKUP */ 61 | 62 | /* USER CODE END Check_RTC_BKUP */ 63 | 64 | /** Initialize RTC and set the Time and Date 65 | */ 66 | sTime.Hours = 0; 67 | sTime.Minutes = 0; 68 | sTime.Seconds = 0; 69 | sTime.SubSeconds = 0; 70 | sTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE; 71 | sTime.StoreOperation = RTC_STOREOPERATION_RESET; 72 | if (HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BIN) != HAL_OK) 73 | { 74 | Error_Handler(); 75 | } 76 | sDate.WeekDay = RTC_WEEKDAY_MONDAY; 77 | sDate.Month = RTC_MONTH_JANUARY; 78 | sDate.Date = 1; 79 | sDate.Year = 23; 80 | 81 | if (HAL_RTC_SetDate(&hrtc, &sDate, RTC_FORMAT_BIN) != HAL_OK) 82 | { 83 | Error_Handler(); 84 | } 85 | /* USER CODE BEGIN RTC_Init 2 */ 86 | 87 | /* USER CODE END RTC_Init 2 */ 88 | 89 | } 90 | 91 | void HAL_RTC_MspInit(RTC_HandleTypeDef* rtcHandle) 92 | { 93 | 94 | RCC_PeriphCLKInitTypeDef PeriphClkInit = {0}; 95 | if(rtcHandle->Instance==RTC) 96 | { 97 | /* USER CODE BEGIN RTC_MspInit 0 */ 98 | 99 | /* USER CODE END RTC_MspInit 0 */ 100 | 101 | /** Initializes the peripherals clocks 102 | */ 103 | PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_RTC; 104 | PeriphClkInit.RTCClockSelection = RCC_RTCCLKSOURCE_LSE; 105 | if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) 106 | { 107 | Error_Handler(); 108 | } 109 | 110 | /* RTC clock enable */ 111 | __HAL_RCC_RTC_ENABLE(); 112 | __HAL_RCC_RTCAPB_CLK_ENABLE(); 113 | /* USER CODE BEGIN RTC_MspInit 1 */ 114 | 115 | /* USER CODE END RTC_MspInit 1 */ 116 | } 117 | } 118 | 119 | void HAL_RTC_MspDeInit(RTC_HandleTypeDef* rtcHandle) 120 | { 121 | 122 | if(rtcHandle->Instance==RTC) 123 | { 124 | /* USER CODE BEGIN RTC_MspDeInit 0 */ 125 | 126 | /* USER CODE END RTC_MspDeInit 0 */ 127 | /* Peripheral clock disable */ 128 | __HAL_RCC_RTC_DISABLE(); 129 | __HAL_RCC_RTCAPB_CLK_DISABLE(); 130 | /* USER CODE BEGIN RTC_MspDeInit 1 */ 131 | 132 | /* USER CODE END RTC_MspDeInit 1 */ 133 | } 134 | } 135 | 136 | /* USER CODE BEGIN 1 */ 137 | 138 | /* USER CODE END 1 */ 139 | -------------------------------------------------------------------------------- /Examples/STM32C011/01-RTC/Core/Src/stm32c0xx_hal_msp.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32c0xx_hal_msp.c 5 | * @brief This file provides code for the MSP Initialization 6 | * and de-Initialization codes. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2023 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | #include "main.h" 23 | /* USER CODE BEGIN Includes */ 24 | 25 | /* USER CODE END Includes */ 26 | 27 | /* Private typedef -----------------------------------------------------------*/ 28 | /* USER CODE BEGIN TD */ 29 | 30 | /* USER CODE END TD */ 31 | 32 | /* Private define ------------------------------------------------------------*/ 33 | /* USER CODE BEGIN Define */ 34 | 35 | /* USER CODE END Define */ 36 | 37 | /* Private macro -------------------------------------------------------------*/ 38 | /* USER CODE BEGIN Macro */ 39 | 40 | /* USER CODE END Macro */ 41 | 42 | /* Private variables ---------------------------------------------------------*/ 43 | /* USER CODE BEGIN PV */ 44 | 45 | /* USER CODE END PV */ 46 | 47 | /* Private function prototypes -----------------------------------------------*/ 48 | /* USER CODE BEGIN PFP */ 49 | 50 | /* USER CODE END PFP */ 51 | 52 | /* External functions --------------------------------------------------------*/ 53 | /* USER CODE BEGIN ExternalFunctions */ 54 | 55 | /* USER CODE END ExternalFunctions */ 56 | 57 | /* USER CODE BEGIN 0 */ 58 | 59 | /* USER CODE END 0 */ 60 | /** 61 | * Initializes the Global MSP. 62 | */ 63 | void HAL_MspInit(void) 64 | { 65 | /* USER CODE BEGIN MspInit 0 */ 66 | 67 | /* USER CODE END MspInit 0 */ 68 | 69 | __HAL_RCC_SYSCFG_CLK_ENABLE(); 70 | __HAL_RCC_PWR_CLK_ENABLE(); 71 | 72 | /* System interrupt init*/ 73 | 74 | HAL_SYSCFG_EnableRemap(SYSCFG_REMAP_PA11); 75 | HAL_SYSCFG_EnableRemap(SYSCFG_REMAP_PA12); 76 | 77 | /* USER CODE BEGIN MspInit 1 */ 78 | 79 | /* USER CODE END MspInit 1 */ 80 | } 81 | 82 | /* USER CODE BEGIN 1 */ 83 | 84 | /* USER CODE END 1 */ 85 | -------------------------------------------------------------------------------- /Examples/STM32C011/01-RTC/Core/Src/stm32c0xx_it.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32c0xx_it.c 5 | * @brief Interrupt Service Routines. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2023 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | /* USER CODE END Header */ 19 | 20 | /* Includes ------------------------------------------------------------------*/ 21 | #include "main.h" 22 | #include "stm32c0xx_it.h" 23 | /* Private includes ----------------------------------------------------------*/ 24 | /* USER CODE BEGIN Includes */ 25 | /* USER CODE END Includes */ 26 | 27 | /* Private typedef -----------------------------------------------------------*/ 28 | /* USER CODE BEGIN TD */ 29 | 30 | /* USER CODE END TD */ 31 | 32 | /* Private define ------------------------------------------------------------*/ 33 | /* USER CODE BEGIN PD */ 34 | 35 | /* USER CODE END PD */ 36 | 37 | /* Private macro -------------------------------------------------------------*/ 38 | /* USER CODE BEGIN PM */ 39 | 40 | /* USER CODE END PM */ 41 | 42 | /* Private variables ---------------------------------------------------------*/ 43 | /* USER CODE BEGIN PV */ 44 | 45 | /* USER CODE END PV */ 46 | 47 | /* Private function prototypes -----------------------------------------------*/ 48 | /* USER CODE BEGIN PFP */ 49 | 50 | /* USER CODE END PFP */ 51 | 52 | /* Private user code ---------------------------------------------------------*/ 53 | /* USER CODE BEGIN 0 */ 54 | 55 | /* USER CODE END 0 */ 56 | 57 | /* External variables --------------------------------------------------------*/ 58 | 59 | /* USER CODE BEGIN EV */ 60 | 61 | /* USER CODE END EV */ 62 | 63 | /******************************************************************************/ 64 | /* Cortex Processor Interruption and Exception Handlers */ 65 | /******************************************************************************/ 66 | /** 67 | * @brief This function handles Non maskable interrupt. 68 | */ 69 | void NMI_Handler(void) 70 | { 71 | /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ 72 | 73 | /* USER CODE END NonMaskableInt_IRQn 0 */ 74 | /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ 75 | while (1) 76 | { 77 | } 78 | /* USER CODE END NonMaskableInt_IRQn 1 */ 79 | } 80 | 81 | /** 82 | * @brief This function handles Hard fault interrupt. 83 | */ 84 | void HardFault_Handler(void) 85 | { 86 | /* USER CODE BEGIN HardFault_IRQn 0 */ 87 | 88 | /* USER CODE END HardFault_IRQn 0 */ 89 | while (1) 90 | { 91 | /* USER CODE BEGIN W1_HardFault_IRQn 0 */ 92 | /* USER CODE END W1_HardFault_IRQn 0 */ 93 | } 94 | } 95 | 96 | /** 97 | * @brief This function handles System service call via SWI instruction. 98 | */ 99 | void SVC_Handler(void) 100 | { 101 | /* USER CODE BEGIN SVC_IRQn 0 */ 102 | 103 | /* USER CODE END SVC_IRQn 0 */ 104 | /* USER CODE BEGIN SVC_IRQn 1 */ 105 | 106 | /* USER CODE END SVC_IRQn 1 */ 107 | } 108 | 109 | /** 110 | * @brief This function handles Pendable request for system service. 111 | */ 112 | void PendSV_Handler(void) 113 | { 114 | /* USER CODE BEGIN PendSV_IRQn 0 */ 115 | 116 | /* USER CODE END PendSV_IRQn 0 */ 117 | /* USER CODE BEGIN PendSV_IRQn 1 */ 118 | 119 | /* USER CODE END PendSV_IRQn 1 */ 120 | } 121 | 122 | /** 123 | * @brief This function handles System tick timer. 124 | */ 125 | void SysTick_Handler(void) 126 | { 127 | /* USER CODE BEGIN SysTick_IRQn 0 */ 128 | 129 | /* USER CODE END SysTick_IRQn 0 */ 130 | HAL_IncTick(); 131 | /* USER CODE BEGIN SysTick_IRQn 1 */ 132 | 133 | /* USER CODE END SysTick_IRQn 1 */ 134 | } 135 | 136 | /******************************************************************************/ 137 | /* STM32C0xx Peripheral Interrupt Handlers */ 138 | /* Add here the Interrupt Handlers for the used peripherals. */ 139 | /* For the available peripheral interrupt handler names, */ 140 | /* please refer to the startup file (startup_stm32c0xx.s). */ 141 | /******************************************************************************/ 142 | 143 | /* USER CODE BEGIN 1 */ 144 | 145 | /* USER CODE END 1 */ 146 | -------------------------------------------------------------------------------- /Examples/STM32C011/01-RTC/Core/Src/system_stm32c0xx.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32c0xx.c 4 | * @author MCD Application Team 5 | * @brief CMSIS Cortex-M0+ Device Peripheral Access Layer System Source File 6 | * 7 | * This file provides two functions and one global variable to be called from 8 | * user application: 9 | * - SystemInit(): This function is called at startup just after reset and 10 | * before branch to main program. This call is made inside 11 | * the "startup_stm32c0xx.s" file. 12 | * 13 | * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used 14 | * by the user application to setup the SysTick 15 | * timer or configure other parameters. 16 | * 17 | * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must 18 | * be called whenever the core clock is changed 19 | * during program execution. 20 | * 21 | ****************************************************************************** 22 | * @attention 23 | * 24 | * Copyright (c) 2022 STMicroelectronics. 25 | * All rights reserved. 26 | * 27 | * This software is licensed under terms that can be found in the LICENSE file 28 | * in the root directory of this software component. 29 | * If no LICENSE file comes with this software, it is provided AS-IS. 30 | * 31 | ****************************************************************************** 32 | */ 33 | 34 | /** @addtogroup CMSIS 35 | * @{ 36 | */ 37 | 38 | /** @addtogroup stm32c0xx_system 39 | * @{ 40 | */ 41 | 42 | /** @addtogroup STM32C0xx_System_Private_Includes 43 | * @{ 44 | */ 45 | 46 | #include "stm32c0xx.h" 47 | 48 | #if !defined (HSE_VALUE) 49 | #define HSE_VALUE (48000000UL) /*!< Value of the External oscillator in Hz */ 50 | #endif /* HSE_VALUE */ 51 | 52 | #if !defined (HSI_VALUE) 53 | #define HSI_VALUE (48000000UL) /*!< Value of the Internal oscillator in Hz*/ 54 | #endif /* HSI_VALUE */ 55 | 56 | #if !defined (LSI_VALUE) 57 | #define LSI_VALUE (32000UL) /*!< Value of LSI in Hz*/ 58 | #endif /* LSI_VALUE */ 59 | 60 | #if !defined (LSE_VALUE) 61 | #define LSE_VALUE (32768UL) /*!< Value of LSE in Hz*/ 62 | #endif /* LSE_VALUE */ 63 | 64 | /** 65 | * @} 66 | */ 67 | 68 | /** @addtogroup STM32C0xx_System_Private_TypesDefinitions 69 | * @{ 70 | */ 71 | 72 | /** 73 | * @} 74 | */ 75 | 76 | /** @addtogroup STM32C0xx_System_Private_Defines 77 | * @{ 78 | */ 79 | 80 | /************************* Miscellaneous Configuration ************************/ 81 | /*!< Uncomment the following line if you need to relocate your vector Table in 82 | Internal SRAM. */ 83 | //#define VECT_TAB_SRAM 84 | #define VECT_TAB_OFFSET 0x0U /*!< Vector Table base offset field. 85 | This value must be a multiple of 0x100. */ 86 | /******************************************************************************/ 87 | /** 88 | * @} 89 | */ 90 | 91 | /** @addtogroup STM32C0xx_System_Private_Macros 92 | * @{ 93 | */ 94 | 95 | /** 96 | * @} 97 | */ 98 | 99 | /** @addtogroup STM32C0xx_System_Private_Variables 100 | * @{ 101 | */ 102 | /* The SystemCoreClock variable is updated in three ways: 103 | 1) by calling CMSIS function SystemCoreClockUpdate() 104 | 2) by calling HAL API function HAL_RCC_GetHCLKFreq() 105 | 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency 106 | Note: If you use this function to configure the system clock; then there 107 | is no need to call the 2 first functions listed above, since SystemCoreClock 108 | variable is updated automatically. 109 | */ 110 | uint32_t SystemCoreClock = 48000000UL; 111 | 112 | const uint32_t AHBPrescTable[16UL] = {0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 1UL, 2UL, 3UL, 4UL, 6UL, 7UL, 8UL, 9UL}; 113 | const uint32_t APBPrescTable[8UL] = {0UL, 0UL, 0UL, 0UL, 1UL, 2UL, 3UL, 4UL}; 114 | 115 | /** 116 | * @} 117 | */ 118 | 119 | /** @addtogroup STM32C0xx_System_Private_FunctionPrototypes 120 | * @{ 121 | */ 122 | 123 | /** 124 | * @} 125 | */ 126 | 127 | /** @addtogroup STM32C0xx_System_Private_Functions 128 | * @{ 129 | */ 130 | 131 | /** 132 | * @brief Setup the microcontroller system. 133 | * @param None 134 | * @retval None 135 | */ 136 | void SystemInit(void) 137 | { 138 | 139 | /* Configure the Vector Table location add offset address ------------------*/ 140 | #ifdef VECT_TAB_SRAM 141 | SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ 142 | #else 143 | SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */ 144 | #endif 145 | } 146 | 147 | /** 148 | * @brief Update SystemCoreClock variable according to Clock Register Values. 149 | * The SystemCoreClock variable contains the core clock (HCLK), it can 150 | * be used by the user application to setup the SysTick timer or configure 151 | * other parameters. 152 | * 153 | * @note Each time the core clock (HCLK) changes, this function must be called 154 | * to update SystemCoreClock variable value. Otherwise, any configuration 155 | * based on this variable will be incorrect. 156 | * 157 | * @note - The system frequency computed by this function is not the real 158 | * frequency in the chip. It is calculated based on the predefined 159 | * constant and the selected clock source: 160 | * 161 | * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(**) / HSI division factor 162 | * 163 | * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(***) 164 | * 165 | * - If SYSCLK source is LSI, SystemCoreClock will contain the LSI_VALUE 166 | * 167 | * - If SYSCLK source is LSE, SystemCoreClock will contain the LSE_VALUE 168 | * 169 | * (**) HSI_VALUE is a constant defined in stm32c0xx_hal_conf.h file (default value 170 | * 48 MHz) but the real value may vary depending on the variations 171 | * in voltage and temperature. 172 | * 173 | * (***) HSE_VALUE is a constant defined in stm32c0xx_hal_conf.h file (default value 174 | * 48 MHz), user has to ensure that HSE_VALUE is same as the real 175 | * frequency of the crystal used. Otherwise, this function may 176 | * have wrong result. 177 | * 178 | * - The result of this function could be not correct when using fractional 179 | * value for HSE crystal. 180 | * 181 | * @param None 182 | * @retval None 183 | */ 184 | void SystemCoreClockUpdate(void) 185 | { 186 | uint32_t tmp; 187 | uint32_t hsidiv; 188 | 189 | /* Get SYSCLK source -------------------------------------------------------*/ 190 | switch (RCC->CFGR & RCC_CFGR_SWS) 191 | { 192 | case RCC_CFGR_SWS_0: /* HSE used as system clock */ 193 | SystemCoreClock = HSE_VALUE; 194 | break; 195 | 196 | case (RCC_CFGR_SWS_1 | RCC_CFGR_SWS_0): /* LSI used as system clock */ 197 | SystemCoreClock = LSI_VALUE; 198 | break; 199 | 200 | case RCC_CFGR_SWS_2: /* LSE used as system clock */ 201 | SystemCoreClock = LSE_VALUE; 202 | break; 203 | 204 | case 0x00000000U: /* HSI used as system clock */ 205 | default: /* HSI used as system clock */ 206 | hsidiv = (1UL << ((READ_BIT(RCC->CR, RCC_CR_HSIDIV))>> RCC_CR_HSIDIV_Pos)); 207 | SystemCoreClock = (HSI_VALUE/hsidiv); 208 | break; 209 | } 210 | /* Compute HCLK clock frequency --------------------------------------------*/ 211 | /* Get HCLK prescaler */ 212 | tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> RCC_CFGR_HPRE_Pos)]; 213 | /* HCLK clock frequency */ 214 | SystemCoreClock >>= tmp; 215 | } 216 | 217 | 218 | /** 219 | * @} 220 | */ 221 | 222 | /** 223 | * @} 224 | */ 225 | 226 | /** 227 | * @} 228 | */ 229 | -------------------------------------------------------------------------------- /Examples/STM32C011/01-RTC/Core/Src/usart.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file usart.c 5 | * @brief This file provides code for the configuration 6 | * of the USART instances. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2023 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | /* Includes ------------------------------------------------------------------*/ 21 | #include "usart.h" 22 | 23 | /* USER CODE BEGIN 0 */ 24 | 25 | /* USER CODE END 0 */ 26 | 27 | UART_HandleTypeDef huart1; 28 | 29 | /* USART1 init function */ 30 | 31 | void MX_USART1_UART_Init(void) 32 | { 33 | 34 | /* USER CODE BEGIN USART1_Init 0 */ 35 | 36 | /* USER CODE END USART1_Init 0 */ 37 | 38 | /* USER CODE BEGIN USART1_Init 1 */ 39 | 40 | /* USER CODE END USART1_Init 1 */ 41 | huart1.Instance = USART1; 42 | huart1.Init.BaudRate = 115200; 43 | huart1.Init.WordLength = UART_WORDLENGTH_8B; 44 | huart1.Init.StopBits = UART_STOPBITS_1; 45 | huart1.Init.Parity = UART_PARITY_NONE; 46 | huart1.Init.Mode = UART_MODE_TX_RX; 47 | huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE; 48 | huart1.Init.OverSampling = UART_OVERSAMPLING_16; 49 | huart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE; 50 | huart1.Init.ClockPrescaler = UART_PRESCALER_DIV1; 51 | huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT; 52 | if (HAL_UART_Init(&huart1) != HAL_OK) 53 | { 54 | Error_Handler(); 55 | } 56 | if (HAL_UARTEx_SetTxFifoThreshold(&huart1, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK) 57 | { 58 | Error_Handler(); 59 | } 60 | if (HAL_UARTEx_SetRxFifoThreshold(&huart1, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK) 61 | { 62 | Error_Handler(); 63 | } 64 | if (HAL_UARTEx_DisableFifoMode(&huart1) != HAL_OK) 65 | { 66 | Error_Handler(); 67 | } 68 | /* USER CODE BEGIN USART1_Init 2 */ 69 | 70 | /* USER CODE END USART1_Init 2 */ 71 | 72 | } 73 | 74 | void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle) 75 | { 76 | 77 | GPIO_InitTypeDef GPIO_InitStruct = {0}; 78 | RCC_PeriphCLKInitTypeDef PeriphClkInit = {0}; 79 | if(uartHandle->Instance==USART1) 80 | { 81 | /* USER CODE BEGIN USART1_MspInit 0 */ 82 | 83 | /* USER CODE END USART1_MspInit 0 */ 84 | 85 | /** Initializes the peripherals clocks 86 | */ 87 | PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART1; 88 | PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_PCLK1; 89 | if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) 90 | { 91 | Error_Handler(); 92 | } 93 | 94 | /* USART1 clock enable */ 95 | __HAL_RCC_USART1_CLK_ENABLE(); 96 | 97 | __HAL_RCC_GPIOA_CLK_ENABLE(); 98 | /**USART1 GPIO Configuration 99 | PA9 [PA11] ------> USART1_TX 100 | PA10 [PA12] ------> USART1_RX 101 | */ 102 | GPIO_InitStruct.Pin = GPIO_PIN_9|GPIO_PIN_10; 103 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 104 | GPIO_InitStruct.Pull = GPIO_NOPULL; 105 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 106 | GPIO_InitStruct.Alternate = GPIO_AF1_USART1; 107 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 108 | 109 | /* USER CODE BEGIN USART1_MspInit 1 */ 110 | 111 | /* USER CODE END USART1_MspInit 1 */ 112 | } 113 | } 114 | 115 | void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle) 116 | { 117 | 118 | if(uartHandle->Instance==USART1) 119 | { 120 | /* USER CODE BEGIN USART1_MspDeInit 0 */ 121 | 122 | /* USER CODE END USART1_MspDeInit 0 */ 123 | /* Peripheral clock disable */ 124 | __HAL_RCC_USART1_CLK_DISABLE(); 125 | 126 | /**USART1 GPIO Configuration 127 | PA9 [PA11] ------> USART1_TX 128 | PA10 [PA12] ------> USART1_RX 129 | */ 130 | HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_10); 131 | 132 | /* USER CODE BEGIN USART1_MspDeInit 1 */ 133 | 134 | /* USER CODE END USART1_MspDeInit 1 */ 135 | } 136 | } 137 | 138 | /* USER CODE BEGIN 1 */ 139 | 140 | /* USER CODE END 1 */ 141 | -------------------------------------------------------------------------------- /Examples/STM32C011/01-RTC/Drivers/CMSIS/Device/ST/STM32C0xx/Include/stm32c0xx.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32c0xx.h 4 | * @author MCD Application Team 5 | * @brief CMSIS STM32C0xx Device Peripheral Access Layer Header File. 6 | * 7 | * The file is the unique include file that the application programmer 8 | * is using in the C source code, usually in main.c. This file contains: 9 | * - Configuration section that allows to select: 10 | * - The STM32C0xx device used in the target application 11 | * - To use or not the peripherals drivers in application code(i.e. 12 | * code will be based on direct access to peripherals registers 13 | * rather than drivers API), this option is controlled by 14 | * "#define USE_HAL_DRIVER" 15 | * 16 | ****************************************************************************** 17 | * @attention 18 | * 19 | * Copyright (c) 2022 STMicroelectronics. 20 | * All rights reserved. 21 | * 22 | * This software is licensed under terms that can be found in the LICENSE file 23 | * in the root directory of this software component. 24 | * If no LICENSE file comes with this software, it is provided AS-IS. 25 | * 26 | ****************************************************************************** 27 | */ 28 | 29 | /** @addtogroup CMSIS 30 | * @{ 31 | */ 32 | 33 | /** @addtogroup stm32c0xx 34 | * @{ 35 | */ 36 | 37 | #ifndef STM32C0xx_H 38 | #define STM32C0xx_H 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif /* __cplusplus */ 43 | 44 | /** @addtogroup Library_configuration_section 45 | * @{ 46 | */ 47 | 48 | /** 49 | * @brief STM32 Family 50 | */ 51 | #if !defined (STM32C0) 52 | #define STM32C0 53 | #endif /* STM32C0 */ 54 | 55 | /* Uncomment the line below according to the target STM32C0 device used in your 56 | application 57 | */ 58 | 59 | #if !defined (STM32C011xx) && !defined (STM32C031xx) 60 | /* #define STM32C011xx */ /*!< STM32C011xx Devices */ 61 | /* #define STM32C031xx */ /*!< STM32C031xx Devices */ 62 | #endif 63 | 64 | /* Tip: To avoid modifying this file each time you need to switch between these 65 | devices, you can define the device in your toolchain compiler preprocessor. 66 | */ 67 | #if !defined (USE_HAL_DRIVER) 68 | /** 69 | * @brief Comment the line below if you will not use the peripherals drivers. 70 | In this case, these drivers will not be included and the application code will 71 | be based on direct access to peripherals registers 72 | */ 73 | /*#define USE_HAL_DRIVER */ 74 | #endif /* USE_HAL_DRIVER */ 75 | 76 | /** 77 | * @brief CMSIS Device version number V1.0.0 78 | */ 79 | #define __STM32C0_CMSIS_VERSION_MAIN (0x01U) /*!< [31:24] main version */ 80 | #define __STM32C0_CMSIS_VERSION_SUB1 (0x00U) /*!< [23:16] sub1 version */ 81 | #define __STM32C0_CMSIS_VERSION_SUB2 (0x00U) /*!< [15:8] sub2 version */ 82 | #define __STM32C0_CMSIS_VERSION_RC (0x00U) /*!< [7:0] release candidate */ 83 | #define __STM32C0_CMSIS_VERSION ((__STM32C0_CMSIS_VERSION_MAIN << 24)\ 84 | |(__STM32C0_CMSIS_VERSION_SUB1 << 16)\ 85 | |(__STM32C0_CMSIS_VERSION_SUB2 << 8 )\ 86 | |(__STM32C0_CMSIS_VERSION_RC)) 87 | 88 | /** 89 | * @} 90 | */ 91 | 92 | /** @addtogroup Device_Included 93 | * @{ 94 | */ 95 | 96 | #if defined(STM32C011xx) 97 | #include "stm32c011xx.h" 98 | #elif defined(STM32C031xx) 99 | #include "stm32c031xx.h" 100 | #else 101 | #error "Please select first the target STM32C0xx device used in your application (in stm32c0xx.h file)" 102 | #endif 103 | 104 | /** 105 | * @} 106 | */ 107 | 108 | /** @addtogroup Exported_types 109 | * @{ 110 | */ 111 | typedef enum 112 | { 113 | RESET = 0, 114 | SET = !RESET 115 | } FlagStatus, ITStatus; 116 | 117 | typedef enum 118 | { 119 | DISABLE = 0, 120 | ENABLE = !DISABLE 121 | } FunctionalState; 122 | #define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE)) 123 | 124 | typedef enum 125 | { 126 | SUCCESS = 0, 127 | ERROR = !SUCCESS 128 | } ErrorStatus; 129 | 130 | /** 131 | * @} 132 | */ 133 | 134 | /** @addtogroup Exported_macros 135 | * @{ 136 | */ 137 | #define SET_BIT(REG, BIT) ((REG) |= (BIT)) 138 | 139 | #define CLEAR_BIT(REG, BIT) ((REG) &= ~(BIT)) 140 | 141 | #define READ_BIT(REG, BIT) ((REG) & (BIT)) 142 | 143 | #define CLEAR_REG(REG) ((REG) = (0x0)) 144 | 145 | #define WRITE_REG(REG, VAL) ((REG) = (VAL)) 146 | 147 | #define READ_REG(REG) ((REG)) 148 | 149 | #define MODIFY_REG(REG, CLEARMASK, SETMASK) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK))) 150 | 151 | /* Use of interrupt control for register exclusive access */ 152 | /* Atomic 32-bit register access macro to set one or several bits */ 153 | #define ATOMIC_SET_BIT(REG, BIT) \ 154 | do { \ 155 | uint32_t primask; \ 156 | primask = __get_PRIMASK(); \ 157 | __set_PRIMASK(1); \ 158 | SET_BIT((REG), (BIT)); \ 159 | __set_PRIMASK(primask); \ 160 | } while(0) 161 | 162 | /* Atomic 32-bit register access macro to clear one or several bits */ 163 | #define ATOMIC_CLEAR_BIT(REG, BIT) \ 164 | do { \ 165 | uint32_t primask; \ 166 | primask = __get_PRIMASK(); \ 167 | __set_PRIMASK(1); \ 168 | CLEAR_BIT((REG), (BIT)); \ 169 | __set_PRIMASK(primask); \ 170 | } while(0) 171 | 172 | /* Atomic 32-bit register access macro to clear and set one or several bits */ 173 | #define ATOMIC_MODIFY_REG(REG, CLEARMSK, SETMASK) \ 174 | do { \ 175 | uint32_t primask; \ 176 | primask = __get_PRIMASK(); \ 177 | __set_PRIMASK(1); \ 178 | MODIFY_REG((REG), (CLEARMSK), (SETMASK)); \ 179 | __set_PRIMASK(primask); \ 180 | } while(0) 181 | 182 | /* Atomic 16-bit register access macro to set one or several bits */ 183 | #define ATOMIC_SETH_BIT(REG, BIT) ATOMIC_SET_BIT(REG, BIT) \ 184 | 185 | /* Atomic 16-bit register access macro to clear one or several bits */ 186 | #define ATOMIC_CLEARH_BIT(REG, BIT) ATOMIC_CLEAR_BIT(REG, BIT) \ 187 | 188 | /* Atomic 16-bit register access macro to clear and set one or several bits */ 189 | #define ATOMIC_MODIFYH_REG(REG, CLEARMSK, SETMASK) ATOMIC_MODIFY_REG(REG, CLEARMSK, SETMASK) \ 190 | 191 | #define POSITION_VAL(VAL) (__CLZ(__RBIT(VAL))) 192 | /** 193 | * @} 194 | */ 195 | 196 | #if defined (USE_HAL_DRIVER) 197 | #include "stm32c0xx_hal.h" 198 | #endif /* USE_HAL_DRIVER */ 199 | 200 | #ifdef __cplusplus 201 | } 202 | #endif /* __cplusplus */ 203 | 204 | #endif /* STM32C0xx_H */ 205 | /** 206 | * @} 207 | */ 208 | 209 | /** 210 | * @} 211 | */ 212 | 213 | -------------------------------------------------------------------------------- /Examples/STM32C011/01-RTC/Drivers/CMSIS/Device/ST/STM32C0xx/Include/system_stm32c0xx.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32c0xx.h 4 | * @author MCD Application Team 5 | * @brief CMSIS Cortex-M0+ Device System Source File for STM32C0xx devices. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2022 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /** @addtogroup CMSIS 20 | * @{ 21 | */ 22 | 23 | /** @addtogroup stm32c0xx_system 24 | * @{ 25 | */ 26 | 27 | /** 28 | * @brief Define to prevent recursive inclusion 29 | */ 30 | #ifndef SYSTEM_STM32C0XX_H 31 | #define SYSTEM_STM32C0XX_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /** @addtogroup STM32C0xx_System_Includes 38 | * @{ 39 | */ 40 | 41 | /** 42 | * @} 43 | */ 44 | 45 | 46 | /** @addtogroup STM32C0xx_System_Exported_types 47 | * @{ 48 | */ 49 | /* This variable is updated in three ways: 50 | 1) by calling CMSIS function SystemCoreClockUpdate() 51 | 2) by calling HAL API function HAL_RCC_GetSysClockFreq() 52 | 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency 53 | Note: If you use this function to configure the system clock; then there 54 | is no need to call the 2 first functions listed above, since SystemCoreClock 55 | variable is updated automatically. 56 | */ 57 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 58 | 59 | extern const uint32_t AHBPrescTable[16]; /*!< AHB prescalers table values */ 60 | extern const uint32_t APBPrescTable[8]; /*!< APB prescalers table values */ 61 | 62 | /** 63 | * @} 64 | */ 65 | 66 | /** @addtogroup STM32C0xx_System_Exported_Constants 67 | * @{ 68 | */ 69 | 70 | /** 71 | * @} 72 | */ 73 | 74 | /** @addtogroup STM32C0xx_System_Exported_Macros 75 | * @{ 76 | */ 77 | 78 | /** 79 | * @} 80 | */ 81 | 82 | /** @addtogroup STM32C0xx_System_Exported_Functions 83 | * @{ 84 | */ 85 | 86 | extern void SystemInit(void); 87 | extern void SystemCoreClockUpdate(void); 88 | /** 89 | * @} 90 | */ 91 | 92 | #ifdef __cplusplus 93 | } 94 | #endif 95 | 96 | #endif /*SYSTEM_STM32C0XX_H */ 97 | 98 | /** 99 | * @} 100 | */ 101 | 102 | /** 103 | * @} 104 | */ 105 | 106 | -------------------------------------------------------------------------------- /Examples/STM32C011/01-RTC/Drivers/CMSIS/Device/ST/STM32C0xx/LICENSE.txt: -------------------------------------------------------------------------------- 1 | This software component is provided to you as part of a software package and 2 | applicable license terms are in the Package_license file. If you received this 3 | software component outside of a package or without applicable license terms, 4 | the terms of the Apache-2.0 license shall apply. 5 | You may obtain a copy of the Apache-2.0 at: 6 | https://opensource.org/licenses/Apache-2.0 7 | -------------------------------------------------------------------------------- /Examples/STM32C011/01-RTC/Drivers/CMSIS/Include/cmsis_version.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file cmsis_version.h 3 | * @brief CMSIS Core(M) Version definitions 4 | * @version V5.0.3 5 | * @date 24. June 2019 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2009-2019 ARM Limited. All rights reserved. 9 | * 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the License); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | #if defined ( __ICCARM__ ) 26 | #pragma system_include /* treat file as system include file for MISRA check */ 27 | #elif defined (__clang__) 28 | #pragma clang system_header /* treat file as system include file */ 29 | #endif 30 | 31 | #ifndef __CMSIS_VERSION_H 32 | #define __CMSIS_VERSION_H 33 | 34 | /* CMSIS Version definitions */ 35 | #define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */ 36 | #define __CM_CMSIS_VERSION_SUB ( 3U) /*!< [15:0] CMSIS Core(M) sub version */ 37 | #define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \ 38 | __CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */ 39 | #endif 40 | -------------------------------------------------------------------------------- /Examples/STM32C011/01-RTC/Drivers/CMSIS/Include/tz_context.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * @file tz_context.h 3 | * @brief Context Management for Armv8-M TrustZone 4 | * @version V1.0.1 5 | * @date 10. January 2018 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2017-2018 Arm Limited. All rights reserved. 9 | * 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the License); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | #if defined ( __ICCARM__ ) 26 | #pragma system_include /* treat file as system include file for MISRA check */ 27 | #elif defined (__clang__) 28 | #pragma clang system_header /* treat file as system include file */ 29 | #endif 30 | 31 | #ifndef TZ_CONTEXT_H 32 | #define TZ_CONTEXT_H 33 | 34 | #include 35 | 36 | #ifndef TZ_MODULEID_T 37 | #define TZ_MODULEID_T 38 | /// \details Data type that identifies secure software modules called by a process. 39 | typedef uint32_t TZ_ModuleId_t; 40 | #endif 41 | 42 | /// \details TZ Memory ID identifies an allocated memory slot. 43 | typedef uint32_t TZ_MemoryId_t; 44 | 45 | /// Initialize secure context memory system 46 | /// \return execution status (1: success, 0: error) 47 | uint32_t TZ_InitContextSystem_S (void); 48 | 49 | /// Allocate context memory for calling secure software modules in TrustZone 50 | /// \param[in] module identifies software modules called from non-secure mode 51 | /// \return value != 0 id TrustZone memory slot identifier 52 | /// \return value 0 no memory available or internal error 53 | TZ_MemoryId_t TZ_AllocModuleContext_S (TZ_ModuleId_t module); 54 | 55 | /// Free context memory that was previously allocated with \ref TZ_AllocModuleContext_S 56 | /// \param[in] id TrustZone memory slot identifier 57 | /// \return execution status (1: success, 0: error) 58 | uint32_t TZ_FreeModuleContext_S (TZ_MemoryId_t id); 59 | 60 | /// Load secure context (called on RTOS thread context switch) 61 | /// \param[in] id TrustZone memory slot identifier 62 | /// \return execution status (1: success, 0: error) 63 | uint32_t TZ_LoadContext_S (TZ_MemoryId_t id); 64 | 65 | /// Store secure context (called on RTOS thread context switch) 66 | /// \param[in] id TrustZone memory slot identifier 67 | /// \return execution status (1: success, 0: error) 68 | uint32_t TZ_StoreContext_S (TZ_MemoryId_t id); 69 | 70 | #endif // TZ_CONTEXT_H 71 | -------------------------------------------------------------------------------- /Examples/STM32C011/01-RTC/Drivers/STM32C0xx_HAL_Driver/Inc/stm32c0xx_hal_def.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32c0xx_hal_def.h 4 | * @author MCD Application Team 5 | * @brief This file contains HAL common defines, enumeration, macros and 6 | * structures definitions. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2022 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef STM32C0xx_HAL_DEF 22 | #define STM32C0xx_HAL_DEF 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "stm32c0xx.h" 30 | #include "Legacy/stm32_hal_legacy.h" /* Aliases file for old names compatibility */ 31 | #include 32 | 33 | /* Exported types ------------------------------------------------------------*/ 34 | 35 | /** 36 | * @brief HAL Status structures definition 37 | */ 38 | typedef enum 39 | { 40 | HAL_OK = 0x00U, 41 | HAL_ERROR = 0x01U, 42 | HAL_BUSY = 0x02U, 43 | HAL_TIMEOUT = 0x03U 44 | } HAL_StatusTypeDef; 45 | 46 | /** 47 | * @brief HAL Lock structures definition 48 | */ 49 | typedef enum 50 | { 51 | HAL_UNLOCKED = 0x00U, 52 | HAL_LOCKED = 0x01U 53 | } HAL_LockTypeDef; 54 | 55 | /* Exported macros -----------------------------------------------------------*/ 56 | 57 | #define UNUSED(X) (void)X /* To avoid gcc/g++ warnings */ 58 | 59 | #define HAL_MAX_DELAY 0xFFFFFFFFU 60 | 61 | #define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) == (BIT)) 62 | #define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == 0U) 63 | 64 | #define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__) \ 65 | do{ \ 66 | (__HANDLE__)->__PPP_DMA_FIELD__ = &(__DMA_HANDLE__); \ 67 | (__DMA_HANDLE__).Parent = (__HANDLE__); \ 68 | } while(0U) 69 | 70 | /** @brief Reset the Handles State field. 71 | * @param __HANDLE__ specifies the Peripheral Handle. 72 | * @note This macro can be used for the following purpose: 73 | * - When the Handle is declared as local variable; before passing it as parameter 74 | * to HAL_PPP_Init() for the first time, it is mandatory to use this macro 75 | * to set to 0 the Handles "State" field. 76 | * Otherwise, "State" field may have any random value and the first time the function 77 | * HAL_PPP_Init() is called, the low level hardware initialization will be missed 78 | * (i.e. HAL_PPP_MspInit() will not be executed). 79 | * - When there is a need to reconfigure the low level hardware: instead of calling 80 | * HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init(). 81 | * In this later function, when the Handles "State" field is set to 0, it will execute the function 82 | * HAL_PPP_MspInit() which will reconfigure the low level hardware. 83 | * @retval None 84 | */ 85 | #define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0U) 86 | 87 | #if (USE_RTOS == 1U) 88 | /* Reserved for future use */ 89 | #error " USE_RTOS should be 0 in the current HAL release " 90 | #else 91 | #define __HAL_LOCK(__HANDLE__) \ 92 | do{ \ 93 | if((__HANDLE__)->Lock == HAL_LOCKED) \ 94 | { \ 95 | return HAL_BUSY; \ 96 | } \ 97 | else \ 98 | { \ 99 | (__HANDLE__)->Lock = HAL_LOCKED; \ 100 | } \ 101 | }while (0U) 102 | 103 | #define __HAL_UNLOCK(__HANDLE__) \ 104 | do{ \ 105 | (__HANDLE__)->Lock = HAL_UNLOCKED; \ 106 | }while (0U) 107 | #endif /* USE_RTOS */ 108 | 109 | #if defined ( __GNUC__ ) 110 | #ifndef __weak 111 | #define __weak __attribute__((weak)) 112 | #endif /* __weak */ 113 | #ifndef __packed 114 | #define __packed __attribute__((__packed__)) 115 | #endif /* __packed */ 116 | #endif /* __GNUC__ */ 117 | 118 | 119 | /* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */ 120 | /* GNU Compiler */ 121 | #if defined (__GNUC__) 122 | #ifndef __ALIGN_END 123 | #define __ALIGN_END __attribute__ ((aligned (4U))) 124 | #endif /* __ALIGN_END */ 125 | #ifndef __ALIGN_BEGIN 126 | #define __ALIGN_BEGIN 127 | #endif /* __ALIGN_BEGIN */ 128 | #else 129 | #ifndef __ALIGN_END 130 | #define __ALIGN_END 131 | #endif /* __ALIGN_END */ 132 | #ifndef __ALIGN_BEGIN 133 | /* ARM Compiler */ 134 | #if defined (__CC_ARM) 135 | #define __ALIGN_BEGIN __align(4U) 136 | /* IAR Compiler */ 137 | #elif defined (__ICCARM__) 138 | #define __ALIGN_BEGIN 139 | #endif /* __CC_ARM */ 140 | #endif /* __ALIGN_BEGIN */ 141 | #endif /* __GNUC__ */ 142 | 143 | /** 144 | * @brief __RAM_FUNC definition 145 | */ 146 | #if defined ( __CC_ARM ) 147 | /* ARM Compiler 148 | ------------ 149 | RAM functions are defined using the toolchain options. 150 | Functions that are executed in RAM should reside in a separate source module. 151 | Using the 'Options for File' dialog you can simply change the 'Code / Const' 152 | area of a module to a memory space in physical RAM. 153 | Available memory areas are declared in the 'Target' tab of the 'Options for Target' 154 | dialog. 155 | */ 156 | #define __RAM_FUNC 157 | 158 | #elif defined ( __ICCARM__ ) 159 | /* ICCARM Compiler 160 | --------------- 161 | RAM functions are defined using a specific toolchain keyword "__ramfunc". 162 | */ 163 | #define __RAM_FUNC __ramfunc 164 | 165 | #elif defined ( __GNUC__ ) 166 | /* GNU Compiler 167 | ------------ 168 | RAM functions are defined using a specific toolchain attribute 169 | "__attribute__((section(".RamFunc")))". 170 | */ 171 | #define __RAM_FUNC __attribute__((section(".RamFunc"))) 172 | 173 | #endif 174 | 175 | /** 176 | * @brief __NOINLINE definition 177 | */ 178 | #if defined ( __CC_ARM ) || defined ( __GNUC__ ) 179 | /* ARM & GNUCompiler 180 | ---------------- 181 | */ 182 | #define __NOINLINE __attribute__ ( (noinline) ) 183 | 184 | #elif defined ( __ICCARM__ ) 185 | /* ICCARM Compiler 186 | --------------- 187 | */ 188 | #define __NOINLINE _Pragma("optimize = no_inline") 189 | 190 | #endif 191 | 192 | 193 | #ifdef __cplusplus 194 | } 195 | #endif 196 | 197 | #endif /* STM32C0xx_HAL_DEF */ 198 | -------------------------------------------------------------------------------- /Examples/STM32C011/01-RTC/Drivers/STM32C0xx_HAL_Driver/Inc/stm32c0xx_hal_flash_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32c0xx_hal_flash_ex.h 4 | * @author MCD Application Team 5 | * @brief Header file of FLASH HAL Extended module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2022 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /* Define to prevent recursive inclusion -------------------------------------*/ 20 | #ifndef STM32C0xx_HAL_FLASH_EX_H 21 | #define STM32C0xx_HAL_FLASH_EX_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "stm32c0xx_hal_def.h" 29 | 30 | /** @addtogroup STM32C0xx_HAL_Driver 31 | * @{ 32 | */ 33 | 34 | /** @addtogroup FLASHEx 35 | * @{ 36 | */ 37 | 38 | /* Exported types ------------------------------------------------------------*/ 39 | /* Exported constants --------------------------------------------------------*/ 40 | /** @defgroup FLASHEx_Exported_Constants FLASHEx Exported Constants 41 | * @{ 42 | */ 43 | /** @defgroup FLASHEx_Empty_Check FLASHEx Empty Check 44 | * @{ 45 | */ 46 | #define FLASH_PROG_NOT_EMPTY 0x00000000u /*!< 1st location in Flash is programmed */ 47 | #define FLASH_PROG_EMPTY FLASH_ACR_PROGEMPTY /*!< 1st location in Flash is empty */ 48 | /** 49 | * @} 50 | */ 51 | /** 52 | * @} 53 | */ 54 | 55 | /* Exported macro ------------------------------------------------------------*/ 56 | /* Exported functions --------------------------------------------------------*/ 57 | /** @addtogroup FLASHEx_Exported_Functions 58 | * @{ 59 | */ 60 | 61 | /* Extended Program operation functions *************************************/ 62 | /** @addtogroup FLASHEx_Exported_Functions_Group1 63 | * @{ 64 | */ 65 | HAL_StatusTypeDef HAL_FLASHEx_Erase(FLASH_EraseInitTypeDef *pEraseInit, uint32_t *PageError); 66 | HAL_StatusTypeDef HAL_FLASHEx_Erase_IT(FLASH_EraseInitTypeDef *pEraseInit); 67 | void HAL_FLASHEx_EnableDebugger(void); 68 | void HAL_FLASHEx_DisableDebugger(void); 69 | uint32_t HAL_FLASHEx_FlashEmptyCheck(void); 70 | void HAL_FLASHEx_ForceFlashEmpty(uint32_t FlashEmpty); 71 | void HAL_FLASHEx_EnableSecMemProtection(uint32_t Bank); 72 | HAL_StatusTypeDef HAL_FLASHEx_OBProgram(FLASH_OBProgramInitTypeDef *pOBInit); 73 | void HAL_FLASHEx_OBGetConfig(FLASH_OBProgramInitTypeDef *pOBInit); 74 | /** 75 | * @} 76 | */ 77 | 78 | /** 79 | * @} 80 | */ 81 | 82 | /* Private macros ------------------------------------------------------------*/ 83 | /** @defgroup FLASHEx_Private_Constants FLASHEx Private Constants 84 | * @{ 85 | */ 86 | #define FLASH_PCROP_GRANULARITY_OFFSET 9u /*!< FLASH Code Readout 87 | Protection granularity offset */ 88 | #define FLASH_PCROP_GRANULARITY (1UL << FLASH_PCROP_GRANULARITY_OFFSET) /*!< FLASH Code Readout 89 | Protection granularity, 512 Bytes */ 90 | /** 91 | * @} 92 | */ 93 | 94 | 95 | /** @defgroup FLASHEx_Private_Macros FLASHEx Private Macros 96 | * @{ 97 | */ 98 | #define IS_FLASH_EMPTY_CHECK(__VALUE__) (((__VALUE__) == FLASH_PROG_EMPTY) || ((__VALUE__) == FLASH_PROG_NOT_EMPTY)) 99 | void FLASH_PageErase(uint32_t Page); 100 | /** 101 | * @} 102 | */ 103 | 104 | /** 105 | * @} 106 | */ 107 | 108 | /** 109 | * @} 110 | */ 111 | 112 | #ifdef __cplusplus 113 | } 114 | #endif 115 | 116 | #endif /* STM32C0xx_HAL_FLASH_EX_H */ 117 | -------------------------------------------------------------------------------- /Examples/STM32C011/01-RTC/Drivers/STM32C0xx_HAL_Driver/Inc/stm32c0xx_hal_pwr_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32c0xx_hal_pwr_ex.h 4 | * @author MCD Application Team 5 | * @brief Header file of PWR HAL Extended module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2022 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /* Define to prevent recursive inclusion -------------------------------------*/ 20 | #ifndef STM32C0xx_HAL_PWR_EX_H 21 | #define STM32C0xx_HAL_PWR_EX_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "stm32c0xx_hal_def.h" 29 | 30 | /** @addtogroup STM32C0xx_HAL_Driver 31 | * @{ 32 | */ 33 | 34 | /** @defgroup PWREx PWREx 35 | * @brief PWR Extended HAL module driver 36 | * @{ 37 | */ 38 | 39 | /* Exported types ------------------------------------------------------------*/ 40 | /* Exported constants --------------------------------------------------------*/ 41 | /** @defgroup PWREx_Exported_Constants PWR Extended Exported Constants 42 | * @{ 43 | */ 44 | 45 | /** @defgroup PWREx_GPIO_Pin_Mask PWR Extended GPIO Pin Mask 46 | * @{ 47 | */ 48 | #define PWR_GPIO_BIT_0 (0x0001U) /*!< GPIO port I/O pin 0 */ 49 | #define PWR_GPIO_BIT_1 (0x0002U) /*!< GPIO port I/O pin 1 */ 50 | #define PWR_GPIO_BIT_2 (0x0004U) /*!< GPIO port I/O pin 2 */ 51 | #define PWR_GPIO_BIT_3 (0x0008U) /*!< GPIO port I/O pin 3 */ 52 | #define PWR_GPIO_BIT_4 (0x0010U) /*!< GPIO port I/O pin 4 */ 53 | #define PWR_GPIO_BIT_5 (0x0020U) /*!< GPIO port I/O pin 5 */ 54 | #define PWR_GPIO_BIT_6 (0x0040U) /*!< GPIO port I/O pin 6 */ 55 | #define PWR_GPIO_BIT_7 (0x0080U) /*!< GPIO port I/O pin 7 */ 56 | #define PWR_GPIO_BIT_8 (0x0100U) /*!< GPIO port I/O pin 8 */ 57 | #define PWR_GPIO_BIT_9 (0x0200U) /*!< GPIO port I/O pin 9 */ 58 | #define PWR_GPIO_BIT_10 (0x0400U) /*!< GPIO port I/O pin 10 */ 59 | #define PWR_GPIO_BIT_11 (0x0800U) /*!< GPIO port I/O pin 11 */ 60 | #define PWR_GPIO_BIT_12 (0x1000U) /*!< GPIO port I/O pin 12 */ 61 | #define PWR_GPIO_BIT_13 (0x2000U) /*!< GPIO port I/O pin 13 */ 62 | #define PWR_GPIO_BIT_14 (0x4000U) /*!< GPIO port I/O pin 14 */ 63 | #define PWR_GPIO_BIT_15 (0x8000U) /*!< GPIO port I/O pin 15 */ 64 | /** 65 | * @} 66 | */ 67 | 68 | /** @defgroup PWREx_Backup_Registers PWREx Backup Registers Definition 69 | * @{ 70 | */ 71 | #define PWR_BKP_NUMBER 4U 72 | #define PWR_BKP_DR0 0x00U 73 | #define PWR_BKP_DR1 0x01U 74 | #define PWR_BKP_DR2 0x02U 75 | #define PWR_BKP_DR3 0x03U 76 | /** 77 | * @} 78 | */ 79 | 80 | /** @defgroup PWREx_GPIO_Port GPIO Port 81 | * @{ 82 | */ 83 | #define PWR_GPIO_A (0x00000000u) /*!< GPIO port A */ 84 | #define PWR_GPIO_B (0x00000001u) /*!< GPIO port B */ 85 | #define PWR_GPIO_C (0x00000002u) /*!< GPIO port C */ 86 | #if defined(STM32C031xx) 87 | #define PWR_GPIO_D (0x00000003u) /*!< GPIO port D */ 88 | #endif /* STM32C031xx */ 89 | #define PWR_GPIO_F (0x00000005u) /*!< GPIO port F */ 90 | /** 91 | * @} 92 | */ 93 | 94 | /** @defgroup PWREx_Flash_PowerDown Flash Power Down modes 95 | * @{ 96 | */ 97 | #define PWR_FLASHPD_SLEEP PWR_CR1_FPD_SLP /*!< Enable Flash power down in sleep mode */ 98 | #define PWR_FLASHPD_STOP PWR_CR1_FPD_STOP /*!< Enable Flash power down in stop mode */ 99 | /** 100 | * @} 101 | */ 102 | 103 | 104 | /** 105 | * @} 106 | */ 107 | 108 | /* Exported macros -----------------------------------------------------------*/ 109 | /* Private macros ------------------------------------------------------------*/ 110 | /** @addtogroup PWREx_Private_Macros PWR Extended Private Macros 111 | * @{ 112 | */ 113 | 114 | #define IS_PWR_GPIO_BIT_NUMBER(__BIT_NUMBER__) ((((__BIT_NUMBER__) & 0x0000FFFFu) != 0x00u) && \ 115 | (((__BIT_NUMBER__) & 0xFFFF0000u) == 0x00u)) 116 | #if defined(STM32C031xx) 117 | #define IS_PWR_GPIO(__GPIO__) (((__GPIO__) == PWR_GPIO_A) || \ 118 | ((__GPIO__) == PWR_GPIO_B) || \ 119 | ((__GPIO__) == PWR_GPIO_C) || \ 120 | ((__GPIO__) == PWR_GPIO_D) || \ 121 | ((__GPIO__) == PWR_GPIO_F)) 122 | #elif defined (STM32C011xx) 123 | #define IS_PWR_GPIO(__GPIO__) (((__GPIO__) == PWR_GPIO_A) || \ 124 | ((__GPIO__) == PWR_GPIO_B) || \ 125 | ((__GPIO__) == PWR_GPIO_C) || \ 126 | ((__GPIO__) == PWR_GPIO_F)) 127 | 128 | #endif /* STM32C031xx */ 129 | #define IS_PWR_FLASH_POWERDOWN(__MODE__) ((((__MODE__) & (PWR_FLASHPD_SLEEP | PWR_FLASHPD_STOP)) != 0x00u) && \ 130 | (((__MODE__) & ~(PWR_FLASHPD_SLEEP | PWR_FLASHPD_STOP)) == 0x00u)) 131 | 132 | #define IS_PWR_BKP(__BKP__) ((__BKP__) < PWR_BKP_NUMBER) 133 | 134 | 135 | 136 | /** 137 | * @} 138 | */ 139 | 140 | /* Exported functions --------------------------------------------------------*/ 141 | /** @defgroup PWREx_Exported_Functions PWR Extended Exported Functions 142 | * @{ 143 | */ 144 | 145 | /** @defgroup PWREx_Exported_Functions_Group1 Extended Peripheral Control functions 146 | * @{ 147 | */ 148 | 149 | /* Peripheral Control functions **********************************************/ 150 | void HAL_PWREx_EnableInternalWakeUpLine(void); 151 | void HAL_PWREx_DisableInternalWakeUpLine(void); 152 | HAL_StatusTypeDef HAL_PWREx_EnableGPIOPullUp(uint32_t GPIO, uint32_t GPIONumber); 153 | HAL_StatusTypeDef HAL_PWREx_DisableGPIOPullUp(uint32_t GPIO, uint32_t GPIONumber); 154 | HAL_StatusTypeDef HAL_PWREx_EnableGPIOPullDown(uint32_t GPIO, uint32_t GPIONumber); 155 | HAL_StatusTypeDef HAL_PWREx_DisableGPIOPullDown(uint32_t GPIO, uint32_t GPIONumber); 156 | void HAL_PWREx_EnablePullUpPullDownConfig(void); 157 | void HAL_PWREx_DisablePullUpPullDownConfig(void); 158 | void HAL_PWREx_EnableFlashPowerDown(uint32_t PowerMode); 159 | void HAL_PWREx_DisableFlashPowerDown(uint32_t PowerMode); 160 | void HAL_PWREx_BKUPWrite(uint32_t BackupRegister, uint16_t Data); 161 | uint32_t HAL_PWREx_BKUPRead(uint32_t BackupRegister); 162 | 163 | /* Low Power modes configuration functions ************************************/ 164 | void HAL_PWREx_EnterSHUTDOWNMode(void); 165 | 166 | 167 | /** 168 | * @} 169 | */ 170 | 171 | /** 172 | * @} 173 | */ 174 | 175 | /** 176 | * @} 177 | */ 178 | 179 | /** 180 | * @} 181 | */ 182 | 183 | #ifdef __cplusplus 184 | } 185 | #endif 186 | 187 | 188 | #endif /* STM32C0xx_HAL_PWR_EX_H */ 189 | -------------------------------------------------------------------------------- /Examples/STM32C011/01-RTC/Drivers/STM32C0xx_HAL_Driver/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright 2022 STMicroelectronics. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | 2. Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation and/or 12 | other materials provided with the distribution. 13 | 14 | 3. Neither the name of the copyright holder nor the names of its contributors 15 | may be used to endorse or promote products derived from this software without 16 | specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 22 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 25 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /Examples/STM32C011/01-RTC/Drivers/STM32C0xx_HAL_Driver/LICENSE.txt: -------------------------------------------------------------------------------- 1 | This software component is provided to you as part of a software package and 2 | applicable license terms are in the Package_license file. If you received this 3 | software component outside of a package or without applicable license terms, 4 | the terms of the BSD-3-Clause license shall apply. 5 | You may obtain a copy of the BSD-3-Clause at: 6 | https://opensource.org/licenses/BSD-3-Clause 7 | -------------------------------------------------------------------------------- /Examples/STM32C011/01-RTC/MDK-ARM/01-RTC/01-RTC.axf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeActStudio/WeActStudio.STM32G0xxC0xxCoreBoard/f692e4e2e853ae9610aa337e2222c6d6d73416d8/Examples/STM32C011/01-RTC/MDK-ARM/01-RTC/01-RTC.axf -------------------------------------------------------------------------------- /Examples/STM32C011/01-RTC/MDK-ARM/RTE/_01-RTC/RTE_Components.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Auto generated Run-Time-Environment Configuration File 4 | * *** Do not modify ! *** 5 | * 6 | * Project: '01-RTC' 7 | * Target: '01-RTC' 8 | */ 9 | 10 | #ifndef RTE_COMPONENTS_H 11 | #define RTE_COMPONENTS_H 12 | 13 | 14 | /* 15 | * Define the Device Header File: 16 | */ 17 | #define CMSIS_device_header "stm32c0xx.h" 18 | 19 | 20 | 21 | #endif /* RTE_COMPONENTS_H */ 22 | -------------------------------------------------------------------------------- /Examples/STM32G030/01-RTC/01-RTC.ioc: -------------------------------------------------------------------------------- 1 | #MicroXplorer Configuration settings - do not modify 2 | CAD.formats= 3 | CAD.pinconfig= 4 | CAD.provider= 5 | File.Version=6 6 | GPIO.groupedBy=Group By Peripherals 7 | KeepUserPlacement=false 8 | Mcu.CPN=STM32G030F6P6 9 | Mcu.Family=STM32G0 10 | Mcu.IP0=NVIC 11 | Mcu.IP1=RCC 12 | Mcu.IP2=RTC 13 | Mcu.IP3=SYS 14 | Mcu.IP4=USART1 15 | Mcu.IPNb=5 16 | Mcu.Name=STM32G030F6Px 17 | Mcu.Package=TSSOP20 18 | Mcu.Pin0=PC14-OSC32_IN (PC14) 19 | Mcu.Pin1=PC15-OSC32_OUT (PC15) 20 | Mcu.Pin10=VP_SYS_VS_Systick 21 | Mcu.Pin2=PA9 [PA11] 22 | Mcu.Pin3=PA10 [PA12] 23 | Mcu.Pin4=PA13 24 | Mcu.Pin5=PA14-BOOT0 25 | Mcu.Pin6=VP_RTC_VS_RTC_Activate 26 | Mcu.Pin7=VP_RTC_VS_RTC_Calendar 27 | Mcu.Pin8=VP_SYS_VS_PINREMAP 28 | Mcu.Pin9=VP_SYS_VS_PINREMAP_10_12 29 | Mcu.PinsNb=11 30 | Mcu.ThirdPartyNb=0 31 | Mcu.UserConstants= 32 | Mcu.UserName=STM32G030F6Px 33 | MxCube.Version=6.7.0 34 | MxDb.Version=DB.6.0.70 35 | NVIC.ForceEnableDMAVector=true 36 | NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false 37 | NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false 38 | NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false 39 | NVIC.SVC_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:true 40 | NVIC.SysTick_IRQn=true\:3\:0\:false\:false\:true\:false\:true\:false 41 | PA10\ [PA12].Locked=true 42 | PA10\ [PA12].Mode=Asynchronous 43 | PA10\ [PA12].Signal=USART1_RX 44 | PA13.Mode=Serial_Wire 45 | PA13.Signal=SYS_SWDIO 46 | PA14-BOOT0.Mode=Serial_Wire 47 | PA14-BOOT0.Signal=SYS_SWCLK 48 | PA14-BOOT0__PA15.StandardMode=true 49 | PA9\ [PA11].Locked=true 50 | PA9\ [PA11].Mode=Asynchronous 51 | PA9\ [PA11].Signal=USART1_TX 52 | PB0__PB1__PB2__PA8.StandardMode=true 53 | PB3__PB4__PB5__PB6.StandardMode=true 54 | PB7__PB8.StandardMode=true 55 | PC14-OSC32_IN\ (PC14).Mode=LSE-External-Oscillator 56 | PC14-OSC32_IN\ (PC14).Signal=RCC_OSC32_IN 57 | PC14-OSC32_IN\ (PC14)__PB9.StandardMode=true 58 | PC15-OSC32_OUT\ (PC15).Mode=LSE-External-Oscillator 59 | PC15-OSC32_OUT\ (PC15).Signal=RCC_OSC32_OUT 60 | PinOutPanel.RotationAngle=0 61 | ProjectManager.AskForMigrate=true 62 | ProjectManager.BackupPrevious=false 63 | ProjectManager.CompilerOptimize=6 64 | ProjectManager.ComputerToolchain=false 65 | ProjectManager.CoupleFile=true 66 | ProjectManager.CustomerFirmwarePackage= 67 | ProjectManager.DefaultFWLocation=true 68 | ProjectManager.DeletePrevious=true 69 | ProjectManager.DeviceId=STM32G030F6Px 70 | ProjectManager.FirmwarePackage=STM32Cube FW_G0 V1.6.1 71 | ProjectManager.FreePins=false 72 | ProjectManager.HalAssertFull=false 73 | ProjectManager.HeapSize=0x200 74 | ProjectManager.KeepUserCode=true 75 | ProjectManager.LastFirmware=true 76 | ProjectManager.LibraryCopy=1 77 | ProjectManager.MainLocation=Core/Src 78 | ProjectManager.NoMain=false 79 | ProjectManager.PreviousToolchain= 80 | ProjectManager.ProjectBuild=false 81 | ProjectManager.ProjectFileName=01-RTC.ioc 82 | ProjectManager.ProjectName=01-RTC 83 | ProjectManager.RegisterCallBack= 84 | ProjectManager.StackSize=0x400 85 | ProjectManager.TargetToolchain=MDK-ARM V5.32 86 | ProjectManager.ToolChainLocation= 87 | ProjectManager.UnderRoot=false 88 | ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_RTC_Init-RTC-false-HAL-true,4-MX_USART1_UART_Init-USART1-false-HAL-true 89 | RCC.ADCFreq_Value=64000000 90 | RCC.AHBFreq_Value=64000000 91 | RCC.APBFreq_Value=64000000 92 | RCC.APBTimFreq_Value=64000000 93 | RCC.CortexFreq_Value=64000000 94 | RCC.EXTERNAL_CLOCK_VALUE=12288000 95 | RCC.FCLKCortexFreq_Value=64000000 96 | RCC.FamilyName=M 97 | RCC.HCLKFreq_Value=64000000 98 | RCC.HSE_VALUE=8000000 99 | RCC.HSI_VALUE=16000000 100 | RCC.I2C1Freq_Value=64000000 101 | RCC.I2S1Freq_Value=64000000 102 | RCC.IPParameters=ADCFreq_Value,AHBFreq_Value,APBFreq_Value,APBTimFreq_Value,CortexFreq_Value,EXTERNAL_CLOCK_VALUE,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,HSI_VALUE,I2C1Freq_Value,I2S1Freq_Value,LSCOPinFreq_Value,LSI_VALUE,MCO1PinFreq_Value,PLLPoutputFreq_Value,PLLRCLKFreq_Value,PWRFreq_Value,RTCClockSelection,RTCFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,USART1Freq_Value,VCOInputFreq_Value,VCOOutputFreq_Value 103 | RCC.LSCOPinFreq_Value=32000 104 | RCC.LSI_VALUE=32000 105 | RCC.MCO1PinFreq_Value=64000000 106 | RCC.PLLPoutputFreq_Value=64000000 107 | RCC.PLLRCLKFreq_Value=64000000 108 | RCC.PWRFreq_Value=64000000 109 | RCC.RTCClockSelection=RCC_RTCCLKSOURCE_LSE 110 | RCC.RTCFreq_Value=32768 111 | RCC.SYSCLKFreq_VALUE=64000000 112 | RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK 113 | RCC.USART1Freq_Value=64000000 114 | RCC.VCOInputFreq_Value=16000000 115 | RCC.VCOOutputFreq_Value=128000000 116 | RTC.IPParameters=Year 117 | RTC.Year=23 118 | USART1.IPParameters=VirtualMode-Asynchronous 119 | USART1.VirtualMode-Asynchronous=VM_ASYNC 120 | VP_RTC_VS_RTC_Activate.Mode=RTC_Enabled 121 | VP_RTC_VS_RTC_Activate.Signal=RTC_VS_RTC_Activate 122 | VP_RTC_VS_RTC_Calendar.Mode=RTC_Calendar 123 | VP_RTC_VS_RTC_Calendar.Signal=RTC_VS_RTC_Calendar 124 | VP_SYS_VS_PINREMAP.Mode=PINREMAP 125 | VP_SYS_VS_PINREMAP.Signal=SYS_VS_PINREMAP 126 | VP_SYS_VS_PINREMAP_10_12.Mode=PINREMAP_10_12 127 | VP_SYS_VS_PINREMAP_10_12.Signal=SYS_VS_PINREMAP_10_12 128 | VP_SYS_VS_Systick.Mode=SysTick 129 | VP_SYS_VS_Systick.Signal=SYS_VS_Systick 130 | board=custom 131 | -------------------------------------------------------------------------------- /Examples/STM32G030/01-RTC/Bsp/board.c: -------------------------------------------------------------------------------- 1 | /*--------------------------------------- 2 | - WeAct Studio Official Link 3 | - taobao: weactstudio.taobao.com 4 | - aliexpress: weactstudio.aliexpress.com 5 | - github: github.com/WeActTC 6 | - gitee: gitee.com/WeAct-TC 7 | - blog: www.weact-tc.cn 8 | ---------------------------------------*/ 9 | 10 | #include "board.h" 11 | 12 | void board_button_init(void) 13 | { 14 | GPIO_InitTypeDef GPIO_InitStruct = {0}; 15 | 16 | /* GPIO Ports Clock Enable */ 17 | __HAL_RCC_GPIOA_CLK_ENABLE(); 18 | 19 | /*Configure GPIO pin : PtPin */ 20 | GPIO_InitStruct.Pin = KEY_Pin; 21 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT; 22 | GPIO_InitStruct.Pull = GPIO_PULLDOWN; 23 | HAL_GPIO_Init(KEY_GPIO_Port, &GPIO_InitStruct); 24 | } 25 | 26 | uint8_t board_button_getstate(void) 27 | { 28 | return HAL_GPIO_ReadPin(KEY_GPIO_Port,KEY_Pin)==GPIO_PIN_SET?1:0; 29 | } 30 | 31 | void board_led_init(void) 32 | { 33 | GPIO_InitTypeDef GPIO_InitStruct = {0}; 34 | 35 | /* GPIO Ports Clock Enable */ 36 | __HAL_RCC_GPIOA_CLK_ENABLE(); 37 | 38 | /*Configure GPIO pin Output Level */ 39 | HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_SET); 40 | 41 | /*Configure GPIO pin : PtPin */ 42 | GPIO_InitStruct.Pin = LED_Pin; 43 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 44 | GPIO_InitStruct.Pull = GPIO_NOPULL; 45 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 46 | HAL_GPIO_Init(LED_GPIO_Port, &GPIO_InitStruct); 47 | } 48 | 49 | void board_led_toggle(void) 50 | { 51 | HAL_GPIO_TogglePin(LED_GPIO_Port,LED_Pin); 52 | } 53 | 54 | void board_led_set(uint8_t set) 55 | { 56 | if (set) 57 | HAL_GPIO_WritePin(LED_GPIO_Port,LED_Pin,GPIO_PIN_SET); 58 | else 59 | HAL_GPIO_WritePin(LED_GPIO_Port,LED_Pin,GPIO_PIN_RESET); 60 | } 61 | -------------------------------------------------------------------------------- /Examples/STM32G030/01-RTC/Bsp/board.h: -------------------------------------------------------------------------------- 1 | #ifndef __BOARD_H 2 | #define __BOARD_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" 6 | { 7 | #endif 8 | 9 | #include "main.h" 10 | 11 | #ifndef KEY_Pin 12 | #define KEY_Pin GPIO_PIN_14 13 | #endif 14 | #ifndef KEY_GPIO_Port 15 | #define KEY_GPIO_Port GPIOA 16 | #endif 17 | #ifndef LED_Pin 18 | #define LED_Pin GPIO_PIN_4 19 | #endif 20 | #ifndef LED_GPIO_Port 21 | #define LED_GPIO_Port GPIOA 22 | #endif 23 | 24 | void board_button_init(void); 25 | uint8_t board_button_getstate(void); 26 | void board_led_init(void); 27 | void board_led_toggle(void); 28 | void board_led_set(uint8_t set); 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /Examples/STM32G030/01-RTC/Core/Inc/gpio.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file gpio.h 5 | * @brief This file contains all the function prototypes for 6 | * the gpio.c file 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2023 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __GPIO_H__ 22 | #define __GPIO_H__ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "main.h" 30 | 31 | /* USER CODE BEGIN Includes */ 32 | 33 | /* USER CODE END Includes */ 34 | 35 | /* USER CODE BEGIN Private defines */ 36 | 37 | /* USER CODE END Private defines */ 38 | 39 | void MX_GPIO_Init(void); 40 | 41 | /* USER CODE BEGIN Prototypes */ 42 | 43 | /* USER CODE END Prototypes */ 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | #endif /*__ GPIO_H__ */ 49 | 50 | -------------------------------------------------------------------------------- /Examples/STM32G030/01-RTC/Core/Inc/main.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : main.h 5 | * @brief : Header for main.c file. 6 | * This file contains the common defines of the application. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2023 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __MAIN_H 23 | #define __MAIN_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | #include "stm32g0xx_hal.h" 31 | 32 | /* Private includes ----------------------------------------------------------*/ 33 | /* USER CODE BEGIN Includes */ 34 | 35 | /* USER CODE END Includes */ 36 | 37 | /* Exported types ------------------------------------------------------------*/ 38 | /* USER CODE BEGIN ET */ 39 | 40 | /* USER CODE END ET */ 41 | 42 | /* Exported constants --------------------------------------------------------*/ 43 | /* USER CODE BEGIN EC */ 44 | 45 | /* USER CODE END EC */ 46 | 47 | /* Exported macro ------------------------------------------------------------*/ 48 | /* USER CODE BEGIN EM */ 49 | 50 | /* USER CODE END EM */ 51 | 52 | /* Exported functions prototypes ---------------------------------------------*/ 53 | void Error_Handler(void); 54 | 55 | /* USER CODE BEGIN EFP */ 56 | 57 | /* USER CODE END EFP */ 58 | 59 | /* Private defines -----------------------------------------------------------*/ 60 | 61 | /* USER CODE BEGIN Private defines */ 62 | 63 | /* USER CODE END Private defines */ 64 | 65 | #ifdef __cplusplus 66 | } 67 | #endif 68 | 69 | #endif /* __MAIN_H */ 70 | -------------------------------------------------------------------------------- /Examples/STM32G030/01-RTC/Core/Inc/rtc.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file rtc.h 5 | * @brief This file contains all the function prototypes for 6 | * the rtc.c file 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2023 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __RTC_H__ 22 | #define __RTC_H__ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "main.h" 30 | 31 | /* USER CODE BEGIN Includes */ 32 | 33 | /* USER CODE END Includes */ 34 | 35 | extern RTC_HandleTypeDef hrtc; 36 | 37 | /* USER CODE BEGIN Private defines */ 38 | 39 | /* USER CODE END Private defines */ 40 | 41 | void MX_RTC_Init(void); 42 | 43 | /* USER CODE BEGIN Prototypes */ 44 | 45 | /* USER CODE END Prototypes */ 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | 51 | #endif /* __RTC_H__ */ 52 | 53 | -------------------------------------------------------------------------------- /Examples/STM32G030/01-RTC/Core/Inc/stm32g0xx_it.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32g0xx_it.h 5 | * @brief This file contains the headers of the interrupt handlers. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2023 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | /* USER CODE END Header */ 19 | 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __STM32G0xx_IT_H 22 | #define __STM32G0xx_IT_H 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Private includes ----------------------------------------------------------*/ 29 | /* USER CODE BEGIN Includes */ 30 | 31 | /* USER CODE END Includes */ 32 | 33 | /* Exported types ------------------------------------------------------------*/ 34 | /* USER CODE BEGIN ET */ 35 | 36 | /* USER CODE END ET */ 37 | 38 | /* Exported constants --------------------------------------------------------*/ 39 | /* USER CODE BEGIN EC */ 40 | 41 | /* USER CODE END EC */ 42 | 43 | /* Exported macro ------------------------------------------------------------*/ 44 | /* USER CODE BEGIN EM */ 45 | 46 | /* USER CODE END EM */ 47 | 48 | /* Exported functions prototypes ---------------------------------------------*/ 49 | void NMI_Handler(void); 50 | void HardFault_Handler(void); 51 | void SVC_Handler(void); 52 | void PendSV_Handler(void); 53 | void SysTick_Handler(void); 54 | /* USER CODE BEGIN EFP */ 55 | 56 | /* USER CODE END EFP */ 57 | 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | 62 | #endif /* __STM32G0xx_IT_H */ 63 | -------------------------------------------------------------------------------- /Examples/STM32G030/01-RTC/Core/Inc/usart.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file usart.h 5 | * @brief This file contains all the function prototypes for 6 | * the usart.c file 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2023 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __USART_H__ 22 | #define __USART_H__ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "main.h" 30 | 31 | /* USER CODE BEGIN Includes */ 32 | 33 | /* USER CODE END Includes */ 34 | 35 | extern UART_HandleTypeDef huart1; 36 | 37 | /* USER CODE BEGIN Private defines */ 38 | 39 | /* USER CODE END Private defines */ 40 | 41 | void MX_USART1_UART_Init(void); 42 | 43 | /* USER CODE BEGIN Prototypes */ 44 | 45 | /* USER CODE END Prototypes */ 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | 51 | #endif /* __USART_H__ */ 52 | 53 | -------------------------------------------------------------------------------- /Examples/STM32G030/01-RTC/Core/Src/gpio.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file gpio.c 5 | * @brief This file provides code for the configuration 6 | * of all used GPIO pins. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2023 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | #include "gpio.h" 23 | 24 | /* USER CODE BEGIN 0 */ 25 | 26 | /* USER CODE END 0 */ 27 | 28 | /*----------------------------------------------------------------------------*/ 29 | /* Configure GPIO */ 30 | /*----------------------------------------------------------------------------*/ 31 | /* USER CODE BEGIN 1 */ 32 | 33 | /* USER CODE END 1 */ 34 | 35 | /** Configure pins as 36 | * Analog 37 | * Input 38 | * Output 39 | * EVENT_OUT 40 | * EXTI 41 | */ 42 | void MX_GPIO_Init(void) 43 | { 44 | 45 | /* GPIO Ports Clock Enable */ 46 | __HAL_RCC_GPIOC_CLK_ENABLE(); 47 | __HAL_RCC_GPIOA_CLK_ENABLE(); 48 | 49 | } 50 | 51 | /* USER CODE BEGIN 2 */ 52 | 53 | /* USER CODE END 2 */ 54 | -------------------------------------------------------------------------------- /Examples/STM32G030/01-RTC/Core/Src/main.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : main.c 5 | * @brief : Main program body 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2023 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | /* USER CODE END Header */ 19 | /* Includes ------------------------------------------------------------------*/ 20 | #include "main.h" 21 | #include "rtc.h" 22 | #include "usart.h" 23 | #include "gpio.h" 24 | 25 | /* Private includes ----------------------------------------------------------*/ 26 | /* USER CODE BEGIN Includes */ 27 | #include 28 | /* USER CODE END Includes */ 29 | 30 | /* Private typedef -----------------------------------------------------------*/ 31 | /* USER CODE BEGIN PTD */ 32 | 33 | /* USER CODE END PTD */ 34 | 35 | /* Private define ------------------------------------------------------------*/ 36 | /* USER CODE BEGIN PD */ 37 | #if defined (__ICCARM__) || defined (__ARMCC_VERSION) 38 | #define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f) 39 | #elif defined(__GNUC__) 40 | /* With GCC, small printf (option LD Linker->Libraries->Small printf 41 | set to 'Yes') calls __io_putchar() */ 42 | #define PUTCHAR_PROTOTYPE int __io_putchar(int ch) 43 | #endif /* __ICCARM__ || __ARMCC_VERSION */ 44 | /* USER CODE END PD */ 45 | 46 | /* Private macro -------------------------------------------------------------*/ 47 | /* USER CODE BEGIN PM */ 48 | 49 | /* USER CODE END PM */ 50 | 51 | /* Private variables ---------------------------------------------------------*/ 52 | 53 | /* USER CODE BEGIN PV */ 54 | 55 | /* USER CODE END PV */ 56 | 57 | /* Private function prototypes -----------------------------------------------*/ 58 | void SystemClock_Config(void); 59 | /* USER CODE BEGIN PFP */ 60 | 61 | /* USER CODE END PFP */ 62 | 63 | /* Private user code ---------------------------------------------------------*/ 64 | /* USER CODE BEGIN 0 */ 65 | /** 66 | * @brief Retargets the C library printf function to the USART. 67 | * @param None 68 | * @retval None 69 | */ 70 | PUTCHAR_PROTOTYPE 71 | { 72 | /* Place your implementation of fputc here */ 73 | /* e.g. write a character to the USART2 and Loop until the end of transmission */ 74 | HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, 0xFFFF); 75 | 76 | return ch; 77 | } 78 | /* USER CODE END 0 */ 79 | 80 | /** 81 | * @brief The application entry point. 82 | * @retval int 83 | */ 84 | int main(void) 85 | { 86 | /* USER CODE BEGIN 1 */ 87 | 88 | /* USER CODE END 1 */ 89 | 90 | /* MCU Configuration--------------------------------------------------------*/ 91 | 92 | /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ 93 | HAL_Init(); 94 | 95 | /* USER CODE BEGIN Init */ 96 | 97 | /* USER CODE END Init */ 98 | 99 | /* Configure the system clock */ 100 | SystemClock_Config(); 101 | 102 | /* USER CODE BEGIN SysInit */ 103 | 104 | /* USER CODE END SysInit */ 105 | 106 | /* Initialize all configured peripherals */ 107 | MX_GPIO_Init(); 108 | MX_RTC_Init(); 109 | MX_USART1_UART_Init(); 110 | /* USER CODE BEGIN 2 */ 111 | #include "board.h" 112 | 113 | // for swd debug 114 | //board_button_init(); 115 | 116 | board_led_init(); 117 | 118 | uint32_t tick,tick_now; 119 | tick = HAL_GetTick() + 200; 120 | tick_now = HAL_GetTick(); 121 | /* USER CODE END 2 */ 122 | 123 | /* Infinite loop */ 124 | /* USER CODE BEGIN WHILE */ 125 | while (1) 126 | { 127 | /* USER CODE END WHILE */ 128 | 129 | /* USER CODE BEGIN 3 */ 130 | tick_now = HAL_GetTick(); 131 | if(board_button_getstate()) 132 | { 133 | if(tick_now >= tick) 134 | { 135 | tick = tick_now + 200; 136 | board_led_toggle(); 137 | } 138 | } 139 | else 140 | { 141 | if(tick_now >= tick) 142 | { 143 | tick = tick_now + 50; 144 | 145 | RTC_DateTypeDef sdatestructureget; 146 | RTC_TimeTypeDef stimestructureget; 147 | static uint8_t Seconds_o; 148 | 149 | /* Get the RTC current Time */ 150 | HAL_RTC_GetTime(&hrtc, &stimestructureget, RTC_FORMAT_BIN); 151 | /* Get the RTC current Date */ 152 | HAL_RTC_GetDate(&hrtc, &sdatestructureget, RTC_FORMAT_BIN); 153 | 154 | if(Seconds_o != stimestructureget.Seconds) 155 | { 156 | Seconds_o = stimestructureget.Seconds; 157 | 158 | printf("20%02d.%02d.%02d %02d:%02d %02d\r\n",sdatestructureget.Year,sdatestructureget.Month,sdatestructureget.Date, \ 159 | stimestructureget.Hours,stimestructureget.Minutes,stimestructureget.Seconds); 160 | board_led_set(0); 161 | } 162 | else 163 | { 164 | board_led_set(1); 165 | } 166 | } 167 | } 168 | } 169 | /* USER CODE END 3 */ 170 | } 171 | 172 | /** 173 | * @brief System Clock Configuration 174 | * @retval None 175 | */ 176 | void SystemClock_Config(void) 177 | { 178 | RCC_OscInitTypeDef RCC_OscInitStruct = {0}; 179 | RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; 180 | 181 | /** Configure the main internal regulator output voltage 182 | */ 183 | HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1); 184 | 185 | /** Configure LSE Drive Capability 186 | */ 187 | HAL_PWR_EnableBkUpAccess(); 188 | __HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_LOW); 189 | 190 | /** Initializes the RCC Oscillators according to the specified parameters 191 | * in the RCC_OscInitTypeDef structure. 192 | */ 193 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_LSE; 194 | RCC_OscInitStruct.LSEState = RCC_LSE_ON; 195 | RCC_OscInitStruct.HSIState = RCC_HSI_ON; 196 | RCC_OscInitStruct.HSIDiv = RCC_HSI_DIV1; 197 | RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; 198 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; 199 | RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI; 200 | RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV1; 201 | RCC_OscInitStruct.PLL.PLLN = 8; 202 | RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; 203 | RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2; 204 | if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) 205 | { 206 | Error_Handler(); 207 | } 208 | 209 | /** Initializes the CPU, AHB and APB buses clocks 210 | */ 211 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK 212 | |RCC_CLOCKTYPE_PCLK1; 213 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; 214 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; 215 | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; 216 | 217 | if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) 218 | { 219 | Error_Handler(); 220 | } 221 | } 222 | 223 | /* USER CODE BEGIN 4 */ 224 | 225 | /* USER CODE END 4 */ 226 | 227 | /** 228 | * @brief This function is executed in case of error occurrence. 229 | * @retval None 230 | */ 231 | void Error_Handler(void) 232 | { 233 | /* USER CODE BEGIN Error_Handler_Debug */ 234 | /* User can add his own implementation to report the HAL error return state */ 235 | __disable_irq(); 236 | while (1) 237 | { 238 | } 239 | /* USER CODE END Error_Handler_Debug */ 240 | } 241 | 242 | #ifdef USE_FULL_ASSERT 243 | /** 244 | * @brief Reports the name of the source file and the source line number 245 | * where the assert_param error has occurred. 246 | * @param file: pointer to the source file name 247 | * @param line: assert_param error line source number 248 | * @retval None 249 | */ 250 | void assert_failed(uint8_t *file, uint32_t line) 251 | { 252 | /* USER CODE BEGIN 6 */ 253 | /* User can add his own implementation to report the file name and line number, 254 | ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ 255 | /* USER CODE END 6 */ 256 | } 257 | #endif /* USE_FULL_ASSERT */ 258 | -------------------------------------------------------------------------------- /Examples/STM32G030/01-RTC/Core/Src/rtc.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file rtc.c 5 | * @brief This file provides code for the configuration 6 | * of the RTC instances. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2023 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | /* Includes ------------------------------------------------------------------*/ 21 | #include "rtc.h" 22 | 23 | /* USER CODE BEGIN 0 */ 24 | 25 | /* USER CODE END 0 */ 26 | 27 | RTC_HandleTypeDef hrtc; 28 | 29 | /* RTC init function */ 30 | void MX_RTC_Init(void) 31 | { 32 | 33 | /* USER CODE BEGIN RTC_Init 0 */ 34 | 35 | /* USER CODE END RTC_Init 0 */ 36 | 37 | RTC_TimeTypeDef sTime = {0}; 38 | RTC_DateTypeDef sDate = {0}; 39 | 40 | /* USER CODE BEGIN RTC_Init 1 */ 41 | 42 | /* USER CODE END RTC_Init 1 */ 43 | 44 | /** Initialize RTC Only 45 | */ 46 | hrtc.Instance = RTC; 47 | hrtc.Init.HourFormat = RTC_HOURFORMAT_24; 48 | hrtc.Init.AsynchPrediv = 127; 49 | hrtc.Init.SynchPrediv = 255; 50 | hrtc.Init.OutPut = RTC_OUTPUT_DISABLE; 51 | hrtc.Init.OutPutRemap = RTC_OUTPUT_REMAP_NONE; 52 | hrtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH; 53 | hrtc.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN; 54 | hrtc.Init.OutPutPullUp = RTC_OUTPUT_PULLUP_NONE; 55 | if (HAL_RTC_Init(&hrtc) != HAL_OK) 56 | { 57 | Error_Handler(); 58 | } 59 | 60 | /* USER CODE BEGIN Check_RTC_BKUP */ 61 | 62 | /* USER CODE END Check_RTC_BKUP */ 63 | 64 | /** Initialize RTC and set the Time and Date 65 | */ 66 | sTime.Hours = 0x0; 67 | sTime.Minutes = 0x0; 68 | sTime.Seconds = 0x0; 69 | sTime.SubSeconds = 0x0; 70 | sTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE; 71 | sTime.StoreOperation = RTC_STOREOPERATION_RESET; 72 | if (HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BCD) != HAL_OK) 73 | { 74 | Error_Handler(); 75 | } 76 | sDate.WeekDay = RTC_WEEKDAY_MONDAY; 77 | sDate.Month = RTC_MONTH_JANUARY; 78 | sDate.Date = 0x1; 79 | sDate.Year = 0x23; 80 | 81 | if (HAL_RTC_SetDate(&hrtc, &sDate, RTC_FORMAT_BCD) != HAL_OK) 82 | { 83 | Error_Handler(); 84 | } 85 | /* USER CODE BEGIN RTC_Init 2 */ 86 | 87 | /* USER CODE END RTC_Init 2 */ 88 | 89 | } 90 | 91 | void HAL_RTC_MspInit(RTC_HandleTypeDef* rtcHandle) 92 | { 93 | 94 | RCC_PeriphCLKInitTypeDef PeriphClkInit = {0}; 95 | if(rtcHandle->Instance==RTC) 96 | { 97 | /* USER CODE BEGIN RTC_MspInit 0 */ 98 | 99 | /* USER CODE END RTC_MspInit 0 */ 100 | 101 | /** Initializes the peripherals clocks 102 | */ 103 | PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_RTC; 104 | PeriphClkInit.RTCClockSelection = RCC_RTCCLKSOURCE_LSE; 105 | 106 | if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) 107 | { 108 | Error_Handler(); 109 | } 110 | 111 | /* RTC clock enable */ 112 | __HAL_RCC_RTC_ENABLE(); 113 | __HAL_RCC_RTCAPB_CLK_ENABLE(); 114 | /* USER CODE BEGIN RTC_MspInit 1 */ 115 | 116 | /* USER CODE END RTC_MspInit 1 */ 117 | } 118 | } 119 | 120 | void HAL_RTC_MspDeInit(RTC_HandleTypeDef* rtcHandle) 121 | { 122 | 123 | if(rtcHandle->Instance==RTC) 124 | { 125 | /* USER CODE BEGIN RTC_MspDeInit 0 */ 126 | 127 | /* USER CODE END RTC_MspDeInit 0 */ 128 | /* Peripheral clock disable */ 129 | __HAL_RCC_RTC_DISABLE(); 130 | __HAL_RCC_RTCAPB_CLK_DISABLE(); 131 | /* USER CODE BEGIN RTC_MspDeInit 1 */ 132 | 133 | /* USER CODE END RTC_MspDeInit 1 */ 134 | } 135 | } 136 | 137 | /* USER CODE BEGIN 1 */ 138 | 139 | /* USER CODE END 1 */ 140 | -------------------------------------------------------------------------------- /Examples/STM32G030/01-RTC/Core/Src/stm32g0xx_hal_msp.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32g0xx_hal_msp.c 5 | * @brief This file provides code for the MSP Initialization 6 | * and de-Initialization codes. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2023 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | #include "main.h" 23 | /* USER CODE BEGIN Includes */ 24 | 25 | /* USER CODE END Includes */ 26 | 27 | /* Private typedef -----------------------------------------------------------*/ 28 | /* USER CODE BEGIN TD */ 29 | 30 | /* USER CODE END TD */ 31 | 32 | /* Private define ------------------------------------------------------------*/ 33 | /* USER CODE BEGIN Define */ 34 | 35 | /* USER CODE END Define */ 36 | 37 | /* Private macro -------------------------------------------------------------*/ 38 | /* USER CODE BEGIN Macro */ 39 | 40 | /* USER CODE END Macro */ 41 | 42 | /* Private variables ---------------------------------------------------------*/ 43 | /* USER CODE BEGIN PV */ 44 | 45 | /* USER CODE END PV */ 46 | 47 | /* Private function prototypes -----------------------------------------------*/ 48 | /* USER CODE BEGIN PFP */ 49 | 50 | /* USER CODE END PFP */ 51 | 52 | /* External functions --------------------------------------------------------*/ 53 | /* USER CODE BEGIN ExternalFunctions */ 54 | 55 | /* USER CODE END ExternalFunctions */ 56 | 57 | /* USER CODE BEGIN 0 */ 58 | 59 | /* USER CODE END 0 */ 60 | /** 61 | * Initializes the Global MSP. 62 | */ 63 | void HAL_MspInit(void) 64 | { 65 | /* USER CODE BEGIN MspInit 0 */ 66 | 67 | /* USER CODE END MspInit 0 */ 68 | 69 | __HAL_RCC_SYSCFG_CLK_ENABLE(); 70 | __HAL_RCC_PWR_CLK_ENABLE(); 71 | 72 | /* System interrupt init*/ 73 | 74 | HAL_SYSCFG_EnableRemap(SYSCFG_REMAP_PA11); 75 | HAL_SYSCFG_EnableRemap(SYSCFG_REMAP_PA12); 76 | 77 | /* USER CODE BEGIN MspInit 1 */ 78 | 79 | /* USER CODE END MspInit 1 */ 80 | } 81 | 82 | /* USER CODE BEGIN 1 */ 83 | 84 | /* USER CODE END 1 */ 85 | -------------------------------------------------------------------------------- /Examples/STM32G030/01-RTC/Core/Src/stm32g0xx_it.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32g0xx_it.c 5 | * @brief Interrupt Service Routines. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2023 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | /* USER CODE END Header */ 19 | 20 | /* Includes ------------------------------------------------------------------*/ 21 | #include "main.h" 22 | #include "stm32g0xx_it.h" 23 | /* Private includes ----------------------------------------------------------*/ 24 | /* USER CODE BEGIN Includes */ 25 | /* USER CODE END Includes */ 26 | 27 | /* Private typedef -----------------------------------------------------------*/ 28 | /* USER CODE BEGIN TD */ 29 | 30 | /* USER CODE END TD */ 31 | 32 | /* Private define ------------------------------------------------------------*/ 33 | /* USER CODE BEGIN PD */ 34 | 35 | /* USER CODE END PD */ 36 | 37 | /* Private macro -------------------------------------------------------------*/ 38 | /* USER CODE BEGIN PM */ 39 | 40 | /* USER CODE END PM */ 41 | 42 | /* Private variables ---------------------------------------------------------*/ 43 | /* USER CODE BEGIN PV */ 44 | 45 | /* USER CODE END PV */ 46 | 47 | /* Private function prototypes -----------------------------------------------*/ 48 | /* USER CODE BEGIN PFP */ 49 | 50 | /* USER CODE END PFP */ 51 | 52 | /* Private user code ---------------------------------------------------------*/ 53 | /* USER CODE BEGIN 0 */ 54 | 55 | /* USER CODE END 0 */ 56 | 57 | /* External variables --------------------------------------------------------*/ 58 | 59 | /* USER CODE BEGIN EV */ 60 | 61 | /* USER CODE END EV */ 62 | 63 | /******************************************************************************/ 64 | /* Cortex-M0+ Processor Interruption and Exception Handlers */ 65 | /******************************************************************************/ 66 | /** 67 | * @brief This function handles Non maskable interrupt. 68 | */ 69 | void NMI_Handler(void) 70 | { 71 | /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ 72 | 73 | /* USER CODE END NonMaskableInt_IRQn 0 */ 74 | /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ 75 | while (1) 76 | { 77 | } 78 | /* USER CODE END NonMaskableInt_IRQn 1 */ 79 | } 80 | 81 | /** 82 | * @brief This function handles Hard fault interrupt. 83 | */ 84 | void HardFault_Handler(void) 85 | { 86 | /* USER CODE BEGIN HardFault_IRQn 0 */ 87 | 88 | /* USER CODE END HardFault_IRQn 0 */ 89 | while (1) 90 | { 91 | /* USER CODE BEGIN W1_HardFault_IRQn 0 */ 92 | /* USER CODE END W1_HardFault_IRQn 0 */ 93 | } 94 | } 95 | 96 | /** 97 | * @brief This function handles System service call via SWI instruction. 98 | */ 99 | void SVC_Handler(void) 100 | { 101 | /* USER CODE BEGIN SVC_IRQn 0 */ 102 | 103 | /* USER CODE END SVC_IRQn 0 */ 104 | /* USER CODE BEGIN SVC_IRQn 1 */ 105 | 106 | /* USER CODE END SVC_IRQn 1 */ 107 | } 108 | 109 | /** 110 | * @brief This function handles Pendable request for system service. 111 | */ 112 | void PendSV_Handler(void) 113 | { 114 | /* USER CODE BEGIN PendSV_IRQn 0 */ 115 | 116 | /* USER CODE END PendSV_IRQn 0 */ 117 | /* USER CODE BEGIN PendSV_IRQn 1 */ 118 | 119 | /* USER CODE END PendSV_IRQn 1 */ 120 | } 121 | 122 | /** 123 | * @brief This function handles System tick timer. 124 | */ 125 | void SysTick_Handler(void) 126 | { 127 | /* USER CODE BEGIN SysTick_IRQn 0 */ 128 | 129 | /* USER CODE END SysTick_IRQn 0 */ 130 | HAL_IncTick(); 131 | /* USER CODE BEGIN SysTick_IRQn 1 */ 132 | 133 | /* USER CODE END SysTick_IRQn 1 */ 134 | } 135 | 136 | /******************************************************************************/ 137 | /* STM32G0xx Peripheral Interrupt Handlers */ 138 | /* Add here the Interrupt Handlers for the used peripherals. */ 139 | /* For the available peripheral interrupt handler names, */ 140 | /* please refer to the startup file (startup_stm32g0xx.s). */ 141 | /******************************************************************************/ 142 | 143 | /* USER CODE BEGIN 1 */ 144 | 145 | /* USER CODE END 1 */ 146 | -------------------------------------------------------------------------------- /Examples/STM32G030/01-RTC/Core/Src/usart.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file usart.c 5 | * @brief This file provides code for the configuration 6 | * of the USART instances. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2023 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | /* Includes ------------------------------------------------------------------*/ 21 | #include "usart.h" 22 | 23 | /* USER CODE BEGIN 0 */ 24 | 25 | /* USER CODE END 0 */ 26 | 27 | UART_HandleTypeDef huart1; 28 | 29 | /* USART1 init function */ 30 | 31 | void MX_USART1_UART_Init(void) 32 | { 33 | 34 | /* USER CODE BEGIN USART1_Init 0 */ 35 | 36 | /* USER CODE END USART1_Init 0 */ 37 | 38 | /* USER CODE BEGIN USART1_Init 1 */ 39 | 40 | /* USER CODE END USART1_Init 1 */ 41 | huart1.Instance = USART1; 42 | huart1.Init.BaudRate = 115200; 43 | huart1.Init.WordLength = UART_WORDLENGTH_8B; 44 | huart1.Init.StopBits = UART_STOPBITS_1; 45 | huart1.Init.Parity = UART_PARITY_NONE; 46 | huart1.Init.Mode = UART_MODE_TX_RX; 47 | huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE; 48 | huart1.Init.OverSampling = UART_OVERSAMPLING_16; 49 | huart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE; 50 | huart1.Init.ClockPrescaler = UART_PRESCALER_DIV1; 51 | huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT; 52 | if (HAL_UART_Init(&huart1) != HAL_OK) 53 | { 54 | Error_Handler(); 55 | } 56 | if (HAL_UARTEx_SetTxFifoThreshold(&huart1, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK) 57 | { 58 | Error_Handler(); 59 | } 60 | if (HAL_UARTEx_SetRxFifoThreshold(&huart1, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK) 61 | { 62 | Error_Handler(); 63 | } 64 | if (HAL_UARTEx_DisableFifoMode(&huart1) != HAL_OK) 65 | { 66 | Error_Handler(); 67 | } 68 | /* USER CODE BEGIN USART1_Init 2 */ 69 | 70 | /* USER CODE END USART1_Init 2 */ 71 | 72 | } 73 | 74 | void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle) 75 | { 76 | 77 | GPIO_InitTypeDef GPIO_InitStruct = {0}; 78 | RCC_PeriphCLKInitTypeDef PeriphClkInit = {0}; 79 | if(uartHandle->Instance==USART1) 80 | { 81 | /* USER CODE BEGIN USART1_MspInit 0 */ 82 | 83 | /* USER CODE END USART1_MspInit 0 */ 84 | 85 | /** Initializes the peripherals clocks 86 | */ 87 | PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART1; 88 | PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_PCLK1; 89 | if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) 90 | { 91 | Error_Handler(); 92 | } 93 | 94 | /* USART1 clock enable */ 95 | __HAL_RCC_USART1_CLK_ENABLE(); 96 | 97 | __HAL_RCC_GPIOA_CLK_ENABLE(); 98 | /**USART1 GPIO Configuration 99 | PA9 [PA11] ------> USART1_TX 100 | PA10 [PA12] ------> USART1_RX 101 | */ 102 | GPIO_InitStruct.Pin = GPIO_PIN_9|GPIO_PIN_10; 103 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 104 | GPIO_InitStruct.Pull = GPIO_NOPULL; 105 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 106 | GPIO_InitStruct.Alternate = GPIO_AF1_USART1; 107 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 108 | 109 | /* USER CODE BEGIN USART1_MspInit 1 */ 110 | 111 | /* USER CODE END USART1_MspInit 1 */ 112 | } 113 | } 114 | 115 | void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle) 116 | { 117 | 118 | if(uartHandle->Instance==USART1) 119 | { 120 | /* USER CODE BEGIN USART1_MspDeInit 0 */ 121 | 122 | /* USER CODE END USART1_MspDeInit 0 */ 123 | /* Peripheral clock disable */ 124 | __HAL_RCC_USART1_CLK_DISABLE(); 125 | 126 | /**USART1 GPIO Configuration 127 | PA9 [PA11] ------> USART1_TX 128 | PA10 [PA12] ------> USART1_RX 129 | */ 130 | HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_10); 131 | 132 | /* USER CODE BEGIN USART1_MspDeInit 1 */ 133 | 134 | /* USER CODE END USART1_MspDeInit 1 */ 135 | } 136 | } 137 | 138 | /* USER CODE BEGIN 1 */ 139 | 140 | /* USER CODE END 1 */ 141 | -------------------------------------------------------------------------------- /Examples/STM32G030/01-RTC/Drivers/CMSIS/Device/ST/STM32G0xx/Include/system_stm32g0xx.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32g0xx.h 4 | * @author MCD Application Team 5 | * @brief CMSIS Cortex-M0+ Device System Source File for STM32G0xx devices. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2018-2021 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | /** @addtogroup CMSIS 19 | * @{ 20 | */ 21 | 22 | /** @addtogroup stm32g0xx_system 23 | * @{ 24 | */ 25 | 26 | /** 27 | * @brief Define to prevent recursive inclusion 28 | */ 29 | #ifndef SYSTEM_STM32G0XX_H 30 | #define SYSTEM_STM32G0XX_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /** @addtogroup STM32G0xx_System_Includes 37 | * @{ 38 | */ 39 | 40 | /** 41 | * @} 42 | */ 43 | 44 | 45 | /** @addtogroup STM32G0xx_System_Exported_types 46 | * @{ 47 | */ 48 | /* This variable is updated in three ways: 49 | 1) by calling CMSIS function SystemCoreClockUpdate() 50 | 2) by calling HAL API function HAL_RCC_GetSysClockFreq() 51 | 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency 52 | Note: If you use this function to configure the system clock; then there 53 | is no need to call the 2 first functions listed above, since SystemCoreClock 54 | variable is updated automatically. 55 | */ 56 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 57 | 58 | extern const uint32_t AHBPrescTable[16]; /*!< AHB prescalers table values */ 59 | extern const uint32_t APBPrescTable[8]; /*!< APB prescalers table values */ 60 | 61 | /** 62 | * @} 63 | */ 64 | 65 | /** @addtogroup STM32G0xx_System_Exported_Constants 66 | * @{ 67 | */ 68 | 69 | /** 70 | * @} 71 | */ 72 | 73 | /** @addtogroup STM32G0xx_System_Exported_Macros 74 | * @{ 75 | */ 76 | 77 | /** 78 | * @} 79 | */ 80 | 81 | /** @addtogroup STM32G0xx_System_Exported_Functions 82 | * @{ 83 | */ 84 | 85 | extern void SystemInit(void); 86 | extern void SystemCoreClockUpdate(void); 87 | /** 88 | * @} 89 | */ 90 | 91 | #ifdef __cplusplus 92 | } 93 | #endif 94 | 95 | #endif /*SYSTEM_STM32G0XX_H */ 96 | 97 | /** 98 | * @} 99 | */ 100 | 101 | /** 102 | * @} 103 | */ 104 | -------------------------------------------------------------------------------- /Examples/STM32G030/01-RTC/Drivers/CMSIS/Device/ST/STM32G0xx/LICENSE.txt: -------------------------------------------------------------------------------- 1 | This software component is provided to you as part of a software package and 2 | applicable license terms are in the Package_license file. If you received this 3 | software component outside of a package or without applicable license terms, 4 | the terms of the Apache-2.0 license shall apply. 5 | You may obtain a copy of the Apache-2.0 at: 6 | https://opensource.org/licenses/Apache-2.0 7 | -------------------------------------------------------------------------------- /Examples/STM32G030/01-RTC/Drivers/CMSIS/Include/cmsis_version.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file cmsis_version.h 3 | * @brief CMSIS Core(M) Version definitions 4 | * @version V5.0.3 5 | * @date 24. June 2019 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2009-2019 ARM Limited. All rights reserved. 9 | * 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the License); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | #if defined ( __ICCARM__ ) 26 | #pragma system_include /* treat file as system include file for MISRA check */ 27 | #elif defined (__clang__) 28 | #pragma clang system_header /* treat file as system include file */ 29 | #endif 30 | 31 | #ifndef __CMSIS_VERSION_H 32 | #define __CMSIS_VERSION_H 33 | 34 | /* CMSIS Version definitions */ 35 | #define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */ 36 | #define __CM_CMSIS_VERSION_SUB ( 3U) /*!< [15:0] CMSIS Core(M) sub version */ 37 | #define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \ 38 | __CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */ 39 | #endif 40 | -------------------------------------------------------------------------------- /Examples/STM32G030/01-RTC/Drivers/CMSIS/Include/tz_context.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * @file tz_context.h 3 | * @brief Context Management for Armv8-M TrustZone 4 | * @version V1.0.1 5 | * @date 10. January 2018 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2017-2018 Arm Limited. All rights reserved. 9 | * 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the License); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | #if defined ( __ICCARM__ ) 26 | #pragma system_include /* treat file as system include file for MISRA check */ 27 | #elif defined (__clang__) 28 | #pragma clang system_header /* treat file as system include file */ 29 | #endif 30 | 31 | #ifndef TZ_CONTEXT_H 32 | #define TZ_CONTEXT_H 33 | 34 | #include 35 | 36 | #ifndef TZ_MODULEID_T 37 | #define TZ_MODULEID_T 38 | /// \details Data type that identifies secure software modules called by a process. 39 | typedef uint32_t TZ_ModuleId_t; 40 | #endif 41 | 42 | /// \details TZ Memory ID identifies an allocated memory slot. 43 | typedef uint32_t TZ_MemoryId_t; 44 | 45 | /// Initialize secure context memory system 46 | /// \return execution status (1: success, 0: error) 47 | uint32_t TZ_InitContextSystem_S (void); 48 | 49 | /// Allocate context memory for calling secure software modules in TrustZone 50 | /// \param[in] module identifies software modules called from non-secure mode 51 | /// \return value != 0 id TrustZone memory slot identifier 52 | /// \return value 0 no memory available or internal error 53 | TZ_MemoryId_t TZ_AllocModuleContext_S (TZ_ModuleId_t module); 54 | 55 | /// Free context memory that was previously allocated with \ref TZ_AllocModuleContext_S 56 | /// \param[in] id TrustZone memory slot identifier 57 | /// \return execution status (1: success, 0: error) 58 | uint32_t TZ_FreeModuleContext_S (TZ_MemoryId_t id); 59 | 60 | /// Load secure context (called on RTOS thread context switch) 61 | /// \param[in] id TrustZone memory slot identifier 62 | /// \return execution status (1: success, 0: error) 63 | uint32_t TZ_LoadContext_S (TZ_MemoryId_t id); 64 | 65 | /// Store secure context (called on RTOS thread context switch) 66 | /// \param[in] id TrustZone memory slot identifier 67 | /// \return execution status (1: success, 0: error) 68 | uint32_t TZ_StoreContext_S (TZ_MemoryId_t id); 69 | 70 | #endif // TZ_CONTEXT_H 71 | -------------------------------------------------------------------------------- /Examples/STM32G030/01-RTC/Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_def.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32g0xx_hal_def.h 4 | * @author MCD Application Team 5 | * @brief This file contains HAL common defines, enumeration, macros and 6 | * structures definitions. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2018 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef STM32G0xx_HAL_DEF 22 | #define STM32G0xx_HAL_DEF 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "stm32g0xx.h" 30 | #include "Legacy/stm32_hal_legacy.h" /* Aliases file for old names compatibility */ 31 | #include 32 | 33 | /* Exported types ------------------------------------------------------------*/ 34 | 35 | /** 36 | * @brief HAL Status structures definition 37 | */ 38 | typedef enum 39 | { 40 | HAL_OK = 0x00U, 41 | HAL_ERROR = 0x01U, 42 | HAL_BUSY = 0x02U, 43 | HAL_TIMEOUT = 0x03U 44 | } HAL_StatusTypeDef; 45 | 46 | /** 47 | * @brief HAL Lock structures definition 48 | */ 49 | typedef enum 50 | { 51 | HAL_UNLOCKED = 0x00U, 52 | HAL_LOCKED = 0x01U 53 | } HAL_LockTypeDef; 54 | 55 | /* Exported macros -----------------------------------------------------------*/ 56 | 57 | #define UNUSED(X) (void)X /* To avoid gcc/g++ warnings */ 58 | 59 | #define HAL_MAX_DELAY 0xFFFFFFFFU 60 | 61 | #define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) == (BIT)) 62 | #define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == 0U) 63 | 64 | #define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__) \ 65 | do{ \ 66 | (__HANDLE__)->__PPP_DMA_FIELD__ = &(__DMA_HANDLE__); \ 67 | (__DMA_HANDLE__).Parent = (__HANDLE__); \ 68 | } while(0U) 69 | 70 | /** @brief Reset the Handles State field. 71 | * @param __HANDLE__ specifies the Peripheral Handle. 72 | * @note This macro can be used for the following purpose: 73 | * - When the Handle is declared as local variable; before passing it as parameter 74 | * to HAL_PPP_Init() for the first time, it is mandatory to use this macro 75 | * to set to 0 the Handles "State" field. 76 | * Otherwise, "State" field may have any random value and the first time the function 77 | * HAL_PPP_Init() is called, the low level hardware initialization will be missed 78 | * (i.e. HAL_PPP_MspInit() will not be executed). 79 | * - When there is a need to reconfigure the low level hardware: instead of calling 80 | * HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init(). 81 | * In this later function, when the Handles "State" field is set to 0, it will execute the function 82 | * HAL_PPP_MspInit() which will reconfigure the low level hardware. 83 | * @retval None 84 | */ 85 | #define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0U) 86 | 87 | #if (USE_RTOS == 1U) 88 | /* Reserved for future use */ 89 | #error " USE_RTOS should be 0 in the current HAL release " 90 | #else 91 | #define __HAL_LOCK(__HANDLE__) \ 92 | do{ \ 93 | if((__HANDLE__)->Lock == HAL_LOCKED) \ 94 | { \ 95 | return HAL_BUSY; \ 96 | } \ 97 | else \ 98 | { \ 99 | (__HANDLE__)->Lock = HAL_LOCKED; \ 100 | } \ 101 | }while (0U) 102 | 103 | #define __HAL_UNLOCK(__HANDLE__) \ 104 | do{ \ 105 | (__HANDLE__)->Lock = HAL_UNLOCKED; \ 106 | }while (0U) 107 | #endif /* USE_RTOS */ 108 | 109 | #if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 110 | #ifndef __weak 111 | #define __weak __attribute__((weak)) 112 | #endif /* __weak */ 113 | #ifndef __packed 114 | #define __packed __attribute__((packed)) 115 | #endif /* __packed */ 116 | #elif defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */ 117 | #ifndef __weak 118 | #define __weak __attribute__((weak)) 119 | #endif /* __weak */ 120 | #ifndef __packed 121 | #define __packed __attribute__((__packed__)) 122 | #endif /* __packed */ 123 | #endif /* __GNUC__ */ 124 | 125 | 126 | /* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */ 127 | /* GNU Compiler */ 128 | #if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) /* ARM Compiler V6 */ 129 | #ifndef __ALIGN_BEGIN 130 | #define __ALIGN_BEGIN 131 | #endif /* __ALIGN_BEGIN */ 132 | #ifndef __ALIGN_END 133 | #define __ALIGN_END __attribute__ ((aligned (4))) 134 | #endif /* __ALIGN_END */ 135 | #elif defined (__GNUC__) && !defined (__CC_ARM) /* GNU Compiler */ 136 | #ifndef __ALIGN_END 137 | #define __ALIGN_END __attribute__ ((aligned (4U))) 138 | #endif /* __ALIGN_END */ 139 | #ifndef __ALIGN_BEGIN 140 | #define __ALIGN_BEGIN 141 | #endif /* __ALIGN_BEGIN */ 142 | #else 143 | #ifndef __ALIGN_END 144 | #define __ALIGN_END 145 | #endif /* __ALIGN_END */ 146 | #ifndef __ALIGN_BEGIN 147 | /* ARM Compiler */ 148 | #if defined (__CC_ARM) /* ARM Compiler V5 */ 149 | #define __ALIGN_BEGIN __align(4U) 150 | /* IAR Compiler */ 151 | #elif defined (__ICCARM__) 152 | #define __ALIGN_BEGIN 153 | #endif /* __CC_ARM */ 154 | #endif /* __ALIGN_BEGIN */ 155 | #endif /* __GNUC__ */ 156 | 157 | /** 158 | * @brief __RAM_FUNC definition 159 | */ 160 | #if defined ( __CC_ARM ) || (defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) 161 | /* ARM Compiler V4/V5 and V6 162 | -------------------------- 163 | RAM functions are defined using the toolchain options. 164 | Functions that are executed in RAM should reside in a separate source module. 165 | Using the 'Options for File' dialog you can simply change the 'Code / Const' 166 | area of a module to a memory space in physical RAM. 167 | Available memory areas are declared in the 'Target' tab of the 'Options for Target' 168 | dialog. 169 | */ 170 | #define __RAM_FUNC 171 | 172 | #elif defined ( __ICCARM__ ) 173 | /* ICCARM Compiler 174 | --------------- 175 | RAM functions are defined using a specific toolchain keyword "__ramfunc". 176 | */ 177 | #define __RAM_FUNC __ramfunc 178 | 179 | #elif defined ( __GNUC__ ) 180 | /* GNU Compiler 181 | ------------ 182 | RAM functions are defined using a specific toolchain attribute 183 | "__attribute__((section(".RamFunc")))". 184 | */ 185 | #define __RAM_FUNC __attribute__((section(".RamFunc"))) 186 | 187 | #endif /* __CC_ARM || __ARMCC_VERSION */ 188 | 189 | /** 190 | * @brief __NOINLINE definition 191 | */ 192 | #if defined ( __CC_ARM ) || (defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) || defined ( __GNUC__ ) 193 | /* ARM V4/V5 and V6 & GNU Compiler 194 | ------------------------------- 195 | */ 196 | #define __NOINLINE __attribute__ ( (noinline) ) 197 | 198 | #elif defined ( __ICCARM__ ) 199 | /* ICCARM Compiler 200 | --------------- 201 | */ 202 | #define __NOINLINE _Pragma("optimize = no_inline") 203 | 204 | #endif /* __CC_ARM || __ARMCC_VERSION */ 205 | 206 | 207 | #ifdef __cplusplus 208 | } 209 | #endif 210 | 211 | #endif /* STM32G0xx_HAL_DEF */ 212 | 213 | 214 | -------------------------------------------------------------------------------- /Examples/STM32G030/01-RTC/Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_flash_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32g0xx_hal_flash_ex.h 4 | * @author MCD Application Team 5 | * @brief Header file of FLASH HAL Extended module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2018 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file in 13 | * the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | ****************************************************************************** 16 | */ 17 | 18 | /* Define to prevent recursive inclusion -------------------------------------*/ 19 | #ifndef STM32G0xx_HAL_FLASH_EX_H 20 | #define STM32G0xx_HAL_FLASH_EX_H 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | /* Includes ------------------------------------------------------------------*/ 27 | #include "stm32g0xx_hal_def.h" 28 | 29 | /** @addtogroup STM32G0xx_HAL_Driver 30 | * @{ 31 | */ 32 | 33 | /** @addtogroup FLASHEx 34 | * @{ 35 | */ 36 | 37 | /* Exported types ------------------------------------------------------------*/ 38 | /* Exported constants --------------------------------------------------------*/ 39 | /** @defgroup FLASHEx_Exported_Constants FLASH Exported Constants 40 | * @{ 41 | */ 42 | /** @defgroup FLASHEx_Empty_Check FLASHEx Empty Check 43 | * @{ 44 | */ 45 | #define FLASH_PROG_NOT_EMPTY 0x00000000u /*!< 1st location in Flash is programmed */ 46 | #define FLASH_PROG_EMPTY FLASH_ACR_PROGEMPTY /*!< 1st location in Flash is empty */ 47 | /** 48 | * @} 49 | */ 50 | /** 51 | * @} 52 | */ 53 | 54 | /* Exported macro ------------------------------------------------------------*/ 55 | /* Exported functions --------------------------------------------------------*/ 56 | /** @addtogroup FLASHEx_Exported_Functions 57 | * @{ 58 | */ 59 | 60 | /* Extended Program operation functions *************************************/ 61 | /** @addtogroup FLASHEx_Exported_Functions_Group1 62 | * @{ 63 | */ 64 | HAL_StatusTypeDef HAL_FLASHEx_Erase(FLASH_EraseInitTypeDef *pEraseInit, uint32_t *PageError); 65 | HAL_StatusTypeDef HAL_FLASHEx_Erase_IT(FLASH_EraseInitTypeDef *pEraseInit); 66 | void HAL_FLASHEx_EnableDebugger(void); 67 | void HAL_FLASHEx_DisableDebugger(void); 68 | uint32_t HAL_FLASHEx_FlashEmptyCheck(void); 69 | void HAL_FLASHEx_ForceFlashEmpty(uint32_t FlashEmpty); 70 | #if defined(FLASH_SECURABLE_MEMORY_SUPPORT) 71 | void HAL_FLASHEx_EnableSecMemProtection(uint32_t Banks); 72 | #endif /* FLASH_SECURABLE_MEMORY_SUPPORT */ 73 | HAL_StatusTypeDef HAL_FLASHEx_OBProgram(FLASH_OBProgramInitTypeDef *pOBInit); 74 | void HAL_FLASHEx_OBGetConfig(FLASH_OBProgramInitTypeDef *pOBInit); 75 | /** 76 | * @} 77 | */ 78 | 79 | /** 80 | * @} 81 | */ 82 | 83 | /* Private macros ------------------------------------------------------------*/ 84 | /** @defgroup FLASHEx_Private_Constants FLASHEx Private Constants 85 | * @{ 86 | */ 87 | #define FLASH_PCROP_GRANULARITY_OFFSET 9u /*!< FLASH Code Readout Protection granularity offset */ 88 | #define FLASH_PCROP_GRANULARITY (1UL << FLASH_PCROP_GRANULARITY_OFFSET) /*!< FLASH Code Readout Protection granularity, 512 Bytes */ 89 | /** 90 | * @} 91 | */ 92 | 93 | 94 | /** @defgroup FLASHEx_Private_Macros FLASHEx Private Macros 95 | * @{ 96 | */ 97 | #define IS_FLASH_EMPTY_CHECK(__VALUE__) (((__VALUE__) == FLASH_PROG_EMPTY) || ((__VALUE__) == FLASH_PROG_NOT_EMPTY)) 98 | void FLASH_PageErase(uint32_t Banks, uint32_t Page); 99 | /** 100 | * @} 101 | */ 102 | 103 | /** 104 | * @} 105 | */ 106 | 107 | /** 108 | * @} 109 | */ 110 | 111 | #ifdef __cplusplus 112 | } 113 | #endif 114 | 115 | #endif /* STM32G0xx_HAL_FLASH_EX_H */ 116 | 117 | -------------------------------------------------------------------------------- /Examples/STM32G030/01-RTC/Drivers/STM32G0xx_HAL_Driver/LICENSE.txt: -------------------------------------------------------------------------------- 1 | This software component is provided to you as part of a software package and 2 | applicable license terms are in the Package_license file. If you received this 3 | software component outside of a package or without applicable license terms, 4 | the terms of the BSD-3-Clause license shall apply. 5 | You may obtain a copy of the BSD-3-Clause at: 6 | https://opensource.org/licenses/BSD-3-Clause 7 | -------------------------------------------------------------------------------- /Examples/STM32G030/01-RTC/MDK-ARM/01-RTC/01-RTC.axf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeActStudio/WeActStudio.STM32G0xxC0xxCoreBoard/f692e4e2e853ae9610aa337e2222c6d6d73416d8/Examples/STM32G030/01-RTC/MDK-ARM/01-RTC/01-RTC.axf -------------------------------------------------------------------------------- /Examples/STM32G030/01-RTC/MDK-ARM/DebugConfig/01-RTC_STM32G030F6Px_1.0.0.dbgconf: -------------------------------------------------------------------------------- 1 | // File: STM32G0x0.dbgconf 2 | // Version: 1.0.0 3 | // Note: refer to STM32G0x0 reference manual (RM0454) 4 | 5 | // <<< Use Configuration Wizard in Context Menu >>> 6 | 7 | // Debug MCU configuration register (DBGMCU_CR) 8 | // Reserved bits must be kept at reset value 9 | // DBG_STANDBY Debug Standby Mode 10 | // DBG_STOP Debug Stop Mode 11 | // 12 | DbgMCU_CR = 0x00000006; 13 | 14 | // Debug MCU APB freeze register 1 (DBGMCU_APB_FZ1) 15 | // Reserved bits must be kept at reset value 16 | // DBG_I2C1_SMBUS_TIMEOUT I2C1 SMBUS timeout is frozen 17 | // DBG_IWDG_STOP Debug independent watchdog stopped when core is halted 18 | // DBG_WWDG_STOP Debug window watchdog stopped when core is halted 19 | // DBG_RTC_STOP Debug RTC stopped when core is halted 20 | // DBG_TIM7_STOP TIM7 counter stopped when core is halted 21 | // DBG_TIM6_STOP TIM6 counter stopped when core is halted 22 | // DBG_TIM3_STOP TIM3 counter stopped when core is halted 23 | // 24 | DbgMCU_APB_Fz1 = 0x00000000; 25 | 26 | // Debug MCU APB freeze register 2 (DBGMCU_APB_FZ2) 27 | // Reserved bits must be kept at reset value 28 | // DBG_TIM17_STOP TIM17 counter stopped when core is halted 29 | // DBG_TIM16_STOP TIM16 counter stopped when core is halted 30 | // DBG_TIM15_STOP TIM15 counter stopped when core is halted 31 | // DBG_TIM1_STOP TIM1 counter stopped when core is halted 32 | // 33 | DbgMCU_APB_Fz2 = 0x00000000; 34 | 35 | // <<< end of configuration section >>> 36 | -------------------------------------------------------------------------------- /Examples/STM32G030/01-RTC/MDK-ARM/EventRecorderStub.scvd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Examples/STM32G030/01-RTC/MDK-ARM/RTE/_01-RTC/RTE_Components.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Auto generated Run-Time-Environment Configuration File 4 | * *** Do not modify ! *** 5 | * 6 | * Project: '01-RTC' 7 | * Target: '01-RTC' 8 | */ 9 | 10 | #ifndef RTE_COMPONENTS_H 11 | #define RTE_COMPONENTS_H 12 | 13 | 14 | /* 15 | * Define the Device Header File: 16 | */ 17 | #define CMSIS_device_header "stm32g0xx.h" 18 | 19 | 20 | 21 | #endif /* RTE_COMPONENTS_H */ 22 | -------------------------------------------------------------------------------- /Examples/STM32G031/01-RTC/01-RTC.ioc: -------------------------------------------------------------------------------- 1 | #MicroXplorer Configuration settings - do not modify 2 | CAD.formats= 3 | CAD.pinconfig= 4 | CAD.provider= 5 | File.Version=6 6 | GPIO.groupedBy= 7 | KeepUserPlacement=false 8 | Mcu.CPN=STM32G031F8P6 9 | Mcu.Family=STM32G0 10 | Mcu.IP0=NVIC 11 | Mcu.IP1=RCC 12 | Mcu.IP2=RTC 13 | Mcu.IP3=SYS 14 | Mcu.IP4=USART1 15 | Mcu.IPNb=5 16 | Mcu.Name=STM32G031F(4-6-8)Px 17 | Mcu.Package=TSSOP20 18 | Mcu.Pin0=PC14-OSC32_IN (PC14) 19 | Mcu.Pin1=PC15-OSC32_OUT (PC15) 20 | Mcu.Pin10=VP_SYS_VS_Systick 21 | Mcu.Pin2=PA9 [PA11] 22 | Mcu.Pin3=PA10 [PA12] 23 | Mcu.Pin4=PA13 24 | Mcu.Pin5=PA14-BOOT0 25 | Mcu.Pin6=VP_RTC_VS_RTC_Activate 26 | Mcu.Pin7=VP_RTC_VS_RTC_Calendar 27 | Mcu.Pin8=VP_SYS_VS_PINREMAP 28 | Mcu.Pin9=VP_SYS_VS_PINREMAP_10_12 29 | Mcu.PinsNb=11 30 | Mcu.ThirdPartyNb=0 31 | Mcu.UserConstants= 32 | Mcu.UserName=STM32G031F8Px 33 | MxCube.Version=6.7.0 34 | MxDb.Version=DB.6.0.70 35 | NVIC.ForceEnableDMAVector=true 36 | NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false 37 | NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false 38 | NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false 39 | NVIC.SVC_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:true 40 | NVIC.SysTick_IRQn=true\:3\:0\:false\:false\:true\:false\:true\:false 41 | PA10\ [PA12].Locked=true 42 | PA10\ [PA12].Mode=Asynchronous 43 | PA10\ [PA12].Signal=USART1_RX 44 | PA13.Mode=Serial_Wire 45 | PA13.Signal=SYS_SWDIO 46 | PA14-BOOT0.Mode=Serial_Wire 47 | PA14-BOOT0.Signal=SYS_SWCLK 48 | PA14-BOOT0__PA15.StandardMode=true 49 | PA9\ [PA11].Mode=Asynchronous 50 | PA9\ [PA11].Signal=USART1_TX 51 | PB0__PB1__PB2__PA8.StandardMode=true 52 | PB3__PB4__PB5__PB6.StandardMode=true 53 | PB7__PB8.StandardMode=true 54 | PC14-OSC32_IN\ (PC14).Mode=LSE-External-Oscillator 55 | PC14-OSC32_IN\ (PC14).Signal=RCC_OSC32_IN 56 | PC14-OSC32_IN\ (PC14)__PB9.StandardMode=true 57 | PC15-OSC32_OUT\ (PC15).Mode=LSE-External-Oscillator 58 | PC15-OSC32_OUT\ (PC15).Signal=RCC_OSC32_OUT 59 | PinOutPanel.RotationAngle=0 60 | ProjectManager.AskForMigrate=true 61 | ProjectManager.BackupPrevious=false 62 | ProjectManager.CompilerOptimize=6 63 | ProjectManager.ComputerToolchain=false 64 | ProjectManager.CoupleFile=true 65 | ProjectManager.CustomerFirmwarePackage= 66 | ProjectManager.DefaultFWLocation=true 67 | ProjectManager.DeletePrevious=true 68 | ProjectManager.DeviceId=STM32G031F8Px 69 | ProjectManager.FirmwarePackage=STM32Cube FW_G0 V1.6.1 70 | ProjectManager.FreePins=false 71 | ProjectManager.HalAssertFull=false 72 | ProjectManager.HeapSize=0x200 73 | ProjectManager.KeepUserCode=true 74 | ProjectManager.LastFirmware=true 75 | ProjectManager.LibraryCopy=1 76 | ProjectManager.MainLocation=Core/Src 77 | ProjectManager.NoMain=false 78 | ProjectManager.PreviousToolchain= 79 | ProjectManager.ProjectBuild=false 80 | ProjectManager.ProjectFileName=01-RTC.ioc 81 | ProjectManager.ProjectName=01-RTC 82 | ProjectManager.RegisterCallBack= 83 | ProjectManager.StackSize=0x400 84 | ProjectManager.TargetToolchain=MDK-ARM V5.32 85 | ProjectManager.ToolChainLocation= 86 | ProjectManager.UnderRoot=false 87 | ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_RTC_Init-RTC-false-HAL-true,4-MX_USART1_UART_Init-USART1-false-HAL-true 88 | RCC.ADCFreq_Value=64000000 89 | RCC.AHBFreq_Value=64000000 90 | RCC.APBFreq_Value=64000000 91 | RCC.APBTimFreq_Value=64000000 92 | RCC.CortexFreq_Value=64000000 93 | RCC.EXTERNAL_CLOCK_VALUE=12288000 94 | RCC.FCLKCortexFreq_Value=64000000 95 | RCC.FamilyName=M 96 | RCC.HCLKFreq_Value=64000000 97 | RCC.HSE_VALUE=8000000 98 | RCC.HSI_VALUE=16000000 99 | RCC.I2C1Freq_Value=64000000 100 | RCC.I2S1Freq_Value=64000000 101 | RCC.IPParameters=ADCFreq_Value,AHBFreq_Value,APBFreq_Value,APBTimFreq_Value,CortexFreq_Value,EXTERNAL_CLOCK_VALUE,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,HSI_VALUE,I2C1Freq_Value,I2S1Freq_Value,LPTIM1Freq_Value,LPTIM2Freq_Value,LPUART1Freq_Value,LSCOPinFreq_Value,LSI_VALUE,MCO1PinFreq_Value,PLLPoutputFreq_Value,PLLQoutputFreq_Value,PLLRCLKFreq_Value,PWRFreq_Value,RTCClockSelection,RTCFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,TIM1Freq_Value,USART1Freq_Value,VCOInputFreq_Value,VCOOutputFreq_Value 102 | RCC.LPTIM1Freq_Value=64000000 103 | RCC.LPTIM2Freq_Value=64000000 104 | RCC.LPUART1Freq_Value=64000000 105 | RCC.LSCOPinFreq_Value=32000 106 | RCC.LSI_VALUE=32000 107 | RCC.MCO1PinFreq_Value=64000000 108 | RCC.PLLPoutputFreq_Value=64000000 109 | RCC.PLLQoutputFreq_Value=64000000 110 | RCC.PLLRCLKFreq_Value=64000000 111 | RCC.PWRFreq_Value=64000000 112 | RCC.RTCClockSelection=RCC_RTCCLKSOURCE_LSE 113 | RCC.RTCFreq_Value=32768 114 | RCC.SYSCLKFreq_VALUE=64000000 115 | RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK 116 | RCC.TIM1Freq_Value=64000000 117 | RCC.USART1Freq_Value=64000000 118 | RCC.VCOInputFreq_Value=16000000 119 | RCC.VCOOutputFreq_Value=128000000 120 | RTC.Format=RTC_FORMAT_BIN 121 | RTC.IPParameters=Year,Format 122 | RTC.Year=23 123 | USART1.IPParameters=VirtualMode-Asynchronous 124 | USART1.VirtualMode-Asynchronous=VM_ASYNC 125 | VP_RTC_VS_RTC_Activate.Mode=RTC_Enabled 126 | VP_RTC_VS_RTC_Activate.Signal=RTC_VS_RTC_Activate 127 | VP_RTC_VS_RTC_Calendar.Mode=RTC_Calendar 128 | VP_RTC_VS_RTC_Calendar.Signal=RTC_VS_RTC_Calendar 129 | VP_SYS_VS_PINREMAP.Mode=PINREMAP 130 | VP_SYS_VS_PINREMAP.Signal=SYS_VS_PINREMAP 131 | VP_SYS_VS_PINREMAP_10_12.Mode=PINREMAP_10_12 132 | VP_SYS_VS_PINREMAP_10_12.Signal=SYS_VS_PINREMAP_10_12 133 | VP_SYS_VS_Systick.Mode=SysTick 134 | VP_SYS_VS_Systick.Signal=SYS_VS_Systick 135 | board=custom 136 | -------------------------------------------------------------------------------- /Examples/STM32G031/01-RTC/Bsp/board.c: -------------------------------------------------------------------------------- 1 | /*--------------------------------------- 2 | - WeAct Studio Official Link 3 | - taobao: weactstudio.taobao.com 4 | - aliexpress: weactstudio.aliexpress.com 5 | - github: github.com/WeActTC 6 | - gitee: gitee.com/WeAct-TC 7 | - blog: www.weact-tc.cn 8 | ---------------------------------------*/ 9 | 10 | #include "board.h" 11 | 12 | void board_button_init(void) 13 | { 14 | GPIO_InitTypeDef GPIO_InitStruct = {0}; 15 | 16 | /* GPIO Ports Clock Enable */ 17 | __HAL_RCC_GPIOA_CLK_ENABLE(); 18 | 19 | /*Configure GPIO pin : PtPin */ 20 | GPIO_InitStruct.Pin = KEY_Pin; 21 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT; 22 | GPIO_InitStruct.Pull = GPIO_PULLDOWN; 23 | HAL_GPIO_Init(KEY_GPIO_Port, &GPIO_InitStruct); 24 | } 25 | 26 | uint8_t board_button_getstate(void) 27 | { 28 | return HAL_GPIO_ReadPin(KEY_GPIO_Port,KEY_Pin)==GPIO_PIN_SET?1:0; 29 | } 30 | 31 | void board_led_init(void) 32 | { 33 | GPIO_InitTypeDef GPIO_InitStruct = {0}; 34 | 35 | /* GPIO Ports Clock Enable */ 36 | __HAL_RCC_GPIOA_CLK_ENABLE(); 37 | 38 | /*Configure GPIO pin Output Level */ 39 | HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_SET); 40 | 41 | /*Configure GPIO pin : PtPin */ 42 | GPIO_InitStruct.Pin = LED_Pin; 43 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 44 | GPIO_InitStruct.Pull = GPIO_NOPULL; 45 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 46 | HAL_GPIO_Init(LED_GPIO_Port, &GPIO_InitStruct); 47 | } 48 | 49 | void board_led_toggle(void) 50 | { 51 | HAL_GPIO_TogglePin(LED_GPIO_Port,LED_Pin); 52 | } 53 | 54 | void board_led_set(uint8_t set) 55 | { 56 | if (set) 57 | HAL_GPIO_WritePin(LED_GPIO_Port,LED_Pin,GPIO_PIN_SET); 58 | else 59 | HAL_GPIO_WritePin(LED_GPIO_Port,LED_Pin,GPIO_PIN_RESET); 60 | } 61 | -------------------------------------------------------------------------------- /Examples/STM32G031/01-RTC/Bsp/board.h: -------------------------------------------------------------------------------- 1 | #ifndef __BOARD_H 2 | #define __BOARD_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" 6 | { 7 | #endif 8 | 9 | #include "main.h" 10 | 11 | #ifndef KEY_Pin 12 | #define KEY_Pin GPIO_PIN_14 13 | #endif 14 | #ifndef KEY_GPIO_Port 15 | #define KEY_GPIO_Port GPIOA 16 | #endif 17 | #ifndef LED_Pin 18 | #define LED_Pin GPIO_PIN_4 19 | #endif 20 | #ifndef LED_GPIO_Port 21 | #define LED_GPIO_Port GPIOA 22 | #endif 23 | 24 | void board_button_init(void); 25 | uint8_t board_button_getstate(void); 26 | void board_led_init(void); 27 | void board_led_toggle(void); 28 | void board_led_set(uint8_t set); 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /Examples/STM32G031/01-RTC/Core/Inc/gpio.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file gpio.h 5 | * @brief This file contains all the function prototypes for 6 | * the gpio.c file 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2023 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __GPIO_H__ 22 | #define __GPIO_H__ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "main.h" 30 | 31 | /* USER CODE BEGIN Includes */ 32 | 33 | /* USER CODE END Includes */ 34 | 35 | /* USER CODE BEGIN Private defines */ 36 | 37 | /* USER CODE END Private defines */ 38 | 39 | void MX_GPIO_Init(void); 40 | 41 | /* USER CODE BEGIN Prototypes */ 42 | 43 | /* USER CODE END Prototypes */ 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | #endif /*__ GPIO_H__ */ 49 | 50 | -------------------------------------------------------------------------------- /Examples/STM32G031/01-RTC/Core/Inc/main.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : main.h 5 | * @brief : Header for main.c file. 6 | * This file contains the common defines of the application. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2023 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __MAIN_H 23 | #define __MAIN_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | #include "stm32g0xx_hal.h" 31 | 32 | /* Private includes ----------------------------------------------------------*/ 33 | /* USER CODE BEGIN Includes */ 34 | 35 | /* USER CODE END Includes */ 36 | 37 | /* Exported types ------------------------------------------------------------*/ 38 | /* USER CODE BEGIN ET */ 39 | 40 | /* USER CODE END ET */ 41 | 42 | /* Exported constants --------------------------------------------------------*/ 43 | /* USER CODE BEGIN EC */ 44 | 45 | /* USER CODE END EC */ 46 | 47 | /* Exported macro ------------------------------------------------------------*/ 48 | /* USER CODE BEGIN EM */ 49 | 50 | /* USER CODE END EM */ 51 | 52 | /* Exported functions prototypes ---------------------------------------------*/ 53 | void Error_Handler(void); 54 | 55 | /* USER CODE BEGIN EFP */ 56 | 57 | /* USER CODE END EFP */ 58 | 59 | /* Private defines -----------------------------------------------------------*/ 60 | 61 | /* USER CODE BEGIN Private defines */ 62 | 63 | /* USER CODE END Private defines */ 64 | 65 | #ifdef __cplusplus 66 | } 67 | #endif 68 | 69 | #endif /* __MAIN_H */ 70 | -------------------------------------------------------------------------------- /Examples/STM32G031/01-RTC/Core/Inc/rtc.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file rtc.h 5 | * @brief This file contains all the function prototypes for 6 | * the rtc.c file 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2023 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __RTC_H__ 22 | #define __RTC_H__ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "main.h" 30 | 31 | /* USER CODE BEGIN Includes */ 32 | 33 | /* USER CODE END Includes */ 34 | 35 | extern RTC_HandleTypeDef hrtc; 36 | 37 | /* USER CODE BEGIN Private defines */ 38 | 39 | /* USER CODE END Private defines */ 40 | 41 | void MX_RTC_Init(void); 42 | 43 | /* USER CODE BEGIN Prototypes */ 44 | 45 | /* USER CODE END Prototypes */ 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | 51 | #endif /* __RTC_H__ */ 52 | 53 | -------------------------------------------------------------------------------- /Examples/STM32G031/01-RTC/Core/Inc/stm32g0xx_it.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32g0xx_it.h 5 | * @brief This file contains the headers of the interrupt handlers. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2023 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | /* USER CODE END Header */ 19 | 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __STM32G0xx_IT_H 22 | #define __STM32G0xx_IT_H 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Private includes ----------------------------------------------------------*/ 29 | /* USER CODE BEGIN Includes */ 30 | 31 | /* USER CODE END Includes */ 32 | 33 | /* Exported types ------------------------------------------------------------*/ 34 | /* USER CODE BEGIN ET */ 35 | 36 | /* USER CODE END ET */ 37 | 38 | /* Exported constants --------------------------------------------------------*/ 39 | /* USER CODE BEGIN EC */ 40 | 41 | /* USER CODE END EC */ 42 | 43 | /* Exported macro ------------------------------------------------------------*/ 44 | /* USER CODE BEGIN EM */ 45 | 46 | /* USER CODE END EM */ 47 | 48 | /* Exported functions prototypes ---------------------------------------------*/ 49 | void NMI_Handler(void); 50 | void HardFault_Handler(void); 51 | void SVC_Handler(void); 52 | void PendSV_Handler(void); 53 | void SysTick_Handler(void); 54 | /* USER CODE BEGIN EFP */ 55 | 56 | /* USER CODE END EFP */ 57 | 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | 62 | #endif /* __STM32G0xx_IT_H */ 63 | -------------------------------------------------------------------------------- /Examples/STM32G031/01-RTC/Core/Inc/usart.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file usart.h 5 | * @brief This file contains all the function prototypes for 6 | * the usart.c file 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2023 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __USART_H__ 22 | #define __USART_H__ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "main.h" 30 | 31 | /* USER CODE BEGIN Includes */ 32 | 33 | /* USER CODE END Includes */ 34 | 35 | extern UART_HandleTypeDef huart1; 36 | 37 | /* USER CODE BEGIN Private defines */ 38 | 39 | /* USER CODE END Private defines */ 40 | 41 | void MX_USART1_UART_Init(void); 42 | 43 | /* USER CODE BEGIN Prototypes */ 44 | 45 | /* USER CODE END Prototypes */ 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | 51 | #endif /* __USART_H__ */ 52 | 53 | -------------------------------------------------------------------------------- /Examples/STM32G031/01-RTC/Core/Src/gpio.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file gpio.c 5 | * @brief This file provides code for the configuration 6 | * of all used GPIO pins. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2023 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | #include "gpio.h" 23 | 24 | /* USER CODE BEGIN 0 */ 25 | 26 | /* USER CODE END 0 */ 27 | 28 | /*----------------------------------------------------------------------------*/ 29 | /* Configure GPIO */ 30 | /*----------------------------------------------------------------------------*/ 31 | /* USER CODE BEGIN 1 */ 32 | 33 | /* USER CODE END 1 */ 34 | 35 | /** Configure pins as 36 | * Analog 37 | * Input 38 | * Output 39 | * EVENT_OUT 40 | * EXTI 41 | */ 42 | void MX_GPIO_Init(void) 43 | { 44 | 45 | /* GPIO Ports Clock Enable */ 46 | __HAL_RCC_GPIOC_CLK_ENABLE(); 47 | __HAL_RCC_GPIOA_CLK_ENABLE(); 48 | 49 | } 50 | 51 | /* USER CODE BEGIN 2 */ 52 | 53 | /* USER CODE END 2 */ 54 | -------------------------------------------------------------------------------- /Examples/STM32G031/01-RTC/Core/Src/main.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : main.c 5 | * @brief : Main program body 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2023 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | /* USER CODE END Header */ 19 | /* Includes ------------------------------------------------------------------*/ 20 | #include "main.h" 21 | #include "rtc.h" 22 | #include "usart.h" 23 | #include "gpio.h" 24 | 25 | /* Private includes ----------------------------------------------------------*/ 26 | /* USER CODE BEGIN Includes */ 27 | #include 28 | /* USER CODE END Includes */ 29 | 30 | /* Private typedef -----------------------------------------------------------*/ 31 | /* USER CODE BEGIN PTD */ 32 | 33 | /* USER CODE END PTD */ 34 | 35 | /* Private define ------------------------------------------------------------*/ 36 | /* USER CODE BEGIN PD */ 37 | #if defined (__ICCARM__) || defined (__ARMCC_VERSION) 38 | #define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f) 39 | #elif defined(__GNUC__) 40 | /* With GCC, small printf (option LD Linker->Libraries->Small printf 41 | set to 'Yes') calls __io_putchar() */ 42 | #define PUTCHAR_PROTOTYPE int __io_putchar(int ch) 43 | #endif /* __ICCARM__ || __ARMCC_VERSION */ 44 | /* USER CODE END PD */ 45 | 46 | /* Private macro -------------------------------------------------------------*/ 47 | /* USER CODE BEGIN PM */ 48 | 49 | /* USER CODE END PM */ 50 | 51 | /* Private variables ---------------------------------------------------------*/ 52 | 53 | /* USER CODE BEGIN PV */ 54 | 55 | /* USER CODE END PV */ 56 | 57 | /* Private function prototypes -----------------------------------------------*/ 58 | void SystemClock_Config(void); 59 | /* USER CODE BEGIN PFP */ 60 | 61 | /* USER CODE END PFP */ 62 | 63 | /* Private user code ---------------------------------------------------------*/ 64 | /* USER CODE BEGIN 0 */ 65 | /** 66 | * @brief Retargets the C library printf function to the USART. 67 | * @param None 68 | * @retval None 69 | */ 70 | PUTCHAR_PROTOTYPE 71 | { 72 | /* Place your implementation of fputc here */ 73 | /* e.g. write a character to the USART2 and Loop until the end of transmission */ 74 | HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, 0xFFFF); 75 | 76 | return ch; 77 | } 78 | /* USER CODE END 0 */ 79 | 80 | /** 81 | * @brief The application entry point. 82 | * @retval int 83 | */ 84 | int main(void) 85 | { 86 | /* USER CODE BEGIN 1 */ 87 | 88 | /* USER CODE END 1 */ 89 | 90 | /* MCU Configuration--------------------------------------------------------*/ 91 | 92 | /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ 93 | HAL_Init(); 94 | 95 | /* USER CODE BEGIN Init */ 96 | 97 | /* USER CODE END Init */ 98 | 99 | /* Configure the system clock */ 100 | SystemClock_Config(); 101 | 102 | /* USER CODE BEGIN SysInit */ 103 | 104 | /* USER CODE END SysInit */ 105 | 106 | /* Initialize all configured peripherals */ 107 | MX_GPIO_Init(); 108 | MX_RTC_Init(); 109 | MX_USART1_UART_Init(); 110 | /* USER CODE BEGIN 2 */ 111 | #include "board.h" 112 | 113 | // for swd debug 114 | //board_button_init(); 115 | 116 | board_led_init(); 117 | 118 | uint32_t tick,tick_now; 119 | tick = HAL_GetTick() + 200; 120 | tick_now = HAL_GetTick(); 121 | /* USER CODE END 2 */ 122 | 123 | /* Infinite loop */ 124 | /* USER CODE BEGIN WHILE */ 125 | while (1) 126 | { 127 | /* USER CODE END WHILE */ 128 | 129 | /* USER CODE BEGIN 3 */ 130 | tick_now = HAL_GetTick(); 131 | if(board_button_getstate()) 132 | { 133 | if(tick_now >= tick) 134 | { 135 | tick = tick_now + 200; 136 | board_led_toggle(); 137 | } 138 | } 139 | else 140 | { 141 | if(tick_now >= tick) 142 | { 143 | tick = tick_now + 50; 144 | 145 | RTC_DateTypeDef sdatestructureget; 146 | RTC_TimeTypeDef stimestructureget; 147 | uint8_t text[30]; 148 | static uint8_t Seconds_o; 149 | 150 | /* Get the RTC current Time */ 151 | HAL_RTC_GetTime(&hrtc, &stimestructureget, RTC_FORMAT_BIN); 152 | /* Get the RTC current Date */ 153 | HAL_RTC_GetDate(&hrtc, &sdatestructureget, RTC_FORMAT_BIN); 154 | 155 | if(Seconds_o != stimestructureget.Seconds) 156 | { 157 | Seconds_o = stimestructureget.Seconds; 158 | 159 | printf("20%02d.%02d.%02d %02d:%02d %02d\r\n",sdatestructureget.Year,sdatestructureget.Month,sdatestructureget.Date, \ 160 | stimestructureget.Hours,stimestructureget.Minutes,stimestructureget.Seconds); 161 | board_led_set(0); 162 | } 163 | else 164 | { 165 | board_led_set(1); 166 | } 167 | } 168 | } 169 | } 170 | /* USER CODE END 3 */ 171 | } 172 | 173 | /** 174 | * @brief System Clock Configuration 175 | * @retval None 176 | */ 177 | void SystemClock_Config(void) 178 | { 179 | RCC_OscInitTypeDef RCC_OscInitStruct = {0}; 180 | RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; 181 | 182 | /** Configure the main internal regulator output voltage 183 | */ 184 | HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1); 185 | 186 | /** Configure LSE Drive Capability 187 | */ 188 | HAL_PWR_EnableBkUpAccess(); 189 | __HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_LOW); 190 | 191 | /** Initializes the RCC Oscillators according to the specified parameters 192 | * in the RCC_OscInitTypeDef structure. 193 | */ 194 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_LSE; 195 | RCC_OscInitStruct.LSEState = RCC_LSE_ON; 196 | RCC_OscInitStruct.HSIState = RCC_HSI_ON; 197 | RCC_OscInitStruct.HSIDiv = RCC_HSI_DIV1; 198 | RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; 199 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; 200 | RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI; 201 | RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV1; 202 | RCC_OscInitStruct.PLL.PLLN = 8; 203 | RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; 204 | RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2; 205 | RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2; 206 | if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) 207 | { 208 | Error_Handler(); 209 | } 210 | 211 | /** Initializes the CPU, AHB and APB buses clocks 212 | */ 213 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK 214 | |RCC_CLOCKTYPE_PCLK1; 215 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; 216 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; 217 | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; 218 | 219 | if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) 220 | { 221 | Error_Handler(); 222 | } 223 | } 224 | 225 | /* USER CODE BEGIN 4 */ 226 | 227 | /* USER CODE END 4 */ 228 | 229 | /** 230 | * @brief This function is executed in case of error occurrence. 231 | * @retval None 232 | */ 233 | void Error_Handler(void) 234 | { 235 | /* USER CODE BEGIN Error_Handler_Debug */ 236 | /* User can add his own implementation to report the HAL error return state */ 237 | __disable_irq(); 238 | while (1) 239 | { 240 | } 241 | /* USER CODE END Error_Handler_Debug */ 242 | } 243 | 244 | #ifdef USE_FULL_ASSERT 245 | /** 246 | * @brief Reports the name of the source file and the source line number 247 | * where the assert_param error has occurred. 248 | * @param file: pointer to the source file name 249 | * @param line: assert_param error line source number 250 | * @retval None 251 | */ 252 | void assert_failed(uint8_t *file, uint32_t line) 253 | { 254 | /* USER CODE BEGIN 6 */ 255 | /* User can add his own implementation to report the file name and line number, 256 | ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ 257 | /* USER CODE END 6 */ 258 | } 259 | #endif /* USE_FULL_ASSERT */ 260 | -------------------------------------------------------------------------------- /Examples/STM32G031/01-RTC/Core/Src/rtc.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file rtc.c 5 | * @brief This file provides code for the configuration 6 | * of the RTC instances. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2023 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | /* Includes ------------------------------------------------------------------*/ 21 | #include "rtc.h" 22 | 23 | /* USER CODE BEGIN 0 */ 24 | 25 | /* USER CODE END 0 */ 26 | 27 | RTC_HandleTypeDef hrtc; 28 | 29 | /* RTC init function */ 30 | void MX_RTC_Init(void) 31 | { 32 | 33 | /* USER CODE BEGIN RTC_Init 0 */ 34 | 35 | /* USER CODE END RTC_Init 0 */ 36 | 37 | RTC_TimeTypeDef sTime = {0}; 38 | RTC_DateTypeDef sDate = {0}; 39 | 40 | /* USER CODE BEGIN RTC_Init 1 */ 41 | 42 | /* USER CODE END RTC_Init 1 */ 43 | 44 | /** Initialize RTC Only 45 | */ 46 | hrtc.Instance = RTC; 47 | hrtc.Init.HourFormat = RTC_HOURFORMAT_24; 48 | hrtc.Init.AsynchPrediv = 127; 49 | hrtc.Init.SynchPrediv = 255; 50 | hrtc.Init.OutPut = RTC_OUTPUT_DISABLE; 51 | hrtc.Init.OutPutRemap = RTC_OUTPUT_REMAP_NONE; 52 | hrtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH; 53 | hrtc.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN; 54 | hrtc.Init.OutPutPullUp = RTC_OUTPUT_PULLUP_NONE; 55 | if (HAL_RTC_Init(&hrtc) != HAL_OK) 56 | { 57 | Error_Handler(); 58 | } 59 | 60 | /* USER CODE BEGIN Check_RTC_BKUP */ 61 | 62 | /* USER CODE END Check_RTC_BKUP */ 63 | 64 | /** Initialize RTC and set the Time and Date 65 | */ 66 | sTime.Hours = 0; 67 | sTime.Minutes = 0; 68 | sTime.Seconds = 0; 69 | sTime.SubSeconds = 0; 70 | sTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE; 71 | sTime.StoreOperation = RTC_STOREOPERATION_RESET; 72 | if (HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BIN) != HAL_OK) 73 | { 74 | Error_Handler(); 75 | } 76 | sDate.WeekDay = RTC_WEEKDAY_MONDAY; 77 | sDate.Month = RTC_MONTH_JANUARY; 78 | sDate.Date = 1; 79 | sDate.Year = 23; 80 | 81 | if (HAL_RTC_SetDate(&hrtc, &sDate, RTC_FORMAT_BIN) != HAL_OK) 82 | { 83 | Error_Handler(); 84 | } 85 | /* USER CODE BEGIN RTC_Init 2 */ 86 | 87 | /* USER CODE END RTC_Init 2 */ 88 | 89 | } 90 | 91 | void HAL_RTC_MspInit(RTC_HandleTypeDef* rtcHandle) 92 | { 93 | 94 | RCC_PeriphCLKInitTypeDef PeriphClkInit = {0}; 95 | if(rtcHandle->Instance==RTC) 96 | { 97 | /* USER CODE BEGIN RTC_MspInit 0 */ 98 | 99 | /* USER CODE END RTC_MspInit 0 */ 100 | 101 | /** Initializes the peripherals clocks 102 | */ 103 | PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_RTC; 104 | PeriphClkInit.RTCClockSelection = RCC_RTCCLKSOURCE_LSE; 105 | 106 | if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) 107 | { 108 | Error_Handler(); 109 | } 110 | 111 | /* RTC clock enable */ 112 | __HAL_RCC_RTC_ENABLE(); 113 | __HAL_RCC_RTCAPB_CLK_ENABLE(); 114 | /* USER CODE BEGIN RTC_MspInit 1 */ 115 | 116 | /* USER CODE END RTC_MspInit 1 */ 117 | } 118 | } 119 | 120 | void HAL_RTC_MspDeInit(RTC_HandleTypeDef* rtcHandle) 121 | { 122 | 123 | if(rtcHandle->Instance==RTC) 124 | { 125 | /* USER CODE BEGIN RTC_MspDeInit 0 */ 126 | 127 | /* USER CODE END RTC_MspDeInit 0 */ 128 | /* Peripheral clock disable */ 129 | __HAL_RCC_RTC_DISABLE(); 130 | __HAL_RCC_RTCAPB_CLK_DISABLE(); 131 | /* USER CODE BEGIN RTC_MspDeInit 1 */ 132 | 133 | /* USER CODE END RTC_MspDeInit 1 */ 134 | } 135 | } 136 | 137 | /* USER CODE BEGIN 1 */ 138 | 139 | /* USER CODE END 1 */ 140 | -------------------------------------------------------------------------------- /Examples/STM32G031/01-RTC/Core/Src/stm32g0xx_hal_msp.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32g0xx_hal_msp.c 5 | * @brief This file provides code for the MSP Initialization 6 | * and de-Initialization codes. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2023 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | #include "main.h" 23 | /* USER CODE BEGIN Includes */ 24 | 25 | /* USER CODE END Includes */ 26 | 27 | /* Private typedef -----------------------------------------------------------*/ 28 | /* USER CODE BEGIN TD */ 29 | 30 | /* USER CODE END TD */ 31 | 32 | /* Private define ------------------------------------------------------------*/ 33 | /* USER CODE BEGIN Define */ 34 | 35 | /* USER CODE END Define */ 36 | 37 | /* Private macro -------------------------------------------------------------*/ 38 | /* USER CODE BEGIN Macro */ 39 | 40 | /* USER CODE END Macro */ 41 | 42 | /* Private variables ---------------------------------------------------------*/ 43 | /* USER CODE BEGIN PV */ 44 | 45 | /* USER CODE END PV */ 46 | 47 | /* Private function prototypes -----------------------------------------------*/ 48 | /* USER CODE BEGIN PFP */ 49 | 50 | /* USER CODE END PFP */ 51 | 52 | /* External functions --------------------------------------------------------*/ 53 | /* USER CODE BEGIN ExternalFunctions */ 54 | 55 | /* USER CODE END ExternalFunctions */ 56 | 57 | /* USER CODE BEGIN 0 */ 58 | 59 | /* USER CODE END 0 */ 60 | /** 61 | * Initializes the Global MSP. 62 | */ 63 | void HAL_MspInit(void) 64 | { 65 | /* USER CODE BEGIN MspInit 0 */ 66 | 67 | /* USER CODE END MspInit 0 */ 68 | 69 | __HAL_RCC_SYSCFG_CLK_ENABLE(); 70 | __HAL_RCC_PWR_CLK_ENABLE(); 71 | 72 | /* System interrupt init*/ 73 | 74 | HAL_SYSCFG_EnableRemap(SYSCFG_REMAP_PA11); 75 | HAL_SYSCFG_EnableRemap(SYSCFG_REMAP_PA12); 76 | 77 | /* USER CODE BEGIN MspInit 1 */ 78 | 79 | /* USER CODE END MspInit 1 */ 80 | } 81 | 82 | /* USER CODE BEGIN 1 */ 83 | 84 | /* USER CODE END 1 */ 85 | -------------------------------------------------------------------------------- /Examples/STM32G031/01-RTC/Core/Src/stm32g0xx_it.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32g0xx_it.c 5 | * @brief Interrupt Service Routines. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2023 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | /* USER CODE END Header */ 19 | 20 | /* Includes ------------------------------------------------------------------*/ 21 | #include "main.h" 22 | #include "stm32g0xx_it.h" 23 | /* Private includes ----------------------------------------------------------*/ 24 | /* USER CODE BEGIN Includes */ 25 | /* USER CODE END Includes */ 26 | 27 | /* Private typedef -----------------------------------------------------------*/ 28 | /* USER CODE BEGIN TD */ 29 | 30 | /* USER CODE END TD */ 31 | 32 | /* Private define ------------------------------------------------------------*/ 33 | /* USER CODE BEGIN PD */ 34 | 35 | /* USER CODE END PD */ 36 | 37 | /* Private macro -------------------------------------------------------------*/ 38 | /* USER CODE BEGIN PM */ 39 | 40 | /* USER CODE END PM */ 41 | 42 | /* Private variables ---------------------------------------------------------*/ 43 | /* USER CODE BEGIN PV */ 44 | 45 | /* USER CODE END PV */ 46 | 47 | /* Private function prototypes -----------------------------------------------*/ 48 | /* USER CODE BEGIN PFP */ 49 | 50 | /* USER CODE END PFP */ 51 | 52 | /* Private user code ---------------------------------------------------------*/ 53 | /* USER CODE BEGIN 0 */ 54 | 55 | /* USER CODE END 0 */ 56 | 57 | /* External variables --------------------------------------------------------*/ 58 | 59 | /* USER CODE BEGIN EV */ 60 | 61 | /* USER CODE END EV */ 62 | 63 | /******************************************************************************/ 64 | /* Cortex-M0+ Processor Interruption and Exception Handlers */ 65 | /******************************************************************************/ 66 | /** 67 | * @brief This function handles Non maskable interrupt. 68 | */ 69 | void NMI_Handler(void) 70 | { 71 | /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ 72 | 73 | /* USER CODE END NonMaskableInt_IRQn 0 */ 74 | /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ 75 | while (1) 76 | { 77 | } 78 | /* USER CODE END NonMaskableInt_IRQn 1 */ 79 | } 80 | 81 | /** 82 | * @brief This function handles Hard fault interrupt. 83 | */ 84 | void HardFault_Handler(void) 85 | { 86 | /* USER CODE BEGIN HardFault_IRQn 0 */ 87 | 88 | /* USER CODE END HardFault_IRQn 0 */ 89 | while (1) 90 | { 91 | /* USER CODE BEGIN W1_HardFault_IRQn 0 */ 92 | /* USER CODE END W1_HardFault_IRQn 0 */ 93 | } 94 | } 95 | 96 | /** 97 | * @brief This function handles System service call via SWI instruction. 98 | */ 99 | void SVC_Handler(void) 100 | { 101 | /* USER CODE BEGIN SVC_IRQn 0 */ 102 | 103 | /* USER CODE END SVC_IRQn 0 */ 104 | /* USER CODE BEGIN SVC_IRQn 1 */ 105 | 106 | /* USER CODE END SVC_IRQn 1 */ 107 | } 108 | 109 | /** 110 | * @brief This function handles Pendable request for system service. 111 | */ 112 | void PendSV_Handler(void) 113 | { 114 | /* USER CODE BEGIN PendSV_IRQn 0 */ 115 | 116 | /* USER CODE END PendSV_IRQn 0 */ 117 | /* USER CODE BEGIN PendSV_IRQn 1 */ 118 | 119 | /* USER CODE END PendSV_IRQn 1 */ 120 | } 121 | 122 | /** 123 | * @brief This function handles System tick timer. 124 | */ 125 | void SysTick_Handler(void) 126 | { 127 | /* USER CODE BEGIN SysTick_IRQn 0 */ 128 | 129 | /* USER CODE END SysTick_IRQn 0 */ 130 | HAL_IncTick(); 131 | /* USER CODE BEGIN SysTick_IRQn 1 */ 132 | 133 | /* USER CODE END SysTick_IRQn 1 */ 134 | } 135 | 136 | /******************************************************************************/ 137 | /* STM32G0xx Peripheral Interrupt Handlers */ 138 | /* Add here the Interrupt Handlers for the used peripherals. */ 139 | /* For the available peripheral interrupt handler names, */ 140 | /* please refer to the startup file (startup_stm32g0xx.s). */ 141 | /******************************************************************************/ 142 | 143 | /* USER CODE BEGIN 1 */ 144 | 145 | /* USER CODE END 1 */ 146 | -------------------------------------------------------------------------------- /Examples/STM32G031/01-RTC/Core/Src/usart.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file usart.c 5 | * @brief This file provides code for the configuration 6 | * of the USART instances. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2023 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | /* Includes ------------------------------------------------------------------*/ 21 | #include "usart.h" 22 | 23 | /* USER CODE BEGIN 0 */ 24 | 25 | /* USER CODE END 0 */ 26 | 27 | UART_HandleTypeDef huart1; 28 | 29 | /* USART1 init function */ 30 | 31 | void MX_USART1_UART_Init(void) 32 | { 33 | 34 | /* USER CODE BEGIN USART1_Init 0 */ 35 | 36 | /* USER CODE END USART1_Init 0 */ 37 | 38 | /* USER CODE BEGIN USART1_Init 1 */ 39 | 40 | /* USER CODE END USART1_Init 1 */ 41 | huart1.Instance = USART1; 42 | huart1.Init.BaudRate = 115200; 43 | huart1.Init.WordLength = UART_WORDLENGTH_8B; 44 | huart1.Init.StopBits = UART_STOPBITS_1; 45 | huart1.Init.Parity = UART_PARITY_NONE; 46 | huart1.Init.Mode = UART_MODE_TX_RX; 47 | huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE; 48 | huart1.Init.OverSampling = UART_OVERSAMPLING_16; 49 | huart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE; 50 | huart1.Init.ClockPrescaler = UART_PRESCALER_DIV1; 51 | huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT; 52 | if (HAL_UART_Init(&huart1) != HAL_OK) 53 | { 54 | Error_Handler(); 55 | } 56 | if (HAL_UARTEx_SetTxFifoThreshold(&huart1, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK) 57 | { 58 | Error_Handler(); 59 | } 60 | if (HAL_UARTEx_SetRxFifoThreshold(&huart1, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK) 61 | { 62 | Error_Handler(); 63 | } 64 | if (HAL_UARTEx_DisableFifoMode(&huart1) != HAL_OK) 65 | { 66 | Error_Handler(); 67 | } 68 | /* USER CODE BEGIN USART1_Init 2 */ 69 | 70 | /* USER CODE END USART1_Init 2 */ 71 | 72 | } 73 | 74 | void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle) 75 | { 76 | 77 | GPIO_InitTypeDef GPIO_InitStruct = {0}; 78 | RCC_PeriphCLKInitTypeDef PeriphClkInit = {0}; 79 | if(uartHandle->Instance==USART1) 80 | { 81 | /* USER CODE BEGIN USART1_MspInit 0 */ 82 | 83 | /* USER CODE END USART1_MspInit 0 */ 84 | 85 | /** Initializes the peripherals clocks 86 | */ 87 | PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART1; 88 | PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_PCLK1; 89 | if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) 90 | { 91 | Error_Handler(); 92 | } 93 | 94 | /* USART1 clock enable */ 95 | __HAL_RCC_USART1_CLK_ENABLE(); 96 | 97 | __HAL_RCC_GPIOA_CLK_ENABLE(); 98 | /**USART1 GPIO Configuration 99 | PA9 [PA11] ------> USART1_TX 100 | PA10 [PA12] ------> USART1_RX 101 | */ 102 | GPIO_InitStruct.Pin = GPIO_PIN_9|GPIO_PIN_10; 103 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 104 | GPIO_InitStruct.Pull = GPIO_NOPULL; 105 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 106 | GPIO_InitStruct.Alternate = GPIO_AF1_USART1; 107 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 108 | 109 | /* USER CODE BEGIN USART1_MspInit 1 */ 110 | 111 | /* USER CODE END USART1_MspInit 1 */ 112 | } 113 | } 114 | 115 | void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle) 116 | { 117 | 118 | if(uartHandle->Instance==USART1) 119 | { 120 | /* USER CODE BEGIN USART1_MspDeInit 0 */ 121 | 122 | /* USER CODE END USART1_MspDeInit 0 */ 123 | /* Peripheral clock disable */ 124 | __HAL_RCC_USART1_CLK_DISABLE(); 125 | 126 | /**USART1 GPIO Configuration 127 | PA9 [PA11] ------> USART1_TX 128 | PA10 [PA12] ------> USART1_RX 129 | */ 130 | HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_10); 131 | 132 | /* USER CODE BEGIN USART1_MspDeInit 1 */ 133 | 134 | /* USER CODE END USART1_MspDeInit 1 */ 135 | } 136 | } 137 | 138 | /* USER CODE BEGIN 1 */ 139 | 140 | /* USER CODE END 1 */ 141 | -------------------------------------------------------------------------------- /Examples/STM32G031/01-RTC/Drivers/CMSIS/Device/ST/STM32G0xx/Include/system_stm32g0xx.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32g0xx.h 4 | * @author MCD Application Team 5 | * @brief CMSIS Cortex-M0+ Device System Source File for STM32G0xx devices. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2018-2021 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | /** @addtogroup CMSIS 19 | * @{ 20 | */ 21 | 22 | /** @addtogroup stm32g0xx_system 23 | * @{ 24 | */ 25 | 26 | /** 27 | * @brief Define to prevent recursive inclusion 28 | */ 29 | #ifndef SYSTEM_STM32G0XX_H 30 | #define SYSTEM_STM32G0XX_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /** @addtogroup STM32G0xx_System_Includes 37 | * @{ 38 | */ 39 | 40 | /** 41 | * @} 42 | */ 43 | 44 | 45 | /** @addtogroup STM32G0xx_System_Exported_types 46 | * @{ 47 | */ 48 | /* This variable is updated in three ways: 49 | 1) by calling CMSIS function SystemCoreClockUpdate() 50 | 2) by calling HAL API function HAL_RCC_GetSysClockFreq() 51 | 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency 52 | Note: If you use this function to configure the system clock; then there 53 | is no need to call the 2 first functions listed above, since SystemCoreClock 54 | variable is updated automatically. 55 | */ 56 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 57 | 58 | extern const uint32_t AHBPrescTable[16]; /*!< AHB prescalers table values */ 59 | extern const uint32_t APBPrescTable[8]; /*!< APB prescalers table values */ 60 | 61 | /** 62 | * @} 63 | */ 64 | 65 | /** @addtogroup STM32G0xx_System_Exported_Constants 66 | * @{ 67 | */ 68 | 69 | /** 70 | * @} 71 | */ 72 | 73 | /** @addtogroup STM32G0xx_System_Exported_Macros 74 | * @{ 75 | */ 76 | 77 | /** 78 | * @} 79 | */ 80 | 81 | /** @addtogroup STM32G0xx_System_Exported_Functions 82 | * @{ 83 | */ 84 | 85 | extern void SystemInit(void); 86 | extern void SystemCoreClockUpdate(void); 87 | /** 88 | * @} 89 | */ 90 | 91 | #ifdef __cplusplus 92 | } 93 | #endif 94 | 95 | #endif /*SYSTEM_STM32G0XX_H */ 96 | 97 | /** 98 | * @} 99 | */ 100 | 101 | /** 102 | * @} 103 | */ 104 | -------------------------------------------------------------------------------- /Examples/STM32G031/01-RTC/Drivers/CMSIS/Device/ST/STM32G0xx/LICENSE.txt: -------------------------------------------------------------------------------- 1 | This software component is provided to you as part of a software package and 2 | applicable license terms are in the Package_license file. If you received this 3 | software component outside of a package or without applicable license terms, 4 | the terms of the Apache-2.0 license shall apply. 5 | You may obtain a copy of the Apache-2.0 at: 6 | https://opensource.org/licenses/Apache-2.0 7 | -------------------------------------------------------------------------------- /Examples/STM32G031/01-RTC/Drivers/CMSIS/Include/cmsis_version.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file cmsis_version.h 3 | * @brief CMSIS Core(M) Version definitions 4 | * @version V5.0.3 5 | * @date 24. June 2019 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2009-2019 ARM Limited. All rights reserved. 9 | * 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the License); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | #if defined ( __ICCARM__ ) 26 | #pragma system_include /* treat file as system include file for MISRA check */ 27 | #elif defined (__clang__) 28 | #pragma clang system_header /* treat file as system include file */ 29 | #endif 30 | 31 | #ifndef __CMSIS_VERSION_H 32 | #define __CMSIS_VERSION_H 33 | 34 | /* CMSIS Version definitions */ 35 | #define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */ 36 | #define __CM_CMSIS_VERSION_SUB ( 3U) /*!< [15:0] CMSIS Core(M) sub version */ 37 | #define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \ 38 | __CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */ 39 | #endif 40 | -------------------------------------------------------------------------------- /Examples/STM32G031/01-RTC/Drivers/CMSIS/Include/tz_context.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * @file tz_context.h 3 | * @brief Context Management for Armv8-M TrustZone 4 | * @version V1.0.1 5 | * @date 10. January 2018 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2017-2018 Arm Limited. All rights reserved. 9 | * 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the License); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | #if defined ( __ICCARM__ ) 26 | #pragma system_include /* treat file as system include file for MISRA check */ 27 | #elif defined (__clang__) 28 | #pragma clang system_header /* treat file as system include file */ 29 | #endif 30 | 31 | #ifndef TZ_CONTEXT_H 32 | #define TZ_CONTEXT_H 33 | 34 | #include 35 | 36 | #ifndef TZ_MODULEID_T 37 | #define TZ_MODULEID_T 38 | /// \details Data type that identifies secure software modules called by a process. 39 | typedef uint32_t TZ_ModuleId_t; 40 | #endif 41 | 42 | /// \details TZ Memory ID identifies an allocated memory slot. 43 | typedef uint32_t TZ_MemoryId_t; 44 | 45 | /// Initialize secure context memory system 46 | /// \return execution status (1: success, 0: error) 47 | uint32_t TZ_InitContextSystem_S (void); 48 | 49 | /// Allocate context memory for calling secure software modules in TrustZone 50 | /// \param[in] module identifies software modules called from non-secure mode 51 | /// \return value != 0 id TrustZone memory slot identifier 52 | /// \return value 0 no memory available or internal error 53 | TZ_MemoryId_t TZ_AllocModuleContext_S (TZ_ModuleId_t module); 54 | 55 | /// Free context memory that was previously allocated with \ref TZ_AllocModuleContext_S 56 | /// \param[in] id TrustZone memory slot identifier 57 | /// \return execution status (1: success, 0: error) 58 | uint32_t TZ_FreeModuleContext_S (TZ_MemoryId_t id); 59 | 60 | /// Load secure context (called on RTOS thread context switch) 61 | /// \param[in] id TrustZone memory slot identifier 62 | /// \return execution status (1: success, 0: error) 63 | uint32_t TZ_LoadContext_S (TZ_MemoryId_t id); 64 | 65 | /// Store secure context (called on RTOS thread context switch) 66 | /// \param[in] id TrustZone memory slot identifier 67 | /// \return execution status (1: success, 0: error) 68 | uint32_t TZ_StoreContext_S (TZ_MemoryId_t id); 69 | 70 | #endif // TZ_CONTEXT_H 71 | -------------------------------------------------------------------------------- /Examples/STM32G031/01-RTC/Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_flash_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32g0xx_hal_flash_ex.h 4 | * @author MCD Application Team 5 | * @brief Header file of FLASH HAL Extended module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2018 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file in 13 | * the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | ****************************************************************************** 16 | */ 17 | 18 | /* Define to prevent recursive inclusion -------------------------------------*/ 19 | #ifndef STM32G0xx_HAL_FLASH_EX_H 20 | #define STM32G0xx_HAL_FLASH_EX_H 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | /* Includes ------------------------------------------------------------------*/ 27 | #include "stm32g0xx_hal_def.h" 28 | 29 | /** @addtogroup STM32G0xx_HAL_Driver 30 | * @{ 31 | */ 32 | 33 | /** @addtogroup FLASHEx 34 | * @{ 35 | */ 36 | 37 | /* Exported types ------------------------------------------------------------*/ 38 | /* Exported constants --------------------------------------------------------*/ 39 | /** @defgroup FLASHEx_Exported_Constants FLASH Exported Constants 40 | * @{ 41 | */ 42 | /** @defgroup FLASHEx_Empty_Check FLASHEx Empty Check 43 | * @{ 44 | */ 45 | #define FLASH_PROG_NOT_EMPTY 0x00000000u /*!< 1st location in Flash is programmed */ 46 | #define FLASH_PROG_EMPTY FLASH_ACR_PROGEMPTY /*!< 1st location in Flash is empty */ 47 | /** 48 | * @} 49 | */ 50 | /** 51 | * @} 52 | */ 53 | 54 | /* Exported macro ------------------------------------------------------------*/ 55 | /* Exported functions --------------------------------------------------------*/ 56 | /** @addtogroup FLASHEx_Exported_Functions 57 | * @{ 58 | */ 59 | 60 | /* Extended Program operation functions *************************************/ 61 | /** @addtogroup FLASHEx_Exported_Functions_Group1 62 | * @{ 63 | */ 64 | HAL_StatusTypeDef HAL_FLASHEx_Erase(FLASH_EraseInitTypeDef *pEraseInit, uint32_t *PageError); 65 | HAL_StatusTypeDef HAL_FLASHEx_Erase_IT(FLASH_EraseInitTypeDef *pEraseInit); 66 | void HAL_FLASHEx_EnableDebugger(void); 67 | void HAL_FLASHEx_DisableDebugger(void); 68 | uint32_t HAL_FLASHEx_FlashEmptyCheck(void); 69 | void HAL_FLASHEx_ForceFlashEmpty(uint32_t FlashEmpty); 70 | #if defined(FLASH_SECURABLE_MEMORY_SUPPORT) 71 | void HAL_FLASHEx_EnableSecMemProtection(uint32_t Banks); 72 | #endif /* FLASH_SECURABLE_MEMORY_SUPPORT */ 73 | HAL_StatusTypeDef HAL_FLASHEx_OBProgram(FLASH_OBProgramInitTypeDef *pOBInit); 74 | void HAL_FLASHEx_OBGetConfig(FLASH_OBProgramInitTypeDef *pOBInit); 75 | /** 76 | * @} 77 | */ 78 | 79 | /** 80 | * @} 81 | */ 82 | 83 | /* Private macros ------------------------------------------------------------*/ 84 | /** @defgroup FLASHEx_Private_Constants FLASHEx Private Constants 85 | * @{ 86 | */ 87 | #define FLASH_PCROP_GRANULARITY_OFFSET 9u /*!< FLASH Code Readout Protection granularity offset */ 88 | #define FLASH_PCROP_GRANULARITY (1UL << FLASH_PCROP_GRANULARITY_OFFSET) /*!< FLASH Code Readout Protection granularity, 512 Bytes */ 89 | /** 90 | * @} 91 | */ 92 | 93 | 94 | /** @defgroup FLASHEx_Private_Macros FLASHEx Private Macros 95 | * @{ 96 | */ 97 | #define IS_FLASH_EMPTY_CHECK(__VALUE__) (((__VALUE__) == FLASH_PROG_EMPTY) || ((__VALUE__) == FLASH_PROG_NOT_EMPTY)) 98 | void FLASH_PageErase(uint32_t Banks, uint32_t Page); 99 | /** 100 | * @} 101 | */ 102 | 103 | /** 104 | * @} 105 | */ 106 | 107 | /** 108 | * @} 109 | */ 110 | 111 | #ifdef __cplusplus 112 | } 113 | #endif 114 | 115 | #endif /* STM32G0xx_HAL_FLASH_EX_H */ 116 | 117 | -------------------------------------------------------------------------------- /Examples/STM32G031/01-RTC/Drivers/STM32G0xx_HAL_Driver/LICENSE.txt: -------------------------------------------------------------------------------- 1 | This software component is provided to you as part of a software package and 2 | applicable license terms are in the Package_license file. If you received this 3 | software component outside of a package or without applicable license terms, 4 | the terms of the BSD-3-Clause license shall apply. 5 | You may obtain a copy of the BSD-3-Clause at: 6 | https://opensource.org/licenses/BSD-3-Clause 7 | -------------------------------------------------------------------------------- /Examples/STM32G031/01-RTC/MDK-ARM/01-RTC/01-RTC.axf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeActStudio/WeActStudio.STM32G0xxC0xxCoreBoard/f692e4e2e853ae9610aa337e2222c6d6d73416d8/Examples/STM32G031/01-RTC/MDK-ARM/01-RTC/01-RTC.axf -------------------------------------------------------------------------------- /Examples/STM32G031/01-RTC/MDK-ARM/DebugConfig/01-RTC_STM32G031F8Px_1.0.0.dbgconf: -------------------------------------------------------------------------------- 1 | // File: STM32G0x1.dbgconf 2 | // Version: 1.0.0 3 | // Note: refer to STM32G0x1 reference manual (RM0444) 4 | 5 | // <<< Use Configuration Wizard in Context Menu >>> 6 | 7 | // Debug MCU configuration register (DBGMCU_CR) 8 | // Reserved bits must be kept at reset value 9 | // DBG_STANDBY Debug Standby Mode 10 | // DBG_STOP Debug Stop Mode 11 | // 12 | DbgMCU_CR = 0x00000006; 13 | 14 | // Debug MCU APB freeze register 1 (DBGMCU_APB_FZ1) 15 | // Reserved bits must be kept at reset value 16 | // DBG_LPTIM1_STOP LPTIMER1 counter stopped when core is halted 17 | // DBG_LPTIM2_STOP LPTIMER2 counter stopped when core is halted 18 | // DBG_I2C1_SMBUS_TIMEOUT I2C1 SMBUS timeout is frozen 19 | // DBG_IWDG_STOP Debug independent watchdog stopped when core is halted 20 | // DBG_WWDG_STOP Debug window watchdog stopped when core is halted 21 | // DBG_RTC_STOP Debug RTC stopped when core is halted 22 | // DBG_TIM7_STOP TIM7 counter stopped when core is halted 23 | // DBG_TIM6_STOP TIM6 counter stopped when core is halted 24 | // DBG_TIM3_STOP TIM3 counter stopped when core is halted 25 | // DBG_TIM2_STOP TIM2 counter stopped when core is halted 26 | // 27 | DbgMCU_APB_Fz1 = 0x00000000; 28 | 29 | // Debug MCU APB freeze register 2 (DBGMCU_APB_FZ2) 30 | // Reserved bits must be kept at reset value 31 | // DBG_TIM17_STOP TIM17 counter stopped when core is halted 32 | // DBG_TIM16_STOP TIM16 counter stopped when core is halted 33 | // DBG_TIM15_STOP TIM15 counter stopped when core is halted 34 | // DBG_TIM14_STOP TIM14 counter stopped when core is halted 35 | // DBG_TIM1_STOP TIM1 counter stopped when core is halted 36 | // 37 | DbgMCU_APB_Fz2 = 0x00000000; 38 | 39 | // <<< end of configuration section >>> 40 | -------------------------------------------------------------------------------- /Examples/STM32G031/01-RTC/MDK-ARM/EventRecorderStub.scvd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Examples/STM32G031/01-RTC/MDK-ARM/RTE/_01-RTC/RTE_Components.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Auto generated Run-Time-Environment Configuration File 4 | * *** Do not modify ! *** 5 | * 6 | * Project: '01-RTC' 7 | * Target: '01-RTC' 8 | */ 9 | 10 | #ifndef RTE_COMPONENTS_H 11 | #define RTE_COMPONENTS_H 12 | 13 | 14 | /* 15 | * Define the Device Header File: 16 | */ 17 | #define CMSIS_device_header "stm32g0xx.h" 18 | 19 | 20 | 21 | #endif /* RTE_COMPONENTS_H */ 22 | -------------------------------------------------------------------------------- /Examples/buildclean.bat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeActStudio/WeActStudio.STM32G0xxC0xxCoreBoard/f692e4e2e853ae9610aa337e2222c6d6d73416d8/Examples/buildclean.bat -------------------------------------------------------------------------------- /Hardware/WeAct-STM32G0xxC0xxCoreBoard_V10 Board Shape 外形.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeActStudio/WeActStudio.STM32G0xxC0xxCoreBoard/f692e4e2e853ae9610aa337e2222c6d6d73416d8/Hardware/WeAct-STM32G0xxC0xxCoreBoard_V10 Board Shape 外形.pdf -------------------------------------------------------------------------------- /Hardware/WeAct-STM32G0xxC0xxCoreBoard_V10 SchDoc.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeActStudio/WeActStudio.STM32G0xxC0xxCoreBoard/f692e4e2e853ae9610aa337e2222c6d6d73416d8/Hardware/WeAct-STM32G0xxC0xxCoreBoard_V10 SchDoc.pdf -------------------------------------------------------------------------------- /Images/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeActStudio/WeActStudio.STM32G0xxC0xxCoreBoard/f692e4e2e853ae9610aa337e2222c6d6d73416d8/Images/1.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | * [中文版本](./README_zh.md) 2 | # WeActStudio.STM32G0xxC0xxCoreBoard 3 | ![display](Images/1.png) 4 | **STM32G030F6P6** 5 | Freq:64Mhz Max 6 | RAM:8KB,ROM:32KB 7 | **STM32G031F8P6** 8 | Freq:64Mhz Max 9 | RAM:8KB,ROM:64KB 10 | **STM32G031F6P6** 11 | Freq:64Mhz Max 12 | RAM:8KB,ROM:32KB 13 | **STM32C011F6P6** 14 | Freq:48Mhz Max 15 | RAM:6KB,ROM:32KB 16 | 17 | ST Official Website www.st.com 18 | 19 | |Dir Name|Explain| 20 | | :--:|:--:| 21 | |Doc|DataSheet/ReferenceManual| 22 | |Hardware|Hardware Development Kit| 23 | |Examples|Software Examples| 24 | 25 | ``` 26 | /*--------------------------------------- 27 | - WeAct Studio Official Link 28 | - taobao: weactstudio.taobao.com 29 | - aliexpress: weactstudio.aliexpress.com 30 | - github: github.com/WeActStudio 31 | - gitee: gitee.com/WeAct-TC 32 | - blog: www.weact-tc.cn 33 | ---------------------------------------*/ 34 | ``` -------------------------------------------------------------------------------- /README_zh.md: -------------------------------------------------------------------------------- 1 | * [English version](./README.md) 2 | # WeActStudio.STM32G0xxC0xxCoreBoard 3 | ![display](Images/1.png) 4 | **STM32G030F6P6** 5 | Freq:64Mhz Max 6 | RAM:8KB,ROM:32KB 7 | **STM32G031F8P6** 8 | Freq:64Mhz Max 9 | RAM:8KB,ROM:64KB 10 | **STM32G031F6P6** 11 | Freq:64Mhz Max 12 | RAM:8KB,ROM:32KB 13 | **STM32C011F6P6** 14 | Freq:48Mhz Max 15 | RAM:6KB,ROM:32KB 16 | 17 | ST 官方网站 Website www.st.com 18 | 19 | |目录名称|内容| 20 | | :--:|:--:| 21 | |Doc| 数据手册/参考手册| 22 | |Hardware| 硬件开发资料| 23 | |Examples|软件例程| 24 | 25 | ``` 26 | /*--------------------------------------- 27 | - WeAct Studio Official Link 28 | - taobao: weactstudio.taobao.com 29 | - aliexpress: weactstudio.aliexpress.com 30 | - github: github.com/WeActStudio 31 | - gitee: gitee.com/WeAct-TC 32 | - blog: www.weact-tc.cn 33 | ---------------------------------------*/ 34 | ``` --------------------------------------------------------------------------------