├── .cproject ├── .gitignore ├── .gitmodules ├── .mxproject ├── .project ├── CHANGELOG.md ├── Core ├── Inc │ ├── ax25.h │ ├── beacon.h │ ├── common.h │ ├── config.h │ ├── digipeater.h │ ├── drivers │ │ ├── digipeater_ll.h │ │ ├── modem_ll.h │ │ ├── uart_ll.h │ │ ├── usb.h │ │ └── watchdog.h │ ├── fx25.h │ ├── kiss.h │ ├── main.h │ ├── modem.h │ ├── stm32f1xx_hal_conf.h │ ├── stm32f1xx_it.h │ ├── systick.h │ ├── terminal.h │ └── uart.h ├── Src │ ├── ax25.c │ ├── beacon.c │ ├── common.c │ ├── config.c │ ├── digipeater.c │ ├── fx25.c │ ├── kiss.c │ ├── main.c │ ├── modem.c │ ├── stm32f1xx_hal_msp.c │ ├── stm32f1xx_it.c │ ├── syscalls.c │ ├── sysmem.c │ ├── system_stm32f1xx.c │ ├── systick.c │ ├── terminal.c │ └── uart.c └── Startup │ └── startup_stm32f103c8tx.s ├── Drivers ├── CMSIS │ ├── Device │ │ └── ST │ │ │ └── STM32F1xx │ │ │ ├── Include │ │ │ ├── stm32f103xb.h │ │ │ ├── stm32f1xx.h │ │ │ └── system_stm32f1xx.h │ │ │ └── LICENSE.txt │ ├── Include │ │ ├── cmsis_armcc.h │ │ ├── cmsis_armclang.h │ │ ├── cmsis_compiler.h │ │ ├── cmsis_gcc.h │ │ ├── cmsis_iccarm.h │ │ ├── cmsis_version.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_cm4.h │ │ ├── core_cm7.h │ │ ├── core_sc000.h │ │ ├── core_sc300.h │ │ ├── mpu_armv7.h │ │ ├── mpu_armv8.h │ │ └── tz_context.h │ └── LICENSE.txt └── STM32F1xx_HAL_Driver │ ├── Inc │ ├── Legacy │ │ └── stm32_hal_legacy.h │ ├── stm32f1xx_hal.h │ ├── stm32f1xx_hal_cortex.h │ ├── stm32f1xx_hal_def.h │ ├── stm32f1xx_hal_dma.h │ ├── stm32f1xx_hal_dma_ex.h │ ├── stm32f1xx_hal_exti.h │ ├── stm32f1xx_hal_flash.h │ ├── stm32f1xx_hal_flash_ex.h │ ├── stm32f1xx_hal_gpio.h │ ├── stm32f1xx_hal_gpio_ex.h │ ├── stm32f1xx_hal_pcd.h │ ├── stm32f1xx_hal_pcd_ex.h │ ├── stm32f1xx_hal_pwr.h │ ├── stm32f1xx_hal_rcc.h │ ├── stm32f1xx_hal_rcc_ex.h │ ├── stm32f1xx_hal_tim.h │ ├── stm32f1xx_hal_tim_ex.h │ ├── stm32f1xx_ll_bus.h │ ├── stm32f1xx_ll_cortex.h │ ├── stm32f1xx_ll_dma.h │ ├── stm32f1xx_ll_exti.h │ ├── stm32f1xx_ll_gpio.h │ ├── stm32f1xx_ll_pwr.h │ ├── stm32f1xx_ll_rcc.h │ ├── stm32f1xx_ll_system.h │ ├── stm32f1xx_ll_usb.h │ └── stm32f1xx_ll_utils.h │ ├── LICENSE.txt │ └── Src │ ├── stm32f1xx_hal.c │ ├── stm32f1xx_hal_cortex.c │ ├── stm32f1xx_hal_dma.c │ ├── stm32f1xx_hal_exti.c │ ├── stm32f1xx_hal_flash.c │ ├── stm32f1xx_hal_flash_ex.c │ ├── stm32f1xx_hal_gpio.c │ ├── stm32f1xx_hal_gpio_ex.c │ ├── stm32f1xx_hal_pcd.c │ ├── stm32f1xx_hal_pcd_ex.c │ ├── stm32f1xx_hal_pwr.c │ ├── stm32f1xx_hal_rcc.c │ ├── stm32f1xx_hal_rcc_ex.c │ ├── stm32f1xx_hal_tim.c │ ├── stm32f1xx_hal_tim_ex.c │ └── stm32f1xx_ll_usb.c ├── F103C8T6_DIGI_USB.xml ├── LICENSE ├── Middlewares └── ST │ └── STM32_USB_Device_Library │ ├── Class │ └── CDC │ │ ├── Inc │ │ └── usbd_cdc.h │ │ └── Src │ │ └── usbd_cdc.c │ └── Core │ ├── Inc │ ├── usbd_core.h │ ├── usbd_ctlreq.h │ ├── usbd_def.h │ └── usbd_ioreq.h │ └── Src │ ├── usbd_core.c │ ├── usbd_ctlreq.c │ └── usbd_ioreq.c ├── README.md ├── README_pl.md ├── STM32F103C8Tx_FLASH.ld ├── TODO ├── USB_DEVICE ├── App │ ├── usb_device.c │ ├── usb_device.h │ ├── usbd_cdc_if.c │ ├── usbd_cdc_if.h │ ├── usbd_desc.c │ └── usbd_desc.h └── Target │ ├── usbd_conf.c │ └── usbd_conf.h ├── doc ├── LICENSE_FDL ├── WA8LMF-Track-2-results.txt ├── manual.md ├── manual_pl.md └── schematic.png └── vp-digi.ioc /.gitignore: -------------------------------------------------------------------------------- 1 | ### C ### 2 | # Prerequisites 3 | *.d 4 | 5 | # Object files 6 | *.o 7 | *.ko 8 | *.obj 9 | *.elf 10 | 11 | # Linker output 12 | *.ilk 13 | *.map 14 | *.exp 15 | 16 | # Precompiled Headers 17 | *.gch 18 | *.pch 19 | 20 | # Libraries 21 | *.lib 22 | *.a 23 | *.la 24 | *.lo 25 | 26 | # Shared objects (inc. Windows DLLs) 27 | *.dll 28 | *.so 29 | *.so.* 30 | *.dylib 31 | 32 | # Executables 33 | *.exe 34 | *.out 35 | *.app 36 | *.i*86 37 | *.x86_64 38 | *.hex 39 | 40 | # Debug files 41 | *.dSYM/ 42 | *.su 43 | *.idb 44 | *.pdb 45 | 46 | # Kernel Module Compile Results 47 | *.mod* 48 | *.cmd 49 | .tmp_versions/ 50 | modules.order 51 | Module.symvers 52 | Mkfile.old 53 | dkms.conf 54 | 55 | ### Eclipse ### 56 | .metadata 57 | bin/ 58 | tmp/ 59 | *.tmp 60 | *.bak 61 | *.swp 62 | *~.nib 63 | local.properties 64 | .settings/ 65 | .loadpath 66 | .recommenders 67 | 68 | # External tool builders 69 | .externalToolBuilders/ 70 | 71 | # Locally stored "Eclipse launch configurations" 72 | *.launch 73 | 74 | # PyDev specific (Python IDE for Eclipse) 75 | *.pydevproject 76 | 77 | # CDT- autotools 78 | .autotools 79 | 80 | # Java annotation processor (APT) 81 | .factorypath 82 | 83 | # PDT-specific (PHP Development Tools) 84 | .buildpath 85 | 86 | # sbteclipse plugin 87 | .target 88 | 89 | # Code Recommenders 90 | .recommenders/ 91 | 92 | # Annotation Processing 93 | .apt_generated/ 94 | .apt_generated_test/ 95 | 96 | ### Eclipse Patch ### 97 | # Spring Boot Tooling 98 | .sts4-cache/ 99 | 100 | Debug/ 101 | Release/ -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "lwfec"] 2 | path = lwfec 3 | url = https://github.com/sq8vps/lwfec 4 | -------------------------------------------------------------------------------- /.mxproject: -------------------------------------------------------------------------------- 1 | [PreviousLibFiles] 2 | LibFiles=Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_pcd.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_pcd_ex.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_usb.h;Drivers\STM32F1xx_HAL_Driver\Inc\Legacy\stm32_hal_legacy.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_def.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_rcc.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_rcc_ex.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_bus.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_rcc.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_system.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_utils.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_gpio.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_gpio_ex.h;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_gpio_ex.c;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_gpio.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_dma_ex.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_dma.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_dma.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_cortex.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_cortex.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_pwr.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_pwr.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_flash.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_flash_ex.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_exti.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_exti.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_tim.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_tim_ex.h;Middlewares\ST\STM32_USB_Device_Library\Core\Inc\usbd_core.h;Middlewares\ST\STM32_USB_Device_Library\Core\Inc\usbd_ctlreq.h;Middlewares\ST\STM32_USB_Device_Library\Core\Inc\usbd_def.h;Middlewares\ST\STM32_USB_Device_Library\Core\Inc\usbd_ioreq.h;Middlewares\ST\STM32_USB_Device_Library\Class\CDC\Inc\usbd_cdc.h;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_pcd.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_pcd_ex.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_usb.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_rcc.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_rcc_ex.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_gpio.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_dma.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_cortex.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_pwr.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_flash.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_flash_ex.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_exti.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_tim.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_tim_ex.c;Middlewares\ST\STM32_USB_Device_Library\Core\Src\usbd_core.c;Middlewares\ST\STM32_USB_Device_Library\Core\Src\usbd_ctlreq.c;Middlewares\ST\STM32_USB_Device_Library\Core\Src\usbd_ioreq.c;Middlewares\ST\STM32_USB_Device_Library\Class\CDC\Src\usbd_cdc.c;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_pcd.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_pcd_ex.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_usb.h;Drivers\STM32F1xx_HAL_Driver\Inc\Legacy\stm32_hal_legacy.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_def.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_rcc.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_rcc_ex.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_bus.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_rcc.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_system.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_utils.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_gpio.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_gpio_ex.h;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_gpio_ex.c;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_gpio.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_dma_ex.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_dma.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_dma.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_cortex.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_cortex.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_pwr.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_pwr.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_flash.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_flash_ex.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_exti.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_exti.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_tim.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_tim_ex.h;Middlewares\ST\STM32_USB_Device_Library\Core\Inc\usbd_core.h;Middlewares\ST\STM32_USB_Device_Library\Core\Inc\usbd_ctlreq.h;Middlewares\ST\STM32_USB_Device_Library\Core\Inc\usbd_def.h;Middlewares\ST\STM32_USB_Device_Library\Core\Inc\usbd_ioreq.h;Middlewares\ST\STM32_USB_Device_Library\Class\CDC\Inc\usbd_cdc.h;Drivers\CMSIS\Device\ST\STM32F1xx\Include\stm32f103xb.h;Drivers\CMSIS\Device\ST\STM32F1xx\Include\stm32f1xx.h;Drivers\CMSIS\Device\ST\STM32F1xx\Include\system_stm32f1xx.h;Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c;Drivers\CMSIS\Include\cmsis_armcc.h;Drivers\CMSIS\Include\cmsis_armclang.h;Drivers\CMSIS\Include\cmsis_compiler.h;Drivers\CMSIS\Include\cmsis_gcc.h;Drivers\CMSIS\Include\cmsis_iccarm.h;Drivers\CMSIS\Include\cmsis_version.h;Drivers\CMSIS\Include\core_armv8mbl.h;Drivers\CMSIS\Include\core_armv8mml.h;Drivers\CMSIS\Include\core_cm0.h;Drivers\CMSIS\Include\core_cm0plus.h;Drivers\CMSIS\Include\core_cm1.h;Drivers\CMSIS\Include\core_cm23.h;Drivers\CMSIS\Include\core_cm3.h;Drivers\CMSIS\Include\core_cm33.h;Drivers\CMSIS\Include\core_cm4.h;Drivers\CMSIS\Include\core_cm7.h;Drivers\CMSIS\Include\core_sc000.h;Drivers\CMSIS\Include\core_sc300.h;Drivers\CMSIS\Include\mpu_armv7.h;Drivers\CMSIS\Include\mpu_armv8.h;Drivers\CMSIS\Include\tz_context.h; 3 | 4 | [PreviousUsedCubeIDEFiles] 5 | SourceFiles=Core\Src\main.c;USB_DEVICE\App\usb_device.c;USB_DEVICE\Target\usbd_conf.c;USB_DEVICE\App\usbd_desc.c;USB_DEVICE\App\usbd_cdc_if.c;Core\Src\stm32f1xx_it.c;Core\Src\stm32f1xx_hal_msp.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_gpio_ex.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_pcd.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_pcd_ex.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_usb.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_rcc.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_rcc_ex.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_gpio.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_dma.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_cortex.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_pwr.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_flash.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_flash_ex.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_exti.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_tim.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_tim_ex.c;Middlewares\ST\STM32_USB_Device_Library\Core\Src\usbd_core.c;Middlewares\ST\STM32_USB_Device_Library\Core\Src\usbd_ctlreq.c;Middlewares\ST\STM32_USB_Device_Library\Core\Src\usbd_ioreq.c;Middlewares\ST\STM32_USB_Device_Library\Class\CDC\Src\usbd_cdc.c;Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c;Core\Src\system_stm32f1xx.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_gpio_ex.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_pcd.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_pcd_ex.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_usb.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_rcc.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_rcc_ex.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_gpio.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_dma.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_cortex.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_pwr.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_flash.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_flash_ex.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_exti.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_tim.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_tim_ex.c;Middlewares\ST\STM32_USB_Device_Library\Core\Src\usbd_core.c;Middlewares\ST\STM32_USB_Device_Library\Core\Src\usbd_ctlreq.c;Middlewares\ST\STM32_USB_Device_Library\Core\Src\usbd_ioreq.c;Middlewares\ST\STM32_USB_Device_Library\Class\CDC\Src\usbd_cdc.c;Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c;Core\Src\system_stm32f1xx.c;;;Middlewares\ST\STM32_USB_Device_Library\Core\Src\usbd_core.c;Middlewares\ST\STM32_USB_Device_Library\Core\Src\usbd_ctlreq.c;Middlewares\ST\STM32_USB_Device_Library\Core\Src\usbd_ioreq.c;Middlewares\ST\STM32_USB_Device_Library\Class\CDC\Src\usbd_cdc.c; 6 | HeaderPath=Drivers\STM32F1xx_HAL_Driver\Inc;Drivers\STM32F1xx_HAL_Driver\Inc\Legacy;Middlewares\ST\STM32_USB_Device_Library\Core\Inc;Middlewares\ST\STM32_USB_Device_Library\Class\CDC\Inc;Drivers\CMSIS\Device\ST\STM32F1xx\Include;Drivers\CMSIS\Include;USB_DEVICE\App;USB_DEVICE\Target;Core\Inc; 7 | CDefines=USE_HAL_DRIVER;STM32F103xB;USE_HAL_DRIVER;USE_HAL_DRIVER; 8 | 9 | [PreviousGenFiles] 10 | AdvancedFolderStructure=true 11 | HeaderFileListSize=7 12 | HeaderFiles#0=..\USB_DEVICE\App\usb_device.h 13 | HeaderFiles#1=..\USB_DEVICE\Target\usbd_conf.h 14 | HeaderFiles#2=..\USB_DEVICE\App\usbd_desc.h 15 | HeaderFiles#3=..\USB_DEVICE\App\usbd_cdc_if.h 16 | HeaderFiles#4=..\Core\Inc\stm32f1xx_it.h 17 | HeaderFiles#5=..\Core\Inc\stm32f1xx_hal_conf.h 18 | HeaderFiles#6=..\Core\Inc\main.h 19 | HeaderFolderListSize=3 20 | HeaderPath#0=..\USB_DEVICE\App 21 | HeaderPath#1=..\USB_DEVICE\Target 22 | HeaderPath#2=..\Core\Inc 23 | HeaderFiles=; 24 | SourceFileListSize=7 25 | SourceFiles#0=..\USB_DEVICE\App\usb_device.c 26 | SourceFiles#1=..\USB_DEVICE\Target\usbd_conf.c 27 | SourceFiles#2=..\USB_DEVICE\App\usbd_desc.c 28 | SourceFiles#3=..\USB_DEVICE\App\usbd_cdc_if.c 29 | SourceFiles#4=..\Core\Src\stm32f1xx_it.c 30 | SourceFiles#5=..\Core\Src\stm32f1xx_hal_msp.c 31 | SourceFiles#6=..\Core\Src\main.c 32 | SourceFolderListSize=3 33 | SourcePath#0=..\USB_DEVICE\App 34 | SourcePath#1=..\USB_DEVICE\Target 35 | SourcePath#2=..\Core\Src 36 | SourceFiles=; 37 | 38 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | vp-digi 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | 14 | 15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 16 | full,incremental, 17 | 18 | 19 | 20 | 21 | 22 | com.st.stm32cube.ide.mcu.MCUProjectNature 23 | org.eclipse.cdt.core.cnature 24 | com.st.stm32cube.ide.mcu.MCUCubeIdeServicesRevAev2ProjectNature 25 | com.st.stm32cube.ide.mcu.MCUCubeProjectNature 26 | com.st.stm32cube.ide.mcu.MCUAdvancedStructureProjectNature 27 | com.st.stm32cube.ide.mcu.MCUSingleCpuProjectNature 28 | com.st.stm32cube.ide.mcu.MCURootProjectNature 29 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 30 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 31 | 32 | 33 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # 2.1.0 (2025-03-04) 2 | ## New features 3 | * Digipeater disable input at PB0 (pull to GND to disable digipeater) 4 | * Digipeater active LED at PB1 (high state when active) 5 | ## Bug fixes 6 | * Hopefully resolved KISS TX deadlock ultimately... 7 | * No more problems when entering callsigns without explicit SSID 8 | ## Other 9 | * do...while(0) guards on multiline macros 10 | ## Known bugs 11 | * none 12 | # 2.0.1 (2025-02-06) 13 | ## New features 14 | * none 15 | ## Bug fixes 16 | * Resolved KISS TX deadlock 17 | ## Other 18 | * none 19 | ## Known bugs 20 | * KISS TX deadlock still present anyway... 21 | # 2.0.0 (2023-09-09) 22 | ## New features 23 | * New modems: AFSK Bell 103 (300 Bd, 1600/1800 Hz), GFSK G3RUH (9600 Bd), AFSK V.23 (1200 Bd, 1300/2100 Hz) 24 | * FX.25 (AX.25 with Reed-Solomon FEC) support 25 | * Default UART/USB modes can be configured 26 | ## Bug fixes 27 | * none 28 | ## Other 29 | * New signal level measurement method 30 | * Got rid of float operations for PLL adjustment 31 | * Full documentation (English and Polish) in Markdown 32 | * Project moved to STM32CubeIDE 33 | * Updated HAL version used for USB 34 | ## Known bugs 35 | * none 36 | # 1.3.3 (2023-09-04) 37 | ## New features 38 | * none 39 | ## Bug fixes 40 | * RX buffer pointers bug fix 41 | * AX.25 to TNC2 converter bug with non-UI frames 42 | ## Other 43 | * New KISS handling method to support long and multiple frames 44 | ## Known bugs 45 | * none 46 | # 1.3.2 (2023-08-31) 47 | ## New features 48 | * none 49 | ## Bug fixes 50 | * Duplicate protection was not working properly 51 | ## Other 52 | * none 53 | ## Known bugs 54 | * none 55 | # 1.3.1 (2023-08-30) 56 | ## New features 57 | * none 58 | ## Bug fixes 59 | * Non-APRS switch was not stored in memory 60 | ## Other 61 | * PWM is now the default option 62 | ## Known bugs 63 | * none 64 | # 1.3.0 (2023-08-30) 65 | ## New features 66 | * Callsign is now set together with SSID using ```call ``` 67 | * ```time``` command to show uptime 68 | ## Removed features 69 | * ```ssid``` command is removed 70 | * Auto-reset functionality and ```autoreset``` command is removed 71 | ## Bug fixes 72 | * When beacon *n* delay hadn't passed yet, beacon *n+1*, *n+2*, ... were not sent regardless of their delay 73 | * Bugs with line ending parsing 74 | ## Other 75 | * Major code refactoring and rewrite 76 | * Got rid of *uart_transmitStart()* routine 77 | * USB sending is handled the same way as UART 78 | * New way of TX and RX frame handling to improve non-APRS compatibility 79 | * Much bigger frame buffer 80 | * Minimized number of temporary buffers 81 | * All *malloc()*s removed 82 | * Added copyright notice as required by GNU GPL 83 | ## Known bugs 84 | * none 85 | # 1.2.6 (2023-07-29) 86 | ## New features 87 | * Added ```nonaprs [on/off]``` command that enables reception of non-APRS frames, e.g. for full Packet Radio use 88 | ## Bug fixes 89 | * Beacons not being send fixed 90 | ## Other 91 | * none 92 | ## Known bugs 93 | * none 94 | # 1.2.5 (2022-11-05) 95 | ## New features 96 | * Added ```dest
``` command that enables setting own destination address 97 | ## Bug fixes 98 | * none 99 | ## Other 100 | * PWM defaulting to 50% 101 | ## Known bugs 102 | * none 103 | # 1.2.4 (2022-08-30) 104 | ## New features 105 | * Added ```monkiss [on/off]``` command that enables sending own and digipeated frames to KISS ports 106 | ## Bug fixes 107 | * included .cproject so that the project can be imported and compiled in SW4STM32 without generating in CubeMX 108 | ## Other 109 | * none 110 | ## Known bugs 111 | * none 112 | # 1.2.3 (2022-08-23) 113 | ## New features 114 | * none 115 | ## Bug fixes 116 | * KISS TX (UART and USB) buffer overrun, minor changes 117 | ## Other 118 | * none 119 | ## Known bugs 120 | * none 121 | # 1.2.2 (2022-06-11) 122 | ## New features 123 | * none 124 | ## Bug fixes 125 | * Default de-dupe time was 0, backspace was sometimes stored in config, frame length was not checked in viscous delay mode 126 | ## Other 127 | * none 128 | ## Known bugs 129 | * USB in KISS mode has problem with TX frames 130 | # 1.2.1 (2021-10-13) 131 | ## New features 132 | * none 133 | ## Bug fixes 134 | * Digi max and rep values could not be entered when only LF line ending was used. 135 | ## Other 136 | * none 137 | ## Known bugs 138 | * none 139 | # 1.2.0 (2021-09-10) 140 | This is the very first open-source VP-Digi release. 141 | ## New features 142 | * Viscous-delay and direct-only modes are enabled separately for each digipeater alias: ```digi <0-7> viscous [on/off]``` and ``` digi <0-7> direct [on/off] ```. 143 | **When updating from version <1.2.0 please erase configuration or set new settings carefully.** 144 | * Selectable signal input type: normal (filtered) audio or flat (unfiltered) audio: ```flat [on/off]``` - switches modem settings - before v. 1.2.0 was hardcoded for normal audio 145 | * Erase all settings command: ```eraseall``` 146 | ## Bug fixes 147 | * none 148 | ## Other 149 | * Code was partially rewritten (especially digipeater, modem and AX.25 layer) 150 | ## Known bugs 151 | * none -------------------------------------------------------------------------------- /Core/Inc/ax25.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020-2023 Piotr Wilkon 3 | 4 | This file is part of VP-Digi. 5 | 6 | VP-Digi is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | VP-Digi is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with VP-Digi. If not, see . 18 | */ 19 | 20 | #ifndef AX25_H_ 21 | #define AX25_H_ 22 | 23 | #include 24 | #include 25 | 26 | #define AX25_NOT_FX25 255 27 | 28 | //for AX.25 329 bytes is the theoretical max size assuming 2-byte Control, 1-byte PID, 256-byte info field and 8 digi address fields 29 | #define AX25_FRAME_MAX_SIZE (329) //single frame max length 30 | 31 | enum Ax25RxStage 32 | { 33 | RX_STAGE_IDLE = 0, 34 | RX_STAGE_FLAG, 35 | RX_STAGE_FRAME, 36 | #ifdef ENABLE_FX25 37 | RX_STAGE_FX25_FRAME, 38 | #endif 39 | }; 40 | 41 | struct Ax25ProtoConfig 42 | { 43 | uint16_t txDelayLength; //TXDelay length in ms 44 | uint16_t txTailLength; //TXTail length in ms 45 | uint16_t quietTime; //Quiet time in ms 46 | uint8_t allowNonAprs : 1; //allow non-APRS packets 47 | uint8_t fx25 : 1; //enable FX.25 (AX.25 + FEC) 48 | uint8_t fx25Tx : 1; //enable TX in FX.25 49 | }; 50 | 51 | extern struct Ax25ProtoConfig Ax25Config; 52 | 53 | 54 | /** 55 | * @brief Write frame to transmit buffer 56 | * @param *data Data to transmit 57 | * @param size Data size 58 | * @return Pointer to internal frame handle or NULL on failure 59 | * @attention This function will block if transmission is already in progress 60 | */ 61 | void *Ax25WriteTxFrame(uint8_t *data, uint16_t size); 62 | 63 | /** 64 | * @brief Get bitmap of "frame received" flags for each decoder. A non-zero value means that a frame was received 65 | * @return Bitmap of decoder that received the frame 66 | */ 67 | uint8_t Ax25GetReceivedFrameBitmap(void); 68 | 69 | /** 70 | * @brief Clear bitmap of "frame received" flags 71 | */ 72 | void Ax25ClearReceivedFrameBitmap(void); 73 | 74 | /** 75 | * @brief Get next received frame (if available) 76 | * @param **dst Pointer to internal buffer 77 | * @param *size Actual frame size 78 | * @param *peak Signak positive peak value in % 79 | * @param *valley Signal negative peak value in % 80 | * @param *level Signal level in % 81 | * @param *corrected Number of bytes corrected in FX.25 mode. 255 is returned if not a FX.25 packet. 82 | * @return True if frame was read, false if no more frames to read 83 | */ 84 | bool Ax25ReadNextRxFrame(uint8_t **dst, uint16_t *size, int8_t *peak, int8_t *valley, uint8_t *level, uint8_t *corrected); 85 | 86 | /** 87 | * @brief Get current RX stage 88 | * @param[in] modemNo Modem/decoder number (0 or 1) 89 | * @return RX_STATE_IDLE, RX_STATE_FLAG or RX_STATE_FRAME 90 | * @warning Only for internal use 91 | */ 92 | enum Ax25RxStage Ax25GetRxStage(uint8_t modemNo); 93 | 94 | /** 95 | * @brief Parse incoming bit (not symbol!) 96 | * @details Handles bit-stuffing, header and CRC checking, stores received frame and sets "frame received flag", multiplexes both decoders 97 | * @param[in] bit Incoming bit 98 | * @param[in] *dem Modem state pointer 99 | * @warning Only for internal use 100 | */ 101 | void Ax25BitParse(uint8_t bit, uint8_t modemNo); 102 | 103 | /** 104 | * @brief Get next bit to be transmitted 105 | * @return Bit to be transmitted 106 | * @warning Only for internal use 107 | */ 108 | uint8_t Ax25GetTxBit(void); 109 | 110 | /** 111 | * @brief Initialize transmission and start when possible 112 | */ 113 | void Ax25TransmitBuffer(void); 114 | 115 | /** 116 | * @brief Start transmitting when possible 117 | * @attention Must be continuously polled in main loop 118 | */ 119 | void Ax25TransmitCheck(void); 120 | 121 | /** 122 | * @brief Initialize AX25 module 123 | */ 124 | void Ax25Init(void); 125 | 126 | #endif /* AX25_H_ */ 127 | -------------------------------------------------------------------------------- /Core/Inc/beacon.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020-2023 Piotr Wilkon 3 | 4 | This file is part of VP-Digi. 5 | 6 | VP-Digi is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | VP-Digi is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with VP-Digi. If not, see . 18 | */ 19 | 20 | #ifndef BEACON_H_ 21 | #define BEACON_H_ 22 | 23 | 24 | #include 25 | 26 | #define BEACON_MAX_PAYLOAD_SIZE 100 27 | 28 | struct Beacon 29 | { 30 | uint8_t enable; //enable beacon 31 | uint32_t interval; //interval in seconds 32 | uint32_t delay; //delay in seconds 33 | uint8_t data[BEACON_MAX_PAYLOAD_SIZE + 1]; //information field 34 | uint8_t path[15]; //path, 2 parts max, e.g. WIDE11SP22, can be at byte 0, 7 and 14 35 | uint32_t next; //next beacon timestamp 36 | }; 37 | 38 | extern struct Beacon beacon[8]; 39 | 40 | /** 41 | * @brief Send specified beacon 42 | * @param number Beacon number (0-7) 43 | */ 44 | void BeaconSend(uint8_t number); 45 | 46 | 47 | /** 48 | * @brief Check if any beacon should be transmitted and transmit if necessary 49 | */ 50 | void BeaconCheck(void); 51 | 52 | /** 53 | * @brief Initialize beacon module 54 | */ 55 | void BeaconInit(void); 56 | 57 | #endif /* BEACON_H_ */ 58 | -------------------------------------------------------------------------------- /Core/Inc/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020-2023 Piotr Wilkon 3 | 4 | This file is part of VP-Digi. 5 | 6 | VP-Digi is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | VP-Digi is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with VP-Digi. If not, see . 18 | */ 19 | 20 | #ifndef COMMON_H_ 21 | #define COMMON_H_ 22 | 23 | #include 24 | #include "uart.h" 25 | 26 | #define IS_UPPERCASE_ALPHANUMERIC(x) ((((x) >= '0') && ((x) <= '9')) || (((x) >= 'A') && ((x) <= 'Z'))) 27 | #define IS_NUMBER(x) (((x) >= '0') && ((x) <= '9')) 28 | #define ABS(x) (((x) > 0) ? (x) : (-x)) 29 | 30 | #define CRC32_INIT 0xFFFFFFFF 31 | 32 | struct _GeneralConfig 33 | { 34 | uint8_t call[6]; //device callsign 35 | uint8_t callSsid; //device ssid 36 | uint8_t dest[7]; //destination address for own beacons. Should be APNV01-0 for VP-Digi, but can be changed. SSID MUST remain 0. 37 | uint8_t kissMonitor; 38 | }; 39 | 40 | extern struct _GeneralConfig GeneralConfig; 41 | 42 | extern const char versionString[]; //version string 43 | 44 | 45 | /** 46 | * @brief Generate random number from min to max 47 | * @param[in] min Lower boundary 48 | * @param[in] max Higher boundary 49 | * @return Generated number 50 | */ 51 | int16_t Random(int16_t min, int16_t max); 52 | 53 | /** 54 | * @brief Convert string to int 55 | * @param[in] *str Input string 56 | * @param[in] len String length or 0 to detect by strlen() 57 | * @return Converted int 58 | */ 59 | int64_t StrToInt(const char *str, uint16_t len); 60 | 61 | ///** 62 | // * @brief Convert AX25 frame to TNC2 (readable) format 63 | // * @param *from Input AX25 frame 64 | // * @param len Input frame length 65 | // * @param *to Destination buffer, will be NULL terminated 66 | // * @param limit Destination buffer size limit 67 | // */ 68 | //void ConvertToTNC2(uint8_t *from, uint16_t fromlen, uint8_t *to, uint16_t limit); 69 | 70 | /** 71 | * @brief Convert AX25 frame to TNC2 (readable) format and send it through available ports 72 | * @param *from Input AX25 frame 73 | * @param len Input frame length 74 | */ 75 | void SendTNC2(uint8_t *from, uint16_t len); 76 | 77 | /** 78 | * @brief Calculate CRC32 79 | * @param[in] crc0 Initial or current CRC value 80 | * @param[in] *s Input data 81 | * @param[in] n Input data length 82 | * @return Calculated CRC32 83 | */ 84 | uint32_t Crc32(uint32_t crc0, uint8_t *s, uint64_t n); 85 | 86 | /** 87 | * @brief Check if callsign is correct and convert it to AX.25 format 88 | * @param *in Input ASCII callsign 89 | * @param size Input size, not bigger than 6 90 | * @param *out Output buffer, exactly 6 bytes 91 | * @return True if callsign is valid 92 | */ 93 | bool ParseCallsign(const char *in, uint16_t size, uint8_t *out); 94 | 95 | /** 96 | * @brief Check if callsign with SSID is correct and convert it to AX.25 format 97 | * @param *in Input ASCII callsign with SSID 98 | * @param size Input size 99 | * @param *out Output buffer, exactly 6 bytes 100 | * @param *ssid Output SSID, exactly 1 byte 101 | * @return True if callsign is valid 102 | */ 103 | bool ParseCallsignWithSsid(const char *in, uint16_t size, uint8_t *out, uint8_t *ssid); 104 | 105 | /** 106 | * @brief Check if SSID is correct and convert it to uint8_t 107 | * @param *in Input ASCII SSID 108 | * @param size Input size 109 | * @param *out Output buffer, exactly 1 byte 110 | * @return True if SSID is valid 111 | */ 112 | bool ParseSsid(const char *in, uint16_t size, uint8_t *out); 113 | 114 | #endif /* COMMON_H_ */ 115 | -------------------------------------------------------------------------------- /Core/Inc/config.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020-2023 Piotr Wilkon 3 | 4 | This file is part of VP-Digi. 5 | 6 | VP-Digi is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | VP-Digi is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with VP-Digi. If not, see . 18 | */ 19 | 20 | #ifndef CONFIG_H_ 21 | #define CONFIG_H_ 22 | 23 | 24 | #include 25 | 26 | 27 | 28 | /** 29 | * @brief Store configuration from RAM to Flash 30 | */ 31 | void ConfigWrite(void); 32 | 33 | /** 34 | * @brief Erase all configuration 35 | */ 36 | void ConfigErase(void); 37 | 38 | /** 39 | * @brief Read configuration from Flash to RAM 40 | * @return 1 if success, 0 if no configuration stored in Flash 41 | */ 42 | uint8_t ConfigRead(void); 43 | 44 | #endif /* CONFIG_H_ */ 45 | -------------------------------------------------------------------------------- /Core/Inc/digipeater.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020-2025 Piotr Wilkon 3 | 4 | This file is part of VP-Digi. 5 | 6 | VP-Digi is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | VP-Digi is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with VP-Digi. If not, see . 18 | */ 19 | 20 | #ifndef DIGIPEATER_H_ 21 | #define DIGIPEATER_H_ 22 | 23 | #include 24 | 25 | 26 | struct _DigiConfig 27 | { 28 | uint8_t alias[8][6]; //digi alias list 29 | uint8_t ssid[4]; //ssid list for simple aliases 30 | uint8_t max[4]; //max n to digipeat 31 | uint8_t rep[4]; //min n to replace 32 | uint8_t traced; //tracing for each alias, 0 - untraced, 1 - traced 33 | uint8_t enableAlias; //enabling each alias, 0 - disabled, 1 - enabled 34 | uint8_t enable : 1; //enable whole digi 35 | uint8_t viscous; //visous-delay enable for each alias 36 | uint8_t directOnly; //direct-only enable for each alias 37 | uint8_t dupeTime; //duplicate filtering time in seconds 38 | uint8_t callFilter[20][7]; //callsign filter array 39 | uint8_t callFilterEnable; //enable filter by call for every alias 40 | uint8_t filterPolarity : 1; //filter polarity: 0 - blacklist, 1- whitelist 41 | }; 42 | 43 | extern struct _DigiConfig DigiConfig; //digipeater state 44 | 45 | 46 | /** 47 | * @brief Digipeater entry point 48 | * @param[in] *frame Pointer to frame buffer 49 | * @param[in] len Frame length 50 | * Decides whether the frame should be digipeated or not, processes it and pushes to TX buffer if needed 51 | */ 52 | void DigiDigipeat(uint8_t *frame, uint16_t len); 53 | 54 | /** 55 | * @brief Store duplicate protection hash for frame 56 | * @param *buf Frame buffer 57 | * @param size Frame size 58 | */ 59 | void DigiStoreDeDupe(uint8_t *buf, uint16_t size); 60 | 61 | /** 62 | * @brief Initialize digipeater 63 | */ 64 | void DigiInitialize(void); 65 | 66 | /** 67 | * @brief Update internal digipeater state 68 | * @attention Should be called in main loop 69 | */ 70 | void DigiUpdateState(void); 71 | 72 | #endif /* DIGIPEATER_H_ */ 73 | -------------------------------------------------------------------------------- /Core/Inc/drivers/digipeater_ll.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020-2025 Piotr Wilkon 3 | This file is part of VP-Digi. 4 | 5 | VP-Digi is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | VP-Digi is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with VP-Digi. If not, see . 17 | */ 18 | 19 | /* 20 | * This file is kind of HAL for digipeater external controls and signalization 21 | */ 22 | 23 | #ifndef DRIVERS_DIGIPEATER_LL_H_ 24 | #define DRIVERS_DIGIPEATER_LL_H_ 25 | 26 | #include 27 | 28 | #if defined(STM32F103xB) || defined(STM32F103x8) 29 | 30 | #include "stm32f1xx.h" 31 | 32 | #define DIGIPEATER_LL_LED_ON() (GPIOB->BSRR = GPIO_BSRR_BS1) 33 | #define DIGIPEATER_LL_LED_OFF() (GPIOB->BSRR = GPIO_BSRR_BR1) 34 | 35 | /** 36 | * @brief Get external digipeater disable state 37 | * @return True if disabled, false if enabled 38 | */ 39 | #define DIGIPEATER_LL_GET_DISABLE_STATE() (!(GPIOB->IDR & GPIO_IDR_IDR0)) 40 | 41 | #define DIGIPEATER_LL_INITIALIZE_RCC() do { \ 42 | RCC->APB2ENR |= RCC_APB2ENR_IOPBEN; \ 43 | } while(0); \ 44 | 45 | #define DIGIPEATER_LL_INITIALIZE_INPUTS_OUTPUTS() do { \ 46 | /* Digi disable input: PB0 (active low - pull up); digi active output: PB1 (active high) */ \ 47 | /* Digi disable input: PB0 */ \ 48 | GPIOB->CRL &= ~GPIO_CRL_MODE0; \ 49 | GPIOB->CRL &= ~GPIO_CRL_CNF0_0; \ 50 | GPIOB->CRL |= GPIO_CRL_CNF0_1; \ 51 | GPIOB->BSRR = GPIO_BSRR_BS0; \ 52 | /* Digi active LED: PB1 */ \ 53 | GPIOB->CRL |= GPIO_CRL_MODE1_1; \ 54 | GPIOB->CRL &= ~GPIO_CRL_MODE1_0; \ 55 | GPIOB->CRL &= ~GPIO_CRL_CNF1; \ 56 | } while(0); \ 57 | 58 | 59 | 60 | #endif 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /Core/Inc/drivers/modem_ll.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020-2025 Piotr Wilkon 3 | This file is part of VP-Digi. 4 | 5 | VP-Digi is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | VP-Digi is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with VP-Digi. If not, see . 17 | */ 18 | 19 | /* 20 | * This file is kind of HAL for modem 21 | */ 22 | 23 | #ifndef DRIVERS_MODEM_LL_H_ 24 | #define DRIVERS_MODEM_LL_H_ 25 | 26 | #include 27 | 28 | //Oversampling factor 29 | //This is a helper value, not a setting that can be changed without further code modification! 30 | #define MODEM_LL_OVERSAMPLING_FACTOR 4 31 | 32 | #if defined(STM32F103xB) || defined(STM32F103x8) 33 | 34 | #include "stm32f1xx.h" 35 | 36 | /** 37 | * TIM1 is used for pushing samples to DAC (R2R or PWM) (clocked at 18 MHz) 38 | * TIM3 is the baudrate generator for TX (clocked at 18 MHz) 39 | * TIM4 is the PWM generator with no software interrupt 40 | * TIM2 is the RX sampling timer with no software interrupt, but it directly calls DMA 41 | */ 42 | 43 | #define MODEM_LL_DMA_INTERRUPT_HANDLER DMA1_Channel2_IRQHandler 44 | #define MODEM_LL_DAC_INTERRUPT_HANDLER TIM1_UP_IRQHandler 45 | #define MODEM_LL_BAUDRATE_TIMER_INTERRUPT_HANDLER TIM3_IRQHandler 46 | 47 | #define MODEM_LL_DMA_IRQ DMA1_Channel2_IRQn 48 | #define MODEM_LL_DAC_IRQ TIM1_UP_IRQn 49 | #define MODEM_LL_BAUDRATE_TIMER_IRQ TIM3_IRQn 50 | 51 | #define MODEM_LL_DMA_TRANSFER_COMPLETE_FLAG (DMA1->ISR & DMA_ISR_TCIF2) 52 | #define MODEM_LL_DMA_CLEAR_TRANSFER_COMPLETE_FLAG() (DMA1->IFCR |= DMA_IFCR_CTCIF2) 53 | 54 | #define MODEM_LL_BAUDRATE_TIMER_CLEAR_INTERRUPT_FLAG() (TIM3->SR &= ~TIM_SR_UIF) 55 | #define MODEM_LL_BAUDRATE_TIMER_ENABLE() (TIM3->CR1 = TIM_CR1_CEN) 56 | #define MODEM_LL_BAUDRATE_TIMER_DISABLE() (TIM3->CR1 &= ~TIM_CR1_CEN) 57 | #define MODEM_LL_BAUDRATE_TIMER_SET_RELOAD_VALUE(val) (TIM3->ARR = (val)) 58 | 59 | #define MODEM_LL_DAC_TIMER_CLEAR_INTERRUPT_FLAG (TIM1->SR &= ~TIM_SR_UIF) 60 | #define MODEM_LL_DAC_TIMER_SET_RELOAD_VALUE(val) (TIM1->ARR = (val)) 61 | #define MODEM_LL_DAC_TIMER_SET_CURRENT_VALUE(val) (TIM1->CNT = (val)) 62 | #define MODEM_LL_DAC_TIMER_ENABLE() (TIM1->CR1 |= TIM_CR1_CEN) 63 | #define MODEM_LL_DAC_TIMER_DISABLE() (TIM1->CR1 &= ~TIM_CR1_CEN) 64 | 65 | #define MODEM_LL_ADC_TIMER_ENABLE() (TIM2->CR1 |= TIM_CR1_CEN) 66 | #define MODEM_LL_ADC_TIMER_DISABLE() (TIM2->CR1 &= ~TIM_CR1_CEN) 67 | 68 | #define MODEM_LL_PWM_PUT_VALUE(value) (TIM4->CCR1 = (value)) 69 | 70 | #define MODEM_LL_R2R_PUT_VALUE(value) do {GPIOB->ODR &= ~0xF000; \ 71 | GPIOB->ODR |= ((uint32_t)(value) << 12); } while(0); \ 72 | 73 | 74 | #define MODEM_LL_DCD_LED_ON() do { \ 75 | GPIOC->BSRR = GPIO_BSRR_BR13; \ 76 | GPIOB->BSRR = GPIO_BSRR_BS5; \ 77 | } while(0); \ 78 | 79 | #define MODEM_LL_DCD_LED_OFF() do { \ 80 | GPIOC->BSRR = GPIO_BSRR_BS13; \ 81 | GPIOB->BSRR = GPIO_BSRR_BR5; \ 82 | } while(0); \ 83 | 84 | #define MODEM_LL_PTT_ON() (GPIOB->BSRR = GPIO_BSRR_BS7) 85 | #define MODEM_LL_PTT_OFF() (GPIOB->BSRR = GPIO_BSRR_BR7) 86 | 87 | #define MODEM_LL_INITIALIZE_RCC() do { \ 88 | RCC->APB2ENR |= RCC_APB2ENR_IOPBEN; \ 89 | RCC->APB2ENR |= RCC_APB2ENR_IOPCEN; \ 90 | RCC->APB2ENR |= RCC_APB2ENR_IOPAEN; \ 91 | RCC->APB1ENR |= RCC_APB1ENR_TIM2EN; \ 92 | RCC->APB1ENR |= RCC_APB1ENR_TIM3EN; \ 93 | RCC->APB2ENR |= RCC_APB2ENR_TIM1EN; \ 94 | RCC->APB2ENR |= RCC_APB2ENR_ADC1EN; \ 95 | RCC->AHBENR |= RCC_AHBENR_DMA1EN; \ 96 | RCC->APB1ENR |= RCC_APB1ENR_TIM4EN; \ 97 | } while(0); \ 98 | 99 | #define MODEM_LL_INITIALIZE_OUTPUTS() do { \ 100 | /* DCD LEDs: PC13 (cathode driven - built-in LED on Blue Pill) and PB5 (anode driven) */ \ 101 | GPIOC->CRH |= GPIO_CRH_MODE13_1; \ 102 | GPIOC->CRH &= ~GPIO_CRH_MODE13_0; \ 103 | GPIOC->CRH &= ~GPIO_CRH_CNF13; \ 104 | GPIOB->CRL |= GPIO_CRL_MODE5_1; \ 105 | GPIOB->CRL &= ~GPIO_CRL_MODE5_0; \ 106 | GPIOB->CRL &= ~GPIO_CRL_CNF5; \ 107 | /* PTT: PB7 */ \ 108 | GPIOB->CRL |= GPIO_CRL_MODE7_1; \ 109 | GPIOB->CRL &= ~GPIO_CRL_MODE7_0; \ 110 | GPIOB->CRL &= ~GPIO_CRL_CNF7; \ 111 | /* R2R: 4 bits, PB12-PB15 */ \ 112 | GPIOB->CRH &= ~0xFFFF0000; \ 113 | GPIOB->CRH |= 0x22220000; \ 114 | /* PWM output: PB6 */ \ 115 | GPIOB->CRL |= GPIO_CRL_CNF6_1; \ 116 | GPIOB->CRL |= GPIO_CRL_MODE6; \ 117 | GPIOB->CRL &= ~GPIO_CRL_CNF6_0; \ 118 | } while(0); \ 119 | 120 | #define MODEM_LL_INITIALIZE_ADC() do { \ 121 | /* ADC input: PA0 */ \ 122 | GPIOA->CRL &= ~GPIO_CRL_CNF0; \ 123 | GPIOA->CRL &= ~GPIO_CRL_MODE0; \ 124 | /*/6 prescaler */ \ 125 | RCC->CFGR |= RCC_CFGR_ADCPRE_1; \ 126 | RCC->CFGR &= ~RCC_CFGR_ADCPRE_0; \ 127 | ADC1->CR2 |= ADC_CR2_CONT; \ 128 | ADC1->CR2 |= ADC_CR2_EXTSEL; \ 129 | ADC1->SQR1 &= ~ADC_SQR1_L; \ 130 | /* 41.5 cycle sampling */ \ 131 | ADC1->SMPR2 |= ADC_SMPR2_SMP0_2; \ 132 | ADC1->SQR3 &= ~ADC_SQR3_SQ1; \ 133 | ADC1->CR2 |= ADC_CR2_ADON; \ 134 | /* calibrate */ \ 135 | ADC1->CR2 |= ADC_CR2_RSTCAL; \ 136 | while(ADC1->CR2 & ADC_CR2_RSTCAL) \ 137 | ; \ 138 | ADC1->CR2 |= ADC_CR2_CAL; \ 139 | while(ADC1->CR2 & ADC_CR2_CAL) \ 140 | ; \ 141 | ADC1->CR2 |= ADC_CR2_EXTTRIG; \ 142 | ADC1->CR2 |= ADC_CR2_SWSTART; \ 143 | } while(0); \ 144 | 145 | #define MODEM_LL_INITIALIZE_DMA(buffer) do { \ 146 | /* 16 bit memory region */ \ 147 | DMA1_Channel2->CCR |= DMA_CCR_MSIZE_0; \ 148 | DMA1_Channel2->CCR &= ~DMA_CCR_MSIZE_1; \ 149 | DMA1_Channel2->CCR |= DMA_CCR_PSIZE_0; \ 150 | DMA1_Channel2->CCR &= ~DMA_CCR_PSIZE_1; \ 151 | /* enable memory pointer increment, circular mode and interrupt generation */ \ 152 | DMA1_Channel2->CCR |= DMA_CCR_MINC | DMA_CCR_CIRC| DMA_CCR_TCIE; \ 153 | DMA1_Channel2->CNDTR = MODEM_LL_OVERSAMPLING_FACTOR; \ 154 | DMA1_Channel2->CPAR = (uintptr_t)&(ADC1->DR); \ 155 | DMA1_Channel2->CMAR = (uintptr_t)buffer; \ 156 | DMA1_Channel2->CCR |= DMA_CCR_EN; \ 157 | } while(0); \ 158 | 159 | #define MODEM_LL_ADC_TIMER_INITIALIZE() do { \ 160 | /* 72 / 9 = 8 MHz */ \ 161 | TIM2->PSC = 8; \ 162 | /* enable DMA call instead of standard interrupt */ \ 163 | TIM2->DIER |= TIM_DIER_UDE; \ 164 | } while(0); \ 165 | 166 | #define MODEM_LL_DAC_TIMER_INITIALIZE() do { \ 167 | /* 72 / 4 = 18 MHz */ \ 168 | TIM1->PSC = 3; \ 169 | TIM1->DIER |= TIM_DIER_UIE; \ 170 | } while(0); \ 171 | 172 | #define MODEM_LL_BAUDRATE_TIMER_INITIALIZE() do { \ 173 | /* 72 / 4 = 18 MHz */ \ 174 | TIM3->PSC = 3; \ 175 | TIM3->DIER |= TIM_DIER_UIE; \ 176 | } while(0); \ 177 | 178 | #define MODEM_LL_PWM_INITIALIZE() do { \ 179 | /* 72 / 3 = 24 MHz to provide 8 bit resolution at around 100 kHz */ \ 180 | TIM4->PSC = 2; \ 181 | /* 24 MHz / 258 = 93 kHz */ \ 182 | TIM4->ARR = 257; \ 183 | TIM4->CCMR1 |= TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_2; \ 184 | TIM4->CCER |= TIM_CCER_CC1E; \ 185 | TIM4->CR1 |= TIM_CR1_CEN; \ 186 | } while(0); \ 187 | 188 | #define MODEM_LL_ADC_SET_SAMPLE_RATE(rate) (TIM2->ARR = (8000000 / (rate)) - 1) 189 | 190 | #define MODEM_LL_DAC_TIMER_CALCULATE_STEP(frequency) ((18000000 / (frequency)) - 1) 191 | 192 | #define MODEM_LL_BAUDRATE_TIMER_CALCULATE_STEP(frequency) ((18000000 / (frequency)) - 1) 193 | 194 | #endif 195 | 196 | #endif /* DRIVERS_MODEM_LL_H_ */ 197 | -------------------------------------------------------------------------------- /Core/Inc/drivers/uart_ll.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020-2025 Piotr Wilkon 3 | This file is part of VP-Digi. 4 | 5 | VP-Digi is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | VP-Digi is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with VP-Digi. If not, see . 17 | */ 18 | 19 | /* 20 | * This file is kind of HAL for UART 21 | */ 22 | 23 | #ifndef DRIVERS_UART_LL_H_ 24 | #define DRIVERS_UART_LL_H_ 25 | 26 | #if defined(STM32F103xB) || defined(STM32F103x8) 27 | 28 | #include "stm32f1xx.h" 29 | 30 | #define UART_LL_ENABLE(port) (port->CR1 |= USART_CR1_RXNEIE | USART_CR1_TE | USART_CR1_RE | USART_CR1_UE | USART_CR1_IDLEIE) 31 | #define UART_LL_DISABLE(port) (port->CR1 &= (~USART_CR1_RXNEIE) & (~USART_CR1_TE) & (~USART_CR1_RE) & (~USART_CR1_UE) & (~USART_CR1_IDLEIE)) 32 | 33 | #define UART_LL_CHECK_RX_NOT_EMPTY(port) (port->SR & USART_SR_RXNE) 34 | #define UART_LL_CLEAR_RX_NOT_EMPTY(port) (port->SR &= ~USART_SR_RXNE) 35 | 36 | #define UART_LL_CHECK_TX_EMPTY(port) (port->SR & USART_SR_TXE) 37 | #define UART_LL_ENABLE_TX_EMPTY_INTERRUPT(port) (port->CR1 |= USART_CR1_TXEIE) 38 | #define UART_LL_DISABLE_TX_EMPTY_INTERRUPT(port) (port->CR1 &= ~USART_CR1_TXEIE) 39 | #define UART_LL_CHECK_ENABLED_TX_EMPTY_INTERRUPT(port) (port->CR1 & USART_CR1_TXEIE) 40 | 41 | 42 | #define UART_LL_CHECK_RX_IDLE(port) (port->SR & USART_SR_IDLE) 43 | 44 | #define UART_LL_GET_DATA(port) (port->DR) 45 | #define UART_LL_PUT_DATA(port, data) (port->DR = (data)) 46 | 47 | 48 | #define UART_LL_UART1_INTERUPT_HANDLER USART1_IRQHandler 49 | #define UART_LL_UART2_INTERUPT_HANDLER USART2_IRQHandler 50 | 51 | #define UART_LL_UART1_STRUCTURE USART1 52 | #define UART_LL_UART2_STRUCTURE USART2 53 | 54 | #define UART_LL_UART1_IRQ USART1_IRQn 55 | #define UART_LL_UART2_IRQ USART2_IRQn 56 | 57 | #define UART_LL_UART1_INITIALIZE_PERIPHERAL(baudrate) do { \ 58 | RCC->APB2ENR |= RCC_APB2ENR_IOPAEN; \ 59 | RCC->APB2ENR |= RCC_APB2ENR_USART1EN; \ 60 | GPIOA->CRH |= GPIO_CRH_MODE9_1; \ 61 | GPIOA->CRH &= ~GPIO_CRH_CNF9_0; \ 62 | GPIOA->CRH |= GPIO_CRH_CNF9_1; \ 63 | GPIOA->CRH |= GPIO_CRH_CNF10_0; \ 64 | GPIOA->CRH &= ~GPIO_CRH_CNF10_1; \ 65 | UART_LL_UART1_STRUCTURE->BRR = (SystemCoreClock / baudrate); \ 66 | } while(0); \ 67 | 68 | #define UART_LL_UART2_INITIALIZE_PERIPHERAL(baudrate) do { \ 69 | RCC->APB2ENR |= RCC_APB2ENR_IOPAEN; \ 70 | RCC->APB1ENR |= RCC_APB1ENR_USART2EN; \ 71 | GPIOA->CRL |= GPIO_CRL_MODE2_1; \ 72 | GPIOA->CRL &= ~GPIO_CRL_CNF2_0; \ 73 | GPIOA->CRL |= GPIO_CRL_CNF2_1; \ 74 | GPIOA->CRL |= GPIO_CRL_CNF3_0; \ 75 | GPIOA->CRL &= ~GPIO_CRL_CNF3_1; \ 76 | UART_LL_UART2_STRUCTURE->BRR = (SystemCoreClock / (baudrate * 2)); \ 77 | } while(0); \ 78 | 79 | #endif 80 | 81 | #endif /* INC_DRIVERS_UART_LL_H_ */ 82 | -------------------------------------------------------------------------------- /Core/Inc/drivers/usb.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020-2025 Piotr Wilkon 3 | 4 | This file is part of VP-Digi. 5 | 6 | VP-Digi is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | VP-Digi is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with VP-Digi. If not, see . 18 | */ 19 | 20 | 21 | #ifndef DRIVERS_USB_H_ 22 | #define DRIVERS_USB_H_ 23 | 24 | #include "systick.h" 25 | 26 | #if defined(STM32F103xB) || defined(STM32F103x8) 27 | 28 | #include "stm32f1xx.h" 29 | 30 | #define USB_FORCE_REENUMERATION() do { \ 31 | /* Pull D+ to ground for a moment to force reenumeration */ \ 32 | RCC->APB2ENR |= RCC_APB2ENR_IOPAEN; \ 33 | GPIOA->CRH |= GPIO_CRH_MODE12_1; \ 34 | GPIOA->CRH &= ~GPIO_CRH_CNF12; \ 35 | GPIOA->BSRR = GPIO_BSRR_BR12; \ 36 | Delay(100); \ 37 | GPIOA->CRH &= ~GPIO_CRH_MODE12; \ 38 | GPIOA->CRH |= GPIO_CRH_CNF12_0; \ 39 | } while(0); \ 40 | 41 | #endif 42 | 43 | #endif /* DRIVERS_USB_H_ */ 44 | -------------------------------------------------------------------------------- /Core/Inc/drivers/watchdog.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020-2023 Piotr Wilkon 3 | 4 | This file is part of VP-Digi. 5 | 6 | VP-Digi is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | VP-Digi is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with VP-Digi. If not, see . 18 | */ 19 | 20 | #ifndef DRIVERS_WATCHDOG_H_ 21 | #define DRIVERS_WATCHDOG_H_ 22 | 23 | #if defined(STM32F103xB) || defined(STM32F103x8) 24 | 25 | /** 26 | * @brief Initialize watchdog 27 | */ 28 | void WdogInit(void) 29 | { 30 | IWDG->KR = 0x5555; //configuration mode 31 | IWDG->PR = 0b101; //prescaler 32 | IWDG->RLR = 0xFFF; //timeout register 33 | IWDG->KR = 0xCCCC; //start 34 | } 35 | 36 | /** 37 | * @brief Restart watchdog 38 | * @attention Must be called continuously in main loop 39 | */ 40 | void WdogReset(void) 41 | { 42 | IWDG->KR = 0xAAAA; //reset 43 | } 44 | 45 | #endif 46 | 47 | #endif /* DRIVERS_WATCHDOG_H_ */ 48 | -------------------------------------------------------------------------------- /Core/Inc/fx25.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020-2023 Piotr Wilkon 3 | 4 | This file is part of VP-Digi. 5 | 6 | VP-Digi is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | VP-Digi is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with VP-Digi. If not, see . 18 | */ 19 | 20 | #ifndef FX25_H_ 21 | #define FX25_H_ 22 | 23 | #ifdef ENABLE_FX25 24 | 25 | #include 26 | #include 27 | 28 | #define FX25_MAX_BLOCK_SIZE 255 29 | 30 | struct Fx25Mode 31 | { 32 | uint64_t tag; //correlation tag 33 | uint16_t K; //data size 34 | uint8_t T; //parity check size 35 | }; 36 | 37 | extern const struct Fx25Mode Fx25ModeList[11]; 38 | 39 | /** 40 | * @brief Get FX.25 mode for given correlation tag 41 | * @param tag FX.25 correlation tag 42 | * @return FX.25 mode structure pointer or NULL if not a FX.25 tag 43 | */ 44 | const struct Fx25Mode* Fx25GetModeForTag(uint64_t tag); 45 | 46 | /** 47 | * @brief Get FX.25 mode for given payload size 48 | * @param size Payload size including flags and CRC 49 | * @return FX.25 mode structure pointer or NULL if standard AX.25 must be used 50 | */ 51 | const struct Fx25Mode* Fx25GetModeForSize(uint16_t size); 52 | 53 | /** 54 | * @brief Encode AX.25 message in FX.25 55 | * @param *buffer AX.25 message (bit-stuffed, with CRC and padding) 56 | * @param *mode FX.25 mode 57 | */ 58 | void Fx25Encode(uint8_t *buffer, const struct Fx25Mode *mode); 59 | 60 | /** 61 | * @brief Decode/fix FX.25 packet 62 | * @param *buffer Input buffer 63 | * @param *mode FX.25 mode 64 | * @param *fixed Number of bytes fixed 65 | * @return True if message is valid, false if uncorrectable 66 | */ 67 | bool Fx25Decode(uint8_t *buffer, const struct Fx25Mode *mode, uint8_t *fixed); 68 | 69 | /** 70 | * @brief Initialize FX.25 module 71 | */ 72 | void Fx25Init(void); 73 | 74 | #endif 75 | 76 | #endif /* FX25_H_ */ 77 | -------------------------------------------------------------------------------- /Core/Inc/kiss.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020-2023 Piotr Wilkon 3 | 4 | This file is part of VP-Digi. 5 | 6 | VP-Digi is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | VP-Digi is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with VP-Digi. If not, see . 18 | */ 19 | 20 | #ifndef KISS_H_ 21 | #define KISS_H_ 22 | 23 | #include 24 | #include "uart.h" 25 | 26 | /** 27 | * @brief Convert AX.25 frame to KISS and send 28 | * @param *port UART structure 29 | * @param *buf Frame buffer 30 | * @param size Frame size 31 | */ 32 | void KissSend(Uart *port, uint8_t *buf, uint16_t size); 33 | 34 | /** 35 | * @brief Parse bytes received from UART to form a KISS frame (possibly) and send this frame 36 | * @param *port UART structure 37 | * @param data Received byte 38 | */ 39 | void KissParse(Uart *port, uint8_t data); 40 | 41 | void KissProcess(Uart *port); 42 | #endif /* KISS_H_ */ 43 | -------------------------------------------------------------------------------- /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 | 20 | /* 21 | Copyright 2020-2023 Piotr Wilkon 22 | 23 | This file is part of VP-Digi. 24 | 25 | VP-Digi is free software: you can redistribute it and/or modify 26 | it under the terms of the GNU General Public License as published by 27 | the Free Software Foundation; either version 3 of the License, or 28 | (at your option) any later version. 29 | 30 | VP-Digi is distributed in the hope that it will be useful, 31 | but WITHOUT ANY WARRANTY; without even the implied warranty of 32 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 33 | GNU General Public License for more details. 34 | 35 | You should have received a copy of the GNU General Public License 36 | along with VP-Digi. If not, see . 37 | */ 38 | /* USER CODE END Header */ 39 | 40 | /* Define to prevent recursive inclusion -------------------------------------*/ 41 | #ifndef __MAIN_H 42 | #define __MAIN_H 43 | 44 | #ifdef __cplusplus 45 | extern "C" { 46 | #endif 47 | 48 | /* Includes ------------------------------------------------------------------*/ 49 | #include "stm32f1xx_hal.h" 50 | 51 | /* Private includes ----------------------------------------------------------*/ 52 | /* USER CODE BEGIN Includes */ 53 | 54 | /* USER CODE END Includes */ 55 | 56 | /* Exported types ------------------------------------------------------------*/ 57 | /* USER CODE BEGIN ET */ 58 | 59 | /* USER CODE END ET */ 60 | 61 | /* Exported constants --------------------------------------------------------*/ 62 | /* USER CODE BEGIN EC */ 63 | 64 | /* USER CODE END EC */ 65 | 66 | /* Exported macro ------------------------------------------------------------*/ 67 | /* USER CODE BEGIN EM */ 68 | 69 | /* USER CODE END EM */ 70 | 71 | /* Exported functions prototypes ---------------------------------------------*/ 72 | void Error_Handler(void); 73 | 74 | /* USER CODE BEGIN EFP */ 75 | 76 | /* USER CODE END EFP */ 77 | 78 | /* Private defines -----------------------------------------------------------*/ 79 | 80 | /* USER CODE BEGIN Private defines */ 81 | 82 | /* USER CODE END Private defines */ 83 | 84 | #ifdef __cplusplus 85 | } 86 | #endif 87 | 88 | #endif /* __MAIN_H */ 89 | -------------------------------------------------------------------------------- /Core/Inc/modem.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020-2023 Piotr Wilkon 3 | 4 | This file is part of VP-Digi. 5 | 6 | VP-Digi is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | VP-Digi is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with VP-Digi. If not, see . 18 | */ 19 | 20 | #ifndef DRIVERS_MODEM_H_ 21 | #define DRIVERS_MODEM_H_ 22 | 23 | #include 24 | 25 | //number of maximum parallel demodulators 26 | //each demodulator must be explicitly configured in code 27 | //currently used only for 1200 Bd modem 28 | #define MODEM_MAX_DEMODULATOR_COUNT 2 29 | 30 | enum ModemType 31 | { 32 | MODEM_1200 = 0, 33 | MODEM_1200_V23, 34 | MODEM_300, 35 | MODEM_9600, 36 | }; 37 | 38 | enum ModemTxTestMode 39 | { 40 | TEST_DISABLED, 41 | TEST_MARK, 42 | TEST_SPACE, 43 | TEST_ALTERNATING, 44 | }; 45 | 46 | 47 | struct ModemDemodConfig 48 | { 49 | enum ModemType modem; 50 | uint8_t usePWM : 1; //0 - use R2R, 1 - use PWM 51 | uint8_t flatAudioIn : 1; //0 - normal (deemphasized) audio input, 1 - flat audio (unfiltered) input 52 | }; 53 | 54 | extern struct ModemDemodConfig ModemConfig; 55 | 56 | enum ModemPrefilter 57 | { 58 | PREFILTER_NONE = 0, 59 | PREFILTER_PREEMPHASIS, 60 | PREFILTER_DEEMPHASIS, 61 | PREFILTER_FLAT, 62 | }; 63 | 64 | /** 65 | * @brief Get measured signal level 66 | * @param modem Modem number 67 | * @param *peak Output signal positive peak in % 68 | * @param *valley Output signal negative peak in % 69 | * @param *level Output signal level in % 70 | */ 71 | void ModemGetSignalLevel(uint8_t modem, int8_t *peak, int8_t *valley, uint8_t *level); 72 | 73 | /** 74 | * @brief Get current modem baudrate 75 | * @return Baudrate 76 | */ 77 | float ModemGetBaudrate(void); 78 | 79 | /** 80 | * @brief Get count of demodulators running in parallel 81 | * @return Count of demodulators 82 | */ 83 | uint8_t ModemGetDemodulatorCount(void); 84 | 85 | /** 86 | * @brief Get prefilter type (preemphasis, deemphasis etc.) for given modem 87 | * @param modem Modem number 88 | * @return Filter type 89 | */ 90 | enum ModemPrefilter ModemGetFilterType(uint8_t modem); 91 | 92 | /** 93 | * @brief Get current DCD state 94 | * @return 1 if channel busy, 0 if free 95 | */ 96 | uint8_t ModemDcdState(void); 97 | 98 | /** 99 | * @brief Check if there is a TX test mode enabled 100 | * @return 1 if in TX test mode, 0 otherwise 101 | */ 102 | uint8_t ModemIsTxTestOngoing(void); 103 | 104 | /** 105 | * @brief Clear modem RMS counter 106 | * @param number Modem number 107 | */ 108 | void ModemClearRMS(uint8_t number); 109 | 110 | /** 111 | * @brief Get RMS value for modem 112 | * @param number Modem number 113 | * @return RMS value 114 | */ 115 | uint16_t ModemGetRMS(uint8_t number); 116 | 117 | /** 118 | * @brief Start or restart TX test mode 119 | * @param type TX test type: TEST_MARK, TEST_SPACE or TEST_ALTERNATING 120 | */ 121 | void ModemTxTestStart(enum ModemTxTestMode type); 122 | 123 | 124 | /** 125 | * @brief Stop TX test mode 126 | */ 127 | void ModemTxTestStop(void); 128 | 129 | /** 130 | * @brief Configure and start TX 131 | * @info This function is used internally by protocol module. 132 | * @warning Use Ax25TransmitStart() to initialize transmission 133 | */ 134 | void ModemTransmitStart(void); 135 | 136 | 137 | /** 138 | * @brief Stop TX and go back to RX 139 | */ 140 | void ModemTransmitStop(void); 141 | 142 | 143 | /** 144 | * @brief Initialize modem module 145 | */ 146 | void ModemInit(void); 147 | 148 | #endif 149 | -------------------------------------------------------------------------------- /Core/Inc/stm32f1xx_it.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32f1xx_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 __STM32F1xx_IT_H 22 | #define __STM32F1xx_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 MemManage_Handler(void); 52 | void BusFault_Handler(void); 53 | void UsageFault_Handler(void); 54 | void SVC_Handler(void); 55 | void DebugMon_Handler(void); 56 | void PendSV_Handler(void); 57 | void SysTick_Handler(void); 58 | void USB_LP_CAN1_RX0_IRQHandler(void); 59 | /* USER CODE BEGIN EFP */ 60 | 61 | /* USER CODE END EFP */ 62 | 63 | #ifdef __cplusplus 64 | } 65 | #endif 66 | 67 | #endif /* __STM32F1xx_IT_H */ 68 | -------------------------------------------------------------------------------- /Core/Inc/systick.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020-2023 Piotr Wilkon 3 | 4 | This file is part of VP-Digi. 5 | 6 | VP-Digi is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | VP-Digi is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with VP-Digi. If not, see . 18 | */ 19 | #ifndef SYSTICK_H_ 20 | #define SYSTICK_H_ 21 | 22 | #include 23 | 24 | #define SYSTICK_FREQUENCY 100 //systick frequency in Hz 25 | #define SYSTICK_INTERVAL (1000 / SYSTICK_FREQUENCY) //systick interval in milliseconds 26 | 27 | /** 28 | * @brief Initialize SysTick 29 | */ 30 | void SysTickInit(void); 31 | 32 | /** 33 | * @brief Get current SysTick counter value 34 | * @return Current SysTick counter value 35 | */ 36 | uint32_t SysTickGet(void); 37 | 38 | /** 39 | * @brief Execute a blocking delay 40 | * @param ms Time in milliseconds 41 | */ 42 | void Delay(uint32_t ms); 43 | 44 | #endif /* SYSTICK_H_ */ 45 | -------------------------------------------------------------------------------- /Core/Inc/terminal.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020-2023 Piotr Wilkon 3 | 4 | This file is part of VP-Digi. 5 | 6 | VP-Digi is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | VP-Digi is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with VP-Digi. If not, see . 18 | */ 19 | 20 | #ifndef TERMINAL_H_ 21 | #define TERMINAL_H_ 22 | 23 | #include "uart.h" 24 | #include 25 | 26 | /** 27 | * @brief Send data to all available ports 28 | * @param mode Output mode/data type 29 | * @param *data Data buffer 30 | * @param size Data size 31 | */ 32 | void TermSendToAll(enum UartMode mode, uint8_t *data, uint16_t size); 33 | 34 | /** 35 | * @brief Send signed number to all available ports 36 | * @param mode Output mode/data type 37 | * @param n Number to send 38 | */ 39 | void TermSendNumberToAll(enum UartMode mode, int32_t n); 40 | 41 | 42 | /** 43 | * @brief Handle "special" terminal cases like backspace or local echo 44 | * @param *u UART structure 45 | * @attention Must be called for every received data 46 | */ 47 | void TermHandleSpecial(Uart *u); 48 | 49 | /** 50 | * @brief Parse and process received data 51 | * @param *src UART structure 52 | */ 53 | void TermParse(Uart *src); 54 | 55 | #endif /* DEBUG_H_ */ 56 | -------------------------------------------------------------------------------- /Core/Inc/uart.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020-2024 Piotr Wilkon 3 | 4 | This file is part of VP-Digi. 5 | 6 | VP-Digi is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | VP-Digi is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with VP-Digi. If not, see . 18 | */ 19 | 20 | #ifndef UART_H_ 21 | #define UART_H_ 22 | 23 | #include 24 | #include "usbd_cdc_if.h" 25 | #include "ax25.h" 26 | #include "drivers/uart_ll.h" 27 | 28 | #define UART_BUFFER_SIZE 130 29 | 30 | enum UartMode 31 | { 32 | MODE_KISS, 33 | MODE_TERM, 34 | MODE_MONITOR, 35 | }; 36 | 37 | enum UartDataType 38 | { 39 | DATA_NOTHING = 0, 40 | DATA_TERM, 41 | DATA_KISS, 42 | DATA_USB, 43 | }; 44 | 45 | typedef struct 46 | { 47 | volatile USART_TypeDef *port; //UART peripheral 48 | uint32_t baudrate; //baudrate 1200-115200 49 | volatile enum UartDataType rxType; //rx status 50 | uint8_t enabled : 1; 51 | uint8_t isUsb : 1; 52 | volatile uint8_t rxBuffer[UART_BUFFER_SIZE]; 53 | volatile uint16_t rxBufferHead; 54 | uint8_t txBuffer[UART_BUFFER_SIZE]; 55 | volatile uint16_t txBufferHead, txBufferTail; 56 | volatile uint8_t txBufferFull : 1; 57 | enum UartMode mode; 58 | enum UartMode defaultMode; 59 | volatile uint16_t lastRxBufferHead; //for special characters handling 60 | volatile uint8_t kissBuffer[AX25_FRAME_MAX_SIZE + 1]; 61 | volatile uint16_t kissBufferHead; 62 | volatile uint8_t kissProcessingOngoing; 63 | volatile uint8_t kissTempBuffer[10]; 64 | volatile uint16_t kissTempBufferHead; 65 | } Uart; 66 | 67 | extern Uart Uart1, Uart2, UartUsb; 68 | 69 | 70 | /** 71 | * @brief Send byte 72 | * @param[in] *port UART 73 | * @param[in] data Data 74 | */ 75 | void UartSendByte(Uart *port, uint8_t data); 76 | 77 | /** 78 | * @brief Send string 79 | * @param *port UART 80 | * @param *data Buffer 81 | * @param len Buffer length or 0 for null-terminated string 82 | */ 83 | void UartSendString(Uart *port, void *data, uint16_t datalen); 84 | 85 | /** 86 | * @brief Send signed number 87 | * @param *port UART 88 | * @param n Number 89 | */ 90 | void UartSendNumber(Uart *port, int32_t n); 91 | 92 | 93 | /** 94 | * @brief Initialize UART structures 95 | * @param *port UART [prt 96 | * @param *uart Physical UART peripheral. NULL if USB in CDC mode 97 | * @param baud Baudrate 98 | */ 99 | void UartInit(Uart *port, USART_TypeDef *uart, uint32_t baud); 100 | 101 | /** 102 | * @brief Configure and enable/disable UART 103 | * @param *port UART port 104 | * @param state 0 - disable, 1 - enable 105 | */ 106 | void UartConfig(Uart *port, uint8_t state); 107 | 108 | /** 109 | * @brief Clear RX buffer and flags 110 | * @param *port UART port 111 | */ 112 | void UartClearRx(Uart *port); 113 | 114 | #endif 115 | -------------------------------------------------------------------------------- /Core/Src/beacon.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020-2023 Piotr Wilkon 3 | 4 | This file is part of VP-Digi. 5 | 6 | VP-Digi is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | VP-Digi is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with VP-Digi. If not, see . 18 | */ 19 | 20 | #include "beacon.h" 21 | #include "digipeater.h" 22 | #include "common.h" 23 | #include 24 | #include 25 | #include "ax25.h" 26 | #include "terminal.h" 27 | 28 | struct Beacon beacon[8]; 29 | 30 | static uint32_t beaconDelay[8] = {0}; 31 | static uint8_t buf[150]; //frame buffer 32 | 33 | /** 34 | * @brief Send specified beacon 35 | * @param[in] no Beacon number (0-7) 36 | */ 37 | void BeaconSend(uint8_t number) 38 | { 39 | if(beacon[number].enable == 0) 40 | return; //beacon disabled 41 | 42 | uint16_t idx = 0; 43 | 44 | for(uint8_t i = 0; i < sizeof(GeneralConfig.dest); i++) //add destination address 45 | buf[idx++] = GeneralConfig.dest[i]; 46 | 47 | for(uint8_t i = 0; i < sizeof(GeneralConfig.call); i++) //add source address 48 | buf[idx++] = GeneralConfig.call[i]; 49 | 50 | buf[idx++] = ((GeneralConfig.callSsid << 1) + 0b01100000); //add source ssid 51 | 52 | if(beacon[number].path[0] > 0) //this beacon has some path set 53 | { 54 | for(uint8_t i = 0; i < 14; i++) //loop through path 55 | { 56 | if((beacon[number].path[i] > 0) || (i == 6) || (i == 13)) //normal data, not a NULL symbol 57 | { 58 | buf[idx] = beacon[number].path[i]; //copy path 59 | if((i == 6) || (i == 13)) //it was and ssid 60 | { 61 | buf[idx] = ((buf[idx] << 1) + 0b01100000); //add appropriate bits for ssid 62 | } 63 | idx++; 64 | } 65 | else //NULL in path 66 | break; //end here 67 | } 68 | } 69 | buf[idx - 1] |= 1; //add c-bit on the last element 70 | buf[idx++] = 0x03; //control 71 | buf[idx++] = 0xF0; //pid 72 | for(uint8_t i = 0; i < strlen((char*)beacon[number].data); i++) 73 | { 74 | buf[idx++] = beacon[number].data[i]; //copy beacon comment 75 | } 76 | 77 | void *handle = NULL; 78 | if(NULL != (handle = Ax25WriteTxFrame(buf, idx))) //try to write frame to TX buffer 79 | { 80 | if(GeneralConfig.kissMonitor) //monitoring mode, send own frames to KISS ports 81 | { 82 | TermSendToAll(MODE_KISS, buf, idx); 83 | } 84 | 85 | DigiStoreDeDupe(buf, idx); //store frame hash in duplicate protection buffer (to prevent from digipeating own packets) 86 | 87 | TermSendToAll(MODE_MONITOR, (uint8_t*)"(AX.25) Transmitting beacon ", 0); 88 | 89 | TermSendNumberToAll(MODE_MONITOR, number); 90 | TermSendToAll(MODE_MONITOR, (uint8_t*)": ", 0); 91 | SendTNC2(buf, idx); 92 | TermSendToAll(MODE_MONITOR, (uint8_t*)"\r\n", 0); 93 | } 94 | 95 | } 96 | 97 | /** 98 | * @brief Check if any beacon should be transmitted and transmit if necessary 99 | */ 100 | void BeaconCheck(void) 101 | { 102 | for(uint8_t i = 0; i < 8; i++) 103 | { 104 | if(beacon[i].enable == 0) 105 | continue; 106 | 107 | if((beacon[i].interval > 0) && ((SysTickGet() >= beacon[i].next) || (beacon[i].next == 0))) 108 | { 109 | if(beaconDelay[i] > SysTickGet()) //check for beacon delay (only for the very first transmission) 110 | continue; 111 | beacon[i].next = SysTickGet() + beacon[i].interval; //save next beacon timestamp 112 | beaconDelay[i] = 0; 113 | BeaconSend(i); 114 | } 115 | } 116 | } 117 | 118 | 119 | /** 120 | * @brief Initialize beacon module 121 | */ 122 | void BeaconInit(void) 123 | { 124 | for(uint8_t i = 0; i < 8; i++) 125 | { 126 | beaconDelay[i] = (beacon[i].delay * SYSTICK_FREQUENCY) + SysTickGet() + (30000 / SYSTICK_INTERVAL); //set delay for beacons and add constant 30 seconds of delay 127 | beacon[i].next = 0; 128 | } 129 | } 130 | 131 | -------------------------------------------------------------------------------- /Core/Src/common.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020-2024 Piotr Wilkon 3 | 4 | This file is part of VP-Digi. 5 | 6 | VP-Digi is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | VP-Digi is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with VP-Digi. If not, see . 18 | */ 19 | 20 | #include 21 | #include 22 | #include "common.h" 23 | #include "ax25.h" 24 | #include "usbd_cdc_if.h" 25 | 26 | struct _GeneralConfig GeneralConfig = 27 | { 28 | .call = {'N' << 1, '0' << 1, 'C' << 1, 'A' << 1, 'L' << 1, 'L' << 1}, 29 | .callSsid = 0, 30 | .dest = {130, 160, 156, 172, 96, 98, 96}, //destination address: APNV01-0 by default. SSID MUST remain 0. 31 | .kissMonitor = 0, 32 | }; 33 | 34 | 35 | const char versionString[] = "VP-Digi v. 2.1.0\r\nThe open-source standalone APRS digipeater controller and KISS TNC\r\n" 36 | #ifdef ENABLE_FX25 37 | "With FX.25 support compiled-in\r\n" 38 | #endif 39 | ; 40 | 41 | 42 | static uint64_t pow10i(uint16_t exp) 43 | { 44 | if(exp == 0) 45 | return 1; 46 | uint64_t n = 1; 47 | while(exp--) 48 | n *= 10; 49 | return n; 50 | } 51 | 52 | int64_t StrToInt(const char *str, uint16_t len) 53 | { 54 | if(len == 0) 55 | len = strlen(str); 56 | 57 | int64_t tmp = 0; 58 | for(int32_t i = (len - 1); i >= 0; i--) 59 | { 60 | if((i == 0) && (str[0] == '-')) 61 | { 62 | return -tmp; 63 | } 64 | else if(IS_NUMBER(str[i])) 65 | tmp += ((str[i] - '0') * pow10i(len - 1 - i)); 66 | else 67 | return 0; 68 | } 69 | return tmp; 70 | } 71 | 72 | 73 | int16_t Random(int16_t min, int16_t max) 74 | { 75 | int16_t tmp; 76 | if (max >= min) 77 | max -= min; 78 | else 79 | { 80 | tmp = min - max; 81 | min = max; 82 | max = tmp; 83 | } 84 | return max ? (rand() % max + min) : min; 85 | } 86 | 87 | static void sendTNC2ToUart(Uart *uart, uint8_t *from, uint16_t len) 88 | { 89 | for(uint8_t i = 0; i < 6; i++) //source call 90 | { 91 | if((from[7 + i] >> 1) != ' ') //skip spaces 92 | { 93 | UartSendByte(uart, from[7 + i] >> 1); 94 | } 95 | } 96 | 97 | uint8_t ssid = ((from[13] >> 1) & 0b00001111); //store ssid 98 | if(ssid > 0) //SSID >0 99 | { 100 | UartSendByte(uart, '-'); //add - 101 | UartSendNumber(uart, ssid); 102 | } 103 | 104 | UartSendByte(uart, '>'); //first separator 105 | 106 | for(uint8_t i = 0; i < 6; i++) //destination call 107 | { 108 | if((from[i] >> 1) != ' ') //skip spaces 109 | { 110 | UartSendByte(uart, from[i] >> 1); 111 | } 112 | } 113 | ssid = ((from[6] >> 1) & 0b00001111); //store ssid 114 | 115 | if(ssid > 0) //SSID >0 116 | { 117 | UartSendByte(uart, '-'); //add - 118 | UartSendNumber(uart, ssid); 119 | } 120 | 121 | uint16_t nextPathEl = 14; //next path element index 122 | 123 | if(!(from[13] & 1)) //no c-bit in source address, there is a digi path 124 | { 125 | do //analyze all path elements 126 | { 127 | UartSendByte(uart, ','); //path separator 128 | 129 | for(uint8_t i = 0; i < 6; i++) //copy element 130 | { 131 | if((from[nextPathEl + i] >> 1) != ' ') //skip spaces 132 | { 133 | UartSendByte(uart, from[nextPathEl + i] >> 1); 134 | } 135 | } 136 | 137 | ssid = ((from[nextPathEl + 6] >> 1) & 0b00001111); //store ssid 138 | if(ssid > 0) //SSID >0 139 | { 140 | UartSendByte(uart, '-'); //add - 141 | UartSendNumber(uart, ssid); 142 | } 143 | if((from[nextPathEl + 6] & 0x80)) //h-bit in ssid 144 | UartSendByte(uart, '*'); //add * 145 | 146 | nextPathEl += 7; //next path element 147 | if(nextPathEl > 56) //too many path elements 148 | break; 149 | } 150 | while((from[nextPathEl - 1] & 1) == 0); //loop until the c-bit is found 151 | 152 | } 153 | 154 | UartSendByte(uart, ':'); //separator 155 | 156 | if((from[nextPathEl] & 0b11101111) == 0b00000011) //check if UI packet 157 | { 158 | nextPathEl += 2; //skip Control and PID 159 | 160 | UartSendString(uart, &(from[nextPathEl]), len - nextPathEl); //send information field 161 | } 162 | else 163 | UartSendString(uart, "", 0); 164 | 165 | UartSendByte(uart, 0); //terminate with NULL 166 | } 167 | 168 | void SendTNC2(uint8_t *from, uint16_t len) 169 | { 170 | if(UartUsb.mode == MODE_MONITOR) 171 | sendTNC2ToUart(&UartUsb, from, len); 172 | if(Uart1.mode == MODE_MONITOR) 173 | sendTNC2ToUart(&Uart1, from, len); 174 | if(Uart2.mode == MODE_MONITOR) 175 | sendTNC2ToUart(&Uart2, from, len); 176 | } 177 | 178 | uint32_t Crc32(uint32_t crc0, uint8_t *s, uint64_t n) 179 | { 180 | uint32_t crc = ~crc0; 181 | 182 | for(uint64_t i = 0; i < n; i++) 183 | { 184 | uint8_t ch = s[i]; 185 | for(uint8_t j = 0; j < 8; j++) { 186 | uint32_t b = (ch ^ crc) & 1; 187 | crc >>= 1; 188 | if(b) crc ^= 0xEDB88320; 189 | ch >>= 1; 190 | } 191 | } 192 | 193 | return ~crc; 194 | } 195 | 196 | bool ParseCallsign(const char *in, uint16_t size, uint8_t *out) 197 | { 198 | if(size > 6) 199 | return false; 200 | 201 | uint8_t tmp[6]; 202 | 203 | uint8_t i = 0; 204 | for(; i < size; i++) 205 | { 206 | if(!IS_UPPERCASE_ALPHANUMERIC(in[i])) 207 | return false; 208 | 209 | tmp[i] = in[i] << 1; 210 | } 211 | 212 | for(uint8_t k = 0; k < i; k++) 213 | out[k] = tmp[k]; 214 | 215 | for(; i < 6; i++) 216 | out[i] = ' ' << 1; 217 | 218 | 219 | return true; 220 | } 221 | 222 | bool ParseCallsignWithSsid(const char *in, uint16_t size, uint8_t *out, uint8_t *ssid) 223 | { 224 | uint16_t hyphenPosition = size; 225 | for(uint16_t i = 0; i < size; i++) 226 | { 227 | if(in[i] == '-') 228 | { 229 | hyphenPosition = i; 230 | break; 231 | } 232 | } 233 | if(!ParseCallsign(in, hyphenPosition, out)) 234 | return false; 235 | 236 | if(hyphenPosition == size) 237 | { 238 | *ssid = 0; 239 | return true; 240 | } 241 | 242 | if(!ParseSsid(&in[hyphenPosition + 1], size - hyphenPosition - 1, ssid)) 243 | return false; 244 | 245 | return true; 246 | } 247 | 248 | bool ParseSsid(const char *in, uint16_t size, uint8_t *out) 249 | { 250 | int64_t ssid = StrToInt(in, size); 251 | if((ssid >= 0) && (ssid <= 15)) 252 | { 253 | *out = (uint8_t)ssid; 254 | return true; 255 | } 256 | return false; 257 | } 258 | 259 | 260 | -------------------------------------------------------------------------------- /Core/Src/fx25.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020-2023 Piotr Wilkon 3 | 4 | This file is part of VP-Digi. 5 | 6 | VP-Digi is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | VP-Digi is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with VP-Digi. If not, see . 18 | */ 19 | 20 | #ifdef ENABLE_FX25 21 | 22 | #include "fx25.h" 23 | #include 24 | #include "rs.h" 25 | 26 | #define FX25_RS_FCR 1 27 | 28 | #define FX25_PREGENERATE_POLYS 29 | #define FX25_MAX_DISTANCE 10 //maximum Hamming distance when comparing tags 30 | 31 | const struct Fx25Mode Fx25ModeList[11] = 32 | { 33 | {.tag = 0xB74DB7DF8A532F3E, .K = 239, .T = 16}, 34 | {.tag = 0x26FF60A600CC8FDE, .K = 128, .T = 16}, 35 | {.tag = 0xC7DC0508F3D9B09E, .K = 64, .T = 16}, 36 | {.tag = 0x8F056EB4369660EE, .K = 32, .T = 16}, 37 | {.tag = 0x6E260B1AC5835FAE, .K = 223, .T = 32}, 38 | {.tag = 0xFF94DC634F1CFF4E, .K = 128, .T = 32}, 39 | {.tag = 0x1EB7B9CDBC09C00E, .K = 64, .T = 32}, 40 | {.tag = 0xDBF869BD2DBB1776, .K = 32, .T = 32}, 41 | {.tag = 0x3ADB0C13DEAE2836, .K = 191, .T = 64}, 42 | {.tag = 0xAB69DB6A543188D6, .K = 128, .T = 64}, 43 | {.tag = 0x4A4ABEC4A724B796, .K = 64, .T = 64} 44 | }; 45 | 46 | 47 | 48 | const struct Fx25Mode* Fx25GetModeForTag(uint64_t tag) 49 | { 50 | for(uint8_t i = 0; i < sizeof(Fx25ModeList) / sizeof(*Fx25ModeList); i++) 51 | { 52 | if(__builtin_popcountll(tag ^ Fx25ModeList[i].tag) <= FX25_MAX_DISTANCE) 53 | return &Fx25ModeList[i]; 54 | } 55 | return NULL; 56 | } 57 | 58 | const struct Fx25Mode* Fx25GetModeForSize(uint16_t size) 59 | { 60 | //use "UZ7HO Soundmodem standard" for choosing FX.25 mode 61 | if(size <= 32) 62 | return &Fx25ModeList[3]; 63 | else if(size <= 64) 64 | return &Fx25ModeList[2]; 65 | else if(size <= 128) 66 | return &Fx25ModeList[5]; 67 | else if(size <= 191) 68 | return &Fx25ModeList[8]; 69 | else if(size <= 223) 70 | return &Fx25ModeList[4]; 71 | else if(size <= 239) 72 | return &Fx25ModeList[0]; 73 | else 74 | return NULL; //frame too big, do not use FX.25 75 | } 76 | 77 | #ifdef FX25_PREGENERATE_POLYS 78 | static struct LwFecRS rs16, rs32, rs64; 79 | #else 80 | static struct LwFecRS rs; 81 | #endif 82 | 83 | void Fx25Encode(uint8_t *buffer, const struct Fx25Mode *mode) 84 | { 85 | #ifdef FX25_PREGENERATE_POLYS 86 | struct LwFecRS *rs = NULL; 87 | switch(mode->T) 88 | { 89 | case 16: 90 | rs = &rs16; 91 | break; 92 | case 32: 93 | rs = &rs32; 94 | break; 95 | case 64: 96 | rs = &rs64; 97 | break; 98 | default: 99 | rs = &rs16; 100 | break; 101 | } 102 | RsEncode(rs, buffer, mode->K); 103 | #else 104 | RsInit(&rs, mode->T, FX25_RS_FCR); 105 | RsEncode(&rs, buffer, mode->K); 106 | #endif 107 | 108 | } 109 | 110 | bool Fx25Decode(uint8_t *buffer, const struct Fx25Mode *mode, uint8_t *fixed) 111 | { 112 | #ifdef FX25_PREGENERATE_POLYS 113 | struct LwFecRS *rs = NULL; 114 | switch(mode->T) 115 | { 116 | case 16: 117 | rs = &rs16; 118 | break; 119 | case 32: 120 | rs = &rs32; 121 | break; 122 | case 64: 123 | rs = &rs64; 124 | break; 125 | default: 126 | rs = &rs16; 127 | break; 128 | } 129 | return RsDecode(rs, buffer, mode->K, fixed); 130 | #else 131 | RsInit(&rs, mode->T, FX25_RS_FCR); 132 | return RsDecode(&rs, buffer, mode->K, fixed); 133 | #endif 134 | 135 | } 136 | 137 | void Fx25Init(void) 138 | { 139 | #ifdef FX25_PREGENERATE_POLYS 140 | RsInit(&rs16, 16, FX25_RS_FCR); 141 | RsInit(&rs32, 32, FX25_RS_FCR); 142 | RsInit(&rs64, 64, FX25_RS_FCR); 143 | #else 144 | #endif 145 | } 146 | 147 | #endif 148 | -------------------------------------------------------------------------------- /Core/Src/kiss.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020-2024 Piotr Wilkon 3 | 4 | This file is part of VP-Digi. 5 | 6 | VP-Digi is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | VP-Digi is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with VP-Digi. If not, see . 18 | */ 19 | 20 | #include "kiss.h" 21 | #include "ax25.h" 22 | #include "digipeater.h" 23 | 24 | void KissSend(Uart *port, uint8_t *buf, uint16_t size) 25 | { 26 | if(port->mode == MODE_KISS) 27 | { 28 | UartSendByte(port, 0xC0); 29 | UartSendByte(port, 0x00); 30 | for(uint16_t i = 0; i < size; i++) 31 | { 32 | if(buf[i] == 0xC0) //frame end in data 33 | { 34 | UartSendByte(port, 0xDB); //frame escape 35 | UartSendByte(port, 0xDC); //transposed frame end 36 | } 37 | else if(buf[i] == 0xDB) //frame escape in data 38 | { 39 | UartSendByte(port, 0xDB); //frame escape 40 | UartSendByte(port, 0xDD); //transposed frame escape 41 | } 42 | else 43 | UartSendByte(port, buf[i]); 44 | } 45 | UartSendByte(port, 0xC0); 46 | } 47 | } 48 | 49 | 50 | void KissParse(Uart *port, uint8_t data) 51 | { 52 | 53 | volatile uint8_t *buf = NULL; 54 | volatile uint16_t *index = NULL; 55 | bool useTempBuffer = port->kissProcessingOngoing; 56 | 57 | if(!useTempBuffer) 58 | { 59 | buf = port->kissBuffer; 60 | index = &port->kissBufferHead; 61 | } 62 | else 63 | { 64 | buf = port->kissTempBuffer; 65 | index = &port->kissTempBufferHead; 66 | } 67 | 68 | if(data == 0xC0) //frame end marker 69 | { 70 | if(useTempBuffer) //temporary buffer is used = KISS processing is ongoing, must drop the incoming frame 71 | { 72 | *index = 0; 73 | return; 74 | } 75 | 76 | if(port->kissBufferHead < 16) //command+source+destination+Control=16 77 | { 78 | port->kissBufferHead = 0; 79 | return; 80 | } 81 | 82 | if((port->kissBuffer[0] & 0xF) != 0) //check if this is an actual frame 83 | { 84 | port->kissBufferHead = 0; 85 | return; 86 | } 87 | 88 | //simple sanity check 89 | //check if LSbits in the first 13 bytes are set to 0 90 | //they should always be in an AX.25 frame 91 | for(uint8_t i = 0; i < 13; i++) 92 | { 93 | if((port->kissBuffer[i + 1] & 1) != 0) 94 | { 95 | port->kissBufferHead = 0; 96 | return; 97 | } 98 | } 99 | 100 | uint16_t pathEnd = 0; 101 | 102 | //find path end bit (C-bit) 103 | for(uint16_t i = 0; i < port->kissBufferHead; i++) 104 | { 105 | if((port->kissBuffer[i + 1] & 1) != 0) 106 | { 107 | pathEnd = i + 1; 108 | break; 109 | } 110 | } 111 | 112 | //C-bit must lay on a 7 byte boundary (every path element is 7 bytes long) 113 | if(pathEnd % 7) 114 | { 115 | port->kissBufferHead = 0; 116 | return; 117 | } 118 | 119 | 120 | __disable_irq(); 121 | port->kissProcessingOngoing = 1; 122 | port->kissTempBufferHead = 0; 123 | port->rxType = DATA_KISS; 124 | __enable_irq(); 125 | return; 126 | } 127 | else if(*index > 0) 128 | { 129 | if((data == 0xDC) && (buf[*index - 1] == 0xDB)) //escape character with transposed frame end 130 | { 131 | buf[*index - 1] = 0xC0; 132 | return; 133 | } 134 | else if((data == 0xDD) && (buf[*index - 1] == 0xDB)) //escape character with transposed escape character 135 | { 136 | buf[*index - 1] = 0xDB; 137 | return; 138 | } 139 | } 140 | buf[(*index)++] = data; 141 | 142 | if(!useTempBuffer) 143 | port->kissBufferHead %= sizeof(port->kissBuffer); 144 | else 145 | port->kissTempBufferHead %= sizeof(port->kissTempBuffer); 146 | } 147 | 148 | void KissProcess(Uart *port) 149 | { 150 | if(port->rxType == DATA_KISS) 151 | { 152 | Ax25WriteTxFrame((uint8_t*)&port->kissBuffer[1], port->kissBufferHead - 1); 153 | DigiStoreDeDupe((uint8_t*)&port->kissBuffer[1], port->kissBufferHead - 1); 154 | port->kissBufferHead = 0; 155 | __disable_irq(); 156 | port->kissProcessingOngoing = 0; 157 | if(port->kissTempBufferHead > 0) 158 | { 159 | memcpy((uint8_t*)port->kissBuffer, (uint8_t*)port->kissTempBuffer, port->kissTempBufferHead); 160 | port->kissBufferHead = port->kissTempBufferHead; 161 | port->kissTempBufferHead = 0; 162 | } 163 | port->rxType = DATA_NOTHING; 164 | __enable_irq(); 165 | } 166 | } 167 | -------------------------------------------------------------------------------- /Core/Src/stm32f1xx_hal_msp.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32f1xx_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 | 24 | /* USER CODE BEGIN Includes */ 25 | 26 | /* USER CODE END Includes */ 27 | 28 | /* Private typedef -----------------------------------------------------------*/ 29 | /* USER CODE BEGIN TD */ 30 | 31 | /* USER CODE END TD */ 32 | 33 | /* Private define ------------------------------------------------------------*/ 34 | /* USER CODE BEGIN Define */ 35 | 36 | /* USER CODE END Define */ 37 | 38 | /* Private macro -------------------------------------------------------------*/ 39 | /* USER CODE BEGIN Macro */ 40 | 41 | /* USER CODE END Macro */ 42 | 43 | /* Private variables ---------------------------------------------------------*/ 44 | /* USER CODE BEGIN PV */ 45 | 46 | /* USER CODE END PV */ 47 | 48 | /* Private function prototypes -----------------------------------------------*/ 49 | /* USER CODE BEGIN PFP */ 50 | 51 | /* USER CODE END PFP */ 52 | 53 | /* External functions --------------------------------------------------------*/ 54 | /* USER CODE BEGIN ExternalFunctions */ 55 | 56 | /* USER CODE END ExternalFunctions */ 57 | 58 | /* USER CODE BEGIN 0 */ 59 | 60 | /* USER CODE END 0 */ 61 | /** 62 | * Initializes the Global MSP. 63 | */ 64 | void HAL_MspInit(void) 65 | { 66 | /* USER CODE BEGIN MspInit 0 */ 67 | 68 | /* USER CODE END MspInit 0 */ 69 | 70 | __HAL_RCC_AFIO_CLK_ENABLE(); 71 | __HAL_RCC_PWR_CLK_ENABLE(); 72 | 73 | /* System interrupt init*/ 74 | 75 | /** NOJTAG: JTAG-DP Disabled and SW-DP Enabled 76 | */ 77 | __HAL_AFIO_REMAP_SWJ_NOJTAG(); 78 | 79 | /* USER CODE BEGIN MspInit 1 */ 80 | 81 | /* USER CODE END MspInit 1 */ 82 | } 83 | 84 | /* USER CODE BEGIN 1 */ 85 | 86 | /* USER CODE END 1 */ 87 | -------------------------------------------------------------------------------- /Core/Src/stm32f1xx_it.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32f1xx_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 "stm32f1xx_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 | extern PCD_HandleTypeDef hpcd_USB_FS; 59 | /* USER CODE BEGIN EV */ 60 | 61 | /* USER CODE END EV */ 62 | 63 | /******************************************************************************/ 64 | /* Cortex-M3 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 | NVIC_SystemReset(); 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 | NVIC_SystemReset(); 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 Memory management fault. 98 | */ 99 | void MemManage_Handler(void) 100 | { 101 | /* USER CODE BEGIN MemoryManagement_IRQn 0 */ 102 | NVIC_SystemReset(); 103 | /* USER CODE END MemoryManagement_IRQn 0 */ 104 | while (1) 105 | { 106 | /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */ 107 | /* USER CODE END W1_MemoryManagement_IRQn 0 */ 108 | } 109 | } 110 | 111 | /** 112 | * @brief This function handles Prefetch fault, memory access fault. 113 | */ 114 | void BusFault_Handler(void) 115 | { 116 | /* USER CODE BEGIN BusFault_IRQn 0 */ 117 | NVIC_SystemReset(); 118 | /* USER CODE END BusFault_IRQn 0 */ 119 | while (1) 120 | { 121 | /* USER CODE BEGIN W1_BusFault_IRQn 0 */ 122 | /* USER CODE END W1_BusFault_IRQn 0 */ 123 | } 124 | } 125 | 126 | /** 127 | * @brief This function handles Undefined instruction or illegal state. 128 | */ 129 | void UsageFault_Handler(void) 130 | { 131 | /* USER CODE BEGIN UsageFault_IRQn 0 */ 132 | NVIC_SystemReset(); 133 | /* USER CODE END UsageFault_IRQn 0 */ 134 | while (1) 135 | { 136 | /* USER CODE BEGIN W1_UsageFault_IRQn 0 */ 137 | /* USER CODE END W1_UsageFault_IRQn 0 */ 138 | } 139 | } 140 | 141 | /** 142 | * @brief This function handles System service call via SWI instruction. 143 | */ 144 | void SVC_Handler(void) 145 | { 146 | /* USER CODE BEGIN SVCall_IRQn 0 */ 147 | 148 | /* USER CODE END SVCall_IRQn 0 */ 149 | /* USER CODE BEGIN SVCall_IRQn 1 */ 150 | 151 | /* USER CODE END SVCall_IRQn 1 */ 152 | } 153 | 154 | /** 155 | * @brief This function handles Debug monitor. 156 | */ 157 | void DebugMon_Handler(void) 158 | { 159 | /* USER CODE BEGIN DebugMonitor_IRQn 0 */ 160 | 161 | /* USER CODE END DebugMonitor_IRQn 0 */ 162 | /* USER CODE BEGIN DebugMonitor_IRQn 1 */ 163 | 164 | /* USER CODE END DebugMonitor_IRQn 1 */ 165 | } 166 | 167 | /** 168 | * @brief This function handles Pendable request for system service. 169 | */ 170 | void PendSV_Handler(void) 171 | { 172 | /* USER CODE BEGIN PendSV_IRQn 0 */ 173 | 174 | /* USER CODE END PendSV_IRQn 0 */ 175 | /* USER CODE BEGIN PendSV_IRQn 1 */ 176 | 177 | /* USER CODE END PendSV_IRQn 1 */ 178 | } 179 | 180 | /** 181 | * @brief This function handles System tick timer. 182 | */ 183 | void SysTick_Handler(void) 184 | { 185 | /* USER CODE BEGIN SysTick_IRQn 0 */ 186 | 187 | /* USER CODE END SysTick_IRQn 0 */ 188 | HAL_IncTick(); 189 | /* USER CODE BEGIN SysTick_IRQn 1 */ 190 | extern volatile uint32_t ticks; 191 | ticks++; 192 | /* USER CODE END SysTick_IRQn 1 */ 193 | } 194 | 195 | /******************************************************************************/ 196 | /* STM32F1xx Peripheral Interrupt Handlers */ 197 | /* Add here the Interrupt Handlers for the used peripherals. */ 198 | /* For the available peripheral interrupt handler names, */ 199 | /* please refer to the startup file (startup_stm32f1xx.s). */ 200 | /******************************************************************************/ 201 | 202 | /** 203 | * @brief This function handles USB low priority or CAN RX0 interrupts. 204 | */ 205 | void USB_LP_CAN1_RX0_IRQHandler(void) 206 | { 207 | /* USER CODE BEGIN USB_LP_CAN1_RX0_IRQn 0 */ 208 | 209 | /* USER CODE END USB_LP_CAN1_RX0_IRQn 0 */ 210 | HAL_PCD_IRQHandler(&hpcd_USB_FS); 211 | /* USER CODE BEGIN USB_LP_CAN1_RX0_IRQn 1 */ 212 | 213 | /* USER CODE END USB_LP_CAN1_RX0_IRQn 1 */ 214 | } 215 | 216 | /* USER CODE BEGIN 1 */ 217 | 218 | /* USER CODE END 1 */ 219 | -------------------------------------------------------------------------------- /Core/Src/syscalls.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file syscalls.c 4 | * @author Auto-generated by STM32CubeIDE 5 | * @brief STM32CubeIDE Minimal System calls file 6 | * 7 | * For more information about which c-functions 8 | * need which of these lowlevel functions 9 | * please consult the Newlib libc-manual 10 | ****************************************************************************** 11 | * @attention 12 | * 13 | * Copyright (c) 2020-2023 STMicroelectronics. 14 | * All rights reserved. 15 | * 16 | * This software is licensed under terms that can be found in the LICENSE file 17 | * in the root directory of this software component. 18 | * If no LICENSE file comes with this software, it is provided AS-IS. 19 | * 20 | ****************************************************************************** 21 | */ 22 | 23 | /* Includes */ 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | 34 | /* Variables */ 35 | extern int __io_putchar(int ch) __attribute__((weak)); 36 | extern int __io_getchar(void) __attribute__((weak)); 37 | 38 | 39 | char *__env[1] = { 0 }; 40 | char **environ = __env; 41 | 42 | 43 | /* Functions */ 44 | void initialise_monitor_handles() 45 | { 46 | } 47 | 48 | int _getpid(void) 49 | { 50 | return 1; 51 | } 52 | 53 | int _kill(int pid, int sig) 54 | { 55 | (void)pid; 56 | (void)sig; 57 | errno = EINVAL; 58 | return -1; 59 | } 60 | 61 | void _exit (int status) 62 | { 63 | _kill(status, -1); 64 | while (1) {} /* Make sure we hang here */ 65 | } 66 | 67 | __attribute__((weak)) int _read(int file, char *ptr, int len) 68 | { 69 | (void)file; 70 | int DataIdx; 71 | 72 | for (DataIdx = 0; DataIdx < len; DataIdx++) 73 | { 74 | *ptr++ = __io_getchar(); 75 | } 76 | 77 | return len; 78 | } 79 | 80 | __attribute__((weak)) int _write(int file, char *ptr, int len) 81 | { 82 | (void)file; 83 | int DataIdx; 84 | 85 | for (DataIdx = 0; DataIdx < len; DataIdx++) 86 | { 87 | __io_putchar(*ptr++); 88 | } 89 | return len; 90 | } 91 | 92 | int _close(int file) 93 | { 94 | (void)file; 95 | return -1; 96 | } 97 | 98 | 99 | int _fstat(int file, struct stat *st) 100 | { 101 | (void)file; 102 | st->st_mode = S_IFCHR; 103 | return 0; 104 | } 105 | 106 | int _isatty(int file) 107 | { 108 | (void)file; 109 | return 1; 110 | } 111 | 112 | int _lseek(int file, int ptr, int dir) 113 | { 114 | (void)file; 115 | (void)ptr; 116 | (void)dir; 117 | return 0; 118 | } 119 | 120 | int _open(char *path, int flags, ...) 121 | { 122 | (void)path; 123 | (void)flags; 124 | /* Pretend like we always fail */ 125 | return -1; 126 | } 127 | 128 | int _wait(int *status) 129 | { 130 | (void)status; 131 | errno = ECHILD; 132 | return -1; 133 | } 134 | 135 | int _unlink(char *name) 136 | { 137 | (void)name; 138 | errno = ENOENT; 139 | return -1; 140 | } 141 | 142 | int _times(struct tms *buf) 143 | { 144 | (void)buf; 145 | return -1; 146 | } 147 | 148 | int _stat(char *file, struct stat *st) 149 | { 150 | (void)file; 151 | st->st_mode = S_IFCHR; 152 | return 0; 153 | } 154 | 155 | int _link(char *old, char *new) 156 | { 157 | (void)old; 158 | (void)new; 159 | errno = EMLINK; 160 | return -1; 161 | } 162 | 163 | int _fork(void) 164 | { 165 | errno = EAGAIN; 166 | return -1; 167 | } 168 | 169 | int _execve(char *name, char **argv, char **env) 170 | { 171 | (void)name; 172 | (void)argv; 173 | (void)env; 174 | errno = ENOMEM; 175 | return -1; 176 | } 177 | -------------------------------------------------------------------------------- /Core/Src/sysmem.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file sysmem.c 4 | * @author Generated by STM32CubeIDE 5 | * @brief STM32CubeIDE System Memory calls file 6 | * 7 | * For more information about which C functions 8 | * need which of these lowlevel functions 9 | * please consult the newlib libc manual 10 | ****************************************************************************** 11 | * @attention 12 | * 13 | * Copyright (c) 2023 STMicroelectronics. 14 | * All rights reserved. 15 | * 16 | * This software is licensed under terms that can be found in the LICENSE file 17 | * in the root directory of this software component. 18 | * If no LICENSE file comes with this software, it is provided AS-IS. 19 | * 20 | ****************************************************************************** 21 | */ 22 | 23 | /* Includes */ 24 | #include 25 | #include 26 | 27 | /** 28 | * Pointer to the current high watermark of the heap usage 29 | */ 30 | static uint8_t *__sbrk_heap_end = NULL; 31 | 32 | /** 33 | * @brief _sbrk() allocates memory to the newlib heap and is used by malloc 34 | * and others from the C library 35 | * 36 | * @verbatim 37 | * ############################################################################ 38 | * # .data # .bss # newlib heap # MSP stack # 39 | * # # # # Reserved by _Min_Stack_Size # 40 | * ############################################################################ 41 | * ^-- RAM start ^-- _end _estack, RAM end --^ 42 | * @endverbatim 43 | * 44 | * This implementation starts allocating at the '_end' linker symbol 45 | * The '_Min_Stack_Size' linker symbol reserves a memory for the MSP stack 46 | * The implementation considers '_estack' linker symbol to be RAM end 47 | * NOTE: If the MSP stack, at any point during execution, grows larger than the 48 | * reserved size, please increase the '_Min_Stack_Size'. 49 | * 50 | * @param incr Memory size 51 | * @return Pointer to allocated memory 52 | */ 53 | void *_sbrk(ptrdiff_t incr) 54 | { 55 | extern uint8_t _end; /* Symbol defined in the linker script */ 56 | extern uint8_t _estack; /* Symbol defined in the linker script */ 57 | extern uint32_t _Min_Stack_Size; /* Symbol defined in the linker script */ 58 | const uint32_t stack_limit = (uint32_t)&_estack - (uint32_t)&_Min_Stack_Size; 59 | const uint8_t *max_heap = (uint8_t *)stack_limit; 60 | uint8_t *prev_heap_end; 61 | 62 | /* Initialize heap end at first call */ 63 | if (NULL == __sbrk_heap_end) 64 | { 65 | __sbrk_heap_end = &_end; 66 | } 67 | 68 | /* Protect heap from growing into the reserved MSP stack */ 69 | if (__sbrk_heap_end + incr > max_heap) 70 | { 71 | errno = ENOMEM; 72 | return (void *)-1; 73 | } 74 | 75 | prev_heap_end = __sbrk_heap_end; 76 | __sbrk_heap_end += incr; 77 | 78 | return (void *)prev_heap_end; 79 | } 80 | -------------------------------------------------------------------------------- /Core/Src/systick.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020-2023 Piotr Wilkon 3 | 4 | This file is part of VP-Digi. 5 | 6 | VP-Digi is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | VP-Digi is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with VP-Digi. If not, see . 18 | */ 19 | 20 | #include "stm32f1xx.h" 21 | #include "systick.h" 22 | 23 | volatile uint32_t ticks = 0; //SysTick counter 24 | 25 | //with HAL enabled, the handler is in stm32f1xx_it.c 26 | //void SysTick_Handler(void) 27 | //{ 28 | //ticks++; 29 | //} 30 | 31 | void SysTickInit(void) 32 | { 33 | SysTick_Config(SystemCoreClock / SYSTICK_FREQUENCY); //SysTick every 10 ms 34 | } 35 | 36 | uint32_t SysTickGet(void) 37 | { 38 | return ticks; 39 | } 40 | 41 | void Delay(uint32_t ms) 42 | { 43 | uint32_t target = SysTickGet() + ms / SYSTICK_INTERVAL; 44 | while(target > SysTickGet()) 45 | ; 46 | } 47 | -------------------------------------------------------------------------------- /Core/Src/uart.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020-2023 Piotr Wilkon 3 | This file is part of VP-Digi. 4 | 5 | VP-Digi is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | VP-Digi is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with VP-Digi. If not, see . 17 | */ 18 | 19 | #include "terminal.h" 20 | #include "ax25.h" 21 | #include "common.h" 22 | #include 23 | #include 24 | #include 25 | #include "digipeater.h" 26 | #include "kiss.h" 27 | 28 | Uart Uart1 = {.defaultMode = MODE_KISS}, Uart2 = {.defaultMode = MODE_KISS}, UartUsb= {.defaultMode = MODE_KISS}; 29 | 30 | static void handleInterrupt(Uart *port) 31 | { 32 | if(UART_LL_CHECK_RX_NOT_EMPTY(port->port)) //byte received 33 | { 34 | UART_LL_CLEAR_RX_NOT_EMPTY(port->port); 35 | uint8_t data = port->port->DR; 36 | port->rxBuffer[port->rxBufferHead++] = data; //store it 37 | port->rxBufferHead %= UART_BUFFER_SIZE; 38 | 39 | KissParse(port, data); 40 | TermHandleSpecial(port); 41 | 42 | } 43 | if(UART_LL_CHECK_RX_IDLE(port->port)) //line is idle, end of data reception 44 | { 45 | UART_LL_GET_DATA(port->port); //reset idle flag by dummy read 46 | if(port->rxBufferHead != 0) 47 | { 48 | if(((port->rxBuffer[port->rxBufferHead - 1] == '\r') || (port->rxBuffer[port->rxBufferHead - 1] == '\n'))) //data ends with \r or \n, process as data 49 | { 50 | port->rxType = DATA_TERM; 51 | } 52 | } 53 | } 54 | if(UART_LL_CHECK_TX_EMPTY(port->port)) //TX buffer empty 55 | { 56 | if((port->txBufferHead != port->txBufferTail) || port->txBufferFull) //if there is anything to transmit 57 | { 58 | UART_LL_PUT_DATA(port->port, port->txBuffer[port->txBufferTail++]); 59 | port->txBufferTail %= UART_BUFFER_SIZE; 60 | port->txBufferFull = 0; 61 | } 62 | else //nothing more to be transmitted 63 | { 64 | UART_LL_DISABLE_TX_EMPTY_INTERRUPT(port->port); 65 | } 66 | } 67 | } 68 | 69 | void UART_LL_UART1_INTERUPT_HANDLER(void) __attribute__ ((interrupt)); 70 | void UART_LL_UART1_INTERUPT_HANDLER(void) 71 | { 72 | handleInterrupt(&Uart1); 73 | } 74 | 75 | void UART_LL_UART2_INTERUPT_HANDLER(void) __attribute__ ((interrupt)); 76 | void UART_LL_UART2_INTERUPT_HANDLER(void) 77 | { 78 | handleInterrupt(&Uart2); 79 | } 80 | 81 | 82 | void UartSendByte(Uart *port, uint8_t data) 83 | { 84 | if(!port->enabled) 85 | return; 86 | 87 | if(port->isUsb) 88 | { 89 | CDC_Transmit_FS(&data, 1); 90 | } 91 | else 92 | { 93 | while(port->txBufferFull) 94 | ; 95 | port->txBuffer[port->txBufferHead++] = data; 96 | port->txBufferHead %= UART_BUFFER_SIZE; 97 | __disable_irq(); 98 | if(port->txBufferHead == port->txBufferTail) 99 | port->txBufferFull = 1; 100 | if(0 == (UART_LL_CHECK_ENABLED_TX_EMPTY_INTERRUPT(port->port))) 101 | UART_LL_ENABLE_TX_EMPTY_INTERRUPT(port->port); 102 | __enable_irq(); 103 | } 104 | } 105 | 106 | 107 | void UartSendString(Uart *port, void *data, uint16_t len) 108 | { 109 | if(0 == len) 110 | len = strlen((char*)data); 111 | 112 | for(uint16_t i = 0; i < len; i++) 113 | { 114 | UartSendByte(port, ((uint8_t*)data)[i]); 115 | } 116 | } 117 | 118 | 119 | static unsigned int findHighestPosition(unsigned int n) 120 | { 121 | unsigned int i = 1; 122 | while((i * 10) <= n) 123 | i *= 10; 124 | 125 | return i; 126 | } 127 | 128 | void UartSendNumber(Uart *port, int32_t n) 129 | { 130 | if(n < 0) 131 | UartSendByte(port, '-'); 132 | n = abs(n); 133 | unsigned int position = findHighestPosition(n); 134 | while(position) 135 | { 136 | unsigned int number = n / position; 137 | UartSendByte(port, (number + 48)); 138 | n -= (number * position); 139 | position /= 10; 140 | } 141 | } 142 | 143 | void UartInit(Uart *port, USART_TypeDef *uart, uint32_t baud) 144 | { 145 | port->port = uart; 146 | port->baudrate = baud; 147 | port->rxType = DATA_NOTHING; 148 | port->rxBufferHead = 0; 149 | port->txBufferHead = 0; 150 | port->txBufferTail = 0; 151 | port->txBufferFull = 0; 152 | if(port->defaultMode > MODE_MONITOR) 153 | port->defaultMode = MODE_KISS; 154 | port->mode = port->defaultMode; 155 | port->enabled = 0; 156 | port->kissBufferHead = 0; 157 | port->lastRxBufferHead = 0; 158 | memset((void*)port->rxBuffer, 0, sizeof(port->rxBuffer)); 159 | memset((void*)port->txBuffer, 0, sizeof(port->txBuffer)); 160 | memset((void*)port->kissBuffer, 0, sizeof(port->kissBuffer)); 161 | } 162 | 163 | 164 | void UartConfig(Uart *port, uint8_t state) 165 | { 166 | if(port->port == UART_LL_UART1_STRUCTURE) 167 | { 168 | UART_LL_UART1_INITIALIZE_PERIPHERAL(port->baudrate); 169 | 170 | if(state) 171 | { 172 | UART_LL_ENABLE(port->port); 173 | } 174 | else 175 | { 176 | UART_LL_DISABLE(port->port); 177 | } 178 | 179 | NVIC_SetPriority(UART_LL_UART1_IRQ, 2); 180 | if(state) 181 | NVIC_EnableIRQ(UART_LL_UART1_IRQ); 182 | else 183 | NVIC_DisableIRQ(UART_LL_UART1_IRQ); 184 | 185 | port->enabled = state > 0; 186 | port->isUsb = 0; 187 | } 188 | else if(port->port == UART_LL_UART2_STRUCTURE) 189 | { 190 | UART_LL_UART2_INITIALIZE_PERIPHERAL(port->baudrate); 191 | 192 | if(state) 193 | { 194 | UART_LL_ENABLE(port->port); 195 | } 196 | else 197 | { 198 | UART_LL_DISABLE(port->port); 199 | } 200 | 201 | NVIC_SetPriority(UART_LL_UART2_IRQ, 2); 202 | if(state) 203 | NVIC_EnableIRQ(UART_LL_UART2_IRQ); 204 | else 205 | NVIC_DisableIRQ(UART_LL_UART2_IRQ); 206 | 207 | port->enabled = state > 0; 208 | port->isUsb = 0; 209 | } 210 | else 211 | { 212 | port->isUsb = 1; 213 | port->enabled = state > 0; 214 | } 215 | 216 | } 217 | 218 | 219 | void UartClearRx(Uart *port) 220 | { 221 | __disable_irq(); 222 | port->rxBufferHead = 0; 223 | port->rxType = DATA_NOTHING; 224 | __enable_irq(); 225 | } 226 | 227 | -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Include/system_stm32f1xx.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32f1xx.h 4 | * @author MCD Application Team 5 | * @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Header File. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2017-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 | 19 | /** @addtogroup CMSIS 20 | * @{ 21 | */ 22 | 23 | /** @addtogroup stm32f10x_system 24 | * @{ 25 | */ 26 | 27 | /** 28 | * @brief Define to prevent recursive inclusion 29 | */ 30 | #ifndef __SYSTEM_STM32F10X_H 31 | #define __SYSTEM_STM32F10X_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /** @addtogroup STM32F10x_System_Includes 38 | * @{ 39 | */ 40 | 41 | /** 42 | * @} 43 | */ 44 | 45 | 46 | /** @addtogroup STM32F10x_System_Exported_types 47 | * @{ 48 | */ 49 | 50 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 51 | extern const uint8_t AHBPrescTable[16U]; /*!< AHB prescalers table values */ 52 | extern const uint8_t APBPrescTable[8U]; /*!< APB prescalers table values */ 53 | 54 | /** 55 | * @} 56 | */ 57 | 58 | /** @addtogroup STM32F10x_System_Exported_Constants 59 | * @{ 60 | */ 61 | 62 | /** 63 | * @} 64 | */ 65 | 66 | /** @addtogroup STM32F10x_System_Exported_Macros 67 | * @{ 68 | */ 69 | 70 | /** 71 | * @} 72 | */ 73 | 74 | /** @addtogroup STM32F10x_System_Exported_Functions 75 | * @{ 76 | */ 77 | 78 | extern void SystemInit(void); 79 | extern void SystemCoreClockUpdate(void); 80 | /** 81 | * @} 82 | */ 83 | 84 | #ifdef __cplusplus 85 | } 86 | #endif 87 | 88 | #endif /*__SYSTEM_STM32F10X_H */ 89 | 90 | /** 91 | * @} 92 | */ 93 | 94 | /** 95 | * @} 96 | */ 97 | -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/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 | -------------------------------------------------------------------------------- /Drivers/CMSIS/Include/cmsis_compiler.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file cmsis_compiler.h 3 | * @brief CMSIS compiler generic header file 4 | * @version V5.0.4 5 | * @date 10. January 2018 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2009-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 | #ifndef __CMSIS_COMPILER_H 26 | #define __CMSIS_COMPILER_H 27 | 28 | #include 29 | 30 | /* 31 | * Arm Compiler 4/5 32 | */ 33 | #if defined ( __CC_ARM ) 34 | #include "cmsis_armcc.h" 35 | 36 | 37 | /* 38 | * Arm Compiler 6 (armclang) 39 | */ 40 | #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 41 | #include "cmsis_armclang.h" 42 | 43 | 44 | /* 45 | * GNU Compiler 46 | */ 47 | #elif defined ( __GNUC__ ) 48 | #include "cmsis_gcc.h" 49 | 50 | 51 | /* 52 | * IAR Compiler 53 | */ 54 | #elif defined ( __ICCARM__ ) 55 | #include 56 | 57 | 58 | /* 59 | * TI Arm Compiler 60 | */ 61 | #elif defined ( __TI_ARM__ ) 62 | #include 63 | 64 | #ifndef __ASM 65 | #define __ASM __asm 66 | #endif 67 | #ifndef __INLINE 68 | #define __INLINE inline 69 | #endif 70 | #ifndef __STATIC_INLINE 71 | #define __STATIC_INLINE static inline 72 | #endif 73 | #ifndef __STATIC_FORCEINLINE 74 | #define __STATIC_FORCEINLINE __STATIC_INLINE 75 | #endif 76 | #ifndef __NO_RETURN 77 | #define __NO_RETURN __attribute__((noreturn)) 78 | #endif 79 | #ifndef __USED 80 | #define __USED __attribute__((used)) 81 | #endif 82 | #ifndef __WEAK 83 | #define __WEAK __attribute__((weak)) 84 | #endif 85 | #ifndef __PACKED 86 | #define __PACKED __attribute__((packed)) 87 | #endif 88 | #ifndef __PACKED_STRUCT 89 | #define __PACKED_STRUCT struct __attribute__((packed)) 90 | #endif 91 | #ifndef __PACKED_UNION 92 | #define __PACKED_UNION union __attribute__((packed)) 93 | #endif 94 | #ifndef __UNALIGNED_UINT32 /* deprecated */ 95 | struct __attribute__((packed)) T_UINT32 { uint32_t v; }; 96 | #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) 97 | #endif 98 | #ifndef __UNALIGNED_UINT16_WRITE 99 | __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; 100 | #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void*)(addr))->v) = (val)) 101 | #endif 102 | #ifndef __UNALIGNED_UINT16_READ 103 | __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; 104 | #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) 105 | #endif 106 | #ifndef __UNALIGNED_UINT32_WRITE 107 | __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; 108 | #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) 109 | #endif 110 | #ifndef __UNALIGNED_UINT32_READ 111 | __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; 112 | #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) 113 | #endif 114 | #ifndef __ALIGNED 115 | #define __ALIGNED(x) __attribute__((aligned(x))) 116 | #endif 117 | #ifndef __RESTRICT 118 | #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored. 119 | #define __RESTRICT 120 | #endif 121 | 122 | 123 | /* 124 | * TASKING Compiler 125 | */ 126 | #elif defined ( __TASKING__ ) 127 | /* 128 | * The CMSIS functions have been implemented as intrinsics in the compiler. 129 | * Please use "carm -?i" to get an up to date list of all intrinsics, 130 | * Including the CMSIS ones. 131 | */ 132 | 133 | #ifndef __ASM 134 | #define __ASM __asm 135 | #endif 136 | #ifndef __INLINE 137 | #define __INLINE inline 138 | #endif 139 | #ifndef __STATIC_INLINE 140 | #define __STATIC_INLINE static inline 141 | #endif 142 | #ifndef __STATIC_FORCEINLINE 143 | #define __STATIC_FORCEINLINE __STATIC_INLINE 144 | #endif 145 | #ifndef __NO_RETURN 146 | #define __NO_RETURN __attribute__((noreturn)) 147 | #endif 148 | #ifndef __USED 149 | #define __USED __attribute__((used)) 150 | #endif 151 | #ifndef __WEAK 152 | #define __WEAK __attribute__((weak)) 153 | #endif 154 | #ifndef __PACKED 155 | #define __PACKED __packed__ 156 | #endif 157 | #ifndef __PACKED_STRUCT 158 | #define __PACKED_STRUCT struct __packed__ 159 | #endif 160 | #ifndef __PACKED_UNION 161 | #define __PACKED_UNION union __packed__ 162 | #endif 163 | #ifndef __UNALIGNED_UINT32 /* deprecated */ 164 | struct __packed__ T_UINT32 { uint32_t v; }; 165 | #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) 166 | #endif 167 | #ifndef __UNALIGNED_UINT16_WRITE 168 | __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; 169 | #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) 170 | #endif 171 | #ifndef __UNALIGNED_UINT16_READ 172 | __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; 173 | #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) 174 | #endif 175 | #ifndef __UNALIGNED_UINT32_WRITE 176 | __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; 177 | #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) 178 | #endif 179 | #ifndef __UNALIGNED_UINT32_READ 180 | __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; 181 | #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) 182 | #endif 183 | #ifndef __ALIGNED 184 | #define __ALIGNED(x) __align(x) 185 | #endif 186 | #ifndef __RESTRICT 187 | #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored. 188 | #define __RESTRICT 189 | #endif 190 | 191 | 192 | /* 193 | * COSMIC Compiler 194 | */ 195 | #elif defined ( __CSMC__ ) 196 | #include 197 | 198 | #ifndef __ASM 199 | #define __ASM _asm 200 | #endif 201 | #ifndef __INLINE 202 | #define __INLINE inline 203 | #endif 204 | #ifndef __STATIC_INLINE 205 | #define __STATIC_INLINE static inline 206 | #endif 207 | #ifndef __STATIC_FORCEINLINE 208 | #define __STATIC_FORCEINLINE __STATIC_INLINE 209 | #endif 210 | #ifndef __NO_RETURN 211 | // NO RETURN is automatically detected hence no warning here 212 | #define __NO_RETURN 213 | #endif 214 | #ifndef __USED 215 | #warning No compiler specific solution for __USED. __USED is ignored. 216 | #define __USED 217 | #endif 218 | #ifndef __WEAK 219 | #define __WEAK __weak 220 | #endif 221 | #ifndef __PACKED 222 | #define __PACKED @packed 223 | #endif 224 | #ifndef __PACKED_STRUCT 225 | #define __PACKED_STRUCT @packed struct 226 | #endif 227 | #ifndef __PACKED_UNION 228 | #define __PACKED_UNION @packed union 229 | #endif 230 | #ifndef __UNALIGNED_UINT32 /* deprecated */ 231 | @packed struct T_UINT32 { uint32_t v; }; 232 | #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) 233 | #endif 234 | #ifndef __UNALIGNED_UINT16_WRITE 235 | __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; 236 | #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) 237 | #endif 238 | #ifndef __UNALIGNED_UINT16_READ 239 | __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; 240 | #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) 241 | #endif 242 | #ifndef __UNALIGNED_UINT32_WRITE 243 | __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; 244 | #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) 245 | #endif 246 | #ifndef __UNALIGNED_UINT32_READ 247 | __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; 248 | #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) 249 | #endif 250 | #ifndef __ALIGNED 251 | #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored. 252 | #define __ALIGNED(x) 253 | #endif 254 | #ifndef __RESTRICT 255 | #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored. 256 | #define __RESTRICT 257 | #endif 258 | 259 | 260 | #else 261 | #error Unknown compiler. 262 | #endif 263 | 264 | 265 | #endif /* __CMSIS_COMPILER_H */ 266 | 267 | -------------------------------------------------------------------------------- /Drivers/CMSIS/Include/cmsis_version.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file cmsis_version.h 3 | * @brief CMSIS Core(M) Version definitions 4 | * @version V5.0.2 5 | * @date 19. April 2017 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2009-2017 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 ( 1U) /*!< [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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_def.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f1xx_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) 2017 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 __STM32F1xx_HAL_DEF 22 | #define __STM32F1xx_HAL_DEF 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "stm32f1xx.h" 30 | #include "Legacy/stm32_hal_legacy.h" 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 macro ------------------------------------------------------------*/ 56 | #define HAL_MAX_DELAY 0xFFFFFFFFU 57 | 58 | #define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) != 0U) 59 | #define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == 0U) 60 | 61 | #define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__) \ 62 | do{ \ 63 | (__HANDLE__)->__PPP_DMA_FIELD__ = &(__DMA_HANDLE__); \ 64 | (__DMA_HANDLE__).Parent = (__HANDLE__); \ 65 | } while(0U) 66 | 67 | #if !defined(UNUSED) 68 | #define UNUSED(X) (void)X /* To avoid gcc/g++ warnings */ 69 | #endif /* UNUSED */ 70 | 71 | /** @brief Reset the Handle's State field. 72 | * @param __HANDLE__ specifies the Peripheral Handle. 73 | * @note This macro can be used for the following purpose: 74 | * - When the Handle is declared as local variable; before passing it as parameter 75 | * to HAL_PPP_Init() for the first time, it is mandatory to use this macro 76 | * to set to 0 the Handle's "State" field. 77 | * Otherwise, "State" field may have any random value and the first time the function 78 | * HAL_PPP_Init() is called, the low level hardware initialization will be missed 79 | * (i.e. HAL_PPP_MspInit() will not be executed). 80 | * - When there is a need to reconfigure the low level hardware: instead of calling 81 | * HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init(). 82 | * In this later function, when the Handle's "State" field is set to 0, it will execute the function 83 | * HAL_PPP_MspInit() which will reconfigure the low level hardware. 84 | * @retval None 85 | */ 86 | #define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0U) 87 | 88 | #if (USE_RTOS == 1U) 89 | /* Reserved for future use */ 90 | #error "USE_RTOS should be 0 in the current HAL release" 91 | #else 92 | #define __HAL_LOCK(__HANDLE__) \ 93 | do{ \ 94 | if((__HANDLE__)->Lock == HAL_LOCKED) \ 95 | { \ 96 | return HAL_BUSY; \ 97 | } \ 98 | else \ 99 | { \ 100 | (__HANDLE__)->Lock = HAL_LOCKED; \ 101 | } \ 102 | }while (0U) 103 | 104 | #define __HAL_UNLOCK(__HANDLE__) \ 105 | do{ \ 106 | (__HANDLE__)->Lock = HAL_UNLOCKED; \ 107 | }while (0U) 108 | #endif /* USE_RTOS */ 109 | 110 | #if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) /* ARM Compiler V6 */ 111 | #ifndef __weak 112 | #define __weak __attribute__((weak)) 113 | #endif 114 | #ifndef __packed 115 | #define __packed __attribute__((packed)) 116 | #endif 117 | #elif defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */ 118 | #ifndef __weak 119 | #define __weak __attribute__((weak)) 120 | #endif /* __weak */ 121 | #ifndef __packed 122 | #define __packed __attribute__((__packed__)) 123 | #endif /* __packed */ 124 | #endif /* __GNUC__ */ 125 | 126 | 127 | /* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */ 128 | #if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) /* ARM Compiler V6 */ 129 | #ifndef __ALIGN_BEGIN 130 | #define __ALIGN_BEGIN 131 | #endif 132 | #ifndef __ALIGN_END 133 | #define __ALIGN_END __attribute__ ((aligned (4))) 134 | #endif 135 | #elif defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */ 136 | #ifndef __ALIGN_END 137 | #define __ALIGN_END __attribute__ ((aligned (4))) 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 | #if defined (__CC_ARM) /* ARM Compiler V5*/ 148 | #define __ALIGN_BEGIN __align(4) 149 | #elif defined (__ICCARM__) /* IAR Compiler */ 150 | #define __ALIGN_BEGIN 151 | #endif /* __CC_ARM */ 152 | #endif /* __ALIGN_BEGIN */ 153 | #endif /* __GNUC__ */ 154 | 155 | 156 | /** 157 | * @brief __RAM_FUNC definition 158 | */ 159 | #if defined ( __CC_ARM ) || (defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) 160 | /* ARM Compiler V4/V5 and V6 161 | -------------------------- 162 | RAM functions are defined using the toolchain options. 163 | Functions that are executed in RAM should reside in a separate source module. 164 | Using the 'Options for File' dialog you can simply change the 'Code / Const' 165 | area of a module to a memory space in physical RAM. 166 | Available memory areas are declared in the 'Target' tab of the 'Options for Target' 167 | dialog. 168 | */ 169 | #define __RAM_FUNC 170 | 171 | #elif defined ( __ICCARM__ ) 172 | /* ICCARM Compiler 173 | --------------- 174 | RAM functions are defined using a specific toolchain keyword "__ramfunc". 175 | */ 176 | #define __RAM_FUNC __ramfunc 177 | 178 | #elif defined ( __GNUC__ ) 179 | /* GNU Compiler 180 | ------------ 181 | RAM functions are defined using a specific toolchain attribute 182 | "__attribute__((section(".RamFunc")))". 183 | */ 184 | #define __RAM_FUNC __attribute__((section(".RamFunc"))) 185 | 186 | #endif 187 | 188 | /** 189 | * @brief __NOINLINE definition 190 | */ 191 | #if defined ( __CC_ARM ) || (defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) || defined ( __GNUC__ ) 192 | /* ARM V4/V5 and V6 & GNU Compiler 193 | ------------------------------- 194 | */ 195 | #define __NOINLINE __attribute__ ( (noinline) ) 196 | 197 | #elif defined ( __ICCARM__ ) 198 | /* ICCARM Compiler 199 | --------------- 200 | */ 201 | #define __NOINLINE _Pragma("optimize = no_inline") 202 | 203 | #endif 204 | 205 | #ifdef __cplusplus 206 | } 207 | #endif 208 | 209 | #endif /* ___STM32F1xx_HAL_DEF */ 210 | 211 | 212 | -------------------------------------------------------------------------------- /Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_pcd_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f1xx_hal_pcd_ex.h 4 | * @author MCD Application Team 5 | * @brief Header file of PCD HAL Extension module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2016 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 STM32F1xx_HAL_PCD_EX_H 21 | #define STM32F1xx_HAL_PCD_EX_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif /* __cplusplus */ 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "stm32f1xx_hal_def.h" 29 | 30 | #if defined (USB) || defined (USB_OTG_FS) 31 | /** @addtogroup STM32F1xx_HAL_Driver 32 | * @{ 33 | */ 34 | 35 | /** @addtogroup PCDEx 36 | * @{ 37 | */ 38 | /* Exported types ------------------------------------------------------------*/ 39 | /* Exported constants --------------------------------------------------------*/ 40 | /* Exported macros -----------------------------------------------------------*/ 41 | /* Exported functions --------------------------------------------------------*/ 42 | /** @addtogroup PCDEx_Exported_Functions PCDEx Exported Functions 43 | * @{ 44 | */ 45 | /** @addtogroup PCDEx_Exported_Functions_Group1 Peripheral Control functions 46 | * @{ 47 | */ 48 | 49 | #if defined (USB_OTG_FS) 50 | HAL_StatusTypeDef HAL_PCDEx_SetTxFiFo(PCD_HandleTypeDef *hpcd, uint8_t fifo, uint16_t size); 51 | HAL_StatusTypeDef HAL_PCDEx_SetRxFiFo(PCD_HandleTypeDef *hpcd, uint16_t size); 52 | #endif /* defined (USB_OTG_FS) */ 53 | 54 | #if defined (USB) 55 | HAL_StatusTypeDef HAL_PCDEx_PMAConfig(PCD_HandleTypeDef *hpcd, uint16_t ep_addr, 56 | uint16_t ep_kind, uint32_t pmaadress); 57 | 58 | void HAL_PCDEx_SetConnectionState(PCD_HandleTypeDef *hpcd, uint8_t state); 59 | #endif /* defined (USB) */ 60 | void HAL_PCDEx_LPM_Callback(PCD_HandleTypeDef *hpcd, PCD_LPM_MsgTypeDef msg); 61 | void HAL_PCDEx_BCD_Callback(PCD_HandleTypeDef *hpcd, PCD_BCD_MsgTypeDef msg); 62 | 63 | /** 64 | * @} 65 | */ 66 | 67 | /** 68 | * @} 69 | */ 70 | 71 | /** 72 | * @} 73 | */ 74 | 75 | /** 76 | * @} 77 | */ 78 | #endif /* defined (USB) || defined (USB_OTG_FS) */ 79 | 80 | #ifdef __cplusplus 81 | } 82 | #endif /* __cplusplus */ 83 | 84 | 85 | #endif /* STM32F1xx_HAL_PCD_EX_H */ 86 | -------------------------------------------------------------------------------- /Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_utils.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f1xx_ll_utils.h 4 | * @author MCD Application Team 5 | * @brief Header file of UTILS LL module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2016 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 | @verbatim 18 | ============================================================================== 19 | ##### How to use this driver ##### 20 | ============================================================================== 21 | [..] 22 | The LL UTILS driver contains a set of generic APIs that can be 23 | used by user: 24 | (+) Device electronic signature 25 | (+) Timing functions 26 | (+) PLL configuration functions 27 | 28 | @endverbatim 29 | ****************************************************************************** 30 | */ 31 | 32 | /* Define to prevent recursive inclusion -------------------------------------*/ 33 | #ifndef __STM32F1xx_LL_UTILS_H 34 | #define __STM32F1xx_LL_UTILS_H 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | /* Includes ------------------------------------------------------------------*/ 41 | #include "stm32f1xx.h" 42 | 43 | /** @addtogroup STM32F1xx_LL_Driver 44 | * @{ 45 | */ 46 | 47 | /** @defgroup UTILS_LL UTILS 48 | * @{ 49 | */ 50 | 51 | /* Private types -------------------------------------------------------------*/ 52 | /* Private variables ---------------------------------------------------------*/ 53 | 54 | /* Private constants ---------------------------------------------------------*/ 55 | /** @defgroup UTILS_LL_Private_Constants UTILS Private Constants 56 | * @{ 57 | */ 58 | 59 | /* Max delay can be used in LL_mDelay */ 60 | #define LL_MAX_DELAY 0xFFFFFFFFU 61 | 62 | /** 63 | * @brief Unique device ID register base address 64 | */ 65 | #define UID_BASE_ADDRESS UID_BASE 66 | 67 | /** 68 | * @brief Flash size data register base address 69 | */ 70 | #define FLASHSIZE_BASE_ADDRESS FLASHSIZE_BASE 71 | 72 | /** 73 | * @} 74 | */ 75 | 76 | /* Private macros ------------------------------------------------------------*/ 77 | /** @defgroup UTILS_LL_Private_Macros UTILS Private Macros 78 | * @{ 79 | */ 80 | /** 81 | * @} 82 | */ 83 | /* Exported types ------------------------------------------------------------*/ 84 | /** @defgroup UTILS_LL_ES_INIT UTILS Exported structures 85 | * @{ 86 | */ 87 | /** 88 | * @brief UTILS PLL structure definition 89 | */ 90 | typedef struct 91 | { 92 | uint32_t PLLMul; /*!< Multiplication factor for PLL VCO input clock. 93 | This parameter can be a value of @ref RCC_LL_EC_PLL_MUL 94 | 95 | This feature can be modified afterwards using unitary function 96 | @ref LL_RCC_PLL_ConfigDomain_SYS(). */ 97 | 98 | uint32_t Prediv; /*!< Division factor for HSE used as PLL clock source. 99 | This parameter can be a value of @ref RCC_LL_EC_PREDIV_DIV 100 | 101 | This feature can be modified afterwards using unitary function 102 | @ref LL_RCC_PLL_ConfigDomain_SYS(). */ 103 | } LL_UTILS_PLLInitTypeDef; 104 | 105 | /** 106 | * @brief UTILS System, AHB and APB buses clock configuration structure definition 107 | */ 108 | typedef struct 109 | { 110 | uint32_t AHBCLKDivider; /*!< The AHB clock (HCLK) divider. This clock is derived from the system clock (SYSCLK). 111 | This parameter can be a value of @ref RCC_LL_EC_SYSCLK_DIV 112 | 113 | This feature can be modified afterwards using unitary function 114 | @ref LL_RCC_SetAHBPrescaler(). */ 115 | 116 | uint32_t APB1CLKDivider; /*!< The APB1 clock (PCLK1) divider. This clock is derived from the AHB clock (HCLK). 117 | This parameter can be a value of @ref RCC_LL_EC_APB1_DIV 118 | 119 | This feature can be modified afterwards using unitary function 120 | @ref LL_RCC_SetAPB1Prescaler(). */ 121 | 122 | uint32_t APB2CLKDivider; /*!< The APB2 clock (PCLK2) divider. This clock is derived from the AHB clock (HCLK). 123 | This parameter can be a value of @ref RCC_LL_EC_APB2_DIV 124 | 125 | This feature can be modified afterwards using unitary function 126 | @ref LL_RCC_SetAPB2Prescaler(). */ 127 | 128 | } LL_UTILS_ClkInitTypeDef; 129 | 130 | /** 131 | * @} 132 | */ 133 | 134 | /* Exported constants --------------------------------------------------------*/ 135 | /** @defgroup UTILS_LL_Exported_Constants UTILS Exported Constants 136 | * @{ 137 | */ 138 | 139 | /** @defgroup UTILS_EC_HSE_BYPASS HSE Bypass activation 140 | * @{ 141 | */ 142 | #define LL_UTILS_HSEBYPASS_OFF 0x00000000U /*!< HSE Bypass is not enabled */ 143 | #define LL_UTILS_HSEBYPASS_ON 0x00000001U /*!< HSE Bypass is enabled */ 144 | /** 145 | * @} 146 | */ 147 | 148 | /** 149 | * @} 150 | */ 151 | 152 | /* Exported macro ------------------------------------------------------------*/ 153 | 154 | /* Exported functions --------------------------------------------------------*/ 155 | /** @defgroup UTILS_LL_Exported_Functions UTILS Exported Functions 156 | * @{ 157 | */ 158 | 159 | /** @defgroup UTILS_EF_DEVICE_ELECTRONIC_SIGNATURE DEVICE ELECTRONIC SIGNATURE 160 | * @{ 161 | */ 162 | 163 | /** 164 | * @brief Get Word0 of the unique device identifier (UID based on 96 bits) 165 | * @retval UID[31:0] 166 | */ 167 | __STATIC_INLINE uint32_t LL_GetUID_Word0(void) 168 | { 169 | return (uint32_t)(READ_REG(*((uint32_t *)UID_BASE_ADDRESS))); 170 | } 171 | 172 | /** 173 | * @brief Get Word1 of the unique device identifier (UID based on 96 bits) 174 | * @retval UID[63:32] 175 | */ 176 | __STATIC_INLINE uint32_t LL_GetUID_Word1(void) 177 | { 178 | return (uint32_t)(READ_REG(*((uint32_t *)(UID_BASE_ADDRESS + 4U)))); 179 | } 180 | 181 | /** 182 | * @brief Get Word2 of the unique device identifier (UID based on 96 bits) 183 | * @retval UID[95:64] 184 | */ 185 | __STATIC_INLINE uint32_t LL_GetUID_Word2(void) 186 | { 187 | return (uint32_t)(READ_REG(*((uint32_t *)(UID_BASE_ADDRESS + 8U)))); 188 | } 189 | 190 | /** 191 | * @brief Get Flash memory size 192 | * @note This bitfield indicates the size of the device Flash memory expressed in 193 | * Kbytes. As an example, 0x040 corresponds to 64 Kbytes. 194 | * @retval FLASH_SIZE[15:0]: Flash memory size 195 | */ 196 | __STATIC_INLINE uint32_t LL_GetFlashSize(void) 197 | { 198 | return (uint16_t)(READ_REG(*((uint32_t *)FLASHSIZE_BASE_ADDRESS))); 199 | } 200 | 201 | 202 | /** 203 | * @} 204 | */ 205 | 206 | /** @defgroup UTILS_LL_EF_DELAY DELAY 207 | * @{ 208 | */ 209 | 210 | /** 211 | * @brief This function configures the Cortex-M SysTick source of the time base. 212 | * @param HCLKFrequency HCLK frequency in Hz (can be calculated thanks to RCC helper macro) 213 | * @note When a RTOS is used, it is recommended to avoid changing the SysTick 214 | * configuration by calling this function, for a delay use rather osDelay RTOS service. 215 | * @param Ticks Number of ticks 216 | * @retval None 217 | */ 218 | __STATIC_INLINE void LL_InitTick(uint32_t HCLKFrequency, uint32_t Ticks) 219 | { 220 | /* Configure the SysTick to have interrupt in 1ms time base */ 221 | SysTick->LOAD = (uint32_t)((HCLKFrequency / Ticks) - 1UL); /* set reload register */ 222 | SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ 223 | SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | 224 | SysTick_CTRL_ENABLE_Msk; /* Enable the Systick Timer */ 225 | } 226 | 227 | void LL_Init1msTick(uint32_t HCLKFrequency); 228 | void LL_mDelay(uint32_t Delay); 229 | 230 | /** 231 | * @} 232 | */ 233 | 234 | /** @defgroup UTILS_EF_SYSTEM SYSTEM 235 | * @{ 236 | */ 237 | 238 | void LL_SetSystemCoreClock(uint32_t HCLKFrequency); 239 | #if defined(FLASH_ACR_LATENCY) 240 | ErrorStatus LL_SetFlashLatency(uint32_t Frequency); 241 | #endif /* FLASH_ACR_LATENCY */ 242 | ErrorStatus LL_PLL_ConfigSystemClock_HSI(LL_UTILS_PLLInitTypeDef *UTILS_PLLInitStruct, 243 | LL_UTILS_ClkInitTypeDef *UTILS_ClkInitStruct); 244 | ErrorStatus LL_PLL_ConfigSystemClock_HSE(uint32_t HSEFrequency, uint32_t HSEBypass, 245 | LL_UTILS_PLLInitTypeDef *UTILS_PLLInitStruct, LL_UTILS_ClkInitTypeDef *UTILS_ClkInitStruct); 246 | #if defined(RCC_PLL2_SUPPORT) 247 | ErrorStatus LL_PLL_ConfigSystemClock_PLL2(uint32_t HSEFrequency, uint32_t HSEBypass, LL_UTILS_PLLInitTypeDef *UTILS_PLLInitStruct, 248 | LL_UTILS_PLLInitTypeDef *UTILS_PLL2InitStruct, LL_UTILS_ClkInitTypeDef *UTILS_ClkInitStruct); 249 | #endif /* RCC_PLL2_SUPPORT */ 250 | /** 251 | * @} 252 | */ 253 | 254 | /** 255 | * @} 256 | */ 257 | 258 | /** 259 | * @} 260 | */ 261 | 262 | /** 263 | * @} 264 | */ 265 | 266 | #ifdef __cplusplus 267 | } 268 | #endif 269 | 270 | #endif /* __STM32F1xx_LL_UTILS_H */ 271 | -------------------------------------------------------------------------------- /Drivers/STM32F1xx_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 | -------------------------------------------------------------------------------- /Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f1xx_hal_gpio_ex.c 4 | * @author MCD Application Team 5 | * @brief GPIO Extension HAL module driver. 6 | * This file provides firmware functions to manage the following 7 | * functionalities of the General Purpose Input/Output (GPIO) extension peripheral. 8 | * + Extended features functions 9 | * 10 | ****************************************************************************** 11 | * @attention 12 | * 13 | * Copyright (c) 2016 STMicroelectronics. 14 | * All rights reserved. 15 | * 16 | * This software is licensed under terms that can be found in the LICENSE file 17 | * in the root directory of this software component. 18 | * If no LICENSE file comes with this software, it is provided AS-IS. 19 | * 20 | ****************************************************************************** 21 | @verbatim 22 | ============================================================================== 23 | ##### GPIO Peripheral extension features ##### 24 | ============================================================================== 25 | [..] GPIO module on STM32F1 family, manage also the AFIO register: 26 | (+) Possibility to use the EVENTOUT Cortex feature 27 | 28 | ##### How to use this driver ##### 29 | ============================================================================== 30 | [..] This driver provides functions to use EVENTOUT Cortex feature 31 | (#) Configure EVENTOUT Cortex feature using the function HAL_GPIOEx_ConfigEventout() 32 | (#) Activate EVENTOUT Cortex feature using the HAL_GPIOEx_EnableEventout() 33 | (#) Deactivate EVENTOUT Cortex feature using the HAL_GPIOEx_DisableEventout() 34 | 35 | @endverbatim 36 | ****************************************************************************** 37 | */ 38 | 39 | /* Includes ------------------------------------------------------------------*/ 40 | #include "stm32f1xx_hal.h" 41 | 42 | /** @addtogroup STM32F1xx_HAL_Driver 43 | * @{ 44 | */ 45 | 46 | /** @defgroup GPIOEx GPIOEx 47 | * @brief GPIO HAL module driver 48 | * @{ 49 | */ 50 | 51 | #ifdef HAL_GPIO_MODULE_ENABLED 52 | 53 | /** @defgroup GPIOEx_Exported_Functions GPIOEx Exported Functions 54 | * @{ 55 | */ 56 | 57 | /** @defgroup GPIOEx_Exported_Functions_Group1 Extended features functions 58 | * @brief Extended features functions 59 | * 60 | @verbatim 61 | ============================================================================== 62 | ##### Extended features functions ##### 63 | ============================================================================== 64 | [..] This section provides functions allowing to: 65 | (+) Configure EVENTOUT Cortex feature using the function HAL_GPIOEx_ConfigEventout() 66 | (+) Activate EVENTOUT Cortex feature using the HAL_GPIOEx_EnableEventout() 67 | (+) Deactivate EVENTOUT Cortex feature using the HAL_GPIOEx_DisableEventout() 68 | 69 | @endverbatim 70 | * @{ 71 | */ 72 | 73 | /** 74 | * @brief Configures the port and pin on which the EVENTOUT Cortex signal will be connected. 75 | * @param GPIO_PortSource Select the port used to output the Cortex EVENTOUT signal. 76 | * This parameter can be a value of @ref GPIOEx_EVENTOUT_PORT. 77 | * @param GPIO_PinSource Select the pin used to output the Cortex EVENTOUT signal. 78 | * This parameter can be a value of @ref GPIOEx_EVENTOUT_PIN. 79 | * @retval None 80 | */ 81 | void HAL_GPIOEx_ConfigEventout(uint32_t GPIO_PortSource, uint32_t GPIO_PinSource) 82 | { 83 | /* Verify the parameters */ 84 | assert_param(IS_AFIO_EVENTOUT_PORT(GPIO_PortSource)); 85 | assert_param(IS_AFIO_EVENTOUT_PIN(GPIO_PinSource)); 86 | 87 | /* Apply the new configuration */ 88 | MODIFY_REG(AFIO->EVCR, (AFIO_EVCR_PORT) | (AFIO_EVCR_PIN), (GPIO_PortSource) | (GPIO_PinSource)); 89 | } 90 | 91 | /** 92 | * @brief Enables the Event Output. 93 | * @retval None 94 | */ 95 | void HAL_GPIOEx_EnableEventout(void) 96 | { 97 | SET_BIT(AFIO->EVCR, AFIO_EVCR_EVOE); 98 | } 99 | 100 | /** 101 | * @brief Disables the Event Output. 102 | * @retval None 103 | */ 104 | void HAL_GPIOEx_DisableEventout(void) 105 | { 106 | CLEAR_BIT(AFIO->EVCR, AFIO_EVCR_EVOE); 107 | } 108 | 109 | /** 110 | * @} 111 | */ 112 | 113 | /** 114 | * @} 115 | */ 116 | 117 | #endif /* HAL_GPIO_MODULE_ENABLED */ 118 | 119 | /** 120 | * @} 121 | */ 122 | 123 | /** 124 | * @} 125 | */ 126 | 127 | -------------------------------------------------------------------------------- /Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pcd_ex.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f1xx_hal_pcd_ex.c 4 | * @author MCD Application Team 5 | * @brief PCD Extended HAL module driver. 6 | * This file provides firmware functions to manage the following 7 | * functionalities of the USB Peripheral Controller: 8 | * + Extended features functions 9 | * 10 | ****************************************************************************** 11 | * @attention 12 | * 13 | * Copyright (c) 2016 STMicroelectronics. 14 | * All rights reserved. 15 | * 16 | * This software is licensed under terms that can be found in the LICENSE file 17 | * in the root directory of this software component. 18 | * If no LICENSE file comes with this software, it is provided AS-IS. 19 | * 20 | ****************************************************************************** 21 | */ 22 | 23 | /* Includes ------------------------------------------------------------------*/ 24 | #include "stm32f1xx_hal.h" 25 | 26 | /** @addtogroup STM32F1xx_HAL_Driver 27 | * @{ 28 | */ 29 | 30 | /** @defgroup PCDEx PCDEx 31 | * @brief PCD Extended HAL module driver 32 | * @{ 33 | */ 34 | 35 | #ifdef HAL_PCD_MODULE_ENABLED 36 | 37 | #if defined (USB) || defined (USB_OTG_FS) 38 | /* Private types -------------------------------------------------------------*/ 39 | /* Private variables ---------------------------------------------------------*/ 40 | /* Private constants ---------------------------------------------------------*/ 41 | /* Private macros ------------------------------------------------------------*/ 42 | /* Private functions ---------------------------------------------------------*/ 43 | /* Exported functions --------------------------------------------------------*/ 44 | 45 | /** @defgroup PCDEx_Exported_Functions PCDEx Exported Functions 46 | * @{ 47 | */ 48 | 49 | /** @defgroup PCDEx_Exported_Functions_Group1 Peripheral Control functions 50 | * @brief PCDEx control functions 51 | * 52 | @verbatim 53 | =============================================================================== 54 | ##### Extended features functions ##### 55 | =============================================================================== 56 | [..] This section provides functions allowing to: 57 | (+) Update FIFO configuration 58 | 59 | @endverbatim 60 | * @{ 61 | */ 62 | #if defined (USB_OTG_FS) 63 | /** 64 | * @brief Set Tx FIFO 65 | * @param hpcd PCD handle 66 | * @param fifo The number of Tx fifo 67 | * @param size Fifo size 68 | * @retval HAL status 69 | */ 70 | HAL_StatusTypeDef HAL_PCDEx_SetTxFiFo(PCD_HandleTypeDef *hpcd, uint8_t fifo, uint16_t size) 71 | { 72 | uint8_t i; 73 | uint32_t Tx_Offset; 74 | 75 | /* TXn min size = 16 words. (n : Transmit FIFO index) 76 | When a TxFIFO is not used, the Configuration should be as follows: 77 | case 1 : n > m and Txn is not used (n,m : Transmit FIFO indexes) 78 | --> Txm can use the space allocated for Txn. 79 | case2 : n < m and Txn is not used (n,m : Transmit FIFO indexes) 80 | --> Txn should be configured with the minimum space of 16 words 81 | The FIFO is used optimally when used TxFIFOs are allocated in the top 82 | of the FIFO.Ex: use EP1 and EP2 as IN instead of EP1 and EP3 as IN ones. 83 | When DMA is used 3n * FIFO locations should be reserved for internal DMA registers */ 84 | 85 | Tx_Offset = hpcd->Instance->GRXFSIZ; 86 | 87 | if (fifo == 0U) 88 | { 89 | hpcd->Instance->DIEPTXF0_HNPTXFSIZ = ((uint32_t)size << 16) | Tx_Offset; 90 | } 91 | else 92 | { 93 | Tx_Offset += (hpcd->Instance->DIEPTXF0_HNPTXFSIZ) >> 16; 94 | for (i = 0U; i < (fifo - 1U); i++) 95 | { 96 | Tx_Offset += (hpcd->Instance->DIEPTXF[i] >> 16); 97 | } 98 | 99 | /* Multiply Tx_Size by 2 to get higher performance */ 100 | hpcd->Instance->DIEPTXF[fifo - 1U] = ((uint32_t)size << 16) | Tx_Offset; 101 | } 102 | 103 | return HAL_OK; 104 | } 105 | 106 | /** 107 | * @brief Set Rx FIFO 108 | * @param hpcd PCD handle 109 | * @param size Size of Rx fifo 110 | * @retval HAL status 111 | */ 112 | HAL_StatusTypeDef HAL_PCDEx_SetRxFiFo(PCD_HandleTypeDef *hpcd, uint16_t size) 113 | { 114 | hpcd->Instance->GRXFSIZ = size; 115 | 116 | return HAL_OK; 117 | } 118 | #endif /* defined (USB_OTG_FS) */ 119 | #if defined (USB) 120 | /** 121 | * @brief Configure PMA for EP 122 | * @param hpcd Device instance 123 | * @param ep_addr endpoint address 124 | * @param ep_kind endpoint Kind 125 | * USB_SNG_BUF: Single Buffer used 126 | * USB_DBL_BUF: Double Buffer used 127 | * @param pmaadress: EP address in The PMA: In case of single buffer endpoint 128 | * this parameter is 16-bit value providing the address 129 | * in PMA allocated to endpoint. 130 | * In case of double buffer endpoint this parameter 131 | * is a 32-bit value providing the endpoint buffer 0 address 132 | * in the LSB part of 32-bit value and endpoint buffer 1 address 133 | * in the MSB part of 32-bit value. 134 | * @retval HAL status 135 | */ 136 | 137 | HAL_StatusTypeDef HAL_PCDEx_PMAConfig(PCD_HandleTypeDef *hpcd, uint16_t ep_addr, 138 | uint16_t ep_kind, uint32_t pmaadress) 139 | { 140 | PCD_EPTypeDef *ep; 141 | 142 | /* initialize ep structure*/ 143 | if ((0x80U & ep_addr) == 0x80U) 144 | { 145 | ep = &hpcd->IN_ep[ep_addr & EP_ADDR_MSK]; 146 | } 147 | else 148 | { 149 | ep = &hpcd->OUT_ep[ep_addr]; 150 | } 151 | 152 | /* Here we check if the endpoint is single or double Buffer*/ 153 | if (ep_kind == PCD_SNG_BUF) 154 | { 155 | /* Single Buffer */ 156 | ep->doublebuffer = 0U; 157 | /* Configure the PMA */ 158 | ep->pmaadress = (uint16_t)pmaadress; 159 | } 160 | #if (USE_USB_DOUBLE_BUFFER == 1U) 161 | else /* USB_DBL_BUF */ 162 | { 163 | /* Double Buffer Endpoint */ 164 | ep->doublebuffer = 1U; 165 | /* Configure the PMA */ 166 | ep->pmaaddr0 = (uint16_t)(pmaadress & 0xFFFFU); 167 | ep->pmaaddr1 = (uint16_t)((pmaadress & 0xFFFF0000U) >> 16); 168 | } 169 | #endif /* (USE_USB_DOUBLE_BUFFER == 1U) */ 170 | 171 | return HAL_OK; 172 | } 173 | 174 | /** 175 | * @brief Software Device Connection, 176 | * this function is not required by USB OTG FS peripheral, it is used 177 | * only by USB Device FS peripheral. 178 | * @param hpcd PCD handle 179 | * @param state connection state (0 : disconnected / 1: connected) 180 | * @retval None 181 | */ 182 | __weak void HAL_PCDEx_SetConnectionState(PCD_HandleTypeDef *hpcd, uint8_t state) 183 | { 184 | /* Prevent unused argument(s) compilation warning */ 185 | UNUSED(hpcd); 186 | UNUSED(state); 187 | /* NOTE : This function Should not be modified, when the callback is needed, 188 | the HAL_PCDEx_SetConnectionState could be implemented in the user file 189 | */ 190 | } 191 | #endif /* defined (USB) */ 192 | 193 | /** 194 | * @brief Send LPM message to user layer callback. 195 | * @param hpcd PCD handle 196 | * @param msg LPM message 197 | * @retval HAL status 198 | */ 199 | __weak void HAL_PCDEx_LPM_Callback(PCD_HandleTypeDef *hpcd, PCD_LPM_MsgTypeDef msg) 200 | { 201 | /* Prevent unused argument(s) compilation warning */ 202 | UNUSED(hpcd); 203 | UNUSED(msg); 204 | 205 | /* NOTE : This function should not be modified, when the callback is needed, 206 | the HAL_PCDEx_LPM_Callback could be implemented in the user file 207 | */ 208 | } 209 | 210 | /** 211 | * @brief Send BatteryCharging message to user layer callback. 212 | * @param hpcd PCD handle 213 | * @param msg LPM message 214 | * @retval HAL status 215 | */ 216 | __weak void HAL_PCDEx_BCD_Callback(PCD_HandleTypeDef *hpcd, PCD_BCD_MsgTypeDef msg) 217 | { 218 | /* Prevent unused argument(s) compilation warning */ 219 | UNUSED(hpcd); 220 | UNUSED(msg); 221 | 222 | /* NOTE : This function should not be modified, when the callback is needed, 223 | the HAL_PCDEx_BCD_Callback could be implemented in the user file 224 | */ 225 | } 226 | 227 | /** 228 | * @} 229 | */ 230 | 231 | /** 232 | * @} 233 | */ 234 | #endif /* defined (USB) || defined (USB_OTG_FS) */ 235 | #endif /* HAL_PCD_MODULE_ENABLED */ 236 | 237 | /** 238 | * @} 239 | */ 240 | 241 | /** 242 | * @} 243 | */ 244 | -------------------------------------------------------------------------------- /F103C8T6_DIGI_USB.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | ]> 11 | 12 | 13 | 14 | F103C8T6_DIGI_USB 15 | SWD 16 | ST-Link 17 | stm32f103c8tx 18 | 19 | 20 | -------------------------------------------------------------------------------- /Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc/usbd_cdc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_cdc.h 4 | * @author MCD Application Team 5 | * @brief header file for the usbd_cdc.c file. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© Copyright (c) 2015 STMicroelectronics. 10 | * All rights reserved.

11 | * 12 | * This software component is licensed by ST under Ultimate Liberty license 13 | * SLA0044, the "License"; You may not use this file except in compliance with 14 | * the License. You may obtain a copy of the License at: 15 | * www.st.com/SLA0044 16 | * 17 | ****************************************************************************** 18 | */ 19 | 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __USB_CDC_H 22 | #define __USB_CDC_H 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "usbd_ioreq.h" 30 | 31 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 32 | * @{ 33 | */ 34 | 35 | /** @defgroup usbd_cdc 36 | * @brief This file is the Header file for usbd_cdc.c 37 | * @{ 38 | */ 39 | 40 | 41 | /** @defgroup usbd_cdc_Exported_Defines 42 | * @{ 43 | */ 44 | #define CDC_IN_EP 0x81U /* EP1 for data IN */ 45 | #define CDC_OUT_EP 0x01U /* EP1 for data OUT */ 46 | #define CDC_CMD_EP 0x82U /* EP2 for CDC commands */ 47 | 48 | #ifndef CDC_HS_BINTERVAL 49 | #define CDC_HS_BINTERVAL 0x10U 50 | #endif /* CDC_HS_BINTERVAL */ 51 | 52 | #ifndef CDC_FS_BINTERVAL 53 | #define CDC_FS_BINTERVAL 0x10U 54 | #endif /* CDC_FS_BINTERVAL */ 55 | 56 | /* CDC Endpoints parameters: you can fine tune these values depending on the needed baudrates and performance. */ 57 | #define CDC_DATA_HS_MAX_PACKET_SIZE 512U /* Endpoint IN & OUT Packet size */ 58 | #define CDC_DATA_FS_MAX_PACKET_SIZE 64U /* Endpoint IN & OUT Packet size */ 59 | #define CDC_CMD_PACKET_SIZE 8U /* Control Endpoint Packet size */ 60 | 61 | #define USB_CDC_CONFIG_DESC_SIZ 67U 62 | #define CDC_DATA_HS_IN_PACKET_SIZE CDC_DATA_HS_MAX_PACKET_SIZE 63 | #define CDC_DATA_HS_OUT_PACKET_SIZE CDC_DATA_HS_MAX_PACKET_SIZE 64 | 65 | #define CDC_DATA_FS_IN_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE 66 | #define CDC_DATA_FS_OUT_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE 67 | 68 | /*---------------------------------------------------------------------*/ 69 | /* CDC definitions */ 70 | /*---------------------------------------------------------------------*/ 71 | #define CDC_SEND_ENCAPSULATED_COMMAND 0x00U 72 | #define CDC_GET_ENCAPSULATED_RESPONSE 0x01U 73 | #define CDC_SET_COMM_FEATURE 0x02U 74 | #define CDC_GET_COMM_FEATURE 0x03U 75 | #define CDC_CLEAR_COMM_FEATURE 0x04U 76 | #define CDC_SET_LINE_CODING 0x20U 77 | #define CDC_GET_LINE_CODING 0x21U 78 | #define CDC_SET_CONTROL_LINE_STATE 0x22U 79 | #define CDC_SEND_BREAK 0x23U 80 | 81 | /** 82 | * @} 83 | */ 84 | 85 | 86 | /** @defgroup USBD_CORE_Exported_TypesDefinitions 87 | * @{ 88 | */ 89 | 90 | /** 91 | * @} 92 | */ 93 | typedef struct 94 | { 95 | uint32_t bitrate; 96 | uint8_t format; 97 | uint8_t paritytype; 98 | uint8_t datatype; 99 | } USBD_CDC_LineCodingTypeDef; 100 | 101 | typedef struct _USBD_CDC_Itf 102 | { 103 | int8_t (* Init)(void); 104 | int8_t (* DeInit)(void); 105 | int8_t (* Control)(uint8_t cmd, uint8_t *pbuf, uint16_t length); 106 | int8_t (* Receive)(uint8_t *Buf, uint32_t *Len); 107 | 108 | } USBD_CDC_ItfTypeDef; 109 | 110 | 111 | typedef struct 112 | { 113 | uint32_t data[CDC_DATA_HS_MAX_PACKET_SIZE / 4U]; /* Force 32bits alignment */ 114 | uint8_t CmdOpCode; 115 | uint8_t CmdLength; 116 | uint8_t *RxBuffer; 117 | uint8_t *TxBuffer; 118 | uint32_t RxLength; 119 | uint32_t TxLength; 120 | 121 | __IO uint32_t TxState; 122 | __IO uint32_t RxState; 123 | } 124 | USBD_CDC_HandleTypeDef; 125 | 126 | 127 | 128 | /** @defgroup USBD_CORE_Exported_Macros 129 | * @{ 130 | */ 131 | 132 | /** 133 | * @} 134 | */ 135 | 136 | /** @defgroup USBD_CORE_Exported_Variables 137 | * @{ 138 | */ 139 | 140 | extern USBD_ClassTypeDef USBD_CDC; 141 | #define USBD_CDC_CLASS &USBD_CDC 142 | /** 143 | * @} 144 | */ 145 | 146 | /** @defgroup USB_CORE_Exported_Functions 147 | * @{ 148 | */ 149 | uint8_t USBD_CDC_RegisterInterface(USBD_HandleTypeDef *pdev, 150 | USBD_CDC_ItfTypeDef *fops); 151 | 152 | uint8_t USBD_CDC_SetTxBuffer(USBD_HandleTypeDef *pdev, 153 | uint8_t *pbuff, 154 | uint16_t length); 155 | 156 | uint8_t USBD_CDC_SetRxBuffer(USBD_HandleTypeDef *pdev, 157 | uint8_t *pbuff); 158 | 159 | uint8_t USBD_CDC_ReceivePacket(USBD_HandleTypeDef *pdev); 160 | 161 | uint8_t USBD_CDC_TransmitPacket(USBD_HandleTypeDef *pdev); 162 | /** 163 | * @} 164 | */ 165 | 166 | #ifdef __cplusplus 167 | } 168 | #endif 169 | 170 | #endif /* __USB_CDC_H */ 171 | /** 172 | * @} 173 | */ 174 | 175 | /** 176 | * @} 177 | */ 178 | 179 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 180 | -------------------------------------------------------------------------------- /Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_core.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_core.h 4 | * @author MCD Application Team 5 | * @brief Header file for usbd_core.c file 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© Copyright (c) 2015 STMicroelectronics. 10 | * All rights reserved.

11 | * 12 | * This software component is licensed by ST under Ultimate Liberty license 13 | * SLA0044, the "License"; You may not use this file except in compliance with 14 | * the License. You may obtain a copy of the License at: 15 | * www.st.com/SLA0044 16 | * 17 | ****************************************************************************** 18 | */ 19 | 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __USBD_CORE_H 22 | #define __USBD_CORE_H 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "usbd_conf.h" 30 | #include "usbd_def.h" 31 | #include "usbd_ioreq.h" 32 | #include "usbd_ctlreq.h" 33 | 34 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 35 | * @{ 36 | */ 37 | 38 | /** @defgroup USBD_CORE 39 | * @brief This file is the Header file for usbd_core.c file 40 | * @{ 41 | */ 42 | 43 | 44 | /** @defgroup USBD_CORE_Exported_Defines 45 | * @{ 46 | */ 47 | #ifndef USBD_DEBUG_LEVEL 48 | #define USBD_DEBUG_LEVEL 0U 49 | #endif /* USBD_DEBUG_LEVEL */ 50 | /** 51 | * @} 52 | */ 53 | 54 | 55 | /** @defgroup USBD_CORE_Exported_TypesDefinitions 56 | * @{ 57 | */ 58 | 59 | 60 | /** 61 | * @} 62 | */ 63 | 64 | 65 | 66 | /** @defgroup USBD_CORE_Exported_Macros 67 | * @{ 68 | */ 69 | 70 | /** 71 | * @} 72 | */ 73 | 74 | /** @defgroup USBD_CORE_Exported_Variables 75 | * @{ 76 | */ 77 | #define USBD_SOF USBD_LL_SOF 78 | /** 79 | * @} 80 | */ 81 | 82 | /** @defgroup USBD_CORE_Exported_FunctionsPrototype 83 | * @{ 84 | */ 85 | USBD_StatusTypeDef USBD_Init(USBD_HandleTypeDef *pdev, USBD_DescriptorsTypeDef *pdesc, uint8_t id); 86 | USBD_StatusTypeDef USBD_DeInit(USBD_HandleTypeDef *pdev); 87 | USBD_StatusTypeDef USBD_Start(USBD_HandleTypeDef *pdev); 88 | USBD_StatusTypeDef USBD_Stop(USBD_HandleTypeDef *pdev); 89 | USBD_StatusTypeDef USBD_RegisterClass(USBD_HandleTypeDef *pdev, USBD_ClassTypeDef *pclass); 90 | 91 | USBD_StatusTypeDef USBD_RunTestMode(USBD_HandleTypeDef *pdev); 92 | USBD_StatusTypeDef USBD_SetClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx); 93 | USBD_StatusTypeDef USBD_ClrClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx); 94 | 95 | USBD_StatusTypeDef USBD_LL_SetupStage(USBD_HandleTypeDef *pdev, uint8_t *psetup); 96 | USBD_StatusTypeDef USBD_LL_DataOutStage(USBD_HandleTypeDef *pdev, uint8_t epnum, uint8_t *pdata); 97 | USBD_StatusTypeDef USBD_LL_DataInStage(USBD_HandleTypeDef *pdev, uint8_t epnum, uint8_t *pdata); 98 | 99 | USBD_StatusTypeDef USBD_LL_Reset(USBD_HandleTypeDef *pdev); 100 | USBD_StatusTypeDef USBD_LL_SetSpeed(USBD_HandleTypeDef *pdev, USBD_SpeedTypeDef speed); 101 | USBD_StatusTypeDef USBD_LL_Suspend(USBD_HandleTypeDef *pdev); 102 | USBD_StatusTypeDef USBD_LL_Resume(USBD_HandleTypeDef *pdev); 103 | 104 | USBD_StatusTypeDef USBD_LL_SOF(USBD_HandleTypeDef *pdev); 105 | USBD_StatusTypeDef USBD_LL_IsoINIncomplete(USBD_HandleTypeDef *pdev, uint8_t epnum); 106 | USBD_StatusTypeDef USBD_LL_IsoOUTIncomplete(USBD_HandleTypeDef *pdev, uint8_t epnum); 107 | 108 | USBD_StatusTypeDef USBD_LL_DevConnected(USBD_HandleTypeDef *pdev); 109 | USBD_StatusTypeDef USBD_LL_DevDisconnected(USBD_HandleTypeDef *pdev); 110 | 111 | /* USBD Low Level Driver */ 112 | USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev); 113 | USBD_StatusTypeDef USBD_LL_DeInit(USBD_HandleTypeDef *pdev); 114 | USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef *pdev); 115 | USBD_StatusTypeDef USBD_LL_Stop(USBD_HandleTypeDef *pdev); 116 | USBD_StatusTypeDef USBD_LL_OpenEP(USBD_HandleTypeDef *pdev, 117 | uint8_t ep_addr, 118 | uint8_t ep_type, 119 | uint16_t ep_mps); 120 | 121 | USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr); 122 | USBD_StatusTypeDef USBD_LL_FlushEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr); 123 | USBD_StatusTypeDef USBD_LL_StallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr); 124 | USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr); 125 | uint8_t USBD_LL_IsStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr); 126 | USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev, uint8_t dev_addr); 127 | USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef *pdev, 128 | uint8_t ep_addr, 129 | uint8_t *pbuf, 130 | uint16_t size); 131 | 132 | USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev, 133 | uint8_t ep_addr, 134 | uint8_t *pbuf, 135 | uint16_t size); 136 | 137 | uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef *pdev, uint8_t ep_addr); 138 | void USBD_LL_Delay(uint32_t Delay); 139 | 140 | /** 141 | * @} 142 | */ 143 | 144 | #ifdef __cplusplus 145 | } 146 | #endif 147 | 148 | #endif /* __USBD_CORE_H */ 149 | 150 | /** 151 | * @} 152 | */ 153 | 154 | /** 155 | * @} 156 | */ 157 | 158 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 159 | 160 | 161 | 162 | -------------------------------------------------------------------------------- /Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_ctlreq.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_req.h 4 | * @author MCD Application Team 5 | * @brief Header file for the usbd_req.c file 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© Copyright (c) 2015 STMicroelectronics. 10 | * All rights reserved.

11 | * 12 | * This software component is licensed by ST under Ultimate Liberty license 13 | * SLA0044, the "License"; You may not use this file except in compliance with 14 | * the License. You may obtain a copy of the License at: 15 | * www.st.com/SLA0044 16 | * 17 | ****************************************************************************** 18 | */ 19 | 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __USB_REQUEST_H 22 | #define __USB_REQUEST_H 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "usbd_def.h" 30 | 31 | 32 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 33 | * @{ 34 | */ 35 | 36 | /** @defgroup USBD_REQ 37 | * @brief header file for the usbd_req.c file 38 | * @{ 39 | */ 40 | 41 | /** @defgroup USBD_REQ_Exported_Defines 42 | * @{ 43 | */ 44 | /** 45 | * @} 46 | */ 47 | 48 | 49 | /** @defgroup USBD_REQ_Exported_Types 50 | * @{ 51 | */ 52 | /** 53 | * @} 54 | */ 55 | 56 | 57 | 58 | /** @defgroup USBD_REQ_Exported_Macros 59 | * @{ 60 | */ 61 | /** 62 | * @} 63 | */ 64 | 65 | /** @defgroup USBD_REQ_Exported_Variables 66 | * @{ 67 | */ 68 | /** 69 | * @} 70 | */ 71 | 72 | /** @defgroup USBD_REQ_Exported_FunctionsPrototype 73 | * @{ 74 | */ 75 | 76 | USBD_StatusTypeDef USBD_StdDevReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 77 | USBD_StatusTypeDef USBD_StdItfReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 78 | USBD_StatusTypeDef USBD_StdEPReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 79 | 80 | 81 | void USBD_CtlError(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 82 | 83 | void USBD_ParseSetupRequest(USBD_SetupReqTypedef *req, uint8_t *pdata); 84 | 85 | void USBD_GetString(uint8_t *desc, uint8_t *unicode, uint16_t *len); 86 | /** 87 | * @} 88 | */ 89 | 90 | #ifdef __cplusplus 91 | } 92 | #endif 93 | 94 | #endif /* __USB_REQUEST_H */ 95 | 96 | /** 97 | * @} 98 | */ 99 | 100 | /** 101 | * @} 102 | */ 103 | 104 | 105 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 106 | -------------------------------------------------------------------------------- /Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_ioreq.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_ioreq.h 4 | * @author MCD Application Team 5 | * @brief Header file for the usbd_ioreq.c file 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© Copyright (c) 2015 STMicroelectronics. 10 | * All rights reserved.

11 | * 12 | * This software component is licensed by ST under Ultimate Liberty license 13 | * SLA0044, the "License"; You may not use this file except in compliance with 14 | * the License. You may obtain a copy of the License at: 15 | * www.st.com/SLA0044 16 | * 17 | ****************************************************************************** 18 | */ 19 | 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __USBD_IOREQ_H 22 | #define __USBD_IOREQ_H 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "usbd_def.h" 30 | #include "usbd_core.h" 31 | 32 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 33 | * @{ 34 | */ 35 | 36 | /** @defgroup USBD_IOREQ 37 | * @brief header file for the usbd_ioreq.c file 38 | * @{ 39 | */ 40 | 41 | /** @defgroup USBD_IOREQ_Exported_Defines 42 | * @{ 43 | */ 44 | /** 45 | * @} 46 | */ 47 | 48 | 49 | /** @defgroup USBD_IOREQ_Exported_Types 50 | * @{ 51 | */ 52 | 53 | 54 | /** 55 | * @} 56 | */ 57 | 58 | 59 | 60 | /** @defgroup USBD_IOREQ_Exported_Macros 61 | * @{ 62 | */ 63 | 64 | /** 65 | * @} 66 | */ 67 | 68 | /** @defgroup USBD_IOREQ_Exported_Variables 69 | * @{ 70 | */ 71 | 72 | /** 73 | * @} 74 | */ 75 | 76 | /** @defgroup USBD_IOREQ_Exported_FunctionsPrototype 77 | * @{ 78 | */ 79 | 80 | USBD_StatusTypeDef USBD_CtlSendData(USBD_HandleTypeDef *pdev, 81 | uint8_t *pbuf, 82 | uint16_t len); 83 | 84 | USBD_StatusTypeDef USBD_CtlContinueSendData(USBD_HandleTypeDef *pdev, 85 | uint8_t *pbuf, 86 | uint16_t len); 87 | 88 | USBD_StatusTypeDef USBD_CtlPrepareRx(USBD_HandleTypeDef *pdev, 89 | uint8_t *pbuf, 90 | uint16_t len); 91 | 92 | USBD_StatusTypeDef USBD_CtlContinueRx(USBD_HandleTypeDef *pdev, 93 | uint8_t *pbuf, 94 | uint16_t len); 95 | 96 | USBD_StatusTypeDef USBD_CtlSendStatus(USBD_HandleTypeDef *pdev); 97 | 98 | USBD_StatusTypeDef USBD_CtlReceiveStatus(USBD_HandleTypeDef *pdev); 99 | 100 | uint32_t USBD_GetRxCount(USBD_HandleTypeDef *pdev, uint8_t ep_addr); 101 | 102 | /** 103 | * @} 104 | */ 105 | 106 | #ifdef __cplusplus 107 | } 108 | #endif 109 | 110 | #endif /* __USBD_IOREQ_H */ 111 | 112 | /** 113 | * @} 114 | */ 115 | 116 | /** 117 | * @} 118 | */ 119 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 120 | -------------------------------------------------------------------------------- /Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_ioreq.c 4 | * @author MCD Application Team 5 | * @brief This file provides the IO requests APIs for control endpoints. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© Copyright (c) 2015 STMicroelectronics. 10 | * All rights reserved.

11 | * 12 | * This software component is licensed by ST under Ultimate Liberty license 13 | * SLA0044, the "License"; You may not use this file except in compliance with 14 | * the License. You may obtain a copy of the License at: 15 | * www.st.com/SLA0044 16 | * 17 | ****************************************************************************** 18 | */ 19 | 20 | /* Includes ------------------------------------------------------------------*/ 21 | #include "usbd_ioreq.h" 22 | 23 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 24 | * @{ 25 | */ 26 | 27 | 28 | /** @defgroup USBD_IOREQ 29 | * @brief control I/O requests module 30 | * @{ 31 | */ 32 | 33 | /** @defgroup USBD_IOREQ_Private_TypesDefinitions 34 | * @{ 35 | */ 36 | /** 37 | * @} 38 | */ 39 | 40 | 41 | /** @defgroup USBD_IOREQ_Private_Defines 42 | * @{ 43 | */ 44 | 45 | /** 46 | * @} 47 | */ 48 | 49 | 50 | /** @defgroup USBD_IOREQ_Private_Macros 51 | * @{ 52 | */ 53 | /** 54 | * @} 55 | */ 56 | 57 | 58 | /** @defgroup USBD_IOREQ_Private_Variables 59 | * @{ 60 | */ 61 | 62 | /** 63 | * @} 64 | */ 65 | 66 | 67 | /** @defgroup USBD_IOREQ_Private_FunctionPrototypes 68 | * @{ 69 | */ 70 | /** 71 | * @} 72 | */ 73 | 74 | 75 | /** @defgroup USBD_IOREQ_Private_Functions 76 | * @{ 77 | */ 78 | 79 | /** 80 | * @brief USBD_CtlSendData 81 | * send data on the ctl pipe 82 | * @param pdev: device instance 83 | * @param buff: pointer to data buffer 84 | * @param len: length of data to be sent 85 | * @retval status 86 | */ 87 | USBD_StatusTypeDef USBD_CtlSendData(USBD_HandleTypeDef *pdev, 88 | uint8_t *pbuf, uint16_t len) 89 | { 90 | /* Set EP0 State */ 91 | pdev->ep0_state = USBD_EP0_DATA_IN; 92 | pdev->ep_in[0].total_length = len; 93 | pdev->ep_in[0].rem_length = len; 94 | 95 | /* Start the transfer */ 96 | USBD_LL_Transmit(pdev, 0x00U, pbuf, len); 97 | 98 | return USBD_OK; 99 | } 100 | 101 | /** 102 | * @brief USBD_CtlContinueSendData 103 | * continue sending data on the ctl pipe 104 | * @param pdev: device instance 105 | * @param buff: pointer to data buffer 106 | * @param len: length of data to be sent 107 | * @retval status 108 | */ 109 | USBD_StatusTypeDef USBD_CtlContinueSendData(USBD_HandleTypeDef *pdev, 110 | uint8_t *pbuf, uint16_t len) 111 | { 112 | /* Start the next transfer */ 113 | USBD_LL_Transmit(pdev, 0x00U, pbuf, len); 114 | 115 | return USBD_OK; 116 | } 117 | 118 | /** 119 | * @brief USBD_CtlPrepareRx 120 | * receive data on the ctl pipe 121 | * @param pdev: device instance 122 | * @param buff: pointer to data buffer 123 | * @param len: length of data to be received 124 | * @retval status 125 | */ 126 | USBD_StatusTypeDef USBD_CtlPrepareRx(USBD_HandleTypeDef *pdev, 127 | uint8_t *pbuf, uint16_t len) 128 | { 129 | /* Set EP0 State */ 130 | pdev->ep0_state = USBD_EP0_DATA_OUT; 131 | pdev->ep_out[0].total_length = len; 132 | pdev->ep_out[0].rem_length = len; 133 | 134 | /* Start the transfer */ 135 | USBD_LL_PrepareReceive(pdev, 0U, pbuf, len); 136 | 137 | return USBD_OK; 138 | } 139 | 140 | /** 141 | * @brief USBD_CtlContinueRx 142 | * continue receive data on the ctl pipe 143 | * @param pdev: device instance 144 | * @param buff: pointer to data buffer 145 | * @param len: length of data to be received 146 | * @retval status 147 | */ 148 | USBD_StatusTypeDef USBD_CtlContinueRx(USBD_HandleTypeDef *pdev, 149 | uint8_t *pbuf, uint16_t len) 150 | { 151 | USBD_LL_PrepareReceive(pdev, 0U, pbuf, len); 152 | 153 | return USBD_OK; 154 | } 155 | 156 | /** 157 | * @brief USBD_CtlSendStatus 158 | * send zero lzngth packet on the ctl pipe 159 | * @param pdev: device instance 160 | * @retval status 161 | */ 162 | USBD_StatusTypeDef USBD_CtlSendStatus(USBD_HandleTypeDef *pdev) 163 | { 164 | /* Set EP0 State */ 165 | pdev->ep0_state = USBD_EP0_STATUS_IN; 166 | 167 | /* Start the transfer */ 168 | USBD_LL_Transmit(pdev, 0x00U, NULL, 0U); 169 | 170 | return USBD_OK; 171 | } 172 | 173 | /** 174 | * @brief USBD_CtlReceiveStatus 175 | * receive zero lzngth packet on the ctl pipe 176 | * @param pdev: device instance 177 | * @retval status 178 | */ 179 | USBD_StatusTypeDef USBD_CtlReceiveStatus(USBD_HandleTypeDef *pdev) 180 | { 181 | /* Set EP0 State */ 182 | pdev->ep0_state = USBD_EP0_STATUS_OUT; 183 | 184 | /* Start the transfer */ 185 | USBD_LL_PrepareReceive(pdev, 0U, NULL, 0U); 186 | 187 | return USBD_OK; 188 | } 189 | 190 | /** 191 | * @brief USBD_GetRxCount 192 | * returns the received data length 193 | * @param pdev: device instance 194 | * @param ep_addr: endpoint address 195 | * @retval Rx Data blength 196 | */ 197 | uint32_t USBD_GetRxCount(USBD_HandleTypeDef *pdev, uint8_t ep_addr) 198 | { 199 | return USBD_LL_GetRxDataSize(pdev, ep_addr); 200 | } 201 | 202 | /** 203 | * @} 204 | */ 205 | 206 | 207 | /** 208 | * @} 209 | */ 210 | 211 | 212 | /** 213 | * @} 214 | */ 215 | 216 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 217 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # VP-Digi 2 | Polska wersja tego pliku dostępna jest [tutaj](README_pl.md). 3 | 4 | **VP-Digi** is a functional, affordable, easy-to-assemble, and configure STM32-based APRS digipeater controller with a built-in KISS modem. 5 | 6 | * Multiple modems: 7 | * 1200 Bd AFSK Bell 202 (VHF standard) 8 | * 300 Bd AFSK Bell 103 (HF standard) 9 | * 9600 Bd GFSK G3RUH (UHF standard) 10 | * 1200 Bd AFSK V.23 11 | * PWM (or deprecated R2R) signal generation 12 | * Analog-digital busy channel detection (data carrier detection) 13 | * AX.25 coder/decoder 14 | * FX.25 (AX.25 with error correction) coder/decoder, fully compatible with [Direwolf](https://github.com/wb2osz/direwolf) and [UZ7HO Soundmodem](http://uz7.ho.ua/packetradio.htm) 15 | * Digipeater: 4 settable n-N aliases, 4 simple aliases, viscous delay (known from aprx) or direct only, black and white list 16 | * 8 independent beacons 17 | * KISS mode (can be used as an ordinary Packet Radio, Winlink, APRS, etc. modem) 18 | * USB and 2 UARTs: independent, running in KISS, monitor, or configuration mode 19 | 20 | ## Download and setup 21 | The latest compiled firmware can be downloaded [here](https://github.com/sq8vps/vp-digi/releases).\ 22 | Full documentation can be found [here](doc/manual.md). 23 | 24 | ## Updating to 2.0.0+ on older hardware 25 | 26 | Since version 2.0.0, the component values have changed to provide support for faster modulations (9600 Bd). If you want to use these, some components must be replaced. For more information, refer to the [manual](doc/manual.md). 27 | 28 | ## Description, schematic, instructions 29 | 30 | The user manual and technical description are available [here](doc/manual.md). 31 | 32 | ## Source code 33 | 34 | The firmware was written using STM32CubeIDE, and you should be able to import this repository directly into the IDE. You can get the source code using: 35 | 36 | ```bash 37 | git clone https://github.com/sq8vps/vp-digi.git 38 | ``` 39 | Since version 2.0.0, you will also need to get the appropriate submodule ([LwFEC](https://github.com/sq8vps/lwfec) for Reed-Solomon FEC): 40 | 41 | ```bash 42 | git submodule init 43 | git submodule update 44 | ``` 45 | Since version 2.0.0, there is also a possibility to build the firmware with or without FX.25 protocol support. The `ENABLE_FX25` symbol must be defined to enable FX.25 support. On STM32CubeIDE, this can be done under *Project->Properties->C/C++ Build->Settings->Preprocessor->Defined symbols*. 46 | 47 | ## Contributing 48 | All contributions are appreciated. 49 | 50 | ## License 51 | The project is licensed under the GNU GPL v3 license (see [LICENSE](LICENSE)). 52 | -------------------------------------------------------------------------------- /README_pl.md: -------------------------------------------------------------------------------- 1 | # VP-Digi 2 | 3 | **VP-Digi** jest funkcjonalnym, tanim, łatwym w budowie i konfiguracji kontrolerem digipeatera APRS opartym na procesorze STM32 z wbudowanym TNC KISS. 4 | 5 | * Wiele modemów: 6 | * 1200 Bd AFSK Bell 202 (standard VHF) 7 | * 300 Bd AFSK Bell 103 (standard HF) 8 | * 9600 Bd GFSK G3RUH (standard UHF) 9 | * 1200 Bd AFSK V.23 10 | * Generowanie sygnału z użyciem PWM (lub R2R - niezalecane) 11 | * Analogowo-cyfrowe wykrywanie zajętości kanału (DCD) 12 | * Obsługa AX.25 13 | * Obsługa FX.25 (AX.25 z korekcją błędów), w pełni kompatybilna z [Direwolf](https://github.com/wb2osz/direwolf) i [UZ7HO Soundmodem](http://uz7.ho.ua/packetradio.htm) 14 | * Digipeater: 4 ustawialne aliasy n-N, 4 proste aliasy, *viscous delay* (znane z aprx) lub tryb bezpośredni, lista czarna i biała 15 | * 8 niezależnych beaconów 16 | * Tryb KISS (użycie jako zwykły modem Packet Radio, Winlink, APRS itp.) 17 | * USB i 2 interfejsy UART: niezależne, działające w trybie KISS, monitora lub konfiguracji 18 | 19 | ## Pobieranie i konfiguracja 20 | Najnowsze skompilowane oprogramowanie można znaleźć [tutaj](https://github.com/sq8vps/vp-digi/releases).\ 21 | Pełną dokumentację można znaleźć [tutaj](doc/manual_pl.md). 22 | 23 | ## Aktualizacja oprogramowania do wersji 2.0.0+ na starszym sprzęcie 24 | 25 | W wersji 2.0.0 wartości komponentów zostały zmienione, aby umożliwić obsługę szybszych modulacji (9600 Bd). W przypadku potrzeby użycia tych modulacji niektóre komponenty muszą zostać wymienione. Więcej informacji dostępnych jest w [instrukcji obsługi](doc/manual_pl.md). 26 | 27 | ## Opis, schemat, instrukcje 28 | 29 | Instrukcja użytkownika i opis techniczny są dostępne [tutaj](doc/manual_pl.md). 30 | 31 | ## Kod źródłowy 32 | 33 | Firmware został napisany w środowisku STM32CubeIDE, gdzie można bezpośrednio zaimportować projekt. Kod źródłowy można pobrać za pomocą: 34 | 35 | ```bash 36 | git clone https://github.com/sq8vps/vp-digi.git 37 | ``` 38 | Począwszy od wersji 2.0.0 konieczne jest także pobranie odpowiedniego modułu ([LwFEC](https://github.com/sq8vps/lwfec) dla obsługi kodowania Reeda-Solomona): 39 | ```bash 40 | git submodule init 41 | git submodule update 42 | ``` 43 | Począwszy od wersji 2.0.0 istnieje również możliwość kompilowania oprogramowania z obsługą lub bez obsługi protokołu FX.25. Symbol `ENABLE_FX25` musi zostać zdefiniowany, aby włączyć obsługę FX.25. W STM32CubeIDE można to zrobić w menu *Project->Properties->C/C++ Build->Settings->Preprocessor->Defined symbols*. 44 | 45 | ## Wkład 46 | Każdy wkład jest mile widziany. 47 | 48 | ## Licencja 49 | Projekt jest objęty licencją GNU GPL v3 (zobacz [LICENSE](LICENSE)). 50 | -------------------------------------------------------------------------------- /STM32F103C8Tx_FLASH.ld: -------------------------------------------------------------------------------- 1 | /* 2 | ****************************************************************************** 3 | ** 4 | ** @file : LinkerScript.ld 5 | ** 6 | ** @author : Auto-generated by STM32CubeIDE 7 | ** 8 | ** @brief : Linker script for STM32F103C8Tx Device from STM32F1 series 9 | ** 64KBytes FLASH 10 | ** 20KBytes RAM 11 | ** 12 | ** Set heap size, stack size and stack location according 13 | ** to application requirements. 14 | ** 15 | ** Set memory bank area and size if external memory is used 16 | ** 17 | ** Target : STMicroelectronics STM32 18 | ** 19 | ** Distribution: The file is distributed as is, without any warranty 20 | ** of any kind. 21 | ** 22 | ****************************************************************************** 23 | ** @attention 24 | ** 25 | ** Copyright (c) 2023 STMicroelectronics. 26 | ** All rights reserved. 27 | ** 28 | ** This software is licensed under terms that can be found in the LICENSE file 29 | ** in the root directory of this software component. 30 | ** If no LICENSE file comes with this software, it is provided AS-IS. 31 | ** 32 | ****************************************************************************** 33 | */ 34 | 35 | /* Entry Point */ 36 | ENTRY(Reset_Handler) 37 | 38 | /* Highest address of the user mode stack */ 39 | _estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */ 40 | 41 | _Min_Heap_Size = 0x200; /* required amount of heap */ 42 | _Min_Stack_Size = 0x200; /* required amount of stack */ 43 | 44 | /* Memories definition */ 45 | MEMORY 46 | { 47 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K 48 | FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 60K 49 | } 50 | 51 | /* Sections */ 52 | SECTIONS 53 | { 54 | /* The startup code into "FLASH" Rom type memory */ 55 | .isr_vector : 56 | { 57 | . = ALIGN(4); 58 | KEEP(*(.isr_vector)) /* Startup code */ 59 | . = ALIGN(4); 60 | } >FLASH 61 | 62 | /* The program code and other data into "FLASH" Rom type memory */ 63 | .text : 64 | { 65 | . = ALIGN(4); 66 | *(.text) /* .text sections (code) */ 67 | *(.text*) /* .text* sections (code) */ 68 | *(.glue_7) /* glue arm to thumb code */ 69 | *(.glue_7t) /* glue thumb to arm code */ 70 | *(.eh_frame) 71 | 72 | KEEP (*(.init)) 73 | KEEP (*(.fini)) 74 | 75 | . = ALIGN(4); 76 | _etext = .; /* define a global symbols at end of code */ 77 | } >FLASH 78 | 79 | /* Constant data into "FLASH" Rom type memory */ 80 | .rodata : 81 | { 82 | . = ALIGN(4); 83 | *(.rodata) /* .rodata sections (constants, strings, etc.) */ 84 | *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ 85 | . = ALIGN(4); 86 | } >FLASH 87 | 88 | .ARM.extab : { 89 | . = ALIGN(4); 90 | *(.ARM.extab* .gnu.linkonce.armextab.*) 91 | . = ALIGN(4); 92 | } >FLASH 93 | 94 | .ARM : { 95 | . = ALIGN(4); 96 | __exidx_start = .; 97 | *(.ARM.exidx*) 98 | __exidx_end = .; 99 | . = ALIGN(4); 100 | } >FLASH 101 | 102 | .preinit_array : 103 | { 104 | . = ALIGN(4); 105 | PROVIDE_HIDDEN (__preinit_array_start = .); 106 | KEEP (*(.preinit_array*)) 107 | PROVIDE_HIDDEN (__preinit_array_end = .); 108 | . = ALIGN(4); 109 | } >FLASH 110 | 111 | .init_array : 112 | { 113 | . = ALIGN(4); 114 | PROVIDE_HIDDEN (__init_array_start = .); 115 | KEEP (*(SORT(.init_array.*))) 116 | KEEP (*(.init_array*)) 117 | PROVIDE_HIDDEN (__init_array_end = .); 118 | . = ALIGN(4); 119 | } >FLASH 120 | 121 | .fini_array : 122 | { 123 | . = ALIGN(4); 124 | PROVIDE_HIDDEN (__fini_array_start = .); 125 | KEEP (*(SORT(.fini_array.*))) 126 | KEEP (*(.fini_array*)) 127 | PROVIDE_HIDDEN (__fini_array_end = .); 128 | . = ALIGN(4); 129 | } >FLASH 130 | 131 | /* Used by the startup to initialize data */ 132 | _sidata = LOADADDR(.data); 133 | 134 | /* Initialized data sections into "RAM" Ram type memory */ 135 | .data : 136 | { 137 | . = ALIGN(4); 138 | _sdata = .; /* create a global symbol at data start */ 139 | *(.data) /* .data sections */ 140 | *(.data*) /* .data* sections */ 141 | *(.RamFunc) /* .RamFunc sections */ 142 | *(.RamFunc*) /* .RamFunc* sections */ 143 | 144 | . = ALIGN(4); 145 | _edata = .; /* define a global symbol at data end */ 146 | 147 | } >RAM AT> FLASH 148 | 149 | /* Uninitialized data section into "RAM" Ram type memory */ 150 | . = ALIGN(4); 151 | .bss : 152 | { 153 | /* This is used by the startup in order to initialize the .bss section */ 154 | _sbss = .; /* define a global symbol at bss start */ 155 | __bss_start__ = _sbss; 156 | *(.bss) 157 | *(.bss*) 158 | *(COMMON) 159 | 160 | . = ALIGN(4); 161 | _ebss = .; /* define a global symbol at bss end */ 162 | __bss_end__ = _ebss; 163 | } >RAM 164 | 165 | /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */ 166 | ._user_heap_stack : 167 | { 168 | . = ALIGN(8); 169 | PROVIDE ( end = . ); 170 | PROVIDE ( _end = . ); 171 | . = . + _Min_Heap_Size; 172 | . = . + _Min_Stack_Size; 173 | . = ALIGN(8); 174 | } >RAM 175 | 176 | /* Remove information from the compiler libraries */ 177 | /DISCARD/ : 178 | { 179 | libc.a ( * ) 180 | libm.a ( * ) 181 | libgcc.a ( * ) 182 | } 183 | 184 | .ARM.attributes 0 : { *(.ARM.attributes) } 185 | } 186 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sq8vps/vp-digi/58ae854d511cb712024bc5e8e23c4332e004d808/TODO -------------------------------------------------------------------------------- /USB_DEVICE/App/usb_device.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : usb_device.c 5 | * @version : v2.0_Cube 6 | * @brief : This file implements the USB Device 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 | 23 | #include "usb_device.h" 24 | #include "usbd_core.h" 25 | #include "usbd_desc.h" 26 | #include "usbd_cdc.h" 27 | #include "usbd_cdc_if.h" 28 | 29 | /* USER CODE BEGIN Includes */ 30 | 31 | /* USER CODE END Includes */ 32 | 33 | /* USER CODE BEGIN PV */ 34 | /* Private variables ---------------------------------------------------------*/ 35 | 36 | /* USER CODE END PV */ 37 | 38 | /* USER CODE BEGIN PFP */ 39 | /* Private function prototypes -----------------------------------------------*/ 40 | 41 | /* USER CODE END PFP */ 42 | 43 | /* USB Device Core handle declaration. */ 44 | USBD_HandleTypeDef hUsbDeviceFS; 45 | 46 | /* 47 | * -- Insert your variables declaration here -- 48 | */ 49 | /* USER CODE BEGIN 0 */ 50 | 51 | /* USER CODE END 0 */ 52 | 53 | /* 54 | * -- Insert your external function declaration here -- 55 | */ 56 | /* USER CODE BEGIN 1 */ 57 | 58 | /* USER CODE END 1 */ 59 | 60 | /** 61 | * Init USB device Library, add supported class and start the library 62 | * @retval None 63 | */ 64 | void MX_USB_DEVICE_Init(void) 65 | { 66 | /* USER CODE BEGIN USB_DEVICE_Init_PreTreatment */ 67 | 68 | /* USER CODE END USB_DEVICE_Init_PreTreatment */ 69 | 70 | /* Init Device Library, add supported class and start the library. */ 71 | if (USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS) != USBD_OK) 72 | { 73 | Error_Handler(); 74 | } 75 | if (USBD_RegisterClass(&hUsbDeviceFS, &USBD_CDC) != USBD_OK) 76 | { 77 | Error_Handler(); 78 | } 79 | if (USBD_CDC_RegisterInterface(&hUsbDeviceFS, &USBD_Interface_fops_FS) != USBD_OK) 80 | { 81 | Error_Handler(); 82 | } 83 | if (USBD_Start(&hUsbDeviceFS) != USBD_OK) 84 | { 85 | Error_Handler(); 86 | } 87 | 88 | /* USER CODE BEGIN USB_DEVICE_Init_PostTreatment */ 89 | 90 | /* USER CODE END USB_DEVICE_Init_PostTreatment */ 91 | } 92 | 93 | /** 94 | * @} 95 | */ 96 | 97 | /** 98 | * @} 99 | */ 100 | 101 | -------------------------------------------------------------------------------- /USB_DEVICE/App/usb_device.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : usb_device.h 5 | * @version : v2.0_Cube 6 | * @brief : Header for usb_device.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 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __USB_DEVICE__H__ 23 | #define __USB_DEVICE__H__ 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | #include "stm32f1xx.h" 31 | #include "stm32f1xx_hal.h" 32 | #include "usbd_def.h" 33 | 34 | /* USER CODE BEGIN INCLUDE */ 35 | 36 | /* USER CODE END INCLUDE */ 37 | 38 | /** @addtogroup USBD_OTG_DRIVER 39 | * @{ 40 | */ 41 | 42 | /** @defgroup USBD_DEVICE USBD_DEVICE 43 | * @brief Device file for Usb otg low level driver. 44 | * @{ 45 | */ 46 | 47 | /** @defgroup USBD_DEVICE_Exported_Variables USBD_DEVICE_Exported_Variables 48 | * @brief Public variables. 49 | * @{ 50 | */ 51 | 52 | /* Private variables ---------------------------------------------------------*/ 53 | /* USER CODE BEGIN PV */ 54 | 55 | /* USER CODE END PV */ 56 | 57 | /* Private function prototypes -----------------------------------------------*/ 58 | /* USER CODE BEGIN PFP */ 59 | 60 | /* USER CODE END PFP */ 61 | 62 | /* 63 | * -- Insert your variables declaration here -- 64 | */ 65 | /* USER CODE BEGIN VARIABLES */ 66 | 67 | /* USER CODE END VARIABLES */ 68 | /** 69 | * @} 70 | */ 71 | 72 | /** @defgroup USBD_DEVICE_Exported_FunctionsPrototype USBD_DEVICE_Exported_FunctionsPrototype 73 | * @brief Declaration of public functions for Usb device. 74 | * @{ 75 | */ 76 | 77 | /** USB Device initialization function. */ 78 | void MX_USB_DEVICE_Init(void); 79 | 80 | /* 81 | * -- Insert functions declaration here -- 82 | */ 83 | /* USER CODE BEGIN FD */ 84 | 85 | /* USER CODE END FD */ 86 | /** 87 | * @} 88 | */ 89 | 90 | /** 91 | * @} 92 | */ 93 | 94 | /** 95 | * @} 96 | */ 97 | 98 | #ifdef __cplusplus 99 | } 100 | #endif 101 | 102 | #endif /* __USB_DEVICE__H__ */ 103 | -------------------------------------------------------------------------------- /USB_DEVICE/App/usbd_cdc_if.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : usbd_cdc_if.h 5 | * @version : v2.0_Cube 6 | * @brief : Header for usbd_cdc_if.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 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __USBD_CDC_IF_H__ 23 | #define __USBD_CDC_IF_H__ 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | #include "usbd_cdc.h" 31 | 32 | /* USER CODE BEGIN INCLUDE */ 33 | 34 | /* USER CODE END INCLUDE */ 35 | 36 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY 37 | * @brief For Usb device. 38 | * @{ 39 | */ 40 | 41 | /** @defgroup USBD_CDC_IF USBD_CDC_IF 42 | * @brief Usb VCP device module 43 | * @{ 44 | */ 45 | 46 | /** @defgroup USBD_CDC_IF_Exported_Defines USBD_CDC_IF_Exported_Defines 47 | * @brief Defines. 48 | * @{ 49 | */ 50 | /* Define size for the receive and transmit buffer over CDC */ 51 | #define APP_RX_DATA_SIZE 256 52 | #define APP_TX_DATA_SIZE 64 53 | /* USER CODE BEGIN EXPORTED_DEFINES */ 54 | 55 | /* USER CODE END EXPORTED_DEFINES */ 56 | 57 | /** 58 | * @} 59 | */ 60 | 61 | /** @defgroup USBD_CDC_IF_Exported_Types USBD_CDC_IF_Exported_Types 62 | * @brief Types. 63 | * @{ 64 | */ 65 | 66 | /* USER CODE BEGIN EXPORTED_TYPES */ 67 | 68 | /* USER CODE END EXPORTED_TYPES */ 69 | 70 | /** 71 | * @} 72 | */ 73 | 74 | /** @defgroup USBD_CDC_IF_Exported_Macros USBD_CDC_IF_Exported_Macros 75 | * @brief Aliases. 76 | * @{ 77 | */ 78 | 79 | /* USER CODE BEGIN EXPORTED_MACRO */ 80 | 81 | /* USER CODE END EXPORTED_MACRO */ 82 | 83 | /** 84 | * @} 85 | */ 86 | 87 | /** @defgroup USBD_CDC_IF_Exported_Variables USBD_CDC_IF_Exported_Variables 88 | * @brief Public variables. 89 | * @{ 90 | */ 91 | 92 | /** CDC Interface callback. */ 93 | extern USBD_CDC_ItfTypeDef USBD_Interface_fops_FS; 94 | 95 | /* USER CODE BEGIN EXPORTED_VARIABLES */ 96 | 97 | /* USER CODE END EXPORTED_VARIABLES */ 98 | 99 | /** 100 | * @} 101 | */ 102 | 103 | /** @defgroup USBD_CDC_IF_Exported_FunctionsPrototype USBD_CDC_IF_Exported_FunctionsPrototype 104 | * @brief Public functions declaration. 105 | * @{ 106 | */ 107 | 108 | uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len); 109 | 110 | /* USER CODE BEGIN EXPORTED_FUNCTIONS */ 111 | 112 | /* USER CODE END EXPORTED_FUNCTIONS */ 113 | 114 | /** 115 | * @} 116 | */ 117 | 118 | /** 119 | * @} 120 | */ 121 | 122 | /** 123 | * @} 124 | */ 125 | 126 | #ifdef __cplusplus 127 | } 128 | #endif 129 | 130 | #endif /* __USBD_CDC_IF_H__ */ 131 | 132 | -------------------------------------------------------------------------------- /USB_DEVICE/App/usbd_desc.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : usbd_desc.c 5 | * @version : v2.0_Cube 6 | * @brief : Header for usbd_conf.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 __USBD_DESC__C__ 22 | #define __USBD_DESC__C__ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "usbd_def.h" 30 | 31 | /* USER CODE BEGIN INCLUDE */ 32 | 33 | /* USER CODE END INCLUDE */ 34 | 35 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY 36 | * @{ 37 | */ 38 | 39 | /** @defgroup USBD_DESC USBD_DESC 40 | * @brief Usb device descriptors module. 41 | * @{ 42 | */ 43 | 44 | /** @defgroup USBD_DESC_Exported_Constants USBD_DESC_Exported_Constants 45 | * @brief Constants. 46 | * @{ 47 | */ 48 | #define DEVICE_ID1 (UID_BASE) 49 | #define DEVICE_ID2 (UID_BASE + 0x4) 50 | #define DEVICE_ID3 (UID_BASE + 0x8) 51 | 52 | #define USB_SIZ_STRING_SERIAL 0x1A 53 | 54 | /* USER CODE BEGIN EXPORTED_CONSTANTS */ 55 | 56 | /* USER CODE END EXPORTED_CONSTANTS */ 57 | 58 | /** 59 | * @} 60 | */ 61 | 62 | /** @defgroup USBD_DESC_Exported_Defines USBD_DESC_Exported_Defines 63 | * @brief Defines. 64 | * @{ 65 | */ 66 | 67 | /* USER CODE BEGIN EXPORTED_DEFINES */ 68 | 69 | /* USER CODE END EXPORTED_DEFINES */ 70 | 71 | /** 72 | * @} 73 | */ 74 | 75 | /** @defgroup USBD_DESC_Exported_TypesDefinitions USBD_DESC_Exported_TypesDefinitions 76 | * @brief Types. 77 | * @{ 78 | */ 79 | 80 | /* USER CODE BEGIN EXPORTED_TYPES */ 81 | 82 | /* USER CODE END EXPORTED_TYPES */ 83 | 84 | /** 85 | * @} 86 | */ 87 | 88 | /** @defgroup USBD_DESC_Exported_Macros USBD_DESC_Exported_Macros 89 | * @brief Aliases. 90 | * @{ 91 | */ 92 | 93 | /* USER CODE BEGIN EXPORTED_MACRO */ 94 | 95 | /* USER CODE END EXPORTED_MACRO */ 96 | 97 | /** 98 | * @} 99 | */ 100 | 101 | /** @defgroup USBD_DESC_Exported_Variables USBD_DESC_Exported_Variables 102 | * @brief Public variables. 103 | * @{ 104 | */ 105 | 106 | /** Descriptor for the Usb device. */ 107 | extern USBD_DescriptorsTypeDef FS_Desc; 108 | 109 | /* USER CODE BEGIN EXPORTED_VARIABLES */ 110 | 111 | /* USER CODE END EXPORTED_VARIABLES */ 112 | 113 | /** 114 | * @} 115 | */ 116 | 117 | /** @defgroup USBD_DESC_Exported_FunctionsPrototype USBD_DESC_Exported_FunctionsPrototype 118 | * @brief Public functions declaration. 119 | * @{ 120 | */ 121 | 122 | /* USER CODE BEGIN EXPORTED_FUNCTIONS */ 123 | 124 | /* USER CODE END EXPORTED_FUNCTIONS */ 125 | 126 | /** 127 | * @} 128 | */ 129 | 130 | /** 131 | * @} 132 | */ 133 | 134 | /** 135 | * @} 136 | */ 137 | 138 | #ifdef __cplusplus 139 | } 140 | #endif 141 | 142 | #endif /* __USBD_DESC__C__ */ 143 | 144 | -------------------------------------------------------------------------------- /USB_DEVICE/Target/usbd_conf.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : usbd_conf.h 5 | * @version : v2.0_Cube 6 | * @brief : Header for usbd_conf.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 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __USBD_CONF__H__ 23 | #define __USBD_CONF__H__ 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | #include 31 | #include 32 | #include 33 | #include "main.h" 34 | #include "stm32f1xx.h" 35 | #include "stm32f1xx_hal.h" 36 | 37 | /* USER CODE BEGIN INCLUDE */ 38 | 39 | /* USER CODE END INCLUDE */ 40 | 41 | /** @addtogroup USBD_OTG_DRIVER 42 | * @{ 43 | */ 44 | 45 | /** @defgroup USBD_CONF USBD_CONF 46 | * @brief Configuration file for Usb otg low level driver. 47 | * @{ 48 | */ 49 | 50 | /** @defgroup USBD_CONF_Exported_Variables USBD_CONF_Exported_Variables 51 | * @brief Public variables. 52 | * @{ 53 | */ 54 | 55 | /** 56 | * @} 57 | */ 58 | 59 | /** @defgroup USBD_CONF_Exported_Defines USBD_CONF_Exported_Defines 60 | * @brief Defines for configuration of the Usb device. 61 | * @{ 62 | */ 63 | 64 | /*---------- -----------*/ 65 | #define USBD_MAX_NUM_INTERFACES 1 66 | /*---------- -----------*/ 67 | #define USBD_MAX_NUM_CONFIGURATION 1 68 | /*---------- -----------*/ 69 | #define USBD_MAX_STR_DESC_SIZ 32 70 | /*---------- -----------*/ 71 | #define USBD_DEBUG_LEVEL 0 72 | /*---------- -----------*/ 73 | #define USBD_SELF_POWERED 0 74 | /*---------- -----------*/ 75 | #define MAX_STATIC_ALLOC_SIZE 512 76 | 77 | /****************************************/ 78 | /* #define for FS and HS identification */ 79 | #define DEVICE_FS 0 80 | 81 | /** 82 | * @} 83 | */ 84 | 85 | /** @defgroup USBD_CONF_Exported_Macros USBD_CONF_Exported_Macros 86 | * @brief Aliases. 87 | * @{ 88 | */ 89 | 90 | /* Memory management macros */ 91 | 92 | /** Alias for memory allocation. */ 93 | #define USBD_malloc (uint32_t *)USBD_static_malloc 94 | 95 | /** Alias for memory release. */ 96 | #define USBD_free USBD_static_free 97 | 98 | /** Alias for memory set. */ 99 | #define USBD_memset /* Not used */ 100 | 101 | /** Alias for memory copy. */ 102 | #define USBD_memcpy /* Not used */ 103 | 104 | /** Alias for delay. */ 105 | #define USBD_Delay HAL_Delay 106 | 107 | /* For footprint reasons and since only one allocation is handled in the HID class 108 | driver, the malloc/free is changed into a static allocation method */ 109 | void *USBD_static_malloc(uint32_t size); 110 | void USBD_static_free(void *p); 111 | 112 | /* DEBUG macros */ 113 | 114 | #if (USBD_DEBUG_LEVEL > 0) 115 | #define USBD_UsrLog(...) printf(__VA_ARGS__);\ 116 | printf("\n"); 117 | #else 118 | #define USBD_UsrLog(...) 119 | #endif 120 | 121 | #if (USBD_DEBUG_LEVEL > 1) 122 | 123 | #define USBD_ErrLog(...) printf("ERROR: ") ;\ 124 | printf(__VA_ARGS__);\ 125 | printf("\n"); 126 | #else 127 | #define USBD_ErrLog(...) 128 | #endif 129 | 130 | #if (USBD_DEBUG_LEVEL > 2) 131 | #define USBD_DbgLog(...) printf("DEBUG : ") ;\ 132 | printf(__VA_ARGS__);\ 133 | printf("\n"); 134 | #else 135 | #define USBD_DbgLog(...) 136 | #endif 137 | 138 | /** 139 | * @} 140 | */ 141 | 142 | /** @defgroup USBD_CONF_Exported_Types USBD_CONF_Exported_Types 143 | * @brief Types. 144 | * @{ 145 | */ 146 | 147 | /** 148 | * @} 149 | */ 150 | 151 | /** @defgroup USBD_CONF_Exported_FunctionsPrototype USBD_CONF_Exported_FunctionsPrototype 152 | * @brief Declaration of public functions for Usb device. 153 | * @{ 154 | */ 155 | 156 | /* Exported functions -------------------------------------------------------*/ 157 | 158 | /** 159 | * @} 160 | */ 161 | 162 | /** 163 | * @} 164 | */ 165 | 166 | /** 167 | * @} 168 | */ 169 | 170 | #ifdef __cplusplus 171 | } 172 | #endif 173 | 174 | #endif /* __USBD_CONF__H__ */ 175 | 176 | -------------------------------------------------------------------------------- /doc/schematic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sq8vps/vp-digi/58ae854d511cb712024bc5e8e23c4332e004d808/doc/schematic.png -------------------------------------------------------------------------------- /vp-digi.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=STM32F103C8T6 9 | Mcu.Family=STM32F1 10 | Mcu.IP0=NVIC 11 | Mcu.IP1=RCC 12 | Mcu.IP2=SYS 13 | Mcu.IP3=USB 14 | Mcu.IP4=USB_DEVICE 15 | Mcu.IPNb=5 16 | Mcu.Name=STM32F103C(8-B)Tx 17 | Mcu.Package=LQFP48 18 | Mcu.Pin0=PD0-OSC_IN 19 | Mcu.Pin1=PD1-OSC_OUT 20 | Mcu.Pin2=PA11 21 | Mcu.Pin3=PA12 22 | Mcu.Pin4=PA13 23 | Mcu.Pin5=PA14 24 | Mcu.Pin6=VP_SYS_VS_Systick 25 | Mcu.Pin7=VP_USB_DEVICE_VS_USB_DEVICE_CDC_FS 26 | Mcu.PinsNb=8 27 | Mcu.ThirdPartyNb=0 28 | Mcu.UserConstants= 29 | Mcu.UserName=STM32F103C8Tx 30 | MxCube.Version=6.9.1 31 | MxDb.Version=DB.6.0.91 32 | NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false 33 | NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false 34 | NVIC.ForceEnableDMAVector=true 35 | NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false 36 | NVIC.MemoryManagement_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.PriorityGroup=NVIC_PRIORITYGROUP_4 40 | NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false 41 | NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:false\:true\:false 42 | NVIC.USB_LP_CAN1_RX0_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:true 43 | NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false 44 | PA11.Mode=Device 45 | PA11.Signal=USB_DM 46 | PA12.Mode=Device 47 | PA12.Signal=USB_DP 48 | PA13.Mode=Serial_Wire 49 | PA13.Signal=SYS_JTMS-SWDIO 50 | PA14.Mode=Serial_Wire 51 | PA14.Signal=SYS_JTCK-SWCLK 52 | PD0-OSC_IN.Mode=HSE-External-Oscillator 53 | PD0-OSC_IN.Signal=RCC_OSC_IN 54 | PD1-OSC_OUT.Mode=HSE-External-Oscillator 55 | PD1-OSC_OUT.Signal=RCC_OSC_OUT 56 | PinOutPanel.RotationAngle=0 57 | ProjectManager.AskForMigrate=true 58 | ProjectManager.BackupPrevious=false 59 | ProjectManager.CompilerOptimize=6 60 | ProjectManager.ComputerToolchain=false 61 | ProjectManager.CoupleFile=false 62 | ProjectManager.CustomerFirmwarePackage= 63 | ProjectManager.DefaultFWLocation=true 64 | ProjectManager.DeletePrevious=true 65 | ProjectManager.DeviceId=STM32F103C8Tx 66 | ProjectManager.FirmwarePackage=STM32Cube FW_F1 V1.8.5 67 | ProjectManager.FreePins=false 68 | ProjectManager.HalAssertFull=false 69 | ProjectManager.HeapSize=0x100 70 | ProjectManager.KeepUserCode=true 71 | ProjectManager.LastFirmware=true 72 | ProjectManager.LibraryCopy=1 73 | ProjectManager.MainLocation=Core/Src 74 | ProjectManager.NoMain=false 75 | ProjectManager.PreviousToolchain=STM32CubeIDE 76 | ProjectManager.ProjectBuild=false 77 | ProjectManager.ProjectFileName=vp-digi.ioc 78 | ProjectManager.ProjectName=vp-digi 79 | ProjectManager.ProjectStructure= 80 | ProjectManager.RegisterCallBack= 81 | ProjectManager.StackSize=0x200 82 | ProjectManager.TargetToolchain=STM32CubeIDE 83 | ProjectManager.ToolChainLocation= 84 | ProjectManager.UAScriptAfterPath= 85 | ProjectManager.UAScriptBeforePath= 86 | ProjectManager.UnderRoot=true 87 | ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false 88 | RCC.ADCFreqValue=36000000 89 | RCC.AHBFreq_Value=72000000 90 | RCC.APB1CLKDivider=RCC_HCLK_DIV2 91 | RCC.APB1Freq_Value=36000000 92 | RCC.APB1TimFreq_Value=72000000 93 | RCC.APB2Freq_Value=72000000 94 | RCC.APB2TimFreq_Value=72000000 95 | RCC.FCLKCortexFreq_Value=72000000 96 | RCC.FamilyName=M 97 | RCC.HCLKFreq_Value=72000000 98 | RCC.IPParameters=ADCFreqValue,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2Freq_Value,APB2TimFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,MCOFreq_Value,PLLCLKFreq_Value,PLLMCOFreq_Value,PLLMUL,SYSCLKFreq_VALUE,SYSCLKSource,TimSysFreq_Value,USBFreq_Value,USBPrescaler,VCOOutput2Freq_Value 99 | RCC.MCOFreq_Value=72000000 100 | RCC.PLLCLKFreq_Value=72000000 101 | RCC.PLLMCOFreq_Value=36000000 102 | RCC.PLLMUL=RCC_PLL_MUL9 103 | RCC.SYSCLKFreq_VALUE=72000000 104 | RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK 105 | RCC.TimSysFreq_Value=72000000 106 | RCC.USBFreq_Value=48000000 107 | RCC.USBPrescaler=RCC_USBCLKSOURCE_PLL_DIV1_5 108 | RCC.VCOOutput2Freq_Value=8000000 109 | USB_DEVICE.APP_RX_DATA_SIZE=256 110 | USB_DEVICE.APP_TX_DATA_SIZE=64 111 | USB_DEVICE.CLASS_NAME_FS=CDC 112 | USB_DEVICE.CONFIGURATION_STRING_CDC_FS=VP-Digi 113 | USB_DEVICE.INTERFACE_STRING_CDC_FS=VP-Digi 114 | USB_DEVICE.IPParameters=VirtualMode,VirtualModeFS,CLASS_NAME_FS,PRODUCT_STRING_CDC_FS,CONFIGURATION_STRING_CDC_FS,INTERFACE_STRING_CDC_FS,MANUFACTURER_STRING,APP_RX_DATA_SIZE,APP_TX_DATA_SIZE,USBD_MAX_STR_DESC_SIZ,USBD_SELF_POWERED,USBD_DEBUG_LEVEL 115 | USB_DEVICE.MANUFACTURER_STRING=SQ8L 116 | USB_DEVICE.PRODUCT_STRING_CDC_FS=VP-Digi 117 | USB_DEVICE.USBD_DEBUG_LEVEL=0 118 | USB_DEVICE.USBD_MAX_STR_DESC_SIZ=32 119 | USB_DEVICE.USBD_SELF_POWERED=0 120 | USB_DEVICE.VirtualMode=Cdc 121 | USB_DEVICE.VirtualModeFS=Cdc_FS 122 | VP_SYS_VS_Systick.Mode=SysTick 123 | VP_SYS_VS_Systick.Signal=SYS_VS_Systick 124 | VP_USB_DEVICE_VS_USB_DEVICE_CDC_FS.Mode=CDC_FS 125 | VP_USB_DEVICE_VS_USB_DEVICE_CDC_FS.Signal=USB_DEVICE_VS_USB_DEVICE_CDC_FS 126 | board=custom 127 | --------------------------------------------------------------------------------