├── Fabrication ├── BOM_HHID-v2.xlsx ├── HHID-v2-all-pos.csv ├── gerber.zip └── gerber │ ├── HHID-v2-B_Cu.gbr │ ├── HHID-v2-B_Fab.gbr │ ├── HHID-v2-B_Mask.gbr │ ├── HHID-v2-B_Paste.gbr │ ├── HHID-v2-Edge_Cuts.gbr │ ├── HHID-v2-F_Cu.gbr │ ├── HHID-v2-F_Fab.gbr │ ├── HHID-v2-F_Mask.gbr │ ├── HHID-v2-F_Paste.gbr │ ├── HHID-v2-NPTH.drl │ └── HHID-v2-PTH.drl ├── KiCad ├── HHID-v2.kicad_pcb ├── HHID-v2.kicad_prl ├── HHID-v2.kicad_pro ├── HHID-v2.kicad_sch └── fp-info-cache ├── README.md ├── STM32 ├── Core │ ├── Inc │ │ ├── main.h │ │ ├── stm32f0xx_hal_conf.h │ │ └── stm32f0xx_it.h │ └── Src │ │ ├── main.c │ │ ├── stm32f0xx_hal_msp.c │ │ ├── stm32f0xx_it.c │ │ └── system_stm32f0xx.c ├── Debug │ ├── RubberDuckyHelloWorld.elf │ └── RubberDuckyHelloWorld.hex ├── Middlewares │ └── ST │ │ └── STM32_USB_Device_Library │ │ ├── Class │ │ └── HID │ │ │ ├── Inc │ │ │ └── usbd_hid.h │ │ │ └── Src │ │ │ └── usbd_hid.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 ├── RubberDuckyHelloWorld.ioc ├── STM32CubeIDE │ └── Middlewares │ │ └── USB_Device_Library │ │ └── usbd_hid_ext.h └── USB_DEVICE │ ├── App │ ├── usb_device.c │ ├── usb_device.h │ ├── usbd_desc.c │ └── usbd_desc.h │ └── Target │ ├── usbd_conf.c │ └── usbd_conf.h └── photos ├── IMG_20250104_114501_754.jpg ├── IMG_20250118_131920_344.jpg ├── IMG_20250118_132318_155.jpg ├── IMG_20250118_132709_884.jpg ├── IMG_20250118_132744_293.jpg ├── IMG_20250118_132744_294.jpg ├── Screenshot 2025-01-18 160303.png ├── bot-hr.jpg ├── cover-cropped.jpg └── top-hr.jpg /Fabrication/BOM_HHID-v2.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enblack0/Hidden-HID-v2/4f44eee1a87c04dfad725e9ba3b24868d8b28b1a/Fabrication/BOM_HHID-v2.xlsx -------------------------------------------------------------------------------- /Fabrication/HHID-v2-all-pos.csv: -------------------------------------------------------------------------------- 1 | Ref,Val,Package,PosX,PosY,Rot,Side 2 | "C1","4.7µ","C_0402_1005Metric_noSS",9.375000,5.075000,-90.000000,bottom 3 | "C2","1µ","C_0402_1005Metric_noSS",3.175000,6.805000,90.000000,bottom 4 | "C3","1µ","C_0402_1005Metric_noSS",3.175000,3.220000,90.000000,bottom 5 | "Q1","Würth 1541201NC3060","LED_1206_3216Metric_IPC_C",10.950000,2.150000,-90.000000,bottom 6 | "Q2","Würth 1541201NC3060","LED_1206_3216Metric_IPC_C",1.150000,2.150000,-90.000000,bottom 7 | "Q3","Würth 1541201NC3060","LED_1206_3216Metric_IPC_C",1.150000,6.050000,90.000000,bottom 8 | "Q4","Würth 1541201NC3060","LED_1206_3216Metric_IPC_C",10.950000,6.050000,90.000000,bottom 9 | "R2","2k2","R_0402_1005Metric_noSS",9.375000,3.220000,-90.000000,bottom 10 | "U2","NCP115AMX330TCG","OnSemi_XDFN4-1EP_1.0x1.0mm_EP0.52x0.52mm",2.900000,5.025000,90.000000,bottom 11 | "U3","STM32F042G6Ux","QFN-28_4x4mm_P0.5mm",6.269400,4.839734,0.000000,bottom 12 | -------------------------------------------------------------------------------- /Fabrication/gerber.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enblack0/Hidden-HID-v2/4f44eee1a87c04dfad725e9ba3b24868d8b28b1a/Fabrication/gerber.zip -------------------------------------------------------------------------------- /Fabrication/gerber/HHID-v2-B_Fab.gbr: -------------------------------------------------------------------------------- 1 | %TF.GenerationSoftware,KiCad,Pcbnew,8.0.0*% 2 | %TF.CreationDate,2024-11-24T15:26:49+01:00*% 3 | %TF.ProjectId,HHID-v2,48484944-2d76-4322-9e6b-696361645f70,rev?*% 4 | %TF.SameCoordinates,PX89013e0PY67486e0*% 5 | %TF.FileFunction,AssemblyDrawing,Bot*% 6 | %FSLAX46Y46*% 7 | G04 Gerber Fmt 4.6, Leading zero omitted, Abs format (unit mm)* 8 | G04 Created by KiCad (PCBNEW 8.0.0) date 2024-11-24 15:26:49* 9 | %MOMM*% 10 | %LPD*% 11 | G01* 12 | G04 APERTURE LIST* 13 | %ADD10C,0.150000*% 14 | %ADD11C,0.120000*% 15 | %ADD12C,0.075000*% 16 | %ADD13C,0.040000*% 17 | %ADD14C,0.100000*% 18 | G04 APERTURE END LIST* 19 | D10* 20 | X1145514Y7291542D02* 21 | X1145514Y7491542D01* 22 | X831228Y7577256D02* 23 | X831228Y7291542D01* 24 | X831228Y7291542D02* 25 | X1431228Y7291542D01* 26 | X1431228Y7291542D02* 27 | X1431228Y7577256D01* 28 | X888371Y4934399D02* 29 | X859800Y4905827D01* 30 | X859800Y4905827D02* 31 | X831228Y4820113D01* 32 | X831228Y4820113D02* 33 | X831228Y4762970D01* 34 | X831228Y4762970D02* 35 | X859800Y4677256D01* 36 | X859800Y4677256D02* 37 | X916942Y4620113D01* 38 | X916942Y4620113D02* 39 | X974085Y4591542D01* 40 | X974085Y4591542D02* 41 | X1088371Y4562970D01* 42 | X1088371Y4562970D02* 43 | X1174085Y4562970D01* 44 | X1174085Y4562970D02* 45 | X1288371Y4591542D01* 46 | X1288371Y4591542D02* 47 | X1345514Y4620113D01* 48 | X1345514Y4620113D02* 49 | X1402657Y4677256D01* 50 | X1402657Y4677256D02* 51 | X1431228Y4762970D01* 52 | X1431228Y4762970D02* 53 | X1431228Y4820113D01* 54 | X1431228Y4820113D02* 55 | X1402657Y4905827D01* 56 | X1402657Y4905827D02* 57 | X1374085Y4934399D01* 58 | D11* 59 | X1226190Y5609955D02* 60 | X1302380Y5648050D01* 61 | X1302380Y5648050D02* 62 | X1378571Y5724240D01* 63 | X1378571Y5724240D02* 64 | X1492857Y5838526D01* 65 | X1492857Y5838526D02* 66 | X1569047Y5876621D01* 67 | X1569047Y5876621D02* 68 | X1645238Y5876621D01* 69 | X1607142Y5686145D02* 70 | X1683333Y5724240D01* 71 | X1683333Y5724240D02* 72 | X1759523Y5800431D01* 73 | X1759523Y5800431D02* 74 | X1797619Y5952812D01* 75 | X1797619Y5952812D02* 76 | X1797619Y6219479D01* 77 | X1797619Y6219479D02* 78 | X1759523Y6371860D01* 79 | X1759523Y6371860D02* 80 | X1683333Y6448050D01* 81 | X1683333Y6448050D02* 82 | X1607142Y6486145D01* 83 | X1607142Y6486145D02* 84 | X1454761Y6486145D01* 85 | X1454761Y6486145D02* 86 | X1378571Y6448050D01* 87 | X1378571Y6448050D02* 88 | X1302380Y6371860D01* 89 | X1302380Y6371860D02* 90 | X1264285Y6219479D01* 91 | X1264285Y6219479D02* 92 | X1264285Y5952812D01* 93 | X1264285Y5952812D02* 94 | X1302380Y5800431D01* 95 | X1302380Y5800431D02* 96 | X1378571Y5724240D01* 97 | X1378571Y5724240D02* 98 | X1454761Y5686145D01* 99 | X1454761Y5686145D02* 100 | X1607142Y5686145D01* 101 | X997619Y6486145D02* 102 | X502381Y6486145D01* 103 | X502381Y6486145D02* 104 | X769047Y6181383D01* 105 | X769047Y6181383D02* 106 | X654762Y6181383D01* 107 | X654762Y6181383D02* 108 | X578571Y6143288D01* 109 | X578571Y6143288D02* 110 | X540476Y6105193D01* 111 | X540476Y6105193D02* 112 | X502381Y6029002D01* 113 | X502381Y6029002D02* 114 | X502381Y5838526D01* 115 | X502381Y5838526D02* 116 | X540476Y5762336D01* 117 | X540476Y5762336D02* 118 | X578571Y5724240D01* 119 | X578571Y5724240D02* 120 | X654762Y5686145D01* 121 | X654762Y5686145D02* 122 | X883333Y5686145D01* 123 | X883333Y5686145D02* 124 | X959524Y5724240D01* 125 | X959524Y5724240D02* 126 | X997619Y5762336D01* 127 | D10* 128 | X1154485Y908459D02* 129 | X1154485Y708459D01* 130 | X1468771Y622745D02* 131 | X1468771Y908459D01* 132 | X1468771Y908459D02* 133 | X868771Y908459D01* 134 | X868771Y908459D02* 135 | X868771Y622745D01* 136 | X1411628Y3265602D02* 137 | X1440200Y3294174D01* 138 | X1440200Y3294174D02* 139 | X1468771Y3379888D01* 140 | X1468771Y3379888D02* 141 | X1468771Y3437031D01* 142 | X1468771Y3437031D02* 143 | X1440200Y3522745D01* 144 | X1440200Y3522745D02* 145 | X1383057Y3579888D01* 146 | X1383057Y3579888D02* 147 | X1325914Y3608459D01* 148 | X1325914Y3608459D02* 149 | X1211628Y3637031D01* 150 | X1211628Y3637031D02* 151 | X1125914Y3637031D01* 152 | X1125914Y3637031D02* 153 | X1011628Y3608459D01* 154 | X1011628Y3608459D02* 155 | X954485Y3579888D01* 156 | X954485Y3579888D02* 157 | X897342Y3522745D01* 158 | X897342Y3522745D02* 159 | X868771Y3437031D01* 160 | X868771Y3437031D02* 161 | X868771Y3379888D01* 162 | X868771Y3379888D02* 163 | X897342Y3294174D01* 164 | X897342Y3294174D02* 165 | X925914Y3265602D01* 166 | D11* 167 | X1251190Y1709955D02* 168 | X1327380Y1748050D01* 169 | X1327380Y1748050D02* 170 | X1403571Y1824240D01* 171 | X1403571Y1824240D02* 172 | X1517857Y1938526D01* 173 | X1517857Y1938526D02* 174 | X1594047Y1976621D01* 175 | X1594047Y1976621D02* 176 | X1670238Y1976621D01* 177 | X1632142Y1786145D02* 178 | X1708333Y1824240D01* 179 | X1708333Y1824240D02* 180 | X1784523Y1900431D01* 181 | X1784523Y1900431D02* 182 | X1822619Y2052812D01* 183 | X1822619Y2052812D02* 184 | X1822619Y2319479D01* 185 | X1822619Y2319479D02* 186 | X1784523Y2471860D01* 187 | X1784523Y2471860D02* 188 | X1708333Y2548050D01* 189 | X1708333Y2548050D02* 190 | X1632142Y2586145D01* 191 | X1632142Y2586145D02* 192 | X1479761Y2586145D01* 193 | X1479761Y2586145D02* 194 | X1403571Y2548050D01* 195 | X1403571Y2548050D02* 196 | X1327380Y2471860D01* 197 | X1327380Y2471860D02* 198 | X1289285Y2319479D01* 199 | X1289285Y2319479D02* 200 | X1289285Y2052812D01* 201 | X1289285Y2052812D02* 202 | X1327380Y1900431D01* 203 | X1327380Y1900431D02* 204 | X1403571Y1824240D01* 205 | X1403571Y1824240D02* 206 | X1479761Y1786145D01* 207 | X1479761Y1786145D02* 208 | X1632142Y1786145D01* 209 | X984524Y2509955D02* 210 | X946428Y2548050D01* 211 | X946428Y2548050D02* 212 | X870238Y2586145D01* 213 | X870238Y2586145D02* 214 | X679762Y2586145D01* 215 | X679762Y2586145D02* 216 | X603571Y2548050D01* 217 | X603571Y2548050D02* 218 | X565476Y2509955D01* 219 | X565476Y2509955D02* 220 | X527381Y2433764D01* 221 | X527381Y2433764D02* 222 | X527381Y2357574D01* 223 | X527381Y2357574D02* 224 | X565476Y2243288D01* 225 | X565476Y2243288D02* 226 | X1022619Y1786145D01* 227 | X1022619Y1786145D02* 228 | X527381Y1786145D01* 229 | D10* 230 | X10954485Y908459D02* 231 | X10954485Y708459D01* 232 | X11268771Y622745D02* 233 | X11268771Y908459D01* 234 | X11268771Y908459D02* 235 | X10668771Y908459D01* 236 | X10668771Y908459D02* 237 | X10668771Y622745D01* 238 | X11211628Y3265602D02* 239 | X11240200Y3294174D01* 240 | X11240200Y3294174D02* 241 | X11268771Y3379888D01* 242 | X11268771Y3379888D02* 243 | X11268771Y3437031D01* 244 | X11268771Y3437031D02* 245 | X11240200Y3522745D01* 246 | X11240200Y3522745D02* 247 | X11183057Y3579888D01* 248 | X11183057Y3579888D02* 249 | X11125914Y3608459D01* 250 | X11125914Y3608459D02* 251 | X11011628Y3637031D01* 252 | X11011628Y3637031D02* 253 | X10925914Y3637031D01* 254 | X10925914Y3637031D02* 255 | X10811628Y3608459D01* 256 | X10811628Y3608459D02* 257 | X10754485Y3579888D01* 258 | X10754485Y3579888D02* 259 | X10697342Y3522745D01* 260 | X10697342Y3522745D02* 261 | X10668771Y3437031D01* 262 | X10668771Y3437031D02* 263 | X10668771Y3379888D01* 264 | X10668771Y3379888D02* 265 | X10697342Y3294174D01* 266 | X10697342Y3294174D02* 267 | X10725914Y3265602D01* 268 | D11* 269 | X11001190Y1684955D02* 270 | X11077380Y1723050D01* 271 | X11077380Y1723050D02* 272 | X11153571Y1799240D01* 273 | X11153571Y1799240D02* 274 | X11267857Y1913526D01* 275 | X11267857Y1913526D02* 276 | X11344047Y1951621D01* 277 | X11344047Y1951621D02* 278 | X11420238Y1951621D01* 279 | X11382142Y1761145D02* 280 | X11458333Y1799240D01* 281 | X11458333Y1799240D02* 282 | X11534523Y1875431D01* 283 | X11534523Y1875431D02* 284 | X11572619Y2027812D01* 285 | X11572619Y2027812D02* 286 | X11572619Y2294479D01* 287 | X11572619Y2294479D02* 288 | X11534523Y2446860D01* 289 | X11534523Y2446860D02* 290 | X11458333Y2523050D01* 291 | X11458333Y2523050D02* 292 | X11382142Y2561145D01* 293 | X11382142Y2561145D02* 294 | X11229761Y2561145D01* 295 | X11229761Y2561145D02* 296 | X11153571Y2523050D01* 297 | X11153571Y2523050D02* 298 | X11077380Y2446860D01* 299 | X11077380Y2446860D02* 300 | X11039285Y2294479D01* 301 | X11039285Y2294479D02* 302 | X11039285Y2027812D01* 303 | X11039285Y2027812D02* 304 | X11077380Y1875431D01* 305 | X11077380Y1875431D02* 306 | X11153571Y1799240D01* 307 | X11153571Y1799240D02* 308 | X11229761Y1761145D01* 309 | X11229761Y1761145D02* 310 | X11382142Y1761145D01* 311 | X10277381Y1761145D02* 312 | X10734524Y1761145D01* 313 | X10505952Y1761145D02* 314 | X10505952Y2561145D01* 315 | X10505952Y2561145D02* 316 | X10582143Y2446860D01* 317 | X10582143Y2446860D02* 318 | X10658333Y2370669D01* 319 | X10658333Y2370669D02* 320 | X10734524Y2332574D01* 321 | D10* 322 | X10945514Y7291542D02* 323 | X10945514Y7491542D01* 324 | X10631228Y7577256D02* 325 | X10631228Y7291542D01* 326 | X10631228Y7291542D02* 327 | X11231228Y7291542D01* 328 | X11231228Y7291542D02* 329 | X11231228Y7577256D01* 330 | X10688371Y4934399D02* 331 | X10659800Y4905827D01* 332 | X10659800Y4905827D02* 333 | X10631228Y4820113D01* 334 | X10631228Y4820113D02* 335 | X10631228Y4762970D01* 336 | X10631228Y4762970D02* 337 | X10659800Y4677256D01* 338 | X10659800Y4677256D02* 339 | X10716942Y4620113D01* 340 | X10716942Y4620113D02* 341 | X10774085Y4591542D01* 342 | X10774085Y4591542D02* 343 | X10888371Y4562970D01* 344 | X10888371Y4562970D02* 345 | X10974085Y4562970D01* 346 | X10974085Y4562970D02* 347 | X11088371Y4591542D01* 348 | X11088371Y4591542D02* 349 | X11145514Y4620113D01* 350 | X11145514Y4620113D02* 351 | X11202657Y4677256D01* 352 | X11202657Y4677256D02* 353 | X11231228Y4762970D01* 354 | X11231228Y4762970D02* 355 | X11231228Y4820113D01* 356 | X11231228Y4820113D02* 357 | X11202657Y4905827D01* 358 | X11202657Y4905827D02* 359 | X11174085Y4934399D01* 360 | D11* 361 | X11051190Y5509955D02* 362 | X11127380Y5548050D01* 363 | X11127380Y5548050D02* 364 | X11203571Y5624240D01* 365 | X11203571Y5624240D02* 366 | X11317857Y5738526D01* 367 | X11317857Y5738526D02* 368 | X11394047Y5776621D01* 369 | X11394047Y5776621D02* 370 | X11470238Y5776621D01* 371 | X11432142Y5586145D02* 372 | X11508333Y5624240D01* 373 | X11508333Y5624240D02* 374 | X11584523Y5700431D01* 375 | X11584523Y5700431D02* 376 | X11622619Y5852812D01* 377 | X11622619Y5852812D02* 378 | X11622619Y6119479D01* 379 | X11622619Y6119479D02* 380 | X11584523Y6271860D01* 381 | X11584523Y6271860D02* 382 | X11508333Y6348050D01* 383 | X11508333Y6348050D02* 384 | X11432142Y6386145D01* 385 | X11432142Y6386145D02* 386 | X11279761Y6386145D01* 387 | X11279761Y6386145D02* 388 | X11203571Y6348050D01* 389 | X11203571Y6348050D02* 390 | X11127380Y6271860D01* 391 | X11127380Y6271860D02* 392 | X11089285Y6119479D01* 393 | X11089285Y6119479D02* 394 | X11089285Y5852812D01* 395 | X11089285Y5852812D02* 396 | X11127380Y5700431D01* 397 | X11127380Y5700431D02* 398 | X11203571Y5624240D01* 399 | X11203571Y5624240D02* 400 | X11279761Y5586145D01* 401 | X11279761Y5586145D02* 402 | X11432142Y5586145D01* 403 | X10403571Y6119479D02* 404 | X10403571Y5586145D01* 405 | X10594047Y6424240D02* 406 | X10784524Y5852812D01* 407 | X10784524Y5852812D02* 408 | X10289285Y5852812D01* 409 | D12* 410 | X2602409Y5390953D02* 411 | X3007171Y5390953D01* 412 | X3007171Y5390953D02* 413 | X3054790Y5367143D01* 414 | X3054790Y5367143D02* 415 | X3078600Y5343334D01* 416 | X3078600Y5343334D02* 417 | X3102409Y5295715D01* 418 | X3102409Y5295715D02* 419 | X3102409Y5200477D01* 420 | X3102409Y5200477D02* 421 | X3078600Y5152858D01* 422 | X3078600Y5152858D02* 423 | X3054790Y5129048D01* 424 | X3054790Y5129048D02* 425 | X3007171Y5105239D01* 426 | X3007171Y5105239D02* 427 | X2602409Y5105239D01* 428 | X2650028Y4890952D02* 429 | X2626219Y4867143D01* 430 | X2626219Y4867143D02* 431 | X2602409Y4819524D01* 432 | X2602409Y4819524D02* 433 | X2602409Y4700476D01* 434 | X2602409Y4700476D02* 435 | X2626219Y4652857D01* 436 | X2626219Y4652857D02* 437 | X2650028Y4629048D01* 438 | X2650028Y4629048D02* 439 | X2697647Y4605238D01* 440 | X2697647Y4605238D02* 441 | X2745266Y4605238D01* 442 | X2745266Y4605238D02* 443 | X2816695Y4629048D01* 444 | X2816695Y4629048D02* 445 | X3102409Y4914762D01* 446 | X3102409Y4914762D02* 447 | X3102409Y4605238D01* 448 | D13* 449 | X3264765Y3261667D02* 450 | X3276670Y3273571D01* 451 | X3276670Y3273571D02* 452 | X3288574Y3309286D01* 453 | X3288574Y3309286D02* 454 | X3288574Y3333095D01* 455 | X3288574Y3333095D02* 456 | X3276670Y3368809D01* 457 | X3276670Y3368809D02* 458 | X3252860Y3392619D01* 459 | X3252860Y3392619D02* 460 | X3229050Y3404524D01* 461 | X3229050Y3404524D02* 462 | X3181431Y3416428D01* 463 | X3181431Y3416428D02* 464 | X3145717Y3416428D01* 465 | X3145717Y3416428D02* 466 | X3098098Y3404524D01* 467 | X3098098Y3404524D02* 468 | X3074289Y3392619D01* 469 | X3074289Y3392619D02* 470 | X3050479Y3368809D01* 471 | X3050479Y3368809D02* 472 | X3038574Y3333095D01* 473 | X3038574Y3333095D02* 474 | X3038574Y3309286D01* 475 | X3038574Y3309286D02* 476 | X3050479Y3273571D01* 477 | X3050479Y3273571D02* 478 | X3062384Y3261667D01* 479 | X3038574Y3178333D02* 480 | X3038574Y3023571D01* 481 | X3038574Y3023571D02* 482 | X3133812Y3106905D01* 483 | X3133812Y3106905D02* 484 | X3133812Y3071190D01* 485 | X3133812Y3071190D02* 486 | X3145717Y3047381D01* 487 | X3145717Y3047381D02* 488 | X3157622Y3035476D01* 489 | X3157622Y3035476D02* 490 | X3181431Y3023571D01* 491 | X3181431Y3023571D02* 492 | X3240955Y3023571D01* 493 | X3240955Y3023571D02* 494 | X3264765Y3035476D01* 495 | X3264765Y3035476D02* 496 | X3276670Y3047381D01* 497 | X3276670Y3047381D02* 498 | X3288574Y3071190D01* 499 | X3288574Y3071190D02* 500 | X3288574Y3142619D01* 501 | X3288574Y3142619D02* 502 | X3276670Y3166428D01* 503 | X3276670Y3166428D02* 504 | X3264765Y3178333D01* 505 | D10* 506 | X7031304Y5384915D02* 507 | X7031304Y4575392D01* 508 | X7031304Y4575392D02* 509 | X6983685Y4480154D01* 510 | X6983685Y4480154D02* 511 | X6936066Y4432534D01* 512 | X6936066Y4432534D02* 513 | X6840828Y4384915D01* 514 | X6840828Y4384915D02* 515 | X6650352Y4384915D01* 516 | X6650352Y4384915D02* 517 | X6555114Y4432534D01* 518 | X6555114Y4432534D02* 519 | X6507495Y4480154D01* 520 | X6507495Y4480154D02* 521 | X6459876Y4575392D01* 522 | X6459876Y4575392D02* 523 | X6459876Y5384915D01* 524 | X6078923Y5384915D02* 525 | X5459876Y5384915D01* 526 | X5459876Y5384915D02* 527 | X5793209Y5003963D01* 528 | X5793209Y5003963D02* 529 | X5650352Y5003963D01* 530 | X5650352Y5003963D02* 531 | X5555114Y4956344D01* 532 | X5555114Y4956344D02* 533 | X5507495Y4908725D01* 534 | X5507495Y4908725D02* 535 | X5459876Y4813487D01* 536 | X5459876Y4813487D02* 537 | X5459876Y4575392D01* 538 | X5459876Y4575392D02* 539 | X5507495Y4480154D01* 540 | X5507495Y4480154D02* 541 | X5555114Y4432534D01* 542 | X5555114Y4432534D02* 543 | X5650352Y4384915D01* 544 | X5650352Y4384915D02* 545 | X5936066Y4384915D01* 546 | X5936066Y4384915D02* 547 | X6031304Y4432534D01* 548 | X6031304Y4432534D02* 549 | X6078923Y4480154D01* 550 | D13* 551 | X3264765Y6846667D02* 552 | X3276670Y6858571D01* 553 | X3276670Y6858571D02* 554 | X3288574Y6894286D01* 555 | X3288574Y6894286D02* 556 | X3288574Y6918095D01* 557 | X3288574Y6918095D02* 558 | X3276670Y6953809D01* 559 | X3276670Y6953809D02* 560 | X3252860Y6977619D01* 561 | X3252860Y6977619D02* 562 | X3229050Y6989524D01* 563 | X3229050Y6989524D02* 564 | X3181431Y7001428D01* 565 | X3181431Y7001428D02* 566 | X3145717Y7001428D01* 567 | X3145717Y7001428D02* 568 | X3098098Y6989524D01* 569 | X3098098Y6989524D02* 570 | X3074289Y6977619D01* 571 | X3074289Y6977619D02* 572 | X3050479Y6953809D01* 573 | X3050479Y6953809D02* 574 | X3038574Y6918095D01* 575 | X3038574Y6918095D02* 576 | X3038574Y6894286D01* 577 | X3038574Y6894286D02* 578 | X3050479Y6858571D01* 579 | X3050479Y6858571D02* 580 | X3062384Y6846667D01* 581 | X3062384Y6751428D02* 582 | X3050479Y6739524D01* 583 | X3050479Y6739524D02* 584 | X3038574Y6715714D01* 585 | X3038574Y6715714D02* 586 | X3038574Y6656190D01* 587 | X3038574Y6656190D02* 588 | X3050479Y6632381D01* 589 | X3050479Y6632381D02* 590 | X3062384Y6620476D01* 591 | X3062384Y6620476D02* 592 | X3086193Y6608571D01* 593 | X3086193Y6608571D02* 594 | X3110003Y6608571D01* 595 | X3110003Y6608571D02* 596 | X3145717Y6620476D01* 597 | X3145717Y6620476D02* 598 | X3288574Y6763333D01* 599 | X3288574Y6763333D02* 600 | X3288574Y6608571D01* 601 | X9493200Y3263333D02* 602 | X9369391Y3350000D01* 603 | X9493200Y3411905D02* 604 | X9233200Y3411905D01* 605 | X9233200Y3411905D02* 606 | X9233200Y3312857D01* 607 | X9233200Y3312857D02* 608 | X9245581Y3288095D01* 609 | X9245581Y3288095D02* 610 | X9257962Y3275714D01* 611 | X9257962Y3275714D02* 612 | X9282724Y3263333D01* 613 | X9282724Y3263333D02* 614 | X9319867Y3263333D01* 615 | X9319867Y3263333D02* 616 | X9344629Y3275714D01* 617 | X9344629Y3275714D02* 618 | X9357010Y3288095D01* 619 | X9357010Y3288095D02* 620 | X9369391Y3312857D01* 621 | X9369391Y3312857D02* 622 | X9369391Y3411905D01* 623 | X9257962Y3164286D02* 624 | X9245581Y3151905D01* 625 | X9245581Y3151905D02* 626 | X9233200Y3127143D01* 627 | X9233200Y3127143D02* 628 | X9233200Y3065238D01* 629 | X9233200Y3065238D02* 630 | X9245581Y3040476D01* 631 | X9245581Y3040476D02* 632 | X9257962Y3028095D01* 633 | X9257962Y3028095D02* 634 | X9282724Y3015714D01* 635 | X9282724Y3015714D02* 636 | X9307486Y3015714D01* 637 | X9307486Y3015714D02* 638 | X9344629Y3028095D01* 639 | X9344629Y3028095D02* 640 | X9493200Y3176667D01* 641 | X9493200Y3176667D02* 642 | X9493200Y3015714D01* 643 | X9464765Y5116667D02* 644 | X9476670Y5128571D01* 645 | X9476670Y5128571D02* 646 | X9488574Y5164286D01* 647 | X9488574Y5164286D02* 648 | X9488574Y5188095D01* 649 | X9488574Y5188095D02* 650 | X9476670Y5223809D01* 651 | X9476670Y5223809D02* 652 | X9452860Y5247619D01* 653 | X9452860Y5247619D02* 654 | X9429050Y5259524D01* 655 | X9429050Y5259524D02* 656 | X9381431Y5271428D01* 657 | X9381431Y5271428D02* 658 | X9345717Y5271428D01* 659 | X9345717Y5271428D02* 660 | X9298098Y5259524D01* 661 | X9298098Y5259524D02* 662 | X9274289Y5247619D01* 663 | X9274289Y5247619D02* 664 | X9250479Y5223809D01* 665 | X9250479Y5223809D02* 666 | X9238574Y5188095D01* 667 | X9238574Y5188095D02* 668 | X9238574Y5164286D01* 669 | X9238574Y5164286D02* 670 | X9250479Y5128571D01* 671 | X9250479Y5128571D02* 672 | X9262384Y5116667D01* 673 | X9488574Y4878571D02* 674 | X9488574Y5021428D01* 675 | X9488574Y4950000D02* 676 | X9238574Y4950000D01* 677 | X9238574Y4950000D02* 678 | X9274289Y4973809D01* 679 | X9274289Y4973809D02* 680 | X9298098Y4997619D01* 681 | X9298098Y4997619D02* 682 | X9310003Y5021428D01* 683 | D14* 684 | %TO.C,Q3*% 685 | X350000Y4250000D02* 686 | X1950000Y4250000D01* 687 | X350000Y7850000D02* 688 | X350000Y4250000D01* 689 | X1950000Y4250000D02* 690 | X1950000Y7450000D01* 691 | X1550000Y7850000D02* 692 | X1950000Y7450000D01* 693 | X1550000Y7850000D02* 694 | X350000Y7850000D01* 695 | %TO.C,Q2*% 696 | X1950000Y3950000D02* 697 | X350000Y3950000D01* 698 | X1950000Y350000D02* 699 | X1950000Y3950000D01* 700 | X350000Y3950000D02* 701 | X350000Y750000D01* 702 | X750000Y350000D02* 703 | X350000Y750000D01* 704 | X750000Y350000D02* 705 | X1950000Y350000D01* 706 | %TO.C,Q1*% 707 | X11750000Y3950000D02* 708 | X10150000Y3950000D01* 709 | X11750000Y350000D02* 710 | X11750000Y3950000D01* 711 | X10150000Y3950000D02* 712 | X10150000Y750000D01* 713 | X10550000Y350000D02* 714 | X10150000Y750000D01* 715 | X10550000Y350000D02* 716 | X11750000Y350000D01* 717 | %TO.C,Q4*% 718 | X10150000Y4250000D02* 719 | X11750000Y4250000D01* 720 | X10150000Y7850000D02* 721 | X10150000Y4250000D01* 722 | X11750000Y4250000D02* 723 | X11750000Y7450000D01* 724 | X11350000Y7850000D02* 725 | X11750000Y7450000D01* 726 | X11350000Y7850000D02* 727 | X10150000Y7850000D01* 728 | %TO.C,U2*% 729 | X2400000Y5525000D02* 730 | X3400000Y5525000D01* 731 | X2400000Y4525000D02* 732 | X2400000Y5525000D01* 733 | X3150000Y4525000D02* 734 | X2400000Y4525000D01* 735 | X3400000Y5525000D02* 736 | X3400000Y4775000D01* 737 | X3400000Y4775000D02* 738 | X3150000Y4525000D01* 739 | %TO.C,C3*% 740 | X2925000Y3720000D02* 741 | X3425000Y3720000D01* 742 | X2925000Y2720000D02* 743 | X2925000Y3720000D01* 744 | X3425000Y3720000D02* 745 | X3425000Y2720000D01* 746 | X3425000Y2720000D02* 747 | X2925000Y2720000D01* 748 | %TO.C,U3*% 749 | X4269400Y6839734D02* 750 | X8269400Y6839734D01* 751 | X4269400Y3839734D02* 752 | X4269400Y6839734D01* 753 | X5269400Y2839734D02* 754 | X4269400Y3839734D01* 755 | X8269400Y6839734D02* 756 | X8269400Y2839734D01* 757 | X8269400Y2839734D02* 758 | X5269400Y2839734D01* 759 | %TO.C,C2*% 760 | X2925000Y7305000D02* 761 | X3425000Y7305000D01* 762 | X2925000Y6305000D02* 763 | X2925000Y7305000D01* 764 | X3425000Y7305000D02* 765 | X3425000Y6305000D01* 766 | X3425000Y6305000D02* 767 | X2925000Y6305000D01* 768 | %TO.C,R2*% 769 | X9105000Y3745000D02* 770 | X9645000Y3745000D01* 771 | X9105000Y2695000D02* 772 | X9105000Y3745000D01* 773 | X9645000Y3745000D02* 774 | X9645000Y2695000D01* 775 | X9645000Y2695000D02* 776 | X9105000Y2695000D01* 777 | %TO.C,C1*% 778 | X9125000Y5575000D02* 779 | X9625000Y5575000D01* 780 | X9125000Y4575000D02* 781 | X9125000Y5575000D01* 782 | X9625000Y5575000D02* 783 | X9625000Y4575000D01* 784 | X9625000Y4575000D02* 785 | X9125000Y4575000D01* 786 | %TD*% 787 | M02* 788 | -------------------------------------------------------------------------------- /Fabrication/gerber/HHID-v2-B_Mask.gbr: -------------------------------------------------------------------------------- 1 | %TF.GenerationSoftware,KiCad,Pcbnew,8.0.0*% 2 | %TF.CreationDate,2024-11-24T15:26:49+01:00*% 3 | %TF.ProjectId,HHID-v2,48484944-2d76-4322-9e6b-696361645f70,rev?*% 4 | %TF.SameCoordinates,PX89013e0PY67486e0*% 5 | %TF.FileFunction,Soldermask,Bot*% 6 | %TF.FilePolarity,Negative*% 7 | %FSLAX46Y46*% 8 | G04 Gerber Fmt 4.6, Leading zero omitted, Abs format (unit mm)* 9 | G04 Created by KiCad (PCBNEW 8.0.0) date 2024-11-24 15:26:49* 10 | %MOMM*% 11 | %LPD*% 12 | G01* 13 | G04 APERTURE LIST* 14 | G04 Aperture macros list* 15 | %AMRoundRect* 16 | 0 Rectangle with rounded corners* 17 | 0 $1 Rounding radius* 18 | 0 $2 $3 $4 $5 $6 $7 $8 $9 X,Y pos of 4 corners* 19 | 0 Add a 4 corners polygon primitive as box body* 20 | 4,1,4,$2,$3,$4,$5,$6,$7,$8,$9,$2,$3,0* 21 | 0 Add four circle primitives for the rounded corners* 22 | 1,1,$1+$1,$2,$3* 23 | 1,1,$1+$1,$4,$5* 24 | 1,1,$1+$1,$6,$7* 25 | 1,1,$1+$1,$8,$9* 26 | 0 Add four rect primitives between the rounded corners* 27 | 20,1,$1+$1,$2,$3,$4,$5,0* 28 | 20,1,$1+$1,$4,$5,$6,$7,0* 29 | 20,1,$1+$1,$6,$7,$8,$9,0* 30 | 20,1,$1+$1,$8,$9,$2,$3,0*% 31 | %AMRotRect* 32 | 0 Rectangle, with rotation* 33 | 0 The origin of the aperture is its center* 34 | 0 $1 length* 35 | 0 $2 width* 36 | 0 $3 Rotation angle, in degrees counterclockwise* 37 | 0 Add horizontal line* 38 | 21,1,$1,$2,0,0,$3*% 39 | %AMFreePoly0* 40 | 4,1,6,0.130000,-0.115000,-0.020000,-0.275000,-0.130000,-0.275000,-0.130000,0.115000,0.130000,0.115000,0.130000,-0.115000,0.130000,-0.115000,$1*% 41 | %AMFreePoly1* 42 | 4,1,6,0.130000,-0.275000,0.020000,-0.275000,-0.130000,-0.115000,-0.130000,0.115000,0.130000,0.115000,0.130000,-0.275000,0.130000,-0.275000,$1*% 43 | %AMFreePoly2* 44 | 4,1,14,0.364320,0.111820,0.377500,0.080000,0.377500,0.053640,0.364320,0.021820,0.230680,-0.111820,0.198860,-0.125000,-0.332500,-0.125000,-0.364320,-0.111820,-0.377500,-0.080000,-0.377500,0.080000,-0.364320,0.111820,-0.332500,0.125000,0.332500,0.125000,0.364320,0.111820,0.364320,0.111820,$1*% 45 | %AMFreePoly3* 46 | 4,1,14,0.230680,0.111820,0.364320,-0.021820,0.377500,-0.053640,0.377500,-0.080000,0.364320,-0.111820,0.332500,-0.125000,-0.332500,-0.125000,-0.364320,-0.111820,-0.377500,-0.080000,-0.377500,0.080000,-0.364320,0.111820,-0.332500,0.125000,0.198860,0.125000,0.230680,0.111820,0.230680,0.111820,$1*% 47 | %AMFreePoly4* 48 | 4,1,14,0.111820,0.364320,0.125000,0.332500,0.125000,-0.332500,0.111820,-0.364320,0.080000,-0.377500,0.053640,-0.377500,0.021820,-0.364320,-0.111820,-0.230680,-0.125000,-0.198860,-0.125000,0.332500,-0.111820,0.364320,-0.080000,0.377500,0.080000,0.377500,0.111820,0.364320,0.111820,0.364320,$1*% 49 | %AMFreePoly5* 50 | 4,1,14,0.111820,0.364320,0.125000,0.332500,0.125000,-0.198860,0.111820,-0.230680,-0.021820,-0.364320,-0.053640,-0.377500,-0.080000,-0.377500,-0.111820,-0.364320,-0.125000,-0.332500,-0.125000,0.332500,-0.111820,0.364320,-0.080000,0.377500,0.080000,0.377500,0.111820,0.364320,0.111820,0.364320,$1*% 51 | %AMFreePoly6* 52 | 4,1,14,0.364320,0.111820,0.377500,0.080000,0.377500,-0.080000,0.364320,-0.111820,0.332500,-0.125000,-0.332500,-0.125000,-0.364320,-0.111820,-0.377500,-0.080000,-0.377500,-0.053640,-0.364320,-0.021820,-0.230680,0.111820,-0.198860,0.125000,0.332500,0.125000,0.364320,0.111820,0.364320,0.111820,$1*% 53 | %AMFreePoly7* 54 | 4,1,14,0.364320,0.111820,0.377500,0.080000,0.377500,-0.080000,0.364320,-0.111820,0.332500,-0.125000,-0.198860,-0.125000,-0.230680,-0.111820,-0.364320,0.021820,-0.377500,0.053640,-0.377500,0.080000,-0.364320,0.111820,-0.332500,0.125000,0.332500,0.125000,0.364320,0.111820,0.364320,0.111820,$1*% 55 | %AMFreePoly8* 56 | 4,1,14,-0.021820,0.364320,0.111820,0.230680,0.125000,0.198860,0.125000,-0.332500,0.111820,-0.364320,0.080000,-0.377500,-0.080000,-0.377500,-0.111820,-0.364320,-0.125000,-0.332500,-0.125000,0.332500,-0.111820,0.364320,-0.080000,0.377500,-0.053640,0.377500,-0.021820,0.364320,-0.021820,0.364320,$1*% 57 | %AMFreePoly9* 58 | 4,1,14,0.111820,0.364320,0.125000,0.332500,0.125000,-0.332500,0.111820,-0.364320,0.080000,-0.377500,-0.080000,-0.377500,-0.111820,-0.364320,-0.125000,-0.332500,-0.125000,0.198860,-0.111820,0.230680,0.021820,0.364320,0.053640,0.377500,0.080000,0.377500,0.111820,0.364320,0.111820,0.364320,$1*% 59 | G04 Aperture macros list end* 60 | %ADD10RoundRect,0.200000X0.675000X-0.300000X0.675000X0.300000X-0.675000X0.300000X-0.675000X-0.300000X0*% 61 | %ADD11RoundRect,0.200000X-0.675000X0.300000X-0.675000X-0.300000X0.675000X-0.300000X0.675000X0.300000X0*% 62 | %ADD12C,1.000000*% 63 | %ADD13FreePoly0,180.000000*% 64 | %ADD14FreePoly1,180.000000*% 65 | %ADD15FreePoly0,0.000000*% 66 | %ADD16FreePoly1,0.000000*% 67 | %ADD17RotRect,0.520000X0.520000X315.000000*% 68 | %ADD18RoundRect,0.140000X0.170000X-0.140000X0.170000X0.140000X-0.170000X0.140000X-0.170000X-0.140000X0*% 69 | %ADD19FreePoly2,0.000000*% 70 | %ADD20RoundRect,0.062500X-0.375000X-0.062500X0.375000X-0.062500X0.375000X0.062500X-0.375000X0.062500X0*% 71 | %ADD21FreePoly3,0.000000*% 72 | %ADD22FreePoly4,0.000000*% 73 | %ADD23RoundRect,0.062500X-0.062500X-0.375000X0.062500X-0.375000X0.062500X0.375000X-0.062500X0.375000X0*% 74 | %ADD24FreePoly5,0.000000*% 75 | %ADD25FreePoly6,0.000000*% 76 | %ADD26FreePoly7,0.000000*% 77 | %ADD27FreePoly8,0.000000*% 78 | %ADD28FreePoly9,0.000000*% 79 | %ADD29RoundRect,0.135000X-0.185000X0.135000X-0.185000X-0.135000X0.185000X-0.135000X0.185000X0.135000X0*% 80 | %ADD30RoundRect,0.140000X-0.170000X0.140000X-0.170000X-0.140000X0.170000X-0.140000X0.170000X0.140000X0*% 81 | G04 APERTURE END LIST* 82 | D10* 83 | %TO.C,Q3*% 84 | X1150000Y4700000D03* 85 | X1150000Y7400000D03* 86 | %TD*% 87 | D11* 88 | %TO.C,Q2*% 89 | X1150000Y3500000D03* 90 | X1150000Y800000D03* 91 | %TD*% 92 | %TO.C,Q1*% 93 | X10950000Y3500000D03* 94 | X10950000Y800000D03* 95 | %TD*% 96 | D10* 97 | %TO.C,Q4*% 98 | X10950000Y4700000D03* 99 | X10950000Y7400000D03* 100 | %TD*% 101 | D12* 102 | %TO.C,TP1*% 103 | X6050000Y1200000D03* 104 | %TD*% 105 | D13* 106 | %TO.C,U2*% 107 | X3225000Y4540000D03* 108 | D14* 109 | X2575000Y4540000D03* 110 | D15* 111 | X2575000Y5510000D03* 112 | D16* 113 | X3225000Y5510000D03* 114 | D17* 115 | X2900000Y5025000D03* 116 | %TD*% 117 | D18* 118 | %TO.C,C3*% 119 | X3175000Y2740000D03* 120 | X3175000Y3700000D03* 121 | %TD*% 122 | D19* 123 | %TO.C,U3*% 124 | X4271900Y3339734D03* 125 | D20* 126 | X4331900Y3839734D03* 127 | X4331900Y4339734D03* 128 | X4331900Y4839734D03* 129 | X4331900Y5339734D03* 130 | X4331900Y5839734D03* 131 | D21* 132 | X4271900Y6339734D03* 133 | D22* 134 | X4769400Y6837234D03* 135 | D23* 136 | X5269400Y6777234D03* 137 | X5769400Y6777234D03* 138 | X6269400Y6777234D03* 139 | X6769400Y6777234D03* 140 | X7269400Y6777234D03* 141 | D24* 142 | X7769400Y6837234D03* 143 | D25* 144 | X8266900Y6339734D03* 145 | D20* 146 | X8206900Y5839734D03* 147 | X8206900Y5339734D03* 148 | X8206900Y4839734D03* 149 | X8206900Y4339734D03* 150 | X8206900Y3839734D03* 151 | D26* 152 | X8266900Y3339734D03* 153 | D27* 154 | X7769400Y2842234D03* 155 | D23* 156 | X7269400Y2902234D03* 157 | X6769400Y2902234D03* 158 | X6269400Y2902234D03* 159 | X5769400Y2902234D03* 160 | X5269400Y2902234D03* 161 | D28* 162 | X4769400Y2842234D03* 163 | %TD*% 164 | D18* 165 | %TO.C,C2*% 166 | X3175000Y6325000D03* 167 | X3175000Y7285000D03* 168 | %TD*% 169 | D29* 170 | %TO.C,R2*% 171 | X9375000Y3730000D03* 172 | X9375000Y2710000D03* 173 | %TD*% 174 | D12* 175 | %TO.C,TP2*% 176 | X3310000Y1200000D03* 177 | %TD*% 178 | D30* 179 | %TO.C,C1*% 180 | X9375000Y5555000D03* 181 | X9375000Y4595000D03* 182 | %TD*% 183 | D12* 184 | %TO.C,TP3*% 185 | X8790000Y1200000D03* 186 | %TD*% 187 | M02* 188 | -------------------------------------------------------------------------------- /Fabrication/gerber/HHID-v2-B_Paste.gbr: -------------------------------------------------------------------------------- 1 | %TF.GenerationSoftware,KiCad,Pcbnew,8.0.0*% 2 | %TF.CreationDate,2024-11-24T15:26:49+01:00*% 3 | %TF.ProjectId,HHID-v2,48484944-2d76-4322-9e6b-696361645f70,rev?*% 4 | %TF.SameCoordinates,PX89013e0PY67486e0*% 5 | %TF.FileFunction,Paste,Bot*% 6 | %TF.FilePolarity,Positive*% 7 | %FSLAX46Y46*% 8 | G04 Gerber Fmt 4.6, Leading zero omitted, Abs format (unit mm)* 9 | G04 Created by KiCad (PCBNEW 8.0.0) date 2024-11-24 15:26:49* 10 | %MOMM*% 11 | %LPD*% 12 | G01* 13 | G04 APERTURE LIST* 14 | G04 Aperture macros list* 15 | %AMRoundRect* 16 | 0 Rectangle with rounded corners* 17 | 0 $1 Rounding radius* 18 | 0 $2 $3 $4 $5 $6 $7 $8 $9 X,Y pos of 4 corners* 19 | 0 Add a 4 corners polygon primitive as box body* 20 | 4,1,4,$2,$3,$4,$5,$6,$7,$8,$9,$2,$3,0* 21 | 0 Add four circle primitives for the rounded corners* 22 | 1,1,$1+$1,$2,$3* 23 | 1,1,$1+$1,$4,$5* 24 | 1,1,$1+$1,$6,$7* 25 | 1,1,$1+$1,$8,$9* 26 | 0 Add four rect primitives between the rounded corners* 27 | 20,1,$1+$1,$2,$3,$4,$5,0* 28 | 20,1,$1+$1,$4,$5,$6,$7,0* 29 | 20,1,$1+$1,$6,$7,$8,$9,0* 30 | 20,1,$1+$1,$8,$9,$2,$3,0*% 31 | %AMRotRect* 32 | 0 Rectangle, with rotation* 33 | 0 The origin of the aperture is its center* 34 | 0 $1 length* 35 | 0 $2 width* 36 | 0 $3 Rotation angle, in degrees counterclockwise* 37 | 0 Add horizontal line* 38 | 21,1,$1,$2,0,0,$3*% 39 | %AMFreePoly0* 40 | 4,1,6,0.130000,-0.115000,-0.020000,-0.275000,-0.130000,-0.275000,-0.130000,0.115000,0.130000,0.115000,0.130000,-0.115000,0.130000,-0.115000,$1*% 41 | %AMFreePoly1* 42 | 4,1,6,0.130000,-0.275000,0.020000,-0.275000,-0.130000,-0.115000,-0.130000,0.115000,0.130000,0.115000,0.130000,-0.275000,0.130000,-0.275000,$1*% 43 | %AMFreePoly2* 44 | 4,1,14,0.364320,0.111820,0.377500,0.080000,0.377500,0.053640,0.364320,0.021820,0.230680,-0.111820,0.198860,-0.125000,-0.332500,-0.125000,-0.364320,-0.111820,-0.377500,-0.080000,-0.377500,0.080000,-0.364320,0.111820,-0.332500,0.125000,0.332500,0.125000,0.364320,0.111820,0.364320,0.111820,$1*% 45 | %AMFreePoly3* 46 | 4,1,14,0.230680,0.111820,0.364320,-0.021820,0.377500,-0.053640,0.377500,-0.080000,0.364320,-0.111820,0.332500,-0.125000,-0.332500,-0.125000,-0.364320,-0.111820,-0.377500,-0.080000,-0.377500,0.080000,-0.364320,0.111820,-0.332500,0.125000,0.198860,0.125000,0.230680,0.111820,0.230680,0.111820,$1*% 47 | %AMFreePoly4* 48 | 4,1,14,0.111820,0.364320,0.125000,0.332500,0.125000,-0.332500,0.111820,-0.364320,0.080000,-0.377500,0.053640,-0.377500,0.021820,-0.364320,-0.111820,-0.230680,-0.125000,-0.198860,-0.125000,0.332500,-0.111820,0.364320,-0.080000,0.377500,0.080000,0.377500,0.111820,0.364320,0.111820,0.364320,$1*% 49 | %AMFreePoly5* 50 | 4,1,14,0.111820,0.364320,0.125000,0.332500,0.125000,-0.198860,0.111820,-0.230680,-0.021820,-0.364320,-0.053640,-0.377500,-0.080000,-0.377500,-0.111820,-0.364320,-0.125000,-0.332500,-0.125000,0.332500,-0.111820,0.364320,-0.080000,0.377500,0.080000,0.377500,0.111820,0.364320,0.111820,0.364320,$1*% 51 | %AMFreePoly6* 52 | 4,1,14,0.364320,0.111820,0.377500,0.080000,0.377500,-0.080000,0.364320,-0.111820,0.332500,-0.125000,-0.332500,-0.125000,-0.364320,-0.111820,-0.377500,-0.080000,-0.377500,-0.053640,-0.364320,-0.021820,-0.230680,0.111820,-0.198860,0.125000,0.332500,0.125000,0.364320,0.111820,0.364320,0.111820,$1*% 53 | %AMFreePoly7* 54 | 4,1,14,0.364320,0.111820,0.377500,0.080000,0.377500,-0.080000,0.364320,-0.111820,0.332500,-0.125000,-0.198860,-0.125000,-0.230680,-0.111820,-0.364320,0.021820,-0.377500,0.053640,-0.377500,0.080000,-0.364320,0.111820,-0.332500,0.125000,0.332500,0.125000,0.364320,0.111820,0.364320,0.111820,$1*% 55 | %AMFreePoly8* 56 | 4,1,14,-0.021820,0.364320,0.111820,0.230680,0.125000,0.198860,0.125000,-0.332500,0.111820,-0.364320,0.080000,-0.377500,-0.080000,-0.377500,-0.111820,-0.364320,-0.125000,-0.332500,-0.125000,0.332500,-0.111820,0.364320,-0.080000,0.377500,-0.053640,0.377500,-0.021820,0.364320,-0.021820,0.364320,$1*% 57 | %AMFreePoly9* 58 | 4,1,14,0.111820,0.364320,0.125000,0.332500,0.125000,-0.332500,0.111820,-0.364320,0.080000,-0.377500,-0.080000,-0.377500,-0.111820,-0.364320,-0.125000,-0.332500,-0.125000,0.198860,-0.111820,0.230680,0.021820,0.364320,0.053640,0.377500,0.080000,0.377500,0.111820,0.364320,0.111820,0.364320,$1*% 59 | G04 Aperture macros list end* 60 | %ADD10RoundRect,0.200000X0.675000X-0.300000X0.675000X0.300000X-0.675000X0.300000X-0.675000X-0.300000X0*% 61 | %ADD11RoundRect,0.200000X-0.675000X0.300000X-0.675000X-0.300000X0.675000X-0.300000X0.675000X0.300000X0*% 62 | %ADD12FreePoly0,180.000000*% 63 | %ADD13FreePoly1,180.000000*% 64 | %ADD14FreePoly0,0.000000*% 65 | %ADD15FreePoly1,0.000000*% 66 | %ADD16RotRect,0.520000X0.520000X315.000000*% 67 | %ADD17RoundRect,0.140000X0.170000X-0.140000X0.170000X0.140000X-0.170000X0.140000X-0.170000X-0.140000X0*% 68 | %ADD18FreePoly2,0.000000*% 69 | %ADD19RoundRect,0.062500X-0.375000X-0.062500X0.375000X-0.062500X0.375000X0.062500X-0.375000X0.062500X0*% 70 | %ADD20FreePoly3,0.000000*% 71 | %ADD21FreePoly4,0.000000*% 72 | %ADD22RoundRect,0.062500X-0.062500X-0.375000X0.062500X-0.375000X0.062500X0.375000X-0.062500X0.375000X0*% 73 | %ADD23FreePoly5,0.000000*% 74 | %ADD24FreePoly6,0.000000*% 75 | %ADD25FreePoly7,0.000000*% 76 | %ADD26FreePoly8,0.000000*% 77 | %ADD27FreePoly9,0.000000*% 78 | %ADD28RoundRect,0.135000X-0.185000X0.135000X-0.185000X-0.135000X0.185000X-0.135000X0.185000X0.135000X0*% 79 | %ADD29RoundRect,0.140000X-0.170000X0.140000X-0.170000X-0.140000X0.170000X-0.140000X0.170000X0.140000X0*% 80 | G04 APERTURE END LIST* 81 | D10* 82 | %TO.C,Q3*% 83 | X1150000Y4700000D03* 84 | X1150000Y7400000D03* 85 | %TD*% 86 | D11* 87 | %TO.C,Q2*% 88 | X1150000Y3500000D03* 89 | X1150000Y800000D03* 90 | %TD*% 91 | %TO.C,Q1*% 92 | X10950000Y3500000D03* 93 | X10950000Y800000D03* 94 | %TD*% 95 | D10* 96 | %TO.C,Q4*% 97 | X10950000Y4700000D03* 98 | X10950000Y7400000D03* 99 | %TD*% 100 | D12* 101 | %TO.C,U2*% 102 | X3225000Y4540000D03* 103 | D13* 104 | X2575000Y4540000D03* 105 | D14* 106 | X2575000Y5510000D03* 107 | D15* 108 | X3225000Y5510000D03* 109 | D16* 110 | X2900000Y5025000D03* 111 | %TD*% 112 | D17* 113 | %TO.C,C3*% 114 | X3175000Y2740000D03* 115 | X3175000Y3700000D03* 116 | %TD*% 117 | D18* 118 | %TO.C,U3*% 119 | X4271900Y3339734D03* 120 | D19* 121 | X4331900Y3839734D03* 122 | X4331900Y4339734D03* 123 | X4331900Y4839734D03* 124 | X4331900Y5339734D03* 125 | X4331900Y5839734D03* 126 | D20* 127 | X4271900Y6339734D03* 128 | D21* 129 | X4769400Y6837234D03* 130 | D22* 131 | X5269400Y6777234D03* 132 | X5769400Y6777234D03* 133 | X6269400Y6777234D03* 134 | X6769400Y6777234D03* 135 | X7269400Y6777234D03* 136 | D23* 137 | X7769400Y6837234D03* 138 | D24* 139 | X8266900Y6339734D03* 140 | D19* 141 | X8206900Y5839734D03* 142 | X8206900Y5339734D03* 143 | X8206900Y4839734D03* 144 | X8206900Y4339734D03* 145 | X8206900Y3839734D03* 146 | D25* 147 | X8266900Y3339734D03* 148 | D26* 149 | X7769400Y2842234D03* 150 | D22* 151 | X7269400Y2902234D03* 152 | X6769400Y2902234D03* 153 | X6269400Y2902234D03* 154 | X5769400Y2902234D03* 155 | X5269400Y2902234D03* 156 | D27* 157 | X4769400Y2842234D03* 158 | %TD*% 159 | D17* 160 | %TO.C,C2*% 161 | X3175000Y6325000D03* 162 | X3175000Y7285000D03* 163 | %TD*% 164 | D28* 165 | %TO.C,R2*% 166 | X9375000Y3730000D03* 167 | X9375000Y2710000D03* 168 | %TD*% 169 | D29* 170 | %TO.C,C1*% 171 | X9375000Y5555000D03* 172 | X9375000Y4595000D03* 173 | %TD*% 174 | M02* 175 | -------------------------------------------------------------------------------- /Fabrication/gerber/HHID-v2-Edge_Cuts.gbr: -------------------------------------------------------------------------------- 1 | %TF.GenerationSoftware,KiCad,Pcbnew,8.0.0*% 2 | %TF.CreationDate,2024-11-24T15:26:49+01:00*% 3 | %TF.ProjectId,HHID-v2,48484944-2d76-4322-9e6b-696361645f70,rev?*% 4 | %TF.SameCoordinates,PX89013e0PY67486e0*% 5 | %TF.FileFunction,Profile,NP*% 6 | %FSLAX46Y46*% 7 | G04 Gerber Fmt 4.6, Leading zero omitted, Abs format (unit mm)* 8 | G04 Created by KiCad (PCBNEW 8.0.0) date 2024-11-24 15:26:49* 9 | %MOMM*% 10 | %LPD*% 11 | G01* 12 | G04 APERTURE LIST* 13 | %TA.AperFunction,Profile*% 14 | %ADD10C,0.050000*% 15 | %TD*% 16 | G04 APERTURE END LIST* 17 | D10* 18 | X12100000Y0D02* 19 | X12100000Y8200000D01* 20 | X0Y0D02* 21 | X12100000Y0D01* 22 | X12100000Y8200000D02* 23 | X0Y8200000D01* 24 | X0Y8200000D02* 25 | X0Y0D01* 26 | M02* 27 | -------------------------------------------------------------------------------- /Fabrication/gerber/HHID-v2-F_Cu.gbr: -------------------------------------------------------------------------------- 1 | %TF.GenerationSoftware,KiCad,Pcbnew,8.0.0*% 2 | %TF.CreationDate,2024-11-24T15:26:49+01:00*% 3 | %TF.ProjectId,HHID-v2,48484944-2d76-4322-9e6b-696361645f70,rev?*% 4 | %TF.SameCoordinates,PX89013e0PY67486e0*% 5 | %TF.FileFunction,Copper,L1,Top*% 6 | %TF.FilePolarity,Positive*% 7 | %FSLAX46Y46*% 8 | G04 Gerber Fmt 4.6, Leading zero omitted, Abs format (unit mm)* 9 | G04 Created by KiCad (PCBNEW 8.0.0) date 2024-11-24 15:26:49* 10 | %MOMM*% 11 | %LPD*% 12 | G01* 13 | G04 APERTURE LIST* 14 | %TA.AperFunction,ConnectorPad*% 15 | %ADD10R,1.900000X6.800000*% 16 | %TD*% 17 | %TA.AperFunction,ConnectorPad*% 18 | %ADD11R,2.000000X6.300000*% 19 | %TD*% 20 | %TA.AperFunction,ViaPad*% 21 | %ADD12C,0.600000*% 22 | %TD*% 23 | %TA.AperFunction,Conductor*% 24 | %ADD13C,0.150000*% 25 | %TD*% 26 | %TA.AperFunction,Conductor*% 27 | %ADD14C,0.250000*% 28 | %TD*% 29 | G04 APERTURE END LIST* 30 | D10* 31 | %TO.P,J1,1,VBUS*% 32 | %TO.N,+5V*% 33 | X2240000Y3900000D03* 34 | D11* 35 | %TO.P,J1,2,D-*% 36 | %TO.N,/DM*% 37 | X4750000Y3650000D03* 38 | %TO.P,J1,3,D+*% 39 | %TO.N,/DP*% 40 | X7350000Y3650000D03* 41 | D10* 42 | %TO.P,J1,4,GND*% 43 | %TO.N,GND*% 44 | X9860000Y3900000D03* 45 | %TD*% 46 | D12* 47 | %TO.N,GND*% 48 | X9425000Y1925000D03* 49 | X9275000Y6300000D03* 50 | %TO.N,+5V*% 51 | X2537500Y6400636D03* 52 | %TO.N,/DP*% 53 | X6735997Y4010449D03* 54 | %TO.N,/DM*% 55 | X5433497Y4558452D03* 56 | %TD*% 57 | D13* 58 | %TO.N,GND*% 59 | X9703106Y3858977D02* 60 | X9703687Y3858396D01* 61 | X9703106Y5698977D02* 62 | X9703106Y3858977D01* 63 | D14* 64 | %TO.N,+5V*% 65 | X2390399Y5391684D02* 66 | X2083106Y5698977D01* 67 | D13* 68 | %TO.N,/DP*% 69 | X7193106Y4968977D02* 70 | X6623106Y4398977D01* 71 | X7193106Y5948977D02* 72 | X7193106Y4968977D01* 73 | %TD*% 74 | M02* 75 | -------------------------------------------------------------------------------- /Fabrication/gerber/HHID-v2-F_Fab.gbr: -------------------------------------------------------------------------------- 1 | %TF.GenerationSoftware,KiCad,Pcbnew,8.0.0*% 2 | %TF.CreationDate,2024-11-24T15:26:49+01:00*% 3 | %TF.ProjectId,HHID-v2,48484944-2d76-4322-9e6b-696361645f70,rev?*% 4 | %TF.SameCoordinates,PX89013e0PY67486e0*% 5 | %TF.FileFunction,AssemblyDrawing,Top*% 6 | %FSLAX46Y46*% 7 | G04 Gerber Fmt 4.6, Leading zero omitted, Abs format (unit mm)* 8 | G04 Created by KiCad (PCBNEW 8.0.0) date 2024-11-24 15:26:49* 9 | %MOMM*% 10 | %LPD*% 11 | G01* 12 | G04 APERTURE LIST* 13 | G04 APERTURE END LIST* 14 | M02* 15 | -------------------------------------------------------------------------------- /Fabrication/gerber/HHID-v2-F_Mask.gbr: -------------------------------------------------------------------------------- 1 | %TF.GenerationSoftware,KiCad,Pcbnew,8.0.0*% 2 | %TF.CreationDate,2024-11-24T15:26:49+01:00*% 3 | %TF.ProjectId,HHID-v2,48484944-2d76-4322-9e6b-696361645f70,rev?*% 4 | %TF.SameCoordinates,PX89013e0PY67486e0*% 5 | %TF.FileFunction,Soldermask,Top*% 6 | %TF.FilePolarity,Negative*% 7 | %FSLAX46Y46*% 8 | G04 Gerber Fmt 4.6, Leading zero omitted, Abs format (unit mm)* 9 | G04 Created by KiCad (PCBNEW 8.0.0) date 2024-11-24 15:26:49* 10 | %MOMM*% 11 | %LPD*% 12 | G01* 13 | G04 APERTURE LIST* 14 | %ADD10R,1.900000X6.800000*% 15 | %ADD11R,2.000000X6.300000*% 16 | G04 APERTURE END LIST* 17 | D10* 18 | %TO.C,J1*% 19 | X2240000Y3900000D03* 20 | D11* 21 | X4750000Y3650000D03* 22 | X7350000Y3650000D03* 23 | D10* 24 | X9860000Y3900000D03* 25 | %TD*% 26 | M02* 27 | -------------------------------------------------------------------------------- /Fabrication/gerber/HHID-v2-F_Paste.gbr: -------------------------------------------------------------------------------- 1 | %TF.GenerationSoftware,KiCad,Pcbnew,8.0.0*% 2 | %TF.CreationDate,2024-11-24T15:26:49+01:00*% 3 | %TF.ProjectId,HHID-v2,48484944-2d76-4322-9e6b-696361645f70,rev?*% 4 | %TF.SameCoordinates,PX89013e0PY67486e0*% 5 | %TF.FileFunction,Paste,Top*% 6 | %TF.FilePolarity,Positive*% 7 | %FSLAX46Y46*% 8 | G04 Gerber Fmt 4.6, Leading zero omitted, Abs format (unit mm)* 9 | G04 Created by KiCad (PCBNEW 8.0.0) date 2024-11-24 15:26:49* 10 | %MOMM*% 11 | %LPD*% 12 | G01* 13 | G04 APERTURE LIST* 14 | G04 APERTURE END LIST* 15 | M02* 16 | -------------------------------------------------------------------------------- /Fabrication/gerber/HHID-v2-NPTH.drl: -------------------------------------------------------------------------------- 1 | M48 2 | ; DRILL file {KiCad 8.0.0} date 2024-11-24T15:00:43+0100 3 | ; FORMAT={-:-/ absolute / metric / decimal} 4 | ; #@! TF.CreationDate,2024-11-24T15:00:43+01:00 5 | ; #@! TF.GenerationSoftware,Kicad,Pcbnew,8.0.0 6 | ; #@! TF.FileFunction,NonPlated,1,2,NPTH 7 | FMAT,2 8 | METRIC 9 | % 10 | G90 11 | G05 12 | M30 13 | -------------------------------------------------------------------------------- /Fabrication/gerber/HHID-v2-PTH.drl: -------------------------------------------------------------------------------- 1 | M48 2 | ; DRILL file {KiCad 8.0.0} date 2024-11-24T15:00:43+0100 3 | ; FORMAT={-:-/ absolute / metric / decimal} 4 | ; #@! TF.CreationDate,2024-11-24T15:00:43+01:00 5 | ; #@! TF.GenerationSoftware,Kicad,Pcbnew,8.0.0 6 | ; #@! TF.FileFunction,Plated,1,2,PTH 7 | FMAT,2 8 | METRIC 9 | ; #@! TA.AperFunction,Plated,PTH,ViaDrill 10 | T1C0.300 11 | % 12 | G90 13 | G05 14 | T1 15 | X2.538Y6.401 16 | X5.433Y4.558 17 | X6.736Y4.01 18 | X9.275Y6.3 19 | X9.425Y1.925 20 | M30 21 | -------------------------------------------------------------------------------- /KiCad/HHID-v2.kicad_prl: -------------------------------------------------------------------------------- 1 | { 2 | "board": { 3 | "active_layer": 48, 4 | "active_layer_preset": "", 5 | "auto_track_width": false, 6 | "hidden_netclasses": [], 7 | "hidden_nets": [], 8 | "high_contrast_mode": 0, 9 | "net_color_mode": 1, 10 | "opacity": { 11 | "images": 0.6, 12 | "pads": 1.0, 13 | "tracks": 1.0, 14 | "vias": 1.0, 15 | "zones": 0.6 16 | }, 17 | "selection_filter": { 18 | "dimensions": true, 19 | "footprints": true, 20 | "graphics": true, 21 | "keepouts": true, 22 | "lockedItems": false, 23 | "otherItems": true, 24 | "pads": true, 25 | "text": true, 26 | "tracks": true, 27 | "vias": true, 28 | "zones": true 29 | }, 30 | "visible_items": [ 31 | 0, 32 | 1, 33 | 2, 34 | 3, 35 | 4, 36 | 5, 37 | 8, 38 | 9, 39 | 10, 40 | 11, 41 | 12, 42 | 13, 43 | 15, 44 | 16, 45 | 17, 46 | 18, 47 | 19, 48 | 20, 49 | 21, 50 | 22, 51 | 23, 52 | 24, 53 | 25, 54 | 26, 55 | 27, 56 | 28, 57 | 29, 58 | 30, 59 | 32, 60 | 33, 61 | 34, 62 | 35, 63 | 36, 64 | 39, 65 | 40 66 | ], 67 | "visible_layers": "ffffeff_ffffffff", 68 | "zone_display_mode": 0 69 | }, 70 | "git": { 71 | "repo_password": "", 72 | "repo_type": "", 73 | "repo_username": "", 74 | "ssh_key": "" 75 | }, 76 | "meta": { 77 | "filename": "HHID-v2.kicad_prl", 78 | "version": 3 79 | }, 80 | "project": { 81 | "files": [] 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /KiCad/HHID-v2.kicad_pro: -------------------------------------------------------------------------------- 1 | { 2 | "board": { 3 | "3dviewports": [], 4 | "design_settings": { 5 | "defaults": { 6 | "apply_defaults_to_fp_fields": false, 7 | "apply_defaults_to_fp_shapes": false, 8 | "apply_defaults_to_fp_text": false, 9 | "board_outline_line_width": 0.049999999999999996, 10 | "copper_line_width": 0.19999999999999998, 11 | "copper_text_italic": false, 12 | "copper_text_size_h": 1.5, 13 | "copper_text_size_v": 1.5, 14 | "copper_text_thickness": 0.3, 15 | "copper_text_upright": false, 16 | "courtyard_line_width": 0.049999999999999996, 17 | "dimension_precision": 4, 18 | "dimension_units": 3, 19 | "dimensions": { 20 | "arrow_length": 1270000, 21 | "extension_offset": 500000, 22 | "keep_text_aligned": true, 23 | "suppress_zeroes": false, 24 | "text_position": 0, 25 | "units_format": 1 26 | }, 27 | "fab_line_width": 0.09999999999999999, 28 | "fab_text_italic": false, 29 | "fab_text_size_h": 1.0, 30 | "fab_text_size_v": 1.0, 31 | "fab_text_thickness": 0.15, 32 | "fab_text_upright": false, 33 | "other_line_width": 0.09999999999999999, 34 | "other_text_italic": false, 35 | "other_text_size_h": 1.0, 36 | "other_text_size_v": 1.0, 37 | "other_text_thickness": 0.15, 38 | "other_text_upright": false, 39 | "pads": { 40 | "drill": 0.0, 41 | "height": 1.7, 42 | "width": 7.2 43 | }, 44 | "silk_line_width": 0.09999999999999999, 45 | "silk_text_italic": false, 46 | "silk_text_size_h": 1.0, 47 | "silk_text_size_v": 1.0, 48 | "silk_text_thickness": 0.09999999999999999, 49 | "silk_text_upright": false, 50 | "zones": { 51 | "min_clearance": 0.125 52 | } 53 | }, 54 | "diff_pair_dimensions": [ 55 | { 56 | "gap": 0.0, 57 | "via_gap": 0.0, 58 | "width": 0.0 59 | } 60 | ], 61 | "drc_exclusions": [], 62 | "meta": { 63 | "version": 2 64 | }, 65 | "rule_severities": { 66 | "annular_width": "error", 67 | "clearance": "error", 68 | "connection_width": "warning", 69 | "copper_edge_clearance": "error", 70 | "copper_sliver": "warning", 71 | "courtyards_overlap": "error", 72 | "diff_pair_gap_out_of_range": "error", 73 | "diff_pair_uncoupled_length_too_long": "error", 74 | "drill_out_of_range": "error", 75 | "duplicate_footprints": "warning", 76 | "extra_footprint": "warning", 77 | "footprint": "error", 78 | "footprint_symbol_mismatch": "warning", 79 | "footprint_type_mismatch": "ignore", 80 | "hole_clearance": "error", 81 | "hole_near_hole": "error", 82 | "invalid_outline": "error", 83 | "isolated_copper": "warning", 84 | "item_on_disabled_layer": "error", 85 | "items_not_allowed": "error", 86 | "length_out_of_range": "error", 87 | "lib_footprint_issues": "warning", 88 | "lib_footprint_mismatch": "warning", 89 | "malformed_courtyard": "error", 90 | "microvia_drill_out_of_range": "error", 91 | "missing_courtyard": "ignore", 92 | "missing_footprint": "warning", 93 | "net_conflict": "warning", 94 | "npth_inside_courtyard": "ignore", 95 | "padstack": "warning", 96 | "pth_inside_courtyard": "ignore", 97 | "shorting_items": "error", 98 | "silk_edge_clearance": "warning", 99 | "silk_over_copper": "warning", 100 | "silk_overlap": "warning", 101 | "skew_out_of_range": "error", 102 | "solder_mask_bridge": "error", 103 | "starved_thermal": "error", 104 | "text_height": "warning", 105 | "text_thickness": "warning", 106 | "through_hole_pad_without_hole": "error", 107 | "too_many_vias": "error", 108 | "track_dangling": "warning", 109 | "track_width": "error", 110 | "tracks_crossing": "error", 111 | "unconnected_items": "error", 112 | "unresolved_variable": "error", 113 | "via_dangling": "warning", 114 | "zones_intersect": "error" 115 | }, 116 | "rules": { 117 | "max_error": 0.005, 118 | "min_clearance": 0.0, 119 | "min_connection": 0.0, 120 | "min_copper_edge_clearance": 0.26, 121 | "min_hole_clearance": 0.25, 122 | "min_hole_to_hole": 0.25, 123 | "min_microvia_diameter": 0.19999999999999998, 124 | "min_microvia_drill": 0.09999999999999999, 125 | "min_resolved_spokes": 2, 126 | "min_silk_clearance": 0.0, 127 | "min_text_height": 0.7999999999999999, 128 | "min_text_thickness": 0.08, 129 | "min_through_hole_diameter": 0.3, 130 | "min_track_width": 0.0, 131 | "min_via_annular_width": 0.09999999999999999, 132 | "min_via_diameter": 0.5, 133 | "solder_mask_to_copper_clearance": 0.0, 134 | "use_height_for_length_calcs": true 135 | }, 136 | "teardrop_options": [ 137 | { 138 | "td_onpadsmd": true, 139 | "td_onroundshapesonly": false, 140 | "td_ontrackend": false, 141 | "td_onviapad": true 142 | } 143 | ], 144 | "teardrop_parameters": [ 145 | { 146 | "td_allow_use_two_tracks": true, 147 | "td_curve_segcount": 0, 148 | "td_height_ratio": 1.0, 149 | "td_length_ratio": 0.5, 150 | "td_maxheight": 2.0, 151 | "td_maxlen": 1.0, 152 | "td_on_pad_in_zone": false, 153 | "td_target_name": "td_round_shape", 154 | "td_width_to_size_filter_ratio": 0.9 155 | }, 156 | { 157 | "td_allow_use_two_tracks": true, 158 | "td_curve_segcount": 0, 159 | "td_height_ratio": 1.0, 160 | "td_length_ratio": 0.5, 161 | "td_maxheight": 2.0, 162 | "td_maxlen": 1.0, 163 | "td_on_pad_in_zone": false, 164 | "td_target_name": "td_rect_shape", 165 | "td_width_to_size_filter_ratio": 0.9 166 | }, 167 | { 168 | "td_allow_use_two_tracks": true, 169 | "td_curve_segcount": 0, 170 | "td_height_ratio": 1.0, 171 | "td_length_ratio": 0.5, 172 | "td_maxheight": 2.0, 173 | "td_maxlen": 1.0, 174 | "td_on_pad_in_zone": false, 175 | "td_target_name": "td_track_end", 176 | "td_width_to_size_filter_ratio": 0.9 177 | } 178 | ], 179 | "track_widths": [ 180 | 0.0, 181 | 0.25 182 | ], 183 | "tuning_pattern_settings": { 184 | "diff_pair_defaults": { 185 | "corner_radius_percentage": 80, 186 | "corner_style": 1, 187 | "max_amplitude": 1.0, 188 | "min_amplitude": 0.2, 189 | "single_sided": false, 190 | "spacing": 1.0 191 | }, 192 | "diff_pair_skew_defaults": { 193 | "corner_radius_percentage": 80, 194 | "corner_style": 1, 195 | "max_amplitude": 1.0, 196 | "min_amplitude": 0.2, 197 | "single_sided": false, 198 | "spacing": 0.6 199 | }, 200 | "single_track_defaults": { 201 | "corner_radius_percentage": 80, 202 | "corner_style": 1, 203 | "max_amplitude": 1.0, 204 | "min_amplitude": 0.2, 205 | "single_sided": false, 206 | "spacing": 0.6 207 | } 208 | }, 209 | "via_dimensions": [ 210 | { 211 | "diameter": 0.0, 212 | "drill": 0.0 213 | } 214 | ], 215 | "zones_allow_external_fillets": false 216 | }, 217 | "ipc2581": { 218 | "dist": "", 219 | "distpn": "", 220 | "internal_id": "", 221 | "mfg": "", 222 | "mpn": "" 223 | }, 224 | "layer_presets": [], 225 | "viewports": [] 226 | }, 227 | "boards": [], 228 | "cvpcb": { 229 | "equivalence_files": [] 230 | }, 231 | "erc": { 232 | "erc_exclusions": [], 233 | "meta": { 234 | "version": 0 235 | }, 236 | "pin_map": [ 237 | [ 238 | 0, 239 | 0, 240 | 0, 241 | 0, 242 | 0, 243 | 0, 244 | 1, 245 | 0, 246 | 0, 247 | 0, 248 | 0, 249 | 2 250 | ], 251 | [ 252 | 0, 253 | 2, 254 | 0, 255 | 1, 256 | 0, 257 | 0, 258 | 1, 259 | 0, 260 | 2, 261 | 2, 262 | 2, 263 | 2 264 | ], 265 | [ 266 | 0, 267 | 0, 268 | 0, 269 | 0, 270 | 0, 271 | 0, 272 | 1, 273 | 0, 274 | 1, 275 | 0, 276 | 1, 277 | 2 278 | ], 279 | [ 280 | 0, 281 | 1, 282 | 0, 283 | 0, 284 | 0, 285 | 0, 286 | 1, 287 | 1, 288 | 2, 289 | 1, 290 | 1, 291 | 2 292 | ], 293 | [ 294 | 0, 295 | 0, 296 | 0, 297 | 0, 298 | 0, 299 | 0, 300 | 1, 301 | 0, 302 | 0, 303 | 0, 304 | 0, 305 | 2 306 | ], 307 | [ 308 | 0, 309 | 0, 310 | 0, 311 | 0, 312 | 0, 313 | 0, 314 | 0, 315 | 0, 316 | 0, 317 | 0, 318 | 0, 319 | 2 320 | ], 321 | [ 322 | 1, 323 | 1, 324 | 1, 325 | 1, 326 | 1, 327 | 0, 328 | 1, 329 | 1, 330 | 1, 331 | 1, 332 | 1, 333 | 2 334 | ], 335 | [ 336 | 0, 337 | 0, 338 | 0, 339 | 1, 340 | 0, 341 | 0, 342 | 1, 343 | 0, 344 | 0, 345 | 0, 346 | 0, 347 | 2 348 | ], 349 | [ 350 | 0, 351 | 2, 352 | 1, 353 | 2, 354 | 0, 355 | 0, 356 | 1, 357 | 0, 358 | 2, 359 | 2, 360 | 2, 361 | 2 362 | ], 363 | [ 364 | 0, 365 | 2, 366 | 0, 367 | 1, 368 | 0, 369 | 0, 370 | 1, 371 | 0, 372 | 2, 373 | 0, 374 | 0, 375 | 2 376 | ], 377 | [ 378 | 0, 379 | 2, 380 | 1, 381 | 1, 382 | 0, 383 | 0, 384 | 1, 385 | 0, 386 | 2, 387 | 0, 388 | 0, 389 | 2 390 | ], 391 | [ 392 | 2, 393 | 2, 394 | 2, 395 | 2, 396 | 2, 397 | 2, 398 | 2, 399 | 2, 400 | 2, 401 | 2, 402 | 2, 403 | 2 404 | ] 405 | ], 406 | "rule_severities": { 407 | "bus_definition_conflict": "error", 408 | "bus_entry_needed": "error", 409 | "bus_to_bus_conflict": "error", 410 | "bus_to_net_conflict": "error", 411 | "conflicting_netclasses": "error", 412 | "different_unit_footprint": "error", 413 | "different_unit_net": "error", 414 | "duplicate_reference": "error", 415 | "duplicate_sheet_names": "error", 416 | "endpoint_off_grid": "warning", 417 | "extra_units": "error", 418 | "global_label_dangling": "warning", 419 | "hier_label_mismatch": "error", 420 | "label_dangling": "error", 421 | "lib_symbol_issues": "warning", 422 | "missing_bidi_pin": "warning", 423 | "missing_input_pin": "warning", 424 | "missing_power_pin": "error", 425 | "missing_unit": "warning", 426 | "multiple_net_names": "warning", 427 | "net_not_bus_member": "warning", 428 | "no_connect_connected": "warning", 429 | "no_connect_dangling": "warning", 430 | "pin_not_connected": "error", 431 | "pin_not_driven": "error", 432 | "pin_to_pin": "warning", 433 | "power_pin_not_driven": "error", 434 | "similar_labels": "warning", 435 | "simulation_model_issue": "ignore", 436 | "unannotated": "error", 437 | "unit_value_mismatch": "error", 438 | "unresolved_variable": "error", 439 | "wire_dangling": "error" 440 | } 441 | }, 442 | "libraries": { 443 | "pinned_footprint_libs": [], 444 | "pinned_symbol_libs": [] 445 | }, 446 | "meta": { 447 | "filename": "HHID-v2.kicad_pro", 448 | "version": 1 449 | }, 450 | "net_settings": { 451 | "classes": [ 452 | { 453 | "bus_width": 12, 454 | "clearance": 0.125, 455 | "diff_pair_gap": 0.25, 456 | "diff_pair_via_gap": 0.25, 457 | "diff_pair_width": 0.2, 458 | "line_style": 0, 459 | "microvia_diameter": 0.3, 460 | "microvia_drill": 0.1, 461 | "name": "Default", 462 | "pcb_color": "rgba(0, 0, 0, 0.000)", 463 | "schematic_color": "rgba(0, 0, 0, 0.000)", 464 | "track_width": 0.125, 465 | "via_diameter": 0.6, 466 | "via_drill": 0.3, 467 | "wire_width": 6 468 | } 469 | ], 470 | "meta": { 471 | "version": 3 472 | }, 473 | "net_colors": null, 474 | "netclass_assignments": null, 475 | "netclass_patterns": [] 476 | }, 477 | "pcbnew": { 478 | "last_paths": { 479 | "gencad": "", 480 | "idf": "", 481 | "netlist": "", 482 | "plot": "gerber/", 483 | "pos_files": "./", 484 | "specctra_dsn": "", 485 | "step": "", 486 | "svg": "", 487 | "vrml": "" 488 | }, 489 | "page_layout_descr_file": "" 490 | }, 491 | "schematic": { 492 | "annotate_start_num": 0, 493 | "bom_fmt_presets": [], 494 | "bom_fmt_settings": { 495 | "field_delimiter": ",", 496 | "keep_line_breaks": false, 497 | "keep_tabs": false, 498 | "name": "CSV", 499 | "ref_delimiter": ",", 500 | "ref_range_delimiter": "", 501 | "string_delimiter": "\"" 502 | }, 503 | "bom_presets": [], 504 | "bom_settings": { 505 | "exclude_dnp": false, 506 | "fields_ordered": [ 507 | { 508 | "group_by": false, 509 | "label": "Reference", 510 | "name": "Reference", 511 | "show": true 512 | }, 513 | { 514 | "group_by": true, 515 | "label": "Value", 516 | "name": "Value", 517 | "show": true 518 | }, 519 | { 520 | "group_by": false, 521 | "label": "Datasheet", 522 | "name": "Datasheet", 523 | "show": true 524 | }, 525 | { 526 | "group_by": false, 527 | "label": "Footprint", 528 | "name": "Footprint", 529 | "show": true 530 | }, 531 | { 532 | "group_by": false, 533 | "label": "Qty", 534 | "name": "${QUANTITY}", 535 | "show": true 536 | }, 537 | { 538 | "group_by": true, 539 | "label": "DNP", 540 | "name": "${DNP}", 541 | "show": true 542 | } 543 | ], 544 | "filter_string": "", 545 | "group_symbols": true, 546 | "name": "Grouped By Value", 547 | "sort_asc": true, 548 | "sort_field": "Reference" 549 | }, 550 | "connection_grid_size": 50.0, 551 | "drawing": { 552 | "dashed_lines_dash_length_ratio": 12.0, 553 | "dashed_lines_gap_length_ratio": 3.0, 554 | "default_line_thickness": 6.0, 555 | "default_text_size": 50.0, 556 | "field_names": [], 557 | "intersheets_ref_own_page": false, 558 | "intersheets_ref_prefix": "", 559 | "intersheets_ref_short": false, 560 | "intersheets_ref_show": false, 561 | "intersheets_ref_suffix": "", 562 | "junction_size_choice": 3, 563 | "label_size_ratio": 0.375, 564 | "operating_point_overlay_i_precision": 3, 565 | "operating_point_overlay_i_range": "~A", 566 | "operating_point_overlay_v_precision": 3, 567 | "operating_point_overlay_v_range": "~V", 568 | "overbar_offset_ratio": 1.23, 569 | "pin_symbol_size": 25.0, 570 | "text_offset_ratio": 0.15 571 | }, 572 | "legacy_lib_dir": "", 573 | "legacy_lib_list": [], 574 | "meta": { 575 | "version": 1 576 | }, 577 | "net_format_name": "", 578 | "page_layout_descr_file": "", 579 | "plot_directory": "", 580 | "spice_current_sheet_as_root": false, 581 | "spice_external_command": "spice \"%I\"", 582 | "spice_model_current_sheet_as_root": true, 583 | "spice_save_all_currents": false, 584 | "spice_save_all_dissipations": false, 585 | "spice_save_all_voltages": false, 586 | "subpart_first_id": 65, 587 | "subpart_id_separator": 0 588 | }, 589 | "sheets": [ 590 | [ 591 | "f235dd1b-57a4-4459-86b4-0864643a9595", 592 | "Root" 593 | ] 594 | ], 595 | "text_variables": {} 596 | } 597 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Hidden-HID-v2 2 | Hidden HID v2 is a tiny USB rubber ducky that can be concealed entirely inside the USB port. I have implemented various hardware improvements compared to v1. 3 | 4 | These include: 5 | 1. Removal of SWD programming pins to rely only on STs internal USB bootloader, which avoids the need to painstakingly solder the PCB to the STLink debugger every time I want to change the program. Now it is only necessary to bridge the BOOT0 test pad (middle) with 3V3 to select bootloader, or with GND to select application (see image below). After connecting BOOT0 to 3V3, the STM32 can then be programmed by inserting into the USB port and using the STCubeProgrammer tool to download the hex file. 6 | 2. Layout changes to enable easier assembly of the spacer elements 7 | 3. Switching the spacer elements from LEDs with no electrical function to IR phototransistors which also provide a simple on-off remote control. This allows the device to be remotely armed and disarmed once inserted. 8 | 9 | 10 | ![rev2-bot](https://github.com/user-attachments/assets/c173be7f-866d-4739-8500-147a9e69233f) 11 | 12 | connect BOOT0 to GND to run application or with 3V3 to reprogram 13 | 14 | 15 | KiCad files can be found under /KiCad, gerber and BOM separately under /Fabrication. 16 | Under /STM32 I have uploaded a basic test firmware. This firmware waits for an IR signal, then opens a terminal and echoes hello world. You may need to tweak the paths a little to get it running on your system. 17 | 18 | If you are interested in purchasing this PCB, I have uploaded it to the PCBWay community. Here you can order either the bare PCB or the assembled PCB directly: https://www.pcbway.com/project/shareproject/Hidden_HID_an_invisible_USB_Rubber_Ducky_3a8cd27f.html 19 | 20 | Also check out the project write-up on hackaday: https://hackaday.io/project/202218-hidden-hid-v2-worlds-smallest-rubber-ducky 21 | 22 | ![cover-cropped](https://github.com/user-attachments/assets/ce369c1e-d2b1-4981-887d-d5b81b368dbf) 23 | 24 | 25 | ![IMG_20250118_132744_294](https://github.com/user-attachments/assets/21be55e5-5d79-4647-a3af-5c7904761213) 26 | -------------------------------------------------------------------------------- /STM32/Core/Inc/main.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : main.h 5 | * @brief : Header for main.c file. 6 | * This file contains the common defines of the application. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2025 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __MAIN_H 23 | #define __MAIN_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | #include "stm32f0xx_hal.h" 31 | 32 | /* Private includes ----------------------------------------------------------*/ 33 | /* USER CODE BEGIN Includes */ 34 | 35 | /* USER CODE END Includes */ 36 | 37 | /* Exported types ------------------------------------------------------------*/ 38 | /* USER CODE BEGIN ET */ 39 | 40 | /* USER CODE END ET */ 41 | 42 | /* Exported constants --------------------------------------------------------*/ 43 | /* USER CODE BEGIN EC */ 44 | 45 | /* USER CODE END EC */ 46 | 47 | /* Exported macro ------------------------------------------------------------*/ 48 | /* USER CODE BEGIN EM */ 49 | 50 | /* USER CODE END EM */ 51 | 52 | /* Exported functions prototypes ---------------------------------------------*/ 53 | void Error_Handler(void); 54 | 55 | /* USER CODE BEGIN EFP */ 56 | 57 | /* USER CODE END EFP */ 58 | 59 | /* Private defines -----------------------------------------------------------*/ 60 | 61 | /* USER CODE BEGIN Private defines */ 62 | 63 | /* USER CODE END Private defines */ 64 | 65 | #ifdef __cplusplus 66 | } 67 | #endif 68 | 69 | #endif /* __MAIN_H */ 70 | -------------------------------------------------------------------------------- /STM32/Core/Inc/stm32f0xx_hal_conf.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32f0xx_hal_conf.h 5 | * @brief HAL configuration file. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2016 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | /* USER CODE END Header */ 19 | 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __STM32F0xx_HAL_CONF_H 22 | #define __STM32F0xx_HAL_CONF_H 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Exported types ------------------------------------------------------------*/ 29 | /* Exported constants --------------------------------------------------------*/ 30 | 31 | /* ########################## Module Selection ############################## */ 32 | /** 33 | * @brief This is the list of modules to be used in the HAL driver 34 | */ 35 | #define HAL_MODULE_ENABLED 36 | #define HAL_ADC_MODULE_ENABLED 37 | /*#define HAL_CRYP_MODULE_ENABLED */ 38 | /*#define HAL_CAN_MODULE_ENABLED */ 39 | /*#define HAL_CEC_MODULE_ENABLED */ 40 | /*#define HAL_COMP_MODULE_ENABLED */ 41 | /*#define HAL_CRC_MODULE_ENABLED */ 42 | /*#define HAL_CRYP_MODULE_ENABLED */ 43 | /*#define HAL_TSC_MODULE_ENABLED */ 44 | /*#define HAL_DAC_MODULE_ENABLED */ 45 | /*#define HAL_I2S_MODULE_ENABLED */ 46 | /*#define HAL_IWDG_MODULE_ENABLED */ 47 | /*#define HAL_LCD_MODULE_ENABLED */ 48 | /*#define HAL_LPTIM_MODULE_ENABLED */ 49 | /*#define HAL_RNG_MODULE_ENABLED */ 50 | /*#define HAL_RTC_MODULE_ENABLED */ 51 | /*#define HAL_SPI_MODULE_ENABLED */ 52 | /*#define HAL_TIM_MODULE_ENABLED */ 53 | /*#define HAL_UART_MODULE_ENABLED */ 54 | /*#define HAL_USART_MODULE_ENABLED */ 55 | /*#define HAL_IRDA_MODULE_ENABLED */ 56 | /*#define HAL_SMARTCARD_MODULE_ENABLED */ 57 | /*#define HAL_SMBUS_MODULE_ENABLED */ 58 | /*#define HAL_WWDG_MODULE_ENABLED */ 59 | #define HAL_PCD_MODULE_ENABLED 60 | #define HAL_CORTEX_MODULE_ENABLED 61 | #define HAL_DMA_MODULE_ENABLED 62 | #define HAL_FLASH_MODULE_ENABLED 63 | #define HAL_GPIO_MODULE_ENABLED 64 | #define HAL_EXTI_MODULE_ENABLED 65 | #define HAL_PWR_MODULE_ENABLED 66 | #define HAL_RCC_MODULE_ENABLED 67 | #define HAL_I2C_MODULE_ENABLED 68 | 69 | /* ########################## HSE/HSI Values adaptation ##################### */ 70 | /** 71 | * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. 72 | * This value is used by the RCC HAL module to compute the system frequency 73 | * (when HSE is used as system clock source, directly or through the PLL). 74 | */ 75 | #if !defined (HSE_VALUE) 76 | #define HSE_VALUE ((uint32_t)8000000) /*!< Value of the External oscillator in Hz */ 77 | #endif /* HSE_VALUE */ 78 | 79 | /** 80 | * @brief In the following line adjust the External High Speed oscillator (HSE) Startup 81 | * Timeout value 82 | */ 83 | #if !defined (HSE_STARTUP_TIMEOUT) 84 | #define HSE_STARTUP_TIMEOUT ((uint32_t)100) /*!< Time out for HSE start up, in ms */ 85 | #endif /* HSE_STARTUP_TIMEOUT */ 86 | 87 | /** 88 | * @brief Internal High Speed oscillator (HSI) value. 89 | * This value is used by the RCC HAL module to compute the system frequency 90 | * (when HSI is used as system clock source, directly or through the PLL). 91 | */ 92 | #if !defined (HSI_VALUE) 93 | #define HSI_VALUE ((uint32_t)8000000) /*!< Value of the Internal oscillator in Hz*/ 94 | #endif /* HSI_VALUE */ 95 | 96 | /** 97 | * @brief In the following line adjust the Internal High Speed oscillator (HSI) Startup 98 | * Timeout value 99 | */ 100 | #if !defined (HSI_STARTUP_TIMEOUT) 101 | #define HSI_STARTUP_TIMEOUT ((uint32_t)5000) /*!< Time out for HSI start up */ 102 | #endif /* HSI_STARTUP_TIMEOUT */ 103 | 104 | /** 105 | * @brief Internal High Speed oscillator for ADC (HSI14) value. 106 | */ 107 | #if !defined (HSI14_VALUE) 108 | #define HSI14_VALUE ((uint32_t)14000000) /*!< Value of the Internal High Speed oscillator for ADC in Hz. 109 | The real value may vary depending on the variations 110 | in voltage and temperature. */ 111 | #endif /* HSI14_VALUE */ 112 | 113 | /** 114 | * @brief Internal High Speed oscillator for USB (HSI48) value. 115 | */ 116 | #if !defined (HSI48_VALUE) 117 | #define HSI48_VALUE ((uint32_t)48000000) /*!< Value of the Internal High Speed oscillator for USB in Hz. 118 | The real value may vary depending on the variations 119 | in voltage and temperature. */ 120 | #endif /* HSI48_VALUE */ 121 | 122 | /** 123 | * @brief Internal Low Speed oscillator (LSI) value. 124 | */ 125 | #if !defined (LSI_VALUE) 126 | #define LSI_VALUE ((uint32_t)40000) 127 | #endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz 128 | The real value may vary depending on the variations 129 | in voltage and temperature. */ 130 | /** 131 | * @brief External Low Speed oscillator (LSI) value. 132 | */ 133 | #if !defined (LSE_VALUE) 134 | #define LSE_VALUE ((uint32_t)32768) /*!< Value of the External Low Speed oscillator in Hz */ 135 | #endif /* LSE_VALUE */ 136 | 137 | /** 138 | * @brief Time out for LSE start up value in ms. 139 | */ 140 | #if !defined (LSE_STARTUP_TIMEOUT) 141 | #define LSE_STARTUP_TIMEOUT ((uint32_t)5000) /*!< Time out for LSE start up, in ms */ 142 | #endif /* LSE_STARTUP_TIMEOUT */ 143 | 144 | /* Tip: To avoid modifying this file each time you need to use different HSE, 145 | === you can define the HSE value in your toolchain compiler preprocessor. */ 146 | 147 | /* ########################### System Configuration ######################### */ 148 | /** 149 | * @brief This is the HAL system configuration section 150 | */ 151 | #define VDD_VALUE ((uint32_t)3300) /*!< Value of VDD in mv */ 152 | #define TICK_INT_PRIORITY ((uint32_t)3) /*!< tick interrupt priority (lowest by default) */ 153 | /* Warning: Must be set to higher priority for HAL_Delay() */ 154 | /* and HAL_GetTick() usage under interrupt context */ 155 | #define USE_RTOS 0 156 | #define PREFETCH_ENABLE 1 157 | #define INSTRUCTION_CACHE_ENABLE 0 158 | #define DATA_CACHE_ENABLE 0 159 | #define USE_SPI_CRC 0U 160 | 161 | #define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */ 162 | #define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */ 163 | #define USE_HAL_COMP_REGISTER_CALLBACKS 0U /* COMP register callback disabled */ 164 | #define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */ 165 | #define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */ 166 | #define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */ 167 | #define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */ 168 | #define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */ 169 | #define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */ 170 | #define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */ 171 | #define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */ 172 | #define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */ 173 | #define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */ 174 | #define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */ 175 | #define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */ 176 | #define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */ 177 | #define USE_HAL_TSC_REGISTER_CALLBACKS 0U /* TSC register callback disabled */ 178 | #define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */ 179 | 180 | /* ########################## Assert Selection ############################## */ 181 | /** 182 | * @brief Uncomment the line below to expanse the "assert_param" macro in the 183 | * HAL drivers code 184 | */ 185 | /* #define USE_FULL_ASSERT 1U */ 186 | 187 | /* Includes ------------------------------------------------------------------*/ 188 | /** 189 | * @brief Include module's header file 190 | */ 191 | 192 | #ifdef HAL_RCC_MODULE_ENABLED 193 | #include "stm32f0xx_hal_rcc.h" 194 | #endif /* HAL_RCC_MODULE_ENABLED */ 195 | 196 | #ifdef HAL_GPIO_MODULE_ENABLED 197 | #include "stm32f0xx_hal_gpio.h" 198 | #endif /* HAL_GPIO_MODULE_ENABLED */ 199 | 200 | #ifdef HAL_EXTI_MODULE_ENABLED 201 | #include "stm32f0xx_hal_exti.h" 202 | #endif /* HAL_EXTI_MODULE_ENABLED */ 203 | 204 | #ifdef HAL_DMA_MODULE_ENABLED 205 | #include "stm32f0xx_hal_dma.h" 206 | #endif /* HAL_DMA_MODULE_ENABLED */ 207 | 208 | #ifdef HAL_CORTEX_MODULE_ENABLED 209 | #include "stm32f0xx_hal_cortex.h" 210 | #endif /* HAL_CORTEX_MODULE_ENABLED */ 211 | 212 | #ifdef HAL_ADC_MODULE_ENABLED 213 | #include "stm32f0xx_hal_adc.h" 214 | #endif /* HAL_ADC_MODULE_ENABLED */ 215 | 216 | #ifdef HAL_CAN_MODULE_ENABLED 217 | #include "stm32f0xx_hal_can.h" 218 | #endif /* HAL_CAN_MODULE_ENABLED */ 219 | 220 | #ifdef HAL_CEC_MODULE_ENABLED 221 | #include "stm32f0xx_hal_cec.h" 222 | #endif /* HAL_CEC_MODULE_ENABLED */ 223 | 224 | #ifdef HAL_COMP_MODULE_ENABLED 225 | #include "stm32f0xx_hal_comp.h" 226 | #endif /* HAL_COMP_MODULE_ENABLED */ 227 | 228 | #ifdef HAL_CRC_MODULE_ENABLED 229 | #include "stm32f0xx_hal_crc.h" 230 | #endif /* HAL_CRC_MODULE_ENABLED */ 231 | 232 | #ifdef HAL_DAC_MODULE_ENABLED 233 | #include "stm32f0xx_hal_dac.h" 234 | #endif /* HAL_DAC_MODULE_ENABLED */ 235 | 236 | #ifdef HAL_FLASH_MODULE_ENABLED 237 | #include "stm32f0xx_hal_flash.h" 238 | #endif /* HAL_FLASH_MODULE_ENABLED */ 239 | 240 | #ifdef HAL_I2C_MODULE_ENABLED 241 | #include "stm32f0xx_hal_i2c.h" 242 | #endif /* HAL_I2C_MODULE_ENABLED */ 243 | 244 | #ifdef HAL_I2S_MODULE_ENABLED 245 | #include "stm32f0xx_hal_i2s.h" 246 | #endif /* HAL_I2S_MODULE_ENABLED */ 247 | 248 | #ifdef HAL_IRDA_MODULE_ENABLED 249 | #include "stm32f0xx_hal_irda.h" 250 | #endif /* HAL_IRDA_MODULE_ENABLED */ 251 | 252 | #ifdef HAL_IWDG_MODULE_ENABLED 253 | #include "stm32f0xx_hal_iwdg.h" 254 | #endif /* HAL_IWDG_MODULE_ENABLED */ 255 | 256 | #ifdef HAL_PCD_MODULE_ENABLED 257 | #include "stm32f0xx_hal_pcd.h" 258 | #endif /* HAL_PCD_MODULE_ENABLED */ 259 | 260 | #ifdef HAL_PWR_MODULE_ENABLED 261 | #include "stm32f0xx_hal_pwr.h" 262 | #endif /* HAL_PWR_MODULE_ENABLED */ 263 | 264 | #ifdef HAL_RTC_MODULE_ENABLED 265 | #include "stm32f0xx_hal_rtc.h" 266 | #endif /* HAL_RTC_MODULE_ENABLED */ 267 | 268 | #ifdef HAL_SMARTCARD_MODULE_ENABLED 269 | #include "stm32f0xx_hal_smartcard.h" 270 | #endif /* HAL_SMARTCARD_MODULE_ENABLED */ 271 | 272 | #ifdef HAL_SMBUS_MODULE_ENABLED 273 | #include "stm32f0xx_hal_smbus.h" 274 | #endif /* HAL_SMBUS_MODULE_ENABLED */ 275 | 276 | #ifdef HAL_SPI_MODULE_ENABLED 277 | #include "stm32f0xx_hal_spi.h" 278 | #endif /* HAL_SPI_MODULE_ENABLED */ 279 | 280 | #ifdef HAL_TIM_MODULE_ENABLED 281 | #include "stm32f0xx_hal_tim.h" 282 | #endif /* HAL_TIM_MODULE_ENABLED */ 283 | 284 | #ifdef HAL_TSC_MODULE_ENABLED 285 | #include "stm32f0xx_hal_tsc.h" 286 | #endif /* HAL_TSC_MODULE_ENABLED */ 287 | 288 | #ifdef HAL_UART_MODULE_ENABLED 289 | #include "stm32f0xx_hal_uart.h" 290 | #endif /* HAL_UART_MODULE_ENABLED */ 291 | 292 | #ifdef HAL_USART_MODULE_ENABLED 293 | #include "stm32f0xx_hal_usart.h" 294 | #endif /* HAL_USART_MODULE_ENABLED */ 295 | 296 | #ifdef HAL_WWDG_MODULE_ENABLED 297 | #include "stm32f0xx_hal_wwdg.h" 298 | #endif /* HAL_WWDG_MODULE_ENABLED */ 299 | 300 | /* Exported macro ------------------------------------------------------------*/ 301 | #ifdef USE_FULL_ASSERT 302 | /** 303 | * @brief The assert_param macro is used for function's parameters check. 304 | * @param expr If expr is false, it calls assert_failed function 305 | * which reports the name of the source file and the source 306 | * line number of the call that failed. 307 | * If expr is true, it returns no value. 308 | * @retval None 309 | */ 310 | #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) 311 | /* Exported functions ------------------------------------------------------- */ 312 | void assert_failed(uint8_t* file, uint32_t line); 313 | #else 314 | #define assert_param(expr) ((void)0U) 315 | #endif /* USE_FULL_ASSERT */ 316 | 317 | #ifdef __cplusplus 318 | } 319 | #endif 320 | 321 | #endif /* __STM32F0xx_HAL_CONF_H */ 322 | 323 | -------------------------------------------------------------------------------- /STM32/Core/Inc/stm32f0xx_it.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32f0xx_it.h 5 | * @brief This file contains the headers of the interrupt handlers. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2025 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | /* USER CODE END Header */ 19 | 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __STM32F0xx_IT_H 22 | #define __STM32F0xx_IT_H 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Private includes ----------------------------------------------------------*/ 29 | /* USER CODE BEGIN Includes */ 30 | 31 | /* USER CODE END Includes */ 32 | 33 | /* Exported types ------------------------------------------------------------*/ 34 | /* USER CODE BEGIN ET */ 35 | 36 | /* USER CODE END ET */ 37 | 38 | /* Exported constants --------------------------------------------------------*/ 39 | /* USER CODE BEGIN EC */ 40 | 41 | /* USER CODE END EC */ 42 | 43 | /* Exported macro ------------------------------------------------------------*/ 44 | /* USER CODE BEGIN EM */ 45 | 46 | /* USER CODE END EM */ 47 | 48 | /* Exported functions prototypes ---------------------------------------------*/ 49 | void NMI_Handler(void); 50 | void HardFault_Handler(void); 51 | void SVC_Handler(void); 52 | void PendSV_Handler(void); 53 | void SysTick_Handler(void); 54 | void ADC1_IRQHandler(void); 55 | void USB_IRQHandler(void); 56 | /* USER CODE BEGIN EFP */ 57 | 58 | /* USER CODE END EFP */ 59 | 60 | #ifdef __cplusplus 61 | } 62 | #endif 63 | 64 | #endif /* __STM32F0xx_IT_H */ 65 | -------------------------------------------------------------------------------- /STM32/Core/Src/main.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : main.c 5 | * @brief : Main program body 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2025 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | /* USER CODE END Header */ 19 | /* Includes ------------------------------------------------------------------*/ 20 | #include "main.h" 21 | #include "usb_device.h" 22 | #include "stdio.h" 23 | #include "../../STM32CubeIDE/Middlewares/USB_Device_Library/usbd_hid_ext.h" 24 | 25 | 26 | /* Private includes ----------------------------------------------------------*/ 27 | /* USER CODE BEGIN Includes */ 28 | 29 | /* USER CODE END Includes */ 30 | 31 | /* Private typedef -----------------------------------------------------------*/ 32 | /* USER CODE BEGIN PTD */ 33 | 34 | /* USER CODE END PTD */ 35 | 36 | /* Private define ------------------------------------------------------------*/ 37 | /* USER CODE BEGIN PD */ 38 | #define KEYBOARD //also need to define in usbd_hid.c! 39 | 40 | #define MOD_ALT_LEFT 0x04 41 | #define WINKEY_LEFT 0xE3 42 | #define ENTER 0x28 43 | #define SPACE 0x2C 44 | #define COMMA 0x36 45 | #define DOT 0x37 46 | #define K_A 0x04 47 | #define K_B 0x05 48 | #define K_C 0x06 49 | #define K_D 0x07 50 | #define K_E 0x08 51 | #define K_G 0x0A 52 | #define K_H 0x0B 53 | #define K_I 0x0C 54 | #define K_L 0x0F 55 | #define K_M 0x10 56 | #define K_N 0x11 57 | #define K_O 0x12 58 | #define K_P 0x13 59 | #define K_R 0x15 60 | #define K_S 0x16 61 | #define K_T 0x17 62 | #define K_U 0x18 63 | #define K_V 0x19 64 | #define K_W 0x1A 65 | 66 | #define K_F8 0x41 67 | #define CAPSLOCK 0x39 68 | /* USER CODE END PD */ 69 | 70 | /* Private macro -------------------------------------------------------------*/ 71 | /* USER CODE BEGIN PM */ 72 | 73 | /* USER CODE END PM */ 74 | 75 | /* Private variables ---------------------------------------------------------*/ 76 | ADC_HandleTypeDef hadc; 77 | 78 | /* USER CODE BEGIN PV */ 79 | volatile uint8_t capslock_; 80 | /* USER CODE END PV */ 81 | 82 | /* Private function prototypes -----------------------------------------------*/ 83 | void SystemClock_Config(void); 84 | static void MX_GPIO_Init(void); 85 | static void MX_ADC_Init(void); 86 | /* USER CODE BEGIN PFP */ 87 | extern USBD_HandleTypeDef hUsbDeviceFS; 88 | void Keyboard_SendChars(uint8_t mod, uint8_t *buf); 89 | void Keyboard_SendSingleChar(uint8_t mod, uint8_t val); 90 | void Keyboard_SendHelloWorld(); 91 | void Keyboard_WaitCapsLock(); 92 | void Keyboard_ShowPassword(); 93 | void Keyboard_TestADC(); 94 | 95 | typedef struct 96 | { 97 | uint8_t MODIFIER; 98 | uint8_t RESERVED; 99 | uint8_t KEYCODE1; 100 | uint8_t KEYCODE2; 101 | uint8_t KEYCODE3; 102 | uint8_t KEYCODE4; 103 | uint8_t KEYCODE5; 104 | uint8_t KEYCODE6; 105 | } kbdHID; 106 | 107 | kbdHID keyboardHID = {0,0,0,0,0,0,0,0}; 108 | /* USER CODE END PFP */ 109 | 110 | /* Private user code ---------------------------------------------------------*/ 111 | /* USER CODE BEGIN 0 */ 112 | void Keyboard_SendChars(uint8_t mod, uint8_t *buf) 113 | { 114 | keyboardHID.MODIFIER = mod; 115 | keyboardHID.KEYCODE1 = buf[0]; 116 | keyboardHID.KEYCODE2 = buf[1]; 117 | keyboardHID.KEYCODE3 = buf[2]; 118 | keyboardHID.KEYCODE4 = buf[3]; 119 | keyboardHID.KEYCODE5 = buf[4]; 120 | keyboardHID.KEYCODE6 = buf[5]; 121 | USBD_HID_SendReport(&hUsbDeviceFS, &keyboardHID, sizeof (keyboardHID)); 122 | HAL_Delay (50); 123 | 124 | //release 125 | keyboardHID.MODIFIER = 0x00; 126 | keyboardHID.KEYCODE1 = 0x00; 127 | keyboardHID.KEYCODE2 = 0x00; 128 | keyboardHID.KEYCODE3 = 0x00; 129 | keyboardHID.KEYCODE4 = 0x00; 130 | keyboardHID.KEYCODE5 = 0x00; 131 | keyboardHID.KEYCODE6 = 0x00; 132 | USBD_HID_SendReport(&hUsbDeviceFS, &keyboardHID, sizeof (keyboardHID)); 133 | HAL_Delay (50); 134 | } 135 | 136 | void Keyboard_SendSingleChar(uint8_t mod, uint8_t val) 137 | { 138 | keyboardHID.MODIFIER = mod; 139 | keyboardHID.KEYCODE1 = val; 140 | USBD_HID_SendReport(&hUsbDeviceFS, &keyboardHID, sizeof (keyboardHID)); 141 | HAL_Delay (50); 142 | 143 | keyboardHID.MODIFIER = 0; 144 | keyboardHID.KEYCODE1 = 0; 145 | USBD_HID_SendReport(&hUsbDeviceFS, &keyboardHID, sizeof (keyboardHID)); 146 | HAL_Delay(50); 147 | } 148 | 149 | //open terminal and send hello world 150 | void Keyboard_SendHelloWorld() 151 | { 152 | uint8_t buf[6] = {0,0,0,0,0,0}; 153 | //winkey+r to open run utility 154 | buf[0] = WINKEY_LEFT; buf[1] = K_R; 155 | Keyboard_SendChars(0,buf); 156 | HAL_Delay(100); 157 | //open command prompt 158 | buf[0] = K_C; buf[1] = K_M; buf[2] = K_D; buf[3] = ENTER; 159 | Keyboard_SendChars(0,buf); 160 | HAL_Delay(600); 161 | buf[0] = K_E; buf[1] = K_C; buf[2] = K_H; buf[3] = K_O; buf[4] = SPACE; 162 | Keyboard_SendChars(0,buf); 163 | buf[0] = K_H; buf[1] = K_E; buf[2] = K_L; buf[3] = 0x00; buf[4] = 0x00; 164 | Keyboard_SendChars(0,buf); 165 | buf[0] = K_L; buf[1] = K_O; buf[2] = SPACE; 166 | Keyboard_SendChars(0,buf); 167 | buf[0] = K_W; buf[1] = K_O; buf[2] = K_R; buf[3] = K_L; buf[4] = K_D; buf[5] = ENTER; 168 | Keyboard_SendChars(0,buf); 169 | } 170 | 171 | //check that PC is unlocked before executing by setting capslock and waiting for user to turn it off 172 | void Keyboard_WaitCapsLock() 173 | { 174 | //try to set capslock until it succeeds 175 | while(capslock_==0) { 176 | Keyboard_SendSingleChar(0x00, CAPSLOCK); 177 | HAL_Delay(1000); 178 | } 179 | while(capslock_==1); //wait here for user to turn off capslock 180 | HAL_Delay(2000); 181 | } 182 | 183 | //send ALT+F8 shortcut to display passwords being typed in 184 | void Keyboard_ShowPassword() 185 | { 186 | keyboardHID.MODIFIER = MOD_ALT_LEFT; 187 | keyboardHID.KEYCODE1 = K_F8; 188 | USBD_HID_SendReport(&hUsbDeviceFS, &keyboardHID, sizeof (keyboardHID)); 189 | HAL_Delay (250); 190 | 191 | keyboardHID.MODIFIER = 0; 192 | keyboardHID.KEYCODE1 = 0; 193 | USBD_HID_SendReport(&hUsbDeviceFS, &keyboardHID, sizeof (keyboardHID)); 194 | HAL_Delay(50); 195 | } 196 | 197 | //send current ADC value over USB 198 | void Keyboard_TestADC() 199 | { 200 | uint8_t buf[6] = {0,0,0,0,0,0}; 201 | uint16_t adc_val = 0; 202 | char adc_str[6]; 203 | HAL_ADC_Start(&hadc); 204 | HAL_ADC_PollForConversion(&hadc,100); 205 | adc_val = HAL_ADC_GetValue(&hadc); 206 | HAL_ADC_Stop(&hadc); 207 | sprintf(adc_str, "%04d", adc_val); 208 | for(uint8_t i=0;i<4;i++){ 209 | if(adc_str[i]==0x30) buf[i]=0x27; //zero case 210 | else buf[i] = adc_str[i] - 0x13; //translate other digits from ASCII to HID 211 | Keyboard_SendSingleChar(0,buf[i]); 212 | } 213 | Keyboard_SendSingleChar(0,ENTER); 214 | HAL_Delay(1000); 215 | } 216 | /* USER CODE END 0 */ 217 | 218 | /** 219 | * @brief The application entry point. 220 | * @retval int 221 | */ 222 | int main(void) 223 | { 224 | 225 | /* USER CODE BEGIN 1 */ 226 | 227 | /* USER CODE END 1 */ 228 | 229 | /* MCU Configuration--------------------------------------------------------*/ 230 | 231 | /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ 232 | HAL_Init(); 233 | 234 | /* USER CODE BEGIN Init */ 235 | 236 | /* USER CODE END Init */ 237 | 238 | /* Configure the system clock */ 239 | SystemClock_Config(); 240 | 241 | /* USER CODE BEGIN SysInit */ 242 | capslock_ = 0; 243 | /* USER CODE END SysInit */ 244 | 245 | /* Initialize all configured peripherals */ 246 | MX_GPIO_Init(); 247 | MX_USB_DEVICE_Init(); 248 | MX_ADC_Init(); 249 | /* USER CODE BEGIN 2 */ 250 | HAL_Delay(3000); 251 | Keyboard_WaitCapsLock(); 252 | //HAL_Delay(10000); 253 | 254 | //get reference ADC value without IR by averaging 16 ADC readings over first 8 seconds 255 | uint16_t adc_val_ini = 0; 256 | for(uint8_t i = 0; i<16; i++) { 257 | HAL_Delay(500); 258 | HAL_ADC_Start(&hadc); 259 | HAL_ADC_PollForConversion(&hadc,100); 260 | adc_val_ini += HAL_ADC_GetValue(&hadc) >> 4; 261 | HAL_ADC_Stop(&hadc); 262 | } 263 | /* USER CODE END 2 */ 264 | 265 | /* Infinite loop */ 266 | /* USER CODE BEGIN WHILE */ 267 | while (1) 268 | { 269 | HAL_ADC_Start(&hadc); 270 | HAL_ADC_PollForConversion(&hadc,100); 271 | //default ADC value seems to sink quite a bit from initial during use, presumably 272 | //due to temperature dependence of the photodiodes - so subtract 200 from initial value 273 | //to use as reference 274 | if(HAL_ADC_GetValue(&hadc) < (adc_val_ini - 200)) { 275 | Keyboard_SendHelloWorld(); 276 | //Keyboard_ShowPassword(); 277 | } 278 | HAL_Delay(500); 279 | /* USER CODE END WHILE */ 280 | 281 | /* USER CODE BEGIN 3 */ 282 | } 283 | /* USER CODE END 3 */ 284 | } 285 | 286 | /** 287 | * @brief System Clock Configuration 288 | * @retval None 289 | */ 290 | void SystemClock_Config(void) 291 | { 292 | RCC_OscInitTypeDef RCC_OscInitStruct = {0}; 293 | RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; 294 | RCC_PeriphCLKInitTypeDef PeriphClkInit = {0}; 295 | 296 | /** Initializes the RCC Oscillators according to the specified parameters 297 | * in the RCC_OscInitTypeDef structure. 298 | */ 299 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI14|RCC_OSCILLATORTYPE_HSI48; 300 | RCC_OscInitStruct.HSI48State = RCC_HSI48_ON; 301 | RCC_OscInitStruct.HSI14State = RCC_HSI14_ON; 302 | RCC_OscInitStruct.HSI14CalibrationValue = 16; 303 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; 304 | if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) 305 | { 306 | Error_Handler(); 307 | } 308 | 309 | /** Initializes the CPU, AHB and APB buses clocks 310 | */ 311 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK 312 | |RCC_CLOCKTYPE_PCLK1; 313 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI48; 314 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; 315 | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; 316 | 317 | if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK) 318 | { 319 | Error_Handler(); 320 | } 321 | PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB; 322 | PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_HSI48; 323 | 324 | if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) 325 | { 326 | Error_Handler(); 327 | } 328 | } 329 | 330 | /** 331 | * @brief ADC Initialization Function 332 | * @param None 333 | * @retval None 334 | */ 335 | static void MX_ADC_Init(void) 336 | { 337 | 338 | /* USER CODE BEGIN ADC_Init 0 */ 339 | 340 | /* USER CODE END ADC_Init 0 */ 341 | 342 | ADC_ChannelConfTypeDef sConfig = {0}; 343 | 344 | /* USER CODE BEGIN ADC_Init 1 */ 345 | 346 | /* USER CODE END ADC_Init 1 */ 347 | 348 | /** Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion) 349 | */ 350 | hadc.Instance = ADC1; 351 | hadc.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV1; 352 | hadc.Init.Resolution = ADC_RESOLUTION_12B; 353 | hadc.Init.DataAlign = ADC_DATAALIGN_RIGHT; 354 | hadc.Init.ScanConvMode = ADC_SCAN_DIRECTION_FORWARD; 355 | hadc.Init.EOCSelection = ADC_EOC_SINGLE_CONV; 356 | hadc.Init.LowPowerAutoWait = DISABLE; 357 | hadc.Init.LowPowerAutoPowerOff = DISABLE; 358 | hadc.Init.ContinuousConvMode = DISABLE; 359 | hadc.Init.DiscontinuousConvMode = DISABLE; 360 | hadc.Init.ExternalTrigConv = ADC_SOFTWARE_START; 361 | hadc.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; 362 | hadc.Init.DMAContinuousRequests = DISABLE; 363 | hadc.Init.Overrun = ADC_OVR_DATA_PRESERVED; 364 | if (HAL_ADC_Init(&hadc) != HAL_OK) 365 | { 366 | Error_Handler(); 367 | } 368 | 369 | /** Configure for the selected ADC regular channel to be converted. 370 | */ 371 | sConfig.Channel = ADC_CHANNEL_8; 372 | sConfig.Rank = ADC_RANK_CHANNEL_NUMBER; 373 | sConfig.SamplingTime = ADC_SAMPLETIME_1CYCLE_5; 374 | if (HAL_ADC_ConfigChannel(&hadc, &sConfig) != HAL_OK) 375 | { 376 | Error_Handler(); 377 | } 378 | /* USER CODE BEGIN ADC_Init 2 */ 379 | 380 | /* USER CODE END ADC_Init 2 */ 381 | 382 | } 383 | 384 | /** 385 | * @brief GPIO Initialization Function 386 | * @param None 387 | * @retval None 388 | */ 389 | static void MX_GPIO_Init(void) 390 | { 391 | /* USER CODE BEGIN MX_GPIO_Init_1 */ 392 | /* USER CODE END MX_GPIO_Init_1 */ 393 | 394 | /* GPIO Ports Clock Enable */ 395 | __HAL_RCC_GPIOB_CLK_ENABLE(); 396 | __HAL_RCC_GPIOA_CLK_ENABLE(); 397 | 398 | /* USER CODE BEGIN MX_GPIO_Init_2 */ 399 | /* USER CODE END MX_GPIO_Init_2 */ 400 | } 401 | 402 | /* USER CODE BEGIN 4 */ 403 | 404 | /* USER CODE END 4 */ 405 | 406 | /** 407 | * @brief This function is executed in case of error occurrence. 408 | * @retval None 409 | */ 410 | void Error_Handler(void) 411 | { 412 | /* USER CODE BEGIN Error_Handler_Debug */ 413 | /* User can add his own implementation to report the HAL error return state */ 414 | __disable_irq(); 415 | while (1) 416 | { 417 | } 418 | /* USER CODE END Error_Handler_Debug */ 419 | } 420 | 421 | #ifdef USE_FULL_ASSERT 422 | /** 423 | * @brief Reports the name of the source file and the source line number 424 | * where the assert_param error has occurred. 425 | * @param file: pointer to the source file name 426 | * @param line: assert_param error line source number 427 | * @retval None 428 | */ 429 | void assert_failed(uint8_t *file, uint32_t line) 430 | { 431 | /* USER CODE BEGIN 6 */ 432 | /* User can add his own implementation to report the file name and line number, 433 | ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ 434 | /* USER CODE END 6 */ 435 | } 436 | #endif /* USE_FULL_ASSERT */ 437 | -------------------------------------------------------------------------------- /STM32/Core/Src/stm32f0xx_hal_msp.c: -------------------------------------------------------------------------------- 1 | 2 | /* USER CODE BEGIN Header */ 3 | /** 4 | ****************************************************************************** 5 | * @file stm32f0xx_hal_msp.c 6 | * @brief This file provides code for the MSP Initialization 7 | * and de-Initialization codes. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * Copyright (c) 2025 STMicroelectronics. 12 | * All rights reserved. 13 | * 14 | * This software is licensed under terms that can be found in the LICENSE file 15 | * in the root directory of this software component. 16 | * If no LICENSE file comes with this software, it is provided AS-IS. 17 | * 18 | ****************************************************************************** 19 | */ 20 | /* USER CODE END Header */ 21 | 22 | /* Includes ------------------------------------------------------------------*/ 23 | #include "main.h" 24 | /* USER CODE BEGIN Includes */ 25 | 26 | /* USER CODE END Includes */ 27 | 28 | /* Private typedef -----------------------------------------------------------*/ 29 | /* USER CODE BEGIN TD */ 30 | 31 | /* USER CODE END TD */ 32 | 33 | /* Private define ------------------------------------------------------------*/ 34 | /* USER CODE BEGIN Define */ 35 | 36 | /* USER CODE END Define */ 37 | 38 | /* Private macro -------------------------------------------------------------*/ 39 | /* USER CODE BEGIN Macro */ 40 | 41 | /* USER CODE END Macro */ 42 | 43 | /* Private variables ---------------------------------------------------------*/ 44 | /* USER CODE BEGIN PV */ 45 | 46 | /* USER CODE END PV */ 47 | 48 | /* Private function prototypes -----------------------------------------------*/ 49 | /* USER CODE BEGIN PFP */ 50 | 51 | /* USER CODE END PFP */ 52 | 53 | /* External functions --------------------------------------------------------*/ 54 | /* USER CODE BEGIN ExternalFunctions */ 55 | 56 | /* USER CODE END ExternalFunctions */ 57 | 58 | /* USER CODE BEGIN 0 */ 59 | 60 | /* USER CODE END 0 */ 61 | /** 62 | * Initializes the Global MSP. 63 | */ 64 | void HAL_MspInit(void) 65 | { 66 | 67 | /* USER CODE BEGIN MspInit 0 */ 68 | 69 | /* USER CODE END MspInit 0 */ 70 | 71 | __HAL_RCC_SYSCFG_CLK_ENABLE(); 72 | __HAL_RCC_PWR_CLK_ENABLE(); 73 | 74 | /* System interrupt init*/ 75 | 76 | __HAL_REMAP_PIN_ENABLE(HAL_REMAP_PA11_PA12); 77 | 78 | /* USER CODE BEGIN MspInit 1 */ 79 | 80 | /* USER CODE END MspInit 1 */ 81 | } 82 | 83 | /** 84 | * @brief ADC MSP Initialization 85 | * This function configures the hardware resources used in this example 86 | * @param hadc: ADC handle pointer 87 | * @retval None 88 | */ 89 | void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) 90 | { 91 | GPIO_InitTypeDef GPIO_InitStruct = {0}; 92 | if(hadc->Instance==ADC1) 93 | { 94 | /* USER CODE BEGIN ADC1_MspInit 0 */ 95 | 96 | /* USER CODE END ADC1_MspInit 0 */ 97 | /* Peripheral clock enable */ 98 | __HAL_RCC_ADC1_CLK_ENABLE(); 99 | 100 | __HAL_RCC_GPIOB_CLK_ENABLE(); 101 | /**ADC GPIO Configuration 102 | PB0 ------> ADC_IN8 103 | */ 104 | GPIO_InitStruct.Pin = GPIO_PIN_0; 105 | GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; 106 | GPIO_InitStruct.Pull = GPIO_NOPULL; 107 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); 108 | 109 | /* ADC1 interrupt Init */ 110 | HAL_NVIC_SetPriority(ADC1_IRQn, 0, 0); 111 | HAL_NVIC_EnableIRQ(ADC1_IRQn); 112 | /* USER CODE BEGIN ADC1_MspInit 1 */ 113 | 114 | /* USER CODE END ADC1_MspInit 1 */ 115 | 116 | } 117 | 118 | } 119 | 120 | /** 121 | * @brief ADC MSP De-Initialization 122 | * This function freeze the hardware resources used in this example 123 | * @param hadc: ADC handle pointer 124 | * @retval None 125 | */ 126 | void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) 127 | { 128 | if(hadc->Instance==ADC1) 129 | { 130 | /* USER CODE BEGIN ADC1_MspDeInit 0 */ 131 | 132 | /* USER CODE END ADC1_MspDeInit 0 */ 133 | /* Peripheral clock disable */ 134 | __HAL_RCC_ADC1_CLK_DISABLE(); 135 | 136 | /**ADC GPIO Configuration 137 | PB0 ------> ADC_IN8 138 | */ 139 | HAL_GPIO_DeInit(GPIOB, GPIO_PIN_0); 140 | 141 | /* ADC1 interrupt DeInit */ 142 | HAL_NVIC_DisableIRQ(ADC1_IRQn); 143 | /* USER CODE BEGIN ADC1_MspDeInit 1 */ 144 | 145 | /* USER CODE END ADC1_MspDeInit 1 */ 146 | } 147 | 148 | } 149 | 150 | /* USER CODE BEGIN 1 */ 151 | 152 | /* USER CODE END 1 */ 153 | -------------------------------------------------------------------------------- /STM32/Core/Src/stm32f0xx_it.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32f0xx_it.c 5 | * @brief Interrupt Service Routines. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2025 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | /* USER CODE END Header */ 19 | 20 | /* Includes ------------------------------------------------------------------*/ 21 | #include "main.h" 22 | #include "stm32f0xx_it.h" 23 | /* Private includes ----------------------------------------------------------*/ 24 | /* USER CODE BEGIN Includes */ 25 | /* USER CODE END Includes */ 26 | 27 | /* Private typedef -----------------------------------------------------------*/ 28 | /* USER CODE BEGIN TD */ 29 | 30 | /* USER CODE END TD */ 31 | 32 | /* Private define ------------------------------------------------------------*/ 33 | /* USER CODE BEGIN PD */ 34 | 35 | /* USER CODE END PD */ 36 | 37 | /* Private macro -------------------------------------------------------------*/ 38 | /* USER CODE BEGIN PM */ 39 | 40 | /* USER CODE END PM */ 41 | 42 | /* Private variables ---------------------------------------------------------*/ 43 | /* USER CODE BEGIN PV */ 44 | 45 | /* USER CODE END PV */ 46 | 47 | /* Private function prototypes -----------------------------------------------*/ 48 | /* USER CODE BEGIN PFP */ 49 | 50 | /* USER CODE END PFP */ 51 | 52 | /* Private user code ---------------------------------------------------------*/ 53 | /* USER CODE BEGIN 0 */ 54 | 55 | /* USER CODE END 0 */ 56 | 57 | /* External variables --------------------------------------------------------*/ 58 | extern PCD_HandleTypeDef hpcd_USB_FS; 59 | extern ADC_HandleTypeDef hadc; 60 | /* USER CODE BEGIN EV */ 61 | 62 | /* USER CODE END EV */ 63 | 64 | /******************************************************************************/ 65 | /* Cortex-M0 Processor Interruption and Exception Handlers */ 66 | /******************************************************************************/ 67 | /** 68 | * @brief This function handles Non maskable interrupt. 69 | */ 70 | void NMI_Handler(void) 71 | { 72 | /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ 73 | 74 | /* USER CODE END NonMaskableInt_IRQn 0 */ 75 | /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ 76 | while (1) 77 | { 78 | } 79 | /* USER CODE END NonMaskableInt_IRQn 1 */ 80 | } 81 | 82 | /** 83 | * @brief This function handles Hard fault interrupt. 84 | */ 85 | void HardFault_Handler(void) 86 | { 87 | /* USER CODE BEGIN HardFault_IRQn 0 */ 88 | 89 | /* USER CODE END HardFault_IRQn 0 */ 90 | while (1) 91 | { 92 | /* USER CODE BEGIN W1_HardFault_IRQn 0 */ 93 | /* USER CODE END W1_HardFault_IRQn 0 */ 94 | } 95 | } 96 | 97 | /** 98 | * @brief This function handles System service call via SWI instruction. 99 | */ 100 | void SVC_Handler(void) 101 | { 102 | /* USER CODE BEGIN SVC_IRQn 0 */ 103 | 104 | /* USER CODE END SVC_IRQn 0 */ 105 | /* USER CODE BEGIN SVC_IRQn 1 */ 106 | 107 | /* USER CODE END SVC_IRQn 1 */ 108 | } 109 | 110 | /** 111 | * @brief This function handles Pendable request for system service. 112 | */ 113 | void PendSV_Handler(void) 114 | { 115 | /* USER CODE BEGIN PendSV_IRQn 0 */ 116 | 117 | /* USER CODE END PendSV_IRQn 0 */ 118 | /* USER CODE BEGIN PendSV_IRQn 1 */ 119 | 120 | /* USER CODE END PendSV_IRQn 1 */ 121 | } 122 | 123 | /** 124 | * @brief This function handles System tick timer. 125 | */ 126 | void SysTick_Handler(void) 127 | { 128 | /* USER CODE BEGIN SysTick_IRQn 0 */ 129 | 130 | /* USER CODE END SysTick_IRQn 0 */ 131 | HAL_IncTick(); 132 | /* USER CODE BEGIN SysTick_IRQn 1 */ 133 | 134 | /* USER CODE END SysTick_IRQn 1 */ 135 | } 136 | 137 | /******************************************************************************/ 138 | /* STM32F0xx Peripheral Interrupt Handlers */ 139 | /* Add here the Interrupt Handlers for the used peripherals. */ 140 | /* For the available peripheral interrupt handler names, */ 141 | /* please refer to the startup file (startup_stm32f0xx.s). */ 142 | /******************************************************************************/ 143 | 144 | /** 145 | * @brief This function handles ADC interrupt. 146 | */ 147 | void ADC1_IRQHandler(void) 148 | { 149 | /* USER CODE BEGIN ADC1_IRQn 0 */ 150 | 151 | /* USER CODE END ADC1_IRQn 0 */ 152 | HAL_ADC_IRQHandler(&hadc); 153 | /* USER CODE BEGIN ADC1_IRQn 1 */ 154 | 155 | /* USER CODE END ADC1_IRQn 1 */ 156 | } 157 | 158 | /** 159 | * @brief This function handles USB global Interrupt / USB wake-up interrupt through EXTI line 18. 160 | */ 161 | void USB_IRQHandler(void) 162 | { 163 | /* USER CODE BEGIN USB_IRQn 0 */ 164 | 165 | /* USER CODE END USB_IRQn 0 */ 166 | HAL_PCD_IRQHandler(&hpcd_USB_FS); 167 | /* USER CODE BEGIN USB_IRQn 1 */ 168 | 169 | /* USER CODE END USB_IRQn 1 */ 170 | } 171 | 172 | /* USER CODE BEGIN 1 */ 173 | 174 | /* USER CODE END 1 */ 175 | -------------------------------------------------------------------------------- /STM32/Core/Src/system_stm32f0xx.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32f0xx.c 4 | * @author MCD Application Team 5 | * @brief CMSIS Cortex-M0 Device Peripheral Access Layer System Source File. 6 | * 7 | * 1. This file provides two functions and one global variable to be called from 8 | * user application: 9 | * - SystemInit(): This function is called at startup just after reset and 10 | * before branch to main program. This call is made inside 11 | * the "startup_stm32f0xx.s" file. 12 | * 13 | * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used 14 | * by the user application to setup the SysTick 15 | * timer or configure other parameters. 16 | * 17 | * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must 18 | * be called whenever the core clock is changed 19 | * during program execution. 20 | * 21 | * 22 | ****************************************************************************** 23 | * @attention 24 | * 25 | * Copyright (c) 2016 STMicroelectronics. 26 | * All rights reserved. 27 | * 28 | * This software is licensed under terms that can be found in the LICENSE file 29 | * in the root directory of this software component. 30 | * If no LICENSE file comes with this software, it is provided AS-IS. 31 | * 32 | ****************************************************************************** 33 | */ 34 | /** @addtogroup CMSIS 35 | * @{ 36 | */ 37 | 38 | /** @addtogroup stm32f0xx_system 39 | * @{ 40 | */ 41 | 42 | /** @addtogroup STM32F0xx_System_Private_Includes 43 | * @{ 44 | */ 45 | 46 | #include "stm32f0xx.h" 47 | 48 | /** 49 | * @} 50 | */ 51 | 52 | /** @addtogroup STM32F0xx_System_Private_TypesDefinitions 53 | * @{ 54 | */ 55 | 56 | /** 57 | * @} 58 | */ 59 | 60 | /** @addtogroup STM32F0xx_System_Private_Defines 61 | * @{ 62 | */ 63 | #if !defined (HSE_VALUE) 64 | #define HSE_VALUE ((uint32_t)8000000) /*!< Default value of the External oscillator in Hz. 65 | This value can be provided and adapted by the user application. */ 66 | #endif /* HSE_VALUE */ 67 | 68 | #if !defined (HSI_VALUE) 69 | #define HSI_VALUE ((uint32_t)8000000) /*!< Default value of the Internal oscillator in Hz. 70 | This value can be provided and adapted by the user application. */ 71 | #endif /* HSI_VALUE */ 72 | 73 | #if !defined (HSI48_VALUE) 74 | #define HSI48_VALUE ((uint32_t)48000000) /*!< Default value of the HSI48 Internal oscillator in Hz. 75 | This value can be provided and adapted by the user application. */ 76 | #endif /* HSI48_VALUE */ 77 | /** 78 | * @} 79 | */ 80 | 81 | /** @addtogroup STM32F0xx_System_Private_Macros 82 | * @{ 83 | */ 84 | 85 | /** 86 | * @} 87 | */ 88 | 89 | /** @addtogroup STM32F0xx_System_Private_Variables 90 | * @{ 91 | */ 92 | /* This variable is updated in three ways: 93 | 1) by calling CMSIS function SystemCoreClockUpdate() 94 | 2) by calling HAL API function HAL_RCC_GetHCLKFreq() 95 | 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency 96 | Note: If you use this function to configure the system clock; then there 97 | is no need to call the 2 first functions listed above, since SystemCoreClock 98 | variable is updated automatically. 99 | */ 100 | uint32_t SystemCoreClock = 8000000; 101 | 102 | const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9}; 103 | const uint8_t APBPrescTable[8] = {0, 0, 0, 0, 1, 2, 3, 4}; 104 | 105 | /** 106 | * @} 107 | */ 108 | 109 | /** @addtogroup STM32F0xx_System_Private_FunctionPrototypes 110 | * @{ 111 | */ 112 | 113 | /** 114 | * @} 115 | */ 116 | 117 | /** @addtogroup STM32F0xx_System_Private_Functions 118 | * @{ 119 | */ 120 | 121 | /** 122 | * @brief Setup the microcontroller system 123 | * @param None 124 | * @retval None 125 | */ 126 | void SystemInit(void) 127 | { 128 | /* NOTE :SystemInit(): This function is called at startup just after reset and 129 | before branch to main program. This call is made inside 130 | the "startup_stm32f0xx.s" file. 131 | User can setups the default system clock (System clock source, PLL Multiplier 132 | and Divider factors, AHB/APBx prescalers and Flash settings). 133 | */ 134 | } 135 | 136 | /** 137 | * @brief Update SystemCoreClock variable according to Clock Register Values. 138 | * The SystemCoreClock variable contains the core clock (HCLK), it can 139 | * be used by the user application to setup the SysTick timer or configure 140 | * other parameters. 141 | * 142 | * @note Each time the core clock (HCLK) changes, this function must be called 143 | * to update SystemCoreClock variable value. Otherwise, any configuration 144 | * based on this variable will be incorrect. 145 | * 146 | * @note - The system frequency computed by this function is not the real 147 | * frequency in the chip. It is calculated based on the predefined 148 | * constant and the selected clock source: 149 | * 150 | * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*) 151 | * 152 | * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**) 153 | * 154 | * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**) 155 | * or HSI_VALUE(*) multiplied/divided by the PLL factors. 156 | * 157 | * - If SYSCLK source is HSI48, SystemCoreClock will contain the HSI48_VALUE(***) 158 | * 159 | * (*) HSI_VALUE is a constant defined in stm32f0xx_hal_conf.h file (default value 160 | * 8 MHz) but the real value may vary depending on the variations 161 | * in voltage and temperature. 162 | * 163 | * (**) HSE_VALUE is a constant defined in stm32f0xx_hal_conf.h file (its value 164 | * depends on the application requirements), user has to ensure that HSE_VALUE 165 | * is same as the real frequency of the crystal used. Otherwise, this function 166 | * may have wrong result. 167 | * 168 | * (***) HSI48_VALUE is a constant defined in stm32f0xx_hal_conf.h file (default value 169 | * 48 MHz) but the real value may vary depending on the variations 170 | * in voltage and temperature. 171 | * 172 | * - The result of this function could be not correct when using fractional 173 | * value for HSE crystal. 174 | * 175 | * @param None 176 | * @retval None 177 | */ 178 | void SystemCoreClockUpdate (void) 179 | { 180 | uint32_t tmp = 0, pllmull = 0, pllsource = 0, predivfactor = 0; 181 | 182 | /* Get SYSCLK source -------------------------------------------------------*/ 183 | tmp = RCC->CFGR & RCC_CFGR_SWS; 184 | 185 | switch (tmp) 186 | { 187 | case RCC_CFGR_SWS_HSI: /* HSI used as system clock */ 188 | SystemCoreClock = HSI_VALUE; 189 | break; 190 | case RCC_CFGR_SWS_HSE: /* HSE used as system clock */ 191 | SystemCoreClock = HSE_VALUE; 192 | break; 193 | case RCC_CFGR_SWS_PLL: /* PLL used as system clock */ 194 | /* Get PLL clock source and multiplication factor ----------------------*/ 195 | pllmull = RCC->CFGR & RCC_CFGR_PLLMUL; 196 | pllsource = RCC->CFGR & RCC_CFGR_PLLSRC; 197 | pllmull = ( pllmull >> 18) + 2; 198 | predivfactor = (RCC->CFGR2 & RCC_CFGR2_PREDIV) + 1; 199 | 200 | if (pllsource == RCC_CFGR_PLLSRC_HSE_PREDIV) 201 | { 202 | /* HSE used as PLL clock source : SystemCoreClock = HSE/PREDIV * PLLMUL */ 203 | SystemCoreClock = (HSE_VALUE/predivfactor) * pllmull; 204 | } 205 | #if defined(STM32F042x6) || defined(STM32F048xx) || defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || defined(STM32F091xC) || defined(STM32F098xx) 206 | else if (pllsource == RCC_CFGR_PLLSRC_HSI48_PREDIV) 207 | { 208 | /* HSI48 used as PLL clock source : SystemCoreClock = HSI48/PREDIV * PLLMUL */ 209 | SystemCoreClock = (HSI48_VALUE/predivfactor) * pllmull; 210 | } 211 | #endif /* STM32F042x6 || STM32F048xx || STM32F071xB || STM32F072xB || STM32F078xx || STM32F091xC || STM32F098xx */ 212 | else 213 | { 214 | #if defined(STM32F042x6) || defined(STM32F048xx) || defined(STM32F070x6) \ 215 | || defined(STM32F078xx) || defined(STM32F071xB) || defined(STM32F072xB) \ 216 | || defined(STM32F070xB) || defined(STM32F091xC) || defined(STM32F098xx) || defined(STM32F030xC) 217 | /* HSI used as PLL clock source : SystemCoreClock = HSI/PREDIV * PLLMUL */ 218 | SystemCoreClock = (HSI_VALUE/predivfactor) * pllmull; 219 | #else 220 | /* HSI used as PLL clock source : SystemCoreClock = HSI/2 * PLLMUL */ 221 | SystemCoreClock = (HSI_VALUE >> 1) * pllmull; 222 | #endif /* STM32F042x6 || STM32F048xx || STM32F070x6 || 223 | STM32F071xB || STM32F072xB || STM32F078xx || STM32F070xB || 224 | STM32F091xC || STM32F098xx || STM32F030xC */ 225 | } 226 | break; 227 | default: /* HSI used as system clock */ 228 | SystemCoreClock = HSI_VALUE; 229 | break; 230 | } 231 | /* Compute HCLK clock frequency ----------------*/ 232 | /* Get HCLK prescaler */ 233 | tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)]; 234 | /* HCLK clock frequency */ 235 | SystemCoreClock >>= tmp; 236 | } 237 | 238 | /** 239 | * @} 240 | */ 241 | 242 | /** 243 | * @} 244 | */ 245 | 246 | /** 247 | * @} 248 | */ 249 | 250 | -------------------------------------------------------------------------------- /STM32/Debug/RubberDuckyHelloWorld.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enblack0/Hidden-HID-v2/4f44eee1a87c04dfad725e9ba3b24868d8b28b1a/STM32/Debug/RubberDuckyHelloWorld.elf -------------------------------------------------------------------------------- /STM32/Middlewares/ST/STM32_USB_Device_Library/Class/HID/Inc/usbd_hid.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_hid.h 4 | * @author MCD Application Team 5 | * @brief Header file for the usbd_hid_core.c file. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

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

11 | * 12 | * This software component is licensed by ST under Ultimate Liberty license 13 | * SLA0044, the "License"; You may not use this file except in compliance with 14 | * the License. You may obtain a copy of the License at: 15 | * www.st.com/SLA0044 16 | * 17 | ****************************************************************************** 18 | */ 19 | 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __USB_HID_H 22 | #define __USB_HID_H 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "usbd_ioreq.h" 30 | 31 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 32 | * @{ 33 | */ 34 | 35 | /** @defgroup USBD_HID 36 | * @brief This file is the Header file for usbd_hid.c 37 | * @{ 38 | */ 39 | 40 | 41 | /** @defgroup USBD_HID_Exported_Defines 42 | * @{ 43 | */ 44 | #define HID_EPIN_ADDR 0x81U 45 | #define HID_EPIN_SIZE 0x08U //EB new 46 | 47 | #define HID_EPOUT_ADDR 0x01 //EB new 48 | #define HID_EPOUT_SIZE 0x01 //EB new 49 | 50 | #define USB_HID_CONFIG_DESC_SIZ 41U //EB new 51 | #define USB_HID_DESC_SIZ 9U 52 | #define HID_MOUSE_REPORT_DESC_SIZE 74U 53 | #define HID_KBD_REPORT_DESC_SIZE 63U //EB new 54 | 55 | #define HID_DESCRIPTOR_TYPE 0x21U 56 | #define HID_REPORT_DESC 0x22U 57 | 58 | #ifndef HID_HS_BINTERVAL 59 | #define HID_HS_BINTERVAL 0x07U 60 | #endif /* HID_HS_BINTERVAL */ 61 | 62 | #ifndef HID_FS_BINTERVAL 63 | #define HID_FS_BINTERVAL 0x0AU 64 | #endif /* HID_FS_BINTERVAL */ 65 | 66 | #define HID_REQ_SET_PROTOCOL 0x0BU 67 | #define HID_REQ_GET_PROTOCOL 0x03U 68 | 69 | #define HID_REQ_SET_IDLE 0x0AU 70 | #define HID_REQ_GET_IDLE 0x02U 71 | 72 | #define HID_REQ_SET_REPORT 0x09U 73 | #define HID_REQ_GET_REPORT 0x01U 74 | /** 75 | * @} 76 | */ 77 | 78 | 79 | /** @defgroup USBD_CORE_Exported_TypesDefinitions 80 | * @{ 81 | */ 82 | typedef enum 83 | { 84 | HID_IDLE = 0, 85 | HID_BUSY, 86 | } 87 | HID_StateTypeDef; 88 | 89 | 90 | typedef struct 91 | { 92 | uint32_t Protocol; 93 | uint32_t IdleState; 94 | uint32_t AltSetting; 95 | HID_StateTypeDef state; 96 | } 97 | USBD_HID_HandleTypeDef; 98 | /** 99 | * @} 100 | */ 101 | 102 | 103 | 104 | /** @defgroup USBD_CORE_Exported_Macros 105 | * @{ 106 | */ 107 | 108 | /** 109 | * @} 110 | */ 111 | 112 | /** @defgroup USBD_CORE_Exported_Variables 113 | * @{ 114 | */ 115 | 116 | extern USBD_ClassTypeDef USBD_HID; 117 | #define USBD_HID_CLASS &USBD_HID 118 | /** 119 | * @} 120 | */ 121 | 122 | /** @defgroup USB_CORE_Exported_Functions 123 | * @{ 124 | */ 125 | uint8_t USBD_HID_SendReport(USBD_HandleTypeDef *pdev, 126 | uint8_t *report, 127 | uint16_t len); 128 | 129 | uint32_t USBD_HID_GetPollingInterval(USBD_HandleTypeDef *pdev); 130 | 131 | /** 132 | * @} 133 | */ 134 | 135 | #ifdef __cplusplus 136 | } 137 | #endif 138 | 139 | #endif /* __USB_HID_H */ 140 | /** 141 | * @} 142 | */ 143 | 144 | /** 145 | * @} 146 | */ 147 | 148 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 149 | -------------------------------------------------------------------------------- /STM32/Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_core.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_core.h 4 | * @author MCD Application Team 5 | * @brief Header file for usbd_core.c file 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

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

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

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

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

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

11 | * 12 | * This software component is licensed by ST under Ultimate Liberty license 13 | * SLA0044, the "License"; You may not use this file except in compliance with 14 | * the License. You may obtain a copy of the License at: 15 | * www.st.com/SLA0044 16 | * 17 | ****************************************************************************** 18 | */ 19 | 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __USBD_DEF_H 22 | #define __USBD_DEF_H 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "usbd_conf.h" 30 | 31 | /** @addtogroup STM32_USBD_DEVICE_LIBRARY 32 | * @{ 33 | */ 34 | 35 | /** @defgroup USB_DEF 36 | * @brief general defines for the usb device library file 37 | * @{ 38 | */ 39 | 40 | /** @defgroup USB_DEF_Exported_Defines 41 | * @{ 42 | */ 43 | 44 | #ifndef NULL 45 | #define NULL 0U 46 | #endif /* NULL */ 47 | 48 | #ifndef USBD_MAX_NUM_INTERFACES 49 | #define USBD_MAX_NUM_INTERFACES 1U 50 | #endif /* USBD_MAX_NUM_CONFIGURATION */ 51 | 52 | #ifndef USBD_MAX_NUM_CONFIGURATION 53 | #define USBD_MAX_NUM_CONFIGURATION 1U 54 | #endif /* USBD_MAX_NUM_CONFIGURATION */ 55 | 56 | #ifndef USBD_LPM_ENABLED 57 | #define USBD_LPM_ENABLED 0U 58 | #endif /* USBD_LPM_ENABLED */ 59 | 60 | #ifndef USBD_SELF_POWERED 61 | #define USBD_SELF_POWERED 1U 62 | #endif /*USBD_SELF_POWERED */ 63 | 64 | #ifndef USBD_SUPPORT_USER_STRING_DESC 65 | #define USBD_SUPPORT_USER_STRING_DESC 0U 66 | #endif /* USBD_SUPPORT_USER_STRING_DESC */ 67 | 68 | #define USB_LEN_DEV_QUALIFIER_DESC 0x0AU 69 | #define USB_LEN_DEV_DESC 0x12U 70 | #define USB_LEN_CFG_DESC 0x09U 71 | #define USB_LEN_IF_DESC 0x09U 72 | #define USB_LEN_EP_DESC 0x07U 73 | #define USB_LEN_OTG_DESC 0x03U 74 | #define USB_LEN_LANGID_STR_DESC 0x04U 75 | #define USB_LEN_OTHER_SPEED_DESC_SIZ 0x09U 76 | 77 | #define USBD_IDX_LANGID_STR 0x00U 78 | #define USBD_IDX_MFC_STR 0x01U 79 | #define USBD_IDX_PRODUCT_STR 0x02U 80 | #define USBD_IDX_SERIAL_STR 0x03U 81 | #define USBD_IDX_CONFIG_STR 0x04U 82 | #define USBD_IDX_INTERFACE_STR 0x05U 83 | 84 | #define USB_REQ_TYPE_STANDARD 0x00U 85 | #define USB_REQ_TYPE_CLASS 0x20U 86 | #define USB_REQ_TYPE_VENDOR 0x40U 87 | #define USB_REQ_TYPE_MASK 0x60U 88 | 89 | #define USB_REQ_RECIPIENT_DEVICE 0x00U 90 | #define USB_REQ_RECIPIENT_INTERFACE 0x01U 91 | #define USB_REQ_RECIPIENT_ENDPOINT 0x02U 92 | #define USB_REQ_RECIPIENT_MASK 0x03U 93 | 94 | #define USB_REQ_GET_STATUS 0x00U 95 | #define USB_REQ_CLEAR_FEATURE 0x01U 96 | #define USB_REQ_SET_FEATURE 0x03U 97 | #define USB_REQ_SET_ADDRESS 0x05U 98 | #define USB_REQ_GET_DESCRIPTOR 0x06U 99 | #define USB_REQ_SET_DESCRIPTOR 0x07U 100 | #define USB_REQ_GET_CONFIGURATION 0x08U 101 | #define USB_REQ_SET_CONFIGURATION 0x09U 102 | #define USB_REQ_GET_INTERFACE 0x0AU 103 | #define USB_REQ_SET_INTERFACE 0x0BU 104 | #define USB_REQ_SYNCH_FRAME 0x0CU 105 | 106 | #define USB_DESC_TYPE_DEVICE 0x01U 107 | #define USB_DESC_TYPE_CONFIGURATION 0x02U 108 | #define USB_DESC_TYPE_STRING 0x03U 109 | #define USB_DESC_TYPE_INTERFACE 0x04U 110 | #define USB_DESC_TYPE_ENDPOINT 0x05U 111 | #define USB_DESC_TYPE_DEVICE_QUALIFIER 0x06U 112 | #define USB_DESC_TYPE_OTHER_SPEED_CONFIGURATION 0x07U 113 | #define USB_DESC_TYPE_BOS 0x0FU 114 | 115 | #define USB_CONFIG_REMOTE_WAKEUP 0x02U 116 | #define USB_CONFIG_SELF_POWERED 0x01U 117 | 118 | #define USB_FEATURE_EP_HALT 0x00U 119 | #define USB_FEATURE_REMOTE_WAKEUP 0x01U 120 | #define USB_FEATURE_TEST_MODE 0x02U 121 | 122 | #define USB_DEVICE_CAPABITY_TYPE 0x10U 123 | 124 | #define USB_HS_MAX_PACKET_SIZE 512U 125 | #define USB_FS_MAX_PACKET_SIZE 64U 126 | #define USB_MAX_EP0_SIZE 64U 127 | 128 | /* Device Status */ 129 | #define USBD_STATE_DEFAULT 0x01U 130 | #define USBD_STATE_ADDRESSED 0x02U 131 | #define USBD_STATE_CONFIGURED 0x03U 132 | #define USBD_STATE_SUSPENDED 0x04U 133 | 134 | 135 | /* EP0 State */ 136 | #define USBD_EP0_IDLE 0x00U 137 | #define USBD_EP0_SETUP 0x01U 138 | #define USBD_EP0_DATA_IN 0x02U 139 | #define USBD_EP0_DATA_OUT 0x03U 140 | #define USBD_EP0_STATUS_IN 0x04U 141 | #define USBD_EP0_STATUS_OUT 0x05U 142 | #define USBD_EP0_STALL 0x06U 143 | 144 | #define USBD_EP_TYPE_CTRL 0x00U 145 | #define USBD_EP_TYPE_ISOC 0x01U 146 | #define USBD_EP_TYPE_BULK 0x02U 147 | #define USBD_EP_TYPE_INTR 0x03U 148 | 149 | 150 | /** 151 | * @} 152 | */ 153 | 154 | 155 | /** @defgroup USBD_DEF_Exported_TypesDefinitions 156 | * @{ 157 | */ 158 | 159 | typedef struct usb_setup_req 160 | { 161 | uint8_t bmRequest; 162 | uint8_t bRequest; 163 | uint16_t wValue; 164 | uint16_t wIndex; 165 | uint16_t wLength; 166 | } USBD_SetupReqTypedef; 167 | 168 | struct _USBD_HandleTypeDef; 169 | 170 | typedef struct _Device_cb 171 | { 172 | uint8_t (*Init)(struct _USBD_HandleTypeDef *pdev, uint8_t cfgidx); 173 | uint8_t (*DeInit)(struct _USBD_HandleTypeDef *pdev, uint8_t cfgidx); 174 | /* Control Endpoints*/ 175 | uint8_t (*Setup)(struct _USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 176 | uint8_t (*EP0_TxSent)(struct _USBD_HandleTypeDef *pdev); 177 | uint8_t (*EP0_RxReady)(struct _USBD_HandleTypeDef *pdev); 178 | /* Class Specific Endpoints*/ 179 | uint8_t (*DataIn)(struct _USBD_HandleTypeDef *pdev, uint8_t epnum); 180 | uint8_t (*DataOut)(struct _USBD_HandleTypeDef *pdev, uint8_t epnum); 181 | uint8_t (*SOF)(struct _USBD_HandleTypeDef *pdev); 182 | uint8_t (*IsoINIncomplete)(struct _USBD_HandleTypeDef *pdev, uint8_t epnum); 183 | uint8_t (*IsoOUTIncomplete)(struct _USBD_HandleTypeDef *pdev, uint8_t epnum); 184 | 185 | uint8_t *(*GetHSConfigDescriptor)(uint16_t *length); 186 | uint8_t *(*GetFSConfigDescriptor)(uint16_t *length); 187 | uint8_t *(*GetOtherSpeedConfigDescriptor)(uint16_t *length); 188 | uint8_t *(*GetDeviceQualifierDescriptor)(uint16_t *length); 189 | #if (USBD_SUPPORT_USER_STRING_DESC == 1U) 190 | uint8_t *(*GetUsrStrDescriptor)(struct _USBD_HandleTypeDef *pdev, uint8_t index, uint16_t *length); 191 | #endif 192 | 193 | } USBD_ClassTypeDef; 194 | 195 | /* Following USB Device Speed */ 196 | typedef enum 197 | { 198 | USBD_SPEED_HIGH = 0U, 199 | USBD_SPEED_FULL = 1U, 200 | USBD_SPEED_LOW = 2U, 201 | } USBD_SpeedTypeDef; 202 | 203 | /* Following USB Device status */ 204 | typedef enum 205 | { 206 | USBD_OK = 0U, 207 | USBD_BUSY, 208 | USBD_FAIL, 209 | } USBD_StatusTypeDef; 210 | 211 | /* USB Device descriptors structure */ 212 | typedef struct 213 | { 214 | uint8_t *(*GetDeviceDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length); 215 | uint8_t *(*GetLangIDStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length); 216 | uint8_t *(*GetManufacturerStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length); 217 | uint8_t *(*GetProductStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length); 218 | uint8_t *(*GetSerialStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length); 219 | uint8_t *(*GetConfigurationStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length); 220 | uint8_t *(*GetInterfaceStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length); 221 | #if (USBD_LPM_ENABLED == 1U) 222 | uint8_t *(*GetBOSDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length); 223 | #endif 224 | } USBD_DescriptorsTypeDef; 225 | 226 | /* USB Device handle structure */ 227 | typedef struct 228 | { 229 | uint32_t status; 230 | uint32_t is_used; 231 | uint32_t total_length; 232 | uint32_t rem_length; 233 | uint32_t maxpacket; 234 | } USBD_EndpointTypeDef; 235 | 236 | /* USB Device handle structure */ 237 | typedef struct _USBD_HandleTypeDef 238 | { 239 | uint8_t id; 240 | uint32_t dev_config; 241 | uint32_t dev_default_config; 242 | uint32_t dev_config_status; 243 | USBD_SpeedTypeDef dev_speed; 244 | USBD_EndpointTypeDef ep_in[16]; 245 | USBD_EndpointTypeDef ep_out[16]; 246 | uint32_t ep0_state; 247 | uint32_t ep0_data_len; 248 | uint8_t dev_state; 249 | uint8_t dev_old_state; 250 | uint8_t dev_address; 251 | uint8_t dev_connection_status; 252 | uint8_t dev_test_mode; 253 | uint32_t dev_remote_wakeup; 254 | 255 | USBD_SetupReqTypedef request; 256 | USBD_DescriptorsTypeDef *pDesc; 257 | USBD_ClassTypeDef *pClass; 258 | void *pClassData; 259 | void *pUserData; 260 | void *pData; 261 | } USBD_HandleTypeDef; 262 | 263 | /** 264 | * @} 265 | */ 266 | 267 | 268 | 269 | /** @defgroup USBD_DEF_Exported_Macros 270 | * @{ 271 | */ 272 | #define SWAPBYTE(addr) (((uint16_t)(*((uint8_t *)(addr)))) + \ 273 | (((uint16_t)(*(((uint8_t *)(addr)) + 1U))) << 8U)) 274 | 275 | #define LOBYTE(x) ((uint8_t)((x) & 0x00FFU)) 276 | #define HIBYTE(x) ((uint8_t)(((x) & 0xFF00U) >> 8U)) 277 | #define MIN(a, b) (((a) < (b)) ? (a) : (b)) 278 | #define MAX(a, b) (((a) > (b)) ? (a) : (b)) 279 | 280 | 281 | #if defined ( __GNUC__ ) 282 | #ifndef __weak 283 | #define __weak __attribute__((weak)) 284 | #endif /* __weak */ 285 | #ifndef __packed 286 | #define __packed __attribute__((__packed__)) 287 | #endif /* __packed */ 288 | #endif /* __GNUC__ */ 289 | 290 | 291 | /* In HS mode and when the DMA is used, all variables and data structures dealing 292 | with the DMA during the transaction process should be 4-bytes aligned */ 293 | 294 | #if defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */ 295 | #ifndef __ALIGN_END 296 | #define __ALIGN_END __attribute__ ((aligned (4U))) 297 | #endif /* __ALIGN_END */ 298 | #ifndef __ALIGN_BEGIN 299 | #define __ALIGN_BEGIN 300 | #endif /* __ALIGN_BEGIN */ 301 | #else 302 | #ifndef __ALIGN_END 303 | #define __ALIGN_END 304 | #endif /* __ALIGN_END */ 305 | #ifndef __ALIGN_BEGIN 306 | #if defined (__CC_ARM) /* ARM Compiler */ 307 | #define __ALIGN_BEGIN __align(4U) 308 | #elif defined (__ICCARM__) /* IAR Compiler */ 309 | #define __ALIGN_BEGIN 310 | #endif /* __CC_ARM */ 311 | #endif /* __ALIGN_BEGIN */ 312 | #endif /* __GNUC__ */ 313 | 314 | 315 | /** 316 | * @} 317 | */ 318 | 319 | /** @defgroup USBD_DEF_Exported_Variables 320 | * @{ 321 | */ 322 | 323 | /** 324 | * @} 325 | */ 326 | 327 | /** @defgroup USBD_DEF_Exported_FunctionsPrototype 328 | * @{ 329 | */ 330 | 331 | /** 332 | * @} 333 | */ 334 | 335 | #ifdef __cplusplus 336 | } 337 | #endif 338 | 339 | #endif /* __USBD_DEF_H */ 340 | 341 | /** 342 | * @} 343 | */ 344 | 345 | /** 346 | * @} 347 | */ 348 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 349 | -------------------------------------------------------------------------------- /STM32/Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_ioreq.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_ioreq.h 4 | * @author MCD Application Team 5 | * @brief Header file for the usbd_ioreq.c file 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

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

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

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

11 | * 12 | * This software component is licensed by ST under Ultimate Liberty license 13 | * SLA0044, the "License"; You may not use this file except in compliance with 14 | * the License. You may obtain a copy of the License at: 15 | * www.st.com/SLA0044 16 | * 17 | ****************************************************************************** 18 | */ 19 | 20 | /* Includes ------------------------------------------------------------------*/ 21 | #include "usbd_core.h" 22 | 23 | /** @addtogroup STM32_USBD_DEVICE_LIBRARY 24 | * @{ 25 | */ 26 | 27 | 28 | /** @defgroup USBD_CORE 29 | * @brief usbd core module 30 | * @{ 31 | */ 32 | 33 | /** @defgroup USBD_CORE_Private_TypesDefinitions 34 | * @{ 35 | */ 36 | 37 | /** 38 | * @} 39 | */ 40 | 41 | 42 | /** @defgroup USBD_CORE_Private_Defines 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @} 48 | */ 49 | 50 | 51 | /** @defgroup USBD_CORE_Private_Macros 52 | * @{ 53 | */ 54 | 55 | /** 56 | * @} 57 | */ 58 | 59 | 60 | /** @defgroup USBD_CORE_Private_FunctionPrototypes 61 | * @{ 62 | */ 63 | 64 | /** 65 | * @} 66 | */ 67 | 68 | /** @defgroup USBD_CORE_Private_Variables 69 | * @{ 70 | */ 71 | 72 | /** 73 | * @} 74 | */ 75 | 76 | 77 | /** @defgroup USBD_CORE_Private_Functions 78 | * @{ 79 | */ 80 | 81 | /** 82 | * @brief USBD_Init 83 | * Initializes the device stack and load the class driver 84 | * @param pdev: device instance 85 | * @param pdesc: Descriptor structure address 86 | * @param id: Low level core index 87 | * @retval None 88 | */ 89 | USBD_StatusTypeDef USBD_Init(USBD_HandleTypeDef *pdev, 90 | USBD_DescriptorsTypeDef *pdesc, uint8_t id) 91 | { 92 | /* Check whether the USB Host handle is valid */ 93 | if (pdev == NULL) 94 | { 95 | #if (USBD_DEBUG_LEVEL > 1U) 96 | USBD_ErrLog("Invalid Device handle"); 97 | #endif 98 | return USBD_FAIL; 99 | } 100 | 101 | /* Unlink previous class*/ 102 | if (pdev->pClass != NULL) 103 | { 104 | pdev->pClass = NULL; 105 | } 106 | 107 | /* Assign USBD Descriptors */ 108 | if (pdesc != NULL) 109 | { 110 | pdev->pDesc = pdesc; 111 | } 112 | 113 | /* Set Device initial State */ 114 | pdev->dev_state = USBD_STATE_DEFAULT; 115 | pdev->id = id; 116 | /* Initialize low level driver */ 117 | USBD_LL_Init(pdev); 118 | 119 | return USBD_OK; 120 | } 121 | 122 | /** 123 | * @brief USBD_DeInit 124 | * Re-Initialize th device library 125 | * @param pdev: device instance 126 | * @retval status: status 127 | */ 128 | USBD_StatusTypeDef USBD_DeInit(USBD_HandleTypeDef *pdev) 129 | { 130 | /* Set Default State */ 131 | pdev->dev_state = USBD_STATE_DEFAULT; 132 | 133 | /* Free Class Resources */ 134 | pdev->pClass->DeInit(pdev, (uint8_t)pdev->dev_config); 135 | 136 | /* Stop the low level driver */ 137 | USBD_LL_Stop(pdev); 138 | 139 | /* Initialize low level driver */ 140 | USBD_LL_DeInit(pdev); 141 | 142 | return USBD_OK; 143 | } 144 | 145 | /** 146 | * @brief USBD_RegisterClass 147 | * Link class driver to Device Core. 148 | * @param pDevice : Device Handle 149 | * @param pclass: Class handle 150 | * @retval USBD Status 151 | */ 152 | USBD_StatusTypeDef USBD_RegisterClass(USBD_HandleTypeDef *pdev, USBD_ClassTypeDef *pclass) 153 | { 154 | USBD_StatusTypeDef status = USBD_OK; 155 | if (pclass != NULL) 156 | { 157 | /* link the class to the USB Device handle */ 158 | pdev->pClass = pclass; 159 | status = USBD_OK; 160 | } 161 | else 162 | { 163 | #if (USBD_DEBUG_LEVEL > 1U) 164 | USBD_ErrLog("Invalid Class handle"); 165 | #endif 166 | status = USBD_FAIL; 167 | } 168 | 169 | return status; 170 | } 171 | 172 | /** 173 | * @brief USBD_Start 174 | * Start the USB Device Core. 175 | * @param pdev: Device Handle 176 | * @retval USBD Status 177 | */ 178 | USBD_StatusTypeDef USBD_Start(USBD_HandleTypeDef *pdev) 179 | { 180 | /* Start the low level driver */ 181 | USBD_LL_Start(pdev); 182 | 183 | return USBD_OK; 184 | } 185 | 186 | /** 187 | * @brief USBD_Stop 188 | * Stop the USB Device Core. 189 | * @param pdev: Device Handle 190 | * @retval USBD Status 191 | */ 192 | USBD_StatusTypeDef USBD_Stop(USBD_HandleTypeDef *pdev) 193 | { 194 | /* Free Class Resources */ 195 | pdev->pClass->DeInit(pdev, (uint8_t)pdev->dev_config); 196 | 197 | /* Stop the low level driver */ 198 | USBD_LL_Stop(pdev); 199 | 200 | return USBD_OK; 201 | } 202 | 203 | /** 204 | * @brief USBD_RunTestMode 205 | * Launch test mode process 206 | * @param pdev: device instance 207 | * @retval status 208 | */ 209 | USBD_StatusTypeDef USBD_RunTestMode(USBD_HandleTypeDef *pdev) 210 | { 211 | /* Prevent unused argument compilation warning */ 212 | UNUSED(pdev); 213 | 214 | return USBD_OK; 215 | } 216 | 217 | /** 218 | * @brief USBD_SetClassConfig 219 | * Configure device and start the interface 220 | * @param pdev: device instance 221 | * @param cfgidx: configuration index 222 | * @retval status 223 | */ 224 | 225 | USBD_StatusTypeDef USBD_SetClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx) 226 | { 227 | USBD_StatusTypeDef ret = USBD_FAIL; 228 | 229 | if (pdev->pClass != NULL) 230 | { 231 | /* Set configuration and Start the Class*/ 232 | if (pdev->pClass->Init(pdev, cfgidx) == 0U) 233 | { 234 | ret = USBD_OK; 235 | } 236 | } 237 | 238 | return ret; 239 | } 240 | 241 | /** 242 | * @brief USBD_ClrClassConfig 243 | * Clear current configuration 244 | * @param pdev: device instance 245 | * @param cfgidx: configuration index 246 | * @retval status: USBD_StatusTypeDef 247 | */ 248 | USBD_StatusTypeDef USBD_ClrClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx) 249 | { 250 | /* Clear configuration and De-initialize the Class process*/ 251 | pdev->pClass->DeInit(pdev, cfgidx); 252 | 253 | return USBD_OK; 254 | } 255 | 256 | 257 | /** 258 | * @brief USBD_SetupStage 259 | * Handle the setup stage 260 | * @param pdev: device instance 261 | * @retval status 262 | */ 263 | USBD_StatusTypeDef USBD_LL_SetupStage(USBD_HandleTypeDef *pdev, uint8_t *psetup) 264 | { 265 | USBD_ParseSetupRequest(&pdev->request, psetup); 266 | 267 | pdev->ep0_state = USBD_EP0_SETUP; 268 | 269 | pdev->ep0_data_len = pdev->request.wLength; 270 | 271 | switch (pdev->request.bmRequest & 0x1FU) 272 | { 273 | case USB_REQ_RECIPIENT_DEVICE: 274 | USBD_StdDevReq(pdev, &pdev->request); 275 | break; 276 | 277 | case USB_REQ_RECIPIENT_INTERFACE: 278 | USBD_StdItfReq(pdev, &pdev->request); 279 | break; 280 | 281 | case USB_REQ_RECIPIENT_ENDPOINT: 282 | USBD_StdEPReq(pdev, &pdev->request); 283 | break; 284 | 285 | default: 286 | USBD_LL_StallEP(pdev, (pdev->request.bmRequest & 0x80U)); 287 | break; 288 | } 289 | 290 | return USBD_OK; 291 | } 292 | 293 | /** 294 | * @brief USBD_DataOutStage 295 | * Handle data OUT stage 296 | * @param pdev: device instance 297 | * @param epnum: endpoint index 298 | * @retval status 299 | */ 300 | USBD_StatusTypeDef USBD_LL_DataOutStage(USBD_HandleTypeDef *pdev, 301 | uint8_t epnum, uint8_t *pdata) 302 | { 303 | USBD_EndpointTypeDef *pep; 304 | 305 | if (epnum == 0U) 306 | { 307 | pep = &pdev->ep_out[0]; 308 | 309 | if (pdev->ep0_state == USBD_EP0_DATA_OUT) 310 | { 311 | if (pep->rem_length > pep->maxpacket) 312 | { 313 | pep->rem_length -= pep->maxpacket; 314 | 315 | USBD_CtlContinueRx(pdev, pdata, 316 | (uint16_t)MIN(pep->rem_length, pep->maxpacket)); 317 | } 318 | else 319 | { 320 | if ((pdev->pClass->EP0_RxReady != NULL) && 321 | (pdev->dev_state == USBD_STATE_CONFIGURED)) 322 | { 323 | pdev->pClass->EP0_RxReady(pdev); 324 | } 325 | USBD_CtlSendStatus(pdev); 326 | } 327 | } 328 | else 329 | { 330 | if (pdev->ep0_state == USBD_EP0_STATUS_OUT) 331 | { 332 | /* 333 | * STATUS PHASE completed, update ep0_state to idle 334 | */ 335 | pdev->ep0_state = USBD_EP0_IDLE; 336 | USBD_LL_StallEP(pdev, 0U); 337 | } 338 | } 339 | } 340 | else if ((pdev->pClass->DataOut != NULL) && 341 | (pdev->dev_state == USBD_STATE_CONFIGURED)) 342 | { 343 | pdev->pClass->DataOut(pdev, epnum); 344 | } 345 | else 346 | { 347 | /* should never be in this condition */ 348 | return USBD_FAIL; 349 | } 350 | 351 | return USBD_OK; 352 | } 353 | 354 | /** 355 | * @brief USBD_DataInStage 356 | * Handle data in stage 357 | * @param pdev: device instance 358 | * @param epnum: endpoint index 359 | * @retval status 360 | */ 361 | USBD_StatusTypeDef USBD_LL_DataInStage(USBD_HandleTypeDef *pdev, 362 | uint8_t epnum, uint8_t *pdata) 363 | { 364 | USBD_EndpointTypeDef *pep; 365 | 366 | if (epnum == 0U) 367 | { 368 | pep = &pdev->ep_in[0]; 369 | 370 | if (pdev->ep0_state == USBD_EP0_DATA_IN) 371 | { 372 | if (pep->rem_length > pep->maxpacket) 373 | { 374 | pep->rem_length -= pep->maxpacket; 375 | 376 | USBD_CtlContinueSendData(pdev, pdata, (uint16_t)pep->rem_length); 377 | 378 | /* Prepare endpoint for premature end of transfer */ 379 | USBD_LL_PrepareReceive(pdev, 0U, NULL, 0U); 380 | } 381 | else 382 | { 383 | /* last packet is MPS multiple, so send ZLP packet */ 384 | if ((pep->total_length % pep->maxpacket == 0U) && 385 | (pep->total_length >= pep->maxpacket) && 386 | (pep->total_length < pdev->ep0_data_len)) 387 | { 388 | USBD_CtlContinueSendData(pdev, NULL, 0U); 389 | pdev->ep0_data_len = 0U; 390 | 391 | /* Prepare endpoint for premature end of transfer */ 392 | USBD_LL_PrepareReceive(pdev, 0U, NULL, 0U); 393 | } 394 | else 395 | { 396 | if ((pdev->pClass->EP0_TxSent != NULL) && 397 | (pdev->dev_state == USBD_STATE_CONFIGURED)) 398 | { 399 | pdev->pClass->EP0_TxSent(pdev); 400 | } 401 | USBD_LL_StallEP(pdev, 0x80U); 402 | USBD_CtlReceiveStatus(pdev); 403 | } 404 | } 405 | } 406 | else 407 | { 408 | if ((pdev->ep0_state == USBD_EP0_STATUS_IN) || 409 | (pdev->ep0_state == USBD_EP0_IDLE)) 410 | { 411 | USBD_LL_StallEP(pdev, 0x80U); 412 | } 413 | } 414 | 415 | if (pdev->dev_test_mode == 1U) 416 | { 417 | USBD_RunTestMode(pdev); 418 | pdev->dev_test_mode = 0U; 419 | } 420 | } 421 | else if ((pdev->pClass->DataIn != NULL) && 422 | (pdev->dev_state == USBD_STATE_CONFIGURED)) 423 | { 424 | pdev->pClass->DataIn(pdev, epnum); 425 | } 426 | else 427 | { 428 | /* should never be in this condition */ 429 | return USBD_FAIL; 430 | } 431 | 432 | return USBD_OK; 433 | } 434 | 435 | /** 436 | * @brief USBD_LL_Reset 437 | * Handle Reset event 438 | * @param pdev: device instance 439 | * @retval status 440 | */ 441 | 442 | USBD_StatusTypeDef USBD_LL_Reset(USBD_HandleTypeDef *pdev) 443 | { 444 | /* Open EP0 OUT */ 445 | USBD_LL_OpenEP(pdev, 0x00U, USBD_EP_TYPE_CTRL, USB_MAX_EP0_SIZE); 446 | pdev->ep_out[0x00U & 0xFU].is_used = 1U; 447 | 448 | pdev->ep_out[0].maxpacket = USB_MAX_EP0_SIZE; 449 | 450 | /* Open EP0 IN */ 451 | USBD_LL_OpenEP(pdev, 0x80U, USBD_EP_TYPE_CTRL, USB_MAX_EP0_SIZE); 452 | pdev->ep_in[0x80U & 0xFU].is_used = 1U; 453 | 454 | pdev->ep_in[0].maxpacket = USB_MAX_EP0_SIZE; 455 | 456 | /* Upon Reset call user call back */ 457 | pdev->dev_state = USBD_STATE_DEFAULT; 458 | pdev->ep0_state = USBD_EP0_IDLE; 459 | pdev->dev_config = 0U; 460 | pdev->dev_remote_wakeup = 0U; 461 | 462 | if (pdev->pClassData) 463 | { 464 | pdev->pClass->DeInit(pdev, (uint8_t)pdev->dev_config); 465 | } 466 | 467 | return USBD_OK; 468 | } 469 | 470 | /** 471 | * @brief USBD_LL_Reset 472 | * Handle Reset event 473 | * @param pdev: device instance 474 | * @retval status 475 | */ 476 | USBD_StatusTypeDef USBD_LL_SetSpeed(USBD_HandleTypeDef *pdev, 477 | USBD_SpeedTypeDef speed) 478 | { 479 | pdev->dev_speed = speed; 480 | 481 | return USBD_OK; 482 | } 483 | 484 | /** 485 | * @brief USBD_Suspend 486 | * Handle Suspend event 487 | * @param pdev: device instance 488 | * @retval status 489 | */ 490 | 491 | USBD_StatusTypeDef USBD_LL_Suspend(USBD_HandleTypeDef *pdev) 492 | { 493 | pdev->dev_old_state = pdev->dev_state; 494 | pdev->dev_state = USBD_STATE_SUSPENDED; 495 | 496 | return USBD_OK; 497 | } 498 | 499 | /** 500 | * @brief USBD_Resume 501 | * Handle Resume event 502 | * @param pdev: device instance 503 | * @retval status 504 | */ 505 | 506 | USBD_StatusTypeDef USBD_LL_Resume(USBD_HandleTypeDef *pdev) 507 | { 508 | if (pdev->dev_state == USBD_STATE_SUSPENDED) 509 | { 510 | pdev->dev_state = pdev->dev_old_state; 511 | } 512 | 513 | return USBD_OK; 514 | } 515 | 516 | /** 517 | * @brief USBD_SOF 518 | * Handle SOF event 519 | * @param pdev: device instance 520 | * @retval status 521 | */ 522 | 523 | USBD_StatusTypeDef USBD_LL_SOF(USBD_HandleTypeDef *pdev) 524 | { 525 | if (pdev->dev_state == USBD_STATE_CONFIGURED) 526 | { 527 | if (pdev->pClass->SOF != NULL) 528 | { 529 | pdev->pClass->SOF(pdev); 530 | } 531 | } 532 | 533 | return USBD_OK; 534 | } 535 | 536 | /** 537 | * @brief USBD_IsoINIncomplete 538 | * Handle iso in incomplete event 539 | * @param pdev: device instance 540 | * @retval status 541 | */ 542 | USBD_StatusTypeDef USBD_LL_IsoINIncomplete(USBD_HandleTypeDef *pdev, 543 | uint8_t epnum) 544 | { 545 | /* Prevent unused arguments compilation warning */ 546 | UNUSED(pdev); 547 | UNUSED(epnum); 548 | 549 | return USBD_OK; 550 | } 551 | 552 | /** 553 | * @brief USBD_IsoOUTIncomplete 554 | * Handle iso out incomplete event 555 | * @param pdev: device instance 556 | * @retval status 557 | */ 558 | USBD_StatusTypeDef USBD_LL_IsoOUTIncomplete(USBD_HandleTypeDef *pdev, 559 | uint8_t epnum) 560 | { 561 | /* Prevent unused arguments compilation warning */ 562 | UNUSED(pdev); 563 | UNUSED(epnum); 564 | 565 | return USBD_OK; 566 | } 567 | 568 | /** 569 | * @brief USBD_DevConnected 570 | * Handle device connection event 571 | * @param pdev: device instance 572 | * @retval status 573 | */ 574 | USBD_StatusTypeDef USBD_LL_DevConnected(USBD_HandleTypeDef *pdev) 575 | { 576 | /* Prevent unused argument compilation warning */ 577 | UNUSED(pdev); 578 | 579 | return USBD_OK; 580 | } 581 | 582 | /** 583 | * @brief USBD_DevDisconnected 584 | * Handle device disconnection event 585 | * @param pdev: device instance 586 | * @retval status 587 | */ 588 | USBD_StatusTypeDef USBD_LL_DevDisconnected(USBD_HandleTypeDef *pdev) 589 | { 590 | /* Free Class Resources */ 591 | pdev->dev_state = USBD_STATE_DEFAULT; 592 | pdev->pClass->DeInit(pdev, (uint8_t)pdev->dev_config); 593 | 594 | return USBD_OK; 595 | } 596 | /** 597 | * @} 598 | */ 599 | 600 | 601 | /** 602 | * @} 603 | */ 604 | 605 | 606 | /** 607 | * @} 608 | */ 609 | 610 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 611 | 612 | -------------------------------------------------------------------------------- /STM32/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_ioreq.c 4 | * @author MCD Application Team 5 | * @brief This file provides the IO requests APIs for control endpoints. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

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

11 | * 12 | * This software component is licensed by ST under Ultimate Liberty license 13 | * SLA0044, the "License"; You may not use this file except in compliance with 14 | * the License. You may obtain a copy of the License at: 15 | * www.st.com/SLA0044 16 | * 17 | ****************************************************************************** 18 | */ 19 | 20 | /* Includes ------------------------------------------------------------------*/ 21 | #include "usbd_ioreq.h" 22 | 23 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 24 | * @{ 25 | */ 26 | 27 | 28 | /** @defgroup USBD_IOREQ 29 | * @brief control I/O requests module 30 | * @{ 31 | */ 32 | 33 | /** @defgroup USBD_IOREQ_Private_TypesDefinitions 34 | * @{ 35 | */ 36 | /** 37 | * @} 38 | */ 39 | 40 | 41 | /** @defgroup USBD_IOREQ_Private_Defines 42 | * @{ 43 | */ 44 | 45 | /** 46 | * @} 47 | */ 48 | 49 | 50 | /** @defgroup USBD_IOREQ_Private_Macros 51 | * @{ 52 | */ 53 | /** 54 | * @} 55 | */ 56 | 57 | 58 | /** @defgroup USBD_IOREQ_Private_Variables 59 | * @{ 60 | */ 61 | 62 | /** 63 | * @} 64 | */ 65 | 66 | 67 | /** @defgroup USBD_IOREQ_Private_FunctionPrototypes 68 | * @{ 69 | */ 70 | /** 71 | * @} 72 | */ 73 | 74 | 75 | /** @defgroup USBD_IOREQ_Private_Functions 76 | * @{ 77 | */ 78 | 79 | /** 80 | * @brief USBD_CtlSendData 81 | * send data on the ctl pipe 82 | * @param pdev: device instance 83 | * @param buff: pointer to data buffer 84 | * @param len: length of data to be sent 85 | * @retval status 86 | */ 87 | USBD_StatusTypeDef USBD_CtlSendData(USBD_HandleTypeDef *pdev, 88 | uint8_t *pbuf, uint16_t len) 89 | { 90 | /* Set EP0 State */ 91 | pdev->ep0_state = USBD_EP0_DATA_IN; 92 | pdev->ep_in[0].total_length = len; 93 | pdev->ep_in[0].rem_length = len; 94 | 95 | /* Start the transfer */ 96 | USBD_LL_Transmit(pdev, 0x00U, pbuf, len); 97 | 98 | return USBD_OK; 99 | } 100 | 101 | /** 102 | * @brief USBD_CtlContinueSendData 103 | * continue sending data on the ctl pipe 104 | * @param pdev: device instance 105 | * @param buff: pointer to data buffer 106 | * @param len: length of data to be sent 107 | * @retval status 108 | */ 109 | USBD_StatusTypeDef USBD_CtlContinueSendData(USBD_HandleTypeDef *pdev, 110 | uint8_t *pbuf, uint16_t len) 111 | { 112 | /* Start the next transfer */ 113 | USBD_LL_Transmit(pdev, 0x00U, pbuf, len); 114 | 115 | return USBD_OK; 116 | } 117 | 118 | /** 119 | * @brief USBD_CtlPrepareRx 120 | * receive data on the ctl pipe 121 | * @param pdev: device instance 122 | * @param buff: pointer to data buffer 123 | * @param len: length of data to be received 124 | * @retval status 125 | */ 126 | USBD_StatusTypeDef USBD_CtlPrepareRx(USBD_HandleTypeDef *pdev, 127 | uint8_t *pbuf, uint16_t len) 128 | { 129 | /* Set EP0 State */ 130 | pdev->ep0_state = USBD_EP0_DATA_OUT; 131 | pdev->ep_out[0].total_length = len; 132 | pdev->ep_out[0].rem_length = len; 133 | 134 | /* Start the transfer */ 135 | USBD_LL_PrepareReceive(pdev, 0U, pbuf, len); 136 | 137 | return USBD_OK; 138 | } 139 | 140 | /** 141 | * @brief USBD_CtlContinueRx 142 | * continue receive data on the ctl pipe 143 | * @param pdev: device instance 144 | * @param buff: pointer to data buffer 145 | * @param len: length of data to be received 146 | * @retval status 147 | */ 148 | USBD_StatusTypeDef USBD_CtlContinueRx(USBD_HandleTypeDef *pdev, 149 | uint8_t *pbuf, uint16_t len) 150 | { 151 | USBD_LL_PrepareReceive(pdev, 0U, pbuf, len); 152 | 153 | return USBD_OK; 154 | } 155 | 156 | /** 157 | * @brief USBD_CtlSendStatus 158 | * send zero lzngth packet on the ctl pipe 159 | * @param pdev: device instance 160 | * @retval status 161 | */ 162 | USBD_StatusTypeDef USBD_CtlSendStatus(USBD_HandleTypeDef *pdev) 163 | { 164 | /* Set EP0 State */ 165 | pdev->ep0_state = USBD_EP0_STATUS_IN; 166 | 167 | /* Start the transfer */ 168 | USBD_LL_Transmit(pdev, 0x00U, NULL, 0U); 169 | 170 | return USBD_OK; 171 | } 172 | 173 | /** 174 | * @brief USBD_CtlReceiveStatus 175 | * receive zero lzngth packet on the ctl pipe 176 | * @param pdev: device instance 177 | * @retval status 178 | */ 179 | USBD_StatusTypeDef USBD_CtlReceiveStatus(USBD_HandleTypeDef *pdev) 180 | { 181 | /* Set EP0 State */ 182 | pdev->ep0_state = USBD_EP0_STATUS_OUT; 183 | 184 | /* Start the transfer */ 185 | USBD_LL_PrepareReceive(pdev, 0U, NULL, 0U); 186 | 187 | return USBD_OK; 188 | } 189 | 190 | /** 191 | * @brief USBD_GetRxCount 192 | * returns the received data length 193 | * @param pdev: device instance 194 | * @param ep_addr: endpoint address 195 | * @retval Rx Data blength 196 | */ 197 | uint32_t USBD_GetRxCount(USBD_HandleTypeDef *pdev, uint8_t ep_addr) 198 | { 199 | return USBD_LL_GetRxDataSize(pdev, ep_addr); 200 | } 201 | 202 | /** 203 | * @} 204 | */ 205 | 206 | 207 | /** 208 | * @} 209 | */ 210 | 211 | 212 | /** 213 | * @} 214 | */ 215 | 216 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 217 | -------------------------------------------------------------------------------- /STM32/RubberDuckyHelloWorld.ioc: -------------------------------------------------------------------------------- 1 | #MicroXplorer Configuration settings - do not modify 2 | CAD.formats= 3 | CAD.pinconfig= 4 | CAD.provider= 5 | File.Version=6 6 | GPIO.groupedBy= 7 | KeepUserPlacement=false 8 | Mcu.CPN=STM32F042G6U6 9 | Mcu.Family=STM32F0 10 | Mcu.IP0=ADC 11 | Mcu.IP1=NVIC 12 | Mcu.IP2=RCC 13 | Mcu.IP3=SYS 14 | Mcu.IP4=USB 15 | Mcu.IP5=USB_DEVICE 16 | Mcu.IPNb=6 17 | Mcu.Name=STM32F042G(4-6)Ux 18 | Mcu.Package=UFQFPN28 19 | Mcu.Pin0=PB0 20 | Mcu.Pin1=PA11 21 | Mcu.Pin2=PA12 22 | Mcu.Pin3=PA13 23 | Mcu.Pin4=PA14 24 | Mcu.Pin5=VP_SYS_VS_PINREMAP 25 | Mcu.Pin6=VP_SYS_VS_Systick 26 | Mcu.Pin7=VP_USB_DEVICE_VS_USB_DEVICE_HID_FS 27 | Mcu.PinsNb=8 28 | Mcu.ThirdPartyNb=0 29 | Mcu.UserConstants= 30 | Mcu.UserName=STM32F042G6Ux 31 | MxCube.Version=6.12.1 32 | MxDb.Version=DB.6.0.121 33 | NVIC.ADC1_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true 34 | NVIC.ForceEnableDMAVector=true 35 | NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false 36 | NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false 37 | NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false 38 | NVIC.SVC_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:true 39 | NVIC.SysTick_IRQn=true\:3\:0\:false\:false\:true\:false\:true\:false 40 | NVIC.USB_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:true 41 | PA11.Mode=Device 42 | PA11.Signal=USB_DM 43 | PA12.Mode=Device 44 | PA12.Signal=USB_DP 45 | PA13.Mode=Serial_Wire 46 | PA13.Signal=SYS_SWDIO 47 | PA14.Locked=true 48 | PA14.Mode=Serial_Wire 49 | PA14.Signal=SYS_SWCLK 50 | PB0.Locked=true 51 | PB0.Mode=IN8 52 | PB0.Signal=ADC_IN8 53 | PCC.Checker=false 54 | PCC.Line=STM32F0x2 55 | PCC.MCU=STM32F042G(4-6)Ux 56 | PCC.PartNumber=STM32F042G6Ux 57 | PCC.Seq0=2 58 | PCC.Seq0.Step0.Average_Current=13.76 mA 59 | PCC.Seq0.Step0.CPU_Frequency=48 MHz 60 | PCC.Seq0.Step0.Category=In DS Table 61 | PCC.Seq0.Step0.DMIPS=0.0 62 | PCC.Seq0.Step0.Duration=0.1 ms 63 | PCC.Seq0.Step0.Frequency=8 MHz 64 | PCC.Seq0.Step0.Memory=FLASH 65 | PCC.Seq0.Step0.Mode=RUN 66 | PCC.Seq0.Step0.Oscillator=HSI PLL 67 | PCC.Seq0.Step0.Peripherals=GPIOA SYS USB 68 | PCC.Seq0.Step0.TaMax=99.16 69 | PCC.Seq0.Step0.User's_Consumption=0 mA 70 | PCC.Seq0.Step0.Vcore=No Scale 71 | PCC.Seq0.Step0.Vdd=3.6 72 | PCC.Seq0.Step0.Voltage_Source=Battery 73 | PCC.Seq0.Step1.Average_Current=6.2 \u00B5A 74 | PCC.Seq0.Step1.CPU_Frequency=0 Hz 75 | PCC.Seq0.Step1.Category=In DS Table 76 | PCC.Seq0.Step1.DMIPS=0.0 77 | PCC.Seq0.Step1.Duration=0.9 ms 78 | PCC.Seq0.Step1.Frequency=0 Hz 79 | PCC.Seq0.Step1.Memory=n/a 80 | PCC.Seq0.Step1.Mode=STOP 81 | PCC.Seq0.Step1.Oscillator=Regulator_LP 82 | PCC.Seq0.Step1.Peripherals= 83 | PCC.Seq0.Step1.TaMax=105 84 | PCC.Seq0.Step1.User's_Consumption=0 mA 85 | PCC.Seq0.Step1.Vcore=No Scale 86 | PCC.Seq0.Step1.Vdd=3.6 87 | PCC.Seq0.Step1.Voltage_Source=Battery 88 | PCC.Series=STM32F0 89 | PCC.Temperature=25 90 | PCC.Vdd=3.6 91 | PinOutPanel.RotationAngle=0 92 | ProjectManager.AskForMigrate=true 93 | ProjectManager.BackupPrevious=false 94 | ProjectManager.CompilerOptimize=6 95 | ProjectManager.ComputerToolchain=false 96 | ProjectManager.CoupleFile=false 97 | ProjectManager.CustomerFirmwarePackage= 98 | ProjectManager.DefaultFWLocation=true 99 | ProjectManager.DeletePrevious=true 100 | ProjectManager.DeviceId=STM32F042G6Ux 101 | ProjectManager.FirmwarePackage=STM32Cube FW_F0 V1.11.5 102 | ProjectManager.FreePins=false 103 | ProjectManager.HalAssertFull=false 104 | ProjectManager.HeapSize=0x200 105 | ProjectManager.KeepUserCode=true 106 | ProjectManager.LastFirmware=true 107 | ProjectManager.LibraryCopy=1 108 | ProjectManager.MainLocation=Core/Src 109 | ProjectManager.NoMain=false 110 | ProjectManager.PreviousToolchain= 111 | ProjectManager.ProjectBuild=false 112 | ProjectManager.ProjectFileName=RubberDuckyHelloWorld.ioc 113 | ProjectManager.ProjectName=RubberDuckyHelloWorld 114 | ProjectManager.ProjectStructure= 115 | ProjectManager.RegisterCallBack= 116 | ProjectManager.StackSize=0x400 117 | ProjectManager.TargetToolchain=STM32CubeIDE 118 | ProjectManager.ToolChainLocation= 119 | ProjectManager.UAScriptAfterPath= 120 | ProjectManager.UAScriptBeforePath= 121 | ProjectManager.UnderRoot=false 122 | ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,4-MX_ADC_Init-ADC-false-HAL-true 123 | RCC.AHBFreq_Value=48000000 124 | RCC.APB1Freq_Value=48000000 125 | RCC.APB1TimFreq_Value=48000000 126 | RCC.CECFreq_Value=32786.88524590164 127 | RCC.FCLKCortexFreq_Value=48000000 128 | RCC.FamilyName=M 129 | RCC.HCLKFreq_Value=48000000 130 | RCC.HSICECFreq_Value=32786.88524590164 131 | RCC.I2SFreq_Value=48000000 132 | RCC.IPParameters=AHBFreq_Value,APB1Freq_Value,APB1TimFreq_Value,CECFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSICECFreq_Value,I2SFreq_Value,MCOFreq_Value,PLLCLKFreq_Value,PLLMCOFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,TimSysFreq_Value,USART1Freq_Value,VCOOutput2Freq_Value 133 | RCC.MCOFreq_Value=48000000 134 | RCC.PLLCLKFreq_Value=16000000 135 | RCC.PLLMCOFreq_Value=16000000 136 | RCC.SYSCLKFreq_VALUE=48000000 137 | RCC.SYSCLKSource=RCC_SYSCLKSOURCE_HSI48 138 | RCC.TimSysFreq_Value=48000000 139 | RCC.USART1Freq_Value=48000000 140 | RCC.VCOOutput2Freq_Value=8000000 141 | USB_DEVICE.CLASS_NAME_FS=HID 142 | USB_DEVICE.IPParameters=VirtualMode,VirtualModeFS,CLASS_NAME_FS,VID,MANUFACTURER_STRING,PID_HID_FS,PRODUCT_STRING_HID_FS 143 | USB_DEVICE.MANUFACTURER_STRING=Logitech 144 | USB_DEVICE.PID_HID_FS=50475 145 | USB_DEVICE.PRODUCT_STRING_HID_FS=USB Receiver 146 | USB_DEVICE.VID=1133 147 | USB_DEVICE.VirtualMode=Hid 148 | USB_DEVICE.VirtualModeFS=Hid_FS 149 | VP_SYS_VS_PINREMAP.Mode=PINREMAP 150 | VP_SYS_VS_PINREMAP.Signal=SYS_VS_PINREMAP 151 | VP_SYS_VS_Systick.Mode=SysTick 152 | VP_SYS_VS_Systick.Signal=SYS_VS_Systick 153 | VP_USB_DEVICE_VS_USB_DEVICE_HID_FS.Mode=HID_FS 154 | VP_USB_DEVICE_VS_USB_DEVICE_HID_FS.Signal=USB_DEVICE_VS_USB_DEVICE_HID_FS 155 | board=custom 156 | -------------------------------------------------------------------------------- /STM32/STM32CubeIDE/Middlewares/USB_Device_Library/usbd_hid_ext.h: -------------------------------------------------------------------------------- 1 | /* 2 | * usbd_hid_ext.h 3 | * 4 | * Created on: Nov 2, 2024 5 | * Author: emman 6 | */ 7 | 8 | #ifndef MIDDLEWARES_USB_DEVICE_LIBRARY_USBD_HID_EXT_H_ 9 | #define MIDDLEWARES_USB_DEVICE_LIBRARY_USBD_HID_EXT_H_ 10 | 11 | //#include "usb_hid_defines.h" 12 | 13 | extern volatile uint8_t capslock_; 14 | 15 | #endif /* MIDDLEWARES_USB_DEVICE_LIBRARY_USBD_HID_EXT_H_ */ 16 | -------------------------------------------------------------------------------- /STM32/USB_DEVICE/App/usb_device.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : usb_device.c 5 | * @version : v2.0_Cube 6 | * @brief : This file implements the USB Device 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2025 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | 23 | #include "usb_device.h" 24 | #include "usbd_core.h" 25 | #include "usbd_desc.h" 26 | #include "usbd_hid.h" 27 | 28 | /* USER CODE BEGIN Includes */ 29 | 30 | /* USER CODE END Includes */ 31 | 32 | /* USER CODE BEGIN PV */ 33 | /* Private variables ---------------------------------------------------------*/ 34 | 35 | /* USER CODE END PV */ 36 | 37 | /* USER CODE BEGIN PFP */ 38 | /* Private function prototypes -----------------------------------------------*/ 39 | 40 | /* USER CODE END PFP */ 41 | 42 | /* USB Device Core handle declaration. */ 43 | USBD_HandleTypeDef hUsbDeviceFS; 44 | 45 | /* 46 | * -- Insert your variables declaration here -- 47 | */ 48 | /* USER CODE BEGIN 0 */ 49 | 50 | /* USER CODE END 0 */ 51 | 52 | /* 53 | * -- Insert your external function declaration here -- 54 | */ 55 | /* USER CODE BEGIN 1 */ 56 | 57 | /* USER CODE END 1 */ 58 | 59 | /** 60 | * Init USB device Library, add supported class and start the library 61 | * @retval None 62 | */ 63 | void MX_USB_DEVICE_Init(void) 64 | { 65 | /* USER CODE BEGIN USB_DEVICE_Init_PreTreatment */ 66 | 67 | /* USER CODE END USB_DEVICE_Init_PreTreatment */ 68 | 69 | /* Init Device Library, add supported class and start the library. */ 70 | if (USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS) != USBD_OK) 71 | { 72 | Error_Handler(); 73 | } 74 | if (USBD_RegisterClass(&hUsbDeviceFS, &USBD_HID) != USBD_OK) 75 | { 76 | Error_Handler(); 77 | } 78 | if (USBD_Start(&hUsbDeviceFS) != USBD_OK) 79 | { 80 | Error_Handler(); 81 | } 82 | 83 | /* USER CODE BEGIN USB_DEVICE_Init_PostTreatment */ 84 | 85 | /* USER CODE END USB_DEVICE_Init_PostTreatment */ 86 | } 87 | 88 | /** 89 | * @} 90 | */ 91 | 92 | /** 93 | * @} 94 | */ 95 | 96 | -------------------------------------------------------------------------------- /STM32/USB_DEVICE/App/usb_device.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : usb_device.h 5 | * @version : v2.0_Cube 6 | * @brief : Header for usb_device.c file. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2025 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __USB_DEVICE__H__ 23 | #define __USB_DEVICE__H__ 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | #include "stm32f0xx.h" 31 | #include "stm32f0xx_hal.h" 32 | #include "usbd_def.h" 33 | 34 | /* USER CODE BEGIN INCLUDE */ 35 | 36 | /* USER CODE END INCLUDE */ 37 | 38 | /** @addtogroup USBD_OTG_DRIVER 39 | * @{ 40 | */ 41 | 42 | /** @defgroup USBD_DEVICE USBD_DEVICE 43 | * @brief Device file for Usb otg low level driver. 44 | * @{ 45 | */ 46 | 47 | /** @defgroup USBD_DEVICE_Exported_Variables USBD_DEVICE_Exported_Variables 48 | * @brief Public variables. 49 | * @{ 50 | */ 51 | 52 | /* Private variables ---------------------------------------------------------*/ 53 | /* USER CODE BEGIN PV */ 54 | 55 | /* USER CODE END PV */ 56 | 57 | /* Private function prototypes -----------------------------------------------*/ 58 | /* USER CODE BEGIN PFP */ 59 | 60 | /* USER CODE END PFP */ 61 | 62 | /* 63 | * -- Insert your variables declaration here -- 64 | */ 65 | /* USER CODE BEGIN VARIABLES */ 66 | 67 | /* USER CODE END VARIABLES */ 68 | /** 69 | * @} 70 | */ 71 | 72 | /** @defgroup USBD_DEVICE_Exported_FunctionsPrototype USBD_DEVICE_Exported_FunctionsPrototype 73 | * @brief Declaration of public functions for Usb device. 74 | * @{ 75 | */ 76 | 77 | /** USB Device initialization function. */ 78 | void MX_USB_DEVICE_Init(void); 79 | 80 | /* 81 | * -- Insert functions declaration here -- 82 | */ 83 | /* USER CODE BEGIN FD */ 84 | 85 | /* USER CODE END FD */ 86 | /** 87 | * @} 88 | */ 89 | 90 | /** 91 | * @} 92 | */ 93 | 94 | /** 95 | * @} 96 | */ 97 | 98 | #ifdef __cplusplus 99 | } 100 | #endif 101 | 102 | #endif /* __USB_DEVICE__H__ */ 103 | -------------------------------------------------------------------------------- /STM32/USB_DEVICE/App/usbd_desc.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : App/usbd_desc.c 5 | * @version : v2.0_Cube 6 | * @brief : This file implements the USB device descriptors. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2025 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | #include "usbd_core.h" 23 | #include "usbd_desc.h" 24 | #include "usbd_conf.h" 25 | 26 | /* USER CODE BEGIN INCLUDE */ 27 | 28 | /* USER CODE END INCLUDE */ 29 | 30 | /* Private typedef -----------------------------------------------------------*/ 31 | /* Private define ------------------------------------------------------------*/ 32 | /* Private macro -------------------------------------------------------------*/ 33 | 34 | /* USER CODE BEGIN PV */ 35 | /* Private variables ---------------------------------------------------------*/ 36 | 37 | /* USER CODE END PV */ 38 | 39 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY 40 | * @{ 41 | */ 42 | 43 | /** @addtogroup USBD_DESC 44 | * @{ 45 | */ 46 | 47 | /** @defgroup USBD_DESC_Private_TypesDefinitions USBD_DESC_Private_TypesDefinitions 48 | * @brief Private types. 49 | * @{ 50 | */ 51 | 52 | /* USER CODE BEGIN PRIVATE_TYPES */ 53 | 54 | /* USER CODE END PRIVATE_TYPES */ 55 | 56 | /** 57 | * @} 58 | */ 59 | 60 | /** @defgroup USBD_DESC_Private_Defines USBD_DESC_Private_Defines 61 | * @brief Private defines. 62 | * @{ 63 | */ 64 | 65 | #define USBD_VID 1133 66 | #define USBD_LANGID_STRING 1033 67 | #define USBD_MANUFACTURER_STRING "Logitech" 68 | #define USBD_PID_FS 50475 69 | #define USBD_PRODUCT_STRING_FS "USB Receiver" 70 | #define USBD_CONFIGURATION_STRING_FS "HID Config" 71 | #define USBD_INTERFACE_STRING_FS "HID Interface" 72 | 73 | /* USER CODE BEGIN PRIVATE_DEFINES */ 74 | 75 | /* USER CODE END PRIVATE_DEFINES */ 76 | 77 | /** 78 | * @} 79 | */ 80 | 81 | /* USER CODE BEGIN 0 */ 82 | 83 | /* USER CODE END 0 */ 84 | 85 | /** @defgroup USBD_DESC_Private_Macros USBD_DESC_Private_Macros 86 | * @brief Private macros. 87 | * @{ 88 | */ 89 | 90 | /* USER CODE BEGIN PRIVATE_MACRO */ 91 | 92 | /* USER CODE END PRIVATE_MACRO */ 93 | 94 | /** 95 | * @} 96 | */ 97 | 98 | /** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes 99 | * @brief Private functions declaration. 100 | * @{ 101 | */ 102 | 103 | static void Get_SerialNum(void); 104 | static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len); 105 | 106 | /** 107 | * @} 108 | */ 109 | 110 | /** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes 111 | * @brief Private functions declaration for FS. 112 | * @{ 113 | */ 114 | 115 | uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); 116 | uint8_t * USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); 117 | uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); 118 | uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); 119 | uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); 120 | uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); 121 | uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); 122 | 123 | /** 124 | * @} 125 | */ 126 | 127 | /** @defgroup USBD_DESC_Private_Variables USBD_DESC_Private_Variables 128 | * @brief Private variables. 129 | * @{ 130 | */ 131 | 132 | USBD_DescriptorsTypeDef FS_Desc = 133 | { 134 | USBD_FS_DeviceDescriptor 135 | , USBD_FS_LangIDStrDescriptor 136 | , USBD_FS_ManufacturerStrDescriptor 137 | , USBD_FS_ProductStrDescriptor 138 | , USBD_FS_SerialStrDescriptor 139 | , USBD_FS_ConfigStrDescriptor 140 | , USBD_FS_InterfaceStrDescriptor 141 | }; 142 | 143 | #if defined ( __ICCARM__ ) /* IAR Compiler */ 144 | #pragma data_alignment=4 145 | #endif /* defined ( __ICCARM__ ) */ 146 | /** USB standard device descriptor. */ 147 | __ALIGN_BEGIN uint8_t USBD_FS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = 148 | { 149 | 0x12, /*bLength */ 150 | USB_DESC_TYPE_DEVICE, /*bDescriptorType*/ 151 | 0x00, /*bcdUSB */ 152 | 0x02, 153 | 0x00, /*bDeviceClass*/ 154 | 0x00, /*bDeviceSubClass*/ 155 | 0x00, /*bDeviceProtocol*/ 156 | USB_MAX_EP0_SIZE, /*bMaxPacketSize*/ 157 | LOBYTE(USBD_VID), /*idVendor*/ 158 | HIBYTE(USBD_VID), /*idVendor*/ 159 | LOBYTE(USBD_PID_FS), /*idProduct*/ 160 | HIBYTE(USBD_PID_FS), /*idProduct*/ 161 | 0x00, /*bcdDevice rel. 2.00*/ 162 | 0x02, 163 | USBD_IDX_MFC_STR, /*Index of manufacturer string*/ 164 | USBD_IDX_PRODUCT_STR, /*Index of product string*/ 165 | USBD_IDX_SERIAL_STR, /*Index of serial number string*/ 166 | USBD_MAX_NUM_CONFIGURATION /*bNumConfigurations*/ 167 | }; 168 | 169 | /* USB_DeviceDescriptor */ 170 | 171 | /** 172 | * @} 173 | */ 174 | 175 | /** @defgroup USBD_DESC_Private_Variables USBD_DESC_Private_Variables 176 | * @brief Private variables. 177 | * @{ 178 | */ 179 | 180 | #if defined ( __ICCARM__ ) /* IAR Compiler */ 181 | #pragma data_alignment=4 182 | #endif /* defined ( __ICCARM__ ) */ 183 | 184 | /** USB lang identifier descriptor. */ 185 | __ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_LEN_LANGID_STR_DESC] __ALIGN_END = 186 | { 187 | USB_LEN_LANGID_STR_DESC, 188 | USB_DESC_TYPE_STRING, 189 | LOBYTE(USBD_LANGID_STRING), 190 | HIBYTE(USBD_LANGID_STRING) 191 | }; 192 | 193 | #if defined ( __ICCARM__ ) /* IAR Compiler */ 194 | #pragma data_alignment=4 195 | #endif /* defined ( __ICCARM__ ) */ 196 | /* Internal string descriptor. */ 197 | __ALIGN_BEGIN uint8_t USBD_StrDesc[USBD_MAX_STR_DESC_SIZ] __ALIGN_END; 198 | 199 | #if defined ( __ICCARM__ ) /*!< IAR Compiler */ 200 | #pragma data_alignment=4 201 | #endif 202 | __ALIGN_BEGIN uint8_t USBD_StringSerial[USB_SIZ_STRING_SERIAL] __ALIGN_END = { 203 | USB_SIZ_STRING_SERIAL, 204 | USB_DESC_TYPE_STRING, 205 | }; 206 | 207 | /** 208 | * @} 209 | */ 210 | 211 | /** @defgroup USBD_DESC_Private_Functions USBD_DESC_Private_Functions 212 | * @brief Private functions. 213 | * @{ 214 | */ 215 | 216 | /** 217 | * @brief Return the device descriptor 218 | * @param speed : Current device speed 219 | * @param length : Pointer to data length variable 220 | * @retval Pointer to descriptor buffer 221 | */ 222 | uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) 223 | { 224 | UNUSED(speed); 225 | *length = sizeof(USBD_FS_DeviceDesc); 226 | return USBD_FS_DeviceDesc; 227 | } 228 | 229 | /** 230 | * @brief Return the LangID string descriptor 231 | * @param speed : Current device speed 232 | * @param length : Pointer to data length variable 233 | * @retval Pointer to descriptor buffer 234 | */ 235 | uint8_t * USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) 236 | { 237 | UNUSED(speed); 238 | *length = sizeof(USBD_LangIDDesc); 239 | return USBD_LangIDDesc; 240 | } 241 | 242 | /** 243 | * @brief Return the product string descriptor 244 | * @param speed : Current device speed 245 | * @param length : Pointer to data length variable 246 | * @retval Pointer to descriptor buffer 247 | */ 248 | uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) 249 | { 250 | if(speed == 0) 251 | { 252 | USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FS, USBD_StrDesc, length); 253 | } 254 | else 255 | { 256 | USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FS, USBD_StrDesc, length); 257 | } 258 | return USBD_StrDesc; 259 | } 260 | 261 | /** 262 | * @brief Return the manufacturer string descriptor 263 | * @param speed : Current device speed 264 | * @param length : Pointer to data length variable 265 | * @retval Pointer to descriptor buffer 266 | */ 267 | uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) 268 | { 269 | UNUSED(speed); 270 | USBD_GetString((uint8_t *)USBD_MANUFACTURER_STRING, USBD_StrDesc, length); 271 | return USBD_StrDesc; 272 | } 273 | 274 | /** 275 | * @brief Return the serial number string descriptor 276 | * @param speed : Current device speed 277 | * @param length : Pointer to data length variable 278 | * @retval Pointer to descriptor buffer 279 | */ 280 | uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) 281 | { 282 | UNUSED(speed); 283 | *length = USB_SIZ_STRING_SERIAL; 284 | 285 | /* Update the serial number string descriptor with the data from the unique 286 | * ID */ 287 | Get_SerialNum(); 288 | /* USER CODE BEGIN USBD_FS_SerialStrDescriptor */ 289 | 290 | /* USER CODE END USBD_FS_SerialStrDescriptor */ 291 | return (uint8_t *) USBD_StringSerial; 292 | } 293 | 294 | /** 295 | * @brief Return the configuration string descriptor 296 | * @param speed : Current device speed 297 | * @param length : Pointer to data length variable 298 | * @retval Pointer to descriptor buffer 299 | */ 300 | uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) 301 | { 302 | if(speed == USBD_SPEED_HIGH) 303 | { 304 | USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length); 305 | } 306 | else 307 | { 308 | USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length); 309 | } 310 | return USBD_StrDesc; 311 | } 312 | 313 | /** 314 | * @brief Return the interface string descriptor 315 | * @param speed : Current device speed 316 | * @param length : Pointer to data length variable 317 | * @retval Pointer to descriptor buffer 318 | */ 319 | uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) 320 | { 321 | if(speed == 0) 322 | { 323 | USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FS, USBD_StrDesc, length); 324 | } 325 | else 326 | { 327 | USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FS, USBD_StrDesc, length); 328 | } 329 | return USBD_StrDesc; 330 | } 331 | 332 | /** 333 | * @brief Create the serial number string descriptor 334 | * @param None 335 | * @retval None 336 | */ 337 | static void Get_SerialNum(void) 338 | { 339 | uint32_t deviceserial0; 340 | uint32_t deviceserial1; 341 | uint32_t deviceserial2; 342 | 343 | deviceserial0 = *(uint32_t *) DEVICE_ID1; 344 | deviceserial1 = *(uint32_t *) DEVICE_ID2; 345 | deviceserial2 = *(uint32_t *) DEVICE_ID3; 346 | 347 | deviceserial0 += deviceserial2; 348 | 349 | if (deviceserial0 != 0) 350 | { 351 | IntToUnicode(deviceserial0, &USBD_StringSerial[2], 8); 352 | IntToUnicode(deviceserial1, &USBD_StringSerial[18], 4); 353 | } 354 | } 355 | 356 | /** 357 | * @brief Convert Hex 32Bits value into char 358 | * @param value: value to convert 359 | * @param pbuf: pointer to the buffer 360 | * @param len: buffer length 361 | * @retval None 362 | */ 363 | static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len) 364 | { 365 | uint8_t idx = 0; 366 | 367 | for (idx = 0; idx < len; idx++) 368 | { 369 | if (((value >> 28)) < 0xA) 370 | { 371 | pbuf[2 * idx] = (value >> 28) + '0'; 372 | } 373 | else 374 | { 375 | pbuf[2 * idx] = (value >> 28) + 'A' - 10; 376 | } 377 | 378 | value = value << 4; 379 | 380 | pbuf[2 * idx + 1] = 0; 381 | } 382 | } 383 | /** 384 | * @} 385 | */ 386 | 387 | /** 388 | * @} 389 | */ 390 | 391 | /** 392 | * @} 393 | */ 394 | 395 | -------------------------------------------------------------------------------- /STM32/USB_DEVICE/App/usbd_desc.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : usbd_desc.c 5 | * @version : v2.0_Cube 6 | * @brief : Header for usbd_conf.c file. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2025 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __USBD_DESC__C__ 22 | #define __USBD_DESC__C__ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "usbd_def.h" 30 | 31 | /* USER CODE BEGIN INCLUDE */ 32 | 33 | /* USER CODE END INCLUDE */ 34 | 35 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY 36 | * @{ 37 | */ 38 | 39 | /** @defgroup USBD_DESC USBD_DESC 40 | * @brief Usb device descriptors module. 41 | * @{ 42 | */ 43 | 44 | /** @defgroup USBD_DESC_Exported_Constants USBD_DESC_Exported_Constants 45 | * @brief Constants. 46 | * @{ 47 | */ 48 | #define DEVICE_ID1 (UID_BASE) 49 | #define DEVICE_ID2 (UID_BASE + 0x4) 50 | #define DEVICE_ID3 (UID_BASE + 0x8) 51 | 52 | #define USB_SIZ_STRING_SERIAL 0x1A 53 | 54 | /* USER CODE BEGIN EXPORTED_CONSTANTS */ 55 | 56 | /* USER CODE END EXPORTED_CONSTANTS */ 57 | 58 | /** 59 | * @} 60 | */ 61 | 62 | /** @defgroup USBD_DESC_Exported_Defines USBD_DESC_Exported_Defines 63 | * @brief Defines. 64 | * @{ 65 | */ 66 | 67 | /* USER CODE BEGIN EXPORTED_DEFINES */ 68 | 69 | /* USER CODE END EXPORTED_DEFINES */ 70 | 71 | /** 72 | * @} 73 | */ 74 | 75 | /** @defgroup USBD_DESC_Exported_TypesDefinitions USBD_DESC_Exported_TypesDefinitions 76 | * @brief Types. 77 | * @{ 78 | */ 79 | 80 | /* USER CODE BEGIN EXPORTED_TYPES */ 81 | 82 | /* USER CODE END EXPORTED_TYPES */ 83 | 84 | /** 85 | * @} 86 | */ 87 | 88 | /** @defgroup USBD_DESC_Exported_Macros USBD_DESC_Exported_Macros 89 | * @brief Aliases. 90 | * @{ 91 | */ 92 | 93 | /* USER CODE BEGIN EXPORTED_MACRO */ 94 | 95 | /* USER CODE END EXPORTED_MACRO */ 96 | 97 | /** 98 | * @} 99 | */ 100 | 101 | /** @defgroup USBD_DESC_Exported_Variables USBD_DESC_Exported_Variables 102 | * @brief Public variables. 103 | * @{ 104 | */ 105 | 106 | /** Descriptor for the Usb device. */ 107 | extern USBD_DescriptorsTypeDef FS_Desc; 108 | 109 | /* USER CODE BEGIN EXPORTED_VARIABLES */ 110 | 111 | /* USER CODE END EXPORTED_VARIABLES */ 112 | 113 | /** 114 | * @} 115 | */ 116 | 117 | /** @defgroup USBD_DESC_Exported_FunctionsPrototype USBD_DESC_Exported_FunctionsPrototype 118 | * @brief Public functions declaration. 119 | * @{ 120 | */ 121 | 122 | /* USER CODE BEGIN EXPORTED_FUNCTIONS */ 123 | 124 | /* USER CODE END EXPORTED_FUNCTIONS */ 125 | 126 | /** 127 | * @} 128 | */ 129 | 130 | /** 131 | * @} 132 | */ 133 | 134 | /** 135 | * @} 136 | */ 137 | 138 | #ifdef __cplusplus 139 | } 140 | #endif 141 | 142 | #endif /* __USBD_DESC__C__ */ 143 | 144 | -------------------------------------------------------------------------------- /STM32/USB_DEVICE/Target/usbd_conf.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : Target/usbd_conf.c 5 | * @version : v2.0_Cube 6 | * @brief : This file implements the board support package for the USB device library 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2025 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | #include "stm32f0xx.h" 23 | #include "stm32f0xx_hal.h" 24 | #include "usbd_def.h" 25 | #include "usbd_core.h" 26 | #include "usbd_hid.h" 27 | 28 | /* USER CODE BEGIN Includes */ 29 | 30 | /* USER CODE END Includes */ 31 | 32 | /* Private typedef -----------------------------------------------------------*/ 33 | /* Private define ------------------------------------------------------------*/ 34 | /* Private macro -------------------------------------------------------------*/ 35 | 36 | /* USER CODE BEGIN PV */ 37 | /* Private variables ---------------------------------------------------------*/ 38 | 39 | /* USER CODE END PV */ 40 | 41 | PCD_HandleTypeDef hpcd_USB_FS; 42 | void Error_Handler(void); 43 | 44 | /* USER CODE BEGIN 0 */ 45 | 46 | /* USER CODE END 0 */ 47 | 48 | /* USER CODE BEGIN PFP */ 49 | /* Private function prototypes -----------------------------------------------*/ 50 | 51 | /* USER CODE END PFP */ 52 | 53 | /* Private functions ---------------------------------------------------------*/ 54 | static USBD_StatusTypeDef USBD_Get_USB_Status(HAL_StatusTypeDef hal_status); 55 | /* USER CODE BEGIN 1 */ 56 | static void SystemClockConfig_Resume(void); 57 | /* USER CODE END 1 */ 58 | extern void SystemClock_Config(void); 59 | 60 | /******************************************************************************* 61 | LL Driver Callbacks (PCD -> USB Device Library) 62 | *******************************************************************************/ 63 | /* MSP Init */ 64 | 65 | void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle) 66 | { 67 | if(pcdHandle->Instance==USB) 68 | { 69 | /* USER CODE BEGIN USB_MspInit 0 */ 70 | 71 | /* USER CODE END USB_MspInit 0 */ 72 | /* Peripheral clock enable */ 73 | __HAL_RCC_USB_CLK_ENABLE(); 74 | 75 | /* Peripheral interrupt init */ 76 | HAL_NVIC_SetPriority(USB_IRQn, 0, 0); 77 | HAL_NVIC_EnableIRQ(USB_IRQn); 78 | /* USER CODE BEGIN USB_MspInit 1 */ 79 | 80 | /* USER CODE END USB_MspInit 1 */ 81 | } 82 | } 83 | 84 | void HAL_PCD_MspDeInit(PCD_HandleTypeDef* pcdHandle) 85 | { 86 | if(pcdHandle->Instance==USB) 87 | { 88 | /* USER CODE BEGIN USB_MspDeInit 0 */ 89 | 90 | /* USER CODE END USB_MspDeInit 0 */ 91 | /* Peripheral clock disable */ 92 | __HAL_RCC_USB_CLK_DISABLE(); 93 | 94 | /* Peripheral interrupt Deinit*/ 95 | HAL_NVIC_DisableIRQ(USB_IRQn); 96 | 97 | /* USER CODE BEGIN USB_MspDeInit 1 */ 98 | 99 | /* USER CODE END USB_MspDeInit 1 */ 100 | } 101 | } 102 | 103 | /** 104 | * @brief Setup stage callback 105 | * @param hpcd: PCD handle 106 | * @retval None 107 | */ 108 | #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) 109 | static void PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd) 110 | #else 111 | void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd) 112 | #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ 113 | { 114 | USBD_LL_SetupStage((USBD_HandleTypeDef*)hpcd->pData, (uint8_t *)hpcd->Setup); 115 | } 116 | 117 | /** 118 | * @brief Data Out stage callback. 119 | * @param hpcd: PCD handle 120 | * @param epnum: Endpoint number 121 | * @retval None 122 | */ 123 | #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) 124 | static void PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) 125 | #else 126 | void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) 127 | #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ 128 | { 129 | USBD_LL_DataOutStage((USBD_HandleTypeDef*)hpcd->pData, epnum, hpcd->OUT_ep[epnum].xfer_buff); 130 | } 131 | 132 | /** 133 | * @brief Data In stage callback. 134 | * @param hpcd: PCD handle 135 | * @param epnum: Endpoint number 136 | * @retval None 137 | */ 138 | #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) 139 | static void PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) 140 | #else 141 | void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) 142 | #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ 143 | { 144 | USBD_LL_DataInStage((USBD_HandleTypeDef*)hpcd->pData, epnum, hpcd->IN_ep[epnum].xfer_buff); 145 | } 146 | 147 | /** 148 | * @brief SOF callback. 149 | * @param hpcd: PCD handle 150 | * @retval None 151 | */ 152 | #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) 153 | static void PCD_SOFCallback(PCD_HandleTypeDef *hpcd) 154 | #else 155 | void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) 156 | #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ 157 | { 158 | USBD_LL_SOF((USBD_HandleTypeDef*)hpcd->pData); 159 | } 160 | 161 | /** 162 | * @brief Reset callback. 163 | * @param hpcd: PCD handle 164 | * @retval None 165 | */ 166 | #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) 167 | static void PCD_ResetCallback(PCD_HandleTypeDef *hpcd) 168 | #else 169 | void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd) 170 | #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ 171 | { 172 | USBD_SpeedTypeDef speed = USBD_SPEED_FULL; 173 | 174 | if ( hpcd->Init.speed != PCD_SPEED_FULL) 175 | { 176 | Error_Handler(); 177 | } 178 | /* Set Speed. */ 179 | USBD_LL_SetSpeed((USBD_HandleTypeDef*)hpcd->pData, speed); 180 | 181 | /* Reset Device. */ 182 | USBD_LL_Reset((USBD_HandleTypeDef*)hpcd->pData); 183 | } 184 | 185 | /** 186 | * @brief Suspend callback. 187 | * When Low power mode is enabled the debug cannot be used (IAR, Keil doesn't support it) 188 | * @param hpcd: PCD handle 189 | * @retval None 190 | */ 191 | #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) 192 | static void PCD_SuspendCallback(PCD_HandleTypeDef *hpcd) 193 | #else 194 | void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd) 195 | #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ 196 | { 197 | /* Inform USB library that core enters in suspend Mode. */ 198 | USBD_LL_Suspend((USBD_HandleTypeDef*)hpcd->pData); 199 | /* Enter in STOP mode. */ 200 | /* USER CODE BEGIN 2 */ 201 | if (hpcd->Init.low_power_enable) 202 | { 203 | /* Set SLEEPDEEP bit and SleepOnExit of Cortex System Control Register. */ 204 | SCB->SCR |= (uint32_t)((uint32_t)(SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk)); 205 | } 206 | /* USER CODE END 2 */ 207 | } 208 | 209 | /** 210 | * @brief Resume callback. 211 | * When Low power mode is enabled the debug cannot be used (IAR, Keil doesn't support it) 212 | * @param hpcd: PCD handle 213 | * @retval None 214 | */ 215 | #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) 216 | static void PCD_ResumeCallback(PCD_HandleTypeDef *hpcd) 217 | #else 218 | void HAL_PCD_ResumeCallback(PCD_HandleTypeDef *hpcd) 219 | #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ 220 | { 221 | /* USER CODE BEGIN 3 */ 222 | if (hpcd->Init.low_power_enable) 223 | { 224 | /* Reset SLEEPDEEP bit of Cortex System Control Register. */ 225 | SCB->SCR &= (uint32_t)~((uint32_t)(SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk)); 226 | SystemClockConfig_Resume(); 227 | } 228 | /* USER CODE END 3 */ 229 | USBD_LL_Resume((USBD_HandleTypeDef*)hpcd->pData); 230 | } 231 | 232 | /** 233 | * @brief ISOOUTIncomplete callback. 234 | * @param hpcd: PCD handle 235 | * @param epnum: Endpoint number 236 | * @retval None 237 | */ 238 | #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) 239 | static void PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) 240 | #else 241 | void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) 242 | #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ 243 | { 244 | USBD_LL_IsoOUTIncomplete((USBD_HandleTypeDef*)hpcd->pData, epnum); 245 | } 246 | 247 | /** 248 | * @brief ISOINIncomplete callback. 249 | * @param hpcd: PCD handle 250 | * @param epnum: Endpoint number 251 | * @retval None 252 | */ 253 | #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) 254 | static void PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) 255 | #else 256 | void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) 257 | #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ 258 | { 259 | USBD_LL_IsoINIncomplete((USBD_HandleTypeDef*)hpcd->pData, epnum); 260 | } 261 | 262 | /** 263 | * @brief Connect callback. 264 | * @param hpcd: PCD handle 265 | * @retval None 266 | */ 267 | #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) 268 | static void PCD_ConnectCallback(PCD_HandleTypeDef *hpcd) 269 | #else 270 | void HAL_PCD_ConnectCallback(PCD_HandleTypeDef *hpcd) 271 | #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ 272 | { 273 | USBD_LL_DevConnected((USBD_HandleTypeDef*)hpcd->pData); 274 | } 275 | 276 | /** 277 | * @brief Disconnect callback. 278 | * @param hpcd: PCD handle 279 | * @retval None 280 | */ 281 | #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) 282 | static void PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd) 283 | #else 284 | void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd) 285 | #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ 286 | { 287 | USBD_LL_DevDisconnected((USBD_HandleTypeDef*)hpcd->pData); 288 | } 289 | 290 | /******************************************************************************* 291 | LL Driver Interface (USB Device Library --> PCD) 292 | *******************************************************************************/ 293 | 294 | /** 295 | * @brief Initializes the low level portion of the device driver. 296 | * @param pdev: Device handle 297 | * @retval USBD status 298 | */ 299 | USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev) 300 | { 301 | /* Init USB Ip. */ 302 | /* Link the driver to the stack. */ 303 | hpcd_USB_FS.pData = pdev; 304 | pdev->pData = &hpcd_USB_FS; 305 | 306 | hpcd_USB_FS.Instance = USB; 307 | hpcd_USB_FS.Init.dev_endpoints = 8; 308 | hpcd_USB_FS.Init.speed = PCD_SPEED_FULL; 309 | hpcd_USB_FS.Init.phy_itface = PCD_PHY_EMBEDDED; 310 | hpcd_USB_FS.Init.low_power_enable = DISABLE; 311 | hpcd_USB_FS.Init.lpm_enable = DISABLE; 312 | hpcd_USB_FS.Init.battery_charging_enable = DISABLE; 313 | if (HAL_PCD_Init(&hpcd_USB_FS) != HAL_OK) 314 | { 315 | Error_Handler( ); 316 | } 317 | 318 | #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) 319 | /* Register USB PCD CallBacks */ 320 | HAL_PCD_RegisterCallback(&hpcd_USB_FS, HAL_PCD_SOF_CB_ID, PCD_SOFCallback); 321 | HAL_PCD_RegisterCallback(&hpcd_USB_FS, HAL_PCD_SETUPSTAGE_CB_ID, PCD_SetupStageCallback); 322 | HAL_PCD_RegisterCallback(&hpcd_USB_FS, HAL_PCD_RESET_CB_ID, PCD_ResetCallback); 323 | HAL_PCD_RegisterCallback(&hpcd_USB_FS, HAL_PCD_SUSPEND_CB_ID, PCD_SuspendCallback); 324 | HAL_PCD_RegisterCallback(&hpcd_USB_FS, HAL_PCD_RESUME_CB_ID, PCD_ResumeCallback); 325 | HAL_PCD_RegisterCallback(&hpcd_USB_FS, HAL_PCD_CONNECT_CB_ID, PCD_ConnectCallback); 326 | HAL_PCD_RegisterCallback(&hpcd_USB_FS, HAL_PCD_DISCONNECT_CB_ID, PCD_DisconnectCallback); 327 | 328 | HAL_PCD_RegisterDataOutStageCallback(&hpcd_USB_FS, PCD_DataOutStageCallback); 329 | HAL_PCD_RegisterDataInStageCallback(&hpcd_USB_FS, PCD_DataInStageCallback); 330 | HAL_PCD_RegisterIsoOutIncpltCallback(&hpcd_USB_FS, PCD_ISOOUTIncompleteCallback); 331 | HAL_PCD_RegisterIsoInIncpltCallback(&hpcd_USB_FS, PCD_ISOINIncompleteCallback); 332 | #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ 333 | /* USER CODE BEGIN EndPoint_Configuration */ 334 | HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x00 , PCD_SNG_BUF, 0x18); 335 | HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x80 , PCD_SNG_BUF, 0x58); 336 | /* USER CODE END EndPoint_Configuration */ 337 | /* USER CODE BEGIN EndPoint_Configuration_HID */ 338 | HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x81 , PCD_SNG_BUF, 0x100); 339 | /* USER CODE END EndPoint_Configuration_HID */ 340 | return USBD_OK; 341 | } 342 | 343 | /** 344 | * @brief De-Initializes the low level portion of the device driver. 345 | * @param pdev: Device handle 346 | * @retval USBD status 347 | */ 348 | USBD_StatusTypeDef USBD_LL_DeInit(USBD_HandleTypeDef *pdev) 349 | { 350 | HAL_StatusTypeDef hal_status = HAL_OK; 351 | USBD_StatusTypeDef usb_status = USBD_OK; 352 | 353 | hal_status = HAL_PCD_DeInit(pdev->pData); 354 | 355 | usb_status = USBD_Get_USB_Status(hal_status); 356 | 357 | return usb_status; 358 | } 359 | 360 | /** 361 | * @brief Starts the low level portion of the device driver. 362 | * @param pdev: Device handle 363 | * @retval USBD status 364 | */ 365 | USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef *pdev) 366 | { 367 | HAL_StatusTypeDef hal_status = HAL_OK; 368 | USBD_StatusTypeDef usb_status = USBD_OK; 369 | 370 | hal_status = HAL_PCD_Start(pdev->pData); 371 | 372 | usb_status = USBD_Get_USB_Status(hal_status); 373 | 374 | return usb_status; 375 | } 376 | 377 | /** 378 | * @brief Stops the low level portion of the device driver. 379 | * @param pdev: Device handle 380 | * @retval USBD status 381 | */ 382 | USBD_StatusTypeDef USBD_LL_Stop(USBD_HandleTypeDef *pdev) 383 | { 384 | HAL_StatusTypeDef hal_status = HAL_OK; 385 | USBD_StatusTypeDef usb_status = USBD_OK; 386 | 387 | hal_status = HAL_PCD_Stop(pdev->pData); 388 | 389 | usb_status = USBD_Get_USB_Status(hal_status); 390 | 391 | return usb_status; 392 | } 393 | 394 | /** 395 | * @brief Opens an endpoint of the low level driver. 396 | * @param pdev: Device handle 397 | * @param ep_addr: Endpoint number 398 | * @param ep_type: Endpoint type 399 | * @param ep_mps: Endpoint max packet size 400 | * @retval USBD status 401 | */ 402 | USBD_StatusTypeDef USBD_LL_OpenEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t ep_type, uint16_t ep_mps) 403 | { 404 | HAL_StatusTypeDef hal_status = HAL_OK; 405 | USBD_StatusTypeDef usb_status = USBD_OK; 406 | 407 | hal_status = HAL_PCD_EP_Open(pdev->pData, ep_addr, ep_mps, ep_type); 408 | 409 | usb_status = USBD_Get_USB_Status(hal_status); 410 | 411 | return usb_status; 412 | } 413 | 414 | /** 415 | * @brief Closes an endpoint of the low level driver. 416 | * @param pdev: Device handle 417 | * @param ep_addr: Endpoint number 418 | * @retval USBD status 419 | */ 420 | USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) 421 | { 422 | HAL_StatusTypeDef hal_status = HAL_OK; 423 | USBD_StatusTypeDef usb_status = USBD_OK; 424 | 425 | hal_status = HAL_PCD_EP_Close(pdev->pData, ep_addr); 426 | 427 | usb_status = USBD_Get_USB_Status(hal_status); 428 | 429 | return usb_status; 430 | } 431 | 432 | /** 433 | * @brief Flushes an endpoint of the Low Level Driver. 434 | * @param pdev: Device handle 435 | * @param ep_addr: Endpoint number 436 | * @retval USBD status 437 | */ 438 | USBD_StatusTypeDef USBD_LL_FlushEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) 439 | { 440 | HAL_StatusTypeDef hal_status = HAL_OK; 441 | USBD_StatusTypeDef usb_status = USBD_OK; 442 | 443 | hal_status = HAL_PCD_EP_Flush(pdev->pData, ep_addr); 444 | 445 | usb_status = USBD_Get_USB_Status(hal_status); 446 | 447 | return usb_status; 448 | } 449 | 450 | /** 451 | * @brief Sets a Stall condition on an endpoint of the Low Level Driver. 452 | * @param pdev: Device handle 453 | * @param ep_addr: Endpoint number 454 | * @retval USBD status 455 | */ 456 | USBD_StatusTypeDef USBD_LL_StallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) 457 | { 458 | HAL_StatusTypeDef hal_status = HAL_OK; 459 | USBD_StatusTypeDef usb_status = USBD_OK; 460 | 461 | hal_status = HAL_PCD_EP_SetStall(pdev->pData, ep_addr); 462 | 463 | usb_status = USBD_Get_USB_Status(hal_status); 464 | 465 | return usb_status; 466 | } 467 | 468 | /** 469 | * @brief Clears a Stall condition on an endpoint of the Low Level Driver. 470 | * @param pdev: Device handle 471 | * @param ep_addr: Endpoint number 472 | * @retval USBD status 473 | */ 474 | USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) 475 | { 476 | HAL_StatusTypeDef hal_status = HAL_OK; 477 | USBD_StatusTypeDef usb_status = USBD_OK; 478 | 479 | hal_status = HAL_PCD_EP_ClrStall(pdev->pData, ep_addr); 480 | 481 | usb_status = USBD_Get_USB_Status(hal_status); 482 | 483 | return usb_status; 484 | } 485 | 486 | /** 487 | * @brief Returns Stall condition. 488 | * @param pdev: Device handle 489 | * @param ep_addr: Endpoint number 490 | * @retval Stall (1: Yes, 0: No) 491 | */ 492 | uint8_t USBD_LL_IsStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) 493 | { 494 | PCD_HandleTypeDef *hpcd = (PCD_HandleTypeDef*) pdev->pData; 495 | 496 | if((ep_addr & 0x80) == 0x80) 497 | { 498 | return hpcd->IN_ep[ep_addr & 0x7F].is_stall; 499 | } 500 | else 501 | { 502 | return hpcd->OUT_ep[ep_addr & 0x7F].is_stall; 503 | } 504 | } 505 | 506 | /** 507 | * @brief Assigns a USB address to the device. 508 | * @param pdev: Device handle 509 | * @param dev_addr: Device address 510 | * @retval USBD status 511 | */ 512 | USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev, uint8_t dev_addr) 513 | { 514 | HAL_StatusTypeDef hal_status = HAL_OK; 515 | USBD_StatusTypeDef usb_status = USBD_OK; 516 | 517 | hal_status = HAL_PCD_SetAddress(pdev->pData, dev_addr); 518 | 519 | usb_status = USBD_Get_USB_Status(hal_status); 520 | 521 | return usb_status; 522 | } 523 | 524 | /** 525 | * @brief Transmits data over an endpoint. 526 | * @param pdev: Device handle 527 | * @param ep_addr: Endpoint number 528 | * @param pbuf: Pointer to data to be sent 529 | * @param size: Data size 530 | * @retval USBD status 531 | */ 532 | USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint16_t size) 533 | { 534 | HAL_StatusTypeDef hal_status = HAL_OK; 535 | USBD_StatusTypeDef usb_status = USBD_OK; 536 | 537 | hal_status = HAL_PCD_EP_Transmit(pdev->pData, ep_addr, pbuf, size); 538 | 539 | usb_status = USBD_Get_USB_Status(hal_status); 540 | 541 | return usb_status; 542 | } 543 | 544 | /** 545 | * @brief Prepares an endpoint for reception. 546 | * @param pdev: Device handle 547 | * @param ep_addr: Endpoint number 548 | * @param pbuf: Pointer to data to be received 549 | * @param size: Data size 550 | * @retval USBD status 551 | */ 552 | USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint16_t size) 553 | { 554 | HAL_StatusTypeDef hal_status = HAL_OK; 555 | USBD_StatusTypeDef usb_status = USBD_OK; 556 | 557 | hal_status = HAL_PCD_EP_Receive(pdev->pData, ep_addr, pbuf, size); 558 | 559 | usb_status = USBD_Get_USB_Status(hal_status); 560 | 561 | return usb_status; 562 | } 563 | 564 | /** 565 | * @brief Returns the last transferred packet size. 566 | * @param pdev: Device handle 567 | * @param ep_addr: Endpoint number 568 | * @retval Received Data Size 569 | */ 570 | uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef *pdev, uint8_t ep_addr) 571 | { 572 | return HAL_PCD_EP_GetRxCount((PCD_HandleTypeDef*) pdev->pData, ep_addr); 573 | } 574 | 575 | /** 576 | * @brief Delays routine for the USB device library. 577 | * @param Delay: Delay in ms 578 | * @retval None 579 | */ 580 | void USBD_LL_Delay(uint32_t Delay) 581 | { 582 | HAL_Delay(Delay); 583 | } 584 | 585 | /** 586 | * @brief Static single allocation. 587 | * @param size: Size of allocated memory 588 | * @retval None 589 | */ 590 | void *USBD_static_malloc(uint32_t size) 591 | { 592 | static uint32_t mem[(sizeof(USBD_HID_HandleTypeDef)/4)+1];/* On 32-bit boundary */ 593 | return mem; 594 | } 595 | 596 | /** 597 | * @brief Dummy memory free 598 | * @param p: Pointer to allocated memory address 599 | * @retval None 600 | */ 601 | void USBD_static_free(void *p) 602 | { 603 | 604 | } 605 | 606 | /* USER CODE BEGIN 5 */ 607 | /** 608 | * @brief Configures system clock after wake-up from USB Resume CallBack: 609 | * enable HSI, PLL and select PLL as system clock source. 610 | * @retval None 611 | */ 612 | static void SystemClockConfig_Resume(void) 613 | { 614 | SystemClock_Config(); 615 | } 616 | /* USER CODE END 5 */ 617 | 618 | /** 619 | * @brief Returns the USB status depending on the HAL status: 620 | * @param hal_status: HAL status 621 | * @retval USB status 622 | */ 623 | USBD_StatusTypeDef USBD_Get_USB_Status(HAL_StatusTypeDef hal_status) 624 | { 625 | USBD_StatusTypeDef usb_status = USBD_OK; 626 | 627 | switch (hal_status) 628 | { 629 | case HAL_OK : 630 | usb_status = USBD_OK; 631 | break; 632 | case HAL_ERROR : 633 | usb_status = USBD_FAIL; 634 | break; 635 | case HAL_BUSY : 636 | usb_status = USBD_BUSY; 637 | break; 638 | case HAL_TIMEOUT : 639 | usb_status = USBD_FAIL; 640 | break; 641 | default : 642 | usb_status = USBD_FAIL; 643 | break; 644 | } 645 | return usb_status; 646 | } 647 | -------------------------------------------------------------------------------- /STM32/USB_DEVICE/Target/usbd_conf.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : usbd_conf.h 5 | * @version : v2.0_Cube 6 | * @brief : Header for usbd_conf.c file. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2025 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __USBD_CONF__H__ 23 | #define __USBD_CONF__H__ 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | #include 31 | #include 32 | #include 33 | #include "main.h" 34 | #include "stm32f0xx.h" 35 | #include "stm32f0xx_hal.h" 36 | 37 | /* USER CODE BEGIN INCLUDE */ 38 | 39 | /* USER CODE END INCLUDE */ 40 | 41 | /** @addtogroup USBD_OTG_DRIVER 42 | * @{ 43 | */ 44 | 45 | /** @defgroup USBD_CONF USBD_CONF 46 | * @brief Configuration file for Usb otg low level driver. 47 | * @{ 48 | */ 49 | 50 | /** @defgroup USBD_CONF_Exported_Variables USBD_CONF_Exported_Variables 51 | * @brief Public variables. 52 | * @{ 53 | */ 54 | 55 | /** 56 | * @} 57 | */ 58 | 59 | /** @defgroup USBD_CONF_Exported_Defines USBD_CONF_Exported_Defines 60 | * @brief Defines for configuration of the Usb device. 61 | * @{ 62 | */ 63 | 64 | /*---------- -----------*/ 65 | #define USBD_MAX_NUM_INTERFACES 1 66 | /*---------- -----------*/ 67 | #define USBD_MAX_NUM_CONFIGURATION 1 68 | /*---------- -----------*/ 69 | #define USBD_MAX_STR_DESC_SIZ 512 70 | /*---------- -----------*/ 71 | #define USBD_DEBUG_LEVEL 0 72 | /*---------- -----------*/ 73 | #define USBD_SELF_POWERED 1 74 | /*---------- -----------*/ 75 | #define HID_FS_BINTERVAL 0xA 76 | 77 | /****************************************/ 78 | /* #define for FS and HS identification */ 79 | #define DEVICE_FS 0 80 | 81 | /** 82 | * @} 83 | */ 84 | 85 | /** @defgroup USBD_CONF_Exported_Macros USBD_CONF_Exported_Macros 86 | * @brief Aliases. 87 | * @{ 88 | */ 89 | 90 | /* Memory management macros */ 91 | 92 | /** Alias for memory allocation. */ 93 | #define USBD_malloc (uint32_t *)USBD_static_malloc 94 | 95 | /** Alias for memory release. */ 96 | #define USBD_free USBD_static_free 97 | 98 | /** Alias for memory set. */ 99 | #define USBD_memset /* Not used */ 100 | 101 | /** Alias for memory copy. */ 102 | #define USBD_memcpy /* Not used */ 103 | 104 | /** Alias for delay. */ 105 | #define USBD_Delay HAL_Delay 106 | 107 | /* DEBUG macros */ 108 | 109 | #if (USBD_DEBUG_LEVEL > 0) 110 | #define USBD_UsrLog(...) printf(__VA_ARGS__);\ 111 | printf("\n"); 112 | #else 113 | #define USBD_UsrLog(...) 114 | #endif 115 | 116 | #if (USBD_DEBUG_LEVEL > 1) 117 | 118 | #define USBD_ErrLog(...) printf("ERROR: ") ;\ 119 | printf(__VA_ARGS__);\ 120 | printf("\n"); 121 | #else 122 | #define USBD_ErrLog(...) 123 | #endif 124 | 125 | #if (USBD_DEBUG_LEVEL > 2) 126 | #define USBD_DbgLog(...) printf("DEBUG : ") ;\ 127 | printf(__VA_ARGS__);\ 128 | printf("\n"); 129 | #else 130 | #define USBD_DbgLog(...) 131 | #endif 132 | 133 | /** 134 | * @} 135 | */ 136 | 137 | /** @defgroup USBD_CONF_Exported_Types USBD_CONF_Exported_Types 138 | * @brief Types. 139 | * @{ 140 | */ 141 | 142 | /** 143 | * @} 144 | */ 145 | 146 | /** @defgroup USBD_CONF_Exported_FunctionsPrototype USBD_CONF_Exported_FunctionsPrototype 147 | * @brief Declaration of public functions for Usb device. 148 | * @{ 149 | */ 150 | 151 | /* Exported functions -------------------------------------------------------*/ 152 | void *USBD_static_malloc(uint32_t size); 153 | void USBD_static_free(void *p); 154 | /** 155 | * @} 156 | */ 157 | 158 | /** 159 | * @} 160 | */ 161 | 162 | /** 163 | * @} 164 | */ 165 | 166 | #ifdef __cplusplus 167 | } 168 | #endif 169 | 170 | #endif /* __USBD_CONF__H__ */ 171 | -------------------------------------------------------------------------------- /photos/IMG_20250104_114501_754.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enblack0/Hidden-HID-v2/4f44eee1a87c04dfad725e9ba3b24868d8b28b1a/photos/IMG_20250104_114501_754.jpg -------------------------------------------------------------------------------- /photos/IMG_20250118_131920_344.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enblack0/Hidden-HID-v2/4f44eee1a87c04dfad725e9ba3b24868d8b28b1a/photos/IMG_20250118_131920_344.jpg -------------------------------------------------------------------------------- /photos/IMG_20250118_132318_155.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enblack0/Hidden-HID-v2/4f44eee1a87c04dfad725e9ba3b24868d8b28b1a/photos/IMG_20250118_132318_155.jpg -------------------------------------------------------------------------------- /photos/IMG_20250118_132709_884.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enblack0/Hidden-HID-v2/4f44eee1a87c04dfad725e9ba3b24868d8b28b1a/photos/IMG_20250118_132709_884.jpg -------------------------------------------------------------------------------- /photos/IMG_20250118_132744_293.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enblack0/Hidden-HID-v2/4f44eee1a87c04dfad725e9ba3b24868d8b28b1a/photos/IMG_20250118_132744_293.jpg -------------------------------------------------------------------------------- /photos/IMG_20250118_132744_294.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enblack0/Hidden-HID-v2/4f44eee1a87c04dfad725e9ba3b24868d8b28b1a/photos/IMG_20250118_132744_294.jpg -------------------------------------------------------------------------------- /photos/Screenshot 2025-01-18 160303.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enblack0/Hidden-HID-v2/4f44eee1a87c04dfad725e9ba3b24868d8b28b1a/photos/Screenshot 2025-01-18 160303.png -------------------------------------------------------------------------------- /photos/bot-hr.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enblack0/Hidden-HID-v2/4f44eee1a87c04dfad725e9ba3b24868d8b28b1a/photos/bot-hr.jpg -------------------------------------------------------------------------------- /photos/cover-cropped.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enblack0/Hidden-HID-v2/4f44eee1a87c04dfad725e9ba3b24868d8b28b1a/photos/cover-cropped.jpg -------------------------------------------------------------------------------- /photos/top-hr.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enblack0/Hidden-HID-v2/4f44eee1a87c04dfad725e9ba3b24868d8b28b1a/photos/top-hr.jpg --------------------------------------------------------------------------------