├── .gitattributes ├── .gitignore ├── Doc ├── CAN Bitrate Calculate_波特率计算.xlsx ├── SIT1051A-datasheet-V1.1-cn.pdf ├── SIT1051A-datasheet-V1.1-en.pdf └── stm32g0b1_ds.pdf ├── Example ├── Build_You_Own_firmware │ ├── CDC_Test │ │ ├── Bsp │ │ │ ├── bootloader.c │ │ │ ├── bootloader.h │ │ │ ├── perf_counter.c │ │ │ └── perf_counter.h │ │ ├── CDC_Test.fpk │ │ ├── CDC_Test.ioc │ │ ├── Core │ │ │ ├── Inc │ │ │ │ ├── fdcan.h │ │ │ │ ├── gpio.h │ │ │ │ ├── main.h │ │ │ │ ├── stm32g0xx_hal_conf.h │ │ │ │ └── stm32g0xx_it.h │ │ │ ├── Src │ │ │ │ ├── fdcan.c │ │ │ │ ├── gpio.c │ │ │ │ ├── main.c │ │ │ │ ├── stm32g0xx_hal_msp.c │ │ │ │ ├── stm32g0xx_it.c │ │ │ │ ├── syscalls.c │ │ │ │ ├── sysmem.c │ │ │ │ └── system_stm32g0xx.c │ │ │ └── Startup │ │ │ │ └── startup_stm32g0b1cbtx.s │ │ ├── Debug │ │ │ ├── CDC_Test.bin │ │ │ └── CDC_Test.hex │ │ ├── Drivers │ │ │ ├── CMSIS │ │ │ │ ├── Device │ │ │ │ │ └── ST │ │ │ │ │ │ └── STM32G0xx │ │ │ │ │ │ ├── Include │ │ │ │ │ │ ├── stm32g0b1xx.h │ │ │ │ │ │ ├── stm32g0xx.h │ │ │ │ │ │ └── system_stm32g0xx.h │ │ │ │ │ │ └── LICENSE.txt │ │ │ │ ├── Include │ │ │ │ │ ├── cmsis_armcc.h │ │ │ │ │ ├── cmsis_armclang.h │ │ │ │ │ ├── cmsis_armclang_ltm.h │ │ │ │ │ ├── cmsis_compiler.h │ │ │ │ │ ├── cmsis_gcc.h │ │ │ │ │ ├── cmsis_iccarm.h │ │ │ │ │ ├── cmsis_version.h │ │ │ │ │ ├── core_armv81mml.h │ │ │ │ │ ├── core_armv8mbl.h │ │ │ │ │ ├── core_armv8mml.h │ │ │ │ │ ├── core_cm0.h │ │ │ │ │ ├── core_cm0plus.h │ │ │ │ │ ├── core_cm1.h │ │ │ │ │ ├── core_cm23.h │ │ │ │ │ ├── core_cm3.h │ │ │ │ │ ├── core_cm33.h │ │ │ │ │ ├── core_cm35p.h │ │ │ │ │ ├── core_cm4.h │ │ │ │ │ ├── core_cm7.h │ │ │ │ │ ├── core_sc000.h │ │ │ │ │ ├── core_sc300.h │ │ │ │ │ ├── mpu_armv7.h │ │ │ │ │ ├── mpu_armv8.h │ │ │ │ │ └── tz_context.h │ │ │ │ └── LICENSE.txt │ │ │ └── STM32G0xx_HAL_Driver │ │ │ │ ├── Inc │ │ │ │ ├── Legacy │ │ │ │ │ └── stm32_hal_legacy.h │ │ │ │ ├── stm32g0xx_hal.h │ │ │ │ ├── stm32g0xx_hal_cortex.h │ │ │ │ ├── stm32g0xx_hal_def.h │ │ │ │ ├── stm32g0xx_hal_dma.h │ │ │ │ ├── stm32g0xx_hal_dma_ex.h │ │ │ │ ├── stm32g0xx_hal_exti.h │ │ │ │ ├── stm32g0xx_hal_fdcan.h │ │ │ │ ├── stm32g0xx_hal_flash.h │ │ │ │ ├── stm32g0xx_hal_flash_ex.h │ │ │ │ ├── stm32g0xx_hal_gpio.h │ │ │ │ ├── stm32g0xx_hal_gpio_ex.h │ │ │ │ ├── stm32g0xx_hal_pcd.h │ │ │ │ ├── stm32g0xx_hal_pcd_ex.h │ │ │ │ ├── stm32g0xx_hal_pwr.h │ │ │ │ ├── stm32g0xx_hal_pwr_ex.h │ │ │ │ ├── stm32g0xx_hal_rcc.h │ │ │ │ ├── stm32g0xx_hal_rcc_ex.h │ │ │ │ ├── stm32g0xx_hal_tim.h │ │ │ │ ├── stm32g0xx_hal_tim_ex.h │ │ │ │ ├── stm32g0xx_ll_bus.h │ │ │ │ ├── stm32g0xx_ll_cortex.h │ │ │ │ ├── stm32g0xx_ll_crs.h │ │ │ │ ├── stm32g0xx_ll_dma.h │ │ │ │ ├── stm32g0xx_ll_dmamux.h │ │ │ │ ├── stm32g0xx_ll_exti.h │ │ │ │ ├── stm32g0xx_ll_gpio.h │ │ │ │ ├── stm32g0xx_ll_pwr.h │ │ │ │ ├── stm32g0xx_ll_rcc.h │ │ │ │ ├── stm32g0xx_ll_system.h │ │ │ │ ├── stm32g0xx_ll_usb.h │ │ │ │ └── stm32g0xx_ll_utils.h │ │ │ │ ├── LICENSE.txt │ │ │ │ └── Src │ │ │ │ ├── stm32g0xx_hal.c │ │ │ │ ├── stm32g0xx_hal_cortex.c │ │ │ │ ├── stm32g0xx_hal_dma.c │ │ │ │ ├── stm32g0xx_hal_dma_ex.c │ │ │ │ ├── stm32g0xx_hal_exti.c │ │ │ │ ├── stm32g0xx_hal_fdcan.c │ │ │ │ ├── stm32g0xx_hal_flash.c │ │ │ │ ├── stm32g0xx_hal_flash_ex.c │ │ │ │ ├── stm32g0xx_hal_gpio.c │ │ │ │ ├── stm32g0xx_hal_pcd.c │ │ │ │ ├── stm32g0xx_hal_pcd_ex.c │ │ │ │ ├── stm32g0xx_hal_pwr.c │ │ │ │ ├── stm32g0xx_hal_pwr_ex.c │ │ │ │ ├── stm32g0xx_hal_rcc.c │ │ │ │ ├── stm32g0xx_hal_rcc_ex.c │ │ │ │ ├── stm32g0xx_hal_tim.c │ │ │ │ ├── stm32g0xx_hal_tim_ex.c │ │ │ │ ├── stm32g0xx_ll_dma.c │ │ │ │ ├── stm32g0xx_ll_rcc.c │ │ │ │ └── stm32g0xx_ll_usb.c │ │ ├── MDK-ARM │ │ │ ├── CDC_Test.uvoptx │ │ │ ├── CDC_Test.uvprojx │ │ │ ├── CDC_Test │ │ │ │ ├── CDC_Test.axf │ │ │ │ ├── CDC_Test.bin │ │ │ │ └── CDC_Test.hex │ │ │ ├── DebugConfig │ │ │ │ └── CDC_Test_STM32G0B1CBTx_1.0.0.dbgconf │ │ │ ├── RTE │ │ │ │ └── _CDC_Test │ │ │ │ │ └── RTE_Components.h │ │ │ └── startup_stm32g0b1xx.s │ │ ├── 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 │ │ │ │ └── LICENSE.txt │ │ ├── STM32G0B1CBTX_FLASH.ld │ │ ├── STM32G0B1CBTX_RAM.ld │ │ └── 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 │ ├── README.md │ ├── README_zh.md │ └── buildclean.bat └── Python │ ├── CDC_SpeedTest_Rx.py │ └── CDC_SpeedTest_Tx.py ├── Firmware ├── README.md ├── README_zh.md ├── SLCAN │ ├── WeAct-USB2CANV1_V1.0.0.1_download.fpk │ ├── WeAct-USB2CANV1_V1.0.0.2_download.fpk │ └── WeAct-USB2CANV1_V1.0.0.3_download.fpk └── bootloader_stm32g0_2_fix_uid_user.hex ├── Hardware ├── WeAct-USB2CANFDV1 3D.step └── WeAct-USB2CANFDV1_V10 Board Shape 外形.pdf ├── Images ├── 1.png ├── SWD.jpg ├── WeActStudio_Upgrade_Tool_en.png ├── WeActStudio_Upgrade_Tool_zh.png ├── firmware_packager_en.png ├── firmware_packager_zh.png ├── flash_erase.png └── keil.png ├── README.md ├── README_zh.md └── Tools ├── README.md ├── README_zh.md ├── WeActStudio_Upgrade_Tool.7z ├── cangaroo_v0.2.4.1.7z ├── cangaroo_v0.2.4.7z └── firmware_packager.7z /.gitattributes: -------------------------------------------------------------------------------- 1 | *.hex binary -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.psd 2 | *.o 3 | .DS_Store 4 | *~ 5 | .~lock* 6 | *.uvopt 7 | *.dep 8 | *.bak 9 | *.uvgui.* 10 | *.uvguix.* 11 | 12 | UNSupport/ 13 | 14 | *.swp 15 | *.save 16 | .project 17 | .settings 18 | .cproject 19 | obj/ 20 | patches/ 21 | .idea 22 | *.crf 23 | *.d 24 | *.lnp 25 | 26 | # artefacts of top-level Makefile 27 | /downloads/ 28 | /build/ 29 | # local changes only 30 | make/local.mk 31 | 32 | # artefacts for VisualGDB (running in Visual Studio) 33 | mcu.mak 34 | mcu.mak.old 35 | stm32.mak 36 | 37 | # eclipse launch configurations 38 | /support/eclipse 39 | 40 | # ozone launch configurations 41 | /support/ozone 42 | 43 | # artefacts for Visual Studio Code 44 | /.vscode/ 45 | 46 | # artefacts for CLion 47 | /cmake-build-debug/ 48 | 49 | .vagrant 50 | ubuntu*.log 51 | /.vs 52 | -------------------------------------------------------------------------------- /Doc/CAN Bitrate Calculate_波特率计算.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeActStudio/WeActStudio.USB2CANFDV1/8e508c5c6f99532a896d878caaef665682ecca27/Doc/CAN Bitrate Calculate_波特率计算.xlsx -------------------------------------------------------------------------------- /Doc/SIT1051A-datasheet-V1.1-cn.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeActStudio/WeActStudio.USB2CANFDV1/8e508c5c6f99532a896d878caaef665682ecca27/Doc/SIT1051A-datasheet-V1.1-cn.pdf -------------------------------------------------------------------------------- /Doc/SIT1051A-datasheet-V1.1-en.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeActStudio/WeActStudio.USB2CANFDV1/8e508c5c6f99532a896d878caaef665682ecca27/Doc/SIT1051A-datasheet-V1.1-en.pdf -------------------------------------------------------------------------------- /Doc/stm32g0b1_ds.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeActStudio/WeActStudio.USB2CANFDV1/8e508c5c6f99532a896d878caaef665682ecca27/Doc/stm32g0b1_ds.pdf -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/CDC_Test/Bsp/bootloader.c: -------------------------------------------------------------------------------- 1 | /*--------------------------------------- 2 | - WeAct Studio Official Link 3 | - taobao: weactstudio.taobao.com 4 | - aliexpress: weactstudio.aliexpress.com 5 | - github: github.com/WeActStudio 6 | - gitee: gitee.com/WeAct-TC 7 | - blog: www.weact-tc.cn 8 | ---------------------------------------*/ 9 | 10 | #include "bootloader.h" 11 | #include "perf_counter.h" 12 | #include "stdio.h" 13 | 14 | /* �̼����µı�־λ���ñ�־λ���ܱ����� */ 15 | #if defined ( __CC_ARM ) 16 | volatile uint64_t update_flag __attribute__((at(FIRMWARE_UPDATE_VAR_ADDR), zero_init)); 17 | 18 | #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6100100) 19 | #define __INT_TO_STR(x) #x 20 | #define INT_TO_STR(x) __INT_TO_STR(x) 21 | volatile uint64_t update_flag __attribute__((section(".bss.ARM.__at_" INT_TO_STR(FIRMWARE_UPDATE_VAR_ADDR)))); 22 | #elif defined (__GNUC__) 23 | volatile uint64_t update_flag __attribute__((section(".no_init_ram"))); 24 | #else 25 | #error "variable placement not supported for this compiler." 26 | #endif 27 | 28 | /** 29 | * @brief �����ʼ��ǰ��һЩ���� 30 | * @note ִ�е��˴����ں�ʱ���ѳ�ʼ�� 31 | * @retval None 32 | */ 33 | void bootloader_init(void) 34 | { 35 | /* �����ж�������󣬿������ж� */ 36 | __IRQ_SAFE 37 | { 38 | #if defined (__GNUC__) 39 | SCB->VTOR = 0x08006800; 40 | #else 41 | extern int Image$$ER_IROM1$$Base; 42 | SCB->VTOR = (uint32_t)&Image$$ER_IROM1$$Base; 43 | #endif 44 | } 45 | __enable_irq(); 46 | } 47 | 48 | uint64_t bootloader_get_update_flag(void) 49 | { 50 | return update_flag; 51 | } 52 | 53 | void bootloader_enter_update_mode(void) 54 | { 55 | update_flag = FIRMWARE_UPDATE_MAGIC_WORD; 56 | HAL_NVIC_SystemReset(); 57 | } 58 | 59 | uint32_t version_addr; 60 | char fw_version[40]; 61 | char *bootloader_get_version(void) 62 | { 63 | char *version; 64 | version_addr = 1024*(50+26) - 16; 65 | version = (char *)version_addr; 66 | 67 | sprintf(fw_version,"WeAct Studio V%d.%d.%d.%d_%02x%02x%02x%02x\r",version[0],version[1],version[2],version[3],version[7],version[6],version[5],version[4]); 68 | 69 | return fw_version; 70 | } 71 | -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/CDC_Test/Bsp/bootloader.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeActStudio/WeActStudio.USB2CANFDV1/8e508c5c6f99532a896d878caaef665682ecca27/Example/Build_You_Own_firmware/CDC_Test/Bsp/bootloader.h -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/CDC_Test/CDC_Test.fpk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeActStudio/WeActStudio.USB2CANFDV1/8e508c5c6f99532a896d878caaef665682ecca27/Example/Build_You_Own_firmware/CDC_Test/CDC_Test.fpk -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/CDC_Test/CDC_Test.ioc: -------------------------------------------------------------------------------- 1 | #MicroXplorer Configuration settings - do not modify 2 | CAD.formats= 3 | CAD.pinconfig= 4 | CAD.provider= 5 | FDCAN1.CalculateBaudRateNominal=749999 6 | FDCAN1.CalculateTimeBitNominal=1333 7 | FDCAN1.CalculateTimeQuantumNominal=266.6666666666667 8 | FDCAN1.IPParameters=CalculateTimeQuantumNominal,CalculateTimeBitNominal,CalculateBaudRateNominal 9 | File.Version=6 10 | GPIO.groupedBy= 11 | KeepUserPlacement=false 12 | Mcu.CPN=STM32G0B1CBT6 13 | Mcu.Family=STM32G0 14 | Mcu.IP0=FDCAN1 15 | Mcu.IP1=NVIC 16 | Mcu.IP2=RCC 17 | Mcu.IP3=SYS 18 | Mcu.IP4=USB_DEVICE 19 | Mcu.IP5=USB_DRD_FS 20 | Mcu.IPNb=6 21 | Mcu.Name=STM32G0B1C(B-C-E)Tx 22 | Mcu.Package=LQFP48 23 | Mcu.Pin0=PF0-OSC_IN (PF0) 24 | Mcu.Pin1=PF1-OSC_OUT (PF1) 25 | Mcu.Pin10=PB9 26 | Mcu.Pin11=VP_SYS_VS_Systick 27 | Mcu.Pin12=VP_SYS_VS_DBSignals 28 | Mcu.Pin13=VP_USB_DEVICE_VS_USB_DEVICE_CDC_FS 29 | Mcu.Pin2=PA0 30 | Mcu.Pin3=PA1 31 | Mcu.Pin4=PA2 32 | Mcu.Pin5=PA11 [PA9] 33 | Mcu.Pin6=PA12 [PA10] 34 | Mcu.Pin7=PA13 35 | Mcu.Pin8=PA14-BOOT0 36 | Mcu.Pin9=PB8 37 | Mcu.PinsNb=14 38 | Mcu.ThirdPartyNb=0 39 | Mcu.UserConstants= 40 | Mcu.UserName=STM32G0B1CBTx 41 | MxCube.Version=6.11.1 42 | MxDb.Version=DB.6.0.111 43 | NVIC.ForceEnableDMAVector=true 44 | NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false 45 | NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false 46 | NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false 47 | NVIC.SVC_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:true 48 | NVIC.SysTick_IRQn=true\:3\:0\:false\:false\:true\:false\:true\:false 49 | NVIC.USB_UCPD1_2_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true 50 | PA0.GPIOParameters=GPIO_Label 51 | PA0.GPIO_Label=LED_RXD 52 | PA0.Locked=true 53 | PA0.Signal=GPIO_Output 54 | PA1.GPIOParameters=GPIO_Label 55 | PA1.GPIO_Label=LED_TXD 56 | PA1.Locked=true 57 | PA1.Signal=GPIO_Output 58 | PA11\ [PA9].Mode=Device 59 | PA11\ [PA9].Signal=USB_DM 60 | PA12\ [PA10].Mode=Device 61 | PA12\ [PA10].Signal=USB_DP 62 | PA13.Mode=Serial_Wire 63 | PA13.Signal=SYS_SWDIO 64 | PA14-BOOT0.Mode=Serial_Wire 65 | PA14-BOOT0.Signal=SYS_SWCLK 66 | PA2.GPIOParameters=GPIO_Label 67 | PA2.GPIO_Label=LED_READY 68 | PA2.Locked=true 69 | PA2.Signal=GPIO_Output 70 | PB8.Locked=true 71 | PB8.Mode=FDCAN_Activate 72 | PB8.Signal=FDCAN1_RX 73 | PB9.Locked=true 74 | PB9.Mode=FDCAN_Activate 75 | PB9.Signal=FDCAN1_TX 76 | PF0-OSC_IN\ (PF0).Mode=HSE-External-Oscillator 77 | PF0-OSC_IN\ (PF0).Signal=RCC_OSC_IN 78 | PF1-OSC_OUT\ (PF1).Mode=HSE-External-Oscillator 79 | PF1-OSC_OUT\ (PF1).Signal=RCC_OSC_OUT 80 | PinOutPanel.RotationAngle=0 81 | ProjectManager.AskForMigrate=true 82 | ProjectManager.BackupPrevious=false 83 | ProjectManager.CompilerOptimize=6 84 | ProjectManager.ComputerToolchain=false 85 | ProjectManager.CoupleFile=true 86 | ProjectManager.CustomerFirmwarePackage= 87 | ProjectManager.DefaultFWLocation=true 88 | ProjectManager.DeletePrevious=true 89 | ProjectManager.DeviceId=STM32G0B1CBTx 90 | ProjectManager.FirmwarePackage=STM32Cube FW_G0 V1.6.2 91 | ProjectManager.FreePins=false 92 | ProjectManager.HalAssertFull=false 93 | ProjectManager.HeapSize=0x400 94 | ProjectManager.KeepUserCode=true 95 | ProjectManager.LastFirmware=true 96 | ProjectManager.LibraryCopy=1 97 | ProjectManager.MainLocation=Core/Src 98 | ProjectManager.NoMain=false 99 | ProjectManager.PreviousToolchain=STM32CubeIDE 100 | ProjectManager.ProjectBuild=false 101 | ProjectManager.ProjectFileName=CDC_Test.ioc 102 | ProjectManager.ProjectName=CDC_Test 103 | ProjectManager.ProjectStructure= 104 | ProjectManager.RegisterCallBack= 105 | ProjectManager.StackSize=0x400 106 | ProjectManager.TargetToolchain=STM32CubeIDE 107 | ProjectManager.ToolChainLocation= 108 | ProjectManager.UAScriptAfterPath= 109 | ProjectManager.UAScriptBeforePath= 110 | ProjectManager.UnderRoot=true 111 | ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_FDCAN1_Init-FDCAN1-false-HAL-true,4-MX_USB_Device_Init-USB_DEVICE-false-HAL-false 112 | RCC.ADCFreq_Value=60000000 113 | RCC.AHBFreq_Value=60000000 114 | RCC.APBFreq_Value=60000000 115 | RCC.APBTimFreq_Value=60000000 116 | RCC.CECFreq_Value=32786.88524590164 117 | RCC.CortexFreq_Value=60000000 118 | RCC.EXTERNAL_CLOCK_VALUE=48000 119 | RCC.FCLKCortexFreq_Value=60000000 120 | RCC.FDCANFreq_Value=60000000 121 | RCC.FamilyName=M 122 | RCC.HCLKFreq_Value=60000000 123 | RCC.HSE_VALUE=16000000 124 | RCC.HSI48_VALUE=48000000 125 | RCC.HSI_VALUE=16000000 126 | RCC.I2C1Freq_Value=60000000 127 | RCC.I2C2Freq_Value=60000000 128 | RCC.I2S1Freq_Value=60000000 129 | RCC.I2S2Freq_Value=60000000 130 | RCC.IPParameters=ADCFreq_Value,AHBFreq_Value,APBFreq_Value,APBTimFreq_Value,CECFreq_Value,CortexFreq_Value,EXTERNAL_CLOCK_VALUE,FCLKCortexFreq_Value,FDCANFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,HSI48_VALUE,HSI_VALUE,I2C1Freq_Value,I2C2Freq_Value,I2S1Freq_Value,I2S2Freq_Value,LPTIM1Freq_Value,LPTIM2Freq_Value,LPUART1Freq_Value,LPUART2Freq_Value,LSCOPinFreq_Value,LSE_VALUE,LSI_VALUE,MCO1PinFreq_Value,MCO2PinFreq_Value,PLLN,PLLPoutputFreq_Value,PLLQ,PLLQoutputFreq_Value,PLLR,PLLRCLKFreq_Value,PLLSourceVirtual,PWRFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,TIM15Freq_Value,TIM1Freq_Value,USART1Freq_Value,USART2Freq_Value,USART3Freq_Value,USBFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value 131 | RCC.LPTIM1Freq_Value=60000000 132 | RCC.LPTIM2Freq_Value=60000000 133 | RCC.LPUART1Freq_Value=60000000 134 | RCC.LPUART2Freq_Value=60000000 135 | RCC.LSCOPinFreq_Value=32000 136 | RCC.LSE_VALUE=32768 137 | RCC.LSI_VALUE=32000 138 | RCC.MCO1PinFreq_Value=60000000 139 | RCC.MCO2PinFreq_Value=60000000 140 | RCC.PLLN=15 141 | RCC.PLLPoutputFreq_Value=120000000 142 | RCC.PLLQ=RCC_PLLQ_DIV8 143 | RCC.PLLQoutputFreq_Value=30000000 144 | RCC.PLLR=RCC_PLLR_DIV4 145 | RCC.PLLRCLKFreq_Value=60000000 146 | RCC.PLLSourceVirtual=RCC_PLLSOURCE_HSE 147 | RCC.PWRFreq_Value=60000000 148 | RCC.SYSCLKFreq_VALUE=60000000 149 | RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK 150 | RCC.TIM15Freq_Value=60000000 151 | RCC.TIM1Freq_Value=60000000 152 | RCC.USART1Freq_Value=60000000 153 | RCC.USART2Freq_Value=60000000 154 | RCC.USART3Freq_Value=60000000 155 | RCC.USBFreq_Value=48000000 156 | RCC.VCOInputFreq_Value=16000000 157 | RCC.VCOOutputFreq_Value=240000000 158 | USB_DEVICE.CLASS_NAME_FS=CDC 159 | USB_DEVICE.IPParameters=VirtualMode,VirtualModeFS,CLASS_NAME_FS 160 | USB_DEVICE.VirtualMode=Cdc 161 | USB_DEVICE.VirtualModeFS=Cdc_FS 162 | VP_SYS_VS_DBSignals.Mode=DisableDeadBatterySignals 163 | VP_SYS_VS_DBSignals.Signal=SYS_VS_DBSignals 164 | VP_SYS_VS_Systick.Mode=SysTick 165 | VP_SYS_VS_Systick.Signal=SYS_VS_Systick 166 | VP_USB_DEVICE_VS_USB_DEVICE_CDC_FS.Mode=CDC_FS 167 | VP_USB_DEVICE_VS_USB_DEVICE_CDC_FS.Signal=USB_DEVICE_VS_USB_DEVICE_CDC_FS 168 | board=custom 169 | -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/CDC_Test/Core/Inc/fdcan.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file fdcan.h 5 | * @brief This file contains all the function prototypes for 6 | * the fdcan.c file 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2024 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 __FDCAN_H__ 22 | #define __FDCAN_H__ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "main.h" 30 | 31 | /* USER CODE BEGIN Includes */ 32 | 33 | /* USER CODE END Includes */ 34 | 35 | extern FDCAN_HandleTypeDef hfdcan1; 36 | 37 | /* USER CODE BEGIN Private defines */ 38 | 39 | /* USER CODE END Private defines */ 40 | 41 | void MX_FDCAN1_Init(void); 42 | 43 | /* USER CODE BEGIN Prototypes */ 44 | 45 | /* USER CODE END Prototypes */ 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | 51 | #endif /* __FDCAN_H__ */ 52 | 53 | -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/CDC_Test/Core/Inc/gpio.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file gpio.h 5 | * @brief This file contains all the function prototypes for 6 | * the gpio.c file 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2024 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __GPIO_H__ 22 | #define __GPIO_H__ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "main.h" 30 | 31 | /* USER CODE BEGIN Includes */ 32 | 33 | /* USER CODE END Includes */ 34 | 35 | /* USER CODE BEGIN Private defines */ 36 | 37 | /* USER CODE END Private defines */ 38 | 39 | void MX_GPIO_Init(void); 40 | 41 | /* USER CODE BEGIN Prototypes */ 42 | 43 | /* USER CODE END Prototypes */ 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | #endif /*__ GPIO_H__ */ 49 | 50 | -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/CDC_Test/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) 2024 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __MAIN_H 23 | #define __MAIN_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | #include "stm32g0xx_hal.h" 31 | 32 | /* Private includes ----------------------------------------------------------*/ 33 | /* USER CODE BEGIN Includes */ 34 | 35 | /* USER CODE END Includes */ 36 | 37 | /* Exported types ------------------------------------------------------------*/ 38 | /* USER CODE BEGIN ET */ 39 | 40 | /* USER CODE END ET */ 41 | 42 | /* Exported constants --------------------------------------------------------*/ 43 | /* USER CODE BEGIN EC */ 44 | 45 | /* USER CODE END EC */ 46 | 47 | /* Exported macro ------------------------------------------------------------*/ 48 | /* USER CODE BEGIN EM */ 49 | 50 | /* USER CODE END EM */ 51 | 52 | /* Exported functions prototypes ---------------------------------------------*/ 53 | void Error_Handler(void); 54 | 55 | /* USER CODE BEGIN EFP */ 56 | 57 | /* USER CODE END EFP */ 58 | 59 | /* Private defines -----------------------------------------------------------*/ 60 | #define LED_RXD_Pin GPIO_PIN_0 61 | #define LED_RXD_GPIO_Port GPIOA 62 | #define LED_TXD_Pin GPIO_PIN_1 63 | #define LED_TXD_GPIO_Port GPIOA 64 | #define LED_READY_Pin GPIO_PIN_2 65 | #define LED_READY_GPIO_Port GPIOA 66 | 67 | /* USER CODE BEGIN Private defines */ 68 | 69 | /* USER CODE END Private defines */ 70 | 71 | #ifdef __cplusplus 72 | } 73 | #endif 74 | 75 | #endif /* __MAIN_H */ 76 | -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/CDC_Test/Core/Inc/stm32g0xx_it.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32g0xx_it.h 5 | * @brief This file contains the headers of the interrupt handlers. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2024 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | /* USER CODE END Header */ 19 | 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __STM32G0xx_IT_H 22 | #define __STM32G0xx_IT_H 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Private includes ----------------------------------------------------------*/ 29 | /* USER CODE BEGIN Includes */ 30 | 31 | /* USER CODE END Includes */ 32 | 33 | /* Exported types ------------------------------------------------------------*/ 34 | /* USER CODE BEGIN ET */ 35 | 36 | /* USER CODE END ET */ 37 | 38 | /* Exported constants --------------------------------------------------------*/ 39 | /* USER CODE BEGIN EC */ 40 | 41 | /* USER CODE END EC */ 42 | 43 | /* Exported macro ------------------------------------------------------------*/ 44 | /* USER CODE BEGIN EM */ 45 | 46 | /* USER CODE END EM */ 47 | 48 | /* Exported functions prototypes ---------------------------------------------*/ 49 | void NMI_Handler(void); 50 | void HardFault_Handler(void); 51 | void SVC_Handler(void); 52 | void PendSV_Handler(void); 53 | void SysTick_Handler(void); 54 | void USB_UCPD1_2_IRQHandler(void); 55 | /* USER CODE BEGIN EFP */ 56 | 57 | /* USER CODE END EFP */ 58 | 59 | #ifdef __cplusplus 60 | } 61 | #endif 62 | 63 | #endif /* __STM32G0xx_IT_H */ 64 | -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/CDC_Test/Core/Src/fdcan.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file fdcan.c 5 | * @brief This file provides code for the configuration 6 | * of the FDCAN instances. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2024 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | /* Includes ------------------------------------------------------------------*/ 21 | #include "fdcan.h" 22 | 23 | /* USER CODE BEGIN 0 */ 24 | 25 | /* USER CODE END 0 */ 26 | 27 | FDCAN_HandleTypeDef hfdcan1; 28 | 29 | /* FDCAN1 init function */ 30 | void MX_FDCAN1_Init(void) 31 | { 32 | 33 | /* USER CODE BEGIN FDCAN1_Init 0 */ 34 | 35 | /* USER CODE END FDCAN1_Init 0 */ 36 | 37 | /* USER CODE BEGIN FDCAN1_Init 1 */ 38 | 39 | /* USER CODE END FDCAN1_Init 1 */ 40 | hfdcan1.Instance = FDCAN1; 41 | hfdcan1.Init.ClockDivider = FDCAN_CLOCK_DIV1; 42 | hfdcan1.Init.FrameFormat = FDCAN_FRAME_CLASSIC; 43 | hfdcan1.Init.Mode = FDCAN_MODE_NORMAL; 44 | hfdcan1.Init.AutoRetransmission = DISABLE; 45 | hfdcan1.Init.TransmitPause = DISABLE; 46 | hfdcan1.Init.ProtocolException = DISABLE; 47 | hfdcan1.Init.NominalPrescaler = 16; 48 | hfdcan1.Init.NominalSyncJumpWidth = 1; 49 | hfdcan1.Init.NominalTimeSeg1 = 2; 50 | hfdcan1.Init.NominalTimeSeg2 = 2; 51 | hfdcan1.Init.DataPrescaler = 1; 52 | hfdcan1.Init.DataSyncJumpWidth = 1; 53 | hfdcan1.Init.DataTimeSeg1 = 1; 54 | hfdcan1.Init.DataTimeSeg2 = 1; 55 | hfdcan1.Init.StdFiltersNbr = 0; 56 | hfdcan1.Init.ExtFiltersNbr = 0; 57 | hfdcan1.Init.TxFifoQueueMode = FDCAN_TX_FIFO_OPERATION; 58 | if (HAL_FDCAN_Init(&hfdcan1) != HAL_OK) 59 | { 60 | Error_Handler(); 61 | } 62 | /* USER CODE BEGIN FDCAN1_Init 2 */ 63 | 64 | /* USER CODE END FDCAN1_Init 2 */ 65 | 66 | } 67 | 68 | void HAL_FDCAN_MspInit(FDCAN_HandleTypeDef* fdcanHandle) 69 | { 70 | 71 | GPIO_InitTypeDef GPIO_InitStruct = {0}; 72 | RCC_PeriphCLKInitTypeDef PeriphClkInit = {0}; 73 | if(fdcanHandle->Instance==FDCAN1) 74 | { 75 | /* USER CODE BEGIN FDCAN1_MspInit 0 */ 76 | 77 | /* USER CODE END FDCAN1_MspInit 0 */ 78 | 79 | /** Initializes the peripherals clocks 80 | */ 81 | PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_FDCAN; 82 | PeriphClkInit.FdcanClockSelection = RCC_FDCANCLKSOURCE_PCLK1; 83 | 84 | if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) 85 | { 86 | Error_Handler(); 87 | } 88 | 89 | /* FDCAN1 clock enable */ 90 | __HAL_RCC_FDCAN_CLK_ENABLE(); 91 | 92 | __HAL_RCC_GPIOB_CLK_ENABLE(); 93 | /**FDCAN1 GPIO Configuration 94 | PB8 ------> FDCAN1_RX 95 | PB9 ------> FDCAN1_TX 96 | */ 97 | GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9; 98 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 99 | GPIO_InitStruct.Pull = GPIO_NOPULL; 100 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 101 | GPIO_InitStruct.Alternate = GPIO_AF3_FDCAN1; 102 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); 103 | 104 | /* USER CODE BEGIN FDCAN1_MspInit 1 */ 105 | 106 | /* USER CODE END FDCAN1_MspInit 1 */ 107 | } 108 | } 109 | 110 | void HAL_FDCAN_MspDeInit(FDCAN_HandleTypeDef* fdcanHandle) 111 | { 112 | 113 | if(fdcanHandle->Instance==FDCAN1) 114 | { 115 | /* USER CODE BEGIN FDCAN1_MspDeInit 0 */ 116 | 117 | /* USER CODE END FDCAN1_MspDeInit 0 */ 118 | /* Peripheral clock disable */ 119 | __HAL_RCC_FDCAN_CLK_DISABLE(); 120 | 121 | /**FDCAN1 GPIO Configuration 122 | PB8 ------> FDCAN1_RX 123 | PB9 ------> FDCAN1_TX 124 | */ 125 | HAL_GPIO_DeInit(GPIOB, GPIO_PIN_8|GPIO_PIN_9); 126 | 127 | /* USER CODE BEGIN FDCAN1_MspDeInit 1 */ 128 | 129 | /* USER CODE END FDCAN1_MspDeInit 1 */ 130 | } 131 | } 132 | 133 | /* USER CODE BEGIN 1 */ 134 | 135 | /* USER CODE END 1 */ 136 | -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/CDC_Test/Core/Src/gpio.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file gpio.c 5 | * @brief This file provides code for the configuration 6 | * of all used GPIO pins. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2024 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | #include "gpio.h" 23 | 24 | /* USER CODE BEGIN 0 */ 25 | 26 | /* USER CODE END 0 */ 27 | 28 | /*----------------------------------------------------------------------------*/ 29 | /* Configure GPIO */ 30 | /*----------------------------------------------------------------------------*/ 31 | /* USER CODE BEGIN 1 */ 32 | 33 | /* USER CODE END 1 */ 34 | 35 | /** Configure pins as 36 | * Analog 37 | * Input 38 | * Output 39 | * EVENT_OUT 40 | * EXTI 41 | */ 42 | void MX_GPIO_Init(void) 43 | { 44 | 45 | GPIO_InitTypeDef GPIO_InitStruct = {0}; 46 | 47 | /* GPIO Ports Clock Enable */ 48 | __HAL_RCC_GPIOF_CLK_ENABLE(); 49 | __HAL_RCC_GPIOA_CLK_ENABLE(); 50 | __HAL_RCC_GPIOB_CLK_ENABLE(); 51 | 52 | /*Configure GPIO pin Output Level */ 53 | HAL_GPIO_WritePin(GPIOA, LED_RXD_Pin|LED_TXD_Pin|LED_READY_Pin, GPIO_PIN_RESET); 54 | 55 | /*Configure GPIO pins : PAPin PAPin PAPin */ 56 | GPIO_InitStruct.Pin = LED_RXD_Pin|LED_TXD_Pin|LED_READY_Pin; 57 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 58 | GPIO_InitStruct.Pull = GPIO_NOPULL; 59 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 60 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 61 | 62 | } 63 | 64 | /* USER CODE BEGIN 2 */ 65 | 66 | /* USER CODE END 2 */ 67 | -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/CDC_Test/Core/Src/main.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : main.c 5 | * @brief : Main program body 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2024 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | /* USER CODE END Header */ 19 | /* Includes ------------------------------------------------------------------*/ 20 | #include "main.h" 21 | #include "fdcan.h" 22 | #include "usb_device.h" 23 | #include "gpio.h" 24 | 25 | /* Private includes ----------------------------------------------------------*/ 26 | /* USER CODE BEGIN Includes */ 27 | #include "usbd_cdc_if.h" 28 | #include "bootloader.h" 29 | /* USER CODE END Includes */ 30 | 31 | /* Private typedef -----------------------------------------------------------*/ 32 | /* USER CODE BEGIN PTD */ 33 | 34 | /* USER CODE END PTD */ 35 | 36 | /* Private define ------------------------------------------------------------*/ 37 | /* USER CODE BEGIN PD */ 38 | 39 | /* USER CODE END PD */ 40 | 41 | /* Private macro -------------------------------------------------------------*/ 42 | /* USER CODE BEGIN PM */ 43 | 44 | /* USER CODE END PM */ 45 | 46 | /* Private variables ---------------------------------------------------------*/ 47 | 48 | /* USER CODE BEGIN PV */ 49 | 50 | /* USER CODE END PV */ 51 | 52 | /* Private function prototypes -----------------------------------------------*/ 53 | void SystemClock_Config(void); 54 | /* USER CODE BEGIN PFP */ 55 | 56 | /* USER CODE END PFP */ 57 | 58 | /* Private user code ---------------------------------------------------------*/ 59 | /* USER CODE BEGIN 0 */ 60 | 61 | /* USER CODE END 0 */ 62 | 63 | /** 64 | * @brief The application entry point. 65 | * @retval int 66 | */ 67 | int main(void) 68 | { 69 | 70 | /* USER CODE BEGIN 1 */ 71 | bootloader_init(); 72 | /* USER CODE END 1 */ 73 | 74 | /* MCU Configuration--------------------------------------------------------*/ 75 | 76 | /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ 77 | HAL_Init(); 78 | 79 | /* USER CODE BEGIN Init */ 80 | 81 | /* USER CODE END Init */ 82 | 83 | /* Configure the system clock */ 84 | SystemClock_Config(); 85 | 86 | /* USER CODE BEGIN SysInit */ 87 | 88 | /* USER CODE END SysInit */ 89 | 90 | /* Initialize all configured peripherals */ 91 | MX_GPIO_Init(); 92 | MX_FDCAN1_Init(); 93 | MX_USB_Device_Init(); 94 | /* USER CODE BEGIN 2 */ 95 | uint8_t text[30]; 96 | int text_lenth; 97 | uint32_t count = 0; 98 | /* USER CODE END 2 */ 99 | 100 | /* Infinite loop */ 101 | /* USER CODE BEGIN WHILE */ 102 | while (1) 103 | { 104 | /* USER CODE END WHILE */ 105 | 106 | /* USER CODE BEGIN 3 */ 107 | text_lenth = sprintf((char *) &text,"Hello World !\r\n"); 108 | CDC_Transmit_FS(text,text_lenth); 109 | HAL_Delay(500); 110 | text_lenth = sprintf((char *) &text,"Version: %s\r\n",bootloader_get_version()); 111 | CDC_Transmit_FS(text,text_lenth); 112 | HAL_Delay(500); 113 | HAL_GPIO_TogglePin(LED_TXD_GPIO_Port,LED_TXD_Pin); 114 | HAL_GPIO_TogglePin(LED_RXD_GPIO_Port,LED_RXD_Pin); 115 | HAL_GPIO_TogglePin(LED_READY_GPIO_Port,LED_READY_Pin); 116 | count ++; 117 | if(count >= 15) 118 | { 119 | bootloader_enter_update_mode(); 120 | } 121 | 122 | } 123 | /* USER CODE END 3 */ 124 | } 125 | 126 | /** 127 | * @brief System Clock Configuration 128 | * @retval None 129 | */ 130 | void SystemClock_Config(void) 131 | { 132 | RCC_OscInitTypeDef RCC_OscInitStruct = {0}; 133 | RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; 134 | 135 | /** Configure the main internal regulator output voltage 136 | */ 137 | HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1); 138 | 139 | /** Initializes the RCC Oscillators according to the specified parameters 140 | * in the RCC_OscInitTypeDef structure. 141 | */ 142 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE|RCC_OSCILLATORTYPE_HSI48; 143 | RCC_OscInitStruct.HSEState = RCC_HSE_ON; 144 | RCC_OscInitStruct.HSI48State = RCC_HSI48_ON; 145 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; 146 | RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; 147 | RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV1; 148 | RCC_OscInitStruct.PLL.PLLN = 15; 149 | RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; 150 | RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV8; 151 | RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV4; 152 | if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) 153 | { 154 | Error_Handler(); 155 | } 156 | 157 | /** Initializes the CPU, AHB and APB buses clocks 158 | */ 159 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK 160 | |RCC_CLOCKTYPE_PCLK1; 161 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; 162 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; 163 | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; 164 | 165 | if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) 166 | { 167 | Error_Handler(); 168 | } 169 | } 170 | 171 | /* USER CODE BEGIN 4 */ 172 | 173 | /* USER CODE END 4 */ 174 | 175 | /** 176 | * @brief This function is executed in case of error occurrence. 177 | * @retval None 178 | */ 179 | void Error_Handler(void) 180 | { 181 | /* USER CODE BEGIN Error_Handler_Debug */ 182 | /* User can add his own implementation to report the HAL error return state */ 183 | __disable_irq(); 184 | while (1) 185 | { 186 | } 187 | /* USER CODE END Error_Handler_Debug */ 188 | } 189 | 190 | #ifdef USE_FULL_ASSERT 191 | /** 192 | * @brief Reports the name of the source file and the source line number 193 | * where the assert_param error has occurred. 194 | * @param file: pointer to the source file name 195 | * @param line: assert_param error line source number 196 | * @retval None 197 | */ 198 | void assert_failed(uint8_t *file, uint32_t line) 199 | { 200 | /* USER CODE BEGIN 6 */ 201 | /* User can add his own implementation to report the file name and line number, 202 | ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ 203 | /* USER CODE END 6 */ 204 | } 205 | #endif /* USE_FULL_ASSERT */ 206 | -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/CDC_Test/Core/Src/stm32g0xx_hal_msp.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32g0xx_hal_msp.c 5 | * @brief This file provides code for the MSP Initialization 6 | * and de-Initialization codes. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2024 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | #include "main.h" 23 | /* USER CODE BEGIN Includes */ 24 | 25 | /* USER CODE END Includes */ 26 | 27 | /* Private typedef -----------------------------------------------------------*/ 28 | /* USER CODE BEGIN TD */ 29 | 30 | /* USER CODE END TD */ 31 | 32 | /* Private define ------------------------------------------------------------*/ 33 | /* USER CODE BEGIN Define */ 34 | 35 | /* USER CODE END Define */ 36 | 37 | /* Private macro -------------------------------------------------------------*/ 38 | /* USER CODE BEGIN Macro */ 39 | 40 | /* USER CODE END Macro */ 41 | 42 | /* Private variables ---------------------------------------------------------*/ 43 | /* USER CODE BEGIN PV */ 44 | 45 | /* USER CODE END PV */ 46 | 47 | /* Private function prototypes -----------------------------------------------*/ 48 | /* USER CODE BEGIN PFP */ 49 | 50 | /* USER CODE END PFP */ 51 | 52 | /* External functions --------------------------------------------------------*/ 53 | /* USER CODE BEGIN ExternalFunctions */ 54 | 55 | /* USER CODE END ExternalFunctions */ 56 | 57 | /* USER CODE BEGIN 0 */ 58 | 59 | /* USER CODE END 0 */ 60 | /** 61 | * Initializes the Global MSP. 62 | */ 63 | void HAL_MspInit(void) 64 | { 65 | 66 | /* USER CODE BEGIN MspInit 0 */ 67 | 68 | /* USER CODE END MspInit 0 */ 69 | 70 | __HAL_RCC_SYSCFG_CLK_ENABLE(); 71 | __HAL_RCC_PWR_CLK_ENABLE(); 72 | 73 | /* System interrupt init*/ 74 | 75 | /** Disable the internal Pull-Up in Dead Battery pins of UCPD peripheral 76 | */ 77 | HAL_SYSCFG_StrobeDBattpinsConfig(SYSCFG_CFGR1_UCPD1_STROBE | SYSCFG_CFGR1_UCPD2_STROBE); 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 | -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/CDC_Test/Core/Src/stm32g0xx_it.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32g0xx_it.c 5 | * @brief Interrupt Service Routines. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2024 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | /* USER CODE END Header */ 19 | 20 | /* Includes ------------------------------------------------------------------*/ 21 | #include "main.h" 22 | #include "stm32g0xx_it.h" 23 | /* Private includes ----------------------------------------------------------*/ 24 | /* USER CODE BEGIN Includes */ 25 | /* USER CODE END Includes */ 26 | 27 | /* Private typedef -----------------------------------------------------------*/ 28 | /* USER CODE BEGIN TD */ 29 | 30 | /* USER CODE END TD */ 31 | 32 | /* Private define ------------------------------------------------------------*/ 33 | /* USER CODE BEGIN PD */ 34 | 35 | /* USER CODE END PD */ 36 | 37 | /* Private macro -------------------------------------------------------------*/ 38 | /* USER CODE BEGIN PM */ 39 | 40 | /* USER CODE END PM */ 41 | 42 | /* Private variables ---------------------------------------------------------*/ 43 | /* USER CODE BEGIN PV */ 44 | 45 | /* USER CODE END PV */ 46 | 47 | /* Private function prototypes -----------------------------------------------*/ 48 | /* USER CODE BEGIN PFP */ 49 | 50 | /* USER CODE END PFP */ 51 | 52 | /* Private user code ---------------------------------------------------------*/ 53 | /* USER CODE BEGIN 0 */ 54 | 55 | /* USER CODE END 0 */ 56 | 57 | /* External variables --------------------------------------------------------*/ 58 | extern PCD_HandleTypeDef hpcd_USB_DRD_FS; 59 | /* USER CODE BEGIN EV */ 60 | 61 | /* USER CODE END EV */ 62 | 63 | /******************************************************************************/ 64 | /* Cortex-M0+ Processor Interruption and Exception Handlers */ 65 | /******************************************************************************/ 66 | /** 67 | * @brief This function handles Non maskable interrupt. 68 | */ 69 | void NMI_Handler(void) 70 | { 71 | /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ 72 | 73 | /* USER CODE END NonMaskableInt_IRQn 0 */ 74 | /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ 75 | while (1) 76 | { 77 | } 78 | /* USER CODE END NonMaskableInt_IRQn 1 */ 79 | } 80 | 81 | /** 82 | * @brief This function handles Hard fault interrupt. 83 | */ 84 | void HardFault_Handler(void) 85 | { 86 | /* USER CODE BEGIN HardFault_IRQn 0 */ 87 | 88 | /* USER CODE END HardFault_IRQn 0 */ 89 | while (1) 90 | { 91 | /* USER CODE BEGIN W1_HardFault_IRQn 0 */ 92 | /* USER CODE END W1_HardFault_IRQn 0 */ 93 | } 94 | } 95 | 96 | /** 97 | * @brief This function handles System service call via SWI instruction. 98 | */ 99 | void SVC_Handler(void) 100 | { 101 | /* USER CODE BEGIN SVC_IRQn 0 */ 102 | 103 | /* USER CODE END SVC_IRQn 0 */ 104 | /* USER CODE BEGIN SVC_IRQn 1 */ 105 | 106 | /* USER CODE END SVC_IRQn 1 */ 107 | } 108 | 109 | /** 110 | * @brief This function handles Pendable request for system service. 111 | */ 112 | void PendSV_Handler(void) 113 | { 114 | /* USER CODE BEGIN PendSV_IRQn 0 */ 115 | 116 | /* USER CODE END PendSV_IRQn 0 */ 117 | /* USER CODE BEGIN PendSV_IRQn 1 */ 118 | 119 | /* USER CODE END PendSV_IRQn 1 */ 120 | } 121 | 122 | /** 123 | * @brief This function handles System tick timer. 124 | */ 125 | void SysTick_Handler(void) 126 | { 127 | /* USER CODE BEGIN SysTick_IRQn 0 */ 128 | 129 | /* USER CODE END SysTick_IRQn 0 */ 130 | HAL_IncTick(); 131 | /* USER CODE BEGIN SysTick_IRQn 1 */ 132 | 133 | /* USER CODE END SysTick_IRQn 1 */ 134 | } 135 | 136 | /******************************************************************************/ 137 | /* STM32G0xx Peripheral Interrupt Handlers */ 138 | /* Add here the Interrupt Handlers for the used peripherals. */ 139 | /* For the available peripheral interrupt handler names, */ 140 | /* please refer to the startup file (startup_stm32g0xx.s). */ 141 | /******************************************************************************/ 142 | 143 | /** 144 | * @brief This function handles USB, UCPD1 and UCPD2 global interrupts. 145 | */ 146 | void USB_UCPD1_2_IRQHandler(void) 147 | { 148 | /* USER CODE BEGIN USB_UCPD1_2_IRQn 0 */ 149 | 150 | /* USER CODE END USB_UCPD1_2_IRQn 0 */ 151 | HAL_PCD_IRQHandler(&hpcd_USB_DRD_FS); 152 | /* USER CODE BEGIN USB_UCPD1_2_IRQn 1 */ 153 | 154 | /* USER CODE END USB_UCPD1_2_IRQn 1 */ 155 | } 156 | 157 | /* USER CODE BEGIN 1 */ 158 | 159 | /* USER CODE END 1 */ 160 | -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/CDC_Test/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-2024 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 | -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/CDC_Test/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) 2024 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 | -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/CDC_Test/Core/Startup/startup_stm32g0b1cbtx.s: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file startup_stm32g0b1xx.s 4 | * @author MCD Application Team 5 | * @brief STM32G0b1xx devices vector table GCC toolchain. 6 | * This module performs: 7 | * - Set the initial SP 8 | * - Set the initial PC == Reset_Handler, 9 | * - Set the vector table entries with the exceptions ISR address 10 | * - Branches to main in the C library (which eventually 11 | * calls main()). 12 | * After Reset the Cortex-M0+ processor is in Thread mode, 13 | * priority is Privileged, and the Stack is set to Main. 14 | ****************************************************************************** 15 | * @attention 16 | * 17 | * Copyright (c) 2018-2021 STMicroelectronics. 18 | * All rights reserved. 19 | * 20 | * This software is licensed under terms that can be found in the LICENSE file 21 | * in the root directory of this software component. 22 | * If no LICENSE file comes with this software, it is provided AS-IS. 23 | * 24 | ****************************************************************************** 25 | */ 26 | 27 | .syntax unified 28 | .cpu cortex-m0plus 29 | .fpu softvfp 30 | .thumb 31 | 32 | .global g_pfnVectors 33 | .global Default_Handler 34 | 35 | /* start address for the initialization values of the .data section. 36 | defined in linker script */ 37 | .word _sidata 38 | /* start address for the .data section. defined in linker script */ 39 | .word _sdata 40 | /* end address for the .data section. defined in linker script */ 41 | .word _edata 42 | /* start address for the .bss section. defined in linker script */ 43 | .word _sbss 44 | /* end address for the .bss section. defined in linker script */ 45 | .word _ebss 46 | 47 | /** 48 | * @brief This is the code that gets called when the processor first 49 | * starts execution following a reset event. Only the absolutely 50 | * necessary set is performed, after which the application 51 | * supplied main() routine is called. 52 | * @param None 53 | * @retval None 54 | */ 55 | 56 | .section .text.Reset_Handler 57 | .weak Reset_Handler 58 | .type Reset_Handler, %function 59 | Reset_Handler: 60 | ldr r0, =_estack 61 | mov sp, r0 /* set stack pointer */ 62 | 63 | /* Call the clock system initialization function.*/ 64 | bl SystemInit 65 | 66 | /* Copy the data segment initializers from flash to SRAM */ 67 | ldr r0, =_sdata 68 | ldr r1, =_edata 69 | ldr r2, =_sidata 70 | movs r3, #0 71 | b LoopCopyDataInit 72 | 73 | CopyDataInit: 74 | ldr r4, [r2, r3] 75 | str r4, [r0, r3] 76 | adds r3, r3, #4 77 | 78 | LoopCopyDataInit: 79 | adds r4, r0, r3 80 | cmp r4, r1 81 | bcc CopyDataInit 82 | 83 | /* Zero fill the bss segment. */ 84 | ldr r2, =_sbss 85 | ldr r4, =_ebss 86 | movs r3, #0 87 | b LoopFillZerobss 88 | 89 | FillZerobss: 90 | str r3, [r2] 91 | adds r2, r2, #4 92 | 93 | LoopFillZerobss: 94 | cmp r2, r4 95 | bcc FillZerobss 96 | 97 | /* Call static constructors */ 98 | bl __libc_init_array 99 | /* Call the application s entry point.*/ 100 | bl main 101 | 102 | LoopForever: 103 | b LoopForever 104 | 105 | .size Reset_Handler, .-Reset_Handler 106 | 107 | /** 108 | * @brief This is the code that gets called when the processor receives an 109 | * unexpected interrupt. This simply enters an infinite loop, preserving 110 | * the system state for examination by a debugger. 111 | * 112 | * @param None 113 | * @retval None 114 | */ 115 | .section .text.Default_Handler,"ax",%progbits 116 | Default_Handler: 117 | Infinite_Loop: 118 | b Infinite_Loop 119 | .size Default_Handler, .-Default_Handler 120 | 121 | /****************************************************************************** 122 | * 123 | * The minimal vector table for a Cortex M0. Note that the proper constructs 124 | * must be placed on this to ensure that it ends up at physical address 125 | * 0x0000.0000. 126 | * 127 | ******************************************************************************/ 128 | .section .isr_vector,"a",%progbits 129 | .type g_pfnVectors, %object 130 | 131 | g_pfnVectors: 132 | .word _estack 133 | .word Reset_Handler 134 | .word NMI_Handler 135 | .word HardFault_Handler 136 | .word 0 137 | .word 0 138 | .word 0 139 | .word 0 140 | .word 0 141 | .word 0 142 | .word 0 143 | .word SVC_Handler 144 | .word 0 145 | .word 0 146 | .word PendSV_Handler 147 | .word SysTick_Handler 148 | .word WWDG_IRQHandler /* Window WatchDog */ 149 | .word PVD_VDDIO2_IRQHandler /* PVD through EXTI Line detect */ 150 | .word RTC_TAMP_IRQHandler /* RTC through the EXTI line */ 151 | .word FLASH_IRQHandler /* FLASH */ 152 | .word RCC_CRS_IRQHandler /* RCC & CRS */ 153 | .word EXTI0_1_IRQHandler /* EXTI Line 0 and 1 */ 154 | .word EXTI2_3_IRQHandler /* EXTI Line 2 and 3 */ 155 | .word EXTI4_15_IRQHandler /* EXTI Line 4 to 15 */ 156 | .word USB_UCPD1_2_IRQHandler /* USB, UCPD1, UCPD2 */ 157 | .word DMA1_Channel1_IRQHandler /* DMA1 Channel 1 */ 158 | .word DMA1_Channel2_3_IRQHandler /* DMA1 Channel 2 and Channel 3 */ 159 | .word DMA1_Ch4_7_DMA2_Ch1_5_DMAMUX1_OVR_IRQHandler /* DMA1 Ch4 to Ch7, DMA2 Ch1 to Ch5, DMAMUX1 overrun */ 160 | .word ADC1_COMP_IRQHandler /* ADC1, COMP1 and COMP2 */ 161 | .word TIM1_BRK_UP_TRG_COM_IRQHandler /* TIM1 Break, Update, Trigger and Commutation */ 162 | .word TIM1_CC_IRQHandler /* TIM1 Capture Compare */ 163 | .word TIM2_IRQHandler /* TIM2 */ 164 | .word TIM3_TIM4_IRQHandler /* TIM3, TIM4 */ 165 | .word TIM6_DAC_LPTIM1_IRQHandler /* TIM6, DAC and LPTIM1 */ 166 | .word TIM7_LPTIM2_IRQHandler /* TIM7 and LPTIM2 */ 167 | .word TIM14_IRQHandler /* TIM14 */ 168 | .word TIM15_IRQHandler /* TIM15 */ 169 | .word TIM16_FDCAN_IT0_IRQHandler /* TIM16 & FDCAN1_IT0 & FDCAN2_IT0 */ 170 | .word TIM17_FDCAN_IT1_IRQHandler /* TIM17 & FDCAN1_IT1 & FDCAN2_IT1 */ 171 | .word I2C1_IRQHandler /* I2C1 */ 172 | .word I2C2_3_IRQHandler /* I2C2, I2C3 */ 173 | .word SPI1_IRQHandler /* SPI1 */ 174 | .word SPI2_3_IRQHandler /* SPI2, SPI3 */ 175 | .word USART1_IRQHandler /* USART1 */ 176 | .word USART2_LPUART2_IRQHandler /* USART2 & LPUART2 */ 177 | .word USART3_4_5_6_LPUART1_IRQHandler /* USART3, USART4, USART5, USART6, LPUART1 */ 178 | .word CEC_IRQHandler /* CEC */ 179 | 180 | .size g_pfnVectors, .-g_pfnVectors 181 | 182 | /******************************************************************************* 183 | * 184 | * Provide weak aliases for each Exception handler to the Default_Handler. 185 | * As they are weak aliases, any function with the same name will override 186 | * this definition. 187 | * 188 | *******************************************************************************/ 189 | 190 | .weak NMI_Handler 191 | .thumb_set NMI_Handler,Default_Handler 192 | 193 | .weak HardFault_Handler 194 | .thumb_set HardFault_Handler,Default_Handler 195 | 196 | .weak SVC_Handler 197 | .thumb_set SVC_Handler,Default_Handler 198 | 199 | .weak PendSV_Handler 200 | .thumb_set PendSV_Handler,Default_Handler 201 | 202 | .weak SysTick_Handler 203 | .thumb_set SysTick_Handler,Default_Handler 204 | 205 | .weak WWDG_IRQHandler 206 | .thumb_set WWDG_IRQHandler,Default_Handler 207 | 208 | .weak PVD_VDDIO2_IRQHandler 209 | .thumb_set PVD_VDDIO2_IRQHandler,Default_Handler 210 | 211 | .weak RTC_TAMP_IRQHandler 212 | .thumb_set RTC_TAMP_IRQHandler,Default_Handler 213 | 214 | .weak FLASH_IRQHandler 215 | .thumb_set FLASH_IRQHandler,Default_Handler 216 | 217 | .weak RCC_CRS_IRQHandler 218 | .thumb_set RCC_CRS_IRQHandler,Default_Handler 219 | 220 | .weak EXTI0_1_IRQHandler 221 | .thumb_set EXTI0_1_IRQHandler,Default_Handler 222 | 223 | .weak EXTI2_3_IRQHandler 224 | .thumb_set EXTI2_3_IRQHandler,Default_Handler 225 | 226 | .weak EXTI4_15_IRQHandler 227 | .thumb_set EXTI4_15_IRQHandler,Default_Handler 228 | 229 | .weak USB_UCPD1_2_IRQHandler 230 | .thumb_set USB_UCPD1_2_IRQHandler,Default_Handler 231 | 232 | .weak DMA1_Channel1_IRQHandler 233 | .thumb_set DMA1_Channel1_IRQHandler,Default_Handler 234 | 235 | .weak DMA1_Channel2_3_IRQHandler 236 | .thumb_set DMA1_Channel2_3_IRQHandler,Default_Handler 237 | 238 | .weak DMA1_Ch4_7_DMA2_Ch1_5_DMAMUX1_OVR_IRQHandler 239 | .thumb_set DMA1_Ch4_7_DMA2_Ch1_5_DMAMUX1_OVR_IRQHandler,Default_Handler 240 | 241 | .weak ADC1_COMP_IRQHandler 242 | .thumb_set ADC1_COMP_IRQHandler,Default_Handler 243 | 244 | .weak TIM1_BRK_UP_TRG_COM_IRQHandler 245 | .thumb_set TIM1_BRK_UP_TRG_COM_IRQHandler,Default_Handler 246 | 247 | .weak TIM1_CC_IRQHandler 248 | .thumb_set TIM1_CC_IRQHandler,Default_Handler 249 | 250 | .weak TIM2_IRQHandler 251 | .thumb_set TIM2_IRQHandler,Default_Handler 252 | 253 | .weak TIM3_TIM4_IRQHandler 254 | .thumb_set TIM3_TIM4_IRQHandler,Default_Handler 255 | 256 | .weak TIM6_DAC_LPTIM1_IRQHandler 257 | .thumb_set TIM6_DAC_LPTIM1_IRQHandler,Default_Handler 258 | 259 | .weak TIM7_LPTIM2_IRQHandler 260 | .thumb_set TIM7_LPTIM2_IRQHandler,Default_Handler 261 | 262 | .weak TIM14_IRQHandler 263 | .thumb_set TIM14_IRQHandler,Default_Handler 264 | 265 | .weak TIM15_IRQHandler 266 | .thumb_set TIM15_IRQHandler,Default_Handler 267 | 268 | .weak TIM16_FDCAN_IT0_IRQHandler 269 | .thumb_set TIM16_FDCAN_IT0_IRQHandler,Default_Handler 270 | 271 | .weak TIM17_FDCAN_IT1_IRQHandler 272 | .thumb_set TIM17_FDCAN_IT1_IRQHandler,Default_Handler 273 | 274 | .weak I2C1_IRQHandler 275 | .thumb_set I2C1_IRQHandler,Default_Handler 276 | 277 | .weak I2C2_3_IRQHandler 278 | .thumb_set I2C2_3_IRQHandler,Default_Handler 279 | 280 | .weak SPI1_IRQHandler 281 | .thumb_set SPI1_IRQHandler,Default_Handler 282 | 283 | .weak SPI2_3_IRQHandler 284 | .thumb_set SPI2_3_IRQHandler,Default_Handler 285 | 286 | .weak USART1_IRQHandler 287 | .thumb_set USART1_IRQHandler,Default_Handler 288 | 289 | .weak USART2_LPUART2_IRQHandler 290 | .thumb_set USART2_LPUART2_IRQHandler,Default_Handler 291 | 292 | .weak USART3_4_5_6_LPUART1_IRQHandler 293 | .thumb_set USART3_4_5_6_LPUART1_IRQHandler,Default_Handler 294 | 295 | .weak CEC_IRQHandler 296 | .thumb_set CEC_IRQHandler,Default_Handler 297 | -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/CDC_Test/Debug/CDC_Test.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeActStudio/WeActStudio.USB2CANFDV1/8e508c5c6f99532a896d878caaef665682ecca27/Example/Build_You_Own_firmware/CDC_Test/Debug/CDC_Test.bin -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/CDC_Test/Drivers/CMSIS/Device/ST/STM32G0xx/Include/stm32g0xx.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32g0xx.h 4 | * @author MCD Application Team 5 | * @brief CMSIS STM32G0xx Device Peripheral Access Layer Header File. 6 | * 7 | * The file is the unique include file that the application programmer 8 | * is using in the C source code, usually in main.c. This file contains: 9 | * - Configuration section that allows to select: 10 | * - The STM32G0xx device used in the target application 11 | * - To use or not the peripherals drivers in application code(i.e. 12 | * code will be based on direct access to peripherals registers 13 | * rather than drivers API), this option is controlled by 14 | * "#define USE_HAL_DRIVER" 15 | * 16 | ****************************************************************************** 17 | * @attention 18 | * 19 | * Copyright (c) 2018-2021 STMicroelectronics. 20 | * All rights reserved. 21 | * 22 | * This software is licensed under terms that can be found in the LICENSE file 23 | * in the root directory of this software component. 24 | * If no LICENSE file comes with this software, it is provided AS-IS. 25 | * 26 | ****************************************************************************** 27 | */ 28 | /** @addtogroup CMSIS 29 | * @{ 30 | */ 31 | 32 | /** @addtogroup stm32g0xx 33 | * @{ 34 | */ 35 | 36 | #ifndef STM32G0xx_H 37 | #define STM32G0xx_H 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif /* __cplusplus */ 42 | 43 | /** @addtogroup Library_configuration_section 44 | * @{ 45 | */ 46 | 47 | /** 48 | * @brief STM32 Family 49 | */ 50 | #if !defined (STM32G0) 51 | #define STM32G0 52 | #endif /* STM32G0 */ 53 | 54 | /* Uncomment the line below according to the target STM32G0 device used in your 55 | application 56 | */ 57 | 58 | #if !defined (STM32G071xx) && !defined (STM32G081xx) && !defined (STM32G070xx) \ 59 | && !defined (STM32G030xx) && !defined (STM32G031xx) && !defined (STM32G041xx) \ 60 | && !defined (STM32G0B0xx) && !defined (STM32G0B1xx) && !defined (STM32G0C1xx) \ 61 | && !defined (STM32G050xx) && !defined (STM32G051xx) && !defined (STM32G061xx) 62 | /* #define STM32G0B0xx */ /*!< STM32G0B0xx Devices */ 63 | /* #define STM32G0B1xx */ /*!< STM32G0B1xx Devices */ 64 | /* #define STM32G0C1xx */ /*!< STM32G0C1xx Devices */ 65 | /* #define STM32G070xx */ /*!< STM32G070xx Devices */ 66 | /* #define STM32G071xx */ /*!< STM32G071xx Devices */ 67 | /* #define STM32G081xx */ /*!< STM32G081xx Devices */ 68 | /* #define STM32G050xx */ /*!< STM32G050xx Devices */ 69 | /* #define STM32G051xx */ /*!< STM32G051xx Devices */ 70 | /* #define STM32G061xx */ /*!< STM32G061xx Devices */ 71 | /* #define STM32G030xx */ /*!< STM32G030xx Devices */ 72 | /* #define STM32G031xx */ /*!< STM32G031xx Devices */ 73 | /* #define STM32G041xx */ /*!< STM32G041xx Devices */ 74 | #endif 75 | 76 | /* Tip: To avoid modifying this file each time you need to switch between these 77 | devices, you can define the device in your toolchain compiler preprocessor. 78 | */ 79 | #if !defined (USE_HAL_DRIVER) 80 | /** 81 | * @brief Comment the line below if you will not use the peripherals drivers. 82 | In this case, these drivers will not be included and the application code will 83 | be based on direct access to peripherals registers 84 | */ 85 | /*#define USE_HAL_DRIVER */ 86 | #endif /* USE_HAL_DRIVER */ 87 | 88 | /** 89 | * @brief CMSIS Device version number $VERSION$ 90 | */ 91 | #define __STM32G0_CMSIS_VERSION_MAIN (0x01U) /*!< [31:24] main version */ 92 | #define __STM32G0_CMSIS_VERSION_SUB1 (0x04U) /*!< [23:16] sub1 version */ 93 | #define __STM32G0_CMSIS_VERSION_SUB2 (0x04U) /*!< [15:8] sub2 version */ 94 | #define __STM32G0_CMSIS_VERSION_RC (0x00U) /*!< [7:0] release candidate */ 95 | #define __STM32G0_CMSIS_VERSION ((__STM32G0_CMSIS_VERSION_MAIN << 24)\ 96 | |(__STM32G0_CMSIS_VERSION_SUB1 << 16)\ 97 | |(__STM32G0_CMSIS_VERSION_SUB2 << 8 )\ 98 | |(__STM32G0_CMSIS_VERSION_RC)) 99 | 100 | /** 101 | * @} 102 | */ 103 | 104 | /** @addtogroup Device_Included 105 | * @{ 106 | */ 107 | 108 | #if defined(STM32G0B1xx) 109 | #include "stm32g0b1xx.h" 110 | #elif defined(STM32G0C1xx) 111 | #include "stm32g0c1xx.h" 112 | #elif defined(STM32G0B0xx) 113 | #include "stm32g0b0xx.h" 114 | #elif defined(STM32G071xx) 115 | #include "stm32g071xx.h" 116 | #elif defined(STM32G081xx) 117 | #include "stm32g081xx.h" 118 | #elif defined(STM32G070xx) 119 | #include "stm32g070xx.h" 120 | #elif defined(STM32G031xx) 121 | #include "stm32g031xx.h" 122 | #elif defined(STM32G041xx) 123 | #include "stm32g041xx.h" 124 | #elif defined(STM32G030xx) 125 | #include "stm32g030xx.h" 126 | #elif defined(STM32G051xx) 127 | #include "stm32g051xx.h" 128 | #elif defined(STM32G061xx) 129 | #include "stm32g061xx.h" 130 | #elif defined(STM32G050xx) 131 | #include "stm32g050xx.h" 132 | #else 133 | #error "Please select first the target STM32G0xx device used in your application (in stm32g0xx.h file)" 134 | #endif 135 | 136 | /** 137 | * @} 138 | */ 139 | 140 | /** @addtogroup Exported_types 141 | * @{ 142 | */ 143 | typedef enum 144 | { 145 | RESET = 0, 146 | SET = !RESET 147 | } FlagStatus, ITStatus; 148 | 149 | typedef enum 150 | { 151 | DISABLE = 0, 152 | ENABLE = !DISABLE 153 | } FunctionalState; 154 | #define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE)) 155 | 156 | typedef enum 157 | { 158 | SUCCESS = 0, 159 | ERROR = !SUCCESS 160 | } ErrorStatus; 161 | 162 | /** 163 | * @} 164 | */ 165 | 166 | 167 | /** @addtogroup Exported_macros 168 | * @{ 169 | */ 170 | #define SET_BIT(REG, BIT) ((REG) |= (BIT)) 171 | 172 | #define CLEAR_BIT(REG, BIT) ((REG) &= ~(BIT)) 173 | 174 | #define READ_BIT(REG, BIT) ((REG) & (BIT)) 175 | 176 | #define CLEAR_REG(REG) ((REG) = (0x0)) 177 | 178 | #define WRITE_REG(REG, VAL) ((REG) = (VAL)) 179 | 180 | #define READ_REG(REG) ((REG)) 181 | 182 | #define MODIFY_REG(REG, CLEARMASK, SETMASK) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK))) 183 | 184 | /* Use of interrupt control for register exclusive access */ 185 | /* Atomic 32-bit register access macro to set one or several bits */ 186 | #define ATOMIC_SET_BIT(REG, BIT) \ 187 | do { \ 188 | uint32_t primask; \ 189 | primask = __get_PRIMASK(); \ 190 | __set_PRIMASK(1); \ 191 | SET_BIT((REG), (BIT)); \ 192 | __set_PRIMASK(primask); \ 193 | } while(0) 194 | 195 | /* Atomic 32-bit register access macro to clear one or several bits */ 196 | #define ATOMIC_CLEAR_BIT(REG, BIT) \ 197 | do { \ 198 | uint32_t primask; \ 199 | primask = __get_PRIMASK(); \ 200 | __set_PRIMASK(1); \ 201 | CLEAR_BIT((REG), (BIT)); \ 202 | __set_PRIMASK(primask); \ 203 | } while(0) 204 | 205 | /* Atomic 32-bit register access macro to clear and set one or several bits */ 206 | #define ATOMIC_MODIFY_REG(REG, CLEARMSK, SETMASK) \ 207 | do { \ 208 | uint32_t primask; \ 209 | primask = __get_PRIMASK(); \ 210 | __set_PRIMASK(1); \ 211 | MODIFY_REG((REG), (CLEARMSK), (SETMASK)); \ 212 | __set_PRIMASK(primask); \ 213 | } while(0) 214 | 215 | /* Atomic 16-bit register access macro to set one or several bits */ 216 | #define ATOMIC_SETH_BIT(REG, BIT) ATOMIC_SET_BIT(REG, BIT) \ 217 | 218 | /* Atomic 16-bit register access macro to clear one or several bits */ 219 | #define ATOMIC_CLEARH_BIT(REG, BIT) ATOMIC_CLEAR_BIT(REG, BIT) \ 220 | 221 | /* Atomic 16-bit register access macro to clear and set one or several bits */ 222 | #define ATOMIC_MODIFYH_REG(REG, CLEARMSK, SETMASK) ATOMIC_MODIFY_REG(REG, CLEARMSK, SETMASK) \ 223 | 224 | /*#define POSITION_VAL(VAL) (__CLZ(__RBIT(VAL)))*/ 225 | /** 226 | * @} 227 | */ 228 | 229 | #if defined (USE_HAL_DRIVER) 230 | #include "stm32g0xx_hal.h" 231 | #endif /* USE_HAL_DRIVER */ 232 | 233 | #ifdef __cplusplus 234 | } 235 | #endif /* __cplusplus */ 236 | 237 | #endif /* STM32G0xx_H */ 238 | /** 239 | * @} 240 | */ 241 | 242 | /** 243 | * @} 244 | */ 245 | -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/CDC_Test/Drivers/CMSIS/Device/ST/STM32G0xx/Include/system_stm32g0xx.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32g0xx.h 4 | * @author MCD Application Team 5 | * @brief CMSIS Cortex-M0+ Device System Source File for STM32G0xx devices. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2018-2021 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | /** @addtogroup CMSIS 19 | * @{ 20 | */ 21 | 22 | /** @addtogroup stm32g0xx_system 23 | * @{ 24 | */ 25 | 26 | /** 27 | * @brief Define to prevent recursive inclusion 28 | */ 29 | #ifndef SYSTEM_STM32G0XX_H 30 | #define SYSTEM_STM32G0XX_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /** @addtogroup STM32G0xx_System_Includes 37 | * @{ 38 | */ 39 | 40 | /** 41 | * @} 42 | */ 43 | 44 | 45 | /** @addtogroup STM32G0xx_System_Exported_types 46 | * @{ 47 | */ 48 | /* This variable is updated in three ways: 49 | 1) by calling CMSIS function SystemCoreClockUpdate() 50 | 2) by calling HAL API function HAL_RCC_GetSysClockFreq() 51 | 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency 52 | Note: If you use this function to configure the system clock; then there 53 | is no need to call the 2 first functions listed above, since SystemCoreClock 54 | variable is updated automatically. 55 | */ 56 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 57 | 58 | extern const uint32_t AHBPrescTable[16]; /*!< AHB prescalers table values */ 59 | extern const uint32_t APBPrescTable[8]; /*!< APB prescalers table values */ 60 | 61 | /** 62 | * @} 63 | */ 64 | 65 | /** @addtogroup STM32G0xx_System_Exported_Constants 66 | * @{ 67 | */ 68 | 69 | /** 70 | * @} 71 | */ 72 | 73 | /** @addtogroup STM32G0xx_System_Exported_Macros 74 | * @{ 75 | */ 76 | 77 | /** 78 | * @} 79 | */ 80 | 81 | /** @addtogroup STM32G0xx_System_Exported_Functions 82 | * @{ 83 | */ 84 | 85 | extern void SystemInit(void); 86 | extern void SystemCoreClockUpdate(void); 87 | /** 88 | * @} 89 | */ 90 | 91 | #ifdef __cplusplus 92 | } 93 | #endif 94 | 95 | #endif /*SYSTEM_STM32G0XX_H */ 96 | 97 | /** 98 | * @} 99 | */ 100 | 101 | /** 102 | * @} 103 | */ 104 | -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/CDC_Test/Drivers/CMSIS/Device/ST/STM32G0xx/LICENSE.txt: -------------------------------------------------------------------------------- 1 | This software component is provided to you as part of a software package and 2 | applicable license terms are in the Package_license file. If you received this 3 | software component outside of a package or without applicable license terms, 4 | the terms of the Apache-2.0 license shall apply. 5 | You may obtain a copy of the Apache-2.0 at: 6 | https://opensource.org/licenses/Apache-2.0 7 | -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/CDC_Test/Drivers/CMSIS/Include/cmsis_compiler.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file cmsis_compiler.h 3 | * @brief CMSIS compiler generic header file 4 | * @version V5.1.0 5 | * @date 09. October 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.6 LTM (armclang) 39 | */ 40 | #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) && (__ARMCC_VERSION < 6100100) 41 | #include "cmsis_armclang_ltm.h" 42 | 43 | /* 44 | * Arm Compiler above 6.10.1 (armclang) 45 | */ 46 | #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6100100) 47 | #include "cmsis_armclang.h" 48 | 49 | 50 | /* 51 | * GNU Compiler 52 | */ 53 | #elif defined ( __GNUC__ ) 54 | #include "cmsis_gcc.h" 55 | 56 | 57 | /* 58 | * IAR Compiler 59 | */ 60 | #elif defined ( __ICCARM__ ) 61 | #include 62 | 63 | 64 | /* 65 | * TI Arm Compiler 66 | */ 67 | #elif defined ( __TI_ARM__ ) 68 | #include 69 | 70 | #ifndef __ASM 71 | #define __ASM __asm 72 | #endif 73 | #ifndef __INLINE 74 | #define __INLINE inline 75 | #endif 76 | #ifndef __STATIC_INLINE 77 | #define __STATIC_INLINE static inline 78 | #endif 79 | #ifndef __STATIC_FORCEINLINE 80 | #define __STATIC_FORCEINLINE __STATIC_INLINE 81 | #endif 82 | #ifndef __NO_RETURN 83 | #define __NO_RETURN __attribute__((noreturn)) 84 | #endif 85 | #ifndef __USED 86 | #define __USED __attribute__((used)) 87 | #endif 88 | #ifndef __WEAK 89 | #define __WEAK __attribute__((weak)) 90 | #endif 91 | #ifndef __PACKED 92 | #define __PACKED __attribute__((packed)) 93 | #endif 94 | #ifndef __PACKED_STRUCT 95 | #define __PACKED_STRUCT struct __attribute__((packed)) 96 | #endif 97 | #ifndef __PACKED_UNION 98 | #define __PACKED_UNION union __attribute__((packed)) 99 | #endif 100 | #ifndef __UNALIGNED_UINT32 /* deprecated */ 101 | struct __attribute__((packed)) T_UINT32 { uint32_t v; }; 102 | #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) 103 | #endif 104 | #ifndef __UNALIGNED_UINT16_WRITE 105 | __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; 106 | #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void*)(addr))->v) = (val)) 107 | #endif 108 | #ifndef __UNALIGNED_UINT16_READ 109 | __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; 110 | #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) 111 | #endif 112 | #ifndef __UNALIGNED_UINT32_WRITE 113 | __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; 114 | #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) 115 | #endif 116 | #ifndef __UNALIGNED_UINT32_READ 117 | __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; 118 | #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) 119 | #endif 120 | #ifndef __ALIGNED 121 | #define __ALIGNED(x) __attribute__((aligned(x))) 122 | #endif 123 | #ifndef __RESTRICT 124 | #define __RESTRICT __restrict 125 | #endif 126 | #ifndef __COMPILER_BARRIER 127 | #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored. 128 | #define __COMPILER_BARRIER() (void)0 129 | #endif 130 | 131 | 132 | /* 133 | * TASKING Compiler 134 | */ 135 | #elif defined ( __TASKING__ ) 136 | /* 137 | * The CMSIS functions have been implemented as intrinsics in the compiler. 138 | * Please use "carm -?i" to get an up to date list of all intrinsics, 139 | * Including the CMSIS ones. 140 | */ 141 | 142 | #ifndef __ASM 143 | #define __ASM __asm 144 | #endif 145 | #ifndef __INLINE 146 | #define __INLINE inline 147 | #endif 148 | #ifndef __STATIC_INLINE 149 | #define __STATIC_INLINE static inline 150 | #endif 151 | #ifndef __STATIC_FORCEINLINE 152 | #define __STATIC_FORCEINLINE __STATIC_INLINE 153 | #endif 154 | #ifndef __NO_RETURN 155 | #define __NO_RETURN __attribute__((noreturn)) 156 | #endif 157 | #ifndef __USED 158 | #define __USED __attribute__((used)) 159 | #endif 160 | #ifndef __WEAK 161 | #define __WEAK __attribute__((weak)) 162 | #endif 163 | #ifndef __PACKED 164 | #define __PACKED __packed__ 165 | #endif 166 | #ifndef __PACKED_STRUCT 167 | #define __PACKED_STRUCT struct __packed__ 168 | #endif 169 | #ifndef __PACKED_UNION 170 | #define __PACKED_UNION union __packed__ 171 | #endif 172 | #ifndef __UNALIGNED_UINT32 /* deprecated */ 173 | struct __packed__ T_UINT32 { uint32_t v; }; 174 | #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) 175 | #endif 176 | #ifndef __UNALIGNED_UINT16_WRITE 177 | __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; 178 | #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) 179 | #endif 180 | #ifndef __UNALIGNED_UINT16_READ 181 | __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; 182 | #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) 183 | #endif 184 | #ifndef __UNALIGNED_UINT32_WRITE 185 | __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; 186 | #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) 187 | #endif 188 | #ifndef __UNALIGNED_UINT32_READ 189 | __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; 190 | #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) 191 | #endif 192 | #ifndef __ALIGNED 193 | #define __ALIGNED(x) __align(x) 194 | #endif 195 | #ifndef __RESTRICT 196 | #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored. 197 | #define __RESTRICT 198 | #endif 199 | #ifndef __COMPILER_BARRIER 200 | #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored. 201 | #define __COMPILER_BARRIER() (void)0 202 | #endif 203 | 204 | 205 | /* 206 | * COSMIC Compiler 207 | */ 208 | #elif defined ( __CSMC__ ) 209 | #include 210 | 211 | #ifndef __ASM 212 | #define __ASM _asm 213 | #endif 214 | #ifndef __INLINE 215 | #define __INLINE inline 216 | #endif 217 | #ifndef __STATIC_INLINE 218 | #define __STATIC_INLINE static inline 219 | #endif 220 | #ifndef __STATIC_FORCEINLINE 221 | #define __STATIC_FORCEINLINE __STATIC_INLINE 222 | #endif 223 | #ifndef __NO_RETURN 224 | // NO RETURN is automatically detected hence no warning here 225 | #define __NO_RETURN 226 | #endif 227 | #ifndef __USED 228 | #warning No compiler specific solution for __USED. __USED is ignored. 229 | #define __USED 230 | #endif 231 | #ifndef __WEAK 232 | #define __WEAK __weak 233 | #endif 234 | #ifndef __PACKED 235 | #define __PACKED @packed 236 | #endif 237 | #ifndef __PACKED_STRUCT 238 | #define __PACKED_STRUCT @packed struct 239 | #endif 240 | #ifndef __PACKED_UNION 241 | #define __PACKED_UNION @packed union 242 | #endif 243 | #ifndef __UNALIGNED_UINT32 /* deprecated */ 244 | @packed struct T_UINT32 { uint32_t v; }; 245 | #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) 246 | #endif 247 | #ifndef __UNALIGNED_UINT16_WRITE 248 | __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; 249 | #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) 250 | #endif 251 | #ifndef __UNALIGNED_UINT16_READ 252 | __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; 253 | #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) 254 | #endif 255 | #ifndef __UNALIGNED_UINT32_WRITE 256 | __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; 257 | #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) 258 | #endif 259 | #ifndef __UNALIGNED_UINT32_READ 260 | __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; 261 | #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) 262 | #endif 263 | #ifndef __ALIGNED 264 | #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored. 265 | #define __ALIGNED(x) 266 | #endif 267 | #ifndef __RESTRICT 268 | #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored. 269 | #define __RESTRICT 270 | #endif 271 | #ifndef __COMPILER_BARRIER 272 | #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored. 273 | #define __COMPILER_BARRIER() (void)0 274 | #endif 275 | 276 | 277 | #else 278 | #error Unknown compiler. 279 | #endif 280 | 281 | 282 | #endif /* __CMSIS_COMPILER_H */ 283 | 284 | -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/CDC_Test/Drivers/CMSIS/Include/cmsis_version.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file cmsis_version.h 3 | * @brief CMSIS Core(M) Version definitions 4 | * @version V5.0.3 5 | * @date 24. June 2019 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2009-2019 ARM Limited. All rights reserved. 9 | * 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the License); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | #if defined ( __ICCARM__ ) 26 | #pragma system_include /* treat file as system include file for MISRA check */ 27 | #elif defined (__clang__) 28 | #pragma clang system_header /* treat file as system include file */ 29 | #endif 30 | 31 | #ifndef __CMSIS_VERSION_H 32 | #define __CMSIS_VERSION_H 33 | 34 | /* CMSIS Version definitions */ 35 | #define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */ 36 | #define __CM_CMSIS_VERSION_SUB ( 3U) /*!< [15:0] CMSIS Core(M) sub version */ 37 | #define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \ 38 | __CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */ 39 | #endif 40 | -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/CDC_Test/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 | -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/CDC_Test/Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_def.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32g0xx_hal_def.h 4 | * @author MCD Application Team 5 | * @brief This file contains HAL common defines, enumeration, macros and 6 | * structures definitions. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2018 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef STM32G0xx_HAL_DEF 22 | #define STM32G0xx_HAL_DEF 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "stm32g0xx.h" 30 | #include "Legacy/stm32_hal_legacy.h" /* Aliases file for old names compatibility */ 31 | #include 32 | 33 | /* Exported types ------------------------------------------------------------*/ 34 | 35 | /** 36 | * @brief HAL Status structures definition 37 | */ 38 | typedef enum 39 | { 40 | HAL_OK = 0x00U, 41 | HAL_ERROR = 0x01U, 42 | HAL_BUSY = 0x02U, 43 | HAL_TIMEOUT = 0x03U 44 | } HAL_StatusTypeDef; 45 | 46 | /** 47 | * @brief HAL Lock structures definition 48 | */ 49 | typedef enum 50 | { 51 | HAL_UNLOCKED = 0x00U, 52 | HAL_LOCKED = 0x01U 53 | } HAL_LockTypeDef; 54 | 55 | /* Exported macros -----------------------------------------------------------*/ 56 | 57 | #if !defined(UNUSED) 58 | #define UNUSED(X) (void)X /* To avoid gcc/g++ warnings */ 59 | #endif /* UNUSED */ 60 | 61 | #define HAL_MAX_DELAY 0xFFFFFFFFU 62 | 63 | #define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) == (BIT)) 64 | #define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == 0U) 65 | 66 | #define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__) \ 67 | do{ \ 68 | (__HANDLE__)->__PPP_DMA_FIELD__ = &(__DMA_HANDLE__); \ 69 | (__DMA_HANDLE__).Parent = (__HANDLE__); \ 70 | } while(0U) 71 | 72 | /** @brief Reset the Handles State field. 73 | * @param __HANDLE__ specifies the Peripheral Handle. 74 | * @note This macro can be used for the following purpose: 75 | * - When the Handle is declared as local variable; before passing it as parameter 76 | * to HAL_PPP_Init() for the first time, it is mandatory to use this macro 77 | * to set to 0 the Handles "State" field. 78 | * Otherwise, "State" field may have any random value and the first time the function 79 | * HAL_PPP_Init() is called, the low level hardware initialization will be missed 80 | * (i.e. HAL_PPP_MspInit() will not be executed). 81 | * - When there is a need to reconfigure the low level hardware: instead of calling 82 | * HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init(). 83 | * In this later function, when the Handles "State" field is set to 0, it will execute the function 84 | * HAL_PPP_MspInit() which will reconfigure the low level hardware. 85 | * @retval None 86 | */ 87 | #define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0U) 88 | 89 | #if (USE_RTOS == 1U) 90 | /* Reserved for future use */ 91 | #error " USE_RTOS should be 0 in the current HAL release " 92 | #else 93 | #define __HAL_LOCK(__HANDLE__) \ 94 | do{ \ 95 | if((__HANDLE__)->Lock == HAL_LOCKED) \ 96 | { \ 97 | return HAL_BUSY; \ 98 | } \ 99 | else \ 100 | { \ 101 | (__HANDLE__)->Lock = HAL_LOCKED; \ 102 | } \ 103 | }while (0U) 104 | 105 | #define __HAL_UNLOCK(__HANDLE__) \ 106 | do{ \ 107 | (__HANDLE__)->Lock = HAL_UNLOCKED; \ 108 | }while (0U) 109 | #endif /* USE_RTOS */ 110 | 111 | #if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 112 | #ifndef __weak 113 | #define __weak __attribute__((weak)) 114 | #endif /* __weak */ 115 | #ifndef __packed 116 | #define __packed __attribute__((packed)) 117 | #endif /* __packed */ 118 | #elif defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */ 119 | #ifndef __weak 120 | #define __weak __attribute__((weak)) 121 | #endif /* __weak */ 122 | #ifndef __packed 123 | #define __packed __attribute__((__packed__)) 124 | #endif /* __packed */ 125 | #endif /* __GNUC__ */ 126 | 127 | 128 | /* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */ 129 | /* GNU Compiler */ 130 | #if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) /* ARM Compiler V6 */ 131 | #ifndef __ALIGN_BEGIN 132 | #define __ALIGN_BEGIN 133 | #endif /* __ALIGN_BEGIN */ 134 | #ifndef __ALIGN_END 135 | #define __ALIGN_END __attribute__ ((aligned (4))) 136 | #endif /* __ALIGN_END */ 137 | #elif defined (__GNUC__) && !defined (__CC_ARM) /* GNU Compiler */ 138 | #ifndef __ALIGN_END 139 | #define __ALIGN_END __attribute__ ((aligned (4U))) 140 | #endif /* __ALIGN_END */ 141 | #ifndef __ALIGN_BEGIN 142 | #define __ALIGN_BEGIN 143 | #endif /* __ALIGN_BEGIN */ 144 | #else 145 | #ifndef __ALIGN_END 146 | #define __ALIGN_END 147 | #endif /* __ALIGN_END */ 148 | #ifndef __ALIGN_BEGIN 149 | /* ARM Compiler */ 150 | #if defined (__CC_ARM) /* ARM Compiler V5 */ 151 | #define __ALIGN_BEGIN __align(4U) 152 | /* IAR Compiler */ 153 | #elif defined (__ICCARM__) 154 | #define __ALIGN_BEGIN 155 | #endif /* __CC_ARM */ 156 | #endif /* __ALIGN_BEGIN */ 157 | #endif /* __GNUC__ */ 158 | 159 | /** 160 | * @brief __RAM_FUNC definition 161 | */ 162 | #if defined ( __CC_ARM ) || (defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) 163 | /* ARM Compiler V4/V5 and V6 164 | -------------------------- 165 | RAM functions are defined using the toolchain options. 166 | Functions that are executed in RAM should reside in a separate source module. 167 | Using the 'Options for File' dialog you can simply change the 'Code / Const' 168 | area of a module to a memory space in physical RAM. 169 | Available memory areas are declared in the 'Target' tab of the 'Options for Target' 170 | dialog. 171 | */ 172 | #define __RAM_FUNC 173 | 174 | #elif defined ( __ICCARM__ ) 175 | /* ICCARM Compiler 176 | --------------- 177 | RAM functions are defined using a specific toolchain keyword "__ramfunc". 178 | */ 179 | #define __RAM_FUNC __ramfunc 180 | 181 | #elif defined ( __GNUC__ ) 182 | /* GNU Compiler 183 | ------------ 184 | RAM functions are defined using a specific toolchain attribute 185 | "__attribute__((section(".RamFunc")))". 186 | */ 187 | #define __RAM_FUNC __attribute__((section(".RamFunc"))) 188 | 189 | #endif /* __CC_ARM || __ARMCC_VERSION */ 190 | 191 | /** 192 | * @brief __NOINLINE definition 193 | */ 194 | #if defined ( __CC_ARM ) || (defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) || defined ( __GNUC__ ) 195 | /* ARM V4/V5 and V6 & GNU Compiler 196 | ------------------------------- 197 | */ 198 | #define __NOINLINE __attribute__ ( (noinline) ) 199 | 200 | #elif defined ( __ICCARM__ ) 201 | /* ICCARM Compiler 202 | --------------- 203 | */ 204 | #define __NOINLINE _Pragma("optimize = no_inline") 205 | 206 | #endif /* __CC_ARM || __ARMCC_VERSION */ 207 | 208 | 209 | #ifdef __cplusplus 210 | } 211 | #endif 212 | 213 | #endif /* STM32G0xx_HAL_DEF */ 214 | 215 | 216 | -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/CDC_Test/Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_flash_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32g0xx_hal_flash_ex.h 4 | * @author MCD Application Team 5 | * @brief Header file of FLASH HAL Extended module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2018 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file in 13 | * the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | ****************************************************************************** 16 | */ 17 | 18 | /* Define to prevent recursive inclusion -------------------------------------*/ 19 | #ifndef STM32G0xx_HAL_FLASH_EX_H 20 | #define STM32G0xx_HAL_FLASH_EX_H 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | /* Includes ------------------------------------------------------------------*/ 27 | #include "stm32g0xx_hal_def.h" 28 | 29 | /** @addtogroup STM32G0xx_HAL_Driver 30 | * @{ 31 | */ 32 | 33 | /** @addtogroup FLASHEx 34 | * @{ 35 | */ 36 | 37 | /* Exported types ------------------------------------------------------------*/ 38 | /* Exported constants --------------------------------------------------------*/ 39 | /** @defgroup FLASHEx_Exported_Constants FLASH Exported Constants 40 | * @{ 41 | */ 42 | /** @defgroup FLASHEx_Empty_Check FLASHEx Empty Check 43 | * @{ 44 | */ 45 | #define FLASH_PROG_NOT_EMPTY 0x00000000u /*!< 1st location in Flash is programmed */ 46 | #define FLASH_PROG_EMPTY FLASH_ACR_PROGEMPTY /*!< 1st location in Flash is empty */ 47 | /** 48 | * @} 49 | */ 50 | /** 51 | * @} 52 | */ 53 | 54 | /* Exported macro ------------------------------------------------------------*/ 55 | /* Exported functions --------------------------------------------------------*/ 56 | /** @addtogroup FLASHEx_Exported_Functions 57 | * @{ 58 | */ 59 | 60 | /* Extended Program operation functions *************************************/ 61 | /** @addtogroup FLASHEx_Exported_Functions_Group1 62 | * @{ 63 | */ 64 | HAL_StatusTypeDef HAL_FLASHEx_Erase(FLASH_EraseInitTypeDef *pEraseInit, uint32_t *PageError); 65 | HAL_StatusTypeDef HAL_FLASHEx_Erase_IT(FLASH_EraseInitTypeDef *pEraseInit); 66 | void HAL_FLASHEx_EnableDebugger(void); 67 | void HAL_FLASHEx_DisableDebugger(void); 68 | uint32_t HAL_FLASHEx_FlashEmptyCheck(void); 69 | void HAL_FLASHEx_ForceFlashEmpty(uint32_t FlashEmpty); 70 | #if defined(FLASH_SECURABLE_MEMORY_SUPPORT) 71 | void HAL_FLASHEx_EnableSecMemProtection(uint32_t Banks); 72 | #endif /* FLASH_SECURABLE_MEMORY_SUPPORT */ 73 | HAL_StatusTypeDef HAL_FLASHEx_OBProgram(FLASH_OBProgramInitTypeDef *pOBInit); 74 | void HAL_FLASHEx_OBGetConfig(FLASH_OBProgramInitTypeDef *pOBInit); 75 | /** 76 | * @} 77 | */ 78 | 79 | /** 80 | * @} 81 | */ 82 | 83 | /* Private macros ------------------------------------------------------------*/ 84 | /** @defgroup FLASHEx_Private_Constants FLASHEx Private Constants 85 | * @{ 86 | */ 87 | #define FLASH_PCROP_GRANULARITY_OFFSET 9u /*!< FLASH Code Readout Protection granularity offset */ 88 | #define FLASH_PCROP_GRANULARITY (1UL << FLASH_PCROP_GRANULARITY_OFFSET) /*!< FLASH Code Readout Protection granularity, 512 Bytes */ 89 | /** 90 | * @} 91 | */ 92 | 93 | 94 | /** @defgroup FLASHEx_Private_Macros FLASHEx Private Macros 95 | * @{ 96 | */ 97 | #define IS_FLASH_EMPTY_CHECK(__VALUE__) (((__VALUE__) == FLASH_PROG_EMPTY) || ((__VALUE__) == FLASH_PROG_NOT_EMPTY)) 98 | void FLASH_PageErase(uint32_t Banks, uint32_t Page); 99 | /** 100 | * @} 101 | */ 102 | 103 | /** 104 | * @} 105 | */ 106 | 107 | /** 108 | * @} 109 | */ 110 | 111 | #ifdef __cplusplus 112 | } 113 | #endif 114 | 115 | #endif /* STM32G0xx_HAL_FLASH_EX_H */ 116 | 117 | -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/CDC_Test/Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_pcd_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32g0xx_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) 2018 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 STM32G0xx_HAL_PCD_EX_H 21 | #define STM32G0xx_HAL_PCD_EX_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif /* __cplusplus */ 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "stm32g0xx_hal_def.h" 29 | 30 | #if defined (USB_DRD_FS) 31 | /** @addtogroup STM32G0xx_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 | 50 | 51 | HAL_StatusTypeDef HAL_PCDEx_PMAConfig(PCD_HandleTypeDef *hpcd, uint16_t ep_addr, 52 | uint16_t ep_kind, uint32_t pmaadress); 53 | 54 | 55 | HAL_StatusTypeDef HAL_PCDEx_ActivateLPM(PCD_HandleTypeDef *hpcd); 56 | HAL_StatusTypeDef HAL_PCDEx_DeActivateLPM(PCD_HandleTypeDef *hpcd); 57 | 58 | 59 | HAL_StatusTypeDef HAL_PCDEx_ActivateBCD(PCD_HandleTypeDef *hpcd); 60 | HAL_StatusTypeDef HAL_PCDEx_DeActivateBCD(PCD_HandleTypeDef *hpcd); 61 | void HAL_PCDEx_BCD_VBUSDetect(PCD_HandleTypeDef *hpcd); 62 | 63 | void HAL_PCDEx_LPM_Callback(PCD_HandleTypeDef *hpcd, PCD_LPM_MsgTypeDef msg); 64 | void HAL_PCDEx_BCD_Callback(PCD_HandleTypeDef *hpcd, PCD_BCD_MsgTypeDef msg); 65 | 66 | /** 67 | * @} 68 | */ 69 | 70 | /** 71 | * @} 72 | */ 73 | 74 | /** 75 | * @} 76 | */ 77 | 78 | /** 79 | * @} 80 | */ 81 | #endif /* defined (USB_DRD_FS) */ 82 | 83 | #ifdef __cplusplus 84 | } 85 | #endif /* __cplusplus */ 86 | 87 | 88 | #endif /* STM32G0xx_HAL_PCD_EX_H */ 89 | -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/CDC_Test/Drivers/STM32G0xx_HAL_Driver/LICENSE.txt: -------------------------------------------------------------------------------- 1 | This software component is provided to you as part of a software package and 2 | applicable license terms are in the Package_license file. If you received this 3 | software component outside of a package or without applicable license terms, 4 | the terms of the BSD-3-Clause license shall apply. 5 | You may obtain a copy of the BSD-3-Clause at: 6 | https://opensource.org/licenses/BSD-3-Clause 7 | -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/CDC_Test/Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_pcd_ex.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32g0xx_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) 2018 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 "stm32g0xx_hal.h" 25 | 26 | /** @addtogroup STM32G0xx_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_DRD_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 | 63 | /** 64 | * @brief Configure PMA for EP 65 | * @param hpcd Device instance 66 | * @param ep_addr endpoint address 67 | * @param ep_kind endpoint Kind 68 | * USB_SNG_BUF: Single Buffer used 69 | * USB_DBL_BUF: Double Buffer used 70 | * @param pmaadress: EP address in The PMA: In case of single buffer endpoint 71 | * this parameter is 16-bit value providing the address 72 | * in PMA allocated to endpoint. 73 | * In case of double buffer endpoint this parameter 74 | * is a 32-bit value providing the endpoint buffer 0 address 75 | * in the LSB part of 32-bit value and endpoint buffer 1 address 76 | * in the MSB part of 32-bit value. 77 | * @retval HAL status 78 | */ 79 | 80 | HAL_StatusTypeDef HAL_PCDEx_PMAConfig(PCD_HandleTypeDef *hpcd, uint16_t ep_addr, 81 | uint16_t ep_kind, uint32_t pmaadress) 82 | { 83 | PCD_EPTypeDef *ep; 84 | 85 | /* initialize ep structure*/ 86 | if ((0x80U & ep_addr) == 0x80U) 87 | { 88 | ep = &hpcd->IN_ep[ep_addr & EP_ADDR_MSK]; 89 | } 90 | else 91 | { 92 | ep = &hpcd->OUT_ep[ep_addr]; 93 | } 94 | 95 | /* Here we check if the endpoint is single or double Buffer*/ 96 | if (ep_kind == PCD_SNG_BUF) 97 | { 98 | /* Single Buffer */ 99 | ep->doublebuffer = 0U; 100 | /* Configure the PMA */ 101 | ep->pmaadress = (uint16_t)pmaadress; 102 | } 103 | #if (USE_USB_DOUBLE_BUFFER == 1U) 104 | else /* USB_DBL_BUF */ 105 | { 106 | /* Double Buffer Endpoint */ 107 | ep->doublebuffer = 1U; 108 | /* Configure the PMA */ 109 | ep->pmaaddr0 = (uint16_t)(pmaadress & 0xFFFFU); 110 | ep->pmaaddr1 = (uint16_t)((pmaadress & 0xFFFF0000U) >> 16); 111 | } 112 | #endif /* (USE_USB_DOUBLE_BUFFER == 1U) */ 113 | 114 | return HAL_OK; 115 | } 116 | 117 | /** 118 | * @brief Activate BatteryCharging feature. 119 | * @param hpcd PCD handle 120 | * @retval HAL status 121 | */ 122 | HAL_StatusTypeDef HAL_PCDEx_ActivateBCD(PCD_HandleTypeDef *hpcd) 123 | { 124 | USB_DRD_TypeDef *USBx = hpcd->Instance; 125 | hpcd->battery_charging_active = 1U; 126 | 127 | /* Enable BCD feature */ 128 | USBx->BCDR |= USB_BCDR_BCDEN; 129 | 130 | /* Enable DCD : Data Contact Detect */ 131 | USBx->BCDR &= ~(USB_BCDR_PDEN); 132 | USBx->BCDR &= ~(USB_BCDR_SDEN); 133 | USBx->BCDR |= USB_BCDR_DCDEN; 134 | 135 | return HAL_OK; 136 | } 137 | 138 | /** 139 | * @brief Deactivate BatteryCharging feature. 140 | * @param hpcd PCD handle 141 | * @retval HAL status 142 | */ 143 | HAL_StatusTypeDef HAL_PCDEx_DeActivateBCD(PCD_HandleTypeDef *hpcd) 144 | { 145 | USB_DRD_TypeDef *USBx = hpcd->Instance; 146 | hpcd->battery_charging_active = 0U; 147 | 148 | /* Disable BCD feature */ 149 | USBx->BCDR &= ~(USB_BCDR_BCDEN); 150 | 151 | return HAL_OK; 152 | } 153 | 154 | /** 155 | * @brief Handle BatteryCharging Process. 156 | * @param hpcd PCD handle 157 | * @retval HAL status 158 | */ 159 | void HAL_PCDEx_BCD_VBUSDetect(PCD_HandleTypeDef *hpcd) 160 | { 161 | USB_DRD_TypeDef *USBx = hpcd->Instance; 162 | uint32_t tickstart = HAL_GetTick(); 163 | 164 | /* Wait for Min DCD Timeout */ 165 | HAL_Delay(300U); 166 | 167 | /* Data Pin Contact ? Check Detect flag */ 168 | if ((USBx->BCDR & USB_BCDR_DCDET) == USB_BCDR_DCDET) 169 | { 170 | #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) 171 | hpcd->BCDCallback(hpcd, PCD_BCD_CONTACT_DETECTION); 172 | #else 173 | HAL_PCDEx_BCD_Callback(hpcd, PCD_BCD_CONTACT_DETECTION); 174 | #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ 175 | } 176 | /* Primary detection: checks if connected to Standard Downstream Port 177 | (without charging capability) */ 178 | USBx->BCDR &= ~(USB_BCDR_DCDEN); 179 | HAL_Delay(50U); 180 | USBx->BCDR |= (USB_BCDR_PDEN); 181 | HAL_Delay(50U); 182 | 183 | /* If Charger detect ? */ 184 | if ((USBx->BCDR & USB_BCDR_PDET) == USB_BCDR_PDET) 185 | { 186 | /* Start secondary detection to check connection to Charging Downstream 187 | Port or Dedicated Charging Port */ 188 | USBx->BCDR &= ~(USB_BCDR_PDEN); 189 | HAL_Delay(50U); 190 | USBx->BCDR |= (USB_BCDR_SDEN); 191 | HAL_Delay(50U); 192 | 193 | /* If CDP ? */ 194 | if ((USBx->BCDR & USB_BCDR_SDET) == USB_BCDR_SDET) 195 | { 196 | /* Dedicated Downstream Port DCP */ 197 | #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) 198 | hpcd->BCDCallback(hpcd, PCD_BCD_DEDICATED_CHARGING_PORT); 199 | #else 200 | HAL_PCDEx_BCD_Callback(hpcd, PCD_BCD_DEDICATED_CHARGING_PORT); 201 | #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ 202 | } 203 | else 204 | { 205 | /* Charging Downstream Port CDP */ 206 | #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) 207 | hpcd->BCDCallback(hpcd, PCD_BCD_CHARGING_DOWNSTREAM_PORT); 208 | #else 209 | HAL_PCDEx_BCD_Callback(hpcd, PCD_BCD_CHARGING_DOWNSTREAM_PORT); 210 | #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ 211 | } 212 | } 213 | else /* NO */ 214 | { 215 | /* Standard Downstream Port */ 216 | #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) 217 | hpcd->BCDCallback(hpcd, PCD_BCD_STD_DOWNSTREAM_PORT); 218 | #else 219 | HAL_PCDEx_BCD_Callback(hpcd, PCD_BCD_STD_DOWNSTREAM_PORT); 220 | #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ 221 | } 222 | 223 | /* Battery Charging capability discovery finished Start Enumeration */ 224 | (void)HAL_PCDEx_DeActivateBCD(hpcd); 225 | 226 | /* Check for the Timeout, else start USB Device */ 227 | if ((HAL_GetTick() - tickstart) > 1000U) 228 | { 229 | #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) 230 | hpcd->BCDCallback(hpcd, PCD_BCD_ERROR); 231 | #else 232 | HAL_PCDEx_BCD_Callback(hpcd, PCD_BCD_ERROR); 233 | #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ 234 | } 235 | else 236 | { 237 | #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) 238 | hpcd->BCDCallback(hpcd, PCD_BCD_DISCOVERY_COMPLETED); 239 | #else 240 | HAL_PCDEx_BCD_Callback(hpcd, PCD_BCD_DISCOVERY_COMPLETED); 241 | #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ 242 | } 243 | } 244 | 245 | 246 | /** 247 | * @brief Activate LPM feature. 248 | * @param hpcd PCD handle 249 | * @retval HAL status 250 | */ 251 | HAL_StatusTypeDef HAL_PCDEx_ActivateLPM(PCD_HandleTypeDef *hpcd) 252 | { 253 | 254 | USB_DRD_TypeDef *USBx = hpcd->Instance; 255 | hpcd->lpm_active = 1U; 256 | hpcd->LPM_State = LPM_L0; 257 | 258 | USBx->LPMCSR |= USB_LPMCSR_LMPEN; 259 | USBx->LPMCSR |= USB_LPMCSR_LPMACK; 260 | 261 | return HAL_OK; 262 | } 263 | 264 | /** 265 | * @brief Deactivate LPM feature. 266 | * @param hpcd PCD handle 267 | * @retval HAL status 268 | */ 269 | HAL_StatusTypeDef HAL_PCDEx_DeActivateLPM(PCD_HandleTypeDef *hpcd) 270 | { 271 | USB_DRD_TypeDef *USBx = hpcd->Instance; 272 | 273 | hpcd->lpm_active = 0U; 274 | 275 | USBx->LPMCSR &= ~(USB_LPMCSR_LMPEN); 276 | USBx->LPMCSR &= ~(USB_LPMCSR_LPMACK); 277 | 278 | return HAL_OK; 279 | } 280 | 281 | 282 | 283 | /** 284 | * @brief Send LPM message to user layer callback. 285 | * @param hpcd PCD handle 286 | * @param msg LPM message 287 | * @retval HAL status 288 | */ 289 | __weak void HAL_PCDEx_LPM_Callback(PCD_HandleTypeDef *hpcd, PCD_LPM_MsgTypeDef msg) 290 | { 291 | /* Prevent unused argument(s) compilation warning */ 292 | UNUSED(hpcd); 293 | UNUSED(msg); 294 | 295 | /* NOTE : This function should not be modified, when the callback is needed, 296 | the HAL_PCDEx_LPM_Callback could be implemented in the user file 297 | */ 298 | } 299 | 300 | /** 301 | * @brief Send BatteryCharging message to user layer callback. 302 | * @param hpcd PCD handle 303 | * @param msg LPM message 304 | * @retval HAL status 305 | */ 306 | __weak void HAL_PCDEx_BCD_Callback(PCD_HandleTypeDef *hpcd, PCD_BCD_MsgTypeDef msg) 307 | { 308 | /* Prevent unused argument(s) compilation warning */ 309 | UNUSED(hpcd); 310 | UNUSED(msg); 311 | 312 | /* NOTE : This function should not be modified, when the callback is needed, 313 | the HAL_PCDEx_BCD_Callback could be implemented in the user file 314 | */ 315 | } 316 | 317 | /** 318 | * @} 319 | */ 320 | 321 | /** 322 | * @} 323 | */ 324 | #endif /* defined (USB_DRD_FS) */ 325 | #endif /* HAL_PCD_MODULE_ENABLED */ 326 | 327 | /** 328 | * @} 329 | */ 330 | 331 | /** 332 | * @} 333 | */ 334 | -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/CDC_Test/MDK-ARM/CDC_Test/CDC_Test.axf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeActStudio/WeActStudio.USB2CANFDV1/8e508c5c6f99532a896d878caaef665682ecca27/Example/Build_You_Own_firmware/CDC_Test/MDK-ARM/CDC_Test/CDC_Test.axf -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/CDC_Test/MDK-ARM/CDC_Test/CDC_Test.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeActStudio/WeActStudio.USB2CANFDV1/8e508c5c6f99532a896d878caaef665682ecca27/Example/Build_You_Own_firmware/CDC_Test/MDK-ARM/CDC_Test/CDC_Test.bin -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/CDC_Test/MDK-ARM/DebugConfig/CDC_Test_STM32G0B1CBTx_1.0.0.dbgconf: -------------------------------------------------------------------------------- 1 | // File: STM32G0x1.dbgconf 2 | // Version: 1.0.0 3 | // Note: refer to STM32G0x1 reference manual (RM0444) 4 | 5 | // <<< Use Configuration Wizard in Context Menu >>> 6 | 7 | // Debug MCU configuration register (DBGMCU_CR) 8 | // Reserved bits must be kept at reset value 9 | // DBG_STANDBY Debug Standby Mode 10 | // DBG_STOP Debug Stop Mode 11 | // 12 | DbgMCU_CR = 0x00000006; 13 | 14 | // Debug MCU APB freeze register 1 (DBGMCU_APB_FZ1) 15 | // Reserved bits must be kept at reset value 16 | // DBG_LPTIM1_STOP LPTIMER1 counter stopped when core is halted 17 | // DBG_LPTIM2_STOP LPTIMER2 counter stopped when core is halted 18 | // DBG_I2C1_SMBUS_TIMEOUT I2C1 SMBUS timeout is frozen 19 | // DBG_IWDG_STOP Debug independent watchdog stopped when core is halted 20 | // DBG_WWDG_STOP Debug window watchdog stopped when core is halted 21 | // DBG_RTC_STOP Debug RTC stopped when core is halted 22 | // DBG_TIM7_STOP TIM7 counter stopped when core is halted 23 | // DBG_TIM6_STOP TIM6 counter stopped when core is halted 24 | // DBG_TIM3_STOP TIM3 counter stopped when core is halted 25 | // DBG_TIM2_STOP TIM2 counter stopped when core is halted 26 | // 27 | DbgMCU_APB_Fz1 = 0x00000000; 28 | 29 | // Debug MCU APB freeze register 2 (DBGMCU_APB_FZ2) 30 | // Reserved bits must be kept at reset value 31 | // DBG_TIM17_STOP TIM17 counter stopped when core is halted 32 | // DBG_TIM16_STOP TIM16 counter stopped when core is halted 33 | // DBG_TIM15_STOP TIM15 counter stopped when core is halted 34 | // DBG_TIM14_STOP TIM14 counter stopped when core is halted 35 | // DBG_TIM1_STOP TIM1 counter stopped when core is halted 36 | // 37 | DbgMCU_APB_Fz2 = 0x00000000; 38 | 39 | // <<< end of configuration section >>> 40 | -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/CDC_Test/MDK-ARM/RTE/_CDC_Test/RTE_Components.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Auto generated Run-Time-Environment Configuration File 4 | * *** Do not modify ! *** 5 | * 6 | * Project: 'CDC_Test' 7 | * Target: 'CDC_Test' 8 | */ 9 | 10 | #ifndef RTE_COMPONENTS_H 11 | #define RTE_COMPONENTS_H 12 | 13 | 14 | /* 15 | * Define the Device Header File: 16 | */ 17 | #define CMSIS_device_header "stm32g0xx.h" 18 | 19 | 20 | 21 | #endif /* RTE_COMPONENTS_H */ 22 | -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/CDC_Test/MDK-ARM/startup_stm32g0b1xx.s: -------------------------------------------------------------------------------- 1 | ;****************************************************************************** 2 | ;* File Name : startup_stm32g0b1xx.s 3 | ;* Author : MCD Application Team 4 | ;* Description : STM32G0b1xx devices vector table for MDK-ARM toolchain. 5 | ;* This module performs: 6 | ;* - Set the initial SP 7 | ;* - Set the initial PC == Reset_Handler 8 | ;* - Set the vector table entries with the exceptions ISR address 9 | ;* - Branches to __main in the C library (which eventually 10 | ;* calls main()). 11 | ;* After Reset the CortexM0 processor is in Thread mode, 12 | ;* priority is Privileged, and the Stack is set to Main. 13 | ;* <<< Use Configuration Wizard in Context Menu >>> 14 | ;****************************************************************************** 15 | ;* @attention 16 | ;* 17 | ;* Copyright (c) 2018-2021 STMicroelectronics. 18 | ;* All rights reserved. 19 | ;* 20 | ;* This software is licensed under terms that can be found in the LICENSE file 21 | ;* in the root directory of this software component. 22 | ;* If no LICENSE file comes with this software, it is provided AS-IS. 23 | ;* 24 | ;****************************************************************************** 25 | ; Amount of memory (in bytes) allocated for Stack 26 | ; Tailor this value to your application needs 27 | ; Stack Configuration 28 | ; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> 29 | ; 30 | 31 | Stack_Size EQU 0x400 32 | 33 | AREA STACK, NOINIT, READWRITE, ALIGN=3 34 | Stack_Mem SPACE Stack_Size 35 | __initial_sp 36 | 37 | 38 | ; Heap Configuration 39 | ; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> 40 | ; 41 | 42 | Heap_Size EQU 0x400 43 | 44 | AREA HEAP, NOINIT, READWRITE, ALIGN=3 45 | __heap_base 46 | Heap_Mem SPACE Heap_Size 47 | __heap_limit 48 | 49 | PRESERVE8 50 | THUMB 51 | 52 | 53 | ; Vector Table Mapped to Address 0 at Reset 54 | AREA RESET, DATA, READONLY 55 | EXPORT __Vectors 56 | EXPORT __Vectors_End 57 | EXPORT __Vectors_Size 58 | 59 | __Vectors DCD __initial_sp ; Top of Stack 60 | DCD Reset_Handler ; Reset Handler 61 | DCD NMI_Handler ; NMI Handler 62 | DCD HardFault_Handler ; Hard Fault Handler 63 | DCD 0 ; Reserved 64 | DCD 0 ; Reserved 65 | DCD 0 ; Reserved 66 | DCD 0 ; Reserved 67 | DCD 0 ; Reserved 68 | DCD 0 ; Reserved 69 | DCD 0 ; Reserved 70 | DCD SVC_Handler ; SVCall Handler 71 | DCD 0 ; Reserved 72 | DCD 0 ; Reserved 73 | DCD PendSV_Handler ; PendSV Handler 74 | DCD SysTick_Handler ; SysTick Handler 75 | 76 | ; External Interrupts 77 | DCD WWDG_IRQHandler ; Window Watchdog 78 | DCD PVD_VDDIO2_IRQHandler ; PVD through EXTI Line detect 79 | DCD RTC_TAMP_IRQHandler ; RTC through EXTI Line 80 | DCD FLASH_IRQHandler ; FLASH 81 | DCD RCC_CRS_IRQHandler ; RCC & CRS 82 | DCD EXTI0_1_IRQHandler ; EXTI Line 0 and 1 83 | DCD EXTI2_3_IRQHandler ; EXTI Line 2 and 3 84 | DCD EXTI4_15_IRQHandler ; EXTI Line 4 to 15 85 | DCD USB_UCPD1_2_IRQHandler ; USB, UCPD1 & UCPD2 86 | DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1 87 | DCD DMA1_Channel2_3_IRQHandler ; DMA1 Channel 2 and Channel 3 88 | DCD DMA1_Ch4_7_DMA2_Ch1_5_DMAMUX1_OVR_IRQHandler ; DMA1 Ch4 to Ch7, DMA2 Ch1 to Ch5 ,DMAMUX1 overrun 89 | DCD ADC1_COMP_IRQHandler ; ADC1, COMP1, COMP2 and COMP3 90 | DCD TIM1_BRK_UP_TRG_COM_IRQHandler ; TIM1 Break, Update, Trigger and Commutation 91 | DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare 92 | DCD TIM2_IRQHandler ; TIM2 93 | DCD TIM3_TIM4_IRQHandler ; TIM3, TIM4 94 | DCD TIM6_DAC_LPTIM1_IRQHandler ; TIM6, DAC & LPTIM1 95 | DCD TIM7_LPTIM2_IRQHandler ; TIM7 & LPTIM2 96 | DCD TIM14_IRQHandler ; TIM14 97 | DCD TIM15_IRQHandler ; TIM15 98 | DCD TIM16_FDCAN_IT0_IRQHandler ; TIM16 & FDCAN1_IT0 & FDCAN2_IT0 99 | DCD TIM17_FDCAN_IT1_IRQHandler ; TIM17 & FDCAN1_IT1 & FDCAN2_IT1 100 | DCD I2C1_IRQHandler ; I2C1 101 | DCD I2C2_3_IRQHandler ; I2C2, I2C3 102 | DCD SPI1_IRQHandler ; SPI1 103 | DCD SPI2_3_IRQHandler ; SPI2, SPI3 104 | DCD USART1_IRQHandler ; USART1 105 | DCD USART2_LPUART2_IRQHandler ; USART2 & LPUART2 106 | DCD USART3_4_5_6_LPUART1_IRQHandler ; USART3, USART4, USART5, USART6, LPUART1 107 | DCD CEC_IRQHandler ; CEC 108 | 109 | __Vectors_End 110 | 111 | __Vectors_Size EQU __Vectors_End - __Vectors 112 | 113 | AREA |.text|, CODE, READONLY 114 | 115 | ; Reset handler routine 116 | Reset_Handler PROC 117 | EXPORT Reset_Handler [WEAK] 118 | IMPORT __main 119 | IMPORT SystemInit 120 | LDR R0, =SystemInit 121 | BLX R0 122 | LDR R0, =__main 123 | BX R0 124 | ENDP 125 | 126 | ; Dummy Exception Handlers (infinite loops which can be modified) 127 | 128 | NMI_Handler PROC 129 | EXPORT NMI_Handler [WEAK] 130 | B . 131 | ENDP 132 | HardFault_Handler\ 133 | PROC 134 | EXPORT HardFault_Handler [WEAK] 135 | B . 136 | ENDP 137 | SVC_Handler PROC 138 | EXPORT SVC_Handler [WEAK] 139 | B . 140 | ENDP 141 | PendSV_Handler PROC 142 | EXPORT PendSV_Handler [WEAK] 143 | B . 144 | ENDP 145 | SysTick_Handler PROC 146 | EXPORT SysTick_Handler [WEAK] 147 | B . 148 | ENDP 149 | 150 | Default_Handler PROC 151 | 152 | EXPORT WWDG_IRQHandler [WEAK] 153 | EXPORT PVD_VDDIO2_IRQHandler [WEAK] 154 | EXPORT RTC_TAMP_IRQHandler [WEAK] 155 | EXPORT FLASH_IRQHandler [WEAK] 156 | EXPORT RCC_CRS_IRQHandler [WEAK] 157 | EXPORT EXTI0_1_IRQHandler [WEAK] 158 | EXPORT EXTI2_3_IRQHandler [WEAK] 159 | EXPORT EXTI4_15_IRQHandler [WEAK] 160 | EXPORT USB_UCPD1_2_IRQHandler [WEAK] 161 | EXPORT DMA1_Channel1_IRQHandler [WEAK] 162 | EXPORT DMA1_Channel2_3_IRQHandler [WEAK] 163 | EXPORT DMA1_Ch4_7_DMA2_Ch1_5_DMAMUX1_OVR_IRQHandler [WEAK] 164 | EXPORT ADC1_COMP_IRQHandler [WEAK] 165 | EXPORT TIM1_BRK_UP_TRG_COM_IRQHandler [WEAK] 166 | EXPORT TIM1_CC_IRQHandler [WEAK] 167 | EXPORT TIM2_IRQHandler [WEAK] 168 | EXPORT TIM3_TIM4_IRQHandler [WEAK] 169 | EXPORT TIM6_DAC_LPTIM1_IRQHandler [WEAK] 170 | EXPORT TIM7_LPTIM2_IRQHandler [WEAK] 171 | EXPORT TIM14_IRQHandler [WEAK] 172 | EXPORT TIM15_IRQHandler [WEAK] 173 | EXPORT TIM16_FDCAN_IT0_IRQHandler [WEAK] 174 | EXPORT TIM17_FDCAN_IT1_IRQHandler [WEAK] 175 | EXPORT I2C1_IRQHandler [WEAK] 176 | EXPORT I2C2_3_IRQHandler [WEAK] 177 | EXPORT SPI1_IRQHandler [WEAK] 178 | EXPORT SPI2_3_IRQHandler [WEAK] 179 | EXPORT USART1_IRQHandler [WEAK] 180 | EXPORT USART2_LPUART2_IRQHandler [WEAK] 181 | EXPORT USART3_4_5_6_LPUART1_IRQHandler [WEAK] 182 | EXPORT CEC_IRQHandler [WEAK] 183 | 184 | 185 | WWDG_IRQHandler 186 | PVD_VDDIO2_IRQHandler 187 | RTC_TAMP_IRQHandler 188 | FLASH_IRQHandler 189 | RCC_CRS_IRQHandler 190 | EXTI0_1_IRQHandler 191 | EXTI2_3_IRQHandler 192 | EXTI4_15_IRQHandler 193 | USB_UCPD1_2_IRQHandler 194 | DMA1_Channel1_IRQHandler 195 | DMA1_Channel2_3_IRQHandler 196 | DMA1_Ch4_7_DMA2_Ch1_5_DMAMUX1_OVR_IRQHandler 197 | ADC1_COMP_IRQHandler 198 | TIM1_BRK_UP_TRG_COM_IRQHandler 199 | TIM1_CC_IRQHandler 200 | TIM2_IRQHandler 201 | TIM3_TIM4_IRQHandler 202 | TIM6_DAC_LPTIM1_IRQHandler 203 | TIM7_LPTIM2_IRQHandler 204 | TIM14_IRQHandler 205 | TIM15_IRQHandler 206 | TIM16_FDCAN_IT0_IRQHandler 207 | TIM17_FDCAN_IT1_IRQHandler 208 | I2C1_IRQHandler 209 | I2C2_3_IRQHandler 210 | SPI1_IRQHandler 211 | SPI2_3_IRQHandler 212 | USART1_IRQHandler 213 | USART2_LPUART2_IRQHandler 214 | USART3_4_5_6_LPUART1_IRQHandler 215 | CEC_IRQHandler 216 | 217 | B . 218 | 219 | ENDP 220 | 221 | ALIGN 222 | 223 | ;******************************************************************************* 224 | ; User Stack and Heap initialization 225 | ;******************************************************************************* 226 | IF :DEF:__MICROLIB 227 | 228 | EXPORT __initial_sp 229 | EXPORT __heap_base 230 | EXPORT __heap_limit 231 | 232 | ELSE 233 | 234 | IMPORT __use_two_region_memory 235 | EXPORT __user_initial_stackheap 236 | 237 | __user_initial_stackheap 238 | 239 | LDR R0, = Heap_Mem 240 | LDR R1, =(Stack_Mem + Stack_Size) 241 | LDR R2, = (Heap_Mem + Heap_Size) 242 | LDR R3, = Stack_Mem 243 | BX LR 244 | 245 | ALIGN 246 | 247 | ENDIF 248 | 249 | END 250 | -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/CDC_Test/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 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 __USB_CDC_H 21 | #define __USB_CDC_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "usbd_ioreq.h" 29 | 30 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 31 | * @{ 32 | */ 33 | 34 | /** @defgroup usbd_cdc 35 | * @brief This file is the Header file for usbd_cdc.c 36 | * @{ 37 | */ 38 | 39 | 40 | /** @defgroup usbd_cdc_Exported_Defines 41 | * @{ 42 | */ 43 | #ifndef CDC_IN_EP 44 | #define CDC_IN_EP 0x81U /* EP1 for data IN */ 45 | #endif /* CDC_IN_EP */ 46 | #ifndef CDC_OUT_EP 47 | #define CDC_OUT_EP 0x01U /* EP1 for data OUT */ 48 | #endif /* CDC_OUT_EP */ 49 | #ifndef CDC_CMD_EP 50 | #define CDC_CMD_EP 0x82U /* EP2 for CDC commands */ 51 | #endif /* CDC_CMD_EP */ 52 | 53 | #ifndef CDC_HS_BINTERVAL 54 | #define CDC_HS_BINTERVAL 0x10U 55 | #endif /* CDC_HS_BINTERVAL */ 56 | 57 | #ifndef CDC_FS_BINTERVAL 58 | #define CDC_FS_BINTERVAL 0x10U 59 | #endif /* CDC_FS_BINTERVAL */ 60 | 61 | /* CDC Endpoints parameters: you can fine tune these values depending on the needed baudrates and performance. */ 62 | #define CDC_DATA_HS_MAX_PACKET_SIZE 512U /* Endpoint IN & OUT Packet size */ 63 | #define CDC_DATA_FS_MAX_PACKET_SIZE 64U /* Endpoint IN & OUT Packet size */ 64 | #define CDC_CMD_PACKET_SIZE 8U /* Control Endpoint Packet size */ 65 | 66 | #define USB_CDC_CONFIG_DESC_SIZ 67U 67 | #define CDC_DATA_HS_IN_PACKET_SIZE CDC_DATA_HS_MAX_PACKET_SIZE 68 | #define CDC_DATA_HS_OUT_PACKET_SIZE CDC_DATA_HS_MAX_PACKET_SIZE 69 | 70 | #define CDC_DATA_FS_IN_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE 71 | #define CDC_DATA_FS_OUT_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE 72 | 73 | #define CDC_REQ_MAX_DATA_SIZE 0x7U 74 | /*---------------------------------------------------------------------*/ 75 | /* CDC definitions */ 76 | /*---------------------------------------------------------------------*/ 77 | #define CDC_SEND_ENCAPSULATED_COMMAND 0x00U 78 | #define CDC_GET_ENCAPSULATED_RESPONSE 0x01U 79 | #define CDC_SET_COMM_FEATURE 0x02U 80 | #define CDC_GET_COMM_FEATURE 0x03U 81 | #define CDC_CLEAR_COMM_FEATURE 0x04U 82 | #define CDC_SET_LINE_CODING 0x20U 83 | #define CDC_GET_LINE_CODING 0x21U 84 | #define CDC_SET_CONTROL_LINE_STATE 0x22U 85 | #define CDC_SEND_BREAK 0x23U 86 | 87 | /** 88 | * @} 89 | */ 90 | 91 | 92 | /** @defgroup USBD_CORE_Exported_TypesDefinitions 93 | * @{ 94 | */ 95 | 96 | /** 97 | * @} 98 | */ 99 | typedef struct 100 | { 101 | uint32_t bitrate; 102 | uint8_t format; 103 | uint8_t paritytype; 104 | uint8_t datatype; 105 | } USBD_CDC_LineCodingTypeDef; 106 | 107 | typedef struct _USBD_CDC_Itf 108 | { 109 | int8_t (* Init)(void); 110 | int8_t (* DeInit)(void); 111 | int8_t (* Control)(uint8_t cmd, uint8_t *pbuf, uint16_t length); 112 | int8_t (* Receive)(uint8_t *Buf, uint32_t *Len); 113 | int8_t (* TransmitCplt)(uint8_t *Buf, uint32_t *Len, uint8_t epnum); 114 | } USBD_CDC_ItfTypeDef; 115 | 116 | 117 | typedef struct 118 | { 119 | uint32_t data[CDC_DATA_HS_MAX_PACKET_SIZE / 4U]; /* Force 32-bit alignment */ 120 | uint8_t CmdOpCode; 121 | uint8_t CmdLength; 122 | uint8_t *RxBuffer; 123 | uint8_t *TxBuffer; 124 | uint32_t RxLength; 125 | uint32_t TxLength; 126 | 127 | __IO uint32_t TxState; 128 | __IO uint32_t RxState; 129 | } USBD_CDC_HandleTypeDef; 130 | 131 | 132 | 133 | /** @defgroup USBD_CORE_Exported_Macros 134 | * @{ 135 | */ 136 | 137 | /** 138 | * @} 139 | */ 140 | 141 | /** @defgroup USBD_CORE_Exported_Variables 142 | * @{ 143 | */ 144 | 145 | extern USBD_ClassTypeDef USBD_CDC; 146 | #define USBD_CDC_CLASS &USBD_CDC 147 | /** 148 | * @} 149 | */ 150 | 151 | /** @defgroup USB_CORE_Exported_Functions 152 | * @{ 153 | */ 154 | uint8_t USBD_CDC_RegisterInterface(USBD_HandleTypeDef *pdev, 155 | USBD_CDC_ItfTypeDef *fops); 156 | 157 | #ifdef USE_USBD_COMPOSITE 158 | uint8_t USBD_CDC_SetTxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff, 159 | uint32_t length, uint8_t ClassId); 160 | uint8_t USBD_CDC_TransmitPacket(USBD_HandleTypeDef *pdev, uint8_t ClassId); 161 | #else 162 | uint8_t USBD_CDC_SetTxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff, 163 | uint32_t length); 164 | uint8_t USBD_CDC_TransmitPacket(USBD_HandleTypeDef *pdev); 165 | #endif /* USE_USBD_COMPOSITE */ 166 | uint8_t USBD_CDC_SetRxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff); 167 | uint8_t USBD_CDC_ReceivePacket(USBD_HandleTypeDef *pdev); 168 | /** 169 | * @} 170 | */ 171 | 172 | #ifdef __cplusplus 173 | } 174 | #endif 175 | 176 | #endif /* __USB_CDC_H */ 177 | /** 178 | * @} 179 | */ 180 | 181 | /** 182 | * @} 183 | */ 184 | 185 | -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/CDC_Test/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 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 __USBD_CORE_H 21 | #define __USBD_CORE_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "usbd_conf.h" 29 | #include "usbd_def.h" 30 | #include "usbd_ioreq.h" 31 | #include "usbd_ctlreq.h" 32 | 33 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 34 | * @{ 35 | */ 36 | 37 | /** @defgroup USBD_CORE 38 | * @brief This file is the Header file for usbd_core.c file 39 | * @{ 40 | */ 41 | 42 | 43 | /** @defgroup USBD_CORE_Exported_Defines 44 | * @{ 45 | */ 46 | #ifndef USBD_DEBUG_LEVEL 47 | #define USBD_DEBUG_LEVEL 0U 48 | #endif /* USBD_DEBUG_LEVEL */ 49 | /** 50 | * @} 51 | */ 52 | 53 | 54 | /** @defgroup USBD_CORE_Exported_TypesDefinitions 55 | * @{ 56 | */ 57 | 58 | 59 | /** 60 | * @} 61 | */ 62 | 63 | 64 | 65 | /** @defgroup USBD_CORE_Exported_Macros 66 | * @{ 67 | */ 68 | 69 | /** 70 | * @} 71 | */ 72 | 73 | /** @defgroup USBD_CORE_Exported_Variables 74 | * @{ 75 | */ 76 | #define USBD_SOF USBD_LL_SOF 77 | /** 78 | * @} 79 | */ 80 | 81 | /** @defgroup USBD_CORE_Exported_FunctionsPrototype 82 | * @{ 83 | */ 84 | USBD_StatusTypeDef USBD_Init(USBD_HandleTypeDef *pdev, USBD_DescriptorsTypeDef *pdesc, uint8_t id); 85 | USBD_StatusTypeDef USBD_DeInit(USBD_HandleTypeDef *pdev); 86 | USBD_StatusTypeDef USBD_Start(USBD_HandleTypeDef *pdev); 87 | USBD_StatusTypeDef USBD_Stop(USBD_HandleTypeDef *pdev); 88 | USBD_StatusTypeDef USBD_RegisterClass(USBD_HandleTypeDef *pdev, USBD_ClassTypeDef *pclass); 89 | 90 | #ifdef USE_USBD_COMPOSITE 91 | USBD_StatusTypeDef USBD_RegisterClassComposite(USBD_HandleTypeDef *pdev, USBD_ClassTypeDef *pclass, 92 | USBD_CompositeClassTypeDef classtype, uint8_t *EpAddr); 93 | 94 | USBD_StatusTypeDef USBD_UnRegisterClassComposite(USBD_HandleTypeDef *pdev); 95 | uint8_t USBD_CoreGetEPAdd(USBD_HandleTypeDef *pdev, uint8_t ep_dir, uint8_t ep_type, uint8_t ClassId); 96 | #endif /* USE_USBD_COMPOSITE */ 97 | 98 | uint8_t USBD_CoreFindIF(USBD_HandleTypeDef *pdev, uint8_t index); 99 | uint8_t USBD_CoreFindEP(USBD_HandleTypeDef *pdev, uint8_t index); 100 | 101 | USBD_StatusTypeDef USBD_RunTestMode(USBD_HandleTypeDef *pdev); 102 | USBD_StatusTypeDef USBD_SetClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx); 103 | USBD_StatusTypeDef USBD_ClrClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx); 104 | 105 | USBD_StatusTypeDef USBD_LL_SetupStage(USBD_HandleTypeDef *pdev, uint8_t *psetup); 106 | USBD_StatusTypeDef USBD_LL_DataOutStage(USBD_HandleTypeDef *pdev, uint8_t epnum, uint8_t *pdata); 107 | USBD_StatusTypeDef USBD_LL_DataInStage(USBD_HandleTypeDef *pdev, uint8_t epnum, uint8_t *pdata); 108 | 109 | USBD_StatusTypeDef USBD_LL_Reset(USBD_HandleTypeDef *pdev); 110 | USBD_StatusTypeDef USBD_LL_SetSpeed(USBD_HandleTypeDef *pdev, USBD_SpeedTypeDef speed); 111 | USBD_StatusTypeDef USBD_LL_Suspend(USBD_HandleTypeDef *pdev); 112 | USBD_StatusTypeDef USBD_LL_Resume(USBD_HandleTypeDef *pdev); 113 | 114 | USBD_StatusTypeDef USBD_LL_SOF(USBD_HandleTypeDef *pdev); 115 | USBD_StatusTypeDef USBD_LL_IsoINIncomplete(USBD_HandleTypeDef *pdev, uint8_t epnum); 116 | USBD_StatusTypeDef USBD_LL_IsoOUTIncomplete(USBD_HandleTypeDef *pdev, uint8_t epnum); 117 | 118 | USBD_StatusTypeDef USBD_LL_DevConnected(USBD_HandleTypeDef *pdev); 119 | USBD_StatusTypeDef USBD_LL_DevDisconnected(USBD_HandleTypeDef *pdev); 120 | 121 | /* USBD Low Level Driver */ 122 | USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev); 123 | USBD_StatusTypeDef USBD_LL_DeInit(USBD_HandleTypeDef *pdev); 124 | USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef *pdev); 125 | USBD_StatusTypeDef USBD_LL_Stop(USBD_HandleTypeDef *pdev); 126 | 127 | USBD_StatusTypeDef USBD_LL_OpenEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr, 128 | uint8_t ep_type, uint16_t ep_mps); 129 | 130 | USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr); 131 | USBD_StatusTypeDef USBD_LL_FlushEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr); 132 | USBD_StatusTypeDef USBD_LL_StallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr); 133 | USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr); 134 | USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev, uint8_t dev_addr); 135 | 136 | USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef *pdev, uint8_t ep_addr, 137 | uint8_t *pbuf, uint32_t size); 138 | 139 | USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev, uint8_t ep_addr, 140 | uint8_t *pbuf, uint32_t size); 141 | 142 | #ifdef USBD_HS_TESTMODE_ENABLE 143 | USBD_StatusTypeDef USBD_LL_SetTestMode(USBD_HandleTypeDef *pdev, uint8_t testmode); 144 | #endif /* USBD_HS_TESTMODE_ENABLE */ 145 | 146 | uint8_t USBD_LL_IsStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr); 147 | uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef *pdev, uint8_t ep_addr); 148 | 149 | void USBD_LL_Delay(uint32_t Delay); 150 | 151 | void *USBD_GetEpDesc(uint8_t *pConfDesc, uint8_t EpAddr); 152 | USBD_DescHeaderTypeDef *USBD_GetNextDesc(uint8_t *pbuf, uint16_t *ptr); 153 | 154 | /** 155 | * @} 156 | */ 157 | 158 | #ifdef __cplusplus 159 | } 160 | #endif 161 | 162 | #endif /* __USBD_CORE_H */ 163 | 164 | /** 165 | * @} 166 | */ 167 | 168 | /** 169 | * @} 170 | */ 171 | 172 | 173 | -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/CDC_Test/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 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 __USB_REQUEST_H 21 | #define __USB_REQUEST_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "usbd_def.h" 29 | 30 | 31 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 32 | * @{ 33 | */ 34 | 35 | /** @defgroup USBD_REQ 36 | * @brief header file for the usbd_req.c file 37 | * @{ 38 | */ 39 | 40 | /** @defgroup USBD_REQ_Exported_Defines 41 | * @{ 42 | */ 43 | /** 44 | * @} 45 | */ 46 | 47 | 48 | /** @defgroup USBD_REQ_Exported_Types 49 | * @{ 50 | */ 51 | /** 52 | * @} 53 | */ 54 | 55 | 56 | 57 | /** @defgroup USBD_REQ_Exported_Macros 58 | * @{ 59 | */ 60 | /** 61 | * @} 62 | */ 63 | 64 | /** @defgroup USBD_REQ_Exported_Variables 65 | * @{ 66 | */ 67 | /** 68 | * @} 69 | */ 70 | 71 | /** @defgroup USBD_REQ_Exported_FunctionsPrototype 72 | * @{ 73 | */ 74 | 75 | USBD_StatusTypeDef USBD_StdDevReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 76 | USBD_StatusTypeDef USBD_StdItfReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 77 | USBD_StatusTypeDef USBD_StdEPReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 78 | 79 | void USBD_CtlError(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 80 | void USBD_ParseSetupRequest(USBD_SetupReqTypedef *req, uint8_t *pdata); 81 | void USBD_GetString(uint8_t *desc, uint8_t *unicode, uint16_t *len); 82 | 83 | /** 84 | * @} 85 | */ 86 | 87 | #ifdef __cplusplus 88 | } 89 | #endif 90 | 91 | #endif /* __USB_REQUEST_H */ 92 | 93 | /** 94 | * @} 95 | */ 96 | 97 | /** 98 | * @} 99 | */ 100 | 101 | 102 | -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/CDC_Test/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 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 __USBD_IOREQ_H 21 | #define __USBD_IOREQ_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "usbd_def.h" 29 | #include "usbd_core.h" 30 | 31 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 32 | * @{ 33 | */ 34 | 35 | /** @defgroup USBD_IOREQ 36 | * @brief header file for the usbd_ioreq.c file 37 | * @{ 38 | */ 39 | 40 | /** @defgroup USBD_IOREQ_Exported_Defines 41 | * @{ 42 | */ 43 | /** 44 | * @} 45 | */ 46 | 47 | 48 | /** @defgroup USBD_IOREQ_Exported_Types 49 | * @{ 50 | */ 51 | 52 | 53 | /** 54 | * @} 55 | */ 56 | 57 | 58 | 59 | /** @defgroup USBD_IOREQ_Exported_Macros 60 | * @{ 61 | */ 62 | 63 | /** 64 | * @} 65 | */ 66 | 67 | /** @defgroup USBD_IOREQ_Exported_Variables 68 | * @{ 69 | */ 70 | 71 | /** 72 | * @} 73 | */ 74 | 75 | /** @defgroup USBD_IOREQ_Exported_FunctionsPrototype 76 | * @{ 77 | */ 78 | 79 | USBD_StatusTypeDef USBD_CtlSendData(USBD_HandleTypeDef *pdev, 80 | uint8_t *pbuf, uint32_t len); 81 | 82 | USBD_StatusTypeDef USBD_CtlContinueSendData(USBD_HandleTypeDef *pdev, 83 | uint8_t *pbuf, uint32_t len); 84 | 85 | USBD_StatusTypeDef USBD_CtlPrepareRx(USBD_HandleTypeDef *pdev, 86 | uint8_t *pbuf, uint32_t len); 87 | 88 | USBD_StatusTypeDef USBD_CtlContinueRx(USBD_HandleTypeDef *pdev, 89 | uint8_t *pbuf, uint32_t len); 90 | 91 | USBD_StatusTypeDef USBD_CtlSendStatus(USBD_HandleTypeDef *pdev); 92 | USBD_StatusTypeDef USBD_CtlReceiveStatus(USBD_HandleTypeDef *pdev); 93 | 94 | uint32_t USBD_GetRxCount(USBD_HandleTypeDef *pdev, uint8_t ep_addr); 95 | 96 | /** 97 | * @} 98 | */ 99 | 100 | #ifdef __cplusplus 101 | } 102 | #endif 103 | 104 | #endif /* __USBD_IOREQ_H */ 105 | 106 | /** 107 | * @} 108 | */ 109 | 110 | /** 111 | * @} 112 | */ 113 | 114 | -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/CDC_Test/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 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 | /* Includes ------------------------------------------------------------------*/ 20 | #include "usbd_ioreq.h" 21 | 22 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 23 | * @{ 24 | */ 25 | 26 | 27 | /** @defgroup USBD_IOREQ 28 | * @brief control I/O requests module 29 | * @{ 30 | */ 31 | 32 | /** @defgroup USBD_IOREQ_Private_TypesDefinitions 33 | * @{ 34 | */ 35 | /** 36 | * @} 37 | */ 38 | 39 | 40 | /** @defgroup USBD_IOREQ_Private_Defines 41 | * @{ 42 | */ 43 | 44 | /** 45 | * @} 46 | */ 47 | 48 | 49 | /** @defgroup USBD_IOREQ_Private_Macros 50 | * @{ 51 | */ 52 | /** 53 | * @} 54 | */ 55 | 56 | 57 | /** @defgroup USBD_IOREQ_Private_Variables 58 | * @{ 59 | */ 60 | 61 | /** 62 | * @} 63 | */ 64 | 65 | 66 | /** @defgroup USBD_IOREQ_Private_FunctionPrototypes 67 | * @{ 68 | */ 69 | /** 70 | * @} 71 | */ 72 | 73 | 74 | /** @defgroup USBD_IOREQ_Private_Functions 75 | * @{ 76 | */ 77 | 78 | /** 79 | * @brief USBD_CtlSendData 80 | * send data on the ctl pipe 81 | * @param pdev: device instance 82 | * @param buff: pointer to data buffer 83 | * @param len: length of data to be sent 84 | * @retval status 85 | */ 86 | USBD_StatusTypeDef USBD_CtlSendData(USBD_HandleTypeDef *pdev, 87 | uint8_t *pbuf, uint32_t len) 88 | { 89 | /* Set EP0 State */ 90 | pdev->ep0_state = USBD_EP0_DATA_IN; 91 | pdev->ep_in[0].total_length = len; 92 | 93 | #ifdef USBD_AVOID_PACKET_SPLIT_MPS 94 | pdev->ep_in[0].rem_length = 0U; 95 | #else 96 | pdev->ep_in[0].rem_length = len; 97 | #endif /* USBD_AVOID_PACKET_SPLIT_MPS */ 98 | 99 | /* Start the transfer */ 100 | (void)USBD_LL_Transmit(pdev, 0x00U, pbuf, len); 101 | 102 | return USBD_OK; 103 | } 104 | 105 | /** 106 | * @brief USBD_CtlContinueSendData 107 | * continue sending data on the ctl pipe 108 | * @param pdev: device instance 109 | * @param buff: pointer to data buffer 110 | * @param len: length of data to be sent 111 | * @retval status 112 | */ 113 | USBD_StatusTypeDef USBD_CtlContinueSendData(USBD_HandleTypeDef *pdev, 114 | uint8_t *pbuf, uint32_t len) 115 | { 116 | /* Start the next transfer */ 117 | (void)USBD_LL_Transmit(pdev, 0x00U, pbuf, len); 118 | 119 | return USBD_OK; 120 | } 121 | 122 | /** 123 | * @brief USBD_CtlPrepareRx 124 | * receive data on the ctl pipe 125 | * @param pdev: device instance 126 | * @param buff: pointer to data buffer 127 | * @param len: length of data to be received 128 | * @retval status 129 | */ 130 | USBD_StatusTypeDef USBD_CtlPrepareRx(USBD_HandleTypeDef *pdev, 131 | uint8_t *pbuf, uint32_t len) 132 | { 133 | /* Set EP0 State */ 134 | pdev->ep0_state = USBD_EP0_DATA_OUT; 135 | pdev->ep_out[0].total_length = len; 136 | 137 | #ifdef USBD_AVOID_PACKET_SPLIT_MPS 138 | pdev->ep_out[0].rem_length = 0U; 139 | #else 140 | pdev->ep_out[0].rem_length = len; 141 | #endif /* USBD_AVOID_PACKET_SPLIT_MPS */ 142 | 143 | /* Start the transfer */ 144 | (void)USBD_LL_PrepareReceive(pdev, 0U, pbuf, len); 145 | 146 | return USBD_OK; 147 | } 148 | 149 | /** 150 | * @brief USBD_CtlContinueRx 151 | * continue receive data on the ctl pipe 152 | * @param pdev: device instance 153 | * @param buff: pointer to data buffer 154 | * @param len: length of data to be received 155 | * @retval status 156 | */ 157 | USBD_StatusTypeDef USBD_CtlContinueRx(USBD_HandleTypeDef *pdev, 158 | uint8_t *pbuf, uint32_t len) 159 | { 160 | (void)USBD_LL_PrepareReceive(pdev, 0U, pbuf, len); 161 | 162 | return USBD_OK; 163 | } 164 | 165 | /** 166 | * @brief USBD_CtlSendStatus 167 | * send zero lzngth packet on the ctl pipe 168 | * @param pdev: device instance 169 | * @retval status 170 | */ 171 | USBD_StatusTypeDef USBD_CtlSendStatus(USBD_HandleTypeDef *pdev) 172 | { 173 | /* Set EP0 State */ 174 | pdev->ep0_state = USBD_EP0_STATUS_IN; 175 | 176 | /* Start the transfer */ 177 | (void)USBD_LL_Transmit(pdev, 0x00U, NULL, 0U); 178 | 179 | return USBD_OK; 180 | } 181 | 182 | /** 183 | * @brief USBD_CtlReceiveStatus 184 | * receive zero lzngth packet on the ctl pipe 185 | * @param pdev: device instance 186 | * @retval status 187 | */ 188 | USBD_StatusTypeDef USBD_CtlReceiveStatus(USBD_HandleTypeDef *pdev) 189 | { 190 | /* Set EP0 State */ 191 | pdev->ep0_state = USBD_EP0_STATUS_OUT; 192 | 193 | /* Start the transfer */ 194 | (void)USBD_LL_PrepareReceive(pdev, 0U, NULL, 0U); 195 | 196 | return USBD_OK; 197 | } 198 | 199 | /** 200 | * @brief USBD_GetRxCount 201 | * returns the received data length 202 | * @param pdev: device instance 203 | * @param ep_addr: endpoint address 204 | * @retval Rx Data blength 205 | */ 206 | uint32_t USBD_GetRxCount(USBD_HandleTypeDef *pdev, uint8_t ep_addr) 207 | { 208 | return USBD_LL_GetRxDataSize(pdev, ep_addr); 209 | } 210 | 211 | /** 212 | * @} 213 | */ 214 | 215 | 216 | /** 217 | * @} 218 | */ 219 | 220 | 221 | /** 222 | * @} 223 | */ 224 | 225 | -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/CDC_Test/Middlewares/ST/STM32_USB_Device_Library/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 SLA0044 license shall apply and are fully reproduced below: 5 | 6 | SLA0044 Rev5/February 2018 7 | 8 | Software license agreement 9 | 10 | ULTIMATE LIBERTY SOFTWARE LICENSE AGREEMENT 11 | 12 | BY INSTALLING, COPYING, DOWNLOADING, ACCESSING OR OTHERWISE USING THIS SOFTWARE 13 | OR ANY PART THEREOF (AND THE RELATED DOCUMENTATION) FROM STMICROELECTRONICS 14 | INTERNATIONAL N.V, SWISS BRANCH AND/OR ITS AFFILIATED COMPANIES 15 | (STMICROELECTRONICS), THE RECIPIENT, ON BEHALF OF HIMSELF OR HERSELF, OR ON 16 | BEHALF OF ANY ENTITY BY WHICH SUCH RECIPIENT IS EMPLOYED AND/OR ENGAGED AGREES 17 | TO BE BOUND BY THIS SOFTWARE LICENSE AGREEMENT. 18 | 19 | Under STMicroelectronics’ intellectual property rights, the redistribution, 20 | reproduction and use in source and binary forms of the software or any part 21 | thereof, with or without modification, are permitted provided that the following 22 | conditions are met: 23 | 24 | 1. Redistribution of source code (modified or not) must retain any copyright 25 | notice, this list of conditions and the disclaimer set forth below as items 10 26 | and 11. 27 | 28 | 2. Redistributions in binary form, except as embedded into microcontroller or 29 | microprocessor device manufactured by or for STMicroelectronics or a software 30 | update for such device, must reproduce any copyright notice provided with the 31 | binary code, this list of conditions, and the disclaimer set forth below as 32 | items 10 and 11, in documentation and/or other materials provided with the 33 | distribution. 34 | 35 | 3. Neither the name of STMicroelectronics nor the names of other contributors to 36 | this software may be used to endorse or promote products derived from this 37 | software or part thereof without specific written permission. 38 | 39 | 4. This software or any part thereof, including modifications and/or derivative 40 | works of this software, must be used and execute solely and exclusively on or in 41 | combination with a microcontroller or microprocessor device manufactured by or 42 | for STMicroelectronics. 43 | 44 | 5. No use, reproduction or redistribution of this software partially or totally 45 | may be done in any manner that would subject this software to any Open Source 46 | Terms. “Open Source Terms” shall mean any open source license which requires as 47 | part of distribution of software that the source code of such software is 48 | distributed therewith or otherwise made available, or open source license that 49 | substantially complies with the Open Source definition specified at 50 | www.opensource.org and any other comparable open source license such as for 51 | example GNU General Public License (GPL), Eclipse Public License (EPL), Apache 52 | Software License, BSD license or MIT license. 53 | 54 | 6. STMicroelectronics has no obligation to provide any maintenance, support or 55 | updates for the software. 56 | 57 | 7. The software is and will remain the exclusive property of STMicroelectronics 58 | and its licensors. The recipient will not take any action that jeopardizes 59 | STMicroelectronics and its licensors' proprietary rights or acquire any rights 60 | in the software, except the limited rights specified hereunder. 61 | 62 | 8. The recipient shall comply with all applicable laws and regulations affecting 63 | the use of the software or any part thereof including any applicable export 64 | control law or regulation. 65 | 66 | 9. Redistribution and use of this software or any part thereof other than as 67 | permitted under this license is void and will automatically terminate your 68 | rights under this license. 69 | 70 | 10. THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" AND 71 | ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 72 | IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 73 | NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY RIGHTS, WHICH ARE 74 | DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT SHALL 75 | STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 76 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 77 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 78 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 79 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 80 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 81 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 82 | 83 | 11. EXCEPT AS EXPRESSLY PERMITTED HEREUNDER, NO LICENSE OR OTHER RIGHTS, WHETHER 84 | EXPRESS OR IMPLIED, ARE GRANTED UNDER ANY PATENT OR OTHER INTELLECTUAL PROPERTY 85 | RIGHTS OF STMICROELECTRONICS OR ANY THIRD PARTY. 86 | 87 | -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/CDC_Test/STM32G0B1CBTX_FLASH.ld: -------------------------------------------------------------------------------- 1 | /* 2 | ****************************************************************************** 3 | ** 4 | ** @file : LinkerScript.ld 5 | ** 6 | ** @author : Auto-generated by STM32CubeIDE 7 | ** 8 | ** @brief : Linker script for STM32G0B1CBTx Device from STM32G0 series 9 | ** 128KBytes FLASH 10 | ** 144KBytes 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) 2024 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 = 0x400; /* required amount of heap */ 42 | _Min_Stack_Size = 0x400; /* required amount of stack */ 43 | 44 | /* Memories definition */ 45 | MEMORY 46 | { 47 | NOINIT_RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 8 48 | RAM (xrw) : ORIGIN = 0x20000008, LENGTH = 0x23FF8 49 | FLASH (rx) : ORIGIN = 0x8006800, LENGTH = 49K 50 | } 51 | 52 | /* Sections */ 53 | SECTIONS 54 | { 55 | /* The startup code into "FLASH" Rom type memory */ 56 | .isr_vector : 57 | { 58 | . = ALIGN(4); 59 | KEEP(*(.isr_vector)) /* Startup code */ 60 | . = ALIGN(4); 61 | } >FLASH 62 | 63 | /* The program code and other data into "FLASH" Rom type memory */ 64 | .text : 65 | { 66 | . = ALIGN(4); 67 | *(.text) /* .text sections (code) */ 68 | *(.text*) /* .text* sections (code) */ 69 | *(.glue_7) /* glue arm to thumb code */ 70 | *(.glue_7t) /* glue thumb to arm code */ 71 | *(.eh_frame) 72 | 73 | KEEP (*(.init)) 74 | KEEP (*(.fini)) 75 | 76 | . = ALIGN(4); 77 | _etext = .; /* define a global symbols at end of code */ 78 | } >FLASH 79 | 80 | /* Constant data into "FLASH" Rom type memory */ 81 | .rodata : 82 | { 83 | . = ALIGN(4); 84 | *(.rodata) /* .rodata sections (constants, strings, etc.) */ 85 | *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ 86 | . = ALIGN(4); 87 | } >FLASH 88 | 89 | .ARM.extab (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */ 90 | { 91 | . = ALIGN(4); 92 | *(.ARM.extab* .gnu.linkonce.armextab.*) 93 | . = ALIGN(4); 94 | } >FLASH 95 | 96 | .ARM (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */ 97 | { 98 | . = ALIGN(4); 99 | __exidx_start = .; 100 | *(.ARM.exidx*) 101 | __exidx_end = .; 102 | . = ALIGN(4); 103 | } >FLASH 104 | 105 | .preinit_array (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */ 106 | { 107 | . = ALIGN(4); 108 | PROVIDE_HIDDEN (__preinit_array_start = .); 109 | KEEP (*(.preinit_array*)) 110 | PROVIDE_HIDDEN (__preinit_array_end = .); 111 | . = ALIGN(4); 112 | } >FLASH 113 | 114 | .init_array (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */ 115 | { 116 | . = ALIGN(4); 117 | PROVIDE_HIDDEN (__init_array_start = .); 118 | KEEP (*(SORT(.init_array.*))) 119 | KEEP (*(.init_array*)) 120 | PROVIDE_HIDDEN (__init_array_end = .); 121 | . = ALIGN(4); 122 | } >FLASH 123 | 124 | .fini_array (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */ 125 | { 126 | . = ALIGN(4); 127 | PROVIDE_HIDDEN (__fini_array_start = .); 128 | KEEP (*(SORT(.fini_array.*))) 129 | KEEP (*(.fini_array*)) 130 | PROVIDE_HIDDEN (__fini_array_end = .); 131 | . = ALIGN(4); 132 | } >FLASH 133 | 134 | /* Used by the startup to initialize data */ 135 | _sidata = LOADADDR(.data); 136 | 137 | /* Initialized data sections into "RAM" Ram type memory */ 138 | .data : 139 | { 140 | . = ALIGN(4); 141 | _sdata = .; /* create a global symbol at data start */ 142 | *(.data) /* .data sections */ 143 | *(.data*) /* .data* sections */ 144 | *(.RamFunc) /* .RamFunc sections */ 145 | *(.RamFunc*) /* .RamFunc* sections */ 146 | 147 | . = ALIGN(4); 148 | _edata = .; /* define a global symbol at data end */ 149 | 150 | } >RAM AT> FLASH 151 | 152 | /* Uninitialized data section into "RAM" Ram type memory */ 153 | . = ALIGN(4); 154 | .bss : 155 | { 156 | /* This is used by the startup in order to initialize the .bss section */ 157 | _sbss = .; /* define a global symbol at bss start */ 158 | __bss_start__ = _sbss; 159 | *(.bss) 160 | *(.bss*) 161 | *(COMMON) 162 | 163 | . = ALIGN(4); 164 | _ebss = .; /* define a global symbol at bss end */ 165 | __bss_end__ = _ebss; 166 | } >RAM 167 | 168 | /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */ 169 | ._user_heap_stack : 170 | { 171 | . = ALIGN(8); 172 | PROVIDE ( end = . ); 173 | PROVIDE ( _end = . ); 174 | . = . + _Min_Heap_Size; 175 | . = . + _Min_Stack_Size; 176 | . = ALIGN(8); 177 | } >RAM 178 | 179 | .no_init_ram : 180 | { 181 | KEEP(*(*.no_init_ram*)) 182 | } >NOINIT_RAM AT> FLASH 183 | 184 | /* Remove information from the compiler libraries */ 185 | /DISCARD/ : 186 | { 187 | libc.a ( * ) 188 | libm.a ( * ) 189 | libgcc.a ( * ) 190 | } 191 | 192 | .ARM.attributes 0 : { *(.ARM.attributes) } 193 | } 194 | -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/CDC_Test/STM32G0B1CBTX_RAM.ld: -------------------------------------------------------------------------------- 1 | /* 2 | ****************************************************************************** 3 | ** 4 | ** @file : LinkerScript.ld (debug in RAM dedicated) 5 | ** 6 | ** @author : Auto-generated by STM32CubeIDE 7 | ** 8 | ** @brief : Linker script for STM32G0B1CBTx Device from STM32G0 series 9 | ** 128KBytes FLASH 10 | ** 144KBytes 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) 2024 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 = 0x400; /* required amount of heap */ 42 | _Min_Stack_Size = 0x400; /* required amount of stack */ 43 | 44 | /* Memories definition */ 45 | MEMORY 46 | { 47 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 144K 48 | FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 128K 49 | } 50 | 51 | /* Sections */ 52 | SECTIONS 53 | { 54 | /* The startup code into "RAM" Ram type memory */ 55 | .isr_vector : 56 | { 57 | . = ALIGN(4); 58 | KEEP(*(.isr_vector)) /* Startup code */ 59 | . = ALIGN(4); 60 | } >RAM 61 | 62 | /* The program code and other data into "RAM" Ram 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 | *(.RamFunc) /* .RamFunc sections */ 72 | *(.RamFunc*) /* .RamFunc* sections */ 73 | 74 | KEEP (*(.init)) 75 | KEEP (*(.fini)) 76 | 77 | . = ALIGN(4); 78 | _etext = .; /* define a global symbols at end of code */ 79 | } >RAM 80 | 81 | /* Constant data into "RAM" Ram type memory */ 82 | .rodata : 83 | { 84 | . = ALIGN(4); 85 | *(.rodata) /* .rodata sections (constants, strings, etc.) */ 86 | *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ 87 | . = ALIGN(4); 88 | } >RAM 89 | 90 | .ARM.extab (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */ 91 | { 92 | . = ALIGN(4); 93 | *(.ARM.extab* .gnu.linkonce.armextab.*) 94 | . = ALIGN(4); 95 | } >RAM 96 | 97 | .ARM (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */ 98 | { 99 | . = ALIGN(4); 100 | __exidx_start = .; 101 | *(.ARM.exidx*) 102 | __exidx_end = .; 103 | . = ALIGN(4); 104 | } >RAM 105 | 106 | .preinit_array (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */ 107 | { 108 | . = ALIGN(4); 109 | PROVIDE_HIDDEN (__preinit_array_start = .); 110 | KEEP (*(.preinit_array*)) 111 | PROVIDE_HIDDEN (__preinit_array_end = .); 112 | . = ALIGN(4); 113 | } >RAM 114 | 115 | .init_array (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */ 116 | { 117 | . = ALIGN(4); 118 | PROVIDE_HIDDEN (__init_array_start = .); 119 | KEEP (*(SORT(.init_array.*))) 120 | KEEP (*(.init_array*)) 121 | PROVIDE_HIDDEN (__init_array_end = .); 122 | . = ALIGN(4); 123 | } >RAM 124 | 125 | .fini_array (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */ 126 | { 127 | . = ALIGN(4); 128 | PROVIDE_HIDDEN (__fini_array_start = .); 129 | KEEP (*(SORT(.fini_array.*))) 130 | KEEP (*(.fini_array*)) 131 | PROVIDE_HIDDEN (__fini_array_end = .); 132 | . = ALIGN(4); 133 | } >RAM 134 | 135 | /* Used by the startup to initialize data */ 136 | _sidata = LOADADDR(.data); 137 | 138 | /* Initialized data sections into "RAM" Ram type memory */ 139 | .data : 140 | { 141 | . = ALIGN(4); 142 | _sdata = .; /* create a global symbol at data start */ 143 | *(.data) /* .data sections */ 144 | *(.data*) /* .data* sections */ 145 | 146 | . = ALIGN(4); 147 | _edata = .; /* define a global symbol at data end */ 148 | 149 | } >RAM 150 | 151 | /* Uninitialized data section into "RAM" Ram type memory */ 152 | . = ALIGN(4); 153 | .bss : 154 | { 155 | /* This is used by the startup in order to initialize the .bss section */ 156 | _sbss = .; /* define a global symbol at bss start */ 157 | __bss_start__ = _sbss; 158 | *(.bss) 159 | *(.bss*) 160 | *(COMMON) 161 | 162 | . = ALIGN(4); 163 | _ebss = .; /* define a global symbol at bss end */ 164 | __bss_end__ = _ebss; 165 | } >RAM 166 | 167 | /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */ 168 | ._user_heap_stack : 169 | { 170 | . = ALIGN(8); 171 | PROVIDE ( end = . ); 172 | PROVIDE ( _end = . ); 173 | . = . + _Min_Heap_Size; 174 | . = . + _Min_Stack_Size; 175 | . = ALIGN(8); 176 | } >RAM 177 | 178 | /* Remove information from the compiler libraries */ 179 | /DISCARD/ : 180 | { 181 | libc.a ( * ) 182 | libm.a ( * ) 183 | libgcc.a ( * ) 184 | } 185 | 186 | .ARM.attributes 0 : { *(.ARM.attributes) } 187 | } 188 | -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/CDC_Test/USB_Device/App/usb_device.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : usb_device.c 5 | * @version : v3.0_Cube 6 | * @brief : This file implements the USB Device 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2024 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 | extern void Error_Handler(void); 44 | /* USB Device Core handle declaration. */ 45 | USBD_HandleTypeDef hUsbDeviceFS; 46 | extern USBD_DescriptorsTypeDef CDC_Desc; 47 | 48 | /* 49 | * -- Insert your variables declaration here -- 50 | */ 51 | /* USER CODE BEGIN 0 */ 52 | 53 | /* USER CODE END 0 */ 54 | 55 | /* 56 | * -- Insert your external function declaration here -- 57 | */ 58 | /* USER CODE BEGIN 1 */ 59 | 60 | /* USER CODE END 1 */ 61 | 62 | /** 63 | * Init USB device Library, add supported class and start the library 64 | * @retval None 65 | */ 66 | void MX_USB_Device_Init(void) 67 | { 68 | /* USER CODE BEGIN USB_Device_Init_PreTreatment */ 69 | 70 | /* USER CODE END USB_Device_Init_PreTreatment */ 71 | 72 | /* Init Device Library, add supported class and start the library. */ 73 | if (USBD_Init(&hUsbDeviceFS, &CDC_Desc, DEVICE_FS) != USBD_OK) { 74 | Error_Handler(); 75 | } 76 | if (USBD_RegisterClass(&hUsbDeviceFS, &USBD_CDC) != USBD_OK) { 77 | Error_Handler(); 78 | } 79 | if (USBD_CDC_RegisterInterface(&hUsbDeviceFS, &USBD_Interface_fops_FS) != USBD_OK) { 80 | Error_Handler(); 81 | } 82 | if (USBD_Start(&hUsbDeviceFS) != USBD_OK) { 83 | Error_Handler(); 84 | } 85 | /* USER CODE BEGIN USB_Device_Init_PostTreatment */ 86 | 87 | /* USER CODE END USB_Device_Init_PostTreatment */ 88 | } 89 | 90 | /** 91 | * @} 92 | */ 93 | 94 | /** 95 | * @} 96 | */ 97 | 98 | -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/CDC_Test/USB_Device/App/usb_device.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : usb_device.h 5 | * @version : v3.0_Cube 6 | * @brief : Header for usb_device.c file. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2024 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 "stm32g0xx.h" 31 | #include "stm32g0xx_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 | 104 | -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/CDC_Test/USB_Device/App/usbd_cdc_if.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : usbd_cdc_if.c 5 | * @version : v3.0_Cube 6 | * @brief : Usb device for Virtual Com Port. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2024 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 "usbd_cdc_if.h" 23 | 24 | /* USER CODE BEGIN INCLUDE */ 25 | 26 | /* USER CODE END INCLUDE */ 27 | 28 | /* Private typedef -----------------------------------------------------------*/ 29 | /* Private define ------------------------------------------------------------*/ 30 | /* Private macro -------------------------------------------------------------*/ 31 | 32 | /* USER CODE BEGIN PV */ 33 | /* Private variables ---------------------------------------------------------*/ 34 | 35 | /* USER CODE END PV */ 36 | 37 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY 38 | * @brief Usb device library. 39 | * @{ 40 | */ 41 | 42 | /** @addtogroup USBD_CDC_IF 43 | * @{ 44 | */ 45 | 46 | /** @defgroup USBD_CDC_IF_Private_TypesDefinitions USBD_CDC_IF_Private_TypesDefinitions 47 | * @brief Private types. 48 | * @{ 49 | */ 50 | 51 | /* USER CODE BEGIN PRIVATE_TYPES */ 52 | 53 | /* USER CODE END PRIVATE_TYPES */ 54 | 55 | /** 56 | * @} 57 | */ 58 | 59 | /** @defgroup USBD_CDC_IF_Private_Defines USBD_CDC_IF_Private_Defines 60 | * @brief Private defines. 61 | * @{ 62 | */ 63 | 64 | /* USER CODE BEGIN PRIVATE_DEFINES */ 65 | /* USER CODE END PRIVATE_DEFINES */ 66 | 67 | /** 68 | * @} 69 | */ 70 | 71 | /** @defgroup USBD_CDC_IF_Private_Macros USBD_CDC_IF_Private_Macros 72 | * @brief Private macros. 73 | * @{ 74 | */ 75 | 76 | /* USER CODE BEGIN PRIVATE_MACRO */ 77 | 78 | /* USER CODE END PRIVATE_MACRO */ 79 | 80 | /** 81 | * @} 82 | */ 83 | 84 | /** @defgroup USBD_CDC_IF_Private_Variables USBD_CDC_IF_Private_Variables 85 | * @brief Private variables. 86 | * @{ 87 | */ 88 | /* Create buffer for reception and transmission */ 89 | /* It's up to user to redefine and/or remove those define */ 90 | /** Received data over USB are stored in this buffer */ 91 | uint8_t UserRxBufferFS[APP_RX_DATA_SIZE]; 92 | 93 | /** Data to send over USB CDC are stored in this buffer */ 94 | uint8_t UserTxBufferFS[APP_TX_DATA_SIZE]; 95 | 96 | /* USER CODE BEGIN PRIVATE_VARIABLES */ 97 | 98 | /* USER CODE END PRIVATE_VARIABLES */ 99 | 100 | /** 101 | * @} 102 | */ 103 | 104 | /** @defgroup USBD_CDC_IF_Exported_Variables USBD_CDC_IF_Exported_Variables 105 | * @brief Public variables. 106 | * @{ 107 | */ 108 | 109 | extern USBD_HandleTypeDef hUsbDeviceFS; 110 | 111 | /* USER CODE BEGIN EXPORTED_VARIABLES */ 112 | 113 | /* USER CODE END EXPORTED_VARIABLES */ 114 | 115 | /** 116 | * @} 117 | */ 118 | 119 | /** @defgroup USBD_CDC_IF_Private_FunctionPrototypes USBD_CDC_IF_Private_FunctionPrototypes 120 | * @brief Private functions declaration. 121 | * @{ 122 | */ 123 | 124 | static int8_t CDC_Init_FS(void); 125 | static int8_t CDC_DeInit_FS(void); 126 | static int8_t CDC_Control_FS(uint8_t cmd, uint8_t* pbuf, uint16_t length); 127 | static int8_t CDC_Receive_FS(uint8_t* pbuf, uint32_t *Len); 128 | static int8_t CDC_TransmitCplt_FS(uint8_t *pbuf, uint32_t *Len, uint8_t epnum); 129 | 130 | /* USER CODE BEGIN PRIVATE_FUNCTIONS_DECLARATION */ 131 | 132 | /* USER CODE END PRIVATE_FUNCTIONS_DECLARATION */ 133 | 134 | /** 135 | * @} 136 | */ 137 | 138 | USBD_CDC_ItfTypeDef USBD_Interface_fops_FS = 139 | { 140 | CDC_Init_FS, 141 | CDC_DeInit_FS, 142 | CDC_Control_FS, 143 | CDC_Receive_FS, 144 | CDC_TransmitCplt_FS 145 | }; 146 | 147 | /* Private functions ---------------------------------------------------------*/ 148 | /** 149 | * @brief Initializes the CDC media low layer over the FS USB IP 150 | * @retval USBD_OK if all operations are OK else USBD_FAIL 151 | */ 152 | static int8_t CDC_Init_FS(void) 153 | { 154 | /* USER CODE BEGIN 3 */ 155 | /* Set Application Buffers */ 156 | USBD_CDC_SetTxBuffer(&hUsbDeviceFS, UserTxBufferFS, 0); 157 | USBD_CDC_SetRxBuffer(&hUsbDeviceFS, UserRxBufferFS); 158 | return (USBD_OK); 159 | /* USER CODE END 3 */ 160 | } 161 | 162 | /** 163 | * @brief DeInitializes the CDC media low layer 164 | * @retval USBD_OK if all operations are OK else USBD_FAIL 165 | */ 166 | static int8_t CDC_DeInit_FS(void) 167 | { 168 | /* USER CODE BEGIN 4 */ 169 | return (USBD_OK); 170 | /* USER CODE END 4 */ 171 | } 172 | 173 | /** 174 | * @brief Manage the CDC class requests 175 | * @param cmd: Command code 176 | * @param pbuf: Buffer containing command data (request parameters) 177 | * @param length: Number of data to be sent (in bytes) 178 | * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL 179 | */ 180 | static int8_t CDC_Control_FS(uint8_t cmd, uint8_t* pbuf, uint16_t length) 181 | { 182 | /* USER CODE BEGIN 5 */ 183 | switch(cmd) 184 | { 185 | case CDC_SEND_ENCAPSULATED_COMMAND: 186 | 187 | break; 188 | 189 | case CDC_GET_ENCAPSULATED_RESPONSE: 190 | 191 | break; 192 | 193 | case CDC_SET_COMM_FEATURE: 194 | 195 | break; 196 | 197 | case CDC_GET_COMM_FEATURE: 198 | 199 | break; 200 | 201 | case CDC_CLEAR_COMM_FEATURE: 202 | 203 | break; 204 | 205 | /*******************************************************************************/ 206 | /* Line Coding Structure */ 207 | /*-----------------------------------------------------------------------------*/ 208 | /* Offset | Field | Size | Value | Description */ 209 | /* 0 | dwDTERate | 4 | Number |Data terminal rate, in bits per second*/ 210 | /* 4 | bCharFormat | 1 | Number | Stop bits */ 211 | /* 0 - 1 Stop bit */ 212 | /* 1 - 1.5 Stop bits */ 213 | /* 2 - 2 Stop bits */ 214 | /* 5 | bParityType | 1 | Number | Parity */ 215 | /* 0 - None */ 216 | /* 1 - Odd */ 217 | /* 2 - Even */ 218 | /* 3 - Mark */ 219 | /* 4 - Space */ 220 | /* 6 | bDataBits | 1 | Number Data bits (5, 6, 7, 8 or 16). */ 221 | /*******************************************************************************/ 222 | case CDC_SET_LINE_CODING: 223 | 224 | break; 225 | 226 | case CDC_GET_LINE_CODING: 227 | 228 | break; 229 | 230 | case CDC_SET_CONTROL_LINE_STATE: 231 | 232 | break; 233 | 234 | case CDC_SEND_BREAK: 235 | 236 | break; 237 | 238 | default: 239 | break; 240 | } 241 | 242 | return (USBD_OK); 243 | /* USER CODE END 5 */ 244 | } 245 | 246 | /** 247 | * @brief Data received over USB OUT endpoint are sent over CDC interface 248 | * through this function. 249 | * 250 | * @note 251 | * This function will issue a NAK packet on any OUT packet received on 252 | * USB endpoint until exiting this function. If you exit this function 253 | * before transfer is complete on CDC interface (ie. using DMA controller) 254 | * it will result in receiving more data while previous ones are still 255 | * not sent. 256 | * 257 | * @param Buf: Buffer of data to be received 258 | * @param Len: Number of data received (in bytes) 259 | * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL 260 | */ 261 | static int8_t CDC_Receive_FS(uint8_t* Buf, uint32_t *Len) 262 | { 263 | /* USER CODE BEGIN 6 */ 264 | USBD_CDC_SetRxBuffer(&hUsbDeviceFS, &Buf[0]); 265 | USBD_CDC_ReceivePacket(&hUsbDeviceFS); 266 | return (USBD_OK); 267 | /* USER CODE END 6 */ 268 | } 269 | 270 | /** 271 | * @brief CDC_Transmit_FS 272 | * Data to send over USB IN endpoint are sent over CDC interface 273 | * through this function. 274 | * @note 275 | * 276 | * 277 | * @param Buf: Buffer of data to be sent 278 | * @param Len: Number of data to be sent (in bytes) 279 | * @retval USBD_OK if all operations are OK else USBD_FAIL or USBD_BUSY 280 | */ 281 | uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len) 282 | { 283 | uint8_t result = USBD_OK; 284 | /* USER CODE BEGIN 7 */ 285 | USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef*)hUsbDeviceFS.pClassData; 286 | if (hcdc->TxState != 0){ 287 | return USBD_BUSY; 288 | } 289 | USBD_CDC_SetTxBuffer(&hUsbDeviceFS, Buf, Len); 290 | result = USBD_CDC_TransmitPacket(&hUsbDeviceFS); 291 | /* USER CODE END 7 */ 292 | return result; 293 | } 294 | 295 | /** 296 | * @brief CDC_TransmitCplt_FS 297 | * Data transmitted callback 298 | * 299 | * @note 300 | * This function is IN transfer complete callback used to inform user that 301 | * the submitted Data is successfully sent over USB. 302 | * 303 | * @param Buf: Buffer of data to be received 304 | * @param Len: Number of data received (in bytes) 305 | * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL 306 | */ 307 | static int8_t CDC_TransmitCplt_FS(uint8_t *Buf, uint32_t *Len, uint8_t epnum) 308 | { 309 | uint8_t result = USBD_OK; 310 | /* USER CODE BEGIN 13 */ 311 | UNUSED(Buf); 312 | UNUSED(Len); 313 | UNUSED(epnum); 314 | /* USER CODE END 13 */ 315 | return result; 316 | } 317 | 318 | /* USER CODE BEGIN PRIVATE_FUNCTIONS_IMPLEMENTATION */ 319 | 320 | /* USER CODE END PRIVATE_FUNCTIONS_IMPLEMENTATION */ 321 | 322 | /** 323 | * @} 324 | */ 325 | 326 | /** 327 | * @} 328 | */ 329 | 330 | -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/CDC_Test/USB_Device/App/usbd_cdc_if.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : usbd_cdc_if.h 5 | * @version : v3.0_Cube 6 | * @brief : Header for usbd_cdc_if.c file. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2024 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 2048 52 | #define APP_TX_DATA_SIZE 2048 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 | -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/CDC_Test/USB_Device/App/usbd_desc.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : usbd_desc.c 5 | * @version : v3.0_Cube 6 | * @brief : Header for usbd_conf.c file. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2024 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_DESC__C__ 23 | #define __USBD_DESC__C__ 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | #include "usbd_def.h" 31 | 32 | /* USER CODE BEGIN INCLUDE */ 33 | 34 | /* USER CODE END INCLUDE */ 35 | 36 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY 37 | * @{ 38 | */ 39 | 40 | /** @defgroup USBD_DESC USBD_DESC 41 | * @brief Usb device descriptors module. 42 | * @{ 43 | */ 44 | 45 | /** @defgroup USBD_DESC_Exported_Constants USBD_DESC_Exported_Constants 46 | * @brief Constants. 47 | * @{ 48 | */ 49 | #define DEVICE_ID1 (UID_BASE) 50 | #define DEVICE_ID2 (UID_BASE + 0x4) 51 | #define DEVICE_ID3 (UID_BASE + 0x8) 52 | 53 | #define USB_SIZ_STRING_SERIAL 0x1A 54 | 55 | /* USER CODE BEGIN EXPORTED_CONSTANTS */ 56 | 57 | /* USER CODE END EXPORTED_CONSTANTS */ 58 | 59 | /** 60 | * @} 61 | */ 62 | 63 | /** @defgroup USBD_DESC_Exported_Defines USBD_DESC_Exported_Defines 64 | * @brief Defines. 65 | * @{ 66 | */ 67 | 68 | /* USER CODE BEGIN EXPORTED_DEFINES */ 69 | 70 | /* USER CODE END EXPORTED_DEFINES */ 71 | 72 | /** 73 | * @} 74 | */ 75 | 76 | /** @defgroup USBD_DESC_Exported_TypesDefinitions USBD_DESC_Exported_TypesDefinitions 77 | * @brief Types. 78 | * @{ 79 | */ 80 | 81 | /* USER CODE BEGIN EXPORTED_TYPES */ 82 | 83 | /* USER CODE END EXPORTED_TYPES */ 84 | 85 | /** 86 | * @} 87 | */ 88 | 89 | /** @defgroup USBD_DESC_Exported_Macros USBD_DESC_Exported_Macros 90 | * @brief Aliases. 91 | * @{ 92 | */ 93 | 94 | /* USER CODE BEGIN EXPORTED_MACRO */ 95 | 96 | /* USER CODE END EXPORTED_MACRO */ 97 | 98 | /** 99 | * @} 100 | */ 101 | 102 | /** @defgroup USBD_DESC_Exported_Variables USBD_DESC_Exported_Variables 103 | * @brief Public variables. 104 | * @{ 105 | */ 106 | 107 | extern USBD_DescriptorsTypeDef CDC_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 | -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/CDC_Test/USB_Device/Target/usbd_conf.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : usbd_conf.h 5 | * @version : v3.0_Cube 6 | * @brief : Header for usbd_conf.c file. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2024 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 "stm32g0xx.h" 34 | #include "stm32g0xx_hal.h" 35 | 36 | /* USER CODE BEGIN INCLUDE */ 37 | 38 | /* USER CODE END INCLUDE */ 39 | 40 | /** @addtogroup USBD_OTG_DRIVER 41 | * @brief Driver for Usb device. 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 | /* Private variables ---------------------------------------------------------*/ 56 | /* USER CODE BEGIN PV */ 57 | /* USER CODE END PV */ 58 | /** 59 | * @} 60 | */ 61 | 62 | /** @defgroup USBD_CONF_Exported_Defines USBD_CONF_Exported_Defines 63 | * @brief Defines for configuration of the Usb device. 64 | * @{ 65 | */ 66 | 67 | /*---------- -----------*/ 68 | #define USBD_MAX_NUM_INTERFACES 1U 69 | /*---------- -----------*/ 70 | #define USBD_MAX_NUM_CONFIGURATION 1U 71 | /*---------- -----------*/ 72 | #define USBD_MAX_STR_DESC_SIZ 512U 73 | /*---------- -----------*/ 74 | #define USBD_DEBUG_LEVEL 0U 75 | /*---------- -----------*/ 76 | #define USBD_LPM_ENABLED 1U 77 | /*---------- -----------*/ 78 | #define USBD_SELF_POWERED 1U 79 | 80 | /****************************************/ 81 | /* #define for FS and HS identification */ 82 | #define DEVICE_FS 0 83 | 84 | /** 85 | * @} 86 | */ 87 | 88 | /** @defgroup USBD_CONF_Exported_Macros USBD_CONF_Exported_Macros 89 | * @brief Aliases. 90 | * @{ 91 | */ 92 | 93 | /* Memory management macros make sure to use static memory allocation */ 94 | /** Alias for memory allocation. */ 95 | #define USBD_malloc (void *)USBD_static_malloc 96 | 97 | /** Alias for memory release. */ 98 | #define USBD_free USBD_static_free 99 | 100 | /** Alias for memory set. */ 101 | #define USBD_memset memset 102 | 103 | /** Alias for memory copy. */ 104 | #define USBD_memcpy memcpy 105 | 106 | /** Alias for delay. */ 107 | #define USBD_Delay HAL_Delay 108 | 109 | /* DEBUG macros */ 110 | 111 | #if (USBD_DEBUG_LEVEL > 0) 112 | #define USBD_UsrLog(...) printf(__VA_ARGS__);\ 113 | printf("\n"); 114 | #else 115 | #define USBD_UsrLog(...) 116 | #endif 117 | 118 | #if (USBD_DEBUG_LEVEL > 1) 119 | 120 | #define USBD_ErrLog(...) printf("ERROR: ") ;\ 121 | printf(__VA_ARGS__);\ 122 | printf("\n"); 123 | #else 124 | #define USBD_ErrLog(...) 125 | #endif 126 | 127 | #if (USBD_DEBUG_LEVEL > 2) 128 | #define USBD_DbgLog(...) printf("DEBUG : ") ;\ 129 | printf(__VA_ARGS__);\ 130 | printf("\n"); 131 | #else 132 | #define USBD_DbgLog(...) 133 | #endif 134 | 135 | /** 136 | * @} 137 | */ 138 | 139 | /** @defgroup USBD_CONF_Exported_Types USBD_CONF_Exported_Types 140 | * @brief Types. 141 | * @{ 142 | */ 143 | 144 | /** 145 | * @} 146 | */ 147 | 148 | /** @defgroup USBD_CONF_Exported_FunctionsPrototype USBD_CONF_Exported_FunctionsPrototype 149 | * @brief Declaration of public functions for Usb device. 150 | * @{ 151 | */ 152 | 153 | /* Exported functions -------------------------------------------------------*/ 154 | void *USBD_static_malloc(uint32_t size); 155 | void USBD_static_free(void *p); 156 | 157 | /** 158 | * @} 159 | */ 160 | 161 | /** 162 | * @} 163 | */ 164 | 165 | /** 166 | * @} 167 | */ 168 | 169 | #ifdef __cplusplus 170 | } 171 | #endif 172 | 173 | #endif /* __USBD_CONF__H__ */ 174 | 175 | -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/README.md: -------------------------------------------------------------------------------- 1 | * [中文版本](/Example/Build_You_Own_firmware/README_zh.md) 2 | # Build your own firmware 3 | ## Project Setup 4 | ### CubeIDE 5 | 1. Modify Ld file, add `NOINIT_RAM` without initializing partition, address: 0x20000000, size 0x08. 6 | 2. Modify Ld file, FLASH address to 0x8006800, size 49K. 7 | Add bootloader.c, bootloader.h, perf_counter.c, perf_counter.h files. 8 | 4. Add `bootloader_init()` at the beginning of the main function. 9 | 5. Need to enter the firmware upgrade mode, call `bootloader_enter_update_mode`. 10 | 11 | ### Keil 12 | 1. Change the Settings as shown below 13 | ![display](/Images/keil.png) 14 | Add bootloader.c, bootloader.h, perf_counter.c, perf_counter.h files. 15 | 3. Add `bootloader_init()` at the beginning of the main function. 16 | 4. To enter firmware upgrade mode, simply call `bootloader_enter_update_mode()`. 17 | 18 | ## Firmware packaging 19 | * Open Tools/firmware_packager, select the firmware, check Do not encrypt, add character watermark, select the header size, and click Pack. 20 | ![display](/Images/firmware_packager_en.png) -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/README_zh.md: -------------------------------------------------------------------------------- 1 | * [English version](/Example/Build_You_Own_firmware/README.md) 2 | # 构建自己的固件 3 | ## 工程设置 4 | ### CubeIDE 5 | 1. 修改Ld文件,增加`NOINIT_RAM`不初始化分区,地址:0x20000000,大小0x08。 6 | 2. 修改Ld文件,FLASH地址改为0x8006800,大小49K。 7 | 3. 增加bootloader.c、bootloader.h、perf_counter.c、perf_counter.h文件。 8 | 4. main函数开头增加`bootloader_init()`。 9 | 5. 需要进入固件升级模式时,调用`bootloader_enter_update_mode()`即可。 10 | 11 | ### Keil 12 | 1. 修改设置,见下图 13 | ![display](/Images/keil.png) 14 | 2. 增加bootloader.c、bootloader.h、perf_counter.c、perf_counter.h文件。 15 | 3. main函数开头增加`bootloader_init()`。 16 | 4. 需要进入固件升级模式时,调用`bootloader_enter_update_mode()`即可。 17 | 18 | ## 固件打包 19 | * 打开Tools/firmware_packager工具,选择相应固件,勾选不加密,添加字符水印,选择表头尺寸后,点击打包即可 20 | ![display](/Images/firmware_packager_zh.png) -------------------------------------------------------------------------------- /Example/Build_You_Own_firmware/buildclean.bat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeActStudio/WeActStudio.USB2CANFDV1/8e508c5c6f99532a896d878caaef665682ecca27/Example/Build_You_Own_firmware/buildclean.bat -------------------------------------------------------------------------------- /Example/Python/CDC_SpeedTest_Rx.py: -------------------------------------------------------------------------------- 1 | import serial 2 | import time 3 | import threading 4 | 5 | def check_key(): 6 | while True: 7 | if input() == 'q': 8 | print("quit now") 9 | break 10 | 11 | check_key_thread = threading.Thread(target=check_key) 12 | check_key_thread.start() 13 | 14 | aux_device_ser = serial.Serial('COM523', 1152000, 8, 'N', 1,timeout=1) 15 | 16 | aux_device_ser.write("S8\r".encode('utf-8')) 17 | aux_device_ser.write("Y5\r".encode('utf-8')) 18 | aux_device_ser.write("O\r".encode('utf-8')) 19 | print('port_open ',aux_device_ser.port,aux_device_ser.read_until()) 20 | 21 | tick_1s = int(round(time.time() * 1000)) + 1000 22 | data_len = 0 23 | data_len_sum = 0 24 | while True: 25 | data = aux_device_ser.read_all() 26 | data_len = data_len + len(data) 27 | data_len_sum = len(data) + data_len_sum 28 | # print(aux_device_ser.port,data,len(data)) 29 | 30 | ms = int(round(time.time() * 1000)) 31 | if ms > tick_1s: 32 | tick_1s = ms + 1000 33 | print('rx speed:',data_len,'Byte/S',data_len/1024,'kByte/S') 34 | print('data_len_sum:',data_len,'Count',data_len_sum/22) 35 | data_len = 0 36 | 37 | if check_key_thread.is_alive() == False: 38 | break 39 | 40 | aux_device_ser.write("C\r".encode('utf-8')) 41 | aux_device_ser.read_until(expected='\r'.encode('utf-8')) 42 | aux_device_ser.close() 43 | -------------------------------------------------------------------------------- /Example/Python/CDC_SpeedTest_Tx.py: -------------------------------------------------------------------------------- 1 | import serial 2 | import time 3 | import threading 4 | 5 | def check_key(): 6 | while True: 7 | if input() == 'q': 8 | print("quit now") 9 | break 10 | 11 | check_key_thread = threading.Thread(target=check_key) 12 | check_key_thread.start() 13 | 14 | aux_device_ser = serial.Serial('COM33', 1152000, 8, 'N', 1,timeout=1) 15 | 16 | aux_device_ser.write("S8\r".encode('utf-8')) 17 | aux_device_ser.write("Y5\r".encode('utf-8')) 18 | aux_device_ser.write("O\r".encode('utf-8')) 19 | print('port_open ',aux_device_ser.port,aux_device_ser.read_until()) 20 | 21 | tick_1s = int(round(time.time() * 1000)) + 1000 22 | test_len = 0 23 | data_len = 0 24 | test_write = "b0008aabbaabbaabbaabb\r".encode('utf-8') 25 | tx_Success = 0 26 | while True: 27 | aux_device_ser.write(test_write) 28 | # time.sleep(0.001) 29 | # data = aux_device_ser.read_all() 30 | data = aux_device_ser.read_until(expected='\r'.encode('utf-8')) 31 | if data == '\r'.encode('utf-8'): 32 | tx_Success = tx_Success + 1 33 | data_len = data_len + len(data) 34 | test_len = test_len + len(test_write) 35 | # print(aux_device_ser.port,data,len(data)) 36 | 37 | ms = int(round(time.time() * 1000)) 38 | if ms > tick_1s: 39 | tick_1s = ms + 1000 40 | print('tx speed:',test_len,'Byte/S',test_len/1024,'kByte/S') 41 | print('tx_Success:',tx_Success) 42 | print('rx speed:',data_len,'Byte/S',data_len/1024,'kByte/S') 43 | print('') 44 | test_len = 0 45 | data_len = 0 46 | 47 | if check_key_thread.is_alive() == False: 48 | break 49 | 50 | aux_device_ser.write("C\r".encode('utf-8')) 51 | aux_device_ser.read_until(expected='\r'.encode('utf-8')) 52 | aux_device_ser.close() -------------------------------------------------------------------------------- /Firmware/README.md: -------------------------------------------------------------------------------- 1 | * [中文版本](./README_zh.md) 2 | # Firmware description 3 | ## Bootloader 4 | If you want to restore the factory firmware, You can download the bootloader: `bootloader_stm32g0_2_fix_uid_user.Hex`, and modify the `Option bytes` parameter, the specific steps are as follows: 5 | 1. Download the Bootloader. 6 | 2. Modify the Option bytes parameter. 7 | 3. Power off the device, and then power on. 8 | 4. Open `WeActStudio_Upgrade_Tool`, select the fpk format upgrade package, and write. 9 | 5. If TX/RX blinks for 1 second, the factory firmware is restored successfully. 10 | ``` 11 | The Option bytes parameters 12 | RDP = BB 13 | BOR_EN = Checked 14 | BORF_LEV = 3 15 | BORR_LEV = 3 16 | PCROP1A_STRT = 0x04 17 | PCROP1A_END = 0x33 18 | PCROP_RDP = Checked 19 | WRP1A_STRT = 0x0 20 | WRP1A_END = 0x1 21 | ``` 22 | 23 | ## SLCAN version description 24 | ### V1.0.0.1 25 | * Initial version 26 | ### V1.0.0.2 27 | 1. Optimize the USB serial number naming rule to avoid repetition. (In later versions, if an upgrade failure message is displayed, the device needs to short-circuit DIO and GND pins and power on to forcibly enter the firmware upgrade mode) 28 | 2. Fix the abnormal TX/RX indicator display Bug, and optimize the logic: If the sending and receiving period is less than 50mS, it is always on. 29 | ### V1.0.0.3 30 | 1. Add more common baud rate commands. 31 | 2. The custom baud rate command supports the clock frequency division function. 32 | 3. The `S7\r` command changes the baud rate from 750kbps to 800Kbps. -------------------------------------------------------------------------------- /Firmware/README_zh.md: -------------------------------------------------------------------------------- 1 | * [English version](./README.md) 2 | # 固件说明 3 | ## Bootloader 4 | 如果你想恢复出厂固件可以刷入这个Bootloader:`bootloader_stm32g0_2_fix_uid_user.Hex`,并修改`Option bytes`参数,具体步骤如下: 5 | 1. 刷入Bootloader 6 | 2. 修改Option bytes参数 7 | 3. 设备掉电,重新上电 8 | 4. 使用`WeActStudio_Upgrade_Tool`写入fpk格式升级包 9 | 5. 设备TX RX闪烁1秒,出厂固件恢复成功 10 | ``` 11 | Option bytes 参数如下 12 | RDP = BB 13 | BOR_EN = Checked 14 | BORF_LEV = 3 15 | BORR_LEV = 3 16 | PCROP1A_STRT = 0x04 17 | PCROP1A_END = 0x33 18 | PCROP_RDP = Checked 19 | WRP1A_STRT = 0x0 20 | WRP1A_END = 0x1 21 | ``` 22 | 23 | ## SLCAN 版本说明 24 | ### V1.0.0.1 25 | * 初始版本 26 | ### V1.0.0.2 27 | 1. 优化USB序列号命名规则,避免重复(后续版本,如提示升级失败,设备需要短接DIO和GND管脚上电强制进入固件升级模式)。 28 | 2. 修复TX/RX指示灯显示异常Bug,并优化逻辑:收发周期持续低于50mS为常亮。 29 | ### V1.0.0.3 30 | 1. 增加更多常用波特率命令。 31 | 2. 自定义波特率命令支持时钟分频功能。 32 | 2. S7\r 命令波特率由750kbps改为800Kbps。 -------------------------------------------------------------------------------- /Firmware/SLCAN/WeAct-USB2CANV1_V1.0.0.1_download.fpk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeActStudio/WeActStudio.USB2CANFDV1/8e508c5c6f99532a896d878caaef665682ecca27/Firmware/SLCAN/WeAct-USB2CANV1_V1.0.0.1_download.fpk -------------------------------------------------------------------------------- /Firmware/SLCAN/WeAct-USB2CANV1_V1.0.0.2_download.fpk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeActStudio/WeActStudio.USB2CANFDV1/8e508c5c6f99532a896d878caaef665682ecca27/Firmware/SLCAN/WeAct-USB2CANV1_V1.0.0.2_download.fpk -------------------------------------------------------------------------------- /Firmware/SLCAN/WeAct-USB2CANV1_V1.0.0.3_download.fpk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeActStudio/WeActStudio.USB2CANFDV1/8e508c5c6f99532a896d878caaef665682ecca27/Firmware/SLCAN/WeAct-USB2CANV1_V1.0.0.3_download.fpk -------------------------------------------------------------------------------- /Hardware/WeAct-USB2CANFDV1_V10 Board Shape 外形.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeActStudio/WeActStudio.USB2CANFDV1/8e508c5c6f99532a896d878caaef665682ecca27/Hardware/WeAct-USB2CANFDV1_V10 Board Shape 外形.pdf -------------------------------------------------------------------------------- /Images/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeActStudio/WeActStudio.USB2CANFDV1/8e508c5c6f99532a896d878caaef665682ecca27/Images/1.png -------------------------------------------------------------------------------- /Images/SWD.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeActStudio/WeActStudio.USB2CANFDV1/8e508c5c6f99532a896d878caaef665682ecca27/Images/SWD.jpg -------------------------------------------------------------------------------- /Images/WeActStudio_Upgrade_Tool_en.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeActStudio/WeActStudio.USB2CANFDV1/8e508c5c6f99532a896d878caaef665682ecca27/Images/WeActStudio_Upgrade_Tool_en.png -------------------------------------------------------------------------------- /Images/WeActStudio_Upgrade_Tool_zh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeActStudio/WeActStudio.USB2CANFDV1/8e508c5c6f99532a896d878caaef665682ecca27/Images/WeActStudio_Upgrade_Tool_zh.png -------------------------------------------------------------------------------- /Images/firmware_packager_en.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeActStudio/WeActStudio.USB2CANFDV1/8e508c5c6f99532a896d878caaef665682ecca27/Images/firmware_packager_en.png -------------------------------------------------------------------------------- /Images/firmware_packager_zh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeActStudio/WeActStudio.USB2CANFDV1/8e508c5c6f99532a896d878caaef665682ecca27/Images/firmware_packager_zh.png -------------------------------------------------------------------------------- /Images/flash_erase.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeActStudio/WeActStudio.USB2CANFDV1/8e508c5c6f99532a896d878caaef665682ecca27/Images/flash_erase.png -------------------------------------------------------------------------------- /Images/keil.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeActStudio/WeActStudio.USB2CANFDV1/8e508c5c6f99532a896d878caaef665682ecca27/Images/keil.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | * [中文版本](./README_zh.md) 2 | # WeActStudio.USB2CANFDV1 3 | ![display](Images/1.png) 4 | STM32G0B1CBT6 5 | > 64Mhz Max,128KB RAM,128KB ROM 6 | 7 | CANFD/CAN2.0 8 | > 1500V isolation, 5Mbps Max, support cangaroo or secondary development. Transceiver part number: SIT1051A&sitcores 9 | 10 | Connector 11 | > 3.81mm 1x3P WJ15EDGK-3.81-3P 12 | 13 | ## SLCAN Protocol Description 14 | > Please upgrade to the latest firmware version to support more baud rates 15 | 16 | > Using the virtual serial, the command is as follows: 17 | - `O[CR]` - Opens the CAN channel 18 | - `C[CR]` - Close the CAN channel 19 | - `S0[CR]` - Set the nominal bit rate to 10k 20 | - `S1[CR]` - Set the nominal bit rate to 20k 21 | - `S2[CR]` - Set the nominal bit rate to 50k 22 | - `S3[CR]` - Set the nominal bit rate to 100k 23 | - `S4[CR]` - Set the nominal bit rate to 125k (default) 24 | - `S5[CR]` - Set the nominal bit rate to 250k 25 | - `S6[CR]` - Set the nominal bit rate to 500k 26 | - `S7[CR]` - Set the nominal bit rate to 800k 27 | - `S8[CR]` - Set the nominal bit rate to 1M 28 | - `S9[CR]` - Set the nominal bit rate to 83.3k 29 | - `SA[CR]` - Set the nominal bit rate to 75k 30 | - `SB[CR]` - Set the nominal bit rate to 62.5k 31 | - `SC[CR]` - Set the nominal bit rate to 33.3k 32 | - `SD[CR]` - Set the nominal bit rate to 5k 33 | - `Sxxyy[CR]` - Custom nominal bit rate (60/2=30Mhz CAN clock) [xx=seg1(hex,0x02\~0xff), yy=seg2(hex,0x02\~0x80)] 34 | - `Sddxxyy[CR]` - Custom nominal bit rate ([60/div]Mhz CAN clock) [dd=div(hex,0x01\~0xff), xx=seg1(hex,0x02\~0xff), yy=seg2(hex,0x02\~0x80)] 35 | - `Y1[CR]` - Set the CANFD data segment bit rate to 1M 36 | - `Y2[CR]` - Set CANFD data segment bit rate to 2M (default) 37 | - `Y3[CR]` - Set the CANFD data segment bit rate to 3M 38 | - `Y4[CR]` - Set the CANFD data segment bit rate to 4M 39 | - `Y5[CR]` - Set the CANFD data segment bit rate to 5M 40 | - `Yxxyy[CR]` - Custom CANFD data segment bit rate (60Mhz CAN clock) [xx=seg1(hex,0x01\~0x20), yy=seg2(hex,0x01\~0x10)] 41 | - `Yddxxyy[CR]` - Custom CANFD data segment bit rate ([60/div]Mhz CAN clock) [dd=div(hex,0x01\~0x20), xx=seg1(hex,0x01\~0x20), yy=seg2(hex,0x01\~0x10)] 42 | - `M0[CR]` - Set to normal mode (default) 43 | - `M1[CR]` - Set to silent mode 44 | - `A0[CR]` - Turn off automatic retransmission (default) 45 | - `A1[CR]` - Enable automatic retransmission (not recommended, may crash) 46 | - `tIIILDD...[CR] `- Transfer data frame (standard ID) [ID, length, data] 47 | - `TIIIIIIIILDD...[CR] `- Transfer data frame (extended ID) [ID, length, data] 48 | - `rIIIL[CR]` - Transfer remote frame (standard ID) [ID, length] 49 | - `RIIIIIIIIL[CR]` - Transfer remote frame (extended ID) [ID, length] 50 | - `dIIILDD...[CR] `- Transmit CANFD standard frames (without BRS enabled) [ID, length, data] 51 | - `DIIIIIIIILDD...[CR] `- Transmit CANFD extended frames (without BRS enabled) [ID, length, data] 52 | - `bIIILDD...[CR] `- Transmit CANFD standard frames (BRS enabled) [ID, length, data] 53 | - `BIIIIIIIILDD...[CR] `- Transmit CANFD extended frames (BRS enable) [ID, length, data] 54 | - `V[CR]` - Reads the firmware version 55 | - `E[CR]` - Read the failure state 56 | - `X[CR]` - Enter firmware upgrade mode 57 | 58 | `[CR]` : `0x0D` (hex), `\r` (ascii) 59 | 60 | **A status statement is returned after the command is sent** 61 | - [CR]: transmission successful 62 | - 0x07: transmission failed 63 | 64 | **Note** 65 | The CANFD message length is as follows (in hex): 66 | - `0-8` : Same as standard CAN 67 | - `9` : length = 12 68 | - `A` : length = 16 69 | - `B` : length = 20 70 | - `C` : length = 24 71 | - `D` : length = 32 72 | - `E` : length = 48 73 | - `F` : length = 64 74 | 75 | **cangaroo is located in `Tools/cangaroo`** 76 | **The documentation for calculating custom Bitrate Settings is located in `Doc/CAN Bitrate Calculate_波特率计算.xlsx`** 77 | 78 | ## Pin Description 79 | | pin | definition | specification | 80 | |:--:|:--:| :--:| 81 | |PA0|LED_RXD| Receive indicator, flashing when there is data | 82 | |PA1|LED_TXD| Send indicator light, flashing when there is data | 83 | |PA2|LED_READY| Status indicator, flashing 0.5S when the CAN port is opened and 1S when is in upgrade mode | 84 | |PB9|FDCAN1_TX|FDCAN1 tx | 85 | |PB8|FDCAN1_RX|FDCAN1 rx | 86 | |PA12|USB_DP|USB 2.0 12Mbps| 87 | |PA11|USB_DM|USB 2.0 12Mbps| 88 | |PF0|OSC_IN|16Mhz XTAL| 89 | |PF1|OSC_OUT|16Mhz XTAL| 90 | 91 | ## Partitioning Notes 92 | | Start address | Partition name | Size | Description | 93 | | :-: | :-: | :-: | :-: | 94 | |0x08000000|bootloader|26 kbyte| bootloader, character watermark: USB2CANV1| 95 | |0x08006800|app|50 kbyte| application | 96 | |0x08013000|download|50 kbyte| download partition | 97 | 98 | ## How to compile your own firmware 99 | See Example\Build_You_Own_firmware 100 | 101 | ## How to force firmware upgrade mode 102 | When the firmware is brushed dead, short DIO and GND to power on, the blue light is on and then released, and the red light flashes slowly, indicating that is currently in upgrade mode. 103 | ![display](Images/SWD.jpg) 104 | 105 | ## How to upgrade firmware 106 | Open Tools/WeActStudio_Upgrade_Tool and follow the prompts. 107 | ![display](Images/WeActStudio_Upgrade_Tool_en.png) 108 | 109 | ## How to completely empty Flash 110 | Open the STM32CubeProgrammer, connect the SWD interface of the module using STLink, and perform the following operations: 111 | ![display](Images/flash_erase.png) 112 | > If you need to restore factory Firmware, see the `Firmware/README` instructions 113 | 114 | ## Catalog Description 115 | | Directory name | content | 116 | |:--:| :--:| 117 | |Doc|Datasheet| 118 | |Hardware| Hardware development data | 119 | |Examples| Software routines | 120 | |Tools| Tools| 121 | 122 | ``` 123 | /*--------------------------------------- 124 | - WeAct Studio Official Link 125 | - taobao: weactstudio.taobao.com 126 | - aliexpress: weactstudio.aliexpress.com 127 | - github: github.com/WeActStudio 128 | - gitee: gitee.com/WeAct-TC 129 | - blog: www.weact-tc.cn 130 | ---------------------------------------*/ 131 | ``` -------------------------------------------------------------------------------- /README_zh.md: -------------------------------------------------------------------------------- 1 | * [English version](./README.md) 2 | # WeActStudio.USB2CANFDV1 3 | ![display](Images/1.png) 4 | STM32G0B1CBT6 5 | > 64Mhz Max,128KB RAM,128KB ROM 6 | 7 | CANFD/CAN2.0 8 | > 1500V隔离, 速率最大5Mbps,支持cangaroo或二次开发,收发器型号:SIT1051A&芯力特 9 | 10 | 连接器 11 | > 3.81mm 1x3P WJ15EDGK-3.81-3P 12 | 13 | ## SLCAN协议说明 14 | > 请升级到最新的固件版本以支持更多的波特率 15 | 16 | > 采用虚拟串口,命令如下: 17 | - `O[CR]` - 打开CAN通道 18 | - `C[CR]` - 关闭CAN通道 19 | - `S0[CR]` - 设置标称位比特率为 10k 20 | - `S1[CR]` - 设置标称位比特率为 20k 21 | - `S2[CR]` - 设置标称位比特率为 50k 22 | - `S3[CR]` - 设置标称位比特率为 100k 23 | - `S4[CR]` - 设置标称位比特率为 125k (默认) 24 | - `S5[CR]` - 设置标称位比特率为 250k 25 | - `S6[CR]` - 设置标称位比特率为 500k 26 | - `S7[CR]` - 设置标称位比特率为 800k 27 | - `S8[CR]` - 设置标称位比特率为 1M 28 | - `S9[CR]` - 设置标称位比特率为 83.3k 29 | - `SA[CR]` - 设置标称位比特率为 75k 30 | - `SB[CR]` - 设置标称位比特率为 62.5k 31 | - `SC[CR]` - 设置标称位比特率为 33.3k 32 | - `SD[CR]` - 设置标称位比特率为 5k 33 | - `Sxxyy[CR]` - 自定义标称位比特率 (60/2=30Mhz CAN时钟) [xx=seg1(hex,0x02\~0xff), yy=seg2(hex,0x02\~0x80)] 34 | - `Sddxxyy[CR]` - 自定义标称位比特率 ([60/div]Mhz CAN时钟) [dd=div(hex,0x01\~0xff), xx=seg1(hex,0x02\~0xff), yy=seg2(hex,0x02\~0x80)] 35 | - `Y1[CR]` - 设置CANFD数据段比特率为 1M 36 | - `Y2[CR]` - 设置CANFD数据段比特率为 2M (默认) 37 | - `Y3[CR]` - 设置CANFD数据段比特率为 3M 38 | - `Y4[CR]` - 设置CANFD数据段比特率为 4M 39 | - `Y5[CR]` - 设置CANFD数据段比特率为 5M 40 | - `Yxxyy[CR]` - 自定义CANFD数据段比特率 (60Mhz CAN时钟) [xx=seg1(hex,0x01\~0x20), yy=seg2(hex,0x01\~0x10)] 41 | - `Yddxxyy[CR]` - 自定义CANFD数据段比特率 ([60/div]Mhz CAN时钟) [dd=div(hex,0x01\~0x20), xx=seg1(hex,0x01\~0x20), yy=seg2(hex,0x01\~0x10)] 42 | - `M0[CR]` - 设置为正常模式 (默认) 43 | - `M1[CR]` - 设置为监听模式 44 | - `A0[CR]` - 关闭自动重发 (默认) 45 | - `A1[CR]` - 使能自动重发 (不推荐,概率死机) 46 | - `tIIILDD...[CR]` - 传输数据帧 (标准ID) [ID, length, data] 47 | - `TIIIIIIIILDD...[CR]` - 传输数据帧 (扩展ID) [ID, length, data] 48 | - `rIIIL[CR]` - 传输远程帧 (标准ID) [ID, length] 49 | - `RIIIIIIIIL[CR]` - 传输远程帧 (扩展ID) [ID, length] 50 | - `dIIILDD...[CR]` - 传输 CANFD 标准帧 (不使能 BRS) [ID, length, data] 51 | - `DIIIIIIIILDD...[CR]` - 传输 CANFD 扩展帧 (不使能 BRS) [ID, length, data] 52 | - `bIIILDD...[CR]` - 传输 CANFD 标准帧 (使能 BRS) [ID, length, data] 53 | - `BIIIIIIIILDD...[CR]` - 传输 CANFD 扩展帧 (使能 BRS) [ID, length, data] 54 | - `V[CR]` - 读取固件版本 55 | - `E[CR]` - 读取故障状态 56 | - `X[CR]` - 进入固件升级模式 57 | 58 | `[CR]` : `0x0D` (hex), `\r` (ascii) 59 | 60 | **命令发送后返回状态说明** 61 | - [CR]:发送成功 62 | - 0x07: 发送失败 63 | 64 | **注意** 65 | CANFD消息长度如下所示 (用十六进制表示): 66 | - `0-8`: 与标准CAN相同 67 | - `9`: 长度 = 12 68 | - `A`: 长度 = 16 69 | - `B`: 长度 = 20 70 | - `C`: 长度 = 24 71 | - `D`: 长度 = 32 72 | - `E`: 长度 = 48 73 | - `F`: 长度 = 64 74 | 75 | **上位机见Tools/cangaroo** 76 | **自定义比特率设置值计算说明文档位于`Doc/CAN Bitrate Calculate_波特率计算.xlsx`** 77 | 78 | ## 管脚说明 79 | |管脚|定义|说明| 80 | | :--:|:--:|:--:| 81 | |PA0|LED_RXD|接收指示灯,有数据时闪烁| 82 | |PA1|LED_TXD|发送指示灯,有数据时闪烁| 83 | |PA2|LED_READY|状态指示灯,CAN端口打开时0.5S闪烁,固件升级时1S闪烁| 84 | |PB9|FDCAN1_TX|FDCAN1发送| 85 | |PB8|FDCAN1_RX|FDCAN1接收| 86 | |PA12|USB_DP|USB 2.0 12Mbps| 87 | |PA11|USB_DM|USB 2.0 12Mbps| 88 | |PF0|OSC_IN|16Mhz XTAL| 89 | |PF1|OSC_OUT|16Mhz XTAL| 90 | 91 | ## 分区说明 92 | |起始地址|分区名|大小|说明| 93 | |:--:|:--:|:--:|:--:| 94 | |0x08000000|bootloader|26 kbyte|引导装载程序,字符水印:USB2CANV1| 95 | |0x08006800|app|50 kbyte|应用程序| 96 | |0x08013000|download|50 kbyte|下载分区| 97 | 98 | ## 如何编译自己的固件 99 | 见Example\Build_You_Own_firmware 100 | 101 | ## 如何强制进入固件升级模式 102 | 当固件刷死时,短接DIO和GND上电,蓝灯亮起后松开,此时红灯慢闪,指示当前处于固件升级模式。 103 | ![display](Images/SWD.jpg) 104 | 105 | ## 如何进行固件升级 106 | 打开Tools/WeActStudio_Upgrade_Tool,根据界面提示操作。 107 | ![display](Images/WeActStudio_Upgrade_Tool_zh.png) 108 | 109 | ## 如何彻底清空Flash 110 | 打开STM32CubeProgrammer,使用STLink连接模块SWD接口,执行以下操作: 111 | ![display](Images/flash_erase.png) 112 | > 如需要恢复出厂固件,见`Firmware/README`说明 113 | 114 | ## 目录说明 115 | |目录名称|内容| 116 | | :--:|:--:| 117 | |Doc|数据手册| 118 | |Hardware| 硬件开发资料| 119 | |Examples|软件例程| 120 | |Tools|工具| 121 | 122 | ``` 123 | /*--------------------------------------- 124 | - WeAct Studio Official Link 125 | - taobao: weactstudio.taobao.com 126 | - aliexpress: weactstudio.aliexpress.com 127 | - github: github.com/WeActStudio 128 | - gitee: gitee.com/WeAct-TC 129 | - blog: www.weact-tc.cn 130 | ---------------------------------------*/ 131 | ``` -------------------------------------------------------------------------------- /Tools/README.md: -------------------------------------------------------------------------------- 1 | * [中文版本](./README_zh.md) 2 | # Tool Version Description 3 | ## cangaroo 4 | ### V0.2.4 5 | * Initial version 6 | ### V0.2.4.1 7 | 1. Fix software startup measurement crash after device removal. 8 | 2. Fixed 800kbps baud rate setting error problem. 9 | 3. Optimize the custom baud rate function to support more baud rates (firmware version must be ≥`V1.0.0.3`). 10 | 4. Add the firmware version printing function, see the Log window. 11 | 5. Add more common baud rate options. 12 | 13 | ## WeActStudio_Upgrade_Tool 14 | For firmware upgrade 15 | 16 | ## firmware_packager 17 | Firmware packaging tool, so that firmware support using the `WeActStudio_Upgrade_Tool` tool burning -------------------------------------------------------------------------------- /Tools/README_zh.md: -------------------------------------------------------------------------------- 1 | * [English version](./README.md) 2 | # 工具版本说明 3 | ## cangaroo 4 | ### V0.2.4 5 | * 初始版本 6 | ### V0.2.4.1 7 | 1. 修复移除设备后,软件启动测量崩溃的问题。 8 | 2. 修复800kbps波特率设置错误问题。 9 | 3. 优化自定义波特率功能,支持更多波特率(固件版本需要≥V1.0.0.3)。 10 | 4. 新增固件版本打印功能,见日志窗口。 11 | 5. 增加更多常用波特率选项。 12 | 13 | ## WeActStudio_Upgrade_Tool 14 | 用于固件升级 15 | 16 | ## firmware_packager 17 | 固件打包工具,以支持使用`WeActStudio_Upgrade_Tool`工具烧录 -------------------------------------------------------------------------------- /Tools/WeActStudio_Upgrade_Tool.7z: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeActStudio/WeActStudio.USB2CANFDV1/8e508c5c6f99532a896d878caaef665682ecca27/Tools/WeActStudio_Upgrade_Tool.7z -------------------------------------------------------------------------------- /Tools/cangaroo_v0.2.4.1.7z: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeActStudio/WeActStudio.USB2CANFDV1/8e508c5c6f99532a896d878caaef665682ecca27/Tools/cangaroo_v0.2.4.1.7z -------------------------------------------------------------------------------- /Tools/cangaroo_v0.2.4.7z: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeActStudio/WeActStudio.USB2CANFDV1/8e508c5c6f99532a896d878caaef665682ecca27/Tools/cangaroo_v0.2.4.7z -------------------------------------------------------------------------------- /Tools/firmware_packager.7z: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeActStudio/WeActStudio.USB2CANFDV1/8e508c5c6f99532a896d878caaef665682ecca27/Tools/firmware_packager.7z --------------------------------------------------------------------------------