├── .gitignore ├── .mxproject ├── Drivers ├── CMSIS │ ├── Device │ │ └── ST │ │ │ └── STM32F1xx │ │ │ ├── Include │ │ │ ├── stm32f100xb.h │ │ │ ├── stm32f100xe.h │ │ │ ├── stm32f101x6.h │ │ │ ├── stm32f101xb.h │ │ │ ├── stm32f101xe.h │ │ │ ├── stm32f101xg.h │ │ │ ├── stm32f102x6.h │ │ │ ├── stm32f102xb.h │ │ │ ├── stm32f103x6.h │ │ │ ├── stm32f103xb.h │ │ │ ├── stm32f103xe.h │ │ │ ├── stm32f103xg.h │ │ │ ├── stm32f105xc.h │ │ │ ├── stm32f107xc.h │ │ │ ├── stm32f1xx.h │ │ │ └── system_stm32f1xx.h │ │ │ └── Source │ │ │ └── Templates │ │ │ ├── gcc │ │ │ └── startup_stm32f103xb.s │ │ │ └── system_stm32f1xx.c │ └── Include │ │ ├── arm_common_tables.h │ │ ├── arm_const_structs.h │ │ ├── arm_math.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 └── STM32F1xx_HAL_Driver │ ├── Inc │ ├── Legacy │ │ └── stm32_hal_legacy.h │ ├── stm32f1xx_hal.h │ ├── stm32f1xx_hal_cortex.h │ ├── stm32f1xx_hal_def.h │ ├── stm32f1xx_hal_dma.h │ ├── stm32f1xx_hal_dma_ex.h │ ├── stm32f1xx_hal_flash.h │ ├── stm32f1xx_hal_flash_ex.h │ ├── stm32f1xx_hal_gpio.h │ ├── stm32f1xx_hal_gpio_ex.h │ ├── stm32f1xx_hal_pcd.h │ ├── stm32f1xx_hal_pcd_ex.h │ ├── stm32f1xx_hal_pwr.h │ ├── stm32f1xx_hal_rcc.h │ ├── stm32f1xx_hal_rcc_ex.h │ ├── stm32f1xx_hal_tim.h │ ├── stm32f1xx_hal_tim_ex.h │ └── stm32f1xx_ll_usb.h │ └── Src │ ├── stm32f1xx_hal.c │ ├── stm32f1xx_hal_cortex.c │ ├── stm32f1xx_hal_dma.c │ ├── stm32f1xx_hal_flash.c │ ├── stm32f1xx_hal_flash_ex.c │ ├── stm32f1xx_hal_gpio.c │ ├── stm32f1xx_hal_gpio_ex.c │ ├── stm32f1xx_hal_pcd.c │ ├── stm32f1xx_hal_pcd_ex.c │ ├── stm32f1xx_hal_pwr.c │ ├── stm32f1xx_hal_rcc.c │ ├── stm32f1xx_hal_rcc_ex.c │ ├── stm32f1xx_hal_tim.c │ ├── stm32f1xx_hal_tim_ex.c │ └── stm32f1xx_ll_usb.c ├── Inc ├── mxconstants.h ├── stm32f1xx_hal_conf.h ├── stm32f1xx_it.h ├── usb_device.h ├── usbd_conf.h └── usbd_desc.h ├── Middlewares └── ST │ └── STM32_USB_Device_Library │ ├── Class │ └── HID │ │ ├── Inc │ │ ├── usbd_hid.h │ │ └── usbd_hid.h.bak │ │ └── Src │ │ ├── usbd_hid.c │ │ └── usbd_hid.c.bak │ └── Core │ ├── Inc │ ├── usbd_core.h │ ├── usbd_ctlreq.h │ ├── usbd_def.h │ ├── usbd_def.h.bak │ └── usbd_ioreq.h │ └── Src │ ├── usbd_core.c │ ├── usbd_ctlreq.c │ └── usbd_ioreq.c ├── README.md ├── Src ├── main.c ├── startup_stm32f10x_md.s ├── stm32f1xx_hal_msp.c ├── stm32f1xx_it.c ├── usb_device.c ├── usbd_conf.c └── usbd_desc.c ├── stm32_PPM_F103.cogui ├── stm32_PPM_F103.comarker ├── stm32_PPM_F103.comemgui ├── stm32_PPM_F103.coproj ├── stm32_PPM_F103.ioc ├── stm32_PPM_F103.txt ├── stm32_PPM_F103 ├── Debug │ ├── bin │ │ ├── history.xml │ │ ├── stm32_PPM_F103.bin │ │ ├── stm32_PPM_F103.elf │ │ ├── stm32_PPM_F103.hex │ │ └── stm32_PPM_F103.map │ └── obj │ │ ├── history.xml │ │ ├── main.o │ │ ├── startup_stm32f10x_md.o │ │ ├── stm32f1xx_hal.o │ │ ├── stm32f1xx_hal_cortex.o │ │ ├── stm32f1xx_hal_dma.o │ │ ├── stm32f1xx_hal_flash.o │ │ ├── stm32f1xx_hal_flash_ex.o │ │ ├── stm32f1xx_hal_gpio.o │ │ ├── stm32f1xx_hal_gpio_ex.o │ │ ├── stm32f1xx_hal_msp.o │ │ ├── stm32f1xx_hal_pcd.o │ │ ├── stm32f1xx_hal_pcd_ex.o │ │ ├── stm32f1xx_hal_pwr.o │ │ ├── stm32f1xx_hal_rcc.o │ │ ├── stm32f1xx_hal_rcc_ex.o │ │ ├── stm32f1xx_hal_tim.o │ │ ├── stm32f1xx_hal_tim_ex.o │ │ ├── stm32f1xx_it.o │ │ ├── stm32f1xx_ll_usb.o │ │ ├── system_stm32f1xx.o │ │ ├── usb_device.o │ │ ├── usbd_conf.o │ │ ├── usbd_core.o │ │ ├── usbd_ctlreq.o │ │ ├── usbd_desc.o │ │ ├── usbd_hid.o │ │ └── usbd_ioreq.o └── stm32_PPM_F103.elf.xcodeproj │ └── project.pbxproj └── stm32_PPM_F103_Configuration.pdf /.gitignore: -------------------------------------------------------------------------------- 1 | *.sublime* 2 | -------------------------------------------------------------------------------- /.mxproject: -------------------------------------------------------------------------------- 1 | [PreviousGenFiles] 2 | HeaderPath=D:/WorkSTM32/stm32_PPM_F103/Inc 3 | SourcePath=D:/WorkSTM32/stm32_PPM_F103/Src 4 | SourceFiles=usb_device.h;usbd_conf.h;usbd_desc.h;stm32f1xx_it.h;stm32f1xx_hal_conf.h;mxconstants.h;usb_device.c;usbd_conf.c;usbd_desc.c;stm32f1xx_it.c;stm32f1xx_hal_msp.c;main.c; 5 | HeaderFiles=usb_device.h;usbd_conf.h;usbd_desc.h;stm32f1xx_it.h;stm32f1xx_hal_conf.h;mxconstants.h; 6 | 7 | [PreviousLibFiles] 8 | LibFiles=Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_pcd.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_pcd_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_usb.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_def.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_cortex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_pwr.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/HID/Inc/usbd_hid.h;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pcd.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pcd_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_usb.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.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/HID/Src/usbd_hid.c;Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/system_stm32f1xx.c;Drivers/CMSIS/Include/arm_common_tables.h;Drivers/CMSIS/Include/arm_const_structs.h;Drivers/CMSIS/Include/arm_math.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;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f100xb.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f100xe.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f101x6.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f101xb.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f101xe.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f101xg.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f102x6.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f102xb.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103x6.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xe.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xg.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f105xc.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f107xc.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f1xx.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/system_stm32f1xx.h; 9 | 10 | [PreviousUsedTStudioFiles] 11 | HeaderPath=..\Drivers\STM32F1xx_HAL_Driver\Inc;..\Drivers\STM32F1xx_HAL_Driver\Inc\Legacy;..\Middlewares\ST\STM32_USB_Device_Library\Core\Inc;..\Middlewares\ST\STM32_USB_Device_Library\Class\HID\Inc;..\Drivers\CMSIS\Include;..\Drivers\CMSIS\Device\ST\STM32F1xx\Include; 12 | SourceFiles=../Src/main.c;../Src/usb_device.c;../Src/usbd_conf.c;../Src/usbd_desc.c;../Src/stm32f1xx_it.c;../Src/stm32f1xx_hal_msp.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pcd.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pcd_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_usb.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.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/HID/Src/usbd_hid.c;../Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/system_stm32f1xx.c;../Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f103xb.s;../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/HID/Src/usbd_hid.c; 13 | 14 | -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f100xb.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voroshkov/STM32-RC-USB-Adapter/afb6fe4015db4f0c237fd50d51814f468beb3ed4/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f100xb.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f100xe.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voroshkov/STM32-RC-USB-Adapter/afb6fe4015db4f0c237fd50d51814f468beb3ed4/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f100xe.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f101x6.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voroshkov/STM32-RC-USB-Adapter/afb6fe4015db4f0c237fd50d51814f468beb3ed4/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f101x6.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f101xb.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voroshkov/STM32-RC-USB-Adapter/afb6fe4015db4f0c237fd50d51814f468beb3ed4/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f101xb.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f101xe.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voroshkov/STM32-RC-USB-Adapter/afb6fe4015db4f0c237fd50d51814f468beb3ed4/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f101xe.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f101xg.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voroshkov/STM32-RC-USB-Adapter/afb6fe4015db4f0c237fd50d51814f468beb3ed4/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f101xg.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f102x6.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voroshkov/STM32-RC-USB-Adapter/afb6fe4015db4f0c237fd50d51814f468beb3ed4/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f102x6.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f102xb.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voroshkov/STM32-RC-USB-Adapter/afb6fe4015db4f0c237fd50d51814f468beb3ed4/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f102xb.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103x6.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voroshkov/STM32-RC-USB-Adapter/afb6fe4015db4f0c237fd50d51814f468beb3ed4/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103x6.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voroshkov/STM32-RC-USB-Adapter/afb6fe4015db4f0c237fd50d51814f468beb3ed4/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xe.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voroshkov/STM32-RC-USB-Adapter/afb6fe4015db4f0c237fd50d51814f468beb3ed4/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xe.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xg.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voroshkov/STM32-RC-USB-Adapter/afb6fe4015db4f0c237fd50d51814f468beb3ed4/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xg.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f105xc.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voroshkov/STM32-RC-USB-Adapter/afb6fe4015db4f0c237fd50d51814f468beb3ed4/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f105xc.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f107xc.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voroshkov/STM32-RC-USB-Adapter/afb6fe4015db4f0c237fd50d51814f468beb3ed4/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f107xc.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f1xx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voroshkov/STM32-RC-USB-Adapter/afb6fe4015db4f0c237fd50d51814f468beb3ed4/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f1xx.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Include/system_stm32f1xx.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32f10x.h 4 | * @author MCD Application Team 5 | * @version V4.0.1 6 | * @date 31-July-2015 7 | * @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Header File. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT(c) 2015 STMicroelectronics

12 | * 13 | * Redistribution and use in source and binary forms, with or without modification, 14 | * are permitted provided that the following conditions are met: 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, 18 | * this list of conditions and the following disclaimer in the documentation 19 | * and/or other materials provided with the distribution. 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 21 | * may be used to endorse or promote products derived from this software 22 | * without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | ****************************************************************************** 36 | */ 37 | 38 | /** @addtogroup CMSIS 39 | * @{ 40 | */ 41 | 42 | /** @addtogroup stm32f10x_system 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @brief Define to prevent recursive inclusion 48 | */ 49 | #ifndef __SYSTEM_STM32F10X_H 50 | #define __SYSTEM_STM32F10X_H 51 | 52 | #ifdef __cplusplus 53 | extern "C" { 54 | #endif 55 | 56 | /** @addtogroup STM32F10x_System_Includes 57 | * @{ 58 | */ 59 | 60 | /** 61 | * @} 62 | */ 63 | 64 | 65 | /** @addtogroup STM32F10x_System_Exported_types 66 | * @{ 67 | */ 68 | 69 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 70 | 71 | /** 72 | * @} 73 | */ 74 | 75 | /** @addtogroup STM32F10x_System_Exported_Constants 76 | * @{ 77 | */ 78 | 79 | /** 80 | * @} 81 | */ 82 | 83 | /** @addtogroup STM32F10x_System_Exported_Macros 84 | * @{ 85 | */ 86 | 87 | /** 88 | * @} 89 | */ 90 | 91 | /** @addtogroup STM32F10x_System_Exported_Functions 92 | * @{ 93 | */ 94 | 95 | extern void SystemInit(void); 96 | extern void SystemCoreClockUpdate(void); 97 | /** 98 | * @} 99 | */ 100 | 101 | #ifdef __cplusplus 102 | } 103 | #endif 104 | 105 | #endif /*__SYSTEM_STM32F10X_H */ 106 | 107 | /** 108 | * @} 109 | */ 110 | 111 | /** 112 | * @} 113 | */ 114 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 115 | -------------------------------------------------------------------------------- /Drivers/CMSIS/Include/arm_common_tables.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_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/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f1xx_hal.h 4 | * @author MCD Application Team 5 | * @version V1.0.1 6 | * @date 31-July-2015 7 | * @brief This file contains all the functions prototypes for the HAL 8 | * module driver. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT(c) 2015 STMicroelectronics

13 | * 14 | * Redistribution and use in source and binary forms, with or without modification, 15 | * are permitted provided that the following conditions are met: 16 | * 1. Redistributions of source code must retain the above copyright notice, 17 | * this list of conditions and the following disclaimer. 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 22 | * may be used to endorse or promote products derived from this software 23 | * without specific prior written permission. 24 | * 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 28 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 31 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 33 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | ****************************************************************************** 37 | */ 38 | 39 | /* Define to prevent recursive inclusion -------------------------------------*/ 40 | #ifndef __STM32F1xx_HAL_H 41 | #define __STM32F1xx_HAL_H 42 | 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | /* Includes ------------------------------------------------------------------*/ 48 | #include "stm32f1xx_hal_conf.h" 49 | 50 | /** @addtogroup STM32F1xx_HAL_Driver 51 | * @{ 52 | */ 53 | 54 | /** @addtogroup HAL 55 | * @{ 56 | */ 57 | 58 | /* Exported types ------------------------------------------------------------*/ 59 | /* Exported constants --------------------------------------------------------*/ 60 | 61 | /* Exported macro ------------------------------------------------------------*/ 62 | 63 | /** @defgroup HAL_Exported_Macros HAL Exported Macros 64 | * @{ 65 | */ 66 | 67 | /** @defgroup DBGMCU_Freeze_Unfreeze Freeze Unfreeze Peripherals in Debug mode 68 | * @brief Freeze/Unfreeze Peripherals in Debug mode 69 | * Note: On devices STM32F10xx8 and STM32F10xxB, 70 | * STM32F101xC/D/E and STM32F103xC/D/E, 71 | * STM32F101xF/G and STM32F103xF/G 72 | * STM32F10xx4 and STM32F10xx6 73 | * Debug registers DBGMCU_IDCODE and DBGMCU_CR are accessible only in 74 | * debug mode (not accessible by the user software in normal mode). 75 | * Refer to errata sheet of these devices for more details. 76 | * @{ 77 | */ 78 | 79 | /* Peripherals on APB1 */ 80 | /** 81 | * @brief TIM2 Peripherals Debug mode 82 | */ 83 | #define __HAL_DBGMCU_FREEZE_TIM2() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM2_STOP) 84 | #define __HAL_DBGMCU_UNFREEZE_TIM2() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM2_STOP) 85 | 86 | /** 87 | * @brief TIM3 Peripherals Debug mode 88 | */ 89 | #define __HAL_DBGMCU_FREEZE_TIM3() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM3_STOP) 90 | #define __HAL_DBGMCU_UNFREEZE_TIM3() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM3_STOP) 91 | 92 | #if defined (DBGMCU_CR_DBG_TIM4_STOP) 93 | /** 94 | * @brief TIM4 Peripherals Debug mode 95 | */ 96 | #define __HAL_DBGMCU_FREEZE_TIM4() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM4_STOP) 97 | #define __HAL_DBGMCU_UNFREEZE_TIM4() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM4_STOP) 98 | #endif 99 | 100 | #if defined (DBGMCU_CR_DBG_TIM5_STOP) 101 | /** 102 | * @brief TIM5 Peripherals Debug mode 103 | */ 104 | #define __HAL_DBGMCU_FREEZE_TIM5() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM5_STOP) 105 | #define __HAL_DBGMCU_UNFREEZE_TIM5() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM5_STOP) 106 | #endif 107 | 108 | #if defined (DBGMCU_CR_DBG_TIM6_STOP) 109 | /** 110 | * @brief TIM6 Peripherals Debug mode 111 | */ 112 | #define __HAL_DBGMCU_FREEZE_TIM6() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM6_STOP) 113 | #define __HAL_DBGMCU_UNFREEZE_TIM6() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM6_STOP) 114 | #endif 115 | 116 | #if defined (DBGMCU_CR_DBG_TIM7_STOP) 117 | /** 118 | * @brief TIM7 Peripherals Debug mode 119 | */ 120 | #define __HAL_DBGMCU_FREEZE_TIM7() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM7_STOP) 121 | #define __HAL_DBGMCU_UNFREEZE_TIM7() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM7_STOP) 122 | #endif 123 | 124 | #if defined (DBGMCU_CR_DBG_TIM12_STOP) 125 | /** 126 | * @brief TIM12 Peripherals Debug mode 127 | */ 128 | #define __HAL_DBGMCU_FREEZE_TIM12() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM12_STOP) 129 | #define __HAL_DBGMCU_UNFREEZE_TIM12() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM12_STOP) 130 | #endif 131 | 132 | #if defined (DBGMCU_CR_DBG_TIM13_STOP) 133 | /** 134 | * @brief TIM13 Peripherals Debug mode 135 | */ 136 | #define __HAL_DBGMCU_FREEZE_TIM13() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM13_STOP) 137 | #define __HAL_DBGMCU_UNFREEZE_TIM13() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM13_STOP) 138 | #endif 139 | 140 | #if defined (DBGMCU_CR_DBG_TIM14_STOP) 141 | /** 142 | * @brief TIM14 Peripherals Debug mode 143 | */ 144 | #define __HAL_DBGMCU_FREEZE_TIM14() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM14_STOP) 145 | #define __HAL_DBGMCU_UNFREEZE_TIM14() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM14_STOP) 146 | #endif 147 | 148 | /** 149 | * @brief WWDG Peripherals Debug mode 150 | */ 151 | #define __HAL_DBGMCU_FREEZE_WWDG() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_WWDG_STOP) 152 | #define __HAL_DBGMCU_UNFREEZE_WWDG() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_WWDG_STOP) 153 | 154 | /** 155 | * @brief IWDG Peripherals Debug mode 156 | */ 157 | #define __HAL_DBGMCU_FREEZE_IWDG() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_IWDG_STOP) 158 | #define __HAL_DBGMCU_UNFREEZE_IWDG() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_IWDG_STOP) 159 | 160 | /** 161 | * @brief I2C1 Peripherals Debug mode 162 | */ 163 | #define __HAL_DBGMCU_FREEZE_I2C1_TIMEOUT() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_I2C1_SMBUS_TIMEOUT) 164 | #define __HAL_DBGMCU_UNFREEZE_I2C1_TIMEOUT() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_I2C1_SMBUS_TIMEOUT) 165 | 166 | #if defined (DBGMCU_CR_DBG_I2C2_SMBUS_TIMEOUT) 167 | /** 168 | * @brief I2C2 Peripherals Debug mode 169 | */ 170 | #define __HAL_DBGMCU_FREEZE_I2C2_TIMEOUT() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_I2C2_SMBUS_TIMEOUT) 171 | #define __HAL_DBGMCU_UNFREEZE_I2C2_TIMEOUT() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_I2C2_SMBUS_TIMEOUT) 172 | #endif 173 | 174 | #if defined (DBGMCU_CR_DBG_CAN1_STOP) 175 | /** 176 | * @brief CAN1 Peripherals Debug mode 177 | */ 178 | #define __HAL_DBGMCU_FREEZE_CAN1() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_CAN1_STOP) 179 | #define __HAL_DBGMCU_UNFREEZE_CAN1() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_CAN1_STOP) 180 | #endif 181 | 182 | #if defined (DBGMCU_CR_DBG_CAN2_STOP) 183 | /** 184 | * @brief CAN2 Peripherals Debug mode 185 | */ 186 | #define __HAL_DBGMCU_FREEZE_CAN2() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_CAN2_STOP) 187 | #define __HAL_DBGMCU_UNFREEZE_CAN2() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_CAN2_STOP) 188 | #endif 189 | 190 | /* Peripherals on APB2 */ 191 | #if defined (DBGMCU_CR_DBG_TIM1_STOP) 192 | /** 193 | * @brief TIM1 Peripherals Debug mode 194 | */ 195 | #define __HAL_DBGMCU_FREEZE_TIM1() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM1_STOP) 196 | #define __HAL_DBGMCU_UNFREEZE_TIM1() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM1_STOP) 197 | #endif 198 | 199 | #if defined (DBGMCU_CR_DBG_TIM8_STOP) 200 | /** 201 | * @brief TIM8 Peripherals Debug mode 202 | */ 203 | #define __HAL_DBGMCU_FREEZE_TIM8() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM8_STOP) 204 | #define __HAL_DBGMCU_UNFREEZE_TIM8() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM8_STOP) 205 | #endif 206 | 207 | #if defined (DBGMCU_CR_DBG_TIM9_STOP) 208 | /** 209 | * @brief TIM9 Peripherals Debug mode 210 | */ 211 | #define __HAL_DBGMCU_FREEZE_TIM9() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM9_STOP) 212 | #define __HAL_DBGMCU_UNFREEZE_TIM9() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM9_STOP) 213 | #endif 214 | 215 | #if defined (DBGMCU_CR_DBG_TIM10_STOP) 216 | /** 217 | * @brief TIM10 Peripherals Debug mode 218 | */ 219 | #define __HAL_DBGMCU_FREEZE_TIM10() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM10_STOP) 220 | #define __HAL_DBGMCU_UNFREEZE_TIM10() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM10_STOP) 221 | #endif 222 | 223 | #if defined (DBGMCU_CR_DBG_TIM11_STOP) 224 | /** 225 | * @brief TIM11 Peripherals Debug mode 226 | */ 227 | #define __HAL_DBGMCU_FREEZE_TIM11() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM11_STOP) 228 | #define __HAL_DBGMCU_UNFREEZE_TIM11() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM11_STOP) 229 | #endif 230 | 231 | 232 | #if defined (DBGMCU_CR_DBG_TIM15_STOP) 233 | /** 234 | * @brief TIM15 Peripherals Debug mode 235 | */ 236 | #define __HAL_DBGMCU_FREEZE_TIM15() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM15_STOP) 237 | #define __HAL_DBGMCU_UNFREEZE_TIM15() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM15_STOP) 238 | #endif 239 | 240 | #if defined (DBGMCU_CR_DBG_TIM16_STOP) 241 | /** 242 | * @brief TIM16 Peripherals Debug mode 243 | */ 244 | #define __HAL_DBGMCU_FREEZE_TIM16() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM16_STOP) 245 | #define __HAL_DBGMCU_UNFREEZE_TIM16() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM16_STOP) 246 | #endif 247 | 248 | #if defined (DBGMCU_CR_DBG_TIM17_STOP) 249 | /** 250 | * @brief TIM17 Peripherals Debug mode 251 | */ 252 | #define __HAL_DBGMCU_FREEZE_TIM17() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM17_STOP) 253 | #define __HAL_DBGMCU_UNFREEZE_TIM17() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM17_STOP) 254 | #endif 255 | 256 | /** 257 | * @} 258 | */ 259 | 260 | /** 261 | * @} 262 | */ 263 | 264 | /* Exported functions --------------------------------------------------------*/ 265 | 266 | /** @addtogroup HAL_Exported_Functions 267 | * @{ 268 | */ 269 | 270 | /** @addtogroup HAL_Exported_Functions_Group1 271 | * @{ 272 | */ 273 | 274 | /* Initialization and de-initialization functions ******************************/ 275 | HAL_StatusTypeDef HAL_Init(void); 276 | HAL_StatusTypeDef HAL_DeInit(void); 277 | void HAL_MspInit(void); 278 | void HAL_MspDeInit(void); 279 | HAL_StatusTypeDef HAL_InitTick (uint32_t TickPriority); 280 | 281 | /** 282 | * @} 283 | */ 284 | 285 | /** @addtogroup HAL_Exported_Functions_Group2 286 | * @{ 287 | */ 288 | 289 | /* Peripheral Control functions ************************************************/ 290 | void HAL_IncTick(void); 291 | void HAL_Delay(__IO uint32_t Delay); 292 | uint32_t HAL_GetTick(void); 293 | void HAL_SuspendTick(void); 294 | void HAL_ResumeTick(void); 295 | uint32_t HAL_GetHalVersion(void); 296 | uint32_t HAL_GetREVID(void); 297 | uint32_t HAL_GetDEVID(void); 298 | void HAL_DBGMCU_EnableDBGSleepMode(void); 299 | void HAL_DBGMCU_DisableDBGSleepMode(void); 300 | void HAL_DBGMCU_EnableDBGStopMode(void); 301 | void HAL_DBGMCU_DisableDBGStopMode(void); 302 | void HAL_DBGMCU_EnableDBGStandbyMode(void); 303 | void HAL_DBGMCU_DisableDBGStandbyMode(void); 304 | 305 | /** 306 | * @} 307 | */ 308 | 309 | /** 310 | * @} 311 | */ 312 | 313 | 314 | /** 315 | * @} 316 | */ 317 | 318 | /** 319 | * @} 320 | */ 321 | 322 | #ifdef __cplusplus 323 | } 324 | #endif 325 | 326 | #endif /* __STM32F1xx_HAL_H */ 327 | 328 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 329 | -------------------------------------------------------------------------------- /Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_def.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f1xx_hal_def.h 4 | * @author MCD Application Team 5 | * @version V1.0.1 6 | * @date 31-July-2015 7 | * @brief This file contains HAL common defines, enumeration, macros and 8 | * structures definitions. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT(c) 2015 STMicroelectronics

13 | * 14 | * Redistribution and use in source and binary forms, with or without modification, 15 | * are permitted provided that the following conditions are met: 16 | * 1. Redistributions of source code must retain the above copyright notice, 17 | * this list of conditions and the following disclaimer. 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 22 | * may be used to endorse or promote products derived from this software 23 | * without specific prior written permission. 24 | * 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 28 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 31 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 33 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | ****************************************************************************** 37 | */ 38 | 39 | /* Define to prevent recursive inclusion -------------------------------------*/ 40 | #ifndef __STM32F1xx_HAL_DEF 41 | #define __STM32F1xx_HAL_DEF 42 | 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | /* Includes ------------------------------------------------------------------*/ 48 | #include "stm32f1xx.h" 49 | #include "Legacy/stm32_hal_legacy.h" 50 | #include 51 | 52 | /* Exported types ------------------------------------------------------------*/ 53 | 54 | /** 55 | * @brief HAL Status structures definition 56 | */ 57 | typedef enum 58 | { 59 | HAL_OK = 0x00, 60 | HAL_ERROR = 0x01, 61 | HAL_BUSY = 0x02, 62 | HAL_TIMEOUT = 0x03 63 | } HAL_StatusTypeDef; 64 | 65 | /** 66 | * @brief HAL Lock structures definition 67 | */ 68 | typedef enum 69 | { 70 | HAL_UNLOCKED = 0x00, 71 | HAL_LOCKED = 0x01 72 | } HAL_LockTypeDef; 73 | 74 | /* Exported macro ------------------------------------------------------------*/ 75 | 76 | #define HAL_MAX_DELAY 0xFFFFFFFF 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 __RAM_FUNC definition 160 | */ 161 | #if defined ( __CC_ARM ) 162 | /* ARM Compiler 163 | ------------ 164 | RAM functions are defined using the toolchain options. 165 | Functions that are executed in RAM should reside in a separate source module. 166 | Using the 'Options for File' dialog you can simply change the 'Code / Const' 167 | area of a module to a memory space in physical RAM. 168 | Available memory areas are declared in the 'Target' tab of the 'Options for Target' 169 | dialog. 170 | */ 171 | #define __RAM_FUNC HAL_StatusTypeDef 172 | 173 | #elif defined ( __ICCARM__ ) 174 | /* ICCARM Compiler 175 | --------------- 176 | RAM functions are defined using a specific toolchain keyword "__ramfunc". 177 | */ 178 | #define __RAM_FUNC __ramfunc HAL_StatusTypeDef 179 | 180 | #elif defined ( __GNUC__ ) 181 | /* GNU Compiler 182 | ------------ 183 | RAM functions are defined using a specific toolchain attribute 184 | "__attribute__((section(".RamFunc")))". 185 | */ 186 | #define __RAM_FUNC HAL_StatusTypeDef __attribute__((section(".RamFunc"))) 187 | 188 | #endif 189 | 190 | /** 191 | * @brief __NOINLINE definition 192 | */ 193 | #if defined ( __CC_ARM ) || defined ( __GNUC__ ) 194 | /* ARM & GNUCompiler 195 | ---------------- 196 | */ 197 | #define __NOINLINE __attribute__ ( (noinline) ) 198 | 199 | #elif defined ( __ICCARM__ ) 200 | /* ICCARM Compiler 201 | --------------- 202 | */ 203 | #define __NOINLINE _Pragma("optimize = no_inline") 204 | 205 | #endif 206 | 207 | 208 | #ifdef __cplusplus 209 | } 210 | #endif 211 | 212 | #endif /* ___STM32F1xx_HAL_DEF */ 213 | 214 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 215 | -------------------------------------------------------------------------------- /Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f1xx_hal_flash.h 4 | * @author MCD Application Team 5 | * @version V1.0.1 6 | * @date 31-July-2015 7 | * @brief Header file of Flash HAL module. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT(c) 2015 STMicroelectronics

12 | * 13 | * Redistribution and use in source and binary forms, with or without modification, 14 | * are permitted provided that the following conditions are met: 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, 18 | * this list of conditions and the following disclaimer in the documentation 19 | * and/or other materials provided with the distribution. 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 21 | * may be used to endorse or promote products derived from this software 22 | * without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | ****************************************************************************** 36 | */ 37 | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ 39 | #ifndef __STM32F1xx_HAL_FLASH_H 40 | #define __STM32F1xx_HAL_FLASH_H 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | /* Includes ------------------------------------------------------------------*/ 47 | #include "stm32f1xx_hal_def.h" 48 | 49 | /** @addtogroup STM32F1xx_HAL_Driver 50 | * @{ 51 | */ 52 | 53 | /** @addtogroup FLASH 54 | * @{ 55 | */ 56 | 57 | /** @addtogroup FLASH_Private_Constants 58 | * @{ 59 | */ 60 | #define FLASH_TIMEOUT_VALUE ((uint32_t)50000)/* 50 s */ 61 | /** 62 | * @} 63 | */ 64 | 65 | /** @addtogroup FLASH_Private_Macros 66 | * @{ 67 | */ 68 | 69 | #define IS_FLASH_TYPEPROGRAM(VALUE) (((VALUE) == FLASH_TYPEPROGRAM_HALFWORD) || \ 70 | ((VALUE) == FLASH_TYPEPROGRAM_WORD) || \ 71 | ((VALUE) == FLASH_TYPEPROGRAM_DOUBLEWORD)) 72 | 73 | #if defined(FLASH_ACR_LATENCY) 74 | #define IS_FLASH_LATENCY(__LATENCY__) (((__LATENCY__) == FLASH_LATENCY_0) || \ 75 | ((__LATENCY__) == FLASH_LATENCY_1) || \ 76 | ((__LATENCY__) == FLASH_LATENCY_2)) 77 | 78 | #else 79 | #define IS_FLASH_LATENCY(__LATENCY__) ((__LATENCY__) == FLASH_LATENCY_0) 80 | #endif /* FLASH_ACR_LATENCY */ 81 | /** 82 | * @} 83 | */ 84 | 85 | /* Exported types ------------------------------------------------------------*/ 86 | /** @defgroup FLASH_Exported_Types FLASH Exported Types 87 | * @{ 88 | */ 89 | 90 | 91 | /** 92 | * @brief FLASH Procedure structure definition 93 | */ 94 | typedef enum 95 | { 96 | FLASH_PROC_NONE = 0, 97 | FLASH_PROC_PAGEERASE = 1, 98 | FLASH_PROC_MASSERASE = 2, 99 | FLASH_PROC_PROGRAMHALFWORD = 3, 100 | FLASH_PROC_PROGRAMWORD = 4, 101 | FLASH_PROC_PROGRAMDOUBLEWORD = 5 102 | } FLASH_ProcedureTypeDef; 103 | 104 | /** 105 | * @brief FLASH handle Structure definition 106 | */ 107 | typedef struct 108 | { 109 | __IO FLASH_ProcedureTypeDef ProcedureOnGoing; /*!< Internal variable to indicate which procedure is ongoing or not in IT context */ 110 | 111 | __IO uint32_t DataRemaining; /*!< Internal variable to save the remaining pages to erase or half-word to program in IT context */ 112 | 113 | __IO uint32_t Address; /*!< Internal variable to save address selected for program or erase */ 114 | 115 | __IO uint64_t Data; /*!< Internal variable to save data to be programmed */ 116 | 117 | HAL_LockTypeDef Lock; /*!< FLASH locking object */ 118 | 119 | __IO uint32_t ErrorCode; /*!< FLASH error code 120 | This parameter can be a value of @ref FLASH_Error_Codes */ 121 | } FLASH_ProcessTypeDef; 122 | 123 | /** 124 | * @} 125 | */ 126 | 127 | /* Exported constants --------------------------------------------------------*/ 128 | /** @defgroup FLASH_Exported_Constants FLASH Exported Constants 129 | * @{ 130 | */ 131 | 132 | /** @defgroup FLASH_Error_Codes FLASH Error Codes 133 | * @{ 134 | */ 135 | 136 | #define HAL_FLASH_ERROR_NONE ((uint32_t)0x00) /*!< No error */ 137 | #define HAL_FLASH_ERROR_PROG ((uint32_t)0x01) /*!< Programming error */ 138 | #define HAL_FLASH_ERROR_WRP ((uint32_t)0x02) /*!< Write protection error */ 139 | #define HAL_FLASH_ERROR_OPTV ((uint32_t)0x04) 140 | 141 | /** 142 | * @} 143 | */ 144 | 145 | /** @defgroup FLASH_Type_Program FLASH Type Program 146 | * @{ 147 | */ 148 | #define FLASH_TYPEPROGRAM_HALFWORD ((uint32_t)0x01) /*!ACR |= FLASH_ACR_HLFCYA) 202 | 203 | /** 204 | * @brief Disable the FLASH half cycle access. 205 | * @note half cycle access can only be used with a low-frequency clock of less than 206 | 8 MHz that can be obtained with the use of HSI or HSE but not of PLL. 207 | * @retval None 208 | */ 209 | #define __HAL_FLASH_HALF_CYCLE_ACCESS_DISABLE() (FLASH->ACR &= (~FLASH_ACR_HLFCYA)) 210 | 211 | /** 212 | * @} 213 | */ 214 | 215 | #if defined(FLASH_ACR_LATENCY) 216 | /** @defgroup FLASH_EM_Latency FLASH Latency 217 | * @brief macros to handle FLASH Latency 218 | * @{ 219 | */ 220 | 221 | /** 222 | * @brief Set the FLASH Latency. 223 | * @param __LATENCY__: FLASH Latency 224 | * The value of this parameter depend on device used within the same series 225 | * @retval None 226 | */ 227 | #define __HAL_FLASH_SET_LATENCY(__LATENCY__) (FLASH->ACR = (FLASH->ACR&(~FLASH_ACR_LATENCY)) | (__LATENCY__)) 228 | 229 | 230 | /** 231 | * @brief Get the FLASH Latency. 232 | * @retval FLASH Latency 233 | * The value of this parameter depend on device used within the same series 234 | */ 235 | #define __HAL_FLASH_GET_LATENCY() (READ_BIT((FLASH->ACR), FLASH_ACR_LATENCY)) 236 | 237 | /** 238 | * @} 239 | */ 240 | 241 | #endif /* FLASH_ACR_LATENCY */ 242 | /** @defgroup FLASH_Prefetch FLASH Prefetch 243 | * @brief macros to handle FLASH Prefetch buffer 244 | * @{ 245 | */ 246 | /** 247 | * @brief Enable the FLASH prefetch buffer. 248 | * @retval None 249 | */ 250 | #define __HAL_FLASH_PREFETCH_BUFFER_ENABLE() (FLASH->ACR |= FLASH_ACR_PRFTBE) 251 | 252 | /** 253 | * @brief Disable the FLASH prefetch buffer. 254 | * @retval None 255 | */ 256 | #define __HAL_FLASH_PREFETCH_BUFFER_DISABLE() (FLASH->ACR &= (~FLASH_ACR_PRFTBE)) 257 | 258 | /** 259 | * @} 260 | */ 261 | 262 | /** 263 | * @} 264 | */ 265 | 266 | /* Include FLASH HAL Extended module */ 267 | #include "stm32f1xx_hal_flash_ex.h" 268 | 269 | /* Exported functions --------------------------------------------------------*/ 270 | /** @addtogroup FLASH_Exported_Functions 271 | * @{ 272 | */ 273 | 274 | /** @addtogroup FLASH_Exported_Functions_Group1 275 | * @{ 276 | */ 277 | /* IO operation functions *****************************************************/ 278 | HAL_StatusTypeDef HAL_FLASH_Program(uint32_t TypeProgram, uint32_t Address, uint64_t Data); 279 | HAL_StatusTypeDef HAL_FLASH_Program_IT(uint32_t TypeProgram, uint32_t Address, uint64_t Data); 280 | 281 | /* FLASH IRQ handler method */ 282 | void HAL_FLASH_IRQHandler(void); 283 | /* Callbacks in non blocking modes */ 284 | void HAL_FLASH_EndOfOperationCallback(uint32_t ReturnValue); 285 | void HAL_FLASH_OperationErrorCallback(uint32_t ReturnValue); 286 | 287 | /** 288 | * @} 289 | */ 290 | 291 | /** @addtogroup FLASH_Exported_Functions_Group2 292 | * @{ 293 | */ 294 | /* Peripheral Control functions ***********************************************/ 295 | HAL_StatusTypeDef HAL_FLASH_Unlock(void); 296 | HAL_StatusTypeDef HAL_FLASH_Lock(void); 297 | HAL_StatusTypeDef HAL_FLASH_OB_Unlock(void); 298 | HAL_StatusTypeDef HAL_FLASH_OB_Lock(void); 299 | HAL_StatusTypeDef HAL_FLASH_OB_Launch(void); 300 | 301 | /** 302 | * @} 303 | */ 304 | 305 | /** @addtogroup FLASH_Exported_Functions_Group3 306 | * @{ 307 | */ 308 | /* Peripheral State and Error functions ***************************************/ 309 | uint32_t HAL_FLASH_GetError(void); 310 | 311 | /** 312 | * @} 313 | */ 314 | 315 | /** 316 | * @} 317 | */ 318 | 319 | /* Private function -------------------------------------------------*/ 320 | /** @addtogroup FLASH_Private_Functions 321 | * @{ 322 | */ 323 | void FLASH_PageErase(uint32_t PageAddress); 324 | HAL_StatusTypeDef FLASH_WaitForLastOperation(uint32_t Timeout); 325 | #if defined(FLASH_BANK2_END) 326 | HAL_StatusTypeDef FLASH_WaitForLastOperationBank2(uint32_t Timeout); 327 | #endif /* FLASH_BANK2_END */ 328 | 329 | /** 330 | * @} 331 | */ 332 | 333 | /** 334 | * @} 335 | */ 336 | 337 | /** 338 | * @} 339 | */ 340 | 341 | #ifdef __cplusplus 342 | } 343 | #endif 344 | 345 | #endif /* __STM32F1xx_HAL_FLASH_H */ 346 | 347 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 348 | 349 | -------------------------------------------------------------------------------- /Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_pcd_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f1xx_hal_pcd_ex.h 4 | * @author MCD Application Team 5 | * @version V1.0.1 6 | * @date 31-July-2015 7 | * @brief Header file of Extended PCD HAL module. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT(c) 2015 STMicroelectronics

12 | * 13 | * Redistribution and use in source and binary forms, with or without modification, 14 | * are permitted provided that the following conditions are met: 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, 18 | * this list of conditions and the following disclaimer in the documentation 19 | * and/or other materials provided with the distribution. 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 21 | * may be used to endorse or promote products derived from this software 22 | * without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | ****************************************************************************** 36 | */ 37 | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ 39 | #ifndef __STM32F1xx_HAL_PCD_EX_H 40 | #define __STM32F1xx_HAL_PCD_EX_H 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | #if defined(STM32F102x6) || defined(STM32F102xB) || \ 47 | defined(STM32F103x6) || defined(STM32F103xB) || \ 48 | defined(STM32F103xE) || defined(STM32F103xG) || \ 49 | defined(STM32F105xC) || defined(STM32F107xC) 50 | 51 | /* Includes ------------------------------------------------------------------*/ 52 | #include "stm32f1xx_hal_def.h" 53 | 54 | /** @addtogroup STM32F1xx_HAL_Driver 55 | * @{ 56 | */ 57 | 58 | /** @addtogroup PCDEx 59 | * @{ 60 | */ 61 | 62 | /* Exported types ------------------------------------------------------------*/ 63 | /* Exported constants --------------------------------------------------------*/ 64 | /* Exported macros -----------------------------------------------------------*/ 65 | /* Exported functions --------------------------------------------------------*/ 66 | /** @addtogroup PCDEx_Exported_Functions PCDEx Exported Functions 67 | * @{ 68 | */ 69 | /** @addtogroup PCDEx_Exported_Functions_Group1 Peripheral Control functions 70 | * @{ 71 | */ 72 | #if defined (USB_OTG_FS) 73 | HAL_StatusTypeDef HAL_PCDEx_SetTxFiFo(PCD_HandleTypeDef *hpcd, uint8_t fifo, uint16_t size); 74 | HAL_StatusTypeDef HAL_PCDEx_SetRxFiFo(PCD_HandleTypeDef *hpcd, uint16_t size); 75 | #endif /* USB_OTG_FS */ 76 | 77 | #if defined (USB) 78 | HAL_StatusTypeDef HAL_PCDEx_PMAConfig(PCD_HandleTypeDef *hpcd, 79 | uint16_t ep_addr, 80 | uint16_t ep_kind, 81 | uint32_t pmaadress); 82 | #endif /* USB */ 83 | /** 84 | * @} 85 | */ 86 | 87 | /** @addtogroup PCDEx_Exported_Functions_Group2 Peripheral State functions 88 | * @{ 89 | */ 90 | void HAL_PCDEx_SetConnectionState(PCD_HandleTypeDef *hpcd, uint8_t state); 91 | /** 92 | * @} 93 | */ 94 | /** 95 | * @} 96 | */ 97 | /** 98 | * @} 99 | */ 100 | 101 | /** 102 | * @} 103 | */ 104 | #endif /* STM32F102x6 || STM32F102xB || */ 105 | /* STM32F103x6 || STM32F103xB || */ 106 | /* STM32F103xE || STM32F103xG || */ 107 | /* STM32F105xC || STM32F107xC */ 108 | 109 | #ifdef __cplusplus 110 | } 111 | #endif 112 | 113 | 114 | #endif /* __STM32F1xx_HAL_PCD_EX_H */ 115 | 116 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 117 | -------------------------------------------------------------------------------- /Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f1xx_hal_gpio_ex.c 4 | * @author MCD Application Team 5 | * @version V1.0.1 6 | * @date 31-July-2015 7 | * @brief GPIO Extension HAL module driver. 8 | * This file provides firmware functions to manage the following 9 | * functionalities of the General Purpose Input/Output (GPIO) extension peripheral. 10 | * + Extended features functions 11 | * 12 | @verbatim 13 | ============================================================================== 14 | ##### GPIO Peripheral extension features ##### 15 | ============================================================================== 16 | [..] GPIO module on STM32F1 family, manage also the AFIO register: 17 | (+) Possibility to use the EVENTOUT Cortex feature 18 | 19 | ##### How to use this driver ##### 20 | ============================================================================== 21 | [..] This driver provides functions to use EVENTOUT Cortex feature 22 | (#) Configure EVENTOUT Cortex feature using the function HAL_GPIOEx_ConfigEventout() 23 | (#) Activate EVENTOUT Cortex feature using the HAL_GPIOEx_EnableEventout() 24 | (#) Deactivate EVENTOUT Cortex feature using the HAL_GPIOEx_DisableEventout() 25 | 26 | @endverbatim 27 | ****************************************************************************** 28 | * @attention 29 | * 30 | *

© COPYRIGHT(c) 2015 STMicroelectronics

31 | * 32 | * Redistribution and use in source and binary forms, with or without modification, 33 | * are permitted provided that the following conditions are met: 34 | * 1. Redistributions of source code must retain the above copyright notice, 35 | * this list of conditions and the following disclaimer. 36 | * 2. Redistributions in binary form must reproduce the above copyright notice, 37 | * this list of conditions and the following disclaimer in the documentation 38 | * and/or other materials provided with the distribution. 39 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 40 | * may be used to endorse or promote products derived from this software 41 | * without specific prior written permission. 42 | * 43 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 44 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 45 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 46 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 47 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 48 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 49 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 50 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 51 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 52 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 53 | * 54 | ****************************************************************************** 55 | */ 56 | 57 | /* Includes ------------------------------------------------------------------*/ 58 | #include "stm32f1xx_hal.h" 59 | 60 | /** @addtogroup STM32F1xx_HAL_Driver 61 | * @{ 62 | */ 63 | 64 | /** @defgroup GPIOEx GPIOEx 65 | * @brief GPIO HAL module driver 66 | * @{ 67 | */ 68 | 69 | #ifdef HAL_GPIO_MODULE_ENABLED 70 | 71 | /** @defgroup GPIOEx_Exported_Functions GPIOEx Exported Functions 72 | * @{ 73 | */ 74 | 75 | /** @defgroup GPIOEx_Exported_Functions_Group1 Extended features functions 76 | * @brief Extended features functions 77 | * 78 | @verbatim 79 | ============================================================================== 80 | ##### Extended features functions ##### 81 | ============================================================================== 82 | [..] This section provides functions allowing to: 83 | (+) Configure EVENTOUT Cortex feature using the function HAL_GPIOEx_ConfigEventout() 84 | (+) Activate EVENTOUT Cortex feature using the HAL_GPIOEx_EnableEventout() 85 | (+) Deactivate EVENTOUT Cortex feature using the HAL_GPIOEx_DisableEventout() 86 | 87 | @endverbatim 88 | * @{ 89 | */ 90 | 91 | /** 92 | * @brief Configures the port and pin on which the EVENTOUT Cortex signal will be connected. 93 | * @param GPIO_PortSource Select the port used to output the Cortex EVENTOUT signal. 94 | * This parameter can be a value of @ref GPIOEx_EVENTOUT_PORT. 95 | * @param GPIO_PinSource Select the pin used to output the Cortex EVENTOUT signal. 96 | * This parameter can be a value of @ref GPIOEx_EVENTOUT_PIN. 97 | * @retval None 98 | */ 99 | void HAL_GPIOEx_ConfigEventout(uint32_t GPIO_PortSource, uint32_t GPIO_PinSource) 100 | { 101 | /* Verify the parameters */ 102 | assert_param(IS_AFIO_EVENTOUT_PORT(GPIO_PortSource)); 103 | assert_param(IS_AFIO_EVENTOUT_PIN(GPIO_PinSource)); 104 | 105 | /* Apply the new configuration */ 106 | MODIFY_REG(AFIO->EVCR, (AFIO_EVCR_PORT)|(AFIO_EVCR_PIN), (GPIO_PortSource)|(GPIO_PinSource)); 107 | } 108 | 109 | /** 110 | * @brief Enables the Event Output. 111 | * @retval None 112 | */ 113 | void HAL_GPIOEx_EnableEventout(void) 114 | { 115 | SET_BIT(AFIO->EVCR, AFIO_EVCR_EVOE); 116 | } 117 | 118 | /** 119 | * @brief Disables the Event Output. 120 | * @retval None 121 | */ 122 | void HAL_GPIOEx_DisableEventout(void) 123 | { 124 | CLEAR_BIT(AFIO->EVCR, AFIO_EVCR_EVOE); 125 | } 126 | 127 | /** 128 | * @} 129 | */ 130 | 131 | /** 132 | * @} 133 | */ 134 | 135 | #endif /* HAL_GPIO_MODULE_ENABLED */ 136 | 137 | /** 138 | * @} 139 | */ 140 | 141 | /** 142 | * @} 143 | */ 144 | 145 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 146 | -------------------------------------------------------------------------------- /Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pcd_ex.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f1xx_hal_pcd_ex.c 4 | * @author MCD Application Team 5 | * @version V1.0.1 6 | * @date 31-July-2015 7 | * @brief Extended PCD HAL module driver. 8 | * This file provides firmware functions to manage the following 9 | * functionalities of the USB Peripheral Controller: 10 | * + Extended features functions: Update FIFO configuration, 11 | * PMA configuration for EPs 12 | * 13 | ****************************************************************************** 14 | * @attention 15 | * 16 | *

© COPYRIGHT(c) 2015 STMicroelectronics

17 | * 18 | * Redistribution and use in source and binary forms, with or without modification, 19 | * are permitted provided that the following conditions are met: 20 | * 1. Redistributions of source code must retain the above copyright notice, 21 | * this list of conditions and the following disclaimer. 22 | * 2. Redistributions in binary form must reproduce the above copyright notice, 23 | * this list of conditions and the following disclaimer in the documentation 24 | * and/or other materials provided with the distribution. 25 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 26 | * may be used to endorse or promote products derived from this software 27 | * without specific prior written permission. 28 | * 29 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 30 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 31 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 32 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 33 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 34 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 35 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 36 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 37 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 38 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | ****************************************************************************** 41 | */ 42 | 43 | /* Includes ------------------------------------------------------------------*/ 44 | #include "stm32f1xx_hal.h" 45 | 46 | /** @addtogroup STM32F1xx_HAL_Driver 47 | * @{ 48 | */ 49 | 50 | #ifdef HAL_PCD_MODULE_ENABLED 51 | 52 | #if defined(STM32F102x6) || defined(STM32F102xB) || \ 53 | defined(STM32F103x6) || defined(STM32F103xB) || \ 54 | defined(STM32F103xE) || defined(STM32F103xG) || \ 55 | defined(STM32F105xC) || defined(STM32F107xC) 56 | 57 | 58 | /** @defgroup PCDEx PCDEx 59 | * @brief PCD Extended HAL module driver 60 | * @{ 61 | */ 62 | 63 | 64 | /* Private types -------------------------------------------------------------*/ 65 | /* Private variables ---------------------------------------------------------*/ 66 | /* Private constants ---------------------------------------------------------*/ 67 | /* Private macros ------------------------------------------------------------*/ 68 | /* Private functions ---------------------------------------------------------*/ 69 | /* Exported functions --------------------------------------------------------*/ 70 | /** @defgroup PCDEx_Exported_Functions PCDEx Exported Functions 71 | * @{ 72 | */ 73 | 74 | /** @defgroup PCDEx_Exported_Functions_Group1 Peripheral Control functions 75 | * @brief PCDEx control functions 76 | * 77 | @verbatim 78 | =============================================================================== 79 | ##### Extended Peripheral Control functions ##### 80 | =============================================================================== 81 | [..] This section provides functions allowing to: 82 | (+) Update FIFO (USB_OTG_FS) 83 | (+) Update PMA configuration (USB) 84 | 85 | @endverbatim 86 | * @{ 87 | */ 88 | 89 | #if defined (USB_OTG_FS) 90 | /** 91 | * @brief Set Tx FIFO 92 | * @param hpcd: PCD handle 93 | * @param fifo: The number of Tx fifo 94 | * @param size: Fifo size 95 | * @retval HAL status 96 | */ 97 | HAL_StatusTypeDef HAL_PCDEx_SetTxFiFo(PCD_HandleTypeDef *hpcd, uint8_t fifo, uint16_t size) 98 | { 99 | uint8_t index = 0; 100 | uint32_t Tx_Offset = 0; 101 | 102 | /* TXn min size = 16 words. (n : Transmit FIFO index) 103 | When a TxFIFO is not used, the Configuration should be as follows: 104 | case 1 : n > m and Txn is not used (n,m : Transmit FIFO indexes) 105 | --> Txm can use the space allocated for Txn. 106 | case2 : n < m and Txn is not used (n,m : Transmit FIFO indexes) 107 | --> Txn should be configured with the minimum space of 16 words 108 | The FIFO is used optimally when used TxFIFOs are allocated in the top 109 | of the FIFO.Ex: use EP1 and EP2 as IN instead of EP1 and EP3 as IN ones. 110 | When DMA is used 3n * FIFO locations should be reserved for internal DMA registers */ 111 | 112 | Tx_Offset = hpcd->Instance->GRXFSIZ; 113 | 114 | if(fifo == 0) 115 | { 116 | hpcd->Instance->DIEPTXF0_HNPTXFSIZ = (size << 16) | Tx_Offset; 117 | } 118 | else 119 | { 120 | Tx_Offset += (hpcd->Instance->DIEPTXF0_HNPTXFSIZ) >> 16; 121 | for (index = 0; index < (fifo - 1); index++) 122 | { 123 | Tx_Offset += (hpcd->Instance->DIEPTXF[index] >> 16); 124 | } 125 | 126 | /* Multiply Tx_Size by 2 to get higher performance */ 127 | hpcd->Instance->DIEPTXF[fifo - 1] = (size << 16) | Tx_Offset; 128 | 129 | } 130 | 131 | return HAL_OK; 132 | } 133 | 134 | /** 135 | * @brief Set Rx FIFO 136 | * @param hpcd: PCD handle 137 | * @param size: Size of Rx fifo 138 | * @retval HAL status 139 | */ 140 | HAL_StatusTypeDef HAL_PCDEx_SetRxFiFo(PCD_HandleTypeDef *hpcd, uint16_t size) 141 | { 142 | hpcd->Instance->GRXFSIZ = size; 143 | return HAL_OK; 144 | } 145 | #endif /* USB_OTG_FS */ 146 | 147 | #if defined (USB) 148 | /** 149 | * @brief Configure PMA for EP 150 | * @param hpcd : Device instance 151 | * @param ep_addr: endpoint address 152 | * @param ep_kind: endpoint Kind 153 | * USB_SNG_BUF: Single Buffer used 154 | * USB_DBL_BUF: Double Buffer used 155 | * @param pmaadress: EP address in The PMA: In case of single buffer endpoint 156 | * this parameter is 16-bit value providing the address 157 | * in PMA allocated to endpoint. 158 | * In case of double buffer endpoint this parameter 159 | * is a 32-bit value providing the endpoint buffer 0 address 160 | * in the LSB part of 32-bit value and endpoint buffer 1 address 161 | * in the MSB part of 32-bit value. 162 | * @retval HAL status 163 | */ 164 | 165 | HAL_StatusTypeDef HAL_PCDEx_PMAConfig(PCD_HandleTypeDef *hpcd, 166 | uint16_t ep_addr, 167 | uint16_t ep_kind, 168 | uint32_t pmaadress) 169 | 170 | { 171 | PCD_EPTypeDef *ep = NULL; 172 | 173 | /* initialize ep structure*/ 174 | if ((0x80 & ep_addr) == 0x80) 175 | { 176 | ep = &hpcd->IN_ep[ep_addr & 0x7F]; 177 | } 178 | else 179 | { 180 | ep = &hpcd->OUT_ep[ep_addr]; 181 | } 182 | 183 | /* Here we check if the endpoint is single or double Buffer*/ 184 | if (ep_kind == PCD_SNG_BUF) 185 | { 186 | /*Single Buffer*/ 187 | ep->doublebuffer = 0; 188 | /*Configure te PMA*/ 189 | ep->pmaadress = (uint16_t)pmaadress; 190 | } 191 | else /*USB_DBL_BUF*/ 192 | { 193 | /*Double Buffer Endpoint*/ 194 | ep->doublebuffer = 1; 195 | /*Configure the PMA*/ 196 | ep->pmaaddr0 = pmaadress & 0xFFFF; 197 | ep->pmaaddr1 = (pmaadress & 0xFFFF0000) >> 16; 198 | } 199 | 200 | return HAL_OK; 201 | } 202 | #endif /* USB */ 203 | /** 204 | * @} 205 | */ 206 | 207 | /** @defgroup PCDEx_Exported_Functions_Group2 Peripheral State functions 208 | * @brief Manage device connection state 209 | * @{ 210 | */ 211 | /** 212 | * @brief Software Device Connection, 213 | * this function is not required by USB OTG FS peripheral, it is used 214 | * only by USB Device FS peripheral. 215 | * @param hpcd: PCD handle 216 | * @param state: connection state (0 : disconnected / 1: connected) 217 | * @retval None 218 | */ 219 | __weak void HAL_PCDEx_SetConnectionState(PCD_HandleTypeDef *hpcd, uint8_t state) 220 | { 221 | /* NOTE : This function Should not be modified, when the callback is needed, 222 | the HAL_PCDEx_SetConnectionState could be implemented in the user file 223 | */ 224 | } 225 | /** 226 | * @} 227 | */ 228 | 229 | /** 230 | * @} 231 | */ 232 | 233 | /** 234 | * @} 235 | */ 236 | 237 | #endif /* STM32F102x6 || STM32F102xB || */ 238 | /* STM32F103x6 || STM32F103xB || */ 239 | /* STM32F103xE || STM32F103xG || */ 240 | /* STM32F105xC || STM32F107xC */ 241 | 242 | #endif /* HAL_PCD_MODULE_ENABLED */ 243 | 244 | 245 | /** 246 | * @} 247 | */ 248 | 249 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 250 | -------------------------------------------------------------------------------- /Inc/mxconstants.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : mxconstants.h 4 | * Description : This file contains the common defines of the application 5 | ****************************************************************************** 6 | * 7 | * COPYRIGHT(c) 2015 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 | 35 | /* USER CODE BEGIN Includes */ 36 | 37 | /* USER CODE END Includes */ 38 | 39 | /* Private define ------------------------------------------------------------*/ 40 | 41 | /* USER CODE BEGIN Private defines */ 42 | 43 | /* USER CODE END Private defines */ 44 | 45 | /** 46 | * @} 47 | */ 48 | 49 | /** 50 | * @} 51 | */ 52 | 53 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 54 | -------------------------------------------------------------------------------- /Inc/stm32f1xx_it.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f1xx_it.h 4 | * @brief This file contains the headers of the interrupt handlers. 5 | ****************************************************************************** 6 | * 7 | * COPYRIGHT(c) 2015 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 __STM32F1xx_IT_H 36 | #define __STM32F1xx_IT_H 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | /* Includes ------------------------------------------------------------------*/ 43 | /* Exported types ------------------------------------------------------------*/ 44 | /* Exported constants --------------------------------------------------------*/ 45 | /* Exported macro ------------------------------------------------------------*/ 46 | /* Exported functions ------------------------------------------------------- */ 47 | 48 | void SysTick_Handler(void); 49 | void USB_LP_CAN1_RX0_IRQHandler(void); 50 | void TIM1_TRG_COM_IRQHandler(void); 51 | 52 | #ifdef __cplusplus 53 | } 54 | #endif 55 | 56 | #endif /* __STM32F1xx_IT_H */ 57 | 58 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 59 | -------------------------------------------------------------------------------- /Inc/usb_device.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file : USB_DEVICE 4 | * @version : v1.0_Cube 5 | * @brief : Header for usb_device file. 6 | ****************************************************************************** 7 | * COPYRIGHT(c) 2015 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 | /* Define to prevent recursive inclusion -------------------------------------*/ 34 | #ifndef __usb_device_H 35 | #define __usb_device_H 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | /* Includes ------------------------------------------------------------------*/ 41 | #include "stm32f1xx.h" 42 | #include "stm32f1xx_hal.h" 43 | #include "usbd_def.h" 44 | 45 | extern USBD_HandleTypeDef hUsbDeviceFS; 46 | 47 | /* USB_Device init function */ 48 | void MX_USB_DEVICE_Init(void); 49 | 50 | #ifdef __cplusplus 51 | } 52 | #endif 53 | #endif /*__usb_device_H */ 54 | 55 | /** 56 | * @} 57 | */ 58 | 59 | /** 60 | * @} 61 | */ 62 | 63 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 64 | -------------------------------------------------------------------------------- /Inc/usbd_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file : usbd_conf.h 4 | * @version : v1.0_Cube 5 | * @brief : Header for usbd_conf file. 6 | ****************************************************************************** 7 | * COPYRIGHT(c) 2015 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 | /* Define to prevent recursive inclusion -------------------------------------*/ 34 | #ifndef __USBD_CONF__H__ 35 | #define __USBD_CONF__H__ 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | /* Includes ------------------------------------------------------------------*/ 40 | #include 41 | #include 42 | #include 43 | #include "stm32f1xx.h" 44 | #include "stm32f1xx_hal.h" 45 | #include "usbd_def.h" 46 | 47 | /** @addtogroup USBD_OTG_DRIVER 48 | * @{ 49 | */ 50 | 51 | /** @defgroup USBD_CONF 52 | * @brief usb otg low level driver configuration file 53 | * @{ 54 | */ 55 | 56 | /** @defgroup USBD_CONF_Exported_Defines 57 | * @{ 58 | */ 59 | 60 | /*---------- -----------*/ 61 | #define USBD_MAX_NUM_INTERFACES 1 62 | /*---------- -----------*/ 63 | #define USBD_MAX_NUM_CONFIGURATION 1 64 | /*---------- -----------*/ 65 | #define USBD_MAX_STR_DESC_SIZ 512 66 | /*---------- -----------*/ 67 | #define USBD_SUPPORT_USER_STRING 0 68 | /*---------- -----------*/ 69 | #define USBD_DEBUG_LEVEL 0 70 | /*---------- -----------*/ 71 | #define USBD_SELF_POWERED 1 72 | /****************************************/ 73 | /* #define for FS and HS identification */ 74 | #define DEVICE_FS 0 75 | 76 | /** @defgroup USBD_Exported_Macros 77 | * @{ 78 | */ 79 | 80 | /* Memory management macros */ 81 | #define USBD_malloc (uint32_t *)USBD_static_malloc 82 | #define USBD_free USBD_static_free 83 | #define USBD_memset /* Not used */ 84 | #define USBD_memcpy /* Not used */ 85 | 86 | #define USBD_Delay HAL_Delay 87 | 88 | /* For footprint reasons and since only one allocation is handled in the HID class 89 | driver, the malloc/free is changed into a static allocation method */ 90 | void *USBD_static_malloc(uint32_t size); 91 | void USBD_static_free(void *p); 92 | 93 | /* DEBUG macros */ 94 | #if (USBD_DEBUG_LEVEL > 0) 95 | #define USBD_UsrLog(...) printf(__VA_ARGS__);\ 96 | printf("\n"); 97 | #else 98 | #define USBD_UsrLog(...) 99 | #endif 100 | 101 | 102 | #if (USBD_DEBUG_LEVEL > 1) 103 | 104 | #define USBD_ErrLog(...) printf("ERROR: ") ;\ 105 | printf(__VA_ARGS__);\ 106 | printf("\n"); 107 | #else 108 | #define USBD_ErrLog(...) 109 | #endif 110 | 111 | 112 | #if (USBD_DEBUG_LEVEL > 2) 113 | #define USBD_DbgLog(...) printf("DEBUG : ") ;\ 114 | printf(__VA_ARGS__);\ 115 | printf("\n"); 116 | #else 117 | #define USBD_DbgLog(...) 118 | #endif 119 | 120 | /** 121 | * @} 122 | */ 123 | 124 | 125 | 126 | /** 127 | * @} 128 | */ 129 | 130 | /** @defgroup USBD_CONF_Exported_Types 131 | * @{ 132 | */ 133 | /** 134 | * @} 135 | */ 136 | 137 | /** @defgroup USBD_CONF_Exported_Macros 138 | * @{ 139 | */ 140 | /** 141 | * @} 142 | */ 143 | 144 | /** @defgroup USBD_CONF_Exported_Variables 145 | * @{ 146 | */ 147 | /** 148 | * @} 149 | */ 150 | 151 | /** @defgroup USBD_CONF_Exported_FunctionsPrototype 152 | * @{ 153 | */ 154 | /** 155 | * @} 156 | */ 157 | #ifdef __cplusplus 158 | } 159 | #endif 160 | 161 | #endif //__USBD_CONF__H__ 162 | 163 | /** 164 | * @} 165 | */ 166 | 167 | /** 168 | * @} 169 | */ 170 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 171 | 172 | -------------------------------------------------------------------------------- /Inc/usbd_desc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file : usbd_desc.h 4 | * @version : v1.0_Cube 5 | * @brief : Header for usbd_desc file. 6 | ****************************************************************************** 7 | * COPYRIGHT(c) 2015 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 __USBD_DESC__H__ 36 | #define __USBD_DESC__H__ 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | /* Includes ------------------------------------------------------------------*/ 42 | #include "usbd_def.h" 43 | 44 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY 45 | * @{ 46 | */ 47 | 48 | /** @defgroup USB_DESC 49 | * @brief general defines for the usb device library file 50 | * @{ 51 | */ 52 | 53 | /** @defgroup USB_DESC_Exported_Defines 54 | * @{ 55 | */ 56 | 57 | /** 58 | * @} 59 | */ 60 | 61 | /** @defgroup USBD_DESC_Exported_TypesDefinitions 62 | * @{ 63 | */ 64 | /** 65 | * @} 66 | */ 67 | 68 | /** @defgroup USBD_DESC_Exported_Macros 69 | * @{ 70 | */ 71 | /** 72 | * @} 73 | */ 74 | 75 | /** @defgroup USBD_DESC_Exported_Variables 76 | * @{ 77 | */ 78 | extern USBD_DescriptorsTypeDef FS_Desc; 79 | /** 80 | * @} 81 | */ 82 | 83 | /** @defgroup USBD_DESC_Exported_FunctionsPrototype 84 | * @{ 85 | */ 86 | 87 | /** 88 | * @} 89 | */ 90 | #ifdef __cplusplus 91 | } 92 | #endif 93 | 94 | #endif /* __USBD_DESC_H */ 95 | 96 | /** 97 | * @} 98 | */ 99 | 100 | /** 101 | * @} 102 | */ 103 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 104 | -------------------------------------------------------------------------------- /Middlewares/ST/STM32_USB_Device_Library/Class/HID/Inc/usbd_hid.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_hid.h 4 | * @author MCD Application Team 5 | * @version V2.4.1 6 | * @date 19-June-2015 7 | * @brief Header file for the usbd_hid_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 __USB_HID_H 30 | #define __USB_HID_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_HID 44 | * @brief This file is the Header file for usbd_hid.c 45 | * @{ 46 | */ 47 | 48 | 49 | /** @defgroup USBD_HID_Exported_Defines 50 | * @{ 51 | */ 52 | #define HID_EPIN_ADDR 0x81 53 | #define HID_EPIN_SIZE 0x04 54 | 55 | #define USB_HID_CONFIG_DESC_SIZ 34 56 | #define USB_HID_DESC_SIZ 9 57 | #define HID_MOUSE_REPORT_DESC_SIZE 61 58 | 59 | #define HID_DESCRIPTOR_TYPE 0x21 60 | #define HID_REPORT_DESC 0x22 61 | 62 | #define HID_HS_BINTERVAL 0x07 63 | #define HID_FS_BINTERVAL 0x0A 64 | #define HID_POLLING_INTERVAL 0x0A 65 | 66 | #define HID_REQ_SET_PROTOCOL 0x0B 67 | #define HID_REQ_GET_PROTOCOL 0x03 68 | 69 | #define HID_REQ_SET_IDLE 0x0A 70 | #define HID_REQ_GET_IDLE 0x02 71 | 72 | #define HID_REQ_SET_REPORT 0x09 73 | #define HID_REQ_GET_REPORT 0x01 74 | /** 75 | * @} 76 | */ 77 | 78 | 79 | /** @defgroup USBD_CORE_Exported_TypesDefinitions 80 | * @{ 81 | */ 82 | typedef enum 83 | { 84 | HID_IDLE = 0, 85 | HID_BUSY, 86 | } 87 | HID_StateTypeDef; 88 | 89 | 90 | typedef struct 91 | { 92 | uint32_t Protocol; 93 | uint32_t IdleState; 94 | uint32_t AltSetting; 95 | HID_StateTypeDef state; 96 | } 97 | USBD_HID_HandleTypeDef; 98 | /** 99 | * @} 100 | */ 101 | 102 | 103 | 104 | /** @defgroup USBD_CORE_Exported_Macros 105 | * @{ 106 | */ 107 | 108 | /** 109 | * @} 110 | */ 111 | 112 | /** @defgroup USBD_CORE_Exported_Variables 113 | * @{ 114 | */ 115 | 116 | extern USBD_ClassTypeDef USBD_HID; 117 | #define USBD_HID_CLASS &USBD_HID 118 | /** 119 | * @} 120 | */ 121 | 122 | /** @defgroup USB_CORE_Exported_Functions 123 | * @{ 124 | */ 125 | uint8_t USBD_HID_SendReport (USBD_HandleTypeDef *pdev, 126 | uint8_t *report, 127 | uint16_t len); 128 | 129 | uint32_t USBD_HID_GetPollingInterval (USBD_HandleTypeDef *pdev); 130 | 131 | /** 132 | * @} 133 | */ 134 | 135 | #ifdef __cplusplus 136 | } 137 | #endif 138 | 139 | #endif /* __USB_HID_H */ 140 | /** 141 | * @} 142 | */ 143 | 144 | /** 145 | * @} 146 | */ 147 | 148 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 149 | -------------------------------------------------------------------------------- /Middlewares/ST/STM32_USB_Device_Library/Class/HID/Inc/usbd_hid.h.bak: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_hid.h 4 | * @author MCD Application Team 5 | * @version V2.4.1 6 | * @date 19-June-2015 7 | * @brief Header file for the usbd_hid_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 __USB_HID_H 30 | #define __USB_HID_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_HID 44 | * @brief This file is the Header file for usbd_hid.c 45 | * @{ 46 | */ 47 | 48 | 49 | /** @defgroup USBD_HID_Exported_Defines 50 | * @{ 51 | */ 52 | #define HID_EPIN_ADDR 0x81 53 | #define HID_EPIN_SIZE 0x04 54 | 55 | #define USB_HID_CONFIG_DESC_SIZ 34 56 | #define USB_HID_DESC_SIZ 9 57 | #define HID_MOUSE_REPORT_DESC_SIZE 74 58 | 59 | #define HID_DESCRIPTOR_TYPE 0x21 60 | #define HID_REPORT_DESC 0x22 61 | 62 | #define HID_HS_BINTERVAL 0x07 63 | #define HID_FS_BINTERVAL 0x0A 64 | #define HID_POLLING_INTERVAL 0x0A 65 | 66 | #define HID_REQ_SET_PROTOCOL 0x0B 67 | #define HID_REQ_GET_PROTOCOL 0x03 68 | 69 | #define HID_REQ_SET_IDLE 0x0A 70 | #define HID_REQ_GET_IDLE 0x02 71 | 72 | #define HID_REQ_SET_REPORT 0x09 73 | #define HID_REQ_GET_REPORT 0x01 74 | /** 75 | * @} 76 | */ 77 | 78 | 79 | /** @defgroup USBD_CORE_Exported_TypesDefinitions 80 | * @{ 81 | */ 82 | typedef enum 83 | { 84 | HID_IDLE = 0, 85 | HID_BUSY, 86 | } 87 | HID_StateTypeDef; 88 | 89 | 90 | typedef struct 91 | { 92 | uint32_t Protocol; 93 | uint32_t IdleState; 94 | uint32_t AltSetting; 95 | HID_StateTypeDef state; 96 | } 97 | USBD_HID_HandleTypeDef; 98 | /** 99 | * @} 100 | */ 101 | 102 | 103 | 104 | /** @defgroup USBD_CORE_Exported_Macros 105 | * @{ 106 | */ 107 | 108 | /** 109 | * @} 110 | */ 111 | 112 | /** @defgroup USBD_CORE_Exported_Variables 113 | * @{ 114 | */ 115 | 116 | extern USBD_ClassTypeDef USBD_HID; 117 | #define USBD_HID_CLASS &USBD_HID 118 | /** 119 | * @} 120 | */ 121 | 122 | /** @defgroup USB_CORE_Exported_Functions 123 | * @{ 124 | */ 125 | uint8_t USBD_HID_SendReport (USBD_HandleTypeDef *pdev, 126 | uint8_t *report, 127 | uint16_t len); 128 | 129 | uint32_t USBD_HID_GetPollingInterval (USBD_HandleTypeDef *pdev); 130 | 131 | /** 132 | * @} 133 | */ 134 | 135 | #ifdef __cplusplus 136 | } 137 | #endif 138 | 139 | #endif /* __USB_HID_H */ 140 | /** 141 | * @} 142 | */ 143 | 144 | /** 145 | * @} 146 | */ 147 | 148 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 149 | -------------------------------------------------------------------------------- /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.1 6 | * @date 19-June-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.1 6 | * @date 19-June-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_def.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_def.h 4 | * @author MCD Application Team 5 | * @version V2.4.1 6 | * @date 19-June-2015 7 | * @brief General defines for the usb device library 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_DEF_H 30 | #define __USBD_DEF_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Includes ------------------------------------------------------------------*/ 37 | #include "usbd_conf.h" 38 | 39 | /** @addtogroup STM32_USBD_DEVICE_LIBRARY 40 | * @{ 41 | */ 42 | 43 | /** @defgroup USB_DEF 44 | * @brief general defines for the usb device library file 45 | * @{ 46 | */ 47 | 48 | /** @defgroup USB_DEF_Exported_Defines 49 | * @{ 50 | */ 51 | 52 | #ifndef NULL 53 | #define NULL 0 54 | #endif 55 | 56 | 57 | #define USB_LEN_DEV_QUALIFIER_DESC 0x0A 58 | #define USB_LEN_DEV_DESC 0x12 59 | #define USB_LEN_CFG_DESC 0x09 60 | #define USB_LEN_IF_DESC 0x09 61 | #define USB_LEN_EP_DESC 0x07 62 | #define USB_LEN_OTG_DESC 0x03 63 | #define USB_LEN_LANGID_STR_DESC 0x04 64 | #define USB_LEN_OTHER_SPEED_DESC_SIZ 0x09 65 | 66 | #define USBD_IDX_LANGID_STR 0x00 67 | #define USBD_IDX_MFC_STR 0x01 68 | #define USBD_IDX_PRODUCT_STR 0x02 69 | #define USBD_IDX_SERIAL_STR 0x03 70 | #define USBD_IDX_CONFIG_STR 0x04 71 | #define USBD_IDX_INTERFACE_STR 0x05 72 | 73 | #define USB_REQ_TYPE_STANDARD 0x00 74 | #define USB_REQ_TYPE_CLASS 0x20 75 | #define USB_REQ_TYPE_VENDOR 0x40 76 | #define USB_REQ_TYPE_MASK 0x60 77 | 78 | #define USB_REQ_RECIPIENT_DEVICE 0x00 79 | #define USB_REQ_RECIPIENT_INTERFACE 0x01 80 | #define USB_REQ_RECIPIENT_ENDPOINT 0x02 81 | #define USB_REQ_RECIPIENT_MASK 0x03 82 | 83 | #define USB_REQ_GET_STATUS 0x00 84 | #define USB_REQ_CLEAR_FEATURE 0x01 85 | #define USB_REQ_SET_FEATURE 0x03 86 | #define USB_REQ_SET_ADDRESS 0x05 87 | #define USB_REQ_GET_DESCRIPTOR 0x06 88 | #define USB_REQ_SET_DESCRIPTOR 0x07 89 | #define USB_REQ_GET_CONFIGURATION 0x08 90 | #define USB_REQ_SET_CONFIGURATION 0x09 91 | #define USB_REQ_GET_INTERFACE 0x0A 92 | #define USB_REQ_SET_INTERFACE 0x0B 93 | #define USB_REQ_SYNCH_FRAME 0x0C 94 | 95 | #define USB_DESC_TYPE_DEVICE 1 96 | #define USB_DESC_TYPE_CONFIGURATION 2 97 | #define USB_DESC_TYPE_STRING 3 98 | #define USB_DESC_TYPE_INTERFACE 4 99 | #define USB_DESC_TYPE_ENDPOINT 5 100 | #define USB_DESC_TYPE_DEVICE_QUALIFIER 6 101 | #define USB_DESC_TYPE_OTHER_SPEED_CONFIGURATION 7 102 | //#define USB_DESC_TYPE_BOS 0x0F 103 | 104 | #define USB_CONFIG_REMOTE_WAKEUP 2 105 | #define USB_CONFIG_SELF_POWERED 1 106 | 107 | #define USB_FEATURE_EP_HALT 0 108 | #define USB_FEATURE_REMOTE_WAKEUP 1 109 | #define USB_FEATURE_TEST_MODE 2 110 | 111 | //#define USB_DEVICE_CAPABITY_TYPE 0x10 112 | 113 | #define USB_HS_MAX_PACKET_SIZE 512 114 | #define USB_FS_MAX_PACKET_SIZE 64 115 | #define USB_MAX_EP0_SIZE 64 116 | 117 | /* Device Status */ 118 | #define USBD_STATE_DEFAULT 1 119 | #define USBD_STATE_ADDRESSED 2 120 | #define USBD_STATE_CONFIGURED 3 121 | #define USBD_STATE_SUSPENDED 4 122 | 123 | 124 | /* EP0 State */ 125 | #define USBD_EP0_IDLE 0 126 | #define USBD_EP0_SETUP 1 127 | #define USBD_EP0_DATA_IN 2 128 | #define USBD_EP0_DATA_OUT 3 129 | #define USBD_EP0_STATUS_IN 4 130 | #define USBD_EP0_STATUS_OUT 5 131 | #define USBD_EP0_STALL 6 132 | 133 | #define USBD_EP_TYPE_CTRL 0 134 | #define USBD_EP_TYPE_ISOC 1 135 | #define USBD_EP_TYPE_BULK 2 136 | #define USBD_EP_TYPE_INTR 3 137 | 138 | 139 | /** 140 | * @} 141 | */ 142 | 143 | 144 | /** @defgroup USBD_DEF_Exported_TypesDefinitions 145 | * @{ 146 | */ 147 | 148 | typedef struct usb_setup_req 149 | { 150 | 151 | uint8_t bmRequest; 152 | uint8_t bRequest; 153 | uint16_t wValue; 154 | uint16_t wIndex; 155 | uint16_t wLength; 156 | }USBD_SetupReqTypedef; 157 | 158 | struct _USBD_HandleTypeDef; 159 | 160 | typedef struct _Device_cb 161 | { 162 | uint8_t (*Init) (struct _USBD_HandleTypeDef *pdev , uint8_t cfgidx); 163 | uint8_t (*DeInit) (struct _USBD_HandleTypeDef *pdev , uint8_t cfgidx); 164 | /* Control Endpoints*/ 165 | uint8_t (*Setup) (struct _USBD_HandleTypeDef *pdev , USBD_SetupReqTypedef *req); 166 | uint8_t (*EP0_TxSent) (struct _USBD_HandleTypeDef *pdev ); 167 | uint8_t (*EP0_RxReady) (struct _USBD_HandleTypeDef *pdev ); 168 | /* Class Specific Endpoints*/ 169 | uint8_t (*DataIn) (struct _USBD_HandleTypeDef *pdev , uint8_t epnum); 170 | uint8_t (*DataOut) (struct _USBD_HandleTypeDef *pdev , uint8_t epnum); 171 | uint8_t (*SOF) (struct _USBD_HandleTypeDef *pdev); 172 | uint8_t (*IsoINIncomplete) (struct _USBD_HandleTypeDef *pdev , uint8_t epnum); 173 | uint8_t (*IsoOUTIncomplete) (struct _USBD_HandleTypeDef *pdev , uint8_t epnum); 174 | 175 | uint8_t *(*GetHSConfigDescriptor)(uint16_t *length); 176 | uint8_t *(*GetFSConfigDescriptor)(uint16_t *length); 177 | uint8_t *(*GetOtherSpeedConfigDescriptor)(uint16_t *length); 178 | uint8_t *(*GetDeviceQualifierDescriptor)(uint16_t *length); 179 | #if (USBD_SUPPORT_USER_STRING == 1) 180 | uint8_t *(*GetUsrStrDescriptor)(struct _USBD_HandleTypeDef *pdev ,uint8_t index, uint16_t *length); 181 | #endif 182 | 183 | } USBD_ClassTypeDef; 184 | 185 | /* Following USB Device Speed */ 186 | typedef enum 187 | { 188 | USBD_SPEED_HIGH = 0, 189 | USBD_SPEED_FULL = 1, 190 | USBD_SPEED_LOW = 2, 191 | }USBD_SpeedTypeDef; 192 | 193 | /* Following USB Device status */ 194 | typedef enum { 195 | USBD_OK = 0, 196 | USBD_BUSY, 197 | USBD_FAIL, 198 | }USBD_StatusTypeDef; 199 | 200 | /* USB Device descriptors structure */ 201 | typedef struct 202 | { 203 | uint8_t *(*GetDeviceDescriptor)( USBD_SpeedTypeDef speed , uint16_t *length); 204 | uint8_t *(*GetLangIDStrDescriptor)( USBD_SpeedTypeDef speed , uint16_t *length); 205 | uint8_t *(*GetManufacturerStrDescriptor)( USBD_SpeedTypeDef speed , uint16_t *length); 206 | uint8_t *(*GetProductStrDescriptor)( USBD_SpeedTypeDef speed , uint16_t *length); 207 | uint8_t *(*GetSerialStrDescriptor)( USBD_SpeedTypeDef speed , uint16_t *length); 208 | uint8_t *(*GetConfigurationStrDescriptor)( USBD_SpeedTypeDef speed , uint16_t *length); 209 | uint8_t *(*GetInterfaceStrDescriptor)( USBD_SpeedTypeDef speed , uint16_t *length); 210 | #if (USBD_LPM_ENABLED == 1) 211 | uint8_t *(*GetBOSDescriptor)( USBD_SpeedTypeDef speed , uint16_t *length); 212 | #endif 213 | } USBD_DescriptorsTypeDef; 214 | 215 | /* USB Device handle structure */ 216 | typedef struct 217 | { 218 | uint32_t status; 219 | uint32_t total_length; 220 | uint32_t rem_length; 221 | uint32_t maxpacket; 222 | } USBD_EndpointTypeDef; 223 | 224 | /* USB Device handle structure */ 225 | typedef struct _USBD_HandleTypeDef 226 | { 227 | uint8_t id; 228 | uint32_t dev_config; 229 | uint32_t dev_default_config; 230 | uint32_t dev_config_status; 231 | USBD_SpeedTypeDef dev_speed; 232 | USBD_EndpointTypeDef ep_in[15]; 233 | USBD_EndpointTypeDef ep_out[15]; 234 | uint32_t ep0_state; 235 | uint32_t ep0_data_len; 236 | uint8_t dev_state; 237 | uint8_t dev_old_state; 238 | uint8_t dev_address; 239 | uint8_t dev_connection_status; 240 | uint8_t dev_test_mode; 241 | uint32_t dev_remote_wakeup; 242 | 243 | USBD_SetupReqTypedef request; 244 | USBD_DescriptorsTypeDef *pDesc; 245 | USBD_ClassTypeDef *pClass; 246 | void *pClassData; 247 | void *pUserData; 248 | void *pData; 249 | } USBD_HandleTypeDef; 250 | 251 | /** 252 | * @} 253 | */ 254 | 255 | 256 | 257 | /** @defgroup USBD_DEF_Exported_Macros 258 | * @{ 259 | */ 260 | #define SWAPBYTE(addr) (((uint16_t)(*((uint8_t *)(addr)))) + \ 261 | (((uint16_t)(*(((uint8_t *)(addr)) + 1))) << 8)) 262 | 263 | #define LOBYTE(x) ((uint8_t)(x & 0x00FF)) 264 | #define HIBYTE(x) ((uint8_t)((x & 0xFF00) >>8)) 265 | #define MIN(a, b) (((a) < (b)) ? (a) : (b)) 266 | #define MAX(a, b) (((a) > (b)) ? (a) : (b)) 267 | 268 | 269 | #if defined ( __GNUC__ ) 270 | #ifndef __weak 271 | #define __weak __attribute__((weak)) 272 | #endif /* __weak */ 273 | #ifndef __packed 274 | #define __packed __attribute__((__packed__)) 275 | #endif /* __packed */ 276 | #endif /* __GNUC__ */ 277 | 278 | 279 | /* In HS mode and when the DMA is used, all variables and data structures dealing 280 | with the DMA during the transaction process should be 4-bytes aligned */ 281 | 282 | #if defined (__GNUC__) /* GNU Compiler */ 283 | #define __ALIGN_END __attribute__ ((aligned (4))) 284 | #define __ALIGN_BEGIN 285 | #else 286 | #define __ALIGN_END 287 | #if defined (__CC_ARM) /* ARM Compiler */ 288 | #define __ALIGN_BEGIN __align(4) 289 | #elif defined (__ICCARM__) /* IAR Compiler */ 290 | #define __ALIGN_BEGIN 291 | #elif defined (__TASKING__) /* TASKING Compiler */ 292 | #define __ALIGN_BEGIN __align(4) 293 | #endif /* __CC_ARM */ 294 | #endif /* __GNUC__ */ 295 | 296 | 297 | /** 298 | * @} 299 | */ 300 | 301 | /** @defgroup USBD_DEF_Exported_Variables 302 | * @{ 303 | */ 304 | 305 | /** 306 | * @} 307 | */ 308 | 309 | /** @defgroup USBD_DEF_Exported_FunctionsPrototype 310 | * @{ 311 | */ 312 | 313 | /** 314 | * @} 315 | */ 316 | 317 | #ifdef __cplusplus 318 | } 319 | #endif 320 | 321 | #endif /* __USBD_DEF_H */ 322 | 323 | /** 324 | * @} 325 | */ 326 | 327 | /** 328 | * @} 329 | */ 330 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 331 | -------------------------------------------------------------------------------- /Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_def.h.bak: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_def.h 4 | * @author MCD Application Team 5 | * @version V2.4.1 6 | * @date 19-June-2015 7 | * @brief General defines for the usb device library 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_DEF_H 30 | #define __USBD_DEF_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Includes ------------------------------------------------------------------*/ 37 | #include "usbd_conf.h" 38 | 39 | /** @addtogroup STM32_USBD_DEVICE_LIBRARY 40 | * @{ 41 | */ 42 | 43 | /** @defgroup USB_DEF 44 | * @brief general defines for the usb device library file 45 | * @{ 46 | */ 47 | 48 | /** @defgroup USB_DEF_Exported_Defines 49 | * @{ 50 | */ 51 | 52 | #ifndef NULL 53 | #define NULL 0 54 | #endif 55 | 56 | 57 | #define USB_LEN_DEV_QUALIFIER_DESC 0x0A 58 | #define USB_LEN_DEV_DESC 0x12 59 | #define USB_LEN_CFG_DESC 0x09 60 | #define USB_LEN_IF_DESC 0x09 61 | #define USB_LEN_EP_DESC 0x07 62 | #define USB_LEN_OTG_DESC 0x03 63 | #define USB_LEN_LANGID_STR_DESC 0x04 64 | #define USB_LEN_OTHER_SPEED_DESC_SIZ 0x09 65 | 66 | #define USBD_IDX_LANGID_STR 0x00 67 | #define USBD_IDX_MFC_STR 0x01 68 | #define USBD_IDX_PRODUCT_STR 0x02 69 | #define USBD_IDX_SERIAL_STR 0x03 70 | #define USBD_IDX_CONFIG_STR 0x04 71 | #define USBD_IDX_INTERFACE_STR 0x05 72 | 73 | #define USB_REQ_TYPE_STANDARD 0x00 74 | #define USB_REQ_TYPE_CLASS 0x20 75 | #define USB_REQ_TYPE_VENDOR 0x40 76 | #define USB_REQ_TYPE_MASK 0x60 77 | 78 | #define USB_REQ_RECIPIENT_DEVICE 0x00 79 | #define USB_REQ_RECIPIENT_INTERFACE 0x01 80 | #define USB_REQ_RECIPIENT_ENDPOINT 0x02 81 | #define USB_REQ_RECIPIENT_MASK 0x03 82 | 83 | #define USB_REQ_GET_STATUS 0x00 84 | #define USB_REQ_CLEAR_FEATURE 0x01 85 | #define USB_REQ_SET_FEATURE 0x03 86 | #define USB_REQ_SET_ADDRESS 0x05 87 | #define USB_REQ_GET_DESCRIPTOR 0x06 88 | #define USB_REQ_SET_DESCRIPTOR 0x07 89 | #define USB_REQ_GET_CONFIGURATION 0x08 90 | #define USB_REQ_SET_CONFIGURATION 0x09 91 | #define USB_REQ_GET_INTERFACE 0x0A 92 | #define USB_REQ_SET_INTERFACE 0x0B 93 | #define USB_REQ_SYNCH_FRAME 0x0C 94 | 95 | #define USB_DESC_TYPE_DEVICE 1 96 | #define USB_DESC_TYPE_CONFIGURATION 2 97 | #define USB_DESC_TYPE_STRING 3 98 | #define USB_DESC_TYPE_INTERFACE 4 99 | #define USB_DESC_TYPE_ENDPOINT 5 100 | #define USB_DESC_TYPE_DEVICE_QUALIFIER 6 101 | #define USB_DESC_TYPE_OTHER_SPEED_CONFIGURATION 7 102 | #define USB_DESC_TYPE_BOS 0x0F 103 | 104 | #define USB_CONFIG_REMOTE_WAKEUP 2 105 | #define USB_CONFIG_SELF_POWERED 1 106 | 107 | #define USB_FEATURE_EP_HALT 0 108 | #define USB_FEATURE_REMOTE_WAKEUP 1 109 | #define USB_FEATURE_TEST_MODE 2 110 | 111 | #define USB_DEVICE_CAPABITY_TYPE 0x10 112 | 113 | #define USB_HS_MAX_PACKET_SIZE 512 114 | #define USB_FS_MAX_PACKET_SIZE 64 115 | #define USB_MAX_EP0_SIZE 64 116 | 117 | /* Device Status */ 118 | #define USBD_STATE_DEFAULT 1 119 | #define USBD_STATE_ADDRESSED 2 120 | #define USBD_STATE_CONFIGURED 3 121 | #define USBD_STATE_SUSPENDED 4 122 | 123 | 124 | /* EP0 State */ 125 | #define USBD_EP0_IDLE 0 126 | #define USBD_EP0_SETUP 1 127 | #define USBD_EP0_DATA_IN 2 128 | #define USBD_EP0_DATA_OUT 3 129 | #define USBD_EP0_STATUS_IN 4 130 | #define USBD_EP0_STATUS_OUT 5 131 | #define USBD_EP0_STALL 6 132 | 133 | #define USBD_EP_TYPE_CTRL 0 134 | #define USBD_EP_TYPE_ISOC 1 135 | #define USBD_EP_TYPE_BULK 2 136 | #define USBD_EP_TYPE_INTR 3 137 | 138 | 139 | /** 140 | * @} 141 | */ 142 | 143 | 144 | /** @defgroup USBD_DEF_Exported_TypesDefinitions 145 | * @{ 146 | */ 147 | 148 | typedef struct usb_setup_req 149 | { 150 | 151 | uint8_t bmRequest; 152 | uint8_t bRequest; 153 | uint16_t wValue; 154 | uint16_t wIndex; 155 | uint16_t wLength; 156 | }USBD_SetupReqTypedef; 157 | 158 | struct _USBD_HandleTypeDef; 159 | 160 | typedef struct _Device_cb 161 | { 162 | uint8_t (*Init) (struct _USBD_HandleTypeDef *pdev , uint8_t cfgidx); 163 | uint8_t (*DeInit) (struct _USBD_HandleTypeDef *pdev , uint8_t cfgidx); 164 | /* Control Endpoints*/ 165 | uint8_t (*Setup) (struct _USBD_HandleTypeDef *pdev , USBD_SetupReqTypedef *req); 166 | uint8_t (*EP0_TxSent) (struct _USBD_HandleTypeDef *pdev ); 167 | uint8_t (*EP0_RxReady) (struct _USBD_HandleTypeDef *pdev ); 168 | /* Class Specific Endpoints*/ 169 | uint8_t (*DataIn) (struct _USBD_HandleTypeDef *pdev , uint8_t epnum); 170 | uint8_t (*DataOut) (struct _USBD_HandleTypeDef *pdev , uint8_t epnum); 171 | uint8_t (*SOF) (struct _USBD_HandleTypeDef *pdev); 172 | uint8_t (*IsoINIncomplete) (struct _USBD_HandleTypeDef *pdev , uint8_t epnum); 173 | uint8_t (*IsoOUTIncomplete) (struct _USBD_HandleTypeDef *pdev , uint8_t epnum); 174 | 175 | uint8_t *(*GetHSConfigDescriptor)(uint16_t *length); 176 | uint8_t *(*GetFSConfigDescriptor)(uint16_t *length); 177 | uint8_t *(*GetOtherSpeedConfigDescriptor)(uint16_t *length); 178 | uint8_t *(*GetDeviceQualifierDescriptor)(uint16_t *length); 179 | #if (USBD_SUPPORT_USER_STRING == 1) 180 | uint8_t *(*GetUsrStrDescriptor)(struct _USBD_HandleTypeDef *pdev ,uint8_t index, uint16_t *length); 181 | #endif 182 | 183 | } USBD_ClassTypeDef; 184 | 185 | /* Following USB Device Speed */ 186 | typedef enum 187 | { 188 | USBD_SPEED_HIGH = 0, 189 | USBD_SPEED_FULL = 1, 190 | USBD_SPEED_LOW = 2, 191 | }USBD_SpeedTypeDef; 192 | 193 | /* Following USB Device status */ 194 | typedef enum { 195 | USBD_OK = 0, 196 | USBD_BUSY, 197 | USBD_FAIL, 198 | }USBD_StatusTypeDef; 199 | 200 | /* USB Device descriptors structure */ 201 | typedef struct 202 | { 203 | uint8_t *(*GetDeviceDescriptor)( USBD_SpeedTypeDef speed , uint16_t *length); 204 | uint8_t *(*GetLangIDStrDescriptor)( USBD_SpeedTypeDef speed , uint16_t *length); 205 | uint8_t *(*GetManufacturerStrDescriptor)( USBD_SpeedTypeDef speed , uint16_t *length); 206 | uint8_t *(*GetProductStrDescriptor)( USBD_SpeedTypeDef speed , uint16_t *length); 207 | uint8_t *(*GetSerialStrDescriptor)( USBD_SpeedTypeDef speed , uint16_t *length); 208 | uint8_t *(*GetConfigurationStrDescriptor)( USBD_SpeedTypeDef speed , uint16_t *length); 209 | uint8_t *(*GetInterfaceStrDescriptor)( USBD_SpeedTypeDef speed , uint16_t *length); 210 | #if (USBD_LPM_ENABLED == 1) 211 | uint8_t *(*GetBOSDescriptor)( USBD_SpeedTypeDef speed , uint16_t *length); 212 | #endif 213 | } USBD_DescriptorsTypeDef; 214 | 215 | /* USB Device handle structure */ 216 | typedef struct 217 | { 218 | uint32_t status; 219 | uint32_t total_length; 220 | uint32_t rem_length; 221 | uint32_t maxpacket; 222 | } USBD_EndpointTypeDef; 223 | 224 | /* USB Device handle structure */ 225 | typedef struct _USBD_HandleTypeDef 226 | { 227 | uint8_t id; 228 | uint32_t dev_config; 229 | uint32_t dev_default_config; 230 | uint32_t dev_config_status; 231 | USBD_SpeedTypeDef dev_speed; 232 | USBD_EndpointTypeDef ep_in[15]; 233 | USBD_EndpointTypeDef ep_out[15]; 234 | uint32_t ep0_state; 235 | uint32_t ep0_data_len; 236 | uint8_t dev_state; 237 | uint8_t dev_old_state; 238 | uint8_t dev_address; 239 | uint8_t dev_connection_status; 240 | uint8_t dev_test_mode; 241 | uint32_t dev_remote_wakeup; 242 | 243 | USBD_SetupReqTypedef request; 244 | USBD_DescriptorsTypeDef *pDesc; 245 | USBD_ClassTypeDef *pClass; 246 | void *pClassData; 247 | void *pUserData; 248 | void *pData; 249 | } USBD_HandleTypeDef; 250 | 251 | /** 252 | * @} 253 | */ 254 | 255 | 256 | 257 | /** @defgroup USBD_DEF_Exported_Macros 258 | * @{ 259 | */ 260 | #define SWAPBYTE(addr) (((uint16_t)(*((uint8_t *)(addr)))) + \ 261 | (((uint16_t)(*(((uint8_t *)(addr)) + 1))) << 8)) 262 | 263 | #define LOBYTE(x) ((uint8_t)(x & 0x00FF)) 264 | #define HIBYTE(x) ((uint8_t)((x & 0xFF00) >>8)) 265 | #define MIN(a, b) (((a) < (b)) ? (a) : (b)) 266 | #define MAX(a, b) (((a) > (b)) ? (a) : (b)) 267 | 268 | 269 | #if defined ( __GNUC__ ) 270 | #ifndef __weak 271 | #define __weak __attribute__((weak)) 272 | #endif /* __weak */ 273 | #ifndef __packed 274 | #define __packed __attribute__((__packed__)) 275 | #endif /* __packed */ 276 | #endif /* __GNUC__ */ 277 | 278 | 279 | /* In HS mode and when the DMA is used, all variables and data structures dealing 280 | with the DMA during the transaction process should be 4-bytes aligned */ 281 | 282 | #if defined (__GNUC__) /* GNU Compiler */ 283 | #define __ALIGN_END __attribute__ ((aligned (4))) 284 | #define __ALIGN_BEGIN 285 | #else 286 | #define __ALIGN_END 287 | #if defined (__CC_ARM) /* ARM Compiler */ 288 | #define __ALIGN_BEGIN __align(4) 289 | #elif defined (__ICCARM__) /* IAR Compiler */ 290 | #define __ALIGN_BEGIN 291 | #elif defined (__TASKING__) /* TASKING Compiler */ 292 | #define __ALIGN_BEGIN __align(4) 293 | #endif /* __CC_ARM */ 294 | #endif /* __GNUC__ */ 295 | 296 | 297 | /** 298 | * @} 299 | */ 300 | 301 | /** @defgroup USBD_DEF_Exported_Variables 302 | * @{ 303 | */ 304 | 305 | /** 306 | * @} 307 | */ 308 | 309 | /** @defgroup USBD_DEF_Exported_FunctionsPrototype 310 | * @{ 311 | */ 312 | 313 | /** 314 | * @} 315 | */ 316 | 317 | #ifdef __cplusplus 318 | } 319 | #endif 320 | 321 | #endif /* __USBD_DEF_H */ 322 | 323 | /** 324 | * @} 325 | */ 326 | 327 | /** 328 | * @} 329 | */ 330 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 331 | -------------------------------------------------------------------------------- /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.1 6 | * @date 19-June-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.1 6 | * @date 19-June-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 | # STM32F1 Radio Control USB adapter 2 | # (NO LONGER SUPPORTED BY AUTHOR). 3 | 4 | Allows to connect RC transmitter to PC as a USB HID game controller. 5 | 6 | Based on same project for STM32F3Discovery: https://github.com/alexeystn/stm32-ppm-usb-adapter, but ported for STM32F1 (tested on STM32F103C8) controllers. 7 | 8 | Project for CooCox IDE. 9 | 10 | Compiled binaries can be found in Debug dir: https://github.com/voroshkov/STM32-RC-USB-Adapter/tree/master/stm32_PPM_F103/Debug/bin 11 | 12 | #Connections: 13 | - RC PPM out <==> PA8 14 | - RC GND <==> GND 15 | -------------------------------------------------------------------------------- /Src/main.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : main.c 4 | * Description : Main program body 5 | ****************************************************************************** 6 | * 7 | * COPYRIGHT(c) 2015 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 "stm32f1xx_hal.h" 35 | #include "usb_device.h" 36 | 37 | /* USER CODE BEGIN Includes */ 38 | #include "usbd_hid.h" 39 | /* USER CODE END Includes */ 40 | 41 | /* Private variables ---------------------------------------------------------*/ 42 | TIM_HandleTypeDef htim1; 43 | 44 | /* USER CODE BEGIN PV */ 45 | /* Private variables ---------------------------------------------------------*/ 46 | uint16_t captured_value[8] = { 0 }; 47 | uint16_t rc_data[5] = { 0 }; 48 | uint8_t pointer = 0; 49 | uint8_t data_ready = 0; 50 | /* USER CODE END PV */ 51 | 52 | /* Private function prototypes -----------------------------------------------*/ 53 | void SystemClock_Config(void); 54 | static void MX_GPIO_Init(void); 55 | static void MX_TIM1_Init(void); 56 | 57 | /* USER CODE BEGIN PFP */ 58 | /* Private function prototypes -----------------------------------------------*/ 59 | 60 | /* USER CODE END PFP */ 61 | 62 | /* USER CODE BEGIN 0 */ 63 | 64 | void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim) { 65 | // HAL_GPIO_WritePin(GPIOB, GPIO_PIN_6, GPIO_PIN_SET); 66 | // asm("NOP"); 67 | // asm("NOP"); 68 | // asm("NOP"); 69 | // asm("NOP"); 70 | // asm("NOP"); 71 | // asm("NOP"); 72 | // HAL_GPIO_WritePin(GPIOB, GPIO_PIN_6, GPIO_PIN_RESET); 73 | 74 | uint8_t i; 75 | uint16_t temp; 76 | temp = HAL_TIM_ReadCapturedValue(htim, TIM_CHANNEL_1); 77 | if ((temp > 5000) && (!data_ready)) { 78 | pointer = 0; 79 | for (i = 0; i < 4; i++) { 80 | if (captured_value[i] < 1000) 81 | captured_value[i] = 1000; 82 | else if (captured_value[i] > 2000) 83 | captured_value[i] = 2000; 84 | rc_data[i] = captured_value[i] - 1000; 85 | }; 86 | rc_data[4] = 0; 87 | if (captured_value[4] > 1500) 88 | rc_data[4] |= (1 << 4); 89 | if (captured_value[5] > 1500) 90 | rc_data[4] |= (1 << 5); 91 | if (captured_value[6] > 1500) 92 | rc_data[4] |= (1 << 6); 93 | if (captured_value[7] > 1500) 94 | rc_data[4] |= (1 << 7); 95 | data_ready = 1; 96 | } else { 97 | captured_value[pointer] = temp; 98 | pointer++; 99 | } 100 | if (pointer == 8) 101 | pointer = 0; 102 | } 103 | 104 | /* USER CODE END 0 */ 105 | 106 | int main(void) { 107 | 108 | /* USER CODE BEGIN 1 */ 109 | 110 | /* USER CODE END 1 */ 111 | 112 | /* MCU Configuration----------------------------------------------------------*/ 113 | 114 | /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ 115 | HAL_Init(); 116 | 117 | /* Configure the system clock */ 118 | SystemClock_Config(); 119 | 120 | /* Initialize all configured peripherals */ 121 | MX_GPIO_Init(); 122 | MX_TIM1_Init(); 123 | MX_USB_DEVICE_Init(); 124 | 125 | /* USER CODE BEGIN 2 */ 126 | HAL_TIM_IC_Start_IT(&htim1, TIM_CHANNEL_1); 127 | 128 | /* USER CODE END 2 */ 129 | 130 | /* Infinite loop */ 131 | /* USER CODE BEGIN WHILE */ 132 | 133 | //DBGMCU->CR |= DBGMCU_CR_DBG_TIM1_STOP; //this is for timer debugging 134 | 135 | while (1) { 136 | /* USER CODE END WHILE */ 137 | 138 | /* USER CODE BEGIN 3 */ 139 | if (data_ready) { 140 | USBD_HID_SendReport(&hUsbDeviceFS, (uint8_t*) rc_data, 10); 141 | data_ready = 0; 142 | } 143 | } 144 | /* USER CODE END 3 */ 145 | 146 | } 147 | 148 | /** System Clock Configuration 149 | */ 150 | void SystemClock_Config(void) { 151 | 152 | RCC_OscInitTypeDef RCC_OscInitStruct; 153 | RCC_ClkInitTypeDef RCC_ClkInitStruct; 154 | RCC_PeriphCLKInitTypeDef PeriphClkInit; 155 | 156 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; 157 | RCC_OscInitStruct.HSEState = RCC_HSE_ON; 158 | RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1; 159 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; 160 | RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; 161 | RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9; 162 | HAL_RCC_OscConfig(&RCC_OscInitStruct); 163 | 164 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1; 165 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; 166 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; 167 | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; 168 | RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; 169 | HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2); 170 | 171 | PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB; 172 | PeriphClkInit.UsbClockSelection = RCC_USBPLLCLK_DIV1_5; 173 | HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit); 174 | 175 | HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq() / 1000); 176 | 177 | HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK); 178 | 179 | /* SysTick_IRQn interrupt configuration */ 180 | HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); 181 | } 182 | 183 | /* TIM1 init function */ 184 | void MX_TIM1_Init(void) { 185 | 186 | TIM_ClockConfigTypeDef sClockSourceConfig; 187 | TIM_SlaveConfigTypeDef sSlaveConfig; 188 | TIM_MasterConfigTypeDef sMasterConfig; 189 | TIM_IC_InitTypeDef sConfigIC; 190 | 191 | htim1.Instance = TIM1; 192 | htim1.Init.Prescaler = 71; 193 | htim1.Init.CounterMode = TIM_COUNTERMODE_UP; 194 | htim1.Init.Period = 0xFFFF; 195 | htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; 196 | htim1.Init.RepetitionCounter = 0; 197 | HAL_TIM_Base_Init(&htim1); 198 | 199 | sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL; 200 | HAL_TIM_ConfigClockSource(&htim1, &sClockSourceConfig); 201 | 202 | HAL_TIM_IC_Init(&htim1); 203 | 204 | sSlaveConfig.SlaveMode = TIM_SLAVEMODE_RESET; 205 | sSlaveConfig.InputTrigger = TIM_TS_TI1FP1; 206 | sSlaveConfig.TriggerPolarity = TIM_INPUTCHANNELPOLARITY_FALLING; 207 | sSlaveConfig.TriggerFilter = 0; 208 | HAL_TIM_SlaveConfigSynchronization(&htim1, &sSlaveConfig); 209 | 210 | sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; 211 | sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; 212 | HAL_TIMEx_MasterConfigSynchronization(&htim1, &sMasterConfig); 213 | 214 | sConfigIC.ICPolarity = TIM_INPUTCHANNELPOLARITY_FALLING; 215 | sConfigIC.ICSelection = TIM_ICSELECTION_DIRECTTI; 216 | sConfigIC.ICPrescaler = TIM_ICPSC_DIV1; 217 | sConfigIC.ICFilter = 0; 218 | HAL_TIM_IC_ConfigChannel(&htim1, &sConfigIC, TIM_CHANNEL_1); 219 | } 220 | 221 | /** Configure pins as 222 | * Analog 223 | * Input 224 | * Output 225 | * EVENT_OUT 226 | * EXTI 227 | */ 228 | void MX_GPIO_Init(void) { 229 | 230 | // GPIO_InitTypeDef GPIO_InitStruct; 231 | // 232 | // /* GPIO Ports Clock Enable */ 233 | // __GPIOD_CLK_ENABLE(); 234 | // __GPIOA_CLK_ENABLE(); 235 | // __GPIOB_CLK_ENABLE(); 236 | // 237 | // /*Configure GPIO pin : PB6 */ 238 | // GPIO_InitStruct.Pin = GPIO_PIN_6 | GPIO_PIN_5; 239 | // GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 240 | // GPIO_InitStruct.Speed = GPIO_SPEED_LOW; 241 | // HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); 242 | // 243 | // HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5, GPIO_PIN_SET); 244 | // HAL_GPIO_WritePin(GPIOB, GPIO_PIN_6, GPIO_PIN_SET); 245 | } 246 | 247 | /* USER CODE BEGIN 4 */ 248 | 249 | /* USER CODE END 4 */ 250 | 251 | #ifdef USE_FULL_ASSERT 252 | 253 | /** 254 | * @brief Reports the name of the source file and the source line number 255 | * where the assert_param error has occurred. 256 | * @param file: pointer to the source file name 257 | * @param line: assert_param error line source number 258 | * @retval None 259 | */ 260 | void assert_failed(uint8_t* file, uint32_t line) 261 | { 262 | /* USER CODE BEGIN 6 */ 263 | /* User can add his own implementation to report the file name and line number, 264 | ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ 265 | /* USER CODE END 6 */ 266 | 267 | } 268 | 269 | #endif 270 | 271 | /** 272 | * @} 273 | */ 274 | 275 | /** 276 | * @} 277 | */ 278 | 279 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 280 | 281 | -------------------------------------------------------------------------------- /Src/startup_stm32f10x_md.s: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file startup_stm32f10x_md.s 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief STM32F10x Medium Density Devices vector table for RIDE7 toolchain. 8 | * This module performs: 9 | * - Set the initial SP 10 | * - Set the initial PC == Reset_Handler, 11 | * - Set the vector table entries with the exceptions ISR address 12 | * - Configure the clock system 13 | * - Branches to main in the C library (which eventually 14 | * calls main()). 15 | * After Reset the Cortex-M3 processor is in Thread mode, 16 | * priority is Privileged, and the Stack is set to Main. 17 | ****************************************************************************** 18 | * @attention 19 | * 20 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 21 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 22 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 23 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 24 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 25 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 26 | * 27 | *

© COPYRIGHT 2011 STMicroelectronics

28 | ****************************************************************************** 29 | */ 30 | 31 | .syntax unified 32 | .cpu cortex-m3 33 | .fpu softvfp 34 | .thumb 35 | 36 | .global g_pfnVectors 37 | .global Default_Handler 38 | 39 | /* start address for the initialization values of the .data section. 40 | defined in linker script */ 41 | .word _sidata 42 | /* start address for the .data section. defined in linker script */ 43 | .word _sdata 44 | /* end address for the .data section. defined in linker script */ 45 | .word _edata 46 | /* start address for the .bss section. defined in linker script */ 47 | .word _sbss 48 | /* end address for the .bss section. defined in linker script */ 49 | .word _ebss 50 | 51 | .equ BootRAM, 0xF108F85F 52 | /** 53 | * @brief This is the code that gets called when the processor first 54 | * starts execution following a reset event. Only the absolutely 55 | * necessary set is performed, after which the application 56 | * supplied main() routine is called. 57 | * @param None 58 | * @retval : None 59 | */ 60 | 61 | .section .text.Reset_Handler 62 | .weak Reset_Handler 63 | .type Reset_Handler, %function 64 | Reset_Handler: 65 | 66 | /* Copy the data segment initializers from flash to SRAM */ 67 | movs r1, #0 68 | b LoopCopyDataInit 69 | 70 | CopyDataInit: 71 | ldr r3, =_sidata 72 | ldr r3, [r3, r1] 73 | str r3, [r0, r1] 74 | adds r1, r1, #4 75 | 76 | LoopCopyDataInit: 77 | ldr r0, =_sdata 78 | ldr r3, =_edata 79 | adds r2, r0, r1 80 | cmp r2, r3 81 | bcc CopyDataInit 82 | ldr r2, =_sbss 83 | b LoopFillZerobss 84 | /* Zero fill the bss segment. */ 85 | FillZerobss: 86 | movs r3, #0 87 | str r3, [r2], #4 88 | 89 | LoopFillZerobss: 90 | ldr r3, = _ebss 91 | cmp r2, r3 92 | bcc FillZerobss 93 | /* Call the clock system intitialization function.*/ 94 | bl SystemInit 95 | /* Call the application's entry point.*/ 96 | bl main 97 | bx lr 98 | .size Reset_Handler, .-Reset_Handler 99 | 100 | /** 101 | * @brief This is the code that gets called when the processor receives an 102 | * unexpected interrupt. This simply enters an infinite loop, preserving 103 | * the system state for examination by a debugger. 104 | * @param None 105 | * @retval None 106 | */ 107 | .section .text.Default_Handler,"ax",%progbits 108 | Default_Handler: 109 | Infinite_Loop: 110 | b Infinite_Loop 111 | .size Default_Handler, .-Default_Handler 112 | /****************************************************************************** 113 | * 114 | * The minimal vector table for a Cortex M3. Note that the proper constructs 115 | * must be placed on this to ensure that it ends up at physical address 116 | * 0x0000.0000. 117 | * 118 | ******************************************************************************/ 119 | .section .isr_vector,"a",%progbits 120 | .type g_pfnVectors, %object 121 | .size g_pfnVectors, .-g_pfnVectors 122 | 123 | 124 | g_pfnVectors: 125 | .word _eram 126 | .word Reset_Handler 127 | .word NMI_Handler 128 | .word HardFault_Handler 129 | .word MemManage_Handler 130 | .word BusFault_Handler 131 | .word UsageFault_Handler 132 | .word 0 133 | .word 0 134 | .word 0 135 | .word 0 136 | .word SVC_Handler 137 | .word DebugMon_Handler 138 | .word 0 139 | .word PendSV_Handler 140 | .word SysTick_Handler 141 | .word WWDG_IRQHandler 142 | .word PVD_IRQHandler 143 | .word TAMPER_IRQHandler 144 | .word RTC_IRQHandler 145 | .word FLASH_IRQHandler 146 | .word RCC_IRQHandler 147 | .word EXTI0_IRQHandler 148 | .word EXTI1_IRQHandler 149 | .word EXTI2_IRQHandler 150 | .word EXTI3_IRQHandler 151 | .word EXTI4_IRQHandler 152 | .word DMA1_Channel1_IRQHandler 153 | .word DMA1_Channel2_IRQHandler 154 | .word DMA1_Channel3_IRQHandler 155 | .word DMA1_Channel4_IRQHandler 156 | .word DMA1_Channel5_IRQHandler 157 | .word DMA1_Channel6_IRQHandler 158 | .word DMA1_Channel7_IRQHandler 159 | .word ADC1_2_IRQHandler 160 | .word USB_HP_CAN1_TX_IRQHandler 161 | .word USB_LP_CAN1_RX0_IRQHandler 162 | .word CAN1_RX1_IRQHandler 163 | .word CAN1_SCE_IRQHandler 164 | .word EXTI9_5_IRQHandler 165 | .word TIM1_BRK_IRQHandler 166 | .word TIM1_UP_IRQHandler 167 | .word TIM1_TRG_COM_IRQHandler 168 | .word TIM1_CC_IRQHandler 169 | .word TIM2_IRQHandler 170 | .word TIM3_IRQHandler 171 | .word TIM4_IRQHandler 172 | .word I2C1_EV_IRQHandler 173 | .word I2C1_ER_IRQHandler 174 | .word I2C2_EV_IRQHandler 175 | .word I2C2_ER_IRQHandler 176 | .word SPI1_IRQHandler 177 | .word SPI2_IRQHandler 178 | .word USART1_IRQHandler 179 | .word USART2_IRQHandler 180 | .word USART3_IRQHandler 181 | .word EXTI15_10_IRQHandler 182 | .word RTCAlarm_IRQHandler 183 | .word USBWakeUp_IRQHandler 184 | .word 0 185 | .word 0 186 | .word 0 187 | .word 0 188 | .word 0 189 | .word 0 190 | .word 0 191 | .word BootRAM /* @0x108. This is for boot in RAM mode for 192 | STM32F10x Medium Density devices. */ 193 | 194 | /******************************************************************************* 195 | * 196 | * Provide weak aliases for each Exception handler to the Default_Handler. 197 | * As they are weak aliases, any function with the same name will override 198 | * this definition. 199 | * 200 | *******************************************************************************/ 201 | 202 | .weak NMI_Handler 203 | .thumb_set NMI_Handler,Default_Handler 204 | 205 | .weak HardFault_Handler 206 | .thumb_set HardFault_Handler,Default_Handler 207 | 208 | .weak MemManage_Handler 209 | .thumb_set MemManage_Handler,Default_Handler 210 | 211 | .weak BusFault_Handler 212 | .thumb_set BusFault_Handler,Default_Handler 213 | 214 | .weak UsageFault_Handler 215 | .thumb_set UsageFault_Handler,Default_Handler 216 | 217 | .weak SVC_Handler 218 | .thumb_set SVC_Handler,Default_Handler 219 | 220 | .weak DebugMon_Handler 221 | .thumb_set DebugMon_Handler,Default_Handler 222 | 223 | .weak PendSV_Handler 224 | .thumb_set PendSV_Handler,Default_Handler 225 | 226 | .weak SysTick_Handler 227 | .thumb_set SysTick_Handler,Default_Handler 228 | 229 | .weak WWDG_IRQHandler 230 | .thumb_set WWDG_IRQHandler,Default_Handler 231 | 232 | .weak PVD_IRQHandler 233 | .thumb_set PVD_IRQHandler,Default_Handler 234 | 235 | .weak TAMPER_IRQHandler 236 | .thumb_set TAMPER_IRQHandler,Default_Handler 237 | 238 | .weak RTC_IRQHandler 239 | .thumb_set RTC_IRQHandler,Default_Handler 240 | 241 | .weak FLASH_IRQHandler 242 | .thumb_set FLASH_IRQHandler,Default_Handler 243 | 244 | .weak RCC_IRQHandler 245 | .thumb_set RCC_IRQHandler,Default_Handler 246 | 247 | .weak EXTI0_IRQHandler 248 | .thumb_set EXTI0_IRQHandler,Default_Handler 249 | 250 | .weak EXTI1_IRQHandler 251 | .thumb_set EXTI1_IRQHandler,Default_Handler 252 | 253 | .weak EXTI2_IRQHandler 254 | .thumb_set EXTI2_IRQHandler,Default_Handler 255 | 256 | .weak EXTI3_IRQHandler 257 | .thumb_set EXTI3_IRQHandler,Default_Handler 258 | 259 | .weak EXTI4_IRQHandler 260 | .thumb_set EXTI4_IRQHandler,Default_Handler 261 | 262 | .weak DMA1_Channel1_IRQHandler 263 | .thumb_set DMA1_Channel1_IRQHandler,Default_Handler 264 | 265 | .weak DMA1_Channel2_IRQHandler 266 | .thumb_set DMA1_Channel2_IRQHandler,Default_Handler 267 | 268 | .weak DMA1_Channel3_IRQHandler 269 | .thumb_set DMA1_Channel3_IRQHandler,Default_Handler 270 | 271 | .weak DMA1_Channel4_IRQHandler 272 | .thumb_set DMA1_Channel4_IRQHandler,Default_Handler 273 | 274 | .weak DMA1_Channel5_IRQHandler 275 | .thumb_set DMA1_Channel5_IRQHandler,Default_Handler 276 | 277 | .weak DMA1_Channel6_IRQHandler 278 | .thumb_set DMA1_Channel6_IRQHandler,Default_Handler 279 | 280 | .weak DMA1_Channel7_IRQHandler 281 | .thumb_set DMA1_Channel7_IRQHandler,Default_Handler 282 | 283 | .weak ADC1_2_IRQHandler 284 | .thumb_set ADC1_2_IRQHandler,Default_Handler 285 | 286 | .weak USB_HP_CAN1_TX_IRQHandler 287 | .thumb_set USB_HP_CAN1_TX_IRQHandler,Default_Handler 288 | 289 | .weak USB_LP_CAN1_RX0_IRQHandler 290 | .thumb_set USB_LP_CAN1_RX0_IRQHandler,Default_Handler 291 | 292 | .weak CAN1_RX1_IRQHandler 293 | .thumb_set CAN1_RX1_IRQHandler,Default_Handler 294 | 295 | .weak CAN1_SCE_IRQHandler 296 | .thumb_set CAN1_SCE_IRQHandler,Default_Handler 297 | 298 | .weak EXTI9_5_IRQHandler 299 | .thumb_set EXTI9_5_IRQHandler,Default_Handler 300 | 301 | .weak TIM1_BRK_IRQHandler 302 | .thumb_set TIM1_BRK_IRQHandler,Default_Handler 303 | 304 | .weak TIM1_UP_IRQHandler 305 | .thumb_set TIM1_UP_IRQHandler,Default_Handler 306 | 307 | .weak TIM1_TRG_COM_IRQHandler 308 | .thumb_set TIM1_TRG_COM_IRQHandler,Default_Handler 309 | 310 | .weak TIM1_CC_IRQHandler 311 | .thumb_set TIM1_CC_IRQHandler,Default_Handler 312 | 313 | .weak TIM2_IRQHandler 314 | .thumb_set TIM2_IRQHandler,Default_Handler 315 | 316 | .weak TIM3_IRQHandler 317 | .thumb_set TIM3_IRQHandler,Default_Handler 318 | 319 | .weak TIM4_IRQHandler 320 | .thumb_set TIM4_IRQHandler,Default_Handler 321 | 322 | .weak I2C1_EV_IRQHandler 323 | .thumb_set I2C1_EV_IRQHandler,Default_Handler 324 | 325 | .weak I2C1_ER_IRQHandler 326 | .thumb_set I2C1_ER_IRQHandler,Default_Handler 327 | 328 | .weak I2C2_EV_IRQHandler 329 | .thumb_set I2C2_EV_IRQHandler,Default_Handler 330 | 331 | .weak I2C2_ER_IRQHandler 332 | .thumb_set I2C2_ER_IRQHandler,Default_Handler 333 | 334 | .weak SPI1_IRQHandler 335 | .thumb_set SPI1_IRQHandler,Default_Handler 336 | 337 | .weak SPI2_IRQHandler 338 | .thumb_set SPI2_IRQHandler,Default_Handler 339 | 340 | .weak USART1_IRQHandler 341 | .thumb_set USART1_IRQHandler,Default_Handler 342 | 343 | .weak USART2_IRQHandler 344 | .thumb_set USART2_IRQHandler,Default_Handler 345 | 346 | .weak USART3_IRQHandler 347 | .thumb_set USART3_IRQHandler,Default_Handler 348 | 349 | .weak EXTI15_10_IRQHandler 350 | .thumb_set EXTI15_10_IRQHandler,Default_Handler 351 | 352 | .weak RTCAlarm_IRQHandler 353 | .thumb_set RTCAlarm_IRQHandler,Default_Handler 354 | 355 | .weak USBWakeUp_IRQHandler 356 | .thumb_set USBWakeUp_IRQHandler,Default_Handler 357 | 358 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 359 | -------------------------------------------------------------------------------- /Src/stm32f1xx_hal_msp.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : stm32f1xx_hal_msp.c 4 | * Description : This file provides code for the MSP Initialization 5 | * and de-Initialization codes. 6 | ****************************************************************************** 7 | * 8 | * COPYRIGHT(c) 2015 STMicroelectronics 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 2. Redistributions in binary form must reproduce the above copyright notice, 15 | * this list of conditions and the following disclaimer in the documentation 16 | * and/or other materials provided with the distribution. 17 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without 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 ARE 24 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | ****************************************************************************** 33 | */ 34 | /* Includes ------------------------------------------------------------------*/ 35 | #include "stm32f1xx_hal.h" 36 | 37 | /* USER CODE BEGIN 0 */ 38 | 39 | /* USER CODE END 0 */ 40 | 41 | /** 42 | * Initializes the Global MSP. 43 | */ 44 | void HAL_MspInit(void) 45 | { 46 | /* USER CODE BEGIN MspInit 0 */ 47 | 48 | /* USER CODE END MspInit 0 */ 49 | 50 | __HAL_RCC_AFIO_CLK_ENABLE(); 51 | 52 | HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4); 53 | 54 | /* System interrupt init*/ 55 | /* SysTick_IRQn interrupt configuration */ 56 | HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); 57 | 58 | /* USER CODE BEGIN MspInit 1 */ 59 | 60 | /* USER CODE END MspInit 1 */ 61 | } 62 | 63 | void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base) 64 | { 65 | 66 | GPIO_InitTypeDef GPIO_InitStruct; 67 | if(htim_base->Instance==TIM1) 68 | { 69 | /* USER CODE BEGIN TIM1_MspInit 0 */ 70 | 71 | /* USER CODE END TIM1_MspInit 0 */ 72 | /* Peripheral clock enable */ 73 | __TIM1_CLK_ENABLE(); 74 | 75 | /**TIM1 GPIO Configuration 76 | PA8 ------> TIM1_CH1 77 | */ 78 | GPIO_InitStruct.Pin = GPIO_PIN_8; 79 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT; 80 | GPIO_InitStruct.Pull = GPIO_NOPULL; 81 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 82 | 83 | /* Peripheral interrupt init*/ 84 | HAL_NVIC_SetPriority(TIM1_CC_IRQn, 0, 0); 85 | HAL_NVIC_EnableIRQ(TIM1_CC_IRQn); 86 | /* USER CODE BEGIN TIM1_MspInit 1 */ 87 | 88 | /* USER CODE END TIM1_MspInit 1 */ 89 | } 90 | 91 | } 92 | 93 | void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base) 94 | { 95 | 96 | if(htim_base->Instance==TIM1) 97 | { 98 | /* USER CODE BEGIN TIM1_MspDeInit 0 */ 99 | 100 | /* USER CODE END TIM1_MspDeInit 0 */ 101 | /* Peripheral clock disable */ 102 | __TIM1_CLK_DISABLE(); 103 | 104 | /**TIM1 GPIO Configuration 105 | PA8 ------> TIM1_CH1 106 | */ 107 | HAL_GPIO_DeInit(GPIOA, GPIO_PIN_8); 108 | 109 | /* Peripheral interrupt DeInit*/ 110 | HAL_NVIC_DisableIRQ(TIM1_CC_IRQn); 111 | 112 | } 113 | /* USER CODE BEGIN TIM1_MspDeInit 1 */ 114 | 115 | /* USER CODE END TIM1_MspDeInit 1 */ 116 | 117 | } 118 | 119 | /* USER CODE BEGIN 1 */ 120 | 121 | /* USER CODE END 1 */ 122 | 123 | /** 124 | * @} 125 | */ 126 | 127 | /** 128 | * @} 129 | */ 130 | 131 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 132 | -------------------------------------------------------------------------------- /Src/stm32f1xx_it.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f1xx_it.c 4 | * @brief Interrupt Service Routines. 5 | ****************************************************************************** 6 | * 7 | * COPYRIGHT(c) 2015 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 "stm32f1xx_hal.h" 35 | #include "stm32f1xx.h" 36 | #include "stm32f1xx_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 | extern TIM_HandleTypeDef htim1; 45 | 46 | /******************************************************************************/ 47 | /* Cortex-M3 Processor Interruption and Exception Handlers */ 48 | /******************************************************************************/ 49 | 50 | /** 51 | * @brief This function handles System tick timer. 52 | */ 53 | void SysTick_Handler(void) 54 | { 55 | /* USER CODE BEGIN SysTick_IRQn 0 */ 56 | 57 | /* USER CODE END SysTick_IRQn 0 */ 58 | HAL_IncTick(); 59 | HAL_SYSTICK_IRQHandler(); 60 | /* USER CODE BEGIN SysTick_IRQn 1 */ 61 | 62 | /* USER CODE END SysTick_IRQn 1 */ 63 | } 64 | 65 | /******************************************************************************/ 66 | /* STM32F1xx Peripheral Interrupt Handlers */ 67 | /* Add here the Interrupt Handlers for the used peripherals. */ 68 | /* For the available peripheral interrupt handler names, */ 69 | /* please refer to the startup file (startup_stm32f1xx.s). */ 70 | /******************************************************************************/ 71 | 72 | /** 73 | * @brief This function handles USB low priority or CAN RX0 interrupts. 74 | */ 75 | void USB_LP_CAN1_RX0_IRQHandler(void) 76 | { 77 | /* USER CODE BEGIN USB_LP_CAN1_RX0_IRQn 0 */ 78 | 79 | /* USER CODE END USB_LP_CAN1_RX0_IRQn 0 */ 80 | HAL_PCD_IRQHandler(&hpcd_USB_FS); 81 | /* USER CODE BEGIN USB_LP_CAN1_RX0_IRQn 1 */ 82 | 83 | /* USER CODE END USB_LP_CAN1_RX0_IRQn 1 */ 84 | } 85 | 86 | /** 87 | * @brief This function handles TIM1 capture compare interrupt. 88 | */ 89 | void TIM1_CC_IRQHandler(void) 90 | { 91 | /* USER CODE BEGIN TIM1_CC_IRQn 0 */ 92 | 93 | /* USER CODE END TIM1_CC_IRQn 0 */ 94 | HAL_TIM_IRQHandler(&htim1); 95 | /* USER CODE BEGIN TIM1_CC_IRQn 1 */ 96 | 97 | /* USER CODE END TIM1_CC_IRQn 1 */ 98 | } 99 | 100 | /* USER CODE BEGIN 1 */ 101 | 102 | /* USER CODE END 1 */ 103 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 104 | -------------------------------------------------------------------------------- /Src/usb_device.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file : USB_DEVICE 4 | * @version : v1.0_Cube 5 | * @brief : This file implements the USB Device 6 | ****************************************************************************** 7 | * 8 | * COPYRIGHT(c) 2015 STMicroelectronics 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 2. Redistributions in binary form must reproduce the above copyright notice, 15 | * this list of conditions and the following disclaimer in the documentation 16 | * and/or other materials provided with the distribution. 17 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without 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 ARE 24 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | ****************************************************************************** 33 | */ 34 | 35 | /* Includes ------------------------------------------------------------------*/ 36 | 37 | #include "usb_device.h" 38 | #include "usbd_core.h" 39 | #include "usbd_desc.h" 40 | #include "usbd_hid.h" 41 | 42 | /* USB Device Core handle declaration */ 43 | USBD_HandleTypeDef hUsbDeviceFS; 44 | 45 | /* init function */ 46 | void MX_USB_DEVICE_Init(void) 47 | { 48 | /* Init Device Library,Add Supported Class and Start the library*/ 49 | USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS); 50 | 51 | USBD_RegisterClass(&hUsbDeviceFS, &USBD_HID); 52 | 53 | USBD_Start(&hUsbDeviceFS); 54 | 55 | } 56 | /** 57 | * @} 58 | */ 59 | 60 | /** 61 | * @} 62 | */ 63 | 64 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 65 | -------------------------------------------------------------------------------- /Src/usbd_desc.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file : usbd_desc.c 4 | * @version : v1.0_Cube 5 | * @brief : This file implements the USB Device descriptors 6 | ****************************************************************************** 7 | * 8 | * COPYRIGHT(c) 2015 STMicroelectronics 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 2. Redistributions in binary form must reproduce the above copyright notice, 15 | * this list of conditions and the following disclaimer in the documentation 16 | * and/or other materials provided with the distribution. 17 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without 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 ARE 24 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | ****************************************************************************** 33 | */ 34 | 35 | /* Includes ------------------------------------------------------------------*/ 36 | #include "usbd_core.h" 37 | #include "usbd_desc.h" 38 | #include "usbd_conf.h" 39 | 40 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY 41 | * @{ 42 | */ 43 | 44 | /** @defgroup USBD_DESC 45 | * @brief USBD descriptors module 46 | * @{ 47 | */ 48 | 49 | /** @defgroup USBD_DESC_Private_TypesDefinitions 50 | * @{ 51 | */ 52 | /** 53 | * @} 54 | */ 55 | 56 | /** @defgroup USBD_DESC_Private_Defines 57 | * @{ 58 | */ 59 | #define USBD_VID 0x483 60 | #define USBD_LANGID_STRING 1033 61 | #define USBD_MANUFACTURER_STRING "STMicroelectronics" 62 | #define USBD_PID_FS 0x57FF 63 | #define USBD_PRODUCT_STRING_FS "STM32 PPM-USB Adapter" 64 | /* USER CODE BEGIN SERIALNUMBER_STRING_FS */ 65 | #define USBD_SERIALNUMBER_STRING_FS "00000000001A" 66 | /* USER CODE END SERIALNUMBER_STRING_FS */ 67 | #define USBD_CONFIGURATION_STRING_FS "HID Config" 68 | #define USBD_INTERFACE_STRING_FS "HID Interface" 69 | 70 | /** 71 | * @} 72 | */ 73 | 74 | /** @defgroup USBD_DESC_Private_Macros 75 | * @{ 76 | */ 77 | /** 78 | * @} 79 | */ 80 | 81 | /** @defgroup USBD_DESC_Private_Variables 82 | * @{ 83 | */ 84 | uint8_t * USBD_FS_DeviceDescriptor( USBD_SpeedTypeDef speed , uint16_t *length); 85 | uint8_t * USBD_FS_LangIDStrDescriptor( USBD_SpeedTypeDef speed , uint16_t *length); 86 | uint8_t * USBD_FS_ManufacturerStrDescriptor ( USBD_SpeedTypeDef speed , uint16_t *length); 87 | uint8_t * USBD_FS_ProductStrDescriptor ( USBD_SpeedTypeDef speed , uint16_t *length); 88 | uint8_t * USBD_FS_SerialStrDescriptor( USBD_SpeedTypeDef speed , uint16_t *length); 89 | uint8_t * USBD_FS_ConfigStrDescriptor( USBD_SpeedTypeDef speed , uint16_t *length); 90 | uint8_t * USBD_FS_InterfaceStrDescriptor( USBD_SpeedTypeDef speed , uint16_t *length); 91 | 92 | #ifdef USB_SUPPORT_USER_STRING_DESC 93 | uint8_t * USBD_FS_USRStringDesc (USBD_SpeedTypeDef speed, uint8_t idx , uint16_t *length); 94 | #endif /* USB_SUPPORT_USER_STRING_DESC */ 95 | 96 | USBD_DescriptorsTypeDef FS_Desc = 97 | { 98 | USBD_FS_DeviceDescriptor, 99 | USBD_FS_LangIDStrDescriptor, 100 | USBD_FS_ManufacturerStrDescriptor, 101 | USBD_FS_ProductStrDescriptor, 102 | USBD_FS_SerialStrDescriptor, 103 | USBD_FS_ConfigStrDescriptor, 104 | USBD_FS_InterfaceStrDescriptor, 105 | }; 106 | 107 | #if defined ( __ICCARM__ ) /*!< IAR Compiler */ 108 | #pragma data_alignment=4 109 | #endif 110 | /* USB Standard Device Descriptor */ 111 | __ALIGN_BEGIN uint8_t USBD_FS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = 112 | { 113 | 0x12, /*bLength */ 114 | USB_DESC_TYPE_DEVICE, /*bDescriptorType*/ 115 | 0x00, /* bcdUSB */ 116 | 0x02, 117 | 0x00, /*bDeviceClass*/ 118 | 0x00, /*bDeviceSubClass*/ 119 | 0x00, /*bDeviceProtocol*/ 120 | USB_MAX_EP0_SIZE, /*bMaxPacketSize*/ 121 | LOBYTE(USBD_VID), /*idVendor*/ 122 | HIBYTE(USBD_VID), /*idVendor*/ 123 | LOBYTE(USBD_PID_FS), /*idVendor*/ 124 | HIBYTE(USBD_PID_FS), /*idVendor*/ 125 | 0x00, /*bcdDevice rel. 2.00*/ 126 | 0x02, 127 | USBD_IDX_MFC_STR, /*Index of manufacturer string*/ 128 | USBD_IDX_PRODUCT_STR, /*Index of product string*/ 129 | USBD_IDX_SERIAL_STR, /*Index of serial number string*/ 130 | USBD_MAX_NUM_CONFIGURATION /*bNumConfigurations*/ 131 | } ; 132 | /* USB_DeviceDescriptor */ 133 | 134 | #if defined ( __ICCARM__ ) /*!< IAR Compiler */ 135 | #pragma data_alignment=4 136 | #endif 137 | 138 | /* USB Standard Device Descriptor */ 139 | __ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_LEN_LANGID_STR_DESC] __ALIGN_END = 140 | { 141 | USB_LEN_LANGID_STR_DESC, 142 | USB_DESC_TYPE_STRING, 143 | LOBYTE(USBD_LANGID_STRING), 144 | HIBYTE(USBD_LANGID_STRING), 145 | }; 146 | 147 | #if defined ( __ICCARM__ ) /*!< IAR Compiler */ 148 | #pragma data_alignment=4 149 | #endif 150 | __ALIGN_BEGIN uint8_t USBD_StrDesc[USBD_MAX_STR_DESC_SIZ] __ALIGN_END; 151 | /** 152 | * @} 153 | */ 154 | 155 | /** @defgroup USBD_DESC_Private_FunctionPrototypes 156 | * @{ 157 | */ 158 | /** 159 | * @} 160 | */ 161 | 162 | /** @defgroup USBD_DESC_Private_Functions 163 | * @{ 164 | */ 165 | 166 | /** 167 | * @brief USBD_FS_DeviceDescriptor 168 | * return the device descriptor 169 | * @param speed : current device speed 170 | * @param length : pointer to data length variable 171 | * @retval pointer to descriptor buffer 172 | */ 173 | uint8_t * USBD_FS_DeviceDescriptor( USBD_SpeedTypeDef speed , uint16_t *length) 174 | { 175 | *length = sizeof(USBD_FS_DeviceDesc); 176 | return USBD_FS_DeviceDesc; 177 | } 178 | 179 | /** 180 | * @brief USBD_FS_LangIDStrDescriptor 181 | * return the LangID string descriptor 182 | * @param speed : current device speed 183 | * @param length : pointer to data length variable 184 | * @retval pointer to descriptor buffer 185 | */ 186 | uint8_t * USBD_FS_LangIDStrDescriptor( USBD_SpeedTypeDef speed , uint16_t *length) 187 | { 188 | *length = sizeof(USBD_LangIDDesc); 189 | return USBD_LangIDDesc; 190 | } 191 | 192 | /** 193 | * @brief USBD_FS_ProductStrDescriptor 194 | * return the product string descriptor 195 | * @param speed : current device speed 196 | * @param length : pointer to data length variable 197 | * @retval pointer to descriptor buffer 198 | */ 199 | uint8_t * USBD_FS_ProductStrDescriptor( USBD_SpeedTypeDef speed , uint16_t *length) 200 | { 201 | if(speed == 0) 202 | { 203 | USBD_GetString (USBD_PRODUCT_STRING_FS, USBD_StrDesc, length); 204 | } 205 | else 206 | { 207 | USBD_GetString (USBD_PRODUCT_STRING_FS, USBD_StrDesc, length); 208 | } 209 | return USBD_StrDesc; 210 | } 211 | 212 | /** 213 | * @brief USBD_FS_ManufacturerStrDescriptor 214 | * return the manufacturer string descriptor 215 | * @param speed : current device speed 216 | * @param length : pointer to data length variable 217 | * @retval pointer to descriptor buffer 218 | */ 219 | uint8_t * USBD_FS_ManufacturerStrDescriptor( USBD_SpeedTypeDef speed , uint16_t *length) 220 | { 221 | USBD_GetString (USBD_MANUFACTURER_STRING, USBD_StrDesc, length); 222 | return USBD_StrDesc; 223 | } 224 | 225 | /** 226 | * @brief USBD_FS_SerialStrDescriptor 227 | * return the serial number string descriptor 228 | * @param speed : current device speed 229 | * @param length : pointer to data length variable 230 | * @retval pointer to descriptor buffer 231 | */ 232 | uint8_t * USBD_FS_SerialStrDescriptor( USBD_SpeedTypeDef speed , uint16_t *length) 233 | { 234 | if(speed == USBD_SPEED_HIGH) 235 | { 236 | USBD_GetString (USBD_SERIALNUMBER_STRING_FS, USBD_StrDesc, length); 237 | } 238 | else 239 | { 240 | USBD_GetString (USBD_SERIALNUMBER_STRING_FS, USBD_StrDesc, length); 241 | } 242 | return USBD_StrDesc; 243 | } 244 | 245 | /** 246 | * @brief USBD_FS_ConfigStrDescriptor 247 | * return the configuration string descriptor 248 | * @param speed : current device speed 249 | * @param length : pointer to data length variable 250 | * @retval pointer to descriptor buffer 251 | */ 252 | uint8_t * USBD_FS_ConfigStrDescriptor( USBD_SpeedTypeDef speed , uint16_t *length) 253 | { 254 | if(speed == USBD_SPEED_HIGH) 255 | { 256 | USBD_GetString (USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length); 257 | } 258 | else 259 | { 260 | USBD_GetString (USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length); 261 | } 262 | return USBD_StrDesc; 263 | } 264 | 265 | /** 266 | * @brief USBD_HS_InterfaceStrDescriptor 267 | * return the interface string descriptor 268 | * @param speed : current device speed 269 | * @param length : pointer to data length variable 270 | * @retval pointer to descriptor buffer 271 | */ 272 | uint8_t * USBD_FS_InterfaceStrDescriptor( USBD_SpeedTypeDef speed , uint16_t *length) 273 | { 274 | if(speed == 0) 275 | { 276 | USBD_GetString (USBD_INTERFACE_STRING_FS, USBD_StrDesc, length); 277 | } 278 | else 279 | { 280 | USBD_GetString (USBD_INTERFACE_STRING_FS, USBD_StrDesc, length); 281 | } 282 | return USBD_StrDesc; 283 | } 284 | /** 285 | * @} 286 | */ 287 | 288 | /** 289 | * @} 290 | */ 291 | 292 | /** 293 | * @} 294 | */ 295 | 296 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 297 | -------------------------------------------------------------------------------- /stm32_PPM_F103.comarker: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /stm32_PPM_F103.comemgui: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /stm32_PPM_F103.ioc: -------------------------------------------------------------------------------- 1 | #MicroXplorer Configuration settings - do not modify 2 | File.Version=5 3 | KeepUserPlacement=false 4 | Mcu.Family=STM32F1 5 | Mcu.IP0=NVIC 6 | Mcu.IP1=RCC 7 | Mcu.IP2=TIM1 8 | Mcu.IP3=USB 9 | Mcu.IP4=USB_DEVICE 10 | Mcu.IPNb=5 11 | Mcu.Name=STM32F103C(8-B)Tx 12 | Mcu.Package=LQFP48 13 | Mcu.Pin0=PD0-OSC_IN 14 | Mcu.Pin1=PD1-OSC_OUT 15 | Mcu.Pin2=PA8 16 | Mcu.Pin3=PA11 17 | Mcu.Pin4=PA12 18 | Mcu.Pin5=PB6 19 | Mcu.Pin6=VP_TIM1_VS_ControllerModeReset 20 | Mcu.Pin7=VP_TIM1_VS_ClockSourceINT 21 | Mcu.Pin8=VP_USB_DEVICE_VS_USB_DEVICE_HID_FS 22 | Mcu.PinsNb=9 23 | Mcu.UserConstants= 24 | Mcu.UserName=STM32F103C8Tx 25 | MxCube.Version=4.11.0 26 | MxDb.Version=DB.4.0.110 27 | NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 28 | NVIC.SysTick_IRQn=true\:0\:0\:false 29 | NVIC.TIM1_CC_IRQn=true\:0\:0\:false 30 | NVIC.USB_LP_CAN1_RX0_IRQn=true\:0\:0\:false 31 | PA11.Mode=Device 32 | PA11.Signal=USB_DM 33 | PA12.Mode=Device 34 | PA12.Signal=USB_DP 35 | PA8.Signal=S_TIM1_CH1 36 | PB6.Locked=true 37 | PB6.Signal=GPIO_Output 38 | PCC.Checker=false 39 | PCC.Line=STM32F103 40 | PCC.MCU=STM32F103C(8-B)Tx 41 | PCC.MXVersion=4.11.0 42 | PCC.PartNumber=STM32F103C8Tx 43 | PCC.Seq0=0 44 | PCC.Series=STM32F1 45 | PCC.Temperature=25 46 | PCC.Vdd=3.3 47 | PD0-OSC_IN.Mode=HSE-External-Oscillator 48 | PD0-OSC_IN.Signal=RCC_OSC_IN 49 | PD1-OSC_OUT.Mode=HSE-External-Oscillator 50 | PD1-OSC_OUT.Signal=RCC_OSC_OUT 51 | ProjectManager.AskForMigrate=true 52 | ProjectManager.BackupPrevious=true 53 | ProjectManager.CompilerOptimize=2 54 | ProjectManager.ComputerToolchain=false 55 | ProjectManager.CoupleFile=false 56 | ProjectManager.DeletePrevious=false 57 | ProjectManager.DeviceId=STM32F103C8Tx 58 | ProjectManager.FirmwarePackage=STM32Cube FW_F1 V1.2.0 59 | ProjectManager.FreePins=false 60 | ProjectManager.HalAssertFull=false 61 | ProjectManager.KeepUserCode=true 62 | ProjectManager.LastFirmware=true 63 | ProjectManager.LibraryCopy=1 64 | ProjectManager.ProjectBuild=false 65 | ProjectManager.ProjectFileName=stm32_PPM_F103.ioc 66 | ProjectManager.ProjectName=stm32_PPM_F103 67 | ProjectManager.TargetToolchain=TrueSTUDIO 68 | ProjectManager.ToolChainLocation= 69 | RCC.ADCFreqValue=36000000 70 | RCC.AHBFreq_Value=72000000 71 | RCC.APB1CLKDivider=RCC_HCLK_DIV2 72 | RCC.APB1Freq_Value=36000000 73 | RCC.APB1TimFreq_Value=72000000 74 | RCC.APB2Freq_Value=72000000 75 | RCC.APB2TimFreq_Value=72000000 76 | RCC.FCLKCortexFreq_Value=72000000 77 | RCC.FamilyName=M 78 | RCC.HCLKFreq_Value=72000000 79 | RCC.HSIState=RCC_HSI_ON 80 | RCC.IPParameters=FamilyName,PLLCLKFreq_Value,PLLMCOFreq_Value,TimSysFreq_Value,APB1Freq_Value,APB2Freq_Value,USBFreq_Value,VCOOutput2Freq_Value,PLLMUL,SYSCLKSource,HCLKFreq_Value,AHBFreq_Value,FCLKCortexFreq_Value,APB1TimFreq_Value,APB2TimFreq_Value,ADCFreqValue,MCOFreq_Value,SYSCLKFreq_VALUE,HSIState,APB1CLKDivider,USBPrescaler 81 | RCC.MCOFreq_Value=72000000 82 | RCC.PLLCLKFreq_Value=72000000 83 | RCC.PLLMCOFreq_Value=36000000 84 | RCC.PLLMUL=RCC_PLL_MUL9 85 | RCC.SYSCLKFreq_VALUE=72000000 86 | RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK 87 | RCC.TimSysFreq_Value=72000000 88 | RCC.USBFreq_Value=48000000 89 | RCC.USBPrescaler=RCC_USBPLLCLK_DIV1_5 90 | RCC.VCOOutput2Freq_Value=8000000 91 | SH.S_TIM1_CH1.0=TIM1_CH1,TriggerSource_TI1FP1 92 | SH.S_TIM1_CH1.1=TIM1_CH1,Input_Capture1_from_TI1 93 | SH.S_TIM1_CH1.ConfNb=2 94 | TIM1.ICPolarity_CH1=TIM_INPUTCHANNELPOLARITY_FALLING 95 | TIM1.IPParameters=Prescaler,Period,ICPolarity_CH1 96 | TIM1.Period=0xFFFF 97 | TIM1.Prescaler=71 98 | USB_DEVICE.IPParameters=VirtualMode,VirtualModeFS,USBD_HandleTypeDef,PID_HID_FS,PRODUCT_STRING_HID_FS 99 | USB_DEVICE.PID_HID_FS=0x57FF 100 | USB_DEVICE.PRODUCT_STRING_HID_FS=STM32 PPM-USB Adapter 101 | USB_DEVICE.USBD_HandleTypeDef=hUsbDeviceFS 102 | USB_DEVICE.VirtualMode=Hid 103 | USB_DEVICE.VirtualModeFS=Hid_FS 104 | VP_TIM1_VS_ClockSourceINT.Mode=Internal 105 | VP_TIM1_VS_ClockSourceINT.Signal=TIM1_VS_ClockSourceINT 106 | VP_TIM1_VS_ControllerModeReset.Mode=Reset Mode 107 | VP_TIM1_VS_ControllerModeReset.Signal=TIM1_VS_ControllerModeReset 108 | VP_USB_DEVICE_VS_USB_DEVICE_HID_FS.Mode=HID_FS 109 | VP_USB_DEVICE_VS_USB_DEVICE_HID_FS.Signal=USB_DEVICE_VS_USB_DEVICE_HID_FS 110 | board=stm32_PPM_F103 111 | -------------------------------------------------------------------------------- /stm32_PPM_F103.txt: -------------------------------------------------------------------------------- 1 | Configuration stm32_PPM_F103 2 | STM32CubeMX 4.11.0 3 | Date 12/06/2015 4 | MCU STM32F103C8Tx 5 | 6 | 7 | 8 | PERIPHERALS MODES FUNCTIONS PINS 9 | RCC Crystal/Ceramic Resonator RCC_OSC_IN PD0-OSC_IN 10 | RCC Crystal/Ceramic Resonator RCC_OSC_OUT PD1-OSC_OUT 11 | TIM1 Reset Mode TIM1_VS_ControllerModeReset VP_TIM1_VS_ControllerModeReset 12 | TIM1 TI1FP1 TIM1_CH1 PA8 13 | TIM1 Internal Clock TIM1_VS_ClockSourceINT VP_TIM1_VS_ClockSourceINT 14 | TIM1 Input Capture direct mode TIM1_CH1 PA8 15 | USB Device (FS) USB_DM PA11 16 | USB Device (FS) USB_DP PA12 17 | 18 | 19 | 20 | Pin Nb PINs FUNCTIONs LABELs 21 | 5 PD0-OSC_IN RCC_OSC_IN 22 | 6 PD1-OSC_OUT RCC_OSC_OUT 23 | 29 PA8 TIM1_CH1 24 | 32 PA11 USB_DM 25 | 33 PA12 USB_DP 26 | 27 | 28 | 29 | SOFTWARE PROJECT 30 | 31 | Project Settings : 32 | Project Name : stm32_PPM_F103 33 | Project Folder : D:\WorkSTM32\stm32_PPM_F103 34 | Toolchain / IDE : TrueSTUDIO 35 | Firmware Package Name and Version : STM32Cube FW_F1 V1.2.0 36 | 37 | 38 | Code Generation Settings : 39 | STM32Cube Firmware Library Package : Copy only the necessary library files 40 | Generate peripheral initialization as a pair of '.c/.h' files per IP : No 41 | Backup previously generated files when re-generating : No 42 | Delete previously generated files when not re-generated : No 43 | Set all free pins as analog (to optimize the power consumption) : No 44 | 45 | 46 | Toolchains Settings : 47 | Compiler Optimizations : Balanced Size/Speed 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /stm32_PPM_F103/Debug/bin/history.xml: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /stm32_PPM_F103/Debug/bin/stm32_PPM_F103.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voroshkov/STM32-RC-USB-Adapter/afb6fe4015db4f0c237fd50d51814f468beb3ed4/stm32_PPM_F103/Debug/bin/stm32_PPM_F103.bin -------------------------------------------------------------------------------- /stm32_PPM_F103/Debug/bin/stm32_PPM_F103.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voroshkov/STM32-RC-USB-Adapter/afb6fe4015db4f0c237fd50d51814f468beb3ed4/stm32_PPM_F103/Debug/bin/stm32_PPM_F103.elf -------------------------------------------------------------------------------- /stm32_PPM_F103/Debug/obj/history.xml: -------------------------------------------------------------------------------- 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 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /stm32_PPM_F103/Debug/obj/main.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voroshkov/STM32-RC-USB-Adapter/afb6fe4015db4f0c237fd50d51814f468beb3ed4/stm32_PPM_F103/Debug/obj/main.o -------------------------------------------------------------------------------- /stm32_PPM_F103/Debug/obj/startup_stm32f10x_md.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voroshkov/STM32-RC-USB-Adapter/afb6fe4015db4f0c237fd50d51814f468beb3ed4/stm32_PPM_F103/Debug/obj/startup_stm32f10x_md.o -------------------------------------------------------------------------------- /stm32_PPM_F103/Debug/obj/stm32f1xx_hal.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voroshkov/STM32-RC-USB-Adapter/afb6fe4015db4f0c237fd50d51814f468beb3ed4/stm32_PPM_F103/Debug/obj/stm32f1xx_hal.o -------------------------------------------------------------------------------- /stm32_PPM_F103/Debug/obj/stm32f1xx_hal_cortex.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voroshkov/STM32-RC-USB-Adapter/afb6fe4015db4f0c237fd50d51814f468beb3ed4/stm32_PPM_F103/Debug/obj/stm32f1xx_hal_cortex.o -------------------------------------------------------------------------------- /stm32_PPM_F103/Debug/obj/stm32f1xx_hal_dma.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voroshkov/STM32-RC-USB-Adapter/afb6fe4015db4f0c237fd50d51814f468beb3ed4/stm32_PPM_F103/Debug/obj/stm32f1xx_hal_dma.o -------------------------------------------------------------------------------- /stm32_PPM_F103/Debug/obj/stm32f1xx_hal_flash.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voroshkov/STM32-RC-USB-Adapter/afb6fe4015db4f0c237fd50d51814f468beb3ed4/stm32_PPM_F103/Debug/obj/stm32f1xx_hal_flash.o -------------------------------------------------------------------------------- /stm32_PPM_F103/Debug/obj/stm32f1xx_hal_flash_ex.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voroshkov/STM32-RC-USB-Adapter/afb6fe4015db4f0c237fd50d51814f468beb3ed4/stm32_PPM_F103/Debug/obj/stm32f1xx_hal_flash_ex.o -------------------------------------------------------------------------------- /stm32_PPM_F103/Debug/obj/stm32f1xx_hal_gpio.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voroshkov/STM32-RC-USB-Adapter/afb6fe4015db4f0c237fd50d51814f468beb3ed4/stm32_PPM_F103/Debug/obj/stm32f1xx_hal_gpio.o -------------------------------------------------------------------------------- /stm32_PPM_F103/Debug/obj/stm32f1xx_hal_gpio_ex.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voroshkov/STM32-RC-USB-Adapter/afb6fe4015db4f0c237fd50d51814f468beb3ed4/stm32_PPM_F103/Debug/obj/stm32f1xx_hal_gpio_ex.o -------------------------------------------------------------------------------- /stm32_PPM_F103/Debug/obj/stm32f1xx_hal_msp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voroshkov/STM32-RC-USB-Adapter/afb6fe4015db4f0c237fd50d51814f468beb3ed4/stm32_PPM_F103/Debug/obj/stm32f1xx_hal_msp.o -------------------------------------------------------------------------------- /stm32_PPM_F103/Debug/obj/stm32f1xx_hal_pcd.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voroshkov/STM32-RC-USB-Adapter/afb6fe4015db4f0c237fd50d51814f468beb3ed4/stm32_PPM_F103/Debug/obj/stm32f1xx_hal_pcd.o -------------------------------------------------------------------------------- /stm32_PPM_F103/Debug/obj/stm32f1xx_hal_pcd_ex.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voroshkov/STM32-RC-USB-Adapter/afb6fe4015db4f0c237fd50d51814f468beb3ed4/stm32_PPM_F103/Debug/obj/stm32f1xx_hal_pcd_ex.o -------------------------------------------------------------------------------- /stm32_PPM_F103/Debug/obj/stm32f1xx_hal_pwr.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voroshkov/STM32-RC-USB-Adapter/afb6fe4015db4f0c237fd50d51814f468beb3ed4/stm32_PPM_F103/Debug/obj/stm32f1xx_hal_pwr.o -------------------------------------------------------------------------------- /stm32_PPM_F103/Debug/obj/stm32f1xx_hal_rcc.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voroshkov/STM32-RC-USB-Adapter/afb6fe4015db4f0c237fd50d51814f468beb3ed4/stm32_PPM_F103/Debug/obj/stm32f1xx_hal_rcc.o -------------------------------------------------------------------------------- /stm32_PPM_F103/Debug/obj/stm32f1xx_hal_rcc_ex.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voroshkov/STM32-RC-USB-Adapter/afb6fe4015db4f0c237fd50d51814f468beb3ed4/stm32_PPM_F103/Debug/obj/stm32f1xx_hal_rcc_ex.o -------------------------------------------------------------------------------- /stm32_PPM_F103/Debug/obj/stm32f1xx_hal_tim.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voroshkov/STM32-RC-USB-Adapter/afb6fe4015db4f0c237fd50d51814f468beb3ed4/stm32_PPM_F103/Debug/obj/stm32f1xx_hal_tim.o -------------------------------------------------------------------------------- /stm32_PPM_F103/Debug/obj/stm32f1xx_hal_tim_ex.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voroshkov/STM32-RC-USB-Adapter/afb6fe4015db4f0c237fd50d51814f468beb3ed4/stm32_PPM_F103/Debug/obj/stm32f1xx_hal_tim_ex.o -------------------------------------------------------------------------------- /stm32_PPM_F103/Debug/obj/stm32f1xx_it.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voroshkov/STM32-RC-USB-Adapter/afb6fe4015db4f0c237fd50d51814f468beb3ed4/stm32_PPM_F103/Debug/obj/stm32f1xx_it.o -------------------------------------------------------------------------------- /stm32_PPM_F103/Debug/obj/stm32f1xx_ll_usb.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voroshkov/STM32-RC-USB-Adapter/afb6fe4015db4f0c237fd50d51814f468beb3ed4/stm32_PPM_F103/Debug/obj/stm32f1xx_ll_usb.o -------------------------------------------------------------------------------- /stm32_PPM_F103/Debug/obj/system_stm32f1xx.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voroshkov/STM32-RC-USB-Adapter/afb6fe4015db4f0c237fd50d51814f468beb3ed4/stm32_PPM_F103/Debug/obj/system_stm32f1xx.o -------------------------------------------------------------------------------- /stm32_PPM_F103/Debug/obj/usb_device.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voroshkov/STM32-RC-USB-Adapter/afb6fe4015db4f0c237fd50d51814f468beb3ed4/stm32_PPM_F103/Debug/obj/usb_device.o -------------------------------------------------------------------------------- /stm32_PPM_F103/Debug/obj/usbd_conf.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voroshkov/STM32-RC-USB-Adapter/afb6fe4015db4f0c237fd50d51814f468beb3ed4/stm32_PPM_F103/Debug/obj/usbd_conf.o -------------------------------------------------------------------------------- /stm32_PPM_F103/Debug/obj/usbd_core.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voroshkov/STM32-RC-USB-Adapter/afb6fe4015db4f0c237fd50d51814f468beb3ed4/stm32_PPM_F103/Debug/obj/usbd_core.o -------------------------------------------------------------------------------- /stm32_PPM_F103/Debug/obj/usbd_ctlreq.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voroshkov/STM32-RC-USB-Adapter/afb6fe4015db4f0c237fd50d51814f468beb3ed4/stm32_PPM_F103/Debug/obj/usbd_ctlreq.o -------------------------------------------------------------------------------- /stm32_PPM_F103/Debug/obj/usbd_desc.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voroshkov/STM32-RC-USB-Adapter/afb6fe4015db4f0c237fd50d51814f468beb3ed4/stm32_PPM_F103/Debug/obj/usbd_desc.o -------------------------------------------------------------------------------- /stm32_PPM_F103/Debug/obj/usbd_hid.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voroshkov/STM32-RC-USB-Adapter/afb6fe4015db4f0c237fd50d51814f468beb3ed4/stm32_PPM_F103/Debug/obj/usbd_hid.o -------------------------------------------------------------------------------- /stm32_PPM_F103/Debug/obj/usbd_ioreq.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voroshkov/STM32-RC-USB-Adapter/afb6fe4015db4f0c237fd50d51814f468beb3ed4/stm32_PPM_F103/Debug/obj/usbd_ioreq.o -------------------------------------------------------------------------------- /stm32_PPM_F103_Configuration.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voroshkov/STM32-RC-USB-Adapter/afb6fe4015db4f0c237fd50d51814f468beb3ed4/stm32_PPM_F103_Configuration.pdf --------------------------------------------------------------------------------