├── .gdbinit ├── .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 │ │ │ ├── linker │ │ │ │ ├── STM32F100XB_FLASH.ld │ │ │ │ ├── STM32F100XE_FLASH.ld │ │ │ │ ├── STM32F101X6_FLASH.ld │ │ │ │ ├── STM32F101XB_FLASH.ld │ │ │ │ ├── STM32F101XE_FLASH.ld │ │ │ │ ├── STM32F101XG_FLASH.ld │ │ │ │ ├── STM32F102X6_FLASH.ld │ │ │ │ ├── STM32F102XB_FLASH.ld │ │ │ │ ├── STM32F103X6_FLASH.ld │ │ │ │ ├── STM32F103XB_FLASH.ld │ │ │ │ ├── STM32F103XE_FLASH.ld │ │ │ │ ├── STM32F103XG_FLASH.ld │ │ │ │ ├── STM32F105XC_FLASH.ld │ │ │ │ └── STM32F107XC_FLASH.ld │ │ │ ├── startup_stm32f100xb.s │ │ │ ├── startup_stm32f100xe.s │ │ │ ├── startup_stm32f101x6.s │ │ │ ├── startup_stm32f101xb.s │ │ │ ├── startup_stm32f101xe.s │ │ │ ├── startup_stm32f101xg.s │ │ │ ├── startup_stm32f102x6.s │ │ │ ├── startup_stm32f102xb.s │ │ │ ├── startup_stm32f103x6.s │ │ │ ├── startup_stm32f103xb.s │ │ │ ├── startup_stm32f103xe.s │ │ │ ├── startup_stm32f103xg.s │ │ │ ├── startup_stm32f105xc.s │ │ │ └── startup_stm32f107xc.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_adc.h │ ├── stm32f1xx_hal_adc_ex.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_spi.h │ ├── stm32f1xx_hal_uart.h │ └── stm32f1xx_ll_usb.h │ └── Src │ ├── stm32f1xx_hal.c │ ├── stm32f1xx_hal_adc.c │ ├── stm32f1xx_hal_adc_ex.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_spi.c │ ├── stm32f1xx_hal_spi_ex.c │ ├── stm32f1xx_hal_uart.c │ └── stm32f1xx_ll_usb.c ├── Inc ├── stm32f1xx_hal_conf.h ├── stm32f1xx_it.h ├── usb_device.h ├── usbd_conf.h ├── usbd_custom_hid_if.h └── usbd_desc.h ├── LICENSE ├── Middlewares └── ST │ └── STM32_USB_Device_Library │ ├── Class │ └── CustomHID │ │ ├── Inc │ │ └── usbd_customhid.h │ │ └── Src │ │ └── usbd_customhid.c │ └── Core │ ├── Inc │ ├── usbd_core.h │ ├── usbd_ctlreq.h │ ├── usbd_def.h │ └── usbd_ioreq.h │ └── Src │ ├── usbd_core.c │ ├── usbd_ctlreq.c │ └── usbd_ioreq.c ├── README ├── Src ├── main.c ├── stm32f1xx_hal_msp.c ├── stm32f1xx_it.c ├── usb_device.c ├── usbd_conf.c ├── usbd_custom_hid_if.c └── usbd_desc.c ├── hid-test.py ├── makefile ├── one_button_only.hid └── stm32f1-custom-usbhid.ioc /.gdbinit: -------------------------------------------------------------------------------- 1 | define flags 2 | if (($xpsr >> 31) & 1 ) 3 | printf "N " 4 | else 5 | printf "n " 6 | end 7 | if (($xpsr >> 30) & 1 ) 8 | printf "Z " 9 | else 10 | printf "z " 11 | end 12 | if (($xpsr >> 29) & 1 ) 13 | printf "C " 14 | else 15 | printf "c " 16 | end 17 | if (($xpsr >> 28) & 1 ) 18 | printf "V " 19 | else 20 | printf "V " 21 | end 22 | if (($xpsr >> 9) & 1 ) 23 | printf "E " 24 | else 25 | printf "e " 26 | end 27 | if (($xpsr >> 7) & 1 ) 28 | printf "I " 29 | else 30 | printf "i " 31 | end 32 | if (($xpsr >> 6) & 1 ) 33 | printf "F " 34 | else 35 | printf "f " 36 | end 37 | if (($xpsr >> 5) & 1 ) 38 | printf "T " 39 | else 40 | printf "t " 41 | end 42 | printf "\n" 43 | end 44 | document flags 45 | Print flags register 46 | end 47 | 48 | define ascii_char 49 | set $_c=*(unsigned char *)($arg0) 50 | if ( $_c < 0x20 || $_c > 0x7E ) 51 | printf "." 52 | else 53 | printf "%c", $_c 54 | end 55 | end 56 | document ascii_char 57 | Print the ASCII value of arg0 or '.' if value is unprintable 58 | end 59 | 60 | set $LITTLE_ENDIAN = 0 61 | 62 | define hex_quad 63 | if $LITTLE_ENDIAN 64 | printf "%02x %02x %02x %02x %02x %02x %02x %02x", \ 65 | *(unsigned char*)($arg0), *(unsigned char*)($arg0 + 1), \ 66 | *(unsigned char*)($arg0 + 2), *(unsigned char*)($arg0 + 3), \ 67 | *(unsigned char*)($arg0 + 4), *(unsigned char*)($arg0 + 5), \ 68 | *(unsigned char*)($arg0 + 6), *(unsigned char*)($arg0 + 7) 69 | else 70 | printf "%02x%02x%02x%02x %02x%02x%02x%02x", \ 71 | *(unsigned char*)($arg0 + 3), *(unsigned char*)($arg0 + 2), \ 72 | *(unsigned char*)($arg0 + 1), *(unsigned char*)($arg0 + 0), \ 73 | *(unsigned char*)($arg0 + 7), *(unsigned char*)($arg0 + 6), \ 74 | *(unsigned char*)($arg0 + 5), *(unsigned char*)($arg0 + 4) 75 | end 76 | end 77 | document hex_quad 78 | Print eight hexadecimal bytes starting at arg0 79 | end 80 | 81 | define hexdump 82 | printf "%08x : ", $arg0 83 | hex_quad $arg0 84 | printf " - " 85 | hex_quad ($arg0+8) 86 | printf " " 87 | 88 | ascii_char ($arg0) 89 | ascii_char ($arg0+1) 90 | ascii_char ($arg0+2) 91 | ascii_char ($arg0+3) 92 | ascii_char ($arg0+4) 93 | ascii_char ($arg0+5) 94 | ascii_char ($arg0+6) 95 | ascii_char ($arg0+7) 96 | ascii_char ($arg0+8) 97 | ascii_char ($arg0+9) 98 | ascii_char ($arg0+0xA) 99 | ascii_char ($arg0+0xB) 100 | ascii_char ($arg0+0xC) 101 | ascii_char ($arg0+0xD) 102 | ascii_char ($arg0+0xE) 103 | ascii_char ($arg0+0xF) 104 | 105 | printf "\n" 106 | end 107 | document hexdump 108 | Display a 16-byte hex/ASCII dump of arg0 109 | end 110 | 111 | define reg 112 | printf " r0:%08x r1:%08x r2:%08x r3:%08x ", $r0, $r1, $r2, $r3 113 | printf " msp:%08x psp:%08x\n", $msp, $psp 114 | printf " r4:%08x r5:%08x r6:%08x r7:%08x ", $r4, $r5, $r6, $r7 115 | printf " lr:%08x\n", $lr 116 | printf " r8:%08x r9:%08x r10:%08x ", $r8, $r9, $r10 117 | printf "r11:%08x xpsr:%08x\n", $r11, $xpsr 118 | printf " r12:%08x ", $r12 119 | flags 120 | end 121 | document reg 122 | Print CPU registers 123 | end 124 | 125 | define code 126 | printf "[%08x]------------------------", $pc 127 | printf "---------------------------------[ code]\n" 128 | x /6i $pc 129 | printf "---------------------------------------" 130 | printf "---------------------------------------\n" 131 | end 132 | document code 133 | show current code location 134 | end 135 | 136 | define code-on 137 | set $SHOW_CODE = 1 138 | end 139 | define code-off 140 | set $SHOW_CODE = 0 141 | end 142 | 143 | define context 144 | if $SHOW_CONTEXT 145 | if $SHOW_CODE 146 | code 147 | else 148 | x /1i $pc 149 | end 150 | printf "_______________________________________" 151 | printf "______________________________________________\n" 152 | reg 153 | 154 | printf "[%08x]------------------------", $sp 155 | printf "--------------------------------------------[stack]\n" 156 | hexdump $sp 157 | hexdump $sp+0x10 158 | hexdump $sp+0x20 159 | hexdump $sp+0x30 160 | end 161 | end 162 | document context 163 | Print regs, stack, and disassemble pc 164 | end 165 | 166 | define context-on 167 | set $SHOW_CONTEXT = 1 168 | end 169 | document context-on 170 | Enable display of context on every program stop 171 | end 172 | 173 | define context-off 174 | set $SHOW_CONTEXT = 1 175 | end 176 | document context-on 177 | Disable display of context on every program stop 178 | end 179 | 180 | # Calls "context" at every breakpoint. 181 | define hook-stop 182 | context 183 | end 184 | 185 | file main.elf 186 | target extended-remote /dev/ttyACM0 187 | monitor swdp_scan 188 | attach 1 189 | context-on 190 | -------------------------------------------------------------------------------- /.mxproject: -------------------------------------------------------------------------------- 1 | [PreviousLibFiles] 2 | 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_adc.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_adc_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_spi.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_spi_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_uart.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/CustomHID/Inc/usbd_customhid.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_adc.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.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/CustomHID/Src/usbd_customhid.c;Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/system_stm32f1xx.c;Drivers/CMSIS/Include/core_cmInstr.h;Drivers/CMSIS/Include/core_sc000.h;Drivers/CMSIS/Include/core_cm0.h;Drivers/CMSIS/Include/core_cm4.h;Drivers/CMSIS/Include/core_cmFunc.h;Drivers/CMSIS/Include/core_cm0plus.h;Drivers/CMSIS/Include/core_cmSimd.h;Drivers/CMSIS/Include/arm_const_structs.h;Drivers/CMSIS/Include/core_sc300.h;Drivers/CMSIS/Include/core_cm3.h;Drivers/CMSIS/Include/arm_math.h;Drivers/CMSIS/Include/core_cm7.h;Drivers/CMSIS/Include/arm_common_tables.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103x6.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f101xe.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f102x6.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f1xx.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f100xe.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f101xg.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f101xb.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xe.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f107xc.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f105xc.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f101x6.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f100xb.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/system_stm32f1xx.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xg.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f102xb.h; 3 | 4 | [PreviousGenFiles] 5 | HeaderPath=/home/jack/ARM/stm32/stm32f1-custom-usbhid/Inc 6 | SourcePath=/home/jack/ARM/stm32/stm32f1-custom-usbhid/Src 7 | SourceFiles=usb_device.h;usbd_conf.h;usbd_desc.h;usbd_custom_hid_if.h;stm32f1xx_it.h;stm32f1xx_hal_conf.h;usb_device.c;usbd_conf.c;usbd_desc.c;usbd_custom_hid_if.c;stm32f1xx_it.c;stm32f1xx_hal_msp.c;main.c; 8 | HeaderFiles=usb_device.h;usbd_conf.h;usbd_desc.h;usbd_custom_hid_if.h;stm32f1xx_it.h;stm32f1xx_hal_conf.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/CustomHID/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/usbd_custom_hid_if.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_adc.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.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/CustomHID/Src/usbd_customhid.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/CustomHID/Src/usbd_customhid.c; 13 | 14 | -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f100xb.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hansfbaier/stm32f1-custom-usbhid/26f28026685e66b9dfbf609c35eb2d5977157e3b/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f100xb.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f100xe.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hansfbaier/stm32f1-custom-usbhid/26f28026685e66b9dfbf609c35eb2d5977157e3b/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f100xe.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f101x6.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hansfbaier/stm32f1-custom-usbhid/26f28026685e66b9dfbf609c35eb2d5977157e3b/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f101x6.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f101xb.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hansfbaier/stm32f1-custom-usbhid/26f28026685e66b9dfbf609c35eb2d5977157e3b/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f101xb.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f101xe.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hansfbaier/stm32f1-custom-usbhid/26f28026685e66b9dfbf609c35eb2d5977157e3b/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f101xe.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f101xg.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hansfbaier/stm32f1-custom-usbhid/26f28026685e66b9dfbf609c35eb2d5977157e3b/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f101xg.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f102x6.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hansfbaier/stm32f1-custom-usbhid/26f28026685e66b9dfbf609c35eb2d5977157e3b/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f102x6.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f102xb.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hansfbaier/stm32f1-custom-usbhid/26f28026685e66b9dfbf609c35eb2d5977157e3b/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f102xb.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103x6.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hansfbaier/stm32f1-custom-usbhid/26f28026685e66b9dfbf609c35eb2d5977157e3b/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103x6.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hansfbaier/stm32f1-custom-usbhid/26f28026685e66b9dfbf609c35eb2d5977157e3b/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xe.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hansfbaier/stm32f1-custom-usbhid/26f28026685e66b9dfbf609c35eb2d5977157e3b/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xe.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xg.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hansfbaier/stm32f1-custom-usbhid/26f28026685e66b9dfbf609c35eb2d5977157e3b/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xg.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f105xc.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hansfbaier/stm32f1-custom-usbhid/26f28026685e66b9dfbf609c35eb2d5977157e3b/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f105xc.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f107xc.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hansfbaier/stm32f1-custom-usbhid/26f28026685e66b9dfbf609c35eb2d5977157e3b/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f107xc.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f1xx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hansfbaier/stm32f1-custom-usbhid/26f28026685e66b9dfbf609c35eb2d5977157e3b/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.0 6 | * @date 16-December-2014 7 | * @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Header File. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT(c) 2014 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/Device/ST/STM32F1xx/Source/Templates/gcc/linker/STM32F100XB_FLASH.ld: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hansfbaier/stm32f1-custom-usbhid/26f28026685e66b9dfbf609c35eb2d5977157e3b/Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/linker/STM32F100XB_FLASH.ld -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/linker/STM32F100XE_FLASH.ld: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hansfbaier/stm32f1-custom-usbhid/26f28026685e66b9dfbf609c35eb2d5977157e3b/Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/linker/STM32F100XE_FLASH.ld -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/linker/STM32F101X6_FLASH.ld: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hansfbaier/stm32f1-custom-usbhid/26f28026685e66b9dfbf609c35eb2d5977157e3b/Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/linker/STM32F101X6_FLASH.ld -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/linker/STM32F101XB_FLASH.ld: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hansfbaier/stm32f1-custom-usbhid/26f28026685e66b9dfbf609c35eb2d5977157e3b/Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/linker/STM32F101XB_FLASH.ld -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/linker/STM32F101XE_FLASH.ld: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hansfbaier/stm32f1-custom-usbhid/26f28026685e66b9dfbf609c35eb2d5977157e3b/Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/linker/STM32F101XE_FLASH.ld -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/linker/STM32F101XG_FLASH.ld: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hansfbaier/stm32f1-custom-usbhid/26f28026685e66b9dfbf609c35eb2d5977157e3b/Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/linker/STM32F101XG_FLASH.ld -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/linker/STM32F102X6_FLASH.ld: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hansfbaier/stm32f1-custom-usbhid/26f28026685e66b9dfbf609c35eb2d5977157e3b/Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/linker/STM32F102X6_FLASH.ld -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/linker/STM32F102XB_FLASH.ld: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hansfbaier/stm32f1-custom-usbhid/26f28026685e66b9dfbf609c35eb2d5977157e3b/Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/linker/STM32F102XB_FLASH.ld -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/linker/STM32F103X6_FLASH.ld: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hansfbaier/stm32f1-custom-usbhid/26f28026685e66b9dfbf609c35eb2d5977157e3b/Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/linker/STM32F103X6_FLASH.ld -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/linker/STM32F103XB_FLASH.ld: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hansfbaier/stm32f1-custom-usbhid/26f28026685e66b9dfbf609c35eb2d5977157e3b/Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/linker/STM32F103XB_FLASH.ld -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/linker/STM32F103XE_FLASH.ld: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hansfbaier/stm32f1-custom-usbhid/26f28026685e66b9dfbf609c35eb2d5977157e3b/Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/linker/STM32F103XE_FLASH.ld -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/linker/STM32F103XG_FLASH.ld: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hansfbaier/stm32f1-custom-usbhid/26f28026685e66b9dfbf609c35eb2d5977157e3b/Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/linker/STM32F103XG_FLASH.ld -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/linker/STM32F105XC_FLASH.ld: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hansfbaier/stm32f1-custom-usbhid/26f28026685e66b9dfbf609c35eb2d5977157e3b/Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/linker/STM32F105XC_FLASH.ld -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/linker/STM32F107XC_FLASH.ld: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hansfbaier/stm32f1-custom-usbhid/26f28026685e66b9dfbf609c35eb2d5977157e3b/Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/linker/STM32F107XC_FLASH.ld -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f101x6.s: -------------------------------------------------------------------------------- 1 | /** 2 | *************** (C) COPYRIGHT 2014 STMicroelectronics ************************ 3 | * @file startup_stm32f101x6.s 4 | * @author MCD Application Team 5 | * @version V4.0.0 6 | * @date 16-December-2014 7 | * @brief STM32F101x6 Devices vector table for Atollic 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 | * 19 | *

© COPYRIGHT(c) 2014 STMicroelectronics

20 | * 21 | * Redistribution and use in source and binary forms, with or without modification, 22 | * are permitted provided that the following conditions are met: 23 | * 1. Redistributions of source code must retain the above copyright notice, 24 | * this list of conditions and the following disclaimer. 25 | * 2. Redistributions in binary form must reproduce the above copyright notice, 26 | * this list of conditions and the following disclaimer in the documentation 27 | * and/or other materials provided with the distribution. 28 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 29 | * may be used to endorse or promote products derived from this software 30 | * without specific prior written permission. 31 | * 32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 33 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 34 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 35 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 36 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 37 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 38 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 39 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 40 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 41 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 42 | * 43 | ****************************************************************************** 44 | */ 45 | 46 | .syntax unified 47 | .cpu cortex-m3 48 | .fpu softvfp 49 | .thumb 50 | 51 | .global g_pfnVectors 52 | .global Default_Handler 53 | 54 | /* start address for the initialization values of the .data section. 55 | defined in linker script */ 56 | .word _sidata 57 | /* start address for the .data section. defined in linker script */ 58 | .word _sdata 59 | /* end address for the .data section. defined in linker script */ 60 | .word _edata 61 | /* start address for the .bss section. defined in linker script */ 62 | .word _sbss 63 | /* end address for the .bss section. defined in linker script */ 64 | .word _ebss 65 | 66 | .equ BootRAM, 0xF108F85F 67 | /** 68 | * @brief This is the code that gets called when the processor first 69 | * starts execution following a reset event. Only the absolutely 70 | * necessary set is performed, after which the application 71 | * supplied main() routine is called. 72 | * @param None 73 | * @retval : None 74 | */ 75 | 76 | .section .text.Reset_Handler 77 | .weak Reset_Handler 78 | .type Reset_Handler, %function 79 | Reset_Handler: 80 | 81 | /* Copy the data segment initializers from flash to SRAM */ 82 | movs r1, #0 83 | b LoopCopyDataInit 84 | 85 | CopyDataInit: 86 | ldr r3, =_sidata 87 | ldr r3, [r3, r1] 88 | str r3, [r0, r1] 89 | adds r1, r1, #4 90 | 91 | LoopCopyDataInit: 92 | ldr r0, =_sdata 93 | ldr r3, =_edata 94 | adds r2, r0, r1 95 | cmp r2, r3 96 | bcc CopyDataInit 97 | ldr r2, =_sbss 98 | b LoopFillZerobss 99 | /* Zero fill the bss segment. */ 100 | FillZerobss: 101 | movs r3, #0 102 | str r3, [r2], #4 103 | 104 | LoopFillZerobss: 105 | ldr r3, = _ebss 106 | cmp r2, r3 107 | bcc FillZerobss 108 | 109 | /* Call the clock system intitialization function.*/ 110 | bl SystemInit 111 | /* Call static constructors */ 112 | bl __libc_init_array 113 | /* Call the application's entry point.*/ 114 | bl main 115 | bx lr 116 | .size Reset_Handler, .-Reset_Handler 117 | 118 | /** 119 | * @brief This is the code that gets called when the processor receives an 120 | * unexpected interrupt. This simply enters an infinite loop, preserving 121 | * the system state for examination by a debugger. 122 | * 123 | * @param None 124 | * @retval : None 125 | */ 126 | .section .text.Default_Handler,"ax",%progbits 127 | Default_Handler: 128 | Infinite_Loop: 129 | b Infinite_Loop 130 | .size Default_Handler, .-Default_Handler 131 | /****************************************************************************** 132 | * 133 | * The minimal vector table for a Cortex M3. Note that the proper constructs 134 | * must be placed on this to ensure that it ends up at physical address 135 | * 0x0000.0000. 136 | * 137 | ******************************************************************************/ 138 | .section .isr_vector,"a",%progbits 139 | .type g_pfnVectors, %object 140 | .size g_pfnVectors, .-g_pfnVectors 141 | 142 | 143 | g_pfnVectors: 144 | 145 | 146 | .word _estack 147 | .word Reset_Handler 148 | .word NMI_Handler 149 | .word HardFault_Handler 150 | .word MemManage_Handler 151 | .word BusFault_Handler 152 | .word UsageFault_Handler 153 | .word 0 154 | .word 0 155 | .word 0 156 | .word 0 157 | .word SVC_Handler 158 | .word DebugMon_Handler 159 | .word 0 160 | .word PendSV_Handler 161 | .word SysTick_Handler 162 | .word WWDG_IRQHandler 163 | .word PVD_IRQHandler 164 | .word TAMPER_IRQHandler 165 | .word RTC_IRQHandler 166 | .word FLASH_IRQHandler 167 | .word RCC_IRQHandler 168 | .word EXTI0_IRQHandler 169 | .word EXTI1_IRQHandler 170 | .word EXTI2_IRQHandler 171 | .word EXTI3_IRQHandler 172 | .word EXTI4_IRQHandler 173 | .word DMA1_Channel1_IRQHandler 174 | .word DMA1_Channel2_IRQHandler 175 | .word DMA1_Channel3_IRQHandler 176 | .word DMA1_Channel4_IRQHandler 177 | .word DMA1_Channel5_IRQHandler 178 | .word DMA1_Channel6_IRQHandler 179 | .word DMA1_Channel7_IRQHandler 180 | .word ADC1_IRQHandler 181 | .word 0 182 | .word 0 183 | .word 0 184 | .word 0 185 | .word EXTI9_5_IRQHandler 186 | .word 0 187 | .word 0 188 | .word 0 189 | .word 0 190 | .word TIM2_IRQHandler 191 | .word TIM3_IRQHandler 192 | .word 0 193 | .word I2C1_EV_IRQHandler 194 | .word I2C1_ER_IRQHandler 195 | .word 0 196 | .word 0 197 | .word SPI1_IRQHandler 198 | .word 0 199 | .word USART1_IRQHandler 200 | .word USART2_IRQHandler 201 | .word 0 202 | .word EXTI15_10_IRQHandler 203 | .word RTC_Alarm_IRQHandler 204 | .word 0 205 | .word 0 206 | .word 0 207 | .word 0 208 | .word 0 209 | .word 0 210 | .word 0 211 | .word 0 212 | .word BootRAM /* @0x108. This is for boot in RAM mode for 213 | STM32F10x Low Density devices.*/ 214 | 215 | /******************************************************************************* 216 | * 217 | * Provide weak aliases for each Exception handler to the Default_Handler. 218 | * As they are weak aliases, any function with the same name will override 219 | * this definition. 220 | * 221 | *******************************************************************************/ 222 | 223 | .weak NMI_Handler 224 | .thumb_set NMI_Handler,Default_Handler 225 | 226 | .weak HardFault_Handler 227 | .thumb_set HardFault_Handler,Default_Handler 228 | 229 | .weak MemManage_Handler 230 | .thumb_set MemManage_Handler,Default_Handler 231 | 232 | .weak BusFault_Handler 233 | .thumb_set BusFault_Handler,Default_Handler 234 | 235 | .weak UsageFault_Handler 236 | .thumb_set UsageFault_Handler,Default_Handler 237 | 238 | .weak SVC_Handler 239 | .thumb_set SVC_Handler,Default_Handler 240 | 241 | .weak DebugMon_Handler 242 | .thumb_set DebugMon_Handler,Default_Handler 243 | 244 | .weak PendSV_Handler 245 | .thumb_set PendSV_Handler,Default_Handler 246 | 247 | .weak SysTick_Handler 248 | .thumb_set SysTick_Handler,Default_Handler 249 | 250 | .weak WWDG_IRQHandler 251 | .thumb_set WWDG_IRQHandler,Default_Handler 252 | 253 | .weak PVD_IRQHandler 254 | .thumb_set PVD_IRQHandler,Default_Handler 255 | 256 | .weak TAMPER_IRQHandler 257 | .thumb_set TAMPER_IRQHandler,Default_Handler 258 | 259 | .weak RTC_IRQHandler 260 | .thumb_set RTC_IRQHandler,Default_Handler 261 | 262 | .weak FLASH_IRQHandler 263 | .thumb_set FLASH_IRQHandler,Default_Handler 264 | 265 | .weak RCC_IRQHandler 266 | .thumb_set RCC_IRQHandler,Default_Handler 267 | 268 | .weak EXTI0_IRQHandler 269 | .thumb_set EXTI0_IRQHandler,Default_Handler 270 | 271 | .weak EXTI1_IRQHandler 272 | .thumb_set EXTI1_IRQHandler,Default_Handler 273 | 274 | .weak EXTI2_IRQHandler 275 | .thumb_set EXTI2_IRQHandler,Default_Handler 276 | 277 | .weak EXTI3_IRQHandler 278 | .thumb_set EXTI3_IRQHandler,Default_Handler 279 | 280 | .weak EXTI4_IRQHandler 281 | .thumb_set EXTI4_IRQHandler,Default_Handler 282 | 283 | .weak DMA1_Channel1_IRQHandler 284 | .thumb_set DMA1_Channel1_IRQHandler,Default_Handler 285 | 286 | .weak DMA1_Channel2_IRQHandler 287 | .thumb_set DMA1_Channel2_IRQHandler,Default_Handler 288 | 289 | .weak DMA1_Channel3_IRQHandler 290 | .thumb_set DMA1_Channel3_IRQHandler,Default_Handler 291 | 292 | .weak DMA1_Channel4_IRQHandler 293 | .thumb_set DMA1_Channel4_IRQHandler,Default_Handler 294 | 295 | .weak DMA1_Channel5_IRQHandler 296 | .thumb_set DMA1_Channel5_IRQHandler,Default_Handler 297 | 298 | .weak DMA1_Channel6_IRQHandler 299 | .thumb_set DMA1_Channel6_IRQHandler,Default_Handler 300 | 301 | .weak DMA1_Channel7_IRQHandler 302 | .thumb_set DMA1_Channel7_IRQHandler,Default_Handler 303 | 304 | .weak ADC1_IRQHandler 305 | .thumb_set ADC1_IRQHandler,Default_Handler 306 | 307 | .weak EXTI9_5_IRQHandler 308 | .thumb_set EXTI9_5_IRQHandler,Default_Handler 309 | 310 | .weak TIM2_IRQHandler 311 | .thumb_set TIM2_IRQHandler,Default_Handler 312 | 313 | .weak TIM3_IRQHandler 314 | .thumb_set TIM3_IRQHandler,Default_Handler 315 | 316 | .weak I2C1_EV_IRQHandler 317 | .thumb_set I2C1_EV_IRQHandler,Default_Handler 318 | 319 | .weak I2C1_ER_IRQHandler 320 | .thumb_set I2C1_ER_IRQHandler,Default_Handler 321 | 322 | .weak SPI1_IRQHandler 323 | .thumb_set SPI1_IRQHandler,Default_Handler 324 | 325 | .weak USART1_IRQHandler 326 | .thumb_set USART1_IRQHandler,Default_Handler 327 | 328 | .weak USART2_IRQHandler 329 | .thumb_set USART2_IRQHandler,Default_Handler 330 | 331 | .weak EXTI15_10_IRQHandler 332 | .thumb_set EXTI15_10_IRQHandler,Default_Handler 333 | 334 | .weak RTC_Alarm_IRQHandler 335 | .thumb_set RTC_Alarm_IRQHandler,Default_Handler 336 | 337 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 338 | -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f101xb.s: -------------------------------------------------------------------------------- 1 | /** 2 | *************** (C) COPYRIGHT 2014 STMicroelectronics ************************ 3 | * @file startup_stm32f101xb.s 4 | * @author MCD Application Team 5 | * @version V4.0.0 6 | * @date 16-December-2014 7 | * @brief STM32F101xB Devices vector table for Atollic 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 | * 19 | *

© COPYRIGHT(c) 2014 STMicroelectronics

20 | * 21 | * Redistribution and use in source and binary forms, with or without modification, 22 | * are permitted provided that the following conditions are met: 23 | * 1. Redistributions of source code must retain the above copyright notice, 24 | * this list of conditions and the following disclaimer. 25 | * 2. Redistributions in binary form must reproduce the above copyright notice, 26 | * this list of conditions and the following disclaimer in the documentation 27 | * and/or other materials provided with the distribution. 28 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 29 | * may be used to endorse or promote products derived from this software 30 | * without specific prior written permission. 31 | * 32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 33 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 34 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 35 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 36 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 37 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 38 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 39 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 40 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 41 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 42 | * 43 | ****************************************************************************** 44 | */ 45 | 46 | .syntax unified 47 | .cpu cortex-m3 48 | .fpu softvfp 49 | .thumb 50 | 51 | .global g_pfnVectors 52 | .global Default_Handler 53 | 54 | /* start address for the initialization values of the .data section. 55 | defined in linker script */ 56 | .word _sidata 57 | /* start address for the .data section. defined in linker script */ 58 | .word _sdata 59 | /* end address for the .data section. defined in linker script */ 60 | .word _edata 61 | /* start address for the .bss section. defined in linker script */ 62 | .word _sbss 63 | /* end address for the .bss section. defined in linker script */ 64 | .word _ebss 65 | 66 | .equ BootRAM, 0xF108F85F 67 | /** 68 | * @brief This is the code that gets called when the processor first 69 | * starts execution following a reset event. Only the absolutely 70 | * necessary set is performed, after which the application 71 | * supplied main() routine is called. 72 | * @param None 73 | * @retval : None 74 | */ 75 | 76 | .section .text.Reset_Handler 77 | .weak Reset_Handler 78 | .type Reset_Handler, %function 79 | Reset_Handler: 80 | 81 | /* Copy the data segment initializers from flash to SRAM */ 82 | movs r1, #0 83 | b LoopCopyDataInit 84 | 85 | CopyDataInit: 86 | ldr r3, =_sidata 87 | ldr r3, [r3, r1] 88 | str r3, [r0, r1] 89 | adds r1, r1, #4 90 | 91 | LoopCopyDataInit: 92 | ldr r0, =_sdata 93 | ldr r3, =_edata 94 | adds r2, r0, r1 95 | cmp r2, r3 96 | bcc CopyDataInit 97 | ldr r2, =_sbss 98 | b LoopFillZerobss 99 | /* Zero fill the bss segment. */ 100 | FillZerobss: 101 | movs r3, #0 102 | str r3, [r2], #4 103 | 104 | LoopFillZerobss: 105 | ldr r3, = _ebss 106 | cmp r2, r3 107 | bcc FillZerobss 108 | 109 | /* Call the clock system intitialization function.*/ 110 | bl SystemInit 111 | /* Call static constructors */ 112 | bl __libc_init_array 113 | /* Call the application's entry point.*/ 114 | bl main 115 | bx lr 116 | .size Reset_Handler, .-Reset_Handler 117 | 118 | /** 119 | * @brief This is the code that gets called when the processor receives an 120 | * unexpected interrupt. This simply enters an infinite loop, preserving 121 | * the system state for examination by a debugger. 122 | * 123 | * @param None 124 | * @retval : None 125 | */ 126 | .section .text.Default_Handler,"ax",%progbits 127 | Default_Handler: 128 | Infinite_Loop: 129 | b Infinite_Loop 130 | .size Default_Handler, .-Default_Handler 131 | /****************************************************************************** 132 | * 133 | * The minimal vector table for a Cortex M3. Note that the proper constructs 134 | * must be placed on this to ensure that it ends up at physical address 135 | * 0x0000.0000. 136 | * 137 | ******************************************************************************/ 138 | .section .isr_vector,"a",%progbits 139 | .type g_pfnVectors, %object 140 | .size g_pfnVectors, .-g_pfnVectors 141 | 142 | 143 | g_pfnVectors: 144 | 145 | .word _estack 146 | .word Reset_Handler 147 | .word NMI_Handler 148 | .word HardFault_Handler 149 | .word MemManage_Handler 150 | .word BusFault_Handler 151 | .word UsageFault_Handler 152 | .word 0 153 | .word 0 154 | .word 0 155 | .word 0 156 | .word SVC_Handler 157 | .word DebugMon_Handler 158 | .word 0 159 | .word PendSV_Handler 160 | .word SysTick_Handler 161 | .word WWDG_IRQHandler 162 | .word PVD_IRQHandler 163 | .word TAMPER_IRQHandler 164 | .word RTC_IRQHandler 165 | .word FLASH_IRQHandler 166 | .word RCC_IRQHandler 167 | .word EXTI0_IRQHandler 168 | .word EXTI1_IRQHandler 169 | .word EXTI2_IRQHandler 170 | .word EXTI3_IRQHandler 171 | .word EXTI4_IRQHandler 172 | .word DMA1_Channel1_IRQHandler 173 | .word DMA1_Channel2_IRQHandler 174 | .word DMA1_Channel3_IRQHandler 175 | .word DMA1_Channel4_IRQHandler 176 | .word DMA1_Channel5_IRQHandler 177 | .word DMA1_Channel6_IRQHandler 178 | .word DMA1_Channel7_IRQHandler 179 | .word ADC1_IRQHandler 180 | .word 0 181 | .word 0 182 | .word 0 183 | .word 0 184 | .word EXTI9_5_IRQHandler 185 | .word 0 186 | .word 0 187 | .word 0 188 | .word 0 189 | .word TIM2_IRQHandler 190 | .word TIM3_IRQHandler 191 | .word TIM4_IRQHandler 192 | .word I2C1_EV_IRQHandler 193 | .word I2C1_ER_IRQHandler 194 | .word I2C2_EV_IRQHandler 195 | .word I2C2_ER_IRQHandler 196 | .word SPI1_IRQHandler 197 | .word SPI2_IRQHandler 198 | .word USART1_IRQHandler 199 | .word USART2_IRQHandler 200 | .word USART3_IRQHandler 201 | .word EXTI15_10_IRQHandler 202 | .word RTC_Alarm_IRQHandler 203 | .word 0 204 | .word 0 205 | .word 0 206 | .word 0 207 | .word 0 208 | .word 0 209 | .word 0 210 | .word 0 211 | .word BootRAM /* @0x108. This is for boot in RAM mode for 212 | STM32F10x Medium Density devices. */ 213 | 214 | /******************************************************************************* 215 | * 216 | * Provide weak aliases for each Exception handler to the Default_Handler. 217 | * As they are weak aliases, any function with the same name will override 218 | * this definition. 219 | * 220 | *******************************************************************************/ 221 | 222 | .weak NMI_Handler 223 | .thumb_set NMI_Handler,Default_Handler 224 | 225 | .weak HardFault_Handler 226 | .thumb_set HardFault_Handler,Default_Handler 227 | 228 | .weak MemManage_Handler 229 | .thumb_set MemManage_Handler,Default_Handler 230 | 231 | .weak BusFault_Handler 232 | .thumb_set BusFault_Handler,Default_Handler 233 | 234 | .weak UsageFault_Handler 235 | .thumb_set UsageFault_Handler,Default_Handler 236 | 237 | .weak SVC_Handler 238 | .thumb_set SVC_Handler,Default_Handler 239 | 240 | .weak DebugMon_Handler 241 | .thumb_set DebugMon_Handler,Default_Handler 242 | 243 | .weak PendSV_Handler 244 | .thumb_set PendSV_Handler,Default_Handler 245 | 246 | .weak SysTick_Handler 247 | .thumb_set SysTick_Handler,Default_Handler 248 | 249 | .weak WWDG_IRQHandler 250 | .thumb_set WWDG_IRQHandler,Default_Handler 251 | 252 | .weak PVD_IRQHandler 253 | .thumb_set PVD_IRQHandler,Default_Handler 254 | 255 | .weak TAMPER_IRQHandler 256 | .thumb_set TAMPER_IRQHandler,Default_Handler 257 | 258 | .weak RTC_IRQHandler 259 | .thumb_set RTC_IRQHandler,Default_Handler 260 | 261 | .weak FLASH_IRQHandler 262 | .thumb_set FLASH_IRQHandler,Default_Handler 263 | 264 | .weak RCC_IRQHandler 265 | .thumb_set RCC_IRQHandler,Default_Handler 266 | 267 | .weak EXTI0_IRQHandler 268 | .thumb_set EXTI0_IRQHandler,Default_Handler 269 | 270 | .weak EXTI1_IRQHandler 271 | .thumb_set EXTI1_IRQHandler,Default_Handler 272 | 273 | .weak EXTI2_IRQHandler 274 | .thumb_set EXTI2_IRQHandler,Default_Handler 275 | 276 | .weak EXTI3_IRQHandler 277 | .thumb_set EXTI3_IRQHandler,Default_Handler 278 | 279 | .weak EXTI4_IRQHandler 280 | .thumb_set EXTI4_IRQHandler,Default_Handler 281 | 282 | .weak DMA1_Channel1_IRQHandler 283 | .thumb_set DMA1_Channel1_IRQHandler,Default_Handler 284 | 285 | .weak DMA1_Channel2_IRQHandler 286 | .thumb_set DMA1_Channel2_IRQHandler,Default_Handler 287 | 288 | .weak DMA1_Channel3_IRQHandler 289 | .thumb_set DMA1_Channel3_IRQHandler,Default_Handler 290 | 291 | .weak DMA1_Channel4_IRQHandler 292 | .thumb_set DMA1_Channel4_IRQHandler,Default_Handler 293 | 294 | .weak DMA1_Channel5_IRQHandler 295 | .thumb_set DMA1_Channel5_IRQHandler,Default_Handler 296 | 297 | .weak DMA1_Channel6_IRQHandler 298 | .thumb_set DMA1_Channel6_IRQHandler,Default_Handler 299 | 300 | .weak DMA1_Channel7_IRQHandler 301 | .thumb_set DMA1_Channel7_IRQHandler,Default_Handler 302 | 303 | .weak ADC1_IRQHandler 304 | .thumb_set ADC1_IRQHandler,Default_Handler 305 | 306 | .weak EXTI9_5_IRQHandler 307 | .thumb_set EXTI9_5_IRQHandler,Default_Handler 308 | 309 | .weak TIM2_IRQHandler 310 | .thumb_set TIM2_IRQHandler,Default_Handler 311 | 312 | .weak TIM3_IRQHandler 313 | .thumb_set TIM3_IRQHandler,Default_Handler 314 | 315 | .weak TIM4_IRQHandler 316 | .thumb_set TIM4_IRQHandler,Default_Handler 317 | 318 | .weak I2C1_EV_IRQHandler 319 | .thumb_set I2C1_EV_IRQHandler,Default_Handler 320 | 321 | .weak I2C1_ER_IRQHandler 322 | .thumb_set I2C1_ER_IRQHandler,Default_Handler 323 | 324 | .weak I2C2_EV_IRQHandler 325 | .thumb_set I2C2_EV_IRQHandler,Default_Handler 326 | 327 | .weak I2C2_ER_IRQHandler 328 | .thumb_set I2C2_ER_IRQHandler,Default_Handler 329 | 330 | .weak SPI1_IRQHandler 331 | .thumb_set SPI1_IRQHandler,Default_Handler 332 | 333 | .weak SPI2_IRQHandler 334 | .thumb_set SPI2_IRQHandler,Default_Handler 335 | 336 | .weak USART1_IRQHandler 337 | .thumb_set USART1_IRQHandler,Default_Handler 338 | 339 | .weak USART2_IRQHandler 340 | .thumb_set USART2_IRQHandler,Default_Handler 341 | 342 | .weak USART3_IRQHandler 343 | .thumb_set USART3_IRQHandler,Default_Handler 344 | 345 | .weak EXTI15_10_IRQHandler 346 | .thumb_set EXTI15_10_IRQHandler,Default_Handler 347 | 348 | .weak RTC_Alarm_IRQHandler 349 | .thumb_set RTC_Alarm_IRQHandler,Default_Handler 350 | 351 | 352 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 353 | 354 | -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f102x6.s: -------------------------------------------------------------------------------- 1 | /** 2 | *************** (C) COPYRIGHT 2014 STMicroelectronics ************************ 3 | * @file startup_stm32f102x6.s 4 | * @author MCD Application Team 5 | * @version V4.0.0 6 | * @date 16-December-2014 7 | * @brief STM32F102x6 Devices vector table for Atollic 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 | * 19 | *

© COPYRIGHT(c) 2014 STMicroelectronics

20 | * 21 | * Redistribution and use in source and binary forms, with or without modification, 22 | * are permitted provided that the following conditions are met: 23 | * 1. Redistributions of source code must retain the above copyright notice, 24 | * this list of conditions and the following disclaimer. 25 | * 2. Redistributions in binary form must reproduce the above copyright notice, 26 | * this list of conditions and the following disclaimer in the documentation 27 | * and/or other materials provided with the distribution. 28 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 29 | * may be used to endorse or promote products derived from this software 30 | * without specific prior written permission. 31 | * 32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 33 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 34 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 35 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 36 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 37 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 38 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 39 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 40 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 41 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 42 | * 43 | ****************************************************************************** 44 | */ 45 | 46 | .syntax unified 47 | .cpu cortex-m3 48 | .fpu softvfp 49 | .thumb 50 | 51 | .global g_pfnVectors 52 | .global Default_Handler 53 | 54 | /* start address for the initialization values of the .data section. 55 | defined in linker script */ 56 | .word _sidata 57 | /* start address for the .data section. defined in linker script */ 58 | .word _sdata 59 | /* end address for the .data section. defined in linker script */ 60 | .word _edata 61 | /* start address for the .bss section. defined in linker script */ 62 | .word _sbss 63 | /* end address for the .bss section. defined in linker script */ 64 | .word _ebss 65 | 66 | .equ BootRAM, 0xF108F85F 67 | /** 68 | * @brief This is the code that gets called when the processor first 69 | * starts execution following a reset event. Only the absolutely 70 | * necessary set is performed, after which the application 71 | * supplied main() routine is called. 72 | * @param None 73 | * @retval : None 74 | */ 75 | 76 | .section .text.Reset_Handler 77 | .weak Reset_Handler 78 | .type Reset_Handler, %function 79 | Reset_Handler: 80 | 81 | /* Copy the data segment initializers from flash to SRAM */ 82 | movs r1, #0 83 | b LoopCopyDataInit 84 | 85 | CopyDataInit: 86 | ldr r3, =_sidata 87 | ldr r3, [r3, r1] 88 | str r3, [r0, r1] 89 | adds r1, r1, #4 90 | 91 | LoopCopyDataInit: 92 | ldr r0, =_sdata 93 | ldr r3, =_edata 94 | adds r2, r0, r1 95 | cmp r2, r3 96 | bcc CopyDataInit 97 | ldr r2, =_sbss 98 | b LoopFillZerobss 99 | /* Zero fill the bss segment. */ 100 | FillZerobss: 101 | movs r3, #0 102 | str r3, [r2], #4 103 | 104 | LoopFillZerobss: 105 | ldr r3, = _ebss 106 | cmp r2, r3 107 | bcc FillZerobss 108 | 109 | /* Call the clock system intitialization function.*/ 110 | bl SystemInit 111 | /* Call static constructors */ 112 | bl __libc_init_array 113 | /* Call the application's entry point.*/ 114 | bl main 115 | bx lr 116 | .size Reset_Handler, .-Reset_Handler 117 | 118 | /** 119 | * @brief This is the code that gets called when the processor receives an 120 | * unexpected interrupt. This simply enters an infinite loop, preserving 121 | * the system state for examination by a debugger. 122 | * 123 | * @param None 124 | * @retval : None 125 | */ 126 | .section .text.Default_Handler,"ax",%progbits 127 | Default_Handler: 128 | Infinite_Loop: 129 | b Infinite_Loop 130 | .size Default_Handler, .-Default_Handler 131 | /****************************************************************************** 132 | * 133 | * The minimal vector table for a Cortex M3. Note that the proper constructs 134 | * must be placed on this to ensure that it ends up at physical address 135 | * 0x0000.0000. 136 | * 137 | ******************************************************************************/ 138 | .section .isr_vector,"a",%progbits 139 | .type g_pfnVectors, %object 140 | .size g_pfnVectors, .-g_pfnVectors 141 | 142 | 143 | g_pfnVectors: 144 | 145 | .word _estack 146 | .word Reset_Handler 147 | .word NMI_Handler 148 | .word HardFault_Handler 149 | .word MemManage_Handler 150 | .word BusFault_Handler 151 | .word UsageFault_Handler 152 | .word 0 153 | .word 0 154 | .word 0 155 | .word 0 156 | .word SVC_Handler 157 | .word DebugMon_Handler 158 | .word 0 159 | .word PendSV_Handler 160 | .word SysTick_Handler 161 | .word WWDG_IRQHandler 162 | .word PVD_IRQHandler 163 | .word TAMPER_IRQHandler 164 | .word RTC_IRQHandler 165 | .word FLASH_IRQHandler 166 | .word RCC_IRQHandler 167 | .word EXTI0_IRQHandler 168 | .word EXTI1_IRQHandler 169 | .word EXTI2_IRQHandler 170 | .word EXTI3_IRQHandler 171 | .word EXTI4_IRQHandler 172 | .word DMA1_Channel1_IRQHandler 173 | .word DMA1_Channel2_IRQHandler 174 | .word DMA1_Channel3_IRQHandler 175 | .word DMA1_Channel4_IRQHandler 176 | .word DMA1_Channel5_IRQHandler 177 | .word DMA1_Channel6_IRQHandler 178 | .word DMA1_Channel7_IRQHandler 179 | .word ADC1_IRQHandler 180 | .word USB_HP_IRQHandler 181 | .word USB_LP_IRQHandler 182 | .word 0 183 | .word 0 184 | .word EXTI9_5_IRQHandler 185 | .word 0 186 | .word 0 187 | .word 0 188 | .word 0 189 | .word TIM2_IRQHandler 190 | .word TIM3_IRQHandler 191 | .word 0 192 | .word I2C1_EV_IRQHandler 193 | .word I2C1_ER_IRQHandler 194 | .word 0 195 | .word 0 196 | .word SPI1_IRQHandler 197 | .word 0 198 | .word USART1_IRQHandler 199 | .word USART2_IRQHandler 200 | .word 0 201 | .word EXTI15_10_IRQHandler 202 | .word RTC_Alarm_IRQHandler 203 | .word USBWakeUp_IRQHandler 204 | .word 0 205 | .word 0 206 | .word 0 207 | .word 0 208 | .word 0 209 | .word 0 210 | .word 0 211 | .word BootRAM /* @0x108. This is for boot in RAM mode for 212 | STM32F10x Low Density devices.*/ 213 | 214 | /******************************************************************************* 215 | * 216 | * Provide weak aliases for each Exception handler to the Default_Handler. 217 | * As they are weak aliases, any function with the same name will override 218 | * this definition. 219 | * 220 | *******************************************************************************/ 221 | 222 | .weak NMI_Handler 223 | .thumb_set NMI_Handler,Default_Handler 224 | 225 | .weak HardFault_Handler 226 | .thumb_set HardFault_Handler,Default_Handler 227 | 228 | .weak MemManage_Handler 229 | .thumb_set MemManage_Handler,Default_Handler 230 | 231 | .weak BusFault_Handler 232 | .thumb_set BusFault_Handler,Default_Handler 233 | 234 | .weak UsageFault_Handler 235 | .thumb_set UsageFault_Handler,Default_Handler 236 | 237 | .weak SVC_Handler 238 | .thumb_set SVC_Handler,Default_Handler 239 | 240 | .weak DebugMon_Handler 241 | .thumb_set DebugMon_Handler,Default_Handler 242 | 243 | .weak PendSV_Handler 244 | .thumb_set PendSV_Handler,Default_Handler 245 | 246 | .weak SysTick_Handler 247 | .thumb_set SysTick_Handler,Default_Handler 248 | 249 | .weak WWDG_IRQHandler 250 | .thumb_set WWDG_IRQHandler,Default_Handler 251 | 252 | .weak PVD_IRQHandler 253 | .thumb_set PVD_IRQHandler,Default_Handler 254 | 255 | .weak TAMPER_IRQHandler 256 | .thumb_set TAMPER_IRQHandler,Default_Handler 257 | 258 | .weak RTC_IRQHandler 259 | .thumb_set RTC_IRQHandler,Default_Handler 260 | 261 | .weak FLASH_IRQHandler 262 | .thumb_set FLASH_IRQHandler,Default_Handler 263 | 264 | .weak RCC_IRQHandler 265 | .thumb_set RCC_IRQHandler,Default_Handler 266 | 267 | .weak EXTI0_IRQHandler 268 | .thumb_set EXTI0_IRQHandler,Default_Handler 269 | 270 | .weak EXTI1_IRQHandler 271 | .thumb_set EXTI1_IRQHandler,Default_Handler 272 | 273 | .weak EXTI2_IRQHandler 274 | .thumb_set EXTI2_IRQHandler,Default_Handler 275 | 276 | .weak EXTI3_IRQHandler 277 | .thumb_set EXTI3_IRQHandler,Default_Handler 278 | 279 | .weak EXTI4_IRQHandler 280 | .thumb_set EXTI4_IRQHandler,Default_Handler 281 | 282 | .weak DMA1_Channel1_IRQHandler 283 | .thumb_set DMA1_Channel1_IRQHandler,Default_Handler 284 | 285 | .weak DMA1_Channel2_IRQHandler 286 | .thumb_set DMA1_Channel2_IRQHandler,Default_Handler 287 | 288 | .weak DMA1_Channel3_IRQHandler 289 | .thumb_set DMA1_Channel3_IRQHandler,Default_Handler 290 | 291 | .weak DMA1_Channel4_IRQHandler 292 | .thumb_set DMA1_Channel4_IRQHandler,Default_Handler 293 | 294 | .weak DMA1_Channel5_IRQHandler 295 | .thumb_set DMA1_Channel5_IRQHandler,Default_Handler 296 | 297 | .weak DMA1_Channel6_IRQHandler 298 | .thumb_set DMA1_Channel6_IRQHandler,Default_Handler 299 | 300 | .weak DMA1_Channel7_IRQHandler 301 | .thumb_set DMA1_Channel7_IRQHandler,Default_Handler 302 | 303 | .weak ADC1_IRQHandler 304 | .thumb_set ADC1_IRQHandler,Default_Handler 305 | 306 | .weak USB_HP_IRQHandler 307 | .thumb_set USB_HP_IRQHandler,Default_Handler 308 | 309 | .weak USB_LP_IRQHandler 310 | .thumb_set USB_LP_IRQHandler,Default_Handler 311 | 312 | .weak EXTI9_5_IRQHandler 313 | .thumb_set EXTI9_5_IRQHandler,Default_Handler 314 | 315 | .weak TIM2_IRQHandler 316 | .thumb_set TIM2_IRQHandler,Default_Handler 317 | 318 | .weak TIM3_IRQHandler 319 | .thumb_set TIM3_IRQHandler,Default_Handler 320 | 321 | .weak I2C1_EV_IRQHandler 322 | .thumb_set I2C1_EV_IRQHandler,Default_Handler 323 | 324 | .weak I2C1_ER_IRQHandler 325 | .thumb_set I2C1_ER_IRQHandler,Default_Handler 326 | 327 | .weak SPI1_IRQHandler 328 | .thumb_set SPI1_IRQHandler,Default_Handler 329 | 330 | .weak USART1_IRQHandler 331 | .thumb_set USART1_IRQHandler,Default_Handler 332 | 333 | .weak USART2_IRQHandler 334 | .thumb_set USART2_IRQHandler,Default_Handler 335 | 336 | .weak EXTI15_10_IRQHandler 337 | .thumb_set EXTI15_10_IRQHandler,Default_Handler 338 | 339 | .weak RTC_Alarm_IRQHandler 340 | .thumb_set RTC_Alarm_IRQHandler,Default_Handler 341 | 342 | .weak USBWakeUp_IRQHandler 343 | .thumb_set USBWakeUp_IRQHandler,Default_Handler 344 | 345 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 346 | -------------------------------------------------------------------------------- /Drivers/CMSIS/Include/arm_common_tables.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010-2014 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 31. July 2014 5 | * $Revision: V1.4.4 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: 31. July 2014 5 | * $Revision: V1.4.4 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_cortex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f1xx_hal_cortex.h 4 | * @author MCD Application Team 5 | * @version V1.0.0 6 | * @date 15-December-2014 7 | * @brief Header file of CORTEX HAL module. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT(c) 2014 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_CORTEX_H 40 | #define __STM32F1xx_HAL_CORTEX_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 CORTEX 54 | * @{ 55 | */ 56 | /* Exported types ------------------------------------------------------------*/ 57 | /* Exported constants --------------------------------------------------------*/ 58 | 59 | /** @defgroup CORTEX_Exported_Constants CORTEX Exported Constants 60 | * @{ 61 | */ 62 | 63 | 64 | /** @defgroup CORTEX_Preemption_Priority_Group CORTEX Preemption Priority Group 65 | * @{ 66 | */ 67 | 68 | #define NVIC_PRIORITYGROUP_0 ((uint32_t)0x00000007) /*!< 0 bits for pre-emption priority 69 | 4 bits for subpriority */ 70 | #define NVIC_PRIORITYGROUP_1 ((uint32_t)0x00000006) /*!< 1 bits for pre-emption priority 71 | 3 bits for subpriority */ 72 | #define NVIC_PRIORITYGROUP_2 ((uint32_t)0x00000005) /*!< 2 bits for pre-emption priority 73 | 2 bits for subpriority */ 74 | #define NVIC_PRIORITYGROUP_3 ((uint32_t)0x00000004) /*!< 3 bits for pre-emption priority 75 | 1 bits for subpriority */ 76 | #define NVIC_PRIORITYGROUP_4 ((uint32_t)0x00000003) /*!< 4 bits for pre-emption priority 77 | 0 bits for subpriority */ 78 | /** 79 | * @} 80 | */ 81 | 82 | /** @defgroup CORTEX_SysTick_clock_source CORTEX SysTick clock source 83 | * @{ 84 | */ 85 | #define SYSTICK_CLKSOURCE_HCLK_DIV8 ((uint32_t)0x00000000) 86 | #define SYSTICK_CLKSOURCE_HCLK ((uint32_t)0x00000004) 87 | 88 | /** 89 | * @} 90 | */ 91 | 92 | /** 93 | * @} 94 | */ 95 | 96 | /* Exported Macros -----------------------------------------------------------*/ 97 | /** @defgroup CORTEX_Exported_Macros CORTEX Exported Macros 98 | * @{ 99 | */ 100 | 101 | /** @defgroup CORTEX_SysTick_clock_source_Macro_Exported CORTEX SysTick clock source 102 | * @{ 103 | */ 104 | 105 | /** @brief Configures the SysTick clock source. 106 | * @param __CLKSRC__: specifies the SysTick clock source. 107 | * This parameter can be one of the following values: 108 | * @arg SYSTICK_CLKSOURCE_HCLK_DIV8: AHB clock divided by 8 selected as SysTick clock source. 109 | * @arg SYSTICK_CLKSOURCE_HCLK: AHB clock selected as SysTick clock source. 110 | * @retval None 111 | */ 112 | #define __HAL_CORTEX_SYSTICKCLK_CONFIG(__CLKSRC__) \ 113 | do { \ 114 | if ((__CLKSRC__) == SYSTICK_CLKSOURCE_HCLK) \ 115 | { \ 116 | SET_BIT(SysTick->CTRL, SYSTICK_CLKSOURCE_HCLK); \ 117 | } \ 118 | else \ 119 | CLEAR_BIT(SysTick->CTRL, SYSTICK_CLKSOURCE_HCLK); \ 120 | } while(0) 121 | /** 122 | * @} 123 | */ 124 | 125 | /** 126 | * @} 127 | */ 128 | 129 | /* Private macro -------------------------------------------------------------*/ 130 | /** @defgroup CORTEX_Private_Macros CORTEX Private Macros 131 | * @{ 132 | */ 133 | 134 | /** @defgroup CORTEX_Preemption_Priority_Group_Macro CORTEX Preemption Priority Group 135 | * @{ 136 | */ 137 | #define IS_NVIC_PRIORITY_GROUP(GROUP) (((GROUP) == NVIC_PRIORITYGROUP_0) || \ 138 | ((GROUP) == NVIC_PRIORITYGROUP_1) || \ 139 | ((GROUP) == NVIC_PRIORITYGROUP_2) || \ 140 | ((GROUP) == NVIC_PRIORITYGROUP_3) || \ 141 | ((GROUP) == NVIC_PRIORITYGROUP_4)) 142 | 143 | #define IS_NVIC_PREEMPTION_PRIORITY(PRIORITY) ((PRIORITY) < 0x10) 144 | 145 | #define IS_NVIC_SUB_PRIORITY(PRIORITY) ((PRIORITY) < 0x10) 146 | 147 | #define IS_NVIC_DEVICE_IRQ(IRQ) ((IRQ) >= 0x00) 148 | 149 | /** 150 | * @} 151 | */ 152 | 153 | /** @defgroup CORTEX_SysTick_clock_source_Macro_Private CORTEX SysTick clock source 154 | * @{ 155 | */ 156 | #define IS_SYSTICK_CLK_SOURCE(SOURCE) (((SOURCE) == SYSTICK_CLKSOURCE_HCLK) || \ 157 | ((SOURCE) == SYSTICK_CLKSOURCE_HCLK_DIV8)) 158 | /** 159 | * @} 160 | */ 161 | 162 | /** 163 | * @} 164 | */ 165 | 166 | /* Exported functions --------------------------------------------------------*/ 167 | 168 | /** @addtogroup CORTEX_Exported_Functions 169 | * @{ 170 | */ 171 | 172 | /** @addtogroup CORTEX_Exported_Functions_Group1 173 | * @{ 174 | */ 175 | /* Initialization and de-initialization functions *****************************/ 176 | void HAL_NVIC_SetPriorityGrouping(uint32_t PriorityGroup); 177 | void HAL_NVIC_SetPriority(IRQn_Type IRQn, uint32_t PreemptPriority, uint32_t SubPriority); 178 | void HAL_NVIC_EnableIRQ(IRQn_Type IRQn); 179 | void HAL_NVIC_DisableIRQ(IRQn_Type IRQn); 180 | void HAL_NVIC_SystemReset(void); 181 | uint32_t HAL_SYSTICK_Config(uint32_t TicksNumb); 182 | /** 183 | * @} 184 | */ 185 | 186 | /** @addtogroup CORTEX_Exported_Functions_Group2 187 | * @{ 188 | */ 189 | /* Peripheral Control functions ***********************************************/ 190 | uint32_t HAL_NVIC_GetPriorityGrouping(void); 191 | void HAL_NVIC_GetPriority(IRQn_Type IRQn, uint32_t PriorityGroup, uint32_t* pPreemptPriority, uint32_t* pSubPriority); 192 | uint32_t HAL_NVIC_GetPendingIRQ(IRQn_Type IRQn); 193 | void HAL_NVIC_SetPendingIRQ(IRQn_Type IRQn); 194 | void HAL_NVIC_ClearPendingIRQ(IRQn_Type IRQn); 195 | uint32_t HAL_NVIC_GetActive(IRQn_Type IRQn); 196 | void HAL_SYSTICK_CLKSourceConfig(uint32_t CLKSource); 197 | void HAL_SYSTICK_IRQHandler(void); 198 | void HAL_SYSTICK_Callback(void); 199 | /** 200 | * @} 201 | */ 202 | 203 | /** 204 | * @} 205 | */ 206 | 207 | /** 208 | * @} 209 | */ 210 | 211 | /** 212 | * @} 213 | */ 214 | 215 | #ifdef __cplusplus 216 | } 217 | #endif 218 | 219 | #endif /* __STM32F1xx_HAL_CORTEX_H */ 220 | 221 | 222 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 223 | -------------------------------------------------------------------------------- /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.0 6 | * @date 15-December-2014 7 | * @brief This file contains HAL common defines, enumeration, macros and 8 | * structures definitions. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT(c) 2014 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 | 51 | /* Exported types ------------------------------------------------------------*/ 52 | 53 | /** 54 | * @brief HAL Status structures definition 55 | */ 56 | typedef enum 57 | { 58 | HAL_OK = 0x00, 59 | HAL_ERROR = 0x01, 60 | HAL_BUSY = 0x02, 61 | HAL_TIMEOUT = 0x03 62 | } HAL_StatusTypeDef; 63 | 64 | /** 65 | * @brief HAL Lock structures definition 66 | */ 67 | typedef enum 68 | { 69 | HAL_UNLOCKED = 0x00, 70 | HAL_LOCKED = 0x01 71 | } HAL_LockTypeDef; 72 | 73 | /* Exported macro ------------------------------------------------------------*/ 74 | #ifndef NULL 75 | #define NULL 0 76 | #endif 77 | 78 | #define HAL_MAX_DELAY 0xFFFFFFFF 79 | 80 | #define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) != RESET) 81 | #define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == RESET) 82 | 83 | #define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD_, __DMA_HANDLE_) \ 84 | do{ \ 85 | (__HANDLE__)->__PPP_DMA_FIELD_ = &(__DMA_HANDLE_); \ 86 | (__DMA_HANDLE_).Parent = (__HANDLE__); \ 87 | } while(0) 88 | 89 | #define UNUSED(x) ((void)(x)) 90 | 91 | /** @brief Reset the Handle's State field. 92 | * @param __HANDLE__: specifies the Peripheral Handle. 93 | * @note This macro can be used for the following purpose: 94 | * - When the Handle is declared as local variable; before passing it as parameter 95 | * to HAL_PPP_Init() for the first time, it is mandatory to use this macro 96 | * to set to 0 the Handle's "State" field. 97 | * Otherwise, "State" field may have any random value and the first time the function 98 | * HAL_PPP_Init() is called, the low level hardware initialization will be missed 99 | * (i.e. HAL_PPP_MspInit() will not be executed). 100 | * - When there is a need to reconfigure the low level hardware: instead of calling 101 | * HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init(). 102 | * In this later function, when the Handle's "State" field is set to 0, it will execute the function 103 | * HAL_PPP_MspInit() which will reconfigure the low level hardware. 104 | * @retval None 105 | */ 106 | #define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0) 107 | 108 | #if (USE_RTOS == 1) 109 | #error " USE_RTOS should be 0 in the current HAL release " 110 | #else 111 | #define __HAL_LOCK(__HANDLE__) \ 112 | do{ \ 113 | if((__HANDLE__)->Lock == HAL_LOCKED) \ 114 | { \ 115 | return HAL_BUSY; \ 116 | } \ 117 | else \ 118 | { \ 119 | (__HANDLE__)->Lock = HAL_LOCKED; \ 120 | } \ 121 | }while (0) 122 | 123 | #define __HAL_UNLOCK(__HANDLE__) \ 124 | do{ \ 125 | (__HANDLE__)->Lock = HAL_UNLOCKED; \ 126 | }while (0) 127 | #endif /* USE_RTOS */ 128 | 129 | #if defined ( __GNUC__ ) 130 | #ifndef __weak 131 | #define __weak __attribute__((weak)) 132 | #endif /* __weak */ 133 | #ifndef __packed 134 | #define __packed __attribute__((__packed__)) 135 | #endif /* __packed */ 136 | #endif /* __GNUC__ */ 137 | 138 | 139 | /* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */ 140 | #if defined (__GNUC__) /* GNU Compiler */ 141 | #ifndef __ALIGN_END 142 | #define __ALIGN_END __attribute__ ((aligned (4))) 143 | #endif /* __ALIGN_END */ 144 | #ifndef __ALIGN_BEGIN 145 | #define __ALIGN_BEGIN 146 | #endif /* __ALIGN_BEGIN */ 147 | #else 148 | #ifndef __ALIGN_END 149 | #define __ALIGN_END 150 | #endif /* __ALIGN_END */ 151 | #ifndef __ALIGN_BEGIN 152 | #if defined (__CC_ARM) /* ARM Compiler */ 153 | #define __ALIGN_BEGIN __align(4) 154 | #elif defined (__ICCARM__) /* IAR Compiler */ 155 | #define __ALIGN_BEGIN 156 | #endif /* __CC_ARM */ 157 | #endif /* __ALIGN_BEGIN */ 158 | #endif /* __GNUC__ */ 159 | 160 | /** 161 | * @brief __RAM_FUNC definition 162 | */ 163 | #if defined ( __CC_ARM ) 164 | /* ARM Compiler 165 | ------------ 166 | RAM functions are defined using the toolchain options. 167 | Functions that are executed in RAM should reside in a separate source module. 168 | Using the 'Options for File' dialog you can simply change the 'Code / Const' 169 | area of a module to a memory space in physical RAM. 170 | Available memory areas are declared in the 'Target' tab of the 'Options for Target' 171 | dialog. 172 | */ 173 | #define __RAM_FUNC HAL_StatusTypeDef 174 | 175 | #elif defined ( __ICCARM__ ) 176 | /* ICCARM Compiler 177 | --------------- 178 | RAM functions are defined using a specific toolchain keyword "__ramfunc". 179 | */ 180 | #define __RAM_FUNC __ramfunc HAL_StatusTypeDef 181 | 182 | #elif defined ( __GNUC__ ) 183 | /* GNU Compiler 184 | ------------ 185 | RAM functions are defined using a specific toolchain attribute 186 | "__attribute__((section(".RamFunc")))". 187 | */ 188 | #define __RAM_FUNC HAL_StatusTypeDef __attribute__((section(".RamFunc"))) 189 | 190 | #endif 191 | 192 | /** 193 | * @brief __NOINLINE definition 194 | */ 195 | #if defined ( __CC_ARM ) || defined ( __GNUC__ ) 196 | /* ARM & GNUCompiler 197 | ---------------- 198 | */ 199 | #define __NOINLINE __attribute__ ( (noinline) ) 200 | 201 | #elif defined ( __ICCARM__ ) 202 | /* ICCARM Compiler 203 | --------------- 204 | */ 205 | #define __NOINLINE _Pragma("optimize = no_inline") 206 | 207 | #endif 208 | 209 | 210 | #ifdef __cplusplus 211 | } 212 | #endif 213 | 214 | #endif /* ___STM32F1xx_HAL_DEF */ 215 | 216 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 217 | -------------------------------------------------------------------------------- /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.0 6 | * @date 15-December-2014 7 | * @brief Header file of Flash HAL module. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT(c) 2014 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 | /** 74 | * @} 75 | */ 76 | 77 | /* Exported types ------------------------------------------------------------*/ 78 | /** @defgroup FLASH_Exported_Types FLASH Exported Types 79 | * @{ 80 | */ 81 | 82 | 83 | /** 84 | * @brief FLASH Procedure structure definition 85 | */ 86 | typedef enum 87 | { 88 | FLASH_PROC_NONE = 0, 89 | FLASH_PROC_PAGEERASE = 1, 90 | FLASH_PROC_MASSERASE = 2, 91 | FLASH_PROC_PROGRAMHALFWORD = 3, 92 | FLASH_PROC_PROGRAMWORD = 4, 93 | FLASH_PROC_PROGRAMDOUBLEWORD = 5 94 | } FLASH_ProcedureTypeDef; 95 | 96 | /** 97 | * @brief FLASH handle Structure definition 98 | */ 99 | typedef struct 100 | { 101 | __IO FLASH_ProcedureTypeDef ProcedureOnGoing; /* Internal variable to indicate which procedure is ongoing or not in IT context */ 102 | 103 | __IO uint32_t DataRemaining; /* Internal variable to save the remaining pages to erase or half-word to program in IT context */ 104 | 105 | __IO uint32_t Address; /* Internal variable to save address selected for program or erase */ 106 | 107 | __IO uint64_t Data; /* Internal variable to save data to be programmed */ 108 | 109 | HAL_LockTypeDef Lock; /* FLASH locking object */ 110 | 111 | __IO uint32_t ErrorCode; /* FLASH error code */ 112 | 113 | } FLASH_ProcessTypeDef; 114 | 115 | /** 116 | * @} 117 | */ 118 | 119 | /* Exported constants --------------------------------------------------------*/ 120 | /** @defgroup FLASH_Exported_Constants FLASH Exported Constants 121 | * @{ 122 | */ 123 | 124 | /** @defgroup FLASH_Error_Codes FLASH Error Codes 125 | * @{ 126 | */ 127 | 128 | #define HAL_FLASH_ERROR_NONE ((uint32_t)0x00) 129 | #define HAL_FLASH_ERROR_PROG ((uint32_t)0x01) 130 | #define HAL_FLASH_ERROR_WRP ((uint32_t)0x02) 131 | #define HAL_FLASH_ERROR_OPTV ((uint32_t)0x04) 132 | 133 | /** 134 | * @} 135 | */ 136 | 137 | 138 | /** @defgroup FLASH_Type_Program Type Program 139 | * @{ 140 | */ 141 | #define FLASH_TYPEPROGRAM_HALFWORD ((uint32_t)0x01) /*!ACR |= FLASH_ACR_HLFCYA) 167 | 168 | /** 169 | * @brief Disable the FLASH half cycle access. 170 | * @note halfcycle access can only be used with a low-frequency clock of less than 171 | 8 MHz that can be obtained with the use of HSI or HSE but not of PLL. 172 | * @retval None 173 | */ 174 | #define __HAL_FLASH_HALF_CYCLE_ACCESS_DISABLE() (FLASH->ACR &= (~FLASH_ACR_HLFCYA)) 175 | 176 | /** 177 | * @} 178 | */ 179 | 180 | /* Include FLASH HAL Extended module */ 181 | #include "stm32f1xx_hal_flash_ex.h" 182 | 183 | /* Exported functions --------------------------------------------------------*/ 184 | /** @addtogroup FLASH_Exported_Functions 185 | * @{ 186 | */ 187 | 188 | /** @addtogroup FLASH_Exported_Functions_Group1 189 | * @{ 190 | */ 191 | /* IO operation functions *****************************************************/ 192 | HAL_StatusTypeDef HAL_FLASH_Program(uint32_t TypeProgram, uint32_t Address, uint64_t Data); 193 | HAL_StatusTypeDef HAL_FLASH_Program_IT(uint32_t TypeProgram, uint32_t Address, uint64_t Data); 194 | 195 | /* FLASH IRQ handler method */ 196 | void HAL_FLASH_IRQHandler(void); 197 | /* Callbacks in non blocking modes */ 198 | void HAL_FLASH_EndOfOperationCallback(uint32_t ReturnValue); 199 | void HAL_FLASH_OperationErrorCallback(uint32_t ReturnValue); 200 | 201 | /** 202 | * @} 203 | */ 204 | 205 | /** @addtogroup FLASH_Exported_Functions_Group2 206 | * @{ 207 | */ 208 | /* Peripheral Control functions ***********************************************/ 209 | HAL_StatusTypeDef HAL_FLASH_Unlock(void); 210 | HAL_StatusTypeDef HAL_FLASH_Lock(void); 211 | HAL_StatusTypeDef HAL_FLASH_OB_Unlock(void); 212 | HAL_StatusTypeDef HAL_FLASH_OB_Lock(void); 213 | HAL_StatusTypeDef HAL_FLASH_OB_Launch(void); 214 | 215 | /** 216 | * @} 217 | */ 218 | 219 | /** @addtogroup FLASH_Exported_Functions_Group3 220 | * @{ 221 | */ 222 | /* Peripheral State and Error functions ***************************************/ 223 | uint32_t HAL_FLASH_GetError(void); 224 | 225 | /** 226 | * @} 227 | */ 228 | 229 | /** 230 | * @} 231 | */ 232 | 233 | /* Private function -------------------------------------------------*/ 234 | /** @addtogroup FLASH_Private_Functions 235 | * @{ 236 | */ 237 | void FLASH_PageErase(uint32_t PageAddress); 238 | HAL_StatusTypeDef FLASH_WaitForLastOperation(uint32_t Timeout); 239 | void FLASH_SetErrorCode(void); 240 | void FLASH_Program_HalfWord(uint32_t Address, uint16_t Data); 241 | 242 | /** 243 | * @} 244 | */ 245 | 246 | /** 247 | * @} 248 | */ 249 | 250 | /** 251 | * @} 252 | */ 253 | 254 | #ifdef __cplusplus 255 | } 256 | #endif 257 | 258 | #endif /* __STM32F1xx_HAL_FLASH_H */ 259 | 260 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 261 | 262 | -------------------------------------------------------------------------------- /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.0 6 | * @date 15-December-2014 7 | * @brief Header file of Extended PCD HAL module. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT(c) 2014 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.0 6 | * @date 15-December-2014 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) 2014 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.0 6 | * @date 15-December-2014 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) 2014 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 | -------------------------------------------------------------------------------- /Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi_ex.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f1xx_hal_spi_ex.c 4 | * @author MCD Application Team 5 | * @version V1.0.0 6 | * @date 15-December-2014 7 | * @brief Extended SPI HAL module driver. 8 | * 9 | * This file provides firmware functions to manage the following 10 | * functionalities SPI extension peripheral: 11 | * + Extended Peripheral Control functions 12 | * 13 | ****************************************************************************** 14 | * @attention 15 | * 16 | *

© COPYRIGHT(c) 2014 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 | /** @addtogroup SPI 51 | * @{ 52 | */ 53 | #ifdef HAL_SPI_MODULE_ENABLED 54 | 55 | /** @defgroup SPI_Private_Variables SPI Private Variables 56 | * @{ 57 | */ 58 | /* Variable used to determine if device is impacted by implementation of workaround 59 | related to wrong CRC errors detection on SPI2. Conditions in which this workaround has to be applied, are: 60 | - STM32F101CDE/STM32F103CDE 61 | - Revision ID : Z 62 | - SPI2 63 | - In receive only mode, with CRC calculation enabled, at the end of the CRC reception, 64 | the software needs to check the CRCERR flag. If it is found set, read back the SPI_RXCRC: 65 | + If the value is 0, the complete data transfer is successful. 66 | + Otherwise, one or more errors have been detected during the data transfer by CPU or DMA. 67 | If CRCERR is found reset, the complete data transfer is considered successful. 68 | */ 69 | uint8_t uCRCErrorWorkaroundCheck = 0; 70 | /** 71 | * @} 72 | */ 73 | 74 | 75 | /* Private typedef -----------------------------------------------------------*/ 76 | /* Private define ------------------------------------------------------------*/ 77 | /* Private macro -------------------------------------------------------------*/ 78 | /* Private variables ---------------------------------------------------------*/ 79 | /* Private function prototypes -----------------------------------------------*/ 80 | /* Private functions ---------------------------------------------------------*/ 81 | 82 | /** @addtogroup SPI_Exported_Functions 83 | * @{ 84 | */ 85 | 86 | /** @addtogroup SPI_Exported_Functions_Group1 87 | * 88 | * @{ 89 | */ 90 | 91 | /** 92 | * @brief Initializes the SPI according to the specified parameters 93 | * in the SPI_InitTypeDef and create the associated handle. 94 | * @param hspi: pointer to a SPI_HandleTypeDef structure that contains 95 | * the configuration information for SPI module. 96 | * @retval HAL status 97 | */ 98 | HAL_StatusTypeDef HAL_SPI_Init(SPI_HandleTypeDef *hspi) 99 | { 100 | /* Check the SPI handle allocation */ 101 | if(hspi == NULL) 102 | { 103 | return HAL_ERROR; 104 | } 105 | 106 | /* Check the parameters */ 107 | assert_param(IS_SPI_ALL_INSTANCE(hspi->Instance)); 108 | assert_param(IS_SPI_MODE(hspi->Init.Mode)); 109 | assert_param(IS_SPI_DIRECTION_MODE(hspi->Init.Direction)); 110 | assert_param(IS_SPI_DATASIZE(hspi->Init.DataSize)); 111 | assert_param(IS_SPI_CPOL(hspi->Init.CLKPolarity)); 112 | assert_param(IS_SPI_CPHA(hspi->Init.CLKPhase)); 113 | assert_param(IS_SPI_NSS(hspi->Init.NSS)); 114 | assert_param(IS_SPI_BAUDRATE_PRESCALER(hspi->Init.BaudRatePrescaler)); 115 | assert_param(IS_SPI_FIRST_BIT(hspi->Init.FirstBit)); 116 | assert_param(IS_SPI_TIMODE(hspi->Init.TIMode)); 117 | assert_param(IS_SPI_CRC_CALCULATION(hspi->Init.CRCCalculation)); 118 | assert_param(IS_SPI_CRC_POLYNOMIAL(hspi->Init.CRCPolynomial)); 119 | 120 | if(hspi->State == HAL_SPI_STATE_RESET) 121 | { 122 | /* Init the low level hardware : GPIO, CLOCK, NVIC... */ 123 | HAL_SPI_MspInit(hspi); 124 | } 125 | 126 | hspi->State = HAL_SPI_STATE_BUSY; 127 | 128 | /* Disble the selected SPI peripheral */ 129 | __HAL_SPI_DISABLE(hspi); 130 | 131 | /*----------------------- SPIx CR1 & CR2 Configuration ---------------------*/ 132 | /* Configure : SPI Mode, Communication Mode, Data size, Clock polarity and phase, NSS management, 133 | Communication speed, First bit and CRC calculation state */ 134 | WRITE_REG(hspi->Instance->CR1, (hspi->Init.Mode | hspi->Init.Direction | hspi->Init.DataSize | 135 | hspi->Init.CLKPolarity | hspi->Init.CLKPhase | (hspi->Init.NSS & SPI_CR1_SSM) | 136 | hspi->Init.BaudRatePrescaler | hspi->Init.FirstBit | hspi->Init.CRCCalculation) ); 137 | 138 | /* Configure : NSS management */ 139 | WRITE_REG(hspi->Instance->CR2, (((hspi->Init.NSS >> 16) & SPI_CR2_SSOE) | hspi->Init.TIMode)); 140 | 141 | /*---------------------------- SPIx CRCPOLY Configuration ------------------*/ 142 | /* Configure : CRC Polynomial */ 143 | WRITE_REG(hspi->Instance->CRCPR, hspi->Init.CRCPolynomial); 144 | 145 | #if defined (STM32F101x6) || defined (STM32F101xB) || defined (STM32F101xE) || defined (STM32F101xG) || defined (STM32F102x6) || defined (STM32F102xB) || defined (STM32F103x6) || defined (STM32F103xB) || defined (STM32F103xE) || defined (STM32F103xG) || defined (STM32F105xC) || defined (STM32F107xC) 146 | /* Activate the SPI mode (Make sure that I2SMOD bit in I2SCFGR register is reset) */ 147 | CLEAR_BIT(hspi->Instance->I2SCFGR, SPI_I2SCFGR_I2SMOD); 148 | #endif 149 | 150 | #if defined (STM32F101xE) || defined (STM32F103xE) 151 | /* Check RevisionID value for identifying if Device is Rev Z (0x0001) in order to enable workaround for 152 | CRC errors wrongly detected */ 153 | /* Pb is that ES_STM32F10xxCDE also identify an issue in Debug registers access while not in Debug mode. 154 | Revision ID information is only available in Debug mode, so Workaround could not be implemented 155 | to distinguish Rev Z devices (issue present) from more recent version (issue fixed). 156 | So, in case of Revison Z F101 or F103 devices, below variable should be assigned to 1 */ 157 | uCRCErrorWorkaroundCheck = 0; 158 | #else 159 | uCRCErrorWorkaroundCheck = 0; 160 | #endif 161 | 162 | hspi->ErrorCode = HAL_SPI_ERROR_NONE; 163 | hspi->State = HAL_SPI_STATE_READY; 164 | 165 | return HAL_OK; 166 | } 167 | 168 | /** 169 | * @} 170 | */ 171 | 172 | /** 173 | * @} 174 | */ 175 | 176 | /** @addtogroup SPI_Private_Functions 177 | * @{ 178 | */ 179 | 180 | /** 181 | * @brief Checks if encountered CRC error could be corresponding to wrongly detected errors 182 | * according to SPI instance, Device type, and revision ID. 183 | * @param hspi: pointer to a SPI_HandleTypeDef structure that contains 184 | * the configuration information for SPI module. 185 | * @retval CRC error validity (SPI_INVALID_CRC_ERROR or SPI_VALID_CRC_ERROR). 186 | */ 187 | uint8_t SPI_ISCRCErrorValid(SPI_HandleTypeDef *hspi) 188 | { 189 | #if defined (STM32F101xE) || defined (STM32F103xE) 190 | /* Check how to handle this CRC error (workaround to be applied or not) */ 191 | /* If CRC errors could be wrongly detected (issue 2.15.2 in STM32F10xxC/D/E silicon limitations ES (DocID14732 Rev 13) */ 192 | if ( (uCRCErrorWorkaroundCheck != 0) && (hspi->Instance == SPI2) ) 193 | { 194 | if (hspi->Instance->RXCRCR == 0) 195 | { 196 | return (SPI_INVALID_CRC_ERROR); 197 | } 198 | } 199 | return (SPI_VALID_CRC_ERROR); 200 | #else 201 | return (SPI_VALID_CRC_ERROR); 202 | #endif 203 | } 204 | /** 205 | * @} 206 | */ 207 | 208 | #endif /* HAL_SPI_MODULE_ENABLED */ 209 | /** 210 | * @} 211 | */ 212 | 213 | /** 214 | * @} 215 | */ 216 | 217 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 218 | -------------------------------------------------------------------------------- /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 USART1_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 1 68 | /*---------- -----------*/ 69 | #define USBD_DEBUG_LEVEL 0 70 | /*---------- -----------*/ 71 | #define USBD_SELF_POWERED 1 72 | /*---------- -----------*/ 73 | #define USBD_CUSTOMHID_OUTREPORT_BUF_SIZE 2 74 | /*---------- -----------*/ 75 | #define USBD_CUSTOM_HID_REPORT_DESC_SIZE 34 76 | /****************************************/ 77 | /* #define for FS and HS identification */ 78 | #define DEVICE_FS 0 79 | 80 | /** @defgroup USBD_Exported_Macros 81 | * @{ 82 | */ 83 | 84 | /* Memory management macros */ 85 | #define USBD_malloc (uint32_t *)USBD_static_malloc 86 | #define USBD_free USBD_static_free 87 | #define USBD_memset /* Not used */ 88 | #define USBD_memcpy /* Not used */ 89 | 90 | #define USBD_Delay HAL_Delay 91 | 92 | /* For footprint reasons and since only one allocation is handled in the HID class 93 | driver, the malloc/free is changed into a static allocation method */ 94 | void *USBD_static_malloc(uint32_t size); 95 | void USBD_static_free(void *p); 96 | 97 | /* DEBUG macros */ 98 | #if (USBD_DEBUG_LEVEL > 0) 99 | #define USBD_UsrLog(...) printf(__VA_ARGS__);\ 100 | printf("\n"); 101 | #else 102 | #define USBD_UsrLog(...) 103 | #endif 104 | 105 | 106 | #if (USBD_DEBUG_LEVEL > 1) 107 | 108 | #define USBD_ErrLog(...) printf("ERROR: ") ;\ 109 | printf(__VA_ARGS__);\ 110 | printf("\n"); 111 | #else 112 | #define USBD_ErrLog(...) 113 | #endif 114 | 115 | 116 | #if (USBD_DEBUG_LEVEL > 2) 117 | #define USBD_DbgLog(...) printf("DEBUG : ") ;\ 118 | printf(__VA_ARGS__);\ 119 | printf("\n"); 120 | #else 121 | #define USBD_DbgLog(...) 122 | #endif 123 | 124 | /** 125 | * @} 126 | */ 127 | 128 | 129 | 130 | /** 131 | * @} 132 | */ 133 | 134 | /** @defgroup USBD_CONF_Exported_Types 135 | * @{ 136 | */ 137 | /** 138 | * @} 139 | */ 140 | 141 | /** @defgroup USBD_CONF_Exported_Macros 142 | * @{ 143 | */ 144 | /** 145 | * @} 146 | */ 147 | 148 | /** @defgroup USBD_CONF_Exported_Variables 149 | * @{ 150 | */ 151 | /** 152 | * @} 153 | */ 154 | 155 | /** @defgroup USBD_CONF_Exported_FunctionsPrototype 156 | * @{ 157 | */ 158 | /** 159 | * @} 160 | */ 161 | #ifdef __cplusplus 162 | } 163 | #endif 164 | 165 | #endif //__USBD_CONF__H__ 166 | 167 | /** 168 | * @} 169 | */ 170 | 171 | /** 172 | * @} 173 | */ 174 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 175 | 176 | -------------------------------------------------------------------------------- /Inc/usbd_custom_hid_if.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file : usbd_custom_hid_if_if.h 4 | * @brief : header file for the usbd_custom_hid_if.c file 5 | ****************************************************************************** 6 | * COPYRIGHT(c) 2015 STMicroelectronics 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | ****************************************************************************** 31 | */ 32 | 33 | /* Define to prevent recursive inclusion -------------------------------------*/ 34 | 35 | #ifndef __USBD_CUSTOM_HID_IF_H_ 36 | #define __USBD_CUSTOM_HID_IF_H_ 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | /* Includes ------------------------------------------------------------------*/ 42 | #include "usbd_customhid.h" 43 | 44 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY 45 | * @{ 46 | */ 47 | 48 | /** @defgroup USBD_CUSTOM_HID 49 | * @{ 50 | */ 51 | 52 | /** @defgroup USBD_CUSTOM_HID_Exported_Defines 53 | * @{ 54 | */ 55 | /** 56 | * @} 57 | */ 58 | 59 | /** @defgroup USBD_CUSTOM_HID_Exported_Types 60 | * @{ 61 | */ 62 | 63 | /** 64 | * @} 65 | */ 66 | 67 | /** @defgroup USBD_CUSTOM_HID_Exported_Macros 68 | * @{ 69 | */ 70 | 71 | /** 72 | * @} 73 | */ 74 | 75 | /** @defgroup USBD_CUSTOM_HID_Exported_Variables 76 | * @{ 77 | */ 78 | extern USBD_CUSTOM_HID_ItfTypeDef USBD_CustomHID_fops_FS; 79 | /** 80 | * @} 81 | */ 82 | 83 | /** @defgroup USBD_CUSTOM_HID_Exported_FunctionsPrototype 84 | * @{ 85 | */ 86 | 87 | /** 88 | * @} 89 | */ 90 | 91 | #ifdef __cplusplus 92 | } 93 | #endif 94 | 95 | #endif /* __USBD_CUSTOM_HID_IF_H_ */ 96 | 97 | /** 98 | * @} 99 | */ 100 | 101 | /** 102 | * @} 103 | */ 104 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 105 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 hansfbaier 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /Middlewares/ST/STM32_USB_Device_Library/Class/CustomHID/Inc/usbd_customhid.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_customhid.h 4 | * @author MCD Application Team 5 | * @version V2.3.0 6 | * @date 04-November-2014 7 | * @brief header file for the usbd_customhid.c file. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2014 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_CUSTOMHID_H 30 | #define __USB_CUSTOMHID_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_CUSTOM_HID 44 | * @brief This file is the Header file for USBD_customhid.c 45 | * @{ 46 | */ 47 | 48 | 49 | /** @defgroup USBD_CUSTOM_HID_Exported_Defines 50 | * @{ 51 | */ 52 | #define CUSTOM_HID_EPIN_ADDR 0x81 53 | #define CUSTOM_HID_EPIN_SIZE 0x02 54 | 55 | #define CUSTOM_HID_EPOUT_ADDR 0x01 56 | #define CUSTOM_HID_EPOUT_SIZE 0x02 57 | 58 | #define USB_CUSTOM_HID_CONFIG_DESC_SIZ 41 59 | #define USB_CUSTOM_HID_DESC_SIZ 9 60 | 61 | #define CUSTOM_HID_DESCRIPTOR_TYPE 0x21 62 | #define CUSTOM_HID_REPORT_DESC 0x22 63 | 64 | 65 | #define CUSTOM_HID_REQ_SET_PROTOCOL 0x0B 66 | #define CUSTOM_HID_REQ_GET_PROTOCOL 0x03 67 | 68 | #define CUSTOM_HID_REQ_SET_IDLE 0x0A 69 | #define CUSTOM_HID_REQ_GET_IDLE 0x02 70 | 71 | #define CUSTOM_HID_REQ_SET_REPORT 0x09 72 | #define CUSTOM_HID_REQ_GET_REPORT 0x01 73 | /** 74 | * @} 75 | */ 76 | 77 | 78 | /** @defgroup USBD_CORE_Exported_TypesDefinitions 79 | * @{ 80 | */ 81 | typedef enum 82 | { 83 | CUSTOM_HID_IDLE = 0, 84 | CUSTOM_HID_BUSY, 85 | } 86 | CUSTOM_HID_StateTypeDef; 87 | 88 | typedef struct _USBD_CUSTOM_HID_Itf 89 | { 90 | uint8_t *pReport; 91 | int8_t (* Init) (void); 92 | int8_t (* DeInit) (void); 93 | int8_t (* OutEvent) (uint8_t, uint8_t ); 94 | 95 | }USBD_CUSTOM_HID_ItfTypeDef; 96 | 97 | typedef struct 98 | { 99 | uint8_t Report_buf[USBD_CUSTOMHID_OUTREPORT_BUF_SIZE]; 100 | uint32_t Protocol; 101 | uint32_t IdleState; 102 | uint32_t AltSetting; 103 | uint32_t IsReportAvailable; 104 | CUSTOM_HID_StateTypeDef state; 105 | } 106 | USBD_CUSTOM_HID_HandleTypeDef; 107 | /** 108 | * @} 109 | */ 110 | 111 | 112 | 113 | /** @defgroup USBD_CORE_Exported_Macros 114 | * @{ 115 | */ 116 | 117 | /** 118 | * @} 119 | */ 120 | 121 | /** @defgroup USBD_CORE_Exported_Variables 122 | * @{ 123 | */ 124 | 125 | extern USBD_ClassTypeDef USBD_CUSTOM_HID; 126 | #define USBD_CUSTOM_HID_CLASS &USBD_CUSTOM_HID 127 | /** 128 | * @} 129 | */ 130 | 131 | /** @defgroup USB_CORE_Exported_Functions 132 | * @{ 133 | */ 134 | uint8_t USBD_CUSTOM_HID_SendReport (USBD_HandleTypeDef *pdev, 135 | uint8_t *report, 136 | uint16_t len); 137 | 138 | 139 | 140 | uint8_t USBD_CUSTOM_HID_RegisterInterface (USBD_HandleTypeDef *pdev, 141 | USBD_CUSTOM_HID_ItfTypeDef *fops); 142 | 143 | /** 144 | * @} 145 | */ 146 | 147 | #ifdef __cplusplus 148 | } 149 | #endif 150 | 151 | #endif /* __USB_CUSTOMHID_H */ 152 | /** 153 | * @} 154 | */ 155 | 156 | /** 157 | * @} 158 | */ 159 | 160 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 161 | -------------------------------------------------------------------------------- /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.3.0 6 | * @date 04-November-2014 7 | * @brief Header file for usbd_core.c file 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2014 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.3.0 6 | * @date 04-November-2014 7 | * @brief Header file for the usbd_req.c file 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2014 STMicroelectronics

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

© COPYRIGHT 2014 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.3.0 6 | * @date 04-November-2014 7 | * @brief This file provides the IO requests APIs for control endpoints. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2014 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: -------------------------------------------------------------------------------- 1 | This is a custom HID example for STM32F103xB, 2 | using Makefiles, basic skeleton generated by STM32CubeMX. 3 | Be sure to adapt or remove the .gdbinit file 4 | if you do not use the black magic probe. 5 | -------------------------------------------------------------------------------- /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 | 39 | /* USER CODE END Includes */ 40 | 41 | /* Private variables ---------------------------------------------------------*/ 42 | ADC_HandleTypeDef hadc1; 43 | 44 | SPI_HandleTypeDef hspi1; 45 | 46 | UART_HandleTypeDef huart1; 47 | 48 | /* USER CODE BEGIN PV */ 49 | /* Private variables ---------------------------------------------------------*/ 50 | 51 | /* USER CODE END PV */ 52 | 53 | /* Private function prototypes -----------------------------------------------*/ 54 | void SystemClock_Config(void); 55 | static void MX_GPIO_Init(void); 56 | static void MX_ADC1_Init(void); 57 | static void MX_SPI1_Init(void); 58 | static void MX_USART1_UART_Init(void); 59 | 60 | /* USER CODE BEGIN PFP */ 61 | /* Private function prototypes -----------------------------------------------*/ 62 | 63 | /* USER CODE END PFP */ 64 | 65 | /* USER CODE BEGIN 0 */ 66 | extern int8_t USBD_CUSTOM_HID_SendReport_FS (uint8_t *report,uint16_t len); 67 | /* USER CODE END 0 */ 68 | 69 | int main(void) 70 | { 71 | 72 | /* USER CODE BEGIN 1 */ 73 | 74 | /* USER CODE END 1 */ 75 | 76 | /* MCU Configuration----------------------------------------------------------*/ 77 | 78 | /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ 79 | HAL_Init(); 80 | 81 | /* Configure the system clock */ 82 | SystemClock_Config(); 83 | 84 | /* Initialize all configured peripherals */ 85 | MX_GPIO_Init(); 86 | MX_ADC1_Init(); 87 | MX_SPI1_Init(); 88 | MX_USART1_UART_Init(); 89 | MX_USB_DEVICE_Init(); 90 | 91 | /* USER CODE BEGIN 2 */ 92 | 93 | /* USER CODE END 2 */ 94 | 95 | /* Infinite loop */ 96 | /* USER CODE BEGIN WHILE */ 97 | uint8_t report = 0; 98 | 99 | while (1) 100 | { 101 | /* USER CODE END WHILE */ 102 | HAL_Delay(500); 103 | 104 | USBD_CUSTOM_HID_SendReport_FS(&report, 1); 105 | report = !report; 106 | /* USER CODE BEGIN 3 */ 107 | 108 | } 109 | /* USER CODE END 3 */ 110 | 111 | } 112 | 113 | /** System Clock Configuration 114 | */ 115 | void SystemClock_Config(void) 116 | { 117 | 118 | RCC_OscInitTypeDef RCC_OscInitStruct; 119 | RCC_ClkInitTypeDef RCC_ClkInitStruct; 120 | RCC_PeriphCLKInitTypeDef PeriphClkInit; 121 | 122 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; 123 | RCC_OscInitStruct.HSEState = RCC_HSE_ON; 124 | RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1; 125 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; 126 | RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; 127 | RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9; 128 | HAL_RCC_OscConfig(&RCC_OscInitStruct); 129 | 130 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK|RCC_CLOCKTYPE_PCLK1; 131 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; 132 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; 133 | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; 134 | RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; 135 | HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2); 136 | 137 | PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADC|RCC_PERIPHCLK_USB; 138 | PeriphClkInit.AdcClockSelection = RCC_ADCPCLK2_DIV6; 139 | PeriphClkInit.UsbClockSelection = RCC_USBPLLCLK_DIV1_5; 140 | HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit); 141 | 142 | HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000); 143 | 144 | HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK); 145 | 146 | } 147 | 148 | /* ADC1 init function */ 149 | void MX_ADC1_Init(void) 150 | { 151 | 152 | ADC_ChannelConfTypeDef sConfig; 153 | 154 | /**Common config 155 | */ 156 | hadc1.Instance = ADC1; 157 | hadc1.Init.ScanConvMode = ADC_SCAN_DISABLE; 158 | hadc1.Init.ContinuousConvMode = DISABLE; 159 | hadc1.Init.DiscontinuousConvMode = DISABLE; 160 | hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START; 161 | hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT; 162 | hadc1.Init.NbrOfConversion = 1; 163 | HAL_ADC_Init(&hadc1); 164 | 165 | /**Configure Regular Channel 166 | */ 167 | sConfig.Channel = ADC_CHANNEL_0; 168 | sConfig.Rank = 1; 169 | sConfig.SamplingTime = ADC_SAMPLETIME_1CYCLE_5; 170 | HAL_ADC_ConfigChannel(&hadc1, &sConfig); 171 | 172 | } 173 | 174 | /* SPI1 init function */ 175 | void MX_SPI1_Init(void) 176 | { 177 | 178 | hspi1.Instance = SPI1; 179 | hspi1.Init.Mode = SPI_MODE_MASTER; 180 | hspi1.Init.Direction = SPI_DIRECTION_2LINES; 181 | hspi1.Init.DataSize = SPI_DATASIZE_8BIT; 182 | hspi1.Init.CLKPolarity = SPI_POLARITY_LOW; 183 | hspi1.Init.CLKPhase = SPI_PHASE_1EDGE; 184 | hspi1.Init.NSS = SPI_NSS_SOFT; 185 | hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_32; 186 | hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB; 187 | hspi1.Init.TIMode = SPI_TIMODE_DISABLED; 188 | hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLED; 189 | hspi1.Init.CRCPolynomial = 10; 190 | HAL_SPI_Init(&hspi1); 191 | 192 | } 193 | 194 | /* USART1 init function */ 195 | void MX_USART1_UART_Init(void) 196 | { 197 | 198 | huart1.Instance = USART1; 199 | huart1.Init.BaudRate = 115200; 200 | huart1.Init.WordLength = UART_WORDLENGTH_8B; 201 | huart1.Init.StopBits = UART_STOPBITS_1; 202 | huart1.Init.Parity = UART_PARITY_NONE; 203 | huart1.Init.Mode = UART_MODE_TX_RX; 204 | huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE; 205 | huart1.Init.OverSampling = UART_OVERSAMPLING_16; 206 | HAL_UART_Init(&huart1); 207 | 208 | } 209 | 210 | /** Configure pins as 211 | * Analog 212 | * Input 213 | * Output 214 | * EVENT_OUT 215 | * EXTI 216 | */ 217 | void MX_GPIO_Init(void) 218 | { 219 | 220 | /* GPIO Ports Clock Enable */ 221 | __GPIOD_CLK_ENABLE(); 222 | __GPIOA_CLK_ENABLE(); 223 | 224 | } 225 | 226 | /* USER CODE BEGIN 4 */ 227 | 228 | /* USER CODE END 4 */ 229 | 230 | #ifdef USE_FULL_ASSERT 231 | 232 | /** 233 | * @brief Reports the name of the source file and the source line number 234 | * where the assert_param error has occurred. 235 | * @param file: pointer to the source file name 236 | * @param line: assert_param error line source number 237 | * @retval None 238 | */ 239 | void assert_failed(uint8_t* file, uint32_t line) 240 | { 241 | /* USER CODE BEGIN 6 */ 242 | /* User can add his own implementation to report the file name and line number, 243 | ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ 244 | /* USER CODE END 6 */ 245 | 246 | } 247 | 248 | #endif 249 | 250 | /** 251 | * @} 252 | */ 253 | 254 | /** 255 | * @} 256 | */ 257 | 258 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 259 | -------------------------------------------------------------------------------- /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 | /**NOJTAG: JTAG-DP Disabled and SW-DP Enabled 59 | */ 60 | __HAL_AFIO_REMAP_SWJ_NOJTAG(); 61 | 62 | /* USER CODE BEGIN MspInit 1 */ 63 | 64 | /* USER CODE END MspInit 1 */ 65 | } 66 | 67 | void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) 68 | { 69 | 70 | GPIO_InitTypeDef GPIO_InitStruct; 71 | if(hadc->Instance==ADC1) 72 | { 73 | /* USER CODE BEGIN ADC1_MspInit 0 */ 74 | 75 | /* USER CODE END ADC1_MspInit 0 */ 76 | /* Peripheral clock enable */ 77 | __ADC1_CLK_ENABLE(); 78 | 79 | /**ADC1 GPIO Configuration 80 | PA0-WKUP ------> ADC1_IN0 81 | */ 82 | GPIO_InitStruct.Pin = GPIO_PIN_0; 83 | GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; 84 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 85 | 86 | /* USER CODE BEGIN ADC1_MspInit 1 */ 87 | 88 | /* USER CODE END ADC1_MspInit 1 */ 89 | } 90 | 91 | } 92 | 93 | void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) 94 | { 95 | 96 | if(hadc->Instance==ADC1) 97 | { 98 | /* USER CODE BEGIN ADC1_MspDeInit 0 */ 99 | 100 | /* USER CODE END ADC1_MspDeInit 0 */ 101 | /* Peripheral clock disable */ 102 | __ADC1_CLK_DISABLE(); 103 | 104 | /**ADC1 GPIO Configuration 105 | PA0-WKUP ------> ADC1_IN0 106 | */ 107 | HAL_GPIO_DeInit(GPIOA, GPIO_PIN_0); 108 | 109 | } 110 | /* USER CODE BEGIN ADC1_MspDeInit 1 */ 111 | 112 | /* USER CODE END ADC1_MspDeInit 1 */ 113 | 114 | } 115 | 116 | void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) 117 | { 118 | 119 | GPIO_InitTypeDef GPIO_InitStruct; 120 | if(hspi->Instance==SPI1) 121 | { 122 | /* USER CODE BEGIN SPI1_MspInit 0 */ 123 | 124 | /* USER CODE END SPI1_MspInit 0 */ 125 | /* Peripheral clock enable */ 126 | __SPI1_CLK_ENABLE(); 127 | 128 | /**SPI1 GPIO Configuration 129 | PA5 ------> SPI1_SCK 130 | PA6 ------> SPI1_MISO 131 | PA7 ------> SPI1_MOSI 132 | */ 133 | GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_7; 134 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 135 | GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; 136 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 137 | 138 | GPIO_InitStruct.Pin = GPIO_PIN_6; 139 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT; 140 | GPIO_InitStruct.Pull = GPIO_NOPULL; 141 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 142 | 143 | /* USER CODE BEGIN SPI1_MspInit 1 */ 144 | 145 | /* USER CODE END SPI1_MspInit 1 */ 146 | } 147 | 148 | } 149 | 150 | void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) 151 | { 152 | 153 | if(hspi->Instance==SPI1) 154 | { 155 | /* USER CODE BEGIN SPI1_MspDeInit 0 */ 156 | 157 | /* USER CODE END SPI1_MspDeInit 0 */ 158 | /* Peripheral clock disable */ 159 | __SPI1_CLK_DISABLE(); 160 | 161 | /**SPI1 GPIO Configuration 162 | PA5 ------> SPI1_SCK 163 | PA6 ------> SPI1_MISO 164 | PA7 ------> SPI1_MOSI 165 | */ 166 | HAL_GPIO_DeInit(GPIOA, GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7); 167 | 168 | } 169 | /* USER CODE BEGIN SPI1_MspDeInit 1 */ 170 | 171 | /* USER CODE END SPI1_MspDeInit 1 */ 172 | 173 | } 174 | 175 | void HAL_UART_MspInit(UART_HandleTypeDef* huart) 176 | { 177 | 178 | GPIO_InitTypeDef GPIO_InitStruct; 179 | if(huart->Instance==USART1) 180 | { 181 | /* USER CODE BEGIN USART1_MspInit 0 */ 182 | 183 | /* USER CODE END USART1_MspInit 0 */ 184 | /* Peripheral clock enable */ 185 | __USART1_CLK_ENABLE(); 186 | 187 | /**USART1 GPIO Configuration 188 | PA9 ------> USART1_TX 189 | PA10 ------> USART1_RX 190 | */ 191 | GPIO_InitStruct.Pin = GPIO_PIN_9; 192 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 193 | GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; 194 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 195 | 196 | GPIO_InitStruct.Pin = GPIO_PIN_10; 197 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT; 198 | GPIO_InitStruct.Pull = GPIO_NOPULL; 199 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 200 | 201 | /* Peripheral interrupt init*/ 202 | HAL_NVIC_SetPriority(USART1_IRQn, 0, 0); 203 | HAL_NVIC_EnableIRQ(USART1_IRQn); 204 | /* USER CODE BEGIN USART1_MspInit 1 */ 205 | 206 | /* USER CODE END USART1_MspInit 1 */ 207 | } 208 | 209 | } 210 | 211 | void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) 212 | { 213 | 214 | if(huart->Instance==USART1) 215 | { 216 | /* USER CODE BEGIN USART1_MspDeInit 0 */ 217 | 218 | /* USER CODE END USART1_MspDeInit 0 */ 219 | /* Peripheral clock disable */ 220 | __USART1_CLK_DISABLE(); 221 | 222 | /**USART1 GPIO Configuration 223 | PA9 ------> USART1_TX 224 | PA10 ------> USART1_RX 225 | */ 226 | HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_10); 227 | 228 | /* Peripheral interrupt DeInit*/ 229 | HAL_NVIC_DisableIRQ(USART1_IRQn); 230 | 231 | } 232 | /* USER CODE BEGIN USART1_MspDeInit 1 */ 233 | 234 | /* USER CODE END USART1_MspDeInit 1 */ 235 | 236 | } 237 | 238 | /* USER CODE BEGIN 1 */ 239 | 240 | /* USER CODE END 1 */ 241 | 242 | /** 243 | * @} 244 | */ 245 | 246 | /** 247 | * @} 248 | */ 249 | 250 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 251 | -------------------------------------------------------------------------------- /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 UART_HandleTypeDef huart1; 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 USART1 global interrupt. 88 | */ 89 | void USART1_IRQHandler(void) 90 | { 91 | /* USER CODE BEGIN USART1_IRQn 0 */ 92 | 93 | /* USER CODE END USART1_IRQn 0 */ 94 | HAL_UART_IRQHandler(&huart1); 95 | /* USER CODE BEGIN USART1_IRQn 1 */ 96 | 97 | /* USER CODE END USART1_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_customhid.h" 41 | #include "usbd_custom_hid_if.h" 42 | 43 | /* USB Device Core handle declaration */ 44 | USBD_HandleTypeDef hUsbDeviceFS; 45 | 46 | /* init function */ 47 | void MX_USB_DEVICE_Init(void) 48 | { 49 | /* Init Device Library,Add Supported Class and Start the library*/ 50 | USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS); 51 | 52 | USBD_RegisterClass(&hUsbDeviceFS, &USBD_CUSTOM_HID); 53 | 54 | USBD_CUSTOM_HID_RegisterInterface(&hUsbDeviceFS, &USBD_CustomHID_fops_FS); 55 | 56 | USBD_Start(&hUsbDeviceFS); 57 | 58 | } 59 | /** 60 | * @} 61 | */ 62 | 63 | /** 64 | * @} 65 | */ 66 | 67 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 68 | -------------------------------------------------------------------------------- /Src/usbd_custom_hid_if.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file : usbd_custom_hid_if.c 4 | * @brief : USB Device Custom HID interface file. 5 | ****************************************************************************** 6 | * COPYRIGHT(c) 2015 STMicroelectronics 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | ****************************************************************************** 31 | */ 32 | 33 | /* Includes ------------------------------------------------------------------*/ 34 | #include "usbd_custom_hid_if.h" 35 | 36 | /* Private typedef -----------------------------------------------------------*/ 37 | /* Private define ------------------------------------------------------------*/ 38 | /* Private macro -------------------------------------------------------------*/ 39 | /* Private variables ---------------------------------------------------------*/ 40 | 41 | __ALIGN_BEGIN static uint8_t CUSTOM_HID_ReportDesc_FS[USBD_CUSTOM_HID_REPORT_DESC_SIZE] __ALIGN_END = 42 | { 43 | /* USER CODE BEGIN 0 */ 44 | 0x05, 0x01, // USAGE_PAGE (Generic Desktop) 45 | 0x09, 0x02, // USAGE (Mouse) 46 | 0xa1, 0x01, // COLLECTION (Application) 47 | 0x09, 0x01, // USAGE (Pointer) 48 | 0xa1, 0x00, // COLLECTION (Physical) 49 | 0x05, 0x09, // USAGE_PAGE (Button) 50 | 0x19, 0x01, // USAGE_MINIMUM (Button 1) 51 | 0x29, 0x01, // USAGE_MAXIMUM (Button 1) 52 | 0x15, 0x00, // LOGICAL_MINIMUM (0) 53 | 0x25, 0x01, // LOGICAL_MAXIMUM (1) 54 | 0x95, 0x01, // REPORT_COUNT (1) 55 | 0x75, 0x01, // REPORT_SIZE (1) 56 | 0x81, 0x02, // INPUT (Data,Var,Abs) 57 | 0x95, 0x01, // REPORT_COUNT (1) 58 | 0x75, 0x07, // REPORT_SIZE (7) 59 | 0x81, 0x03, // INPUT (Cnst,Var,Abs) 60 | 0xc0, // END_COLLECTION 61 | 0xc0 // END_COLLECTION 62 | /* USER CODE END 0 */ 63 | }; 64 | 65 | /* USB handler declaration */ 66 | /* Handle for USB Full Speed IP */ 67 | USBD_HandleTypeDef *hUsbDevice_0; 68 | 69 | extern USBD_HandleTypeDef hUsbDeviceFS; 70 | 71 | /* Private function prototypes -----------------------------------------------*/ 72 | /* Extern function prototypes ------------------------------------------------*/ 73 | /* Private functions ---------------------------------------------------------*/ 74 | static int8_t CUSTOM_HID_Init_FS (void); 75 | static int8_t CUSTOM_HID_DeInit_FS (void); 76 | static int8_t CUSTOM_HID_OutEvent_FS (uint8_t event_idx, uint8_t state); 77 | /* USER CODE BEGIN 2 */ 78 | /* USER CODE END 2 */ 79 | 80 | USBD_CUSTOM_HID_ItfTypeDef USBD_CustomHID_fops_FS = 81 | { 82 | CUSTOM_HID_ReportDesc_FS, 83 | CUSTOM_HID_Init_FS, 84 | CUSTOM_HID_DeInit_FS, 85 | CUSTOM_HID_OutEvent_FS, 86 | }; 87 | 88 | /* Private functions ---------------------------------------------------------*/ 89 | /** 90 | * @brief CUSTOM_HID_Init_FS 91 | * Initializes the CUSTOM HID media low layer 92 | * @param None 93 | * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL 94 | */ 95 | static int8_t CUSTOM_HID_Init_FS(void) 96 | { 97 | hUsbDevice_0 = &hUsbDeviceFS; 98 | /* USER CODE BEGIN 4 */ 99 | return (0); 100 | /* USER CODE END 4 */ 101 | } 102 | 103 | /** 104 | * @brief CUSTOM_HID_DeInit_FS 105 | * DeInitializes the CUSTOM HID media low layer 106 | * @param None 107 | * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL 108 | */ 109 | static int8_t CUSTOM_HID_DeInit_FS(void) 110 | { 111 | /* USER CODE BEGIN 5 */ 112 | return (0); 113 | /* USER CODE END 5 */ 114 | } 115 | 116 | /** 117 | * @brief CUSTOM_HID_OutEvent_FS 118 | * Manage the CUSTOM HID class events 119 | * @param event_idx: event index 120 | * @param state: event state 121 | * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL 122 | */ 123 | static int8_t CUSTOM_HID_OutEvent_FS (uint8_t event_idx, uint8_t state) 124 | { 125 | /* USER CODE BEGIN 6 */ 126 | return (0); 127 | /* USER CODE END 6 */ 128 | } 129 | 130 | /* USER CODE BEGIN 7 */ 131 | /** 132 | * @brief USBD_CUSTOM_HID_SendReport_FS 133 | * Send the report to the Host 134 | * @param report: the report to be sent 135 | * @param len: the report length 136 | * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL 137 | */ 138 | 139 | int8_t USBD_CUSTOM_HID_SendReport_FS ( uint8_t *report,uint16_t len) 140 | { 141 | return USBD_CUSTOM_HID_SendReport(hUsbDevice_0, report, len); 142 | } 143 | /* USER CODE END 7 */ 144 | 145 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 146 | -------------------------------------------------------------------------------- /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 1155 60 | #define USBD_LANGID_STRING 1033 61 | #define USBD_MANUFACTURER_STRING "STMicroelectronics" 62 | #define USBD_PID_FS 22352 63 | #define USBD_PRODUCT_STRING_FS "STM32 Custom Human interface" 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 "Custom HID Config" 68 | #define USBD_INTERFACE_STRING_FS "Custom 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 | -------------------------------------------------------------------------------- /hid-test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import hidapi 4 | import binascii 5 | import time 6 | 7 | hidapi.hid_init() 8 | 9 | print 'Loaded hidapi library from: {:s}\n'.format(hidapi.hid_lib_path()) 10 | 11 | devices = hidapi.hid_enumerate(0x0483, 0x5750) 12 | if len(devices) == 0: 13 | print "No dev attached" 14 | exit(1) 15 | 16 | device = hidapi.hid_open(0x0483, 0x5750) 17 | 18 | 19 | import random 20 | while True: 21 | result = hidapi.hid_read(device, 4) 22 | state = binascii.hexlify(result) 23 | print "#%d: %s" % (len(result), state) 24 | 25 | hidapi.hid_close(device) 26 | -------------------------------------------------------------------------------- /makefile: -------------------------------------------------------------------------------- 1 | # Set the external clock frequency 2 | HSE_VALUE = 8000000L 3 | 4 | # Enable debug compilation 5 | #DEBUG = 1 6 | 7 | # [OPTIONAL] Uncomment to link to maths library libm 8 | #LIBM = -lm 9 | 10 | export DEBUG 11 | export MESSAGES 12 | 13 | TARGET_ARCH = -mcpu=cortex-m3 -mthumb 14 | DEVICE_TYPE = STM32F103xB 15 | 16 | INCLUDE_DIRS = -I . -I ./Inc -I ./Drivers/CMSIS/Device/ST/STM32F1xx/Include/\ 17 | -I ./Drivers/CMSIS/Include/ -I ./Drivers/STM32F1xx_HAL_Driver/Inc/\ 18 | -I ./Middlewares/ST/STM32_USB_Device_Library/Core/Inc/\ 19 | -I ./Middlewares/ST/STM32_USB_Device_Library/Class/CustomHID/Inc/ 20 | 21 | DEFINES = -D$(DEVICE_TYPE) -DHSE_VALUE=$(HSE_VALUE) 22 | 23 | export DEFINES 24 | 25 | COMPILE_OPTS = $(WARNINGS) $(TARGET_OPTS) $(MESSAGES) $(INCLUDE_DIRS) $(DEFINES) 26 | WARNINGS = -Wall -W -Wshadow -Wcast-qual -Wwrite-strings -Winline 27 | 28 | ifdef DEBUG 29 | TARGET_OPTS = -O0 -g3 30 | DEBUG_MACRO = -DDEBUG 31 | else 32 | TARGET_OPTS = -O2 $(F_INLINE) $(F_INLINE_ONCE) $(F_UNROLL_LOOPS) 33 | F_INLINE = -finline 34 | F_INLINE_ONCE = -finline-functions-called-once 35 | #F_UNROLL_LOOPS = -funroll-loops 36 | endif 37 | 38 | CC = arm-none-eabi-gcc 39 | CFLAGS = -std=gnu99 $(COMPILE_OPTS) 40 | 41 | AS = $(CC) -x assembler-with-cpp -c $(TARGET_ARCH) 42 | ASFLAGS = $(COMPILE_OPTS) 43 | 44 | LD = $(CC) 45 | LDFLAGS = -Wl,--gc-sections,-Map=$(MAIN_MAP),-cref -T ./Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/linker/STM32F103XB_FLASH.ld $(INCLUDE_DIRS)\ 46 | $(LIBM) 47 | 48 | AR = arm-none-eabi-ar 49 | ARFLAGS = cr 50 | 51 | OBJCOPY = arm-none-eabi-objcopy 52 | OBJCOPYFLAGS = -O binary 53 | 54 | STARTUP_FILE = stm32f103xb 55 | STARTUP_OBJ = Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_$(STARTUP_FILE).o 56 | 57 | MAIN_OUT = main.elf 58 | MAIN_MAP = $(MAIN_OUT:%.elf=%.map) 59 | MAIN_BIN = $(MAIN_OUT:%.elf=%.bin) 60 | 61 | MAIN_SRCS = ./Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/system_stm32f1xx.c\ 62 | $(wildcard ./Drivers/STM32F1xx_HAL_Driver/Src/*.c)\ 63 | $(wildcard ./Middlewares/ST/STM32_USB_Device_Library/Core/Src/*.c)\ 64 | $(wildcard ./Middlewares/ST/STM32_USB_Device_Library/Class/CustomHID/Src/*.c)\ 65 | $(wildcard ./Src/*.c)\ 66 | 67 | MAIN_OBJS = $(sort \ 68 | $(patsubst %.c,%.o,$(MAIN_SRCS)) \ 69 | $(STARTUP_OBJ)) 70 | 71 | .PHONY: all 72 | all: $(MAIN_BIN) 73 | 74 | $(MAIN_OUT): $(MAIN_OBJS) $(FWLIB) $(USBLIB) 75 | $(LD) $(LDFLAGS) $(TARGET_ARCH) $^ -o $@ 76 | arm-none-eabi-size -x -A main.elf 77 | arm-none-eabi-size -B main.elf 78 | 79 | $(MAIN_OBJS): $(wildcard ./Drivers/CMSIS/Device/ST/STM32F1xx/Include/*.h) \ 80 | $(wildcard ./Drivers/CMSIS/Include/*.h)\ 81 | $(wildcard ./Drivers/STM32F1xx_HAL_Driver/Inc/*.h)\ 82 | $(wildcard ./Drivers/STM32F1xx_HAL_Driver/Inc/Legacy/*.h)\ 83 | $(wildcard ./Inc/*.h)\ 84 | $(wildcard ./Middlewares/ST/STM32_USB_Device_Library/Class/CustomHID/Inc/*.h)\ 85 | $(wildcard ./Middlewares/ST/STM32_USB_Device_Library/Core/Inc/*.h)\ 86 | 87 | $(MAIN_BIN): $(MAIN_OUT) 88 | $(OBJCOPY) $(OBJCOPYFLAGS) $< $@ 89 | 90 | clean: 91 | find . -name \*.o -exec rm {} \; 92 | rm $(MAIN_BIN) $(MAIN_OUT) $(MAIN_MAP) 93 | 94 | -------------------------------------------------------------------------------- /one_button_only.hid: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hansfbaier/stm32f1-custom-usbhid/26f28026685e66b9dfbf609c35eb2d5977157e3b/one_button_only.hid -------------------------------------------------------------------------------- /stm32f1-custom-usbhid.ioc: -------------------------------------------------------------------------------- 1 | #MicroXplorer Configuration settings - do not modify 2 | ADC1.Channel-0\#ChannelRegularConversion=ADC_CHANNEL_0 3 | ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,NbrOfConversionFlag,master 4 | ADC1.NbrOfConversionFlag=1 5 | ADC1.Rank-0\#ChannelRegularConversion=1 6 | ADC1.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_1CYCLE_5 7 | ADC1.master=1 8 | File.Version=5 9 | KeepUserPlacement=false 10 | Mcu.Family=STM32F1 11 | Mcu.IP0=ADC1 12 | Mcu.IP1=NVIC 13 | Mcu.IP2=RCC 14 | Mcu.IP3=SPI1 15 | Mcu.IP4=SYS 16 | Mcu.IP5=USART1 17 | Mcu.IP6=USB 18 | Mcu.IP7=USB_DEVICE 19 | Mcu.IPNb=8 20 | Mcu.Name=STM32F103C(8-B)Tx 21 | Mcu.Package=LQFP48 22 | Mcu.Pin0=PD0-OSC_IN 23 | Mcu.Pin1=PD1-OSC_OUT 24 | Mcu.Pin10=PA13 25 | Mcu.Pin11=PA14 26 | Mcu.Pin12=VP_USB_DEVICE_VS_USB_DEVICE_CUSTOM_HID_FS 27 | Mcu.Pin2=PA0-WKUP 28 | Mcu.Pin3=PA5 29 | Mcu.Pin4=PA6 30 | Mcu.Pin5=PA7 31 | Mcu.Pin6=PA9 32 | Mcu.Pin7=PA10 33 | Mcu.Pin8=PA11 34 | Mcu.Pin9=PA12 35 | Mcu.PinsNb=13 36 | Mcu.UserConstants= 37 | Mcu.UserName=STM32F103CBTx 38 | MxCube.Version=4.9.0 39 | MxDb.Version=DB.4.0.90 40 | NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 41 | NVIC.SysTick_IRQn=true\:0\:0\:false 42 | NVIC.USART1_IRQn=true\:0\:0\:false 43 | NVIC.USB_LP_CAN1_RX0_IRQn=true\:0\:0\:false 44 | PA0-WKUP.Signal=ADCx_IN0 45 | PA10.Mode=Asynchronous 46 | PA10.Signal=USART1_RX 47 | PA11.Mode=Device 48 | PA11.Signal=USB_DM 49 | PA12.Mode=Device 50 | PA12.Signal=USB_DP 51 | PA13.Mode=Serial_Wire 52 | PA13.Signal=SYS_JTMS-SWDIO 53 | PA14.Mode=Serial_Wire 54 | PA14.Signal=SYS_JTCK-SWCLK 55 | PA5.Mode=Full_Duplex_Master 56 | PA5.Signal=SPI1_SCK 57 | PA6.Mode=Full_Duplex_Master 58 | PA6.Signal=SPI1_MISO 59 | PA7.Mode=Full_Duplex_Master 60 | PA7.Signal=SPI1_MOSI 61 | PA9.Mode=Asynchronous 62 | PA9.Signal=USART1_TX 63 | PCC.Checker=false 64 | PCC.Line=STM32F103 65 | PCC.MCU=STM32F103C(8-B)Tx 66 | PCC.MXVersion=4.9.0 67 | PCC.PartNumber=STM32F103CBTx 68 | PCC.Seq0=0 69 | PCC.Series=STM32F1 70 | PCC.Temperature=25 71 | PCC.Vdd=3.3 72 | PD0-OSC_IN.Mode=HSE-External-Oscillator 73 | PD0-OSC_IN.Signal=RCC_OSC_IN 74 | PD1-OSC_OUT.Mode=HSE-External-Oscillator 75 | PD1-OSC_OUT.Signal=RCC_OSC_OUT 76 | ProjectManager.AskForMigrate=true 77 | ProjectManager.BackupPrevious=false 78 | ProjectManager.CompilerOptimize=2 79 | ProjectManager.ComputerToolchain=false 80 | ProjectManager.CoupleFile=false 81 | ProjectManager.DeletePrevious=true 82 | ProjectManager.DeviceId=STM32F103CBTx 83 | ProjectManager.FirmwarePackage=STM32Cube FW_F1 V1.1.0 84 | ProjectManager.FreePins=false 85 | ProjectManager.HalAssertFull=false 86 | ProjectManager.KeepUserCode=true 87 | ProjectManager.LastFirmware=true 88 | ProjectManager.LibraryCopy=1 89 | ProjectManager.ProjectBuild=false 90 | ProjectManager.ProjectFileName=stm32f1-custom-usbhid.ioc 91 | ProjectManager.ProjectName=stm32f1-custom-usbhid 92 | ProjectManager.TargetToolchain=TrueSTUDIO 93 | ProjectManager.ToolChainLocation= 94 | RCC.ADCFreqValue=12000000 95 | RCC.ADCPresc=RCC_ADCPCLK2_DIV6 96 | RCC.AHBFreq_Value=72000000 97 | RCC.APB1CLKDivider=RCC_HCLK_DIV2 98 | RCC.APB1Freq_Value=36000000 99 | RCC.APB1TimFreq_Value=72000000 100 | RCC.APB2Freq_Value=72000000 101 | RCC.APB2TimFreq_Value=72000000 102 | RCC.FCLKCortexFreq_Value=72000000 103 | RCC.FamilyName=M 104 | RCC.HCLKFreq_Value=72000000 105 | RCC.HSIState=RCC_HSI_ON 106 | RCC.IPParameters=FamilyName,TimSysFreq_Value,APB1Freq_Value,APB2Freq_Value,PLLCLKFreq_Value,PLLMCOFreq_Value,HCLKFreq_Value,AHBFreq_Value,FCLKCortexFreq_Value,APB1TimFreq_Value,APB2TimFreq_Value,ADCFreqValue,SYSCLKSource,USBFreq_Value,VCOOutput2Freq_Value,HSIState,PLLMUL,MCOFreq_Value,SYSCLKFreq_VALUE,USBPrescaler,APB1CLKDivider,ADCPresc 107 | RCC.MCOFreq_Value=72000000 108 | RCC.PLLCLKFreq_Value=72000000 109 | RCC.PLLMCOFreq_Value=36000000 110 | RCC.PLLMUL=RCC_PLL_MUL9 111 | RCC.SYSCLKFreq_VALUE=72000000 112 | RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK 113 | RCC.TimSysFreq_Value=72000000 114 | RCC.USBFreq_Value=48000000 115 | RCC.USBPrescaler=RCC_USBPLLCLK_DIV1_5 116 | RCC.VCOOutput2Freq_Value=8000000 117 | SH.ADCx_IN0.0=ADC1_IN0,IN0 118 | SH.ADCx_IN0.ConfNb=1 119 | SPI1.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_32 120 | SPI1.CalculateBaudRate=2.25 MBits/s 121 | SPI1.IPParameters=Mode,CalculateBaudRate,BaudRatePrescaler 122 | SPI1.Mode=SPI_MODE_MASTER 123 | USB_DEVICE.IPParameters=VirtualMode,VirtualModeFS,USBD_HandleTypeDef 124 | USB_DEVICE.USBD_HandleTypeDef=hUsbDeviceFS 125 | USB_DEVICE.VirtualMode=CustomHid 126 | USB_DEVICE.VirtualModeFS=Custom_Hid_FS 127 | VP_USB_DEVICE_VS_USB_DEVICE_CUSTOM_HID_FS.Mode=CUSTOM_HID_FS 128 | VP_USB_DEVICE_VS_USB_DEVICE_CUSTOM_HID_FS.Signal=USB_DEVICE_VS_USB_DEVICE_CUSTOM_HID_FS 129 | board=foo 130 | --------------------------------------------------------------------------------