diff --git a/Firmware/.cproject b/Firmware/.cproject
index 6a432af..312f829 100644
--- a/Firmware/.cproject
+++ b/Firmware/.cproject
@@ -23,9 +23,11 @@
-
+
+
+
@@ -42,6 +44,10 @@
+
+
+
+
@@ -64,6 +70,10 @@
+
+
+
+
@@ -87,6 +97,12 @@
+
+
+
+
+
+
@@ -117,6 +133,8 @@
+
+
@@ -147,7 +165,7 @@
-
+
@@ -162,6 +180,10 @@
+
+
+
+
@@ -183,6 +205,10 @@
+
+
+
+
@@ -204,6 +230,12 @@
+
+
+
+
+
+
@@ -232,6 +264,7 @@
+
@@ -240,199 +273,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -467,4 +307,12 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Firmware/.mxproject b/Firmware/.mxproject
index 18eb5e4..940ee3f 100644
--- a/Firmware/.mxproject
+++ b/Firmware/.mxproject
@@ -1,14 +1,14 @@
[PreviousLibFiles]
-LibFiles=Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_adc.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_adc_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_adc.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_def.h;Drivers\STM32G4xx_HAL_Driver\Inc\Legacy\stm32_hal_legacy.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_rcc.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_rcc_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_bus.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_rcc.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_system.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_utils.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_crs.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_flash.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_flash_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_flash_ramfunc.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_gpio.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_gpio_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_gpio.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_exti.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_exti.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_dma.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_dma_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_dma.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_dmamux.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_pwr.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_pwr_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_pwr.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_cortex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_cortex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_comp.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_comp.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_dac.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_dac.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_dac_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_fdcan.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_opamp.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_opamp.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_opamp_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_tim.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_tim.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_tim_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_uart.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_usart.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_lpuart.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_uart_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_pcd.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_pcd_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_usb.h;Middlewares\Third_Party\FreeRTOS\Source\include\croutine.h;Middlewares\Third_Party\FreeRTOS\Source\include\deprecated_definitions.h;Middlewares\Third_Party\FreeRTOS\Source\include\event_groups.h;Middlewares\Third_Party\FreeRTOS\Source\include\FreeRTOS.h;Middlewares\Third_Party\FreeRTOS\Source\include\list.h;Middlewares\Third_Party\FreeRTOS\Source\include\message_buffer.h;Middlewares\Third_Party\FreeRTOS\Source\include\mpu_prototypes.h;Middlewares\Third_Party\FreeRTOS\Source\include\mpu_wrappers.h;Middlewares\Third_Party\FreeRTOS\Source\include\portable.h;Middlewares\Third_Party\FreeRTOS\Source\include\projdefs.h;Middlewares\Third_Party\FreeRTOS\Source\include\queue.h;Middlewares\Third_Party\FreeRTOS\Source\include\semphr.h;Middlewares\Third_Party\FreeRTOS\Source\include\stack_macros.h;Middlewares\Third_Party\FreeRTOS\Source\include\StackMacros.h;Middlewares\Third_Party\FreeRTOS\Source\include\stream_buffer.h;Middlewares\Third_Party\FreeRTOS\Source\include\task.h;Middlewares\Third_Party\FreeRTOS\Source\include\timers.h;Middlewares\Third_Party\FreeRTOS\Source\include\atomic.h;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os2.h;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os.h;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\freertos_mpool.h;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\freertos_os2.h;Middlewares\Third_Party\FreeRTOS\Source\portable\GCC\ARM_CM4F\portmacro.h;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_adc.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_adc_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_ll_adc.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_rcc.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_rcc_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_flash.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_flash_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_flash_ramfunc.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_gpio.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_exti.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_dma.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_dma_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_pwr.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_pwr_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_cortex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_comp.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_dac.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_dac_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_fdcan.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_opamp.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_opamp_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_tim.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_tim_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_uart.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_uart_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_pcd.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_pcd_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_ll_usb.c;Middlewares\Third_Party\FreeRTOS\Source\croutine.c;Middlewares\Third_Party\FreeRTOS\Source\event_groups.c;Middlewares\Third_Party\FreeRTOS\Source\list.c;Middlewares\Third_Party\FreeRTOS\Source\queue.c;Middlewares\Third_Party\FreeRTOS\Source\stream_buffer.c;Middlewares\Third_Party\FreeRTOS\Source\tasks.c;Middlewares\Third_Party\FreeRTOS\Source\timers.c;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os2.c;Middlewares\Third_Party\FreeRTOS\Source\portable\MemMang\heap_4.c;Middlewares\Third_Party\FreeRTOS\Source\portable\GCC\ARM_CM4F\port.c;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_adc.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_adc_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_adc.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_def.h;Drivers\STM32G4xx_HAL_Driver\Inc\Legacy\stm32_hal_legacy.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_rcc.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_rcc_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_bus.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_rcc.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_system.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_utils.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_crs.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_flash.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_flash_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_flash_ramfunc.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_gpio.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_gpio_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_gpio.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_exti.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_exti.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_dma.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_dma_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_dma.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_dmamux.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_pwr.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_pwr_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_pwr.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_cortex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_cortex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_comp.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_comp.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_dac.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_dac.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_dac_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_fdcan.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_opamp.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_opamp.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_opamp_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_tim.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_tim.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_tim_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_uart.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_usart.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_lpuart.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_uart_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_pcd.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_pcd_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_usb.h;Middlewares\Third_Party\FreeRTOS\Source\include\croutine.h;Middlewares\Third_Party\FreeRTOS\Source\include\deprecated_definitions.h;Middlewares\Third_Party\FreeRTOS\Source\include\event_groups.h;Middlewares\Third_Party\FreeRTOS\Source\include\FreeRTOS.h;Middlewares\Third_Party\FreeRTOS\Source\include\list.h;Middlewares\Third_Party\FreeRTOS\Source\include\message_buffer.h;Middlewares\Third_Party\FreeRTOS\Source\include\mpu_prototypes.h;Middlewares\Third_Party\FreeRTOS\Source\include\mpu_wrappers.h;Middlewares\Third_Party\FreeRTOS\Source\include\portable.h;Middlewares\Third_Party\FreeRTOS\Source\include\projdefs.h;Middlewares\Third_Party\FreeRTOS\Source\include\queue.h;Middlewares\Third_Party\FreeRTOS\Source\include\semphr.h;Middlewares\Third_Party\FreeRTOS\Source\include\stack_macros.h;Middlewares\Third_Party\FreeRTOS\Source\include\StackMacros.h;Middlewares\Third_Party\FreeRTOS\Source\include\stream_buffer.h;Middlewares\Third_Party\FreeRTOS\Source\include\task.h;Middlewares\Third_Party\FreeRTOS\Source\include\timers.h;Middlewares\Third_Party\FreeRTOS\Source\include\atomic.h;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os2.h;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os.h;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\freertos_mpool.h;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\freertos_os2.h;Middlewares\Third_Party\FreeRTOS\Source\portable\GCC\ARM_CM4F\portmacro.h;Drivers\CMSIS\Device\ST\STM32G4xx\Include\stm32g474xx.h;Drivers\CMSIS\Device\ST\STM32G4xx\Include\stm32g4xx.h;Drivers\CMSIS\Device\ST\STM32G4xx\Include\system_stm32g4xx.h;Drivers\CMSIS\Device\ST\STM32G4xx\Include\system_stm32g4xx.h;Drivers\CMSIS\Device\ST\STM32G4xx\Source\Templates\system_stm32g4xx.c;Drivers\CMSIS\Include\cmsis_armcc.h;Drivers\CMSIS\Include\cmsis_armclang.h;Drivers\CMSIS\Include\cmsis_armclang_ltm.h;Drivers\CMSIS\Include\cmsis_compiler.h;Drivers\CMSIS\Include\cmsis_gcc.h;Drivers\CMSIS\Include\cmsis_iccarm.h;Drivers\CMSIS\Include\cmsis_version.h;Drivers\CMSIS\Include\core_armv81mml.h;Drivers\CMSIS\Include\core_armv8mbl.h;Drivers\CMSIS\Include\core_armv8mml.h;Drivers\CMSIS\Include\core_cm0.h;Drivers\CMSIS\Include\core_cm0plus.h;Drivers\CMSIS\Include\core_cm1.h;Drivers\CMSIS\Include\core_cm23.h;Drivers\CMSIS\Include\core_cm3.h;Drivers\CMSIS\Include\core_cm33.h;Drivers\CMSIS\Include\core_cm35p.h;Drivers\CMSIS\Include\core_cm4.h;Drivers\CMSIS\Include\core_cm7.h;Drivers\CMSIS\Include\core_sc000.h;Drivers\CMSIS\Include\core_sc300.h;Drivers\CMSIS\Include\mpu_armv7.h;Drivers\CMSIS\Include\mpu_armv8.h;Drivers\CMSIS\Include\tz_context.h;
+LibFiles=Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_pcd.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_pcd_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_usb.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_def.h;Drivers\STM32G4xx_HAL_Driver\Inc\Legacy\stm32_hal_legacy.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_rcc.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_rcc_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_bus.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_rcc.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_system.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_utils.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_crs.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_flash.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_flash_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_flash_ramfunc.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_gpio.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_gpio_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_gpio.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_exti.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_exti.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_dma.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_dma_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_dma.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_dmamux.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_pwr.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_pwr_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_pwr.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_cortex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_cortex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_adc.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_adc_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_adc.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_comp.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_comp.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_dac.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_dac.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_dac_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_fdcan.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_opamp.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_opamp.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_opamp_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_tim.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_tim.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_tim_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_uart.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_usart.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_lpuart.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_uart_ex.h;Middlewares\Third_Party\FreeRTOS\Source\include\croutine.h;Middlewares\Third_Party\FreeRTOS\Source\include\deprecated_definitions.h;Middlewares\Third_Party\FreeRTOS\Source\include\event_groups.h;Middlewares\Third_Party\FreeRTOS\Source\include\FreeRTOS.h;Middlewares\Third_Party\FreeRTOS\Source\include\list.h;Middlewares\Third_Party\FreeRTOS\Source\include\message_buffer.h;Middlewares\Third_Party\FreeRTOS\Source\include\mpu_prototypes.h;Middlewares\Third_Party\FreeRTOS\Source\include\mpu_wrappers.h;Middlewares\Third_Party\FreeRTOS\Source\include\portable.h;Middlewares\Third_Party\FreeRTOS\Source\include\projdefs.h;Middlewares\Third_Party\FreeRTOS\Source\include\queue.h;Middlewares\Third_Party\FreeRTOS\Source\include\semphr.h;Middlewares\Third_Party\FreeRTOS\Source\include\stack_macros.h;Middlewares\Third_Party\FreeRTOS\Source\include\StackMacros.h;Middlewares\Third_Party\FreeRTOS\Source\include\stream_buffer.h;Middlewares\Third_Party\FreeRTOS\Source\include\task.h;Middlewares\Third_Party\FreeRTOS\Source\include\timers.h;Middlewares\Third_Party\FreeRTOS\Source\include\atomic.h;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os2.h;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os.h;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\freertos_mpool.h;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\freertos_os2.h;Middlewares\Third_Party\FreeRTOS\Source\portable\GCC\ARM_CM4F\portmacro.h;Middlewares\ST\STM32_USB_Device_Library\Core\Inc\usbd_core.h;Middlewares\ST\STM32_USB_Device_Library\Core\Inc\usbd_ctlreq.h;Middlewares\ST\STM32_USB_Device_Library\Core\Inc\usbd_def.h;Middlewares\ST\STM32_USB_Device_Library\Core\Inc\usbd_ioreq.h;Middlewares\ST\STM32_USB_Device_Library\Class\CustomHID\Inc\usbd_customhid.h;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_pcd.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_pcd_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_ll_usb.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_rcc.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_rcc_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_flash.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_flash_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_flash_ramfunc.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_gpio.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_exti.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_dma.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_dma_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_pwr.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_pwr_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_cortex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_adc.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_adc_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_ll_adc.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_comp.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_dac.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_dac_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_fdcan.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_opamp.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_opamp_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_tim.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_tim_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_uart.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_uart_ex.c;Middlewares\Third_Party\FreeRTOS\Source\croutine.c;Middlewares\Third_Party\FreeRTOS\Source\event_groups.c;Middlewares\Third_Party\FreeRTOS\Source\list.c;Middlewares\Third_Party\FreeRTOS\Source\queue.c;Middlewares\Third_Party\FreeRTOS\Source\stream_buffer.c;Middlewares\Third_Party\FreeRTOS\Source\tasks.c;Middlewares\Third_Party\FreeRTOS\Source\timers.c;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os2.c;Middlewares\Third_Party\FreeRTOS\Source\portable\MemMang\heap_4.c;Middlewares\Third_Party\FreeRTOS\Source\portable\GCC\ARM_CM4F\port.c;Middlewares\ST\STM32_USB_Device_Library\Core\Src\usbd_core.c;Middlewares\ST\STM32_USB_Device_Library\Core\Src\usbd_ctlreq.c;Middlewares\ST\STM32_USB_Device_Library\Core\Src\usbd_ioreq.c;Middlewares\ST\STM32_USB_Device_Library\Class\CustomHID\Src\usbd_customhid.c;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_pcd.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_pcd_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_usb.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_def.h;Drivers\STM32G4xx_HAL_Driver\Inc\Legacy\stm32_hal_legacy.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_rcc.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_rcc_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_bus.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_rcc.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_system.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_utils.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_crs.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_flash.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_flash_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_flash_ramfunc.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_gpio.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_gpio_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_gpio.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_exti.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_exti.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_dma.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_dma_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_dma.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_dmamux.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_pwr.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_pwr_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_pwr.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_cortex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_cortex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_adc.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_adc_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_adc.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_comp.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_comp.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_dac.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_dac.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_dac_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_fdcan.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_opamp.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_opamp.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_opamp_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_tim.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_tim.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_tim_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_uart.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_usart.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_lpuart.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_uart_ex.h;Middlewares\Third_Party\FreeRTOS\Source\include\croutine.h;Middlewares\Third_Party\FreeRTOS\Source\include\deprecated_definitions.h;Middlewares\Third_Party\FreeRTOS\Source\include\event_groups.h;Middlewares\Third_Party\FreeRTOS\Source\include\FreeRTOS.h;Middlewares\Third_Party\FreeRTOS\Source\include\list.h;Middlewares\Third_Party\FreeRTOS\Source\include\message_buffer.h;Middlewares\Third_Party\FreeRTOS\Source\include\mpu_prototypes.h;Middlewares\Third_Party\FreeRTOS\Source\include\mpu_wrappers.h;Middlewares\Third_Party\FreeRTOS\Source\include\portable.h;Middlewares\Third_Party\FreeRTOS\Source\include\projdefs.h;Middlewares\Third_Party\FreeRTOS\Source\include\queue.h;Middlewares\Third_Party\FreeRTOS\Source\include\semphr.h;Middlewares\Third_Party\FreeRTOS\Source\include\stack_macros.h;Middlewares\Third_Party\FreeRTOS\Source\include\StackMacros.h;Middlewares\Third_Party\FreeRTOS\Source\include\stream_buffer.h;Middlewares\Third_Party\FreeRTOS\Source\include\task.h;Middlewares\Third_Party\FreeRTOS\Source\include\timers.h;Middlewares\Third_Party\FreeRTOS\Source\include\atomic.h;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os2.h;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os.h;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\freertos_mpool.h;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\freertos_os2.h;Middlewares\Third_Party\FreeRTOS\Source\portable\GCC\ARM_CM4F\portmacro.h;Middlewares\ST\STM32_USB_Device_Library\Core\Inc\usbd_core.h;Middlewares\ST\STM32_USB_Device_Library\Core\Inc\usbd_ctlreq.h;Middlewares\ST\STM32_USB_Device_Library\Core\Inc\usbd_def.h;Middlewares\ST\STM32_USB_Device_Library\Core\Inc\usbd_ioreq.h;Middlewares\ST\STM32_USB_Device_Library\Class\CustomHID\Inc\usbd_customhid.h;Drivers\CMSIS\Device\ST\STM32G4xx\Include\stm32g474xx.h;Drivers\CMSIS\Device\ST\STM32G4xx\Include\stm32g4xx.h;Drivers\CMSIS\Device\ST\STM32G4xx\Include\system_stm32g4xx.h;Drivers\CMSIS\Device\ST\STM32G4xx\Include\system_stm32g4xx.h;Drivers\CMSIS\Device\ST\STM32G4xx\Source\Templates\system_stm32g4xx.c;Drivers\CMSIS\Include\cmsis_armcc.h;Drivers\CMSIS\Include\cmsis_armclang.h;Drivers\CMSIS\Include\cmsis_armclang_ltm.h;Drivers\CMSIS\Include\cmsis_compiler.h;Drivers\CMSIS\Include\cmsis_gcc.h;Drivers\CMSIS\Include\cmsis_iccarm.h;Drivers\CMSIS\Include\cmsis_version.h;Drivers\CMSIS\Include\core_armv81mml.h;Drivers\CMSIS\Include\core_armv8mbl.h;Drivers\CMSIS\Include\core_armv8mml.h;Drivers\CMSIS\Include\core_cm0.h;Drivers\CMSIS\Include\core_cm0plus.h;Drivers\CMSIS\Include\core_cm1.h;Drivers\CMSIS\Include\core_cm23.h;Drivers\CMSIS\Include\core_cm3.h;Drivers\CMSIS\Include\core_cm33.h;Drivers\CMSIS\Include\core_cm35p.h;Drivers\CMSIS\Include\core_cm4.h;Drivers\CMSIS\Include\core_cm7.h;Drivers\CMSIS\Include\core_sc000.h;Drivers\CMSIS\Include\core_sc300.h;Drivers\CMSIS\Include\mpu_armv7.h;Drivers\CMSIS\Include\mpu_armv8.h;Drivers\CMSIS\Include\tz_context.h;
[PreviousUsedCubeIDEFiles]
-SourceFiles=Core\Src\main.c;Core\Src\gpio.c;Core\Src\app_freertos.c;Core\Src\adc.c;Core\Src\comp.c;Core\Src\dac.c;Core\Src\fdcan.c;Core\Src\opamp.c;Core\Src\tim.c;Core\Src\usart.c;Core\Src\usb.c;Core\Src\stm32g4xx_it.c;Core\Src\stm32g4xx_hal_msp.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_adc.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_adc_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_ll_adc.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_rcc.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_rcc_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_flash.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_flash_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_flash_ramfunc.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_gpio.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_exti.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_dma.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_dma_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_pwr.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_pwr_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_cortex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_comp.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_dac.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_dac_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_fdcan.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_opamp.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_opamp_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_tim.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_tim_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_uart.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_uart_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_pcd.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_pcd_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_ll_usb.c;Middlewares\Third_Party\FreeRTOS\Source\croutine.c;Middlewares\Third_Party\FreeRTOS\Source\event_groups.c;Middlewares\Third_Party\FreeRTOS\Source\list.c;Middlewares\Third_Party\FreeRTOS\Source\queue.c;Middlewares\Third_Party\FreeRTOS\Source\stream_buffer.c;Middlewares\Third_Party\FreeRTOS\Source\tasks.c;Middlewares\Third_Party\FreeRTOS\Source\timers.c;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os2.c;Middlewares\Third_Party\FreeRTOS\Source\portable\MemMang\heap_4.c;Middlewares\Third_Party\FreeRTOS\Source\portable\GCC\ARM_CM4F\port.c;Drivers\CMSIS\Device\ST\STM32G4xx\Source\Templates\system_stm32g4xx.c;Core\Src\system_stm32g4xx.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_adc.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_adc_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_ll_adc.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_rcc.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_rcc_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_flash.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_flash_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_flash_ramfunc.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_gpio.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_exti.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_dma.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_dma_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_pwr.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_pwr_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_cortex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_comp.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_dac.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_dac_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_fdcan.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_opamp.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_opamp_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_tim.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_tim_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_uart.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_uart_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_pcd.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_pcd_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_ll_usb.c;Middlewares\Third_Party\FreeRTOS\Source\croutine.c;Middlewares\Third_Party\FreeRTOS\Source\event_groups.c;Middlewares\Third_Party\FreeRTOS\Source\list.c;Middlewares\Third_Party\FreeRTOS\Source\queue.c;Middlewares\Third_Party\FreeRTOS\Source\stream_buffer.c;Middlewares\Third_Party\FreeRTOS\Source\tasks.c;Middlewares\Third_Party\FreeRTOS\Source\timers.c;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os2.c;Middlewares\Third_Party\FreeRTOS\Source\portable\MemMang\heap_4.c;Middlewares\Third_Party\FreeRTOS\Source\portable\GCC\ARM_CM4F\port.c;Drivers\CMSIS\Device\ST\STM32G4xx\Source\Templates\system_stm32g4xx.c;Core\Src\system_stm32g4xx.c;;;Middlewares\Third_Party\FreeRTOS\Source\croutine.c;Middlewares\Third_Party\FreeRTOS\Source\event_groups.c;Middlewares\Third_Party\FreeRTOS\Source\list.c;Middlewares\Third_Party\FreeRTOS\Source\queue.c;Middlewares\Third_Party\FreeRTOS\Source\stream_buffer.c;Middlewares\Third_Party\FreeRTOS\Source\tasks.c;Middlewares\Third_Party\FreeRTOS\Source\timers.c;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os2.c;Middlewares\Third_Party\FreeRTOS\Source\portable\MemMang\heap_4.c;Middlewares\Third_Party\FreeRTOS\Source\portable\GCC\ARM_CM4F\port.c;
-HeaderPath=Drivers\STM32G4xx_HAL_Driver\Inc;Drivers\STM32G4xx_HAL_Driver\Inc\Legacy;Middlewares\Third_Party\FreeRTOS\Source\include;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2;Middlewares\Third_Party\FreeRTOS\Source\portable\GCC\ARM_CM4F;Drivers\CMSIS\Device\ST\STM32G4xx\Include;Drivers\CMSIS\Include;Core\Inc;
+SourceFiles=Core\Src\main.c;Core\Src\gpio.c;Core\Src\app_freertos.c;Core\Src\adc.c;Core\Src\comp.c;Core\Src\dac.c;Core\Src\fdcan.c;Core\Src\opamp.c;Core\Src\tim.c;Core\Src\usart.c;USB_Device\App\usb_device.c;USB_Device\Target\usbd_conf.c;USB_Device\App\usbd_desc.c;USB_Device\App\usbd_custom_hid_if.c;Core\Src\stm32g4xx_it.c;Core\Src\stm32g4xx_hal_msp.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_pcd.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_pcd_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_ll_usb.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_rcc.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_rcc_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_flash.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_flash_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_flash_ramfunc.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_gpio.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_exti.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_dma.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_dma_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_pwr.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_pwr_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_cortex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_adc.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_adc_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_ll_adc.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_comp.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_dac.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_dac_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_fdcan.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_opamp.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_opamp_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_tim.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_tim_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_uart.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_uart_ex.c;Middlewares\Third_Party\FreeRTOS\Source\croutine.c;Middlewares\Third_Party\FreeRTOS\Source\event_groups.c;Middlewares\Third_Party\FreeRTOS\Source\list.c;Middlewares\Third_Party\FreeRTOS\Source\queue.c;Middlewares\Third_Party\FreeRTOS\Source\stream_buffer.c;Middlewares\Third_Party\FreeRTOS\Source\tasks.c;Middlewares\Third_Party\FreeRTOS\Source\timers.c;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os2.c;Middlewares\Third_Party\FreeRTOS\Source\portable\MemMang\heap_4.c;Middlewares\Third_Party\FreeRTOS\Source\portable\GCC\ARM_CM4F\port.c;Middlewares\ST\STM32_USB_Device_Library\Core\Src\usbd_core.c;Middlewares\ST\STM32_USB_Device_Library\Core\Src\usbd_ctlreq.c;Middlewares\ST\STM32_USB_Device_Library\Core\Src\usbd_ioreq.c;Middlewares\ST\STM32_USB_Device_Library\Class\CustomHID\Src\usbd_customhid.c;Drivers\CMSIS\Device\ST\STM32G4xx\Source\Templates\system_stm32g4xx.c;Core\Src\system_stm32g4xx.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_pcd.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_pcd_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_ll_usb.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_rcc.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_rcc_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_flash.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_flash_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_flash_ramfunc.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_gpio.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_exti.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_dma.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_dma_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_pwr.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_pwr_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_cortex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_adc.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_adc_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_ll_adc.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_comp.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_dac.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_dac_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_fdcan.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_opamp.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_opamp_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_tim.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_tim_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_uart.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_uart_ex.c;Middlewares\Third_Party\FreeRTOS\Source\croutine.c;Middlewares\Third_Party\FreeRTOS\Source\event_groups.c;Middlewares\Third_Party\FreeRTOS\Source\list.c;Middlewares\Third_Party\FreeRTOS\Source\queue.c;Middlewares\Third_Party\FreeRTOS\Source\stream_buffer.c;Middlewares\Third_Party\FreeRTOS\Source\tasks.c;Middlewares\Third_Party\FreeRTOS\Source\timers.c;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os2.c;Middlewares\Third_Party\FreeRTOS\Source\portable\MemMang\heap_4.c;Middlewares\Third_Party\FreeRTOS\Source\portable\GCC\ARM_CM4F\port.c;Middlewares\ST\STM32_USB_Device_Library\Core\Src\usbd_core.c;Middlewares\ST\STM32_USB_Device_Library\Core\Src\usbd_ctlreq.c;Middlewares\ST\STM32_USB_Device_Library\Core\Src\usbd_ioreq.c;Middlewares\ST\STM32_USB_Device_Library\Class\CustomHID\Src\usbd_customhid.c;Drivers\CMSIS\Device\ST\STM32G4xx\Source\Templates\system_stm32g4xx.c;Core\Src\system_stm32g4xx.c;;;Middlewares\Third_Party\FreeRTOS\Source\croutine.c;Middlewares\Third_Party\FreeRTOS\Source\event_groups.c;Middlewares\Third_Party\FreeRTOS\Source\list.c;Middlewares\Third_Party\FreeRTOS\Source\queue.c;Middlewares\Third_Party\FreeRTOS\Source\stream_buffer.c;Middlewares\Third_Party\FreeRTOS\Source\tasks.c;Middlewares\Third_Party\FreeRTOS\Source\timers.c;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os2.c;Middlewares\Third_Party\FreeRTOS\Source\portable\MemMang\heap_4.c;Middlewares\Third_Party\FreeRTOS\Source\portable\GCC\ARM_CM4F\port.c;Middlewares\ST\STM32_USB_Device_Library\Core\Src\usbd_core.c;Middlewares\ST\STM32_USB_Device_Library\Core\Src\usbd_ctlreq.c;Middlewares\ST\STM32_USB_Device_Library\Core\Src\usbd_ioreq.c;Middlewares\ST\STM32_USB_Device_Library\Class\CustomHID\Src\usbd_customhid.c;
+HeaderPath=Drivers\STM32G4xx_HAL_Driver\Inc;Drivers\STM32G4xx_HAL_Driver\Inc\Legacy;Middlewares\Third_Party\FreeRTOS\Source\include;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2;Middlewares\Third_Party\FreeRTOS\Source\portable\GCC\ARM_CM4F;Middlewares\ST\STM32_USB_Device_Library\Core\Inc;Middlewares\ST\STM32_USB_Device_Library\Class\CustomHID\Inc;Drivers\CMSIS\Device\ST\STM32G4xx\Include;Drivers\CMSIS\Include;Core\Inc;USB_Device\App;USB_Device\Target;
CDefines=USE_HAL_DRIVER;STM32G474xx;USE_HAL_DRIVER;USE_HAL_DRIVER;
[PreviousGenFiles]
AdvancedFolderStructure=true
-HeaderFileListSize=13
+HeaderFileListSize=16
HeaderFiles#0=..\Core\Inc\gpio.h
HeaderFiles#1=..\Core\Inc\FreeRTOSConfig.h
HeaderFiles#2=..\Core\Inc\adc.h
@@ -18,14 +18,19 @@ HeaderFiles#5=..\Core\Inc\fdcan.h
HeaderFiles#6=..\Core\Inc\opamp.h
HeaderFiles#7=..\Core\Inc\tim.h
HeaderFiles#8=..\Core\Inc\usart.h
-HeaderFiles#9=..\Core\Inc\usb.h
-HeaderFiles#10=..\Core\Inc\stm32g4xx_it.h
-HeaderFiles#11=..\Core\Inc\stm32g4xx_hal_conf.h
-HeaderFiles#12=..\Core\Inc\main.h
-HeaderFolderListSize=1
+HeaderFiles#9=..\USB_Device\App\usb_device.h
+HeaderFiles#10=..\USB_Device\Target\usbd_conf.h
+HeaderFiles#11=..\USB_Device\App\usbd_desc.h
+HeaderFiles#12=..\USB_Device\App\usbd_custom_hid_if.h
+HeaderFiles#13=..\Core\Inc\stm32g4xx_it.h
+HeaderFiles#14=..\Core\Inc\stm32g4xx_hal_conf.h
+HeaderFiles#15=..\Core\Inc\main.h
+HeaderFolderListSize=3
HeaderPath#0=..\Core\Inc
+HeaderPath#1=..\USB_Device\App
+HeaderPath#2=..\USB_Device\Target
HeaderFiles=;
-SourceFileListSize=13
+SourceFileListSize=16
SourceFiles#0=..\Core\Src\gpio.c
SourceFiles#1=..\Core\Src\app_freertos.c
SourceFiles#2=..\Core\Src\adc.c
@@ -35,11 +40,16 @@ SourceFiles#5=..\Core\Src\fdcan.c
SourceFiles#6=..\Core\Src\opamp.c
SourceFiles#7=..\Core\Src\tim.c
SourceFiles#8=..\Core\Src\usart.c
-SourceFiles#9=..\Core\Src\usb.c
-SourceFiles#10=..\Core\Src\stm32g4xx_it.c
-SourceFiles#11=..\Core\Src\stm32g4xx_hal_msp.c
-SourceFiles#12=..\Core\Src\main.c
-SourceFolderListSize=1
+SourceFiles#9=..\USB_Device\App\usb_device.c
+SourceFiles#10=..\USB_Device\Target\usbd_conf.c
+SourceFiles#11=..\USB_Device\App\usbd_desc.c
+SourceFiles#12=..\USB_Device\App\usbd_custom_hid_if.c
+SourceFiles#13=..\Core\Src\stm32g4xx_it.c
+SourceFiles#14=..\Core\Src\stm32g4xx_hal_msp.c
+SourceFiles#15=..\Core\Src\main.c
+SourceFolderListSize=3
SourcePath#0=..\Core\Src
+SourcePath#1=..\USB_Device\App
+SourcePath#2=..\USB_Device\Target
SourceFiles=;
diff --git a/Firmware/Application/start.cpp b/Firmware/Application/start.cpp
new file mode 100644
index 0000000..8bdbc8f
--- /dev/null
+++ b/Firmware/Application/start.cpp
@@ -0,0 +1,52 @@
+/*
+ * start.cpp
+ *
+ * Created on: Oct 31, 2024
+ * Author: Gabriel
+ */
+
+#include "start.h"
+#include
+#include "FreeRTOS.h"
+#include "GPIO_Pin_STM32.hpp"
+#include "LogDriver.hpp"
+#include "GPIO_Pin_STM32.hpp"
+#include "PWM_Pin_STM32.hpp"
+#include "Queue_STM32.hpp"
+#include "CDC_STM32.hpp"
+#include "Encoder_STM32.hpp"
+#include "SoftTimer_STM32.hpp"
+
+void executableDispatch(void* _executable){
+ Executable* executable = static_cast(_executable);
+ executable->execute();
+ vTaskDelete(NULL);
+}
+
+void start(){
+ printf("----------------INIT----------------\n");
+ printf("X and Y: %u, %u\n", (uint16_t)HAL_GetUIDw0(), (uint16_t)HAL_GetUIDw0()>>16);
+ printf("Wafer number: %u\n", (uint8_t)HAL_GetUIDw1());
+ printf("Lot number: %c%c%c%c%c%c%c\n",
+ (uint8_t)(HAL_GetUIDw1()>>8),
+ (uint8_t)(HAL_GetUIDw1()>>16),
+ (uint8_t)(HAL_GetUIDw1()>>24),
+ (uint8_t)(HAL_GetUIDw2()),
+ (uint8_t)(HAL_GetUIDw2()>>8),
+ (uint8_t)(HAL_GetUIDw2()>>16),
+ (uint8_t)(HAL_GetUIDw2()>>24)
+ );
+ // Init log facility
+ LogDriver::getInstance()->init();
+ TaskHandle_t hTaskLogDriver;
+ xTaskCreate(executableDispatch, "LogDriver", 256, LogDriver::getInstance(), 5, &hTaskLogDriver);
+
+ // Init queues
+
+ // Init shared resources
+
+ //Init components
+
+ //Init tasks
+ vTaskDelete(nullptr);
+}
diff --git a/Firmware/Application/start.h b/Firmware/Application/start.h
new file mode 100644
index 0000000..861b64b
--- /dev/null
+++ b/Firmware/Application/start.h
@@ -0,0 +1,21 @@
+/*
+ * start.h
+ *
+ * Created on: Oct 31, 2024
+ * Author: Gabriel
+ */
+
+#ifndef START_H_
+#define START_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void start();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* START_H_ */
diff --git a/Firmware/BrushedPIDDriver Debug.launch b/Firmware/BrushedPIDDriver Debug.launch
index eda147e..ce9f7f9 100644
--- a/Firmware/BrushedPIDDriver Debug.launch
+++ b/Firmware/BrushedPIDDriver Debug.launch
@@ -26,8 +26,9 @@
+
-
+
@@ -47,6 +48,15 @@
+
+
+
+
+
+
+
+
+
@@ -76,7 +86,7 @@
-
+
diff --git a/Firmware/BrushedPIDDriver.ioc b/Firmware/BrushedPIDDriver.ioc
index 6b466dc..7c59e6b 100644
--- a/Firmware/BrushedPIDDriver.ioc
+++ b/Firmware/BrushedPIDDriver.ioc
@@ -69,6 +69,7 @@ Mcu.IP13=TIM1
Mcu.IP14=TIM2
Mcu.IP15=UART4
Mcu.IP16=USB
+Mcu.IP17=USB_DEVICE
Mcu.IP2=ADC5
Mcu.IP3=COMP5
Mcu.IP4=COMP6
@@ -77,7 +78,7 @@ Mcu.IP6=FDCAN1
Mcu.IP7=FREERTOS
Mcu.IP8=NVIC
Mcu.IP9=OPAMP3
-Mcu.IPNb=17
+Mcu.IPNb=18
Mcu.Name=STM32G474R(B-C-E)Tx
Mcu.Package=LQFP64
Mcu.Pin0=PC13
@@ -106,13 +107,14 @@ Mcu.Pin29=VP_SYS_VS_Systick
Mcu.Pin3=PA0
Mcu.Pin30=VP_SYS_VS_DBSignals
Mcu.Pin31=VP_TIM1_VS_no_output5
+Mcu.Pin32=VP_USB_DEVICE_VS_USB_DEVICE_CUSTOM_HID_FS
Mcu.Pin4=PA1
Mcu.Pin5=PB0
Mcu.Pin6=PB2
Mcu.Pin7=PB10
Mcu.Pin8=PB11
Mcu.Pin9=PB13
-Mcu.PinsNb=32
+Mcu.PinsNb=33
Mcu.ThirdPartyNb=0
Mcu.UserConstants=
Mcu.UserName=STM32G474RBTx
@@ -133,6 +135,7 @@ NVIC.SavedSvcallIrqHandlerGenerated=true
NVIC.SavedSystickIrqHandlerGenerated=true
NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:true\:false\:true\:false
NVIC.TIM1_BRK_TIM15_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
+NVIC.USB_LP_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true\:true
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
PA0.Locked=true
PA0.Signal=S_TIM2_CH1
@@ -212,7 +215,7 @@ ProjectManager.ProjectBuild=false
ProjectManager.ProjectFileName=BrushedPIDDriver.ioc
ProjectManager.ProjectName=BrushedPIDDriver
ProjectManager.ProjectStructure=
-ProjectManager.RegisterCallBack=ADC,COMP,CORDIC,CRYP,DAC,EXTI,FDCAN,FMAC,HRTIM,I2C,I2S,IRDA,LPTIM,NAND,NOR,OPAMP,PCD,QSPI,RNG,RTC,SAI,SMARTCARD,SMBUS,SPI,SRAM,TIM,UART,USART,WWDG
+ProjectManager.RegisterCallBack=ADC,COMP,CORDIC,CRYP,DAC,EXTI,FDCAN,FMAC,HRTIM,I2C,I2S,IRDA,LPTIM,NAND,NOR,OPAMP,QSPI,RNG,RTC,SAI,SMARTCARD,SMBUS,SPI,SRAM,TIM,UART,USART,WWDG
ProjectManager.StackSize=0x400
ProjectManager.TargetToolchain=STM32CubeIDE
ProjectManager.ThreadSafeStrategy=Cortex-M4NS\:FreeRtosStrategy4,
@@ -220,7 +223,7 @@ ProjectManager.ToolChainLocation=
ProjectManager.UAScriptAfterPath=
ProjectManager.UAScriptBeforePath=
ProjectManager.UnderRoot=true
-ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_FDCAN1_Init-FDCAN1-false-HAL-true,4-MX_UART4_Init-UART4-false-HAL-true,5-MX_TIM1_Init-TIM1-false-HAL-true,6-MX_TIM2_Init-TIM2-false-HAL-true,7-MX_USB_PCD_Init-USB-false-HAL-true,8-MX_COMP5_Init-COMP5-false-HAL-true,9-MX_COMP6_Init-COMP6-false-HAL-true,10-MX_DAC4_Init-DAC4-false-HAL-true,11-MX_OPAMP3_Init-OPAMP3-false-HAL-true,12-MX_OPAMP4_Init-OPAMP4-false-HAL-true,13-MX_ADC1_Init-ADC1-false-HAL-true,14-MX_ADC3_Init-ADC3-false-HAL-true,15-MX_ADC5_Init-ADC5-false-HAL-true
+ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_FDCAN1_Init-FDCAN1-false-HAL-true,4-MX_UART4_Init-UART4-false-HAL-true,5-MX_TIM1_Init-TIM1-false-HAL-true,6-MX_TIM2_Init-TIM2-false-HAL-true,7-MX_COMP5_Init-COMP5-false-HAL-true,8-MX_COMP6_Init-COMP6-false-HAL-true,9-MX_DAC4_Init-DAC4-false-HAL-true,10-MX_OPAMP3_Init-OPAMP3-false-HAL-true,11-MX_OPAMP4_Init-OPAMP4-false-HAL-true,12-MX_ADC1_Init-ADC1-false-HAL-true,13-MX_ADC3_Init-ADC3-false-HAL-true,14-MX_ADC5_Init-ADC5-false-HAL-true,15-MX_USB_Device_Init-USB_DEVICE-false-HAL-false
RCC.ADC12Freq_Value=48000000
RCC.ADC345Freq_Value=48000000
RCC.AHBFreq_Value=48000000
@@ -293,6 +296,12 @@ TIM1.IPParameters=Channel-PWM Generation1 CH1 CH1N,Channel-PWM Generation2 CH2 C
TIM1.Prescaler=0
TIM1.SourceBRKCOMP5=TIM_BREAKINPUTSOURCE_ENABLE
TIM1.SourceBRKCOMP6=TIM_BREAKINPUTSOURCE_ENABLE
+USB_DEVICE.CLASS_NAME_FS=CUSTOM_HID
+USB_DEVICE.IPParameters=VirtualMode,VirtualModeFS,CLASS_NAME_FS,USBD_CUSTOM_HID_REPORT_DESC_SIZE,USBD_CUSTOMHID_OUTREPORT_BUF_SIZE
+USB_DEVICE.USBD_CUSTOMHID_OUTREPORT_BUF_SIZE=64
+USB_DEVICE.USBD_CUSTOM_HID_REPORT_DESC_SIZE=38
+USB_DEVICE.VirtualMode=CustomHid
+USB_DEVICE.VirtualModeFS=Custom_Hid_FS
VP_ADC1_TempSens_Input.Mode=IN-TempSens
VP_ADC1_TempSens_Input.Signal=ADC1_TempSens_Input
VP_ADC1_Vbat_Input.Mode=IN-Vbat
@@ -319,5 +328,7 @@ VP_SYS_VS_Systick.Mode=SysTick
VP_SYS_VS_Systick.Signal=SYS_VS_Systick
VP_TIM1_VS_no_output5.Mode=PWM Generation5 No Output
VP_TIM1_VS_no_output5.Signal=TIM1_VS_no_output5
+VP_USB_DEVICE_VS_USB_DEVICE_CUSTOM_HID_FS.Mode=CUSTOM_HID_FS
+VP_USB_DEVICE_VS_USB_DEVICE_CUSTOM_HID_FS.Signal=USB_DEVICE_VS_USB_DEVICE_CUSTOM_HID_FS
board=custom
rtos.0.ip=FREERTOS
diff --git a/Firmware/Core/Inc/stm32g4xx_hal_conf.h b/Firmware/Core/Inc/stm32g4xx_hal_conf.h
index 4aa6460..c52c9aa 100644
--- a/Firmware/Core/Inc/stm32g4xx_hal_conf.h
+++ b/Firmware/Core/Inc/stm32g4xx_hal_conf.h
@@ -94,7 +94,7 @@
#define USE_HAL_NAND_REGISTER_CALLBACKS 1U
#define USE_HAL_NOR_REGISTER_CALLBACKS 1U
#define USE_HAL_OPAMP_REGISTER_CALLBACKS 1U
-#define USE_HAL_PCD_REGISTER_CALLBACKS 1U
+#define USE_HAL_PCD_REGISTER_CALLBACKS 0U
#define USE_HAL_QSPI_REGISTER_CALLBACKS 1U
#define USE_HAL_RNG_REGISTER_CALLBACKS 1U
#define USE_HAL_RTC_REGISTER_CALLBACKS 1U
diff --git a/Firmware/Core/Inc/stm32g4xx_it.h b/Firmware/Core/Inc/stm32g4xx_it.h
index 55a5155..59fba6e 100644
--- a/Firmware/Core/Inc/stm32g4xx_it.h
+++ b/Firmware/Core/Inc/stm32g4xx_it.h
@@ -53,6 +53,7 @@ void BusFault_Handler(void);
void UsageFault_Handler(void);
void DebugMon_Handler(void);
void SysTick_Handler(void);
+void USB_LP_IRQHandler(void);
void TIM1_BRK_TIM15_IRQHandler(void);
void COMP4_5_6_IRQHandler(void);
/* USER CODE BEGIN EFP */
diff --git a/Firmware/Core/Inc/usb.h b/Firmware/Core/Inc/usb.h
deleted file mode 100644
index 5993b4e..0000000
--- a/Firmware/Core/Inc/usb.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* USER CODE BEGIN Header */
-/**
- ******************************************************************************
- * @file usb.h
- * @brief This file contains all the function prototypes for
- * the usb.c file
- ******************************************************************************
- * @attention
- *
- * Copyright (c) 2025 STMicroelectronics.
- * All rights reserved.
- *
- * This software is licensed under terms that can be found in the LICENSE file
- * in the root directory of this software component.
- * If no LICENSE file comes with this software, it is provided AS-IS.
- *
- ******************************************************************************
- */
-/* USER CODE END Header */
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef __USB_H__
-#define __USB_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Includes ------------------------------------------------------------------*/
-#include "main.h"
-
-/* USER CODE BEGIN Includes */
-
-/* USER CODE END Includes */
-
-extern PCD_HandleTypeDef hpcd_USB_FS;
-
-/* USER CODE BEGIN Private defines */
-
-/* USER CODE END Private defines */
-
-void MX_USB_PCD_Init(void);
-
-/* USER CODE BEGIN Prototypes */
-
-/* USER CODE END Prototypes */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __USB_H__ */
-
diff --git a/Firmware/Core/Src/app_freertos.c b/Firmware/Core/Src/app_freertos.c
index f499562..0ff903c 100644
--- a/Firmware/Core/Src/app_freertos.c
+++ b/Firmware/Core/Src/app_freertos.c
@@ -23,9 +23,11 @@
#include "main.h"
#include "cmsis_os.h"
+#include "usb_device.h"
+
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
-
+#include "../../Application/start.h"
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
@@ -113,7 +115,10 @@ void MX_FREERTOS_Init(void) {
/* USER CODE END Header_StartDefaultTask */
void StartDefaultTask(void *argument)
{
+ /* init code for USB_Device */
+ MX_USB_Device_Init();
/* USER CODE BEGIN StartDefaultTask */
+ start();
/* Infinite loop */
for(;;)
{
diff --git a/Firmware/Core/Src/main.c b/Firmware/Core/Src/main.c
index fcfafc9..2b58f8b 100644
--- a/Firmware/Core/Src/main.c
+++ b/Firmware/Core/Src/main.c
@@ -26,7 +26,7 @@
#include "opamp.h"
#include "tim.h"
#include "usart.h"
-#include "usb.h"
+#include "usb_device.h"
#include "gpio.h"
/* Private includes ----------------------------------------------------------*/
@@ -100,7 +100,6 @@ int main(void)
MX_UART4_Init();
MX_TIM1_Init();
MX_TIM2_Init();
- MX_USB_PCD_Init();
MX_COMP5_Init();
MX_COMP6_Init();
MX_DAC4_Init();
diff --git a/Firmware/Core/Src/stm32g4xx_it.c b/Firmware/Core/Src/stm32g4xx_it.c
index 5676147..ebbc58d 100644
--- a/Firmware/Core/Src/stm32g4xx_it.c
+++ b/Firmware/Core/Src/stm32g4xx_it.c
@@ -57,6 +57,7 @@
/* USER CODE END 0 */
/* External variables --------------------------------------------------------*/
+extern PCD_HandleTypeDef hpcd_USB_FS;
extern COMP_HandleTypeDef hcomp5;
extern COMP_HandleTypeDef hcomp6;
extern TIM_HandleTypeDef htim1;
@@ -184,6 +185,20 @@ void SysTick_Handler(void)
/* please refer to the startup file (startup_stm32g4xx.s). */
/******************************************************************************/
+/**
+ * @brief This function handles USB low priority interrupt remap.
+ */
+void USB_LP_IRQHandler(void)
+{
+ /* USER CODE BEGIN USB_LP_IRQn 0 */
+
+ /* USER CODE END USB_LP_IRQn 0 */
+ HAL_PCD_IRQHandler(&hpcd_USB_FS);
+ /* USER CODE BEGIN USB_LP_IRQn 1 */
+
+ /* USER CODE END USB_LP_IRQn 1 */
+}
+
/**
* @brief This function handles TIM1 break interrupt and TIM15 global interrupt.
*/
diff --git a/Firmware/Core/Src/syscalls.c b/Firmware/Core/Src/syscalls.c
index 8884b5a..8caf6e7 100644
--- a/Firmware/Core/Src/syscalls.c
+++ b/Firmware/Core/Src/syscalls.c
@@ -29,7 +29,7 @@
#include
#include
#include
-
+#include
/* Variables */
extern int __io_putchar(int ch) __attribute__((weak));
@@ -84,7 +84,7 @@ __attribute__((weak)) int _write(int file, char *ptr, int len)
for (DataIdx = 0; DataIdx < len; DataIdx++)
{
- __io_putchar(*ptr++);
+ ITM_SendChar(*ptr++);
}
return len;
}
@@ -174,3 +174,11 @@ int _execve(char *name, char **argv, char **env)
errno = ENOMEM;
return -1;
}
+
+int _gettimeofday( struct timeval *tv, void *tzvp )
+{
+ uint32_t t = HAL_GetTick();
+ tv->tv_sec = t/1000;
+ tv->tv_usec = (t%1000)*1000;
+ return 0;
+}
diff --git a/Firmware/Core/Src/usb.c b/Firmware/Core/Src/usb.c
deleted file mode 100644
index d166cfc..0000000
--- a/Firmware/Core/Src/usb.c
+++ /dev/null
@@ -1,104 +0,0 @@
-/* USER CODE BEGIN Header */
-/**
- ******************************************************************************
- * @file usb.c
- * @brief This file provides code for the configuration
- * of the USB instances.
- ******************************************************************************
- * @attention
- *
- * Copyright (c) 2025 STMicroelectronics.
- * All rights reserved.
- *
- * This software is licensed under terms that can be found in the LICENSE file
- * in the root directory of this software component.
- * If no LICENSE file comes with this software, it is provided AS-IS.
- *
- ******************************************************************************
- */
-/* USER CODE END Header */
-/* Includes ------------------------------------------------------------------*/
-#include "usb.h"
-
-/* USER CODE BEGIN 0 */
-
-/* USER CODE END 0 */
-
-PCD_HandleTypeDef hpcd_USB_FS;
-
-/* USB init function */
-
-void MX_USB_PCD_Init(void)
-{
-
- /* USER CODE BEGIN USB_Init 0 */
-
- /* USER CODE END USB_Init 0 */
-
- /* USER CODE BEGIN USB_Init 1 */
-
- /* USER CODE END USB_Init 1 */
- hpcd_USB_FS.Instance = USB;
- hpcd_USB_FS.Init.dev_endpoints = 8;
- hpcd_USB_FS.Init.speed = PCD_SPEED_FULL;
- hpcd_USB_FS.Init.phy_itface = PCD_PHY_EMBEDDED;
- hpcd_USB_FS.Init.Sof_enable = DISABLE;
- hpcd_USB_FS.Init.low_power_enable = DISABLE;
- hpcd_USB_FS.Init.lpm_enable = DISABLE;
- hpcd_USB_FS.Init.battery_charging_enable = DISABLE;
- if (HAL_PCD_Init(&hpcd_USB_FS) != HAL_OK)
- {
- Error_Handler();
- }
- /* USER CODE BEGIN USB_Init 2 */
-
- /* USER CODE END USB_Init 2 */
-
-}
-
-void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle)
-{
-
- RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
- if(pcdHandle->Instance==USB)
- {
- /* USER CODE BEGIN USB_MspInit 0 */
-
- /* USER CODE END USB_MspInit 0 */
-
- /** Initializes the peripherals clocks
- */
- PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB;
- PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_HSI48;
- if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
- {
- Error_Handler();
- }
-
- /* USB clock enable */
- __HAL_RCC_USB_CLK_ENABLE();
- /* USER CODE BEGIN USB_MspInit 1 */
-
- /* USER CODE END USB_MspInit 1 */
- }
-}
-
-void HAL_PCD_MspDeInit(PCD_HandleTypeDef* pcdHandle)
-{
-
- if(pcdHandle->Instance==USB)
- {
- /* USER CODE BEGIN USB_MspDeInit 0 */
-
- /* USER CODE END USB_MspDeInit 0 */
- /* Peripheral clock disable */
- __HAL_RCC_USB_CLK_DISABLE();
- /* USER CODE BEGIN USB_MspDeInit 1 */
-
- /* USER CODE END USB_MspDeInit 1 */
- }
-}
-
-/* USER CODE BEGIN 1 */
-
-/* USER CODE END 1 */
diff --git a/Firmware/Middlewares/ST/STM32_USB_Device_Library/Class/CustomHID/Inc/usbd_customhid.h b/Firmware/Middlewares/ST/STM32_USB_Device_Library/Class/CustomHID/Inc/usbd_customhid.h
new file mode 100644
index 0000000..d450e63
--- /dev/null
+++ b/Firmware/Middlewares/ST/STM32_USB_Device_Library/Class/CustomHID/Inc/usbd_customhid.h
@@ -0,0 +1,170 @@
+/**
+ ******************************************************************************
+ * @file usbd_customhid.h
+ * @author MCD Application Team
+ * @brief header file for the usbd_customhid.c file.
+ ******************************************************************************
+ * @attention
+ *
+ * © Copyright (c) 2015 STMicroelectronics.
+ * All rights reserved.
+ *
+ * This software component is licensed by ST under Ultimate Liberty license
+ * SLA0044, the "License"; You may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at:
+ * www.st.com/SLA0044
+ *
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __USB_CUSTOMHID_H
+#define __USB_CUSTOMHID_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "usbd_ioreq.h"
+
+/** @addtogroup STM32_USB_DEVICE_LIBRARY
+ * @{
+ */
+
+/** @defgroup USBD_CUSTOM_HID
+ * @brief This file is the Header file for USBD_customhid.c
+ * @{
+ */
+
+
+/** @defgroup USBD_CUSTOM_HID_Exported_Defines
+ * @{
+ */
+#define CUSTOM_HID_EPIN_ADDR 0x81U
+
+#ifndef CUSTOM_HID_EPIN_SIZE
+#define CUSTOM_HID_EPIN_SIZE 0x02U
+#endif
+
+#define CUSTOM_HID_EPOUT_ADDR 0x01U
+
+#ifndef CUSTOM_HID_EPOUT_SIZE
+#define CUSTOM_HID_EPOUT_SIZE 0x02U
+#endif
+
+#define USB_CUSTOM_HID_CONFIG_DESC_SIZ 41U
+#define USB_CUSTOM_HID_DESC_SIZ 9U
+
+#ifndef CUSTOM_HID_HS_BINTERVAL
+#define CUSTOM_HID_HS_BINTERVAL 0x05U
+#endif /* CUSTOM_HID_HS_BINTERVAL */
+
+#ifndef CUSTOM_HID_FS_BINTERVAL
+#define CUSTOM_HID_FS_BINTERVAL 0x05U
+#endif /* CUSTOM_HID_FS_BINTERVAL */
+
+#ifndef USBD_CUSTOMHID_OUTREPORT_BUF_SIZE
+#define USBD_CUSTOMHID_OUTREPORT_BUF_SIZE 0x02U
+#endif /* USBD_CUSTOMHID_OUTREPORT_BUF_SIZE */
+
+#ifndef USBD_CUSTOM_HID_REPORT_DESC_SIZE
+#define USBD_CUSTOM_HID_REPORT_DESC_SIZE 163U
+#endif /* USBD_CUSTOM_HID_REPORT_DESC_SIZE */
+
+#define CUSTOM_HID_DESCRIPTOR_TYPE 0x21U
+#define CUSTOM_HID_REPORT_DESC 0x22U
+
+#define CUSTOM_HID_REQ_SET_PROTOCOL 0x0BU
+#define CUSTOM_HID_REQ_GET_PROTOCOL 0x03U
+
+#define CUSTOM_HID_REQ_SET_IDLE 0x0AU
+#define CUSTOM_HID_REQ_GET_IDLE 0x02U
+
+#define CUSTOM_HID_REQ_SET_REPORT 0x09U
+#define CUSTOM_HID_REQ_GET_REPORT 0x01U
+/**
+ * @}
+ */
+
+
+/** @defgroup USBD_CORE_Exported_TypesDefinitions
+ * @{
+ */
+typedef enum
+{
+ CUSTOM_HID_IDLE = 0U,
+ CUSTOM_HID_BUSY,
+} CUSTOM_HID_StateTypeDef;
+
+typedef struct _USBD_CUSTOM_HID_Itf
+{
+ uint8_t *pReport;
+ int8_t (* Init)(void);
+ int8_t (* DeInit)(void);
+ int8_t (* OutEvent)(uint8_t event_idx, uint8_t state);
+
+} USBD_CUSTOM_HID_ItfTypeDef;
+
+typedef struct
+{
+ uint8_t Report_buf[USBD_CUSTOMHID_OUTREPORT_BUF_SIZE];
+ uint32_t Protocol;
+ uint32_t IdleState;
+ uint32_t AltSetting;
+ uint32_t IsReportAvailable;
+ CUSTOM_HID_StateTypeDef state;
+} USBD_CUSTOM_HID_HandleTypeDef;
+/**
+ * @}
+ */
+
+
+
+/** @defgroup USBD_CORE_Exported_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup USBD_CORE_Exported_Variables
+ * @{
+ */
+
+extern USBD_ClassTypeDef USBD_CUSTOM_HID;
+#define USBD_CUSTOM_HID_CLASS &USBD_CUSTOM_HID
+/**
+ * @}
+ */
+
+/** @defgroup USB_CORE_Exported_Functions
+ * @{
+ */
+uint8_t USBD_CUSTOM_HID_SendReport(USBD_HandleTypeDef *pdev,
+ uint8_t *report, uint16_t len);
+
+uint8_t USBD_CUSTOM_HID_ReceivePacket(USBD_HandleTypeDef *pdev);
+
+uint8_t USBD_CUSTOM_HID_RegisterInterface(USBD_HandleTypeDef *pdev,
+ USBD_CUSTOM_HID_ItfTypeDef *fops);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __USB_CUSTOMHID_H */
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/Firmware/Middlewares/ST/STM32_USB_Device_Library/Class/CustomHID/Src/usbd_customhid.c b/Firmware/Middlewares/ST/STM32_USB_Device_Library/Class/CustomHID/Src/usbd_customhid.c
new file mode 100644
index 0000000..af3eade
--- /dev/null
+++ b/Firmware/Middlewares/ST/STM32_USB_Device_Library/Class/CustomHID/Src/usbd_customhid.c
@@ -0,0 +1,781 @@
+/**
+ ******************************************************************************
+ * @file usbd_customhid.c
+ * @author MCD Application Team
+ * @brief This file provides the CUSTOM_HID core functions.
+ *
+ * @verbatim
+ *
+ * ===================================================================
+ * CUSTOM_HID Class Description
+ * ===================================================================
+ * This module manages the CUSTOM_HID class V1.11 following the "Device Class Definition
+ * for Human Interface Devices (CUSTOM_HID) Version 1.11 Jun 27, 2001".
+ * This driver implements the following aspects of the specification:
+ * - The Boot Interface Subclass
+ * - Usage Page : Generic Desktop
+ * - Usage : Vendor
+ * - Collection : Application
+ *
+ * @note In HS mode and when the DMA is used, all variables and data structures
+ * dealing with the DMA during the transaction process should be 32-bit aligned.
+ *
+ *
+ * @endverbatim
+ *
+ ******************************************************************************
+ * @attention
+ *
+ * © Copyright (c) 2015 STMicroelectronics.
+ * All rights reserved.
+ *
+ * This software component is licensed by ST under Ultimate Liberty license
+ * SLA0044, the "License"; You may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at:
+ * www.st.com/SLA0044
+ *
+ ******************************************************************************
+ */
+
+/* BSPDependencies
+- "stm32xxxxx_{eval}{discovery}{nucleo_144}.c"
+- "stm32xxxxx_{eval}{discovery}_io.c"
+EndBSPDependencies */
+
+/* Includes ------------------------------------------------------------------*/
+#include "usbd_customhid.h"
+#include "usbd_ctlreq.h"
+
+
+/** @addtogroup STM32_USB_DEVICE_LIBRARY
+ * @{
+ */
+
+
+/** @defgroup USBD_CUSTOM_HID
+ * @brief usbd core module
+ * @{
+ */
+
+/** @defgroup USBD_CUSTOM_HID_Private_TypesDefinitions
+ * @{
+ */
+/**
+ * @}
+ */
+
+
+/** @defgroup USBD_CUSTOM_HID_Private_Defines
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+
+/** @defgroup USBD_CUSTOM_HID_Private_Macros
+ * @{
+ */
+/**
+ * @}
+ */
+/** @defgroup USBD_CUSTOM_HID_Private_FunctionPrototypes
+ * @{
+ */
+
+static uint8_t USBD_CUSTOM_HID_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx);
+static uint8_t USBD_CUSTOM_HID_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx);
+static uint8_t USBD_CUSTOM_HID_Setup(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
+
+static uint8_t USBD_CUSTOM_HID_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum);
+static uint8_t USBD_CUSTOM_HID_DataOut(USBD_HandleTypeDef *pdev, uint8_t epnum);
+static uint8_t USBD_CUSTOM_HID_EP0_RxReady(USBD_HandleTypeDef *pdev);
+
+static uint8_t *USBD_CUSTOM_HID_GetFSCfgDesc(uint16_t *length);
+static uint8_t *USBD_CUSTOM_HID_GetHSCfgDesc(uint16_t *length);
+static uint8_t *USBD_CUSTOM_HID_GetOtherSpeedCfgDesc(uint16_t *length);
+static uint8_t *USBD_CUSTOM_HID_GetDeviceQualifierDesc(uint16_t *length);
+
+/**
+ * @}
+ */
+
+/** @defgroup USBD_CUSTOM_HID_Private_Variables
+ * @{
+ */
+
+USBD_ClassTypeDef USBD_CUSTOM_HID =
+{
+ USBD_CUSTOM_HID_Init,
+ USBD_CUSTOM_HID_DeInit,
+ USBD_CUSTOM_HID_Setup,
+ NULL, /*EP0_TxSent*/
+ USBD_CUSTOM_HID_EP0_RxReady, /*EP0_RxReady*/ /* STATUS STAGE IN */
+ USBD_CUSTOM_HID_DataIn, /*DataIn*/
+ USBD_CUSTOM_HID_DataOut,
+ NULL, /*SOF */
+ NULL,
+ NULL,
+ USBD_CUSTOM_HID_GetHSCfgDesc,
+ USBD_CUSTOM_HID_GetFSCfgDesc,
+ USBD_CUSTOM_HID_GetOtherSpeedCfgDesc,
+ USBD_CUSTOM_HID_GetDeviceQualifierDesc,
+};
+
+/* USB CUSTOM_HID device FS Configuration Descriptor */
+__ALIGN_BEGIN static uint8_t USBD_CUSTOM_HID_CfgFSDesc[USB_CUSTOM_HID_CONFIG_DESC_SIZ] __ALIGN_END =
+{
+ 0x09, /* bLength: Configuration Descriptor size */
+ USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
+ USB_CUSTOM_HID_CONFIG_DESC_SIZ, /* wTotalLength: Bytes returned */
+ 0x00,
+ 0x01, /* bNumInterfaces: 1 interface */
+ 0x01, /* bConfigurationValue: Configuration value */
+ 0x00, /* iConfiguration: Index of string descriptor describing the configuration */
+#if (USBD_SELF_POWERED == 1U)
+ 0xC0, /* bmAttributes: Bus Powered according to user configuration */
+#else
+ 0x80, /* bmAttributes: Bus Powered according to user configuration */
+#endif
+ USBD_MAX_POWER, /* MaxPower 100 mA: this current is used for detecting Vbus */
+
+ /************** Descriptor of CUSTOM HID interface ****************/
+ /* 09 */
+ 0x09, /* bLength: Interface Descriptor size*/
+ USB_DESC_TYPE_INTERFACE, /* bDescriptorType: Interface descriptor type */
+ 0x00, /* bInterfaceNumber: Number of Interface */
+ 0x00, /* bAlternateSetting: Alternate setting */
+ 0x02, /* bNumEndpoints*/
+ 0x03, /* bInterfaceClass: CUSTOM_HID */
+ 0x00, /* bInterfaceSubClass : 1=BOOT, 0=no boot */
+ 0x00, /* nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse */
+ 0x00, /* iInterface: Index of string descriptor */
+ /******************** Descriptor of CUSTOM_HID *************************/
+ /* 18 */
+ 0x09, /* bLength: CUSTOM_HID Descriptor size */
+ CUSTOM_HID_DESCRIPTOR_TYPE, /* bDescriptorType: CUSTOM_HID */
+ 0x11, /* bCUSTOM_HIDUSTOM_HID: CUSTOM_HID Class Spec release number */
+ 0x01,
+ 0x00, /* bCountryCode: Hardware target country */
+ 0x01, /* bNumDescriptors: Number of CUSTOM_HID class descriptors to follow */
+ 0x22, /* bDescriptorType */
+ USBD_CUSTOM_HID_REPORT_DESC_SIZE, /* wItemLength: Total length of Report descriptor */
+ 0x00,
+ /******************** Descriptor of Custom HID endpoints ********************/
+ /* 27 */
+ 0x07, /* bLength: Endpoint Descriptor size */
+ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: */
+
+ CUSTOM_HID_EPIN_ADDR, /* bEndpointAddress: Endpoint Address (IN) */
+ 0x03, /* bmAttributes: Interrupt endpoint */
+ CUSTOM_HID_EPIN_SIZE, /* wMaxPacketSize: 2 Byte max */
+ 0x00,
+ CUSTOM_HID_FS_BINTERVAL, /* bInterval: Polling Interval */
+ /* 34 */
+
+ 0x07, /* bLength: Endpoint Descriptor size */
+ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: */
+ CUSTOM_HID_EPOUT_ADDR, /* bEndpointAddress: Endpoint Address (OUT) */
+ 0x03, /* bmAttributes: Interrupt endpoint */
+ CUSTOM_HID_EPOUT_SIZE, /* wMaxPacketSize: 2 Bytes max */
+ 0x00,
+ CUSTOM_HID_FS_BINTERVAL, /* bInterval: Polling Interval */
+ /* 41 */
+};
+
+/* USB CUSTOM_HID device HS Configuration Descriptor */
+__ALIGN_BEGIN static uint8_t USBD_CUSTOM_HID_CfgHSDesc[USB_CUSTOM_HID_CONFIG_DESC_SIZ] __ALIGN_END =
+{
+ 0x09, /* bLength: Configuration Descriptor size */
+ USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
+ USB_CUSTOM_HID_CONFIG_DESC_SIZ, /* wTotalLength: Bytes returned */
+ 0x00,
+ 0x01, /* bNumInterfaces: 1 interface */
+ 0x01, /* bConfigurationValue: Configuration value */
+ 0x00, /* iConfiguration: Index of string descriptor describing the configuration */
+#if (USBD_SELF_POWERED == 1U)
+ 0xC0, /* bmAttributes: Bus Powered according to user configuration */
+#else
+ 0x80, /* bmAttributes: Bus Powered according to user configuration */
+#endif
+ USBD_MAX_POWER, /* MaxPower 100 mA: this current is used for detecting Vbus */
+
+ /************** Descriptor of CUSTOM HID interface ****************/
+ /* 09 */
+ 0x09, /* bLength: Interface Descriptor size */
+ USB_DESC_TYPE_INTERFACE, /* bDescriptorType: Interface descriptor type */
+ 0x00, /* bInterfaceNumber: Number of Interface */
+ 0x00, /* bAlternateSetting: Alternate setting */
+ 0x02, /* bNumEndpoints */
+ 0x03, /* bInterfaceClass: CUSTOM_HID */
+ 0x00, /* bInterfaceSubClass : 1=BOOT, 0=no boot */
+ 0x00, /* nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse */
+ 0, /* iInterface: Index of string descriptor */
+ /******************** Descriptor of CUSTOM_HID *************************/
+ /* 18 */
+ 0x09, /* bLength: CUSTOM_HID Descriptor size */
+ CUSTOM_HID_DESCRIPTOR_TYPE, /* bDescriptorType: CUSTOM_HID */
+ 0x11, /* bCUSTOM_HIDUSTOM_HID: CUSTOM_HID Class Spec release number */
+ 0x01,
+ 0x00, /* bCountryCode: Hardware target country */
+ 0x01, /* bNumDescriptors: Number of CUSTOM_HID class descriptors to follow */
+ 0x22, /* bDescriptorType */
+ USBD_CUSTOM_HID_REPORT_DESC_SIZE, /* wItemLength: Total length of Report descriptor */
+ 0x00,
+ /******************** Descriptor of Custom HID endpoints ********************/
+ /* 27 */
+ 0x07, /* bLength: Endpoint Descriptor size */
+ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: */
+
+ CUSTOM_HID_EPIN_ADDR, /* bEndpointAddress: Endpoint Address (IN) */
+ 0x03, /* bmAttributes: Interrupt endpoint */
+ CUSTOM_HID_EPIN_SIZE, /* wMaxPacketSize: 2 Byte max */
+ 0x00,
+ CUSTOM_HID_HS_BINTERVAL, /* bInterval: Polling Interval */
+ /* 34 */
+
+ 0x07, /* bLength: Endpoint Descriptor size */
+ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: */
+ CUSTOM_HID_EPOUT_ADDR, /* bEndpointAddress: Endpoint Address (OUT) */
+ 0x03, /* bmAttributes: Interrupt endpoint */
+ CUSTOM_HID_EPOUT_SIZE, /* wMaxPacketSize: 2 Bytes max */
+ 0x00,
+ CUSTOM_HID_HS_BINTERVAL, /* bInterval: Polling Interval */
+ /* 41 */
+};
+
+/* USB CUSTOM_HID device Other Speed Configuration Descriptor */
+__ALIGN_BEGIN static uint8_t USBD_CUSTOM_HID_OtherSpeedCfgDesc[USB_CUSTOM_HID_CONFIG_DESC_SIZ] __ALIGN_END =
+{
+ 0x09, /* bLength: Configuration Descriptor size */
+ USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
+ USB_CUSTOM_HID_CONFIG_DESC_SIZ, /* wTotalLength: Bytes returned */
+ 0x00,
+ 0x01, /* bNumInterfaces: 1 interface */
+ 0x01, /* bConfigurationValue: Configuration value */
+ 0x00, /* iConfiguration: Index of string descriptor describing the configuration */
+#if (USBD_SELF_POWERED == 1U)
+ 0xC0, /* bmAttributes: Bus Powered according to user configuration */
+#else
+ 0x80, /* bmAttributes: Bus Powered according to user configuration */
+#endif
+ USBD_MAX_POWER, /* MaxPower 100 mA: this current is used for detecting Vbus */
+
+ /************** Descriptor of CUSTOM HID interface ****************/
+ /* 09 */
+ 0x09, /* bLength: Interface Descriptor size */
+ USB_DESC_TYPE_INTERFACE, /* bDescriptorType: Interface descriptor type */
+ 0x00, /* bInterfaceNumber: Number of Interface */
+ 0x00, /* bAlternateSetting: Alternate setting */
+ 0x02, /* bNumEndpoints */
+ 0x03, /* bInterfaceClass: CUSTOM_HID */
+ 0x00, /* bInterfaceSubClass : 1=BOOT, 0=no boot */
+ 0x00, /* nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse */
+ 0, /* iInterface: Index of string descriptor */
+ /******************** Descriptor of CUSTOM_HID *************************/
+ /* 18 */
+ 0x09, /* bLength: CUSTOM_HID Descriptor size */
+ CUSTOM_HID_DESCRIPTOR_TYPE, /* bDescriptorType: CUSTOM_HID */
+ 0x11, /* bCUSTOM_HIDUSTOM_HID: CUSTOM_HID Class Spec release number */
+ 0x01,
+ 0x00, /* bCountryCode: Hardware target country */
+ 0x01, /* bNumDescriptors: Number of CUSTOM_HID class descriptors to follow */
+ 0x22, /* bDescriptorType */
+ USBD_CUSTOM_HID_REPORT_DESC_SIZE, /* wItemLength: Total length of Report descriptor */
+ 0x00,
+ /******************** Descriptor of Custom HID endpoints ********************/
+ /* 27 */
+ 0x07, /* bLength: Endpoint Descriptor size */
+ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: */
+
+ CUSTOM_HID_EPIN_ADDR, /* bEndpointAddress: Endpoint Address (IN) */
+ 0x03, /* bmAttributes: Interrupt endpoint */
+ CUSTOM_HID_EPIN_SIZE, /* wMaxPacketSize: 2 Bytes max */
+ 0x00,
+ CUSTOM_HID_FS_BINTERVAL, /* bInterval: Polling Interval */
+ /* 34 */
+
+ 0x07, /* bLength: Endpoint Descriptor size */
+ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: */
+ CUSTOM_HID_EPOUT_ADDR, /* bEndpointAddress: Endpoint Address (OUT) */
+ 0x03, /* bmAttributes: Interrupt endpoint */
+ CUSTOM_HID_EPOUT_SIZE, /* wMaxPacketSize: 2 Bytes max */
+ 0x00,
+ CUSTOM_HID_FS_BINTERVAL, /* bInterval: Polling Interval */
+ /* 41 */
+};
+
+/* USB CUSTOM_HID device Configuration Descriptor */
+__ALIGN_BEGIN static uint8_t USBD_CUSTOM_HID_Desc[USB_CUSTOM_HID_DESC_SIZ] __ALIGN_END =
+{
+ /* 18 */
+ 0x09, /* bLength: CUSTOM_HID Descriptor size */
+ CUSTOM_HID_DESCRIPTOR_TYPE, /* bDescriptorType: CUSTOM_HID */
+ 0x11, /* bCUSTOM_HIDUSTOM_HID: CUSTOM_HID Class Spec release number */
+ 0x01,
+ 0x00, /* bCountryCode: Hardware target country */
+ 0x01, /* bNumDescriptors: Number of CUSTOM_HID class descriptors to follow */
+ 0x22, /* bDescriptorType */
+ USBD_CUSTOM_HID_REPORT_DESC_SIZE, /* wItemLength: Total length of Report descriptor */
+ 0x00,
+};
+
+/* USB Standard Device Descriptor */
+__ALIGN_BEGIN static uint8_t USBD_CUSTOM_HID_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC] __ALIGN_END =
+{
+ USB_LEN_DEV_QUALIFIER_DESC,
+ USB_DESC_TYPE_DEVICE_QUALIFIER,
+ 0x00,
+ 0x02,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x40,
+ 0x01,
+ 0x00,
+};
+
+/**
+ * @}
+ */
+
+/** @defgroup USBD_CUSTOM_HID_Private_Functions
+ * @{
+ */
+
+/**
+ * @brief USBD_CUSTOM_HID_Init
+ * Initialize the CUSTOM_HID interface
+ * @param pdev: device instance
+ * @param cfgidx: Configuration index
+ * @retval status
+ */
+static uint8_t USBD_CUSTOM_HID_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
+{
+ UNUSED(cfgidx);
+ USBD_CUSTOM_HID_HandleTypeDef *hhid;
+
+ hhid = USBD_malloc(sizeof(USBD_CUSTOM_HID_HandleTypeDef));
+
+ if (hhid == NULL)
+ {
+ pdev->pClassData = NULL;
+ return (uint8_t)USBD_EMEM;
+ }
+
+ pdev->pClassData = (void *)hhid;
+
+ if (pdev->dev_speed == USBD_SPEED_HIGH)
+ {
+ pdev->ep_in[CUSTOM_HID_EPIN_ADDR & 0xFU].bInterval = CUSTOM_HID_HS_BINTERVAL;
+ pdev->ep_out[CUSTOM_HID_EPOUT_ADDR & 0xFU].bInterval = CUSTOM_HID_HS_BINTERVAL;
+ }
+ else /* LOW and FULL-speed endpoints */
+ {
+ pdev->ep_in[CUSTOM_HID_EPIN_ADDR & 0xFU].bInterval = CUSTOM_HID_FS_BINTERVAL;
+ pdev->ep_out[CUSTOM_HID_EPOUT_ADDR & 0xFU].bInterval = CUSTOM_HID_FS_BINTERVAL;
+ }
+
+ /* Open EP IN */
+ (void)USBD_LL_OpenEP(pdev, CUSTOM_HID_EPIN_ADDR, USBD_EP_TYPE_INTR,
+ CUSTOM_HID_EPIN_SIZE);
+
+ pdev->ep_in[CUSTOM_HID_EPIN_ADDR & 0xFU].is_used = 1U;
+
+ /* Open EP OUT */
+ (void)USBD_LL_OpenEP(pdev, CUSTOM_HID_EPOUT_ADDR, USBD_EP_TYPE_INTR,
+ CUSTOM_HID_EPOUT_SIZE);
+
+ pdev->ep_out[CUSTOM_HID_EPOUT_ADDR & 0xFU].is_used = 1U;
+
+ hhid->state = CUSTOM_HID_IDLE;
+
+ ((USBD_CUSTOM_HID_ItfTypeDef *)pdev->pUserData)->Init();
+
+ /* Prepare Out endpoint to receive 1st packet */
+ (void)USBD_LL_PrepareReceive(pdev, CUSTOM_HID_EPOUT_ADDR, hhid->Report_buf,
+ USBD_CUSTOMHID_OUTREPORT_BUF_SIZE);
+
+ return (uint8_t)USBD_OK;
+}
+
+/**
+ * @brief USBD_CUSTOM_HID_Init
+ * DeInitialize the CUSTOM_HID layer
+ * @param pdev: device instance
+ * @param cfgidx: Configuration index
+ * @retval status
+ */
+static uint8_t USBD_CUSTOM_HID_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
+{
+ UNUSED(cfgidx);
+
+ /* Close CUSTOM_HID EP IN */
+ (void)USBD_LL_CloseEP(pdev, CUSTOM_HID_EPIN_ADDR);
+ pdev->ep_in[CUSTOM_HID_EPIN_ADDR & 0xFU].is_used = 0U;
+ pdev->ep_in[CUSTOM_HID_EPIN_ADDR & 0xFU].bInterval = 0U;
+
+ /* Close CUSTOM_HID EP OUT */
+ (void)USBD_LL_CloseEP(pdev, CUSTOM_HID_EPOUT_ADDR);
+ pdev->ep_out[CUSTOM_HID_EPOUT_ADDR & 0xFU].is_used = 0U;
+ pdev->ep_out[CUSTOM_HID_EPOUT_ADDR & 0xFU].bInterval = 0U;
+
+ /* Free allocated memory */
+ if (pdev->pClassData != NULL)
+ {
+ ((USBD_CUSTOM_HID_ItfTypeDef *)pdev->pUserData)->DeInit();
+ USBD_free(pdev->pClassData);
+ pdev->pClassData = NULL;
+ }
+
+ return (uint8_t)USBD_OK;
+}
+
+/**
+ * @brief USBD_CUSTOM_HID_Setup
+ * Handle the CUSTOM_HID specific requests
+ * @param pdev: instance
+ * @param req: usb requests
+ * @retval status
+ */
+static uint8_t USBD_CUSTOM_HID_Setup(USBD_HandleTypeDef *pdev,
+ USBD_SetupReqTypedef *req)
+{
+ USBD_CUSTOM_HID_HandleTypeDef *hhid = (USBD_CUSTOM_HID_HandleTypeDef *)pdev->pClassData;
+ uint16_t len = 0U;
+ uint8_t *pbuf = NULL;
+ uint16_t status_info = 0U;
+ USBD_StatusTypeDef ret = USBD_OK;
+
+ if (hhid == NULL)
+ {
+ return (uint8_t)USBD_FAIL;
+ }
+
+ switch (req->bmRequest & USB_REQ_TYPE_MASK)
+ {
+ case USB_REQ_TYPE_CLASS:
+ switch (req->bRequest)
+ {
+ case CUSTOM_HID_REQ_SET_PROTOCOL:
+ hhid->Protocol = (uint8_t)(req->wValue);
+ break;
+
+ case CUSTOM_HID_REQ_GET_PROTOCOL:
+ (void)USBD_CtlSendData(pdev, (uint8_t *)&hhid->Protocol, 1U);
+ break;
+
+ case CUSTOM_HID_REQ_SET_IDLE:
+ hhid->IdleState = (uint8_t)(req->wValue >> 8);
+ break;
+
+ case CUSTOM_HID_REQ_GET_IDLE:
+ (void)USBD_CtlSendData(pdev, (uint8_t *)&hhid->IdleState, 1U);
+ break;
+
+ case CUSTOM_HID_REQ_SET_REPORT:
+ hhid->IsReportAvailable = 1U;
+ (void)USBD_CtlPrepareRx(pdev, hhid->Report_buf, req->wLength);
+ break;
+
+ default:
+ USBD_CtlError(pdev, req);
+ ret = USBD_FAIL;
+ break;
+ }
+ break;
+
+ case USB_REQ_TYPE_STANDARD:
+ switch (req->bRequest)
+ {
+ case USB_REQ_GET_STATUS:
+ if (pdev->dev_state == USBD_STATE_CONFIGURED)
+ {
+ (void)USBD_CtlSendData(pdev, (uint8_t *)&status_info, 2U);
+ }
+ else
+ {
+ USBD_CtlError(pdev, req);
+ ret = USBD_FAIL;
+ }
+ break;
+
+ case USB_REQ_GET_DESCRIPTOR:
+ if ((req->wValue >> 8) == CUSTOM_HID_REPORT_DESC)
+ {
+ len = MIN(USBD_CUSTOM_HID_REPORT_DESC_SIZE, req->wLength);
+ pbuf = ((USBD_CUSTOM_HID_ItfTypeDef *)pdev->pUserData)->pReport;
+ }
+ else
+ {
+ if ((req->wValue >> 8) == CUSTOM_HID_DESCRIPTOR_TYPE)
+ {
+ pbuf = USBD_CUSTOM_HID_Desc;
+ len = MIN(USB_CUSTOM_HID_DESC_SIZ, req->wLength);
+ }
+ }
+
+ (void)USBD_CtlSendData(pdev, pbuf, len);
+ break;
+
+ case USB_REQ_GET_INTERFACE:
+ if (pdev->dev_state == USBD_STATE_CONFIGURED)
+ {
+ (void)USBD_CtlSendData(pdev, (uint8_t *)&hhid->AltSetting, 1U);
+ }
+ else
+ {
+ USBD_CtlError(pdev, req);
+ ret = USBD_FAIL;
+ }
+ break;
+
+ case USB_REQ_SET_INTERFACE:
+ if (pdev->dev_state == USBD_STATE_CONFIGURED)
+ {
+ hhid->AltSetting = (uint8_t)(req->wValue);
+ }
+ else
+ {
+ USBD_CtlError(pdev, req);
+ ret = USBD_FAIL;
+ }
+ break;
+
+ case USB_REQ_CLEAR_FEATURE:
+ break;
+
+ default:
+ USBD_CtlError(pdev, req);
+ ret = USBD_FAIL;
+ break;
+ }
+ break;
+
+ default:
+ USBD_CtlError(pdev, req);
+ ret = USBD_FAIL;
+ break;
+ }
+ return (uint8_t)ret;
+}
+
+/**
+ * @brief USBD_CUSTOM_HID_SendReport
+ * Send CUSTOM_HID Report
+ * @param pdev: device instance
+ * @param buff: pointer to report
+ * @retval status
+ */
+uint8_t USBD_CUSTOM_HID_SendReport(USBD_HandleTypeDef *pdev,
+ uint8_t *report, uint16_t len)
+{
+ USBD_CUSTOM_HID_HandleTypeDef *hhid;
+
+ if (pdev->pClassData == NULL)
+ {
+ return (uint8_t)USBD_FAIL;
+ }
+
+ hhid = (USBD_CUSTOM_HID_HandleTypeDef *)pdev->pClassData;
+
+ if (pdev->dev_state == USBD_STATE_CONFIGURED)
+ {
+ if (hhid->state == CUSTOM_HID_IDLE)
+ {
+ hhid->state = CUSTOM_HID_BUSY;
+ (void)USBD_LL_Transmit(pdev, CUSTOM_HID_EPIN_ADDR, report, len);
+ }
+ else
+ {
+ return (uint8_t)USBD_BUSY;
+ }
+ }
+ return (uint8_t)USBD_OK;
+}
+
+/**
+ * @brief USBD_CUSTOM_HID_GetFSCfgDesc
+ * return FS configuration descriptor
+ * @param speed : current device speed
+ * @param length : pointer data length
+ * @retval pointer to descriptor buffer
+ */
+static uint8_t *USBD_CUSTOM_HID_GetFSCfgDesc(uint16_t *length)
+{
+ *length = (uint16_t)sizeof(USBD_CUSTOM_HID_CfgFSDesc);
+
+ return USBD_CUSTOM_HID_CfgFSDesc;
+}
+
+/**
+ * @brief USBD_CUSTOM_HID_GetHSCfgDesc
+ * return HS configuration descriptor
+ * @param speed : current device speed
+ * @param length : pointer data length
+ * @retval pointer to descriptor buffer
+ */
+static uint8_t *USBD_CUSTOM_HID_GetHSCfgDesc(uint16_t *length)
+{
+ *length = (uint16_t)sizeof(USBD_CUSTOM_HID_CfgHSDesc);
+
+ return USBD_CUSTOM_HID_CfgHSDesc;
+}
+
+/**
+ * @brief USBD_CUSTOM_HID_GetOtherSpeedCfgDesc
+ * return other speed configuration descriptor
+ * @param speed : current device speed
+ * @param length : pointer data length
+ * @retval pointer to descriptor buffer
+ */
+static uint8_t *USBD_CUSTOM_HID_GetOtherSpeedCfgDesc(uint16_t *length)
+{
+ *length = (uint16_t)sizeof(USBD_CUSTOM_HID_OtherSpeedCfgDesc);
+
+ return USBD_CUSTOM_HID_OtherSpeedCfgDesc;
+}
+
+/**
+ * @brief USBD_CUSTOM_HID_DataIn
+ * handle data IN Stage
+ * @param pdev: device instance
+ * @param epnum: endpoint index
+ * @retval status
+ */
+static uint8_t USBD_CUSTOM_HID_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum)
+{
+ UNUSED(epnum);
+
+ /* Ensure that the FIFO is empty before a new transfer, this condition could
+ be caused by a new transfer before the end of the previous transfer */
+ ((USBD_CUSTOM_HID_HandleTypeDef *)pdev->pClassData)->state = CUSTOM_HID_IDLE;
+
+ return (uint8_t)USBD_OK;
+}
+
+/**
+ * @brief USBD_CUSTOM_HID_DataOut
+ * handle data OUT Stage
+ * @param pdev: device instance
+ * @param epnum: endpoint index
+ * @retval status
+ */
+static uint8_t USBD_CUSTOM_HID_DataOut(USBD_HandleTypeDef *pdev, uint8_t epnum)
+{
+ UNUSED(epnum);
+ USBD_CUSTOM_HID_HandleTypeDef *hhid;
+
+ if (pdev->pClassData == NULL)
+ {
+ return (uint8_t)USBD_FAIL;
+ }
+
+ hhid = (USBD_CUSTOM_HID_HandleTypeDef *)pdev->pClassData;
+
+ /* USB data will be immediately processed, this allow next USB traffic being
+ NAKed till the end of the application processing */
+ ((USBD_CUSTOM_HID_ItfTypeDef *)pdev->pUserData)->OutEvent(hhid->Report_buf[0],
+ hhid->Report_buf[1]);
+
+ return (uint8_t)USBD_OK;
+}
+
+
+/**
+ * @brief USBD_CUSTOM_HID_ReceivePacket
+ * prepare OUT Endpoint for reception
+ * @param pdev: device instance
+ * @retval status
+ */
+uint8_t USBD_CUSTOM_HID_ReceivePacket(USBD_HandleTypeDef *pdev)
+{
+ USBD_CUSTOM_HID_HandleTypeDef *hhid;
+
+ if (pdev->pClassData == NULL)
+ {
+ return (uint8_t)USBD_FAIL;
+ }
+
+ hhid = (USBD_CUSTOM_HID_HandleTypeDef *)pdev->pClassData;
+
+ /* Resume USB Out process */
+ (void)USBD_LL_PrepareReceive(pdev, CUSTOM_HID_EPOUT_ADDR, hhid->Report_buf,
+ USBD_CUSTOMHID_OUTREPORT_BUF_SIZE);
+
+ return (uint8_t)USBD_OK;
+}
+
+
+/**
+ * @brief USBD_CUSTOM_HID_EP0_RxReady
+ * Handles control request data.
+ * @param pdev: device instance
+ * @retval status
+ */
+static uint8_t USBD_CUSTOM_HID_EP0_RxReady(USBD_HandleTypeDef *pdev)
+{
+ USBD_CUSTOM_HID_HandleTypeDef *hhid = (USBD_CUSTOM_HID_HandleTypeDef *)pdev->pClassData;
+
+ if (hhid == NULL)
+ {
+ return (uint8_t)USBD_FAIL;
+ }
+
+ if (hhid->IsReportAvailable == 1U)
+ {
+ ((USBD_CUSTOM_HID_ItfTypeDef *)pdev->pUserData)->OutEvent(hhid->Report_buf[0],
+ hhid->Report_buf[1]);
+ hhid->IsReportAvailable = 0U;
+ }
+
+ return (uint8_t)USBD_OK;
+}
+
+/**
+ * @brief DeviceQualifierDescriptor
+ * return Device Qualifier descriptor
+ * @param length : pointer data length
+ * @retval pointer to descriptor buffer
+ */
+static uint8_t *USBD_CUSTOM_HID_GetDeviceQualifierDesc(uint16_t *length)
+{
+ *length = (uint16_t)sizeof(USBD_CUSTOM_HID_DeviceQualifierDesc);
+
+ return USBD_CUSTOM_HID_DeviceQualifierDesc;
+}
+
+/**
+ * @brief USBD_CUSTOM_HID_RegisterInterface
+ * @param pdev: device instance
+ * @param fops: CUSTOMHID Interface callback
+ * @retval status
+ */
+uint8_t USBD_CUSTOM_HID_RegisterInterface(USBD_HandleTypeDef *pdev,
+ USBD_CUSTOM_HID_ItfTypeDef *fops)
+{
+ if (fops == NULL)
+ {
+ return (uint8_t)USBD_FAIL;
+ }
+
+ pdev->pUserData = fops;
+
+ return (uint8_t)USBD_OK;
+}
+/**
+ * @}
+ */
+
+
+/**
+ * @}
+ */
+
+
+/**
+ * @}
+ */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/Firmware/Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_core.h b/Firmware/Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_core.h
new file mode 100644
index 0000000..3f9dedb
--- /dev/null
+++ b/Firmware/Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_core.h
@@ -0,0 +1,158 @@
+/**
+ ******************************************************************************
+ * @file usbd_core.h
+ * @author MCD Application Team
+ * @brief Header file for usbd_core.c file
+ ******************************************************************************
+ * @attention
+ *
+ * © Copyright (c) 2015 STMicroelectronics.
+ * All rights reserved.
+ *
+ * This software component is licensed by ST under Ultimate Liberty license
+ * SLA0044, the "License"; You may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at:
+ * www.st.com/SLA0044
+ *
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __USBD_CORE_H
+#define __USBD_CORE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "usbd_conf.h"
+#include "usbd_def.h"
+#include "usbd_ioreq.h"
+#include "usbd_ctlreq.h"
+
+/** @addtogroup STM32_USB_DEVICE_LIBRARY
+ * @{
+ */
+
+/** @defgroup USBD_CORE
+ * @brief This file is the Header file for usbd_core.c file
+ * @{
+ */
+
+
+/** @defgroup USBD_CORE_Exported_Defines
+ * @{
+ */
+#ifndef USBD_DEBUG_LEVEL
+#define USBD_DEBUG_LEVEL 0U
+#endif /* USBD_DEBUG_LEVEL */
+/**
+ * @}
+ */
+
+
+/** @defgroup USBD_CORE_Exported_TypesDefinitions
+ * @{
+ */
+
+
+/**
+ * @}
+ */
+
+
+
+/** @defgroup USBD_CORE_Exported_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup USBD_CORE_Exported_Variables
+ * @{
+ */
+#define USBD_SOF USBD_LL_SOF
+/**
+ * @}
+ */
+
+/** @defgroup USBD_CORE_Exported_FunctionsPrototype
+ * @{
+ */
+USBD_StatusTypeDef USBD_Init(USBD_HandleTypeDef *pdev, USBD_DescriptorsTypeDef *pdesc, uint8_t id);
+USBD_StatusTypeDef USBD_DeInit(USBD_HandleTypeDef *pdev);
+USBD_StatusTypeDef USBD_Start(USBD_HandleTypeDef *pdev);
+USBD_StatusTypeDef USBD_Stop(USBD_HandleTypeDef *pdev);
+USBD_StatusTypeDef USBD_RegisterClass(USBD_HandleTypeDef *pdev, USBD_ClassTypeDef *pclass);
+
+USBD_StatusTypeDef USBD_RunTestMode(USBD_HandleTypeDef *pdev);
+USBD_StatusTypeDef USBD_SetClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx);
+USBD_StatusTypeDef USBD_ClrClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx);
+
+USBD_StatusTypeDef USBD_LL_SetupStage(USBD_HandleTypeDef *pdev, uint8_t *psetup);
+USBD_StatusTypeDef USBD_LL_DataOutStage(USBD_HandleTypeDef *pdev, uint8_t epnum, uint8_t *pdata);
+USBD_StatusTypeDef USBD_LL_DataInStage(USBD_HandleTypeDef *pdev, uint8_t epnum, uint8_t *pdata);
+
+USBD_StatusTypeDef USBD_LL_Reset(USBD_HandleTypeDef *pdev);
+USBD_StatusTypeDef USBD_LL_SetSpeed(USBD_HandleTypeDef *pdev, USBD_SpeedTypeDef speed);
+USBD_StatusTypeDef USBD_LL_Suspend(USBD_HandleTypeDef *pdev);
+USBD_StatusTypeDef USBD_LL_Resume(USBD_HandleTypeDef *pdev);
+
+USBD_StatusTypeDef USBD_LL_SOF(USBD_HandleTypeDef *pdev);
+USBD_StatusTypeDef USBD_LL_IsoINIncomplete(USBD_HandleTypeDef *pdev, uint8_t epnum);
+USBD_StatusTypeDef USBD_LL_IsoOUTIncomplete(USBD_HandleTypeDef *pdev, uint8_t epnum);
+
+USBD_StatusTypeDef USBD_LL_DevConnected(USBD_HandleTypeDef *pdev);
+USBD_StatusTypeDef USBD_LL_DevDisconnected(USBD_HandleTypeDef *pdev);
+
+/* USBD Low Level Driver */
+USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev);
+USBD_StatusTypeDef USBD_LL_DeInit(USBD_HandleTypeDef *pdev);
+USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef *pdev);
+USBD_StatusTypeDef USBD_LL_Stop(USBD_HandleTypeDef *pdev);
+
+USBD_StatusTypeDef USBD_LL_OpenEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr,
+ uint8_t ep_type, uint16_t ep_mps);
+
+USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr);
+USBD_StatusTypeDef USBD_LL_FlushEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr);
+USBD_StatusTypeDef USBD_LL_StallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr);
+USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr);
+USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev, uint8_t dev_addr);
+
+USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef *pdev, uint8_t ep_addr,
+ uint8_t *pbuf, uint32_t size);
+
+USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev, uint8_t ep_addr,
+ uint8_t *pbuf, uint32_t size);
+
+uint8_t USBD_LL_IsStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr);
+uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef *pdev, uint8_t ep_addr);
+
+void USBD_LL_Delay(uint32_t Delay);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __USBD_CORE_H */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
+
+
+
diff --git a/Firmware/Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_ctlreq.h b/Firmware/Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_ctlreq.h
new file mode 100644
index 0000000..4239126
--- /dev/null
+++ b/Firmware/Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_ctlreq.h
@@ -0,0 +1,103 @@
+/**
+ ******************************************************************************
+ * @file usbd_req.h
+ * @author MCD Application Team
+ * @brief Header file for the usbd_req.c file
+ ******************************************************************************
+ * @attention
+ *
+ * © Copyright (c) 2015 STMicroelectronics.
+ * All rights reserved.
+ *
+ * This software component is licensed by ST under Ultimate Liberty license
+ * SLA0044, the "License"; You may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at:
+ * www.st.com/SLA0044
+ *
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __USB_REQUEST_H
+#define __USB_REQUEST_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "usbd_def.h"
+
+
+/** @addtogroup STM32_USB_DEVICE_LIBRARY
+ * @{
+ */
+
+/** @defgroup USBD_REQ
+ * @brief header file for the usbd_req.c file
+ * @{
+ */
+
+/** @defgroup USBD_REQ_Exported_Defines
+ * @{
+ */
+/**
+ * @}
+ */
+
+
+/** @defgroup USBD_REQ_Exported_Types
+ * @{
+ */
+/**
+ * @}
+ */
+
+
+
+/** @defgroup USBD_REQ_Exported_Macros
+ * @{
+ */
+/**
+ * @}
+ */
+
+/** @defgroup USBD_REQ_Exported_Variables
+ * @{
+ */
+/**
+ * @}
+ */
+
+/** @defgroup USBD_REQ_Exported_FunctionsPrototype
+ * @{
+ */
+
+USBD_StatusTypeDef USBD_StdDevReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
+USBD_StatusTypeDef USBD_StdItfReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
+USBD_StatusTypeDef USBD_StdEPReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
+
+void USBD_CtlError(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
+void USBD_ParseSetupRequest(USBD_SetupReqTypedef *req, uint8_t *pdata);
+void USBD_GetString(uint8_t *desc, uint8_t *unicode, uint16_t *len);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __USB_REQUEST_H */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/Firmware/Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_def.h b/Firmware/Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_def.h
new file mode 100644
index 0000000..e88f995
--- /dev/null
+++ b/Firmware/Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_def.h
@@ -0,0 +1,420 @@
+/**
+ ******************************************************************************
+ * @file usbd_def.h
+ * @author MCD Application Team
+ * @brief General defines for the usb device library
+ ******************************************************************************
+ * @attention
+ *
+ * © Copyright (c) 2015 STMicroelectronics.
+ * All rights reserved.
+ *
+ * This software component is licensed by ST under Ultimate Liberty license
+ * SLA0044, the "License"; You may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at:
+ * www.st.com/SLA0044
+ *
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __USBD_DEF_H
+#define __USBD_DEF_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "usbd_conf.h"
+
+/** @addtogroup STM32_USBD_DEVICE_LIBRARY
+ * @{
+ */
+
+/** @defgroup USB_DEF
+ * @brief general defines for the usb device library file
+ * @{
+ */
+
+/** @defgroup USB_DEF_Exported_Defines
+ * @{
+ */
+
+#ifndef NULL
+#define NULL 0U
+#endif /* NULL */
+
+#ifndef USBD_MAX_NUM_INTERFACES
+#define USBD_MAX_NUM_INTERFACES 1U
+#endif /* USBD_MAX_NUM_CONFIGURATION */
+
+#ifndef USBD_MAX_NUM_CONFIGURATION
+#define USBD_MAX_NUM_CONFIGURATION 1U
+#endif /* USBD_MAX_NUM_CONFIGURATION */
+
+#ifndef USBD_LPM_ENABLED
+#define USBD_LPM_ENABLED 0U
+#endif /* USBD_LPM_ENABLED */
+
+#ifndef USBD_SELF_POWERED
+#define USBD_SELF_POWERED 1U
+#endif /*USBD_SELF_POWERED */
+
+#ifndef USBD_MAX_POWER
+#define USBD_MAX_POWER 0x32U /* 100 mA */
+#endif /* USBD_MAX_POWER */
+
+#ifndef USBD_SUPPORT_USER_STRING_DESC
+#define USBD_SUPPORT_USER_STRING_DESC 0U
+#endif /* USBD_SUPPORT_USER_STRING_DESC */
+
+#ifndef USBD_CLASS_USER_STRING_DESC
+#define USBD_CLASS_USER_STRING_DESC 0U
+#endif /* USBD_CLASS_USER_STRING_DESC */
+
+#define USB_LEN_DEV_QUALIFIER_DESC 0x0AU
+#define USB_LEN_DEV_DESC 0x12U
+#define USB_LEN_CFG_DESC 0x09U
+#define USB_LEN_IF_DESC 0x09U
+#define USB_LEN_EP_DESC 0x07U
+#define USB_LEN_OTG_DESC 0x03U
+#define USB_LEN_LANGID_STR_DESC 0x04U
+#define USB_LEN_OTHER_SPEED_DESC_SIZ 0x09U
+
+#define USBD_IDX_LANGID_STR 0x00U
+#define USBD_IDX_MFC_STR 0x01U
+#define USBD_IDX_PRODUCT_STR 0x02U
+#define USBD_IDX_SERIAL_STR 0x03U
+#define USBD_IDX_CONFIG_STR 0x04U
+#define USBD_IDX_INTERFACE_STR 0x05U
+
+#define USB_REQ_TYPE_STANDARD 0x00U
+#define USB_REQ_TYPE_CLASS 0x20U
+#define USB_REQ_TYPE_VENDOR 0x40U
+#define USB_REQ_TYPE_MASK 0x60U
+
+#define USB_REQ_RECIPIENT_DEVICE 0x00U
+#define USB_REQ_RECIPIENT_INTERFACE 0x01U
+#define USB_REQ_RECIPIENT_ENDPOINT 0x02U
+#define USB_REQ_RECIPIENT_MASK 0x03U
+
+#define USB_REQ_GET_STATUS 0x00U
+#define USB_REQ_CLEAR_FEATURE 0x01U
+#define USB_REQ_SET_FEATURE 0x03U
+#define USB_REQ_SET_ADDRESS 0x05U
+#define USB_REQ_GET_DESCRIPTOR 0x06U
+#define USB_REQ_SET_DESCRIPTOR 0x07U
+#define USB_REQ_GET_CONFIGURATION 0x08U
+#define USB_REQ_SET_CONFIGURATION 0x09U
+#define USB_REQ_GET_INTERFACE 0x0AU
+#define USB_REQ_SET_INTERFACE 0x0BU
+#define USB_REQ_SYNCH_FRAME 0x0CU
+
+#define USB_DESC_TYPE_DEVICE 0x01U
+#define USB_DESC_TYPE_CONFIGURATION 0x02U
+#define USB_DESC_TYPE_STRING 0x03U
+#define USB_DESC_TYPE_INTERFACE 0x04U
+#define USB_DESC_TYPE_ENDPOINT 0x05U
+#define USB_DESC_TYPE_DEVICE_QUALIFIER 0x06U
+#define USB_DESC_TYPE_OTHER_SPEED_CONFIGURATION 0x07U
+#define USB_DESC_TYPE_IAD 0x0BU
+#define USB_DESC_TYPE_BOS 0x0FU
+
+#define USB_CONFIG_REMOTE_WAKEUP 0x02U
+#define USB_CONFIG_SELF_POWERED 0x01U
+
+#define USB_FEATURE_EP_HALT 0x00U
+#define USB_FEATURE_REMOTE_WAKEUP 0x01U
+#define USB_FEATURE_TEST_MODE 0x02U
+
+#define USB_DEVICE_CAPABITY_TYPE 0x10U
+
+#define USB_CONF_DESC_SIZE 0x09U
+#define USB_IF_DESC_SIZE 0x09U
+#define USB_EP_DESC_SIZE 0x07U
+#define USB_IAD_DESC_SIZE 0x08U
+
+#define USB_HS_MAX_PACKET_SIZE 512U
+#define USB_FS_MAX_PACKET_SIZE 64U
+#define USB_MAX_EP0_SIZE 64U
+
+/* Device Status */
+#define USBD_STATE_DEFAULT 0x01U
+#define USBD_STATE_ADDRESSED 0x02U
+#define USBD_STATE_CONFIGURED 0x03U
+#define USBD_STATE_SUSPENDED 0x04U
+
+
+/* EP0 State */
+#define USBD_EP0_IDLE 0x00U
+#define USBD_EP0_SETUP 0x01U
+#define USBD_EP0_DATA_IN 0x02U
+#define USBD_EP0_DATA_OUT 0x03U
+#define USBD_EP0_STATUS_IN 0x04U
+#define USBD_EP0_STATUS_OUT 0x05U
+#define USBD_EP0_STALL 0x06U
+
+#define USBD_EP_TYPE_CTRL 0x00U
+#define USBD_EP_TYPE_ISOC 0x01U
+#define USBD_EP_TYPE_BULK 0x02U
+#define USBD_EP_TYPE_INTR 0x03U
+
+/**
+ * @}
+ */
+
+
+/** @defgroup USBD_DEF_Exported_TypesDefinitions
+ * @{
+ */
+
+typedef struct usb_setup_req
+{
+ uint8_t bmRequest;
+ uint8_t bRequest;
+ uint16_t wValue;
+ uint16_t wIndex;
+ uint16_t wLength;
+} USBD_SetupReqTypedef;
+
+typedef struct
+{
+ uint8_t bLength;
+ uint8_t bDescriptorType;
+ uint16_t wTotalLength;
+ uint8_t bNumInterfaces;
+ uint8_t bConfigurationValue;
+ uint8_t iConfiguration;
+ uint8_t bmAttributes;
+ uint8_t bMaxPower;
+} USBD_ConfigDescTypedef;
+
+typedef struct
+{
+ uint8_t bLength;
+ uint8_t bDescriptorType;
+ uint16_t wTotalLength;
+ uint8_t bNumDeviceCaps;
+} USBD_BosDescTypedef;
+
+typedef struct
+{
+ uint8_t bLength;
+ uint8_t bDescriptorType;
+ uint8_t bEndpointAddress;
+ uint8_t bmAttributes;
+ uint16_t wMaxPacketSize;
+ uint8_t bInterval;
+} USBD_EpDescTypedef;
+
+struct _USBD_HandleTypeDef;
+
+typedef struct _Device_cb
+{
+ uint8_t (*Init)(struct _USBD_HandleTypeDef *pdev, uint8_t cfgidx);
+ uint8_t (*DeInit)(struct _USBD_HandleTypeDef *pdev, uint8_t cfgidx);
+ /* Control Endpoints*/
+ uint8_t (*Setup)(struct _USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
+ uint8_t (*EP0_TxSent)(struct _USBD_HandleTypeDef *pdev);
+ uint8_t (*EP0_RxReady)(struct _USBD_HandleTypeDef *pdev);
+ /* Class Specific Endpoints*/
+ uint8_t (*DataIn)(struct _USBD_HandleTypeDef *pdev, uint8_t epnum);
+ uint8_t (*DataOut)(struct _USBD_HandleTypeDef *pdev, uint8_t epnum);
+ uint8_t (*SOF)(struct _USBD_HandleTypeDef *pdev);
+ uint8_t (*IsoINIncomplete)(struct _USBD_HandleTypeDef *pdev, uint8_t epnum);
+ uint8_t (*IsoOUTIncomplete)(struct _USBD_HandleTypeDef *pdev, uint8_t epnum);
+
+ uint8_t *(*GetHSConfigDescriptor)(uint16_t *length);
+ uint8_t *(*GetFSConfigDescriptor)(uint16_t *length);
+ uint8_t *(*GetOtherSpeedConfigDescriptor)(uint16_t *length);
+ uint8_t *(*GetDeviceQualifierDescriptor)(uint16_t *length);
+#if (USBD_SUPPORT_USER_STRING_DESC == 1U)
+ uint8_t *(*GetUsrStrDescriptor)(struct _USBD_HandleTypeDef *pdev, uint8_t index, uint16_t *length);
+#endif
+
+} USBD_ClassTypeDef;
+
+/* Following USB Device Speed */
+typedef enum
+{
+ USBD_SPEED_HIGH = 0U,
+ USBD_SPEED_FULL = 1U,
+ USBD_SPEED_LOW = 2U,
+} USBD_SpeedTypeDef;
+
+/* Following USB Device status */
+typedef enum
+{
+ USBD_OK = 0U,
+ USBD_BUSY,
+ USBD_EMEM,
+ USBD_FAIL,
+} USBD_StatusTypeDef;
+
+/* USB Device descriptors structure */
+typedef struct
+{
+ uint8_t *(*GetDeviceDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length);
+ uint8_t *(*GetLangIDStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length);
+ uint8_t *(*GetManufacturerStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length);
+ uint8_t *(*GetProductStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length);
+ uint8_t *(*GetSerialStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length);
+ uint8_t *(*GetConfigurationStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length);
+ uint8_t *(*GetInterfaceStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length);
+#if (USBD_CLASS_USER_STRING_DESC == 1)
+ uint8_t *(*GetUserStrDescriptor)(USBD_SpeedTypeDef speed, uint8_t idx, uint16_t *length);
+#endif
+#if ((USBD_LPM_ENABLED == 1U) || (USBD_CLASS_BOS_ENABLED == 1))
+ uint8_t *(*GetBOSDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length);
+#endif
+} USBD_DescriptorsTypeDef;
+
+/* USB Device handle structure */
+typedef struct
+{
+ uint32_t status;
+ uint32_t total_length;
+ uint32_t rem_length;
+ uint32_t maxpacket;
+ uint16_t is_used;
+ uint16_t bInterval;
+} USBD_EndpointTypeDef;
+
+/* USB Device handle structure */
+typedef struct _USBD_HandleTypeDef
+{
+ uint8_t id;
+ uint32_t dev_config;
+ uint32_t dev_default_config;
+ uint32_t dev_config_status;
+ USBD_SpeedTypeDef dev_speed;
+ USBD_EndpointTypeDef ep_in[16];
+ USBD_EndpointTypeDef ep_out[16];
+ __IO uint32_t ep0_state;
+ uint32_t ep0_data_len;
+ __IO uint8_t dev_state;
+ __IO uint8_t dev_old_state;
+ uint8_t dev_address;
+ uint8_t dev_connection_status;
+ uint8_t dev_test_mode;
+ uint32_t dev_remote_wakeup;
+ uint8_t ConfIdx;
+
+ USBD_SetupReqTypedef request;
+ USBD_DescriptorsTypeDef *pDesc;
+ USBD_ClassTypeDef *pClass;
+ void *pClassData;
+ void *pUserData;
+ void *pData;
+ void *pBosDesc;
+ void *pConfDesc;
+} USBD_HandleTypeDef;
+
+/**
+ * @}
+ */
+
+
+
+/** @defgroup USBD_DEF_Exported_Macros
+ * @{
+ */
+__STATIC_INLINE uint16_t SWAPBYTE(uint8_t *addr)
+{
+ uint16_t _SwapVal, _Byte1, _Byte2;
+ uint8_t *_pbuff = addr;
+
+ _Byte1 = *(uint8_t *)_pbuff;
+ _pbuff++;
+ _Byte2 = *(uint8_t *)_pbuff;
+
+ _SwapVal = (_Byte2 << 8) | _Byte1;
+
+ return _SwapVal;
+}
+
+#ifndef LOBYTE
+#define LOBYTE(x) ((uint8_t)((x) & 0x00FFU))
+#endif
+
+#ifndef HIBYTE
+#define HIBYTE(x) ((uint8_t)(((x) & 0xFF00U) >> 8U))
+#endif
+
+#ifndef MIN
+#define MIN(a, b) (((a) < (b)) ? (a) : (b))
+#endif
+
+#ifndef MAX
+#define MAX(a, b) (((a) > (b)) ? (a) : (b))
+#endif
+
+#if defined ( __GNUC__ )
+#ifndef __weak
+#define __weak __attribute__((weak))
+#endif /* __weak */
+#ifndef __packed
+#define __packed __attribute__((__packed__))
+#endif /* __packed */
+#endif /* __GNUC__ */
+
+
+/* In HS mode and when the DMA is used, all variables and data structures dealing
+ with the DMA during the transaction process should be 4-bytes aligned */
+
+#if defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */
+#ifndef __ALIGN_END
+#define __ALIGN_END __attribute__ ((aligned (4U)))
+#endif /* __ALIGN_END */
+#ifndef __ALIGN_BEGIN
+#define __ALIGN_BEGIN
+#endif /* __ALIGN_BEGIN */
+#else
+#ifndef __ALIGN_END
+#define __ALIGN_END
+#endif /* __ALIGN_END */
+#ifndef __ALIGN_BEGIN
+#if defined (__CC_ARM) /* ARM Compiler */
+#define __ALIGN_BEGIN __align(4U)
+#elif defined (__ICCARM__) /* IAR Compiler */
+#define __ALIGN_BEGIN
+#endif /* __CC_ARM */
+#endif /* __ALIGN_BEGIN */
+#endif /* __GNUC__ */
+
+
+/**
+ * @}
+ */
+
+/** @defgroup USBD_DEF_Exported_Variables
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup USBD_DEF_Exported_FunctionsPrototype
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __USBD_DEF_H */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/Firmware/Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_ioreq.h b/Firmware/Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_ioreq.h
new file mode 100644
index 0000000..3ba14b0
--- /dev/null
+++ b/Firmware/Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_ioreq.h
@@ -0,0 +1,114 @@
+/**
+ ******************************************************************************
+ * @file usbd_ioreq.h
+ * @author MCD Application Team
+ * @brief Header file for the usbd_ioreq.c file
+ ******************************************************************************
+ * @attention
+ *
+ * © Copyright (c) 2015 STMicroelectronics.
+ * All rights reserved.
+ *
+ * This software component is licensed by ST under Ultimate Liberty license
+ * SLA0044, the "License"; You may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at:
+ * www.st.com/SLA0044
+ *
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __USBD_IOREQ_H
+#define __USBD_IOREQ_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "usbd_def.h"
+#include "usbd_core.h"
+
+/** @addtogroup STM32_USB_DEVICE_LIBRARY
+ * @{
+ */
+
+/** @defgroup USBD_IOREQ
+ * @brief header file for the usbd_ioreq.c file
+ * @{
+ */
+
+/** @defgroup USBD_IOREQ_Exported_Defines
+ * @{
+ */
+/**
+ * @}
+ */
+
+
+/** @defgroup USBD_IOREQ_Exported_Types
+ * @{
+ */
+
+
+/**
+ * @}
+ */
+
+
+
+/** @defgroup USBD_IOREQ_Exported_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup USBD_IOREQ_Exported_Variables
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup USBD_IOREQ_Exported_FunctionsPrototype
+ * @{
+ */
+
+USBD_StatusTypeDef USBD_CtlSendData(USBD_HandleTypeDef *pdev,
+ uint8_t *pbuf, uint32_t len);
+
+USBD_StatusTypeDef USBD_CtlContinueSendData(USBD_HandleTypeDef *pdev,
+ uint8_t *pbuf, uint32_t len);
+
+USBD_StatusTypeDef USBD_CtlPrepareRx(USBD_HandleTypeDef *pdev,
+ uint8_t *pbuf, uint32_t len);
+
+USBD_StatusTypeDef USBD_CtlContinueRx(USBD_HandleTypeDef *pdev,
+ uint8_t *pbuf, uint32_t len);
+
+USBD_StatusTypeDef USBD_CtlSendStatus(USBD_HandleTypeDef *pdev);
+USBD_StatusTypeDef USBD_CtlReceiveStatus(USBD_HandleTypeDef *pdev);
+
+uint32_t USBD_GetRxCount(USBD_HandleTypeDef *pdev, uint8_t ep_addr);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __USBD_IOREQ_H */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/Firmware/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c b/Firmware/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c
new file mode 100644
index 0000000..e1e0de6
--- /dev/null
+++ b/Firmware/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c
@@ -0,0 +1,694 @@
+/**
+ ******************************************************************************
+ * @file usbd_core.c
+ * @author MCD Application Team
+ * @brief This file provides all the USBD core functions.
+ ******************************************************************************
+ * @attention
+ *
+ * © Copyright (c) 2015 STMicroelectronics.
+ * All rights reserved.
+ *
+ * This software component is licensed by ST under Ultimate Liberty license
+ * SLA0044, the "License"; You may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at:
+ * www.st.com/SLA0044
+ *
+ ******************************************************************************
+ */
+
+/* Includes ------------------------------------------------------------------*/
+#include "usbd_core.h"
+
+/** @addtogroup STM32_USBD_DEVICE_LIBRARY
+ * @{
+ */
+
+
+/** @defgroup USBD_CORE
+ * @brief usbd core module
+ * @{
+ */
+
+/** @defgroup USBD_CORE_Private_TypesDefinitions
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+
+/** @defgroup USBD_CORE_Private_Defines
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+
+/** @defgroup USBD_CORE_Private_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+
+/** @defgroup USBD_CORE_Private_FunctionPrototypes
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup USBD_CORE_Private_Variables
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+
+/** @defgroup USBD_CORE_Private_Functions
+ * @{
+ */
+
+/**
+ * @brief USBD_Init
+ * Initializes the device stack and load the class driver
+ * @param pdev: device instance
+ * @param pdesc: Descriptor structure address
+ * @param id: Low level core index
+ * @retval None
+ */
+USBD_StatusTypeDef USBD_Init(USBD_HandleTypeDef *pdev,
+ USBD_DescriptorsTypeDef *pdesc, uint8_t id)
+{
+ USBD_StatusTypeDef ret;
+
+ /* Check whether the USB Host handle is valid */
+ if (pdev == NULL)
+ {
+#if (USBD_DEBUG_LEVEL > 1U)
+ USBD_ErrLog("Invalid Device handle");
+#endif
+ return USBD_FAIL;
+ }
+
+ /* Unlink previous class resources */
+ pdev->pClass = NULL;
+ pdev->pUserData = NULL;
+ pdev->pConfDesc = NULL;
+
+ /* Assign USBD Descriptors */
+ if (pdesc != NULL)
+ {
+ pdev->pDesc = pdesc;
+ }
+
+ /* Set Device initial State */
+ pdev->dev_state = USBD_STATE_DEFAULT;
+ pdev->id = id;
+
+ /* Initialize low level driver */
+ ret = USBD_LL_Init(pdev);
+
+ return ret;
+}
+
+/**
+ * @brief USBD_DeInit
+ * Re-Initialize the device library
+ * @param pdev: device instance
+ * @retval status: status
+ */
+USBD_StatusTypeDef USBD_DeInit(USBD_HandleTypeDef *pdev)
+{
+ USBD_StatusTypeDef ret;
+
+ /* Disconnect the USB Device */
+ (void)USBD_LL_Stop(pdev);
+
+ /* Set Default State */
+ pdev->dev_state = USBD_STATE_DEFAULT;
+
+ /* Free Class Resources */
+ if (pdev->pClass != NULL)
+ {
+ pdev->pClass->DeInit(pdev, (uint8_t)pdev->dev_config);
+ pdev->pClass = NULL;
+ pdev->pUserData = NULL;
+ }
+
+ /* Free Device descriptors resources */
+ pdev->pDesc = NULL;
+ pdev->pConfDesc = NULL;
+
+ /* DeInitialize low level driver */
+ ret = USBD_LL_DeInit(pdev);
+
+ return ret;
+}
+
+/**
+ * @brief USBD_RegisterClass
+ * Link class driver to Device Core.
+ * @param pDevice : Device Handle
+ * @param pclass: Class handle
+ * @retval USBD Status
+ */
+USBD_StatusTypeDef USBD_RegisterClass(USBD_HandleTypeDef *pdev, USBD_ClassTypeDef *pclass)
+{
+ uint16_t len = 0U;
+
+ if (pclass == NULL)
+ {
+#if (USBD_DEBUG_LEVEL > 1U)
+ USBD_ErrLog("Invalid Class handle");
+#endif
+ return USBD_FAIL;
+ }
+
+ /* link the class to the USB Device handle */
+ pdev->pClass = pclass;
+
+ /* Get Device Configuration Descriptor */
+#ifdef USE_USB_HS
+ if (pdev->pClass->GetHSConfigDescriptor != NULL)
+ {
+ pdev->pConfDesc = (void *)pdev->pClass->GetHSConfigDescriptor(&len);
+ }
+#else /* Default USE_USB_FS */
+ if (pdev->pClass->GetFSConfigDescriptor != NULL)
+ {
+ pdev->pConfDesc = (void *)pdev->pClass->GetFSConfigDescriptor(&len);
+ }
+#endif /* USE_USB_FS */
+
+ return USBD_OK;
+}
+
+/**
+ * @brief USBD_Start
+ * Start the USB Device Core.
+ * @param pdev: Device Handle
+ * @retval USBD Status
+ */
+USBD_StatusTypeDef USBD_Start(USBD_HandleTypeDef *pdev)
+{
+ /* Start the low level driver */
+ return USBD_LL_Start(pdev);
+}
+
+/**
+ * @brief USBD_Stop
+ * Stop the USB Device Core.
+ * @param pdev: Device Handle
+ * @retval USBD Status
+ */
+USBD_StatusTypeDef USBD_Stop(USBD_HandleTypeDef *pdev)
+{
+ /* Disconnect USB Device */
+ (void)USBD_LL_Stop(pdev);
+
+ /* Free Class Resources */
+ if (pdev->pClass != NULL)
+ {
+ (void)pdev->pClass->DeInit(pdev, (uint8_t)pdev->dev_config);
+ }
+
+ return USBD_OK;
+}
+
+/**
+ * @brief USBD_RunTestMode
+ * Launch test mode process
+ * @param pdev: device instance
+ * @retval status
+ */
+USBD_StatusTypeDef USBD_RunTestMode(USBD_HandleTypeDef *pdev)
+{
+ /* Prevent unused argument compilation warning */
+ UNUSED(pdev);
+
+ return USBD_OK;
+}
+
+/**
+ * @brief USBD_SetClassConfig
+ * Configure device and start the interface
+ * @param pdev: device instance
+ * @param cfgidx: configuration index
+ * @retval status
+ */
+
+USBD_StatusTypeDef USBD_SetClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
+{
+ USBD_StatusTypeDef ret = USBD_FAIL;
+
+ if (pdev->pClass != NULL)
+ {
+ /* Set configuration and Start the Class */
+ ret = (USBD_StatusTypeDef)pdev->pClass->Init(pdev, cfgidx);
+ }
+
+ return ret;
+}
+
+/**
+ * @brief USBD_ClrClassConfig
+ * Clear current configuration
+ * @param pdev: device instance
+ * @param cfgidx: configuration index
+ * @retval status: USBD_StatusTypeDef
+ */
+USBD_StatusTypeDef USBD_ClrClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
+{
+ /* Clear configuration and De-initialize the Class process */
+ if (pdev->pClass != NULL)
+ {
+ pdev->pClass->DeInit(pdev, cfgidx);
+ }
+
+ return USBD_OK;
+}
+
+
+/**
+ * @brief USBD_LL_SetupStage
+ * Handle the setup stage
+ * @param pdev: device instance
+ * @retval status
+ */
+USBD_StatusTypeDef USBD_LL_SetupStage(USBD_HandleTypeDef *pdev, uint8_t *psetup)
+{
+ USBD_StatusTypeDef ret;
+
+ USBD_ParseSetupRequest(&pdev->request, psetup);
+
+ pdev->ep0_state = USBD_EP0_SETUP;
+
+ pdev->ep0_data_len = pdev->request.wLength;
+
+ switch (pdev->request.bmRequest & 0x1FU)
+ {
+ case USB_REQ_RECIPIENT_DEVICE:
+ ret = USBD_StdDevReq(pdev, &pdev->request);
+ break;
+
+ case USB_REQ_RECIPIENT_INTERFACE:
+ ret = USBD_StdItfReq(pdev, &pdev->request);
+ break;
+
+ case USB_REQ_RECIPIENT_ENDPOINT:
+ ret = USBD_StdEPReq(pdev, &pdev->request);
+ break;
+
+ default:
+ ret = USBD_LL_StallEP(pdev, (pdev->request.bmRequest & 0x80U));
+ break;
+ }
+
+ return ret;
+}
+
+/**
+ * @brief USBD_LL_DataOutStage
+ * Handle data OUT stage
+ * @param pdev: device instance
+ * @param epnum: endpoint index
+ * @param pdata: data pointer
+ * @retval status
+ */
+USBD_StatusTypeDef USBD_LL_DataOutStage(USBD_HandleTypeDef *pdev,
+ uint8_t epnum, uint8_t *pdata)
+{
+ USBD_EndpointTypeDef *pep;
+ USBD_StatusTypeDef ret;
+
+ if (epnum == 0U)
+ {
+ pep = &pdev->ep_out[0];
+
+ if (pdev->ep0_state == USBD_EP0_DATA_OUT)
+ {
+ if (pep->rem_length > pep->maxpacket)
+ {
+ pep->rem_length -= pep->maxpacket;
+
+ (void)USBD_CtlContinueRx(pdev, pdata, MIN(pep->rem_length, pep->maxpacket));
+ }
+ else
+ {
+ if (pdev->dev_state == USBD_STATE_CONFIGURED)
+ {
+ if (pdev->pClass->EP0_RxReady != NULL)
+ {
+ pdev->pClass->EP0_RxReady(pdev);
+ }
+ }
+
+ (void)USBD_CtlSendStatus(pdev);
+ }
+ }
+ else
+ {
+#if 0
+ if (pdev->ep0_state == USBD_EP0_STATUS_OUT)
+ {
+ /*
+ * STATUS PHASE completed, update ep0_state to idle
+ */
+ pdev->ep0_state = USBD_EP0_IDLE;
+ (void)USBD_LL_StallEP(pdev, 0U);
+ }
+#endif
+ }
+ }
+ else
+ {
+ if (pdev->dev_state == USBD_STATE_CONFIGURED)
+ {
+ if (pdev->pClass->DataOut != NULL)
+ {
+ ret = (USBD_StatusTypeDef)pdev->pClass->DataOut(pdev, epnum);
+
+ if (ret != USBD_OK)
+ {
+ return ret;
+ }
+ }
+ }
+ }
+
+ return USBD_OK;
+}
+
+/**
+ * @brief USBD_LL_DataInStage
+ * Handle data in stage
+ * @param pdev: device instance
+ * @param epnum: endpoint index
+ * @retval status
+ */
+USBD_StatusTypeDef USBD_LL_DataInStage(USBD_HandleTypeDef *pdev,
+ uint8_t epnum, uint8_t *pdata)
+{
+ USBD_EndpointTypeDef *pep;
+ USBD_StatusTypeDef ret;
+
+ if (epnum == 0U)
+ {
+ pep = &pdev->ep_in[0];
+
+ if (pdev->ep0_state == USBD_EP0_DATA_IN)
+ {
+ if (pep->rem_length > pep->maxpacket)
+ {
+ pep->rem_length -= pep->maxpacket;
+
+ (void)USBD_CtlContinueSendData(pdev, pdata, pep->rem_length);
+
+ /* Prepare endpoint for premature end of transfer */
+ (void)USBD_LL_PrepareReceive(pdev, 0U, NULL, 0U);
+ }
+ else
+ {
+ /* last packet is MPS multiple, so send ZLP packet */
+ if ((pep->maxpacket == pep->rem_length) &&
+ (pep->total_length >= pep->maxpacket) &&
+ (pep->total_length < pdev->ep0_data_len))
+ {
+ (void)USBD_CtlContinueSendData(pdev, NULL, 0U);
+ pdev->ep0_data_len = 0U;
+
+ /* Prepare endpoint for premature end of transfer */
+ (void)USBD_LL_PrepareReceive(pdev, 0U, NULL, 0U);
+ }
+ else
+ {
+ if (pdev->dev_state == USBD_STATE_CONFIGURED)
+ {
+ if (pdev->pClass->EP0_TxSent != NULL)
+ {
+ pdev->pClass->EP0_TxSent(pdev);
+ }
+ }
+ (void)USBD_LL_StallEP(pdev, 0x80U);
+ (void)USBD_CtlReceiveStatus(pdev);
+ }
+ }
+ }
+ else
+ {
+#if 0
+ if ((pdev->ep0_state == USBD_EP0_STATUS_IN) ||
+ (pdev->ep0_state == USBD_EP0_IDLE))
+ {
+ (void)USBD_LL_StallEP(pdev, 0x80U);
+ }
+#endif
+ }
+
+ if (pdev->dev_test_mode == 1U)
+ {
+ (void)USBD_RunTestMode(pdev);
+ pdev->dev_test_mode = 0U;
+ }
+ }
+ else
+ {
+ if (pdev->dev_state == USBD_STATE_CONFIGURED)
+ {
+ if (pdev->pClass->DataIn != NULL)
+ {
+ ret = (USBD_StatusTypeDef)pdev->pClass->DataIn(pdev, epnum);
+
+ if (ret != USBD_OK)
+ {
+ return ret;
+ }
+ }
+ }
+ }
+
+ return USBD_OK;
+}
+
+/**
+ * @brief USBD_LL_Reset
+ * Handle Reset event
+ * @param pdev: device instance
+ * @retval status
+ */
+
+USBD_StatusTypeDef USBD_LL_Reset(USBD_HandleTypeDef *pdev)
+{
+ /* Upon Reset call user call back */
+ pdev->dev_state = USBD_STATE_DEFAULT;
+ pdev->ep0_state = USBD_EP0_IDLE;
+ pdev->dev_config = 0U;
+ pdev->dev_remote_wakeup = 0U;
+
+ if (pdev->pClass == NULL)
+ {
+ return USBD_FAIL;
+ }
+
+ if (pdev->pClassData != NULL)
+ {
+ if (pdev->pClass->DeInit != NULL)
+ {
+ (void)pdev->pClass->DeInit(pdev, (uint8_t)pdev->dev_config);
+ }
+ }
+
+ /* Open EP0 OUT */
+ (void)USBD_LL_OpenEP(pdev, 0x00U, USBD_EP_TYPE_CTRL, USB_MAX_EP0_SIZE);
+ pdev->ep_out[0x00U & 0xFU].is_used = 1U;
+
+ pdev->ep_out[0].maxpacket = USB_MAX_EP0_SIZE;
+
+ /* Open EP0 IN */
+ (void)USBD_LL_OpenEP(pdev, 0x80U, USBD_EP_TYPE_CTRL, USB_MAX_EP0_SIZE);
+ pdev->ep_in[0x80U & 0xFU].is_used = 1U;
+
+ pdev->ep_in[0].maxpacket = USB_MAX_EP0_SIZE;
+
+ return USBD_OK;
+}
+
+/**
+ * @brief USBD_LL_SetSpeed
+ * Handle Reset event
+ * @param pdev: device instance
+ * @retval status
+ */
+USBD_StatusTypeDef USBD_LL_SetSpeed(USBD_HandleTypeDef *pdev,
+ USBD_SpeedTypeDef speed)
+{
+ pdev->dev_speed = speed;
+
+ return USBD_OK;
+}
+
+/**
+ * @brief USBD_LL_Suspend
+ * Handle Suspend event
+ * @param pdev: device instance
+ * @retval status
+ */
+
+USBD_StatusTypeDef USBD_LL_Suspend(USBD_HandleTypeDef *pdev)
+{
+ pdev->dev_old_state = pdev->dev_state;
+ pdev->dev_state = USBD_STATE_SUSPENDED;
+
+ return USBD_OK;
+}
+
+/**
+ * @brief USBD_LL_Resume
+ * Handle Resume event
+ * @param pdev: device instance
+ * @retval status
+ */
+
+USBD_StatusTypeDef USBD_LL_Resume(USBD_HandleTypeDef *pdev)
+{
+ if (pdev->dev_state == USBD_STATE_SUSPENDED)
+ {
+ pdev->dev_state = pdev->dev_old_state;
+ }
+
+ return USBD_OK;
+}
+
+/**
+ * @brief USBD_LL_SOF
+ * Handle SOF event
+ * @param pdev: device instance
+ * @retval status
+ */
+
+USBD_StatusTypeDef USBD_LL_SOF(USBD_HandleTypeDef *pdev)
+{
+ if (pdev->pClass == NULL)
+ {
+ return USBD_FAIL;
+ }
+
+ if (pdev->dev_state == USBD_STATE_CONFIGURED)
+ {
+ if (pdev->pClass->SOF != NULL)
+ {
+ (void)pdev->pClass->SOF(pdev);
+ }
+ }
+
+ return USBD_OK;
+}
+
+/**
+ * @brief USBD_LL_IsoINIncomplete
+ * Handle iso in incomplete event
+ * @param pdev: device instance
+ * @retval status
+ */
+USBD_StatusTypeDef USBD_LL_IsoINIncomplete(USBD_HandleTypeDef *pdev,
+ uint8_t epnum)
+{
+ if (pdev->pClass == NULL)
+ {
+ return USBD_FAIL;
+ }
+
+ if (pdev->dev_state == USBD_STATE_CONFIGURED)
+ {
+ if (pdev->pClass->IsoINIncomplete != NULL)
+ {
+ (void)pdev->pClass->IsoINIncomplete(pdev, epnum);
+ }
+ }
+
+ return USBD_OK;
+}
+
+/**
+ * @brief USBD_LL_IsoOUTIncomplete
+ * Handle iso out incomplete event
+ * @param pdev: device instance
+ * @retval status
+ */
+USBD_StatusTypeDef USBD_LL_IsoOUTIncomplete(USBD_HandleTypeDef *pdev,
+ uint8_t epnum)
+{
+ if (pdev->pClass == NULL)
+ {
+ return USBD_FAIL;
+ }
+
+ if (pdev->dev_state == USBD_STATE_CONFIGURED)
+ {
+ if (pdev->pClass->IsoOUTIncomplete != NULL)
+ {
+ (void)pdev->pClass->IsoOUTIncomplete(pdev, epnum);
+ }
+ }
+
+ return USBD_OK;
+}
+
+/**
+ * @brief USBD_LL_DevConnected
+ * Handle device connection event
+ * @param pdev: device instance
+ * @retval status
+ */
+USBD_StatusTypeDef USBD_LL_DevConnected(USBD_HandleTypeDef *pdev)
+{
+ /* Prevent unused argument compilation warning */
+ UNUSED(pdev);
+
+ return USBD_OK;
+}
+
+/**
+ * @brief USBD_LL_DevDisconnected
+ * Handle device disconnection event
+ * @param pdev: device instance
+ * @retval status
+ */
+USBD_StatusTypeDef USBD_LL_DevDisconnected(USBD_HandleTypeDef *pdev)
+{
+ /* Free Class Resources */
+ pdev->dev_state = USBD_STATE_DEFAULT;
+
+ if (pdev->pClass != NULL)
+ {
+ (void)pdev->pClass->DeInit(pdev, (uint8_t)pdev->dev_config);
+ }
+
+ return USBD_OK;
+}
+/**
+ * @}
+ */
+
+
+/**
+ * @}
+ */
+
+
+/**
+ * @}
+ */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
+
diff --git a/Firmware/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ctlreq.c b/Firmware/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ctlreq.c
new file mode 100644
index 0000000..8679de4
--- /dev/null
+++ b/Firmware/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ctlreq.c
@@ -0,0 +1,948 @@
+/**
+ ******************************************************************************
+ * @file usbd_req.c
+ * @author MCD Application Team
+ * @brief This file provides the standard USB requests following chapter 9.
+ ******************************************************************************
+ * @attention
+ *
+ * © Copyright (c) 2015 STMicroelectronics.
+ * All rights reserved.
+ *
+ * This software component is licensed by ST under Ultimate Liberty license
+ * SLA0044, the "License"; You may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at:
+ * www.st.com/SLA0044
+ *
+ ******************************************************************************
+ */
+
+/* Includes ------------------------------------------------------------------*/
+#include "usbd_ctlreq.h"
+#include "usbd_ioreq.h"
+
+
+/** @addtogroup STM32_USBD_STATE_DEVICE_LIBRARY
+ * @{
+ */
+
+
+/** @defgroup USBD_REQ
+ * @brief USB standard requests module
+ * @{
+ */
+
+/** @defgroup USBD_REQ_Private_TypesDefinitions
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+
+/** @defgroup USBD_REQ_Private_Defines
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+
+/** @defgroup USBD_REQ_Private_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+
+/** @defgroup USBD_REQ_Private_Variables
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+
+/** @defgroup USBD_REQ_Private_FunctionPrototypes
+ * @{
+ */
+static void USBD_GetDescriptor(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
+static void USBD_SetAddress(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
+static USBD_StatusTypeDef USBD_SetConfig(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
+static void USBD_GetConfig(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
+static void USBD_GetStatus(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
+static void USBD_SetFeature(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
+static void USBD_ClrFeature(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
+static uint8_t USBD_GetLen(uint8_t *buf);
+
+/**
+ * @}
+ */
+
+
+/** @defgroup USBD_REQ_Private_Functions
+ * @{
+ */
+
+
+/**
+ * @brief USBD_StdDevReq
+ * Handle standard usb device requests
+ * @param pdev: device instance
+ * @param req: usb request
+ * @retval status
+ */
+USBD_StatusTypeDef USBD_StdDevReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
+{
+ USBD_StatusTypeDef ret = USBD_OK;
+
+ switch (req->bmRequest & USB_REQ_TYPE_MASK)
+ {
+ case USB_REQ_TYPE_CLASS:
+ case USB_REQ_TYPE_VENDOR:
+ ret = (USBD_StatusTypeDef)pdev->pClass->Setup(pdev, req);
+ break;
+
+ case USB_REQ_TYPE_STANDARD:
+ switch (req->bRequest)
+ {
+ case USB_REQ_GET_DESCRIPTOR:
+ USBD_GetDescriptor(pdev, req);
+ break;
+
+ case USB_REQ_SET_ADDRESS:
+ USBD_SetAddress(pdev, req);
+ break;
+
+ case USB_REQ_SET_CONFIGURATION:
+ ret = USBD_SetConfig(pdev, req);
+ break;
+
+ case USB_REQ_GET_CONFIGURATION:
+ USBD_GetConfig(pdev, req);
+ break;
+
+ case USB_REQ_GET_STATUS:
+ USBD_GetStatus(pdev, req);
+ break;
+
+ case USB_REQ_SET_FEATURE:
+ USBD_SetFeature(pdev, req);
+ break;
+
+ case USB_REQ_CLEAR_FEATURE:
+ USBD_ClrFeature(pdev, req);
+ break;
+
+ default:
+ USBD_CtlError(pdev, req);
+ break;
+ }
+ break;
+
+ default:
+ USBD_CtlError(pdev, req);
+ break;
+ }
+
+ return ret;
+}
+
+/**
+ * @brief USBD_StdItfReq
+ * Handle standard usb interface requests
+ * @param pdev: device instance
+ * @param req: usb request
+ * @retval status
+ */
+USBD_StatusTypeDef USBD_StdItfReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
+{
+ USBD_StatusTypeDef ret = USBD_OK;
+
+ switch (req->bmRequest & USB_REQ_TYPE_MASK)
+ {
+ case USB_REQ_TYPE_CLASS:
+ case USB_REQ_TYPE_VENDOR:
+ case USB_REQ_TYPE_STANDARD:
+ switch (pdev->dev_state)
+ {
+ case USBD_STATE_DEFAULT:
+ case USBD_STATE_ADDRESSED:
+ case USBD_STATE_CONFIGURED:
+
+ if (LOBYTE(req->wIndex) <= USBD_MAX_NUM_INTERFACES)
+ {
+ ret = (USBD_StatusTypeDef)pdev->pClass->Setup(pdev, req);
+
+ if ((req->wLength == 0U) && (ret == USBD_OK))
+ {
+ (void)USBD_CtlSendStatus(pdev);
+ }
+ }
+ else
+ {
+ USBD_CtlError(pdev, req);
+ }
+ break;
+
+ default:
+ USBD_CtlError(pdev, req);
+ break;
+ }
+ break;
+
+ default:
+ USBD_CtlError(pdev, req);
+ break;
+ }
+
+ return ret;
+}
+
+/**
+ * @brief USBD_StdEPReq
+ * Handle standard usb endpoint requests
+ * @param pdev: device instance
+ * @param req: usb request
+ * @retval status
+ */
+USBD_StatusTypeDef USBD_StdEPReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
+{
+ USBD_EndpointTypeDef *pep;
+ uint8_t ep_addr;
+ USBD_StatusTypeDef ret = USBD_OK;
+ ep_addr = LOBYTE(req->wIndex);
+
+ switch (req->bmRequest & USB_REQ_TYPE_MASK)
+ {
+ case USB_REQ_TYPE_CLASS:
+ case USB_REQ_TYPE_VENDOR:
+ ret = (USBD_StatusTypeDef)pdev->pClass->Setup(pdev, req);
+ break;
+
+ case USB_REQ_TYPE_STANDARD:
+ switch (req->bRequest)
+ {
+ case USB_REQ_SET_FEATURE:
+ switch (pdev->dev_state)
+ {
+ case USBD_STATE_ADDRESSED:
+ if ((ep_addr != 0x00U) && (ep_addr != 0x80U))
+ {
+ (void)USBD_LL_StallEP(pdev, ep_addr);
+ (void)USBD_LL_StallEP(pdev, 0x80U);
+ }
+ else
+ {
+ USBD_CtlError(pdev, req);
+ }
+ break;
+
+ case USBD_STATE_CONFIGURED:
+ if (req->wValue == USB_FEATURE_EP_HALT)
+ {
+ if ((ep_addr != 0x00U) && (ep_addr != 0x80U) && (req->wLength == 0x00U))
+ {
+ (void)USBD_LL_StallEP(pdev, ep_addr);
+ }
+ }
+ (void)USBD_CtlSendStatus(pdev);
+
+ break;
+
+ default:
+ USBD_CtlError(pdev, req);
+ break;
+ }
+ break;
+
+ case USB_REQ_CLEAR_FEATURE:
+
+ switch (pdev->dev_state)
+ {
+ case USBD_STATE_ADDRESSED:
+ if ((ep_addr != 0x00U) && (ep_addr != 0x80U))
+ {
+ (void)USBD_LL_StallEP(pdev, ep_addr);
+ (void)USBD_LL_StallEP(pdev, 0x80U);
+ }
+ else
+ {
+ USBD_CtlError(pdev, req);
+ }
+ break;
+
+ case USBD_STATE_CONFIGURED:
+ if (req->wValue == USB_FEATURE_EP_HALT)
+ {
+ if ((ep_addr & 0x7FU) != 0x00U)
+ {
+ (void)USBD_LL_ClearStallEP(pdev, ep_addr);
+ }
+ (void)USBD_CtlSendStatus(pdev);
+ ret = (USBD_StatusTypeDef)pdev->pClass->Setup(pdev, req);
+ }
+ break;
+
+ default:
+ USBD_CtlError(pdev, req);
+ break;
+ }
+ break;
+
+ case USB_REQ_GET_STATUS:
+ switch (pdev->dev_state)
+ {
+ case USBD_STATE_ADDRESSED:
+ if ((ep_addr != 0x00U) && (ep_addr != 0x80U))
+ {
+ USBD_CtlError(pdev, req);
+ break;
+ }
+ pep = ((ep_addr & 0x80U) == 0x80U) ? &pdev->ep_in[ep_addr & 0x7FU] : \
+ &pdev->ep_out[ep_addr & 0x7FU];
+
+ pep->status = 0x0000U;
+
+ (void)USBD_CtlSendData(pdev, (uint8_t *)&pep->status, 2U);
+ break;
+
+ case USBD_STATE_CONFIGURED:
+ if ((ep_addr & 0x80U) == 0x80U)
+ {
+ if (pdev->ep_in[ep_addr & 0xFU].is_used == 0U)
+ {
+ USBD_CtlError(pdev, req);
+ break;
+ }
+ }
+ else
+ {
+ if (pdev->ep_out[ep_addr & 0xFU].is_used == 0U)
+ {
+ USBD_CtlError(pdev, req);
+ break;
+ }
+ }
+
+ pep = ((ep_addr & 0x80U) == 0x80U) ? &pdev->ep_in[ep_addr & 0x7FU] : \
+ &pdev->ep_out[ep_addr & 0x7FU];
+
+ if ((ep_addr == 0x00U) || (ep_addr == 0x80U))
+ {
+ pep->status = 0x0000U;
+ }
+ else if (USBD_LL_IsStallEP(pdev, ep_addr) != 0U)
+ {
+ pep->status = 0x0001U;
+ }
+ else
+ {
+ pep->status = 0x0000U;
+ }
+
+ (void)USBD_CtlSendData(pdev, (uint8_t *)&pep->status, 2U);
+ break;
+
+ default:
+ USBD_CtlError(pdev, req);
+ break;
+ }
+ break;
+
+ default:
+ USBD_CtlError(pdev, req);
+ break;
+ }
+ break;
+
+ default:
+ USBD_CtlError(pdev, req);
+ break;
+ }
+
+ return ret;
+}
+
+
+/**
+ * @brief USBD_GetDescriptor
+ * Handle Get Descriptor requests
+ * @param pdev: device instance
+ * @param req: usb request
+ * @retval status
+ */
+static void USBD_GetDescriptor(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
+{
+ uint16_t len = 0U;
+ uint8_t *pbuf = NULL;
+ uint8_t err = 0U;
+
+ switch (req->wValue >> 8)
+ {
+#if ((USBD_LPM_ENABLED == 1U) || (USBD_CLASS_BOS_ENABLED == 1U))
+ case USB_DESC_TYPE_BOS:
+ if (pdev->pDesc->GetBOSDescriptor != NULL)
+ {
+ pbuf = pdev->pDesc->GetBOSDescriptor(pdev->dev_speed, &len);
+ }
+ else
+ {
+ USBD_CtlError(pdev, req);
+ err++;
+ }
+ break;
+#endif
+ case USB_DESC_TYPE_DEVICE:
+ pbuf = pdev->pDesc->GetDeviceDescriptor(pdev->dev_speed, &len);
+ break;
+
+ case USB_DESC_TYPE_CONFIGURATION:
+ if (pdev->dev_speed == USBD_SPEED_HIGH)
+ {
+ pbuf = pdev->pClass->GetHSConfigDescriptor(&len);
+ pbuf[1] = USB_DESC_TYPE_CONFIGURATION;
+ }
+ else
+ {
+ pbuf = pdev->pClass->GetFSConfigDescriptor(&len);
+ pbuf[1] = USB_DESC_TYPE_CONFIGURATION;
+ }
+ break;
+
+ case USB_DESC_TYPE_STRING:
+ switch ((uint8_t)(req->wValue))
+ {
+ case USBD_IDX_LANGID_STR:
+ if (pdev->pDesc->GetLangIDStrDescriptor != NULL)
+ {
+ pbuf = pdev->pDesc->GetLangIDStrDescriptor(pdev->dev_speed, &len);
+ }
+ else
+ {
+ USBD_CtlError(pdev, req);
+ err++;
+ }
+ break;
+
+ case USBD_IDX_MFC_STR:
+ if (pdev->pDesc->GetManufacturerStrDescriptor != NULL)
+ {
+ pbuf = pdev->pDesc->GetManufacturerStrDescriptor(pdev->dev_speed, &len);
+ }
+ else
+ {
+ USBD_CtlError(pdev, req);
+ err++;
+ }
+ break;
+
+ case USBD_IDX_PRODUCT_STR:
+ if (pdev->pDesc->GetProductStrDescriptor != NULL)
+ {
+ pbuf = pdev->pDesc->GetProductStrDescriptor(pdev->dev_speed, &len);
+ }
+ else
+ {
+ USBD_CtlError(pdev, req);
+ err++;
+ }
+ break;
+
+ case USBD_IDX_SERIAL_STR:
+ if (pdev->pDesc->GetSerialStrDescriptor != NULL)
+ {
+ pbuf = pdev->pDesc->GetSerialStrDescriptor(pdev->dev_speed, &len);
+ }
+ else
+ {
+ USBD_CtlError(pdev, req);
+ err++;
+ }
+ break;
+
+ case USBD_IDX_CONFIG_STR:
+ if (pdev->pDesc->GetConfigurationStrDescriptor != NULL)
+ {
+ pbuf = pdev->pDesc->GetConfigurationStrDescriptor(pdev->dev_speed, &len);
+ }
+ else
+ {
+ USBD_CtlError(pdev, req);
+ err++;
+ }
+ break;
+
+ case USBD_IDX_INTERFACE_STR:
+ if (pdev->pDesc->GetInterfaceStrDescriptor != NULL)
+ {
+ pbuf = pdev->pDesc->GetInterfaceStrDescriptor(pdev->dev_speed, &len);
+ }
+ else
+ {
+ USBD_CtlError(pdev, req);
+ err++;
+ }
+ break;
+
+ default:
+#if (USBD_SUPPORT_USER_STRING_DESC == 1U)
+ if (pdev->pClass->GetUsrStrDescriptor != NULL)
+ {
+ pbuf = pdev->pClass->GetUsrStrDescriptor(pdev, (req->wValue), &len);
+ }
+ else
+ {
+ USBD_CtlError(pdev, req);
+ err++;
+ }
+#endif
+
+#if (USBD_CLASS_USER_STRING_DESC == 1U)
+ if (pdev->pDesc->GetUserStrDescriptor != NULL)
+ {
+ pbuf = pdev->pDesc->GetUserStrDescriptor(pdev->dev_speed, (req->wValue), &len);
+ }
+ else
+ {
+ USBD_CtlError(pdev, req);
+ err++;
+ }
+#endif
+
+#if ((USBD_CLASS_USER_STRING_DESC == 0U) && (USBD_SUPPORT_USER_STRING_DESC == 0U))
+ USBD_CtlError(pdev, req);
+ err++;
+#endif
+ break;
+ }
+ break;
+
+ case USB_DESC_TYPE_DEVICE_QUALIFIER:
+ if (pdev->dev_speed == USBD_SPEED_HIGH)
+ {
+ pbuf = pdev->pClass->GetDeviceQualifierDescriptor(&len);
+ }
+ else
+ {
+ USBD_CtlError(pdev, req);
+ err++;
+ }
+ break;
+
+ case USB_DESC_TYPE_OTHER_SPEED_CONFIGURATION:
+ if (pdev->dev_speed == USBD_SPEED_HIGH)
+ {
+ pbuf = pdev->pClass->GetOtherSpeedConfigDescriptor(&len);
+ pbuf[1] = USB_DESC_TYPE_OTHER_SPEED_CONFIGURATION;
+ }
+ else
+ {
+ USBD_CtlError(pdev, req);
+ err++;
+ }
+ break;
+
+ default:
+ USBD_CtlError(pdev, req);
+ err++;
+ break;
+ }
+
+ if (err != 0U)
+ {
+ return;
+ }
+
+ if (req->wLength != 0U)
+ {
+ if (len != 0U)
+ {
+ len = MIN(len, req->wLength);
+ (void)USBD_CtlSendData(pdev, pbuf, len);
+ }
+ else
+ {
+ USBD_CtlError(pdev, req);
+ }
+ }
+ else
+ {
+ (void)USBD_CtlSendStatus(pdev);
+ }
+}
+
+
+/**
+ * @brief USBD_SetAddress
+ * Set device address
+ * @param pdev: device instance
+ * @param req: usb request
+ * @retval status
+ */
+static void USBD_SetAddress(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
+{
+ uint8_t dev_addr;
+
+ if ((req->wIndex == 0U) && (req->wLength == 0U) && (req->wValue < 128U))
+ {
+ dev_addr = (uint8_t)(req->wValue) & 0x7FU;
+
+ if (pdev->dev_state == USBD_STATE_CONFIGURED)
+ {
+ USBD_CtlError(pdev, req);
+ }
+ else
+ {
+ pdev->dev_address = dev_addr;
+ (void)USBD_LL_SetUSBAddress(pdev, dev_addr);
+ (void)USBD_CtlSendStatus(pdev);
+
+ if (dev_addr != 0U)
+ {
+ pdev->dev_state = USBD_STATE_ADDRESSED;
+ }
+ else
+ {
+ pdev->dev_state = USBD_STATE_DEFAULT;
+ }
+ }
+ }
+ else
+ {
+ USBD_CtlError(pdev, req);
+ }
+}
+
+/**
+ * @brief USBD_SetConfig
+ * Handle Set device configuration request
+ * @param pdev: device instance
+ * @param req: usb request
+ * @retval status
+ */
+static USBD_StatusTypeDef USBD_SetConfig(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
+{
+ USBD_StatusTypeDef ret = USBD_OK;
+ static uint8_t cfgidx;
+
+ cfgidx = (uint8_t)(req->wValue);
+
+ if (cfgidx > USBD_MAX_NUM_CONFIGURATION)
+ {
+ USBD_CtlError(pdev, req);
+ return USBD_FAIL;
+ }
+
+ switch (pdev->dev_state)
+ {
+ case USBD_STATE_ADDRESSED:
+ if (cfgidx != 0U)
+ {
+ pdev->dev_config = cfgidx;
+
+ ret = USBD_SetClassConfig(pdev, cfgidx);
+
+ if (ret != USBD_OK)
+ {
+ USBD_CtlError(pdev, req);
+ }
+ else
+ {
+ (void)USBD_CtlSendStatus(pdev);
+ pdev->dev_state = USBD_STATE_CONFIGURED;
+ }
+ }
+ else
+ {
+ (void)USBD_CtlSendStatus(pdev);
+ }
+ break;
+
+ case USBD_STATE_CONFIGURED:
+ if (cfgidx == 0U)
+ {
+ pdev->dev_state = USBD_STATE_ADDRESSED;
+ pdev->dev_config = cfgidx;
+ (void)USBD_ClrClassConfig(pdev, cfgidx);
+ (void)USBD_CtlSendStatus(pdev);
+ }
+ else if (cfgidx != pdev->dev_config)
+ {
+ /* Clear old configuration */
+ (void)USBD_ClrClassConfig(pdev, (uint8_t)pdev->dev_config);
+
+ /* set new configuration */
+ pdev->dev_config = cfgidx;
+
+ ret = USBD_SetClassConfig(pdev, cfgidx);
+
+ if (ret != USBD_OK)
+ {
+ USBD_CtlError(pdev, req);
+ (void)USBD_ClrClassConfig(pdev, (uint8_t)pdev->dev_config);
+ pdev->dev_state = USBD_STATE_ADDRESSED;
+ }
+ else
+ {
+ (void)USBD_CtlSendStatus(pdev);
+ }
+ }
+ else
+ {
+ (void)USBD_CtlSendStatus(pdev);
+ }
+ break;
+
+ default:
+ USBD_CtlError(pdev, req);
+ (void)USBD_ClrClassConfig(pdev, cfgidx);
+ ret = USBD_FAIL;
+ break;
+ }
+
+ return ret;
+}
+
+/**
+ * @brief USBD_GetConfig
+ * Handle Get device configuration request
+ * @param pdev: device instance
+ * @param req: usb request
+ * @retval status
+ */
+static void USBD_GetConfig(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
+{
+ if (req->wLength != 1U)
+ {
+ USBD_CtlError(pdev, req);
+ }
+ else
+ {
+ switch (pdev->dev_state)
+ {
+ case USBD_STATE_DEFAULT:
+ case USBD_STATE_ADDRESSED:
+ pdev->dev_default_config = 0U;
+ (void)USBD_CtlSendData(pdev, (uint8_t *)&pdev->dev_default_config, 1U);
+ break;
+
+ case USBD_STATE_CONFIGURED:
+ (void)USBD_CtlSendData(pdev, (uint8_t *)&pdev->dev_config, 1U);
+ break;
+
+ default:
+ USBD_CtlError(pdev, req);
+ break;
+ }
+ }
+}
+
+/**
+ * @brief USBD_GetStatus
+ * Handle Get Status request
+ * @param pdev: device instance
+ * @param req: usb request
+ * @retval status
+ */
+static void USBD_GetStatus(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
+{
+ switch (pdev->dev_state)
+ {
+ case USBD_STATE_DEFAULT:
+ case USBD_STATE_ADDRESSED:
+ case USBD_STATE_CONFIGURED:
+ if (req->wLength != 0x2U)
+ {
+ USBD_CtlError(pdev, req);
+ break;
+ }
+
+#if (USBD_SELF_POWERED == 1U)
+ pdev->dev_config_status = USB_CONFIG_SELF_POWERED;
+#else
+ pdev->dev_config_status = 0U;
+#endif
+
+ if (pdev->dev_remote_wakeup != 0U)
+ {
+ pdev->dev_config_status |= USB_CONFIG_REMOTE_WAKEUP;
+ }
+
+ (void)USBD_CtlSendData(pdev, (uint8_t *)&pdev->dev_config_status, 2U);
+ break;
+
+ default:
+ USBD_CtlError(pdev, req);
+ break;
+ }
+}
+
+
+/**
+ * @brief USBD_SetFeature
+ * Handle Set device feature request
+ * @param pdev: device instance
+ * @param req: usb request
+ * @retval status
+ */
+static void USBD_SetFeature(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
+{
+ if (req->wValue == USB_FEATURE_REMOTE_WAKEUP)
+ {
+ pdev->dev_remote_wakeup = 1U;
+ (void)USBD_CtlSendStatus(pdev);
+ }
+}
+
+
+/**
+ * @brief USBD_ClrFeature
+ * Handle clear device feature request
+ * @param pdev: device instance
+ * @param req: usb request
+ * @retval status
+ */
+static void USBD_ClrFeature(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
+{
+ switch (pdev->dev_state)
+ {
+ case USBD_STATE_DEFAULT:
+ case USBD_STATE_ADDRESSED:
+ case USBD_STATE_CONFIGURED:
+ if (req->wValue == USB_FEATURE_REMOTE_WAKEUP)
+ {
+ pdev->dev_remote_wakeup = 0U;
+ (void)USBD_CtlSendStatus(pdev);
+ }
+ break;
+
+ default:
+ USBD_CtlError(pdev, req);
+ break;
+ }
+}
+
+
+/**
+ * @brief USBD_ParseSetupRequest
+ * Copy buffer into setup structure
+ * @param pdev: device instance
+ * @param req: usb request
+ * @retval None
+ */
+void USBD_ParseSetupRequest(USBD_SetupReqTypedef *req, uint8_t *pdata)
+{
+ uint8_t *pbuff = pdata;
+
+ req->bmRequest = *(uint8_t *)(pbuff);
+
+ pbuff++;
+ req->bRequest = *(uint8_t *)(pbuff);
+
+ pbuff++;
+ req->wValue = SWAPBYTE(pbuff);
+
+ pbuff++;
+ pbuff++;
+ req->wIndex = SWAPBYTE(pbuff);
+
+ pbuff++;
+ pbuff++;
+ req->wLength = SWAPBYTE(pbuff);
+}
+
+
+/**
+ * @brief USBD_CtlError
+ * Handle USB low level Error
+ * @param pdev: device instance
+ * @param req: usb request
+ * @retval None
+ */
+void USBD_CtlError(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
+{
+ UNUSED(req);
+
+ (void)USBD_LL_StallEP(pdev, 0x80U);
+ (void)USBD_LL_StallEP(pdev, 0U);
+}
+
+
+/**
+ * @brief USBD_GetString
+ * Convert Ascii string into unicode one
+ * @param desc : descriptor buffer
+ * @param unicode : Formatted string buffer (unicode)
+ * @param len : descriptor length
+ * @retval None
+ */
+void USBD_GetString(uint8_t *desc, uint8_t *unicode, uint16_t *len)
+{
+ uint8_t idx = 0U;
+ uint8_t *pdesc;
+
+ if (desc == NULL)
+ {
+ return;
+ }
+
+ pdesc = desc;
+ *len = ((uint16_t)USBD_GetLen(pdesc) * 2U) + 2U;
+
+ unicode[idx] = *(uint8_t *)len;
+ idx++;
+ unicode[idx] = USB_DESC_TYPE_STRING;
+ idx++;
+
+ while (*pdesc != (uint8_t)'\0')
+ {
+ unicode[idx] = *pdesc;
+ pdesc++;
+ idx++;
+
+ unicode[idx] = 0U;
+ idx++;
+ }
+}
+
+
+/**
+ * @brief USBD_GetLen
+ * return the string length
+ * @param buf : pointer to the ascii string buffer
+ * @retval string length
+ */
+static uint8_t USBD_GetLen(uint8_t *buf)
+{
+ uint8_t len = 0U;
+ uint8_t *pbuff = buf;
+
+ while (*pbuff != (uint8_t)'\0')
+ {
+ len++;
+ pbuff++;
+ }
+
+ return len;
+}
+/**
+ * @}
+ */
+
+
+/**
+ * @}
+ */
+
+
+/**
+ * @}
+ */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/Firmware/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c b/Firmware/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c
new file mode 100644
index 0000000..99b5945
--- /dev/null
+++ b/Firmware/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c
@@ -0,0 +1,226 @@
+/**
+ ******************************************************************************
+ * @file usbd_ioreq.c
+ * @author MCD Application Team
+ * @brief This file provides the IO requests APIs for control endpoints.
+ ******************************************************************************
+ * @attention
+ *
+ * © Copyright (c) 2015 STMicroelectronics.
+ * All rights reserved.
+ *
+ * This software component is licensed by ST under Ultimate Liberty license
+ * SLA0044, the "License"; You may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at:
+ * www.st.com/SLA0044
+ *
+ ******************************************************************************
+ */
+
+/* Includes ------------------------------------------------------------------*/
+#include "usbd_ioreq.h"
+
+/** @addtogroup STM32_USB_DEVICE_LIBRARY
+ * @{
+ */
+
+
+/** @defgroup USBD_IOREQ
+ * @brief control I/O requests module
+ * @{
+ */
+
+/** @defgroup USBD_IOREQ_Private_TypesDefinitions
+ * @{
+ */
+/**
+ * @}
+ */
+
+
+/** @defgroup USBD_IOREQ_Private_Defines
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+
+/** @defgroup USBD_IOREQ_Private_Macros
+ * @{
+ */
+/**
+ * @}
+ */
+
+
+/** @defgroup USBD_IOREQ_Private_Variables
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+
+/** @defgroup USBD_IOREQ_Private_FunctionPrototypes
+ * @{
+ */
+/**
+ * @}
+ */
+
+
+/** @defgroup USBD_IOREQ_Private_Functions
+ * @{
+ */
+
+/**
+ * @brief USBD_CtlSendData
+ * send data on the ctl pipe
+ * @param pdev: device instance
+ * @param buff: pointer to data buffer
+ * @param len: length of data to be sent
+ * @retval status
+ */
+USBD_StatusTypeDef USBD_CtlSendData(USBD_HandleTypeDef *pdev,
+ uint8_t *pbuf, uint32_t len)
+{
+ /* Set EP0 State */
+ pdev->ep0_state = USBD_EP0_DATA_IN;
+ pdev->ep_in[0].total_length = len;
+
+#ifdef USBD_AVOID_PACKET_SPLIT_MPS
+ pdev->ep_in[0].rem_length = 0U;
+#else
+ pdev->ep_in[0].rem_length = len;
+#endif
+
+ /* Start the transfer */
+ (void)USBD_LL_Transmit(pdev, 0x00U, pbuf, len);
+
+ return USBD_OK;
+}
+
+/**
+ * @brief USBD_CtlContinueSendData
+ * continue sending data on the ctl pipe
+ * @param pdev: device instance
+ * @param buff: pointer to data buffer
+ * @param len: length of data to be sent
+ * @retval status
+ */
+USBD_StatusTypeDef USBD_CtlContinueSendData(USBD_HandleTypeDef *pdev,
+ uint8_t *pbuf, uint32_t len)
+{
+ /* Start the next transfer */
+ (void)USBD_LL_Transmit(pdev, 0x00U, pbuf, len);
+
+ return USBD_OK;
+}
+
+/**
+ * @brief USBD_CtlPrepareRx
+ * receive data on the ctl pipe
+ * @param pdev: device instance
+ * @param buff: pointer to data buffer
+ * @param len: length of data to be received
+ * @retval status
+ */
+USBD_StatusTypeDef USBD_CtlPrepareRx(USBD_HandleTypeDef *pdev,
+ uint8_t *pbuf, uint32_t len)
+{
+ /* Set EP0 State */
+ pdev->ep0_state = USBD_EP0_DATA_OUT;
+ pdev->ep_out[0].total_length = len;
+
+#ifdef USBD_AVOID_PACKET_SPLIT_MPS
+ pdev->ep_out[0].rem_length = 0U;
+#else
+ pdev->ep_out[0].rem_length = len;
+#endif
+
+ /* Start the transfer */
+ (void)USBD_LL_PrepareReceive(pdev, 0U, pbuf, len);
+
+ return USBD_OK;
+}
+
+/**
+ * @brief USBD_CtlContinueRx
+ * continue receive data on the ctl pipe
+ * @param pdev: device instance
+ * @param buff: pointer to data buffer
+ * @param len: length of data to be received
+ * @retval status
+ */
+USBD_StatusTypeDef USBD_CtlContinueRx(USBD_HandleTypeDef *pdev,
+ uint8_t *pbuf, uint32_t len)
+{
+ (void)USBD_LL_PrepareReceive(pdev, 0U, pbuf, len);
+
+ return USBD_OK;
+}
+
+/**
+ * @brief USBD_CtlSendStatus
+ * send zero lzngth packet on the ctl pipe
+ * @param pdev: device instance
+ * @retval status
+ */
+USBD_StatusTypeDef USBD_CtlSendStatus(USBD_HandleTypeDef *pdev)
+{
+ /* Set EP0 State */
+ pdev->ep0_state = USBD_EP0_STATUS_IN;
+
+ /* Start the transfer */
+ (void)USBD_LL_Transmit(pdev, 0x00U, NULL, 0U);
+
+ return USBD_OK;
+}
+
+/**
+ * @brief USBD_CtlReceiveStatus
+ * receive zero lzngth packet on the ctl pipe
+ * @param pdev: device instance
+ * @retval status
+ */
+USBD_StatusTypeDef USBD_CtlReceiveStatus(USBD_HandleTypeDef *pdev)
+{
+ /* Set EP0 State */
+ pdev->ep0_state = USBD_EP0_STATUS_OUT;
+
+ /* Start the transfer */
+ (void)USBD_LL_PrepareReceive(pdev, 0U, NULL, 0U);
+
+ return USBD_OK;
+}
+
+/**
+ * @brief USBD_GetRxCount
+ * returns the received data length
+ * @param pdev: device instance
+ * @param ep_addr: endpoint address
+ * @retval Rx Data blength
+ */
+uint32_t USBD_GetRxCount(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
+{
+ return USBD_LL_GetRxDataSize(pdev, ep_addr);
+}
+
+/**
+ * @}
+ */
+
+
+/**
+ * @}
+ */
+
+
+/**
+ * @}
+ */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/Firmware/USB_Device/App/usb_device.c b/Firmware/USB_Device/App/usb_device.c
new file mode 100644
index 0000000..7f7f7ab
--- /dev/null
+++ b/Firmware/USB_Device/App/usb_device.c
@@ -0,0 +1,97 @@
+/* USER CODE BEGIN Header */
+/**
+ ******************************************************************************
+ * @file : usb_device.c
+ * @version : v3.0_Cube
+ * @brief : This file implements the USB Device
+ ******************************************************************************
+ * @attention
+ *
+ * Copyright (c) 2025 STMicroelectronics.
+ * All rights reserved.
+ *
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
+ *
+ ******************************************************************************
+ */
+/* USER CODE END Header */
+
+/* Includes ------------------------------------------------------------------*/
+
+#include "usb_device.h"
+#include "usbd_core.h"
+#include "usbd_desc.h"
+#include "usbd_customhid.h"
+#include "usbd_custom_hid_if.h"
+
+/* USER CODE BEGIN Includes */
+
+/* USER CODE END Includes */
+
+/* USER CODE BEGIN PV */
+/* Private variables ---------------------------------------------------------*/
+
+/* USER CODE END PV */
+
+/* USER CODE BEGIN PFP */
+/* Private function prototypes -----------------------------------------------*/
+
+/* USER CODE END PFP */
+
+extern void Error_Handler(void);
+/* USB Device Core handle declaration. */
+USBD_HandleTypeDef hUsbDeviceFS;
+extern USBD_DescriptorsTypeDef CUSTOM_HID_Desc;
+
+/*
+ * -- Insert your variables declaration here --
+ */
+/* USER CODE BEGIN 0 */
+
+/* USER CODE END 0 */
+
+/*
+ * -- Insert your external function declaration here --
+ */
+/* USER CODE BEGIN 1 */
+
+/* USER CODE END 1 */
+
+/**
+ * Init USB device Library, add supported class and start the library
+ * @retval None
+ */
+void MX_USB_Device_Init(void)
+{
+ /* USER CODE BEGIN USB_Device_Init_PreTreatment */
+
+ /* USER CODE END USB_Device_Init_PreTreatment */
+
+ /* Init Device Library, add supported class and start the library. */
+ if (USBD_Init(&hUsbDeviceFS, &CUSTOM_HID_Desc, DEVICE_FS) != USBD_OK) {
+ Error_Handler();
+ }
+ if (USBD_RegisterClass(&hUsbDeviceFS, &USBD_CUSTOM_HID) != USBD_OK) {
+ Error_Handler();
+ }
+ if (USBD_CUSTOM_HID_RegisterInterface(&hUsbDeviceFS, &USBD_CustomHID_fops_FS) != USBD_OK) {
+ Error_Handler();
+ }
+ if (USBD_Start(&hUsbDeviceFS) != USBD_OK) {
+ Error_Handler();
+ }
+ /* USER CODE BEGIN USB_Device_Init_PostTreatment */
+
+ /* USER CODE END USB_Device_Init_PostTreatment */
+}
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
diff --git a/Firmware/USB_Device/App/usb_device.h b/Firmware/USB_Device/App/usb_device.h
new file mode 100644
index 0000000..0ec5831
--- /dev/null
+++ b/Firmware/USB_Device/App/usb_device.h
@@ -0,0 +1,103 @@
+/* USER CODE BEGIN Header */
+/**
+ ******************************************************************************
+ * @file : usb_device.h
+ * @version : v3.0_Cube
+ * @brief : Header for usb_device.c file.
+ ******************************************************************************
+ * @attention
+ *
+ * Copyright (c) 2025 STMicroelectronics.
+ * All rights reserved.
+ *
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
+ *
+ ******************************************************************************
+ */
+/* USER CODE END Header */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __USB_DEVICE__H__
+#define __USB_DEVICE__H__
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32g4xx.h"
+#include "stm32g4xx_hal.h"
+#include "usbd_def.h"
+
+/* USER CODE BEGIN INCLUDE */
+
+/* USER CODE END INCLUDE */
+
+/** @addtogroup USBD_OTG_DRIVER
+ * @{
+ */
+
+/** @defgroup USBD_DEVICE USBD_DEVICE
+ * @brief Device file for Usb otg low level driver.
+ * @{
+ */
+
+/** @defgroup USBD_DEVICE_Exported_Variables USBD_DEVICE_Exported_Variables
+ * @brief Public variables.
+ * @{
+ */
+
+/* Private variables ---------------------------------------------------------*/
+/* USER CODE BEGIN PV */
+
+/* USER CODE END PV */
+
+/* Private function prototypes -----------------------------------------------*/
+/* USER CODE BEGIN PFP */
+
+/* USER CODE END PFP */
+
+/*
+ * -- Insert your variables declaration here --
+ */
+/* USER CODE BEGIN VARIABLES */
+
+/* USER CODE END VARIABLES */
+/**
+ * @}
+ */
+
+/** @defgroup USBD_DEVICE_Exported_FunctionsPrototype USBD_DEVICE_Exported_FunctionsPrototype
+ * @brief Declaration of public functions for Usb device.
+ * @{
+ */
+
+/** USB Device initialization function. */
+void MX_USB_Device_Init(void);
+
+/*
+ * -- Insert functions declaration here --
+ */
+/* USER CODE BEGIN FD */
+
+/* USER CODE END FD */
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __USB_DEVICE__H__ */
+
diff --git a/Firmware/USB_Device/App/usbd_custom_hid_if.c b/Firmware/USB_Device/App/usbd_custom_hid_if.c
new file mode 100644
index 0000000..1b3a44e
--- /dev/null
+++ b/Firmware/USB_Device/App/usbd_custom_hid_if.c
@@ -0,0 +1,238 @@
+/* USER CODE BEGIN Header */
+/**
+ ******************************************************************************
+ * @file : usbd_custom_hid_if.c
+ * @version : v3.0_Cube
+ * @brief : USB Device Custom HID interface file.
+ ******************************************************************************
+ * @attention
+ *
+ * Copyright (c) 2025 STMicroelectronics.
+ * All rights reserved.
+ *
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
+ *
+ ******************************************************************************
+ */
+/* USER CODE END Header */
+
+/* Includes ------------------------------------------------------------------*/
+#include "usbd_custom_hid_if.h"
+
+/* USER CODE BEGIN INCLUDE */
+
+/* USER CODE END INCLUDE */
+
+/* Private typedef -----------------------------------------------------------*/
+/* Private define ------------------------------------------------------------*/
+/* Private macro -------------------------------------------------------------*/
+
+/* USER CODE BEGIN PV */
+/* Private variables ---------------------------------------------------------*/
+
+/* USER CODE END PV */
+
+/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
+ * @brief Usb device.
+ * @{
+ */
+
+/** @addtogroup USBD_CUSTOM_HID
+ * @{
+ */
+
+/** @defgroup USBD_CUSTOM_HID_Private_TypesDefinitions USBD_CUSTOM_HID_Private_TypesDefinitions
+ * @brief Private types.
+ * @{
+ */
+
+/* USER CODE BEGIN PRIVATE_TYPES */
+
+/* USER CODE END PRIVATE_TYPES */
+
+/**
+ * @}
+ */
+
+/** @defgroup USBD_CUSTOM_HID_Private_Defines USBD_CUSTOM_HID_Private_Defines
+ * @brief Private defines.
+ * @{
+ */
+
+/* USER CODE BEGIN PRIVATE_DEFINES */
+
+/* USER CODE END PRIVATE_DEFINES */
+
+/**
+ * @}
+ */
+
+/** @defgroup USBD_CUSTOM_HID_Private_Macros USBD_CUSTOM_HID_Private_Macros
+ * @brief Private macros.
+ * @{
+ */
+
+/* USER CODE BEGIN PRIVATE_MACRO */
+
+/* USER CODE END PRIVATE_MACRO */
+
+/**
+ * @}
+ */
+
+/** @defgroup USBD_CUSTOM_HID_Private_Variables USBD_CUSTOM_HID_Private_Variables
+ * @brief Private variables.
+ * @{
+ */
+
+/** Usb HID report descriptor. */
+__ALIGN_BEGIN static uint8_t CUSTOM_HID_ReportDesc_FS[USBD_CUSTOM_HID_REPORT_DESC_SIZE] __ALIGN_END =
+{
+ /* USER CODE BEGIN 0 */
+ 0x06, 0x00, 0xFF, // Usage Page (Vendor Defined 0xFF00)
+ 0x09, 0x01, // Usage (0x01)
+ 0xA1, 0x01, // Collection (Application)
+
+ // Input Report (Device → Host)
+ 0x85, 0x01, // Report ID (1)
+ 0x09, 0x02, // Usage (0x02)
+ 0x15, 0x00, // Logical Minimum (0)
+ 0x26, 0xFF, 0x00, // Logical Maximum (255)
+ 0x75, 0x08, // Report Size (8 bits)
+ 0x95, 0x3F, // Report Count (63 bytes)
+ 0x81, 0x02, // Input (Data,Var,Abs)
+
+ // Output Report (Host → Device)
+ 0x85, 0x02, // Report ID (2)
+ 0x09, 0x03, // Usage (0x03)
+ 0x15, 0x00, // Logical Minimum (0)
+ 0x26, 0xFF, 0x00, // Logical Maximum (255)
+ 0x75, 0x08, // Report Size (8 bits)
+ 0x95, 0x3F, // Report Count (63 bytes)
+ 0x91, 0x02, // Output (Data,Var,Abs)
+ /* USER CODE END 0 */
+ 0xC0 /* END_COLLECTION */
+};
+
+/* USER CODE BEGIN PRIVATE_VARIABLES */
+
+/* USER CODE END PRIVATE_VARIABLES */
+
+/**
+ * @}
+ */
+
+/** @defgroup USBD_CUSTOM_HID_Exported_Variables USBD_CUSTOM_HID_Exported_Variables
+ * @brief Public variables.
+ * @{
+ */
+extern USBD_HandleTypeDef hUsbDeviceFS;
+
+/* USER CODE BEGIN EXPORTED_VARIABLES */
+
+/* USER CODE END EXPORTED_VARIABLES */
+/**
+ * @}
+ */
+
+/** @defgroup USBD_CUSTOM_HID_Private_FunctionPrototypes USBD_CUSTOM_HID_Private_FunctionPrototypes
+ * @brief Private functions declaration.
+ * @{
+ */
+
+static int8_t CUSTOM_HID_Init_FS(void);
+static int8_t CUSTOM_HID_DeInit_FS(void);
+static int8_t CUSTOM_HID_OutEvent_FS(uint8_t event_idx, uint8_t state);
+
+/**
+ * @}
+ */
+
+USBD_CUSTOM_HID_ItfTypeDef USBD_CustomHID_fops_FS =
+{
+ CUSTOM_HID_ReportDesc_FS,
+ CUSTOM_HID_Init_FS,
+ CUSTOM_HID_DeInit_FS,
+ CUSTOM_HID_OutEvent_FS
+};
+
+/** @defgroup USBD_CUSTOM_HID_Private_Functions USBD_CUSTOM_HID_Private_Functions
+ * @brief Private functions.
+ * @{
+ */
+
+/* Private functions ---------------------------------------------------------*/
+
+/**
+ * @brief Initializes the CUSTOM HID media low layer
+ * @retval USBD_OK if all operations are OK else USBD_FAIL
+ */
+static int8_t CUSTOM_HID_Init_FS(void)
+{
+ /* USER CODE BEGIN 4 */
+ return (USBD_OK);
+ /* USER CODE END 4 */
+}
+
+/**
+ * @brief DeInitializes the CUSTOM HID media low layer
+ * @retval USBD_OK if all operations are OK else USBD_FAIL
+ */
+static int8_t CUSTOM_HID_DeInit_FS(void)
+{
+ /* USER CODE BEGIN 5 */
+ return (USBD_OK);
+ /* USER CODE END 5 */
+}
+
+/**
+ * @brief Manage the CUSTOM HID class events
+ * @param event_idx: Event index
+ * @param state: Event state
+ * @retval USBD_OK if all operations are OK else USBD_FAIL
+ */
+static int8_t CUSTOM_HID_OutEvent_FS(uint8_t event_idx, uint8_t state)
+{
+ /* USER CODE BEGIN 6 */
+ UNUSED(event_idx);
+ UNUSED(state);
+
+ /* Start next USB packet transfer once data processing is completed */
+ USBD_CUSTOM_HID_ReceivePacket(&hUsbDeviceFS);
+
+ return (USBD_OK);
+ /* USER CODE END 6 */
+}
+
+/* USER CODE BEGIN 7 */
+/**
+ * @brief Send the report to the Host
+ * @param report: The report to be sent
+ * @param len: The report length
+ * @retval USBD_OK if all operations are OK else USBD_FAIL
+ */
+/*
+static int8_t USBD_CUSTOM_HID_SendReport_FS(uint8_t *report, uint16_t len)
+{
+ return USBD_CUSTOM_HID_SendReport(&hUsbDeviceFS, report, len);
+}
+*/
+/* USER CODE END 7 */
+
+/* USER CODE BEGIN PRIVATE_FUNCTIONS_IMPLEMENTATION */
+
+/* USER CODE END PRIVATE_FUNCTIONS_IMPLEMENTATION */
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
diff --git a/Firmware/USB_Device/App/usbd_custom_hid_if.h b/Firmware/USB_Device/App/usbd_custom_hid_if.h
new file mode 100644
index 0000000..827389e
--- /dev/null
+++ b/Firmware/USB_Device/App/usbd_custom_hid_if.h
@@ -0,0 +1,127 @@
+/* USER CODE BEGIN Header */
+/**
+ ******************************************************************************
+ * @file : usbd_custom_hid_if.h
+ * @version : v3.0_Cube
+ * @brief : Header for usbd_custom_hid_if.c file.
+ ******************************************************************************
+ * @attention
+ *
+ * Copyright (c) 2025 STMicroelectronics.
+ * All rights reserved.
+ *
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
+ *
+ ******************************************************************************
+ */
+/* USER CODE END Header */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __USBD_CUSTOM_HID_IF_H__
+#define __USBD_CUSTOM_HID_IF_H__
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "usbd_customhid.h"
+
+/* USER CODE BEGIN INCLUDE */
+
+/* USER CODE END INCLUDE */
+
+/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
+ * @brief For Usb device.
+ * @{
+ */
+
+/** @defgroup USBD_CUSTOM_HID USBD_CUSTOM_HID
+ * @brief Usb custom human interface device module.
+ * @{
+ */
+
+/** @defgroup USBD_CUSTOM_HID_Exported_Defines USBD_CUSTOM_HID_Exported_Defines
+ * @brief Defines.
+ * @{
+ */
+
+/* USER CODE BEGIN EXPORTED_DEFINES */
+
+/* USER CODE END EXPORTED_DEFINES */
+
+/**
+ * @}
+ */
+
+/** @defgroup USBD_CUSTOM_HID_Exported_Types USBD_CUSTOM_HID_Exported_Types
+ * @brief Types.
+ * @{
+ */
+
+/* USER CODE BEGIN EXPORTED_TYPES */
+
+/* USER CODE END EXPORTED_TYPES */
+
+/**
+ * @}
+ */
+
+/** @defgroup USBD_CUSTOM_HID_Exported_Macros USBD_CUSTOM_HID_Exported_Macros
+ * @brief Aliases.
+ * @{
+ */
+
+/* USER CODE BEGIN EXPORTED_MACRO */
+
+/* USER CODE END EXPORTED_MACRO */
+
+/**
+ * @}
+ */
+
+/** @defgroup USBD_CUSTOM_HID_Exported_Variables USBD_CUSTOM_HID_Exported_Variables
+ * @brief Public variables.
+ * @{
+ */
+
+/** CUSTOMHID Interface callback. */
+extern USBD_CUSTOM_HID_ItfTypeDef USBD_CustomHID_fops_FS;
+
+/* USER CODE BEGIN EXPORTED_VARIABLES */
+
+/* USER CODE END EXPORTED_VARIABLES */
+
+/**
+ * @}
+ */
+
+/** @defgroup USBD_CUSTOM_HID_Exported_FunctionsPrototype USBD_CUSTOM_HID_Exported_FunctionsPrototype
+ * @brief Public functions declaration.
+ * @{
+ */
+
+/* USER CODE BEGIN EXPORTED_FUNCTIONS */
+
+/* USER CODE END EXPORTED_FUNCTIONS */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __USBD_CUSTOM_HID_IF_H__ */
+
diff --git a/Firmware/USB_Device/App/usbd_desc.c b/Firmware/USB_Device/App/usbd_desc.c
new file mode 100644
index 0000000..977d064
--- /dev/null
+++ b/Firmware/USB_Device/App/usbd_desc.c
@@ -0,0 +1,396 @@
+/* USER CODE BEGIN Header */
+/**
+ ******************************************************************************
+ * @file : App/usbd_desc.c
+ * @version : v3.0_Cube
+ * @brief : This file implements the USB device descriptors.
+ ******************************************************************************
+ * @attention
+ *
+ * Copyright (c) 2025 STMicroelectronics.
+ * All rights reserved.
+ *
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
+ *
+ ******************************************************************************
+ */
+/* USER CODE END Header */
+
+/* Includes ------------------------------------------------------------------*/
+#include "usbd_core.h"
+#include "usbd_desc.h"
+#include "usbd_conf.h"
+
+/* USER CODE BEGIN INCLUDE */
+
+/* USER CODE END INCLUDE */
+
+/* Private typedef -----------------------------------------------------------*/
+/* Private define ------------------------------------------------------------*/
+/* Private macro -------------------------------------------------------------*/
+
+/* USER CODE BEGIN PV */
+/* Private variables ---------------------------------------------------------*/
+
+/* USER CODE END PV */
+
+/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
+ * @{
+ */
+
+/** @addtogroup USBD_DESC
+ * @{
+ */
+
+/** @defgroup USBD_DESC_Private_TypesDefinitions USBD_DESC_Private_TypesDefinitions
+ * @brief Private types.
+ * @{
+ */
+
+/* USER CODE BEGIN PRIVATE_TYPES */
+
+/* USER CODE END PRIVATE_TYPES */
+
+/**
+ * @}
+ */
+
+/** @defgroup USBD_DESC_Private_Defines USBD_DESC_Private_Defines
+ * @brief Private defines.
+ * @{
+ */
+
+#define USBD_VID 1155
+#define USBD_LANGID_STRING 1033
+#define USBD_MANUFACTURER_STRING "STMicroelectronics"
+#define USBD_PID 22352
+#define USBD_PRODUCT_STRING "STM32 Custom Human interface"
+#define USBD_CONFIGURATION_STRING "Custom HID Config"
+#define USBD_INTERFACE_STRING "Custom HID Interface"
+
+/* USER CODE BEGIN PRIVATE_DEFINES */
+
+/* USER CODE END PRIVATE_DEFINES */
+
+/**
+ * @}
+ */
+
+/* USER CODE BEGIN 0 */
+
+/* USER CODE END 0 */
+
+/** @defgroup USBD_DESC_Private_Macros USBD_DESC_Private_Macros
+ * @brief Private macros.
+ * @{
+ */
+
+/* USER CODE BEGIN PRIVATE_MACRO */
+
+/* USER CODE END PRIVATE_MACRO */
+
+/**
+ * @}
+ */
+
+/** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes
+ * @brief Private functions declaration.
+ * @{
+ */
+
+static void Get_SerialNum(void);
+static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len);
+
+/**
+ * @}
+ */
+
+/** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes
+ * @brief Private functions declaration.
+ * @{
+ */
+
+uint8_t * USBD_CUSTOM_HID_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
+uint8_t * USBD_CUSTOM_HID_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
+uint8_t * USBD_CUSTOM_HID_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
+uint8_t * USBD_CUSTOM_HID_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
+uint8_t * USBD_CUSTOM_HID_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
+uint8_t * USBD_CUSTOM_HID_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
+uint8_t * USBD_CUSTOM_HID_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
+
+/**
+ * @}
+ */
+
+/** @defgroup USBD_DESC_Private_Variables USBD_DESC_Private_Variables
+ * @brief Private variables.
+ * @{
+ */
+
+USBD_DescriptorsTypeDef CUSTOM_HID_Desc =
+{
+ USBD_CUSTOM_HID_DeviceDescriptor,
+ USBD_CUSTOM_HID_LangIDStrDescriptor,
+ USBD_CUSTOM_HID_ManufacturerStrDescriptor,
+ USBD_CUSTOM_HID_ProductStrDescriptor,
+ USBD_CUSTOM_HID_SerialStrDescriptor,
+ USBD_CUSTOM_HID_ConfigStrDescriptor,
+ USBD_CUSTOM_HID_InterfaceStrDescriptor
+};
+
+#if defined ( __ICCARM__ ) /* IAR Compiler */
+ #pragma data_alignment=4
+#endif /* defined ( __ICCARM__ ) */
+/** USB standard device descriptor. */
+__ALIGN_BEGIN uint8_t USBD_CUSTOM_HID_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END =
+{
+ 0x12, /*bLength */
+ USB_DESC_TYPE_DEVICE, /*bDescriptorType*/
+ 0x00, /*bcdUSB */
+ 0x02,
+ 0x00, /*bDeviceClass*/
+ 0x00, /*bDeviceSubClass*/
+ 0x00, /*bDeviceProtocol*/
+ USB_MAX_EP0_SIZE, /*bMaxPacketSize*/
+ LOBYTE(USBD_VID), /*idVendor*/
+ HIBYTE(USBD_VID), /*idVendor*/
+ LOBYTE(USBD_PID), /*idProduct*/
+ HIBYTE(USBD_PID), /*idProduct*/
+ 0x00, /*bcdDevice rel. 2.00*/
+ 0x02,
+ USBD_IDX_MFC_STR, /*Index of manufacturer string*/
+ USBD_IDX_PRODUCT_STR, /*Index of product string*/
+ USBD_IDX_SERIAL_STR, /*Index of serial number string*/
+ USBD_MAX_NUM_CONFIGURATION /*bNumConfigurations*/
+};
+
+/* USB_DeviceDescriptor */
+
+/**
+ * @}
+ */
+
+/** @defgroup USBD_DESC_Private_Variables USBD_DESC_Private_Variables
+ * @brief Private variables.
+ * @{
+ */
+
+#if defined ( __ICCARM__ ) /* IAR Compiler */
+ #pragma data_alignment=4
+#endif /* defined ( __ICCARM__ ) */
+
+/** USB lang identifier descriptor. */
+__ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_LEN_LANGID_STR_DESC] __ALIGN_END =
+{
+ USB_LEN_LANGID_STR_DESC,
+ USB_DESC_TYPE_STRING,
+ LOBYTE(USBD_LANGID_STRING),
+ HIBYTE(USBD_LANGID_STRING)
+};
+
+#if defined ( __ICCARM__ ) /* IAR Compiler */
+ #pragma data_alignment=4
+#endif /* defined ( __ICCARM__ ) */
+/* Internal string descriptor. */
+__ALIGN_BEGIN uint8_t USBD_StrDesc[USBD_MAX_STR_DESC_SIZ] __ALIGN_END;
+
+#if defined ( __ICCARM__ ) /*!< IAR Compiler */
+ #pragma data_alignment=4
+#endif
+__ALIGN_BEGIN uint8_t USBD_StringSerial[USB_SIZ_STRING_SERIAL] __ALIGN_END = {
+ USB_SIZ_STRING_SERIAL,
+ USB_DESC_TYPE_STRING,
+};
+
+/**
+ * @}
+ */
+
+/** @defgroup USBD_DESC_Private_Functions USBD_DESC_Private_Functions
+ * @brief Private functions.
+ * @{
+ */
+
+/**
+ * @brief Return the device descriptor
+ * @param speed : Current device speed
+ * @param length : Pointer to data length variable
+ * @retval Pointer to descriptor buffer
+ */
+uint8_t * USBD_CUSTOM_HID_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
+{
+ UNUSED(speed);
+ *length = sizeof(USBD_CUSTOM_HID_DeviceDesc);
+ return USBD_CUSTOM_HID_DeviceDesc;
+}
+
+/**
+ * @brief Return the LangID string descriptor
+ * @param speed : Current device speed
+ * @param length : Pointer to data length variable
+ * @retval Pointer to descriptor buffer
+ */
+uint8_t * USBD_CUSTOM_HID_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
+{
+ UNUSED(speed);
+ *length = sizeof(USBD_LangIDDesc);
+ return USBD_LangIDDesc;
+}
+
+/**
+ * @brief Return the product string descriptor
+ * @param speed : Current device speed
+ * @param length : Pointer to data length variable
+ * @retval Pointer to descriptor buffer
+ */
+uint8_t * USBD_CUSTOM_HID_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
+{
+ if(speed == 0)
+ {
+ USBD_GetString((uint8_t *)USBD_PRODUCT_STRING, USBD_StrDesc, length);
+ }
+ else
+ {
+ USBD_GetString((uint8_t *)USBD_PRODUCT_STRING, USBD_StrDesc, length);
+ }
+ return USBD_StrDesc;
+}
+
+/**
+ * @brief Return the manufacturer string descriptor
+ * @param speed : Current device speed
+ * @param length : Pointer to data length variable
+ * @retval Pointer to descriptor buffer
+ */
+uint8_t * USBD_CUSTOM_HID_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
+{
+ UNUSED(speed);
+ USBD_GetString((uint8_t *)USBD_MANUFACTURER_STRING, USBD_StrDesc, length);
+ return USBD_StrDesc;
+}
+
+/**
+ * @brief Return the serial number string descriptor
+ * @param speed : Current device speed
+ * @param length : Pointer to data length variable
+ * @retval Pointer to descriptor buffer
+ */
+uint8_t * USBD_CUSTOM_HID_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
+{
+ UNUSED(speed);
+ *length = USB_SIZ_STRING_SERIAL;
+
+ /* Update the serial number string descriptor with the data from the unique
+ * ID */
+ Get_SerialNum();
+
+ /* USER CODE BEGIN USBD_CUSTOM_HID_SerialStrDescriptor */
+
+ /* USER CODE END USBD_CUSTOM_HID_SerialStrDescriptor */
+
+ return (uint8_t *) USBD_StringSerial;
+}
+
+/**
+ * @brief Return the configuration string descriptor
+ * @param speed : Current device speed
+ * @param length : Pointer to data length variable
+ * @retval Pointer to descriptor buffer
+ */
+uint8_t * USBD_CUSTOM_HID_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
+{
+ if(speed == USBD_SPEED_HIGH)
+ {
+ USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING, USBD_StrDesc, length);
+ }
+ else
+ {
+ USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING, USBD_StrDesc, length);
+ }
+ return USBD_StrDesc;
+}
+
+/**
+ * @brief Return the interface string descriptor
+ * @param speed : Current device speed
+ * @param length : Pointer to data length variable
+ * @retval Pointer to descriptor buffer
+ */
+uint8_t * USBD_CUSTOM_HID_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
+{
+ if(speed == 0)
+ {
+ USBD_GetString((uint8_t *)USBD_INTERFACE_STRING, USBD_StrDesc, length);
+ }
+ else
+ {
+ USBD_GetString((uint8_t *)USBD_INTERFACE_STRING, USBD_StrDesc, length);
+ }
+ return USBD_StrDesc;
+}
+
+/**
+ * @brief Create the serial number string descriptor
+ * @param None
+ * @retval None
+ */
+static void Get_SerialNum(void)
+{
+ uint32_t deviceserial0;
+ uint32_t deviceserial1;
+ uint32_t deviceserial2;
+
+ deviceserial0 = *(uint32_t *) DEVICE_ID1;
+ deviceserial1 = *(uint32_t *) DEVICE_ID2;
+ deviceserial2 = *(uint32_t *) DEVICE_ID3;
+
+ deviceserial0 += deviceserial2;
+
+ if (deviceserial0 != 0)
+ {
+ IntToUnicode(deviceserial0, &USBD_StringSerial[2], 8);
+ IntToUnicode(deviceserial1, &USBD_StringSerial[18], 4);
+ }
+}
+
+/**
+ * @brief Convert Hex 32Bits value into char
+ * @param value: value to convert
+ * @param pbuf: pointer to the buffer
+ * @param len: buffer length
+ * @retval None
+ */
+static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len)
+{
+ uint8_t idx = 0;
+
+ for (idx = 0; idx < len; idx++)
+ {
+ if (((value >> 28)) < 0xA)
+ {
+ pbuf[2 * idx] = (value >> 28) + '0';
+ }
+ else
+ {
+ pbuf[2 * idx] = (value >> 28) + 'A' - 10;
+ }
+
+ value = value << 4;
+
+ pbuf[2 * idx + 1] = 0;
+ }
+}
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
diff --git a/Firmware/USB_Device/App/usbd_desc.h b/Firmware/USB_Device/App/usbd_desc.h
new file mode 100644
index 0000000..b91cbff
--- /dev/null
+++ b/Firmware/USB_Device/App/usbd_desc.h
@@ -0,0 +1,143 @@
+/* USER CODE BEGIN Header */
+/**
+ ******************************************************************************
+ * @file : usbd_desc.c
+ * @version : v3.0_Cube
+ * @brief : Header for usbd_conf.c file.
+ ******************************************************************************
+ * @attention
+ *
+ * Copyright (c) 2025 STMicroelectronics.
+ * All rights reserved.
+ *
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
+ *
+ ******************************************************************************
+ */
+/* USER CODE END Header */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __USBD_DESC__C__
+#define __USBD_DESC__C__
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "usbd_def.h"
+
+/* USER CODE BEGIN INCLUDE */
+
+/* USER CODE END INCLUDE */
+
+/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
+ * @{
+ */
+
+/** @defgroup USBD_DESC USBD_DESC
+ * @brief Usb device descriptors module.
+ * @{
+ */
+
+/** @defgroup USBD_DESC_Exported_Constants USBD_DESC_Exported_Constants
+ * @brief Constants.
+ * @{
+ */
+#define DEVICE_ID1 (UID_BASE)
+#define DEVICE_ID2 (UID_BASE + 0x4)
+#define DEVICE_ID3 (UID_BASE + 0x8)
+
+#define USB_SIZ_STRING_SERIAL 0x1A
+
+/* USER CODE BEGIN EXPORTED_CONSTANTS */
+
+/* USER CODE END EXPORTED_CONSTANTS */
+
+/**
+ * @}
+ */
+
+/** @defgroup USBD_DESC_Exported_Defines USBD_DESC_Exported_Defines
+ * @brief Defines.
+ * @{
+ */
+
+/* USER CODE BEGIN EXPORTED_DEFINES */
+
+/* USER CODE END EXPORTED_DEFINES */
+
+/**
+ * @}
+ */
+
+/** @defgroup USBD_DESC_Exported_TypesDefinitions USBD_DESC_Exported_TypesDefinitions
+ * @brief Types.
+ * @{
+ */
+
+/* USER CODE BEGIN EXPORTED_TYPES */
+
+/* USER CODE END EXPORTED_TYPES */
+
+/**
+ * @}
+ */
+
+/** @defgroup USBD_DESC_Exported_Macros USBD_DESC_Exported_Macros
+ * @brief Aliases.
+ * @{
+ */
+
+/* USER CODE BEGIN EXPORTED_MACRO */
+
+/* USER CODE END EXPORTED_MACRO */
+
+/**
+ * @}
+ */
+
+/** @defgroup USBD_DESC_Exported_Variables USBD_DESC_Exported_Variables
+ * @brief Public variables.
+ * @{
+ */
+
+extern USBD_DescriptorsTypeDef CUSTOM_HID_Desc;
+
+/* USER CODE BEGIN EXPORTED_VARIABLES */
+
+/* USER CODE END EXPORTED_VARIABLES */
+
+/**
+ * @}
+ */
+
+/** @defgroup USBD_DESC_Exported_FunctionsPrototype USBD_DESC_Exported_FunctionsPrototype
+ * @brief Public functions declaration.
+ * @{
+ */
+
+/* USER CODE BEGIN EXPORTED_FUNCTIONS */
+
+/* USER CODE END EXPORTED_FUNCTIONS */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __USBD_DESC__C__ */
+
diff --git a/Firmware/USB_Device/Target/usbd_conf.c b/Firmware/USB_Device/Target/usbd_conf.c
new file mode 100644
index 0000000..85ba857
--- /dev/null
+++ b/Firmware/USB_Device/Target/usbd_conf.c
@@ -0,0 +1,796 @@
+/* USER CODE BEGIN Header */
+/**
+ ******************************************************************************
+ * @file : Target/usbd_conf.c
+ * @version : v3.0_Cube
+ * @brief : This file implements the board support package for the USB device library
+ ******************************************************************************
+ * @attention
+ *
+ * Copyright (c) 2025 STMicroelectronics.
+ * All rights reserved.
+ *
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
+ *
+ ******************************************************************************
+ */
+/* USER CODE END Header */
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32g4xx.h"
+#include "stm32g4xx_hal.h"
+#include "usbd_def.h"
+#include "usbd_core.h"
+
+#include "usbd_customhid.h"
+
+/* USER CODE BEGIN Includes */
+
+/* USER CODE END Includes */
+
+/* Private typedef -----------------------------------------------------------*/
+/* Private define ------------------------------------------------------------*/
+/* Private macro -------------------------------------------------------------*/
+
+/* Private variables ---------------------------------------------------------*/
+/* USER CODE BEGIN PV */
+
+/* USER CODE END PV */
+
+PCD_HandleTypeDef hpcd_USB_FS;
+void Error_Handler(void);
+
+/* USER CODE BEGIN 0 */
+
+/* USER CODE END 0 */
+
+/* Exported function prototypes ----------------------------------------------*/
+
+/* USER CODE BEGIN PFP */
+/* Private function prototypes -----------------------------------------------*/
+
+/* USER CODE END PFP */
+
+/* Private functions ---------------------------------------------------------*/
+static USBD_StatusTypeDef USBD_Get_USB_Status(HAL_StatusTypeDef hal_status);
+/* USER CODE BEGIN 1 */
+static void SystemClockConfig_Resume(void);
+
+/* USER CODE END 1 */
+extern void SystemClock_Config(void);
+
+/*******************************************************************************
+ LL Driver Callbacks (PCD -> USB Device Library)
+*******************************************************************************/
+/* MSP Init */
+
+#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
+static void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle)
+#else
+void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle)
+#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
+{
+ RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
+ if(pcdHandle->Instance==USB)
+ {
+ /* USER CODE BEGIN USB_MspInit 0 */
+
+ /* USER CODE END USB_MspInit 0 */
+
+ /** Initializes the peripherals clocks
+ */
+ PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB;
+ PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_HSI48;
+ if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
+ {
+ Error_Handler();
+ }
+
+ /* Peripheral clock enable */
+ __HAL_RCC_USB_CLK_ENABLE();
+
+ /* Peripheral interrupt init */
+ HAL_NVIC_SetPriority(USB_LP_IRQn, 5, 0);
+ HAL_NVIC_EnableIRQ(USB_LP_IRQn);
+ /* USER CODE BEGIN USB_MspInit 1 */
+
+ /* USER CODE END USB_MspInit 1 */
+ }
+}
+
+#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
+static void HAL_PCD_MspDeInit(PCD_HandleTypeDef* pcdHandle)
+#else
+void HAL_PCD_MspDeInit(PCD_HandleTypeDef* pcdHandle)
+#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
+{
+ if(pcdHandle->Instance==USB)
+ {
+ /* USER CODE BEGIN USB_MspDeInit 0 */
+
+ /* USER CODE END USB_MspDeInit 0 */
+ /* Peripheral clock disable */
+ __HAL_RCC_USB_CLK_DISABLE();
+
+ /* Peripheral interrupt Deinit*/
+ HAL_NVIC_DisableIRQ(USB_LP_IRQn);
+
+ /* USER CODE BEGIN USB_MspDeInit 1 */
+
+ /* USER CODE END USB_MspDeInit 1 */
+ }
+}
+
+/**
+ * @brief Setup stage callback
+ * @param hpcd: PCD handle
+ * @retval None
+ */
+#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
+static void PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd)
+#else
+void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd)
+#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
+{
+ /* USER CODE BEGIN HAL_PCD_SetupStageCallback_PreTreatment */
+
+ /* USER CODE END HAL_PCD_SetupStageCallback_PreTreatment */
+ USBD_LL_SetupStage((USBD_HandleTypeDef*)hpcd->pData, (uint8_t *)hpcd->Setup);
+ /* USER CODE BEGIN HAL_PCD_SetupStageCallback_PostTreatment */
+
+ /* USER CODE END HAL_PCD_SetupStageCallback_PostTreatment */
+}
+
+/**
+ * @brief Data Out stage callback.
+ * @param hpcd: PCD handle
+ * @param epnum: Endpoint number
+ * @retval None
+ */
+#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
+static void PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
+#else
+void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
+#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
+{
+ /* USER CODE BEGIN HAL_PCD_DataOutStageCallback_PreTreatment */
+
+ /* USER CODE END HAL_PCD_DataOutStageCallback_PreTreatment */
+ USBD_LL_DataOutStage((USBD_HandleTypeDef*)hpcd->pData, epnum, hpcd->OUT_ep[epnum].xfer_buff);
+ /* USER CODE BEGIN HAL_PCD_DataOutStageCallback_PostTreatment */
+
+ /* USER CODE END HAL_PCD_DataOutStageCallback_PostTreatment */
+}
+
+/**
+ * @brief Data In stage callback.
+ * @param hpcd: PCD handle
+ * @param epnum: Endpoint number
+ * @retval None
+ */
+#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
+static void PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
+#else
+void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
+#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
+{
+ /* USER CODE BEGIN HAL_PCD_DataInStageCallback_PreTreatment */
+
+ /* USER CODE END HAL_PCD_DataInStageCallback_PreTreatment */
+ USBD_LL_DataInStage((USBD_HandleTypeDef*)hpcd->pData, epnum, hpcd->IN_ep[epnum].xfer_buff);
+ /* USER CODE BEGIN HAL_PCD_DataInStageCallback_PostTreatment */
+
+ /* USER CODE END HAL_PCD_DataInStageCallback_PostTreatment */
+}
+
+/**
+ * @brief SOF callback.
+ * @param hpcd: PCD handle
+ * @retval None
+ */
+#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
+static void PCD_SOFCallback(PCD_HandleTypeDef *hpcd)
+#else
+void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd)
+#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
+{
+ /* USER CODE BEGIN HAL_PCD_SOFCallback_PreTreatment */
+
+ /* USER CODE END HAL_PCD_SOFCallback_PreTreatment */
+ USBD_LL_SOF((USBD_HandleTypeDef*)hpcd->pData);
+ /* USER CODE BEGIN HAL_PCD_SOFCallback_PostTreatment */
+
+ /* USER CODE END HAL_PCD_SOFCallback_PostTreatment */
+}
+
+/**
+ * @brief Reset callback.
+ * @param hpcd: PCD handle
+ * @retval None
+ */
+#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
+static void PCD_ResetCallback(PCD_HandleTypeDef *hpcd)
+#else
+void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd)
+#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
+{
+ /* USER CODE BEGIN HAL_PCD_ResetCallback_PreTreatment */
+
+ /* USER CODE END HAL_PCD_ResetCallback_PreTreatment */
+ USBD_SpeedTypeDef speed = USBD_SPEED_FULL;
+
+ if ( hpcd->Init.speed != PCD_SPEED_FULL)
+ {
+ Error_Handler();
+ }
+ /* Set Speed. */
+ USBD_LL_SetSpeed((USBD_HandleTypeDef*)hpcd->pData, speed);
+
+ /* Reset Device. */
+ USBD_LL_Reset((USBD_HandleTypeDef*)hpcd->pData);
+ /* USER CODE BEGIN HAL_PCD_ResetCallback_PostTreatment */
+
+ /* USER CODE END HAL_PCD_ResetCallback_PostTreatment */
+}
+
+/**
+ * @brief Suspend callback.
+ * When Low power mode is enabled the debug cannot be used (IAR, Keil doesn't support it)
+ * @param hpcd: PCD handle
+ * @retval None
+ */
+#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
+static void PCD_SuspendCallback(PCD_HandleTypeDef *hpcd)
+#else
+void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd)
+#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
+{
+ /* USER CODE BEGIN HAL_PCD_SuspendCallback_PreTreatment */
+
+ /* USER CODE END HAL_PCD_SuspendCallback_PreTreatment */
+ /* Inform USB library that core enters in suspend Mode. */
+ USBD_LL_Suspend((USBD_HandleTypeDef*)hpcd->pData);
+ /* Enter in STOP mode. */
+ /* USER CODE BEGIN 2 */
+ if (hpcd->Init.low_power_enable)
+ {
+ /* Set SLEEPDEEP bit and SleepOnExit of Cortex System Control Register. */
+ SCB->SCR |= (uint32_t)((uint32_t)(SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk));
+ }
+ /* USER CODE END 2 */
+ /* USER CODE BEGIN HAL_PCD_SuspendCallback_PostTreatment */
+
+ /* USER CODE END HAL_PCD_SuspendCallback_PostTreatment */
+}
+
+/**
+ * @brief Resume callback.
+ * When Low power mode is enabled the debug cannot be used (IAR, Keil doesn't support it)
+ * @param hpcd: PCD handle
+ * @retval None
+ */
+#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
+static void PCD_ResumeCallback(PCD_HandleTypeDef *hpcd)
+#else
+void HAL_PCD_ResumeCallback(PCD_HandleTypeDef *hpcd)
+#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
+{
+ /* USER CODE BEGIN HAL_PCD_ResumeCallback_PreTreatment */
+
+ /* USER CODE END HAL_PCD_ResumeCallback_PreTreatment */
+
+ /* USER CODE BEGIN 3 */
+ if (hpcd->Init.low_power_enable)
+ {
+ /* Reset SLEEPDEEP bit of Cortex System Control Register. */
+ SCB->SCR &= (uint32_t)~((uint32_t)(SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk));
+ SystemClockConfig_Resume();
+ }
+ /* USER CODE END 3 */
+
+ USBD_LL_Resume((USBD_HandleTypeDef*)hpcd->pData);
+ /* USER CODE BEGIN HAL_PCD_ResumeCallback_PostTreatment */
+
+ /* USER CODE END HAL_PCD_ResumeCallback_PostTreatment */
+}
+
+/**
+ * @brief ISOOUTIncomplete callback.
+ * @param hpcd: PCD handle
+ * @param epnum: Endpoint number
+ * @retval None
+ */
+#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
+static void PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
+#else
+void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
+#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
+{
+ /* USER CODE BEGIN HAL_PCD_ISOOUTIncompleteCallback_PreTreatment */
+
+ /* USER CODE END HAL_PCD_ISOOUTIncompleteCallback_PreTreatment */
+ USBD_LL_IsoOUTIncomplete((USBD_HandleTypeDef*)hpcd->pData, epnum);
+ /* USER CODE BEGIN HAL_PCD_ISOOUTIncompleteCallback_PostTreatment */
+
+ /* USER CODE END HAL_PCD_ISOOUTIncompleteCallback_PostTreatment */
+}
+
+/**
+ * @brief ISOINIncomplete callback.
+ * @param hpcd: PCD handle
+ * @param epnum: Endpoint number
+ * @retval None
+ */
+#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
+static void PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
+#else
+void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
+#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
+{
+ /* USER CODE BEGIN HAL_PCD_ISOINIncompleteCallback_PreTreatment */
+
+ /* USER CODE END HAL_PCD_ISOINIncompleteCallback_PreTreatment */
+ USBD_LL_IsoINIncomplete((USBD_HandleTypeDef*)hpcd->pData, epnum);
+ /* USER CODE BEGIN HAL_PCD_ISOINIncompleteCallback_PostTreatment */
+
+ /* USER CODE END HAL_PCD_ISOINIncompleteCallback_PostTreatment */
+}
+
+/**
+ * @brief Connect callback.
+ * @param hpcd: PCD handle
+ * @retval None
+ */
+#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
+static void PCD_ConnectCallback(PCD_HandleTypeDef *hpcd)
+#else
+void HAL_PCD_ConnectCallback(PCD_HandleTypeDef *hpcd)
+#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
+{
+ /* USER CODE BEGIN HAL_PCD_ConnectCallback_PreTreatment */
+
+ /* USER CODE END HAL_PCD_ConnectCallback_PreTreatment */
+ USBD_LL_DevConnected((USBD_HandleTypeDef*)hpcd->pData);
+ /* USER CODE BEGIN HAL_PCD_ConnectCallback_PostTreatment */
+
+ /* USER CODE END HAL_PCD_ConnectCallback_PostTreatment */
+}
+
+/**
+ * @brief Disconnect callback.
+ * @param hpcd: PCD handle
+ * @retval None
+ */
+#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
+static void PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd)
+#else
+void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd)
+#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
+{
+ /* USER CODE BEGIN HAL_PCD_DisconnectCallback_PreTreatment */
+
+ /* USER CODE END HAL_PCD_DisconnectCallback_PreTreatment */
+ USBD_LL_DevDisconnected((USBD_HandleTypeDef*)hpcd->pData);
+ /* USER CODE BEGIN HAL_PCD_DisconnectCallback_PostTreatment */
+
+ /* USER CODE END HAL_PCD_DisconnectCallback_PostTreatment */
+}
+
+ /* USER CODE BEGIN LowLevelInterface */
+
+ /* USER CODE END LowLevelInterface */
+
+/*******************************************************************************
+ LL Driver Interface (USB Device Library --> PCD)
+*******************************************************************************/
+
+/**
+ * @brief Initializes the low level portion of the device driver.
+ * @param pdev: Device handle
+ * @retval USBD status
+ */
+USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev)
+{
+ /* Init USB Ip. */
+ hpcd_USB_FS.pData = pdev;
+ /* Link the driver to the stack. */
+ pdev->pData = &hpcd_USB_FS;
+
+ hpcd_USB_FS.Instance = USB;
+ hpcd_USB_FS.Init.dev_endpoints = 8;
+ hpcd_USB_FS.Init.speed = PCD_SPEED_FULL;
+ hpcd_USB_FS.Init.phy_itface = PCD_PHY_EMBEDDED;
+ hpcd_USB_FS.Init.Sof_enable = DISABLE;
+ hpcd_USB_FS.Init.low_power_enable = DISABLE;
+ hpcd_USB_FS.Init.lpm_enable = DISABLE;
+ hpcd_USB_FS.Init.battery_charging_enable = DISABLE;
+
+ #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
+ /* register Msp Callbacks (before the Init) */
+ HAL_PCD_RegisterCallback(&hpcd_USB_FS, HAL_PCD_MSPINIT_CB_ID, PCD_MspInit);
+ HAL_PCD_RegisterCallback(&hpcd_USB_FS, HAL_PCD_MSPDEINIT_CB_ID, PCD_MspDeInit);
+ #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
+
+ if (HAL_PCD_Init(&hpcd_USB_FS) != HAL_OK)
+ {
+ Error_Handler( );
+ }
+
+#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
+ /* Register USB PCD CallBacks */
+ HAL_PCD_RegisterCallback(&hpcd_USB_FS, HAL_PCD_SOF_CB_ID, PCD_SOFCallback);
+ HAL_PCD_RegisterCallback(&hpcd_USB_FS, HAL_PCD_SETUPSTAGE_CB_ID, PCD_SetupStageCallback);
+ HAL_PCD_RegisterCallback(&hpcd_USB_FS, HAL_PCD_RESET_CB_ID, PCD_ResetCallback);
+ HAL_PCD_RegisterCallback(&hpcd_USB_FS, HAL_PCD_SUSPEND_CB_ID, PCD_SuspendCallback);
+ HAL_PCD_RegisterCallback(&hpcd_USB_FS, HAL_PCD_RESUME_CB_ID, PCD_ResumeCallback);
+ HAL_PCD_RegisterCallback(&hpcd_USB_FS, HAL_PCD_CONNECT_CB_ID, PCD_ConnectCallback);
+ HAL_PCD_RegisterCallback(&hpcd_USB_FS, HAL_PCD_DISCONNECT_CB_ID, PCD_DisconnectCallback);
+ /* USER CODE BEGIN RegisterCallBackFirstPart */
+
+ /* USER CODE END RegisterCallBackFirstPart */
+ HAL_PCD_RegisterLpmCallback(&hpcd_USB_FS, PCDEx_LPM_Callback);
+ HAL_PCD_RegisterDataOutStageCallback(&hpcd_USB_FS, PCD_DataOutStageCallback);
+ HAL_PCD_RegisterDataInStageCallback(&hpcd_USB_FS, PCD_DataInStageCallback);
+ HAL_PCD_RegisterIsoOutIncpltCallback(&hpcd_USB_FS, PCD_ISOOUTIncompleteCallback);
+ HAL_PCD_RegisterIsoInIncpltCallback(&hpcd_USB_FS, PCD_ISOINIncompleteCallback);
+ /* USER CODE BEGIN RegisterCallBackSecondPart */
+
+ /* USER CODE END RegisterCallBackSecondPart */
+#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
+ /* USER CODE BEGIN EndPoint_Configuration */
+ HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x00 , PCD_SNG_BUF, 0x18);
+ HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x80 , PCD_SNG_BUF, 0x58);
+ /* USER CODE END EndPoint_Configuration */
+ /* USER CODE BEGIN EndPoint_Configuration_CUSTOM_HID */
+ HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , CUSTOM_HID_EPIN_ADDR , PCD_SNG_BUF, 0x98);
+ HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , CUSTOM_HID_EPOUT_ADDR , PCD_SNG_BUF, 0xD8);
+ /* USER CODE END EndPoint_Configuration_CUSTOM_HID */
+ return USBD_OK;
+}
+
+/**
+ * @brief De-Initializes the low level portion of the device driver.
+ * @param pdev: Device handle
+ * @retval USBD status
+ */
+USBD_StatusTypeDef USBD_LL_DeInit(USBD_HandleTypeDef *pdev)
+{
+ HAL_StatusTypeDef hal_status = HAL_OK;
+ USBD_StatusTypeDef usb_status = USBD_OK;
+
+ hal_status = HAL_PCD_DeInit(pdev->pData);
+
+ usb_status = USBD_Get_USB_Status(hal_status);
+
+ return usb_status;
+}
+
+/**
+ * @brief Starts the low level portion of the device driver.
+ * @param pdev: Device handle
+ * @retval USBD status
+ */
+USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef *pdev)
+{
+ HAL_StatusTypeDef hal_status = HAL_OK;
+ USBD_StatusTypeDef usb_status = USBD_OK;
+
+ hal_status = HAL_PCD_Start(pdev->pData);
+
+ usb_status = USBD_Get_USB_Status(hal_status);
+
+ return usb_status;
+}
+
+/**
+ * @brief Stops the low level portion of the device driver.
+ * @param pdev: Device handle
+ * @retval USBD status
+ */
+USBD_StatusTypeDef USBD_LL_Stop(USBD_HandleTypeDef *pdev)
+{
+ HAL_StatusTypeDef hal_status = HAL_OK;
+ USBD_StatusTypeDef usb_status = USBD_OK;
+
+ hal_status = HAL_PCD_Stop(pdev->pData);
+
+ usb_status = USBD_Get_USB_Status(hal_status);
+
+ return usb_status;
+}
+
+/**
+ * @brief Opens an endpoint of the low level driver.
+ * @param pdev: Device handle
+ * @param ep_addr: Endpoint number
+ * @param ep_type: Endpoint type
+ * @param ep_mps: Endpoint max packet size
+ * @retval USBD status
+ */
+USBD_StatusTypeDef USBD_LL_OpenEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t ep_type, uint16_t ep_mps)
+{
+ HAL_StatusTypeDef hal_status = HAL_OK;
+ USBD_StatusTypeDef usb_status = USBD_OK;
+
+ hal_status = HAL_PCD_EP_Open(pdev->pData, ep_addr, ep_mps, ep_type);
+
+ usb_status = USBD_Get_USB_Status(hal_status);
+
+ return usb_status;
+}
+
+/**
+ * @brief Closes an endpoint of the low level driver.
+ * @param pdev: Device handle
+ * @param ep_addr: Endpoint number
+ * @retval USBD status
+ */
+USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
+{
+ HAL_StatusTypeDef hal_status = HAL_OK;
+ USBD_StatusTypeDef usb_status = USBD_OK;
+
+ hal_status = HAL_PCD_EP_Close(pdev->pData, ep_addr);
+
+ usb_status = USBD_Get_USB_Status(hal_status);
+
+ return usb_status;
+}
+
+/**
+ * @brief Flushes an endpoint of the Low Level Driver.
+ * @param pdev: Device handle
+ * @param ep_addr: Endpoint number
+ * @retval USBD status
+ */
+USBD_StatusTypeDef USBD_LL_FlushEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
+{
+ HAL_StatusTypeDef hal_status = HAL_OK;
+ USBD_StatusTypeDef usb_status = USBD_OK;
+
+ hal_status = HAL_PCD_EP_Flush(pdev->pData, ep_addr);
+
+ usb_status = USBD_Get_USB_Status(hal_status);
+
+ return usb_status;
+}
+
+/**
+ * @brief Sets a Stall condition on an endpoint of the Low Level Driver.
+ * @param pdev: Device handle
+ * @param ep_addr: Endpoint number
+ * @retval USBD status
+ */
+USBD_StatusTypeDef USBD_LL_StallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
+{
+ HAL_StatusTypeDef hal_status = HAL_OK;
+ USBD_StatusTypeDef usb_status = USBD_OK;
+
+ hal_status = HAL_PCD_EP_SetStall(pdev->pData, ep_addr);
+
+ usb_status = USBD_Get_USB_Status(hal_status);
+
+ return usb_status;
+}
+
+/**
+ * @brief Clears a Stall condition on an endpoint of the Low Level Driver.
+ * @param pdev: Device handle
+ * @param ep_addr: Endpoint number
+ * @retval USBD status
+ */
+USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
+{
+ HAL_StatusTypeDef hal_status = HAL_OK;
+ USBD_StatusTypeDef usb_status = USBD_OK;
+
+ hal_status = HAL_PCD_EP_ClrStall(pdev->pData, ep_addr);
+
+ usb_status = USBD_Get_USB_Status(hal_status);
+
+ return usb_status;
+}
+
+/**
+ * @brief Returns Stall condition.
+ * @param pdev: Device handle
+ * @param ep_addr: Endpoint number
+ * @retval Stall (1: Yes, 0: No)
+ */
+uint8_t USBD_LL_IsStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
+{
+ PCD_HandleTypeDef *hpcd = (PCD_HandleTypeDef*) pdev->pData;
+
+ if((ep_addr & 0x80) == 0x80)
+ {
+ return hpcd->IN_ep[ep_addr & 0x7F].is_stall;
+ }
+ else
+ {
+ return hpcd->OUT_ep[ep_addr & 0x7F].is_stall;
+ }
+}
+
+/**
+ * @brief Assigns a USB address to the device.
+ * @param pdev: Device handle
+ * @param dev_addr: Device address
+ * @retval USBD status
+ */
+USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev, uint8_t dev_addr)
+{
+ HAL_StatusTypeDef hal_status = HAL_OK;
+ USBD_StatusTypeDef usb_status = USBD_OK;
+
+ hal_status = HAL_PCD_SetAddress(pdev->pData, dev_addr);
+
+ usb_status = USBD_Get_USB_Status(hal_status);
+
+ return usb_status;
+}
+
+/**
+ * @brief Transmits data over an endpoint.
+ * @param pdev: Device handle
+ * @param ep_addr: Endpoint number
+ * @param pbuf: Pointer to data to be sent
+ * @param size: Data size
+ * @retval USBD status
+ */
+USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint32_t size)
+{
+ HAL_StatusTypeDef hal_status = HAL_OK;
+ USBD_StatusTypeDef usb_status = USBD_OK;
+
+ hal_status = HAL_PCD_EP_Transmit(pdev->pData, ep_addr, pbuf, size);
+
+ usb_status = USBD_Get_USB_Status(hal_status);
+
+ return usb_status;
+}
+
+/**
+ * @brief Prepares an endpoint for reception.
+ * @param pdev: Device handle
+ * @param ep_addr: Endpoint number
+ * @param pbuf: Pointer to data to be received
+ * @param size: Data size
+ * @retval USBD status
+ */
+USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint32_t size)
+{
+ HAL_StatusTypeDef hal_status = HAL_OK;
+ USBD_StatusTypeDef usb_status = USBD_OK;
+
+ hal_status = HAL_PCD_EP_Receive(pdev->pData, ep_addr, pbuf, size);
+
+ usb_status = USBD_Get_USB_Status(hal_status);
+
+ return usb_status;
+}
+
+/**
+ * @brief Returns the last transferred packet size.
+ * @param pdev: Device handle
+ * @param ep_addr: Endpoint number
+ * @retval Received Data Size
+ */
+uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
+{
+ return HAL_PCD_EP_GetRxCount((PCD_HandleTypeDef*) pdev->pData, ep_addr);
+}
+
+/**
+ * @brief Send LPM message to user layer
+ * @param hpcd: PCD handle
+ * @param msg: LPM message
+ * @retval None
+ */
+#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
+static void PCDEx_LPM_Callback(PCD_HandleTypeDef *hpcd, PCD_LPM_MsgTypeDef msg)
+#else
+void HAL_PCDEx_LPM_Callback(PCD_HandleTypeDef *hpcd, PCD_LPM_MsgTypeDef msg)
+#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
+{
+ /* USER CODE BEGIN LPM_Callback */
+ switch (msg)
+ {
+ case PCD_LPM_L0_ACTIVE:
+ if (hpcd->Init.low_power_enable)
+ {
+ SystemClockConfig_Resume();
+
+ /* Reset SLEEPDEEP bit of Cortex System Control Register. */
+ SCB->SCR &= (uint32_t)~((uint32_t)(SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk));
+ }
+ USBD_LL_Resume(hpcd->pData);
+ break;
+
+ case PCD_LPM_L1_ACTIVE:
+ USBD_LL_Suspend(hpcd->pData);
+
+ /* Enter in STOP mode. */
+ if (hpcd->Init.low_power_enable)
+ {
+ /* Set SLEEPDEEP bit and SleepOnExit of Cortex System Control Register. */
+ SCB->SCR |= (uint32_t)((uint32_t)(SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk));
+ }
+ break;
+ }
+ /* USER CODE END LPM_Callback */
+}
+
+/**
+ * @brief Delays routine for the USB Device Library.
+ * @param Delay: Delay in ms
+ * @retval None
+ */
+void USBD_LL_Delay(uint32_t Delay)
+{
+ HAL_Delay(Delay);
+}
+
+/**
+ * @brief Static single allocation.
+ * @param size: Size of allocated memory
+ * @retval None
+ */
+void *USBD_static_malloc(uint32_t size)
+{
+ static uint32_t mem[(sizeof(USBD_CUSTOM_HID_HandleTypeDef)/4+1)];/* On 32-bit boundary */
+ return mem;
+}
+
+/**
+ * @brief Dummy memory free
+ * @param p: Pointer to allocated memory address
+ * @retval None
+ */
+void USBD_static_free(void *p)
+{
+
+}
+
+/* USER CODE BEGIN 5 */
+/**
+ * @brief Configures system clock after wake-up from USB resume callBack:
+ * enable HSI, PLL and select PLL as system clock source.
+ * @retval None
+ */
+static void SystemClockConfig_Resume(void)
+{
+ SystemClock_Config();
+}
+/* USER CODE END 5 */
+
+/**
+ * @brief Returns the USB status depending on the HAL status:
+ * @param hal_status: HAL status
+ * @retval USB status
+ */
+USBD_StatusTypeDef USBD_Get_USB_Status(HAL_StatusTypeDef hal_status)
+{
+ USBD_StatusTypeDef usb_status = USBD_OK;
+
+ switch (hal_status)
+ {
+ case HAL_OK :
+ usb_status = USBD_OK;
+ break;
+ case HAL_ERROR :
+ usb_status = USBD_FAIL;
+ break;
+ case HAL_BUSY :
+ usb_status = USBD_BUSY;
+ break;
+ case HAL_TIMEOUT :
+ usb_status = USBD_FAIL;
+ break;
+ default :
+ usb_status = USBD_FAIL;
+ break;
+ }
+ return usb_status;
+}
diff --git a/Firmware/USB_Device/Target/usbd_conf.h b/Firmware/USB_Device/Target/usbd_conf.h
new file mode 100644
index 0000000..6888169
--- /dev/null
+++ b/Firmware/USB_Device/Target/usbd_conf.h
@@ -0,0 +1,181 @@
+/* USER CODE BEGIN Header */
+/**
+ ******************************************************************************
+ * @file : usbd_conf.h
+ * @version : v3.0_Cube
+ * @brief : Header for usbd_conf.c file.
+ ******************************************************************************
+ * @attention
+ *
+ * Copyright (c) 2025 STMicroelectronics.
+ * All rights reserved.
+ *
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
+ *
+ ******************************************************************************
+ */
+/* USER CODE END Header */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __USBD_CONF__H__
+#define __USBD_CONF__H__
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include
+#include
+#include
+#include "stm32g4xx.h"
+#include "stm32g4xx_hal.h"
+
+/* USER CODE BEGIN INCLUDE */
+
+/* USER CODE END INCLUDE */
+
+/** @addtogroup USBD_OTG_DRIVER
+ * @brief Driver for Usb device.
+ * @{
+ */
+
+/** @defgroup USBD_CONF USBD_CONF
+ * @brief Configuration file for Usb otg low level driver.
+ * @{
+ */
+
+/** @defgroup USBD_CONF_Exported_Variables USBD_CONF_Exported_Variables
+ * @brief Public variables.
+ * @{
+ */
+
+/* Private variables ---------------------------------------------------------*/
+/* USER CODE BEGIN PV */
+/* USER CODE END PV */
+/**
+ * @}
+ */
+
+/** @defgroup USBD_CONF_Exported_Defines USBD_CONF_Exported_Defines
+ * @brief Defines for configuration of the Usb device.
+ * @{
+ */
+
+/*---------- -----------*/
+#define USBD_MAX_NUM_INTERFACES 1U
+/*---------- -----------*/
+#define USBD_MAX_NUM_CONFIGURATION 1U
+/*---------- -----------*/
+#define USBD_MAX_STR_DESC_SIZ 512U
+/*---------- -----------*/
+#define USBD_DEBUG_LEVEL 0U
+/*---------- -----------*/
+#define USBD_LPM_ENABLED 1U
+/*---------- -----------*/
+#define USBD_SELF_POWERED 1U
+/*---------- -----------*/
+#define USBD_CUSTOMHID_OUTREPORT_BUF_SIZE 64U
+/*---------- -----------*/
+#define USBD_CUSTOM_HID_REPORT_DESC_SIZE 38U
+/*---------- -----------*/
+#define CUSTOM_HID_FS_BINTERVAL 0x5U
+
+/****************************************/
+/* #define for FS and HS identification */
+#define DEVICE_FS 0
+
+/**
+ * @}
+ */
+
+/** @defgroup USBD_CONF_Exported_Macros USBD_CONF_Exported_Macros
+ * @brief Aliases.
+ * @{
+ */
+
+/* Memory management macros */
+
+/** Alias for memory allocation. */
+#define USBD_malloc (void *)USBD_static_malloc
+
+/** Alias for memory release. */
+#define USBD_free USBD_static_free
+
+/** Alias for memory set. */
+#define USBD_memset memset
+
+/** Alias for memory copy. */
+#define USBD_memcpy memcpy
+
+/** Alias for delay. */
+#define USBD_Delay HAL_Delay
+
+/* DEBUG macros */
+
+#if (USBD_DEBUG_LEVEL > 0)
+#define USBD_UsrLog(...) printf(__VA_ARGS__);\
+ printf("\n");
+#else
+#define USBD_UsrLog(...)
+#endif
+
+#if (USBD_DEBUG_LEVEL > 1)
+
+#define USBD_ErrLog(...) printf("ERROR: ") ;\
+ printf(__VA_ARGS__);\
+ printf("\n");
+#else
+#define USBD_ErrLog(...)
+#endif
+
+#if (USBD_DEBUG_LEVEL > 2)
+#define USBD_DbgLog(...) printf("DEBUG : ") ;\
+ printf(__VA_ARGS__);\
+ printf("\n");
+#else
+#define USBD_DbgLog(...)
+#endif
+
+/**
+ * @}
+ */
+
+/** @defgroup USBD_CONF_Exported_Types USBD_CONF_Exported_Types
+ * @brief Types.
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup USBD_CONF_Exported_FunctionsPrototype USBD_CONF_Exported_FunctionsPrototype
+ * @brief Declaration of public functions for Usb device.
+ * @{
+ */
+
+/* Exported functions -------------------------------------------------------*/
+void *USBD_static_malloc(uint32_t size);
+void USBD_static_free(void *p);
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __USBD_CONF__H__ */
+