├── .cproject ├── .gitignore ├── .mxproject ├── .project ├── .settings ├── com.atollic.truestudio.debug.hardware_device.prefs ├── language.settings.xml ├── org.eclipse.cdt.codan.core.prefs └── org.eclipse.cdt.managedbuilder.core.prefs ├── Drivers ├── CMSIS │ ├── Device │ │ └── ST │ │ │ └── STM32F0xx │ │ │ └── Include │ │ │ ├── stm32f042x6.h │ │ │ ├── stm32f0xx.h │ │ │ └── system_stm32f0xx.h │ └── Include │ │ ├── arm_common_tables.h │ │ ├── arm_const_structs.h │ │ ├── arm_math.h │ │ ├── cmsis_armcc.h │ │ ├── cmsis_armcc_V6.h │ │ ├── cmsis_gcc.h │ │ ├── core_cm0.h │ │ ├── core_cm0plus.h │ │ ├── core_cm3.h │ │ ├── core_cm4.h │ │ ├── core_cm7.h │ │ ├── core_cmFunc.h │ │ ├── core_cmInstr.h │ │ ├── core_cmSimd.h │ │ ├── core_sc000.h │ │ └── core_sc300.h └── STM32F0xx_HAL_Driver │ ├── Inc │ ├── Legacy │ │ └── stm32_hal_legacy.h │ ├── stm32f0xx_hal.h │ ├── stm32f0xx_hal_can.h │ ├── stm32f0xx_hal_cortex.h │ ├── stm32f0xx_hal_def.h │ ├── stm32f0xx_hal_dma.h │ ├── stm32f0xx_hal_dma_ex.h │ ├── stm32f0xx_hal_flash.h │ ├── stm32f0xx_hal_flash_ex.h │ ├── stm32f0xx_hal_gpio.h │ ├── stm32f0xx_hal_gpio_ex.h │ ├── stm32f0xx_hal_i2c.h │ ├── stm32f0xx_hal_i2c_ex.h │ ├── stm32f0xx_hal_iwdg.h │ ├── stm32f0xx_hal_pcd.h │ ├── stm32f0xx_hal_pcd_ex.h │ ├── stm32f0xx_hal_pwr.h │ ├── stm32f0xx_hal_pwr_ex.h │ ├── stm32f0xx_hal_rcc.h │ ├── stm32f0xx_hal_rcc_ex.h │ ├── stm32f0xx_hal_tim.h │ ├── stm32f0xx_hal_tim_ex.h │ ├── stm32f0xx_hal_uart.h │ └── stm32f0xx_hal_uart_ex.h │ └── Src │ ├── stm32f0xx_hal.c │ ├── stm32f0xx_hal_can.c │ ├── stm32f0xx_hal_cortex.c │ ├── stm32f0xx_hal_dma.c │ ├── stm32f0xx_hal_flash.c │ ├── stm32f0xx_hal_flash_ex.c │ ├── stm32f0xx_hal_gpio.c │ ├── stm32f0xx_hal_i2c.c │ ├── stm32f0xx_hal_i2c_ex.c │ ├── stm32f0xx_hal_iwdg.c │ ├── stm32f0xx_hal_pcd.c │ ├── stm32f0xx_hal_pcd_ex.c │ ├── stm32f0xx_hal_pwr.c │ ├── stm32f0xx_hal_pwr_ex.c │ ├── stm32f0xx_hal_rcc.c │ ├── stm32f0xx_hal_rcc_ex.c │ ├── stm32f0xx_hal_tim.c │ ├── stm32f0xx_hal_tim_ex.c │ ├── stm32f0xx_hal_uart.c │ └── stm32f0xx_hal_uart_ex.c ├── Inc ├── main.h ├── stm32f0xx_hal_conf.h ├── stm32f0xx_it.h ├── usb_device.h ├── usbd_cdc_if.h ├── usbd_conf.h └── usbd_desc.h ├── LICENSE ├── Middlewares └── ST │ └── STM32_USB_Device_Library │ ├── Class │ └── CDC │ │ ├── Inc │ │ └── usbd_cdc.h │ │ └── Src │ │ └── usbd_cdc.c │ └── Core │ ├── Inc │ ├── usbd_core.h │ ├── usbd_ctlreq.h │ ├── usbd_def.h │ └── usbd_ioreq.h │ └── Src │ ├── usbd_core.c │ ├── usbd_ctlreq.c │ └── usbd_ioreq.c ├── README.md ├── STM32F042C6_FLASH.ld ├── Src ├── bootloader │ └── bootloader.c ├── main.c ├── slcan │ ├── slcan.c │ ├── slcan.h │ ├── slcan_additional.c │ └── slcan_additional.h ├── stm32f0xx_hal_msp.c ├── stm32f0xx_it.c ├── system_stm32f0xx.c ├── usb_device.c ├── usbd_cdc_if.c ├── usbd_conf.c └── usbd_desc.c ├── UCCBEmbedded.elf (1).launch ├── UCCBEmbedded.elf.launch ├── UCCBEmbedded.ioc ├── script ├── UCCB_Upload.sh └── test_dongle.py └── startup └── startup_stm32f042x6.s /.gitignore: -------------------------------------------------------------------------------- 1 | # Object files 2 | *.o 3 | *.ko 4 | *.obj 5 | *.elf 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Libraries 12 | *.lib 13 | *.a 14 | *.la 15 | *.lo 16 | 17 | # Shared objects (inc. Windows DLLs) 18 | *.dll 19 | *.so 20 | *.so.* 21 | *.dylib 22 | 23 | # Executables 24 | *.exe 25 | *.out 26 | *.app 27 | *.i*86 28 | *.x86_64 29 | *.hex 30 | 31 | # Debug files 32 | *.dSYM/ 33 | *.su 34 | *.map 35 | TrueSTUDIO/USB_CAN_CONVERTER_BASIC/Debug/USB_CAN_CONVERTER_BASIC.elf.list 36 | TrueSTUDIO/USB_CAN_CONVERTER_BASIC/.settings/com.atollic.truestudio.debug.hardware_device.prefs 37 | TrueSTUDIO/USB_CAN_CONVERTER_BASIC/.settings/language.settings.xml 38 | .mxproject 39 | TrueSTUDIO/USB_CAN_CONVERTER_BASIC/.settings/language.settings.xml 40 | /Debug 41 | -------------------------------------------------------------------------------- /.mxproject: -------------------------------------------------------------------------------- 1 | [PreviousGenFiles] 2 | HeaderPath=D:/GIThub/UCCBEmbedded/Inc 3 | HeaderFiles=usb_device.h;usbd_conf.h;usbd_desc.h;usbd_cdc_if.h;stm32f0xx_it.h;stm32f0xx_hal_conf.h;main.h; 4 | SourcePath=D:/GIThub/UCCBEmbedded/Src 5 | SourceFiles=usb_device.h;usbd_conf.h;usbd_desc.h;usbd_cdc_if.h;stm32f0xx_it.h;stm32f0xx_hal_conf.h;main.h;usb_device.c;usbd_conf.c;usbd_desc.c;usbd_cdc_if.c;stm32f0xx_it.c;stm32f0xx_hal_msp.c;main.c; 6 | 7 | [PreviousLibFiles] 8 | LibFiles=Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_pcd.h;Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_pcd_ex.h;Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_can.h;Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_iwdg.h;Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_tim.h;Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_tim_ex.h;Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_uart.h;Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_uart_ex.h;Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_rcc.h;Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_rcc_ex.h;Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal.h;Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_def.h;Drivers/STM32F0xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_i2c.h;Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_i2c_ex.h;Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_gpio.h;Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_gpio_ex.h;Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_dma_ex.h;Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_dma.h;Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_cortex.h;Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_pwr.h;Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_pwr_ex.h;Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_flash.h;Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_flash_ex.h;Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_core.h;Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_ctlreq.h;Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_def.h;Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_ioreq.h;Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc/usbd_cdc.h;Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_pcd.c;Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_pcd_ex.c;Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_can.c;Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_iwdg.c;Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_tim.c;Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_tim_ex.c;Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_uart.c;Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_uart_ex.c;Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_rcc.c;Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_rcc_ex.c;Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal.c;Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_i2c.c;Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_i2c_ex.c;Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_gpio.c;Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_dma.c;Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_cortex.c;Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_pwr.c;Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_pwr_ex.c;Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_flash.c;Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_flash_ex.c;Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c;Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ctlreq.c;Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c;Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c;Drivers/CMSIS/Device/ST/STM32F0xx/Include/stm32f042x6.h;Drivers/CMSIS/Device/ST/STM32F0xx/Include/stm32f0xx.h;Drivers/CMSIS/Device/ST/STM32F0xx/Include/system_stm32f0xx.h;Drivers/CMSIS/Device/ST/STM32F0xx/Source/Templates/system_stm32f0xx.c;Drivers/CMSIS/Include/arm_common_tables.h;Drivers/CMSIS/Include/arm_const_structs.h;Drivers/CMSIS/Include/arm_math.h;Drivers/CMSIS/Include/cmsis_armcc.h;Drivers/CMSIS/Include/cmsis_armcc_V6.h;Drivers/CMSIS/Include/cmsis_gcc.h;Drivers/CMSIS/Include/core_cm0.h;Drivers/CMSIS/Include/core_cm0plus.h;Drivers/CMSIS/Include/core_cm3.h;Drivers/CMSIS/Include/core_cm4.h;Drivers/CMSIS/Include/core_cm7.h;Drivers/CMSIS/Include/core_cmFunc.h;Drivers/CMSIS/Include/core_cmInstr.h;Drivers/CMSIS/Include/core_cmSimd.h;Drivers/CMSIS/Include/core_sc000.h;Drivers/CMSIS/Include/core_sc300.h; 9 | 10 | [PreviousUsedTStudioFiles] 11 | SourceFiles=..\Src\main.c;..\Src\usb_device.c;..\Src\usbd_conf.c;..\Src\usbd_desc.c;..\Src\usbd_cdc_if.c;..\Src\stm32f0xx_it.c;..\Src\stm32f0xx_hal_msp.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_pcd.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_pcd_ex.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_can.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_iwdg.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_tim.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_tim_ex.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_uart.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_uart_ex.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_rcc.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_rcc_ex.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_i2c.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_i2c_ex.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_gpio.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_dma.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_cortex.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_pwr.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_pwr_ex.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_flash.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_flash_ex.c;../Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c;../Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ctlreq.c;../Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c;../Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c;../\Src/system_stm32f0xx.c;../Drivers/CMSIS/Device/ST/STM32F0xx/Source/Templates/system_stm32f0xx.c;null;../Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c;../Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ctlreq.c;../Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c;../Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c; 12 | HeaderPath=..\Drivers\STM32F0xx_HAL_Driver\Inc;..\Drivers\STM32F0xx_HAL_Driver\Inc\Legacy;..\Middlewares\ST\STM32_USB_Device_Library\Core\Inc;..\Middlewares\ST\STM32_USB_Device_Library\Class\CDC\Inc;..\Drivers\CMSIS\Device\ST\STM32F0xx\Include;..\Drivers\CMSIS\Include;..\Inc; 13 | CDefines=__weak:__attribute__((weak));__packed:__attribute__((__packed__)); 14 | 15 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | UCCBEmbedded 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | ?children? 14 | ?name?=outputEntries\|?children?=?name?=entry\\\\\\\|\\\|\|| 15 | 16 | 17 | ?name? 18 | 19 | 20 | 21 | org.eclipse.cdt.make.core.append_environment 22 | true 23 | 24 | 25 | org.eclipse.cdt.make.core.buildArguments 26 | 27 | 28 | 29 | org.eclipse.cdt.make.core.buildCommand 30 | make 31 | 32 | 33 | org.eclipse.cdt.make.core.buildLocation 34 | ${workspace_loc:/STM32100B-EVAL/Debug} 35 | 36 | 37 | org.eclipse.cdt.make.core.contents 38 | org.eclipse.cdt.make.core.activeConfigSettings 39 | 40 | 41 | org.eclipse.cdt.make.core.enableAutoBuild 42 | false 43 | 44 | 45 | org.eclipse.cdt.make.core.enableCleanBuild 46 | true 47 | 48 | 49 | org.eclipse.cdt.make.core.enableFullBuild 50 | true 51 | 52 | 53 | org.eclipse.cdt.make.core.stopOnError 54 | true 55 | 56 | 57 | org.eclipse.cdt.make.core.useDefaultBuildCmd 58 | true 59 | 60 | 61 | 62 | 63 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 64 | 65 | 66 | 67 | 68 | 69 | org.eclipse.cdt.core.cnature 70 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 71 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 72 | 73 | 74 | -------------------------------------------------------------------------------- /.settings/com.atollic.truestudio.debug.hardware_device.prefs: -------------------------------------------------------------------------------- 1 | BOARD=None 2 | CODE_LOCATION=FLASH 3 | ENDIAN=Little-endian 4 | MCU=STM32F042C6 5 | MCU_VENDOR=STMicroelectronics 6 | MODEL=Lite 7 | PROBE=ST-LINK 8 | PROJECT_FORMAT_VERSION=2 9 | TARGET=ARM\u00AE 10 | VERSION=4.1.0 11 | eclipse.preferences.version=1 12 | -------------------------------------------------------------------------------- /.settings/language.settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /.settings/org.eclipse.cdt.managedbuilder.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | environment/buildEnvironmentInclude/com.atollic.truestudio.exe.debug.1518366166/CPATH/delimiter=; 3 | environment/buildEnvironmentInclude/com.atollic.truestudio.exe.debug.1518366166/CPATH/operation=remove 4 | environment/buildEnvironmentInclude/com.atollic.truestudio.exe.debug.1518366166/C_INCLUDE_PATH/delimiter=; 5 | environment/buildEnvironmentInclude/com.atollic.truestudio.exe.debug.1518366166/C_INCLUDE_PATH/operation=remove 6 | environment/buildEnvironmentInclude/com.atollic.truestudio.exe.debug.1518366166/append=true 7 | environment/buildEnvironmentInclude/com.atollic.truestudio.exe.debug.1518366166/appendContributed=true 8 | environment/buildEnvironmentLibrary/com.atollic.truestudio.exe.debug.1518366166/LIBRARY_PATH/delimiter=; 9 | environment/buildEnvironmentLibrary/com.atollic.truestudio.exe.debug.1518366166/LIBRARY_PATH/operation=remove 10 | environment/buildEnvironmentLibrary/com.atollic.truestudio.exe.debug.1518366166/append=true 11 | environment/buildEnvironmentLibrary/com.atollic.truestudio.exe.debug.1518366166/appendContributed=true 12 | -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F0xx/Include/stm32f042x6.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UsbCANConverter-UCCbasic/UCCBEmbedded/0de2ff76d3143558c70a246ba89d3c40f9ac79a7/Drivers/CMSIS/Device/ST/STM32F0xx/Include/stm32f042x6.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F0xx/Include/stm32f0xx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UsbCANConverter-UCCbasic/UCCBEmbedded/0de2ff76d3143558c70a246ba89d3c40f9ac79a7/Drivers/CMSIS/Device/ST/STM32F0xx/Include/stm32f0xx.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F0xx/Include/system_stm32f0xx.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32f0xx.h 4 | * @author MCD Application Team 5 | * @brief CMSIS Cortex-M0 Device System Source File for STM32F0xx devices. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© COPYRIGHT(c) 2016 STMicroelectronics

10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 19 | * may be used to endorse or promote products derived from this software 20 | * without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * 33 | ****************************************************************************** 34 | */ 35 | 36 | /** @addtogroup CMSIS 37 | * @{ 38 | */ 39 | 40 | /** @addtogroup stm32f0xx_system 41 | * @{ 42 | */ 43 | 44 | /** 45 | * @brief Define to prevent recursive inclusion 46 | */ 47 | #ifndef __SYSTEM_STM32F0XX_H 48 | #define __SYSTEM_STM32F0XX_H 49 | 50 | #ifdef __cplusplus 51 | extern "C" { 52 | #endif 53 | 54 | /** @addtogroup STM32F0xx_System_Includes 55 | * @{ 56 | */ 57 | 58 | /** 59 | * @} 60 | */ 61 | 62 | 63 | /** @addtogroup STM32F0xx_System_Exported_types 64 | * @{ 65 | */ 66 | /* This variable is updated in three ways: 67 | 1) by calling CMSIS function SystemCoreClockUpdate() 68 | 3) by calling HAL API function HAL_RCC_GetHCLKFreq() 69 | 3) by calling HAL API function HAL_RCC_ClockConfig() 70 | Note: If you use this function to configure the system clock; then there 71 | is no need to call the 2 first functions listed above, since SystemCoreClock 72 | variable is updated automatically. 73 | */ 74 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 75 | extern const uint8_t AHBPrescTable[16]; /*!< AHB prescalers table values */ 76 | extern const uint8_t APBPrescTable[8]; /*!< APB prescalers table values */ 77 | 78 | /** 79 | * @} 80 | */ 81 | 82 | /** @addtogroup STM32F0xx_System_Exported_Constants 83 | * @{ 84 | */ 85 | 86 | /** 87 | * @} 88 | */ 89 | 90 | /** @addtogroup STM32F0xx_System_Exported_Macros 91 | * @{ 92 | */ 93 | 94 | /** 95 | * @} 96 | */ 97 | 98 | /** @addtogroup STM32F0xx_System_Exported_Functions 99 | * @{ 100 | */ 101 | 102 | extern void SystemInit(void); 103 | extern void SystemCoreClockUpdate(void); 104 | /** 105 | * @} 106 | */ 107 | 108 | #ifdef __cplusplus 109 | } 110 | #endif 111 | 112 | #endif /*__SYSTEM_STM32F0XX_H */ 113 | 114 | /** 115 | * @} 116 | */ 117 | 118 | /** 119 | * @} 120 | */ 121 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 122 | -------------------------------------------------------------------------------- /Drivers/CMSIS/Include/arm_common_tables.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010-2014 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 19. October 2015 5 | * $Revision: V.1.4.5 a 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_common_tables.h 9 | * 10 | * Description: This file has extern declaration for common tables like Bitreverse, reciprocal etc which are used across different functions 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3 13 | * 14 | * Redistribution and use in source and binary forms, with or without 15 | * modification, are permitted provided that the following conditions 16 | * are met: 17 | * - Redistributions of source code must retain the above copyright 18 | * notice, this list of conditions and the following disclaimer. 19 | * - Redistributions in binary form must reproduce the above copyright 20 | * notice, this list of conditions and the following disclaimer in 21 | * the documentation and/or other materials provided with the 22 | * distribution. 23 | * - Neither the name of ARM LIMITED nor the names of its contributors 24 | * may be used to endorse or promote products derived from this 25 | * software without specific prior written permission. 26 | * 27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 28 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 29 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 30 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 31 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 32 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 33 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 34 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 35 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * -------------------------------------------------------------------- */ 40 | 41 | #ifndef _ARM_COMMON_TABLES_H 42 | #define _ARM_COMMON_TABLES_H 43 | 44 | #include "arm_math.h" 45 | 46 | extern const uint16_t armBitRevTable[1024]; 47 | extern const q15_t armRecipTableQ15[64]; 48 | extern const q31_t armRecipTableQ31[64]; 49 | /* extern const q31_t realCoefAQ31[1024]; */ 50 | /* extern const q31_t realCoefBQ31[1024]; */ 51 | extern const float32_t twiddleCoef_16[32]; 52 | extern const float32_t twiddleCoef_32[64]; 53 | extern const float32_t twiddleCoef_64[128]; 54 | extern const float32_t twiddleCoef_128[256]; 55 | extern const float32_t twiddleCoef_256[512]; 56 | extern const float32_t twiddleCoef_512[1024]; 57 | extern const float32_t twiddleCoef_1024[2048]; 58 | extern const float32_t twiddleCoef_2048[4096]; 59 | extern const float32_t twiddleCoef_4096[8192]; 60 | #define twiddleCoef twiddleCoef_4096 61 | extern const q31_t twiddleCoef_16_q31[24]; 62 | extern const q31_t twiddleCoef_32_q31[48]; 63 | extern const q31_t twiddleCoef_64_q31[96]; 64 | extern const q31_t twiddleCoef_128_q31[192]; 65 | extern const q31_t twiddleCoef_256_q31[384]; 66 | extern const q31_t twiddleCoef_512_q31[768]; 67 | extern const q31_t twiddleCoef_1024_q31[1536]; 68 | extern const q31_t twiddleCoef_2048_q31[3072]; 69 | extern const q31_t twiddleCoef_4096_q31[6144]; 70 | extern const q15_t twiddleCoef_16_q15[24]; 71 | extern const q15_t twiddleCoef_32_q15[48]; 72 | extern const q15_t twiddleCoef_64_q15[96]; 73 | extern const q15_t twiddleCoef_128_q15[192]; 74 | extern const q15_t twiddleCoef_256_q15[384]; 75 | extern const q15_t twiddleCoef_512_q15[768]; 76 | extern const q15_t twiddleCoef_1024_q15[1536]; 77 | extern const q15_t twiddleCoef_2048_q15[3072]; 78 | extern const q15_t twiddleCoef_4096_q15[6144]; 79 | extern const float32_t twiddleCoef_rfft_32[32]; 80 | extern const float32_t twiddleCoef_rfft_64[64]; 81 | extern const float32_t twiddleCoef_rfft_128[128]; 82 | extern const float32_t twiddleCoef_rfft_256[256]; 83 | extern const float32_t twiddleCoef_rfft_512[512]; 84 | extern const float32_t twiddleCoef_rfft_1024[1024]; 85 | extern const float32_t twiddleCoef_rfft_2048[2048]; 86 | extern const float32_t twiddleCoef_rfft_4096[4096]; 87 | 88 | 89 | /* floating-point bit reversal tables */ 90 | #define ARMBITREVINDEXTABLE__16_TABLE_LENGTH ((uint16_t)20 ) 91 | #define ARMBITREVINDEXTABLE__32_TABLE_LENGTH ((uint16_t)48 ) 92 | #define ARMBITREVINDEXTABLE__64_TABLE_LENGTH ((uint16_t)56 ) 93 | #define ARMBITREVINDEXTABLE_128_TABLE_LENGTH ((uint16_t)208 ) 94 | #define ARMBITREVINDEXTABLE_256_TABLE_LENGTH ((uint16_t)440 ) 95 | #define ARMBITREVINDEXTABLE_512_TABLE_LENGTH ((uint16_t)448 ) 96 | #define ARMBITREVINDEXTABLE1024_TABLE_LENGTH ((uint16_t)1800) 97 | #define ARMBITREVINDEXTABLE2048_TABLE_LENGTH ((uint16_t)3808) 98 | #define ARMBITREVINDEXTABLE4096_TABLE_LENGTH ((uint16_t)4032) 99 | 100 | extern const uint16_t armBitRevIndexTable16[ARMBITREVINDEXTABLE__16_TABLE_LENGTH]; 101 | extern const uint16_t armBitRevIndexTable32[ARMBITREVINDEXTABLE__32_TABLE_LENGTH]; 102 | extern const uint16_t armBitRevIndexTable64[ARMBITREVINDEXTABLE__64_TABLE_LENGTH]; 103 | extern const uint16_t armBitRevIndexTable128[ARMBITREVINDEXTABLE_128_TABLE_LENGTH]; 104 | extern const uint16_t armBitRevIndexTable256[ARMBITREVINDEXTABLE_256_TABLE_LENGTH]; 105 | extern const uint16_t armBitRevIndexTable512[ARMBITREVINDEXTABLE_512_TABLE_LENGTH]; 106 | extern const uint16_t armBitRevIndexTable1024[ARMBITREVINDEXTABLE1024_TABLE_LENGTH]; 107 | extern const uint16_t armBitRevIndexTable2048[ARMBITREVINDEXTABLE2048_TABLE_LENGTH]; 108 | extern const uint16_t armBitRevIndexTable4096[ARMBITREVINDEXTABLE4096_TABLE_LENGTH]; 109 | 110 | /* fixed-point bit reversal tables */ 111 | #define ARMBITREVINDEXTABLE_FIXED___16_TABLE_LENGTH ((uint16_t)12 ) 112 | #define ARMBITREVINDEXTABLE_FIXED___32_TABLE_LENGTH ((uint16_t)24 ) 113 | #define ARMBITREVINDEXTABLE_FIXED___64_TABLE_LENGTH ((uint16_t)56 ) 114 | #define ARMBITREVINDEXTABLE_FIXED__128_TABLE_LENGTH ((uint16_t)112 ) 115 | #define ARMBITREVINDEXTABLE_FIXED__256_TABLE_LENGTH ((uint16_t)240 ) 116 | #define ARMBITREVINDEXTABLE_FIXED__512_TABLE_LENGTH ((uint16_t)480 ) 117 | #define ARMBITREVINDEXTABLE_FIXED_1024_TABLE_LENGTH ((uint16_t)992 ) 118 | #define ARMBITREVINDEXTABLE_FIXED_2048_TABLE_LENGTH ((uint16_t)1984) 119 | #define ARMBITREVINDEXTABLE_FIXED_4096_TABLE_LENGTH ((uint16_t)4032) 120 | 121 | extern const uint16_t armBitRevIndexTable_fixed_16[ARMBITREVINDEXTABLE_FIXED___16_TABLE_LENGTH]; 122 | extern const uint16_t armBitRevIndexTable_fixed_32[ARMBITREVINDEXTABLE_FIXED___32_TABLE_LENGTH]; 123 | extern const uint16_t armBitRevIndexTable_fixed_64[ARMBITREVINDEXTABLE_FIXED___64_TABLE_LENGTH]; 124 | extern const uint16_t armBitRevIndexTable_fixed_128[ARMBITREVINDEXTABLE_FIXED__128_TABLE_LENGTH]; 125 | extern const uint16_t armBitRevIndexTable_fixed_256[ARMBITREVINDEXTABLE_FIXED__256_TABLE_LENGTH]; 126 | extern const uint16_t armBitRevIndexTable_fixed_512[ARMBITREVINDEXTABLE_FIXED__512_TABLE_LENGTH]; 127 | extern const uint16_t armBitRevIndexTable_fixed_1024[ARMBITREVINDEXTABLE_FIXED_1024_TABLE_LENGTH]; 128 | extern const uint16_t armBitRevIndexTable_fixed_2048[ARMBITREVINDEXTABLE_FIXED_2048_TABLE_LENGTH]; 129 | extern const uint16_t armBitRevIndexTable_fixed_4096[ARMBITREVINDEXTABLE_FIXED_4096_TABLE_LENGTH]; 130 | 131 | /* Tables for Fast Math Sine and Cosine */ 132 | extern const float32_t sinTable_f32[FAST_MATH_TABLE_SIZE + 1]; 133 | extern const q31_t sinTable_q31[FAST_MATH_TABLE_SIZE + 1]; 134 | extern const q15_t sinTable_q15[FAST_MATH_TABLE_SIZE + 1]; 135 | 136 | #endif /* ARM_COMMON_TABLES_H */ 137 | -------------------------------------------------------------------------------- /Drivers/CMSIS/Include/arm_const_structs.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010-2014 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 19. March 2015 5 | * $Revision: V.1.4.5 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_const_structs.h 9 | * 10 | * Description: This file has constant structs that are initialized for 11 | * user convenience. For example, some can be given as 12 | * arguments to the arm_cfft_f32() function. 13 | * 14 | * Target Processor: Cortex-M4/Cortex-M3 15 | * 16 | * Redistribution and use in source and binary forms, with or without 17 | * modification, are permitted provided that the following conditions 18 | * are met: 19 | * - Redistributions of source code must retain the above copyright 20 | * notice, this list of conditions and the following disclaimer. 21 | * - Redistributions in binary form must reproduce the above copyright 22 | * notice, this list of conditions and the following disclaimer in 23 | * the documentation and/or other materials provided with the 24 | * distribution. 25 | * - Neither the name of ARM LIMITED nor the names of its contributors 26 | * may be used to endorse or promote products derived from this 27 | * software without specific prior written permission. 28 | * 29 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 30 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 31 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 32 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 33 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 34 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 35 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 36 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 37 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 38 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 39 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 40 | * POSSIBILITY OF SUCH DAMAGE. 41 | * -------------------------------------------------------------------- */ 42 | 43 | #ifndef _ARM_CONST_STRUCTS_H 44 | #define _ARM_CONST_STRUCTS_H 45 | 46 | #include "arm_math.h" 47 | #include "arm_common_tables.h" 48 | 49 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len16; 50 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len32; 51 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len64; 52 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len128; 53 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len256; 54 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len512; 55 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len1024; 56 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len2048; 57 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len4096; 58 | 59 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len16; 60 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len32; 61 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len64; 62 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len128; 63 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len256; 64 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len512; 65 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len1024; 66 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len2048; 67 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len4096; 68 | 69 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len16; 70 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len32; 71 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len64; 72 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len128; 73 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len256; 74 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len512; 75 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len1024; 76 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len2048; 77 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len4096; 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /Drivers/CMSIS/Include/core_cmFunc.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file core_cmFunc.h 3 | * @brief CMSIS Cortex-M Core Function Access Header File 4 | * @version V4.30 5 | * @date 20. October 2015 6 | ******************************************************************************/ 7 | /* Copyright (c) 2009 - 2015 ARM LIMITED 8 | 9 | All rights reserved. 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | - Neither the name of ARM nor the names of its contributors may be used 18 | to endorse or promote products derived from this software without 19 | specific prior written permission. 20 | * 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | ---------------------------------------------------------------------------*/ 33 | 34 | 35 | #if defined ( __ICCARM__ ) 36 | #pragma system_include /* treat file as system include file for MISRA check */ 37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 38 | #pragma clang system_header /* treat file as system include file */ 39 | #endif 40 | 41 | #ifndef __CORE_CMFUNC_H 42 | #define __CORE_CMFUNC_H 43 | 44 | 45 | /* ########################### Core Function Access ########################### */ 46 | /** \ingroup CMSIS_Core_FunctionInterface 47 | \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions 48 | @{ 49 | */ 50 | 51 | /*------------------ RealView Compiler -----------------*/ 52 | #if defined ( __CC_ARM ) 53 | #include "cmsis_armcc.h" 54 | 55 | /*------------------ ARM Compiler V6 -------------------*/ 56 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 57 | #include "cmsis_armcc_V6.h" 58 | 59 | /*------------------ GNU Compiler ----------------------*/ 60 | #elif defined ( __GNUC__ ) 61 | #include "cmsis_gcc.h" 62 | 63 | /*------------------ ICC Compiler ----------------------*/ 64 | #elif defined ( __ICCARM__ ) 65 | #include 66 | 67 | /*------------------ TI CCS Compiler -------------------*/ 68 | #elif defined ( __TMS470__ ) 69 | #include 70 | 71 | /*------------------ TASKING Compiler ------------------*/ 72 | #elif defined ( __TASKING__ ) 73 | /* 74 | * The CMSIS functions have been implemented as intrinsics in the compiler. 75 | * Please use "carm -?i" to get an up to date list of all intrinsics, 76 | * Including the CMSIS ones. 77 | */ 78 | 79 | /*------------------ COSMIC Compiler -------------------*/ 80 | #elif defined ( __CSMC__ ) 81 | #include 82 | 83 | #endif 84 | 85 | /*@} end of CMSIS_Core_RegAccFunctions */ 86 | 87 | #endif /* __CORE_CMFUNC_H */ 88 | -------------------------------------------------------------------------------- /Drivers/CMSIS/Include/core_cmInstr.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file core_cmInstr.h 3 | * @brief CMSIS Cortex-M Core Instruction Access Header File 4 | * @version V4.30 5 | * @date 20. October 2015 6 | ******************************************************************************/ 7 | /* Copyright (c) 2009 - 2015 ARM LIMITED 8 | 9 | All rights reserved. 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | - Neither the name of ARM nor the names of its contributors may be used 18 | to endorse or promote products derived from this software without 19 | specific prior written permission. 20 | * 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | ---------------------------------------------------------------------------*/ 33 | 34 | 35 | #if defined ( __ICCARM__ ) 36 | #pragma system_include /* treat file as system include file for MISRA check */ 37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 38 | #pragma clang system_header /* treat file as system include file */ 39 | #endif 40 | 41 | #ifndef __CORE_CMINSTR_H 42 | #define __CORE_CMINSTR_H 43 | 44 | 45 | /* ########################## Core Instruction Access ######################### */ 46 | /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface 47 | Access to dedicated instructions 48 | @{ 49 | */ 50 | 51 | /*------------------ RealView Compiler -----------------*/ 52 | #if defined ( __CC_ARM ) 53 | #include "cmsis_armcc.h" 54 | 55 | /*------------------ ARM Compiler V6 -------------------*/ 56 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 57 | #include "cmsis_armcc_V6.h" 58 | 59 | /*------------------ GNU Compiler ----------------------*/ 60 | #elif defined ( __GNUC__ ) 61 | #include "cmsis_gcc.h" 62 | 63 | /*------------------ ICC Compiler ----------------------*/ 64 | #elif defined ( __ICCARM__ ) 65 | #include 66 | 67 | /*------------------ TI CCS Compiler -------------------*/ 68 | #elif defined ( __TMS470__ ) 69 | #include 70 | 71 | /*------------------ TASKING Compiler ------------------*/ 72 | #elif defined ( __TASKING__ ) 73 | /* 74 | * The CMSIS functions have been implemented as intrinsics in the compiler. 75 | * Please use "carm -?i" to get an up to date list of all intrinsics, 76 | * Including the CMSIS ones. 77 | */ 78 | 79 | /*------------------ COSMIC Compiler -------------------*/ 80 | #elif defined ( __CSMC__ ) 81 | #include 82 | 83 | #endif 84 | 85 | /*@}*/ /* end of group CMSIS_Core_InstructionInterface */ 86 | 87 | #endif /* __CORE_CMINSTR_H */ 88 | -------------------------------------------------------------------------------- /Drivers/CMSIS/Include/core_cmSimd.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file core_cmSimd.h 3 | * @brief CMSIS Cortex-M SIMD Header File 4 | * @version V4.30 5 | * @date 20. October 2015 6 | ******************************************************************************/ 7 | /* Copyright (c) 2009 - 2015 ARM LIMITED 8 | 9 | All rights reserved. 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | - Neither the name of ARM nor the names of its contributors may be used 18 | to endorse or promote products derived from this software without 19 | specific prior written permission. 20 | * 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | ---------------------------------------------------------------------------*/ 33 | 34 | 35 | #if defined ( __ICCARM__ ) 36 | #pragma system_include /* treat file as system include file for MISRA check */ 37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 38 | #pragma clang system_header /* treat file as system include file */ 39 | #endif 40 | 41 | #ifndef __CORE_CMSIMD_H 42 | #define __CORE_CMSIMD_H 43 | 44 | #ifdef __cplusplus 45 | extern "C" { 46 | #endif 47 | 48 | 49 | /* ################### Compiler specific Intrinsics ########################### */ 50 | /** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics 51 | Access to dedicated SIMD instructions 52 | @{ 53 | */ 54 | 55 | /*------------------ RealView Compiler -----------------*/ 56 | #if defined ( __CC_ARM ) 57 | #include "cmsis_armcc.h" 58 | 59 | /*------------------ ARM Compiler V6 -------------------*/ 60 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 61 | #include "cmsis_armcc_V6.h" 62 | 63 | /*------------------ GNU Compiler ----------------------*/ 64 | #elif defined ( __GNUC__ ) 65 | #include "cmsis_gcc.h" 66 | 67 | /*------------------ ICC Compiler ----------------------*/ 68 | #elif defined ( __ICCARM__ ) 69 | #include 70 | 71 | /*------------------ TI CCS Compiler -------------------*/ 72 | #elif defined ( __TMS470__ ) 73 | #include 74 | 75 | /*------------------ TASKING Compiler ------------------*/ 76 | #elif defined ( __TASKING__ ) 77 | /* 78 | * The CMSIS functions have been implemented as intrinsics in the compiler. 79 | * Please use "carm -?i" to get an up to date list of all intrinsics, 80 | * Including the CMSIS ones. 81 | */ 82 | 83 | /*------------------ COSMIC Compiler -------------------*/ 84 | #elif defined ( __CSMC__ ) 85 | #include 86 | 87 | #endif 88 | 89 | /*@} end of group CMSIS_SIMD_intrinsics */ 90 | 91 | 92 | #ifdef __cplusplus 93 | } 94 | #endif 95 | 96 | #endif /* __CORE_CMSIMD_H */ 97 | -------------------------------------------------------------------------------- /Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_cortex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f0xx_hal_cortex.h 4 | * @author MCD Application Team 5 | * @brief Header file of CORTEX HAL module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© COPYRIGHT(c) 2016 STMicroelectronics

10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 19 | * may be used to endorse or promote products derived from this software 20 | * without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * 33 | ****************************************************************************** 34 | */ 35 | 36 | /* Define to prevent recursive inclusion -------------------------------------*/ 37 | #ifndef __STM32F0xx_HAL_CORTEX_H 38 | #define __STM32F0xx_HAL_CORTEX_H 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | /* Includes ------------------------------------------------------------------*/ 45 | #include "stm32f0xx_hal_def.h" 46 | 47 | /** @addtogroup STM32F0xx_HAL_Driver 48 | * @{ 49 | */ 50 | 51 | /** @addtogroup CORTEX CORTEX 52 | * @{ 53 | */ 54 | /* Exported types ------------------------------------------------------------*/ 55 | /* Exported constants --------------------------------------------------------*/ 56 | 57 | /** @defgroup CORTEX_Exported_Constants CORTEX Exported Constants 58 | * @{ 59 | */ 60 | 61 | /** @defgroup CORTEX_SysTick_clock_source CORTEX SysTick clock source 62 | * @{ 63 | */ 64 | #define SYSTICK_CLKSOURCE_HCLK_DIV8 (0x00000000U) 65 | #define SYSTICK_CLKSOURCE_HCLK (0x00000004U) 66 | 67 | /** 68 | * @} 69 | */ 70 | 71 | /** 72 | * @} 73 | */ 74 | 75 | /* Exported Macros -----------------------------------------------------------*/ 76 | 77 | /* Exported functions --------------------------------------------------------*/ 78 | /** @addtogroup CORTEX_Exported_Functions CORTEX Exported Functions 79 | * @{ 80 | */ 81 | /** @addtogroup CORTEX_Exported_Functions_Group1 Initialization and de-initialization functions 82 | * @brief Initialization and Configuration functions 83 | * @{ 84 | */ 85 | /* Initialization and de-initialization functions *******************************/ 86 | void HAL_NVIC_SetPriority(IRQn_Type IRQn,uint32_t PreemptPriority, uint32_t SubPriority); 87 | void HAL_NVIC_EnableIRQ(IRQn_Type IRQn); 88 | void HAL_NVIC_DisableIRQ(IRQn_Type IRQn); 89 | void HAL_NVIC_SystemReset(void); 90 | uint32_t HAL_SYSTICK_Config(uint32_t TicksNumb); 91 | /** 92 | * @} 93 | */ 94 | 95 | /** @addtogroup CORTEX_Exported_Functions_Group2 Peripheral Control functions 96 | * @brief Cortex control functions 97 | * @{ 98 | */ 99 | 100 | /* Peripheral Control functions *************************************************/ 101 | uint32_t HAL_NVIC_GetPriority(IRQn_Type IRQn); 102 | uint32_t HAL_NVIC_GetPendingIRQ(IRQn_Type IRQn); 103 | void HAL_NVIC_SetPendingIRQ(IRQn_Type IRQn); 104 | void HAL_NVIC_ClearPendingIRQ(IRQn_Type IRQn); 105 | void HAL_SYSTICK_CLKSourceConfig(uint32_t CLKSource); 106 | void HAL_SYSTICK_IRQHandler(void); 107 | void HAL_SYSTICK_Callback(void); 108 | /** 109 | * @} 110 | */ 111 | 112 | /** 113 | * @} 114 | */ 115 | 116 | /* Private types -------------------------------------------------------------*/ 117 | /* Private variables ---------------------------------------------------------*/ 118 | /* Private constants ---------------------------------------------------------*/ 119 | /* Private macros ------------------------------------------------------------*/ 120 | /** @defgroup CORTEX_Private_Macros CORTEX Private Macros 121 | * @{ 122 | */ 123 | #define IS_NVIC_PREEMPTION_PRIORITY(PRIORITY) ((PRIORITY) < 0x4) 124 | 125 | #define IS_NVIC_DEVICE_IRQ(IRQ) ((IRQ) >= 0x00) 126 | 127 | #define IS_SYSTICK_CLK_SOURCE(SOURCE) (((SOURCE) == SYSTICK_CLKSOURCE_HCLK) || \ 128 | ((SOURCE) == SYSTICK_CLKSOURCE_HCLK_DIV8)) 129 | /** 130 | * @} 131 | */ 132 | 133 | /** 134 | * @} 135 | */ 136 | 137 | /** 138 | * @} 139 | */ 140 | 141 | #ifdef __cplusplus 142 | } 143 | #endif 144 | 145 | #endif /* __STM32F0xx_HAL_CORTEX_H */ 146 | 147 | 148 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 149 | 150 | -------------------------------------------------------------------------------- /Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_def.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f0xx_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) 2016 STMicroelectronics

11 | * 12 | * Redistribution and use in source and binary forms, with or without modification, 13 | * are permitted provided that the following conditions are met: 14 | * 1. Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, 17 | * this list of conditions and the following disclaimer in the documentation 18 | * and/or other materials provided with the distribution. 19 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 31 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * 34 | ****************************************************************************** 35 | */ 36 | 37 | /* Define to prevent recursive inclusion -------------------------------------*/ 38 | #ifndef __STM32F0xx_HAL_DEF 39 | #define __STM32F0xx_HAL_DEF 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | /* Includes ------------------------------------------------------------------*/ 46 | #include "stm32f0xx.h" 47 | #if defined(USE_HAL_LEGACY) 48 | #include "Legacy/stm32_hal_legacy.h" 49 | #endif 50 | #include 51 | 52 | /* Exported types ------------------------------------------------------------*/ 53 | 54 | /** 55 | * @brief HAL Status structures definition 56 | */ 57 | typedef enum 58 | { 59 | HAL_OK = 0x00U, 60 | HAL_ERROR = 0x01U, 61 | HAL_BUSY = 0x02U, 62 | HAL_TIMEOUT = 0x03U 63 | } HAL_StatusTypeDef; 64 | 65 | /** 66 | * @brief HAL Lock structures definition 67 | */ 68 | typedef enum 69 | { 70 | HAL_UNLOCKED = 0x00U, 71 | HAL_LOCKED = 0x01U 72 | } HAL_LockTypeDef; 73 | 74 | /* Exported macro ------------------------------------------------------------*/ 75 | 76 | #define HAL_MAX_DELAY 0xFFFFFFFFU 77 | 78 | #define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) != RESET) 79 | #define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == RESET) 80 | 81 | #define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD_, __DMA_HANDLE_) \ 82 | do{ \ 83 | (__HANDLE__)->__PPP_DMA_FIELD_ = &(__DMA_HANDLE_); \ 84 | (__DMA_HANDLE_).Parent = (__HANDLE__); \ 85 | } while(0) 86 | 87 | #define UNUSED(x) ((void)(x)) 88 | 89 | /** @brief Reset the Handle's State field. 90 | * @param __HANDLE__ specifies the Peripheral Handle. 91 | * @note This macro can be used for the following purpose: 92 | * - When the Handle is declared as local variable; before passing it as parameter 93 | * to HAL_PPP_Init() for the first time, it is mandatory to use this macro 94 | * to set to 0 the Handle's "State" field. 95 | * Otherwise, "State" field may have any random value and the first time the function 96 | * HAL_PPP_Init() is called, the low level hardware initialization will be missed 97 | * (i.e. HAL_PPP_MspInit() will not be executed). 98 | * - When there is a need to reconfigure the low level hardware: instead of calling 99 | * HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init(). 100 | * In this later function, when the Handle's "State" field is set to 0, it will execute the function 101 | * HAL_PPP_MspInit() which will reconfigure the low level hardware. 102 | * @retval None 103 | */ 104 | #define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0) 105 | 106 | #if (USE_RTOS == 1) 107 | #error " USE_RTOS should be 0 in the current HAL release " 108 | #else 109 | #define __HAL_LOCK(__HANDLE__) \ 110 | do{ \ 111 | if((__HANDLE__)->Lock == HAL_LOCKED) \ 112 | { \ 113 | return HAL_BUSY; \ 114 | } \ 115 | else \ 116 | { \ 117 | (__HANDLE__)->Lock = HAL_LOCKED; \ 118 | } \ 119 | }while (0) 120 | 121 | #define __HAL_UNLOCK(__HANDLE__) \ 122 | do{ \ 123 | (__HANDLE__)->Lock = HAL_UNLOCKED; \ 124 | }while (0) 125 | #endif /* USE_RTOS */ 126 | 127 | #if defined ( __GNUC__ ) 128 | #ifndef __weak 129 | #define __weak __attribute__((weak)) 130 | #endif /* __weak */ 131 | #ifndef __packed 132 | #define __packed __attribute__((__packed__)) 133 | #endif /* __packed */ 134 | #endif /* __GNUC__ */ 135 | 136 | 137 | /* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */ 138 | #if defined (__GNUC__) /* GNU Compiler */ 139 | #ifndef __ALIGN_END 140 | #define __ALIGN_END __attribute__ ((aligned (4))) 141 | #endif /* __ALIGN_END */ 142 | #ifndef __ALIGN_BEGIN 143 | #define __ALIGN_BEGIN 144 | #endif /* __ALIGN_BEGIN */ 145 | #else 146 | #ifndef __ALIGN_END 147 | #define __ALIGN_END 148 | #endif /* __ALIGN_END */ 149 | #ifndef __ALIGN_BEGIN 150 | #if defined (__CC_ARM) /* ARM Compiler */ 151 | #define __ALIGN_BEGIN __align(4) 152 | #elif defined (__ICCARM__) /* IAR Compiler */ 153 | #define __ALIGN_BEGIN 154 | #endif /* __CC_ARM */ 155 | #endif /* __ALIGN_BEGIN */ 156 | #endif /* __GNUC__ */ 157 | 158 | /** 159 | * @brief __NOINLINE definition 160 | */ 161 | #if defined ( __CC_ARM ) || defined ( __GNUC__ ) 162 | /* ARM & GNUCompiler 163 | ---------------- 164 | */ 165 | #define __NOINLINE __attribute__ ( (noinline) ) 166 | 167 | #elif defined ( __ICCARM__ ) 168 | /* ICCARM Compiler 169 | --------------- 170 | */ 171 | #define __NOINLINE _Pragma("optimize = no_inline") 172 | 173 | #endif 174 | 175 | #ifdef __cplusplus 176 | } 177 | #endif 178 | 179 | #endif /* ___STM32F0xx_HAL_DEF */ 180 | 181 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 182 | 183 | -------------------------------------------------------------------------------- /Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_i2c_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f0xx_hal_i2c_ex.h 4 | * @author MCD Application Team 5 | * @brief Header file of I2C HAL Extended module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© COPYRIGHT(c) 2016 STMicroelectronics

10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 19 | * may be used to endorse or promote products derived from this software 20 | * without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * 33 | ****************************************************************************** 34 | */ 35 | 36 | /* Define to prevent recursive inclusion -------------------------------------*/ 37 | #ifndef __STM32F0xx_HAL_I2C_EX_H 38 | #define __STM32F0xx_HAL_I2C_EX_H 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | /* Includes ------------------------------------------------------------------*/ 45 | #include "stm32f0xx_hal_def.h" 46 | 47 | /** @addtogroup STM32F0xx_HAL_Driver 48 | * @{ 49 | */ 50 | 51 | /** @addtogroup I2CEx 52 | * @{ 53 | */ 54 | 55 | /* Exported types ------------------------------------------------------------*/ 56 | /* Exported constants --------------------------------------------------------*/ 57 | 58 | /** @defgroup I2CEx_Exported_Constants I2C Extended Exported Constants 59 | * @{ 60 | */ 61 | 62 | /** @defgroup I2CEx_Analog_Filter I2C Extended Analog Filter 63 | * @{ 64 | */ 65 | #define I2C_ANALOGFILTER_ENABLE 0x00000000U 66 | #define I2C_ANALOGFILTER_DISABLE I2C_CR1_ANFOFF 67 | /** 68 | * @} 69 | */ 70 | 71 | /** @defgroup I2CEx_FastModePlus I2C Extended Fast Mode Plus 72 | * @{ 73 | */ 74 | #define I2C_FMP_NOT_SUPPORTED 0xAAAA0000U /*!< Fast Mode Plus not supported */ 75 | #if defined(SYSCFG_CFGR1_I2C_FMP_PA9) 76 | #define I2C_FASTMODEPLUS_PA9 SYSCFG_CFGR1_I2C_FMP_PA9 /*!< Enable Fast Mode Plus on PA9 */ 77 | #define I2C_FASTMODEPLUS_PA10 SYSCFG_CFGR1_I2C_FMP_PA10 /*!< Enable Fast Mode Plus on PA10 */ 78 | #else 79 | #define I2C_FASTMODEPLUS_PA9 (uint32_t)(0x00000001U | I2C_FMP_NOT_SUPPORTED) /*!< Fast Mode Plus PA9 not supported */ 80 | #define I2C_FASTMODEPLUS_PA10 (uint32_t)(0x00000002U | I2C_FMP_NOT_SUPPORTED) /*!< Fast Mode Plus PA10 not supported */ 81 | #endif 82 | #define I2C_FASTMODEPLUS_PB6 SYSCFG_CFGR1_I2C_FMP_PB6 /*!< Enable Fast Mode Plus on PB6 */ 83 | #define I2C_FASTMODEPLUS_PB7 SYSCFG_CFGR1_I2C_FMP_PB7 /*!< Enable Fast Mode Plus on PB7 */ 84 | #define I2C_FASTMODEPLUS_PB8 SYSCFG_CFGR1_I2C_FMP_PB8 /*!< Enable Fast Mode Plus on PB8 */ 85 | #define I2C_FASTMODEPLUS_PB9 SYSCFG_CFGR1_I2C_FMP_PB9 /*!< Enable Fast Mode Plus on PB9 */ 86 | #if defined(SYSCFG_CFGR1_I2C_FMP_I2C1) 87 | #define I2C_FASTMODEPLUS_I2C1 SYSCFG_CFGR1_I2C_FMP_I2C1 /*!< Enable Fast Mode Plus on I2C1 pins */ 88 | #else 89 | #define I2C_FASTMODEPLUS_I2C1 (uint32_t)(0x00000100U | I2C_FMP_NOT_SUPPORTED) /*!< Fast Mode Plus I2C1 not supported */ 90 | #endif 91 | #if defined(SYSCFG_CFGR1_I2C_FMP_I2C2) 92 | #define I2C_FASTMODEPLUS_I2C2 SYSCFG_CFGR1_I2C_FMP_I2C2 /*!< Enable Fast Mode Plus on I2C2 pins */ 93 | #else 94 | #define I2C_FASTMODEPLUS_I2C2 (uint32_t)(0x00000200U | I2C_FMP_NOT_SUPPORTED) /*!< Fast Mode Plus I2C2 not supported */ 95 | #endif 96 | /** 97 | * @} 98 | */ 99 | 100 | /** 101 | * @} 102 | */ 103 | 104 | /* Exported macro ------------------------------------------------------------*/ 105 | /* Exported functions --------------------------------------------------------*/ 106 | 107 | /** @addtogroup I2CEx_Exported_Functions I2C Extended Exported Functions 108 | * @{ 109 | */ 110 | 111 | /** @addtogroup I2CEx_Exported_Functions_Group1 Extended features functions 112 | * @brief Extended features functions 113 | * @{ 114 | */ 115 | 116 | /* Peripheral Control functions ************************************************/ 117 | HAL_StatusTypeDef HAL_I2CEx_ConfigAnalogFilter(I2C_HandleTypeDef *hi2c, uint32_t AnalogFilter); 118 | HAL_StatusTypeDef HAL_I2CEx_ConfigDigitalFilter(I2C_HandleTypeDef *hi2c, uint32_t DigitalFilter); 119 | #if defined(I2C_CR1_WUPEN) 120 | HAL_StatusTypeDef HAL_I2CEx_EnableWakeUp(I2C_HandleTypeDef *hi2c); 121 | HAL_StatusTypeDef HAL_I2CEx_DisableWakeUp(I2C_HandleTypeDef *hi2c); 122 | #endif 123 | void HAL_I2CEx_EnableFastModePlus(uint32_t ConfigFastModePlus); 124 | void HAL_I2CEx_DisableFastModePlus(uint32_t ConfigFastModePlus); 125 | 126 | /* Private constants ---------------------------------------------------------*/ 127 | /** @defgroup I2CEx_Private_Constants I2C Extended Private Constants 128 | * @{ 129 | */ 130 | 131 | /** 132 | * @} 133 | */ 134 | 135 | /* Private macros ------------------------------------------------------------*/ 136 | /** @defgroup I2CEx_Private_Macro I2C Extended Private Macros 137 | * @{ 138 | */ 139 | #define IS_I2C_ANALOG_FILTER(FILTER) (((FILTER) == I2C_ANALOGFILTER_ENABLE) || \ 140 | ((FILTER) == I2C_ANALOGFILTER_DISABLE)) 141 | 142 | #define IS_I2C_DIGITAL_FILTER(FILTER) ((FILTER) <= 0x0000000FU) 143 | 144 | #define IS_I2C_FASTMODEPLUS(__CONFIG__) ((((__CONFIG__) & I2C_FMP_NOT_SUPPORTED) != I2C_FMP_NOT_SUPPORTED) && \ 145 | ((((__CONFIG__) & (I2C_FASTMODEPLUS_PA9)) == I2C_FASTMODEPLUS_PA9) || \ 146 | (((__CONFIG__) & (I2C_FASTMODEPLUS_PA10)) == I2C_FASTMODEPLUS_PA10) || \ 147 | (((__CONFIG__) & (I2C_FASTMODEPLUS_PB6)) == I2C_FASTMODEPLUS_PB6) || \ 148 | (((__CONFIG__) & (I2C_FASTMODEPLUS_PB7)) == I2C_FASTMODEPLUS_PB7) || \ 149 | (((__CONFIG__) & (I2C_FASTMODEPLUS_PB8)) == I2C_FASTMODEPLUS_PB8) || \ 150 | (((__CONFIG__) & (I2C_FASTMODEPLUS_PB9)) == I2C_FASTMODEPLUS_PB9) || \ 151 | (((__CONFIG__) & (I2C_FASTMODEPLUS_I2C1)) == I2C_FASTMODEPLUS_I2C1) || \ 152 | (((__CONFIG__) & (I2C_FASTMODEPLUS_I2C2)) == I2C_FASTMODEPLUS_I2C2))) 153 | /** 154 | * @} 155 | */ 156 | 157 | /* Private Functions ---------------------------------------------------------*/ 158 | /** @defgroup I2CEx_Private_Functions I2C Extended Private Functions 159 | * @{ 160 | */ 161 | /* Private functions are defined in stm32f0xx_hal_i2c_ex.c file */ 162 | /** 163 | * @} 164 | */ 165 | 166 | /** 167 | * @} 168 | */ 169 | 170 | /** 171 | * @} 172 | */ 173 | 174 | /** 175 | * @} 176 | */ 177 | 178 | /** 179 | * @} 180 | */ 181 | 182 | #ifdef __cplusplus 183 | } 184 | #endif 185 | 186 | #endif /* __STM32F0xx_HAL_I2C_EX_H */ 187 | 188 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 189 | -------------------------------------------------------------------------------- /Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_iwdg.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f0xx_hal_iwdg.h 4 | * @author MCD Application Team 5 | * @brief Header file of IWDG HAL module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© COPYRIGHT(c) 2016 STMicroelectronics

10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 19 | * may be used to endorse or promote products derived from this software 20 | * without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * 33 | ****************************************************************************** 34 | */ 35 | 36 | /* Define to prevent recursive inclusion -------------------------------------*/ 37 | #ifndef __STM32F0xx_HAL_IWDG_H 38 | #define __STM32F0xx_HAL_IWDG_H 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | /* Includes ------------------------------------------------------------------*/ 45 | #include "stm32f0xx_hal_def.h" 46 | 47 | /** @addtogroup STM32F0xx_HAL_Driver 48 | * @{ 49 | */ 50 | 51 | /** @defgroup IWDG IWDG 52 | * @{ 53 | */ 54 | 55 | /* Exported types ------------------------------------------------------------*/ 56 | /** @defgroup IWDG_Exported_Types IWDG Exported Types 57 | * @{ 58 | */ 59 | 60 | /** 61 | * @brief IWDG Init structure definition 62 | */ 63 | typedef struct 64 | { 65 | uint32_t Prescaler; /*!< Select the prescaler of the IWDG. 66 | This parameter can be a value of @ref IWDG_Prescaler */ 67 | 68 | uint32_t Reload; /*!< Specifies the IWDG down-counter reload value. 69 | This parameter must be a number between Min_Data = 0 and Max_Data = 0x0FFF */ 70 | 71 | uint32_t Window; /*!< Specifies the window value to be compared to the down-counter. 72 | This parameter must be a number between Min_Data = 0 and Max_Data = 0x0FFF */ 73 | 74 | } IWDG_InitTypeDef; 75 | 76 | /** 77 | * @brief IWDG Handle Structure definition 78 | */ 79 | typedef struct 80 | { 81 | IWDG_TypeDef *Instance; /*!< Register base address */ 82 | 83 | IWDG_InitTypeDef Init; /*!< IWDG required parameters */ 84 | 85 | }IWDG_HandleTypeDef; 86 | 87 | /** 88 | * @} 89 | */ 90 | 91 | /* Exported constants --------------------------------------------------------*/ 92 | /** @defgroup IWDG_Exported_Constants IWDG Exported Constants 93 | * @{ 94 | */ 95 | 96 | /** @defgroup IWDG_Prescaler IWDG Prescaler 97 | * @{ 98 | */ 99 | #define IWDG_PRESCALER_4 0x00000000U /*!< IWDG prescaler set to 4 */ 100 | #define IWDG_PRESCALER_8 IWDG_PR_PR_0 /*!< IWDG prescaler set to 8 */ 101 | #define IWDG_PRESCALER_16 IWDG_PR_PR_1 /*!< IWDG prescaler set to 16 */ 102 | #define IWDG_PRESCALER_32 (IWDG_PR_PR_1 | IWDG_PR_PR_0) /*!< IWDG prescaler set to 32 */ 103 | #define IWDG_PRESCALER_64 IWDG_PR_PR_2 /*!< IWDG prescaler set to 64 */ 104 | #define IWDG_PRESCALER_128 (IWDG_PR_PR_2 | IWDG_PR_PR_0) /*!< IWDG prescaler set to 128 */ 105 | #define IWDG_PRESCALER_256 (IWDG_PR_PR_2 | IWDG_PR_PR_1) /*!< IWDG prescaler set to 256 */ 106 | /** 107 | * @} 108 | */ 109 | 110 | /** @defgroup IWDG_Window_option IWDG Window option 111 | * @{ 112 | */ 113 | #define IWDG_WINDOW_DISABLE IWDG_WINR_WIN 114 | /** 115 | * @} 116 | */ 117 | 118 | /** 119 | * @} 120 | */ 121 | 122 | /* Exported macros -----------------------------------------------------------*/ 123 | /** @defgroup IWDG_Exported_Macros IWDG Exported Macros 124 | * @{ 125 | */ 126 | 127 | /** 128 | * @brief Enable the IWDG peripheral. 129 | * @param __HANDLE__ IWDG handle 130 | * @retval None 131 | */ 132 | #define __HAL_IWDG_START(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_ENABLE) 133 | 134 | /** 135 | * @brief Reload IWDG counter with value defined in the reload register 136 | * (write access to IWDG_PR, IWDG_RLR & IWDG_WINR registers disabled). 137 | * @param __HANDLE__ IWDG handle 138 | * @retval None 139 | */ 140 | #define __HAL_IWDG_RELOAD_COUNTER(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_RELOAD) 141 | 142 | /** 143 | * @} 144 | */ 145 | 146 | /* Exported functions --------------------------------------------------------*/ 147 | /** @defgroup IWDG_Exported_Functions IWDG Exported Functions 148 | * @{ 149 | */ 150 | 151 | /** @defgroup IWDG_Exported_Functions_Group1 Initialization and Start functions 152 | * @{ 153 | */ 154 | /* Initialization/Start functions ********************************************/ 155 | HAL_StatusTypeDef HAL_IWDG_Init(IWDG_HandleTypeDef *hiwdg); 156 | /** 157 | * @} 158 | */ 159 | 160 | /** @defgroup IWDG_Exported_Functions_Group2 IO operation functions 161 | * @{ 162 | */ 163 | /* I/O operation functions ****************************************************/ 164 | HAL_StatusTypeDef HAL_IWDG_Refresh(IWDG_HandleTypeDef *hiwdg); 165 | /** 166 | * @} 167 | */ 168 | 169 | /** 170 | * @} 171 | */ 172 | 173 | /* Private constants ---------------------------------------------------------*/ 174 | /** @defgroup IWDG_Private_Constants IWDG Private Constants 175 | * @{ 176 | */ 177 | 178 | /** 179 | * @brief IWDG Key Register BitMask 180 | */ 181 | #define IWDG_KEY_RELOAD 0x0000AAAAU /*!< IWDG Reload Counter Enable */ 182 | #define IWDG_KEY_ENABLE 0x0000CCCCU /*!< IWDG Peripheral Enable */ 183 | #define IWDG_KEY_WRITE_ACCESS_ENABLE 0x00005555U /*!< IWDG KR Write Access Enable */ 184 | #define IWDG_KEY_WRITE_ACCESS_DISABLE 0x00000000U /*!< IWDG KR Write Access Disable */ 185 | 186 | /** 187 | * @} 188 | */ 189 | 190 | /* Private macros ------------------------------------------------------------*/ 191 | /** @defgroup IWDG_Private_Macros IWDG Private Macros 192 | * @{ 193 | */ 194 | 195 | /** 196 | * @brief Enable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers. 197 | * @param __HANDLE__ IWDG handle 198 | * @retval None 199 | */ 200 | #define IWDG_ENABLE_WRITE_ACCESS(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_WRITE_ACCESS_ENABLE) 201 | 202 | /** 203 | * @brief Disable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers. 204 | * @param __HANDLE__ IWDG handle 205 | * @retval None 206 | */ 207 | #define IWDG_DISABLE_WRITE_ACCESS(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_WRITE_ACCESS_DISABLE) 208 | 209 | /** 210 | * @brief Check IWDG prescaler value. 211 | * @param __PRESCALER__ IWDG prescaler value 212 | * @retval None 213 | */ 214 | #define IS_IWDG_PRESCALER(__PRESCALER__) (((__PRESCALER__) == IWDG_PRESCALER_4) || \ 215 | ((__PRESCALER__) == IWDG_PRESCALER_8) || \ 216 | ((__PRESCALER__) == IWDG_PRESCALER_16) || \ 217 | ((__PRESCALER__) == IWDG_PRESCALER_32) || \ 218 | ((__PRESCALER__) == IWDG_PRESCALER_64) || \ 219 | ((__PRESCALER__) == IWDG_PRESCALER_128)|| \ 220 | ((__PRESCALER__) == IWDG_PRESCALER_256)) 221 | 222 | /** 223 | * @brief Check IWDG reload value. 224 | * @param __RELOAD__ IWDG reload value 225 | * @retval None 226 | */ 227 | #define IS_IWDG_RELOAD(__RELOAD__) ((__RELOAD__) <= IWDG_RLR_RL) 228 | 229 | /** 230 | * @brief Check IWDG window value. 231 | * @param __WINDOW__ IWDG window value 232 | * @retval None 233 | */ 234 | #define IS_IWDG_WINDOW(__WINDOW__) ((__WINDOW__) <= IWDG_WINR_WIN) 235 | 236 | /** 237 | * @} 238 | */ 239 | 240 | /** 241 | * @} 242 | */ 243 | 244 | /** 245 | * @} 246 | */ 247 | 248 | 249 | #ifdef __cplusplus 250 | } 251 | #endif 252 | 253 | #endif /* __STM32F0xx_HAL_IWDG_H */ 254 | 255 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 256 | 257 | -------------------------------------------------------------------------------- /Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_pcd_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f0xx_hal_pcd_ex.h 4 | * @author MCD Application Team 5 | * @brief Header file of PCD HAL Extension module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© COPYRIGHT(c) 2016 STMicroelectronics

10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 19 | * may be used to endorse or promote products derived from this software 20 | * without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * 33 | ****************************************************************************** 34 | */ 35 | 36 | /* Define to prevent recursive inclusion -------------------------------------*/ 37 | #ifndef __STM32F0xx_HAL_PCD_EX_H 38 | #define __STM32F0xx_HAL_PCD_EX_H 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | #if defined(STM32F042x6) || defined(STM32F048xx) || defined(STM32F072xB) || defined(STM32F078xx)|| defined(STM32F070xB)|| defined(STM32F070x6) 45 | 46 | /* Includes ------------------------------------------------------------------*/ 47 | #include "stm32f0xx_hal_def.h" 48 | 49 | /** @addtogroup STM32F0xx_HAL_Driver 50 | * @{ 51 | */ 52 | 53 | /** @addtogroup PCDEx 54 | * @{ 55 | */ 56 | 57 | /* Exported types ------------------------------------------------------------*/ 58 | /* Exported constants --------------------------------------------------------*/ 59 | /* Exported macros -----------------------------------------------------------*/ 60 | /* Internal macros -----------------------------------------------------------*/ 61 | /* Exported functions --------------------------------------------------------*/ 62 | /** @addtogroup PCDEx_Exported_Functions PCDEx Exported Functions 63 | * @{ 64 | */ 65 | /** @addtogroup PCDEx_Exported_Functions_Group1 Peripheral Control functions 66 | * @{ 67 | */ 68 | HAL_StatusTypeDef HAL_PCDEx_PMAConfig(PCD_HandleTypeDef *hpcd, 69 | uint16_t ep_addr, 70 | uint16_t ep_kind, 71 | uint32_t pmaadress); 72 | /** 73 | * @} 74 | */ 75 | 76 | /** 77 | * @} 78 | */ 79 | 80 | /** 81 | * @} 82 | */ 83 | 84 | /** 85 | * @} 86 | */ 87 | 88 | #endif /* STM32F042x6 || STM32F072xB || STM32F078xx || STM32F070xB || STM32F070x6*/ 89 | 90 | #ifdef __cplusplus 91 | } 92 | #endif 93 | 94 | 95 | #endif /* __STM32F0xx_HAL_PCD_EX_H */ 96 | 97 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 98 | 99 | -------------------------------------------------------------------------------- /Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_pwr.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f0xx_hal_pwr.h 4 | * @author MCD Application Team 5 | * @brief Header file of PWR HAL module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© COPYRIGHT(c) 2016 STMicroelectronics

10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 19 | * may be used to endorse or promote products derived from this software 20 | * without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * 33 | ****************************************************************************** 34 | */ 35 | 36 | /* Define to prevent recursive inclusion -------------------------------------*/ 37 | #ifndef __STM32F0xx_HAL_PWR_H 38 | #define __STM32F0xx_HAL_PWR_H 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | /* Includes ------------------------------------------------------------------*/ 45 | #include "stm32f0xx_hal_def.h" 46 | 47 | /** @addtogroup STM32F0xx_HAL_Driver 48 | * @{ 49 | */ 50 | 51 | /** @addtogroup PWR PWR 52 | * @{ 53 | */ 54 | 55 | /* Exported types ------------------------------------------------------------*/ 56 | /* Exported constants --------------------------------------------------------*/ 57 | 58 | /** @defgroup PWR_Exported_Constants PWR Exported Constants 59 | * @{ 60 | */ 61 | 62 | /** @defgroup PWR_Regulator_state_in_STOP_mode PWR Regulator state in STOP mode 63 | * @{ 64 | */ 65 | #define PWR_MAINREGULATOR_ON (0x00000000U) 66 | #define PWR_LOWPOWERREGULATOR_ON PWR_CR_LPDS 67 | 68 | #define IS_PWR_REGULATOR(REGULATOR) (((REGULATOR) == PWR_MAINREGULATOR_ON) || \ 69 | ((REGULATOR) == PWR_LOWPOWERREGULATOR_ON)) 70 | /** 71 | * @} 72 | */ 73 | 74 | /** @defgroup PWR_SLEEP_mode_entry PWR SLEEP mode entry 75 | * @{ 76 | */ 77 | #define PWR_SLEEPENTRY_WFI ((uint8_t)0x01U) 78 | #define PWR_SLEEPENTRY_WFE ((uint8_t)0x02U) 79 | #define IS_PWR_SLEEP_ENTRY(ENTRY) (((ENTRY) == PWR_SLEEPENTRY_WFI) || ((ENTRY) == PWR_SLEEPENTRY_WFE)) 80 | /** 81 | * @} 82 | */ 83 | 84 | /** @defgroup PWR_STOP_mode_entry PWR STOP mode entry 85 | * @{ 86 | */ 87 | #define PWR_STOPENTRY_WFI ((uint8_t)0x01U) 88 | #define PWR_STOPENTRY_WFE ((uint8_t)0x02U) 89 | #define IS_PWR_STOP_ENTRY(ENTRY) (((ENTRY) == PWR_STOPENTRY_WFI) || ((ENTRY) == PWR_STOPENTRY_WFE)) 90 | /** 91 | * @} 92 | */ 93 | 94 | 95 | /** 96 | * @} 97 | */ 98 | 99 | /* Exported macro ------------------------------------------------------------*/ 100 | /** @defgroup PWR_Exported_Macro PWR Exported Macro 101 | * @{ 102 | */ 103 | 104 | /** @brief Check PWR flag is set or not. 105 | * @param __FLAG__ specifies the flag to check. 106 | * This parameter can be one of the following values: 107 | * @arg PWR_FLAG_WU: Wake Up flag. This flag indicates that a wakeup event 108 | * was received from the WKUP pin or from the RTC alarm (Alarm A), 109 | * RTC Tamper event, RTC TimeStamp event or RTC Wakeup. 110 | * An additional wakeup event is detected if the WKUP pin is enabled 111 | * (by setting the EWUP bit) when the WKUP pin level is already high. 112 | * @arg PWR_FLAG_SB: StandBy flag. This flag indicates that the system was 113 | * resumed from StandBy mode. 114 | * @arg PWR_FLAG_PVDO: PVD Output. This flag is valid only if PVD is enabled 115 | * by the HAL_PWR_EnablePVD() function. The PVD is stopped by Standby mode 116 | * For this reason, this bit is equal to 0 after Standby or reset 117 | * until the PVDE bit is set. 118 | * Warning: this Flag is not available on STM32F030x8 products 119 | * @arg PWR_FLAG_VREFINTRDY: This flag indicates that the internal reference 120 | * voltage VREFINT is ready. 121 | * Warning: this Flag is not available on STM32F030x8 products 122 | * @retval The new state of __FLAG__ (TRUE or FALSE). 123 | */ 124 | #define __HAL_PWR_GET_FLAG(__FLAG__) ((PWR->CSR & (__FLAG__)) == (__FLAG__)) 125 | 126 | /** @brief Clear the PWR's pending flags. 127 | * @param __FLAG__ specifies the flag to clear. 128 | * This parameter can be one of the following values: 129 | * @arg PWR_FLAG_WU: Wake Up flag 130 | * @arg PWR_FLAG_SB: StandBy flag 131 | */ 132 | #define __HAL_PWR_CLEAR_FLAG(__FLAG__) (PWR->CR |= (__FLAG__) << 2U) 133 | 134 | 135 | /** 136 | * @} 137 | */ 138 | 139 | /* Include PWR HAL Extension module */ 140 | #include "stm32f0xx_hal_pwr_ex.h" 141 | 142 | /* Exported functions --------------------------------------------------------*/ 143 | 144 | /** @addtogroup PWR_Exported_Functions PWR Exported Functions 145 | * @{ 146 | */ 147 | 148 | /** @addtogroup PWR_Exported_Functions_Group1 Initialization and de-initialization functions 149 | * @{ 150 | */ 151 | 152 | /* Initialization and de-initialization functions *****************************/ 153 | void HAL_PWR_DeInit(void); 154 | 155 | /** 156 | * @} 157 | */ 158 | 159 | /** @addtogroup PWR_Exported_Functions_Group2 Peripheral Control functions 160 | * @{ 161 | */ 162 | 163 | /* Peripheral Control functions **********************************************/ 164 | void HAL_PWR_EnableBkUpAccess(void); 165 | void HAL_PWR_DisableBkUpAccess(void); 166 | 167 | /* WakeUp pins configuration functions ****************************************/ 168 | void HAL_PWR_EnableWakeUpPin(uint32_t WakeUpPinx); 169 | void HAL_PWR_DisableWakeUpPin(uint32_t WakeUpPinx); 170 | 171 | /* Low Power modes configuration functions ************************************/ 172 | void HAL_PWR_EnterSTOPMode(uint32_t Regulator, uint8_t STOPEntry); 173 | void HAL_PWR_EnterSLEEPMode(uint32_t Regulator, uint8_t SLEEPEntry); 174 | void HAL_PWR_EnterSTANDBYMode(void); 175 | 176 | void HAL_PWR_EnableSleepOnExit(void); 177 | void HAL_PWR_DisableSleepOnExit(void); 178 | void HAL_PWR_EnableSEVOnPend(void); 179 | void HAL_PWR_DisableSEVOnPend(void); 180 | 181 | /** 182 | * @} 183 | */ 184 | 185 | /** 186 | * @} 187 | */ 188 | 189 | /** 190 | * @} 191 | */ 192 | 193 | /** 194 | * @} 195 | */ 196 | 197 | #ifdef __cplusplus 198 | } 199 | #endif 200 | 201 | 202 | #endif /* __STM32F0xx_HAL_PWR_H */ 203 | 204 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 205 | 206 | -------------------------------------------------------------------------------- /Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_iwdg.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f0xx_hal_iwdg.c 4 | * @author MCD Application Team 5 | * @brief IWDG HAL module driver. 6 | * This file provides firmware functions to manage the following 7 | * functionalities of the Independent Watchdog (IWDG) peripheral: 8 | * + Initialization and Start functions 9 | * + IO operation functions 10 | * 11 | @verbatim 12 | ============================================================================== 13 | ##### IWDG Generic features ##### 14 | ============================================================================== 15 | [..] 16 | (+) The IWDG can be started by either software or hardware (configurable 17 | through option byte). 18 | 19 | (+) The IWDG is clocked by Low-Speed clock (LSI) and thus stays active even 20 | if the main clock fails. 21 | 22 | (+) Once the IWDG is started, the LSI is forced ON and both can not be 23 | disabled. The counter starts counting down from the reset value (0xFFF). 24 | When it reaches the end of count value (0x000) a reset signal is 25 | generated (IWDG reset). 26 | 27 | (+) Whenever the key value 0x0000 AAAA is written in the IWDG_KR register, 28 | the IWDG_RLR value is reloaded in the counter and the watchdog reset is 29 | prevented. 30 | 31 | (+) The IWDG is implemented in the VDD voltage domain that is still functional 32 | in STOP and STANDBY mode (IWDG reset can wake-up from STANDBY). 33 | IWDGRST flag in RCC_CSR register can be used to inform when an IWDG 34 | reset occurs. 35 | 36 | (+) Debug mode : When the microcontroller enters debug mode (core halted), 37 | the IWDG counter either continues to work normally or stops, depending 38 | on DBG_IWDG_STOP configuration bit in DBG module, accessible through 39 | __HAL_DBGMCU_FREEZE_IWDG() and __HAL_DBGMCU_UNFREEZE_IWDG() macros 40 | 41 | [..] Min-max timeout value @40KHz (LSI): ~0.1ms / ~26.2s 42 | The IWDG timeout may vary due to LSI frequency dispersion. STM32F0xx 43 | devices provide the capability to measure the LSI frequency (LSI clock 44 | connected internally to TIM16 CH1 input capture). The measured value 45 | can be used to have an IWDG timeout with an acceptable accuracy. 46 | 47 | ##### How to use this driver ##### 48 | ============================================================================== 49 | [..] 50 | (#) Use IWDG using HAL_IWDG_Init() function to : 51 | (++) Enable instance by writing Start keyword in IWDG_KEY register. LSI 52 | clock is forced ON and IWDG counter starts downcounting. 53 | (++) Enable write access to configuration register: IWDG_PR, IWDG_RLR & 54 | IWDG_WINR. 55 | (++) Configure the IWDG prescaler and counter reload value. This reload 56 | value will be loaded in the IWDG counter each time the watchdog is 57 | reloaded, then the IWDG will start counting down from this value. 58 | (++) wait for status flags to be reset" 59 | (++) Depending on window parameter: 60 | (+++) If Window Init parameter is same as Window register value, 61 | nothing more is done but reload counter value in order to exit 62 | function withy exact time base. 63 | (+++) Else modify Window register. This will automatically reload 64 | watchdog counter. 65 | 66 | (#) Then the application program must refresh the IWDG counter at regular 67 | intervals during normal operation to prevent an MCU reset, using 68 | HAL_IWDG_Refresh() function. 69 | 70 | *** IWDG HAL driver macros list *** 71 | ==================================== 72 | [..] 73 | Below the list of most used macros in IWDG HAL driver: 74 | (+) __HAL_IWDG_START: Enable the IWDG peripheral 75 | (+) __HAL_IWDG_RELOAD_COUNTER: Reloads IWDG counter with value defined in 76 | the reload register 77 | 78 | @endverbatim 79 | ****************************************************************************** 80 | * @attention 81 | * 82 | *

© COPYRIGHT(c) 2016 STMicroelectronics

83 | * 84 | * Redistribution and use in source and binary forms, with or without modification, 85 | * are permitted provided that the following conditions are met: 86 | * 1. Redistributions of source code must retain the above copyright notice, 87 | * this list of conditions and the following disclaimer. 88 | * 2. Redistributions in binary form must reproduce the above copyright notice, 89 | * this list of conditions and the following disclaimer in the documentation 90 | * and/or other materials provided with the distribution. 91 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 92 | * may be used to endorse or promote products derived from this software 93 | * without specific prior written permission. 94 | * 95 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 96 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 97 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 98 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 99 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 100 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 101 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 102 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 103 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 104 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 105 | * 106 | ****************************************************************************** 107 | */ 108 | 109 | /* Includes ------------------------------------------------------------------*/ 110 | #include "stm32f0xx_hal.h" 111 | 112 | /** @addtogroup STM32F0xx_HAL_Driver 113 | * @{ 114 | */ 115 | 116 | #ifdef HAL_IWDG_MODULE_ENABLED 117 | /** @addtogroup IWDG 118 | * @brief IWDG HAL module driver. 119 | * @{ 120 | */ 121 | 122 | /* Private typedef -----------------------------------------------------------*/ 123 | /* Private define ------------------------------------------------------------*/ 124 | /** @defgroup IWDG_Private_Defines IWDG Private Defines 125 | * @{ 126 | */ 127 | /* Status register need 5 RC LSI divided by prescaler clock to be updated. With 128 | higher prescaler (256), and according to LSI variation, we need to wait at 129 | least 6 cycles so 39 ms. */ 130 | #define HAL_IWDG_DEFAULT_TIMEOUT 39U 131 | /** 132 | * @} 133 | */ 134 | 135 | /* Private macro -------------------------------------------------------------*/ 136 | /* Private variables ---------------------------------------------------------*/ 137 | /* Private function prototypes -----------------------------------------------*/ 138 | /* Exported functions --------------------------------------------------------*/ 139 | 140 | /** @addtogroup IWDG_Exported_Functions 141 | * @{ 142 | */ 143 | 144 | /** @addtogroup IWDG_Exported_Functions_Group1 145 | * @brief Initialization and Start functions. 146 | * 147 | @verbatim 148 | =============================================================================== 149 | ##### Initialization and Start functions ##### 150 | =============================================================================== 151 | [..] This section provides functions allowing to: 152 | (+) Initialize the IWDG according to the specified parameters in the 153 | IWDG_InitTypeDef of associated handle. 154 | (+) Manage Window option. 155 | (+) Once initialization is performed in HAL_IWDG_Init function, Watchdog 156 | is reloaded in order to exit function with correct time base. 157 | 158 | @endverbatim 159 | * @{ 160 | */ 161 | 162 | /** 163 | * @brief Initialize the IWDG according to the specified parameters in the 164 | * IWDG_InitTypeDef and start watchdog. Before exiting function, 165 | * watchdog is refreshed in order to have correct time base. 166 | * @param hiwdg pointer to a IWDG_HandleTypeDef structure that contains 167 | * the configuration information for the specified IWDG module. 168 | * @retval HAL status 169 | */ 170 | HAL_StatusTypeDef HAL_IWDG_Init(IWDG_HandleTypeDef *hiwdg) 171 | { 172 | uint32_t tickstart; 173 | 174 | /* Check the IWDG handle allocation */ 175 | if(hiwdg == NULL) 176 | { 177 | return HAL_ERROR; 178 | } 179 | 180 | /* Check the parameters */ 181 | assert_param(IS_IWDG_ALL_INSTANCE(hiwdg->Instance)); 182 | assert_param(IS_IWDG_PRESCALER(hiwdg->Init.Prescaler)); 183 | assert_param(IS_IWDG_RELOAD(hiwdg->Init.Reload)); 184 | assert_param(IS_IWDG_WINDOW(hiwdg->Init.Window)); 185 | 186 | /* Enable IWDG. LSI is turned on automaticaly */ 187 | __HAL_IWDG_START(hiwdg); 188 | 189 | /* Enable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers by writing 190 | 0x5555 in KR */ 191 | IWDG_ENABLE_WRITE_ACCESS(hiwdg); 192 | 193 | /* Write to IWDG registers the Prescaler & Reload values to work with */ 194 | hiwdg->Instance->PR = hiwdg->Init.Prescaler; 195 | hiwdg->Instance->RLR = hiwdg->Init.Reload; 196 | 197 | /* Check pending flag, if previous update not done, return timeout */ 198 | tickstart = HAL_GetTick(); 199 | 200 | /* Wait for register to be updated */ 201 | while(hiwdg->Instance->SR != RESET) 202 | { 203 | if((HAL_GetTick() - tickstart ) > HAL_IWDG_DEFAULT_TIMEOUT) 204 | { 205 | return HAL_TIMEOUT; 206 | } 207 | } 208 | 209 | /* If window parameter is different than current value, modify window 210 | register */ 211 | if(hiwdg->Instance->WINR != hiwdg->Init.Window) 212 | { 213 | /* Write to IWDG WINR the IWDG_Window value to compare with. In any case, 214 | even if window feature is disabled, Watchdog will be reloaded by writing 215 | windows register */ 216 | hiwdg->Instance->WINR = hiwdg->Init.Window; 217 | } 218 | else 219 | { 220 | /* Reload IWDG counter with value defined in the reload register */ 221 | __HAL_IWDG_RELOAD_COUNTER(hiwdg); 222 | } 223 | 224 | /* Return function status */ 225 | return HAL_OK; 226 | } 227 | 228 | /** 229 | * @} 230 | */ 231 | 232 | 233 | /** @addtogroup IWDG_Exported_Functions_Group2 234 | * @brief IO operation functions 235 | * 236 | @verbatim 237 | =============================================================================== 238 | ##### IO operation functions ##### 239 | =============================================================================== 240 | [..] This section provides functions allowing to: 241 | (+) Refresh the IWDG. 242 | 243 | @endverbatim 244 | * @{ 245 | */ 246 | 247 | 248 | /** 249 | * @brief Refresh the IWDG. 250 | * @param hiwdg pointer to a IWDG_HandleTypeDef structure that contains 251 | * the configuration information for the specified IWDG module. 252 | * @retval HAL status 253 | */ 254 | HAL_StatusTypeDef HAL_IWDG_Refresh(IWDG_HandleTypeDef *hiwdg) 255 | { 256 | /* Reload IWDG counter with value defined in the reload register */ 257 | __HAL_IWDG_RELOAD_COUNTER(hiwdg); 258 | 259 | /* Return function status */ 260 | return HAL_OK; 261 | } 262 | 263 | /** 264 | * @} 265 | */ 266 | 267 | /** 268 | * @} 269 | */ 270 | 271 | #endif /* HAL_IWDG_MODULE_ENABLED */ 272 | /** 273 | * @} 274 | */ 275 | 276 | /** 277 | * @} 278 | */ 279 | 280 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 281 | -------------------------------------------------------------------------------- /Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_pcd_ex.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f0xx_hal_pcd_ex.c 4 | * @author MCD Application Team 5 | * @brief Extended PCD HAL module driver. 6 | * This file provides firmware functions to manage the following 7 | * functionalities of the USB Peripheral Controller: 8 | * + Configuration of the PMA for EP 9 | * 10 | ****************************************************************************** 11 | * @attention 12 | * 13 | *

© COPYRIGHT(c) 2016 STMicroelectronics

14 | * 15 | * Redistribution and use in source and binary forms, with or without modification, 16 | * are permitted provided that the following conditions are met: 17 | * 1. Redistributions of source code must retain the above copyright notice, 18 | * this list of conditions and the following disclaimer. 19 | * 2. Redistributions in binary form must reproduce the above copyright notice, 20 | * this list of conditions and the following disclaimer in the documentation 21 | * and/or other materials provided with the distribution. 22 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 23 | * may be used to endorse or promote products derived from this software 24 | * without specific prior written permission. 25 | * 26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 27 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 30 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 32 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 33 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 34 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 35 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | ****************************************************************************** 38 | */ 39 | 40 | /* Includes ------------------------------------------------------------------*/ 41 | #include "stm32f0xx_hal.h" 42 | 43 | #ifdef HAL_PCD_MODULE_ENABLED 44 | 45 | #if defined(STM32F042x6) || defined(STM32F048xx) || defined(STM32F072xB) || defined(STM32F078xx) || defined(STM32F070xB)|| defined(STM32F070x6) 46 | 47 | /** @addtogroup STM32F0xx_HAL_Driver 48 | * @{ 49 | */ 50 | 51 | /** @defgroup PCDEx PCDEx 52 | * @brief PCD Extended HAL module driver 53 | * @{ 54 | */ 55 | 56 | /* Private typedef -----------------------------------------------------------*/ 57 | /* Private define ------------------------------------------------------------*/ 58 | /* Private macro -------------------------------------------------------------*/ 59 | /* Private variables ---------------------------------------------------------*/ 60 | /* Private function prototypes -----------------------------------------------*/ 61 | /* Exported functions ---------------------------------------------------------*/ 62 | /** @defgroup PCDEx_Exported_Functions PCDEx Exported Functions 63 | * @{ 64 | */ 65 | 66 | /** @defgroup PCDEx_Exported_Functions_Group1 Peripheral Control functions 67 | * @brief PCDEx control functions 68 | * 69 | @verbatim 70 | =============================================================================== 71 | ##### Extended Peripheral Control functions ##### 72 | =============================================================================== 73 | [..] This section provides functions allowing to: 74 | (+) Update PMA configuration 75 | 76 | @endverbatim 77 | * @{ 78 | */ 79 | 80 | /** 81 | * @brief Configure PMA for EP 82 | * @param hpcd PCD handle 83 | * @param ep_addr endpoint address 84 | * @param ep_kind endpoint Kind 85 | * @arg USB_SNG_BUF: Single Buffer used 86 | * @arg USB_DBL_BUF: Double Buffer used 87 | * @param pmaadress EP address in The PMA: In case of single buffer endpoint 88 | * this parameter is 16-bit value providing the address 89 | * in PMA allocated to endpoint. 90 | * In case of double buffer endpoint this parameter 91 | * is a 32-bit value providing the endpoint buffer 0 address 92 | * in the LSB part of 32-bit value and endpoint buffer 1 address 93 | * in the MSB part of 32-bit value. 94 | * @retval : status 95 | */ 96 | 97 | HAL_StatusTypeDef HAL_PCDEx_PMAConfig(PCD_HandleTypeDef *hpcd, 98 | uint16_t ep_addr, 99 | uint16_t ep_kind, 100 | uint32_t pmaadress) 101 | 102 | { 103 | PCD_EPTypeDef *ep; 104 | 105 | /* initialize ep structure*/ 106 | if ((0x80U & ep_addr) == 0x80U) 107 | { 108 | ep = &hpcd->IN_ep[ep_addr & 0x7FU]; 109 | } 110 | else 111 | { 112 | ep = &hpcd->OUT_ep[ep_addr]; 113 | } 114 | 115 | /* Here we check if the endpoint is single or double Buffer*/ 116 | if (ep_kind == PCD_SNG_BUF) 117 | { 118 | /*Single Buffer*/ 119 | ep->doublebuffer = 0U; 120 | /*Configure the PMA*/ 121 | ep->pmaadress = (uint16_t)pmaadress; 122 | } 123 | else /*USB_DBL_BUF*/ 124 | { 125 | /*Double Buffer Endpoint*/ 126 | ep->doublebuffer = 1U; 127 | /*Configure the PMA*/ 128 | ep->pmaaddr0 = pmaadress & 0xFFFFU; 129 | ep->pmaaddr1 = (pmaadress & 0xFFFF0000U) >> 16U; 130 | } 131 | 132 | return HAL_OK; 133 | } 134 | /** 135 | * @} 136 | */ 137 | 138 | /** 139 | * @} 140 | */ 141 | 142 | /** 143 | * @} 144 | */ 145 | 146 | /** 147 | * @} 148 | */ 149 | 150 | #endif /* STM32F042x6 || STM32F072xB || STM32F078xx || STM32F070xB || STM32F070x6 */ 151 | 152 | #endif /* HAL_PCD_MODULE_ENABLED */ 153 | 154 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 155 | -------------------------------------------------------------------------------- /Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_pwr_ex.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f0xx_hal_pwr_ex.c 4 | * @author MCD Application Team 5 | * @brief Extended PWR HAL module driver. 6 | * This file provides firmware functions to manage the following 7 | * functionalities of the Power Controller (PWR) peripheral: 8 | * + Extended Initialization and de-initialization functions 9 | * + Extended Peripheral Control functions 10 | * 11 | ****************************************************************************** 12 | * @attention 13 | * 14 | *

© COPYRIGHT(c) 2016 STMicroelectronics

15 | * 16 | * Redistribution and use in source and binary forms, with or without modification, 17 | * are permitted provided that the following conditions are met: 18 | * 1. Redistributions of source code must retain the above copyright notice, 19 | * this list of conditions and the following disclaimer. 20 | * 2. Redistributions in binary form must reproduce the above copyright notice, 21 | * this list of conditions and the following disclaimer in the documentation 22 | * and/or other materials provided with the distribution. 23 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 24 | * may be used to endorse or promote products derived from this software 25 | * without specific prior written permission. 26 | * 27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 28 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 29 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 30 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 31 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 32 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 33 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 34 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 35 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 | * 38 | ****************************************************************************** 39 | */ 40 | 41 | /* Includes ------------------------------------------------------------------*/ 42 | #include "stm32f0xx_hal.h" 43 | 44 | /** @addtogroup STM32F0xx_HAL_Driver 45 | * @{ 46 | */ 47 | 48 | /** @defgroup PWREx PWREx 49 | * @brief PWREx HAL module driver 50 | * @{ 51 | */ 52 | 53 | #ifdef HAL_PWR_MODULE_ENABLED 54 | 55 | /* Private typedef -----------------------------------------------------------*/ 56 | /* Private define ------------------------------------------------------------*/ 57 | /** @defgroup PWREx_Private_Constants PWREx Private Constants 58 | * @{ 59 | */ 60 | #define PVD_MODE_IT (0x00010000U) 61 | #define PVD_MODE_EVT (0x00020000U) 62 | #define PVD_RISING_EDGE (0x00000001U) 63 | #define PVD_FALLING_EDGE (0x00000002U) 64 | /** 65 | * @} 66 | */ 67 | 68 | /* Private macro -------------------------------------------------------------*/ 69 | /* Private variables ---------------------------------------------------------*/ 70 | /* Private function prototypes -----------------------------------------------*/ 71 | /* Exported functions ---------------------------------------------------------*/ 72 | 73 | /** @defgroup PWREx_Exported_Functions PWREx Exported Functions 74 | * @{ 75 | */ 76 | 77 | /** @defgroup PWREx_Exported_Functions_Group1 Peripheral Extended Control Functions 78 | * @brief Extended Peripheral Control functions 79 | * 80 | @verbatim 81 | 82 | =============================================================================== 83 | ##### Peripheral extended control functions ##### 84 | =============================================================================== 85 | 86 | *** PVD configuration *** 87 | ========================= 88 | [..] 89 | (+) The PVD is used to monitor the VDD power supply by comparing it to a 90 | threshold selected by the PVD Level (PLS[2:0] bits in the PWR_CR). 91 | (+) A PVDO flag is available to indicate if VDD/VDDA is higher or lower 92 | than the PVD threshold. This event is internally connected to the EXTI 93 | line16 and can generate an interrupt if enabled. This is done through 94 | HAL_PWR_ConfigPVD(), HAL_PWR_EnablePVD() functions. 95 | (+) The PVD is stopped in Standby mode. 96 | -@- PVD is not available on STM32F030x4/x6/x8 97 | 98 | *** VDDIO2 Monitor Configuration *** 99 | ==================================== 100 | [..] 101 | (+) VDDIO2 monitor is used to monitor the VDDIO2 power supply by comparing it 102 | to VREFInt Voltage 103 | (+) This monitor is internally connected to the EXTI line31 104 | and can generate an interrupt if enabled. This is done through 105 | HAL_PWREx_EnableVddio2Monitor() function. 106 | -@- VDDIO2 is available on STM32F07x/09x/04x 107 | 108 | @endverbatim 109 | * @{ 110 | */ 111 | 112 | #if defined (STM32F031x6) || defined (STM32F051x8) || \ 113 | defined (STM32F071xB) || defined (STM32F091xC) || \ 114 | defined (STM32F042x6) || defined (STM32F072xB) 115 | /** 116 | * @brief Configures the voltage threshold detected by the Power Voltage Detector(PVD). 117 | * @param sConfigPVD pointer to an PWR_PVDTypeDef structure that contains the configuration 118 | * information for the PVD. 119 | * @note Refer to the electrical characteristics of your device datasheet for 120 | * more details about the voltage threshold corresponding to each 121 | * detection level. 122 | * @retval None 123 | */ 124 | void HAL_PWR_ConfigPVD(PWR_PVDTypeDef *sConfigPVD) 125 | { 126 | /* Check the parameters */ 127 | assert_param(IS_PWR_PVD_LEVEL(sConfigPVD->PVDLevel)); 128 | assert_param(IS_PWR_PVD_MODE(sConfigPVD->Mode)); 129 | 130 | /* Set PLS[7:5] bits according to PVDLevel value */ 131 | MODIFY_REG(PWR->CR, PWR_CR_PLS, sConfigPVD->PVDLevel); 132 | 133 | /* Clear any previous config. Keep it clear if no event or IT mode is selected */ 134 | __HAL_PWR_PVD_EXTI_DISABLE_EVENT(); 135 | __HAL_PWR_PVD_EXTI_DISABLE_IT(); 136 | __HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE();__HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE(); 137 | 138 | /* Configure interrupt mode */ 139 | if((sConfigPVD->Mode & PVD_MODE_IT) == PVD_MODE_IT) 140 | { 141 | __HAL_PWR_PVD_EXTI_ENABLE_IT(); 142 | } 143 | 144 | /* Configure event mode */ 145 | if((sConfigPVD->Mode & PVD_MODE_EVT) == PVD_MODE_EVT) 146 | { 147 | __HAL_PWR_PVD_EXTI_ENABLE_EVENT(); 148 | } 149 | 150 | /* Configure the edge */ 151 | if((sConfigPVD->Mode & PVD_RISING_EDGE) == PVD_RISING_EDGE) 152 | { 153 | __HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE(); 154 | } 155 | 156 | if((sConfigPVD->Mode & PVD_FALLING_EDGE) == PVD_FALLING_EDGE) 157 | { 158 | __HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE(); 159 | } 160 | } 161 | 162 | /** 163 | * @brief Enables the Power Voltage Detector(PVD). 164 | * @retval None 165 | */ 166 | void HAL_PWR_EnablePVD(void) 167 | { 168 | PWR->CR |= (uint32_t)PWR_CR_PVDE; 169 | } 170 | 171 | /** 172 | * @brief Disables the Power Voltage Detector(PVD). 173 | * @retval None 174 | */ 175 | void HAL_PWR_DisablePVD(void) 176 | { 177 | PWR->CR &= ~((uint32_t)PWR_CR_PVDE); 178 | } 179 | 180 | /** 181 | * @brief This function handles the PWR PVD interrupt request. 182 | * @note This API should be called under the PVD_IRQHandler() or PVD_VDDIO2_IRQHandler(). 183 | * @retval None 184 | */ 185 | void HAL_PWR_PVD_IRQHandler(void) 186 | { 187 | /* Check PWR exti flag */ 188 | if(__HAL_PWR_PVD_EXTI_GET_FLAG() != RESET) 189 | { 190 | /* PWR PVD interrupt user callback */ 191 | HAL_PWR_PVDCallback(); 192 | 193 | /* Clear PWR Exti pending bit */ 194 | __HAL_PWR_PVD_EXTI_CLEAR_FLAG(); 195 | } 196 | } 197 | 198 | /** 199 | * @brief PWR PVD interrupt callback 200 | * @retval None 201 | */ 202 | __weak void HAL_PWR_PVDCallback(void) 203 | { 204 | /* NOTE : This function Should not be modified, when the callback is needed, 205 | the HAL_PWR_PVDCallback could be implemented in the user file 206 | */ 207 | } 208 | 209 | #endif /* defined (STM32F031x6) || defined (STM32F051x8) || */ 210 | /* defined (STM32F071xB) || defined (STM32F091xC) || */ 211 | /* defined (STM32F042x6) || defined (STM32F072xB) */ 212 | 213 | #if defined (STM32F042x6) || defined (STM32F048xx) || \ 214 | defined (STM32F071xB) || defined (STM32F072xB) || defined (STM32F078xx) || \ 215 | defined (STM32F091xC) || defined (STM32F098xx) 216 | /** 217 | * @brief Enable VDDIO2 monitor: enable Exti 31 and falling edge detection. 218 | * @note If Exti 31 is enable correlty and VDDIO2 voltage goes below Vrefint, 219 | an interrupt is generated Irq line 1. 220 | NVIS has to be enable by user. 221 | * @retval None 222 | */ 223 | void HAL_PWREx_EnableVddio2Monitor(void) 224 | { 225 | __HAL_PWR_VDDIO2_EXTI_ENABLE_IT(); 226 | __HAL_PWR_VDDIO2_EXTI_ENABLE_FALLING_EDGE(); 227 | } 228 | 229 | /** 230 | * @brief Disable the Vddio2 Monitor. 231 | * @retval None 232 | */ 233 | void HAL_PWREx_DisableVddio2Monitor(void) 234 | { 235 | __HAL_PWR_VDDIO2_EXTI_DISABLE_IT(); 236 | __HAL_PWR_VDDIO2_EXTI_DISABLE_FALLING_EDGE(); 237 | 238 | } 239 | 240 | /** 241 | * @brief This function handles the PWR Vddio2 monitor interrupt request. 242 | * @note This API should be called under the VDDIO2_IRQHandler() PVD_VDDIO2_IRQHandler(). 243 | * @retval None 244 | */ 245 | void HAL_PWREx_Vddio2Monitor_IRQHandler(void) 246 | { 247 | /* Check PWR exti flag */ 248 | if(__HAL_PWR_VDDIO2_EXTI_GET_FLAG() != RESET) 249 | { 250 | /* PWR Vddio2 monitor interrupt user callback */ 251 | HAL_PWREx_Vddio2MonitorCallback(); 252 | 253 | /* Clear PWR Exti pending bit */ 254 | __HAL_PWR_VDDIO2_EXTI_CLEAR_FLAG(); 255 | } 256 | } 257 | 258 | /** 259 | * @brief PWR Vddio2 Monitor interrupt callback 260 | * @retval None 261 | */ 262 | __weak void HAL_PWREx_Vddio2MonitorCallback(void) 263 | { 264 | /* NOTE : This function Should not be modified, when the callback is needed, 265 | the HAL_PWREx_Vddio2MonitorCallback could be implemented in the user file 266 | */ 267 | } 268 | 269 | #endif /* defined (STM32F042x6) || defined (STM32F048xx) || \ 270 | defined (STM32F071xB) || defined (STM32F072xB) || defined (STM32F078xx) || \ 271 | defined (STM32F091xC) || defined (STM32F098xx) */ 272 | 273 | /** 274 | * @} 275 | */ 276 | 277 | /** 278 | * @} 279 | */ 280 | 281 | #endif /* HAL_PWR_MODULE_ENABLED */ 282 | /** 283 | * @} 284 | */ 285 | 286 | /** 287 | * @} 288 | */ 289 | 290 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 291 | -------------------------------------------------------------------------------- /Inc/main.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file : main.h 4 | * @brief : Header for main.c file. 5 | * This file contains the common defines of the application. 6 | ****************************************************************************** 7 | * This notice applies to any and all portions of this file 8 | * that are not between comment pairs USER CODE BEGIN and 9 | * USER CODE END. Other portions of this file, whether 10 | * inserted by the user or by software development tools 11 | * are owned by their respective copyright owners. 12 | * 13 | * Copyright (c) 2018 STMicroelectronics International N.V. 14 | * All rights reserved. 15 | * 16 | * Redistribution and use in source and binary forms, with or without 17 | * modification, are permitted, provided that the following conditions are met: 18 | * 19 | * 1. Redistribution of source code must retain the above copyright notice, 20 | * this list of conditions and the following disclaimer. 21 | * 2. Redistributions in binary form must reproduce the above copyright notice, 22 | * this list of conditions and the following disclaimer in the documentation 23 | * and/or other materials provided with the distribution. 24 | * 3. Neither the name of STMicroelectronics nor the names of other 25 | * contributors to this software may be used to endorse or promote products 26 | * derived from this software without specific written permission. 27 | * 4. This software, including modifications and/or derivative works of this 28 | * software, must execute solely and exclusively on microcontroller or 29 | * microprocessor devices manufactured by or for STMicroelectronics. 30 | * 5. Redistribution and use of this software other than as permitted under 31 | * this license is void and will automatically terminate your rights under 32 | * this license. 33 | * 34 | * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" 35 | * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT 36 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 37 | * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY 38 | * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT 39 | * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 40 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 41 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 42 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 43 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 44 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 45 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 46 | * 47 | ****************************************************************************** 48 | */ 49 | 50 | /* Define to prevent recursive inclusion -------------------------------------*/ 51 | #ifndef __MAIN_H__ 52 | #define __MAIN_H__ 53 | 54 | /* Includes ------------------------------------------------------------------*/ 55 | 56 | /* USER CODE BEGIN Includes */ 57 | 58 | /* USER CODE END Includes */ 59 | 60 | /* Private define ------------------------------------------------------------*/ 61 | 62 | #define CAN_MOD_Pin GPIO_PIN_0 63 | #define CAN_MOD_GPIO_Port GPIOF 64 | 65 | /* ########################## Assert Selection ############################## */ 66 | /** 67 | * @brief Uncomment the line below to expanse the "assert_param" macro in the 68 | * HAL drivers code 69 | */ 70 | /* #define USE_FULL_ASSERT 1U */ 71 | 72 | /* USER CODE BEGIN Private defines */ 73 | 74 | /* USER CODE END Private defines */ 75 | 76 | #ifdef __cplusplus 77 | extern "C" { 78 | #endif 79 | void _Error_Handler(char *, int); 80 | 81 | #define Error_Handler() _Error_Handler(__FILE__, __LINE__) 82 | #ifdef __cplusplus 83 | } 84 | #endif 85 | 86 | #endif /* __MAIN_H__ */ 87 | 88 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 89 | -------------------------------------------------------------------------------- /Inc/stm32f0xx_it.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f0xx_it.h 4 | * @brief This file contains the headers of the interrupt handlers. 5 | ****************************************************************************** 6 | * 7 | * COPYRIGHT(c) 2018 STMicroelectronics 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 1. Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 17 | * may be used to endorse or promote products derived from this software 18 | * without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | ****************************************************************************** 32 | */ 33 | 34 | /* Define to prevent recursive inclusion -------------------------------------*/ 35 | #ifndef __STM32F0xx_IT_H 36 | #define __STM32F0xx_IT_H 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | /* Includes ------------------------------------------------------------------*/ 43 | #include "stm32f0xx_hal.h" 44 | #include "main.h" 45 | /* Exported types ------------------------------------------------------------*/ 46 | /* Exported constants --------------------------------------------------------*/ 47 | /* Exported macro ------------------------------------------------------------*/ 48 | /* Exported functions ------------------------------------------------------- */ 49 | 50 | void NMI_Handler(void); 51 | void HardFault_Handler(void); 52 | void SVC_Handler(void); 53 | void PendSV_Handler(void); 54 | void SysTick_Handler(void); 55 | void USB_IRQHandler(void); 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | 61 | #endif /* __STM32F0xx_IT_H */ 62 | 63 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 64 | -------------------------------------------------------------------------------- /Inc/usb_device.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file : usb_device.h 4 | * @version : v2.0_Cube 5 | * @brief : Header for usb_device.c file. 6 | ****************************************************************************** 7 | * This notice applies to any and all portions of this file 8 | * that are not between comment pairs USER CODE BEGIN and 9 | * USER CODE END. Other portions of this file, whether 10 | * inserted by the user or by software development tools 11 | * are owned by their respective copyright owners. 12 | * 13 | * Copyright (c) 2018 STMicroelectronics International N.V. 14 | * All rights reserved. 15 | * 16 | * Redistribution and use in source and binary forms, with or without 17 | * modification, are permitted, provided that the following conditions are met: 18 | * 19 | * 1. Redistribution of source code must retain the above copyright notice, 20 | * this list of conditions and the following disclaimer. 21 | * 2. Redistributions in binary form must reproduce the above copyright notice, 22 | * this list of conditions and the following disclaimer in the documentation 23 | * and/or other materials provided with the distribution. 24 | * 3. Neither the name of STMicroelectronics nor the names of other 25 | * contributors to this software may be used to endorse or promote products 26 | * derived from this software without specific written permission. 27 | * 4. This software, including modifications and/or derivative works of this 28 | * software, must execute solely and exclusively on microcontroller or 29 | * microprocessor devices manufactured by or for STMicroelectronics. 30 | * 5. Redistribution and use of this software other than as permitted under 31 | * this license is void and will automatically terminate your rights under 32 | * this license. 33 | * 34 | * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" 35 | * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT 36 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 37 | * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY 38 | * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT 39 | * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 40 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 41 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 42 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 43 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 44 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 45 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 46 | * 47 | ****************************************************************************** 48 | */ 49 | 50 | /* Define to prevent recursive inclusion -------------------------------------*/ 51 | #ifndef __USB_DEVICE__H__ 52 | #define __USB_DEVICE__H__ 53 | 54 | #ifdef __cplusplus 55 | extern "C" { 56 | #endif 57 | 58 | /* Includes ------------------------------------------------------------------*/ 59 | #include "stm32f0xx.h" 60 | #include "stm32f0xx_hal.h" 61 | #include "usbd_def.h" 62 | 63 | /* USER CODE BEGIN INCLUDE */ 64 | 65 | /* USER CODE END INCLUDE */ 66 | 67 | /** @addtogroup USBD_OTG_DRIVER 68 | * @{ 69 | */ 70 | 71 | /** @defgroup USBD_DEVICE USBD_DEVICE 72 | * @brief Device file for Usb otg low level driver. 73 | * @{ 74 | */ 75 | 76 | /** @defgroup USBD_DEVICE_Exported_Variables USBD_DEVICE_Exported_Variables 77 | * @brief Public variables. 78 | * @{ 79 | */ 80 | 81 | /** USB device core handle. */ 82 | extern USBD_HandleTypeDef hUsbDeviceFS; 83 | 84 | /** 85 | * @} 86 | */ 87 | 88 | /** @defgroup USBD_DEVICE_Exported_FunctionsPrototype USBD_DEVICE_Exported_FunctionsPrototype 89 | * @brief Declaration of public functions for Usb device. 90 | * @{ 91 | */ 92 | 93 | /** USB Device initialization function. */ 94 | void MX_USB_DEVICE_Init(void); 95 | 96 | /** 97 | * @} 98 | */ 99 | 100 | /** 101 | * @} 102 | */ 103 | 104 | /** 105 | * @} 106 | */ 107 | 108 | #ifdef __cplusplus 109 | } 110 | #endif 111 | 112 | #endif /* __USB_DEVICE__H__ */ 113 | 114 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 115 | -------------------------------------------------------------------------------- /Inc/usbd_cdc_if.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file : usbd_cdc_if.h 4 | * @version : v2.0_Cube 5 | * @brief : Header for usbd_cdc_if.c file. 6 | ****************************************************************************** 7 | * This notice applies to any and all portions of this file 8 | * that are not between comment pairs USER CODE BEGIN and 9 | * USER CODE END. Other portions of this file, whether 10 | * inserted by the user or by software development tools 11 | * are owned by their respective copyright owners. 12 | * 13 | * Copyright (c) 2018 STMicroelectronics International N.V. 14 | * All rights reserved. 15 | * 16 | * Redistribution and use in source and binary forms, with or without 17 | * modification, are permitted, provided that the following conditions are met: 18 | * 19 | * 1. Redistribution of source code must retain the above copyright notice, 20 | * this list of conditions and the following disclaimer. 21 | * 2. Redistributions in binary form must reproduce the above copyright notice, 22 | * this list of conditions and the following disclaimer in the documentation 23 | * and/or other materials provided with the distribution. 24 | * 3. Neither the name of STMicroelectronics nor the names of other 25 | * contributors to this software may be used to endorse or promote products 26 | * derived from this software without specific written permission. 27 | * 4. This software, including modifications and/or derivative works of this 28 | * software, must execute solely and exclusively on microcontroller or 29 | * microprocessor devices manufactured by or for STMicroelectronics. 30 | * 5. Redistribution and use of this software other than as permitted under 31 | * this license is void and will automatically terminate your rights under 32 | * this license. 33 | * 34 | * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" 35 | * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT 36 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 37 | * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY 38 | * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT 39 | * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 40 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 41 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 42 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 43 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 44 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 45 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 46 | * 47 | ****************************************************************************** 48 | */ 49 | 50 | /* Define to prevent recursive inclusion -------------------------------------*/ 51 | #ifndef __USBD_CDC_IF_H__ 52 | #define __USBD_CDC_IF_H__ 53 | 54 | #ifdef __cplusplus 55 | extern "C" { 56 | #endif 57 | 58 | /* Includes ------------------------------------------------------------------*/ 59 | #include "usbd_cdc.h" 60 | 61 | /* USER CODE BEGIN INCLUDE */ 62 | /* USER CODE END INCLUDE */ 63 | 64 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY 65 | * @brief For Usb device. 66 | * @{ 67 | */ 68 | 69 | /** @defgroup USBD_CDC_IF USBD_CDC_IF 70 | * @brief Usb VCP device module 71 | * @{ 72 | */ 73 | 74 | /** @defgroup USBD_CDC_IF_Exported_Defines USBD_CDC_IF_Exported_Defines 75 | * @brief Defines. 76 | * @{ 77 | */ 78 | /* USER CODE BEGIN EXPORTED_DEFINES */ 79 | /* USER CODE END EXPORTED_DEFINES */ 80 | 81 | /** 82 | * @} 83 | */ 84 | 85 | /** @defgroup USBD_CDC_IF_Exported_Types USBD_CDC_IF_Exported_Types 86 | * @brief Types. 87 | * @{ 88 | */ 89 | 90 | /* USER CODE BEGIN EXPORTED_TYPES */ 91 | /* USER CODE END EXPORTED_TYPES */ 92 | 93 | /** 94 | * @} 95 | */ 96 | 97 | /** @defgroup USBD_CDC_IF_Exported_Macros USBD_CDC_IF_Exported_Macros 98 | * @brief Aliases. 99 | * @{ 100 | */ 101 | 102 | /* USER CODE BEGIN EXPORTED_MACRO */ 103 | /* USER CODE END EXPORTED_MACRO */ 104 | 105 | /** 106 | * @} 107 | */ 108 | 109 | /** @defgroup USBD_CDC_IF_Exported_Variables USBD_CDC_IF_Exported_Variables 110 | * @brief Public variables. 111 | * @{ 112 | */ 113 | 114 | /** CDC Interface callback. */ 115 | extern USBD_CDC_ItfTypeDef USBD_Interface_fops_FS; 116 | 117 | /* USER CODE BEGIN EXPORTED_VARIABLES */ 118 | /* USER CODE END EXPORTED_VARIABLES */ 119 | 120 | /** 121 | * @} 122 | */ 123 | 124 | /** @defgroup USBD_CDC_IF_Exported_FunctionsPrototype USBD_CDC_IF_Exported_FunctionsPrototype 125 | * @brief Public functions declaration. 126 | * @{ 127 | */ 128 | 129 | uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len); 130 | 131 | /* USER CODE BEGIN EXPORTED_FUNCTIONS */ 132 | /* USER CODE END EXPORTED_FUNCTIONS */ 133 | 134 | /** 135 | * @} 136 | */ 137 | 138 | /** 139 | * @} 140 | */ 141 | 142 | /** 143 | * @} 144 | */ 145 | 146 | #ifdef __cplusplus 147 | } 148 | #endif 149 | 150 | #endif /* __USBD_CDC_IF_H__ */ 151 | 152 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 153 | -------------------------------------------------------------------------------- /Inc/usbd_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file : usbd_conf.h 4 | * @version : v2.0_Cube 5 | * @brief : Header for usbd_conf.c file. 6 | ****************************************************************************** 7 | * This notice applies to any and all portions of this file 8 | * that are not between comment pairs USER CODE BEGIN and 9 | * USER CODE END. Other portions of this file, whether 10 | * inserted by the user or by software development tools 11 | * are owned by their respective copyright owners. 12 | * 13 | * Copyright (c) 2018 STMicroelectronics International N.V. 14 | * All rights reserved. 15 | * 16 | * Redistribution and use in source and binary forms, with or without 17 | * modification, are permitted, provided that the following conditions are met: 18 | * 19 | * 1. Redistribution of source code must retain the above copyright notice, 20 | * this list of conditions and the following disclaimer. 21 | * 2. Redistributions in binary form must reproduce the above copyright notice, 22 | * this list of conditions and the following disclaimer in the documentation 23 | * and/or other materials provided with the distribution. 24 | * 3. Neither the name of STMicroelectronics nor the names of other 25 | * contributors to this software may be used to endorse or promote products 26 | * derived from this software without specific written permission. 27 | * 4. This software, including modifications and/or derivative works of this 28 | * software, must execute solely and exclusively on microcontroller or 29 | * microprocessor devices manufactured by or for STMicroelectronics. 30 | * 5. Redistribution and use of this software other than as permitted under 31 | * this license is void and will automatically terminate your rights under 32 | * this license. 33 | * 34 | * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" 35 | * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT 36 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 37 | * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY 38 | * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT 39 | * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 40 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 41 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 42 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 43 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 44 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 45 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 46 | * 47 | ****************************************************************************** 48 | */ 49 | 50 | /* Define to prevent recursive inclusion -------------------------------------*/ 51 | #ifndef __USBD_CONF__H__ 52 | #define __USBD_CONF__H__ 53 | 54 | #ifdef __cplusplus 55 | extern "C" { 56 | #endif 57 | 58 | /* Includes ------------------------------------------------------------------*/ 59 | #include 60 | #include 61 | #include 62 | #include "stm32f0xx.h" 63 | #include "stm32f0xx_hal.h" 64 | #include "usbd_def.h" 65 | 66 | /* USER CODE BEGIN INCLUDE */ 67 | 68 | /* USER CODE END INCLUDE */ 69 | 70 | /** @addtogroup USBD_OTG_DRIVER 71 | * @{ 72 | */ 73 | 74 | /** @defgroup USBD_CONF USBD_CONF 75 | * @brief Configuration file for Usb otg low level driver. 76 | * @{ 77 | */ 78 | 79 | /** @defgroup USBD_CONF_Exported_Variables USBD_CONF_Exported_Variables 80 | * @brief Public variables. 81 | * @{ 82 | */ 83 | 84 | /** 85 | * @} 86 | */ 87 | 88 | /** @defgroup USBD_CONF_Exported_Defines USBD_CONF_Exported_Defines 89 | * @brief Defines for configuration of the Usb device. 90 | * @{ 91 | */ 92 | 93 | /*---------- -----------*/ 94 | #define USBD_MAX_NUM_INTERFACES 1 95 | /*---------- -----------*/ 96 | #define USBD_MAX_NUM_CONFIGURATION 1 97 | /*---------- -----------*/ 98 | #define USBD_MAX_STR_DESC_SIZ 512 99 | /*---------- -----------*/ 100 | #define USBD_SUPPORT_USER_STRING 0 101 | /*---------- -----------*/ 102 | #define USBD_DEBUG_LEVEL 0 103 | /*---------- -----------*/ 104 | #define USBD_SELF_POWERED 1 105 | /*---------- -----------*/ 106 | #define MAX_STATIC_ALLOC_SIZE 512 107 | 108 | /****************************************/ 109 | /* #define for FS and HS identification */ 110 | #define DEVICE_FS 0 111 | 112 | /** 113 | * @} 114 | */ 115 | 116 | /** @defgroup USBD_CONF_Exported_Macros USBD_CONF_Exported_Macros 117 | * @brief Aliases. 118 | * @{ 119 | */ 120 | 121 | /* Memory management macros */ 122 | 123 | /** Alias for memory allocation. */ 124 | #define USBD_malloc (uint32_t *)USBD_static_malloc 125 | 126 | /** Alias for memory release. */ 127 | #define USBD_free USBD_static_free 128 | 129 | /** Alias for memory set. */ 130 | #define USBD_memset /* Not used */ 131 | 132 | /** Alias for memory copy. */ 133 | #define USBD_memcpy /* Not used */ 134 | 135 | /** Alias for delay. */ 136 | #define USBD_Delay HAL_Delay 137 | 138 | /* DEBUG macros */ 139 | 140 | #if (USBD_DEBUG_LEVEL > 0) 141 | #define USBD_UsrLog(...) printf(__VA_ARGS__);\ 142 | printf("\n"); 143 | #else 144 | #define USBD_UsrLog(...) 145 | #endif 146 | 147 | #if (USBD_DEBUG_LEVEL > 1) 148 | 149 | #define USBD_ErrLog(...) printf("ERROR: ") ;\ 150 | printf(__VA_ARGS__);\ 151 | printf("\n"); 152 | #else 153 | #define USBD_ErrLog(...) 154 | #endif 155 | 156 | #if (USBD_DEBUG_LEVEL > 2) 157 | #define USBD_DbgLog(...) printf("DEBUG : ") ;\ 158 | printf(__VA_ARGS__);\ 159 | printf("\n"); 160 | #else 161 | #define USBD_DbgLog(...) 162 | #endif 163 | 164 | /** 165 | * @} 166 | */ 167 | 168 | /** @defgroup USBD_CONF_Exported_Types USBD_CONF_Exported_Types 169 | * @brief Types. 170 | * @{ 171 | */ 172 | 173 | /** 174 | * @} 175 | */ 176 | 177 | /** @defgroup USBD_CONF_Exported_FunctionsPrototype USBD_CONF_Exported_FunctionsPrototype 178 | * @brief Declaration of public functions for Usb device. 179 | * @{ 180 | */ 181 | 182 | /* Exported functions -------------------------------------------------------*/ 183 | void *USBD_static_malloc(uint32_t size); 184 | void USBD_static_free(void *p); 185 | /** 186 | * @} 187 | */ 188 | 189 | /** 190 | * @} 191 | */ 192 | 193 | /** 194 | * @} 195 | */ 196 | 197 | #ifdef __cplusplus 198 | } 199 | #endif 200 | 201 | #endif /* __USBD_CONF__H__ */ 202 | 203 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 204 | -------------------------------------------------------------------------------- /Inc/usbd_desc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file : usbd_desc.h 4 | * @version : v2.0_Cube 5 | * @brief : Header for usbd_desc.c file. 6 | ****************************************************************************** 7 | * This notice applies to any and all portions of this file 8 | * that are not between comment pairs USER CODE BEGIN and 9 | * USER CODE END. Other portions of this file, whether 10 | * inserted by the user or by software development tools 11 | * are owned by their respective copyright owners. 12 | * 13 | * Copyright (c) 2018 STMicroelectronics International N.V. 14 | * All rights reserved. 15 | * 16 | * Redistribution and use in source and binary forms, with or without 17 | * modification, are permitted, provided that the following conditions are met: 18 | * 19 | * 1. Redistribution of source code must retain the above copyright notice, 20 | * this list of conditions and the following disclaimer. 21 | * 2. Redistributions in binary form must reproduce the above copyright notice, 22 | * this list of conditions and the following disclaimer in the documentation 23 | * and/or other materials provided with the distribution. 24 | * 3. Neither the name of STMicroelectronics nor the names of other 25 | * contributors to this software may be used to endorse or promote products 26 | * derived from this software without specific written permission. 27 | * 4. This software, including modifications and/or derivative works of this 28 | * software, must execute solely and exclusively on microcontroller or 29 | * microprocessor devices manufactured by or for STMicroelectronics. 30 | * 5. Redistribution and use of this software other than as permitted under 31 | * this license is void and will automatically terminate your rights under 32 | * this license. 33 | * 34 | * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" 35 | * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT 36 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 37 | * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY 38 | * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT 39 | * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 40 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 41 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 42 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 43 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 44 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 45 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 46 | * 47 | ****************************************************************************** 48 | */ 49 | 50 | /* Define to prevent recursive inclusion -------------------------------------*/ 51 | #ifndef __USBD_DESC__H__ 52 | #define __USBD_DESC__H__ 53 | 54 | #ifdef __cplusplus 55 | extern "C" { 56 | #endif 57 | 58 | /* Includes ------------------------------------------------------------------*/ 59 | #include "usbd_def.h" 60 | 61 | /* USER CODE BEGIN INCLUDE */ 62 | 63 | /* USER CODE END INCLUDE */ 64 | 65 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY 66 | * @{ 67 | */ 68 | 69 | /** @defgroup USBD_DESC USBD_DESC 70 | * @brief Usb device descriptors module. 71 | * @{ 72 | */ 73 | 74 | /** @defgroup USBD_DESC_Exported_Defines USBD_DESC_Exported_Defines 75 | * @brief Defines. 76 | * @{ 77 | */ 78 | 79 | /* USER CODE BEGIN EXPORTED_DEFINES */ 80 | 81 | /* USER CODE END EXPORTED_DEFINES */ 82 | 83 | /** 84 | * @} 85 | */ 86 | 87 | /** @defgroup USBD_DESC_Exported_TypesDefinitions USBD_DESC_Exported_TypesDefinitions 88 | * @brief Types. 89 | * @{ 90 | */ 91 | 92 | /* USER CODE BEGIN EXPORTED_TYPES */ 93 | 94 | /* USER CODE END EXPORTED_TYPES */ 95 | 96 | /** 97 | * @} 98 | */ 99 | 100 | /** @defgroup USBD_DESC_Exported_Macros USBD_DESC_Exported_Macros 101 | * @brief Aliases. 102 | * @{ 103 | */ 104 | 105 | /* USER CODE BEGIN EXPORTED_MACRO */ 106 | 107 | /* USER CODE END EXPORTED_MACRO */ 108 | 109 | /** 110 | * @} 111 | */ 112 | 113 | /** @defgroup USBD_DESC_Exported_Variables USBD_DESC_Exported_Variables 114 | * @brief Public variables. 115 | * @{ 116 | */ 117 | 118 | /** Descriptor for the Usb device. */ 119 | extern USBD_DescriptorsTypeDef FS_Desc; 120 | 121 | /* USER CODE BEGIN EXPORTED_VARIABLES */ 122 | 123 | /* USER CODE END EXPORTED_VARIABLES */ 124 | 125 | /** 126 | * @} 127 | */ 128 | 129 | /** @defgroup USBD_DESC_Exported_FunctionsPrototype USBD_DESC_Exported_FunctionsPrototype 130 | * @brief Public functions declaration. 131 | * @{ 132 | */ 133 | 134 | /* USER CODE BEGIN EXPORTED_FUNCTIONS */ 135 | 136 | /* USER CODE END EXPORTED_FUNCTIONS */ 137 | 138 | /** 139 | * @} 140 | */ 141 | 142 | /** 143 | * @} 144 | */ 145 | 146 | /** 147 | * @} 148 | */ 149 | 150 | #ifdef __cplusplus 151 | } 152 | #endif 153 | 154 | #endif /* __USBD_DESC__H__ */ 155 | 156 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 157 | -------------------------------------------------------------------------------- /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 | * @version V2.4.2 6 | * @date 11-December-2015 7 | * @brief header file for the usbd_cdc.c file. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2015 STMicroelectronics

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

© COPYRIGHT 2015 STMicroelectronics

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

© COPYRIGHT 2015 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __USB_REQUEST_H 30 | #define __USB_REQUEST_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Includes ------------------------------------------------------------------*/ 37 | #include "usbd_def.h" 38 | 39 | 40 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 41 | * @{ 42 | */ 43 | 44 | /** @defgroup USBD_REQ 45 | * @brief header file for the usbd_req.c file 46 | * @{ 47 | */ 48 | 49 | /** @defgroup USBD_REQ_Exported_Defines 50 | * @{ 51 | */ 52 | /** 53 | * @} 54 | */ 55 | 56 | 57 | /** @defgroup USBD_REQ_Exported_Types 58 | * @{ 59 | */ 60 | /** 61 | * @} 62 | */ 63 | 64 | 65 | 66 | /** @defgroup USBD_REQ_Exported_Macros 67 | * @{ 68 | */ 69 | /** 70 | * @} 71 | */ 72 | 73 | /** @defgroup USBD_REQ_Exported_Variables 74 | * @{ 75 | */ 76 | /** 77 | * @} 78 | */ 79 | 80 | /** @defgroup USBD_REQ_Exported_FunctionsPrototype 81 | * @{ 82 | */ 83 | 84 | USBD_StatusTypeDef USBD_StdDevReq (USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 85 | USBD_StatusTypeDef USBD_StdItfReq (USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 86 | USBD_StatusTypeDef USBD_StdEPReq (USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 87 | 88 | 89 | void USBD_CtlError (USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 90 | 91 | void USBD_ParseSetupRequest (USBD_SetupReqTypedef *req, uint8_t *pdata); 92 | 93 | void USBD_GetString (uint8_t *desc, uint8_t *unicode, uint16_t *len); 94 | /** 95 | * @} 96 | */ 97 | 98 | #ifdef __cplusplus 99 | } 100 | #endif 101 | 102 | #endif /* __USB_REQUEST_H */ 103 | 104 | /** 105 | * @} 106 | */ 107 | 108 | /** 109 | * @} 110 | */ 111 | 112 | 113 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 114 | -------------------------------------------------------------------------------- /Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_ioreq.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_ioreq.h 4 | * @author MCD Application Team 5 | * @version V2.4.2 6 | * @date 11-December-2015 7 | * @brief Header file for the usbd_ioreq.c file 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2015 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __USBD_IOREQ_H 30 | #define __USBD_IOREQ_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Includes ------------------------------------------------------------------*/ 37 | #include "usbd_def.h" 38 | #include "usbd_core.h" 39 | 40 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 41 | * @{ 42 | */ 43 | 44 | /** @defgroup USBD_IOREQ 45 | * @brief header file for the usbd_ioreq.c file 46 | * @{ 47 | */ 48 | 49 | /** @defgroup USBD_IOREQ_Exported_Defines 50 | * @{ 51 | */ 52 | /** 53 | * @} 54 | */ 55 | 56 | 57 | /** @defgroup USBD_IOREQ_Exported_Types 58 | * @{ 59 | */ 60 | 61 | 62 | /** 63 | * @} 64 | */ 65 | 66 | 67 | 68 | /** @defgroup USBD_IOREQ_Exported_Macros 69 | * @{ 70 | */ 71 | 72 | /** 73 | * @} 74 | */ 75 | 76 | /** @defgroup USBD_IOREQ_Exported_Variables 77 | * @{ 78 | */ 79 | 80 | /** 81 | * @} 82 | */ 83 | 84 | /** @defgroup USBD_IOREQ_Exported_FunctionsPrototype 85 | * @{ 86 | */ 87 | 88 | USBD_StatusTypeDef USBD_CtlSendData (USBD_HandleTypeDef *pdev, 89 | uint8_t *buf, 90 | uint16_t len); 91 | 92 | USBD_StatusTypeDef USBD_CtlContinueSendData (USBD_HandleTypeDef *pdev, 93 | uint8_t *pbuf, 94 | uint16_t len); 95 | 96 | USBD_StatusTypeDef USBD_CtlPrepareRx (USBD_HandleTypeDef *pdev, 97 | uint8_t *pbuf, 98 | uint16_t len); 99 | 100 | USBD_StatusTypeDef USBD_CtlContinueRx (USBD_HandleTypeDef *pdev, 101 | uint8_t *pbuf, 102 | uint16_t len); 103 | 104 | USBD_StatusTypeDef USBD_CtlSendStatus (USBD_HandleTypeDef *pdev); 105 | 106 | USBD_StatusTypeDef USBD_CtlReceiveStatus (USBD_HandleTypeDef *pdev); 107 | 108 | uint16_t USBD_GetRxCount (USBD_HandleTypeDef *pdev , 109 | uint8_t epnum); 110 | 111 | /** 112 | * @} 113 | */ 114 | 115 | #ifdef __cplusplus 116 | } 117 | #endif 118 | 119 | #endif /* __USBD_IOREQ_H */ 120 | 121 | /** 122 | * @} 123 | */ 124 | 125 | /** 126 | * @} 127 | */ 128 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 129 | -------------------------------------------------------------------------------- /Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_ioreq.c 4 | * @author MCD Application Team 5 | * @version V2.4.2 6 | * @date 11-December-2015 7 | * @brief This file provides the IO requests APIs for control endpoints. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2015 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "usbd_ioreq.h" 30 | 31 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 32 | * @{ 33 | */ 34 | 35 | 36 | /** @defgroup USBD_IOREQ 37 | * @brief control I/O requests module 38 | * @{ 39 | */ 40 | 41 | /** @defgroup USBD_IOREQ_Private_TypesDefinitions 42 | * @{ 43 | */ 44 | /** 45 | * @} 46 | */ 47 | 48 | 49 | /** @defgroup USBD_IOREQ_Private_Defines 50 | * @{ 51 | */ 52 | 53 | /** 54 | * @} 55 | */ 56 | 57 | 58 | /** @defgroup USBD_IOREQ_Private_Macros 59 | * @{ 60 | */ 61 | /** 62 | * @} 63 | */ 64 | 65 | 66 | /** @defgroup USBD_IOREQ_Private_Variables 67 | * @{ 68 | */ 69 | 70 | /** 71 | * @} 72 | */ 73 | 74 | 75 | /** @defgroup USBD_IOREQ_Private_FunctionPrototypes 76 | * @{ 77 | */ 78 | /** 79 | * @} 80 | */ 81 | 82 | 83 | /** @defgroup USBD_IOREQ_Private_Functions 84 | * @{ 85 | */ 86 | 87 | /** 88 | * @brief USBD_CtlSendData 89 | * send data on the ctl pipe 90 | * @param pdev: device instance 91 | * @param buff: pointer to data buffer 92 | * @param len: length of data to be sent 93 | * @retval status 94 | */ 95 | USBD_StatusTypeDef USBD_CtlSendData (USBD_HandleTypeDef *pdev, 96 | uint8_t *pbuf, 97 | uint16_t len) 98 | { 99 | /* Set EP0 State */ 100 | pdev->ep0_state = USBD_EP0_DATA_IN; 101 | pdev->ep_in[0].total_length = len; 102 | pdev->ep_in[0].rem_length = len; 103 | /* Start the transfer */ 104 | USBD_LL_Transmit (pdev, 0x00, pbuf, len); 105 | 106 | return USBD_OK; 107 | } 108 | 109 | /** 110 | * @brief USBD_CtlContinueSendData 111 | * continue sending data on the ctl pipe 112 | * @param pdev: device instance 113 | * @param buff: pointer to data buffer 114 | * @param len: length of data to be sent 115 | * @retval status 116 | */ 117 | USBD_StatusTypeDef USBD_CtlContinueSendData (USBD_HandleTypeDef *pdev, 118 | uint8_t *pbuf, 119 | uint16_t len) 120 | { 121 | /* Start the next transfer */ 122 | USBD_LL_Transmit (pdev, 0x00, pbuf, len); 123 | 124 | return USBD_OK; 125 | } 126 | 127 | /** 128 | * @brief USBD_CtlPrepareRx 129 | * receive data on the ctl pipe 130 | * @param pdev: device instance 131 | * @param buff: pointer to data buffer 132 | * @param len: length of data to be received 133 | * @retval status 134 | */ 135 | USBD_StatusTypeDef USBD_CtlPrepareRx (USBD_HandleTypeDef *pdev, 136 | uint8_t *pbuf, 137 | uint16_t len) 138 | { 139 | /* Set EP0 State */ 140 | pdev->ep0_state = USBD_EP0_DATA_OUT; 141 | pdev->ep_out[0].total_length = len; 142 | pdev->ep_out[0].rem_length = len; 143 | /* Start the transfer */ 144 | USBD_LL_PrepareReceive (pdev, 145 | 0, 146 | pbuf, 147 | len); 148 | 149 | return USBD_OK; 150 | } 151 | 152 | /** 153 | * @brief USBD_CtlContinueRx 154 | * continue receive data on the ctl pipe 155 | * @param pdev: device instance 156 | * @param buff: pointer to data buffer 157 | * @param len: length of data to be received 158 | * @retval status 159 | */ 160 | USBD_StatusTypeDef USBD_CtlContinueRx (USBD_HandleTypeDef *pdev, 161 | uint8_t *pbuf, 162 | uint16_t len) 163 | { 164 | 165 | USBD_LL_PrepareReceive (pdev, 166 | 0, 167 | pbuf, 168 | len); 169 | return USBD_OK; 170 | } 171 | /** 172 | * @brief USBD_CtlSendStatus 173 | * send zero lzngth packet on the ctl pipe 174 | * @param pdev: device instance 175 | * @retval status 176 | */ 177 | USBD_StatusTypeDef USBD_CtlSendStatus (USBD_HandleTypeDef *pdev) 178 | { 179 | 180 | /* Set EP0 State */ 181 | pdev->ep0_state = USBD_EP0_STATUS_IN; 182 | 183 | /* Start the transfer */ 184 | USBD_LL_Transmit (pdev, 0x00, NULL, 0); 185 | 186 | return USBD_OK; 187 | } 188 | 189 | /** 190 | * @brief USBD_CtlReceiveStatus 191 | * receive zero lzngth packet on the ctl pipe 192 | * @param pdev: device instance 193 | * @retval status 194 | */ 195 | USBD_StatusTypeDef USBD_CtlReceiveStatus (USBD_HandleTypeDef *pdev) 196 | { 197 | /* Set EP0 State */ 198 | pdev->ep0_state = USBD_EP0_STATUS_OUT; 199 | 200 | /* Start the transfer */ 201 | USBD_LL_PrepareReceive ( pdev, 202 | 0, 203 | NULL, 204 | 0); 205 | 206 | return USBD_OK; 207 | } 208 | 209 | 210 | /** 211 | * @brief USBD_GetRxCount 212 | * returns the received data length 213 | * @param pdev: device instance 214 | * @param ep_addr: endpoint address 215 | * @retval Rx Data blength 216 | */ 217 | uint16_t USBD_GetRxCount (USBD_HandleTypeDef *pdev , uint8_t ep_addr) 218 | { 219 | return USBD_LL_GetRxDataSize(pdev, ep_addr); 220 | } 221 | 222 | /** 223 | * @} 224 | */ 225 | 226 | 227 | /** 228 | * @} 229 | */ 230 | 231 | 232 | /** 233 | * @} 234 | */ 235 | 236 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 237 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # UCCBEmbedded 2 | Software for USBCanConverterBasic(UCCB) writen for STM32F042C6 mcu, see [ucandevices](https://ucandevices.github.io/uccb.html) web page for full info. 3 | # Build and run 4 | Source code is pure C. Project can be imported direclty to free vesrion of Atollic TrueSTUDIO for ARM 5.5.1. 5 | Drivers for CAN and USB layer were generated in stm32CubeMX. 6 | # Hardware 7 | Hardware is open source. See [CCBPCB](https://github.com/UsbCANConverter-UCCbasic/UCCBPCB) project for souces. 8 | # Bootloader 9 | STM32 have embedded DFU bootloader, for more info see st.com 10 | -------------------------------------------------------------------------------- /STM32F042C6_FLASH.ld: -------------------------------------------------------------------------------- 1 | /* 2 | ***************************************************************************** 3 | ** 4 | 5 | ** File : stm32_flash.ld 6 | ** 7 | ** Abstract : Linker script for STM32F042C6 Device with 8 | ** 32KByte FLASH, 6KByte RAM 9 | ** 10 | ** Set heap size, stack size and stack location according 11 | ** to application requirements. 12 | ** 13 | ** Set memory bank area and size if external memory is used. 14 | ** 15 | ** Target : STMicroelectronics STM32 16 | ** 17 | ** Environment : Atollic TrueSTUDIO(R) 18 | ** 19 | ** Distribution: The file is distributed as is, without any warranty 20 | ** of any kind. 21 | ** 22 | ** (c)Copyright Atollic AB. 23 | ** You may use this file as-is or modify it according to the needs of your 24 | ** project. This file may only be built (assembled or compiled and linked) 25 | ** using the Atollic TrueSTUDIO(R) product. The use of this file together 26 | ** with other tools than Atollic TrueSTUDIO(R) is not permitted. 27 | ** 28 | ***************************************************************************** 29 | */ 30 | 31 | /* Entry Point */ 32 | ENTRY(Reset_Handler) 33 | 34 | /* Highest address of the user mode stack */ 35 | _estack = 0x20001800; /* end of RAM */ 36 | /* Generate a link error if heap and stack don't fit into RAM */ 37 | _Min_Heap_Size = 0x200; /* required amount of heap */ 38 | _Min_Stack_Size = 0x400; /* required amount of stack */ 39 | 40 | /* Specify the memory areas */ 41 | MEMORY 42 | { 43 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 6K 44 | FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 32K 45 | } 46 | 47 | /* Define output sections */ 48 | SECTIONS 49 | { 50 | /* The startup code goes first into FLASH */ 51 | .isr_vector : 52 | { 53 | . = ALIGN(4); 54 | KEEP(*(.isr_vector)) /* Startup code */ 55 | . = ALIGN(4); 56 | } >FLASH 57 | 58 | /* The program code and other data goes into FLASH */ 59 | .text : 60 | { 61 | . = ALIGN(4); 62 | *(.text) /* .text sections (code) */ 63 | *(.text*) /* .text* sections (code) */ 64 | *(.glue_7) /* glue arm to thumb code */ 65 | *(.glue_7t) /* glue thumb to arm code */ 66 | *(.eh_frame) 67 | 68 | KEEP (*(.init)) 69 | KEEP (*(.fini)) 70 | 71 | . = ALIGN(4); 72 | _etext = .; /* define a global symbols at end of code */ 73 | } >FLASH 74 | 75 | /* Constant data goes into FLASH */ 76 | .rodata : 77 | { 78 | . = ALIGN(4); 79 | *(.rodata) /* .rodata sections (constants, strings, etc.) */ 80 | *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ 81 | . = ALIGN(4); 82 | } >FLASH 83 | 84 | .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH 85 | .ARM : { 86 | __exidx_start = .; 87 | *(.ARM.exidx*) 88 | __exidx_end = .; 89 | } >FLASH 90 | 91 | .preinit_array : 92 | { 93 | PROVIDE_HIDDEN (__preinit_array_start = .); 94 | KEEP (*(.preinit_array*)) 95 | PROVIDE_HIDDEN (__preinit_array_end = .); 96 | } >FLASH 97 | .init_array : 98 | { 99 | PROVIDE_HIDDEN (__init_array_start = .); 100 | KEEP (*(SORT(.init_array.*))) 101 | KEEP (*(.init_array*)) 102 | PROVIDE_HIDDEN (__init_array_end = .); 103 | } >FLASH 104 | .fini_array : 105 | { 106 | PROVIDE_HIDDEN (__fini_array_start = .); 107 | KEEP (*(SORT(.fini_array.*))) 108 | KEEP (*(.fini_array*)) 109 | PROVIDE_HIDDEN (__fini_array_end = .); 110 | } >FLASH 111 | 112 | /* used by the startup to initialize data */ 113 | _sidata = LOADADDR(.data); 114 | 115 | /* Initialized data sections goes into RAM, load LMA copy after code */ 116 | .data : 117 | { 118 | . = ALIGN(4); 119 | _sdata = .; /* create a global symbol at data start */ 120 | *(.data) /* .data sections */ 121 | *(.data*) /* .data* sections */ 122 | 123 | . = ALIGN(4); 124 | _edata = .; /* define a global symbol at data end */ 125 | } >RAM AT> FLASH 126 | 127 | 128 | /* Uninitialized data section */ 129 | . = ALIGN(4); 130 | .bss : 131 | { 132 | /* This is used by the startup in order to initialize the .bss secion */ 133 | _sbss = .; /* define a global symbol at bss start */ 134 | __bss_start__ = _sbss; 135 | *(.bss) 136 | *(.bss*) 137 | *(COMMON) 138 | 139 | . = ALIGN(4); 140 | _ebss = .; /* define a global symbol at bss end */ 141 | __bss_end__ = _ebss; 142 | } >RAM 143 | 144 | /* User_heap_stack section, used to check that there is enough RAM left */ 145 | ._user_heap_stack : 146 | { 147 | . = ALIGN(4); 148 | PROVIDE ( end = . ); 149 | PROVIDE ( _end = . ); 150 | . = . + _Min_Heap_Size; 151 | . = . + _Min_Stack_Size; 152 | . = ALIGN(4); 153 | } >RAM 154 | 155 | 156 | 157 | /* Remove information from the standard libraries */ 158 | /DISCARD/ : 159 | { 160 | libc.a ( * ) 161 | libm.a ( * ) 162 | libgcc.a ( * ) 163 | } 164 | 165 | .ARM.attributes 0 : { *(.ARM.attributes) } 166 | } 167 | 168 | 169 | -------------------------------------------------------------------------------- /Src/bootloader/bootloader.c: -------------------------------------------------------------------------------- 1 | /* 2 | * bootloader.c taken from krasutski.denis https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2Fcortex_mx_stm32%2FJump%20to%20USB%20DFU%20Bootloader%20in%20startup%20code%20on%20STM32F042&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B¤tviews=2147 3 | * Thanks Denis! 4 | */ 5 | 6 | #include "stm32f0xx_hal.h" 7 | #include "usb_device.h" 8 | 9 | //call this at any time to initiate a reboot into bootloader 10 | void RebootToBootloader(){ 11 | 12 | 13 | FLASH_OBProgramInitTypeDef OBParam; 14 | 15 | HAL_FLASHEx_OBGetConfig(&OBParam); 16 | 17 | OBParam.OptionType = OPTIONBYTE_USER; 18 | /*Reset NBOOT0 and BOOT_SEL, see: RM 2.5 Boot configuration*/ 19 | OBParam.USERConfig = 0x77; //Sorry for magic number :) 20 | 21 | HAL_FLASH_Unlock(); 22 | HAL_FLASH_OB_Unlock(); 23 | 24 | HAL_FLASHEx_OBErase(); 25 | 26 | HAL_FLASHEx_OBProgram(&OBParam); 27 | 28 | HAL_FLASH_OB_Lock(); 29 | HAL_FLASH_Lock(); 30 | 31 | HAL_FLASH_OB_Launch(); 32 | } 33 | 34 | //turns off BOOT0 pin 35 | void bootloaderSwitcher(){ 36 | FLASH_OBProgramInitTypeDef OBParam; 37 | 38 | HAL_FLASHEx_OBGetConfig(&OBParam); 39 | 40 | if(OBParam.USERConfig != 0x7F) 41 | { 42 | 43 | OBParam.OptionType = OPTIONBYTE_USER; 44 | OBParam.USERConfig = 0x7F; 45 | 46 | HAL_FLASH_Unlock(); 47 | HAL_FLASH_OB_Unlock(); 48 | HAL_FLASHEx_OBErase(); 49 | HAL_FLASHEx_OBProgram(&OBParam); 50 | HAL_FLASH_OB_Lock(); 51 | HAL_FLASH_OB_Launch(); 52 | } 53 | } 54 | 55 | -------------------------------------------------------------------------------- /Src/slcan/slcan.h: -------------------------------------------------------------------------------- 1 | /* 2 | * slcan_port.h 3 | * 4 | * Created on: Apr 4, 2016 5 | * Author: PLLUJUR1 6 | */ 7 | 8 | #ifndef SLCAN_PORT_H_ 9 | #define SLCAN_PORT_H_ 10 | 11 | #include "stdint.h" 12 | #include "stm32f0xx_hal.h" 13 | #include "stm32f0xx_hal_can.h" 14 | 15 | 16 | #define VERSION_FIRMWARE_MAJOR 4 17 | #define VERSION_FIRMWARE_MINOR 1 18 | 19 | #define VERSION_HARDWARE_MAJOR 1 20 | #define VERSION_HARDWARE_MINOR 1 21 | 22 | #define CAN_BR_10K 0 23 | #define CAN_BR_20K 1 24 | #define CAN_BR_50K 2 25 | #define CAN_BR_100K 3 26 | #define CAN_BR_125K 4 27 | #define CAN_BR_250K 5 28 | #define CAN_BR_500K 6 29 | #define CAN_BR_800K 7 30 | #define CAN_BR_1M 8 31 | #define CAN_BR_83K 36 32 | 33 | #define LINE_MAXLEN 100 34 | 35 | #define STATE_CONFIG 0 36 | #define STATE_LISTEN 1 37 | #define STATE_OPEN 2 38 | 39 | void slcanOutputFlush(void); 40 | void slcanClose(); 41 | uint8_t slcanReciveCanFrame(CanRxMsgTypeDef *pRxMsg); 42 | int slCanProccesInput(uint8_t ch); 43 | uint8_t slCanCheckCommand(uint8_t *line); 44 | uint8_t slcan_getState(void); 45 | 46 | extern uint8_t command[LINE_MAXLEN]; 47 | extern uint8_t lastInputBuffer; 48 | 49 | #endif /* SLCAN_PORT_H_ */ 50 | -------------------------------------------------------------------------------- /Src/slcan/slcan_additional.c: -------------------------------------------------------------------------------- 1 | /* 2 | * can_additional.c 3 | * 4 | * Created on: Jun 30, 2016 5 | * Author: PLLUJUR1 6 | */ 7 | 8 | #include "stm32f0xx_hal.h" 9 | #include "stm32f0xx_hal_can.h" 10 | #include "slcan.h" 11 | #include "slcan_additional.h" 12 | 13 | extern CAN_HandleTypeDef hcan; 14 | extern IWDG_HandleTypeDef hiwdg; 15 | HAL_StatusTypeDef CANInit(void) 16 | { 17 | while (HAL_CAN_Init(&hcan) == HAL_TIMEOUT) 18 | { 19 | HAL_IWDG_Refresh(&hiwdg); 20 | } 21 | return HAL_OK; 22 | } 23 | 24 | HAL_StatusTypeDef slcanClearAllFilters(void) 25 | { 26 | CAN_FilterConfTypeDef sFilterConfig; 27 | sFilterConfig.FilterNumber = 0; 28 | sFilterConfig.FilterMode = CAN_FILTERMODE_IDMASK; 29 | sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT; 30 | sFilterConfig.FilterIdHigh = 0x0000; 31 | sFilterConfig.FilterIdLow = 0; 32 | sFilterConfig.FilterMaskIdHigh = 0x0000; 33 | sFilterConfig.FilterMaskIdLow = 0; 34 | sFilterConfig.FilterFIFOAssignment = 0; 35 | sFilterConfig.FilterActivation = ENABLE; 36 | sFilterConfig.BankNumber = 0; 37 | 38 | if (HAL_CAN_ConfigFilter(&hcan, &sFilterConfig) != HAL_OK) 39 | return HAL_ERROR; 40 | else 41 | return HAL_OK; 42 | } 43 | 44 | tCANfilter slcanFillIdRegister32(tCANFilterFlagsId fl, uint32_t id) 45 | { 46 | tCANfilter f; 47 | f.h.reg = 0; 48 | f.l.reg = 0; 49 | 50 | f.l.f32.RTR = fl.bRTR1; 51 | f.l.f32.IDE = fl.bExtedned1; 52 | if (fl.bExtedned1) 53 | { 54 | f.l.f32.EXID4_0 = id; 55 | f.l.f32.EXID12_5 = id >> 5; 56 | f.h.f32.EXID17_13 = id >> 13; 57 | } else { 58 | f.h.f32.STID2_0 = id; 59 | f.h.f32.STID10_3 = id >> 3; 60 | } 61 | return f; 62 | } 63 | 64 | tCANfilter slcanFillIdRegister16(tCANFilterFlagsId fl, uint32_t id) 65 | { 66 | tCANfilter f; 67 | f.h.reg = 0; 68 | f.l.reg = 0; 69 | 70 | f.l.f16.RTR = fl.bRTR1; 71 | f.l.f16.IDE = fl.bExtedned1; 72 | if (fl.bExtedned1) 73 | { 74 | f.l.f16.STID2_0 = id; 75 | f.l.f16.STID10_3 = id >> 3; 76 | f.l.f16.EXID17_15 = id >> 8; 77 | } 78 | 79 | f.l.f16.RTR = fl.bRTR2; 80 | f.l.f16.IDE = fl.bExtedned2; 81 | if (fl.bExtedned2) 82 | { 83 | f.h.f16.STID2_0 = id >> 16; 84 | f.h.f16.STID10_3 = id >> (3 + 16); 85 | f.h.f16.EXID17_15 = id >> (8 + 16); 86 | } 87 | 88 | return f; 89 | } 90 | 91 | void slcanSetCANBaudRate(uint8_t br) 92 | { //todo it is for 75% sampling point 93 | 94 | hcan.Init.SJW = CAN_SJW_2TQ; 95 | hcan.Init.BS1 = CAN_BS1_11TQ; 96 | hcan.Init.BS2 = CAN_BS2_4TQ; 97 | 98 | switch (br) 99 | { 100 | case CAN_BR_1M: 101 | hcan.Init.Prescaler = 3; 102 | break; 103 | case CAN_BR_500K: 104 | hcan.Init.Prescaler = 6; 105 | break; 106 | case CAN_BR_250K: 107 | hcan.Init.Prescaler = 12; 108 | break; 109 | case CAN_BR_125K: 110 | hcan.Init.Prescaler = 24; 111 | break; 112 | case CAN_BR_100K: 113 | hcan.Init.Prescaler = 30; 114 | break; 115 | case CAN_BR_50K: 116 | hcan.Init.Prescaler = 60; 117 | break; 118 | case CAN_BR_20K: 119 | hcan.Init.Prescaler = 150; 120 | break; 121 | case CAN_BR_10K: 122 | hcan.Init.Prescaler = 300; 123 | break; 124 | case CAN_BR_83K: 125 | hcan.Init.Prescaler = 36; 126 | break; 127 | 128 | default: 129 | break; 130 | } 131 | 132 | CANInit(); 133 | } 134 | 135 | -------------------------------------------------------------------------------- /Src/slcan/slcan_additional.h: -------------------------------------------------------------------------------- 1 | /* 2 | * slcan_additional.h 3 | * 4 | * Created on: Jun 30, 2016 5 | * Author: PLLUJUR1 6 | */ 7 | 8 | #ifndef SLCAN_ADDITIONAL_H_ 9 | #define SLCAN_ADDITIONAL_H_ 10 | 11 | 12 | typedef union { 13 | struct 14 | { 15 | uint32_t bFilterActivation : 1; 16 | uint32_t bMode : 1; 17 | uint32_t bScale : 1; 18 | uint32_t bFIFO : 1; 19 | }; 20 | uint32_t reg; 21 | } tCANFilterFlagsConf; 22 | 23 | typedef union{ 24 | struct { 25 | uint32_t bRTR1 : 1; 26 | uint32_t bExtedned1 : 1; 27 | uint32_t bRTR2 : 1; 28 | uint32_t bExtedned2 : 1; 29 | }; 30 | uint32_t reg; 31 | } tCANFilterFlagsId; 32 | 33 | typedef struct { 34 | uint16_t EXID17_15 : 3; 35 | uint16_t RTR : 1; 36 | uint16_t IDE : 1; 37 | uint16_t STID2_0 : 3; 38 | 39 | uint16_t STID10_3 : 8; 40 | }tCANreg16; 41 | 42 | 43 | typedef struct { 44 | union { 45 | struct { 46 | uint16_t EXID17_13 : 5; 47 | uint16_t STID2_0 : 3; 48 | uint16_t STID10_3 : 8; 49 | } f32; 50 | uint16_t reg; 51 | tCANreg16 f16; 52 | }h; 53 | union { 54 | struct { 55 | uint16_t reserved : 1; 56 | uint16_t RTR : 1; 57 | uint16_t IDE : 1; 58 | uint16_t EXID4_0 : 5; 59 | uint16_t EXID12_5 : 8; 60 | } f32; 61 | uint16_t reg; 62 | tCANreg16 f16; 63 | }l; 64 | }tCANfilter; 65 | 66 | tCANfilter slcanFillIdRegister32(tCANFilterFlagsId fl, uint32_t id); 67 | tCANfilter slcanFillIdRegister16(tCANFilterFlagsId fl, uint32_t id); 68 | HAL_StatusTypeDef slcanClearAllFilters(void); 69 | 70 | HAL_StatusTypeDef CANInit(void); 71 | void slcanSetCANBaudRate(uint8_t br); 72 | 73 | #endif /* SLCAN_ADDITIONAL_H_ */ 74 | 75 | -------------------------------------------------------------------------------- /Src/stm32f0xx_hal_msp.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : stm32f0xx_hal_msp.c 4 | * Description : This file provides code for the MSP Initialization 5 | * and de-Initialization codes. 6 | ****************************************************************************** 7 | * This notice applies to any and all portions of this file 8 | * that are not between comment pairs USER CODE BEGIN and 9 | * USER CODE END. Other portions of this file, whether 10 | * inserted by the user or by software development tools 11 | * are owned by their respective copyright owners. 12 | * 13 | * Copyright (c) 2018 STMicroelectronics International N.V. 14 | * All rights reserved. 15 | * 16 | * Redistribution and use in source and binary forms, with or without 17 | * modification, are permitted, provided that the following conditions are met: 18 | * 19 | * 1. Redistribution of source code must retain the above copyright notice, 20 | * this list of conditions and the following disclaimer. 21 | * 2. Redistributions in binary form must reproduce the above copyright notice, 22 | * this list of conditions and the following disclaimer in the documentation 23 | * and/or other materials provided with the distribution. 24 | * 3. Neither the name of STMicroelectronics nor the names of other 25 | * contributors to this software may be used to endorse or promote products 26 | * derived from this software without specific written permission. 27 | * 4. This software, including modifications and/or derivative works of this 28 | * software, must execute solely and exclusively on microcontroller or 29 | * microprocessor devices manufactured by or for STMicroelectronics. 30 | * 5. Redistribution and use of this software other than as permitted under 31 | * this license is void and will automatically terminate your rights under 32 | * this license. 33 | * 34 | * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" 35 | * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT 36 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 37 | * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY 38 | * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT 39 | * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 40 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 41 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 42 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 43 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 44 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 45 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 46 | * 47 | ****************************************************************************** 48 | */ 49 | /* Includes ------------------------------------------------------------------*/ 50 | #include "stm32f0xx_hal.h" 51 | 52 | extern void _Error_Handler(char *, int); 53 | /* USER CODE BEGIN 0 */ 54 | 55 | /* USER CODE END 0 */ 56 | /** 57 | * Initializes the Global MSP. 58 | */ 59 | void HAL_MspInit(void) 60 | { 61 | /* USER CODE BEGIN MspInit 0 */ 62 | 63 | /* USER CODE END MspInit 0 */ 64 | 65 | __HAL_RCC_SYSCFG_CLK_ENABLE(); 66 | __HAL_RCC_PWR_CLK_ENABLE(); 67 | 68 | /* System interrupt init*/ 69 | /* SVC_IRQn interrupt configuration */ 70 | HAL_NVIC_SetPriority(SVC_IRQn, 0, 0); 71 | /* PendSV_IRQn interrupt configuration */ 72 | HAL_NVIC_SetPriority(PendSV_IRQn, 0, 0); 73 | /* SysTick_IRQn interrupt configuration */ 74 | HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); 75 | 76 | /* USER CODE BEGIN MspInit 1 */ 77 | 78 | /* USER CODE END MspInit 1 */ 79 | } 80 | 81 | void HAL_CAN_MspInit(CAN_HandleTypeDef* hcan) 82 | { 83 | 84 | GPIO_InitTypeDef GPIO_InitStruct; 85 | if(hcan->Instance==CAN) 86 | { 87 | /* USER CODE BEGIN CAN_MspInit 0 */ 88 | 89 | /* USER CODE END CAN_MspInit 0 */ 90 | /* Peripheral clock enable */ 91 | __HAL_RCC_CAN1_CLK_ENABLE(); 92 | 93 | /**CAN GPIO Configuration 94 | PB8 ------> CAN_RX 95 | PB9 ------> CAN_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_HIGH; 101 | GPIO_InitStruct.Alternate = GPIO_AF4_CAN; 102 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); 103 | 104 | /* USER CODE BEGIN CAN_MspInit 1 */ 105 | 106 | /* USER CODE END CAN_MspInit 1 */ 107 | } 108 | 109 | } 110 | 111 | void HAL_CAN_MspDeInit(CAN_HandleTypeDef* hcan) 112 | { 113 | 114 | if(hcan->Instance==CAN) 115 | { 116 | /* USER CODE BEGIN CAN_MspDeInit 0 */ 117 | 118 | /* USER CODE END CAN_MspDeInit 0 */ 119 | /* Peripheral clock disable */ 120 | __HAL_RCC_CAN1_CLK_DISABLE(); 121 | 122 | /**CAN GPIO Configuration 123 | PB8 ------> CAN_RX 124 | PB9 ------> CAN_TX 125 | */ 126 | HAL_GPIO_DeInit(GPIOB, GPIO_PIN_8|GPIO_PIN_9); 127 | 128 | /* USER CODE BEGIN CAN_MspDeInit 1 */ 129 | 130 | /* USER CODE END CAN_MspDeInit 1 */ 131 | } 132 | 133 | } 134 | 135 | void HAL_UART_MspInit(UART_HandleTypeDef* huart) 136 | { 137 | 138 | GPIO_InitTypeDef GPIO_InitStruct; 139 | if(huart->Instance==USART2) 140 | { 141 | /* USER CODE BEGIN USART2_MspInit 0 */ 142 | 143 | /* USER CODE END USART2_MspInit 0 */ 144 | /* Peripheral clock enable */ 145 | __HAL_RCC_USART2_CLK_ENABLE(); 146 | 147 | /**USART2 GPIO Configuration 148 | PA2 ------> USART2_TX 149 | PA3 ------> USART2_RX 150 | */ 151 | GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3; 152 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 153 | GPIO_InitStruct.Pull = GPIO_NOPULL; 154 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; 155 | GPIO_InitStruct.Alternate = GPIO_AF1_USART2; 156 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 157 | 158 | /* USER CODE BEGIN USART2_MspInit 1 */ 159 | 160 | /* USER CODE END USART2_MspInit 1 */ 161 | } 162 | 163 | } 164 | 165 | void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) 166 | { 167 | 168 | if(huart->Instance==USART2) 169 | { 170 | /* USER CODE BEGIN USART2_MspDeInit 0 */ 171 | 172 | /* USER CODE END USART2_MspDeInit 0 */ 173 | /* Peripheral clock disable */ 174 | __HAL_RCC_USART2_CLK_DISABLE(); 175 | 176 | /**USART2 GPIO Configuration 177 | PA2 ------> USART2_TX 178 | PA3 ------> USART2_RX 179 | */ 180 | HAL_GPIO_DeInit(GPIOA, GPIO_PIN_2|GPIO_PIN_3); 181 | 182 | /* USER CODE BEGIN USART2_MspDeInit 1 */ 183 | 184 | /* USER CODE END USART2_MspDeInit 1 */ 185 | } 186 | 187 | } 188 | 189 | /* USER CODE BEGIN 1 */ 190 | 191 | /* USER CODE END 1 */ 192 | 193 | /** 194 | * @} 195 | */ 196 | 197 | /** 198 | * @} 199 | */ 200 | 201 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 202 | -------------------------------------------------------------------------------- /Src/stm32f0xx_it.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f0xx_it.c 4 | * @brief Interrupt Service Routines. 5 | ****************************************************************************** 6 | * 7 | * COPYRIGHT(c) 2018 STMicroelectronics 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 1. Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 17 | * may be used to endorse or promote products derived from this software 18 | * without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | ****************************************************************************** 32 | */ 33 | /* Includes ------------------------------------------------------------------*/ 34 | #include "stm32f0xx_hal.h" 35 | #include "stm32f0xx.h" 36 | #include "stm32f0xx_it.h" 37 | 38 | /* USER CODE BEGIN 0 */ 39 | 40 | /* USER CODE END 0 */ 41 | 42 | /* External variables --------------------------------------------------------*/ 43 | extern PCD_HandleTypeDef hpcd_USB_FS; 44 | 45 | /******************************************************************************/ 46 | /* Cortex-M0 Processor Interruption and Exception Handlers */ 47 | /******************************************************************************/ 48 | 49 | /** 50 | * @brief This function handles Non maskable interrupt. 51 | */ 52 | void NMI_Handler(void) 53 | { 54 | /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ 55 | 56 | /* USER CODE END NonMaskableInt_IRQn 0 */ 57 | /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ 58 | 59 | /* USER CODE END NonMaskableInt_IRQn 1 */ 60 | } 61 | 62 | /** 63 | * @brief This function handles Hard fault interrupt. 64 | */ 65 | void HardFault_Handler(void) 66 | { 67 | /* USER CODE BEGIN HardFault_IRQn 0 */ 68 | 69 | /* USER CODE END HardFault_IRQn 0 */ 70 | while (1) 71 | { 72 | /* USER CODE BEGIN W1_HardFault_IRQn 0 */ 73 | /* USER CODE END W1_HardFault_IRQn 0 */ 74 | } 75 | /* USER CODE BEGIN HardFault_IRQn 1 */ 76 | 77 | /* USER CODE END HardFault_IRQn 1 */ 78 | } 79 | 80 | /** 81 | * @brief This function handles System service call via SWI instruction. 82 | */ 83 | void SVC_Handler(void) 84 | { 85 | /* USER CODE BEGIN SVC_IRQn 0 */ 86 | 87 | /* USER CODE END SVC_IRQn 0 */ 88 | /* USER CODE BEGIN SVC_IRQn 1 */ 89 | 90 | /* USER CODE END SVC_IRQn 1 */ 91 | } 92 | 93 | /** 94 | * @brief This function handles Pendable request for system service. 95 | */ 96 | void PendSV_Handler(void) 97 | { 98 | /* USER CODE BEGIN PendSV_IRQn 0 */ 99 | 100 | /* USER CODE END PendSV_IRQn 0 */ 101 | /* USER CODE BEGIN PendSV_IRQn 1 */ 102 | 103 | /* USER CODE END PendSV_IRQn 1 */ 104 | } 105 | 106 | /** 107 | * @brief This function handles System tick timer. 108 | */ 109 | void SysTick_Handler(void) 110 | { 111 | /* USER CODE BEGIN SysTick_IRQn 0 */ 112 | 113 | /* USER CODE END SysTick_IRQn 0 */ 114 | HAL_IncTick(); 115 | HAL_SYSTICK_IRQHandler(); 116 | /* USER CODE BEGIN SysTick_IRQn 1 */ 117 | 118 | /* USER CODE END SysTick_IRQn 1 */ 119 | } 120 | 121 | /******************************************************************************/ 122 | /* STM32F0xx Peripheral Interrupt Handlers */ 123 | /* Add here the Interrupt Handlers for the used peripherals. */ 124 | /* For the available peripheral interrupt handler names, */ 125 | /* please refer to the startup file (startup_stm32f0xx.s). */ 126 | /******************************************************************************/ 127 | 128 | /** 129 | * @brief This function handles USB global Interrupt / USB wake-up interrupt through EXTI line 18. 130 | */ 131 | void USB_IRQHandler(void) 132 | { 133 | /* USER CODE BEGIN USB_IRQn 0 */ 134 | 135 | /* USER CODE END USB_IRQn 0 */ 136 | HAL_PCD_IRQHandler(&hpcd_USB_FS); 137 | /* USER CODE BEGIN USB_IRQn 1 */ 138 | 139 | /* USER CODE END USB_IRQn 1 */ 140 | } 141 | 142 | /* USER CODE BEGIN 1 */ 143 | extern CAN_HandleTypeDef hcan; 144 | void CEC_CAN_IRQHandler(void) 145 | { 146 | HAL_CAN_IRQHandler(&hcan); 147 | } 148 | 149 | extern UART_HandleTypeDef huart2; 150 | void USART2_IRQHandler(void) 151 | { 152 | UART_HandleTypeDef * huart = &huart2; 153 | // uint16_t uhMask = huart->Mask; 154 | // huart->rx = huart->Instance->RDR & (uint8_t)uhMask; 155 | // HAL_UART_RxCpltCallback(&huart2); 156 | UART_Receive_IT(huart); 157 | 158 | } 159 | /* USER CODE END 1 */ 160 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 161 | -------------------------------------------------------------------------------- /Src/usb_device.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file : usb_device.c 4 | * @version : v2.0_Cube 5 | * @brief : This file implements the USB Device 6 | ****************************************************************************** 7 | * This notice applies to any and all portions of this file 8 | * that are not between comment pairs USER CODE BEGIN and 9 | * USER CODE END. Other portions of this file, whether 10 | * inserted by the user or by software development tools 11 | * are owned by their respective copyright owners. 12 | * 13 | * Copyright (c) 2018 STMicroelectronics International N.V. 14 | * All rights reserved. 15 | * 16 | * Redistribution and use in source and binary forms, with or without 17 | * modification, are permitted, provided that the following conditions are met: 18 | * 19 | * 1. Redistribution of source code must retain the above copyright notice, 20 | * this list of conditions and the following disclaimer. 21 | * 2. Redistributions in binary form must reproduce the above copyright notice, 22 | * this list of conditions and the following disclaimer in the documentation 23 | * and/or other materials provided with the distribution. 24 | * 3. Neither the name of STMicroelectronics nor the names of other 25 | * contributors to this software may be used to endorse or promote products 26 | * derived from this software without specific written permission. 27 | * 4. This software, including modifications and/or derivative works of this 28 | * software, must execute solely and exclusively on microcontroller or 29 | * microprocessor devices manufactured by or for STMicroelectronics. 30 | * 5. Redistribution and use of this software other than as permitted under 31 | * this license is void and will automatically terminate your rights under 32 | * this license. 33 | * 34 | * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" 35 | * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT 36 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 37 | * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY 38 | * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT 39 | * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 40 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 41 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 42 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 43 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 44 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 45 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 46 | * 47 | ****************************************************************************** 48 | */ 49 | 50 | /* Includes ------------------------------------------------------------------*/ 51 | 52 | #include "usb_device.h" 53 | #include "usbd_core.h" 54 | #include "usbd_desc.h" 55 | #include "usbd_cdc.h" 56 | #include "usbd_cdc_if.h" 57 | 58 | /* USER CODE BEGIN Includes */ 59 | 60 | /* USER CODE END Includes */ 61 | 62 | /* USER CODE BEGIN PV */ 63 | /* Private variables ---------------------------------------------------------*/ 64 | 65 | /* USER CODE END PV */ 66 | 67 | /* USER CODE BEGIN PFP */ 68 | /* Private function prototypes -----------------------------------------------*/ 69 | 70 | /* USER CODE END PFP */ 71 | 72 | /* USB Device Core handle declaration. */ 73 | USBD_HandleTypeDef hUsbDeviceFS; 74 | 75 | /* 76 | * -- Insert your variables declaration here -- 77 | */ 78 | /* USER CODE BEGIN 0 */ 79 | 80 | /* USER CODE END 0 */ 81 | 82 | /* 83 | * -- Insert your external function declaration here -- 84 | */ 85 | /* USER CODE BEGIN 1 */ 86 | 87 | /* USER CODE END 1 */ 88 | 89 | /** 90 | * Init USB device Library, add supported class and start the library 91 | * @retval None 92 | */ 93 | void MX_USB_DEVICE_Init(void) 94 | { 95 | /* USER CODE BEGIN USB_DEVICE_Init_PreTreatment */ 96 | 97 | /* USER CODE END USB_DEVICE_Init_PreTreatment */ 98 | 99 | /* Init Device Library, add supported class and start the library. */ 100 | USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS); 101 | 102 | USBD_RegisterClass(&hUsbDeviceFS, &USBD_CDC); 103 | 104 | USBD_CDC_RegisterInterface(&hUsbDeviceFS, &USBD_Interface_fops_FS); 105 | 106 | USBD_Start(&hUsbDeviceFS); 107 | 108 | /* USER CODE BEGIN USB_DEVICE_Init_PostTreatment */ 109 | 110 | /* USER CODE END USB_DEVICE_Init_PostTreatment */ 111 | } 112 | 113 | /** 114 | * @} 115 | */ 116 | 117 | /** 118 | * @} 119 | */ 120 | 121 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 122 | -------------------------------------------------------------------------------- /UCCBEmbedded.elf (1).launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /UCCBEmbedded.elf.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /UCCBEmbedded.ioc: -------------------------------------------------------------------------------- 1 | #MicroXplorer Configuration settings - do not modify 2 | CAN.ABOM=ENABLE 3 | CAN.BS1=CAN_BS1_11TQ 4 | CAN.BS2=CAN_BS2_4TQ 5 | CAN.CalculateTimeBit=1000 6 | CAN.CalculateTimeQuantum=62.5 7 | CAN.IPParameters=CalculateTimeQuantum,CalculateTimeBit,Prescaler,BS1,BS2,SJW,ABOM 8 | CAN.Prescaler=3 9 | CAN.SJW=CAN_SJW_2TQ 10 | File.Version=6 11 | IWDG.IPParameters=Prescaler 12 | IWDG.Prescaler=IWDG_PRESCALER_64 13 | KeepUserPlacement=false 14 | Mcu.Family=STM32F0 15 | Mcu.IP0=CAN 16 | Mcu.IP1=IWDG 17 | Mcu.IP2=NVIC 18 | Mcu.IP3=RCC 19 | Mcu.IP4=SYS 20 | Mcu.IP5=USART2 21 | Mcu.IP6=USB 22 | Mcu.IP7=USB_DEVICE 23 | Mcu.IPNb=8 24 | Mcu.Name=STM32F042C(4-6)Tx 25 | Mcu.Package=LQFP48 26 | Mcu.Pin0=PF0-OSC_IN 27 | Mcu.Pin1=PA2 28 | Mcu.Pin2=PA3 29 | Mcu.Pin3=PA11 30 | Mcu.Pin4=PA12 31 | Mcu.Pin5=PB8 32 | Mcu.Pin6=PB9 33 | Mcu.Pin7=VP_IWDG_VS_IWDG 34 | Mcu.Pin8=VP_SYS_VS_Systick 35 | Mcu.Pin9=VP_USB_DEVICE_VS_USB_DEVICE_CDC_FS 36 | Mcu.PinsNb=10 37 | Mcu.ThirdPartyNb=0 38 | Mcu.UserConstants= 39 | Mcu.UserName=STM32F042C6Tx 40 | MxCube.Version=4.26.0 41 | MxDb.Version=DB.4.0.260 42 | NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:true 43 | NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:true 44 | NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:true 45 | NVIC.SVC_IRQn=true\:0\:0\:false\:false\:true\:true 46 | NVIC.SysTick_IRQn=true\:0\:0\:true\:false\:true\:true 47 | NVIC.USB_IRQn=true\:0\:0\:true\:false\:true\:true 48 | PA11.Mode=Device 49 | PA11.Signal=USB_DM 50 | PA12.Mode=Device 51 | PA12.Signal=USB_DP 52 | PA2.Mode=Asynchronous 53 | PA2.Signal=USART2_TX 54 | PA3.Mode=Asynchronous 55 | PA3.Signal=USART2_RX 56 | PB8.Mode=Master 57 | PB8.Signal=CAN_RX 58 | PB9.Mode=Master 59 | PB9.Signal=CAN_TX 60 | PCC.Checker=false 61 | PCC.Line=STM32F0x2 62 | PCC.MCU=STM32F042C(4-6)Tx 63 | PCC.PartNumber=STM32F042C6Tx 64 | PCC.Seq0=0 65 | PCC.Series=STM32F0 66 | PCC.Temperature=25 67 | PCC.Vdd=3.6 68 | PF0-OSC_IN.GPIOParameters=GPIO_Label 69 | PF0-OSC_IN.GPIO_Label=CAN_MOD 70 | PF0-OSC_IN.Locked=true 71 | PF0-OSC_IN.Signal=GPIO_Output 72 | PinOutPanel.RotationAngle=0 73 | ProjectManager.AskForMigrate=true 74 | ProjectManager.BackupPrevious=false 75 | ProjectManager.CompilerOptimize=2 76 | ProjectManager.ComputerToolchain=false 77 | ProjectManager.CoupleFile=false 78 | ProjectManager.CustomerFirmwarePackage= 79 | ProjectManager.DefaultFWLocation=true 80 | ProjectManager.DeletePrevious=true 81 | ProjectManager.DeviceId=STM32F042C6Tx 82 | ProjectManager.FirmwarePackage=STM32Cube FW_F0 V1.9.0 83 | ProjectManager.FreePins=false 84 | ProjectManager.HalAssertFull=false 85 | ProjectManager.HeapSize=0x200 86 | ProjectManager.KeepUserCode=true 87 | ProjectManager.LastFirmware=true 88 | ProjectManager.LibraryCopy=1 89 | ProjectManager.MainLocation=Src 90 | ProjectManager.PreviousToolchain=TrueSTUDIO 91 | ProjectManager.ProjectBuild=false 92 | ProjectManager.ProjectFileName=UCCBEmbedded.ioc 93 | ProjectManager.ProjectName=UCCBEmbedded 94 | ProjectManager.StackSize=0x400 95 | ProjectManager.TargetToolchain=TrueSTUDIO 96 | ProjectManager.ToolChainLocation= 97 | ProjectManager.UnderRoot=true 98 | ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-true,3-MX_CAN_Init-CAN-false-HAL-true,4-MX_USART2_UART_Init-USART2-false-HAL-true,5-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-true,6-MX_IWDG_Init-IWDG-false-HAL-true 99 | RCC.AHBFreq_Value=48000000 100 | RCC.APB1Freq_Value=48000000 101 | RCC.APB1TimFreq_Value=48000000 102 | RCC.CECFreq_Value=32786.88524590164 103 | RCC.FCLKCortexFreq_Value=48000000 104 | RCC.FamilyName=M 105 | RCC.HCLKFreq_Value=48000000 106 | RCC.HSICECFreq_Value=32786.88524590164 107 | RCC.I2SFreq_Value=48000000 108 | RCC.IPParameters=AHBFreq_Value,APB1Freq_Value,APB1TimFreq_Value,CECFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSICECFreq_Value,I2SFreq_Value,MCOFreq_Value,PLLCLKFreq_Value,PLLMCOFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,TimSysFreq_Value,USART1Freq_Value,VCOOutput2Freq_Value 109 | RCC.MCOFreq_Value=48000000 110 | RCC.PLLCLKFreq_Value=16000000 111 | RCC.PLLMCOFreq_Value=16000000 112 | RCC.SYSCLKFreq_VALUE=48000000 113 | RCC.SYSCLKSource=RCC_SYSCLKSOURCE_HSI48 114 | RCC.TimSysFreq_Value=48000000 115 | RCC.USART1Freq_Value=48000000 116 | RCC.VCOOutput2Freq_Value=8000000 117 | USART2.BaudRate=115200 118 | USART2.IPParameters=BaudRate,WordLength,VirtualMode-Asynchronous 119 | USART2.VirtualMode-Asynchronous=VM_ASYNC 120 | USART2.WordLength=WORDLENGTH_8B 121 | USB_DEVICE.CLASS_NAME_FS=CDC 122 | USB_DEVICE.IPParameters=VirtualMode,VirtualModeFS,USBD_HandleTypeDef,CLASS_NAME_FS,MANUFACTURER_STRING,PRODUCT_STRING_CDC_FS 123 | USB_DEVICE.MANUFACTURER_STRING=CANDevices 124 | USB_DEVICE.PRODUCT_STRING_CDC_FS=CAN_USB_ConverterBasic 125 | USB_DEVICE.USBD_HandleTypeDef=hUsbDeviceFS 126 | USB_DEVICE.VirtualMode=Cdc 127 | USB_DEVICE.VirtualModeFS=Cdc_FS 128 | VP_IWDG_VS_IWDG.Mode=IWDG_Activate 129 | VP_IWDG_VS_IWDG.Signal=IWDG_VS_IWDG 130 | VP_SYS_VS_Systick.Mode=SysTick 131 | VP_SYS_VS_Systick.Signal=SYS_VS_Systick 132 | VP_USB_DEVICE_VS_USB_DEVICE_CDC_FS.Mode=CDC_FS 133 | VP_USB_DEVICE_VS_USB_DEVICE_CDC_FS.Signal=USB_DEVICE_VS_USB_DEVICE_CDC_FS 134 | board=UCCBEmbedded 135 | -------------------------------------------------------------------------------- /script/UCCB_Upload.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | /mnt/d/Programy/STMicroelectronics/STM32CubeProgrammer/bin/STM32_Programmer_CLI.exe -c port=usb1 -e all -d ./0303.hex 0x08000000 -v -s 5 | -------------------------------------------------------------------------------- /script/test_dongle.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | from pyusbtin.usbtin import USBtin 4 | from pyusbtin.canmessage import CANMessage 5 | from time import sleep 6 | 7 | import sys 8 | 9 | can1_rx = 0 10 | can2_rx = 0 11 | 12 | def log_data1(msg): 13 | global can1_rx 14 | print("RX") 15 | print(msg) 16 | can1_rx = can1_rx + 1 17 | 18 | def log_data2(msg): 19 | global can2_rx 20 | print("RX") 21 | print(msg) 22 | can2_rx = can2_rx + 1 23 | 24 | while(True): 25 | input("Press Enter to start Test...") 26 | 27 | usbtin1 = USBtin() 28 | usbtin1.connect(sys.argv[1]) 29 | usbtin1.add_message_listener(log_data1) 30 | usbtin1.open_can_channel(100000, USBtin.ACTIVE) 31 | # usbtin1.serial_port.timeout = 1000 32 | 33 | usbtin2 = USBtin() 34 | usbtin2.connect(sys.argv[2]) 35 | usbtin2.add_message_listener(log_data2) 36 | usbtin2.open_can_channel(100000, USBtin.ACTIVE) 37 | # usbtin2.serial_port.timeout = 1000 38 | 39 | can1_rx = 0 40 | can2_rx = 0 41 | test_pending = 1 42 | test_cycle = 0 43 | while(test_pending): 44 | print("TX") 45 | usbtin1.send(CANMessage(0x100, [1,2,3,4])) 46 | sleep(0.1) 47 | usbtin2.send(CANMessage(0x200, [7,8])) 48 | sleep(0.1) 49 | if ((can1_rx > 1) and (can2_rx > 1)): 50 | test_pending = 0 51 | print("-------- DONGLE OK ------------") 52 | test_cycle = test_cycle + 1 53 | if (test_cycle > 10): 54 | test_pending = 0 55 | print("-------- DONGLE NO RX/TX ------------") 56 | usbtin1.close_can_channel() 57 | usbtin2.close_can_channel() 58 | 59 | 60 | 61 | --------------------------------------------------------------------------------