diff --git a/.cproject b/.cproject
index 377aa0a..15635fd 100644
--- a/.cproject
+++ b/.cproject
@@ -173,4 +173,5 @@
+
\ No newline at end of file
diff --git a/.mxproject b/.mxproject
index fc14a75..cfb84d7 100644
--- a/.mxproject
+++ b/.mxproject
@@ -1,8 +1,8 @@
[PreviousLibFiles]
-LibFiles=Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_cortex.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_cortex.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_eth.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_eth_ex.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_rcc.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_rcc_ex.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_bus.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_rcc.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_crs.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_system.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_utils.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_flash.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_flash_ex.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_gpio.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_gpio_ex.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_gpio.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_hsem.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_hsem.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_dma.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_dma_ex.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_dma.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_dmamux.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_mdma.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_pwr.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_pwr_ex.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_pwr.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_def.h;Drivers\STM32H7xx_HAL_Driver\Inc\Legacy\stm32_hal_legacy.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_i2c.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_i2c_ex.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_exti.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_exti.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_tim.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_tim_ex.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_tim.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_uart.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_usart.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_lpuart.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_uart_ex.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_pcd.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_pcd_ex.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_usb.h;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_cortex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_eth.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_eth_ex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_rcc.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_rcc_ex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_flash.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_flash_ex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_gpio.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_hsem.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_dma.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_dma_ex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_mdma.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_pwr.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_pwr_ex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_i2c.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_i2c_ex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_exti.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_tim.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_tim_ex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_uart.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_uart_ex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_pcd.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_pcd_ex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_ll_usb.c;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_cortex.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_cortex.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_eth.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_eth_ex.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_rcc.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_rcc_ex.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_bus.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_rcc.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_crs.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_system.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_utils.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_flash.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_flash_ex.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_gpio.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_gpio_ex.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_gpio.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_hsem.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_hsem.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_dma.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_dma_ex.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_dma.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_dmamux.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_mdma.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_pwr.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_pwr_ex.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_pwr.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_def.h;Drivers\STM32H7xx_HAL_Driver\Inc\Legacy\stm32_hal_legacy.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_i2c.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_i2c_ex.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_exti.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_exti.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_tim.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_tim_ex.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_tim.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_uart.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_usart.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_lpuart.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_uart_ex.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_pcd.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_pcd_ex.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_usb.h;Drivers\CMSIS\Device\ST\STM32H7xx\Include\stm32h743xx.h;Drivers\CMSIS\Device\ST\STM32H7xx\Include\stm32h7xx.h;Drivers\CMSIS\Device\ST\STM32H7xx\Include\system_stm32h7xx.h;Drivers\CMSIS\Device\ST\STM32H7xx\Source\Templates\system_stm32h7xx.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\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_cortex.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_cortex.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_tim.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_tim_ex.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_tim.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_rcc.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_rcc_ex.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_bus.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_rcc.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_crs.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_system.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_utils.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_flash.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_flash_ex.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_gpio.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_gpio_ex.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_gpio.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_hsem.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_hsem.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_dma.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_dma_ex.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_dma.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_dmamux.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_mdma.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_pwr.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_pwr_ex.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_pwr.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_def.h;Drivers\STM32H7xx_HAL_Driver\Inc\Legacy\stm32_hal_legacy.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_i2c.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_i2c_ex.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_exti.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_exti.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_uart.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_usart.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_lpuart.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_uart_ex.h;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_cortex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_tim.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_tim_ex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_rcc.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_rcc_ex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_flash.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_flash_ex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_gpio.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_hsem.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_dma.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_dma_ex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_mdma.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_pwr.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_pwr_ex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_i2c.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_i2c_ex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_exti.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_uart.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_uart_ex.c;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_cortex.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_cortex.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_tim.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_tim_ex.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_tim.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_rcc.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_rcc_ex.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_bus.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_rcc.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_crs.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_system.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_utils.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_flash.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_flash_ex.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_gpio.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_gpio_ex.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_gpio.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_hsem.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_hsem.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_dma.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_dma_ex.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_dma.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_dmamux.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_mdma.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_pwr.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_pwr_ex.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_pwr.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_def.h;Drivers\STM32H7xx_HAL_Driver\Inc\Legacy\stm32_hal_legacy.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_i2c.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_i2c_ex.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_exti.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_exti.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_uart.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_usart.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_ll_lpuart.h;Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_uart_ex.h;Drivers\CMSIS\Device\ST\STM32H7xx\Include\stm32h743xx.h;Drivers\CMSIS\Device\ST\STM32H7xx\Include\stm32h7xx.h;Drivers\CMSIS\Device\ST\STM32H7xx\Include\system_stm32h7xx.h;Drivers\CMSIS\Device\ST\STM32H7xx\Source\Templates\system_stm32h7xx.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\stm32h7xx_it.c;Core\Src\stm32h7xx_hal_msp.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_cortex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_eth.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_eth_ex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_rcc.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_rcc_ex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_flash.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_flash_ex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_gpio.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_hsem.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_dma.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_dma_ex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_mdma.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_pwr.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_pwr_ex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_i2c.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_i2c_ex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_exti.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_tim.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_tim_ex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_uart.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_uart_ex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_pcd.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_pcd_ex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_ll_usb.c;Drivers\CMSIS\Device\ST\STM32H7xx\Source\Templates\system_stm32h7xx.c;Core\Src\system_stm32h7xx.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_cortex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_eth.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_eth_ex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_rcc.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_rcc_ex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_flash.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_flash_ex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_gpio.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_hsem.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_dma.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_dma_ex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_mdma.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_pwr.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_pwr_ex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_i2c.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_i2c_ex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_exti.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_tim.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_tim_ex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_uart.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_uart_ex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_pcd.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_pcd_ex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_ll_usb.c;Drivers\CMSIS\Device\ST\STM32H7xx\Source\Templates\system_stm32h7xx.c;Core\Src\system_stm32h7xx.c;;;
+SourceFiles=Core\Src\main.c;Core\Src\stm32h7xx_it.c;Core\Src\stm32h7xx_hal_msp.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_cortex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_tim.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_tim_ex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_rcc.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_rcc_ex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_flash.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_flash_ex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_gpio.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_hsem.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_dma.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_dma_ex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_mdma.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_pwr.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_pwr_ex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_i2c.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_i2c_ex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_exti.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_uart.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_uart_ex.c;Drivers\CMSIS\Device\ST\STM32H7xx\Source\Templates\system_stm32h7xx.c;Core\Src\system_stm32h7xx.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_cortex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_tim.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_tim_ex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_rcc.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_rcc_ex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_flash.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_flash_ex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_gpio.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_hsem.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_dma.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_dma_ex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_mdma.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_pwr.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_pwr_ex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_i2c.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_i2c_ex.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_exti.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_uart.c;Drivers\STM32H7xx_HAL_Driver\Src\stm32h7xx_hal_uart_ex.c;Drivers\CMSIS\Device\ST\STM32H7xx\Source\Templates\system_stm32h7xx.c;Core\Src\system_stm32h7xx.c;;;
HeaderPath=Drivers\STM32H7xx_HAL_Driver\Inc;Drivers\STM32H7xx_HAL_Driver\Inc\Legacy;Drivers\CMSIS\Device\ST\STM32H7xx\Include;Drivers\CMSIS\Include;Core\Inc;
CDefines=USE_HAL_DRIVER;STM32H743xx;USE_HAL_DRIVER;USE_HAL_DRIVER;
diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 0000000..696a104
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,6 @@
+{
+ "files.associations": {
+ "limits.h": "c",
+ "main.h": "c"
+ }
+}
\ No newline at end of file
diff --git a/Core/Inc/main.h b/Core/Inc/main.h
index 09a9e5b..b41309b 100644
--- a/Core/Inc/main.h
+++ b/Core/Inc/main.h
@@ -61,6 +61,7 @@ void Error_Handler(void);
/* Private defines -----------------------------------------------------------*/
#define B1_Pin GPIO_PIN_13
#define B1_GPIO_Port GPIOC
+#define B1_EXTI_IRQn EXTI15_10_IRQn
#define LD1_Pin GPIO_PIN_0
#define LD1_GPIO_Port GPIOB
#define LD3_Pin GPIO_PIN_14
diff --git a/Core/Inc/neopixel.h b/Core/Inc/neopixel.h
new file mode 100644
index 0000000..55b5e2f
--- /dev/null
+++ b/Core/Inc/neopixel.h
@@ -0,0 +1,110 @@
+/**
+ ******************************************************************************
+ * @file : neopixel.h
+ * @brief : Types and definitions for objects related to driving the
+ * NeoPixel LED string.
+ ******************************************************************************
+ * @attention
+ *
+ * Copyright (c) 2023 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.
+ *
+ ******************************************************************************
+ */
+
+#ifndef NEOPIXEL_H_ // Multi-include protection
+#define NEOPIXEL_H_
+
+
+/* Includes ------------------------------------------------------------------*/
+#include
+#include
+
+/* Public define ------------------------------------------------------------*/
+
+#define NUM_OF_PIXELS_IN_PULSE_STRIP 60
+#define NUM_OF_PIXELS_IN_RING_STRIP 100
+#define NUM_OF_BITS_PER_PIXEL 24
+#define NUM_OF_FRAMES_PER_SECOND 30
+#define NUM_OF_SECONDS_OF_UNIQUE_ANIMATION 1
+#define NUM_OF_FRAMES (NUM_OF_FRAMES_PER_SECOND * NUM_OF_SECONDS_OF_UNIQUE_ANIMATION)
+
+#define LED_SETPOINT_MIN 0
+#define LED_SETPOINT_MAX 255
+
+#define ARR_SETPOINT (80-1) // ARR = Auto-Reload Register --> Register that sets the PWM frequency and is what effectively sets the reset point of the timer's counter
+// Duty cycle is set in the Capture/Compare Register (CRR) of a timer respective output channel, and is what effectively sets the point at which the PWM center edge occurs.
+#define DUTY_CYCLE_100_PCT ARR_REGISTER_SETPOINT
+#define DUTY_CYCLE_0_PCT 0
+#define DUTY_CYCLE_ZERO_ENCODING 22 // 22 / 80 ~ 0.275 ==> 0.275 x 1,250ns = 343.8ns = 350ns - 6.2ns (which is within +/- 150ns spec)
+#define DUTY_CYCLE_ONE_ENCODING 45 // 45 / 80 ~ 0.560 ==> 0.560 x 1,250ns = 703.1ns = 700ns + 3.1ns (which is within +/- 150ns spec)
+#define DUTY_CYCLE_STOP_ENCODING 0 // Line needs to be low for at least 50us for the transmission to be interpreted as complete by the WS2812 module
+
+/* Public typedef -----------------------------------------------------------*/
+
+typedef uint8_t LEDSetpoint_T; // Setpoint for a given LED is a value from 0 to 255, which is the same range as a byte
+
+// For convenience of looping through the bits for the LEDs, I'll want to place the LSB first and MSB last (since ARM is little-endian)
+struct Pixel_S
+{
+ LEDSetpoint_T blue; // Will become LSB
+ LEDSetpoint_T red;
+ LEDSetpoint_T green; // Will become MSB
+};
+
+union Pixel_U
+{
+ // TODO: Need to note whether the struct will take up the lower 3 bytes or the upper 3 bytes of this space...
+ struct Pixel_S rgb;
+ uint32_t pixel_word;
+};
+
+struct LED_Strip_Frame_S
+{
+ union Pixel_U LEDs[NUM_OF_PIXELS_IN_PULSE_STRIP];
+};
+
+enum RingBrightness_E
+{
+ BRIGHTNESS_OFF,
+ BRIGHTNESS_MIN,
+ BRIGHTNESS_LEVEL_1 = BRIGHTNESS_MIN,
+ BRIGHTNESS_LEVEL_2,
+ BRIGHTNESS_LEVEL_3,
+ BRIGHTNESS_LEVEL_4,
+ BRIGHTNESS_LEVEL_5,
+ BRIGHTNESS_MID = BRIGHTNESS_LEVEL_5,
+ BRIGHTNESS_LEVEL_6,
+ BRIGHTNESS_LEVEL_7,
+ BRIGHTNESS_LEVEL_8,
+ BRIGHTNESS_LEVEL_9,
+ BRIGHTNESS_LEVEL_10,
+ BRIGHTNESS_MAX = BRIGHTNESS_LEVEL_10,
+ NUM_OF_BRIGHTNESS_LEVELS
+};
+
+/* Private macro -------------------------------------------------------------*/
+
+
+
+/* Private variables ---------------------------------------------------------*/
+
+
+
+/* Public function prototypes ------------------------------------------------*/
+
+bool NeoPixel_PulseStrips_FillBuffer(uint8_t frame, uint32_t * buffer, uint32_t length);
+
+bool NeoPixel_RingStrip_FillBuffer(enum RingBrightness_E brightness, uint32_t * buffer, uint32_t length);
+
+bool NeoPixel_RingStrip_AllOff_FillBuffer(uint32_t * buffer, uint32_t length);
+
+bool NeoPixel_PulseStrips_AllOff_FillBuffer(uint32_t * buffer, uint32_t length);
+
+/* Private user code ---------------------------------------------------------*/
+
+#endif // NEOPIXEL_H
\ No newline at end of file
diff --git a/Core/Inc/stm32h7xx_hal_conf.h b/Core/Inc/stm32h7xx_hal_conf.h
index 298c2d8..5ea00c0 100644
--- a/Core/Inc/stm32h7xx_hal_conf.h
+++ b/Core/Inc/stm32h7xx_hal_conf.h
@@ -45,7 +45,7 @@
/* #define HAL_DAC_MODULE_ENABLED */
/* #define HAL_DCMI_MODULE_ENABLED */
/* #define HAL_DMA2D_MODULE_ENABLED */
-#define HAL_ETH_MODULE_ENABLED
+/* #define HAL_ETH_MODULE_ENABLED */
/* #define HAL_ETH_LEGACY_MODULE_ENABLED */
/* #define HAL_NAND_MODULE_ENABLED */
/* #define HAL_NOR_MODULE_ENABLED */
@@ -81,7 +81,7 @@
/* #define HAL_IRDA_MODULE_ENABLED */
/* #define HAL_SMARTCARD_MODULE_ENABLED */
/* #define HAL_WWDG_MODULE_ENABLED */
-#define HAL_PCD_MODULE_ENABLED
+/* #define HAL_PCD_MODULE_ENABLED */
/* #define HAL_HCD_MODULE_ENABLED */
/* #define HAL_DFSDM_MODULE_ENABLED */
/* #define HAL_DSI_MODULE_ENABLED */
diff --git a/Core/Inc/stm32h7xx_it.h b/Core/Inc/stm32h7xx_it.h
index ce87cf8..32af7ba 100644
--- a/Core/Inc/stm32h7xx_it.h
+++ b/Core/Inc/stm32h7xx_it.h
@@ -58,6 +58,7 @@ void SysTick_Handler(void);
void DMA1_Stream0_IRQHandler(void);
void DMA1_Stream1_IRQHandler(void);
void DMA1_Stream2_IRQHandler(void);
+void EXTI15_10_IRQHandler(void);
/* USER CODE BEGIN EFP */
/* USER CODE END EFP */
diff --git a/Core/Src/main.c b/Core/Src/main.c
index 96526e1..f505983 100644
--- a/Core/Src/main.c
+++ b/Core/Src/main.c
@@ -18,21 +18,40 @@
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"
-#include "string.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
+#include
+#include
+#include
+#include "neopixel.h"
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */
+enum LEDStringState_E
+{
+ IDLE_ANIMATION,
+ PROPOSAL_ANIMATION,
+ VICTORY_ANIMATION,
+ NUM_OF_LED_STATEMAP_STATES
+};
+
+struct GPIO_Port_Pin_S
+{
+ GPIO_TypeDef * port;
+ uint16_t pin;
+};
+
/* USER CODE END PTD */
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
+#define DEBOUNCE_WAIT_TIME 5 // ms
+
/* USER CODE END PD */
/* Private macro -------------------------------------------------------------*/
@@ -41,26 +60,6 @@
/* USER CODE END PM */
/* Private variables ---------------------------------------------------------*/
-#if defined ( __ICCARM__ ) /*!< IAR Compiler */
-#pragma location=0x30000000
-ETH_DMADescTypeDef DMARxDscrTab[ETH_RX_DESC_CNT]; /* Ethernet Rx DMA Descriptors */
-#pragma location=0x30000200
-ETH_DMADescTypeDef DMATxDscrTab[ETH_TX_DESC_CNT]; /* Ethernet Tx DMA Descriptors */
-
-#elif defined ( __CC_ARM ) /* MDK ARM Compiler */
-
-__attribute__((at(0x30000000))) ETH_DMADescTypeDef DMARxDscrTab[ETH_RX_DESC_CNT]; /* Ethernet Rx DMA Descriptors */
-__attribute__((at(0x30000200))) ETH_DMADescTypeDef DMATxDscrTab[ETH_TX_DESC_CNT]; /* Ethernet Tx DMA Descriptors */
-
-#elif defined ( __GNUC__ ) /* GNU Compiler */
-ETH_DMADescTypeDef DMARxDscrTab[ETH_RX_DESC_CNT] __attribute__((section(".RxDecripSection"))); /* Ethernet Rx DMA Descriptors */
-ETH_DMADescTypeDef DMATxDscrTab[ETH_TX_DESC_CNT] __attribute__((section(".TxDecripSection"))); /* Ethernet Tx DMA Descriptors */
-
-#endif
-
-ETH_TxPacketConfig TxConfig;
-
-ETH_HandleTypeDef heth;
TIM_HandleTypeDef htim2;
TIM_HandleTypeDef htim3;
@@ -71,10 +70,15 @@ DMA_HandleTypeDef hdma_tim4_ch1;
UART_HandleTypeDef huart3;
-PCD_HandleTypeDef hpcd_USB_OTG_FS;
-
/* USER CODE BEGIN PV */
+static volatile bool DMA_Transfer_Complete; // Flag to indicate a DMA transfer was completed. TODO: Remove this once you figure how to get around the wait after DMA transfer request...
+static volatile bool ButtonPressed;
+
+/* External variables --------------------------------------------------------*/
+
+extern const struct LED_Strip_Frame_S LED_ANIMATION_TABLE[NUM_OF_FRAMES];
+
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
@@ -82,9 +86,7 @@ void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_DMA_Init(void);
static void MX_USART3_UART_Init(void);
-static void MX_USB_OTG_FS_PCD_Init(void);
static void MX_TIM2_Init(void);
-static void MX_ETH_Init(void);
static void MX_TIM3_Init(void);
static void MX_TIM4_Init(void);
/* USER CODE BEGIN PFP */
@@ -94,6 +96,31 @@ static void MX_TIM4_Init(void);
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
+/*!*****************************************************************
+* @fn HAL_TIM_PWM_PulseFinishedCallback
+* @brief Callback function that is called once the DMA has completed its transfer.
+* @param[in] PixelData array that contains the data for each pixel
+* @return void
+*******************************************************************/
+void HAL_TIM_PWM_PulseFinishedCallback(TIM_HandleTypeDef *htim)
+{
+ HAL_TIM_PWM_Stop_DMA( htim, TIM_CHANNEL_1 );
+ DMA_Transfer_Complete = true;
+}
+
+/**
+ * @brief EXTI line detection callback.
+ * @param GPIO_Pin: Specifies the port pin connected to corresponding EXTI line.
+ * @retval None
+ */
+void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
+{
+ if ( GPIO_Pin == B1_Pin )
+ {
+ ButtonPressed = true;
+ }
+}
+
/* USER CODE END 0 */
/**
@@ -104,6 +131,21 @@ int main(void)
{
/* USER CODE BEGIN 1 */
+ static enum LEDStringState_E LEDStateMapState = IDLE_ANIMATION;
+ static bool AnimationComplete = false;
+ static uint8_t LED_Idx = 0;
+ static bool StateUpdated = false;
+ uint32_t dma_buffer_ring_strip[NUM_OF_PIXELS_IN_RING_STRIP * NUM_OF_BITS_PER_PIXEL + 1];
+ uint32_t dma_buffer_pulse_strip[NUM_OF_PIXELS_IN_PULSE_STRIP * NUM_OF_BITS_PER_PIXEL + 1];
+
+ // Declarations and definitions for LED selection
+ static const struct GPIO_Port_Pin_S LED_OPTIONS_TABLE[] =
+ {
+ { LD1_GPIO_Port, LD1_Pin },
+ { LD2_GPIO_Port, LD2_Pin },
+ { LD3_GPIO_Port, LD3_Pin },
+ };
+
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
@@ -126,22 +168,216 @@ int main(void)
MX_GPIO_Init();
MX_DMA_Init();
MX_USART3_UART_Init();
- MX_USB_OTG_FS_PCD_Init();
MX_TIM2_Init();
- MX_ETH_Init();
MX_TIM3_Init();
MX_TIM4_Init();
/* USER CODE BEGIN 2 */
+
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
+ HAL_GPIO_WritePin( LED_OPTIONS_TABLE[LED_Idx].port, LED_OPTIONS_TABLE[LED_Idx].pin, GPIO_PIN_SET );
+
while (1)
{
+
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
+
+ switch( LEDStateMapState )
+ {
+ case IDLE_ANIMATION:
+ StateUpdated = false;
+
+ NeoPixel_RingStrip_AllOff_FillBuffer(dma_buffer_ring_strip, sizeof(dma_buffer_ring_strip)/sizeof(uint32_t));
+ NeoPixel_PulseStrips_AllOff_FillBuffer(dma_buffer_pulse_strip, sizeof(dma_buffer_pulse_strip)/sizeof(uint32_t));
+
+ // Send away to timer 4
+ if ( HAL_TIM_PWM_Start_DMA( &htim4, TIM_CHANNEL_1, dma_buffer_ring_strip, sizeof(dma_buffer_ring_strip)/sizeof(uint32_t) ) != HAL_OK )
+ {
+ // TODO: Write a handler to indicate the DMA start request failed...
+ }
+ while( DMA_Transfer_Complete == false );
+ DMA_Transfer_Complete = false;
+
+ // Send away to the timer 2
+ if ( HAL_TIM_PWM_Start_DMA( &htim2, TIM_CHANNEL_1, dma_buffer_pulse_strip, sizeof(dma_buffer_pulse_strip)/sizeof(uint32_t) ) != HAL_OK )
+ {
+ // TODO: Write a handler to indicate the DMA start request failed...
+ }
+ // For some reason, despite this defeating the whole purpose of the DMA, I have to wait otherwise the data gets corrupted...
+ // TODO: Figure out how to not have to do this!
+ while( DMA_Transfer_Complete == false );
+ DMA_Transfer_Complete = false;
+
+ // Send away to the timer 3
+ if ( HAL_TIM_PWM_Start_DMA( &htim3, TIM_CHANNEL_1, dma_buffer_pulse_strip, sizeof(dma_buffer_pulse_strip)/sizeof(uint32_t) ) != HAL_OK )
+ {
+ // TODO: Write a handler to indicate the DMA start request failed...
+ }
+ while( DMA_Transfer_Complete == false );
+ DMA_Transfer_Complete = false;
+
+
+ // Process button press, if applicable
+ if ( ButtonPressed == true )
+ {
+ StateUpdated = true;
+ AnimationComplete = false;
+ LEDStateMapState = PROPOSAL_ANIMATION; // Next loop will transition to next state
+ ButtonPressed = false;
+ HAL_Delay( DEBOUNCE_WAIT_TIME ); // TODO: Handle debounces without a delay...
+
+ // For debug purposes, drive one of the board LEDs to indicate state
+ HAL_GPIO_WritePin( LED_OPTIONS_TABLE[LED_Idx].port, LED_OPTIONS_TABLE[LED_Idx].pin, GPIO_PIN_RESET );
+ LED_Idx++;
+ // Wrap-around if past table bounds
+ if ( LED_Idx >= (sizeof(LED_OPTIONS_TABLE) / sizeof(struct GPIO_Port_Pin_S)) )
+ {
+ LED_Idx = 0;
+ }
+ HAL_GPIO_WritePin( LED_OPTIONS_TABLE[LED_Idx].port, LED_OPTIONS_TABLE[LED_Idx].pin, GPIO_PIN_SET );
+
+ }
+
+ break;
+
+ case PROPOSAL_ANIMATION:
+
+ // Process button press, if applicable
+ if ( ButtonPressed == true )
+ {
+ if ( AnimationComplete == false )
+ {
+ // Hold off on transitioning
+ }
+ else
+ {
+ LEDStateMapState = VICTORY_ANIMATION; // Next loop will transition to next state
+ ButtonPressed = false;
+ HAL_Delay( DEBOUNCE_WAIT_TIME ); // TODO: Handle debounces without a delay...
+
+ // For debug purposes, drive one of the board LEDs to indicate state
+ HAL_GPIO_WritePin( LED_OPTIONS_TABLE[LED_Idx].port, LED_OPTIONS_TABLE[LED_Idx].pin, GPIO_PIN_RESET );
+ LED_Idx++;
+ // Wrap-around if past table bounds
+ if ( LED_Idx >= (sizeof(LED_OPTIONS_TABLE) / sizeof(struct GPIO_Port_Pin_S)) )
+ {
+ LED_Idx = 0;
+ }
+ HAL_GPIO_WritePin( LED_OPTIONS_TABLE[LED_Idx].port, LED_OPTIONS_TABLE[LED_Idx].pin, GPIO_PIN_SET );
+ }
+
+ }
+
+ // Animate!
+ if ( AnimationComplete == false )
+ {
+
+ for ( uint8_t pulse_idx = 1; pulse_idx < (NUM_OF_BRIGHTNESS_LEVELS - 1); pulse_idx++ )
+ {
+ // Perform pulse animation
+
+ if ( pulse_idx == 1 )
+ {
+ HAL_Delay(2000); // Wait two seconds after button press essentially...
+ }
+
+ // Pulse one strip
+ for ( uint8_t frame_idx = 0; frame_idx < NUM_OF_FRAMES; frame_idx++ )
+ {
+ NeoPixel_PulseStrips_FillBuffer( frame_idx, dma_buffer_pulse_strip, sizeof(dma_buffer_pulse_strip)/sizeof(uint32_t) );
+ // Send away to the timer 2
+ if ( HAL_TIM_PWM_Start_DMA( &htim2, TIM_CHANNEL_1, dma_buffer_pulse_strip, sizeof(dma_buffer_pulse_strip)/sizeof(uint32_t) ) != HAL_OK )
+ {
+ // TODO: Write a handler to indicate the DMA start request failed...
+ }
+ // For some reason, despite this defeating the whole purpose of the DMA, I have to wait otherwise the data gets corrupted...
+ // TODO: Figure out how to not have to do this!
+ while( DMA_Transfer_Complete == false );
+ DMA_Transfer_Complete = false;
+
+ HAL_Delay(15); // REDO COMMENT: 1s / 30 frames ~ 33.333ms, and it takes about 30us x 60 LEDs x 2 strips = 3.6ms to update the strips, so 33.333ms - 3.600ms = 29.733ms ~ 30ms
+ }
+
+ // Go to next brightness level with the ring strip
+ NeoPixel_RingStrip_FillBuffer( (enum RingBrightness_E) pulse_idx, dma_buffer_ring_strip, sizeof(dma_buffer_ring_strip)/sizeof(uint32_t) );
+ if ( HAL_TIM_PWM_Start_DMA( &htim4, TIM_CHANNEL_1, dma_buffer_ring_strip, sizeof(dma_buffer_ring_strip)/sizeof(uint32_t) ) != HAL_OK )
+ {
+ // TODO: Write a handler to indicate the DMA start request failed...
+ }
+ while( DMA_Transfer_Complete == false );
+ DMA_Transfer_Complete = false;
+ pulse_idx++;
+
+ // Pulse the other strip
+ for ( uint8_t frame_idx = 0; frame_idx < NUM_OF_FRAMES; frame_idx++ )
+ {
+ NeoPixel_PulseStrips_FillBuffer( frame_idx, dma_buffer_pulse_strip, sizeof(dma_buffer_pulse_strip)/sizeof(uint32_t) );
+
+ // Send away to the timer 3
+ if ( HAL_TIM_PWM_Start_DMA( &htim3, TIM_CHANNEL_1, dma_buffer_pulse_strip, sizeof(dma_buffer_pulse_strip)/sizeof(uint32_t) ) != HAL_OK )
+ {
+ // TODO: Write a handler to indicate the DMA start request failed...
+ }
+ while( DMA_Transfer_Complete == false );
+ DMA_Transfer_Complete = false;
+
+ HAL_Delay(15); // REDO COMMENT: 1s / 30 frames ~ 33.333ms, and it takes about 30us x 60 LEDs x 2 strips = 3.6ms to update the strips, so 33.333ms - 3.600ms = 29.733ms ~ 30ms
+ }
+
+ // Go to next brightness level with the ring strip
+ NeoPixel_RingStrip_FillBuffer( (enum RingBrightness_E) pulse_idx, dma_buffer_ring_strip, sizeof(dma_buffer_ring_strip)/sizeof(uint32_t) );
+ if ( HAL_TIM_PWM_Start_DMA( &htim4, TIM_CHANNEL_1, dma_buffer_ring_strip, sizeof(dma_buffer_ring_strip)/sizeof(uint32_t) ) != HAL_OK )
+ {
+ // TODO: Write a handler to indicate the DMA start request failed...
+ }
+ while( DMA_Transfer_Complete == false );
+ DMA_Transfer_Complete = false;
+
+ }
+
+ AnimationComplete = true;
+ }
+
+ else
+ {
+ // Do nothing. Hold at last animation frame!
+ // TODO: Pulse the ring?
+ }
+
+ break;
+
+ case VICTORY_ANIMATION:
+
+ // Process button press, if applicable
+ if ( ButtonPressed == true )
+ {
+
+ AnimationComplete = false;
+ LEDStateMapState = IDLE_ANIMATION; // Next loop will transition to next state
+ ButtonPressed = false;
+ HAL_Delay( DEBOUNCE_WAIT_TIME ); // TODO: Handle debounces without a delay...
+
+ // For debug purposes, drive one of the board LEDs to indicate state
+ HAL_GPIO_WritePin( LED_OPTIONS_TABLE[LED_Idx].port, LED_OPTIONS_TABLE[LED_Idx].pin, GPIO_PIN_RESET );
+ LED_Idx++;
+ // Wrap-around if past table bounds
+ if ( LED_Idx >= (sizeof(LED_OPTIONS_TABLE) / sizeof(struct GPIO_Port_Pin_S)) )
+ {
+ LED_Idx = 0;
+ }
+ HAL_GPIO_WritePin( LED_OPTIONS_TABLE[LED_Idx].port, LED_OPTIONS_TABLE[LED_Idx].pin, GPIO_PIN_SET );
+
+ }
+
+ break;
+
+ }
+
}
/* USER CODE END 3 */
}
@@ -168,20 +404,10 @@ void SystemClock_Config(void)
/** Initializes the RCC Oscillators according to the specified parameters
* in the RCC_OscInitTypeDef structure.
*/
- RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_HSE;
- RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS;
+ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
RCC_OscInitStruct.HSIState = RCC_HSI_DIV1;
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
- RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
- RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
- RCC_OscInitStruct.PLL.PLLM = 1;
- RCC_OscInitStruct.PLL.PLLN = 24;
- RCC_OscInitStruct.PLL.PLLP = 2;
- RCC_OscInitStruct.PLL.PLLQ = 4;
- RCC_OscInitStruct.PLL.PLLR = 2;
- RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_3;
- RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOWIDE;
- RCC_OscInitStruct.PLL.PLLFRACN = 0;
+ RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
@@ -206,55 +432,6 @@ void SystemClock_Config(void)
}
}
-/**
- * @brief ETH Initialization Function
- * @param None
- * @retval None
- */
-static void MX_ETH_Init(void)
-{
-
- /* USER CODE BEGIN ETH_Init 0 */
-
- /* USER CODE END ETH_Init 0 */
-
- static uint8_t MACAddr[6];
-
- /* USER CODE BEGIN ETH_Init 1 */
-
- /* USER CODE END ETH_Init 1 */
- heth.Instance = ETH;
- MACAddr[0] = 0x00;
- MACAddr[1] = 0x80;
- MACAddr[2] = 0xE1;
- MACAddr[3] = 0x00;
- MACAddr[4] = 0x00;
- MACAddr[5] = 0x00;
- heth.Init.MACAddr = &MACAddr[0];
- heth.Init.MediaInterface = HAL_ETH_RMII_MODE;
- heth.Init.TxDesc = DMATxDscrTab;
- heth.Init.RxDesc = DMARxDscrTab;
- heth.Init.RxBuffLen = 1524;
-
- /* USER CODE BEGIN MACADDRESS */
-
- /* USER CODE END MACADDRESS */
-
- if (HAL_ETH_Init(&heth) != HAL_OK)
- {
- Error_Handler();
- }
-
- memset(&TxConfig, 0 , sizeof(ETH_TxPacketConfig));
- TxConfig.Attributes = ETH_TX_PACKETS_FEATURES_CSUM | ETH_TX_PACKETS_FEATURES_CRCPAD;
- TxConfig.ChecksumCtrl = ETH_CHECKSUM_IPHDR_PAYLOAD_INSERT_PHDR_CALC;
- TxConfig.CRCPadCtrl = ETH_CRC_PAD_INSERT;
- /* USER CODE BEGIN ETH_Init 2 */
-
- /* USER CODE END ETH_Init 2 */
-
-}
-
/**
* @brief TIM2 Initialization Function
* @param None
@@ -336,7 +513,7 @@ static void MX_TIM3_Init(void)
htim3.Instance = TIM3;
htim3.Init.Prescaler = 0;
htim3.Init.CounterMode = TIM_COUNTERMODE_UP;
- htim3.Init.Period = 80;
+ htim3.Init.Period = 80-1;
htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
if (HAL_TIM_Base_Init(&htim3) != HAL_OK)
@@ -395,7 +572,7 @@ static void MX_TIM4_Init(void)
htim4.Instance = TIM4;
htim4.Init.Prescaler = 0;
htim4.Init.CounterMode = TIM_COUNTERMODE_UP;
- htim4.Init.Period = 80;
+ htim4.Init.Period = 80-1;
htim4.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim4.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
if (HAL_TIM_Base_Init(&htim4) != HAL_OK)
@@ -480,42 +657,6 @@ static void MX_USART3_UART_Init(void)
}
-/**
- * @brief USB_OTG_FS Initialization Function
- * @param None
- * @retval None
- */
-static void MX_USB_OTG_FS_PCD_Init(void)
-{
-
- /* USER CODE BEGIN USB_OTG_FS_Init 0 */
-
- /* USER CODE END USB_OTG_FS_Init 0 */
-
- /* USER CODE BEGIN USB_OTG_FS_Init 1 */
-
- /* USER CODE END USB_OTG_FS_Init 1 */
- hpcd_USB_OTG_FS.Instance = USB_OTG_FS;
- hpcd_USB_OTG_FS.Init.dev_endpoints = 9;
- hpcd_USB_OTG_FS.Init.speed = PCD_SPEED_FULL;
- hpcd_USB_OTG_FS.Init.dma_enable = DISABLE;
- hpcd_USB_OTG_FS.Init.phy_itface = PCD_PHY_EMBEDDED;
- hpcd_USB_OTG_FS.Init.Sof_enable = ENABLE;
- hpcd_USB_OTG_FS.Init.low_power_enable = DISABLE;
- hpcd_USB_OTG_FS.Init.lpm_enable = DISABLE;
- hpcd_USB_OTG_FS.Init.battery_charging_enable = ENABLE;
- hpcd_USB_OTG_FS.Init.vbus_sensing_enable = ENABLE;
- hpcd_USB_OTG_FS.Init.use_dedicated_ep1 = DISABLE;
- if (HAL_PCD_Init(&hpcd_USB_OTG_FS) != HAL_OK)
- {
- Error_Handler();
- }
- /* USER CODE BEGIN USB_OTG_FS_Init 2 */
-
- /* USER CODE END USB_OTG_FS_Init 2 */
-
-}
-
/**
* Enable DMA controller clock
*/
@@ -569,10 +710,26 @@ static void MX_GPIO_Init(void)
/*Configure GPIO pin : B1_Pin */
GPIO_InitStruct.Pin = B1_Pin;
- GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
+ GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(B1_GPIO_Port, &GPIO_InitStruct);
+ /*Configure GPIO pins : PC1 PC4 PC5 */
+ GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
+ GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
+ HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
+
+ /*Configure GPIO pins : PA1 PA2 PA7 */
+ GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_7;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
+ GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
+ HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+
/*Configure GPIO pins : LD1_Pin LD3_Pin */
GPIO_InitStruct.Pin = LD1_Pin|LD3_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
@@ -580,6 +737,14 @@ static void MX_GPIO_Init(void)
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
+ /*Configure GPIO pin : PB13 */
+ GPIO_InitStruct.Pin = GPIO_PIN_13;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
+ GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
+ HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
+
/*Configure GPIO pin : USB_OTG_FS_PWR_EN_Pin */
GPIO_InitStruct.Pin = USB_OTG_FS_PWR_EN_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
@@ -593,6 +758,22 @@ static void MX_GPIO_Init(void)
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(USB_OTG_FS_OVCR_GPIO_Port, &GPIO_InitStruct);
+ /*Configure GPIO pins : PA8 PA11 PA12 */
+ GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_11|GPIO_PIN_12;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
+ GPIO_InitStruct.Alternate = GPIO_AF10_OTG1_FS;
+ HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+
+ /*Configure GPIO pins : PG11 PG13 */
+ GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_13;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
+ GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
+ HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
+
/*Configure GPIO pin : LD2_Pin */
GPIO_InitStruct.Pin = LD2_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
@@ -600,6 +781,10 @@ static void MX_GPIO_Init(void)
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(LD2_GPIO_Port, &GPIO_InitStruct);
+ /* EXTI interrupt init*/
+ HAL_NVIC_SetPriority(EXTI15_10_IRQn, 0, 0);
+ HAL_NVIC_EnableIRQ(EXTI15_10_IRQn);
+
/* USER CODE BEGIN MX_GPIO_Init_2 */
/* USER CODE END MX_GPIO_Init_2 */
}
diff --git a/Core/Src/neopixel.c b/Core/Src/neopixel.c
new file mode 100644
index 0000000..0bb6d82
--- /dev/null
+++ b/Core/Src/neopixel.c
@@ -0,0 +1,2388 @@
+/**
+ ******************************************************************************
+ * @file : neopixel.c
+ * @brief : Function and table definitions for driving the NeoPixels.
+ ******************************************************************************
+ * @attention
+ *
+ * Copyright (c) 2023 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.
+ *
+ ******************************************************************************
+ */
+
+/* Includes ------------------------------------------------------------------*/
+#include "neopixel.h"
+#include
+
+
+/* Private typedef -----------------------------------------------------------*/
+
+
+
+/* Private define ------------------------------------------------------------*/
+
+
+
+/* Private macro -------------------------------------------------------------*/
+
+
+
+/* Public variables ---------------------------------------------------------*/
+const struct LED_Strip_Frame_S LED_ANIMATION_TABLE[NUM_OF_FRAMES] =
+{
+ {
+ .LEDs =
+ { // 0
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 }
+ },
+ },
+
+ {
+ .LEDs =
+ { // 1
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 }
+ },
+ },
+
+ {
+ .LEDs =
+ { // 2
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 }
+ },
+ },
+
+ {
+ .LEDs =
+ { // 3
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 }
+ },
+ },
+
+ {
+ .LEDs =
+ { // 4
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 }
+ },
+ },
+
+ {
+ .LEDs =
+ { // 5
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 }
+ },
+ },
+
+ {
+ .LEDs =
+ { // 6
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 }
+ },
+ },
+
+ {
+ .LEDs =
+ { // 7
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 }
+ },
+ },
+
+ {
+ .LEDs =
+ { // 8
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 }
+ },
+ },
+
+ {
+ .LEDs =
+ { // 9
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 }
+ },
+ },
+
+ {
+ .LEDs =
+ { // 10
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 }
+ },
+ },
+
+ {
+ .LEDs =
+ { // 11
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 }
+ },
+ },
+
+ {
+ .LEDs =
+ { // 12
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 }
+ },
+ },
+
+ {
+ .LEDs =
+ { // 13
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 }
+ },
+ },
+
+ {
+ .LEDs =
+ { // 14
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ },
+ },
+
+ {
+ .LEDs =
+ { // 15
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ },
+ },
+
+ {
+ .LEDs =
+ { // 16
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 }
+ },
+ },
+
+ {
+ .LEDs =
+ { // 17
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ },
+ },
+
+ {
+ .LEDs =
+ { // 18
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 }
+ },
+ },
+
+ {
+ .LEDs =
+ { // 19
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 }
+ },
+ },
+
+ {
+ .LEDs =
+ { // 20
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 }
+ },
+ },
+
+ {
+ .LEDs =
+ { // 21
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 }
+ },
+ },
+
+ {
+ .LEDs =
+ { // 22
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 }
+ },
+ },
+
+ {
+ .LEDs =
+ { // 23
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 }
+ },
+ },
+
+ {
+ .LEDs =
+ { // 24
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 }
+ },
+ },
+
+ {
+ .LEDs =
+ { // 25
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ },
+ },
+
+ {
+ .LEDs =
+ { // 26
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ },
+ },
+
+ {
+ .LEDs =
+ { // 27
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ },
+ },
+
+ {
+ .LEDs =
+ { // 28
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ },
+ },
+
+ {
+ .LEDs =
+ { // 29
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=0, .rgb.red=0, .rgb.blue=0 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ { .rgb.green=255, .rgb.red=255, .rgb.blue=255 },
+ },
+ },
+};
+
+/*----------------------------------------------------------------------------------------------------
+ * Brightness follows the curve:
+ * B[n] = 10 x exp( 0.35985316135159782913639419259305 x n )
+ * an exponential curve which is hopefully
+ * perceived as a linear increase in brightness (a linearly increasing command does not get perceived
+ * as an even, linear increased in brightness).
+------------------------------------------------------------------------------------------------------*/
+const uint32_t LED_BRIGHTNESS_TABLE[NUM_OF_BRIGHTNESS_LEVELS] =
+{
+ 0, // BRIGHTNESS_OFF,
+ 10, // BRIGHTNESS_MIN / LEVEL 1
+ 14, // BRIGHTNESS_LEVEL_2,
+ 21, // BRIGHTNESS_LEVEL_3,
+ 29, // BRIGHTNESS_LEVEL_4,
+ 42, // BRIGHTNESS_LEVEL_5 / MID
+ 60, // BRIGHTNESS_LEVEL_6,
+ 87, // BRIGHTNESS_LEVEL_7,
+ 124, // BRIGHTNESS_LEVEL_8,
+ 178, // BRIGHTNESS_LEVEL_9,
+ 255, // BRIGHTNESS_LEVEL_10 / MAX
+};
+
+/* Private variables ---------------------------------------------------------*/
+
+
+
+/* Private function prototypes -----------------------------------------------*/
+
+
+
+/* Public function definitions -----------------------------------------------*/
+
+/*!*****************************************************************
+* @fn NeoPixel_PulseStrips_FillBuffer
+* @brief Fills the passed in buffer with the right duty cycle data
+* based on the passed-in frame.
+* @param[in] frame uint8_t frame of the animation
+* @param[in] buffer uint32_t * buffer to hold duty cycle data
+* @param[in] length length of passed-in buffer --> NEEDS to be (NUM_OF_PIXELS_IN_RING_STRING * NUM_OF_BITS_PER_PIXEL + 1)
+* @param[in] LED_ANIMATION_TABLE data for each pixel for this frame
+* @return bool - Success (true) or Fail (false)
+*******************************************************************/
+bool NeoPixel_PulseStrips_FillBuffer(uint8_t frame, uint32_t * buffer, uint32_t length)
+{
+ bool retVal = true;
+
+ // Verify input parameters
+ if ( frame > (NUM_OF_FRAMES - 1) ||
+ buffer == NULL ||
+ length != (NUM_OF_PIXELS_IN_PULSE_STRIP * NUM_OF_BITS_PER_PIXEL + 1) )
+ {
+ // TODO: Some assert
+ retVal = false;
+ }
+
+ else
+ {
+ // The last duty cycle will be set to zero to ensure line is off.
+ // TODO: Evaluate the proper way to set the line low (turn off timer? turn off output enable?)
+ buffer[length - 1] = DUTY_CYCLE_0_PCT;
+
+ // Iterate through each pixel's setpoint and populate the PWM duty cycle data accordingly
+ // Remember to send the most-signficant bit of each LED's setpoint _first_.
+ // --> I accomplish this by having the pixel data organized MSB first and looping from MSb to LSb.
+ unsigned int duty_cycle_idx = 0;
+ for ( unsigned int pixel_idx = 0; pixel_idx < NUM_OF_PIXELS_IN_PULSE_STRIP; pixel_idx++ )
+ {
+ for ( int8_t bit_idx = (NUM_OF_BITS_PER_PIXEL - 1); bit_idx >= 0 ; bit_idx-- )
+ {
+ if ( ( (LED_ANIMATION_TABLE[frame].LEDs[pixel_idx].pixel_word >> bit_idx) & 0x00000001u ) > 0 )
+ {
+ buffer[duty_cycle_idx] = DUTY_CYCLE_ONE_ENCODING;
+ }
+ else
+ {
+ buffer[duty_cycle_idx] = DUTY_CYCLE_ZERO_ENCODING;
+ }
+
+ duty_cycle_idx++;
+ }
+ }
+ }
+
+ return retVal;
+}
+
+
+/*!*****************************************************************
+* @fn NeoPixel_RingStrip_FillBuffer
+* @brief Fills the passed in buffer with the right duty cycle data
+* based on the passed-in brightness level.
+* @param[in] brightness enum RingBrightness_E A brightness level, used to index into LED_BRIGHTNESS_TABLE
+* @param[in] buffer uint32_t * buffer to hold duty cycle data
+* @param[in] length length of passed-in buffer --> NEEDS to be (NUM_OF_PIXELS_IN_RING_STRING * NUM_OF_BITS_PER_PIXEL + 1)
+* @param[in] LED_BRIGHTNESS_TABLE data for each pixel for this frame
+* @return bool - Success (true) or Fail (false)
+*******************************************************************/
+bool NeoPixel_RingStrip_FillBuffer(enum RingBrightness_E brightness, uint32_t * buffer, uint32_t length)
+{
+ bool retVal = true;
+
+ // Verify input parameters
+ if ( brightness > (NUM_OF_BRIGHTNESS_LEVELS - 1) ||
+ buffer == NULL ||
+ length != (NUM_OF_PIXELS_IN_RING_STRIP * NUM_OF_BITS_PER_PIXEL + 1) )
+ {
+ // TODO: Some assert
+ retVal = false;
+ }
+
+ else
+ {
+ // The last duty cycle will be set to zero to ensure line is off.
+ // TODO: Evaluate the proper way to set the line low (turn off timer? turn off output enable?)
+ buffer[length - 1] = DUTY_CYCLE_0_PCT;
+
+ uint8_t brightness_level = LED_BRIGHTNESS_TABLE[brightness];
+ uint32_t brightness_rgb = (brightness_level << 16) | (brightness_level << 8) | brightness_level;
+ // Iterate through each pixel's setpoint and populate the PWM duty cycle data accordingly
+ // Remember to send the most-signficant bit of each LED's setpoint _first_.
+ // --> I accomplish this by having the pixel data organized MSB first and looping from MSb to LSb.
+ unsigned int duty_cycle_idx = 0;
+ for ( unsigned int pixel_idx = 0; pixel_idx < NUM_OF_PIXELS_IN_RING_STRIP; pixel_idx++ )
+ {
+ for ( int8_t bit_idx = (NUM_OF_BITS_PER_PIXEL - 1); bit_idx >= 0 ; bit_idx-- )
+ {
+ if ( ( (brightness_rgb >> bit_idx) & 0x00000001u ) > 0 )
+ {
+ buffer[duty_cycle_idx] = DUTY_CYCLE_ONE_ENCODING;
+ }
+ else
+ {
+ buffer[duty_cycle_idx] = DUTY_CYCLE_ZERO_ENCODING;
+ }
+
+ duty_cycle_idx++;
+ }
+ }
+ }
+
+ return retVal;
+}
+
+
+bool NeoPixel_RingStrip_AllOff_FillBuffer(uint32_t * buffer, uint32_t length)
+{
+ bool retVal = true;
+
+ // Verify input parameters
+ if ( buffer == NULL ||
+ length != (NUM_OF_PIXELS_IN_RING_STRIP * NUM_OF_BITS_PER_PIXEL + 1) )
+ {
+ // TODO: Some assert
+ retVal = false;
+ }
+
+ else
+ {
+ // The last duty cycle will be set to zero to ensure line is off.
+ // TODO: Evaluate the proper way to set the line low (turn off timer? turn off output enable?)
+ buffer[length - 1] = DUTY_CYCLE_0_PCT;
+
+ // Iterate through each pixel's setpoint and populate the PWM duty cycle data accordingly
+ // Remember to send the most-signficant bit of each LED's setpoint _first_.
+ // --> I accomplish this by having the pixel data organized MSB first and looping from MSb to LSb.
+ unsigned int duty_cycle_idx = 0;
+ for ( unsigned int pixel_idx = 0; pixel_idx < NUM_OF_PIXELS_IN_RING_STRIP; pixel_idx++ )
+ {
+ for ( int8_t bit_idx = (NUM_OF_BITS_PER_PIXEL - 1); bit_idx >= 0 ; bit_idx-- )
+ {
+ buffer[duty_cycle_idx] = DUTY_CYCLE_ZERO_ENCODING;
+ duty_cycle_idx++;
+ }
+ }
+
+ }
+
+ return retVal;
+}
+
+
+bool NeoPixel_PulseStrips_AllOff_FillBuffer(uint32_t * buffer, uint32_t length)
+{
+ bool retVal = true;
+
+ // Verify input parameters
+ if ( buffer == NULL ||
+ length != (NUM_OF_PIXELS_IN_PULSE_STRIP * NUM_OF_BITS_PER_PIXEL + 1) )
+ {
+ // TODO: Some assert
+ retVal = false;
+ }
+
+ else
+ {
+ // The last duty cycle will be set to zero to ensure line is off.
+ // TODO: Evaluate the proper way to set the line low (turn off timer? turn off output enable?)
+ buffer[length - 1] = DUTY_CYCLE_0_PCT;
+
+ // Iterate through each pixel's setpoint and populate the PWM duty cycle data accordingly
+ // Remember to send the most-signficant bit of each LED's setpoint _first_.
+ // --> I accomplish this by having the pixel data organized MSB first and looping from MSb to LSb.
+ unsigned int duty_cycle_idx = 0;
+ for ( unsigned int pixel_idx = 0; pixel_idx < NUM_OF_PIXELS_IN_PULSE_STRIP; pixel_idx++ )
+ {
+ for ( int8_t bit_idx = (NUM_OF_BITS_PER_PIXEL - 1); bit_idx >= 0 ; bit_idx-- )
+ {
+ buffer[duty_cycle_idx] = DUTY_CYCLE_ZERO_ENCODING;
+ duty_cycle_idx++;
+ }
+ }
+
+ }
+
+ return retVal;
+}
+
+
+
+
+/* Private function definitions ----------------------------------------------*/
+
diff --git a/Core/Src/stm32h7xx_hal_msp.c b/Core/Src/stm32h7xx_hal_msp.c
index aa5d10f..090e21b 100644
--- a/Core/Src/stm32h7xx_hal_msp.c
+++ b/Core/Src/stm32h7xx_hal_msp.c
@@ -83,119 +83,6 @@ void HAL_MspInit(void)
/* USER CODE END MspInit 1 */
}
-/**
-* @brief ETH MSP Initialization
-* This function configures the hardware resources used in this example
-* @param heth: ETH handle pointer
-* @retval None
-*/
-void HAL_ETH_MspInit(ETH_HandleTypeDef* heth)
-{
- GPIO_InitTypeDef GPIO_InitStruct = {0};
- if(heth->Instance==ETH)
- {
- /* USER CODE BEGIN ETH_MspInit 0 */
-
- /* USER CODE END ETH_MspInit 0 */
- /* Peripheral clock enable */
- __HAL_RCC_ETH1MAC_CLK_ENABLE();
- __HAL_RCC_ETH1TX_CLK_ENABLE();
- __HAL_RCC_ETH1RX_CLK_ENABLE();
-
- __HAL_RCC_GPIOC_CLK_ENABLE();
- __HAL_RCC_GPIOA_CLK_ENABLE();
- __HAL_RCC_GPIOB_CLK_ENABLE();
- __HAL_RCC_GPIOG_CLK_ENABLE();
- /**ETH GPIO Configuration
- PC1 ------> ETH_MDC
- PA1 ------> ETH_REF_CLK
- PA2 ------> ETH_MDIO
- PA7 ------> ETH_CRS_DV
- PC4 ------> ETH_RXD0
- PC5 ------> ETH_RXD1
- PB13 ------> ETH_TXD1
- PG11 ------> ETH_TX_EN
- PG13 ------> ETH_TXD0
- */
- GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5;
- GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
- GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
- HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
-
- GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_7;
- GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
- GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
- HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
-
- GPIO_InitStruct.Pin = GPIO_PIN_13;
- GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
- GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
- HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
-
- GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_13;
- GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
- GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
- HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
-
- /* USER CODE BEGIN ETH_MspInit 1 */
-
- /* USER CODE END ETH_MspInit 1 */
- }
-
-}
-
-/**
-* @brief ETH MSP De-Initialization
-* This function freeze the hardware resources used in this example
-* @param heth: ETH handle pointer
-* @retval None
-*/
-void HAL_ETH_MspDeInit(ETH_HandleTypeDef* heth)
-{
- if(heth->Instance==ETH)
- {
- /* USER CODE BEGIN ETH_MspDeInit 0 */
-
- /* USER CODE END ETH_MspDeInit 0 */
- /* Peripheral clock disable */
- __HAL_RCC_ETH1MAC_CLK_DISABLE();
- __HAL_RCC_ETH1TX_CLK_DISABLE();
- __HAL_RCC_ETH1RX_CLK_DISABLE();
-
- /**ETH GPIO Configuration
- PC1 ------> ETH_MDC
- PA1 ------> ETH_REF_CLK
- PA2 ------> ETH_MDIO
- PA7 ------> ETH_CRS_DV
- PC4 ------> ETH_RXD0
- PC5 ------> ETH_RXD1
- PB13 ------> ETH_TXD1
- PG11 ------> ETH_TX_EN
- PG13 ------> ETH_TXD0
- */
- HAL_GPIO_DeInit(GPIOC, GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5);
-
- HAL_GPIO_DeInit(GPIOA, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_7);
-
- HAL_GPIO_DeInit(GPIOB, GPIO_PIN_13);
-
- HAL_GPIO_DeInit(GPIOG, GPIO_PIN_11|GPIO_PIN_13);
-
- /* USER CODE BEGIN ETH_MspDeInit 1 */
-
- /* USER CODE END ETH_MspDeInit 1 */
- }
-
-}
-
/**
* @brief TIM_Base MSP Initialization
* This function configures the hardware resources used in this example
@@ -219,10 +106,10 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)
hdma_tim2_ch1.Init.Direction = DMA_MEMORY_TO_PERIPH;
hdma_tim2_ch1.Init.PeriphInc = DMA_PINC_DISABLE;
hdma_tim2_ch1.Init.MemInc = DMA_MINC_ENABLE;
- hdma_tim2_ch1.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;
- hdma_tim2_ch1.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD;
+ hdma_tim2_ch1.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;
+ hdma_tim2_ch1.Init.MemDataAlignment = DMA_MDATAALIGN_WORD;
hdma_tim2_ch1.Init.Mode = DMA_NORMAL;
- hdma_tim2_ch1.Init.Priority = DMA_PRIORITY_LOW;
+ hdma_tim2_ch1.Init.Priority = DMA_PRIORITY_VERY_HIGH;
hdma_tim2_ch1.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
if (HAL_DMA_Init(&hdma_tim2_ch1) != HAL_OK)
{
@@ -250,10 +137,10 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)
hdma_tim3_ch1.Init.Direction = DMA_MEMORY_TO_PERIPH;
hdma_tim3_ch1.Init.PeriphInc = DMA_PINC_DISABLE;
hdma_tim3_ch1.Init.MemInc = DMA_MINC_ENABLE;
- hdma_tim3_ch1.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;
- hdma_tim3_ch1.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD;
+ hdma_tim3_ch1.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;
+ hdma_tim3_ch1.Init.MemDataAlignment = DMA_MDATAALIGN_WORD;
hdma_tim3_ch1.Init.Mode = DMA_NORMAL;
- hdma_tim3_ch1.Init.Priority = DMA_PRIORITY_LOW;
+ hdma_tim3_ch1.Init.Priority = DMA_PRIORITY_VERY_HIGH;
hdma_tim3_ch1.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
if (HAL_DMA_Init(&hdma_tim3_ch1) != HAL_OK)
{
@@ -281,10 +168,10 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)
hdma_tim4_ch1.Init.Direction = DMA_MEMORY_TO_PERIPH;
hdma_tim4_ch1.Init.PeriphInc = DMA_PINC_DISABLE;
hdma_tim4_ch1.Init.MemInc = DMA_MINC_ENABLE;
- hdma_tim4_ch1.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;
- hdma_tim4_ch1.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD;
+ hdma_tim4_ch1.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;
+ hdma_tim4_ch1.Init.MemDataAlignment = DMA_MDATAALIGN_WORD;
hdma_tim4_ch1.Init.Mode = DMA_NORMAL;
- hdma_tim4_ch1.Init.Priority = DMA_PRIORITY_LOW;
+ hdma_tim4_ch1.Init.Priority = DMA_PRIORITY_VERY_HIGH;
hdma_tim4_ch1.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
if (HAL_DMA_Init(&hdma_tim4_ch1) != HAL_OK)
{
@@ -496,94 +383,6 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
}
-/**
-* @brief PCD MSP Initialization
-* This function configures the hardware resources used in this example
-* @param hpcd: PCD handle pointer
-* @retval None
-*/
-void HAL_PCD_MspInit(PCD_HandleTypeDef* hpcd)
-{
- GPIO_InitTypeDef GPIO_InitStruct = {0};
- RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
- if(hpcd->Instance==USB_OTG_FS)
- {
- /* USER CODE BEGIN USB_OTG_FS_MspInit 0 */
-
- /* USER CODE END USB_OTG_FS_MspInit 0 */
-
- /** Initializes the peripherals clock
- */
- PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB;
- PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_PLL;
- if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
- {
- Error_Handler();
- }
-
- /** Enable USB Voltage detector
- */
- HAL_PWREx_EnableUSBVoltageDetector();
-
- __HAL_RCC_GPIOA_CLK_ENABLE();
- /**USB_OTG_FS GPIO Configuration
- PA8 ------> USB_OTG_FS_SOF
- PA9 ------> USB_OTG_FS_VBUS
- PA11 ------> USB_OTG_FS_DM
- PA12 ------> USB_OTG_FS_DP
- */
- GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_11|GPIO_PIN_12;
- GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
- GPIO_InitStruct.Alternate = GPIO_AF10_OTG1_FS;
- HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
-
- GPIO_InitStruct.Pin = GPIO_PIN_9;
- GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
-
- /* Peripheral clock enable */
- __HAL_RCC_USB_OTG_FS_CLK_ENABLE();
- /* USER CODE BEGIN USB_OTG_FS_MspInit 1 */
-
- /* USER CODE END USB_OTG_FS_MspInit 1 */
- }
-
-}
-
-/**
-* @brief PCD MSP De-Initialization
-* This function freeze the hardware resources used in this example
-* @param hpcd: PCD handle pointer
-* @retval None
-*/
-void HAL_PCD_MspDeInit(PCD_HandleTypeDef* hpcd)
-{
- if(hpcd->Instance==USB_OTG_FS)
- {
- /* USER CODE BEGIN USB_OTG_FS_MspDeInit 0 */
-
- /* USER CODE END USB_OTG_FS_MspDeInit 0 */
- /* Peripheral clock disable */
- __HAL_RCC_USB_OTG_FS_CLK_DISABLE();
-
- /**USB_OTG_FS GPIO Configuration
- PA8 ------> USB_OTG_FS_SOF
- PA9 ------> USB_OTG_FS_VBUS
- PA11 ------> USB_OTG_FS_DM
- PA12 ------> USB_OTG_FS_DP
- */
- HAL_GPIO_DeInit(GPIOA, GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_11|GPIO_PIN_12);
-
- /* USER CODE BEGIN USB_OTG_FS_MspDeInit 1 */
-
- /* USER CODE END USB_OTG_FS_MspDeInit 1 */
- }
-
-}
-
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
diff --git a/Core/Src/stm32h7xx_it.c b/Core/Src/stm32h7xx_it.c
index 7ab79f0..e043910 100644
--- a/Core/Src/stm32h7xx_it.c
+++ b/Core/Src/stm32h7xx_it.c
@@ -242,6 +242,20 @@ void DMA1_Stream2_IRQHandler(void)
/* USER CODE END DMA1_Stream2_IRQn 1 */
}
+/**
+ * @brief This function handles EXTI line[15:10] interrupts.
+ */
+void EXTI15_10_IRQHandler(void)
+{
+ /* USER CODE BEGIN EXTI15_10_IRQn 0 */
+
+ /* USER CODE END EXTI15_10_IRQn 0 */
+ HAL_GPIO_EXTI_IRQHandler(B1_Pin);
+ /* USER CODE BEGIN EXTI15_10_IRQn 1 */
+
+ /* USER CODE END EXTI15_10_IRQn 1 */
+}
+
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
diff --git a/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_eth.h b/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_eth.h
deleted file mode 100644
index 0a14686..0000000
--- a/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_eth.h
+++ /dev/null
@@ -1,1855 +0,0 @@
-/**
- ******************************************************************************
- * @file stm32h7xx_hal_eth.h
- * @author MCD Application Team
- * @brief Header file of ETH HAL module.
- ******************************************************************************
- * @attention
- *
- * Copyright (c) 2017 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.
- *
- ******************************************************************************
- */
-
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef STM32H7xx_HAL_ETH_H
-#define STM32H7xx_HAL_ETH_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32h7xx_hal_def.h"
-
-#if defined(ETH)
-
-/** @addtogroup STM32H7xx_HAL_Driver
- * @{
- */
-
-/** @addtogroup ETH
- * @{
- */
-
-/* Exported types ------------------------------------------------------------*/
-#ifndef ETH_TX_DESC_CNT
-#define ETH_TX_DESC_CNT 4U
-#endif /* ETH_TX_DESC_CNT */
-
-#ifndef ETH_RX_DESC_CNT
-#define ETH_RX_DESC_CNT 4U
-#endif /* ETH_RX_DESC_CNT */
-
-#ifndef ETH_SWRESET_TIMEOUT
-#define ETH_SWRESET_TIMEOUT 500U
-#endif /* ETH_SWRESET_TIMEOUT */
-
-#ifndef ETH_MDIO_BUS_TIMEOUT
-#define ETH_MDIO_BUS_TIMEOUT 1000U
-#endif /* ETH_MDIO_BUS_TIMEOUT */
-
-#ifndef ETH_MAC_US_TICK
-#define ETH_MAC_US_TICK 1000000U
-#endif /* ETH_MAC_US_TICK */
-
-/*********************** Descriptors struct def section ************************/
-/** @defgroup ETH_Exported_Types ETH Exported Types
- * @{
- */
-
-/**
- * @brief ETH DMA Descriptor structure definition
- */
-typedef struct
-{
- __IO uint32_t DESC0;
- __IO uint32_t DESC1;
- __IO uint32_t DESC2;
- __IO uint32_t DESC3;
- uint32_t BackupAddr0; /* used to store rx buffer 1 address */
- uint32_t BackupAddr1; /* used to store rx buffer 2 address */
-} ETH_DMADescTypeDef;
-/**
- *
- */
-
-/**
- * @brief ETH Buffers List structure definition
- */
-typedef struct __ETH_BufferTypeDef
-{
- uint8_t *buffer; /*gState = HAL_ETH_STATE_RESET; \
- (__HANDLE__)->MspInitCallback = NULL; \
- (__HANDLE__)->MspDeInitCallback = NULL; \
- } while(0)
-#else
-#define __HAL_ETH_RESET_HANDLE_STATE(__HANDLE__) do{ \
- (__HANDLE__)->gState = HAL_ETH_STATE_RESET; \
- } while(0)
-#endif /*USE_HAL_ETH_REGISTER_CALLBACKS */
-
-/**
- * @brief Enables the specified ETHERNET DMA interrupts.
- * @param __HANDLE__ : ETH Handle
- * @param __INTERRUPT__: specifies the ETHERNET DMA interrupt sources to be
- * enabled @ref ETH_DMA_Interrupts
- * @retval None
- */
-#define __HAL_ETH_DMA_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->DMACIER |= (__INTERRUPT__))
-
-/**
- * @brief Disables the specified ETHERNET DMA interrupts.
- * @param __HANDLE__ : ETH Handle
- * @param __INTERRUPT__: specifies the ETHERNET DMA interrupt sources to be
- * disabled. @ref ETH_DMA_Interrupts
- * @retval None
- */
-#define __HAL_ETH_DMA_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->DMACIER &= ~(__INTERRUPT__))
-
-/**
- * @brief Gets the ETHERNET DMA IT source enabled or disabled.
- * @param __HANDLE__ : ETH Handle
- * @param __INTERRUPT__: specifies the interrupt source to get . @ref ETH_DMA_Interrupts
- * @retval The ETH DMA IT Source enabled or disabled
- */
-#define __HAL_ETH_DMA_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) \
- (((__HANDLE__)->Instance->DMACIER & (__INTERRUPT__)) == (__INTERRUPT__))
-
-/**
- * @brief Gets the ETHERNET DMA IT pending bit.
- * @param __HANDLE__ : ETH Handle
- * @param __INTERRUPT__: specifies the interrupt source to get . @ref ETH_DMA_Interrupts
- * @retval The state of ETH DMA IT (SET or RESET)
- */
-#define __HAL_ETH_DMA_GET_IT(__HANDLE__, __INTERRUPT__) \
- (((__HANDLE__)->Instance->DMACSR & (__INTERRUPT__)) == (__INTERRUPT__))
-
-/**
- * @brief Clears the ETHERNET DMA IT pending bit.
- * @param __HANDLE__ : ETH Handle
- * @param __INTERRUPT__: specifies the interrupt pending bit to clear. @ref ETH_DMA_Interrupts
- * @retval None
- */
-#define __HAL_ETH_DMA_CLEAR_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->DMACSR = (__INTERRUPT__))
-
-/**
- * @brief Checks whether the specified ETHERNET DMA flag is set or not.
- * @param __HANDLE__: ETH Handle
- * @param __FLAG__: specifies the flag to check. @ref ETH_DMA_Status_Flags
- * @retval The state of ETH DMA FLAG (SET or RESET).
- */
-#define __HAL_ETH_DMA_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->DMACSR &( __FLAG__)) == ( __FLAG__))
-
-/**
- * @brief Clears the specified ETHERNET DMA flag.
- * @param __HANDLE__: ETH Handle
- * @param __FLAG__: specifies the flag to check. @ref ETH_DMA_Status_Flags
- * @retval The state of ETH DMA FLAG (SET or RESET).
- */
-#define __HAL_ETH_DMA_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->DMACSR = ( __FLAG__))
-
-/**
- * @brief Enables the specified ETHERNET MAC interrupts.
- * @param __HANDLE__ : ETH Handle
- * @param __INTERRUPT__: specifies the ETHERNET MAC interrupt sources to be
- * enabled @ref ETH_MAC_Interrupts
- * @retval None
- */
-#define __HAL_ETH_MAC_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->MACIER |= (__INTERRUPT__))
-
-/**
- * @brief Disables the specified ETHERNET MAC interrupts.
- * @param __HANDLE__ : ETH Handle
- * @param __INTERRUPT__: specifies the ETHERNET MAC interrupt sources to be
- * enabled @ref ETH_MAC_Interrupts
- * @retval None
- */
-#define __HAL_ETH_MAC_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->MACIER &= ~(__INTERRUPT__))
-
-/**
- * @brief Checks whether the specified ETHERNET MAC flag is set or not.
- * @param __HANDLE__: ETH Handle
- * @param __INTERRUPT__: specifies the flag to check. @ref ETH_MAC_Interrupts
- * @retval The state of ETH MAC IT (SET or RESET).
- */
-#define __HAL_ETH_MAC_GET_IT(__HANDLE__, __INTERRUPT__) \
- (((__HANDLE__)->Instance->MACISR &( __INTERRUPT__)) == ( __INTERRUPT__))
-
-/*!< External interrupt line 86 Connected to the ETH wakeup EXTI Line */
-#define ETH_WAKEUP_EXTI_LINE 0x00400000U /* !< 86 - 64 = 22 */
-
-/**
- * @brief Enable the ETH WAKEUP Exti Line.
- * @param __EXTI_LINE__: specifies the ETH WAKEUP Exti sources to be enabled.
- * @arg ETH_WAKEUP_EXTI_LINE
- * @retval None.
- */
-#define __HAL_ETH_WAKEUP_EXTI_ENABLE_IT(__EXTI_LINE__) (EXTI_D1->IMR3 |= (__EXTI_LINE__))
-
-/**
- * @brief checks whether the specified ETH WAKEUP Exti interrupt flag is set or not.
- * @param __EXTI_LINE__: specifies the ETH WAKEUP Exti sources to be cleared.
- * @arg ETH_WAKEUP_EXTI_LINE
- * @retval EXTI ETH WAKEUP Line Status.
- */
-#define __HAL_ETH_WAKEUP_EXTI_GET_FLAG(__EXTI_LINE__) (EXTI_D1->PR3 & (__EXTI_LINE__))
-
-/**
- * @brief Clear the ETH WAKEUP Exti flag.
- * @param __EXTI_LINE__: specifies the ETH WAKEUP Exti sources to be cleared.
- * @arg ETH_WAKEUP_EXTI_LINE
- * @retval None.
- */
-#define __HAL_ETH_WAKEUP_EXTI_CLEAR_FLAG(__EXTI_LINE__) (EXTI_D1->PR3 = (__EXTI_LINE__))
-
-#if defined(DUAL_CORE)
-/**
- * @brief Enable the ETH WAKEUP Exti Line by Core2.
- * @param __EXTI_LINE__: specifies the ETH WAKEUP Exti sources to be enabled.
- * @arg ETH_WAKEUP_EXTI_LINE
- * @retval None.
- */
-#define __HAL_ETH_WAKEUP_EXTID2_ENABLE_IT(__EXTI_LINE__) (EXTI_D2->IMR3 |= (__EXTI_LINE__))
-
-/**
- * @brief checks whether the specified ETH WAKEUP Exti interrupt flag is set or not.
- * @param __EXTI_LINE__: specifies the ETH WAKEUP Exti sources to be cleared.
- * @arg ETH_WAKEUP_EXTI_LINE
- * @retval EXTI ETH WAKEUP Line Status.
- */
-#define __HAL_ETH_WAKEUP_EXTID2_GET_FLAG(__EXTI_LINE__) (EXTI_D2->PR3 & (__EXTI_LINE__))
-
-/**
- * @brief Clear the ETH WAKEUP Exti flag.
- * @param __EXTI_LINE__: specifies the ETH WAKEUP Exti sources to be cleared.
- * @arg ETH_WAKEUP_EXTI_LINE
- * @retval None.
- */
-#define __HAL_ETH_WAKEUP_EXTID2_CLEAR_FLAG(__EXTI_LINE__) (EXTI_D2->PR3 = (__EXTI_LINE__))
-#endif /* DUAL_CORE */
-
-/**
- * @brief enable rising edge interrupt on selected EXTI line.
- * @param __EXTI_LINE__: specifies the ETH WAKEUP EXTI sources to be disabled.
- * @arg ETH_WAKEUP_EXTI_LINE
- * @retval None
- */
-#define __HAL_ETH_WAKEUP_EXTI_ENABLE_RISING_EDGE(__EXTI_LINE__) (EXTI->FTSR3 &= ~(__EXTI_LINE__)); \
- (EXTI->RTSR3 |= (__EXTI_LINE__))
-
-/**
- * @brief enable falling edge interrupt on selected EXTI line.
- * @param __EXTI_LINE__: specifies the ETH WAKEUP EXTI sources to be disabled.
- * @arg ETH_WAKEUP_EXTI_LINE
- * @retval None
- */
-#define __HAL_ETH_WAKEUP_EXTI_ENABLE_FALLING_EDGE(__EXTI_LINE__) (EXTI->RTSR3 &= ~(__EXTI_LINE__));\
- (EXTI->FTSR3 |= (__EXTI_LINE__))
-
-/**
- * @brief enable falling edge interrupt on selected EXTI line.
- * @param __EXTI_LINE__: specifies the ETH WAKEUP EXTI sources to be disabled.
- * @arg ETH_WAKEUP_EXTI_LINE
- * @retval None
- */
-#define __HAL_ETH_WAKEUP_EXTI_ENABLE_RISING_FALLING_EDGE(__EXTI_LINE__) (EXTI->RTSR3 |= (__EXTI_LINE__));\
- (EXTI->FTSR3 |= (__EXTI_LINE__))
-
-/**
- * @brief Generates a Software interrupt on selected EXTI line.
- * @param __EXTI_LINE__: specifies the ETH WAKEUP EXTI sources to be disabled.
- * @arg ETH_WAKEUP_EXTI_LINE
- * @retval None
- */
-#define __HAL_ETH_WAKEUP_EXTI_GENERATE_SWIT(__EXTI_LINE__) (EXTI->SWIER3 |= (__EXTI_LINE__))
-
-#define __HAL_ETH_GET_PTP_CONTROL(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->MACTSCR) & \
- (__FLAG__)) == (__FLAG__)) ? SET : RESET)
-
-#define __HAL_ETH_SET_PTP_CONTROL(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->MACTSCR |= (__FLAG__))
-/**
- * @}
- */
-
-/* Include ETH HAL Extension module */
-#include "stm32h7xx_hal_eth_ex.h"
-
-/* Exported functions --------------------------------------------------------*/
-
-/** @addtogroup ETH_Exported_Functions
- * @{
- */
-
-/** @addtogroup ETH_Exported_Functions_Group1
- * @{
- */
-/* Initialization and de initialization functions **********************************/
-HAL_StatusTypeDef HAL_ETH_Init(ETH_HandleTypeDef *heth);
-HAL_StatusTypeDef HAL_ETH_DeInit(ETH_HandleTypeDef *heth);
-void HAL_ETH_MspInit(ETH_HandleTypeDef *heth);
-void HAL_ETH_MspDeInit(ETH_HandleTypeDef *heth);
-
-/* Callbacks Register/UnRegister functions ***********************************/
-#if (USE_HAL_ETH_REGISTER_CALLBACKS == 1)
-HAL_StatusTypeDef HAL_ETH_RegisterCallback(ETH_HandleTypeDef *heth, HAL_ETH_CallbackIDTypeDef CallbackID,
- pETH_CallbackTypeDef pCallback);
-HAL_StatusTypeDef HAL_ETH_UnRegisterCallback(ETH_HandleTypeDef *heth, HAL_ETH_CallbackIDTypeDef CallbackID);
-#endif /* USE_HAL_ETH_REGISTER_CALLBACKS */
-
-/**
- * @}
- */
-
-/** @addtogroup ETH_Exported_Functions_Group2
- * @{
- */
-/* IO operation functions *******************************************************/
-HAL_StatusTypeDef HAL_ETH_Start(ETH_HandleTypeDef *heth);
-HAL_StatusTypeDef HAL_ETH_Start_IT(ETH_HandleTypeDef *heth);
-HAL_StatusTypeDef HAL_ETH_Stop(ETH_HandleTypeDef *heth);
-HAL_StatusTypeDef HAL_ETH_Stop_IT(ETH_HandleTypeDef *heth);
-
-HAL_StatusTypeDef HAL_ETH_ReadData(ETH_HandleTypeDef *heth, void **pAppBuff);
-HAL_StatusTypeDef HAL_ETH_RegisterRxAllocateCallback(ETH_HandleTypeDef *heth,
- pETH_rxAllocateCallbackTypeDef rxAllocateCallback);
-HAL_StatusTypeDef HAL_ETH_UnRegisterRxAllocateCallback(ETH_HandleTypeDef *heth);
-HAL_StatusTypeDef HAL_ETH_RegisterRxLinkCallback(ETH_HandleTypeDef *heth, pETH_rxLinkCallbackTypeDef rxLinkCallback);
-HAL_StatusTypeDef HAL_ETH_UnRegisterRxLinkCallback(ETH_HandleTypeDef *heth);
-HAL_StatusTypeDef HAL_ETH_GetRxDataErrorCode(ETH_HandleTypeDef *heth, uint32_t *pErrorCode);
-HAL_StatusTypeDef HAL_ETH_RegisterTxFreeCallback(ETH_HandleTypeDef *heth, pETH_txFreeCallbackTypeDef txFreeCallback);
-HAL_StatusTypeDef HAL_ETH_UnRegisterTxFreeCallback(ETH_HandleTypeDef *heth);
-HAL_StatusTypeDef HAL_ETH_ReleaseTxPacket(ETH_HandleTypeDef *heth);
-
-#ifdef HAL_ETH_USE_PTP
-HAL_StatusTypeDef HAL_ETH_PTP_SetConfig(ETH_HandleTypeDef *heth, ETH_PTP_ConfigTypeDef *ptpconfig);
-HAL_StatusTypeDef HAL_ETH_PTP_GetConfig(ETH_HandleTypeDef *heth, ETH_PTP_ConfigTypeDef *ptpconfig);
-HAL_StatusTypeDef HAL_ETH_PTP_SetTime(ETH_HandleTypeDef *heth, ETH_TimeTypeDef *time);
-HAL_StatusTypeDef HAL_ETH_PTP_GetTime(ETH_HandleTypeDef *heth, ETH_TimeTypeDef *time);
-HAL_StatusTypeDef HAL_ETH_PTP_AddTimeOffset(ETH_HandleTypeDef *heth, ETH_PtpUpdateTypeDef ptpoffsettype,
- ETH_TimeTypeDef *timeoffset);
-HAL_StatusTypeDef HAL_ETH_PTP_InsertTxTimestamp(ETH_HandleTypeDef *heth);
-HAL_StatusTypeDef HAL_ETH_PTP_GetTxTimestamp(ETH_HandleTypeDef *heth, ETH_TimeStampTypeDef *timestamp);
-HAL_StatusTypeDef HAL_ETH_PTP_GetRxTimestamp(ETH_HandleTypeDef *heth, ETH_TimeStampTypeDef *timestamp);
-HAL_StatusTypeDef HAL_ETH_RegisterTxPtpCallback(ETH_HandleTypeDef *heth, pETH_txPtpCallbackTypeDef txPtpCallback);
-HAL_StatusTypeDef HAL_ETH_UnRegisterTxPtpCallback(ETH_HandleTypeDef *heth);
-#endif /* HAL_ETH_USE_PTP */
-
-HAL_StatusTypeDef HAL_ETH_Transmit(ETH_HandleTypeDef *heth, ETH_TxPacketConfig *pTxConfig, uint32_t Timeout);
-HAL_StatusTypeDef HAL_ETH_Transmit_IT(ETH_HandleTypeDef *heth, ETH_TxPacketConfig *pTxConfig);
-
-HAL_StatusTypeDef HAL_ETH_WritePHYRegister(ETH_HandleTypeDef *heth, uint32_t PHYAddr, uint32_t PHYReg,
- uint32_t RegValue);
-HAL_StatusTypeDef HAL_ETH_ReadPHYRegister(ETH_HandleTypeDef *heth, uint32_t PHYAddr, uint32_t PHYReg,
- uint32_t *pRegValue);
-
-void HAL_ETH_IRQHandler(ETH_HandleTypeDef *heth);
-void HAL_ETH_TxCpltCallback(ETH_HandleTypeDef *heth);
-void HAL_ETH_RxCpltCallback(ETH_HandleTypeDef *heth);
-void HAL_ETH_ErrorCallback(ETH_HandleTypeDef *heth);
-void HAL_ETH_PMTCallback(ETH_HandleTypeDef *heth);
-void HAL_ETH_EEECallback(ETH_HandleTypeDef *heth);
-void HAL_ETH_WakeUpCallback(ETH_HandleTypeDef *heth);
-void HAL_ETH_RxAllocateCallback(uint8_t **buff);
-void HAL_ETH_RxLinkCallback(void **pStart, void **pEnd, uint8_t *buff, uint16_t Length);
-void HAL_ETH_TxFreeCallback(uint32_t *buff);
-void HAL_ETH_TxPtpCallback(uint32_t *buff, ETH_TimeStampTypeDef *timestamp);
-/**
- * @}
- */
-
-/** @addtogroup ETH_Exported_Functions_Group3
- * @{
- */
-/* Peripheral Control functions **********************************************/
-/* MAC & DMA Configuration APIs **********************************************/
-HAL_StatusTypeDef HAL_ETH_GetMACConfig(ETH_HandleTypeDef *heth, ETH_MACConfigTypeDef *macconf);
-HAL_StatusTypeDef HAL_ETH_GetDMAConfig(ETH_HandleTypeDef *heth, ETH_DMAConfigTypeDef *dmaconf);
-HAL_StatusTypeDef HAL_ETH_SetMACConfig(ETH_HandleTypeDef *heth, ETH_MACConfigTypeDef *macconf);
-HAL_StatusTypeDef HAL_ETH_SetDMAConfig(ETH_HandleTypeDef *heth, ETH_DMAConfigTypeDef *dmaconf);
-void HAL_ETH_SetMDIOClockRange(ETH_HandleTypeDef *heth);
-
-/* MAC VLAN Processing APIs ************************************************/
-void HAL_ETH_SetRxVLANIdentifier(ETH_HandleTypeDef *heth, uint32_t ComparisonBits,
- uint32_t VLANIdentifier);
-
-/* MAC L2 Packet Filtering APIs **********************************************/
-HAL_StatusTypeDef HAL_ETH_GetMACFilterConfig(ETH_HandleTypeDef *heth, ETH_MACFilterConfigTypeDef *pFilterConfig);
-HAL_StatusTypeDef HAL_ETH_SetMACFilterConfig(ETH_HandleTypeDef *heth, ETH_MACFilterConfigTypeDef *pFilterConfig);
-HAL_StatusTypeDef HAL_ETH_SetHashTable(ETH_HandleTypeDef *heth, uint32_t *pHashTable);
-HAL_StatusTypeDef HAL_ETH_SetSourceMACAddrMatch(ETH_HandleTypeDef *heth, uint32_t AddrNbr, uint8_t *pMACAddr);
-
-/* MAC Power Down APIs *****************************************************/
-void HAL_ETH_EnterPowerDownMode(ETH_HandleTypeDef *heth, ETH_PowerDownConfigTypeDef *pPowerDownConfig);
-void HAL_ETH_ExitPowerDownMode(ETH_HandleTypeDef *heth);
-HAL_StatusTypeDef HAL_ETH_SetWakeUpFilter(ETH_HandleTypeDef *heth, uint32_t *pFilter, uint32_t Count);
-
-/**
- * @}
- */
-
-/** @addtogroup ETH_Exported_Functions_Group4
- * @{
- */
-/* Peripheral State functions **************************************************/
-HAL_ETH_StateTypeDef HAL_ETH_GetState(ETH_HandleTypeDef *heth);
-uint32_t HAL_ETH_GetError(ETH_HandleTypeDef *heth);
-uint32_t HAL_ETH_GetDMAError(ETH_HandleTypeDef *heth);
-uint32_t HAL_ETH_GetMACError(ETH_HandleTypeDef *heth);
-uint32_t HAL_ETH_GetMACWakeUpSource(ETH_HandleTypeDef *heth);
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-#endif /* ETH */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* STM32H7xx_HAL_ETH_H */
-
-
diff --git a/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_eth_ex.h b/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_eth_ex.h
deleted file mode 100644
index b9580fa..0000000
--- a/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_eth_ex.h
+++ /dev/null
@@ -1,368 +0,0 @@
-/**
- ******************************************************************************
- * @file stm32h7xx_hal_eth_ex.h
- * @author MCD Application Team
- * @brief Header file of ETH HAL Extended module.
- ******************************************************************************
- * @attention
- *
- * Copyright (c) 2017 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.
- *
- ******************************************************************************
- */
-
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef STM32H7xx_HAL_ETH_EX_H
-#define STM32H7xx_HAL_ETH_EX_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if defined(ETH)
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32h7xx_hal_def.h"
-
-/** @addtogroup STM32H7xx_HAL_Driver
- * @{
- */
-
-/** @addtogroup ETHEx
- * @{
- */
-
-/* Exported types ------------------------------------------------------------*/
-/** @defgroup ETHEx_Exported_Types ETHEx Exported Types
- * @{
- */
-
-/**
- * @brief ETH RX VLAN structure definition
- */
-typedef struct
-{
- FunctionalState InnerVLANTagInStatus; /*!< Enables or disables Inner VLAN Tag in Rx Status */
-
- uint32_t StripInnerVLANTag; /*!< Sets the Inner VLAN Tag Stripping on Receive
- This parameter can be a value of
- @ref ETHEx_Rx_Inner_VLAN_Tag_Stripping */
-
- FunctionalState InnerVLANTag; /*!< Enables or disables Inner VLAN Tag */
-
- FunctionalState DoubleVLANProcessing; /*!< Enable or Disable double VLAN processing */
-
- FunctionalState VLANTagHashTableMatch; /*!< Enable or Disable VLAN Tag Hash Table Match */
-
- FunctionalState VLANTagInStatus; /*!< Enable or Disable VLAN Tag in Rx status */
-
- uint32_t StripVLANTag; /*!< Set the VLAN Tag Stripping on Receive
- This parameter can be a value of @ref ETHEx_Rx_VLAN_Tag_Stripping */
-
- uint32_t VLANTypeCheck; /*!< Enable or Disable VLAN Type Check
- This parameter can be a value of @ref ETHEx_VLAN_Type_Check */
-
- FunctionalState VLANTagInverceMatch; /*!< Enable or disable VLAN Tag Inverse Match */
-} ETH_RxVLANConfigTypeDef;
-/**
- *
- */
-
-/**
- * @brief ETH TX VLAN structure definition
- */
-typedef struct
-{
- FunctionalState SourceTxDesc; /*!< Enable or Disable VLAN tag source from DMA tx descriptors */
-
- FunctionalState SVLANType; /*!< Enable or Disable insertion of SVLAN type */
-
- uint32_t VLANTagControl; /*!< Sets the VLAN tag control in tx packets
- This parameter can be a value of @ref ETHEx_VLAN_Tag_Control */
-} ETH_TxVLANConfigTypeDef;
-/**
- *
- */
-
-/**
- * @brief ETH L3 filter structure definition
- */
-typedef struct
-{
- uint32_t Protocol; /*!< Sets the L3 filter protocol to IPv4 or IPv6
- This parameter can be a value of @ref ETHEx_L3_Protocol */
-
- uint32_t SrcAddrFilterMatch; /*!< Sets the L3 filter source address match
- This parameter can be a value of @ref ETHEx_L3_Source_Match */
-
- uint32_t DestAddrFilterMatch; /*!< Sets the L3 filter destination address match
- This parameter can be a value of @ref ETHEx_L3_Destination_Match */
-
- uint32_t SrcAddrHigherBitsMatch; /*!< Sets the L3 filter source address higher bits match
- This parameter can be a value from 0 to 31 */
-
- uint32_t DestAddrHigherBitsMatch; /*!< Sets the L3 filter destination address higher bits match
- This parameter can be a value from 0 to 31 */
-
- uint32_t Ip4SrcAddr; /*!< Sets the L3 filter IPv4 source address if IPv4 protocol is used
- This parameter can be a value from 0x0 to 0xFFFFFFFF */
-
- uint32_t Ip4DestAddr; /*!< Sets the L3 filter IPv4 destination address if IPv4 protocol is used
- This parameter can be a value from 0 to 0xFFFFFFFF */
-
- uint32_t Ip6Addr[4]; /*!< Sets the L3 filter IPv6 address if IPv6 protocol is used
- This parameter must be a table of 4 words (4* 32 bits) */
-} ETH_L3FilterConfigTypeDef;
-/**
- *
- */
-
-/**
- * @brief ETH L4 filter structure definition
- */
-typedef struct
-{
- uint32_t Protocol; /*!< Sets the L4 filter protocol to TCP or UDP
- This parameter can be a value of @ref ETHEx_L4_Protocol */
-
- uint32_t SrcPortFilterMatch; /*!< Sets the L4 filter source port match
- This parameter can be a value of @ref ETHEx_L4_Source_Match */
-
- uint32_t DestPortFilterMatch; /*!< Sets the L4 filter destination port match
- This parameter can be a value of @ref ETHEx_L4_Destination_Match */
-
- uint32_t SourcePort; /*!< Sets the L4 filter source port
- This parameter must be a value from 0x0 to 0xFFFF */
-
- uint32_t DestinationPort; /*!< Sets the L4 filter destination port
- This parameter must be a value from 0x0 to 0xFFFF */
-} ETH_L4FilterConfigTypeDef;
-/**
- *
- */
-
-/**
- * @}
- */
-
-/* Exported constants --------------------------------------------------------*/
-/** @defgroup ETHEx_Exported_Constants ETHEx Exported Constants
- * @{
- */
-
-/** @defgroup ETHEx_LPI_Event ETHEx LPI Event
- * @{
- */
-#define ETH_TX_LPI_ENTRY ETH_MACLCSR_TLPIEN
-#define ETH_TX_LPI_EXIT ETH_MACLCSR_TLPIEX
-#define ETH_RX_LPI_ENTRY ETH_MACLCSR_RLPIEN
-#define ETH_RX_LPI_EXIT ETH_MACLCSR_RLPIEX
-/**
- * @}
- */
-
-/** @defgroup ETHEx_L3_Filter ETHEx L3 Filter
- * @{
- */
-#define ETH_L3_FILTER_0 0x00000000U
-#define ETH_L3_FILTER_1 0x0000000CU
-/**
- * @}
- */
-
-/** @defgroup ETHEx_L4_Filter ETHEx L4 Filter
- * @{
- */
-#define ETH_L4_FILTER_0 0x00000000U
-#define ETH_L4_FILTER_1 0x0000000CU
-/**
- * @}
- */
-
-/** @defgroup ETHEx_L3_Protocol ETHEx L3 Protocol
- * @{
- */
-#define ETH_L3_IPV6_MATCH ETH_MACL3L4CR_L3PEN
-#define ETH_L3_IPV4_MATCH 0x00000000U
-/**
- * @}
- */
-
-/** @defgroup ETHEx_L3_Source_Match ETHEx L3 Source Match
- * @{
- */
-#define ETH_L3_SRC_ADDR_PERFECT_MATCH_ENABLE ETH_MACL3L4CR_L3SAM
-#define ETH_L3_SRC_ADDR_INVERSE_MATCH_ENABLE (ETH_MACL3L4CR_L3SAM | ETH_MACL3L4CR_L3SAIM)
-#define ETH_L3_SRC_ADDR_MATCH_DISABLE 0x00000000U
-/**
- * @}
- */
-
-/** @defgroup ETHEx_L3_Destination_Match ETHEx L3 Destination Match
- * @{
- */
-#define ETH_L3_DEST_ADDR_PERFECT_MATCH_ENABLE ETH_MACL3L4CR_L3DAM
-#define ETH_L3_DEST_ADDR_INVERSE_MATCH_ENABLE (ETH_MACL3L4CR_L3DAM | ETH_MACL3L4CR_L3DAIM)
-#define ETH_L3_DEST_ADDR_MATCH_DISABLE 0x00000000U
-/**
- * @}
- */
-
-/** @defgroup ETHEx_L4_Protocol ETHEx L4 Protocol
- * @{
- */
-#define ETH_L4_UDP_MATCH ETH_MACL3L4CR_L4PEN
-#define ETH_L4_TCP_MATCH 0x00000000U
-/**
- * @}
- */
-
-/** @defgroup ETHEx_L4_Source_Match ETHEx L4 Source Match
- * @{
- */
-#define ETH_L4_SRC_PORT_PERFECT_MATCH_ENABLE ETH_MACL3L4CR_L4SPM
-#define ETH_L4_SRC_PORT_INVERSE_MATCH_ENABLE (ETH_MACL3L4CR_L4SPM |ETH_MACL3L4CR_L4SPIM)
-#define ETH_L4_SRC_PORT_MATCH_DISABLE 0x00000000U
-/**
- * @}
- */
-
-/** @defgroup ETHEx_L4_Destination_Match ETHEx L4 Destination Match
- * @{
- */
-#define ETH_L4_DEST_PORT_PERFECT_MATCH_ENABLE ETH_MACL3L4CR_L4DPM
-#define ETH_L4_DEST_PORT_INVERSE_MATCH_ENABLE (ETH_MACL3L4CR_L4DPM | ETH_MACL3L4CR_L4DPIM)
-#define ETH_L4_DEST_PORT_MATCH_DISABLE 0x00000000U
-/**
- * @}
- */
-
-/** @defgroup ETHEx_Rx_Inner_VLAN_Tag_Stripping ETHEx Rx Inner VLAN Tag Stripping
- * @{
- */
-#define ETH_INNERVLANTAGRXSTRIPPING_NONE ETH_MACVTR_EIVLS_DONOTSTRIP
-#define ETH_INNERVLANTAGRXSTRIPPING_IFPASS ETH_MACVTR_EIVLS_STRIPIFPASS
-#define ETH_INNERVLANTAGRXSTRIPPING_IFFAILS ETH_MACVTR_EIVLS_STRIPIFFAILS
-#define ETH_INNERVLANTAGRXSTRIPPING_ALWAYS ETH_MACVTR_EIVLS_ALWAYSSTRIP
-/**
- * @}
- */
-
-/** @defgroup ETHEx_Rx_VLAN_Tag_Stripping ETHEx Rx VLAN Tag Stripping
- * @{
- */
-#define ETH_VLANTAGRXSTRIPPING_NONE ETH_MACVTR_EVLS_DONOTSTRIP
-#define ETH_VLANTAGRXSTRIPPING_IFPASS ETH_MACVTR_EVLS_STRIPIFPASS
-#define ETH_VLANTAGRXSTRIPPING_IFFAILS ETH_MACVTR_EVLS_STRIPIFFAILS
-#define ETH_VLANTAGRXSTRIPPING_ALWAYS ETH_MACVTR_EVLS_ALWAYSSTRIP
-/**
- * @}
- */
-
-/** @defgroup ETHEx_VLAN_Type_Check ETHEx VLAN Type Check
- * @{
- */
-#define ETH_VLANTYPECHECK_DISABLE ETH_MACVTR_DOVLTC
-#define ETH_VLANTYPECHECK_SVLAN (ETH_MACVTR_ERSVLM | ETH_MACVTR_ESVL)
-#define ETH_VLANTYPECHECK_CVLAN 0x00000000U
-/**
- * @}
- */
-
-/** @defgroup ETHEx_VLAN_Tag_Control ETHEx_VLAN_Tag_Control
- * @{
- */
-#define ETH_VLANTAGCONTROL_NONE (ETH_MACVIR_VLP | ETH_MACVIR_VLC_NOVLANTAG)
-#define ETH_VLANTAGCONTROL_DELETE (ETH_MACVIR_VLP | ETH_MACVIR_VLC_VLANTAGDELETE)
-#define ETH_VLANTAGCONTROL_INSERT (ETH_MACVIR_VLP | ETH_MACVIR_VLC_VLANTAGINSERT)
-#define ETH_VLANTAGCONTROL_REPLACE (ETH_MACVIR_VLP | ETH_MACVIR_VLC_VLANTAGREPLACE)
-/**
- * @}
- */
-
-/** @defgroup ETHEx_Tx_VLAN_Tag ETHEx Tx VLAN Tag
- * @{
- */
-#define ETH_INNER_TX_VLANTAG 0x00000001U
-#define ETH_OUTER_TX_VLANTAG 0x00000000U
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/* Exported functions --------------------------------------------------------*/
-/** @addtogroup ETHEx_Exported_Functions
- * @{
- */
-
-/** @addtogroup ETHEx_Exported_Functions_Group1
- * @{
- */
-/* MAC ARP Offloading APIs ***************************************************/
-void HAL_ETHEx_EnableARPOffload(ETH_HandleTypeDef *heth);
-void HAL_ETHEx_DisableARPOffload(ETH_HandleTypeDef *heth);
-void HAL_ETHEx_SetARPAddressMatch(ETH_HandleTypeDef *heth, uint32_t IpAddress);
-
-/* MAC L3 L4 Filtering APIs ***************************************************/
-void HAL_ETHEx_EnableL3L4Filtering(ETH_HandleTypeDef *heth);
-void HAL_ETHEx_DisableL3L4Filtering(ETH_HandleTypeDef *heth);
-HAL_StatusTypeDef HAL_ETHEx_GetL3FilterConfig(ETH_HandleTypeDef *heth, uint32_t Filter,
- ETH_L3FilterConfigTypeDef *pL3FilterConfig);
-HAL_StatusTypeDef HAL_ETHEx_GetL4FilterConfig(ETH_HandleTypeDef *heth, uint32_t Filter,
- ETH_L4FilterConfigTypeDef *pL4FilterConfig);
-HAL_StatusTypeDef HAL_ETHEx_SetL3FilterConfig(ETH_HandleTypeDef *heth, uint32_t Filter,
- ETH_L3FilterConfigTypeDef *pL3FilterConfig);
-HAL_StatusTypeDef HAL_ETHEx_SetL4FilterConfig(ETH_HandleTypeDef *heth, uint32_t Filter,
- ETH_L4FilterConfigTypeDef *pL4FilterConfig);
-
-/* MAC VLAN Processing APIs ************************************************/
-void HAL_ETHEx_EnableVLANProcessing(ETH_HandleTypeDef *heth);
-void HAL_ETHEx_DisableVLANProcessing(ETH_HandleTypeDef *heth);
-HAL_StatusTypeDef HAL_ETHEx_GetRxVLANConfig(ETH_HandleTypeDef *heth, ETH_RxVLANConfigTypeDef *pVlanConfig);
-HAL_StatusTypeDef HAL_ETHEx_SetRxVLANConfig(ETH_HandleTypeDef *heth, ETH_RxVLANConfigTypeDef *pVlanConfig);
-void HAL_ETHEx_SetVLANHashTable(ETH_HandleTypeDef *heth, uint32_t VLANHashTable);
-HAL_StatusTypeDef HAL_ETHEx_GetTxVLANConfig(ETH_HandleTypeDef *heth, uint32_t VLANTag,
- ETH_TxVLANConfigTypeDef *pVlanConfig);
-HAL_StatusTypeDef HAL_ETHEx_SetTxVLANConfig(ETH_HandleTypeDef *heth, uint32_t VLANTag,
- ETH_TxVLANConfigTypeDef *pVlanConfig);
-void HAL_ETHEx_SetTxVLANIdentifier(ETH_HandleTypeDef *heth, uint32_t VLANTag, uint32_t VLANIdentifier);
-
-/* Energy Efficient Ethernet APIs *********************************************/
-void HAL_ETHEx_EnterLPIMode(ETH_HandleTypeDef *heth, FunctionalState TxAutomate,
- FunctionalState TxClockStop);
-void HAL_ETHEx_ExitLPIMode(ETH_HandleTypeDef *heth);
-uint32_t HAL_ETHEx_GetMACLPIEvent(ETH_HandleTypeDef *heth);
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-#endif /* ETH */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* STM32H7xx_HAL_ETH_EX_H */
-
-
diff --git a/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_pcd.h b/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_pcd.h
deleted file mode 100644
index c622c97..0000000
--- a/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_pcd.h
+++ /dev/null
@@ -1,444 +0,0 @@
-/**
- ******************************************************************************
- * @file stm32h7xx_hal_pcd.h
- * @author MCD Application Team
- * @brief Header file of PCD HAL module.
- ******************************************************************************
- * @attention
- *
- * Copyright (c) 2017 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.
- *
- ******************************************************************************
- */
-
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef STM32H7xx_HAL_PCD_H
-#define STM32H7xx_HAL_PCD_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32h7xx_ll_usb.h"
-
-#if defined (USB_OTG_FS) || defined (USB_OTG_HS)
-
-/** @addtogroup STM32H7xx_HAL_Driver
- * @{
- */
-
-/** @addtogroup PCD
- * @{
- */
-
-/* Exported types ------------------------------------------------------------*/
-/** @defgroup PCD_Exported_Types PCD Exported Types
- * @{
- */
-
-/**
- * @brief PCD State structure definition
- */
-typedef enum
-{
- HAL_PCD_STATE_RESET = 0x00,
- HAL_PCD_STATE_READY = 0x01,
- HAL_PCD_STATE_ERROR = 0x02,
- HAL_PCD_STATE_BUSY = 0x03,
- HAL_PCD_STATE_TIMEOUT = 0x04
-} PCD_StateTypeDef;
-
-/* Device LPM suspend state */
-typedef enum
-{
- LPM_L0 = 0x00, /* on */
- LPM_L1 = 0x01, /* LPM L1 sleep */
- LPM_L2 = 0x02, /* suspend */
- LPM_L3 = 0x03, /* off */
-} PCD_LPM_StateTypeDef;
-
-typedef enum
-{
- PCD_LPM_L0_ACTIVE = 0x00, /* on */
- PCD_LPM_L1_ACTIVE = 0x01, /* LPM L1 sleep */
-} PCD_LPM_MsgTypeDef;
-
-typedef enum
-{
- PCD_BCD_ERROR = 0xFF,
- PCD_BCD_CONTACT_DETECTION = 0xFE,
- PCD_BCD_STD_DOWNSTREAM_PORT = 0xFD,
- PCD_BCD_CHARGING_DOWNSTREAM_PORT = 0xFC,
- PCD_BCD_DEDICATED_CHARGING_PORT = 0xFB,
- PCD_BCD_DISCOVERY_COMPLETED = 0x00,
-
-} PCD_BCD_MsgTypeDef;
-
-#if defined (USB_OTG_FS) || defined (USB_OTG_HS)
-typedef USB_OTG_GlobalTypeDef PCD_TypeDef;
-typedef USB_OTG_CfgTypeDef PCD_InitTypeDef;
-typedef USB_OTG_EPTypeDef PCD_EPTypeDef;
-#endif /* defined (USB_OTG_FS) || defined (USB_OTG_HS) */
-
-/**
- * @brief PCD Handle Structure definition
- */
-#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
-typedef struct __PCD_HandleTypeDef
-#else
-typedef struct
-#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
-{
- PCD_TypeDef *Instance; /*!< Register base address */
- PCD_InitTypeDef Init; /*!< PCD required parameters */
- __IO uint8_t USB_Address; /*!< USB Address */
- PCD_EPTypeDef IN_ep[16]; /*!< IN endpoint parameters */
- PCD_EPTypeDef OUT_ep[16]; /*!< OUT endpoint parameters */
- HAL_LockTypeDef Lock; /*!< PCD peripheral status */
- __IO PCD_StateTypeDef State; /*!< PCD communication state */
- __IO uint32_t ErrorCode; /*!< PCD Error code */
- uint32_t Setup[12]; /*!< Setup packet buffer */
- PCD_LPM_StateTypeDef LPM_State; /*!< LPM State */
- uint32_t BESL;
- uint32_t FrameNumber; /*!< Store Current Frame number */
-
-
- uint32_t lpm_active; /*!< Enable or disable the Link Power Management .
- This parameter can be set to ENABLE or DISABLE */
-
- uint32_t battery_charging_active; /*!< Enable or disable Battery charging.
- This parameter can be set to ENABLE or DISABLE */
- void *pData; /*!< Pointer to upper stack Handler */
-
-#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
- void (* SOFCallback)(struct __PCD_HandleTypeDef *hpcd); /*!< USB OTG PCD SOF callback */
- void (* SetupStageCallback)(struct __PCD_HandleTypeDef *hpcd); /*!< USB OTG PCD Setup Stage callback */
- void (* ResetCallback)(struct __PCD_HandleTypeDef *hpcd); /*!< USB OTG PCD Reset callback */
- void (* SuspendCallback)(struct __PCD_HandleTypeDef *hpcd); /*!< USB OTG PCD Suspend callback */
- void (* ResumeCallback)(struct __PCD_HandleTypeDef *hpcd); /*!< USB OTG PCD Resume callback */
- void (* ConnectCallback)(struct __PCD_HandleTypeDef *hpcd); /*!< USB OTG PCD Connect callback */
- void (* DisconnectCallback)(struct __PCD_HandleTypeDef *hpcd); /*!< USB OTG PCD Disconnect callback */
-
- void (* DataOutStageCallback)(struct __PCD_HandleTypeDef *hpcd, uint8_t epnum); /*!< USB OTG PCD Data OUT Stage callback */
- void (* DataInStageCallback)(struct __PCD_HandleTypeDef *hpcd, uint8_t epnum); /*!< USB OTG PCD Data IN Stage callback */
- void (* ISOOUTIncompleteCallback)(struct __PCD_HandleTypeDef *hpcd, uint8_t epnum); /*!< USB OTG PCD ISO OUT Incomplete callback */
- void (* ISOINIncompleteCallback)(struct __PCD_HandleTypeDef *hpcd, uint8_t epnum); /*!< USB OTG PCD ISO IN Incomplete callback */
- void (* BCDCallback)(struct __PCD_HandleTypeDef *hpcd, PCD_BCD_MsgTypeDef msg); /*!< USB OTG PCD BCD callback */
- void (* LPMCallback)(struct __PCD_HandleTypeDef *hpcd, PCD_LPM_MsgTypeDef msg); /*!< USB OTG PCD LPM callback */
-
- void (* MspInitCallback)(struct __PCD_HandleTypeDef *hpcd); /*!< USB OTG PCD Msp Init callback */
- void (* MspDeInitCallback)(struct __PCD_HandleTypeDef *hpcd); /*!< USB OTG PCD Msp DeInit callback */
-#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
-} PCD_HandleTypeDef;
-
-/**
- * @}
- */
-
-/* Include PCD HAL Extended module */
-#include "stm32h7xx_hal_pcd_ex.h"
-
-/* Exported constants --------------------------------------------------------*/
-/** @defgroup PCD_Exported_Constants PCD Exported Constants
- * @{
- */
-
-/** @defgroup PCD_Speed PCD Speed
- * @{
- */
-#define PCD_SPEED_HIGH USBD_HS_SPEED
-#define PCD_SPEED_HIGH_IN_FULL USBD_HSINFS_SPEED
-#define PCD_SPEED_FULL USBD_FS_SPEED
-/**
- * @}
- */
-
-/** @defgroup PCD_PHY_Module PCD PHY Module
- * @{
- */
-#define PCD_PHY_ULPI 1U
-#define PCD_PHY_EMBEDDED 2U
-#define PCD_PHY_UTMI 3U
-/**
- * @}
- */
-
-/** @defgroup PCD_Error_Code_definition PCD Error Code definition
- * @brief PCD Error Code definition
- * @{
- */
-#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
-#define HAL_PCD_ERROR_INVALID_CALLBACK (0x00000010U) /*!< Invalid Callback error */
-#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/* Exported macros -----------------------------------------------------------*/
-/** @defgroup PCD_Exported_Macros PCD Exported Macros
- * @brief macros to handle interrupts and specific clock configurations
- * @{
- */
-#define __HAL_PCD_ENABLE(__HANDLE__) (void)USB_EnableGlobalInt ((__HANDLE__)->Instance)
-#define __HAL_PCD_DISABLE(__HANDLE__) (void)USB_DisableGlobalInt ((__HANDLE__)->Instance)
-
-#define __HAL_PCD_GET_FLAG(__HANDLE__, __INTERRUPT__) \
- ((USB_ReadInterrupts((__HANDLE__)->Instance) & (__INTERRUPT__)) == (__INTERRUPT__))
-
-#if defined (USB_OTG_FS) || defined (USB_OTG_HS)
-#define __HAL_PCD_CLEAR_FLAG(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->GINTSTS) &= (__INTERRUPT__))
-#define __HAL_PCD_IS_INVALID_INTERRUPT(__HANDLE__) (USB_ReadInterrupts((__HANDLE__)->Instance) == 0U)
-
-#define __HAL_PCD_UNGATE_PHYCLOCK(__HANDLE__) \
- *(__IO uint32_t *)((uint32_t)((__HANDLE__)->Instance) + USB_OTG_PCGCCTL_BASE) &= ~(USB_OTG_PCGCCTL_STOPCLK)
-
-#define __HAL_PCD_GATE_PHYCLOCK(__HANDLE__) \
- *(__IO uint32_t *)((uint32_t)((__HANDLE__)->Instance) + USB_OTG_PCGCCTL_BASE) |= USB_OTG_PCGCCTL_STOPCLK
-
-#define __HAL_PCD_IS_PHY_SUSPENDED(__HANDLE__) \
- ((*(__IO uint32_t *)((uint32_t)((__HANDLE__)->Instance) + USB_OTG_PCGCCTL_BASE)) & 0x10U)
-
-#define __HAL_USB_OTG_HS_WAKEUP_EXTI_ENABLE_IT() EXTI_D1->IMR2 |= (USB_OTG_HS_WAKEUP_EXTI_LINE)
-#define __HAL_USB_OTG_HS_WAKEUP_EXTI_DISABLE_IT() EXTI_D1->IMR2 &= ~(USB_OTG_HS_WAKEUP_EXTI_LINE)
-#define __HAL_USB_OTG_FS_WAKEUP_EXTI_ENABLE_IT() EXTI_D1->IMR2 |= (USB_OTG_FS_WAKEUP_EXTI_LINE)
-#define __HAL_USB_OTG_FS_WAKEUP_EXTI_DISABLE_IT() EXTI_D1->IMR2 &= ~(USB_OTG_FS_WAKEUP_EXTI_LINE)
-#endif /* defined (USB_OTG_FS) || defined (USB_OTG_HS) */
-
-
-/**
- * @}
- */
-
-/* Exported functions --------------------------------------------------------*/
-/** @addtogroup PCD_Exported_Functions PCD Exported Functions
- * @{
- */
-
-/* Initialization/de-initialization functions ********************************/
-/** @addtogroup PCD_Exported_Functions_Group1 Initialization and de-initialization functions
- * @{
- */
-HAL_StatusTypeDef HAL_PCD_Init(PCD_HandleTypeDef *hpcd);
-HAL_StatusTypeDef HAL_PCD_DeInit(PCD_HandleTypeDef *hpcd);
-void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd);
-void HAL_PCD_MspDeInit(PCD_HandleTypeDef *hpcd);
-
-#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
-/** @defgroup HAL_PCD_Callback_ID_enumeration_definition HAL USB OTG PCD Callback ID enumeration definition
- * @brief HAL USB OTG PCD Callback ID enumeration definition
- * @{
- */
-typedef enum
-{
- HAL_PCD_SOF_CB_ID = 0x01, /*!< USB PCD SOF callback ID */
- HAL_PCD_SETUPSTAGE_CB_ID = 0x02, /*!< USB PCD Setup Stage callback ID */
- HAL_PCD_RESET_CB_ID = 0x03, /*!< USB PCD Reset callback ID */
- HAL_PCD_SUSPEND_CB_ID = 0x04, /*!< USB PCD Suspend callback ID */
- HAL_PCD_RESUME_CB_ID = 0x05, /*!< USB PCD Resume callback ID */
- HAL_PCD_CONNECT_CB_ID = 0x06, /*!< USB PCD Connect callback ID */
- HAL_PCD_DISCONNECT_CB_ID = 0x07, /*!< USB PCD Disconnect callback ID */
-
- HAL_PCD_MSPINIT_CB_ID = 0x08, /*!< USB PCD MspInit callback ID */
- HAL_PCD_MSPDEINIT_CB_ID = 0x09 /*!< USB PCD MspDeInit callback ID */
-
-} HAL_PCD_CallbackIDTypeDef;
-/**
- * @}
- */
-
-/** @defgroup HAL_PCD_Callback_pointer_definition HAL USB OTG PCD Callback pointer definition
- * @brief HAL USB OTG PCD Callback pointer definition
- * @{
- */
-
-typedef void (*pPCD_CallbackTypeDef)(PCD_HandleTypeDef *hpcd); /*!< pointer to a common USB OTG PCD callback function */
-typedef void (*pPCD_DataOutStageCallbackTypeDef)(PCD_HandleTypeDef *hpcd, uint8_t epnum); /*!< pointer to USB OTG PCD Data OUT Stage callback */
-typedef void (*pPCD_DataInStageCallbackTypeDef)(PCD_HandleTypeDef *hpcd, uint8_t epnum); /*!< pointer to USB OTG PCD Data IN Stage callback */
-typedef void (*pPCD_IsoOutIncpltCallbackTypeDef)(PCD_HandleTypeDef *hpcd, uint8_t epnum); /*!< pointer to USB OTG PCD ISO OUT Incomplete callback */
-typedef void (*pPCD_IsoInIncpltCallbackTypeDef)(PCD_HandleTypeDef *hpcd, uint8_t epnum); /*!< pointer to USB OTG PCD ISO IN Incomplete callback */
-typedef void (*pPCD_LpmCallbackTypeDef)(PCD_HandleTypeDef *hpcd, PCD_LPM_MsgTypeDef msg); /*!< pointer to USB OTG PCD LPM callback */
-typedef void (*pPCD_BcdCallbackTypeDef)(PCD_HandleTypeDef *hpcd, PCD_BCD_MsgTypeDef msg); /*!< pointer to USB OTG PCD BCD callback */
-
-/**
- * @}
- */
-
-HAL_StatusTypeDef HAL_PCD_RegisterCallback(PCD_HandleTypeDef *hpcd, HAL_PCD_CallbackIDTypeDef CallbackID,
- pPCD_CallbackTypeDef pCallback);
-
-HAL_StatusTypeDef HAL_PCD_UnRegisterCallback(PCD_HandleTypeDef *hpcd, HAL_PCD_CallbackIDTypeDef CallbackID);
-
-HAL_StatusTypeDef HAL_PCD_RegisterDataOutStageCallback(PCD_HandleTypeDef *hpcd,
- pPCD_DataOutStageCallbackTypeDef pCallback);
-
-HAL_StatusTypeDef HAL_PCD_UnRegisterDataOutStageCallback(PCD_HandleTypeDef *hpcd);
-
-HAL_StatusTypeDef HAL_PCD_RegisterDataInStageCallback(PCD_HandleTypeDef *hpcd,
- pPCD_DataInStageCallbackTypeDef pCallback);
-
-HAL_StatusTypeDef HAL_PCD_UnRegisterDataInStageCallback(PCD_HandleTypeDef *hpcd);
-
-HAL_StatusTypeDef HAL_PCD_RegisterIsoOutIncpltCallback(PCD_HandleTypeDef *hpcd,
- pPCD_IsoOutIncpltCallbackTypeDef pCallback);
-
-HAL_StatusTypeDef HAL_PCD_UnRegisterIsoOutIncpltCallback(PCD_HandleTypeDef *hpcd);
-
-HAL_StatusTypeDef HAL_PCD_RegisterIsoInIncpltCallback(PCD_HandleTypeDef *hpcd,
- pPCD_IsoInIncpltCallbackTypeDef pCallback);
-
-HAL_StatusTypeDef HAL_PCD_UnRegisterIsoInIncpltCallback(PCD_HandleTypeDef *hpcd);
-
-HAL_StatusTypeDef HAL_PCD_RegisterBcdCallback(PCD_HandleTypeDef *hpcd, pPCD_BcdCallbackTypeDef pCallback);
-HAL_StatusTypeDef HAL_PCD_UnRegisterBcdCallback(PCD_HandleTypeDef *hpcd);
-
-HAL_StatusTypeDef HAL_PCD_RegisterLpmCallback(PCD_HandleTypeDef *hpcd, pPCD_LpmCallbackTypeDef pCallback);
-HAL_StatusTypeDef HAL_PCD_UnRegisterLpmCallback(PCD_HandleTypeDef *hpcd);
-#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
-/**
- * @}
- */
-
-/* I/O operation functions ***************************************************/
-/* Non-Blocking mode: Interrupt */
-/** @addtogroup PCD_Exported_Functions_Group2 Input and Output operation functions
- * @{
- */
-HAL_StatusTypeDef HAL_PCD_Start(PCD_HandleTypeDef *hpcd);
-HAL_StatusTypeDef HAL_PCD_Stop(PCD_HandleTypeDef *hpcd);
-void HAL_PCD_IRQHandler(PCD_HandleTypeDef *hpcd);
-
-void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd);
-void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd);
-void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd);
-void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd);
-void HAL_PCD_ResumeCallback(PCD_HandleTypeDef *hpcd);
-void HAL_PCD_ConnectCallback(PCD_HandleTypeDef *hpcd);
-void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd);
-
-void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum);
-void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum);
-void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum);
-void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum);
-/**
- * @}
- */
-
-/* Peripheral Control functions **********************************************/
-/** @addtogroup PCD_Exported_Functions_Group3 Peripheral Control functions
- * @{
- */
-HAL_StatusTypeDef HAL_PCD_DevConnect(PCD_HandleTypeDef *hpcd);
-HAL_StatusTypeDef HAL_PCD_DevDisconnect(PCD_HandleTypeDef *hpcd);
-HAL_StatusTypeDef HAL_PCD_SetAddress(PCD_HandleTypeDef *hpcd, uint8_t address);
-HAL_StatusTypeDef HAL_PCD_EP_Open(PCD_HandleTypeDef *hpcd, uint8_t ep_addr, uint16_t ep_mps, uint8_t ep_type);
-HAL_StatusTypeDef HAL_PCD_EP_Close(PCD_HandleTypeDef *hpcd, uint8_t ep_addr);
-HAL_StatusTypeDef HAL_PCD_EP_Receive(PCD_HandleTypeDef *hpcd, uint8_t ep_addr, uint8_t *pBuf, uint32_t len);
-HAL_StatusTypeDef HAL_PCD_EP_Transmit(PCD_HandleTypeDef *hpcd, uint8_t ep_addr, uint8_t *pBuf, uint32_t len);
-HAL_StatusTypeDef HAL_PCD_EP_SetStall(PCD_HandleTypeDef *hpcd, uint8_t ep_addr);
-HAL_StatusTypeDef HAL_PCD_EP_ClrStall(PCD_HandleTypeDef *hpcd, uint8_t ep_addr);
-HAL_StatusTypeDef HAL_PCD_EP_Flush(PCD_HandleTypeDef *hpcd, uint8_t ep_addr);
-HAL_StatusTypeDef HAL_PCD_EP_Abort(PCD_HandleTypeDef *hpcd, uint8_t ep_addr);
-HAL_StatusTypeDef HAL_PCD_ActivateRemoteWakeup(PCD_HandleTypeDef *hpcd);
-HAL_StatusTypeDef HAL_PCD_DeActivateRemoteWakeup(PCD_HandleTypeDef *hpcd);
-#if defined (USB_OTG_FS) || defined (USB_OTG_HS)
-HAL_StatusTypeDef HAL_PCD_SetTestMode(PCD_HandleTypeDef *hpcd, uint8_t testmode);
-#endif /* defined (USB_OTG_FS) || defined (USB_OTG_HS) */
-
-uint32_t HAL_PCD_EP_GetRxCount(PCD_HandleTypeDef *hpcd, uint8_t ep_addr);
-/**
- * @}
- */
-
-/* Peripheral State functions ************************************************/
-/** @addtogroup PCD_Exported_Functions_Group4 Peripheral State functions
- * @{
- */
-PCD_StateTypeDef HAL_PCD_GetState(PCD_HandleTypeDef *hpcd);
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/* Private constants ---------------------------------------------------------*/
-/** @defgroup PCD_Private_Constants PCD Private Constants
- * @{
- */
-/** @defgroup USB_EXTI_Line_Interrupt USB EXTI line interrupt
- * @{
- */
-#if defined (USB_OTG_FS) || defined (USB_OTG_HS)
-#define USB_OTG_FS_WAKEUP_EXTI_LINE (0x1U << 12) /*!< USB FS EXTI Line WakeUp Interrupt */
-#define USB_OTG_HS_WAKEUP_EXTI_LINE (0x1U << 11) /*!< USB HS EXTI Line WakeUp Interrupt */
-#endif /* defined (USB_OTG_FS) || defined (USB_OTG_HS) */
-
-
-/**
- * @}
- */
-/**
- * @}
- */
-
-#if defined (USB_OTG_FS) || defined (USB_OTG_HS)
-#ifndef USB_OTG_DOEPINT_OTEPSPR
-#define USB_OTG_DOEPINT_OTEPSPR (0x1UL << 5) /*!< Status Phase Received interrupt */
-#endif /* defined USB_OTG_DOEPINT_OTEPSPR */
-
-#ifndef USB_OTG_DOEPMSK_OTEPSPRM
-#define USB_OTG_DOEPMSK_OTEPSPRM (0x1UL << 5) /*!< Setup Packet Received interrupt mask */
-#endif /* defined USB_OTG_DOEPMSK_OTEPSPRM */
-
-#ifndef USB_OTG_DOEPINT_NAK
-#define USB_OTG_DOEPINT_NAK (0x1UL << 13) /*!< NAK interrupt */
-#endif /* defined USB_OTG_DOEPINT_NAK */
-
-#ifndef USB_OTG_DOEPMSK_NAKM
-#define USB_OTG_DOEPMSK_NAKM (0x1UL << 13) /*!< OUT Packet NAK interrupt mask */
-#endif /* defined USB_OTG_DOEPMSK_NAKM */
-
-#ifndef USB_OTG_DOEPINT_STPKTRX
-#define USB_OTG_DOEPINT_STPKTRX (0x1UL << 15) /*!< Setup Packet Received interrupt */
-#endif /* defined USB_OTG_DOEPINT_STPKTRX */
-
-#ifndef USB_OTG_DOEPMSK_NYETM
-#define USB_OTG_DOEPMSK_NYETM (0x1UL << 14) /*!< Setup Packet Received interrupt mask */
-#endif /* defined USB_OTG_DOEPMSK_NYETM */
-#endif /* defined (USB_OTG_FS) || defined (USB_OTG_HS) */
-
-/* Private macros ------------------------------------------------------------*/
-/** @defgroup PCD_Private_Macros PCD Private Macros
- * @{
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-#endif /* defined (USB_OTG_FS) || defined (USB_OTG_HS) */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* STM32H7xx_HAL_PCD_H */
diff --git a/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_pcd_ex.h b/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_pcd_ex.h
deleted file mode 100644
index 9cfa012..0000000
--- a/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_pcd_ex.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/**
- ******************************************************************************
- * @file stm32h7xx_hal_pcd_ex.h
- * @author MCD Application Team
- * @brief Header file of PCD HAL Extension module.
- ******************************************************************************
- * @attention
- *
- * Copyright (c) 2017 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.
- *
- ******************************************************************************
- */
-
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef STM32H7xx_HAL_PCD_EX_H
-#define STM32H7xx_HAL_PCD_EX_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32h7xx_hal_def.h"
-
-#if defined (USB_OTG_FS) || defined (USB_OTG_HS)
-/** @addtogroup STM32H7xx_HAL_Driver
- * @{
- */
-
-/** @addtogroup PCDEx
- * @{
- */
-/* Exported types ------------------------------------------------------------*/
-/* Exported constants --------------------------------------------------------*/
-/* Exported macros -----------------------------------------------------------*/
-/* Exported functions --------------------------------------------------------*/
-/** @addtogroup PCDEx_Exported_Functions PCDEx Exported Functions
- * @{
- */
-/** @addtogroup PCDEx_Exported_Functions_Group1 Peripheral Control functions
- * @{
- */
-
-#if defined (USB_OTG_FS) || defined (USB_OTG_HS)
-HAL_StatusTypeDef HAL_PCDEx_SetTxFiFo(PCD_HandleTypeDef *hpcd, uint8_t fifo, uint16_t size);
-HAL_StatusTypeDef HAL_PCDEx_SetRxFiFo(PCD_HandleTypeDef *hpcd, uint16_t size);
-#endif /* defined (USB_OTG_FS) || defined (USB_OTG_HS) */
-
-
-HAL_StatusTypeDef HAL_PCDEx_ActivateLPM(PCD_HandleTypeDef *hpcd);
-HAL_StatusTypeDef HAL_PCDEx_DeActivateLPM(PCD_HandleTypeDef *hpcd);
-
-
-HAL_StatusTypeDef HAL_PCDEx_ActivateBCD(PCD_HandleTypeDef *hpcd);
-HAL_StatusTypeDef HAL_PCDEx_DeActivateBCD(PCD_HandleTypeDef *hpcd);
-void HAL_PCDEx_BCD_VBUSDetect(PCD_HandleTypeDef *hpcd);
-
-void HAL_PCDEx_LPM_Callback(PCD_HandleTypeDef *hpcd, PCD_LPM_MsgTypeDef msg);
-void HAL_PCDEx_BCD_Callback(PCD_HandleTypeDef *hpcd, PCD_BCD_MsgTypeDef msg);
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-#endif /* defined (USB_OTG_FS) || defined (USB_OTG_HS) */
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-
-#endif /* STM32H7xx_HAL_PCD_EX_H */
diff --git a/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_usb.h b/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_usb.h
deleted file mode 100644
index 59599bf..0000000
--- a/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_usb.h
+++ /dev/null
@@ -1,558 +0,0 @@
-/**
- ******************************************************************************
- * @file stm32h7xx_ll_usb.h
- * @author MCD Application Team
- * @brief Header file of USB Low Layer HAL module.
- ******************************************************************************
- * @attention
- *
- * Copyright (c) 2017 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.
- *
- ******************************************************************************
- */
-
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef STM32H7xx_LL_USB_H
-#define STM32H7xx_LL_USB_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32h7xx_hal_def.h"
-
-#if defined (USB_OTG_FS) || defined (USB_OTG_HS)
-/** @addtogroup STM32H7xx_HAL_Driver
- * @{
- */
-
-/** @addtogroup USB_LL
- * @{
- */
-
-/* Exported types ------------------------------------------------------------*/
-
-/**
- * @brief USB Mode definition
- */
-
-typedef enum
-{
- USB_DEVICE_MODE = 0,
- USB_HOST_MODE = 1,
- USB_DRD_MODE = 2
-} USB_ModeTypeDef;
-
-/**
- * @brief URB States definition
- */
-typedef enum
-{
- URB_IDLE = 0,
- URB_DONE,
- URB_NOTREADY,
- URB_NYET,
- URB_ERROR,
- URB_STALL
-} USB_URBStateTypeDef;
-
-/**
- * @brief Host channel States definition
- */
-typedef enum
-{
- HC_IDLE = 0,
- HC_XFRC,
- HC_HALTED,
- HC_ACK,
- HC_NAK,
- HC_NYET,
- HC_STALL,
- HC_XACTERR,
- HC_BBLERR,
- HC_DATATGLERR
-} USB_HCStateTypeDef;
-
-
-/**
- * @brief USB Instance Initialization Structure definition
- */
-typedef struct
-{
- uint32_t dev_endpoints; /*!< Device Endpoints number.
- This parameter depends on the used USB core.
- This parameter must be a number between Min_Data = 1 and Max_Data = 15 */
-
- uint32_t Host_channels; /*!< Host Channels number.
- This parameter Depends on the used USB core.
- This parameter must be a number between Min_Data = 1 and Max_Data = 15 */
-
- uint32_t dma_enable; /*!< dma_enable state unused, DMA not supported by FS instance */
-
- uint32_t speed; /*!< USB Core speed.
- This parameter can be any value of @ref PCD_Speed/HCD_Speed
- (HCD_SPEED_xxx, HCD_SPEED_xxx) */
-
- uint32_t ep0_mps; /*!< Set the Endpoint 0 Max Packet size. */
-
- uint32_t phy_itface; /*!< Select the used PHY interface.
- This parameter can be any value of @ref PCD_PHY_Module/HCD_PHY_Module */
-
- uint32_t Sof_enable; /*!< Enable or disable the output of the SOF signal. */
-
- uint32_t low_power_enable; /*!< Enable or disable the low Power Mode. */
-
- uint32_t lpm_enable; /*!< Enable or disable Link Power Management. */
-
- uint32_t battery_charging_enable; /*!< Enable or disable Battery charging. */
-
- uint32_t vbus_sensing_enable; /*!< Enable or disable the VBUS Sensing feature. */
-
- uint32_t use_dedicated_ep1; /*!< Enable or disable the use of the dedicated EP1 interrupt. */
-
- uint32_t use_external_vbus; /*!< Enable or disable the use of the external VBUS. */
-
-} USB_CfgTypeDef;
-
-typedef struct
-{
- uint8_t num; /*!< Endpoint number
- This parameter must be a number between Min_Data = 1 and Max_Data = 15 */
-
- uint8_t is_in; /*!< Endpoint direction
- This parameter must be a number between Min_Data = 0 and Max_Data = 1 */
-
- uint8_t is_stall; /*!< Endpoint stall condition
- This parameter must be a number between Min_Data = 0 and Max_Data = 1 */
-
- uint8_t is_iso_incomplete; /*!< Endpoint isoc condition
- This parameter must be a number between Min_Data = 0 and Max_Data = 1 */
-
- uint8_t type; /*!< Endpoint type
- This parameter can be any value of @ref USB_LL_EP_Type */
-
- uint8_t data_pid_start; /*!< Initial data PID
- This parameter must be a number between Min_Data = 0 and Max_Data = 1 */
-
- uint32_t maxpacket; /*!< Endpoint Max packet size
- This parameter must be a number between Min_Data = 0 and Max_Data = 64KB */
-
- uint8_t *xfer_buff; /*!< Pointer to transfer buffer */
-
- uint32_t xfer_len; /*!< Current transfer length */
-
- uint32_t xfer_count; /*!< Partial transfer length in case of multi packet transfer */
-
- uint8_t even_odd_frame; /*!< IFrame parity
- This parameter must be a number between Min_Data = 0 and Max_Data = 1 */
-
- uint16_t tx_fifo_num; /*!< Transmission FIFO number
- This parameter must be a number between Min_Data = 1 and Max_Data = 15 */
-
- uint32_t dma_addr; /*!< 32 bits aligned transfer buffer address */
-
- uint32_t xfer_size; /*!< requested transfer size */
-} USB_EPTypeDef;
-
-typedef struct
-{
- uint8_t dev_addr; /*!< USB device address.
- This parameter must be a number between Min_Data = 1 and Max_Data = 255 */
-
- uint8_t ch_num; /*!< Host channel number.
- This parameter must be a number between Min_Data = 1 and Max_Data = 15 */
-
- uint8_t ep_num; /*!< Endpoint number.
- This parameter must be a number between Min_Data = 1 and Max_Data = 15 */
-
- uint8_t ep_is_in; /*!< Endpoint direction
- This parameter must be a number between Min_Data = 0 and Max_Data = 1 */
-
- uint8_t speed; /*!< USB Host Channel speed.
- This parameter can be any value of @ref HCD_Device_Speed:
- (HCD_DEVICE_SPEED_xxx) */
-
- uint8_t do_ping; /*!< Enable or disable the use of the PING protocol for HS mode. */
-
- uint8_t process_ping; /*!< Execute the PING protocol for HS mode. */
-
- uint8_t ep_type; /*!< Endpoint Type.
- This parameter can be any value of @ref USB_LL_EP_Type */
-
- uint16_t max_packet; /*!< Endpoint Max packet size.
- This parameter must be a number between Min_Data = 0 and Max_Data = 64KB */
-
- uint8_t data_pid; /*!< Initial data PID.
- This parameter must be a number between Min_Data = 0 and Max_Data = 1 */
-
- uint8_t *xfer_buff; /*!< Pointer to transfer buffer. */
-
- uint32_t XferSize; /*!< OTG Channel transfer size. */
-
- uint32_t xfer_len; /*!< Current transfer length. */
-
- uint32_t xfer_count; /*!< Partial transfer length in case of multi packet transfer. */
-
- uint8_t toggle_in; /*!< IN transfer current toggle flag.
- This parameter must be a number between Min_Data = 0 and Max_Data = 1 */
-
- uint8_t toggle_out; /*!< OUT transfer current toggle flag
- This parameter must be a number between Min_Data = 0 and Max_Data = 1 */
-
- uint32_t dma_addr; /*!< 32 bits aligned transfer buffer address. */
-
- uint32_t ErrCnt; /*!< Host channel error count. */
-
- USB_URBStateTypeDef urb_state; /*!< URB state.
- This parameter can be any value of @ref USB_URBStateTypeDef */
-
- USB_HCStateTypeDef state; /*!< Host Channel state.
- This parameter can be any value of @ref USB_HCStateTypeDef */
-} USB_HCTypeDef;
-
-typedef USB_ModeTypeDef USB_OTG_ModeTypeDef;
-typedef USB_CfgTypeDef USB_OTG_CfgTypeDef;
-typedef USB_EPTypeDef USB_OTG_EPTypeDef;
-typedef USB_URBStateTypeDef USB_OTG_URBStateTypeDef;
-typedef USB_HCStateTypeDef USB_OTG_HCStateTypeDef;
-typedef USB_HCTypeDef USB_OTG_HCTypeDef;
-
-/* Exported constants --------------------------------------------------------*/
-
-/** @defgroup PCD_Exported_Constants PCD Exported Constants
- * @{
- */
-
-#if defined (USB_OTG_FS) || defined (USB_OTG_HS)
-/** @defgroup USB_OTG_CORE VERSION ID
- * @{
- */
-#define USB_OTG_CORE_ID_300A 0x4F54300AU
-#define USB_OTG_CORE_ID_310A 0x4F54310AU
-/**
- * @}
- */
-
-/** @defgroup USB_Core_Mode_ USB Core Mode
- * @{
- */
-#define USB_OTG_MODE_DEVICE 0U
-#define USB_OTG_MODE_HOST 1U
-#define USB_OTG_MODE_DRD 2U
-/**
- * @}
- */
-
-/** @defgroup USB_LL_Core_Speed USB Low Layer Core Speed
- * @{
- */
-#define USB_OTG_SPEED_HIGH 0U
-#define USB_OTG_SPEED_HIGH_IN_FULL 1U
-#define USB_OTG_SPEED_FULL 3U
-/**
- * @}
- */
-
-/** @defgroup USB_LL_Core_PHY USB Low Layer Core PHY
- * @{
- */
-#define USB_OTG_ULPI_PHY 1U
-#define USB_OTG_EMBEDDED_PHY 2U
-/**
- * @}
- */
-
-/** @defgroup USB_LL_Turnaround_Timeout Turnaround Timeout Value
- * @{
- */
-#ifndef USBD_HS_TRDT_VALUE
-#define USBD_HS_TRDT_VALUE 9U
-#endif /* USBD_HS_TRDT_VALUE */
-#ifndef USBD_FS_TRDT_VALUE
-#define USBD_FS_TRDT_VALUE 5U
-#define USBD_DEFAULT_TRDT_VALUE 9U
-#endif /* USBD_HS_TRDT_VALUE */
-/**
- * @}
- */
-
-/** @defgroup USB_LL_Core_MPS USB Low Layer Core MPS
- * @{
- */
-#define USB_OTG_HS_MAX_PACKET_SIZE 512U
-#define USB_OTG_FS_MAX_PACKET_SIZE 64U
-#define USB_OTG_MAX_EP0_SIZE 64U
-/**
- * @}
- */
-
-/** @defgroup USB_LL_Core_PHY_Frequency USB Low Layer Core PHY Frequency
- * @{
- */
-#define DSTS_ENUMSPD_HS_PHY_30MHZ_OR_60MHZ (0U << 1)
-#define DSTS_ENUMSPD_FS_PHY_30MHZ_OR_60MHZ (1U << 1)
-#define DSTS_ENUMSPD_FS_PHY_48MHZ (3U << 1)
-/**
- * @}
- */
-
-/** @defgroup USB_LL_CORE_Frame_Interval USB Low Layer Core Frame Interval
- * @{
- */
-#define DCFG_FRAME_INTERVAL_80 0U
-#define DCFG_FRAME_INTERVAL_85 1U
-#define DCFG_FRAME_INTERVAL_90 2U
-#define DCFG_FRAME_INTERVAL_95 3U
-/**
- * @}
- */
-#endif /* defined (USB_OTG_FS) || defined (USB_OTG_HS) */
-/** @defgroup USB_LL_EP0_MPS USB Low Layer EP0 MPS
- * @{
- */
-#define EP_MPS_64 0U
-#define EP_MPS_32 1U
-#define EP_MPS_16 2U
-#define EP_MPS_8 3U
-/**
- * @}
- */
-
-/** @defgroup USB_LL_EP_Type USB Low Layer EP Type
- * @{
- */
-#define EP_TYPE_CTRL 0U
-#define EP_TYPE_ISOC 1U
-#define EP_TYPE_BULK 2U
-#define EP_TYPE_INTR 3U
-#define EP_TYPE_MSK 3U
-/**
- * @}
- */
-
-/** @defgroup USB_LL_EP_Speed USB Low Layer EP Speed
- * @{
- */
-#define EP_SPEED_LOW 0U
-#define EP_SPEED_FULL 1U
-#define EP_SPEED_HIGH 2U
-/**
- * @}
- */
-
-/** @defgroup USB_LL_CH_PID_Type USB Low Layer Channel PID Type
- * @{
- */
-#define HC_PID_DATA0 0U
-#define HC_PID_DATA2 1U
-#define HC_PID_DATA1 2U
-#define HC_PID_SETUP 3U
-/**
- * @}
- */
-
-/** @defgroup USB_LL Device Speed
- * @{
- */
-#define USBD_HS_SPEED 0U
-#define USBD_HSINFS_SPEED 1U
-#define USBH_HS_SPEED 0U
-#define USBD_FS_SPEED 2U
-#define USBH_FSLS_SPEED 1U
-/**
- * @}
- */
-
-#if defined (USB_OTG_FS) || defined (USB_OTG_HS)
-/** @defgroup USB_LL_STS_Defines USB Low Layer STS Defines
- * @{
- */
-#define STS_GOUT_NAK 1U
-#define STS_DATA_UPDT 2U
-#define STS_XFER_COMP 3U
-#define STS_SETUP_COMP 4U
-#define STS_SETUP_UPDT 6U
-/**
- * @}
- */
-
-/** @defgroup USB_LL_HCFG_SPEED_Defines USB Low Layer HCFG Speed Defines
- * @{
- */
-#define HCFG_30_60_MHZ 0U
-#define HCFG_48_MHZ 1U
-#define HCFG_6_MHZ 2U
-/**
- * @}
- */
-
-/** @defgroup USB_LL_HFIR_Defines USB Low Layer frame interval Defines
- * @{
- */
-#define HFIR_6_MHZ 6000U
-#define HFIR_60_MHZ 60000U
-#define HFIR_48_MHZ 48000U
-/**
- * @}
- */
-
-/** @defgroup USB_LL_HPRT0_PRTSPD_SPEED_Defines USB Low Layer HPRT0 PRTSPD Speed Defines
- * @{
- */
-#define HPRT0_PRTSPD_HIGH_SPEED 0U
-#define HPRT0_PRTSPD_FULL_SPEED 1U
-#define HPRT0_PRTSPD_LOW_SPEED 2U
-/**
- * @}
- */
-
-#define HCCHAR_CTRL 0U
-#define HCCHAR_ISOC 1U
-#define HCCHAR_BULK 2U
-#define HCCHAR_INTR 3U
-
-#define GRXSTS_PKTSTS_IN 2U
-#define GRXSTS_PKTSTS_IN_XFER_COMP 3U
-#define GRXSTS_PKTSTS_DATA_TOGGLE_ERR 5U
-#define GRXSTS_PKTSTS_CH_HALTED 7U
-
-#define CLEAR_INTERRUPT_MASK 0xFFFFFFFFU
-
-#define HC_MAX_PKT_CNT 256U
-
-#define TEST_J 1U
-#define TEST_K 2U
-#define TEST_SE0_NAK 3U
-#define TEST_PACKET 4U
-#define TEST_FORCE_EN 5U
-
-#define USBx_PCGCCTL *(__IO uint32_t *)((uint32_t)USBx_BASE + USB_OTG_PCGCCTL_BASE)
-#define USBx_HPRT0 *(__IO uint32_t *)((uint32_t)USBx_BASE + USB_OTG_HOST_PORT_BASE)
-
-#define USBx_DEVICE ((USB_OTG_DeviceTypeDef *)(USBx_BASE + USB_OTG_DEVICE_BASE))
-#define USBx_INEP(i) ((USB_OTG_INEndpointTypeDef *)(USBx_BASE\
- + USB_OTG_IN_ENDPOINT_BASE + ((i) * USB_OTG_EP_REG_SIZE)))
-
-#define USBx_OUTEP(i) ((USB_OTG_OUTEndpointTypeDef *)(USBx_BASE\
- + USB_OTG_OUT_ENDPOINT_BASE + ((i) * USB_OTG_EP_REG_SIZE)))
-
-#define USBx_DFIFO(i) *(__IO uint32_t *)(USBx_BASE + USB_OTG_FIFO_BASE + ((i) * USB_OTG_FIFO_SIZE))
-
-#define USBx_HOST ((USB_OTG_HostTypeDef *)(USBx_BASE + USB_OTG_HOST_BASE))
-#define USBx_HC(i) ((USB_OTG_HostChannelTypeDef *)(USBx_BASE\
- + USB_OTG_HOST_CHANNEL_BASE\
- + ((i) * USB_OTG_HOST_CHANNEL_SIZE)))
-
-
-#define EP_ADDR_MSK 0xFU
-#endif /* defined (USB_OTG_FS) || defined (USB_OTG_HS) */
-/**
- * @}
- */
-
-/* Exported macro ------------------------------------------------------------*/
-/** @defgroup USB_LL_Exported_Macros USB Low Layer Exported Macros
- * @{
- */
-#if defined (USB_OTG_FS) || defined (USB_OTG_HS)
-#define USB_MASK_INTERRUPT(__INSTANCE__, __INTERRUPT__) ((__INSTANCE__)->GINTMSK &= ~(__INTERRUPT__))
-#define USB_UNMASK_INTERRUPT(__INSTANCE__, __INTERRUPT__) ((__INSTANCE__)->GINTMSK |= (__INTERRUPT__))
-
-#define CLEAR_IN_EP_INTR(__EPNUM__, __INTERRUPT__) (USBx_INEP(__EPNUM__)->DIEPINT = (__INTERRUPT__))
-#define CLEAR_OUT_EP_INTR(__EPNUM__, __INTERRUPT__) (USBx_OUTEP(__EPNUM__)->DOEPINT = (__INTERRUPT__))
-#endif /* defined (USB_OTG_FS) || defined (USB_OTG_HS) */
-/**
- * @}
- */
-
-/* Exported functions --------------------------------------------------------*/
-/** @addtogroup USB_LL_Exported_Functions USB Low Layer Exported Functions
- * @{
- */
-#if defined (USB_OTG_FS) || defined (USB_OTG_HS)
-HAL_StatusTypeDef USB_CoreInit(USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef cfg);
-HAL_StatusTypeDef USB_DevInit(USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef cfg);
-HAL_StatusTypeDef USB_EnableGlobalInt(USB_OTG_GlobalTypeDef *USBx);
-HAL_StatusTypeDef USB_DisableGlobalInt(USB_OTG_GlobalTypeDef *USBx);
-HAL_StatusTypeDef USB_SetTurnaroundTime(USB_OTG_GlobalTypeDef *USBx, uint32_t hclk, uint8_t speed);
-HAL_StatusTypeDef USB_SetCurrentMode(USB_OTG_GlobalTypeDef *USBx, USB_OTG_ModeTypeDef mode);
-HAL_StatusTypeDef USB_SetDevSpeed(USB_OTG_GlobalTypeDef *USBx, uint8_t speed);
-HAL_StatusTypeDef USB_FlushRxFifo(USB_OTG_GlobalTypeDef *USBx);
-HAL_StatusTypeDef USB_FlushTxFifo(USB_OTG_GlobalTypeDef *USBx, uint32_t num);
-HAL_StatusTypeDef USB_ActivateEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep);
-HAL_StatusTypeDef USB_DeactivateEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep);
-HAL_StatusTypeDef USB_ActivateDedicatedEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep);
-HAL_StatusTypeDef USB_DeactivateDedicatedEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep);
-HAL_StatusTypeDef USB_EPStartXfer(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep, uint8_t dma);
-HAL_StatusTypeDef USB_WritePacket(USB_OTG_GlobalTypeDef *USBx, uint8_t *src,
- uint8_t ch_ep_num, uint16_t len, uint8_t dma);
-
-void *USB_ReadPacket(USB_OTG_GlobalTypeDef *USBx, uint8_t *dest, uint16_t len);
-HAL_StatusTypeDef USB_EPSetStall(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep);
-HAL_StatusTypeDef USB_EPClearStall(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep);
-HAL_StatusTypeDef USB_EPStopXfer(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep);
-HAL_StatusTypeDef USB_SetDevAddress(USB_OTG_GlobalTypeDef *USBx, uint8_t address);
-HAL_StatusTypeDef USB_DevConnect(USB_OTG_GlobalTypeDef *USBx);
-HAL_StatusTypeDef USB_DevDisconnect(USB_OTG_GlobalTypeDef *USBx);
-HAL_StatusTypeDef USB_StopDevice(USB_OTG_GlobalTypeDef *USBx);
-HAL_StatusTypeDef USB_ActivateSetup(USB_OTG_GlobalTypeDef *USBx);
-HAL_StatusTypeDef USB_EP0_OutStart(USB_OTG_GlobalTypeDef *USBx, uint8_t dma, uint8_t *psetup);
-uint8_t USB_GetDevSpeed(USB_OTG_GlobalTypeDef *USBx);
-uint32_t USB_GetMode(USB_OTG_GlobalTypeDef *USBx);
-uint32_t USB_ReadInterrupts(USB_OTG_GlobalTypeDef *USBx);
-uint32_t USB_ReadChInterrupts(USB_OTG_GlobalTypeDef *USBx, uint8_t chnum);
-uint32_t USB_ReadDevAllOutEpInterrupt(USB_OTG_GlobalTypeDef *USBx);
-uint32_t USB_ReadDevOutEPInterrupt(USB_OTG_GlobalTypeDef *USBx, uint8_t epnum);
-uint32_t USB_ReadDevAllInEpInterrupt(USB_OTG_GlobalTypeDef *USBx);
-uint32_t USB_ReadDevInEPInterrupt(USB_OTG_GlobalTypeDef *USBx, uint8_t epnum);
-void USB_ClearInterrupts(USB_OTG_GlobalTypeDef *USBx, uint32_t interrupt);
-
-HAL_StatusTypeDef USB_HostInit(USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef cfg);
-HAL_StatusTypeDef USB_InitFSLSPClkSel(USB_OTG_GlobalTypeDef *USBx, uint8_t freq);
-HAL_StatusTypeDef USB_ResetPort(USB_OTG_GlobalTypeDef *USBx);
-HAL_StatusTypeDef USB_DriveVbus(USB_OTG_GlobalTypeDef *USBx, uint8_t state);
-uint32_t USB_GetHostSpeed(USB_OTG_GlobalTypeDef *USBx);
-uint32_t USB_GetCurrentFrame(USB_OTG_GlobalTypeDef *USBx);
-HAL_StatusTypeDef USB_HC_Init(USB_OTG_GlobalTypeDef *USBx, uint8_t ch_num,
- uint8_t epnum, uint8_t dev_address, uint8_t speed,
- uint8_t ep_type, uint16_t mps);
-HAL_StatusTypeDef USB_HC_StartXfer(USB_OTG_GlobalTypeDef *USBx,
- USB_OTG_HCTypeDef *hc, uint8_t dma);
-
-uint32_t USB_HC_ReadInterrupt(USB_OTG_GlobalTypeDef *USBx);
-HAL_StatusTypeDef USB_HC_Halt(USB_OTG_GlobalTypeDef *USBx, uint8_t hc_num);
-HAL_StatusTypeDef USB_DoPing(USB_OTG_GlobalTypeDef *USBx, uint8_t ch_num);
-HAL_StatusTypeDef USB_StopHost(USB_OTG_GlobalTypeDef *USBx);
-HAL_StatusTypeDef USB_ActivateRemoteWakeup(USB_OTG_GlobalTypeDef *USBx);
-HAL_StatusTypeDef USB_DeActivateRemoteWakeup(USB_OTG_GlobalTypeDef *USBx);
-#endif /* defined (USB_OTG_FS) || defined (USB_OTG_HS) */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-#endif /* defined (USB_OTG_FS) || defined (USB_OTG_HS) */
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-
-#endif /* STM32H7xx_LL_USB_H */
diff --git a/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_eth.c b/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_eth.c
deleted file mode 100644
index f1c09d9..0000000
--- a/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_eth.c
+++ /dev/null
@@ -1,3361 +0,0 @@
-/**
- ******************************************************************************
- * @file stm32h7xx_hal_eth.c
- * @author MCD Application Team
- * @brief ETH HAL module driver.
- * This file provides firmware functions to manage the following
- * functionalities of the Ethernet (ETH) peripheral:
- * + Initialization and deinitialization functions
- * + IO operation functions
- * + Peripheral Control functions
- * + Peripheral State and Errors functions
- *
- ******************************************************************************
- * @attention
- *
- * Copyright (c) 2017 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.
- *
- ******************************************************************************
- @verbatim
- ==============================================================================
- ##### How to use this driver #####
- ==============================================================================
- [..]
- The ETH HAL driver can be used as follows:
-
- (#)Declare a ETH_HandleTypeDef handle structure, for example:
- ETH_HandleTypeDef heth;
-
- (#)Fill parameters of Init structure in heth handle
-
- (#)Call HAL_ETH_Init() API to initialize the Ethernet peripheral (MAC, DMA, ...)
-
- (#)Initialize the ETH low level resources through the HAL_ETH_MspInit() API:
- (##) Enable the Ethernet interface clock using
- (+++) __HAL_RCC_ETH1MAC_CLK_ENABLE()
- (+++) __HAL_RCC_ETH1TX_CLK_ENABLE()
- (+++) __HAL_RCC_ETH1RX_CLK_ENABLE()
-
- (##) Initialize the related GPIO clocks
- (##) Configure Ethernet pinout
- (##) Configure Ethernet NVIC interrupt (in Interrupt mode)
-
- (#) Ethernet data reception is asynchronous, so call the following API
- to start the listening mode:
- (##) HAL_ETH_Start():
- This API starts the MAC and DMA transmission and reception process,
- without enabling end of transfer interrupts, in this mode user
- has to poll for data reception by calling HAL_ETH_ReadData()
- (##) HAL_ETH_Start_IT():
- This API starts the MAC and DMA transmission and reception process,
- end of transfer interrupts are enabled in this mode,
- HAL_ETH_RxCpltCallback() will be executed when an Ethernet packet is received
-
- (#) When data is received user can call the following API to get received data:
- (##) HAL_ETH_ReadData(): Read a received packet
-
- (#) For transmission path, two APIs are available:
- (##) HAL_ETH_Transmit(): Transmit an ETH frame in blocking mode
- (##) HAL_ETH_Transmit_IT(): Transmit an ETH frame in interrupt mode,
- HAL_ETH_TxCpltCallback() will be executed when end of transfer occur
-
- (#) Communication with an external PHY device:
- (##) HAL_ETH_ReadPHYRegister(): Read a register from an external PHY
- (##) HAL_ETH_WritePHYRegister(): Write data to an external RHY register
-
- (#) Configure the Ethernet MAC after ETH peripheral initialization
- (##) HAL_ETH_GetMACConfig(): Get MAC actual configuration into ETH_MACConfigTypeDef
- (##) HAL_ETH_SetMACConfig(): Set MAC configuration based on ETH_MACConfigTypeDef
-
- (#) Configure the Ethernet DMA after ETH peripheral initialization
- (##) HAL_ETH_GetDMAConfig(): Get DMA actual configuration into ETH_DMAConfigTypeDef
- (##) HAL_ETH_SetDMAConfig(): Set DMA configuration based on ETH_DMAConfigTypeDef
-
- (#) Configure the Ethernet PTP after ETH peripheral initialization
- (##) Define HAL_ETH_USE_PTP to use PTP APIs.
- (##) HAL_ETH_PTP_GetConfig(): Get PTP actual configuration into ETH_PTP_ConfigTypeDef
- (##) HAL_ETH_PTP_SetConfig(): Set PTP configuration based on ETH_PTP_ConfigTypeDef
- (##) HAL_ETH_PTP_GetTime(): Get Seconds and Nanoseconds for the Ethernet PTP registers
- (##) HAL_ETH_PTP_SetTime(): Set Seconds and Nanoseconds for the Ethernet PTP registers
- (##) HAL_ETH_PTP_AddTimeOffset(): Add Seconds and Nanoseconds offset for the Ethernet PTP registers
- (##) HAL_ETH_PTP_InsertTxTimestamp(): Insert Timestamp in transmission
- (##) HAL_ETH_PTP_GetTxTimestamp(): Get transmission timestamp
- (##) HAL_ETH_PTP_GetRxTimestamp(): Get reception timestamp
-
- -@- The ARP offload feature is not supported in this driver.
-
- -@- The PTP offload feature is not supported in this driver.
-
- *** Callback registration ***
- =============================================
-
- The compilation define USE_HAL_ETH_REGISTER_CALLBACKS when set to 1
- allows the user to configure dynamically the driver callbacks.
- Use Function HAL_ETH_RegisterCallback() to register an interrupt callback.
-
- Function HAL_ETH_RegisterCallback() allows to register following callbacks:
- (+) TxCpltCallback : Tx Complete Callback.
- (+) RxCpltCallback : Rx Complete Callback.
- (+) ErrorCallback : Error Callback.
- (+) PMTCallback : Power Management Callback
- (+) EEECallback : EEE Callback.
- (+) WakeUpCallback : Wake UP Callback
- (+) MspInitCallback : MspInit Callback.
- (+) MspDeInitCallback: MspDeInit Callback.
-
- This function takes as parameters the HAL peripheral handle, the Callback ID
- and a pointer to the user callback function.
-
- For specific callbacks RxAllocateCallback use dedicated register callbacks:
- respectively HAL_ETH_RegisterRxAllocateCallback().
-
- For specific callbacks RxLinkCallback use dedicated register callbacks:
- respectively HAL_ETH_RegisterRxLinkCallback().
-
- For specific callbacks TxFreeCallback use dedicated register callbacks:
- respectively HAL_ETH_RegisterTxFreeCallback().
-
- For specific callbacks TxPtpCallback use dedicated register callbacks:
- respectively HAL_ETH_RegisterTxPtpCallback().
-
- Use function HAL_ETH_UnRegisterCallback() to reset a callback to the default
- weak function.
- HAL_ETH_UnRegisterCallback takes as parameters the HAL peripheral handle,
- and the Callback ID.
- This function allows to reset following callbacks:
- (+) TxCpltCallback : Tx Complete Callback.
- (+) RxCpltCallback : Rx Complete Callback.
- (+) ErrorCallback : Error Callback.
- (+) PMTCallback : Power Management Callback
- (+) EEECallback : EEE Callback.
- (+) WakeUpCallback : Wake UP Callback
- (+) MspInitCallback : MspInit Callback.
- (+) MspDeInitCallback: MspDeInit Callback.
-
- For specific callbacks RxAllocateCallback use dedicated unregister callbacks:
- respectively HAL_ETH_UnRegisterRxAllocateCallback().
-
- For specific callbacks RxLinkCallback use dedicated unregister callbacks:
- respectively HAL_ETH_UnRegisterRxLinkCallback().
-
- For specific callbacks TxFreeCallback use dedicated unregister callbacks:
- respectively HAL_ETH_UnRegisterTxFreeCallback().
-
- For specific callbacks TxPtpCallback use dedicated unregister callbacks:
- respectively HAL_ETH_UnRegisterTxPtpCallback().
-
- By default, after the HAL_ETH_Init and when the state is HAL_ETH_STATE_RESET
- all callbacks are set to the corresponding weak functions:
- examples HAL_ETH_TxCpltCallback(), HAL_ETH_RxCpltCallback().
- Exception done for MspInit and MspDeInit functions that are
- reset to the legacy weak function in the HAL_ETH_Init/ HAL_ETH_DeInit only when
- these callbacks are null (not registered beforehand).
- if not, MspInit or MspDeInit are not null, the HAL_ETH_Init/ HAL_ETH_DeInit
- keep and use the user MspInit/MspDeInit callbacks (registered beforehand)
-
- Callbacks can be registered/unregistered in HAL_ETH_STATE_READY state only.
- Exception done MspInit/MspDeInit that can be registered/unregistered
- in HAL_ETH_STATE_READY or HAL_ETH_STATE_RESET state,
- thus registered (user) MspInit/DeInit callbacks can be used during the Init/DeInit.
- In that case first register the MspInit/MspDeInit user callbacks
- using HAL_ETH_RegisterCallback() before calling HAL_ETH_DeInit
- or HAL_ETH_Init function.
-
- When The compilation define USE_HAL_ETH_REGISTER_CALLBACKS is set to 0 or
- not defined, the callback registration feature is not available and all callbacks
- are set to the corresponding weak functions.
-
- @endverbatim
- ******************************************************************************
- */
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32h7xx_hal.h"
-
-/** @addtogroup STM32H7xx_HAL_Driver
- * @{
- */
-#ifdef HAL_ETH_MODULE_ENABLED
-
-#if defined(ETH)
-
-/** @defgroup ETH ETH
- * @brief ETH HAL module driver
- * @{
- */
-
-/* Private typedef -----------------------------------------------------------*/
-/* Private define ------------------------------------------------------------*/
-/** @addtogroup ETH_Private_Constants ETH Private Constants
- * @{
- */
-#define ETH_MACCR_MASK 0xFFFB7F7CU
-#define ETH_MACECR_MASK 0x3F077FFFU
-#define ETH_MACPFR_MASK 0x800007FFU
-#define ETH_MACWTR_MASK 0x0000010FU
-#define ETH_MACTFCR_MASK 0xFFFF00F2U
-#define ETH_MACRFCR_MASK 0x00000003U
-#define ETH_MTLTQOMR_MASK 0x00000072U
-#define ETH_MTLRQOMR_MASK 0x0000007BU
-
-#define ETH_DMAMR_MASK 0x00007802U
-#define ETH_DMASBMR_MASK 0x0000D001U
-#define ETH_DMACCR_MASK 0x00013FFFU
-#define ETH_DMACTCR_MASK 0x003F1010U
-#define ETH_DMACRCR_MASK 0x803F0000U
-#define ETH_MACPCSR_MASK (ETH_MACPCSR_PWRDWN | ETH_MACPCSR_RWKPKTEN | \
- ETH_MACPCSR_MGKPKTEN | ETH_MACPCSR_GLBLUCAST | \
- ETH_MACPCSR_RWKPFE)
-
-/* Timeout values */
-#define ETH_DMARXNDESCWBF_ERRORS_MASK ((uint32_t)(ETH_DMARXNDESCWBF_DE | ETH_DMARXNDESCWBF_RE | \
- ETH_DMARXNDESCWBF_OE | ETH_DMARXNDESCWBF_RWT |\
- ETH_DMARXNDESCWBF_GP | ETH_DMARXNDESCWBF_CE))
-
-#define ETH_MACTSCR_MASK 0x0087FF2FU
-
-#define ETH_MACSTSUR_VALUE 0xFFFFFFFFU
-#define ETH_MACSTNUR_VALUE 0xBB9ACA00U
-#define ETH_SEGMENT_SIZE_DEFAULT 0x218U
-/**
- * @}
- */
-
-/* Private macros ------------------------------------------------------------*/
-/** @defgroup ETH_Private_Macros ETH Private Macros
- * @{
- */
-/* Helper macros for TX descriptor handling */
-#define INCR_TX_DESC_INDEX(inx, offset) do {\
- (inx) += (offset);\
- if ((inx) >= (uint32_t)ETH_TX_DESC_CNT){\
- (inx) = ((inx) - (uint32_t)ETH_TX_DESC_CNT);}\
- } while (0)
-
-/* Helper macros for RX descriptor handling */
-#define INCR_RX_DESC_INDEX(inx, offset) do {\
- (inx) += (offset);\
- if ((inx) >= (uint32_t)ETH_RX_DESC_CNT){\
- (inx) = ((inx) - (uint32_t)ETH_RX_DESC_CNT);}\
- } while (0)
-/**
- * @}
- */
-/* Private function prototypes -----------------------------------------------*/
-/** @defgroup ETH_Private_Functions ETH Private Functions
- * @{
- */
-static void ETH_SetMACConfig(ETH_HandleTypeDef *heth, ETH_MACConfigTypeDef *macconf);
-static void ETH_SetDMAConfig(ETH_HandleTypeDef *heth, ETH_DMAConfigTypeDef *dmaconf);
-static void ETH_MACDMAConfig(ETH_HandleTypeDef *heth);
-static void ETH_DMATxDescListInit(ETH_HandleTypeDef *heth);
-static void ETH_DMARxDescListInit(ETH_HandleTypeDef *heth);
-static uint32_t ETH_Prepare_Tx_Descriptors(ETH_HandleTypeDef *heth, ETH_TxPacketConfig *pTxConfig, uint32_t ItMode);
-static void ETH_UpdateDescriptor(ETH_HandleTypeDef *heth);
-
-#if (USE_HAL_ETH_REGISTER_CALLBACKS == 1)
-static void ETH_InitCallbacksToDefault(ETH_HandleTypeDef *heth);
-#endif /* USE_HAL_ETH_REGISTER_CALLBACKS */
-/**
- * @}
- */
-
-/* Exported functions ---------------------------------------------------------*/
-/** @defgroup ETH_Exported_Functions ETH Exported Functions
- * @{
- */
-
-/** @defgroup ETH_Exported_Functions_Group1 Initialization and deinitialization functions
- * @brief Initialization and Configuration functions
- *
-@verbatim
-===============================================================================
- ##### Initialization and Configuration functions #####
- ===============================================================================
- [..] This subsection provides a set of functions allowing to initialize and
- deinitialize the ETH peripheral:
-
- (+) User must Implement HAL_ETH_MspInit() function in which he configures
- all related peripherals resources (CLOCK, GPIO and NVIC ).
-
- (+) Call the function HAL_ETH_Init() to configure the selected device with
- the selected configuration:
- (++) MAC address
- (++) Media interface (MII or RMII)
- (++) Rx DMA Descriptors Tab
- (++) Tx DMA Descriptors Tab
- (++) Length of Rx Buffers
-
- (+) Call the function HAL_ETH_DeInit() to restore the default configuration
- of the selected ETH peripheral.
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Initialize the Ethernet peripheral registers.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_ETH_Init(ETH_HandleTypeDef *heth)
-{
- uint32_t tickstart;
-
- if (heth == NULL)
- {
- return HAL_ERROR;
- }
- if (heth->gState == HAL_ETH_STATE_RESET)
- {
- heth->gState = HAL_ETH_STATE_BUSY;
-
-#if (USE_HAL_ETH_REGISTER_CALLBACKS == 1)
-
- ETH_InitCallbacksToDefault(heth);
-
- if (heth->MspInitCallback == NULL)
- {
- heth->MspInitCallback = HAL_ETH_MspInit;
- }
-
- /* Init the low level hardware */
- heth->MspInitCallback(heth);
-#else
- /* Init the low level hardware : GPIO, CLOCK, NVIC. */
- HAL_ETH_MspInit(heth);
-
-#endif /* (USE_HAL_ETH_REGISTER_CALLBACKS) */
- }
-
- __HAL_RCC_SYSCFG_CLK_ENABLE();
-
- if (heth->Init.MediaInterface == HAL_ETH_MII_MODE)
- {
- HAL_SYSCFG_ETHInterfaceSelect(SYSCFG_ETH_MII);
- }
- else
- {
- HAL_SYSCFG_ETHInterfaceSelect(SYSCFG_ETH_RMII);
- }
-
- /* Dummy read to sync with ETH */
- (void)SYSCFG->PMCR;
-
- /* Ethernet Software reset */
- /* Set the SWR bit: resets all MAC subsystem internal registers and logic */
- /* After reset all the registers holds their respective reset values */
- SET_BIT(heth->Instance->DMAMR, ETH_DMAMR_SWR);
-
- /* Get tick */
- tickstart = HAL_GetTick();
-
- /* Wait for software reset */
- while (READ_BIT(heth->Instance->DMAMR, ETH_DMAMR_SWR) > 0U)
- {
- if (((HAL_GetTick() - tickstart) > ETH_SWRESET_TIMEOUT))
- {
- /* Set Error Code */
- heth->ErrorCode = HAL_ETH_ERROR_TIMEOUT;
- /* Set State as Error */
- heth->gState = HAL_ETH_STATE_ERROR;
- /* Return Error */
- return HAL_ERROR;
- }
- }
-
- /*------------------ MDIO CSR Clock Range Configuration --------------------*/
- HAL_ETH_SetMDIOClockRange(heth);
-
- /*------------------ MAC LPI 1US Tic Counter Configuration --------------------*/
- WRITE_REG(heth->Instance->MAC1USTCR, (((uint32_t)HAL_RCC_GetHCLKFreq() / ETH_MAC_US_TICK) - 1U));
-
- /*------------------ MAC, MTL and DMA default Configuration ----------------*/
- ETH_MACDMAConfig(heth);
-
- /* SET DSL to 64 bit */
- MODIFY_REG(heth->Instance->DMACCR, ETH_DMACCR_DSL, ETH_DMACCR_DSL_64BIT);
-
- /* Set Receive Buffers Length (must be a multiple of 4) */
- if ((heth->Init.RxBuffLen % 0x4U) != 0x0U)
- {
- /* Set Error Code */
- heth->ErrorCode = HAL_ETH_ERROR_PARAM;
- /* Set State as Error */
- heth->gState = HAL_ETH_STATE_ERROR;
- /* Return Error */
- return HAL_ERROR;
- }
- else
- {
- MODIFY_REG(heth->Instance->DMACRCR, ETH_DMACRCR_RBSZ, ((heth->Init.RxBuffLen) << 1));
- }
-
- /*------------------ DMA Tx Descriptors Configuration ----------------------*/
- ETH_DMATxDescListInit(heth);
-
- /*------------------ DMA Rx Descriptors Configuration ----------------------*/
- ETH_DMARxDescListInit(heth);
-
- /*--------------------- ETHERNET MAC Address Configuration ------------------*/
- /* Set MAC addr bits 32 to 47 */
- heth->Instance->MACA0HR = (((uint32_t)(heth->Init.MACAddr[5]) << 8) | (uint32_t)heth->Init.MACAddr[4]);
- /* Set MAC addr bits 0 to 31 */
- heth->Instance->MACA0LR = (((uint32_t)(heth->Init.MACAddr[3]) << 24) | ((uint32_t)(heth->Init.MACAddr[2]) << 16) |
- ((uint32_t)(heth->Init.MACAddr[1]) << 8) | (uint32_t)heth->Init.MACAddr[0]);
-
- heth->ErrorCode = HAL_ETH_ERROR_NONE;
- heth->gState = HAL_ETH_STATE_READY;
-
- return HAL_OK;
-}
-
-/**
- * @brief DeInitializes the ETH peripheral.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_ETH_DeInit(ETH_HandleTypeDef *heth)
-{
- /* Set the ETH peripheral state to BUSY */
- heth->gState = HAL_ETH_STATE_BUSY;
-
-#if (USE_HAL_ETH_REGISTER_CALLBACKS == 1)
-
- if (heth->MspDeInitCallback == NULL)
- {
- heth->MspDeInitCallback = HAL_ETH_MspDeInit;
- }
- /* DeInit the low level hardware */
- heth->MspDeInitCallback(heth);
-#else
-
- /* De-Init the low level hardware : GPIO, CLOCK, NVIC. */
- HAL_ETH_MspDeInit(heth);
-
-#endif /* (USE_HAL_ETH_REGISTER_CALLBACKS) */
-
- /* Set ETH HAL state to Disabled */
- heth->gState = HAL_ETH_STATE_RESET;
-
- /* Return function status */
- return HAL_OK;
-}
-
-/**
- * @brief Initializes the ETH MSP.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @retval None
- */
-__weak void HAL_ETH_MspInit(ETH_HandleTypeDef *heth)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(heth);
- /* NOTE : This function Should not be modified, when the callback is needed,
- the HAL_ETH_MspInit could be implemented in the user file
- */
-}
-
-/**
- * @brief DeInitializes ETH MSP.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @retval None
- */
-__weak void HAL_ETH_MspDeInit(ETH_HandleTypeDef *heth)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(heth);
- /* NOTE : This function Should not be modified, when the callback is needed,
- the HAL_ETH_MspDeInit could be implemented in the user file
- */
-}
-
-#if (USE_HAL_ETH_REGISTER_CALLBACKS == 1)
-/**
- * @brief Register a User ETH Callback
- * To be used instead of the weak predefined callback
- * @param heth eth handle
- * @param CallbackID ID of the callback to be registered
- * This parameter can be one of the following values:
- * @arg @ref HAL_ETH_TX_COMPLETE_CB_ID Tx Complete Callback ID
- * @arg @ref HAL_ETH_RX_COMPLETE_CB_ID Rx Complete Callback ID
- * @arg @ref HAL_ETH_ERROR_CB_ID Error Callback ID
- * @arg @ref HAL_ETH_PMT_CB_ID Power Management Callback ID
- * @arg @ref HAL_ETH_EEE_CB_ID EEE Callback ID
- * @arg @ref HAL_ETH_WAKEUP_CB_ID Wake UP Callback ID
- * @arg @ref HAL_ETH_MSPINIT_CB_ID MspInit callback ID
- * @arg @ref HAL_ETH_MSPDEINIT_CB_ID MspDeInit callback ID
- * @param pCallback pointer to the Callback function
- * @retval status
- */
-HAL_StatusTypeDef HAL_ETH_RegisterCallback(ETH_HandleTypeDef *heth, HAL_ETH_CallbackIDTypeDef CallbackID,
- pETH_CallbackTypeDef pCallback)
-{
- HAL_StatusTypeDef status = HAL_OK;
-
- if (pCallback == NULL)
- {
- /* Update the error code */
- heth->ErrorCode |= HAL_ETH_ERROR_INVALID_CALLBACK;
-
- return HAL_ERROR;
- }
-
- if (heth->gState == HAL_ETH_STATE_READY)
- {
- switch (CallbackID)
- {
- case HAL_ETH_TX_COMPLETE_CB_ID :
- heth->TxCpltCallback = pCallback;
- break;
-
- case HAL_ETH_RX_COMPLETE_CB_ID :
- heth->RxCpltCallback = pCallback;
- break;
-
- case HAL_ETH_ERROR_CB_ID :
- heth->ErrorCallback = pCallback;
- break;
-
- case HAL_ETH_PMT_CB_ID :
- heth->PMTCallback = pCallback;
- break;
-
- case HAL_ETH_EEE_CB_ID :
- heth->EEECallback = pCallback;
- break;
-
- case HAL_ETH_WAKEUP_CB_ID :
- heth->WakeUpCallback = pCallback;
- break;
-
- case HAL_ETH_MSPINIT_CB_ID :
- heth->MspInitCallback = pCallback;
- break;
-
- case HAL_ETH_MSPDEINIT_CB_ID :
- heth->MspDeInitCallback = pCallback;
- break;
-
- default :
- /* Update the error code */
- heth->ErrorCode |= HAL_ETH_ERROR_INVALID_CALLBACK;
- /* Return error status */
- status = HAL_ERROR;
- break;
- }
- }
- else if (heth->gState == HAL_ETH_STATE_RESET)
- {
- switch (CallbackID)
- {
- case HAL_ETH_MSPINIT_CB_ID :
- heth->MspInitCallback = pCallback;
- break;
-
- case HAL_ETH_MSPDEINIT_CB_ID :
- heth->MspDeInitCallback = pCallback;
- break;
-
- default :
- /* Update the error code */
- heth->ErrorCode |= HAL_ETH_ERROR_INVALID_CALLBACK;
- /* Return error status */
- status = HAL_ERROR;
- break;
- }
- }
- else
- {
- /* Update the error code */
- heth->ErrorCode |= HAL_ETH_ERROR_INVALID_CALLBACK;
- /* Return error status */
- status = HAL_ERROR;
- }
-
- return status;
-}
-
-/**
- * @brief Unregister an ETH Callback
- * ETH callabck is redirected to the weak predefined callback
- * @param heth eth handle
- * @param CallbackID ID of the callback to be unregistered
- * This parameter can be one of the following values:
- * @arg @ref HAL_ETH_TX_COMPLETE_CB_ID Tx Complete Callback ID
- * @arg @ref HAL_ETH_RX_COMPLETE_CB_ID Rx Complete Callback ID
- * @arg @ref HAL_ETH_ERROR_CB_ID Error Callback ID
- * @arg @ref HAL_ETH_PMT_CB_ID Power Management Callback ID
- * @arg @ref HAL_ETH_EEE_CB_ID EEE Callback ID
- * @arg @ref HAL_ETH_WAKEUP_CB_ID Wake UP Callback ID
- * @arg @ref HAL_ETH_MSPINIT_CB_ID MspInit callback ID
- * @arg @ref HAL_ETH_MSPDEINIT_CB_ID MspDeInit callback ID
- * @retval status
- */
-HAL_StatusTypeDef HAL_ETH_UnRegisterCallback(ETH_HandleTypeDef *heth, HAL_ETH_CallbackIDTypeDef CallbackID)
-{
- HAL_StatusTypeDef status = HAL_OK;
-
- if (heth->gState == HAL_ETH_STATE_READY)
- {
- switch (CallbackID)
- {
- case HAL_ETH_TX_COMPLETE_CB_ID :
- heth->TxCpltCallback = HAL_ETH_TxCpltCallback;
- break;
-
- case HAL_ETH_RX_COMPLETE_CB_ID :
- heth->RxCpltCallback = HAL_ETH_RxCpltCallback;
- break;
-
- case HAL_ETH_ERROR_CB_ID :
- heth->ErrorCallback = HAL_ETH_ErrorCallback;
- break;
-
- case HAL_ETH_PMT_CB_ID :
- heth->PMTCallback = HAL_ETH_PMTCallback;
- break;
-
- case HAL_ETH_EEE_CB_ID :
- heth->EEECallback = HAL_ETH_EEECallback;
- break;
-
- case HAL_ETH_WAKEUP_CB_ID :
- heth->WakeUpCallback = HAL_ETH_WakeUpCallback;
- break;
-
- case HAL_ETH_MSPINIT_CB_ID :
- heth->MspInitCallback = HAL_ETH_MspInit;
- break;
-
- case HAL_ETH_MSPDEINIT_CB_ID :
- heth->MspDeInitCallback = HAL_ETH_MspDeInit;
- break;
-
- default :
- /* Update the error code */
- heth->ErrorCode |= HAL_ETH_ERROR_INVALID_CALLBACK;
- /* Return error status */
- status = HAL_ERROR;
- break;
- }
- }
- else if (heth->gState == HAL_ETH_STATE_RESET)
- {
- switch (CallbackID)
- {
- case HAL_ETH_MSPINIT_CB_ID :
- heth->MspInitCallback = HAL_ETH_MspInit;
- break;
-
- case HAL_ETH_MSPDEINIT_CB_ID :
- heth->MspDeInitCallback = HAL_ETH_MspDeInit;
- break;
-
- default :
- /* Update the error code */
- heth->ErrorCode |= HAL_ETH_ERROR_INVALID_CALLBACK;
- /* Return error status */
- status = HAL_ERROR;
- break;
- }
- }
- else
- {
- /* Update the error code */
- heth->ErrorCode |= HAL_ETH_ERROR_INVALID_CALLBACK;
- /* Return error status */
- status = HAL_ERROR;
- }
-
- return status;
-}
-#endif /* USE_HAL_ETH_REGISTER_CALLBACKS */
-
-/**
- * @}
- */
-
-/** @defgroup ETH_Exported_Functions_Group2 IO operation functions
- * @brief ETH Transmit and Receive functions
- *
-@verbatim
- ==============================================================================
- ##### IO operation functions #####
- ==============================================================================
- [..]
- This subsection provides a set of functions allowing to manage the ETH
- data transfer.
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Enables Ethernet MAC and DMA reception and transmission
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_ETH_Start(ETH_HandleTypeDef *heth)
-{
- if (heth->gState == HAL_ETH_STATE_READY)
- {
- heth->gState = HAL_ETH_STATE_BUSY;
-
- /* Set nombre of descriptors to build */
- heth->RxDescList.RxBuildDescCnt = ETH_RX_DESC_CNT;
-
- /* Build all descriptors */
- ETH_UpdateDescriptor(heth);
-
- /* Enable the MAC transmission */
- SET_BIT(heth->Instance->MACCR, ETH_MACCR_TE);
-
- /* Enable the MAC reception */
- SET_BIT(heth->Instance->MACCR, ETH_MACCR_RE);
-
- /* Set the Flush Transmit FIFO bit */
- SET_BIT(heth->Instance->MTLTQOMR, ETH_MTLTQOMR_FTQ);
-
- /* Enable the DMA transmission */
- SET_BIT(heth->Instance->DMACTCR, ETH_DMACTCR_ST);
-
- /* Enable the DMA reception */
- SET_BIT(heth->Instance->DMACRCR, ETH_DMACRCR_SR);
-
- /* Clear Tx and Rx process stopped flags */
- heth->Instance->DMACSR |= (ETH_DMACSR_TPS | ETH_DMACSR_RPS);
-
- heth->gState = HAL_ETH_STATE_STARTED;
-
- return HAL_OK;
- }
- else
- {
- return HAL_ERROR;
- }
-}
-
-/**
- * @brief Enables Ethernet MAC and DMA reception/transmission in Interrupt mode
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_ETH_Start_IT(ETH_HandleTypeDef *heth)
-{
- if (heth->gState == HAL_ETH_STATE_READY)
- {
- heth->gState = HAL_ETH_STATE_BUSY;
-
- /* save IT mode to ETH Handle */
- heth->RxDescList.ItMode = 1U;
- /* Disable Rx MMC Interrupts */
- SET_BIT(heth->Instance->MMCRIMR, ETH_MMCRIMR_RXLPITRCIM | ETH_MMCRIMR_RXLPIUSCIM | \
- ETH_MMCRIMR_RXUCGPIM | ETH_MMCRIMR_RXALGNERPIM | ETH_MMCRIMR_RXCRCERPIM);
-
- /* Disable Tx MMC Interrupts */
- SET_BIT(heth->Instance->MMCTIMR, ETH_MMCTIMR_TXLPITRCIM | ETH_MMCTIMR_TXLPIUSCIM | \
- ETH_MMCTIMR_TXGPKTIM | ETH_MMCTIMR_TXMCOLGPIM | ETH_MMCTIMR_TXSCOLGPIM);
-
- /* Set nombre of descriptors to build */
- heth->RxDescList.RxBuildDescCnt = ETH_RX_DESC_CNT;
-
- /* Build all descriptors */
- ETH_UpdateDescriptor(heth);
-
- /* Enable the MAC transmission */
- SET_BIT(heth->Instance->MACCR, ETH_MACCR_TE);
-
- /* Enable the MAC reception */
- SET_BIT(heth->Instance->MACCR, ETH_MACCR_RE);
-
- /* Set the Flush Transmit FIFO bit */
- SET_BIT(heth->Instance->MTLTQOMR, ETH_MTLTQOMR_FTQ);
-
- /* Enable the DMA transmission */
- SET_BIT(heth->Instance->DMACTCR, ETH_DMACTCR_ST);
-
- /* Enable the DMA reception */
- SET_BIT(heth->Instance->DMACRCR, ETH_DMACRCR_SR);
-
- /* Clear Tx and Rx process stopped flags */
- heth->Instance->DMACSR |= (ETH_DMACSR_TPS | ETH_DMACSR_RPS);
-
- /* Enable ETH DMA interrupts:
- - Tx complete interrupt
- - Rx complete interrupt
- - Fatal bus interrupt
- */
- __HAL_ETH_DMA_ENABLE_IT(heth, (ETH_DMACIER_NIE | ETH_DMACIER_RIE | ETH_DMACIER_TIE |
- ETH_DMACIER_FBEE | ETH_DMACIER_AIE | ETH_DMACIER_RBUE));
-
- heth->gState = HAL_ETH_STATE_STARTED;
- return HAL_OK;
- }
- else
- {
- return HAL_ERROR;
- }
-}
-
-/**
- * @brief Stop Ethernet MAC and DMA reception/transmission
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_ETH_Stop(ETH_HandleTypeDef *heth)
-{
- if (heth->gState == HAL_ETH_STATE_STARTED)
- {
- /* Set the ETH peripheral state to BUSY */
- heth->gState = HAL_ETH_STATE_BUSY;
- /* Disable the DMA transmission */
- CLEAR_BIT(heth->Instance->DMACTCR, ETH_DMACTCR_ST);
-
- /* Disable the DMA reception */
- CLEAR_BIT(heth->Instance->DMACRCR, ETH_DMACRCR_SR);
-
- /* Disable the MAC reception */
- CLEAR_BIT(heth->Instance->MACCR, ETH_MACCR_RE);
-
- /* Set the Flush Transmit FIFO bit */
- SET_BIT(heth->Instance->MTLTQOMR, ETH_MTLTQOMR_FTQ);
-
- /* Disable the MAC transmission */
- CLEAR_BIT(heth->Instance->MACCR, ETH_MACCR_TE);
-
- heth->gState = HAL_ETH_STATE_READY;
-
- /* Return function status */
- return HAL_OK;
- }
- else
- {
- return HAL_ERROR;
- }
-}
-
-/**
- * @brief Stop Ethernet MAC and DMA reception/transmission in Interrupt mode
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_ETH_Stop_IT(ETH_HandleTypeDef *heth)
-{
- ETH_DMADescTypeDef *dmarxdesc;
- uint32_t descindex;
-
- if (heth->gState == HAL_ETH_STATE_STARTED)
- {
- /* Set the ETH peripheral state to BUSY */
- heth->gState = HAL_ETH_STATE_BUSY;
-
- /* Disable interrupts:
- - Tx complete interrupt
- - Rx complete interrupt
- - Fatal bus interrupt
- */
- __HAL_ETH_DMA_DISABLE_IT(heth, (ETH_DMACIER_NIE | ETH_DMACIER_RIE | ETH_DMACIER_TIE |
- ETH_DMACIER_FBEE | ETH_DMACIER_AIE | ETH_DMACIER_RBUE));
-
- /* Disable the DMA transmission */
- CLEAR_BIT(heth->Instance->DMACTCR, ETH_DMACTCR_ST);
-
- /* Disable the DMA reception */
- CLEAR_BIT(heth->Instance->DMACRCR, ETH_DMACRCR_SR);
-
- /* Disable the MAC reception */
- CLEAR_BIT(heth->Instance->MACCR, ETH_MACCR_RE);
- /* Set the Flush Transmit FIFO bit */
- SET_BIT(heth->Instance->MTLTQOMR, ETH_MTLTQOMR_FTQ);
-
- /* Disable the MAC transmission */
- CLEAR_BIT(heth->Instance->MACCR, ETH_MACCR_TE);
-
- /* Clear IOC bit to all Rx descriptors */
- for (descindex = 0; descindex < (uint32_t)ETH_RX_DESC_CNT; descindex++)
- {
- dmarxdesc = (ETH_DMADescTypeDef *)heth->RxDescList.RxDesc[descindex];
- CLEAR_BIT(dmarxdesc->DESC3, ETH_DMARXNDESCRF_IOC);
- }
-
- heth->RxDescList.ItMode = 0U;
-
- heth->gState = HAL_ETH_STATE_READY;
-
- /* Return function status */
- return HAL_OK;
- }
- else
- {
- return HAL_ERROR;
- }
-}
-
-/**
- * @brief Sends an Ethernet Packet in polling mode.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @param pTxConfig: Hold the configuration of packet to be transmitted
- * @param Timeout: timeout value
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_ETH_Transmit(ETH_HandleTypeDef *heth, ETH_TxPacketConfig *pTxConfig, uint32_t Timeout)
-{
- uint32_t tickstart;
- ETH_DMADescTypeDef *dmatxdesc;
-
- if (pTxConfig == NULL)
- {
- heth->ErrorCode |= HAL_ETH_ERROR_PARAM;
- return HAL_ERROR;
- }
-
- if (heth->gState == HAL_ETH_STATE_STARTED)
- {
- /* Config DMA Tx descriptor by Tx Packet info */
- if (ETH_Prepare_Tx_Descriptors(heth, pTxConfig, 0) != HAL_ETH_ERROR_NONE)
- {
- /* Set the ETH error code */
- heth->ErrorCode |= HAL_ETH_ERROR_BUSY;
- return HAL_ERROR;
- }
-
- /* Ensure completion of descriptor preparation before transmission start */
- __DSB();
-
- dmatxdesc = (ETH_DMADescTypeDef *)(&heth->TxDescList)->TxDesc[heth->TxDescList.CurTxDesc];
-
- /* Incr current tx desc index */
- INCR_TX_DESC_INDEX(heth->TxDescList.CurTxDesc, 1U);
-
- /* Start transmission */
- /* issue a poll command to Tx DMA by writing address of next immediate free descriptor */
- WRITE_REG(heth->Instance->DMACTDTPR, (uint32_t)(heth->TxDescList.TxDesc[heth->TxDescList.CurTxDesc]));
-
- tickstart = HAL_GetTick();
-
- /* Wait for data to be transmitted or timeout occurred */
- while ((dmatxdesc->DESC3 & ETH_DMATXNDESCWBF_OWN) != (uint32_t)RESET)
- {
- if ((heth->Instance->DMACSR & ETH_DMACSR_FBE) != (uint32_t)RESET)
- {
- heth->ErrorCode |= HAL_ETH_ERROR_DMA;
- heth->DMAErrorCode = heth->Instance->DMACSR;
- /* Return function status */
- return HAL_ERROR;
- }
-
- /* Check for the Timeout */
- if (Timeout != HAL_MAX_DELAY)
- {
- if (((HAL_GetTick() - tickstart) > Timeout) || (Timeout == 0U))
- {
- heth->ErrorCode |= HAL_ETH_ERROR_TIMEOUT;
- /* Clear TX descriptor so that we can proceed */
- dmatxdesc->DESC3 = (ETH_DMATXNDESCWBF_FD | ETH_DMATXNDESCWBF_LD);
- return HAL_ERROR;
- }
- }
- }
-
- /* Return function status */
- return HAL_OK;
- }
- else
- {
- return HAL_ERROR;
- }
-}
-
-/**
- * @brief Sends an Ethernet Packet in interrupt mode.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @param pTxConfig: Hold the configuration of packet to be transmitted
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_ETH_Transmit_IT(ETH_HandleTypeDef *heth, ETH_TxPacketConfig *pTxConfig)
-{
- if (pTxConfig == NULL)
- {
- heth->ErrorCode |= HAL_ETH_ERROR_PARAM;
- return HAL_ERROR;
- }
-
- if (heth->gState == HAL_ETH_STATE_STARTED)
- {
- /* Save the packet pointer to release. */
- heth->TxDescList.CurrentPacketAddress = (uint32_t *)pTxConfig->pData;
-
- /* Config DMA Tx descriptor by Tx Packet info */
- if (ETH_Prepare_Tx_Descriptors(heth, pTxConfig, 1) != HAL_ETH_ERROR_NONE)
- {
- heth->ErrorCode |= HAL_ETH_ERROR_BUSY;
- return HAL_ERROR;
- }
-
- /* Ensure completion of descriptor preparation before transmission start */
- __DSB();
-
- /* Incr current tx desc index */
- INCR_TX_DESC_INDEX(heth->TxDescList.CurTxDesc, 1U);
-
- /* Start transmission */
- /* issue a poll command to Tx DMA by writing address of next immediate free descriptor */
- WRITE_REG(heth->Instance->DMACTDTPR, (uint32_t)(heth->TxDescList.TxDesc[heth->TxDescList.CurTxDesc]));
-
- return HAL_OK;
-
- }
- else
- {
- return HAL_ERROR;
- }
-}
-
-/**
- * @brief Read a received packet.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @param pAppBuff: Pointer to an application buffer to receive the packet.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_ETH_ReadData(ETH_HandleTypeDef *heth, void **pAppBuff)
-{
- uint32_t descidx;
- ETH_DMADescTypeDef *dmarxdesc;
- uint32_t desccnt = 0U;
- uint32_t desccntmax;
- uint32_t bufflength;
- uint8_t rxdataready = 0U;
-
-
- if (pAppBuff == NULL)
- {
- heth->ErrorCode |= HAL_ETH_ERROR_PARAM;
- return HAL_ERROR;
- }
-
- if (heth->gState != HAL_ETH_STATE_STARTED)
- {
- return HAL_ERROR;
- }
-
- descidx = heth->RxDescList.RxDescIdx;
- dmarxdesc = (ETH_DMADescTypeDef *)heth->RxDescList.RxDesc[descidx];
- desccntmax = ETH_RX_DESC_CNT - heth->RxDescList.RxBuildDescCnt;
-
- /* Check if descriptor is not owned by DMA */
- while ((READ_BIT(dmarxdesc->DESC3, ETH_DMARXNDESCWBF_OWN) == (uint32_t)RESET) && (desccnt < desccntmax)
- && (rxdataready == 0U))
- {
- if (READ_BIT(dmarxdesc->DESC3, ETH_DMARXNDESCWBF_CTXT) != (uint32_t)RESET)
- {
- /* Get timestamp high */
- heth->RxDescList.TimeStamp.TimeStampHigh = dmarxdesc->DESC1;
- /* Get timestamp low */
- heth->RxDescList.TimeStamp.TimeStampLow = dmarxdesc->DESC0;
- }
- if ((READ_BIT(dmarxdesc->DESC3, ETH_DMARXNDESCWBF_FD) != (uint32_t)RESET) || (heth->RxDescList.pRxStart != NULL))
- {
- /* Check if first descriptor */
- if (READ_BIT(dmarxdesc->DESC3, ETH_DMARXNDESCWBF_FD) != (uint32_t)RESET)
- {
- heth->RxDescList.RxDescCnt = 0;
- heth->RxDescList.RxDataLength = 0;
- }
-
- /* Check if last descriptor */
- bufflength = heth->Init.RxBuffLen;
- if (READ_BIT(dmarxdesc->DESC3, ETH_DMARXNDESCWBF_LD) != (uint32_t)RESET)
- {
- bufflength = READ_BIT(dmarxdesc->DESC3, ETH_DMARXNDESCWBF_PL) - heth->RxDescList.RxDataLength;
-
- /* Save Last descriptor index */
- heth->RxDescList.pRxLastRxDesc = dmarxdesc->DESC3;
-
- /* Packet ready */
- rxdataready = 1;
- }
-
- /* Link data */
-#if (USE_HAL_ETH_REGISTER_CALLBACKS == 1)
- /*Call registered Link callback*/
- heth->rxLinkCallback(&heth->RxDescList.pRxStart, &heth->RxDescList.pRxEnd,
- (uint8_t *)dmarxdesc->BackupAddr0, bufflength);
-#else
- /* Link callback */
- HAL_ETH_RxLinkCallback(&heth->RxDescList.pRxStart, &heth->RxDescList.pRxEnd,
- (uint8_t *)dmarxdesc->BackupAddr0, (uint16_t) bufflength);
-#endif /* USE_HAL_ETH_REGISTER_CALLBACKS */
- heth->RxDescList.RxDescCnt++;
- heth->RxDescList.RxDataLength += bufflength;
-
- /* Clear buffer pointer */
- dmarxdesc->BackupAddr0 = 0;
- }
-
- /* Increment current rx descriptor index */
- INCR_RX_DESC_INDEX(descidx, 1U);
- /* Get current descriptor address */
- dmarxdesc = (ETH_DMADescTypeDef *)heth->RxDescList.RxDesc[descidx];
- desccnt++;
- }
-
- heth->RxDescList.RxBuildDescCnt += desccnt;
- if ((heth->RxDescList.RxBuildDescCnt) != 0U)
- {
- /* Update Descriptors */
- ETH_UpdateDescriptor(heth);
- }
-
- heth->RxDescList.RxDescIdx = descidx;
-
- if (rxdataready == 1U)
- {
- /* Return received packet */
- *pAppBuff = heth->RxDescList.pRxStart;
- /* Reset first element */
- heth->RxDescList.pRxStart = NULL;
-
- return HAL_OK;
- }
-
- /* Packet not ready */
- return HAL_ERROR;
-}
-
-/**
- * @brief This function gives back Rx Desc of the last received Packet
- * to the DMA, so ETH DMA will be able to use these descriptors
- * to receive next Packets.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @retval HAL status
- */
-static void ETH_UpdateDescriptor(ETH_HandleTypeDef *heth)
-{
- uint32_t descidx;
- uint32_t desccount;
- ETH_DMADescTypeDef *dmarxdesc;
- uint8_t *buff = NULL;
- uint8_t allocStatus = 1U;
-
- descidx = heth->RxDescList.RxBuildDescIdx;
- dmarxdesc = (ETH_DMADescTypeDef *)heth->RxDescList.RxDesc[descidx];
- desccount = heth->RxDescList.RxBuildDescCnt;
-
- while ((desccount > 0U) && (allocStatus != 0U))
- {
- /* Check if a buffer's attached the descriptor */
- if (READ_REG(dmarxdesc->BackupAddr0) == 0U)
- {
- /* Get a new buffer. */
-#if (USE_HAL_ETH_REGISTER_CALLBACKS == 1)
- /*Call registered Allocate callback*/
- heth->rxAllocateCallback(&buff);
-#else
- /* Allocate callback */
- HAL_ETH_RxAllocateCallback(&buff);
-#endif /* USE_HAL_ETH_REGISTER_CALLBACKS */
- if (buff == NULL)
- {
- allocStatus = 0U;
- }
- else
- {
- WRITE_REG(dmarxdesc->BackupAddr0, (uint32_t)buff);
- WRITE_REG(dmarxdesc->DESC0, (uint32_t)buff);
- }
- }
-
- if (allocStatus != 0U)
- {
- /* Ensure rest of descriptor is written to RAM before the OWN bit */
- __DMB();
-
- if (heth->RxDescList.ItMode != 0U)
- {
- WRITE_REG(dmarxdesc->DESC3, ETH_DMARXNDESCRF_OWN | ETH_DMARXNDESCRF_BUF1V | ETH_DMARXNDESCRF_IOC);
- }
- else
- {
- WRITE_REG(dmarxdesc->DESC3, ETH_DMARXNDESCRF_OWN | ETH_DMARXNDESCRF_BUF1V);
- }
-
- /* Increment current rx descriptor index */
- INCR_RX_DESC_INDEX(descidx, 1U);
- /* Get current descriptor address */
- dmarxdesc = (ETH_DMADescTypeDef *)heth->RxDescList.RxDesc[descidx];
- desccount--;
- }
- }
-
- if (heth->RxDescList.RxBuildDescCnt != desccount)
- {
- /* Set the Tail pointer address */
- WRITE_REG(heth->Instance->DMACRDTPR, 0);
-
- heth->RxDescList.RxBuildDescIdx = descidx;
- heth->RxDescList.RxBuildDescCnt = desccount;
- }
-}
-
-/**
- * @brief Register the Rx alloc callback.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @param rxAllocateCallback: pointer to function to alloc buffer
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_ETH_RegisterRxAllocateCallback(ETH_HandleTypeDef *heth,
- pETH_rxAllocateCallbackTypeDef rxAllocateCallback)
-{
- if (rxAllocateCallback == NULL)
- {
- /* No buffer to save */
- return HAL_ERROR;
- }
-
- /* Set function to allocate buffer */
- heth->rxAllocateCallback = rxAllocateCallback;
-
- return HAL_OK;
-}
-
-/**
- * @brief Unregister the Rx alloc callback.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_ETH_UnRegisterRxAllocateCallback(ETH_HandleTypeDef *heth)
-{
- /* Set function to allocate buffer */
- heth->rxAllocateCallback = HAL_ETH_RxAllocateCallback;
-
- return HAL_OK;
-}
-
-/**
- * @brief Rx Allocate callback.
- * @param buff: pointer to allocated buffer
- * @retval None
- */
-__weak void HAL_ETH_RxAllocateCallback(uint8_t **buff)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(buff);
- /* NOTE : This function Should not be modified, when the callback is needed,
- the HAL_ETH_RxAllocateCallback could be implemented in the user file
- */
-}
-
-/**
- * @brief Rx Link callback.
- * @param pStart: pointer to packet start
- * @param pStart: pointer to packet end
- * @param buff: pointer to received data
- * @param Length: received data length
- * @retval None
- */
-__weak void HAL_ETH_RxLinkCallback(void **pStart, void **pEnd, uint8_t *buff, uint16_t Length)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(pStart);
- UNUSED(pEnd);
- UNUSED(buff);
- UNUSED(Length);
- /* NOTE : This function Should not be modified, when the callback is needed,
- the HAL_ETH_RxLinkCallback could be implemented in the user file
- */
-}
-
-/**
- * @brief Set the Rx link data function.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @param rxLinkCallback: pointer to function to link data
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_ETH_RegisterRxLinkCallback(ETH_HandleTypeDef *heth, pETH_rxLinkCallbackTypeDef rxLinkCallback)
-{
- if (rxLinkCallback == NULL)
- {
- /* No buffer to save */
- return HAL_ERROR;
- }
-
- /* Set function to link data */
- heth->rxLinkCallback = rxLinkCallback;
-
- return HAL_OK;
-}
-
-/**
- * @brief Unregister the Rx link callback.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_ETH_UnRegisterRxLinkCallback(ETH_HandleTypeDef *heth)
-{
- /* Set function to allocate buffer */
- heth->rxLinkCallback = HAL_ETH_RxLinkCallback;
-
- return HAL_OK;
-}
-
-/**
- * @brief Get the error state of the last received packet.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @param pErrorCode: pointer to uint32_t to hold the error code
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_ETH_GetRxDataErrorCode(ETH_HandleTypeDef *heth, uint32_t *pErrorCode)
-{
- /* Get error bits. */
- *pErrorCode = READ_BIT(heth->RxDescList.pRxLastRxDesc, ETH_DMARXNDESCWBF_ERRORS_MASK);
-
- return HAL_OK;
-}
-
-/**
- * @brief Set the Tx free function.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @param txFreeCallback: pointer to function to release the packet
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_ETH_RegisterTxFreeCallback(ETH_HandleTypeDef *heth, pETH_txFreeCallbackTypeDef txFreeCallback)
-{
- if (txFreeCallback == NULL)
- {
- /* No buffer to save */
- return HAL_ERROR;
- }
-
- /* Set function to free transmmitted packet */
- heth->txFreeCallback = txFreeCallback;
-
- return HAL_OK;
-}
-
-/**
- * @brief Unregister the Tx free callback.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_ETH_UnRegisterTxFreeCallback(ETH_HandleTypeDef *heth)
-{
- /* Set function to allocate buffer */
- heth->txFreeCallback = HAL_ETH_TxFreeCallback;
-
- return HAL_OK;
-}
-
-/**
- * @brief Tx Free callback.
- * @param buff: pointer to buffer to free
- * @retval None
- */
-__weak void HAL_ETH_TxFreeCallback(uint32_t *buff)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(buff);
- /* NOTE : This function Should not be modified, when the callback is needed,
- the HAL_ETH_TxFreeCallback could be implemented in the user file
- */
-}
-
-/**
- * @brief Release transmitted Tx packets.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_ETH_ReleaseTxPacket(ETH_HandleTypeDef *heth)
-{
- ETH_TxDescListTypeDef *dmatxdesclist = &heth->TxDescList;
- uint32_t numOfBuf = dmatxdesclist->BuffersInUse;
- uint32_t idx = dmatxdesclist->releaseIndex;
- uint8_t pktTxStatus = 1U;
- uint8_t pktInUse;
-#ifdef HAL_ETH_USE_PTP
- ETH_TimeStampTypeDef *timestamp = &heth->TxTimestamp;
-#endif /* HAL_ETH_USE_PTP */
-
- /* Loop through buffers in use. */
- while ((numOfBuf != 0U) && (pktTxStatus != 0U))
- {
- pktInUse = 1U;
- numOfBuf--;
- /* If no packet, just examine the next packet. */
- if (dmatxdesclist->PacketAddress[idx] == NULL)
- {
- /* No packet in use, skip to next. */
- idx = (idx + 1U) & (ETH_TX_DESC_CNT - 1U);
- pktInUse = 0U;
- }
-
- if (pktInUse != 0U)
- {
- /* Determine if the packet has been transmitted. */
- if ((heth->Init.TxDesc[idx].DESC3 & ETH_DMATXNDESCRF_OWN) == 0U)
- {
-#ifdef HAL_ETH_USE_PTP
- /* Disable Ptp transmission */
- CLEAR_BIT(heth->Init.TxDesc[idx].DESC3, (0x40000000U));
-
- /* Get timestamp low */
- timestamp->TimeStampLow = heth->Init.TxDesc[idx].DESC0;
- /* Get timestamp high */
- timestamp->TimeStampHigh = heth->Init.TxDesc[idx].DESC1;
-#endif /* HAL_ETH_USE_PTP */
-
-#if (USE_HAL_ETH_REGISTER_CALLBACKS == 1)
- /*Call registered callbacks*/
-#ifdef HAL_ETH_USE_PTP
- /* Handle Ptp */
- heth->txPtpCallback(dmatxdesclist->PacketAddress[idx], timestamp);
-#endif /* HAL_ETH_USE_PTP */
- /* Release the packet. */
- heth->txFreeCallback(dmatxdesclist->PacketAddress[idx]);
-#else
- /* Call callbacks */
-#ifdef HAL_ETH_USE_PTP
- /* Handle Ptp */
- HAL_ETH_TxPtpCallback(dmatxdesclist->PacketAddress[idx], timestamp);
-#endif /* HAL_ETH_USE_PTP */
- /* Release the packet. */
- HAL_ETH_TxFreeCallback(dmatxdesclist->PacketAddress[idx]);
-#endif /* USE_HAL_ETH_REGISTER_CALLBACKS */
-
- /* Clear the entry in the in-use array. */
- dmatxdesclist->PacketAddress[idx] = NULL;
-
- /* Update the transmit relesae index and number of buffers in use. */
- idx = (idx + 1U) & (ETH_TX_DESC_CNT - 1U);
- dmatxdesclist->BuffersInUse = numOfBuf;
- dmatxdesclist->releaseIndex = idx;
- }
- else
- {
- /* Get out of the loop! */
- pktTxStatus = 0U;
- }
- }
- }
- return HAL_OK;
-}
-
-#ifdef HAL_ETH_USE_PTP
-/**
- * @brief Set the Ethernet PTP configuration.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @param ptpconfig: pointer to a ETH_PTP_ConfigTypeDef structure that contains
- * the configuration information for PTP
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_ETH_PTP_SetConfig(ETH_HandleTypeDef *heth, ETH_PTP_ConfigTypeDef *ptpconfig)
-{
- uint32_t tmpTSCR;
- ETH_TimeTypeDef time;
-
- if (ptpconfig == NULL)
- {
- return HAL_ERROR;
- }
-
- tmpTSCR = ptpconfig->Timestamp |
- ((uint32_t)ptpconfig->TimestampUpdate << ETH_MACTSCR_TSUPDT_Pos) |
- ((uint32_t)ptpconfig->TimestampAll << ETH_MACTSCR_TSENALL_Pos) |
- ((uint32_t)ptpconfig->TimestampRolloverMode << ETH_MACTSCR_TSCTRLSSR_Pos) |
- ((uint32_t)ptpconfig->TimestampV2 << ETH_MACTSCR_TSVER2ENA_Pos) |
- ((uint32_t)ptpconfig->TimestampEthernet << ETH_MACTSCR_TSIPENA_Pos) |
- ((uint32_t)ptpconfig->TimestampIPv6 << ETH_MACTSCR_TSIPV6ENA_Pos) |
- ((uint32_t)ptpconfig->TimestampIPv4 << ETH_MACTSCR_TSIPV4ENA_Pos) |
- ((uint32_t)ptpconfig->TimestampEvent << ETH_MACTSCR_TSEVNTENA_Pos) |
- ((uint32_t)ptpconfig->TimestampMaster << ETH_MACTSCR_TSMSTRENA_Pos) |
- ((uint32_t)ptpconfig->TimestampSnapshots << ETH_MACTSCR_SNAPTYPSEL_Pos) |
- ((uint32_t)ptpconfig->TimestampFilter << ETH_MACTSCR_TSENMACADDR_Pos) |
- ((uint32_t)ptpconfig->TimestampChecksumCorrection << ETH_MACTSCR_CSC_Pos) |
- ((uint32_t)ptpconfig->TimestampStatusMode << ETH_MACTSCR_TXTSSTSM_Pos);
-
- /* Write to MACTSCR */
- MODIFY_REG(heth->Instance->MACTSCR, ETH_MACTSCR_MASK, tmpTSCR);
-
- /* Enable Timestamp */
- SET_BIT(heth->Instance->MACTSCR, ETH_MACTSCR_TSENA);
- WRITE_REG(heth->Instance->MACSSIR, ptpconfig->TimestampSubsecondInc);
- WRITE_REG(heth->Instance->MACTSAR, ptpconfig->TimestampAddend);
-
- /* Enable Timestamp */
- if (ptpconfig->TimestampAddendUpdate == ENABLE)
- {
- SET_BIT(heth->Instance->MACTSCR, ETH_MACTSCR_TSADDREG);
- while ((heth->Instance->MACTSCR & ETH_MACTSCR_TSADDREG) != 0) {}
- }
-
- /* Enable Update mode */
- if (ptpconfig->TimestampUpdateMode == ENABLE)
- {
- SET_BIT(heth->Instance->MACTSCR, ETH_MACTSCR_TSCFUPDT);
- }
-
- /* Initialize Time */
- time.Seconds = 0;
- time.NanoSeconds = 0;
- HAL_ETH_PTP_SetTime(heth, &time);
-
- /* Ptp Init */
- SET_BIT(heth->Instance->MACTSCR, ETH_MACTSCR_TSINIT);
-
- /* Set PTP Configuration done */
- heth->IsPtpConfigured = HAL_ETH_PTP_CONFIGURATED;
-
- /* Return function status */
- return HAL_OK;
-}
-
-/**
- * @brief Get the Ethernet PTP configuration.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @param ptpconfig: pointer to a ETH_PTP_ConfigTypeDef structure that contains
- * the configuration information for PTP
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_ETH_PTP_GetConfig(ETH_HandleTypeDef *heth, ETH_PTP_ConfigTypeDef *ptpconfig)
-{
- if (ptpconfig == NULL)
- {
- return HAL_ERROR;
- }
- ptpconfig->Timestamp = READ_BIT(heth->Instance->MACTSCR, ETH_MACTSCR_TSENA);
- ptpconfig->TimestampUpdate = ((READ_BIT(heth->Instance->MACTSCR,
- ETH_MACTSCR_TSCFUPDT) >> ETH_MACTSCR_TSUPDT_Pos) > 0U) ? ENABLE : DISABLE;
- ptpconfig->TimestampAll = ((READ_BIT(heth->Instance->MACTSCR,
- ETH_MACTSCR_TSENALL) >> ETH_MACTSCR_TSENALL_Pos) > 0U) ? ENABLE : DISABLE;
- ptpconfig->TimestampRolloverMode = ((READ_BIT(heth->Instance->MACTSCR,
- ETH_MACTSCR_TSCTRLSSR) >> ETH_MACTSCR_TSCTRLSSR_Pos) > 0U)
- ? ENABLE : DISABLE;
- ptpconfig->TimestampV2 = ((READ_BIT(heth->Instance->MACTSCR,
- ETH_MACTSCR_TSVER2ENA) >> ETH_MACTSCR_TSVER2ENA_Pos) > 0U) ? ENABLE : DISABLE;
- ptpconfig->TimestampEthernet = ((READ_BIT(heth->Instance->MACTSCR,
- ETH_MACTSCR_TSIPENA) >> ETH_MACTSCR_TSIPENA_Pos) > 0U) ? ENABLE : DISABLE;
- ptpconfig->TimestampIPv6 = ((READ_BIT(heth->Instance->MACTSCR,
- ETH_MACTSCR_TSIPV6ENA) >> ETH_MACTSCR_TSIPV6ENA_Pos) > 0U) ? ENABLE : DISABLE;
- ptpconfig->TimestampIPv4 = ((READ_BIT(heth->Instance->MACTSCR,
- ETH_MACTSCR_TSIPV4ENA) >> ETH_MACTSCR_TSIPV4ENA_Pos) > 0U) ? ENABLE : DISABLE;
- ptpconfig->TimestampEvent = ((READ_BIT(heth->Instance->MACTSCR,
- ETH_MACTSCR_TSEVNTENA) >> ETH_MACTSCR_TSEVNTENA_Pos) > 0U) ? ENABLE : DISABLE;
- ptpconfig->TimestampMaster = ((READ_BIT(heth->Instance->MACTSCR,
- ETH_MACTSCR_TSMSTRENA) >> ETH_MACTSCR_TSMSTRENA_Pos) > 0U) ? ENABLE : DISABLE;
- ptpconfig->TimestampSnapshots = ((READ_BIT(heth->Instance->MACTSCR,
- ETH_MACTSCR_SNAPTYPSEL) >> ETH_MACTSCR_SNAPTYPSEL_Pos) > 0U)
- ? ENABLE : DISABLE;
- ptpconfig->TimestampFilter = ((READ_BIT(heth->Instance->MACTSCR,
- ETH_MACTSCR_TSENMACADDR) >> ETH_MACTSCR_TSENMACADDR_Pos) > 0U)
- ? ENABLE : DISABLE;
- ptpconfig->TimestampChecksumCorrection = ((READ_BIT(heth->Instance->MACTSCR,
- ETH_MACTSCR_CSC) >> ETH_MACTSCR_CSC_Pos) > 0U) ? ENABLE : DISABLE;
- ptpconfig->TimestampStatusMode = ((READ_BIT(heth->Instance->MACTSCR,
- ETH_MACTSCR_TXTSSTSM) >> ETH_MACTSCR_TXTSSTSM_Pos) > 0U)
- ? ENABLE : DISABLE;
-
- /* Return function status */
- return HAL_OK;
-}
-
-/**
- * @brief Set Seconds and Nanoseconds for the Ethernet PTP registers.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @param heth: pointer to a ETH_TimeTypeDef structure that contains
- * time to set
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_ETH_PTP_SetTime(ETH_HandleTypeDef *heth, ETH_TimeTypeDef *time)
-{
- if (heth->IsPtpConfigured == HAL_ETH_PTP_CONFIGURATED)
- {
- /* Set Seconds */
- heth->Instance->MACSTSUR = time->Seconds;
-
- /* Set NanoSeconds */
- heth->Instance->MACSTNUR = time->NanoSeconds;
-
- /* Return function status */
- return HAL_OK;
- }
- else
- {
- /* Return function status */
- return HAL_ERROR;
- }
-}
-
-/**
- * @brief Get Seconds and Nanoseconds for the Ethernet PTP registers.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @param heth: pointer to a ETH_TimeTypeDef structure that contains
- * time to get
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_ETH_PTP_GetTime(ETH_HandleTypeDef *heth, ETH_TimeTypeDef *time)
-{
- if (heth->IsPtpConfigured == HAL_ETH_PTP_CONFIGURATED)
- {
- /* Get Seconds */
- time->Seconds = heth->Instance->MACSTSUR;
-
- /* Get NanoSeconds */
- time->NanoSeconds = heth->Instance->MACSTNUR;
-
- /* Return function status */
- return HAL_OK;
- }
- else
- {
- /* Return function status */
- return HAL_ERROR;
- }
-}
-
-/**
- * @brief Update time for the Ethernet PTP registers.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @param timeupdate: pointer to a ETH_TIMEUPDATETypeDef structure that contains
- * the time update information
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_ETH_PTP_AddTimeOffset(ETH_HandleTypeDef *heth, ETH_PtpUpdateTypeDef ptpoffsettype,
- ETH_TimeTypeDef *timeoffset)
-{
- if (heth->IsPtpConfigured == HAL_ETH_PTP_CONFIGURATED)
- {
- if (ptpoffsettype == HAL_ETH_PTP_NEGATIVE_UPDATE)
- {
- /* Set Seconds update */
- heth->Instance->MACSTSUR = ETH_MACSTSUR_VALUE - timeoffset->Seconds + 1U;
-
- if (READ_BIT(heth->Instance->MACTSCR, ETH_MACTSCR_TSCTRLSSR) == ETH_MACTSCR_TSCTRLSSR)
- {
- /* Set nanoSeconds update */
- heth->Instance->MACSTNUR = ETH_MACSTNUR_VALUE - timeoffset->NanoSeconds;
- }
- else
- {
- /* Set nanoSeconds update */
- heth->Instance->MACSTNUR = ETH_MACSTSUR_VALUE - timeoffset->NanoSeconds + 1U;
- }
- }
- else
- {
- /* Set Seconds update */
- heth->Instance->MACSTSUR = timeoffset->Seconds;
- /* Set nanoSeconds update */
- heth->Instance->MACSTNUR = timeoffset->NanoSeconds;
- }
-
- /* Return function status */
- return HAL_OK;
- }
- else
- {
- /* Return function status */
- return HAL_ERROR;
- }
-}
-
-/**
- * @brief Insert Timestamp in transmission.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @param txtimestampconf: Enable or Disable timestamp in transmission
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_ETH_PTP_InsertTxTimestamp(ETH_HandleTypeDef *heth)
-{
- ETH_TxDescListTypeDef *dmatxdesclist = &heth->TxDescList;
- uint32_t descidx = dmatxdesclist->CurTxDesc;
- ETH_DMADescTypeDef *dmatxdesc = (ETH_DMADescTypeDef *)dmatxdesclist->TxDesc[descidx];
-
- if (heth->IsPtpConfigured == HAL_ETH_PTP_CONFIGURATED)
- {
- /* Enable Time Stamp transmission */
- SET_BIT(dmatxdesc->DESC2, ETH_DMATXNDESCRF_TTSE);
-
- /* Return function status */
- return HAL_OK;
- }
- else
- {
- /* Return function status */
- return HAL_ERROR;
- }
-}
-
-/**
- * @brief Get transmission timestamp.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @param timestamp: pointer to ETH_TIMESTAMPTypeDef structure that contains
- * transmission timestamp
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_ETH_PTP_GetTxTimestamp(ETH_HandleTypeDef *heth, ETH_TimeStampTypeDef *timestamp)
-{
- ETH_TxDescListTypeDef *dmatxdesclist = &heth->TxDescList;
- uint32_t idx = dmatxdesclist->releaseIndex;
- ETH_DMADescTypeDef *dmatxdesc = (ETH_DMADescTypeDef *)dmatxdesclist->TxDesc[idx];
-
- if (heth->IsPtpConfigured == HAL_ETH_PTP_CONFIGURATED)
- {
- /* Get timestamp low */
- timestamp->TimeStampLow = dmatxdesc->DESC0;
- /* Get timestamp high */
- timestamp->TimeStampHigh = dmatxdesc->DESC1;
-
- /* Return function status */
- return HAL_OK;
- }
- else
- {
- /* Return function status */
- return HAL_ERROR;
- }
-}
-
-/**
- * @brief Get receive timestamp.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @param timestamp: pointer to ETH_TIMESTAMPTypeDef structure that contains
- * receive timestamp
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_ETH_PTP_GetRxTimestamp(ETH_HandleTypeDef *heth, ETH_TimeStampTypeDef *timestamp)
-{
- if (heth->IsPtpConfigured == HAL_ETH_PTP_CONFIGURATED)
- {
- /* Get timestamp low */
- timestamp->TimeStampLow = heth->RxDescList.TimeStamp.TimeStampLow;
- /* Get timestamp high */
- timestamp->TimeStampHigh = heth->RxDescList.TimeStamp.TimeStampHigh;
-
- /* Return function status */
- return HAL_OK;
- }
- else
- {
- /* Return function status */
- return HAL_ERROR;
- }
-}
-
-/**
- * @brief Register the Tx Ptp callback.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @param txPtpCallback: Function to handle Ptp transmission
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_ETH_RegisterTxPtpCallback(ETH_HandleTypeDef *heth, pETH_txPtpCallbackTypeDef txPtpCallback)
-{
- if (txPtpCallback == NULL)
- {
- /* No buffer to save */
- return HAL_ERROR;
- }
- /* Set Function to handle Tx Ptp */
- heth->txPtpCallback = txPtpCallback;
-
- return HAL_OK;
-}
-
-/**
- * @brief Unregister the Tx Ptp callback.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_ETH_UnRegisterTxPtpCallback(ETH_HandleTypeDef *heth)
-{
- /* Set function to allocate buffer */
- heth->txPtpCallback = HAL_ETH_TxPtpCallback;
-
- return HAL_OK;
-}
-
-/**
- * @brief Tx Ptp callback.
- * @param buff: pointer to application buffer
- * @retval None
- */
-__weak void HAL_ETH_TxPtpCallback(uint32_t *buff, ETH_TimeStampTypeDef *timestamp)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(buff);
- /* NOTE : This function Should not be modified, when the callback is needed,
- the HAL_ETH_TxPtpCallback could be implemented in the user file
- */
-}
-#endif /* HAL_ETH_USE_PTP */
-
-/**
- * @brief This function handles ETH interrupt request.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @retval HAL status
- */
-void HAL_ETH_IRQHandler(ETH_HandleTypeDef *heth)
-{
- uint32_t macirqenable;
- /* Packet received */
- if (__HAL_ETH_DMA_GET_IT(heth, ETH_DMACSR_RI))
- {
- if (__HAL_ETH_DMA_GET_IT_SOURCE(heth, ETH_DMACIER_RIE))
- {
- /* Clear the Eth DMA Rx IT pending bits */
- __HAL_ETH_DMA_CLEAR_IT(heth, ETH_DMACSR_RI | ETH_DMACSR_NIS);
-
-#if (USE_HAL_ETH_REGISTER_CALLBACKS == 1)
- /*Call registered Receive complete callback*/
- heth->RxCpltCallback(heth);
-#else
- /* Receive complete callback */
- HAL_ETH_RxCpltCallback(heth);
-#endif /* USE_HAL_ETH_REGISTER_CALLBACKS */
- }
- }
-
- /* Packet transmitted */
- if (__HAL_ETH_DMA_GET_IT(heth, ETH_DMACSR_TI))
- {
- if (__HAL_ETH_DMA_GET_IT_SOURCE(heth, ETH_DMACIER_TIE))
- {
- /* Clear the Eth DMA Tx IT pending bits */
- __HAL_ETH_DMA_CLEAR_IT(heth, ETH_DMACSR_TI | ETH_DMACSR_NIS);
-
-#if (USE_HAL_ETH_REGISTER_CALLBACKS == 1)
- /*Call registered Transmit complete callback*/
- heth->TxCpltCallback(heth);
-#else
- /* Transfer complete callback */
- HAL_ETH_TxCpltCallback(heth);
-#endif /* USE_HAL_ETH_REGISTER_CALLBACKS */
- }
- }
-
-
- /* ETH DMA Error */
- if (__HAL_ETH_DMA_GET_IT(heth, ETH_DMACSR_AIS))
- {
- if (__HAL_ETH_DMA_GET_IT_SOURCE(heth, ETH_DMACIER_AIE))
- {
- heth->ErrorCode |= HAL_ETH_ERROR_DMA;
-
- /* if fatal bus error occurred */
- if (__HAL_ETH_DMA_GET_IT(heth, ETH_DMACSR_FBE))
- {
- /* Get DMA error code */
- heth->DMAErrorCode = READ_BIT(heth->Instance->DMACSR, (ETH_DMACSR_FBE | ETH_DMACSR_TPS | ETH_DMACSR_RPS));
-
- /* Disable all interrupts */
- __HAL_ETH_DMA_DISABLE_IT(heth, ETH_DMACIER_NIE | ETH_DMACIER_AIE);
-
- /* Set HAL state to ERROR */
- heth->gState = HAL_ETH_STATE_ERROR;
- }
- else
- {
- /* Get DMA error status */
- heth->DMAErrorCode = READ_BIT(heth->Instance->DMACSR, (ETH_DMACSR_CDE | ETH_DMACSR_ETI | ETH_DMACSR_RWT |
- ETH_DMACSR_RBU | ETH_DMACSR_AIS));
-
- /* Clear the interrupt summary flag */
- __HAL_ETH_DMA_CLEAR_IT(heth, (ETH_DMACSR_CDE | ETH_DMACSR_ETI | ETH_DMACSR_RWT |
- ETH_DMACSR_RBU | ETH_DMACSR_AIS));
- }
-#if (USE_HAL_ETH_REGISTER_CALLBACKS == 1)
- /* Call registered Error callback*/
- heth->ErrorCallback(heth);
-#else
- /* Ethernet DMA Error callback */
- HAL_ETH_ErrorCallback(heth);
-#endif /* USE_HAL_ETH_REGISTER_CALLBACKS */
-
- }
- }
-
- /* ETH MAC Error IT */
- macirqenable = heth->Instance->MACIER;
- if (((macirqenable & ETH_MACIER_RXSTSIE) == ETH_MACIER_RXSTSIE) || \
- ((macirqenable & ETH_MACIER_TXSTSIE) == ETH_MACIER_TXSTSIE))
- {
- heth->ErrorCode |= HAL_ETH_ERROR_MAC;
-
- /* Get MAC Rx Tx status and clear Status register pending bit */
- heth->MACErrorCode = READ_REG(heth->Instance->MACRXTXSR);
-
- heth->gState = HAL_ETH_STATE_ERROR;
-
-#if (USE_HAL_ETH_REGISTER_CALLBACKS == 1)
- /* Call registered Error callback*/
- heth->ErrorCallback(heth);
-#else
- /* Ethernet Error callback */
- HAL_ETH_ErrorCallback(heth);
-#endif /* USE_HAL_ETH_REGISTER_CALLBACKS */
-
- heth->MACErrorCode = (uint32_t)(0x0U);
- }
-
- /* ETH PMT IT */
- if (__HAL_ETH_MAC_GET_IT(heth, ETH_MAC_PMT_IT))
- {
- /* Get MAC Wake-up source and clear the status register pending bit */
- heth->MACWakeUpEvent = READ_BIT(heth->Instance->MACPCSR, (ETH_MACPCSR_RWKPRCVD | ETH_MACPCSR_MGKPRCVD));
-
-#if (USE_HAL_ETH_REGISTER_CALLBACKS == 1)
- /* Call registered PMT callback*/
- heth->PMTCallback(heth);
-#else
- /* Ethernet PMT callback */
- HAL_ETH_PMTCallback(heth);
-#endif /* USE_HAL_ETH_REGISTER_CALLBACKS */
-
- heth->MACWakeUpEvent = (uint32_t)(0x0U);
- }
-
- /* ETH EEE IT */
- if (__HAL_ETH_MAC_GET_IT(heth, ETH_MAC_LPI_IT))
- {
- /* Get MAC LPI interrupt source and clear the status register pending bit */
- heth->MACLPIEvent = READ_BIT(heth->Instance->MACPCSR, 0x0000000FU);
-
-#if (USE_HAL_ETH_REGISTER_CALLBACKS == 1)
- /* Call registered EEE callback*/
- heth->EEECallback(heth);
-#else
- /* Ethernet EEE callback */
- HAL_ETH_EEECallback(heth);
-#endif /* USE_HAL_ETH_REGISTER_CALLBACKS */
-
- heth->MACLPIEvent = (uint32_t)(0x0U);
- }
-
-#if defined(DUAL_CORE)
- if (HAL_GetCurrentCPUID() == CM7_CPUID)
- {
- /* check ETH WAKEUP exti flag */
- if (__HAL_ETH_WAKEUP_EXTI_GET_FLAG(ETH_WAKEUP_EXTI_LINE) != (uint32_t)RESET)
- {
- /* Clear ETH WAKEUP Exti pending bit */
- __HAL_ETH_WAKEUP_EXTI_CLEAR_FLAG(ETH_WAKEUP_EXTI_LINE);
-#if (USE_HAL_ETH_REGISTER_CALLBACKS == 1)
- /* Call registered WakeUp callback*/
- heth->WakeUpCallback(heth);
-#else
- /* ETH WAKEUP callback */
- HAL_ETH_WakeUpCallback(heth);
-#endif /* USE_HAL_ETH_REGISTER_CALLBACKS */
- }
- }
- else
- {
- /* check ETH WAKEUP exti flag */
- if (__HAL_ETH_WAKEUP_EXTID2_GET_FLAG(ETH_WAKEUP_EXTI_LINE) != (uint32_t)RESET)
- {
- /* Clear ETH WAKEUP Exti pending bit */
- __HAL_ETH_WAKEUP_EXTID2_CLEAR_FLAG(ETH_WAKEUP_EXTI_LINE);
-#if (USE_HAL_ETH_REGISTER_CALLBACKS == 1)
- /* Call registered WakeUp callback*/
- heth->WakeUpCallback(heth);
-#else
- /* ETH WAKEUP callback */
- HAL_ETH_WakeUpCallback(heth);
-#endif /* USE_HAL_ETH_REGISTER_CALLBACKS */
- }
- }
-#else /* USE_HAL_ETH_REGISTER_CALLBACKS */
- /* check ETH WAKEUP exti flag */
- if (__HAL_ETH_WAKEUP_EXTI_GET_FLAG(ETH_WAKEUP_EXTI_LINE) != (uint32_t)RESET)
- {
- /* Clear ETH WAKEUP Exti pending bit */
- __HAL_ETH_WAKEUP_EXTI_CLEAR_FLAG(ETH_WAKEUP_EXTI_LINE);
-#if (USE_HAL_ETH_REGISTER_CALLBACKS == 1)
- /* Call registered WakeUp callback*/
- heth->WakeUpCallback(heth);
-#else
- /* ETH WAKEUP callback */
- HAL_ETH_WakeUpCallback(heth);
-#endif /* USE_HAL_ETH_REGISTER_CALLBACKS */
- }
-#endif /* USE_HAL_ETH_REGISTER_CALLBACKS */
-}
-
-/**
- * @brief Tx Transfer completed callbacks.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @retval None
- */
-__weak void HAL_ETH_TxCpltCallback(ETH_HandleTypeDef *heth)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(heth);
- /* NOTE : This function Should not be modified, when the callback is needed,
- the HAL_ETH_TxCpltCallback could be implemented in the user file
- */
-}
-
-/**
- * @brief Rx Transfer completed callbacks.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @retval None
- */
-__weak void HAL_ETH_RxCpltCallback(ETH_HandleTypeDef *heth)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(heth);
- /* NOTE : This function Should not be modified, when the callback is needed,
- the HAL_ETH_RxCpltCallback could be implemented in the user file
- */
-}
-
-/**
- * @brief Ethernet transfer error callbacks
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @retval None
- */
-__weak void HAL_ETH_ErrorCallback(ETH_HandleTypeDef *heth)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(heth);
- /* NOTE : This function Should not be modified, when the callback is needed,
- the HAL_ETH_ErrorCallback could be implemented in the user file
- */
-}
-
-/**
- * @brief Ethernet Power Management module IT callback
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @retval None
- */
-__weak void HAL_ETH_PMTCallback(ETH_HandleTypeDef *heth)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(heth);
- /* NOTE : This function Should not be modified, when the callback is needed,
- the HAL_ETH_PMTCallback could be implemented in the user file
- */
-}
-
-/**
- * @brief Energy Efficient Etherent IT callback
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @retval None
- */
-__weak void HAL_ETH_EEECallback(ETH_HandleTypeDef *heth)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(heth);
- /* NOTE : This function Should not be modified, when the callback is needed,
- the HAL_ETH_EEECallback could be implemented in the user file
- */
-}
-
-/**
- * @brief ETH WAKEUP interrupt callback
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @retval None
- */
-__weak void HAL_ETH_WakeUpCallback(ETH_HandleTypeDef *heth)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(heth);
- /* NOTE : This function Should not be modified, when the callback is needed,
- the HAL_ETH_WakeUpCallback could be implemented in the user file
- */
-}
-
-/**
- * @brief Read a PHY register
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @param PHYAddr: PHY port address, must be a value from 0 to 31
- * @param PHYReg: PHY register address, must be a value from 0 to 31
- * @param pRegValue: parameter to hold read value
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_ETH_ReadPHYRegister(ETH_HandleTypeDef *heth, uint32_t PHYAddr, uint32_t PHYReg,
- uint32_t *pRegValue)
-{
- uint32_t tickstart;
- uint32_t tmpreg;
-
- /* Check for the Busy flag */
- if (READ_BIT(heth->Instance->MACMDIOAR, ETH_MACMDIOAR_MB) != (uint32_t)RESET)
- {
- return HAL_ERROR;
- }
-
- /* Get the MACMDIOAR value */
- WRITE_REG(tmpreg, heth->Instance->MACMDIOAR);
-
- /* Prepare the MDIO Address Register value
- - Set the PHY device address
- - Set the PHY register address
- - Set the read mode
- - Set the MII Busy bit */
-
- MODIFY_REG(tmpreg, ETH_MACMDIOAR_PA, (PHYAddr << 21));
- MODIFY_REG(tmpreg, ETH_MACMDIOAR_RDA, (PHYReg << 16));
- MODIFY_REG(tmpreg, ETH_MACMDIOAR_MOC, ETH_MACMDIOAR_MOC_RD);
- SET_BIT(tmpreg, ETH_MACMDIOAR_MB);
-
- /* Write the result value into the MDII Address register */
- WRITE_REG(heth->Instance->MACMDIOAR, tmpreg);
-
- tickstart = HAL_GetTick();
-
- /* Wait for the Busy flag */
- while (READ_BIT(heth->Instance->MACMDIOAR, ETH_MACMDIOAR_MB) > 0U)
- {
- if (((HAL_GetTick() - tickstart) > ETH_MDIO_BUS_TIMEOUT))
- {
- return HAL_ERROR;
- }
- }
-
- /* Get MACMIIDR value */
- WRITE_REG(*pRegValue, (uint16_t)heth->Instance->MACMDIODR);
-
- return HAL_OK;
-}
-
-
-/**
- * @brief Writes to a PHY register.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @param PHYAddr: PHY port address, must be a value from 0 to 31
- * @param PHYReg: PHY register address, must be a value from 0 to 31
- * @param RegValue: the value to write
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_ETH_WritePHYRegister(ETH_HandleTypeDef *heth, uint32_t PHYAddr, uint32_t PHYReg,
- uint32_t RegValue)
-{
- uint32_t tickstart;
- uint32_t tmpreg;
-
- /* Check for the Busy flag */
- if (READ_BIT(heth->Instance->MACMDIOAR, ETH_MACMDIOAR_MB) != (uint32_t)RESET)
- {
- return HAL_ERROR;
- }
-
- /* Get the MACMDIOAR value */
- WRITE_REG(tmpreg, heth->Instance->MACMDIOAR);
-
- /* Prepare the MDIO Address Register value
- - Set the PHY device address
- - Set the PHY register address
- - Set the write mode
- - Set the MII Busy bit */
-
- MODIFY_REG(tmpreg, ETH_MACMDIOAR_PA, (PHYAddr << 21));
- MODIFY_REG(tmpreg, ETH_MACMDIOAR_RDA, (PHYReg << 16));
- MODIFY_REG(tmpreg, ETH_MACMDIOAR_MOC, ETH_MACMDIOAR_MOC_WR);
- SET_BIT(tmpreg, ETH_MACMDIOAR_MB);
-
-
- /* Give the value to the MII data register */
- WRITE_REG(ETH->MACMDIODR, (uint16_t)RegValue);
-
- /* Write the result value into the MII Address register */
- WRITE_REG(ETH->MACMDIOAR, tmpreg);
-
- tickstart = HAL_GetTick();
-
- /* Wait for the Busy flag */
- while (READ_BIT(heth->Instance->MACMDIOAR, ETH_MACMDIOAR_MB) > 0U)
- {
- if (((HAL_GetTick() - tickstart) > ETH_MDIO_BUS_TIMEOUT))
- {
- return HAL_ERROR;
- }
- }
-
- return HAL_OK;
-}
-
-/**
- * @}
- */
-
-/** @defgroup ETH_Exported_Functions_Group3 Peripheral Control functions
- * @brief ETH control functions
- *
-@verbatim
- ==============================================================================
- ##### Peripheral Control functions #####
- ==============================================================================
- [..]
- This subsection provides a set of functions allowing to control the ETH
- peripheral.
-
-@endverbatim
- * @{
- */
-/**
- * @brief Get the configuration of the MAC and MTL subsystems.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @param macconf: pointer to a ETH_MACConfigTypeDef structure that will hold
- * the configuration of the MAC.
- * @retval HAL Status
- */
-HAL_StatusTypeDef HAL_ETH_GetMACConfig(ETH_HandleTypeDef *heth, ETH_MACConfigTypeDef *macconf)
-{
- if (macconf == NULL)
- {
- return HAL_ERROR;
- }
-
- /* Get MAC parameters */
- macconf->PreambleLength = READ_BIT(heth->Instance->MACCR, ETH_MACCR_PRELEN);
- macconf->DeferralCheck = ((READ_BIT(heth->Instance->MACCR, ETH_MACCR_DC) >> 4) > 0U) ? ENABLE : DISABLE;
- macconf->BackOffLimit = READ_BIT(heth->Instance->MACCR, ETH_MACCR_BL);
- macconf->RetryTransmission = ((READ_BIT(heth->Instance->MACCR, ETH_MACCR_DR) >> 8) == 0U) ? ENABLE : DISABLE;
- macconf->CarrierSenseDuringTransmit = ((READ_BIT(heth->Instance->MACCR, ETH_MACCR_DCRS) >> 9) > 0U)
- ? ENABLE : DISABLE;
- macconf->ReceiveOwn = ((READ_BIT(heth->Instance->MACCR, ETH_MACCR_DO) >> 10) == 0U) ? ENABLE : DISABLE;
- macconf->CarrierSenseBeforeTransmit = ((READ_BIT(heth->Instance->MACCR,
- ETH_MACCR_ECRSFD) >> 11) > 0U) ? ENABLE : DISABLE;
- macconf->LoopbackMode = ((READ_BIT(heth->Instance->MACCR, ETH_MACCR_LM) >> 12) > 0U) ? ENABLE : DISABLE;
- macconf->DuplexMode = READ_BIT(heth->Instance->MACCR, ETH_MACCR_DM);
- macconf->Speed = READ_BIT(heth->Instance->MACCR, ETH_MACCR_FES);
- macconf->JumboPacket = ((READ_BIT(heth->Instance->MACCR, ETH_MACCR_JE) >> 16) > 0U) ? ENABLE : DISABLE;
- macconf->Jabber = ((READ_BIT(heth->Instance->MACCR, ETH_MACCR_JD) >> 17) == 0U) ? ENABLE : DISABLE;
- macconf->Watchdog = ((READ_BIT(heth->Instance->MACCR, ETH_MACCR_WD) >> 19) == 0U) ? ENABLE : DISABLE;
- macconf->AutomaticPadCRCStrip = ((READ_BIT(heth->Instance->MACCR, ETH_MACCR_ACS) >> 20) > 0U) ? ENABLE : DISABLE;
- macconf->CRCStripTypePacket = ((READ_BIT(heth->Instance->MACCR, ETH_MACCR_CST) >> 21) > 0U) ? ENABLE : DISABLE;
- macconf->Support2KPacket = ((READ_BIT(heth->Instance->MACCR, ETH_MACCR_S2KP) >> 22) > 0U) ? ENABLE : DISABLE;
- macconf->GiantPacketSizeLimitControl = ((READ_BIT(heth->Instance->MACCR,
- ETH_MACCR_GPSLCE) >> 23) > 0U) ? ENABLE : DISABLE;
- macconf->InterPacketGapVal = READ_BIT(heth->Instance->MACCR, ETH_MACCR_IPG);
- macconf->ChecksumOffload = ((READ_BIT(heth->Instance->MACCR, ETH_MACCR_IPC) >> 27) > 0U) ? ENABLE : DISABLE;
- macconf->SourceAddrControl = READ_BIT(heth->Instance->MACCR, ETH_MACCR_SARC);
-
- macconf->GiantPacketSizeLimit = READ_BIT(heth->Instance->MACECR, ETH_MACECR_GPSL);
- macconf->CRCCheckingRxPackets = ((READ_BIT(heth->Instance->MACECR, ETH_MACECR_DCRCC) >> 16) == 0U) ? ENABLE : DISABLE;
- macconf->SlowProtocolDetect = ((READ_BIT(heth->Instance->MACECR, ETH_MACECR_SPEN) >> 17) > 0U) ? ENABLE : DISABLE;
- macconf->UnicastSlowProtocolPacketDetect = ((READ_BIT(heth->Instance->MACECR,
- ETH_MACECR_USP) >> 18) > 0U) ? ENABLE : DISABLE;
- macconf->ExtendedInterPacketGap = ((READ_BIT(heth->Instance->MACECR, ETH_MACECR_EIPGEN) >> 24) > 0U)
- ? ENABLE : DISABLE;
- macconf->ExtendedInterPacketGapVal = READ_BIT(heth->Instance->MACECR, ETH_MACECR_EIPG) >> 25;
-
-
- macconf->ProgrammableWatchdog = ((READ_BIT(heth->Instance->MACWTR, ETH_MACWTR_PWE) >> 8) > 0U) ? ENABLE : DISABLE;
- macconf->WatchdogTimeout = READ_BIT(heth->Instance->MACWTR, ETH_MACWTR_WTO);
-
- macconf->TransmitFlowControl = ((READ_BIT(heth->Instance->MACTFCR, ETH_MACTFCR_TFE) >> 1) > 0U) ? ENABLE : DISABLE;
- macconf->ZeroQuantaPause = ((READ_BIT(heth->Instance->MACTFCR, ETH_MACTFCR_DZPQ) >> 7) == 0U) ? ENABLE : DISABLE;
- macconf->PauseLowThreshold = READ_BIT(heth->Instance->MACTFCR, ETH_MACTFCR_PLT);
- macconf->PauseTime = (READ_BIT(heth->Instance->MACTFCR, ETH_MACTFCR_PT) >> 16);
-
-
- macconf->ReceiveFlowControl = (READ_BIT(heth->Instance->MACRFCR, ETH_MACRFCR_RFE) > 0U) ? ENABLE : DISABLE;
- macconf->UnicastPausePacketDetect = ((READ_BIT(heth->Instance->MACRFCR, ETH_MACRFCR_UP) >> 1) > 0U)
- ? ENABLE : DISABLE;
-
- macconf->TransmitQueueMode = READ_BIT(heth->Instance->MTLTQOMR, (ETH_MTLTQOMR_TTC | ETH_MTLTQOMR_TSF));
-
- macconf->ReceiveQueueMode = READ_BIT(heth->Instance->MTLRQOMR, (ETH_MTLRQOMR_RTC | ETH_MTLRQOMR_RSF));
- macconf->ForwardRxUndersizedGoodPacket = ((READ_BIT(heth->Instance->MTLRQOMR,
- ETH_MTLRQOMR_FUP) >> 3) > 0U) ? ENABLE : DISABLE;
- macconf->ForwardRxErrorPacket = ((READ_BIT(heth->Instance->MTLRQOMR, ETH_MTLRQOMR_FEP) >> 4) > 0U) ? ENABLE : DISABLE;
- macconf->DropTCPIPChecksumErrorPacket = ((READ_BIT(heth->Instance->MTLRQOMR,
- ETH_MTLRQOMR_DISTCPEF) >> 6) == 0U) ? ENABLE : DISABLE;
-
- return HAL_OK;
-}
-
-/**
- * @brief Get the configuration of the DMA.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @param dmaconf: pointer to a ETH_DMAConfigTypeDef structure that will hold
- * the configuration of the ETH DMA.
- * @retval HAL Status
- */
-HAL_StatusTypeDef HAL_ETH_GetDMAConfig(ETH_HandleTypeDef *heth, ETH_DMAConfigTypeDef *dmaconf)
-{
- if (dmaconf == NULL)
- {
- return HAL_ERROR;
- }
-
- dmaconf->AddressAlignedBeats = ((READ_BIT(heth->Instance->DMASBMR, ETH_DMASBMR_AAL) >> 12) > 0U) ? ENABLE : DISABLE;
- dmaconf->BurstMode = READ_BIT(heth->Instance->DMASBMR, ETH_DMASBMR_FB | ETH_DMASBMR_MB);
- dmaconf->RebuildINCRxBurst = ((READ_BIT(heth->Instance->DMASBMR, ETH_DMASBMR_RB) >> 15) > 0U) ? ENABLE : DISABLE;
-
- dmaconf->DMAArbitration = READ_BIT(heth->Instance->DMAMR, (ETH_DMAMR_TXPR | ETH_DMAMR_PR | ETH_DMAMR_DA));
-
- dmaconf->PBLx8Mode = ((READ_BIT(heth->Instance->DMACCR, ETH_DMACCR_8PBL) >> 16) > 0U) ? ENABLE : DISABLE;
- dmaconf->MaximumSegmentSize = READ_BIT(heth->Instance->DMACCR, ETH_DMACCR_MSS);
-
- dmaconf->FlushRxPacket = ((READ_BIT(heth->Instance->DMACRCR, ETH_DMACRCR_RPF) >> 31) > 0U) ? ENABLE : DISABLE;
- dmaconf->RxDMABurstLength = READ_BIT(heth->Instance->DMACRCR, ETH_DMACRCR_RPBL);
-
- dmaconf->SecondPacketOperate = ((READ_BIT(heth->Instance->DMACTCR, ETH_DMACTCR_OSP) >> 4) > 0U) ? ENABLE : DISABLE;
- dmaconf->TCPSegmentation = ((READ_BIT(heth->Instance->DMACTCR, ETH_DMACTCR_TSE) >> 12) > 0U) ? ENABLE : DISABLE;
- dmaconf->TxDMABurstLength = READ_BIT(heth->Instance->DMACTCR, ETH_DMACTCR_TPBL);
- return HAL_OK;
-}
-
-/**
- * @brief Set the MAC configuration.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @param macconf: pointer to a ETH_MACConfigTypeDef structure that contains
- * the configuration of the MAC.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_ETH_SetMACConfig(ETH_HandleTypeDef *heth, ETH_MACConfigTypeDef *macconf)
-{
- if (macconf == NULL)
- {
- return HAL_ERROR;
- }
-
- if (heth->gState == HAL_ETH_STATE_READY)
- {
- ETH_SetMACConfig(heth, macconf);
-
- return HAL_OK;
- }
- else
- {
- return HAL_ERROR;
- }
-}
-
-/**
- * @brief Set the ETH DMA configuration.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @param dmaconf: pointer to a ETH_DMAConfigTypeDef structure that will hold
- * the configuration of the ETH DMA.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_ETH_SetDMAConfig(ETH_HandleTypeDef *heth, ETH_DMAConfigTypeDef *dmaconf)
-{
- if (dmaconf == NULL)
- {
- return HAL_ERROR;
- }
-
- if (heth->gState == HAL_ETH_STATE_READY)
- {
- ETH_SetDMAConfig(heth, dmaconf);
-
- return HAL_OK;
- }
- else
- {
- return HAL_ERROR;
- }
-}
-
-/**
- * @brief Configures the Clock range of ETH MDIO interface.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @retval None
- */
-void HAL_ETH_SetMDIOClockRange(ETH_HandleTypeDef *heth)
-{
- uint32_t hclk;
- uint32_t tmpreg;
-
- /* Get the ETHERNET MACMDIOAR value */
- tmpreg = (heth->Instance)->MACMDIOAR;
-
- /* Clear CSR Clock Range bits */
- tmpreg &= ~ETH_MACMDIOAR_CR;
-
- /* Get hclk frequency value */
- hclk = HAL_RCC_GetHCLKFreq();
-
- /* Set CR bits depending on hclk value */
- if ((hclk >= 20000000U) && (hclk < 35000000U))
- {
- /* CSR Clock Range between 20-35 MHz */
- tmpreg |= (uint32_t)ETH_MACMDIOAR_CR_DIV16;
- }
- else if ((hclk >= 35000000U) && (hclk < 60000000U))
- {
- /* CSR Clock Range between 35-60 MHz */
- tmpreg |= (uint32_t)ETH_MACMDIOAR_CR_DIV26;
- }
- else if ((hclk >= 60000000U) && (hclk < 100000000U))
- {
- /* CSR Clock Range between 60-100 MHz */
- tmpreg |= (uint32_t)ETH_MACMDIOAR_CR_DIV42;
- }
- else if ((hclk >= 100000000U) && (hclk < 150000000U))
- {
- /* CSR Clock Range between 100-150 MHz */
- tmpreg |= (uint32_t)ETH_MACMDIOAR_CR_DIV62;
- }
- else /* (hclk >= 150000000)&&(hclk <= 200000000) */
- {
- /* CSR Clock Range between 150-200 MHz */
- tmpreg |= (uint32_t)ETH_MACMDIOAR_CR_DIV102;
- }
-
- /* Configure the CSR Clock Range */
- (heth->Instance)->MACMDIOAR = (uint32_t)tmpreg;
-}
-
-/**
- * @brief Set the ETH MAC (L2) Filters configuration.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @param pFilterConfig: pointer to a ETH_MACFilterConfigTypeDef structure that contains
- * the configuration of the ETH MAC filters.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_ETH_SetMACFilterConfig(ETH_HandleTypeDef *heth, ETH_MACFilterConfigTypeDef *pFilterConfig)
-{
- uint32_t filterconfig;
-
- if (pFilterConfig == NULL)
- {
- return HAL_ERROR;
- }
-
- filterconfig = ((uint32_t)pFilterConfig->PromiscuousMode |
- ((uint32_t)pFilterConfig->HashUnicast << 1) |
- ((uint32_t)pFilterConfig->HashMulticast << 2) |
- ((uint32_t)pFilterConfig->DestAddrInverseFiltering << 3) |
- ((uint32_t)pFilterConfig->PassAllMulticast << 4) |
- ((uint32_t)((pFilterConfig->BroadcastFilter == DISABLE) ? 1U : 0U) << 5) |
- ((uint32_t)pFilterConfig->SrcAddrInverseFiltering << 8) |
- ((uint32_t)pFilterConfig->SrcAddrFiltering << 9) |
- ((uint32_t)pFilterConfig->HachOrPerfectFilter << 10) |
- ((uint32_t)pFilterConfig->ReceiveAllMode << 31) |
- pFilterConfig->ControlPacketsFilter);
-
- MODIFY_REG(heth->Instance->MACPFR, ETH_MACPFR_MASK, filterconfig);
-
- return HAL_OK;
-}
-
-/**
- * @brief Get the ETH MAC (L2) Filters configuration.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @param pFilterConfig: pointer to a ETH_MACFilterConfigTypeDef structure that will hold
- * the configuration of the ETH MAC filters.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_ETH_GetMACFilterConfig(ETH_HandleTypeDef *heth, ETH_MACFilterConfigTypeDef *pFilterConfig)
-{
- if (pFilterConfig == NULL)
- {
- return HAL_ERROR;
- }
-
- pFilterConfig->PromiscuousMode = ((READ_BIT(heth->Instance->MACPFR, ETH_MACPFR_PR)) > 0U) ? ENABLE : DISABLE;
- pFilterConfig->HashUnicast = ((READ_BIT(heth->Instance->MACPFR, ETH_MACPFR_HUC) >> 1) > 0U) ? ENABLE : DISABLE;
- pFilterConfig->HashMulticast = ((READ_BIT(heth->Instance->MACPFR, ETH_MACPFR_HMC) >> 2) > 0U) ? ENABLE : DISABLE;
- pFilterConfig->DestAddrInverseFiltering = ((READ_BIT(heth->Instance->MACPFR,
- ETH_MACPFR_DAIF) >> 3) > 0U) ? ENABLE : DISABLE;
- pFilterConfig->PassAllMulticast = ((READ_BIT(heth->Instance->MACPFR, ETH_MACPFR_PM) >> 4) > 0U) ? ENABLE : DISABLE;
- pFilterConfig->BroadcastFilter = ((READ_BIT(heth->Instance->MACPFR, ETH_MACPFR_DBF) >> 5) == 0U) ? ENABLE : DISABLE;
- pFilterConfig->ControlPacketsFilter = READ_BIT(heth->Instance->MACPFR, ETH_MACPFR_PCF);
- pFilterConfig->SrcAddrInverseFiltering = ((READ_BIT(heth->Instance->MACPFR,
- ETH_MACPFR_SAIF) >> 8) > 0U) ? ENABLE : DISABLE;
- pFilterConfig->SrcAddrFiltering = ((READ_BIT(heth->Instance->MACPFR, ETH_MACPFR_SAF) >> 9) > 0U) ? ENABLE : DISABLE;
- pFilterConfig->HachOrPerfectFilter = ((READ_BIT(heth->Instance->MACPFR, ETH_MACPFR_HPF) >> 10) > 0U)
- ? ENABLE : DISABLE;
- pFilterConfig->ReceiveAllMode = ((READ_BIT(heth->Instance->MACPFR, ETH_MACPFR_RA) >> 31) > 0U) ? ENABLE : DISABLE;
-
- return HAL_OK;
-}
-
-/**
- * @brief Set the source MAC Address to be matched.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @param AddrNbr: The MAC address to configure
- * This parameter must be a value of the following:
- * ETH_MAC_ADDRESS1
- * ETH_MAC_ADDRESS2
- * ETH_MAC_ADDRESS3
- * @param pMACAddr: Pointer to MAC address buffer data (6 bytes)
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_ETH_SetSourceMACAddrMatch(ETH_HandleTypeDef *heth, uint32_t AddrNbr, uint8_t *pMACAddr)
-{
- uint32_t macaddrlr;
- uint32_t macaddrhr;
-
- if (pMACAddr == NULL)
- {
- return HAL_ERROR;
- }
-
- /* Get mac addr high reg offset */
- macaddrhr = ((uint32_t) &(heth->Instance->MACA0HR) + AddrNbr);
- /* Get mac addr low reg offset */
- macaddrlr = ((uint32_t) &(heth->Instance->MACA0LR) + AddrNbr);
-
- /* Set MAC addr bits 32 to 47 */
- (*(__IO uint32_t *)macaddrhr) = (((uint32_t)(pMACAddr[5]) << 8) | (uint32_t)pMACAddr[4]);
- /* Set MAC addr bits 0 to 31 */
- (*(__IO uint32_t *)macaddrlr) = (((uint32_t)(pMACAddr[3]) << 24) | ((uint32_t)(pMACAddr[2]) << 16) |
- ((uint32_t)(pMACAddr[1]) << 8) | (uint32_t)pMACAddr[0]);
-
- /* Enable address and set source address bit */
- (*(__IO uint32_t *)macaddrhr) |= (ETH_MACAHR_SA | ETH_MACAHR_AE);
-
- return HAL_OK;
-}
-
-/**
- * @brief Set the ETH Hash Table Value.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @param pHashTable: pointer to a table of two 32 bit values, that contains
- * the 64 bits of the hash table.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_ETH_SetHashTable(ETH_HandleTypeDef *heth, uint32_t *pHashTable)
-{
- if (pHashTable == NULL)
- {
- return HAL_ERROR;
- }
-
- heth->Instance->MACHT0R = pHashTable[0];
- heth->Instance->MACHT1R = pHashTable[1];
-
- return HAL_OK;
-}
-
-/**
- * @brief Set the VLAN Identifier for Rx packets
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @param ComparisonBits: 12 or 16 bit comparison mode
- must be a value of @ref ETH_VLAN_Tag_Comparison
- * @param VLANIdentifier: VLAN Identifier value
- * @retval None
- */
-void HAL_ETH_SetRxVLANIdentifier(ETH_HandleTypeDef *heth, uint32_t ComparisonBits, uint32_t VLANIdentifier)
-{
- if (ComparisonBits == ETH_VLANTAGCOMPARISON_16BIT)
- {
- MODIFY_REG(heth->Instance->MACVTR, ETH_MACVTR_VL, VLANIdentifier);
- CLEAR_BIT(heth->Instance->MACVTR, ETH_MACVTR_ETV);
- }
- else
- {
- MODIFY_REG(heth->Instance->MACVTR, ETH_MACVTR_VL_VID, VLANIdentifier);
- SET_BIT(heth->Instance->MACVTR, ETH_MACVTR_ETV);
- }
-}
-
-/**
- * @brief Enters the Power down mode.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @param pPowerDownConfig: a pointer to ETH_PowerDownConfigTypeDef structure
- * that contains the Power Down configuration
- * @retval None.
- */
-void HAL_ETH_EnterPowerDownMode(ETH_HandleTypeDef *heth, ETH_PowerDownConfigTypeDef *pPowerDownConfig)
-{
- uint32_t powerdownconfig;
-
- powerdownconfig = (((uint32_t)pPowerDownConfig->MagicPacket << 1) |
- ((uint32_t)pPowerDownConfig->WakeUpPacket << 2) |
- ((uint32_t)pPowerDownConfig->GlobalUnicast << 9) |
- ((uint32_t)pPowerDownConfig->WakeUpForward << 10) |
- ETH_MACPCSR_PWRDWN);
-
- /* Enable PMT interrupt */
- __HAL_ETH_MAC_ENABLE_IT(heth, ETH_MACIER_PMTIE);
-
- MODIFY_REG(heth->Instance->MACPCSR, ETH_MACPCSR_MASK, powerdownconfig);
-}
-
-/**
- * @brief Exits from the Power down mode.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @retval None.
- */
-void HAL_ETH_ExitPowerDownMode(ETH_HandleTypeDef *heth)
-{
- /* clear wake up sources */
- CLEAR_BIT(heth->Instance->MACPCSR, ETH_MACPCSR_RWKPKTEN | ETH_MACPCSR_MGKPKTEN | ETH_MACPCSR_GLBLUCAST |
- ETH_MACPCSR_RWKPFE);
-
- if (READ_BIT(heth->Instance->MACPCSR, ETH_MACPCSR_PWRDWN) != (uint32_t)RESET)
- {
- /* Exit power down mode */
- CLEAR_BIT(heth->Instance->MACPCSR, ETH_MACPCSR_PWRDWN);
- }
-
- /* Disable PMT interrupt */
- __HAL_ETH_MAC_DISABLE_IT(heth, ETH_MACIER_PMTIE);
-}
-
-/**
- * @brief Set the WakeUp filter.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @param pFilter: pointer to filter registers values
- * @param Count: number of filter registers, must be from 1 to 8.
- * @retval None.
- */
-HAL_StatusTypeDef HAL_ETH_SetWakeUpFilter(ETH_HandleTypeDef *heth, uint32_t *pFilter, uint32_t Count)
-{
- uint32_t regindex;
-
- if (pFilter == NULL)
- {
- return HAL_ERROR;
- }
-
- /* Reset Filter Pointer */
- SET_BIT(heth->Instance->MACPCSR, ETH_MACPCSR_RWKFILTRST);
-
- /* Wake up packet filter config */
- for (regindex = 0; regindex < Count; regindex++)
- {
- /* Write filter regs */
- WRITE_REG(heth->Instance->MACRWKPFR, pFilter[regindex]);
- }
-
- return HAL_OK;
-}
-
-/**
- * @}
- */
-
-/** @defgroup ETH_Exported_Functions_Group4 Peripheral State and Errors functions
- * @brief ETH State and Errors functions
- *
-@verbatim
- ==============================================================================
- ##### Peripheral State and Errors functions #####
- ==============================================================================
- [..]
- This subsection provides a set of functions allowing to return the State of
- ETH communication process, return Peripheral Errors occurred during communication
- process
-
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Returns the ETH state.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @retval HAL state
- */
-HAL_ETH_StateTypeDef HAL_ETH_GetState(ETH_HandleTypeDef *heth)
-{
- return heth->gState;
-}
-
-/**
- * @brief Returns the ETH error code
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @retval ETH Error Code
- */
-uint32_t HAL_ETH_GetError(ETH_HandleTypeDef *heth)
-{
- return heth->ErrorCode;
-}
-
-/**
- * @brief Returns the ETH DMA error code
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @retval ETH DMA Error Code
- */
-uint32_t HAL_ETH_GetDMAError(ETH_HandleTypeDef *heth)
-{
- return heth->DMAErrorCode;
-}
-
-/**
- * @brief Returns the ETH MAC error code
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @retval ETH MAC Error Code
- */
-uint32_t HAL_ETH_GetMACError(ETH_HandleTypeDef *heth)
-{
- return heth->MACErrorCode;
-}
-
-/**
- * @brief Returns the ETH MAC WakeUp event source
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @retval ETH MAC WakeUp event source
- */
-uint32_t HAL_ETH_GetMACWakeUpSource(ETH_HandleTypeDef *heth)
-{
- return heth->MACWakeUpEvent;
-}
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/** @addtogroup ETH_Private_Functions ETH Private Functions
- * @{
- */
-
-
-static void ETH_SetMACConfig(ETH_HandleTypeDef *heth, ETH_MACConfigTypeDef *macconf)
-{
- uint32_t macregval;
-
- /*------------------------ MACCR Configuration --------------------*/
- macregval = (macconf->InterPacketGapVal |
- macconf->SourceAddrControl |
- ((uint32_t)macconf->ChecksumOffload << 27) |
- ((uint32_t)macconf->GiantPacketSizeLimitControl << 23) |
- ((uint32_t)macconf->Support2KPacket << 22) |
- ((uint32_t)macconf->CRCStripTypePacket << 21) |
- ((uint32_t)macconf->AutomaticPadCRCStrip << 20) |
- ((uint32_t)((macconf->Watchdog == DISABLE) ? 1U : 0U) << 19) |
- ((uint32_t)((macconf->Jabber == DISABLE) ? 1U : 0U) << 17) |
- ((uint32_t)macconf->JumboPacket << 16) |
- macconf->Speed |
- macconf->DuplexMode |
- ((uint32_t)macconf->LoopbackMode << 12) |
- ((uint32_t)macconf->CarrierSenseBeforeTransmit << 11) |
- ((uint32_t)((macconf->ReceiveOwn == DISABLE) ? 1U : 0U) << 10) |
- ((uint32_t)macconf->CarrierSenseDuringTransmit << 9) |
- ((uint32_t)((macconf->RetryTransmission == DISABLE) ? 1U : 0U) << 8) |
- macconf->BackOffLimit |
- ((uint32_t)macconf->DeferralCheck << 4) |
- macconf->PreambleLength);
-
- /* Write to MACCR */
- MODIFY_REG(heth->Instance->MACCR, ETH_MACCR_MASK, macregval);
-
- /*------------------------ MACECR Configuration --------------------*/
- macregval = ((macconf->ExtendedInterPacketGapVal << 25) |
- ((uint32_t)macconf->ExtendedInterPacketGap << 24) |
- ((uint32_t)macconf->UnicastSlowProtocolPacketDetect << 18) |
- ((uint32_t)macconf->SlowProtocolDetect << 17) |
- ((uint32_t)((macconf->CRCCheckingRxPackets == DISABLE) ? 1U : 0U) << 16) |
- macconf->GiantPacketSizeLimit);
-
- /* Write to MACECR */
- MODIFY_REG(heth->Instance->MACECR, ETH_MACECR_MASK, macregval);
-
- /*------------------------ MACWTR Configuration --------------------*/
- macregval = (((uint32_t)macconf->ProgrammableWatchdog << 8) |
- macconf->WatchdogTimeout);
-
- /* Write to MACWTR */
- MODIFY_REG(heth->Instance->MACWTR, ETH_MACWTR_MASK, macregval);
-
- /*------------------------ MACTFCR Configuration --------------------*/
- macregval = (((uint32_t)macconf->TransmitFlowControl << 1) |
- macconf->PauseLowThreshold |
- ((uint32_t)((macconf->ZeroQuantaPause == DISABLE) ? 1U : 0U) << 7) |
- (macconf->PauseTime << 16));
-
- /* Write to MACTFCR */
- MODIFY_REG(heth->Instance->MACTFCR, ETH_MACTFCR_MASK, macregval);
-
- /*------------------------ MACRFCR Configuration --------------------*/
- macregval = ((uint32_t)macconf->ReceiveFlowControl |
- ((uint32_t)macconf->UnicastPausePacketDetect << 1));
-
- /* Write to MACRFCR */
- MODIFY_REG(heth->Instance->MACRFCR, ETH_MACRFCR_MASK, macregval);
-
- /*------------------------ MTLTQOMR Configuration --------------------*/
- /* Write to MTLTQOMR */
- MODIFY_REG(heth->Instance->MTLTQOMR, ETH_MTLTQOMR_MASK, macconf->TransmitQueueMode);
-
- /*------------------------ MTLRQOMR Configuration --------------------*/
- macregval = (macconf->ReceiveQueueMode |
- ((uint32_t)((macconf->DropTCPIPChecksumErrorPacket == DISABLE) ? 1U : 0U) << 6) |
- ((uint32_t)macconf->ForwardRxErrorPacket << 4) |
- ((uint32_t)macconf->ForwardRxUndersizedGoodPacket << 3));
-
- /* Write to MTLRQOMR */
- MODIFY_REG(heth->Instance->MTLRQOMR, ETH_MTLRQOMR_MASK, macregval);
-}
-
-static void ETH_SetDMAConfig(ETH_HandleTypeDef *heth, ETH_DMAConfigTypeDef *dmaconf)
-{
- uint32_t dmaregval;
-
- /*------------------------ DMAMR Configuration --------------------*/
- MODIFY_REG(heth->Instance->DMAMR, ETH_DMAMR_MASK, dmaconf->DMAArbitration);
-
- /*------------------------ DMASBMR Configuration --------------------*/
- dmaregval = (((uint32_t)dmaconf->AddressAlignedBeats << 12) |
- dmaconf->BurstMode |
- ((uint32_t)dmaconf->RebuildINCRxBurst << 15));
-
- MODIFY_REG(heth->Instance->DMASBMR, ETH_DMASBMR_MASK, dmaregval);
-
- /*------------------------ DMACCR Configuration --------------------*/
- dmaregval = (((uint32_t)dmaconf->PBLx8Mode << 16) |
- dmaconf->MaximumSegmentSize);
-
- MODIFY_REG(heth->Instance->DMACCR, ETH_DMACCR_MASK, dmaregval);
-
- /*------------------------ DMACTCR Configuration --------------------*/
- dmaregval = (dmaconf->TxDMABurstLength |
- ((uint32_t)dmaconf->SecondPacketOperate << 4) |
- ((uint32_t)dmaconf->TCPSegmentation << 12));
-
- MODIFY_REG(heth->Instance->DMACTCR, ETH_DMACTCR_MASK, dmaregval);
-
- /*------------------------ DMACRCR Configuration --------------------*/
- dmaregval = (((uint32_t)dmaconf->FlushRxPacket << 31) |
- dmaconf->RxDMABurstLength);
-
- /* Write to DMACRCR */
- MODIFY_REG(heth->Instance->DMACRCR, ETH_DMACRCR_MASK, dmaregval);
-}
-
-/**
- * @brief Configures Ethernet MAC and DMA with default parameters.
- * called by HAL_ETH_Init() API.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @retval HAL status
- */
-static void ETH_MACDMAConfig(ETH_HandleTypeDef *heth)
-{
- ETH_MACConfigTypeDef macDefaultConf;
- ETH_DMAConfigTypeDef dmaDefaultConf;
-
- /*--------------- ETHERNET MAC registers default Configuration --------------*/
- macDefaultConf.AutomaticPadCRCStrip = ENABLE;
- macDefaultConf.BackOffLimit = ETH_BACKOFFLIMIT_10;
- macDefaultConf.CarrierSenseBeforeTransmit = DISABLE;
- macDefaultConf.CarrierSenseDuringTransmit = DISABLE;
- macDefaultConf.ChecksumOffload = ENABLE;
- macDefaultConf.CRCCheckingRxPackets = ENABLE;
- macDefaultConf.CRCStripTypePacket = ENABLE;
- macDefaultConf.DeferralCheck = DISABLE;
- macDefaultConf.DropTCPIPChecksumErrorPacket = ENABLE;
- macDefaultConf.DuplexMode = ETH_FULLDUPLEX_MODE;
- macDefaultConf.ExtendedInterPacketGap = DISABLE;
- macDefaultConf.ExtendedInterPacketGapVal = 0x0;
- macDefaultConf.ForwardRxErrorPacket = DISABLE;
- macDefaultConf.ForwardRxUndersizedGoodPacket = DISABLE;
- macDefaultConf.GiantPacketSizeLimit = 0x618;
- macDefaultConf.GiantPacketSizeLimitControl = DISABLE;
- macDefaultConf.InterPacketGapVal = ETH_INTERPACKETGAP_96BIT;
- macDefaultConf.Jabber = ENABLE;
- macDefaultConf.JumboPacket = DISABLE;
- macDefaultConf.LoopbackMode = DISABLE;
- macDefaultConf.PauseLowThreshold = ETH_PAUSELOWTHRESHOLD_MINUS_4;
- macDefaultConf.PauseTime = 0x0;
- macDefaultConf.PreambleLength = ETH_PREAMBLELENGTH_7;
- macDefaultConf.ProgrammableWatchdog = DISABLE;
- macDefaultConf.ReceiveFlowControl = DISABLE;
- macDefaultConf.ReceiveOwn = ENABLE;
- macDefaultConf.ReceiveQueueMode = ETH_RECEIVESTOREFORWARD;
- macDefaultConf.RetryTransmission = ENABLE;
- macDefaultConf.SlowProtocolDetect = DISABLE;
- macDefaultConf.SourceAddrControl = ETH_SOURCEADDRESS_REPLACE_ADDR0;
- macDefaultConf.Speed = ETH_SPEED_100M;
- macDefaultConf.Support2KPacket = DISABLE;
- macDefaultConf.TransmitQueueMode = ETH_TRANSMITSTOREFORWARD;
- macDefaultConf.TransmitFlowControl = DISABLE;
- macDefaultConf.UnicastPausePacketDetect = DISABLE;
- macDefaultConf.UnicastSlowProtocolPacketDetect = DISABLE;
- macDefaultConf.Watchdog = ENABLE;
- macDefaultConf.WatchdogTimeout = ETH_MACWTR_WTO_2KB;
- macDefaultConf.ZeroQuantaPause = ENABLE;
-
- /* MAC default configuration */
- ETH_SetMACConfig(heth, &macDefaultConf);
-
- /*--------------- ETHERNET DMA registers default Configuration --------------*/
- dmaDefaultConf.AddressAlignedBeats = ENABLE;
- dmaDefaultConf.BurstMode = ETH_BURSTLENGTH_FIXED;
- dmaDefaultConf.DMAArbitration = ETH_DMAARBITRATION_RX1_TX1;
- dmaDefaultConf.FlushRxPacket = DISABLE;
- dmaDefaultConf.PBLx8Mode = DISABLE;
- dmaDefaultConf.RebuildINCRxBurst = DISABLE;
- dmaDefaultConf.RxDMABurstLength = ETH_RXDMABURSTLENGTH_32BEAT;
- dmaDefaultConf.SecondPacketOperate = DISABLE;
- dmaDefaultConf.TxDMABurstLength = ETH_TXDMABURSTLENGTH_32BEAT;
- dmaDefaultConf.TCPSegmentation = DISABLE;
- dmaDefaultConf.MaximumSegmentSize = ETH_SEGMENT_SIZE_DEFAULT;
-
- /* DMA default configuration */
- ETH_SetDMAConfig(heth, &dmaDefaultConf);
-}
-
-
-/**
- * @brief Initializes the DMA Tx descriptors.
- * called by HAL_ETH_Init() API.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @retval None
- */
-static void ETH_DMATxDescListInit(ETH_HandleTypeDef *heth)
-{
- ETH_DMADescTypeDef *dmatxdesc;
- uint32_t i;
-
- /* Fill each DMATxDesc descriptor with the right values */
- for (i = 0; i < (uint32_t)ETH_TX_DESC_CNT; i++)
- {
- dmatxdesc = heth->Init.TxDesc + i;
-
- WRITE_REG(dmatxdesc->DESC0, 0x0);
- WRITE_REG(dmatxdesc->DESC1, 0x0);
- WRITE_REG(dmatxdesc->DESC2, 0x0);
- WRITE_REG(dmatxdesc->DESC3, 0x0);
-
- WRITE_REG(heth->TxDescList.TxDesc[i], (uint32_t)dmatxdesc);
-
- }
-
- heth->TxDescList.CurTxDesc = 0;
-
- /* Set Transmit Descriptor Ring Length */
- WRITE_REG(heth->Instance->DMACTDRLR, (ETH_TX_DESC_CNT - 1U));
-
- /* Set Transmit Descriptor List Address */
- WRITE_REG(heth->Instance->DMACTDLAR, (uint32_t) heth->Init.TxDesc);
-
- /* Set Transmit Descriptor Tail pointer */
- WRITE_REG(heth->Instance->DMACTDTPR, (uint32_t) heth->Init.TxDesc);
-}
-
-/**
- * @brief Initializes the DMA Rx descriptors in chain mode.
- * called by HAL_ETH_Init() API.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @retval None
- */
-static void ETH_DMARxDescListInit(ETH_HandleTypeDef *heth)
-{
- ETH_DMADescTypeDef *dmarxdesc;
- uint32_t i;
-
- for (i = 0; i < (uint32_t)ETH_RX_DESC_CNT; i++)
- {
- dmarxdesc = heth->Init.RxDesc + i;
-
- WRITE_REG(dmarxdesc->DESC0, 0x0);
- WRITE_REG(dmarxdesc->DESC1, 0x0);
- WRITE_REG(dmarxdesc->DESC2, 0x0);
- WRITE_REG(dmarxdesc->DESC3, 0x0);
- WRITE_REG(dmarxdesc->BackupAddr0, 0x0);
- WRITE_REG(dmarxdesc->BackupAddr1, 0x0);
-
-
- /* Set Rx descritors addresses */
- WRITE_REG(heth->RxDescList.RxDesc[i], (uint32_t)dmarxdesc);
-
- }
-
- WRITE_REG(heth->RxDescList.RxDescIdx, 0);
- WRITE_REG(heth->RxDescList.RxDescCnt, 0);
- WRITE_REG(heth->RxDescList.RxBuildDescIdx, 0);
- WRITE_REG(heth->RxDescList.RxBuildDescCnt, 0);
- WRITE_REG(heth->RxDescList.ItMode, 0);
-
- /* Set Receive Descriptor Ring Length */
- WRITE_REG(heth->Instance->DMACRDRLR, ((uint32_t)(ETH_RX_DESC_CNT - 1U)));
-
- /* Set Receive Descriptor List Address */
- WRITE_REG(heth->Instance->DMACRDLAR, (uint32_t) heth->Init.RxDesc);
-
- /* Set Receive Descriptor Tail pointer Address */
- WRITE_REG(heth->Instance->DMACRDTPR, ((uint32_t)(heth->Init.RxDesc + (uint32_t)(ETH_RX_DESC_CNT - 1U))));
-}
-
-/**
- * @brief Prepare Tx DMA descriptor before transmission.
- * called by HAL_ETH_Transmit_IT and HAL_ETH_Transmit_IT() API.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @param pTxConfig: Tx packet configuration
- * @param ItMode: Enable or disable Tx EOT interrept
- * @retval Status
- */
-static uint32_t ETH_Prepare_Tx_Descriptors(ETH_HandleTypeDef *heth, ETH_TxPacketConfig *pTxConfig, uint32_t ItMode)
-{
- ETH_TxDescListTypeDef *dmatxdesclist = &heth->TxDescList;
- uint32_t descidx = dmatxdesclist->CurTxDesc;
- uint32_t firstdescidx = dmatxdesclist->CurTxDesc;
- uint32_t idx;
- uint32_t descnbr = 0;
- ETH_DMADescTypeDef *dmatxdesc = (ETH_DMADescTypeDef *)dmatxdesclist->TxDesc[descidx];
-
- ETH_BufferTypeDef *txbuffer = pTxConfig->TxBuffer;
- uint32_t bd_count = 0;
-
- /* Current Tx Descriptor Owned by DMA: cannot be used by the application */
- if ((READ_BIT(dmatxdesc->DESC3, ETH_DMATXNDESCWBF_OWN) == ETH_DMATXNDESCWBF_OWN)
- || (dmatxdesclist->PacketAddress[descidx] != NULL))
- {
- return HAL_ETH_ERROR_BUSY;
- }
-
- /***************************************************************************/
- /***************** Context descriptor configuration (Optional) **********/
- /***************************************************************************/
- /* If VLAN tag is enabled for this packet */
- if (READ_BIT(pTxConfig->Attributes, ETH_TX_PACKETS_FEATURES_VLANTAG) != (uint32_t)RESET)
- {
- /* Set vlan tag value */
- MODIFY_REG(dmatxdesc->DESC3, ETH_DMATXCDESC_VT, pTxConfig->VlanTag);
- /* Set vlan tag valid bit */
- SET_BIT(dmatxdesc->DESC3, ETH_DMATXCDESC_VLTV);
- /* Set the descriptor as the vlan input source */
- SET_BIT(heth->Instance->MACVIR, ETH_MACVIR_VLTI);
-
- /* if inner VLAN is enabled */
- if (READ_BIT(pTxConfig->Attributes, ETH_TX_PACKETS_FEATURES_INNERVLANTAG) != (uint32_t)RESET)
- {
- /* Set inner vlan tag value */
- MODIFY_REG(dmatxdesc->DESC2, ETH_DMATXCDESC_IVT, (pTxConfig->InnerVlanTag << 16));
- /* Set inner vlan tag valid bit */
- SET_BIT(dmatxdesc->DESC3, ETH_DMATXCDESC_IVLTV);
-
- /* Set Vlan Tag control */
- MODIFY_REG(dmatxdesc->DESC3, ETH_DMATXCDESC_IVTIR, pTxConfig->InnerVlanCtrl);
-
- /* Set the descriptor as the inner vlan input source */
- SET_BIT(heth->Instance->MACIVIR, ETH_MACIVIR_VLTI);
- /* Enable double VLAN processing */
- SET_BIT(heth->Instance->MACVTR, ETH_MACVTR_EDVLP);
- }
- }
-
- /* if tcp segmentation is enabled for this packet */
- if (READ_BIT(pTxConfig->Attributes, ETH_TX_PACKETS_FEATURES_TSO) != (uint32_t)RESET)
- {
- /* Set MSS value */
- MODIFY_REG(dmatxdesc->DESC2, ETH_DMATXCDESC_MSS, pTxConfig->MaxSegmentSize);
- /* Set MSS valid bit */
- SET_BIT(dmatxdesc->DESC3, ETH_DMATXCDESC_TCMSSV);
- }
-
- if ((READ_BIT(pTxConfig->Attributes, ETH_TX_PACKETS_FEATURES_VLANTAG) != (uint32_t)RESET)
- || (READ_BIT(pTxConfig->Attributes, ETH_TX_PACKETS_FEATURES_TSO) != (uint32_t)RESET))
- {
- /* Set as context descriptor */
- SET_BIT(dmatxdesc->DESC3, ETH_DMATXCDESC_CTXT);
- /* Ensure rest of descriptor is written to RAM before the OWN bit */
- __DMB();
- /* Set own bit */
- SET_BIT(dmatxdesc->DESC3, ETH_DMATXCDESC_OWN);
- /* Increment current tx descriptor index */
- INCR_TX_DESC_INDEX(descidx, 1U);
- /* Get current descriptor address */
- dmatxdesc = (ETH_DMADescTypeDef *)dmatxdesclist->TxDesc[descidx];
-
- descnbr += 1U;
-
- /* Current Tx Descriptor Owned by DMA: cannot be used by the application */
- if (READ_BIT(dmatxdesc->DESC3, ETH_DMATXNDESCWBF_OWN) == ETH_DMATXNDESCWBF_OWN)
- {
- dmatxdesc = (ETH_DMADescTypeDef *)dmatxdesclist->TxDesc[firstdescidx];
- /* Ensure rest of descriptor is written to RAM before the OWN bit */
- __DMB();
- /* Clear own bit */
- CLEAR_BIT(dmatxdesc->DESC3, ETH_DMATXCDESC_OWN);
-
- return HAL_ETH_ERROR_BUSY;
- }
- }
-
- /***************************************************************************/
- /***************** Normal descriptors configuration *****************/
- /***************************************************************************/
-
- descnbr += 1U;
-
- /* Set header or buffer 1 address */
- WRITE_REG(dmatxdesc->DESC0, (uint32_t)txbuffer->buffer);
- /* Set header or buffer 1 Length */
- MODIFY_REG(dmatxdesc->DESC2, ETH_DMATXNDESCRF_B1L, txbuffer->len);
-
- if (txbuffer->next != NULL)
- {
- txbuffer = txbuffer->next;
- /* Set buffer 2 address */
- WRITE_REG(dmatxdesc->DESC1, (uint32_t)txbuffer->buffer);
- /* Set buffer 2 Length */
- MODIFY_REG(dmatxdesc->DESC2, ETH_DMATXNDESCRF_B2L, (txbuffer->len << 16));
- }
- else
- {
- WRITE_REG(dmatxdesc->DESC1, 0x0);
- /* Set buffer 2 Length */
- MODIFY_REG(dmatxdesc->DESC2, ETH_DMATXNDESCRF_B2L, 0x0U);
- }
-
- if (READ_BIT(pTxConfig->Attributes, ETH_TX_PACKETS_FEATURES_TSO) != (uint32_t)RESET)
- {
- /* Set TCP Header length */
- MODIFY_REG(dmatxdesc->DESC3, ETH_DMATXNDESCRF_THL, (pTxConfig->TCPHeaderLen << 19));
- /* Set TCP payload length */
- MODIFY_REG(dmatxdesc->DESC3, ETH_DMATXNDESCRF_TPL, pTxConfig->PayloadLen);
- /* Set TCP Segmentation Enabled bit */
- SET_BIT(dmatxdesc->DESC3, ETH_DMATXNDESCRF_TSE);
- }
- else
- {
- MODIFY_REG(dmatxdesc->DESC3, ETH_DMATXNDESCRF_FL, pTxConfig->Length);
-
- if (READ_BIT(pTxConfig->Attributes, ETH_TX_PACKETS_FEATURES_CSUM) != (uint32_t)RESET)
- {
- MODIFY_REG(dmatxdesc->DESC3, ETH_DMATXNDESCRF_CIC, pTxConfig->ChecksumCtrl);
- }
-
- if (READ_BIT(pTxConfig->Attributes, ETH_TX_PACKETS_FEATURES_CRCPAD) != (uint32_t)RESET)
- {
- MODIFY_REG(dmatxdesc->DESC3, ETH_DMATXNDESCRF_CPC, pTxConfig->CRCPadCtrl);
- }
- }
-
- if (READ_BIT(pTxConfig->Attributes, ETH_TX_PACKETS_FEATURES_VLANTAG) != (uint32_t)RESET)
- {
- /* Set Vlan Tag control */
- MODIFY_REG(dmatxdesc->DESC2, ETH_DMATXNDESCRF_VTIR, pTxConfig->VlanCtrl);
- }
-
- /* Mark it as First Descriptor */
- SET_BIT(dmatxdesc->DESC3, ETH_DMATXNDESCRF_FD);
- /* Mark it as NORMAL descriptor */
- CLEAR_BIT(dmatxdesc->DESC3, ETH_DMATXNDESCRF_CTXT);
- /* Ensure rest of descriptor is written to RAM before the OWN bit */
- __DMB();
- /* set OWN bit of FIRST descriptor */
- SET_BIT(dmatxdesc->DESC3, ETH_DMATXNDESCRF_OWN);
-
- /* If source address insertion/replacement is enabled for this packet */
- if (READ_BIT(pTxConfig->Attributes, ETH_TX_PACKETS_FEATURES_SAIC) != (uint32_t)RESET)
- {
- MODIFY_REG(dmatxdesc->DESC3, ETH_DMATXNDESCRF_SAIC, pTxConfig->SrcAddrCtrl);
- }
-
- /* only if the packet is split into more than one descriptors > 1 */
- while (txbuffer->next != NULL)
- {
- /* Clear the LD bit of previous descriptor */
- CLEAR_BIT(dmatxdesc->DESC3, ETH_DMATXNDESCRF_LD);
- /* Increment current tx descriptor index */
- INCR_TX_DESC_INDEX(descidx, 1U);
- /* Get current descriptor address */
- dmatxdesc = (ETH_DMADescTypeDef *)dmatxdesclist->TxDesc[descidx];
-
- /* Clear the FD bit of new Descriptor */
- CLEAR_BIT(dmatxdesc->DESC3, ETH_DMATXNDESCRF_FD);
-
- /* Current Tx Descriptor Owned by DMA: cannot be used by the application */
- if ((READ_BIT(dmatxdesc->DESC3, ETH_DMATXNDESCRF_OWN) == ETH_DMATXNDESCRF_OWN)
- || (dmatxdesclist->PacketAddress[descidx] != NULL))
- {
- descidx = firstdescidx;
- dmatxdesc = (ETH_DMADescTypeDef *)dmatxdesclist->TxDesc[descidx];
-
- /* clear previous desc own bit */
- for (idx = 0; idx < descnbr; idx ++)
- {
- /* Ensure rest of descriptor is written to RAM before the OWN bit */
- __DMB();
-
- CLEAR_BIT(dmatxdesc->DESC3, ETH_DMATXNDESCRF_OWN);
-
- /* Increment current tx descriptor index */
- INCR_TX_DESC_INDEX(descidx, 1U);
- /* Get current descriptor address */
- dmatxdesc = (ETH_DMADescTypeDef *)dmatxdesclist->TxDesc[descidx];
- }
-
- return HAL_ETH_ERROR_BUSY;
- }
-
- descnbr += 1U;
-
- /* Get the next Tx buffer in the list */
- txbuffer = txbuffer->next;
-
- /* Set header or buffer 1 address */
- WRITE_REG(dmatxdesc->DESC0, (uint32_t)txbuffer->buffer);
- /* Set header or buffer 1 Length */
- MODIFY_REG(dmatxdesc->DESC2, ETH_DMATXNDESCRF_B1L, txbuffer->len);
-
- if (txbuffer->next != NULL)
- {
- /* Get the next Tx buffer in the list */
- txbuffer = txbuffer->next;
- /* Set buffer 2 address */
- WRITE_REG(dmatxdesc->DESC1, (uint32_t)txbuffer->buffer);
- /* Set buffer 2 Length */
- MODIFY_REG(dmatxdesc->DESC2, ETH_DMATXNDESCRF_B2L, (txbuffer->len << 16));
- }
- else
- {
- WRITE_REG(dmatxdesc->DESC1, 0x0);
- /* Set buffer 2 Length */
- MODIFY_REG(dmatxdesc->DESC2, ETH_DMATXNDESCRF_B2L, 0x0U);
- }
-
- if (READ_BIT(pTxConfig->Attributes, ETH_TX_PACKETS_FEATURES_TSO) != (uint32_t)RESET)
- {
- /* Set TCP payload length */
- MODIFY_REG(dmatxdesc->DESC3, ETH_DMATXNDESCRF_TPL, pTxConfig->PayloadLen);
- /* Set TCP Segmentation Enabled bit */
- SET_BIT(dmatxdesc->DESC3, ETH_DMATXNDESCRF_TSE);
- }
- else
- {
- /* Set the packet length */
- MODIFY_REG(dmatxdesc->DESC3, ETH_DMATXNDESCRF_FL, pTxConfig->Length);
-
- if (READ_BIT(pTxConfig->Attributes, ETH_TX_PACKETS_FEATURES_CSUM) != (uint32_t)RESET)
- {
- /* Checksum Insertion Control */
- MODIFY_REG(dmatxdesc->DESC3, ETH_DMATXNDESCRF_CIC, pTxConfig->ChecksumCtrl);
- }
- }
-
- bd_count += 1U;
-
- /* Ensure rest of descriptor is written to RAM before the OWN bit */
- __DMB();
- /* Set Own bit */
- SET_BIT(dmatxdesc->DESC3, ETH_DMATXNDESCRF_OWN);
- /* Mark it as NORMAL descriptor */
- CLEAR_BIT(dmatxdesc->DESC3, ETH_DMATXNDESCRF_CTXT);
- }
-
- if (ItMode != ((uint32_t)RESET))
- {
- /* Set Interrupt on completion bit */
- SET_BIT(dmatxdesc->DESC2, ETH_DMATXNDESCRF_IOC);
- }
- else
- {
- /* Clear Interrupt on completion bit */
- CLEAR_BIT(dmatxdesc->DESC2, ETH_DMATXNDESCRF_IOC);
- }
-
- /* Mark it as LAST descriptor */
- SET_BIT(dmatxdesc->DESC3, ETH_DMATXNDESCRF_LD);
- /* Save the current packet address to expose it to the application */
- dmatxdesclist->PacketAddress[descidx] = dmatxdesclist->CurrentPacketAddress;
-
- dmatxdesclist->CurTxDesc = descidx;
-
- /* disable the interrupt */
- __disable_irq();
-
- dmatxdesclist->BuffersInUse += bd_count + 1U;
-
- /* Enable interrupts back */
- __enable_irq();
-
-
- /* Return function status */
- return HAL_ETH_ERROR_NONE;
-}
-
-#if (USE_HAL_ETH_REGISTER_CALLBACKS == 1)
-static void ETH_InitCallbacksToDefault(ETH_HandleTypeDef *heth)
-{
- /* Init the ETH Callback settings */
- heth->TxCpltCallback = HAL_ETH_TxCpltCallback; /* Legacy weak TxCpltCallback */
- heth->RxCpltCallback = HAL_ETH_RxCpltCallback; /* Legacy weak RxCpltCallback */
- heth->ErrorCallback = HAL_ETH_ErrorCallback; /* Legacy weak ErrorCallback */
- heth->PMTCallback = HAL_ETH_PMTCallback; /* Legacy weak PMTCallback */
- heth->EEECallback = HAL_ETH_EEECallback; /* Legacy weak EEECallback */
- heth->WakeUpCallback = HAL_ETH_WakeUpCallback; /* Legacy weak WakeUpCallback */
- heth->rxLinkCallback = HAL_ETH_RxLinkCallback; /* Legacy weak RxLinkCallback */
- heth->txFreeCallback = HAL_ETH_TxFreeCallback; /* Legacy weak TxFreeCallback */
-#ifdef HAL_ETH_USE_PTP
- heth->txPtpCallback = HAL_ETH_TxPtpCallback; /* Legacy weak TxPtpCallback */
-#endif /* HAL_ETH_USE_PTP */
- heth->rxAllocateCallback = HAL_ETH_RxAllocateCallback; /* Legacy weak RxAllocateCallback */
-}
-#endif /* USE_HAL_ETH_REGISTER_CALLBACKS */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-#endif /* ETH */
-
-#endif /* HAL_ETH_MODULE_ENABLED */
-
-/**
- * @}
- */
-
diff --git a/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_eth_ex.c b/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_eth_ex.c
deleted file mode 100644
index ad9870c..0000000
--- a/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_eth_ex.c
+++ /dev/null
@@ -1,578 +0,0 @@
-/**
- ******************************************************************************
- * @file stm32h7xx_hal_eth_ex.c
- * @author MCD Application Team
- * @brief ETH HAL Extended module driver.
- *
- ******************************************************************************
- * @attention
- *
- * Copyright (c) 2017 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.
- *
- ******************************************************************************
- */
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32h7xx_hal.h"
-
-/** @addtogroup STM32H7xx_HAL_Driver
- * @{
- */
-
-#ifdef HAL_ETH_MODULE_ENABLED
-
-#if defined(ETH)
-
-/** @defgroup ETHEx ETHEx
- * @brief ETH HAL Extended module driver
- * @{
- */
-
-
-/* Private typedef -----------------------------------------------------------*/
-/* Private define ------------------------------------------------------------*/
-/** @defgroup ETHEx_Private_Constants ETHEx Private Constants
- * @{
- */
-#define ETH_MACL4CR_MASK (ETH_MACL3L4CR_L4PEN | ETH_MACL3L4CR_L4SPM | \
- ETH_MACL3L4CR_L4SPIM | ETH_MACL3L4CR_L4DPM | \
- ETH_MACL3L4CR_L4DPIM)
-
-#define ETH_MACL3CR_MASK (ETH_MACL3L4CR_L3PEN | ETH_MACL3L4CR_L3SAM | \
- ETH_MACL3L4CR_L3SAIM | ETH_MACL3L4CR_L3DAM | \
- ETH_MACL3L4CR_L3DAIM | ETH_MACL3L4CR_L3HSBM | \
- ETH_MACL3L4CR_L3HDBM)
-
-#define ETH_MACRXVLAN_MASK (ETH_MACVTR_EIVLRXS | ETH_MACVTR_EIVLS | \
- ETH_MACVTR_ERIVLT | ETH_MACVTR_EDVLP | \
- ETH_MACVTR_VTHM | ETH_MACVTR_EVLRXS | \
- ETH_MACVTR_EVLS | ETH_MACVTR_DOVLTC | \
- ETH_MACVTR_ERSVLM | ETH_MACVTR_ESVL | \
- ETH_MACVTR_VTIM | ETH_MACVTR_ETV)
-
-#define ETH_MACTXVLAN_MASK (ETH_MACVIR_VLTI | ETH_MACVIR_CSVL | \
- ETH_MACVIR_VLP | ETH_MACVIR_VLC)
-/**
- * @}
- */
-
-/* Private macros ------------------------------------------------------------*/
-/* Private function prototypes -----------------------------------------------*/
-/* Exported functions ---------------------------------------------------------*/
-/** @defgroup ETHEx_Exported_Functions ETH Extended Exported Functions
- * @{
- */
-
-/** @defgroup ETHEx_Exported_Functions_Group1 Extended features functions
- * @brief Extended features functions
- *
-@verbatim
- ===============================================================================
- ##### Extended features functions #####
- ===============================================================================
- [..] This section provides functions allowing to:
- (+) Configure ARP offload module
- (+) Configure L3 and L4 filters
- (+) Configure Extended VLAN features
- (+) Configure Energy Efficient Ethernet module
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Enables ARP Offload.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @retval None
- */
-void HAL_ETHEx_EnableARPOffload(ETH_HandleTypeDef *heth)
-{
- SET_BIT(heth->Instance->MACCR, ETH_MACCR_ARP);
-}
-
-/**
- * @brief Disables ARP Offload.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @retval None
- */
-void HAL_ETHEx_DisableARPOffload(ETH_HandleTypeDef *heth)
-{
- CLEAR_BIT(heth->Instance->MACCR, ETH_MACCR_ARP);
-}
-
-/**
- * @brief Set the ARP Match IP address
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @param IpAddress: IP Address to be matched for incoming ARP requests
- * @retval None
- */
-void HAL_ETHEx_SetARPAddressMatch(ETH_HandleTypeDef *heth, uint32_t IpAddress)
-{
- WRITE_REG(heth->Instance->MACARPAR, IpAddress);
-}
-
-/**
- * @brief Configures the L4 Filter, this function allow to:
- * set the layer 4 protocol to be matched (TCP or UDP)
- * enable/disable L4 source/destination port perfect/inverse match.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @param Filter: L4 filter to configured, this parameter must be one of the following
- * ETH_L4_FILTER_0
- * ETH_L4_FILTER_1
- * @param pL4FilterConfig: pointer to a ETH_L4FilterConfigTypeDef structure
- * that contains L4 filter configuration.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_ETHEx_SetL4FilterConfig(ETH_HandleTypeDef *heth, uint32_t Filter,
- ETH_L4FilterConfigTypeDef *pL4FilterConfig)
-{
- __IO uint32_t *configreg = ((__IO uint32_t *)(&(heth->Instance->MACL3L4C0R) + Filter));
-
- if (pL4FilterConfig == NULL)
- {
- return HAL_ERROR;
- }
-
- /* Write configuration to (MACL3L4C0R + filter )register */
- MODIFY_REG(*configreg, ETH_MACL4CR_MASK, (pL4FilterConfig->Protocol |
- pL4FilterConfig->SrcPortFilterMatch |
- pL4FilterConfig->DestPortFilterMatch));
-
- configreg = ((__IO uint32_t *)(&(heth->Instance->MACL4A0R) + Filter));
-
- /* Write configuration to (MACL4A0R + filter )register */
- MODIFY_REG(*configreg, (ETH_MACL4AR_L4DP | ETH_MACL4AR_L4SP), (pL4FilterConfig->SourcePort |
- (pL4FilterConfig->DestinationPort << 16)));
-
- /* Enable L4 filter */
- SET_BIT(heth->Instance->MACPFR, ETH_MACPFR_IPFE);
-
- return HAL_OK;
-}
-
-/**
- * @brief Configures the L4 Filter, this function allow to:
- * set the layer 4 protocol to be matched (TCP or UDP)
- * enable/disable L4 source/destination port perfect/inverse match.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @param Filter: L4 filter to configured, this parameter must be one of the following
- * ETH_L4_FILTER_0
- * ETH_L4_FILTER_1
- * @param pL4FilterConfig: pointer to a ETH_L4FilterConfigTypeDef structure
- * that contains L4 filter configuration.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_ETHEx_GetL4FilterConfig(ETH_HandleTypeDef *heth, uint32_t Filter,
- ETH_L4FilterConfigTypeDef *pL4FilterConfig)
-{
- if (pL4FilterConfig == NULL)
- {
- return HAL_ERROR;
- }
-
- /* Get configuration to (MACL3L4C0R + filter )register */
- pL4FilterConfig->Protocol = READ_BIT(*((__IO uint32_t *)(&(heth->Instance->MACL3L4C0R) + Filter)),
- ETH_MACL3L4CR_L4PEN);
- pL4FilterConfig->DestPortFilterMatch = READ_BIT(*((__IO uint32_t *)(&(heth->Instance->MACL3L4C0R) + Filter)),
- (ETH_MACL3L4CR_L4DPM | ETH_MACL3L4CR_L4DPIM));
- pL4FilterConfig->SrcPortFilterMatch = READ_BIT(*((__IO uint32_t *)(&(heth->Instance->MACL3L4C0R) + Filter)),
- (ETH_MACL3L4CR_L4SPM | ETH_MACL3L4CR_L4SPIM));
-
- /* Get configuration to (MACL3L4C0R + filter )register */
- pL4FilterConfig->DestinationPort = (READ_BIT(*((__IO uint32_t *)(&(heth->Instance->MACL4A0R) + Filter)),
- ETH_MACL4AR_L4DP) >> 16);
- pL4FilterConfig->SourcePort = READ_BIT(*((__IO uint32_t *)(&(heth->Instance->MACL4A0R) + Filter)), ETH_MACL4AR_L4SP);
-
- return HAL_OK;
-}
-
-/**
- * @brief Configures the L3 Filter, this function allow to:
- * set the layer 3 protocol to be matched (IPv4 or IPv6)
- * enable/disable L3 source/destination port perfect/inverse match.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @param Filter: L3 filter to configured, this parameter must be one of the following
- * ETH_L3_FILTER_0
- * ETH_L3_FILTER_1
- * @param pL3FilterConfig: pointer to a ETH_L3FilterConfigTypeDef structure
- * that contains L3 filter configuration.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_ETHEx_SetL3FilterConfig(ETH_HandleTypeDef *heth, uint32_t Filter,
- ETH_L3FilterConfigTypeDef *pL3FilterConfig)
-{
- __IO uint32_t *configreg = ((__IO uint32_t *)(&(heth->Instance->MACL3L4C0R) + Filter));
-
- if (pL3FilterConfig == NULL)
- {
- return HAL_ERROR;
- }
-
- /* Write configuration to (MACL3L4C0R + filter )register */
- MODIFY_REG(*configreg, ETH_MACL3CR_MASK, (pL3FilterConfig->Protocol |
- pL3FilterConfig->SrcAddrFilterMatch |
- pL3FilterConfig->DestAddrFilterMatch |
- (pL3FilterConfig->SrcAddrHigherBitsMatch << 6) |
- (pL3FilterConfig->DestAddrHigherBitsMatch << 11)));
-
- /* Check if IPv6 protocol is selected */
- if (pL3FilterConfig->Protocol != ETH_L3_IPV4_MATCH)
- {
- /* Set the IPv6 address match */
- /* Set Bits[31:0] of 128-bit IP addr */
- *((__IO uint32_t *)(&(heth->Instance->MACL3A0R0R) + Filter)) = pL3FilterConfig->Ip6Addr[0];
- /* Set Bits[63:32] of 128-bit IP addr */
- *((__IO uint32_t *)(&(heth->Instance->MACL3A1R0R) + Filter)) = pL3FilterConfig->Ip6Addr[1];
- /* update Bits[95:64] of 128-bit IP addr */
- *((__IO uint32_t *)(&(heth->Instance->MACL3A2R0R) + Filter)) = pL3FilterConfig->Ip6Addr[2];
- /* update Bits[127:96] of 128-bit IP addr */
- *((__IO uint32_t *)(&(heth->Instance->MACL3A3R0R) + Filter)) = pL3FilterConfig->Ip6Addr[3];
- }
- else /* IPv4 protocol is selected */
- {
- /* Set the IPv4 source address match */
- *((__IO uint32_t *)(&(heth->Instance->MACL3A0R0R) + Filter)) = pL3FilterConfig->Ip4SrcAddr;
- /* Set the IPv4 destination address match */
- *((__IO uint32_t *)(&(heth->Instance->MACL3A1R0R) + Filter)) = pL3FilterConfig->Ip4DestAddr;
- }
-
- return HAL_OK;
-}
-
-/**
- * @brief Configures the L3 Filter, this function allow to:
- * set the layer 3 protocol to be matched (IPv4 or IPv6)
- * enable/disable L3 source/destination port perfect/inverse match.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @param Filter: L3 filter to configured, this parameter must be one of the following
- * ETH_L3_FILTER_0
- * ETH_L3_FILTER_1
- * @param pL3FilterConfig: pointer to a ETH_L3FilterConfigTypeDef structure
- * that will contain the L3 filter configuration.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_ETHEx_GetL3FilterConfig(ETH_HandleTypeDef *heth, uint32_t Filter,
- ETH_L3FilterConfigTypeDef *pL3FilterConfig)
-{
- if (pL3FilterConfig == NULL)
- {
- return HAL_ERROR;
- }
-
- pL3FilterConfig->Protocol = READ_BIT(*((__IO uint32_t *)(&(heth->Instance->MACL3L4C0R) + Filter)),
- ETH_MACL3L4CR_L3PEN);
- pL3FilterConfig->SrcAddrFilterMatch = READ_BIT(*((__IO uint32_t *)(&(heth->Instance->MACL3L4C0R) + Filter)),
- (ETH_MACL3L4CR_L3SAM | ETH_MACL3L4CR_L3SAIM));
- pL3FilterConfig->DestAddrFilterMatch = READ_BIT(*((__IO uint32_t *)(&(heth->Instance->MACL3L4C0R) + Filter)),
- (ETH_MACL3L4CR_L3DAM | ETH_MACL3L4CR_L3DAIM));
- pL3FilterConfig->SrcAddrHigherBitsMatch = (READ_BIT(*((__IO uint32_t *)(&(heth->Instance->MACL3L4C0R) + Filter)),
- ETH_MACL3L4CR_L3HSBM) >> 6);
- pL3FilterConfig->DestAddrHigherBitsMatch = (READ_BIT(*((__IO uint32_t *)(&(heth->Instance->MACL3L4C0R) + Filter)),
- ETH_MACL3L4CR_L3HDBM) >> 11);
-
- if (pL3FilterConfig->Protocol != ETH_L3_IPV4_MATCH)
- {
- pL3FilterConfig->Ip6Addr[0] = *((__IO uint32_t *)(&(heth->Instance->MACL3A0R0R) + Filter));
- pL3FilterConfig->Ip6Addr[1] = *((__IO uint32_t *)(&(heth->Instance->MACL3A1R0R) + Filter));
- pL3FilterConfig->Ip6Addr[2] = *((__IO uint32_t *)(&(heth->Instance->MACL3A2R0R) + Filter));
- pL3FilterConfig->Ip6Addr[3] = *((__IO uint32_t *)(&(heth->Instance->MACL3A3R0R) + Filter));
- }
- else
- {
- pL3FilterConfig->Ip4SrcAddr = *((__IO uint32_t *)(&(heth->Instance->MACL3A0R0R) + Filter));
- pL3FilterConfig->Ip4DestAddr = *((__IO uint32_t *)(&(heth->Instance->MACL3A1R0R) + Filter));
- }
-
- return HAL_OK;
-}
-
-/**
- * @brief Enables L3 and L4 filtering process.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @retval None.
- */
-void HAL_ETHEx_EnableL3L4Filtering(ETH_HandleTypeDef *heth)
-{
- /* Enable L3/L4 filter */
- SET_BIT(heth->Instance->MACPFR, ETH_MACPFR_IPFE);
-}
-
-/**
- * @brief Disables L3 and L4 filtering process.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @retval None.
- */
-void HAL_ETHEx_DisableL3L4Filtering(ETH_HandleTypeDef *heth)
-{
- /* Disable L3/L4 filter */
- CLEAR_BIT(heth->Instance->MACPFR, ETH_MACPFR_IPFE);
-}
-
-/**
- * @brief Get the VLAN Configuration for Receive Packets.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @param pVlanConfig: pointer to a ETH_RxVLANConfigTypeDef structure
- * that will contain the VLAN filter configuration.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_ETHEx_GetRxVLANConfig(ETH_HandleTypeDef *heth, ETH_RxVLANConfigTypeDef *pVlanConfig)
-{
- if (pVlanConfig == NULL)
- {
- return HAL_ERROR;
- }
-
- pVlanConfig->InnerVLANTagInStatus = ((READ_BIT(heth->Instance->MACVTR,
- ETH_MACVTR_EIVLRXS) >> 31) == 0U) ? DISABLE : ENABLE;
- pVlanConfig->StripInnerVLANTag = READ_BIT(heth->Instance->MACVTR, ETH_MACVTR_EIVLS);
- pVlanConfig->InnerVLANTag = ((READ_BIT(heth->Instance->MACVTR, ETH_MACVTR_ERIVLT) >> 27) == 0U) ? DISABLE : ENABLE;
- pVlanConfig->DoubleVLANProcessing = ((READ_BIT(heth->Instance->MACVTR,
- ETH_MACVTR_EDVLP) >> 26) == 0U) ? DISABLE : ENABLE;
- pVlanConfig->VLANTagHashTableMatch = ((READ_BIT(heth->Instance->MACVTR,
- ETH_MACVTR_VTHM) >> 25) == 0U) ? DISABLE : ENABLE;
- pVlanConfig->VLANTagInStatus = ((READ_BIT(heth->Instance->MACVTR, ETH_MACVTR_EVLRXS) >> 24) == 0U) ? DISABLE : ENABLE;
- pVlanConfig->StripVLANTag = READ_BIT(heth->Instance->MACVTR, ETH_MACVTR_EVLS);
- pVlanConfig->VLANTypeCheck = READ_BIT(heth->Instance->MACVTR,
- (ETH_MACVTR_DOVLTC | ETH_MACVTR_ERSVLM | ETH_MACVTR_ESVL));
- pVlanConfig->VLANTagInverceMatch = ((READ_BIT(heth->Instance->MACVTR, ETH_MACVTR_VTIM) >> 17) == 0U)
- ? DISABLE : ENABLE;
-
- return HAL_OK;
-}
-
-/**
- * @brief Set the VLAN Configuration for Receive Packets.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @param pVlanConfig: pointer to a ETH_RxVLANConfigTypeDef structure
- * that contains VLAN filter configuration.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_ETHEx_SetRxVLANConfig(ETH_HandleTypeDef *heth, ETH_RxVLANConfigTypeDef *pVlanConfig)
-{
- if (pVlanConfig == NULL)
- {
- return HAL_ERROR;
- }
-
- /* Write config to MACVTR */
- MODIFY_REG(heth->Instance->MACVTR, ETH_MACRXVLAN_MASK, (((uint32_t)pVlanConfig->InnerVLANTagInStatus << 31) |
- pVlanConfig->StripInnerVLANTag |
- ((uint32_t)pVlanConfig->InnerVLANTag << 27) |
- ((uint32_t)pVlanConfig->DoubleVLANProcessing << 26) |
- ((uint32_t)pVlanConfig->VLANTagHashTableMatch << 25) |
- ((uint32_t)pVlanConfig->VLANTagInStatus << 24) |
- pVlanConfig->StripVLANTag |
- pVlanConfig->VLANTypeCheck |
- ((uint32_t)pVlanConfig->VLANTagInverceMatch << 17)));
-
- return HAL_OK;
-}
-
-/**
- * @brief Set the VLAN Hash Table
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @param VLANHashTable: VLAN hash table 16 bit value
- * @retval None
- */
-void HAL_ETHEx_SetVLANHashTable(ETH_HandleTypeDef *heth, uint32_t VLANHashTable)
-{
- MODIFY_REG(heth->Instance->MACVHTR, ETH_MACVHTR_VLHT, VLANHashTable);
-}
-
-/**
- * @brief Get the VLAN Configuration for Transmit Packets.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @param VLANTag: Selects the vlan tag, this parameter must be one of the following
- * ETH_OUTER_TX_VLANTAG
- * ETH_INNER_TX_VLANTAG
- * @param pVlanConfig: pointer to a ETH_TxVLANConfigTypeDef structure
- * that will contain the Tx VLAN filter configuration.
- * @retval HAL Status.
- */
-HAL_StatusTypeDef HAL_ETHEx_GetTxVLANConfig(ETH_HandleTypeDef *heth, uint32_t VLANTag,
- ETH_TxVLANConfigTypeDef *pVlanConfig)
-{
- if (pVlanConfig == NULL)
- {
- return HAL_ERROR;
- }
-
- if (VLANTag == ETH_INNER_TX_VLANTAG)
- {
- pVlanConfig->SourceTxDesc = ((READ_BIT(heth->Instance->MACIVIR, ETH_MACVIR_VLTI) >> 20) == 0U) ? DISABLE : ENABLE;
- pVlanConfig->SVLANType = ((READ_BIT(heth->Instance->MACIVIR, ETH_MACVIR_CSVL) >> 19) == 0U) ? DISABLE : ENABLE;
- pVlanConfig->VLANTagControl = READ_BIT(heth->Instance->MACIVIR, (ETH_MACVIR_VLP | ETH_MACVIR_VLC));
- }
- else
- {
- pVlanConfig->SourceTxDesc = ((READ_BIT(heth->Instance->MACVIR, ETH_MACVIR_VLTI) >> 20) == 0U) ? DISABLE : ENABLE;
- pVlanConfig->SVLANType = ((READ_BIT(heth->Instance->MACVIR, ETH_MACVIR_CSVL) >> 19) == 0U) ? DISABLE : ENABLE;
- pVlanConfig->VLANTagControl = READ_BIT(heth->Instance->MACVIR, (ETH_MACVIR_VLP | ETH_MACVIR_VLC));
- }
-
- return HAL_OK;;
-}
-
-/**
- * @brief Set the VLAN Configuration for Transmit Packets.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @param VLANTag: Selects the vlan tag, this parameter must be one of the following
- * ETH_OUTER_TX_VLANTAG
- * ETH_INNER_TX_VLANTAG
- * @param pVlanConfig: pointer to a ETH_TxVLANConfigTypeDef structure
- * that contains Tx VLAN filter configuration.
- * @retval HAL Status
- */
-HAL_StatusTypeDef HAL_ETHEx_SetTxVLANConfig(ETH_HandleTypeDef *heth, uint32_t VLANTag,
- ETH_TxVLANConfigTypeDef *pVlanConfig)
-{
- if (VLANTag == ETH_INNER_TX_VLANTAG)
- {
- MODIFY_REG(heth->Instance->MACIVIR, ETH_MACTXVLAN_MASK, (((uint32_t)pVlanConfig->SourceTxDesc << 20) |
- ((uint32_t)pVlanConfig->SVLANType << 19) |
- pVlanConfig->VLANTagControl));
- /* Enable Double VLAN processing */
- SET_BIT(heth->Instance->MACVTR, ETH_MACVTR_EDVLP);
- }
- else
- {
- MODIFY_REG(heth->Instance->MACVIR, ETH_MACTXVLAN_MASK, (((uint32_t)pVlanConfig->SourceTxDesc << 20) |
- ((uint32_t)pVlanConfig->SVLANType << 19) |
- pVlanConfig->VLANTagControl));
- }
-
- return HAL_OK;
-}
-
-/**
- * @brief Set the VLAN Tag Identifier for Transmit Packets.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @param VLANTag: Selects the vlan tag, this parameter must be one of the following
- * ETH_OUTER_TX_VLANTAG
- * ETH_INNER_TX_VLANTAG
- * @param VLANIdentifier: VLAN Identifier 16 bit value
- * @retval None
- */
-void HAL_ETHEx_SetTxVLANIdentifier(ETH_HandleTypeDef *heth, uint32_t VLANTag, uint32_t VLANIdentifier)
-{
- if (VLANTag == ETH_INNER_TX_VLANTAG)
- {
- MODIFY_REG(heth->Instance->MACIVIR, ETH_MACVIR_VLT, VLANIdentifier);
- }
- else
- {
- MODIFY_REG(heth->Instance->MACVIR, ETH_MACVIR_VLT, VLANIdentifier);
- }
-}
-
-/**
- * @brief Enables the VLAN Tag Filtering process.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @retval None.
- */
-void HAL_ETHEx_EnableVLANProcessing(ETH_HandleTypeDef *heth)
-{
- /* Enable VLAN processing */
- SET_BIT(heth->Instance->MACPFR, ETH_MACPFR_VTFE);
-}
-
-/**
- * @brief Disables the VLAN Tag Filtering process.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @retval None.
- */
-void HAL_ETHEx_DisableVLANProcessing(ETH_HandleTypeDef *heth)
-{
- /* Disable VLAN processing */
- CLEAR_BIT(heth->Instance->MACPFR, ETH_MACPFR_VTFE);
-}
-
-/**
- * @brief Enters the Low Power Idle (LPI) mode
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @param TxAutomate: Enable/Disable automate enter/exit LPI mode.
- * @param TxClockStop: Enable/Disable Tx clock stop in LPI mode.
- * @retval None
- */
-void HAL_ETHEx_EnterLPIMode(ETH_HandleTypeDef *heth, FunctionalState TxAutomate, FunctionalState TxClockStop)
-{
- /* Enable LPI Interrupts */
- __HAL_ETH_MAC_ENABLE_IT(heth, ETH_MACIER_LPIIE);
-
- /* Write to LPI Control register: Enter low power mode */
- MODIFY_REG(heth->Instance->MACLCSR, (ETH_MACLCSR_LPIEN | ETH_MACLCSR_LPITXA | ETH_MACLCSR_LPITCSE),
- (((uint32_t)TxAutomate << 19) |
- ((uint32_t)TxClockStop << 21) |
- ETH_MACLCSR_LPIEN));
-}
-
-/**
- * @brief Exits the Low Power Idle (LPI) mode.
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @retval None
- */
-void HAL_ETHEx_ExitLPIMode(ETH_HandleTypeDef *heth)
-{
- /* Clear the LPI Config and exit low power mode */
- CLEAR_BIT(heth->Instance->MACLCSR, (ETH_MACLCSR_LPIEN | ETH_MACLCSR_LPITXA | ETH_MACLCSR_LPITCSE));
-
- /* Enable LPI Interrupts */
- __HAL_ETH_MAC_DISABLE_IT(heth, ETH_MACIER_LPIIE);
-}
-
-
-/**
- * @brief Returns the ETH MAC LPI event
- * @param heth: pointer to a ETH_HandleTypeDef structure that contains
- * the configuration information for ETHERNET module
- * @retval ETH MAC WakeUp event
- */
-uint32_t HAL_ETHEx_GetMACLPIEvent(ETH_HandleTypeDef *heth)
-{
- return heth->MACLPIEvent;
-}
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-#endif /* ETH */
-
-#endif /* HAL_ETH_MODULE_ENABLED */
-
-/**
- * @}
- */
-
diff --git a/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_pcd.c b/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_pcd.c
deleted file mode 100644
index be96346..0000000
--- a/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_pcd.c
+++ /dev/null
@@ -1,2352 +0,0 @@
-/**
- ******************************************************************************
- * @file stm32h7xx_hal_pcd.c
- * @author MCD Application Team
- * @brief PCD HAL module driver.
- * This file provides firmware functions to manage the following
- * functionalities of the USB Peripheral Controller:
- * + Initialization and de-initialization functions
- * + IO operation functions
- * + Peripheral Control functions
- * + Peripheral State functions
- *
- ******************************************************************************
- * @attention
- *
- * Copyright (c) 2017 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.
- *
- ******************************************************************************
- @verbatim
- ==============================================================================
- ##### How to use this driver #####
- ==============================================================================
- [..]
- The PCD HAL driver can be used as follows:
-
- (#) Declare a PCD_HandleTypeDef handle structure, for example:
- PCD_HandleTypeDef hpcd;
-
- (#) Fill parameters of Init structure in HCD handle
-
- (#) Call HAL_PCD_Init() API to initialize the PCD peripheral (Core, Device core, ...)
-
- (#) Initialize the PCD low level resources through the HAL_PCD_MspInit() API:
- (##) Enable the PCD/USB Low Level interface clock using
- (+++) __HAL_RCC_USB_OTG_FS_CLK_ENABLE();
- (+++) __HAL_RCC_USB_OTG_HS_CLK_ENABLE(); (For High Speed Mode)
-
- (##) Initialize the related GPIO clocks
- (##) Configure PCD pin-out
- (##) Configure PCD NVIC interrupt
-
- (#)Associate the Upper USB device stack to the HAL PCD Driver:
- (##) hpcd.pData = pdev;
-
- (#)Enable PCD transmission and reception:
- (##) HAL_PCD_Start();
-
- @endverbatim
- ******************************************************************************
- */
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32h7xx_hal.h"
-
-/** @addtogroup STM32H7xx_HAL_Driver
- * @{
- */
-
-/** @defgroup PCD PCD
- * @brief PCD HAL module driver
- * @{
- */
-
-#ifdef HAL_PCD_MODULE_ENABLED
-
-#if defined (USB_OTG_FS) || defined (USB_OTG_HS)
-
-/* Private types -------------------------------------------------------------*/
-/* Private variables ---------------------------------------------------------*/
-/* Private constants ---------------------------------------------------------*/
-/* Private macros ------------------------------------------------------------*/
-/** @defgroup PCD_Private_Macros PCD Private Macros
- * @{
- */
-#define PCD_MIN(a, b) (((a) < (b)) ? (a) : (b))
-#define PCD_MAX(a, b) (((a) > (b)) ? (a) : (b))
-/**
- * @}
- */
-
-/* Private functions prototypes ----------------------------------------------*/
-/** @defgroup PCD_Private_Functions PCD Private Functions
- * @{
- */
-#if defined (USB_OTG_FS) || defined (USB_OTG_HS)
-static HAL_StatusTypeDef PCD_WriteEmptyTxFifo(PCD_HandleTypeDef *hpcd, uint32_t epnum);
-static HAL_StatusTypeDef PCD_EP_OutXfrComplete_int(PCD_HandleTypeDef *hpcd, uint32_t epnum);
-static HAL_StatusTypeDef PCD_EP_OutSetupPacket_int(PCD_HandleTypeDef *hpcd, uint32_t epnum);
-#endif /* defined (USB_OTG_FS) || defined (USB_OTG_HS) */
-/**
- * @}
- */
-
-/* Exported functions --------------------------------------------------------*/
-/** @defgroup PCD_Exported_Functions PCD Exported Functions
- * @{
- */
-
-/** @defgroup PCD_Exported_Functions_Group1 Initialization and de-initialization functions
- * @brief Initialization and Configuration functions
- *
-@verbatim
- ===============================================================================
- ##### Initialization and de-initialization functions #####
- ===============================================================================
- [..] This section provides functions allowing to:
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Initializes the PCD according to the specified
- * parameters in the PCD_InitTypeDef and initialize the associated handle.
- * @param hpcd PCD handle
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_PCD_Init(PCD_HandleTypeDef *hpcd)
-{
- USB_OTG_GlobalTypeDef *USBx;
- uint8_t i;
-
- /* Check the PCD handle allocation */
- if (hpcd == NULL)
- {
- return HAL_ERROR;
- }
-
- /* Check the parameters */
- assert_param(IS_PCD_ALL_INSTANCE(hpcd->Instance));
-
- USBx = hpcd->Instance;
-
- if (hpcd->State == HAL_PCD_STATE_RESET)
- {
- /* Allocate lock resource and initialize it */
- hpcd->Lock = HAL_UNLOCKED;
-
-#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
- hpcd->SOFCallback = HAL_PCD_SOFCallback;
- hpcd->SetupStageCallback = HAL_PCD_SetupStageCallback;
- hpcd->ResetCallback = HAL_PCD_ResetCallback;
- hpcd->SuspendCallback = HAL_PCD_SuspendCallback;
- hpcd->ResumeCallback = HAL_PCD_ResumeCallback;
- hpcd->ConnectCallback = HAL_PCD_ConnectCallback;
- hpcd->DisconnectCallback = HAL_PCD_DisconnectCallback;
- hpcd->DataOutStageCallback = HAL_PCD_DataOutStageCallback;
- hpcd->DataInStageCallback = HAL_PCD_DataInStageCallback;
- hpcd->ISOOUTIncompleteCallback = HAL_PCD_ISOOUTIncompleteCallback;
- hpcd->ISOINIncompleteCallback = HAL_PCD_ISOINIncompleteCallback;
- hpcd->LPMCallback = HAL_PCDEx_LPM_Callback;
- hpcd->BCDCallback = HAL_PCDEx_BCD_Callback;
-
- if (hpcd->MspInitCallback == NULL)
- {
- hpcd->MspInitCallback = HAL_PCD_MspInit;
- }
-
- /* Init the low level hardware */
- hpcd->MspInitCallback(hpcd);
-#else
- /* Init the low level hardware : GPIO, CLOCK, NVIC... */
- HAL_PCD_MspInit(hpcd);
-#endif /* (USE_HAL_PCD_REGISTER_CALLBACKS) */
- }
-
- hpcd->State = HAL_PCD_STATE_BUSY;
-
- /* Disable DMA mode for FS instance */
- if ((USBx->CID & (0x1U << 8)) == 0U)
- {
- hpcd->Init.dma_enable = 0U;
- }
-
- /* Disable the Interrupts */
- __HAL_PCD_DISABLE(hpcd);
-
- /*Init the Core (common init.) */
- if (USB_CoreInit(hpcd->Instance, hpcd->Init) != HAL_OK)
- {
- hpcd->State = HAL_PCD_STATE_ERROR;
- return HAL_ERROR;
- }
-
- /* Force Device Mode*/
- (void)USB_SetCurrentMode(hpcd->Instance, USB_DEVICE_MODE);
-
- /* Init endpoints structures */
- for (i = 0U; i < hpcd->Init.dev_endpoints; i++)
- {
- /* Init ep structure */
- hpcd->IN_ep[i].is_in = 1U;
- hpcd->IN_ep[i].num = i;
- hpcd->IN_ep[i].tx_fifo_num = i;
- /* Control until ep is activated */
- hpcd->IN_ep[i].type = EP_TYPE_CTRL;
- hpcd->IN_ep[i].maxpacket = 0U;
- hpcd->IN_ep[i].xfer_buff = 0U;
- hpcd->IN_ep[i].xfer_len = 0U;
- }
-
- for (i = 0U; i < hpcd->Init.dev_endpoints; i++)
- {
- hpcd->OUT_ep[i].is_in = 0U;
- hpcd->OUT_ep[i].num = i;
- /* Control until ep is activated */
- hpcd->OUT_ep[i].type = EP_TYPE_CTRL;
- hpcd->OUT_ep[i].maxpacket = 0U;
- hpcd->OUT_ep[i].xfer_buff = 0U;
- hpcd->OUT_ep[i].xfer_len = 0U;
- }
-
- /* Init Device */
- if (USB_DevInit(hpcd->Instance, hpcd->Init) != HAL_OK)
- {
- hpcd->State = HAL_PCD_STATE_ERROR;
- return HAL_ERROR;
- }
-
- hpcd->USB_Address = 0U;
- hpcd->State = HAL_PCD_STATE_READY;
-
- /* Activate LPM */
- if (hpcd->Init.lpm_enable == 1U)
- {
- (void)HAL_PCDEx_ActivateLPM(hpcd);
- }
-
- (void)USB_DevDisconnect(hpcd->Instance);
-
- return HAL_OK;
-}
-
-/**
- * @brief DeInitializes the PCD peripheral.
- * @param hpcd PCD handle
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_PCD_DeInit(PCD_HandleTypeDef *hpcd)
-{
- /* Check the PCD handle allocation */
- if (hpcd == NULL)
- {
- return HAL_ERROR;
- }
-
- hpcd->State = HAL_PCD_STATE_BUSY;
-
- /* Stop Device */
- if (USB_StopDevice(hpcd->Instance) != HAL_OK)
- {
- return HAL_ERROR;
- }
-
-#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
- if (hpcd->MspDeInitCallback == NULL)
- {
- hpcd->MspDeInitCallback = HAL_PCD_MspDeInit; /* Legacy weak MspDeInit */
- }
-
- /* DeInit the low level hardware */
- hpcd->MspDeInitCallback(hpcd);
-#else
- /* DeInit the low level hardware: CLOCK, NVIC.*/
- HAL_PCD_MspDeInit(hpcd);
-#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
-
- hpcd->State = HAL_PCD_STATE_RESET;
-
- return HAL_OK;
-}
-
-/**
- * @brief Initializes the PCD MSP.
- * @param hpcd PCD handle
- * @retval None
- */
-__weak void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hpcd);
-
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_PCD_MspInit could be implemented in the user file
- */
-}
-
-/**
- * @brief DeInitializes PCD MSP.
- * @param hpcd PCD handle
- * @retval None
- */
-__weak void HAL_PCD_MspDeInit(PCD_HandleTypeDef *hpcd)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hpcd);
-
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_PCD_MspDeInit could be implemented in the user file
- */
-}
-
-#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
-/**
- * @brief Register a User USB PCD Callback
- * To be used instead of the weak predefined callback
- * @param hpcd USB PCD handle
- * @param CallbackID ID of the callback to be registered
- * This parameter can be one of the following values:
- * @arg @ref HAL_PCD_SOF_CB_ID USB PCD SOF callback ID
- * @arg @ref HAL_PCD_SETUPSTAGE_CB_ID USB PCD Setup callback ID
- * @arg @ref HAL_PCD_RESET_CB_ID USB PCD Reset callback ID
- * @arg @ref HAL_PCD_SUSPEND_CB_ID USB PCD Suspend callback ID
- * @arg @ref HAL_PCD_RESUME_CB_ID USB PCD Resume callback ID
- * @arg @ref HAL_PCD_CONNECT_CB_ID USB PCD Connect callback ID
- * @arg @ref HAL_PCD_DISCONNECT_CB_ID USB PCD Disconnect callback ID
- * @arg @ref HAL_PCD_MSPINIT_CB_ID MspDeInit callback ID
- * @arg @ref HAL_PCD_MSPDEINIT_CB_ID MspDeInit callback ID
- * @param pCallback pointer to the Callback function
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_PCD_RegisterCallback(PCD_HandleTypeDef *hpcd,
- HAL_PCD_CallbackIDTypeDef CallbackID,
- pPCD_CallbackTypeDef pCallback)
-{
- HAL_StatusTypeDef status = HAL_OK;
-
- if (pCallback == NULL)
- {
- /* Update the error code */
- hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK;
- return HAL_ERROR;
- }
- /* Process locked */
- __HAL_LOCK(hpcd);
-
- if (hpcd->State == HAL_PCD_STATE_READY)
- {
- switch (CallbackID)
- {
- case HAL_PCD_SOF_CB_ID :
- hpcd->SOFCallback = pCallback;
- break;
-
- case HAL_PCD_SETUPSTAGE_CB_ID :
- hpcd->SetupStageCallback = pCallback;
- break;
-
- case HAL_PCD_RESET_CB_ID :
- hpcd->ResetCallback = pCallback;
- break;
-
- case HAL_PCD_SUSPEND_CB_ID :
- hpcd->SuspendCallback = pCallback;
- break;
-
- case HAL_PCD_RESUME_CB_ID :
- hpcd->ResumeCallback = pCallback;
- break;
-
- case HAL_PCD_CONNECT_CB_ID :
- hpcd->ConnectCallback = pCallback;
- break;
-
- case HAL_PCD_DISCONNECT_CB_ID :
- hpcd->DisconnectCallback = pCallback;
- break;
-
- case HAL_PCD_MSPINIT_CB_ID :
- hpcd->MspInitCallback = pCallback;
- break;
-
- case HAL_PCD_MSPDEINIT_CB_ID :
- hpcd->MspDeInitCallback = pCallback;
- break;
-
- default :
- /* Update the error code */
- hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK;
- /* Return error status */
- status = HAL_ERROR;
- break;
- }
- }
- else if (hpcd->State == HAL_PCD_STATE_RESET)
- {
- switch (CallbackID)
- {
- case HAL_PCD_MSPINIT_CB_ID :
- hpcd->MspInitCallback = pCallback;
- break;
-
- case HAL_PCD_MSPDEINIT_CB_ID :
- hpcd->MspDeInitCallback = pCallback;
- break;
-
- default :
- /* Update the error code */
- hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK;
- /* Return error status */
- status = HAL_ERROR;
- break;
- }
- }
- else
- {
- /* Update the error code */
- hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK;
- /* Return error status */
- status = HAL_ERROR;
- }
-
- /* Release Lock */
- __HAL_UNLOCK(hpcd);
- return status;
-}
-
-/**
- * @brief Unregister an USB PCD Callback
- * USB PCD callback is redirected to the weak predefined callback
- * @param hpcd USB PCD handle
- * @param CallbackID ID of the callback to be unregistered
- * This parameter can be one of the following values:
- * @arg @ref HAL_PCD_SOF_CB_ID USB PCD SOF callback ID
- * @arg @ref HAL_PCD_SETUPSTAGE_CB_ID USB PCD Setup callback ID
- * @arg @ref HAL_PCD_RESET_CB_ID USB PCD Reset callback ID
- * @arg @ref HAL_PCD_SUSPEND_CB_ID USB PCD Suspend callback ID
- * @arg @ref HAL_PCD_RESUME_CB_ID USB PCD Resume callback ID
- * @arg @ref HAL_PCD_CONNECT_CB_ID USB PCD Connect callback ID
- * @arg @ref HAL_PCD_DISCONNECT_CB_ID USB PCD Disconnect callback ID
- * @arg @ref HAL_PCD_MSPINIT_CB_ID MspDeInit callback ID
- * @arg @ref HAL_PCD_MSPDEINIT_CB_ID MspDeInit callback ID
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_PCD_UnRegisterCallback(PCD_HandleTypeDef *hpcd, HAL_PCD_CallbackIDTypeDef CallbackID)
-{
- HAL_StatusTypeDef status = HAL_OK;
-
- /* Process locked */
- __HAL_LOCK(hpcd);
-
- /* Setup Legacy weak Callbacks */
- if (hpcd->State == HAL_PCD_STATE_READY)
- {
- switch (CallbackID)
- {
- case HAL_PCD_SOF_CB_ID :
- hpcd->SOFCallback = HAL_PCD_SOFCallback;
- break;
-
- case HAL_PCD_SETUPSTAGE_CB_ID :
- hpcd->SetupStageCallback = HAL_PCD_SetupStageCallback;
- break;
-
- case HAL_PCD_RESET_CB_ID :
- hpcd->ResetCallback = HAL_PCD_ResetCallback;
- break;
-
- case HAL_PCD_SUSPEND_CB_ID :
- hpcd->SuspendCallback = HAL_PCD_SuspendCallback;
- break;
-
- case HAL_PCD_RESUME_CB_ID :
- hpcd->ResumeCallback = HAL_PCD_ResumeCallback;
- break;
-
- case HAL_PCD_CONNECT_CB_ID :
- hpcd->ConnectCallback = HAL_PCD_ConnectCallback;
- break;
-
- case HAL_PCD_DISCONNECT_CB_ID :
- hpcd->DisconnectCallback = HAL_PCD_DisconnectCallback;
- break;
-
- case HAL_PCD_MSPINIT_CB_ID :
- hpcd->MspInitCallback = HAL_PCD_MspInit;
- break;
-
- case HAL_PCD_MSPDEINIT_CB_ID :
- hpcd->MspDeInitCallback = HAL_PCD_MspDeInit;
- break;
-
- default :
- /* Update the error code */
- hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK;
-
- /* Return error status */
- status = HAL_ERROR;
- break;
- }
- }
- else if (hpcd->State == HAL_PCD_STATE_RESET)
- {
- switch (CallbackID)
- {
- case HAL_PCD_MSPINIT_CB_ID :
- hpcd->MspInitCallback = HAL_PCD_MspInit;
- break;
-
- case HAL_PCD_MSPDEINIT_CB_ID :
- hpcd->MspDeInitCallback = HAL_PCD_MspDeInit;
- break;
-
- default :
- /* Update the error code */
- hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK;
-
- /* Return error status */
- status = HAL_ERROR;
- break;
- }
- }
- else
- {
- /* Update the error code */
- hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK;
-
- /* Return error status */
- status = HAL_ERROR;
- }
-
- /* Release Lock */
- __HAL_UNLOCK(hpcd);
- return status;
-}
-
-/**
- * @brief Register USB PCD Data OUT Stage Callback
- * To be used instead of the weak HAL_PCD_DataOutStageCallback() predefined callback
- * @param hpcd PCD handle
- * @param pCallback pointer to the USB PCD Data OUT Stage Callback function
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_PCD_RegisterDataOutStageCallback(PCD_HandleTypeDef *hpcd,
- pPCD_DataOutStageCallbackTypeDef pCallback)
-{
- HAL_StatusTypeDef status = HAL_OK;
-
- if (pCallback == NULL)
- {
- /* Update the error code */
- hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK;
-
- return HAL_ERROR;
- }
-
- /* Process locked */
- __HAL_LOCK(hpcd);
-
- if (hpcd->State == HAL_PCD_STATE_READY)
- {
- hpcd->DataOutStageCallback = pCallback;
- }
- else
- {
- /* Update the error code */
- hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK;
-
- /* Return error status */
- status = HAL_ERROR;
- }
-
- /* Release Lock */
- __HAL_UNLOCK(hpcd);
-
- return status;
-}
-
-/**
- * @brief Unregister the USB PCD Data OUT Stage Callback
- * USB PCD Data OUT Stage Callback is redirected to the weak HAL_PCD_DataOutStageCallback() predefined callback
- * @param hpcd PCD handle
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_PCD_UnRegisterDataOutStageCallback(PCD_HandleTypeDef *hpcd)
-{
- HAL_StatusTypeDef status = HAL_OK;
-
- /* Process locked */
- __HAL_LOCK(hpcd);
-
- if (hpcd->State == HAL_PCD_STATE_READY)
- {
- hpcd->DataOutStageCallback = HAL_PCD_DataOutStageCallback; /* Legacy weak DataOutStageCallback */
- }
- else
- {
- /* Update the error code */
- hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK;
-
- /* Return error status */
- status = HAL_ERROR;
- }
-
- /* Release Lock */
- __HAL_UNLOCK(hpcd);
-
- return status;
-}
-
-/**
- * @brief Register USB PCD Data IN Stage Callback
- * To be used instead of the weak HAL_PCD_DataInStageCallback() predefined callback
- * @param hpcd PCD handle
- * @param pCallback pointer to the USB PCD Data IN Stage Callback function
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_PCD_RegisterDataInStageCallback(PCD_HandleTypeDef *hpcd,
- pPCD_DataInStageCallbackTypeDef pCallback)
-{
- HAL_StatusTypeDef status = HAL_OK;
-
- if (pCallback == NULL)
- {
- /* Update the error code */
- hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK;
-
- return HAL_ERROR;
- }
-
- /* Process locked */
- __HAL_LOCK(hpcd);
-
- if (hpcd->State == HAL_PCD_STATE_READY)
- {
- hpcd->DataInStageCallback = pCallback;
- }
- else
- {
- /* Update the error code */
- hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK;
-
- /* Return error status */
- status = HAL_ERROR;
- }
-
- /* Release Lock */
- __HAL_UNLOCK(hpcd);
-
- return status;
-}
-
-/**
- * @brief Unregister the USB PCD Data IN Stage Callback
- * USB PCD Data OUT Stage Callback is redirected to the weak HAL_PCD_DataInStageCallback() predefined callback
- * @param hpcd PCD handle
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_PCD_UnRegisterDataInStageCallback(PCD_HandleTypeDef *hpcd)
-{
- HAL_StatusTypeDef status = HAL_OK;
-
- /* Process locked */
- __HAL_LOCK(hpcd);
-
- if (hpcd->State == HAL_PCD_STATE_READY)
- {
- hpcd->DataInStageCallback = HAL_PCD_DataInStageCallback; /* Legacy weak DataInStageCallback */
- }
- else
- {
- /* Update the error code */
- hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK;
-
- /* Return error status */
- status = HAL_ERROR;
- }
-
- /* Release Lock */
- __HAL_UNLOCK(hpcd);
-
- return status;
-}
-
-/**
- * @brief Register USB PCD Iso OUT incomplete Callback
- * To be used instead of the weak HAL_PCD_ISOOUTIncompleteCallback() predefined callback
- * @param hpcd PCD handle
- * @param pCallback pointer to the USB PCD Iso OUT incomplete Callback function
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_PCD_RegisterIsoOutIncpltCallback(PCD_HandleTypeDef *hpcd,
- pPCD_IsoOutIncpltCallbackTypeDef pCallback)
-{
- HAL_StatusTypeDef status = HAL_OK;
-
- if (pCallback == NULL)
- {
- /* Update the error code */
- hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK;
-
- return HAL_ERROR;
- }
-
- /* Process locked */
- __HAL_LOCK(hpcd);
-
- if (hpcd->State == HAL_PCD_STATE_READY)
- {
- hpcd->ISOOUTIncompleteCallback = pCallback;
- }
- else
- {
- /* Update the error code */
- hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK;
-
- /* Return error status */
- status = HAL_ERROR;
- }
-
- /* Release Lock */
- __HAL_UNLOCK(hpcd);
-
- return status;
-}
-
-/**
- * @brief Unregister the USB PCD Iso OUT incomplete Callback
- * USB PCD Iso OUT incomplete Callback is redirected
- * to the weak HAL_PCD_ISOOUTIncompleteCallback() predefined callback
- * @param hpcd PCD handle
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_PCD_UnRegisterIsoOutIncpltCallback(PCD_HandleTypeDef *hpcd)
-{
- HAL_StatusTypeDef status = HAL_OK;
-
- /* Process locked */
- __HAL_LOCK(hpcd);
-
- if (hpcd->State == HAL_PCD_STATE_READY)
- {
- hpcd->ISOOUTIncompleteCallback = HAL_PCD_ISOOUTIncompleteCallback; /* Legacy weak ISOOUTIncompleteCallback */
- }
- else
- {
- /* Update the error code */
- hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK;
-
- /* Return error status */
- status = HAL_ERROR;
- }
-
- /* Release Lock */
- __HAL_UNLOCK(hpcd);
-
- return status;
-}
-
-/**
- * @brief Register USB PCD Iso IN incomplete Callback
- * To be used instead of the weak HAL_PCD_ISOINIncompleteCallback() predefined callback
- * @param hpcd PCD handle
- * @param pCallback pointer to the USB PCD Iso IN incomplete Callback function
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_PCD_RegisterIsoInIncpltCallback(PCD_HandleTypeDef *hpcd,
- pPCD_IsoInIncpltCallbackTypeDef pCallback)
-{
- HAL_StatusTypeDef status = HAL_OK;
-
- if (pCallback == NULL)
- {
- /* Update the error code */
- hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK;
-
- return HAL_ERROR;
- }
-
- /* Process locked */
- __HAL_LOCK(hpcd);
-
- if (hpcd->State == HAL_PCD_STATE_READY)
- {
- hpcd->ISOINIncompleteCallback = pCallback;
- }
- else
- {
- /* Update the error code */
- hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK;
-
- /* Return error status */
- status = HAL_ERROR;
- }
-
- /* Release Lock */
- __HAL_UNLOCK(hpcd);
-
- return status;
-}
-
-/**
- * @brief Unregister the USB PCD Iso IN incomplete Callback
- * USB PCD Iso IN incomplete Callback is redirected
- * to the weak HAL_PCD_ISOINIncompleteCallback() predefined callback
- * @param hpcd PCD handle
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_PCD_UnRegisterIsoInIncpltCallback(PCD_HandleTypeDef *hpcd)
-{
- HAL_StatusTypeDef status = HAL_OK;
-
- /* Process locked */
- __HAL_LOCK(hpcd);
-
- if (hpcd->State == HAL_PCD_STATE_READY)
- {
- hpcd->ISOINIncompleteCallback = HAL_PCD_ISOINIncompleteCallback; /* Legacy weak ISOINIncompleteCallback */
- }
- else
- {
- /* Update the error code */
- hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK;
-
- /* Return error status */
- status = HAL_ERROR;
- }
-
- /* Release Lock */
- __HAL_UNLOCK(hpcd);
-
- return status;
-}
-
-/**
- * @brief Register USB PCD BCD Callback
- * To be used instead of the weak HAL_PCDEx_BCD_Callback() predefined callback
- * @param hpcd PCD handle
- * @param pCallback pointer to the USB PCD BCD Callback function
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_PCD_RegisterBcdCallback(PCD_HandleTypeDef *hpcd, pPCD_BcdCallbackTypeDef pCallback)
-{
- HAL_StatusTypeDef status = HAL_OK;
-
- if (pCallback == NULL)
- {
- /* Update the error code */
- hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK;
-
- return HAL_ERROR;
- }
-
- /* Process locked */
- __HAL_LOCK(hpcd);
-
- if (hpcd->State == HAL_PCD_STATE_READY)
- {
- hpcd->BCDCallback = pCallback;
- }
- else
- {
- /* Update the error code */
- hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK;
-
- /* Return error status */
- status = HAL_ERROR;
- }
-
- /* Release Lock */
- __HAL_UNLOCK(hpcd);
-
- return status;
-}
-
-/**
- * @brief Unregister the USB PCD BCD Callback
- * USB BCD Callback is redirected to the weak HAL_PCDEx_BCD_Callback() predefined callback
- * @param hpcd PCD handle
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_PCD_UnRegisterBcdCallback(PCD_HandleTypeDef *hpcd)
-{
- HAL_StatusTypeDef status = HAL_OK;
-
- /* Process locked */
- __HAL_LOCK(hpcd);
-
- if (hpcd->State == HAL_PCD_STATE_READY)
- {
- hpcd->BCDCallback = HAL_PCDEx_BCD_Callback; /* Legacy weak HAL_PCDEx_BCD_Callback */
- }
- else
- {
- /* Update the error code */
- hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK;
-
- /* Return error status */
- status = HAL_ERROR;
- }
-
- /* Release Lock */
- __HAL_UNLOCK(hpcd);
-
- return status;
-}
-
-/**
- * @brief Register USB PCD LPM Callback
- * To be used instead of the weak HAL_PCDEx_LPM_Callback() predefined callback
- * @param hpcd PCD handle
- * @param pCallback pointer to the USB PCD LPM Callback function
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_PCD_RegisterLpmCallback(PCD_HandleTypeDef *hpcd, pPCD_LpmCallbackTypeDef pCallback)
-{
- HAL_StatusTypeDef status = HAL_OK;
-
- if (pCallback == NULL)
- {
- /* Update the error code */
- hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK;
-
- return HAL_ERROR;
- }
-
- /* Process locked */
- __HAL_LOCK(hpcd);
-
- if (hpcd->State == HAL_PCD_STATE_READY)
- {
- hpcd->LPMCallback = pCallback;
- }
- else
- {
- /* Update the error code */
- hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK;
-
- /* Return error status */
- status = HAL_ERROR;
- }
-
- /* Release Lock */
- __HAL_UNLOCK(hpcd);
-
- return status;
-}
-
-/**
- * @brief Unregister the USB PCD LPM Callback
- * USB LPM Callback is redirected to the weak HAL_PCDEx_LPM_Callback() predefined callback
- * @param hpcd PCD handle
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_PCD_UnRegisterLpmCallback(PCD_HandleTypeDef *hpcd)
-{
- HAL_StatusTypeDef status = HAL_OK;
-
- /* Process locked */
- __HAL_LOCK(hpcd);
-
- if (hpcd->State == HAL_PCD_STATE_READY)
- {
- hpcd->LPMCallback = HAL_PCDEx_LPM_Callback; /* Legacy weak HAL_PCDEx_LPM_Callback */
- }
- else
- {
- /* Update the error code */
- hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK;
-
- /* Return error status */
- status = HAL_ERROR;
- }
-
- /* Release Lock */
- __HAL_UNLOCK(hpcd);
-
- return status;
-}
-#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
-
-/**
- * @}
- */
-
-/** @defgroup PCD_Exported_Functions_Group2 Input and Output operation functions
- * @brief Data transfers functions
- *
-@verbatim
- ===============================================================================
- ##### IO operation functions #####
- ===============================================================================
- [..]
- This subsection provides a set of functions allowing to manage the PCD data
- transfers.
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Start the USB device
- * @param hpcd PCD handle
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_PCD_Start(PCD_HandleTypeDef *hpcd)
-{
- USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
-
- __HAL_LOCK(hpcd);
-
- if (((USBx->CID & (0x1U << 8)) == 0U) &&
- (hpcd->Init.battery_charging_enable == 1U))
- {
- /* Enable USB Transceiver */
- USBx->GCCFG |= USB_OTG_GCCFG_PWRDWN;
- }
-
- __HAL_PCD_ENABLE(hpcd);
- (void)USB_DevConnect(hpcd->Instance);
- __HAL_UNLOCK(hpcd);
-
- return HAL_OK;
-}
-
-/**
- * @brief Stop the USB device.
- * @param hpcd PCD handle
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_PCD_Stop(PCD_HandleTypeDef *hpcd)
-{
- USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
-
- __HAL_LOCK(hpcd);
- __HAL_PCD_DISABLE(hpcd);
- (void)USB_DevDisconnect(hpcd->Instance);
-
- (void)USB_FlushTxFifo(hpcd->Instance, 0x10U);
-
- if (((USBx->CID & (0x1U << 8)) == 0U) &&
- (hpcd->Init.battery_charging_enable == 1U))
- {
- /* Disable USB Transceiver */
- USBx->GCCFG &= ~(USB_OTG_GCCFG_PWRDWN);
- }
-
- __HAL_UNLOCK(hpcd);
-
- return HAL_OK;
-}
-
-#if defined (USB_OTG_FS) || defined (USB_OTG_HS)
-/**
- * @brief Handles PCD interrupt request.
- * @param hpcd PCD handle
- * @retval HAL status
- */
-void HAL_PCD_IRQHandler(PCD_HandleTypeDef *hpcd)
-{
- USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
- uint32_t USBx_BASE = (uint32_t)USBx;
- USB_OTG_EPTypeDef *ep;
- uint32_t i;
- uint32_t ep_intr;
- uint32_t epint;
- uint32_t epnum;
- uint32_t fifoemptymsk;
- uint32_t RegVal;
-
- /* ensure that we are in device mode */
- if (USB_GetMode(hpcd->Instance) == USB_OTG_MODE_DEVICE)
- {
- /* avoid spurious interrupt */
- if (__HAL_PCD_IS_INVALID_INTERRUPT(hpcd))
- {
- return;
- }
-
- /* store current frame number */
- hpcd->FrameNumber = (USBx_DEVICE->DSTS & USB_OTG_DSTS_FNSOF_Msk) >> USB_OTG_DSTS_FNSOF_Pos;
-
- if (__HAL_PCD_GET_FLAG(hpcd, USB_OTG_GINTSTS_MMIS))
- {
- /* incorrect mode, acknowledge the interrupt */
- __HAL_PCD_CLEAR_FLAG(hpcd, USB_OTG_GINTSTS_MMIS);
- }
-
- /* Handle RxQLevel Interrupt */
- if (__HAL_PCD_GET_FLAG(hpcd, USB_OTG_GINTSTS_RXFLVL))
- {
- USB_MASK_INTERRUPT(hpcd->Instance, USB_OTG_GINTSTS_RXFLVL);
-
- RegVal = USBx->GRXSTSP;
-
- ep = &hpcd->OUT_ep[RegVal & USB_OTG_GRXSTSP_EPNUM];
-
- if (((RegVal & USB_OTG_GRXSTSP_PKTSTS) >> 17) == STS_DATA_UPDT)
- {
- if ((RegVal & USB_OTG_GRXSTSP_BCNT) != 0U)
- {
- (void)USB_ReadPacket(USBx, ep->xfer_buff,
- (uint16_t)((RegVal & USB_OTG_GRXSTSP_BCNT) >> 4));
-
- ep->xfer_buff += (RegVal & USB_OTG_GRXSTSP_BCNT) >> 4;
- ep->xfer_count += (RegVal & USB_OTG_GRXSTSP_BCNT) >> 4;
- }
- }
- else if (((RegVal & USB_OTG_GRXSTSP_PKTSTS) >> 17) == STS_SETUP_UPDT)
- {
- (void)USB_ReadPacket(USBx, (uint8_t *)hpcd->Setup, 8U);
- ep->xfer_count += (RegVal & USB_OTG_GRXSTSP_BCNT) >> 4;
- }
- else
- {
- /* ... */
- }
-
- USB_UNMASK_INTERRUPT(hpcd->Instance, USB_OTG_GINTSTS_RXFLVL);
- }
-
- if (__HAL_PCD_GET_FLAG(hpcd, USB_OTG_GINTSTS_OEPINT))
- {
- epnum = 0U;
-
- /* Read in the device interrupt bits */
- ep_intr = USB_ReadDevAllOutEpInterrupt(hpcd->Instance);
-
- while (ep_intr != 0U)
- {
- if ((ep_intr & 0x1U) != 0U)
- {
- epint = USB_ReadDevOutEPInterrupt(hpcd->Instance, (uint8_t)epnum);
-
- if ((epint & USB_OTG_DOEPINT_XFRC) == USB_OTG_DOEPINT_XFRC)
- {
- CLEAR_OUT_EP_INTR(epnum, USB_OTG_DOEPINT_XFRC);
- (void)PCD_EP_OutXfrComplete_int(hpcd, epnum);
- }
-
- if ((epint & USB_OTG_DOEPINT_STUP) == USB_OTG_DOEPINT_STUP)
- {
- CLEAR_OUT_EP_INTR(epnum, USB_OTG_DOEPINT_STUP);
- /* Class B setup phase done for previous decoded setup */
- (void)PCD_EP_OutSetupPacket_int(hpcd, epnum);
- }
-
- if ((epint & USB_OTG_DOEPINT_OTEPDIS) == USB_OTG_DOEPINT_OTEPDIS)
- {
- CLEAR_OUT_EP_INTR(epnum, USB_OTG_DOEPINT_OTEPDIS);
- }
-
- /* Clear OUT Endpoint disable interrupt */
- if ((epint & USB_OTG_DOEPINT_EPDISD) == USB_OTG_DOEPINT_EPDISD)
- {
- if ((USBx->GINTSTS & USB_OTG_GINTSTS_BOUTNAKEFF) == USB_OTG_GINTSTS_BOUTNAKEFF)
- {
- USBx_DEVICE->DCTL |= USB_OTG_DCTL_CGONAK;
- }
-
- ep = &hpcd->OUT_ep[epnum];
-
- if (ep->is_iso_incomplete == 1U)
- {
- ep->is_iso_incomplete = 0U;
-
-#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
- hpcd->ISOOUTIncompleteCallback(hpcd, (uint8_t)epnum);
-#else
- HAL_PCD_ISOOUTIncompleteCallback(hpcd, (uint8_t)epnum);
-#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
- }
-
- CLEAR_OUT_EP_INTR(epnum, USB_OTG_DOEPINT_EPDISD);
- }
-
- /* Clear Status Phase Received interrupt */
- if ((epint & USB_OTG_DOEPINT_OTEPSPR) == USB_OTG_DOEPINT_OTEPSPR)
- {
- CLEAR_OUT_EP_INTR(epnum, USB_OTG_DOEPINT_OTEPSPR);
- }
-
- /* Clear OUT NAK interrupt */
- if ((epint & USB_OTG_DOEPINT_NAK) == USB_OTG_DOEPINT_NAK)
- {
- CLEAR_OUT_EP_INTR(epnum, USB_OTG_DOEPINT_NAK);
- }
- }
- epnum++;
- ep_intr >>= 1U;
- }
- }
-
- if (__HAL_PCD_GET_FLAG(hpcd, USB_OTG_GINTSTS_IEPINT))
- {
- /* Read in the device interrupt bits */
- ep_intr = USB_ReadDevAllInEpInterrupt(hpcd->Instance);
-
- epnum = 0U;
-
- while (ep_intr != 0U)
- {
- if ((ep_intr & 0x1U) != 0U) /* In ITR */
- {
- epint = USB_ReadDevInEPInterrupt(hpcd->Instance, (uint8_t)epnum);
-
- if ((epint & USB_OTG_DIEPINT_XFRC) == USB_OTG_DIEPINT_XFRC)
- {
- fifoemptymsk = (uint32_t)(0x1UL << (epnum & EP_ADDR_MSK));
- USBx_DEVICE->DIEPEMPMSK &= ~fifoemptymsk;
-
- CLEAR_IN_EP_INTR(epnum, USB_OTG_DIEPINT_XFRC);
-
- if (hpcd->Init.dma_enable == 1U)
- {
- hpcd->IN_ep[epnum].xfer_buff += hpcd->IN_ep[epnum].maxpacket;
-
- /* this is ZLP, so prepare EP0 for next setup */
- if ((epnum == 0U) && (hpcd->IN_ep[epnum].xfer_len == 0U))
- {
- /* prepare to rx more setup packets */
- (void)USB_EP0_OutStart(hpcd->Instance, 1U, (uint8_t *)hpcd->Setup);
- }
- }
-
-#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
- hpcd->DataInStageCallback(hpcd, (uint8_t)epnum);
-#else
- HAL_PCD_DataInStageCallback(hpcd, (uint8_t)epnum);
-#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
- }
- if ((epint & USB_OTG_DIEPINT_TOC) == USB_OTG_DIEPINT_TOC)
- {
- CLEAR_IN_EP_INTR(epnum, USB_OTG_DIEPINT_TOC);
- }
- if ((epint & USB_OTG_DIEPINT_ITTXFE) == USB_OTG_DIEPINT_ITTXFE)
- {
- CLEAR_IN_EP_INTR(epnum, USB_OTG_DIEPINT_ITTXFE);
- }
- if ((epint & USB_OTG_DIEPINT_INEPNE) == USB_OTG_DIEPINT_INEPNE)
- {
- CLEAR_IN_EP_INTR(epnum, USB_OTG_DIEPINT_INEPNE);
- }
- if ((epint & USB_OTG_DIEPINT_EPDISD) == USB_OTG_DIEPINT_EPDISD)
- {
- (void)USB_FlushTxFifo(USBx, epnum);
-
- ep = &hpcd->IN_ep[epnum];
-
- if (ep->is_iso_incomplete == 1U)
- {
- ep->is_iso_incomplete = 0U;
-
-#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
- hpcd->ISOINIncompleteCallback(hpcd, (uint8_t)epnum);
-#else
- HAL_PCD_ISOINIncompleteCallback(hpcd, (uint8_t)epnum);
-#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
- }
-
- CLEAR_IN_EP_INTR(epnum, USB_OTG_DIEPINT_EPDISD);
- }
- if ((epint & USB_OTG_DIEPINT_TXFE) == USB_OTG_DIEPINT_TXFE)
- {
- (void)PCD_WriteEmptyTxFifo(hpcd, epnum);
- }
- }
- epnum++;
- ep_intr >>= 1U;
- }
- }
-
- /* Handle Resume Interrupt */
- if (__HAL_PCD_GET_FLAG(hpcd, USB_OTG_GINTSTS_WKUINT))
- {
- /* Clear the Remote Wake-up Signaling */
- USBx_DEVICE->DCTL &= ~USB_OTG_DCTL_RWUSIG;
-
- if (hpcd->LPM_State == LPM_L1)
- {
- hpcd->LPM_State = LPM_L0;
-
-#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
- hpcd->LPMCallback(hpcd, PCD_LPM_L0_ACTIVE);
-#else
- HAL_PCDEx_LPM_Callback(hpcd, PCD_LPM_L0_ACTIVE);
-#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
- }
- else
- {
-#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
- hpcd->ResumeCallback(hpcd);
-#else
- HAL_PCD_ResumeCallback(hpcd);
-#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
- }
-
- __HAL_PCD_CLEAR_FLAG(hpcd, USB_OTG_GINTSTS_WKUINT);
- }
-
- /* Handle Suspend Interrupt */
- if (__HAL_PCD_GET_FLAG(hpcd, USB_OTG_GINTSTS_USBSUSP))
- {
- if ((USBx_DEVICE->DSTS & USB_OTG_DSTS_SUSPSTS) == USB_OTG_DSTS_SUSPSTS)
- {
-#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
- hpcd->SuspendCallback(hpcd);
-#else
- HAL_PCD_SuspendCallback(hpcd);
-#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
- }
- __HAL_PCD_CLEAR_FLAG(hpcd, USB_OTG_GINTSTS_USBSUSP);
- }
-
- /* Handle LPM Interrupt */
- if (__HAL_PCD_GET_FLAG(hpcd, USB_OTG_GINTSTS_LPMINT))
- {
- __HAL_PCD_CLEAR_FLAG(hpcd, USB_OTG_GINTSTS_LPMINT);
-
- if (hpcd->LPM_State == LPM_L0)
- {
- hpcd->LPM_State = LPM_L1;
- hpcd->BESL = (hpcd->Instance->GLPMCFG & USB_OTG_GLPMCFG_BESL) >> 2U;
-
-#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
- hpcd->LPMCallback(hpcd, PCD_LPM_L1_ACTIVE);
-#else
- HAL_PCDEx_LPM_Callback(hpcd, PCD_LPM_L1_ACTIVE);
-#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
- }
- else
- {
-#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
- hpcd->SuspendCallback(hpcd);
-#else
- HAL_PCD_SuspendCallback(hpcd);
-#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
- }
- }
-
- /* Handle Reset Interrupt */
- if (__HAL_PCD_GET_FLAG(hpcd, USB_OTG_GINTSTS_USBRST))
- {
- USBx_DEVICE->DCTL &= ~USB_OTG_DCTL_RWUSIG;
- (void)USB_FlushTxFifo(hpcd->Instance, 0x10U);
-
- for (i = 0U; i < hpcd->Init.dev_endpoints; i++)
- {
- USBx_INEP(i)->DIEPINT = 0xFB7FU;
- USBx_INEP(i)->DIEPCTL &= ~USB_OTG_DIEPCTL_STALL;
- USBx_OUTEP(i)->DOEPINT = 0xFB7FU;
- USBx_OUTEP(i)->DOEPCTL &= ~USB_OTG_DOEPCTL_STALL;
- USBx_OUTEP(i)->DOEPCTL |= USB_OTG_DOEPCTL_SNAK;
- }
- USBx_DEVICE->DAINTMSK |= 0x10001U;
-
- if (hpcd->Init.use_dedicated_ep1 != 0U)
- {
- USBx_DEVICE->DOUTEP1MSK |= USB_OTG_DOEPMSK_STUPM |
- USB_OTG_DOEPMSK_XFRCM |
- USB_OTG_DOEPMSK_EPDM;
-
- USBx_DEVICE->DINEP1MSK |= USB_OTG_DIEPMSK_TOM |
- USB_OTG_DIEPMSK_XFRCM |
- USB_OTG_DIEPMSK_EPDM;
- }
- else
- {
- USBx_DEVICE->DOEPMSK |= USB_OTG_DOEPMSK_STUPM |
- USB_OTG_DOEPMSK_XFRCM |
- USB_OTG_DOEPMSK_EPDM |
- USB_OTG_DOEPMSK_OTEPSPRM |
- USB_OTG_DOEPMSK_NAKM;
-
- USBx_DEVICE->DIEPMSK |= USB_OTG_DIEPMSK_TOM |
- USB_OTG_DIEPMSK_XFRCM |
- USB_OTG_DIEPMSK_EPDM;
- }
-
- /* Set Default Address to 0 */
- USBx_DEVICE->DCFG &= ~USB_OTG_DCFG_DAD;
-
- /* setup EP0 to receive SETUP packets */
- (void)USB_EP0_OutStart(hpcd->Instance, (uint8_t)hpcd->Init.dma_enable,
- (uint8_t *)hpcd->Setup);
-
- __HAL_PCD_CLEAR_FLAG(hpcd, USB_OTG_GINTSTS_USBRST);
- }
-
- /* Handle Enumeration done Interrupt */
- if (__HAL_PCD_GET_FLAG(hpcd, USB_OTG_GINTSTS_ENUMDNE))
- {
- (void)USB_ActivateSetup(hpcd->Instance);
- hpcd->Init.speed = USB_GetDevSpeed(hpcd->Instance);
-
- /* Set USB Turnaround time */
- (void)USB_SetTurnaroundTime(hpcd->Instance,
- HAL_RCC_GetHCLKFreq(),
- (uint8_t)hpcd->Init.speed);
-
-#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
- hpcd->ResetCallback(hpcd);
-#else
- HAL_PCD_ResetCallback(hpcd);
-#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
-
- __HAL_PCD_CLEAR_FLAG(hpcd, USB_OTG_GINTSTS_ENUMDNE);
- }
-
- /* Handle SOF Interrupt */
- if (__HAL_PCD_GET_FLAG(hpcd, USB_OTG_GINTSTS_SOF))
- {
-#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
- hpcd->SOFCallback(hpcd);
-#else
- HAL_PCD_SOFCallback(hpcd);
-#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
-
- __HAL_PCD_CLEAR_FLAG(hpcd, USB_OTG_GINTSTS_SOF);
- }
-
- /* Handle Global OUT NAK effective Interrupt */
- if (__HAL_PCD_GET_FLAG(hpcd, USB_OTG_GINTSTS_BOUTNAKEFF))
- {
- USBx->GINTMSK &= ~USB_OTG_GINTMSK_GONAKEFFM;
-
- for (epnum = 1U; epnum < hpcd->Init.dev_endpoints; epnum++)
- {
- if (hpcd->OUT_ep[epnum].is_iso_incomplete == 1U)
- {
- /* Abort current transaction and disable the EP */
- (void)HAL_PCD_EP_Abort(hpcd, (uint8_t)epnum);
- }
- }
- }
-
- /* Handle Incomplete ISO IN Interrupt */
- if (__HAL_PCD_GET_FLAG(hpcd, USB_OTG_GINTSTS_IISOIXFR))
- {
- for (epnum = 1U; epnum < hpcd->Init.dev_endpoints; epnum++)
- {
- RegVal = USBx_INEP(epnum)->DIEPCTL;
-
- if ((hpcd->IN_ep[epnum].type == EP_TYPE_ISOC) &&
- ((RegVal & USB_OTG_DIEPCTL_EPENA) == USB_OTG_DIEPCTL_EPENA))
- {
- hpcd->IN_ep[epnum].is_iso_incomplete = 1U;
-
- /* Abort current transaction and disable the EP */
- (void)HAL_PCD_EP_Abort(hpcd, (uint8_t)(epnum | 0x80U));
- }
- }
-
- __HAL_PCD_CLEAR_FLAG(hpcd, USB_OTG_GINTSTS_IISOIXFR);
- }
-
- /* Handle Incomplete ISO OUT Interrupt */
- if (__HAL_PCD_GET_FLAG(hpcd, USB_OTG_GINTSTS_PXFR_INCOMPISOOUT))
- {
- for (epnum = 1U; epnum < hpcd->Init.dev_endpoints; epnum++)
- {
- RegVal = USBx_OUTEP(epnum)->DOEPCTL;
-
- if ((hpcd->OUT_ep[epnum].type == EP_TYPE_ISOC) &&
- ((RegVal & USB_OTG_DOEPCTL_EPENA) == USB_OTG_DOEPCTL_EPENA) &&
- ((RegVal & (0x1U << 16)) == (hpcd->FrameNumber & 0x1U)))
- {
- hpcd->OUT_ep[epnum].is_iso_incomplete = 1U;
-
- USBx->GINTMSK |= USB_OTG_GINTMSK_GONAKEFFM;
-
- if ((USBx->GINTSTS & USB_OTG_GINTSTS_BOUTNAKEFF) == 0U)
- {
- USBx_DEVICE->DCTL |= USB_OTG_DCTL_SGONAK;
- break;
- }
- }
- }
-
- __HAL_PCD_CLEAR_FLAG(hpcd, USB_OTG_GINTSTS_PXFR_INCOMPISOOUT);
- }
-
- /* Handle Connection event Interrupt */
- if (__HAL_PCD_GET_FLAG(hpcd, USB_OTG_GINTSTS_SRQINT))
- {
-#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
- hpcd->ConnectCallback(hpcd);
-#else
- HAL_PCD_ConnectCallback(hpcd);
-#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
-
- __HAL_PCD_CLEAR_FLAG(hpcd, USB_OTG_GINTSTS_SRQINT);
- }
-
- /* Handle Disconnection event Interrupt */
- if (__HAL_PCD_GET_FLAG(hpcd, USB_OTG_GINTSTS_OTGINT))
- {
- RegVal = hpcd->Instance->GOTGINT;
-
- if ((RegVal & USB_OTG_GOTGINT_SEDET) == USB_OTG_GOTGINT_SEDET)
- {
-#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
- hpcd->DisconnectCallback(hpcd);
-#else
- HAL_PCD_DisconnectCallback(hpcd);
-#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
- }
- hpcd->Instance->GOTGINT |= RegVal;
- }
- }
-}
-#endif /* defined (USB_OTG_FS) || defined (USB_OTG_HS) */
-
-
-/**
- * @brief Data OUT stage callback.
- * @param hpcd PCD handle
- * @param epnum endpoint number
- * @retval None
- */
-__weak void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hpcd);
- UNUSED(epnum);
-
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_PCD_DataOutStageCallback could be implemented in the user file
- */
-}
-
-/**
- * @brief Data IN stage callback
- * @param hpcd PCD handle
- * @param epnum endpoint number
- * @retval None
- */
-__weak void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hpcd);
- UNUSED(epnum);
-
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_PCD_DataInStageCallback could be implemented in the user file
- */
-}
-/**
- * @brief Setup stage callback
- * @param hpcd PCD handle
- * @retval None
- */
-__weak void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hpcd);
-
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_PCD_SetupStageCallback could be implemented in the user file
- */
-}
-
-/**
- * @brief USB Start Of Frame callback.
- * @param hpcd PCD handle
- * @retval None
- */
-__weak void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hpcd);
-
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_PCD_SOFCallback could be implemented in the user file
- */
-}
-
-/**
- * @brief USB Reset callback.
- * @param hpcd PCD handle
- * @retval None
- */
-__weak void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hpcd);
-
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_PCD_ResetCallback could be implemented in the user file
- */
-}
-
-/**
- * @brief Suspend event callback.
- * @param hpcd PCD handle
- * @retval None
- */
-__weak void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hpcd);
-
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_PCD_SuspendCallback could be implemented in the user file
- */
-}
-
-/**
- * @brief Resume event callback.
- * @param hpcd PCD handle
- * @retval None
- */
-__weak void HAL_PCD_ResumeCallback(PCD_HandleTypeDef *hpcd)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hpcd);
-
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_PCD_ResumeCallback could be implemented in the user file
- */
-}
-
-/**
- * @brief Incomplete ISO OUT callback.
- * @param hpcd PCD handle
- * @param epnum endpoint number
- * @retval None
- */
-__weak void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hpcd);
- UNUSED(epnum);
-
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_PCD_ISOOUTIncompleteCallback could be implemented in the user file
- */
-}
-
-/**
- * @brief Incomplete ISO IN callback.
- * @param hpcd PCD handle
- * @param epnum endpoint number
- * @retval None
- */
-__weak void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hpcd);
- UNUSED(epnum);
-
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_PCD_ISOINIncompleteCallback could be implemented in the user file
- */
-}
-
-/**
- * @brief Connection event callback.
- * @param hpcd PCD handle
- * @retval None
- */
-__weak void HAL_PCD_ConnectCallback(PCD_HandleTypeDef *hpcd)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hpcd);
-
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_PCD_ConnectCallback could be implemented in the user file
- */
-}
-
-/**
- * @brief Disconnection event callback.
- * @param hpcd PCD handle
- * @retval None
- */
-__weak void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hpcd);
-
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_PCD_DisconnectCallback could be implemented in the user file
- */
-}
-
-/**
- * @}
- */
-
-/** @defgroup PCD_Exported_Functions_Group3 Peripheral Control functions
- * @brief management functions
- *
-@verbatim
- ===============================================================================
- ##### Peripheral Control functions #####
- ===============================================================================
- [..]
- This subsection provides a set of functions allowing to control the PCD data
- transfers.
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Connect the USB device
- * @param hpcd PCD handle
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_PCD_DevConnect(PCD_HandleTypeDef *hpcd)
-{
- USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
-
- __HAL_LOCK(hpcd);
-
- if (((USBx->CID & (0x1U << 8)) == 0U) &&
- (hpcd->Init.battery_charging_enable == 1U))
- {
- /* Enable USB Transceiver */
- USBx->GCCFG |= USB_OTG_GCCFG_PWRDWN;
- }
- (void)USB_DevConnect(hpcd->Instance);
- __HAL_UNLOCK(hpcd);
-
- return HAL_OK;
-}
-
-/**
- * @brief Disconnect the USB device.
- * @param hpcd PCD handle
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_PCD_DevDisconnect(PCD_HandleTypeDef *hpcd)
-{
- USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
-
- __HAL_LOCK(hpcd);
- (void)USB_DevDisconnect(hpcd->Instance);
-
- if (((USBx->CID & (0x1U << 8)) == 0U) &&
- (hpcd->Init.battery_charging_enable == 1U))
- {
- /* Disable USB Transceiver */
- USBx->GCCFG &= ~(USB_OTG_GCCFG_PWRDWN);
- }
-
- __HAL_UNLOCK(hpcd);
-
- return HAL_OK;
-}
-
-/**
- * @brief Set the USB Device address.
- * @param hpcd PCD handle
- * @param address new device address
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_PCD_SetAddress(PCD_HandleTypeDef *hpcd, uint8_t address)
-{
- __HAL_LOCK(hpcd);
- hpcd->USB_Address = address;
- (void)USB_SetDevAddress(hpcd->Instance, address);
- __HAL_UNLOCK(hpcd);
-
- return HAL_OK;
-}
-/**
- * @brief Open and configure an endpoint.
- * @param hpcd PCD handle
- * @param ep_addr endpoint address
- * @param ep_mps endpoint max packet size
- * @param ep_type endpoint type
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_PCD_EP_Open(PCD_HandleTypeDef *hpcd, uint8_t ep_addr,
- uint16_t ep_mps, uint8_t ep_type)
-{
- HAL_StatusTypeDef ret = HAL_OK;
- PCD_EPTypeDef *ep;
-
- if ((ep_addr & 0x80U) == 0x80U)
- {
- ep = &hpcd->IN_ep[ep_addr & EP_ADDR_MSK];
- ep->is_in = 1U;
- }
- else
- {
- ep = &hpcd->OUT_ep[ep_addr & EP_ADDR_MSK];
- ep->is_in = 0U;
- }
-
- ep->num = ep_addr & EP_ADDR_MSK;
- ep->maxpacket = ep_mps;
- ep->type = ep_type;
-
- if (ep->is_in != 0U)
- {
- /* Assign a Tx FIFO */
- ep->tx_fifo_num = ep->num;
- }
-
- /* Set initial data PID. */
- if (ep_type == EP_TYPE_BULK)
- {
- ep->data_pid_start = 0U;
- }
-
- __HAL_LOCK(hpcd);
- (void)USB_ActivateEndpoint(hpcd->Instance, ep);
- __HAL_UNLOCK(hpcd);
-
- return ret;
-}
-
-/**
- * @brief Deactivate an endpoint.
- * @param hpcd PCD handle
- * @param ep_addr endpoint address
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_PCD_EP_Close(PCD_HandleTypeDef *hpcd, uint8_t ep_addr)
-{
- PCD_EPTypeDef *ep;
-
- if ((ep_addr & 0x80U) == 0x80U)
- {
- ep = &hpcd->IN_ep[ep_addr & EP_ADDR_MSK];
- ep->is_in = 1U;
- }
- else
- {
- ep = &hpcd->OUT_ep[ep_addr & EP_ADDR_MSK];
- ep->is_in = 0U;
- }
- ep->num = ep_addr & EP_ADDR_MSK;
-
- __HAL_LOCK(hpcd);
- (void)USB_DeactivateEndpoint(hpcd->Instance, ep);
- __HAL_UNLOCK(hpcd);
- return HAL_OK;
-}
-
-
-/**
- * @brief Receive an amount of data.
- * @param hpcd PCD handle
- * @param ep_addr endpoint address
- * @param pBuf pointer to the reception buffer
- * @param len amount of data to be received
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_PCD_EP_Receive(PCD_HandleTypeDef *hpcd, uint8_t ep_addr, uint8_t *pBuf, uint32_t len)
-{
- PCD_EPTypeDef *ep;
-
- ep = &hpcd->OUT_ep[ep_addr & EP_ADDR_MSK];
-
- /*setup and start the Xfer */
- ep->xfer_buff = pBuf;
- ep->xfer_len = len;
- ep->xfer_count = 0U;
- ep->is_in = 0U;
- ep->num = ep_addr & EP_ADDR_MSK;
-
- if (hpcd->Init.dma_enable == 1U)
- {
- ep->dma_addr = (uint32_t)pBuf;
- }
-
- (void)USB_EPStartXfer(hpcd->Instance, ep, (uint8_t)hpcd->Init.dma_enable);
-
- return HAL_OK;
-}
-
-/**
- * @brief Get Received Data Size
- * @param hpcd PCD handle
- * @param ep_addr endpoint address
- * @retval Data Size
- */
-uint32_t HAL_PCD_EP_GetRxCount(PCD_HandleTypeDef *hpcd, uint8_t ep_addr)
-{
- return hpcd->OUT_ep[ep_addr & EP_ADDR_MSK].xfer_count;
-}
-/**
- * @brief Send an amount of data
- * @param hpcd PCD handle
- * @param ep_addr endpoint address
- * @param pBuf pointer to the transmission buffer
- * @param len amount of data to be sent
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_PCD_EP_Transmit(PCD_HandleTypeDef *hpcd, uint8_t ep_addr, uint8_t *pBuf, uint32_t len)
-{
- PCD_EPTypeDef *ep;
-
- ep = &hpcd->IN_ep[ep_addr & EP_ADDR_MSK];
-
- /*setup and start the Xfer */
- ep->xfer_buff = pBuf;
- ep->xfer_len = len;
- ep->xfer_count = 0U;
- ep->is_in = 1U;
- ep->num = ep_addr & EP_ADDR_MSK;
-
- if (hpcd->Init.dma_enable == 1U)
- {
- ep->dma_addr = (uint32_t)pBuf;
- }
-
- (void)USB_EPStartXfer(hpcd->Instance, ep, (uint8_t)hpcd->Init.dma_enable);
-
- return HAL_OK;
-}
-
-/**
- * @brief Set a STALL condition over an endpoint
- * @param hpcd PCD handle
- * @param ep_addr endpoint address
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_PCD_EP_SetStall(PCD_HandleTypeDef *hpcd, uint8_t ep_addr)
-{
- PCD_EPTypeDef *ep;
-
- if (((uint32_t)ep_addr & EP_ADDR_MSK) > hpcd->Init.dev_endpoints)
- {
- return HAL_ERROR;
- }
-
- if ((0x80U & ep_addr) == 0x80U)
- {
- ep = &hpcd->IN_ep[ep_addr & EP_ADDR_MSK];
- ep->is_in = 1U;
- }
- else
- {
- ep = &hpcd->OUT_ep[ep_addr];
- ep->is_in = 0U;
- }
-
- ep->is_stall = 1U;
- ep->num = ep_addr & EP_ADDR_MSK;
-
- __HAL_LOCK(hpcd);
-
- (void)USB_EPSetStall(hpcd->Instance, ep);
-
- if ((ep_addr & EP_ADDR_MSK) == 0U)
- {
- (void)USB_EP0_OutStart(hpcd->Instance, (uint8_t)hpcd->Init.dma_enable, (uint8_t *)hpcd->Setup);
- }
-
- __HAL_UNLOCK(hpcd);
-
- return HAL_OK;
-}
-
-/**
- * @brief Clear a STALL condition over in an endpoint
- * @param hpcd PCD handle
- * @param ep_addr endpoint address
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_PCD_EP_ClrStall(PCD_HandleTypeDef *hpcd, uint8_t ep_addr)
-{
- PCD_EPTypeDef *ep;
-
- if (((uint32_t)ep_addr & 0x0FU) > hpcd->Init.dev_endpoints)
- {
- return HAL_ERROR;
- }
-
- if ((0x80U & ep_addr) == 0x80U)
- {
- ep = &hpcd->IN_ep[ep_addr & EP_ADDR_MSK];
- ep->is_in = 1U;
- }
- else
- {
- ep = &hpcd->OUT_ep[ep_addr & EP_ADDR_MSK];
- ep->is_in = 0U;
- }
-
- ep->is_stall = 0U;
- ep->num = ep_addr & EP_ADDR_MSK;
-
- __HAL_LOCK(hpcd);
- (void)USB_EPClearStall(hpcd->Instance, ep);
- __HAL_UNLOCK(hpcd);
-
- return HAL_OK;
-}
-
-/**
- * @brief Abort an USB EP transaction.
- * @param hpcd PCD handle
- * @param ep_addr endpoint address
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_PCD_EP_Abort(PCD_HandleTypeDef *hpcd, uint8_t ep_addr)
-{
- HAL_StatusTypeDef ret;
- PCD_EPTypeDef *ep;
-
- if ((0x80U & ep_addr) == 0x80U)
- {
- ep = &hpcd->IN_ep[ep_addr & EP_ADDR_MSK];
- }
- else
- {
- ep = &hpcd->OUT_ep[ep_addr & EP_ADDR_MSK];
- }
-
- /* Stop Xfer */
- ret = USB_EPStopXfer(hpcd->Instance, ep);
-
- return ret;
-}
-
-/**
- * @brief Flush an endpoint
- * @param hpcd PCD handle
- * @param ep_addr endpoint address
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_PCD_EP_Flush(PCD_HandleTypeDef *hpcd, uint8_t ep_addr)
-{
- __HAL_LOCK(hpcd);
-
- if ((ep_addr & 0x80U) == 0x80U)
- {
- (void)USB_FlushTxFifo(hpcd->Instance, (uint32_t)ep_addr & EP_ADDR_MSK);
- }
- else
- {
- (void)USB_FlushRxFifo(hpcd->Instance);
- }
-
- __HAL_UNLOCK(hpcd);
-
- return HAL_OK;
-}
-
-/**
- * @brief Activate remote wakeup signalling
- * @param hpcd PCD handle
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_PCD_ActivateRemoteWakeup(PCD_HandleTypeDef *hpcd)
-{
- return (USB_ActivateRemoteWakeup(hpcd->Instance));
-}
-
-/**
- * @brief De-activate remote wakeup signalling.
- * @param hpcd PCD handle
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_PCD_DeActivateRemoteWakeup(PCD_HandleTypeDef *hpcd)
-{
- return (USB_DeActivateRemoteWakeup(hpcd->Instance));
-}
-
-/**
- * @}
- */
-
-/** @defgroup PCD_Exported_Functions_Group4 Peripheral State functions
- * @brief Peripheral State functions
- *
-@verbatim
- ===============================================================================
- ##### Peripheral State functions #####
- ===============================================================================
- [..]
- This subsection permits to get in run-time the status of the peripheral
- and the data flow.
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Return the PCD handle state.
- * @param hpcd PCD handle
- * @retval HAL state
- */
-PCD_StateTypeDef HAL_PCD_GetState(PCD_HandleTypeDef *hpcd)
-{
- return hpcd->State;
-}
-
-#if defined (USB_OTG_FS) || defined (USB_OTG_HS)
-/**
- * @brief Set the USB Device high speed test mode.
- * @param hpcd PCD handle
- * @param testmode USB Device high speed test mode
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_PCD_SetTestMode(PCD_HandleTypeDef *hpcd, uint8_t testmode)
-{
- USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
- uint32_t USBx_BASE = (uint32_t)USBx;
-
- switch (testmode)
- {
- case TEST_J:
- case TEST_K:
- case TEST_SE0_NAK:
- case TEST_PACKET:
- case TEST_FORCE_EN:
- USBx_DEVICE->DCTL |= (uint32_t)testmode << 4;
- break;
-
- default:
- break;
- }
-
- return HAL_OK;
-}
-#endif /* defined (USB_OTG_FS) || defined (USB_OTG_HS) */
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/* Private functions ---------------------------------------------------------*/
-/** @addtogroup PCD_Private_Functions
- * @{
- */
-#if defined (USB_OTG_FS) || defined (USB_OTG_HS)
-/**
- * @brief Check FIFO for the next packet to be loaded.
- * @param hpcd PCD handle
- * @param epnum endpoint number
- * @retval HAL status
- */
-static HAL_StatusTypeDef PCD_WriteEmptyTxFifo(PCD_HandleTypeDef *hpcd, uint32_t epnum)
-{
- USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
- uint32_t USBx_BASE = (uint32_t)USBx;
- USB_OTG_EPTypeDef *ep;
- uint32_t len;
- uint32_t len32b;
- uint32_t fifoemptymsk;
-
- ep = &hpcd->IN_ep[epnum];
-
- if (ep->xfer_count > ep->xfer_len)
- {
- return HAL_ERROR;
- }
-
- len = ep->xfer_len - ep->xfer_count;
-
- if (len > ep->maxpacket)
- {
- len = ep->maxpacket;
- }
-
- len32b = (len + 3U) / 4U;
-
- while (((USBx_INEP(epnum)->DTXFSTS & USB_OTG_DTXFSTS_INEPTFSAV) >= len32b) &&
- (ep->xfer_count < ep->xfer_len) && (ep->xfer_len != 0U))
- {
- /* Write the FIFO */
- len = ep->xfer_len - ep->xfer_count;
-
- if (len > ep->maxpacket)
- {
- len = ep->maxpacket;
- }
- len32b = (len + 3U) / 4U;
-
- (void)USB_WritePacket(USBx, ep->xfer_buff, (uint8_t)epnum, (uint16_t)len,
- (uint8_t)hpcd->Init.dma_enable);
-
- ep->xfer_buff += len;
- ep->xfer_count += len;
- }
-
- if (ep->xfer_len <= ep->xfer_count)
- {
- fifoemptymsk = (uint32_t)(0x1UL << (epnum & EP_ADDR_MSK));
- USBx_DEVICE->DIEPEMPMSK &= ~fifoemptymsk;
- }
-
- return HAL_OK;
-}
-
-
-/**
- * @brief process EP OUT transfer complete interrupt.
- * @param hpcd PCD handle
- * @param epnum endpoint number
- * @retval HAL status
- */
-static HAL_StatusTypeDef PCD_EP_OutXfrComplete_int(PCD_HandleTypeDef *hpcd, uint32_t epnum)
-{
- USB_OTG_EPTypeDef *ep;
- USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
- uint32_t USBx_BASE = (uint32_t)USBx;
- uint32_t gSNPSiD = *(__IO uint32_t *)(&USBx->CID + 0x1U);
- uint32_t DoepintReg = USBx_OUTEP(epnum)->DOEPINT;
-
- if (hpcd->Init.dma_enable == 1U)
- {
- if ((DoepintReg & USB_OTG_DOEPINT_STUP) == USB_OTG_DOEPINT_STUP) /* Class C */
- {
- /* StupPktRcvd = 1 this is a setup packet */
- if ((gSNPSiD > USB_OTG_CORE_ID_300A) &&
- ((DoepintReg & USB_OTG_DOEPINT_STPKTRX) == USB_OTG_DOEPINT_STPKTRX))
- {
- CLEAR_OUT_EP_INTR(epnum, USB_OTG_DOEPINT_STPKTRX);
- }
- }
- else if ((DoepintReg & USB_OTG_DOEPINT_OTEPSPR) == USB_OTG_DOEPINT_OTEPSPR) /* Class E */
- {
- CLEAR_OUT_EP_INTR(epnum, USB_OTG_DOEPINT_OTEPSPR);
- }
- else if ((DoepintReg & (USB_OTG_DOEPINT_STUP | USB_OTG_DOEPINT_OTEPSPR)) == 0U)
- {
- /* StupPktRcvd = 1 this is a setup packet */
- if ((gSNPSiD > USB_OTG_CORE_ID_300A) &&
- ((DoepintReg & USB_OTG_DOEPINT_STPKTRX) == USB_OTG_DOEPINT_STPKTRX))
- {
- CLEAR_OUT_EP_INTR(epnum, USB_OTG_DOEPINT_STPKTRX);
- }
- else
- {
- ep = &hpcd->OUT_ep[epnum];
-
- /* out data packet received over EP */
- ep->xfer_count = ep->xfer_size - (USBx_OUTEP(epnum)->DOEPTSIZ & USB_OTG_DOEPTSIZ_XFRSIZ);
-
- if (epnum == 0U)
- {
- if (ep->xfer_len == 0U)
- {
- /* this is ZLP, so prepare EP0 for next setup */
- (void)USB_EP0_OutStart(hpcd->Instance, 1U, (uint8_t *)hpcd->Setup);
- }
- else
- {
- ep->xfer_buff += ep->xfer_count;
- }
- }
-
-#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
- hpcd->DataOutStageCallback(hpcd, (uint8_t)epnum);
-#else
- HAL_PCD_DataOutStageCallback(hpcd, (uint8_t)epnum);
-#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
- }
- }
- else
- {
- /* ... */
- }
- }
- else
- {
- if (gSNPSiD == USB_OTG_CORE_ID_310A)
- {
- /* StupPktRcvd = 1 this is a setup packet */
- if ((DoepintReg & USB_OTG_DOEPINT_STPKTRX) == USB_OTG_DOEPINT_STPKTRX)
- {
- CLEAR_OUT_EP_INTR(epnum, USB_OTG_DOEPINT_STPKTRX);
- }
- else
- {
- if ((DoepintReg & USB_OTG_DOEPINT_OTEPSPR) == USB_OTG_DOEPINT_OTEPSPR)
- {
- CLEAR_OUT_EP_INTR(epnum, USB_OTG_DOEPINT_OTEPSPR);
- }
-
-#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
- hpcd->DataOutStageCallback(hpcd, (uint8_t)epnum);
-#else
- HAL_PCD_DataOutStageCallback(hpcd, (uint8_t)epnum);
-#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
- }
- }
- else
- {
- if ((epnum == 0U) && (hpcd->OUT_ep[epnum].xfer_len == 0U))
- {
- /* this is ZLP, so prepare EP0 for next setup */
- (void)USB_EP0_OutStart(hpcd->Instance, 0U, (uint8_t *)hpcd->Setup);
- }
-
-#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
- hpcd->DataOutStageCallback(hpcd, (uint8_t)epnum);
-#else
- HAL_PCD_DataOutStageCallback(hpcd, (uint8_t)epnum);
-#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
- }
- }
-
- return HAL_OK;
-}
-
-
-/**
- * @brief process EP OUT setup packet received interrupt.
- * @param hpcd PCD handle
- * @param epnum endpoint number
- * @retval HAL status
- */
-static HAL_StatusTypeDef PCD_EP_OutSetupPacket_int(PCD_HandleTypeDef *hpcd, uint32_t epnum)
-{
- USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
- uint32_t USBx_BASE = (uint32_t)USBx;
- uint32_t gSNPSiD = *(__IO uint32_t *)(&USBx->CID + 0x1U);
- uint32_t DoepintReg = USBx_OUTEP(epnum)->DOEPINT;
-
- if ((gSNPSiD > USB_OTG_CORE_ID_300A) &&
- ((DoepintReg & USB_OTG_DOEPINT_STPKTRX) == USB_OTG_DOEPINT_STPKTRX))
- {
- CLEAR_OUT_EP_INTR(epnum, USB_OTG_DOEPINT_STPKTRX);
- }
-
- /* Inform the upper layer that a setup packet is available */
-#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
- hpcd->SetupStageCallback(hpcd);
-#else
- HAL_PCD_SetupStageCallback(hpcd);
-#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
-
- if ((gSNPSiD > USB_OTG_CORE_ID_300A) && (hpcd->Init.dma_enable == 1U))
- {
- (void)USB_EP0_OutStart(hpcd->Instance, 1U, (uint8_t *)hpcd->Setup);
- }
-
- return HAL_OK;
-}
-#endif /* defined (USB_OTG_FS) || defined (USB_OTG_HS) */
-
-
-/**
- * @}
- */
-#endif /* defined (USB_OTG_FS) || defined (USB_OTG_HS) */
-#endif /* HAL_PCD_MODULE_ENABLED */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
diff --git a/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_pcd_ex.c b/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_pcd_ex.c
deleted file mode 100644
index 4e6b2bd..0000000
--- a/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_pcd_ex.c
+++ /dev/null
@@ -1,341 +0,0 @@
-/**
- ******************************************************************************
- * @file stm32h7xx_hal_pcd_ex.c
- * @author MCD Application Team
- * @brief PCD Extended HAL module driver.
- * This file provides firmware functions to manage the following
- * functionalities of the USB Peripheral Controller:
- * + Extended features functions
- *
- ******************************************************************************
- * @attention
- *
- * Copyright (c) 2017 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.
- *
- ******************************************************************************
- */
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32h7xx_hal.h"
-
-/** @addtogroup STM32H7xx_HAL_Driver
- * @{
- */
-
-/** @defgroup PCDEx PCDEx
- * @brief PCD Extended HAL module driver
- * @{
- */
-
-#ifdef HAL_PCD_MODULE_ENABLED
-
-#if defined (USB_OTG_FS) || defined (USB_OTG_HS)
-/* Private types -------------------------------------------------------------*/
-/* Private variables ---------------------------------------------------------*/
-/* Private constants ---------------------------------------------------------*/
-/* Private macros ------------------------------------------------------------*/
-/* Private functions ---------------------------------------------------------*/
-/* Exported functions --------------------------------------------------------*/
-
-/** @defgroup PCDEx_Exported_Functions PCDEx Exported Functions
- * @{
- */
-
-/** @defgroup PCDEx_Exported_Functions_Group1 Peripheral Control functions
- * @brief PCDEx control functions
- *
-@verbatim
- ===============================================================================
- ##### Extended features functions #####
- ===============================================================================
- [..] This section provides functions allowing to:
- (+) Update FIFO configuration
-
-@endverbatim
- * @{
- */
-#if defined (USB_OTG_FS) || defined (USB_OTG_HS)
-/**
- * @brief Set Tx FIFO
- * @param hpcd PCD handle
- * @param fifo The number of Tx fifo
- * @param size Fifo size
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_PCDEx_SetTxFiFo(PCD_HandleTypeDef *hpcd, uint8_t fifo, uint16_t size)
-{
- uint8_t i;
- uint32_t Tx_Offset;
-
- /* TXn min size = 16 words. (n : Transmit FIFO index)
- When a TxFIFO is not used, the Configuration should be as follows:
- case 1 : n > m and Txn is not used (n,m : Transmit FIFO indexes)
- --> Txm can use the space allocated for Txn.
- case2 : n < m and Txn is not used (n,m : Transmit FIFO indexes)
- --> Txn should be configured with the minimum space of 16 words
- The FIFO is used optimally when used TxFIFOs are allocated in the top
- of the FIFO.Ex: use EP1 and EP2 as IN instead of EP1 and EP3 as IN ones.
- When DMA is used 3n * FIFO locations should be reserved for internal DMA registers */
-
- Tx_Offset = hpcd->Instance->GRXFSIZ;
-
- if (fifo == 0U)
- {
- hpcd->Instance->DIEPTXF0_HNPTXFSIZ = ((uint32_t)size << 16) | Tx_Offset;
- }
- else
- {
- Tx_Offset += (hpcd->Instance->DIEPTXF0_HNPTXFSIZ) >> 16;
- for (i = 0U; i < (fifo - 1U); i++)
- {
- Tx_Offset += (hpcd->Instance->DIEPTXF[i] >> 16);
- }
-
- /* Multiply Tx_Size by 2 to get higher performance */
- hpcd->Instance->DIEPTXF[fifo - 1U] = ((uint32_t)size << 16) | Tx_Offset;
- }
-
- return HAL_OK;
-}
-
-/**
- * @brief Set Rx FIFO
- * @param hpcd PCD handle
- * @param size Size of Rx fifo
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_PCDEx_SetRxFiFo(PCD_HandleTypeDef *hpcd, uint16_t size)
-{
- hpcd->Instance->GRXFSIZ = size;
-
- return HAL_OK;
-}
-
-/**
- * @brief Activate LPM feature.
- * @param hpcd PCD handle
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_PCDEx_ActivateLPM(PCD_HandleTypeDef *hpcd)
-{
- USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
-
- hpcd->lpm_active = 1U;
- hpcd->LPM_State = LPM_L0;
- USBx->GINTMSK |= USB_OTG_GINTMSK_LPMINTM;
- USBx->GLPMCFG |= (USB_OTG_GLPMCFG_LPMEN | USB_OTG_GLPMCFG_LPMACK | USB_OTG_GLPMCFG_ENBESL);
-
- return HAL_OK;
-}
-
-/**
- * @brief Deactivate LPM feature.
- * @param hpcd PCD handle
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_PCDEx_DeActivateLPM(PCD_HandleTypeDef *hpcd)
-{
- USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
-
- hpcd->lpm_active = 0U;
- USBx->GINTMSK &= ~USB_OTG_GINTMSK_LPMINTM;
- USBx->GLPMCFG &= ~(USB_OTG_GLPMCFG_LPMEN | USB_OTG_GLPMCFG_LPMACK | USB_OTG_GLPMCFG_ENBESL);
-
- return HAL_OK;
-}
-
-
-/**
- * @brief Handle BatteryCharging Process.
- * @param hpcd PCD handle
- * @retval HAL status
- */
-void HAL_PCDEx_BCD_VBUSDetect(PCD_HandleTypeDef *hpcd)
-{
- USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
- uint32_t tickstart = HAL_GetTick();
-
- /* Enable DCD : Data Contact Detect */
- USBx->GCCFG |= USB_OTG_GCCFG_DCDEN;
-
- /* Wait for Min DCD Timeout */
- HAL_Delay(300U);
-
- /* Check Detect flag */
- if ((USBx->GCCFG & USB_OTG_GCCFG_DCDET) == USB_OTG_GCCFG_DCDET)
- {
-#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
- hpcd->BCDCallback(hpcd, PCD_BCD_CONTACT_DETECTION);
-#else
- HAL_PCDEx_BCD_Callback(hpcd, PCD_BCD_CONTACT_DETECTION);
-#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
- }
-
- /* Primary detection: checks if connected to Standard Downstream Port
- (without charging capability) */
- USBx->GCCFG &= ~ USB_OTG_GCCFG_DCDEN;
- HAL_Delay(50U);
- USBx->GCCFG |= USB_OTG_GCCFG_PDEN;
- HAL_Delay(50U);
-
- if ((USBx->GCCFG & USB_OTG_GCCFG_PDET) == 0U)
- {
- /* Case of Standard Downstream Port */
-#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
- hpcd->BCDCallback(hpcd, PCD_BCD_STD_DOWNSTREAM_PORT);
-#else
- HAL_PCDEx_BCD_Callback(hpcd, PCD_BCD_STD_DOWNSTREAM_PORT);
-#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
- }
- else
- {
- /* start secondary detection to check connection to Charging Downstream
- Port or Dedicated Charging Port */
- USBx->GCCFG &= ~(USB_OTG_GCCFG_PDEN);
- HAL_Delay(50U);
- USBx->GCCFG |= USB_OTG_GCCFG_SDEN;
- HAL_Delay(50U);
-
- if ((USBx->GCCFG & USB_OTG_GCCFG_SDET) == USB_OTG_GCCFG_SDET)
- {
- /* case Dedicated Charging Port */
-#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
- hpcd->BCDCallback(hpcd, PCD_BCD_DEDICATED_CHARGING_PORT);
-#else
- HAL_PCDEx_BCD_Callback(hpcd, PCD_BCD_DEDICATED_CHARGING_PORT);
-#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
- }
- else
- {
- /* case Charging Downstream Port */
-#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
- hpcd->BCDCallback(hpcd, PCD_BCD_CHARGING_DOWNSTREAM_PORT);
-#else
- HAL_PCDEx_BCD_Callback(hpcd, PCD_BCD_CHARGING_DOWNSTREAM_PORT);
-#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
- }
- }
-
- /* Battery Charging capability discovery finished */
- (void)HAL_PCDEx_DeActivateBCD(hpcd);
-
- /* Check for the Timeout, else start USB Device */
- if ((HAL_GetTick() - tickstart) > 1000U)
- {
-#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
- hpcd->BCDCallback(hpcd, PCD_BCD_ERROR);
-#else
- HAL_PCDEx_BCD_Callback(hpcd, PCD_BCD_ERROR);
-#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
- }
- else
- {
-#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
- hpcd->BCDCallback(hpcd, PCD_BCD_DISCOVERY_COMPLETED);
-#else
- HAL_PCDEx_BCD_Callback(hpcd, PCD_BCD_DISCOVERY_COMPLETED);
-#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
- }
-}
-
-/**
- * @brief Activate BatteryCharging feature.
- * @param hpcd PCD handle
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_PCDEx_ActivateBCD(PCD_HandleTypeDef *hpcd)
-{
- USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
-
- USBx->GCCFG &= ~(USB_OTG_GCCFG_PDEN);
- USBx->GCCFG &= ~(USB_OTG_GCCFG_SDEN);
-
- /* Power Down USB transceiver */
- USBx->GCCFG &= ~(USB_OTG_GCCFG_PWRDWN);
-
- /* Enable Battery charging */
- USBx->GCCFG |= USB_OTG_GCCFG_BCDEN;
-
- hpcd->battery_charging_active = 1U;
-
- return HAL_OK;
-}
-
-/**
- * @brief Deactivate BatteryCharging feature.
- * @param hpcd PCD handle
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_PCDEx_DeActivateBCD(PCD_HandleTypeDef *hpcd)
-{
- USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
-
- USBx->GCCFG &= ~(USB_OTG_GCCFG_SDEN);
- USBx->GCCFG &= ~(USB_OTG_GCCFG_PDEN);
-
- /* Disable Battery charging */
- USBx->GCCFG &= ~(USB_OTG_GCCFG_BCDEN);
-
- hpcd->battery_charging_active = 0U;
-
- return HAL_OK;
-}
-
-#endif /* defined (USB_OTG_FS) || defined (USB_OTG_HS) */
-
-/**
- * @brief Send LPM message to user layer callback.
- * @param hpcd PCD handle
- * @param msg LPM message
- * @retval HAL status
- */
-__weak void HAL_PCDEx_LPM_Callback(PCD_HandleTypeDef *hpcd, PCD_LPM_MsgTypeDef msg)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hpcd);
- UNUSED(msg);
-
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_PCDEx_LPM_Callback could be implemented in the user file
- */
-}
-
-/**
- * @brief Send BatteryCharging message to user layer callback.
- * @param hpcd PCD handle
- * @param msg LPM message
- * @retval HAL status
- */
-__weak void HAL_PCDEx_BCD_Callback(PCD_HandleTypeDef *hpcd, PCD_BCD_MsgTypeDef msg)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hpcd);
- UNUSED(msg);
-
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_PCDEx_BCD_Callback could be implemented in the user file
- */
-}
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-#endif /* defined (USB_OTG_FS) || defined (USB_OTG_HS) */
-#endif /* HAL_PCD_MODULE_ENABLED */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
diff --git a/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_usb.c b/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_usb.c
deleted file mode 100644
index 85d0136..0000000
--- a/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_usb.c
+++ /dev/null
@@ -1,2143 +0,0 @@
-/**
- ******************************************************************************
- * @file stm32h7xx_ll_usb.c
- * @author MCD Application Team
- * @brief USB Low Layer HAL module driver.
- *
- * This file provides firmware functions to manage the following
- * functionalities of the USB Peripheral Controller:
- * + Initialization/de-initialization functions
- * + I/O operation functions
- * + Peripheral Control functions
- * + Peripheral State functions
- *
- ******************************************************************************
- * @attention
- *
- * Copyright (c) 2017 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.
- *
- ******************************************************************************
- @verbatim
- ==============================================================================
- ##### How to use this driver #####
- ==============================================================================
- [..]
- (#) Fill parameters of Init structure in USB_CfgTypeDef structure.
-
- (#) Call USB_CoreInit() API to initialize the USB Core peripheral.
-
- (#) The upper HAL HCD/PCD driver will call the right routines for its internal processes.
-
- @endverbatim
-
- ******************************************************************************
- */
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32h7xx_hal.h"
-
-/** @addtogroup STM32H7xx_LL_USB_DRIVER
- * @{
- */
-
-#if defined (HAL_PCD_MODULE_ENABLED) || defined (HAL_HCD_MODULE_ENABLED)
-#if defined (USB_OTG_FS) || defined (USB_OTG_HS)
-/* Private typedef -----------------------------------------------------------*/
-/* Private define ------------------------------------------------------------*/
-/* Private macro -------------------------------------------------------------*/
-/* Private variables ---------------------------------------------------------*/
-/* Private function prototypes -----------------------------------------------*/
-/* Private functions ---------------------------------------------------------*/
-#if defined (USB_OTG_FS) || defined (USB_OTG_HS)
-static HAL_StatusTypeDef USB_CoreReset(USB_OTG_GlobalTypeDef *USBx);
-
-/* Exported functions --------------------------------------------------------*/
-/** @defgroup USB_LL_Exported_Functions USB Low Layer Exported Functions
- * @{
- */
-
-/** @defgroup USB_LL_Exported_Functions_Group1 Initialization/de-initialization functions
- * @brief Initialization and Configuration functions
- *
-@verbatim
- ===============================================================================
- ##### Initialization/de-initialization functions #####
- ===============================================================================
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Initializes the USB Core
- * @param USBx USB Instance
- * @param cfg pointer to a USB_OTG_CfgTypeDef structure that contains
- * the configuration information for the specified USBx peripheral.
- * @retval HAL status
- */
-HAL_StatusTypeDef USB_CoreInit(USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef cfg)
-{
- HAL_StatusTypeDef ret;
- if (cfg.phy_itface == USB_OTG_ULPI_PHY)
- {
- USBx->GCCFG &= ~(USB_OTG_GCCFG_PWRDWN);
-
- /* Init The ULPI Interface */
- USBx->GUSBCFG &= ~(USB_OTG_GUSBCFG_TSDPS | USB_OTG_GUSBCFG_ULPIFSLS | USB_OTG_GUSBCFG_PHYSEL);
-
- /* Select vbus source */
- USBx->GUSBCFG &= ~(USB_OTG_GUSBCFG_ULPIEVBUSD | USB_OTG_GUSBCFG_ULPIEVBUSI);
- if (cfg.use_external_vbus == 1U)
- {
- USBx->GUSBCFG |= USB_OTG_GUSBCFG_ULPIEVBUSD;
- }
-
- /* Reset after a PHY select */
- ret = USB_CoreReset(USBx);
- }
- else /* FS interface (embedded Phy) */
- {
- /* Select FS Embedded PHY */
- USBx->GUSBCFG |= USB_OTG_GUSBCFG_PHYSEL;
-
- /* Reset after a PHY select */
- ret = USB_CoreReset(USBx);
-
- if (cfg.battery_charging_enable == 0U)
- {
- /* Activate the USB Transceiver */
- USBx->GCCFG |= USB_OTG_GCCFG_PWRDWN;
- }
- else
- {
- /* Deactivate the USB Transceiver */
- USBx->GCCFG &= ~(USB_OTG_GCCFG_PWRDWN);
- }
- }
-
- if (cfg.dma_enable == 1U)
- {
- /* make sure to reserve 18 fifo Locations for DMA buffers */
- USBx->GDFIFOCFG &= ~(0xFFFFU << 16);
- USBx->GDFIFOCFG |= 0x3EEU << 16;
-
- USBx->GAHBCFG |= USB_OTG_GAHBCFG_HBSTLEN_2;
- USBx->GAHBCFG |= USB_OTG_GAHBCFG_DMAEN;
- }
-
- return ret;
-}
-
-
-/**
- * @brief Set the USB turnaround time
- * @param USBx USB Instance
- * @param hclk: AHB clock frequency
- * @retval USB turnaround time In PHY Clocks number
- */
-HAL_StatusTypeDef USB_SetTurnaroundTime(USB_OTG_GlobalTypeDef *USBx,
- uint32_t hclk, uint8_t speed)
-{
- uint32_t UsbTrd;
-
- /* The USBTRD is configured according to the tables below, depending on AHB frequency
- used by application. In the low AHB frequency range it is used to stretch enough the USB response
- time to IN tokens, the USB turnaround time, so to compensate for the longer AHB read access
- latency to the Data FIFO */
- if (speed == USBD_FS_SPEED)
- {
- if ((hclk >= 14200000U) && (hclk < 15000000U))
- {
- /* hclk Clock Range between 14.2-15 MHz */
- UsbTrd = 0xFU;
- }
- else if ((hclk >= 15000000U) && (hclk < 16000000U))
- {
- /* hclk Clock Range between 15-16 MHz */
- UsbTrd = 0xEU;
- }
- else if ((hclk >= 16000000U) && (hclk < 17200000U))
- {
- /* hclk Clock Range between 16-17.2 MHz */
- UsbTrd = 0xDU;
- }
- else if ((hclk >= 17200000U) && (hclk < 18500000U))
- {
- /* hclk Clock Range between 17.2-18.5 MHz */
- UsbTrd = 0xCU;
- }
- else if ((hclk >= 18500000U) && (hclk < 20000000U))
- {
- /* hclk Clock Range between 18.5-20 MHz */
- UsbTrd = 0xBU;
- }
- else if ((hclk >= 20000000U) && (hclk < 21800000U))
- {
- /* hclk Clock Range between 20-21.8 MHz */
- UsbTrd = 0xAU;
- }
- else if ((hclk >= 21800000U) && (hclk < 24000000U))
- {
- /* hclk Clock Range between 21.8-24 MHz */
- UsbTrd = 0x9U;
- }
- else if ((hclk >= 24000000U) && (hclk < 27700000U))
- {
- /* hclk Clock Range between 24-27.7 MHz */
- UsbTrd = 0x8U;
- }
- else if ((hclk >= 27700000U) && (hclk < 32000000U))
- {
- /* hclk Clock Range between 27.7-32 MHz */
- UsbTrd = 0x7U;
- }
- else /* if(hclk >= 32000000) */
- {
- /* hclk Clock Range between 32-200 MHz */
- UsbTrd = 0x6U;
- }
- }
- else if (speed == USBD_HS_SPEED)
- {
- UsbTrd = USBD_HS_TRDT_VALUE;
- }
- else
- {
- UsbTrd = USBD_DEFAULT_TRDT_VALUE;
- }
-
- USBx->GUSBCFG &= ~USB_OTG_GUSBCFG_TRDT;
- USBx->GUSBCFG |= (uint32_t)((UsbTrd << 10) & USB_OTG_GUSBCFG_TRDT);
-
- return HAL_OK;
-}
-
-/**
- * @brief USB_EnableGlobalInt
- * Enables the controller's Global Int in the AHB Config reg
- * @param USBx Selected device
- * @retval HAL status
- */
-HAL_StatusTypeDef USB_EnableGlobalInt(USB_OTG_GlobalTypeDef *USBx)
-{
- USBx->GAHBCFG |= USB_OTG_GAHBCFG_GINT;
- return HAL_OK;
-}
-
-/**
- * @brief USB_DisableGlobalInt
- * Disable the controller's Global Int in the AHB Config reg
- * @param USBx Selected device
- * @retval HAL status
- */
-HAL_StatusTypeDef USB_DisableGlobalInt(USB_OTG_GlobalTypeDef *USBx)
-{
- USBx->GAHBCFG &= ~USB_OTG_GAHBCFG_GINT;
- return HAL_OK;
-}
-
-/**
- * @brief USB_SetCurrentMode Set functional mode
- * @param USBx Selected device
- * @param mode current core mode
- * This parameter can be one of these values:
- * @arg USB_DEVICE_MODE Peripheral mode
- * @arg USB_HOST_MODE Host mode
- * @retval HAL status
- */
-HAL_StatusTypeDef USB_SetCurrentMode(USB_OTG_GlobalTypeDef *USBx, USB_OTG_ModeTypeDef mode)
-{
- uint32_t ms = 0U;
-
- USBx->GUSBCFG &= ~(USB_OTG_GUSBCFG_FHMOD | USB_OTG_GUSBCFG_FDMOD);
-
- if (mode == USB_HOST_MODE)
- {
- USBx->GUSBCFG |= USB_OTG_GUSBCFG_FHMOD;
-
- do
- {
- HAL_Delay(1U);
- ms++;
- } while ((USB_GetMode(USBx) != (uint32_t)USB_HOST_MODE) && (ms < 50U));
- }
- else if (mode == USB_DEVICE_MODE)
- {
- USBx->GUSBCFG |= USB_OTG_GUSBCFG_FDMOD;
-
- do
- {
- HAL_Delay(1U);
- ms++;
- } while ((USB_GetMode(USBx) != (uint32_t)USB_DEVICE_MODE) && (ms < 50U));
- }
- else
- {
- return HAL_ERROR;
- }
-
- if (ms == 50U)
- {
- return HAL_ERROR;
- }
-
- return HAL_OK;
-}
-
-/**
- * @brief USB_DevInit Initializes the USB_OTG controller registers
- * for device mode
- * @param USBx Selected device
- * @param cfg pointer to a USB_OTG_CfgTypeDef structure that contains
- * the configuration information for the specified USBx peripheral.
- * @retval HAL status
- */
-HAL_StatusTypeDef USB_DevInit(USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef cfg)
-{
- HAL_StatusTypeDef ret = HAL_OK;
- uint32_t USBx_BASE = (uint32_t)USBx;
- uint32_t i;
-
- for (i = 0U; i < 15U; i++)
- {
- USBx->DIEPTXF[i] = 0U;
- }
-
- /* VBUS Sensing setup */
- if (cfg.vbus_sensing_enable == 0U)
- {
- USBx_DEVICE->DCTL |= USB_OTG_DCTL_SDIS;
-
- /* Deactivate VBUS Sensing B */
- USBx->GCCFG &= ~USB_OTG_GCCFG_VBDEN;
-
- /* B-peripheral session valid override enable */
- USBx->GOTGCTL |= USB_OTG_GOTGCTL_BVALOEN;
- USBx->GOTGCTL |= USB_OTG_GOTGCTL_BVALOVAL;
- }
- else
- {
- /* Enable HW VBUS sensing */
- USBx->GCCFG |= USB_OTG_GCCFG_VBDEN;
- }
-
- /* Restart the Phy Clock */
- USBx_PCGCCTL = 0U;
-
- /* Device mode configuration */
- USBx_DEVICE->DCFG |= DCFG_FRAME_INTERVAL_80;
-
- if (cfg.phy_itface == USB_OTG_ULPI_PHY)
- {
- if (cfg.speed == USBD_HS_SPEED)
- {
- /* Set Core speed to High speed mode */
- (void)USB_SetDevSpeed(USBx, USB_OTG_SPEED_HIGH);
- }
- else
- {
- /* Set Core speed to Full speed mode */
- (void)USB_SetDevSpeed(USBx, USB_OTG_SPEED_HIGH_IN_FULL);
- }
- }
- else
- {
- /* Set Core speed to Full speed mode */
- (void)USB_SetDevSpeed(USBx, USB_OTG_SPEED_FULL);
- }
-
- /* Flush the FIFOs */
- if (USB_FlushTxFifo(USBx, 0x10U) != HAL_OK) /* all Tx FIFOs */
- {
- ret = HAL_ERROR;
- }
-
- if (USB_FlushRxFifo(USBx) != HAL_OK)
- {
- ret = HAL_ERROR;
- }
-
- /* Clear all pending Device Interrupts */
- USBx_DEVICE->DIEPMSK = 0U;
- USBx_DEVICE->DOEPMSK = 0U;
- USBx_DEVICE->DAINTMSK = 0U;
-
- for (i = 0U; i < cfg.dev_endpoints; i++)
- {
- if ((USBx_INEP(i)->DIEPCTL & USB_OTG_DIEPCTL_EPENA) == USB_OTG_DIEPCTL_EPENA)
- {
- if (i == 0U)
- {
- USBx_INEP(i)->DIEPCTL = USB_OTG_DIEPCTL_SNAK;
- }
- else
- {
- USBx_INEP(i)->DIEPCTL = USB_OTG_DIEPCTL_EPDIS | USB_OTG_DIEPCTL_SNAK;
- }
- }
- else
- {
- USBx_INEP(i)->DIEPCTL = 0U;
- }
-
- USBx_INEP(i)->DIEPTSIZ = 0U;
- USBx_INEP(i)->DIEPINT = 0xFB7FU;
- }
-
- for (i = 0U; i < cfg.dev_endpoints; i++)
- {
- if ((USBx_OUTEP(i)->DOEPCTL & USB_OTG_DOEPCTL_EPENA) == USB_OTG_DOEPCTL_EPENA)
- {
- if (i == 0U)
- {
- USBx_OUTEP(i)->DOEPCTL = USB_OTG_DOEPCTL_SNAK;
- }
- else
- {
- USBx_OUTEP(i)->DOEPCTL = USB_OTG_DOEPCTL_EPDIS | USB_OTG_DOEPCTL_SNAK;
- }
- }
- else
- {
- USBx_OUTEP(i)->DOEPCTL = 0U;
- }
-
- USBx_OUTEP(i)->DOEPTSIZ = 0U;
- USBx_OUTEP(i)->DOEPINT = 0xFB7FU;
- }
-
- USBx_DEVICE->DIEPMSK &= ~(USB_OTG_DIEPMSK_TXFURM);
-
- /* Disable all interrupts. */
- USBx->GINTMSK = 0U;
-
- /* Clear any pending interrupts */
- USBx->GINTSTS = 0xBFFFFFFFU;
-
- /* Enable the common interrupts */
- if (cfg.dma_enable == 0U)
- {
- USBx->GINTMSK |= USB_OTG_GINTMSK_RXFLVLM;
- }
-
- /* Enable interrupts matching to the Device mode ONLY */
- USBx->GINTMSK |= USB_OTG_GINTMSK_USBSUSPM | USB_OTG_GINTMSK_USBRST |
- USB_OTG_GINTMSK_ENUMDNEM | USB_OTG_GINTMSK_IEPINT |
- USB_OTG_GINTMSK_OEPINT | USB_OTG_GINTMSK_IISOIXFRM |
- USB_OTG_GINTMSK_PXFRM_IISOOXFRM | USB_OTG_GINTMSK_WUIM;
-
- if (cfg.Sof_enable != 0U)
- {
- USBx->GINTMSK |= USB_OTG_GINTMSK_SOFM;
- }
-
- if (cfg.vbus_sensing_enable == 1U)
- {
- USBx->GINTMSK |= (USB_OTG_GINTMSK_SRQIM | USB_OTG_GINTMSK_OTGINT);
- }
-
- return ret;
-}
-
-/**
- * @brief USB_FlushTxFifo Flush a Tx FIFO
- * @param USBx Selected device
- * @param num FIFO number
- * This parameter can be a value from 1 to 15
- 15 means Flush all Tx FIFOs
- * @retval HAL status
- */
-HAL_StatusTypeDef USB_FlushTxFifo(USB_OTG_GlobalTypeDef *USBx, uint32_t num)
-{
- __IO uint32_t count = 0U;
-
- /* Wait for AHB master IDLE state. */
- do
- {
- count++;
-
- if (count > 200000U)
- {
- return HAL_TIMEOUT;
- }
- } while ((USBx->GRSTCTL & USB_OTG_GRSTCTL_AHBIDL) == 0U);
-
- /* Flush TX Fifo */
- count = 0U;
- USBx->GRSTCTL = (USB_OTG_GRSTCTL_TXFFLSH | (num << 6));
-
- do
- {
- count++;
-
- if (count > 200000U)
- {
- return HAL_TIMEOUT;
- }
- } while ((USBx->GRSTCTL & USB_OTG_GRSTCTL_TXFFLSH) == USB_OTG_GRSTCTL_TXFFLSH);
-
- return HAL_OK;
-}
-
-/**
- * @brief USB_FlushRxFifo Flush Rx FIFO
- * @param USBx Selected device
- * @retval HAL status
- */
-HAL_StatusTypeDef USB_FlushRxFifo(USB_OTG_GlobalTypeDef *USBx)
-{
- __IO uint32_t count = 0U;
-
- /* Wait for AHB master IDLE state. */
- do
- {
- count++;
-
- if (count > 200000U)
- {
- return HAL_TIMEOUT;
- }
- } while ((USBx->GRSTCTL & USB_OTG_GRSTCTL_AHBIDL) == 0U);
-
- /* Flush RX Fifo */
- count = 0U;
- USBx->GRSTCTL = USB_OTG_GRSTCTL_RXFFLSH;
-
- do
- {
- count++;
-
- if (count > 200000U)
- {
- return HAL_TIMEOUT;
- }
- } while ((USBx->GRSTCTL & USB_OTG_GRSTCTL_RXFFLSH) == USB_OTG_GRSTCTL_RXFFLSH);
-
- return HAL_OK;
-}
-
-/**
- * @brief USB_SetDevSpeed Initializes the DevSpd field of DCFG register
- * depending the PHY type and the enumeration speed of the device.
- * @param USBx Selected device
- * @param speed device speed
- * This parameter can be one of these values:
- * @arg USB_OTG_SPEED_HIGH: High speed mode
- * @arg USB_OTG_SPEED_HIGH_IN_FULL: High speed core in Full Speed mode
- * @arg USB_OTG_SPEED_FULL: Full speed mode
- * @retval Hal status
- */
-HAL_StatusTypeDef USB_SetDevSpeed(USB_OTG_GlobalTypeDef *USBx, uint8_t speed)
-{
- uint32_t USBx_BASE = (uint32_t)USBx;
-
- USBx_DEVICE->DCFG |= speed;
- return HAL_OK;
-}
-
-/**
- * @brief USB_GetDevSpeed Return the Dev Speed
- * @param USBx Selected device
- * @retval speed device speed
- * This parameter can be one of these values:
- * @arg USBD_HS_SPEED: High speed mode
- * @arg USBD_FS_SPEED: Full speed mode
- */
-uint8_t USB_GetDevSpeed(USB_OTG_GlobalTypeDef *USBx)
-{
- uint32_t USBx_BASE = (uint32_t)USBx;
- uint8_t speed;
- uint32_t DevEnumSpeed = USBx_DEVICE->DSTS & USB_OTG_DSTS_ENUMSPD;
-
- if (DevEnumSpeed == DSTS_ENUMSPD_HS_PHY_30MHZ_OR_60MHZ)
- {
- speed = USBD_HS_SPEED;
- }
- else if ((DevEnumSpeed == DSTS_ENUMSPD_FS_PHY_30MHZ_OR_60MHZ) ||
- (DevEnumSpeed == DSTS_ENUMSPD_FS_PHY_48MHZ))
- {
- speed = USBD_FS_SPEED;
- }
- else
- {
- speed = 0xFU;
- }
-
- return speed;
-}
-
-/**
- * @brief Activate and configure an endpoint
- * @param USBx Selected device
- * @param ep pointer to endpoint structure
- * @retval HAL status
- */
-HAL_StatusTypeDef USB_ActivateEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep)
-{
- uint32_t USBx_BASE = (uint32_t)USBx;
- uint32_t epnum = (uint32_t)ep->num;
-
- if (ep->is_in == 1U)
- {
- USBx_DEVICE->DAINTMSK |= USB_OTG_DAINTMSK_IEPM & (uint32_t)(1UL << (ep->num & EP_ADDR_MSK));
-
- if ((USBx_INEP(epnum)->DIEPCTL & USB_OTG_DIEPCTL_USBAEP) == 0U)
- {
- USBx_INEP(epnum)->DIEPCTL |= (ep->maxpacket & USB_OTG_DIEPCTL_MPSIZ) |
- ((uint32_t)ep->type << 18) | (epnum << 22) |
- USB_OTG_DIEPCTL_SD0PID_SEVNFRM |
- USB_OTG_DIEPCTL_USBAEP;
- }
- }
- else
- {
- USBx_DEVICE->DAINTMSK |= USB_OTG_DAINTMSK_OEPM & ((uint32_t)(1UL << (ep->num & EP_ADDR_MSK)) << 16);
-
- if (((USBx_OUTEP(epnum)->DOEPCTL) & USB_OTG_DOEPCTL_USBAEP) == 0U)
- {
- USBx_OUTEP(epnum)->DOEPCTL |= (ep->maxpacket & USB_OTG_DOEPCTL_MPSIZ) |
- ((uint32_t)ep->type << 18) |
- USB_OTG_DIEPCTL_SD0PID_SEVNFRM |
- USB_OTG_DOEPCTL_USBAEP;
- }
- }
- return HAL_OK;
-}
-
-/**
- * @brief Activate and configure a dedicated endpoint
- * @param USBx Selected device
- * @param ep pointer to endpoint structure
- * @retval HAL status
- */
-HAL_StatusTypeDef USB_ActivateDedicatedEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep)
-{
- uint32_t USBx_BASE = (uint32_t)USBx;
- uint32_t epnum = (uint32_t)ep->num;
-
- /* Read DEPCTLn register */
- if (ep->is_in == 1U)
- {
- if (((USBx_INEP(epnum)->DIEPCTL) & USB_OTG_DIEPCTL_USBAEP) == 0U)
- {
- USBx_INEP(epnum)->DIEPCTL |= (ep->maxpacket & USB_OTG_DIEPCTL_MPSIZ) |
- ((uint32_t)ep->type << 18) | (epnum << 22) |
- USB_OTG_DIEPCTL_SD0PID_SEVNFRM |
- USB_OTG_DIEPCTL_USBAEP;
- }
-
- USBx_DEVICE->DEACHMSK |= USB_OTG_DAINTMSK_IEPM & (uint32_t)(1UL << (ep->num & EP_ADDR_MSK));
- }
- else
- {
- if (((USBx_OUTEP(epnum)->DOEPCTL) & USB_OTG_DOEPCTL_USBAEP) == 0U)
- {
- USBx_OUTEP(epnum)->DOEPCTL |= (ep->maxpacket & USB_OTG_DOEPCTL_MPSIZ) |
- ((uint32_t)ep->type << 18) | (epnum << 22) |
- USB_OTG_DOEPCTL_USBAEP;
- }
-
- USBx_DEVICE->DEACHMSK |= USB_OTG_DAINTMSK_OEPM & ((uint32_t)(1UL << (ep->num & EP_ADDR_MSK)) << 16);
- }
-
- return HAL_OK;
-}
-
-/**
- * @brief De-activate and de-initialize an endpoint
- * @param USBx Selected device
- * @param ep pointer to endpoint structure
- * @retval HAL status
- */
-HAL_StatusTypeDef USB_DeactivateEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep)
-{
- uint32_t USBx_BASE = (uint32_t)USBx;
- uint32_t epnum = (uint32_t)ep->num;
-
- /* Read DEPCTLn register */
- if (ep->is_in == 1U)
- {
- if ((USBx_INEP(epnum)->DIEPCTL & USB_OTG_DIEPCTL_EPENA) == USB_OTG_DIEPCTL_EPENA)
- {
- USBx_INEP(epnum)->DIEPCTL |= USB_OTG_DIEPCTL_SNAK;
- USBx_INEP(epnum)->DIEPCTL |= USB_OTG_DIEPCTL_EPDIS;
- }
-
- USBx_DEVICE->DEACHMSK &= ~(USB_OTG_DAINTMSK_IEPM & (uint32_t)(1UL << (ep->num & EP_ADDR_MSK)));
- USBx_DEVICE->DAINTMSK &= ~(USB_OTG_DAINTMSK_IEPM & (uint32_t)(1UL << (ep->num & EP_ADDR_MSK)));
- USBx_INEP(epnum)->DIEPCTL &= ~(USB_OTG_DIEPCTL_USBAEP |
- USB_OTG_DIEPCTL_MPSIZ |
- USB_OTG_DIEPCTL_TXFNUM |
- USB_OTG_DIEPCTL_SD0PID_SEVNFRM |
- USB_OTG_DIEPCTL_EPTYP);
- }
- else
- {
- if ((USBx_OUTEP(epnum)->DOEPCTL & USB_OTG_DOEPCTL_EPENA) == USB_OTG_DOEPCTL_EPENA)
- {
- USBx_OUTEP(epnum)->DOEPCTL |= USB_OTG_DOEPCTL_SNAK;
- USBx_OUTEP(epnum)->DOEPCTL |= USB_OTG_DOEPCTL_EPDIS;
- }
-
- USBx_DEVICE->DEACHMSK &= ~(USB_OTG_DAINTMSK_OEPM & ((uint32_t)(1UL << (ep->num & EP_ADDR_MSK)) << 16));
- USBx_DEVICE->DAINTMSK &= ~(USB_OTG_DAINTMSK_OEPM & ((uint32_t)(1UL << (ep->num & EP_ADDR_MSK)) << 16));
- USBx_OUTEP(epnum)->DOEPCTL &= ~(USB_OTG_DOEPCTL_USBAEP |
- USB_OTG_DOEPCTL_MPSIZ |
- USB_OTG_DOEPCTL_SD0PID_SEVNFRM |
- USB_OTG_DOEPCTL_EPTYP);
- }
-
- return HAL_OK;
-}
-
-/**
- * @brief De-activate and de-initialize a dedicated endpoint
- * @param USBx Selected device
- * @param ep pointer to endpoint structure
- * @retval HAL status
- */
-HAL_StatusTypeDef USB_DeactivateDedicatedEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep)
-{
- uint32_t USBx_BASE = (uint32_t)USBx;
- uint32_t epnum = (uint32_t)ep->num;
-
- /* Read DEPCTLn register */
- if (ep->is_in == 1U)
- {
- if ((USBx_INEP(epnum)->DIEPCTL & USB_OTG_DIEPCTL_EPENA) == USB_OTG_DIEPCTL_EPENA)
- {
- USBx_INEP(epnum)->DIEPCTL |= USB_OTG_DIEPCTL_SNAK;
- USBx_INEP(epnum)->DIEPCTL |= USB_OTG_DIEPCTL_EPDIS;
- }
-
- USBx_INEP(epnum)->DIEPCTL &= ~ USB_OTG_DIEPCTL_USBAEP;
- USBx_DEVICE->DAINTMSK &= ~(USB_OTG_DAINTMSK_IEPM & (uint32_t)(1UL << (ep->num & EP_ADDR_MSK)));
- }
- else
- {
- if ((USBx_OUTEP(epnum)->DOEPCTL & USB_OTG_DOEPCTL_EPENA) == USB_OTG_DOEPCTL_EPENA)
- {
- USBx_OUTEP(epnum)->DOEPCTL |= USB_OTG_DOEPCTL_SNAK;
- USBx_OUTEP(epnum)->DOEPCTL |= USB_OTG_DOEPCTL_EPDIS;
- }
-
- USBx_OUTEP(epnum)->DOEPCTL &= ~USB_OTG_DOEPCTL_USBAEP;
- USBx_DEVICE->DAINTMSK &= ~(USB_OTG_DAINTMSK_OEPM & ((uint32_t)(1UL << (ep->num & EP_ADDR_MSK)) << 16));
- }
-
- return HAL_OK;
-}
-
-/**
- * @brief USB_EPStartXfer : setup and starts a transfer over an EP
- * @param USBx Selected device
- * @param ep pointer to endpoint structure
- * @param dma USB dma enabled or disabled
- * This parameter can be one of these values:
- * 0 : DMA feature not used
- * 1 : DMA feature used
- * @retval HAL status
- */
-HAL_StatusTypeDef USB_EPStartXfer(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep, uint8_t dma)
-{
- uint32_t USBx_BASE = (uint32_t)USBx;
- uint32_t epnum = (uint32_t)ep->num;
- uint16_t pktcnt;
-
- /* IN endpoint */
- if (ep->is_in == 1U)
- {
- /* Zero Length Packet? */
- if (ep->xfer_len == 0U)
- {
- USBx_INEP(epnum)->DIEPTSIZ &= ~(USB_OTG_DIEPTSIZ_PKTCNT);
- USBx_INEP(epnum)->DIEPTSIZ |= (USB_OTG_DIEPTSIZ_PKTCNT & (1U << 19));
- USBx_INEP(epnum)->DIEPTSIZ &= ~(USB_OTG_DIEPTSIZ_XFRSIZ);
- }
- else
- {
- /* Program the transfer size and packet count
- * as follows: xfersize = N * maxpacket +
- * short_packet pktcnt = N + (short_packet
- * exist ? 1 : 0)
- */
- USBx_INEP(epnum)->DIEPTSIZ &= ~(USB_OTG_DIEPTSIZ_XFRSIZ);
- USBx_INEP(epnum)->DIEPTSIZ &= ~(USB_OTG_DIEPTSIZ_PKTCNT);
-
- if (epnum == 0U)
- {
- if (ep->xfer_len > ep->maxpacket)
- {
- ep->xfer_len = ep->maxpacket;
- }
-
- USBx_INEP(epnum)->DIEPTSIZ |= (USB_OTG_DIEPTSIZ_PKTCNT & (1U << 19));
- }
- else
- {
- USBx_INEP(epnum)->DIEPTSIZ |= (USB_OTG_DIEPTSIZ_PKTCNT &
- (((ep->xfer_len + ep->maxpacket - 1U) / ep->maxpacket) << 19));
- }
-
- USBx_INEP(epnum)->DIEPTSIZ |= (USB_OTG_DIEPTSIZ_XFRSIZ & ep->xfer_len);
-
- if (ep->type == EP_TYPE_ISOC)
- {
- USBx_INEP(epnum)->DIEPTSIZ &= ~(USB_OTG_DIEPTSIZ_MULCNT);
- USBx_INEP(epnum)->DIEPTSIZ |= (USB_OTG_DIEPTSIZ_MULCNT & (1U << 29));
- }
- }
-
- if (dma == 1U)
- {
- if ((uint32_t)ep->dma_addr != 0U)
- {
- USBx_INEP(epnum)->DIEPDMA = (uint32_t)(ep->dma_addr);
- }
-
- if (ep->type == EP_TYPE_ISOC)
- {
- if ((USBx_DEVICE->DSTS & (1U << 8)) == 0U)
- {
- USBx_INEP(epnum)->DIEPCTL |= USB_OTG_DIEPCTL_SODDFRM;
- }
- else
- {
- USBx_INEP(epnum)->DIEPCTL |= USB_OTG_DIEPCTL_SD0PID_SEVNFRM;
- }
- }
-
- /* EP enable, IN data in FIFO */
- USBx_INEP(epnum)->DIEPCTL |= (USB_OTG_DIEPCTL_CNAK | USB_OTG_DIEPCTL_EPENA);
- }
- else
- {
- /* EP enable, IN data in FIFO */
- USBx_INEP(epnum)->DIEPCTL |= (USB_OTG_DIEPCTL_CNAK | USB_OTG_DIEPCTL_EPENA);
-
- if (ep->type != EP_TYPE_ISOC)
- {
- /* Enable the Tx FIFO Empty Interrupt for this EP */
- if (ep->xfer_len > 0U)
- {
- USBx_DEVICE->DIEPEMPMSK |= 1UL << (ep->num & EP_ADDR_MSK);
- }
- }
- else
- {
- if ((USBx_DEVICE->DSTS & (1U << 8)) == 0U)
- {
- USBx_INEP(epnum)->DIEPCTL |= USB_OTG_DIEPCTL_SODDFRM;
- }
- else
- {
- USBx_INEP(epnum)->DIEPCTL |= USB_OTG_DIEPCTL_SD0PID_SEVNFRM;
- }
-
- (void)USB_WritePacket(USBx, ep->xfer_buff, ep->num, (uint16_t)ep->xfer_len, dma);
- }
- }
- }
- else /* OUT endpoint */
- {
- /* Program the transfer size and packet count as follows:
- * pktcnt = N
- * xfersize = N * maxpacket
- */
- USBx_OUTEP(epnum)->DOEPTSIZ &= ~(USB_OTG_DOEPTSIZ_XFRSIZ);
- USBx_OUTEP(epnum)->DOEPTSIZ &= ~(USB_OTG_DOEPTSIZ_PKTCNT);
-
- if (epnum == 0U)
- {
- if (ep->xfer_len > 0U)
- {
- ep->xfer_len = ep->maxpacket;
- }
-
- /* Store transfer size, for EP0 this is equal to endpoint max packet size */
- ep->xfer_size = ep->maxpacket;
-
- USBx_OUTEP(epnum)->DOEPTSIZ |= (USB_OTG_DOEPTSIZ_XFRSIZ & ep->xfer_size);
- USBx_OUTEP(epnum)->DOEPTSIZ |= (USB_OTG_DOEPTSIZ_PKTCNT & (1U << 19));
- }
- else
- {
- if (ep->xfer_len == 0U)
- {
- USBx_OUTEP(epnum)->DOEPTSIZ |= (USB_OTG_DOEPTSIZ_XFRSIZ & ep->maxpacket);
- USBx_OUTEP(epnum)->DOEPTSIZ |= (USB_OTG_DOEPTSIZ_PKTCNT & (1U << 19));
- }
- else
- {
- pktcnt = (uint16_t)((ep->xfer_len + ep->maxpacket - 1U) / ep->maxpacket);
- ep->xfer_size = ep->maxpacket * pktcnt;
-
- USBx_OUTEP(epnum)->DOEPTSIZ |= USB_OTG_DOEPTSIZ_PKTCNT & ((uint32_t)pktcnt << 19);
- USBx_OUTEP(epnum)->DOEPTSIZ |= USB_OTG_DOEPTSIZ_XFRSIZ & ep->xfer_size;
- }
- }
-
- if (dma == 1U)
- {
- if ((uint32_t)ep->xfer_buff != 0U)
- {
- USBx_OUTEP(epnum)->DOEPDMA = (uint32_t)(ep->xfer_buff);
- }
- }
-
- if (ep->type == EP_TYPE_ISOC)
- {
- if ((USBx_DEVICE->DSTS & (1U << 8)) == 0U)
- {
- USBx_OUTEP(epnum)->DOEPCTL |= USB_OTG_DOEPCTL_SODDFRM;
- }
- else
- {
- USBx_OUTEP(epnum)->DOEPCTL |= USB_OTG_DOEPCTL_SD0PID_SEVNFRM;
- }
- }
- /* EP enable */
- USBx_OUTEP(epnum)->DOEPCTL |= (USB_OTG_DOEPCTL_CNAK | USB_OTG_DOEPCTL_EPENA);
- }
-
- return HAL_OK;
-}
-
-
-/**
- * @brief USB_EPStoptXfer Stop transfer on an EP
- * @param USBx usb device instance
- * @param ep pointer to endpoint structure
- * @retval HAL status
- */
-HAL_StatusTypeDef USB_EPStopXfer(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep)
-{
- __IO uint32_t count = 0U;
- HAL_StatusTypeDef ret = HAL_OK;
- uint32_t USBx_BASE = (uint32_t)USBx;
-
- /* IN endpoint */
- if (ep->is_in == 1U)
- {
- /* EP enable, IN data in FIFO */
- if (((USBx_INEP(ep->num)->DIEPCTL) & USB_OTG_DIEPCTL_EPENA) == USB_OTG_DIEPCTL_EPENA)
- {
- USBx_INEP(ep->num)->DIEPCTL |= (USB_OTG_DIEPCTL_SNAK);
- USBx_INEP(ep->num)->DIEPCTL |= (USB_OTG_DIEPCTL_EPDIS);
-
- do
- {
- count++;
-
- if (count > 10000U)
- {
- ret = HAL_ERROR;
- break;
- }
- } while (((USBx_INEP(ep->num)->DIEPCTL) & USB_OTG_DIEPCTL_EPENA) == USB_OTG_DIEPCTL_EPENA);
- }
- }
- else /* OUT endpoint */
- {
- if (((USBx_OUTEP(ep->num)->DOEPCTL) & USB_OTG_DOEPCTL_EPENA) == USB_OTG_DOEPCTL_EPENA)
- {
- USBx_OUTEP(ep->num)->DOEPCTL |= (USB_OTG_DOEPCTL_SNAK);
- USBx_OUTEP(ep->num)->DOEPCTL |= (USB_OTG_DOEPCTL_EPDIS);
-
- do
- {
- count++;
-
- if (count > 10000U)
- {
- ret = HAL_ERROR;
- break;
- }
- } while (((USBx_OUTEP(ep->num)->DOEPCTL) & USB_OTG_DOEPCTL_EPENA) == USB_OTG_DOEPCTL_EPENA);
- }
- }
-
- return ret;
-}
-
-
-/**
- * @brief USB_WritePacket : Writes a packet into the Tx FIFO associated
- * with the EP/channel
- * @param USBx Selected device
- * @param src pointer to source buffer
- * @param ch_ep_num endpoint or host channel number
- * @param len Number of bytes to write
- * @param dma USB dma enabled or disabled
- * This parameter can be one of these values:
- * 0 : DMA feature not used
- * 1 : DMA feature used
- * @retval HAL status
- */
-HAL_StatusTypeDef USB_WritePacket(USB_OTG_GlobalTypeDef *USBx, uint8_t *src,
- uint8_t ch_ep_num, uint16_t len, uint8_t dma)
-{
- uint32_t USBx_BASE = (uint32_t)USBx;
- uint8_t *pSrc = src;
- uint32_t count32b;
- uint32_t i;
-
- if (dma == 0U)
- {
- count32b = ((uint32_t)len + 3U) / 4U;
- for (i = 0U; i < count32b; i++)
- {
- USBx_DFIFO((uint32_t)ch_ep_num) = __UNALIGNED_UINT32_READ(pSrc);
- pSrc++;
- pSrc++;
- pSrc++;
- pSrc++;
- }
- }
-
- return HAL_OK;
-}
-
-/**
- * @brief USB_ReadPacket : read a packet from the RX FIFO
- * @param USBx Selected device
- * @param dest source pointer
- * @param len Number of bytes to read
- * @retval pointer to destination buffer
- */
-void *USB_ReadPacket(USB_OTG_GlobalTypeDef *USBx, uint8_t *dest, uint16_t len)
-{
- uint32_t USBx_BASE = (uint32_t)USBx;
- uint8_t *pDest = dest;
- uint32_t pData;
- uint32_t i;
- uint32_t count32b = (uint32_t)len >> 2U;
- uint16_t remaining_bytes = len % 4U;
-
- for (i = 0U; i < count32b; i++)
- {
- __UNALIGNED_UINT32_WRITE(pDest, USBx_DFIFO(0U));
- pDest++;
- pDest++;
- pDest++;
- pDest++;
- }
-
- /* When Number of data is not word aligned, read the remaining byte */
- if (remaining_bytes != 0U)
- {
- i = 0U;
- __UNALIGNED_UINT32_WRITE(&pData, USBx_DFIFO(0U));
-
- do
- {
- *(uint8_t *)pDest = (uint8_t)(pData >> (8U * (uint8_t)(i)));
- i++;
- pDest++;
- remaining_bytes--;
- } while (remaining_bytes != 0U);
- }
-
- return ((void *)pDest);
-}
-
-/**
- * @brief USB_EPSetStall : set a stall condition over an EP
- * @param USBx Selected device
- * @param ep pointer to endpoint structure
- * @retval HAL status
- */
-HAL_StatusTypeDef USB_EPSetStall(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep)
-{
- uint32_t USBx_BASE = (uint32_t)USBx;
- uint32_t epnum = (uint32_t)ep->num;
-
- if (ep->is_in == 1U)
- {
- if (((USBx_INEP(epnum)->DIEPCTL & USB_OTG_DIEPCTL_EPENA) == 0U) && (epnum != 0U))
- {
- USBx_INEP(epnum)->DIEPCTL &= ~(USB_OTG_DIEPCTL_EPDIS);
- }
- USBx_INEP(epnum)->DIEPCTL |= USB_OTG_DIEPCTL_STALL;
- }
- else
- {
- if (((USBx_OUTEP(epnum)->DOEPCTL & USB_OTG_DOEPCTL_EPENA) == 0U) && (epnum != 0U))
- {
- USBx_OUTEP(epnum)->DOEPCTL &= ~(USB_OTG_DOEPCTL_EPDIS);
- }
- USBx_OUTEP(epnum)->DOEPCTL |= USB_OTG_DOEPCTL_STALL;
- }
-
- return HAL_OK;
-}
-
-/**
- * @brief USB_EPClearStall : Clear a stall condition over an EP
- * @param USBx Selected device
- * @param ep pointer to endpoint structure
- * @retval HAL status
- */
-HAL_StatusTypeDef USB_EPClearStall(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep)
-{
- uint32_t USBx_BASE = (uint32_t)USBx;
- uint32_t epnum = (uint32_t)ep->num;
-
- if (ep->is_in == 1U)
- {
- USBx_INEP(epnum)->DIEPCTL &= ~USB_OTG_DIEPCTL_STALL;
- if ((ep->type == EP_TYPE_INTR) || (ep->type == EP_TYPE_BULK))
- {
- USBx_INEP(epnum)->DIEPCTL |= USB_OTG_DIEPCTL_SD0PID_SEVNFRM; /* DATA0 */
- }
- }
- else
- {
- USBx_OUTEP(epnum)->DOEPCTL &= ~USB_OTG_DOEPCTL_STALL;
- if ((ep->type == EP_TYPE_INTR) || (ep->type == EP_TYPE_BULK))
- {
- USBx_OUTEP(epnum)->DOEPCTL |= USB_OTG_DOEPCTL_SD0PID_SEVNFRM; /* DATA0 */
- }
- }
- return HAL_OK;
-}
-
-/**
- * @brief USB_StopDevice : Stop the usb device mode
- * @param USBx Selected device
- * @retval HAL status
- */
-HAL_StatusTypeDef USB_StopDevice(USB_OTG_GlobalTypeDef *USBx)
-{
- HAL_StatusTypeDef ret;
- uint32_t USBx_BASE = (uint32_t)USBx;
- uint32_t i;
-
- /* Clear Pending interrupt */
- for (i = 0U; i < 15U; i++)
- {
- USBx_INEP(i)->DIEPINT = 0xFB7FU;
- USBx_OUTEP(i)->DOEPINT = 0xFB7FU;
- }
-
- /* Clear interrupt masks */
- USBx_DEVICE->DIEPMSK = 0U;
- USBx_DEVICE->DOEPMSK = 0U;
- USBx_DEVICE->DAINTMSK = 0U;
-
- /* Flush the FIFO */
- ret = USB_FlushRxFifo(USBx);
- if (ret != HAL_OK)
- {
- return ret;
- }
-
- ret = USB_FlushTxFifo(USBx, 0x10U);
- if (ret != HAL_OK)
- {
- return ret;
- }
-
- return ret;
-}
-
-/**
- * @brief USB_SetDevAddress : Stop the usb device mode
- * @param USBx Selected device
- * @param address new device address to be assigned
- * This parameter can be a value from 0 to 255
- * @retval HAL status
- */
-HAL_StatusTypeDef USB_SetDevAddress(USB_OTG_GlobalTypeDef *USBx, uint8_t address)
-{
- uint32_t USBx_BASE = (uint32_t)USBx;
-
- USBx_DEVICE->DCFG &= ~(USB_OTG_DCFG_DAD);
- USBx_DEVICE->DCFG |= ((uint32_t)address << 4) & USB_OTG_DCFG_DAD;
-
- return HAL_OK;
-}
-
-/**
- * @brief USB_DevConnect : Connect the USB device by enabling Rpu
- * @param USBx Selected device
- * @retval HAL status
- */
-HAL_StatusTypeDef USB_DevConnect(USB_OTG_GlobalTypeDef *USBx)
-{
- uint32_t USBx_BASE = (uint32_t)USBx;
-
- /* In case phy is stopped, ensure to ungate and restore the phy CLK */
- USBx_PCGCCTL &= ~(USB_OTG_PCGCCTL_STOPCLK | USB_OTG_PCGCCTL_GATECLK);
-
- USBx_DEVICE->DCTL &= ~USB_OTG_DCTL_SDIS;
-
- return HAL_OK;
-}
-
-/**
- * @brief USB_DevDisconnect : Disconnect the USB device by disabling Rpu
- * @param USBx Selected device
- * @retval HAL status
- */
-HAL_StatusTypeDef USB_DevDisconnect(USB_OTG_GlobalTypeDef *USBx)
-{
- uint32_t USBx_BASE = (uint32_t)USBx;
-
- /* In case phy is stopped, ensure to ungate and restore the phy CLK */
- USBx_PCGCCTL &= ~(USB_OTG_PCGCCTL_STOPCLK | USB_OTG_PCGCCTL_GATECLK);
-
- USBx_DEVICE->DCTL |= USB_OTG_DCTL_SDIS;
-
- return HAL_OK;
-}
-
-/**
- * @brief USB_ReadInterrupts: return the global USB interrupt status
- * @param USBx Selected device
- * @retval USB Global Interrupt status
- */
-uint32_t USB_ReadInterrupts(USB_OTG_GlobalTypeDef *USBx)
-{
- uint32_t tmpreg;
-
- tmpreg = USBx->GINTSTS;
- tmpreg &= USBx->GINTMSK;
-
- return tmpreg;
-}
-
-/**
- * @brief USB_ReadChInterrupts: return USB channel interrupt status
- * @param USBx Selected device
- * @param chnum Channel number
- * @retval USB Channel Interrupt status
- */
-uint32_t USB_ReadChInterrupts(USB_OTG_GlobalTypeDef *USBx, uint8_t chnum)
-{
- uint32_t USBx_BASE = (uint32_t)USBx;
- uint32_t tmpreg;
-
- tmpreg = USBx_HC(chnum)->HCINT;
- tmpreg &= USBx_HC(chnum)->HCINTMSK;
-
- return tmpreg;
-}
-
-/**
- * @brief USB_ReadDevAllOutEpInterrupt: return the USB device OUT endpoints interrupt status
- * @param USBx Selected device
- * @retval USB Device OUT EP interrupt status
- */
-uint32_t USB_ReadDevAllOutEpInterrupt(USB_OTG_GlobalTypeDef *USBx)
-{
- uint32_t USBx_BASE = (uint32_t)USBx;
- uint32_t tmpreg;
-
- tmpreg = USBx_DEVICE->DAINT;
- tmpreg &= USBx_DEVICE->DAINTMSK;
-
- return ((tmpreg & 0xffff0000U) >> 16);
-}
-
-/**
- * @brief USB_ReadDevAllInEpInterrupt: return the USB device IN endpoints interrupt status
- * @param USBx Selected device
- * @retval USB Device IN EP interrupt status
- */
-uint32_t USB_ReadDevAllInEpInterrupt(USB_OTG_GlobalTypeDef *USBx)
-{
- uint32_t USBx_BASE = (uint32_t)USBx;
- uint32_t tmpreg;
-
- tmpreg = USBx_DEVICE->DAINT;
- tmpreg &= USBx_DEVICE->DAINTMSK;
-
- return ((tmpreg & 0xFFFFU));
-}
-
-/**
- * @brief Returns Device OUT EP Interrupt register
- * @param USBx Selected device
- * @param epnum endpoint number
- * This parameter can be a value from 0 to 15
- * @retval Device OUT EP Interrupt register
- */
-uint32_t USB_ReadDevOutEPInterrupt(USB_OTG_GlobalTypeDef *USBx, uint8_t epnum)
-{
- uint32_t USBx_BASE = (uint32_t)USBx;
- uint32_t tmpreg;
-
- tmpreg = USBx_OUTEP((uint32_t)epnum)->DOEPINT;
- tmpreg &= USBx_DEVICE->DOEPMSK;
-
- return tmpreg;
-}
-
-/**
- * @brief Returns Device IN EP Interrupt register
- * @param USBx Selected device
- * @param epnum endpoint number
- * This parameter can be a value from 0 to 15
- * @retval Device IN EP Interrupt register
- */
-uint32_t USB_ReadDevInEPInterrupt(USB_OTG_GlobalTypeDef *USBx, uint8_t epnum)
-{
- uint32_t USBx_BASE = (uint32_t)USBx;
- uint32_t tmpreg;
- uint32_t msk;
- uint32_t emp;
-
- msk = USBx_DEVICE->DIEPMSK;
- emp = USBx_DEVICE->DIEPEMPMSK;
- msk |= ((emp >> (epnum & EP_ADDR_MSK)) & 0x1U) << 7;
- tmpreg = USBx_INEP((uint32_t)epnum)->DIEPINT & msk;
-
- return tmpreg;
-}
-
-/**
- * @brief USB_ClearInterrupts: clear a USB interrupt
- * @param USBx Selected device
- * @param interrupt flag
- * @retval None
- */
-void USB_ClearInterrupts(USB_OTG_GlobalTypeDef *USBx, uint32_t interrupt)
-{
- USBx->GINTSTS |= interrupt;
-}
-
-/**
- * @brief Returns USB core mode
- * @param USBx Selected device
- * @retval return core mode : Host or Device
- * This parameter can be one of these values:
- * 0 : Host
- * 1 : Device
- */
-uint32_t USB_GetMode(USB_OTG_GlobalTypeDef *USBx)
-{
- return ((USBx->GINTSTS) & 0x1U);
-}
-
-/**
- * @brief Activate EP0 for Setup transactions
- * @param USBx Selected device
- * @retval HAL status
- */
-HAL_StatusTypeDef USB_ActivateSetup(USB_OTG_GlobalTypeDef *USBx)
-{
- uint32_t USBx_BASE = (uint32_t)USBx;
-
- /* Set the MPS of the IN EP0 to 64 bytes */
- USBx_INEP(0U)->DIEPCTL &= ~USB_OTG_DIEPCTL_MPSIZ;
-
- USBx_DEVICE->DCTL |= USB_OTG_DCTL_CGINAK;
-
- return HAL_OK;
-}
-
-/**
- * @brief Prepare the EP0 to start the first control setup
- * @param USBx Selected device
- * @param dma USB dma enabled or disabled
- * This parameter can be one of these values:
- * 0 : DMA feature not used
- * 1 : DMA feature used
- * @param psetup pointer to setup packet
- * @retval HAL status
- */
-HAL_StatusTypeDef USB_EP0_OutStart(USB_OTG_GlobalTypeDef *USBx, uint8_t dma, uint8_t *psetup)
-{
- uint32_t USBx_BASE = (uint32_t)USBx;
- uint32_t gSNPSiD = *(__IO uint32_t *)(&USBx->CID + 0x1U);
-
- if (gSNPSiD > USB_OTG_CORE_ID_300A)
- {
- if ((USBx_OUTEP(0U)->DOEPCTL & USB_OTG_DOEPCTL_EPENA) == USB_OTG_DOEPCTL_EPENA)
- {
- return HAL_OK;
- }
- }
-
- USBx_OUTEP(0U)->DOEPTSIZ = 0U;
- USBx_OUTEP(0U)->DOEPTSIZ |= (USB_OTG_DOEPTSIZ_PKTCNT & (1U << 19));
- USBx_OUTEP(0U)->DOEPTSIZ |= (3U * 8U);
- USBx_OUTEP(0U)->DOEPTSIZ |= USB_OTG_DOEPTSIZ_STUPCNT;
-
- if (dma == 1U)
- {
- USBx_OUTEP(0U)->DOEPDMA = (uint32_t)psetup;
- /* EP enable */
- USBx_OUTEP(0U)->DOEPCTL |= USB_OTG_DOEPCTL_EPENA | USB_OTG_DOEPCTL_USBAEP;
- }
-
- return HAL_OK;
-}
-
-/**
- * @brief Reset the USB Core (needed after USB clock settings change)
- * @param USBx Selected device
- * @retval HAL status
- */
-static HAL_StatusTypeDef USB_CoreReset(USB_OTG_GlobalTypeDef *USBx)
-{
- __IO uint32_t count = 0U;
-
- /* Wait for AHB master IDLE state. */
- do
- {
- count++;
-
- if (count > 200000U)
- {
- return HAL_TIMEOUT;
- }
- } while ((USBx->GRSTCTL & USB_OTG_GRSTCTL_AHBIDL) == 0U);
-
- /* Core Soft Reset */
- count = 0U;
- USBx->GRSTCTL |= USB_OTG_GRSTCTL_CSRST;
-
- do
- {
- count++;
-
- if (count > 200000U)
- {
- return HAL_TIMEOUT;
- }
- } while ((USBx->GRSTCTL & USB_OTG_GRSTCTL_CSRST) == USB_OTG_GRSTCTL_CSRST);
-
- return HAL_OK;
-}
-
-/**
- * @brief USB_HostInit : Initializes the USB OTG controller registers
- * for Host mode
- * @param USBx Selected device
- * @param cfg pointer to a USB_OTG_CfgTypeDef structure that contains
- * the configuration information for the specified USBx peripheral.
- * @retval HAL status
- */
-HAL_StatusTypeDef USB_HostInit(USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef cfg)
-{
- HAL_StatusTypeDef ret = HAL_OK;
- uint32_t USBx_BASE = (uint32_t)USBx;
- uint32_t i;
-
- /* Restart the Phy Clock */
- USBx_PCGCCTL = 0U;
-
- /* Disable VBUS sensing */
- USBx->GCCFG &= ~(USB_OTG_GCCFG_VBDEN);
-
- /* Disable Battery chargin detector */
- USBx->GCCFG &= ~(USB_OTG_GCCFG_BCDEN);
-
-
- if ((USBx->CID & (0x1U << 8)) != 0U)
- {
- if (cfg.speed == USBH_FSLS_SPEED)
- {
- /* Force Device Enumeration to FS/LS mode only */
- USBx_HOST->HCFG |= USB_OTG_HCFG_FSLSS;
- }
- else
- {
- /* Set default Max speed support */
- USBx_HOST->HCFG &= ~(USB_OTG_HCFG_FSLSS);
- }
- }
- else
- {
- /* Set default Max speed support */
- USBx_HOST->HCFG &= ~(USB_OTG_HCFG_FSLSS);
- }
-
- /* Make sure the FIFOs are flushed. */
- if (USB_FlushTxFifo(USBx, 0x10U) != HAL_OK) /* all Tx FIFOs */
- {
- ret = HAL_ERROR;
- }
-
- if (USB_FlushRxFifo(USBx) != HAL_OK)
- {
- ret = HAL_ERROR;
- }
-
- /* Clear all pending HC Interrupts */
- for (i = 0U; i < cfg.Host_channels; i++)
- {
- USBx_HC(i)->HCINT = CLEAR_INTERRUPT_MASK;
- USBx_HC(i)->HCINTMSK = 0U;
- }
-
- /* Disable all interrupts. */
- USBx->GINTMSK = 0U;
-
- /* Clear any pending interrupts */
- USBx->GINTSTS = CLEAR_INTERRUPT_MASK;
-
- if ((USBx->CID & (0x1U << 8)) != 0U)
- {
- /* set Rx FIFO size */
- USBx->GRXFSIZ = 0x200U;
- USBx->DIEPTXF0_HNPTXFSIZ = (uint32_t)(((0x100U << 16) & USB_OTG_NPTXFD) | 0x200U);
- USBx->HPTXFSIZ = (uint32_t)(((0xE0U << 16) & USB_OTG_HPTXFSIZ_PTXFD) | 0x300U);
- }
- else
- {
- /* set Rx FIFO size */
- USBx->GRXFSIZ = 0x80U;
- USBx->DIEPTXF0_HNPTXFSIZ = (uint32_t)(((0x60U << 16) & USB_OTG_NPTXFD) | 0x80U);
- USBx->HPTXFSIZ = (uint32_t)(((0x40U << 16)& USB_OTG_HPTXFSIZ_PTXFD) | 0xE0U);
- }
-
- /* Enable the common interrupts */
- if (cfg.dma_enable == 0U)
- {
- USBx->GINTMSK |= USB_OTG_GINTMSK_RXFLVLM;
- }
-
- /* Enable interrupts matching to the Host mode ONLY */
- USBx->GINTMSK |= (USB_OTG_GINTMSK_PRTIM | USB_OTG_GINTMSK_HCIM | \
- USB_OTG_GINTMSK_SOFM | USB_OTG_GINTSTS_DISCINT | \
- USB_OTG_GINTMSK_PXFRM_IISOOXFRM | USB_OTG_GINTMSK_WUIM);
-
- return ret;
-}
-
-/**
- * @brief USB_InitFSLSPClkSel : Initializes the FSLSPClkSel field of the
- * HCFG register on the PHY type and set the right frame interval
- * @param USBx Selected device
- * @param freq clock frequency
- * This parameter can be one of these values:
- * HCFG_48_MHZ : Full Speed 48 MHz Clock
- * HCFG_6_MHZ : Low Speed 6 MHz Clock
- * @retval HAL status
- */
-HAL_StatusTypeDef USB_InitFSLSPClkSel(USB_OTG_GlobalTypeDef *USBx, uint8_t freq)
-{
- uint32_t USBx_BASE = (uint32_t)USBx;
-
- USBx_HOST->HCFG &= ~(USB_OTG_HCFG_FSLSPCS);
- USBx_HOST->HCFG |= (uint32_t)freq & USB_OTG_HCFG_FSLSPCS;
-
- if (freq == HCFG_48_MHZ)
- {
- USBx_HOST->HFIR = HFIR_48_MHZ;
- }
- else if (freq == HCFG_6_MHZ)
- {
- USBx_HOST->HFIR = HFIR_6_MHZ;
- }
- else
- {
- return HAL_ERROR;
- }
-
- return HAL_OK;
-}
-
-/**
- * @brief USB_OTG_ResetPort : Reset Host Port
- * @param USBx Selected device
- * @retval HAL status
- * @note (1)The application must wait at least 10 ms
- * before clearing the reset bit.
- */
-HAL_StatusTypeDef USB_ResetPort(USB_OTG_GlobalTypeDef *USBx)
-{
- uint32_t USBx_BASE = (uint32_t)USBx;
-
- __IO uint32_t hprt0 = 0U;
-
- hprt0 = USBx_HPRT0;
-
- hprt0 &= ~(USB_OTG_HPRT_PENA | USB_OTG_HPRT_PCDET |
- USB_OTG_HPRT_PENCHNG | USB_OTG_HPRT_POCCHNG);
-
- USBx_HPRT0 = (USB_OTG_HPRT_PRST | hprt0);
- HAL_Delay(100U); /* See Note #1 */
- USBx_HPRT0 = ((~USB_OTG_HPRT_PRST) & hprt0);
- HAL_Delay(10U);
-
- return HAL_OK;
-}
-
-/**
- * @brief USB_DriveVbus : activate or de-activate vbus
- * @param state VBUS state
- * This parameter can be one of these values:
- * 0 : Deactivate VBUS
- * 1 : Activate VBUS
- * @retval HAL status
- */
-HAL_StatusTypeDef USB_DriveVbus(USB_OTG_GlobalTypeDef *USBx, uint8_t state)
-{
- uint32_t USBx_BASE = (uint32_t)USBx;
- __IO uint32_t hprt0 = 0U;
-
- hprt0 = USBx_HPRT0;
-
- hprt0 &= ~(USB_OTG_HPRT_PENA | USB_OTG_HPRT_PCDET |
- USB_OTG_HPRT_PENCHNG | USB_OTG_HPRT_POCCHNG);
-
- if (((hprt0 & USB_OTG_HPRT_PPWR) == 0U) && (state == 1U))
- {
- USBx_HPRT0 = (USB_OTG_HPRT_PPWR | hprt0);
- }
- if (((hprt0 & USB_OTG_HPRT_PPWR) == USB_OTG_HPRT_PPWR) && (state == 0U))
- {
- USBx_HPRT0 = ((~USB_OTG_HPRT_PPWR) & hprt0);
- }
- return HAL_OK;
-}
-
-/**
- * @brief Return Host Core speed
- * @param USBx Selected device
- * @retval speed : Host speed
- * This parameter can be one of these values:
- * @arg HCD_SPEED_HIGH: High speed mode
- * @arg HCD_SPEED_FULL: Full speed mode
- * @arg HCD_SPEED_LOW: Low speed mode
- */
-uint32_t USB_GetHostSpeed(USB_OTG_GlobalTypeDef *USBx)
-{
- uint32_t USBx_BASE = (uint32_t)USBx;
- __IO uint32_t hprt0 = 0U;
-
- hprt0 = USBx_HPRT0;
- return ((hprt0 & USB_OTG_HPRT_PSPD) >> 17);
-}
-
-/**
- * @brief Return Host Current Frame number
- * @param USBx Selected device
- * @retval current frame number
- */
-uint32_t USB_GetCurrentFrame(USB_OTG_GlobalTypeDef *USBx)
-{
- uint32_t USBx_BASE = (uint32_t)USBx;
-
- return (USBx_HOST->HFNUM & USB_OTG_HFNUM_FRNUM);
-}
-
-/**
- * @brief Initialize a host channel
- * @param USBx Selected device
- * @param ch_num Channel number
- * This parameter can be a value from 1 to 15
- * @param epnum Endpoint number
- * This parameter can be a value from 1 to 15
- * @param dev_address Current device address
- * This parameter can be a value from 0 to 255
- * @param speed Current device speed
- * This parameter can be one of these values:
- * @arg USB_OTG_SPEED_HIGH: High speed mode
- * @arg USB_OTG_SPEED_FULL: Full speed mode
- * @arg USB_OTG_SPEED_LOW: Low speed mode
- * @param ep_type Endpoint Type
- * This parameter can be one of these values:
- * @arg EP_TYPE_CTRL: Control type
- * @arg EP_TYPE_ISOC: Isochronous type
- * @arg EP_TYPE_BULK: Bulk type
- * @arg EP_TYPE_INTR: Interrupt type
- * @param mps Max Packet Size
- * This parameter can be a value from 0 to 32K
- * @retval HAL state
- */
-HAL_StatusTypeDef USB_HC_Init(USB_OTG_GlobalTypeDef *USBx, uint8_t ch_num,
- uint8_t epnum, uint8_t dev_address, uint8_t speed,
- uint8_t ep_type, uint16_t mps)
-{
- HAL_StatusTypeDef ret = HAL_OK;
- uint32_t USBx_BASE = (uint32_t)USBx;
- uint32_t HCcharEpDir;
- uint32_t HCcharLowSpeed;
- uint32_t HostCoreSpeed;
-
- /* Clear old interrupt conditions for this host channel. */
- USBx_HC((uint32_t)ch_num)->HCINT = CLEAR_INTERRUPT_MASK;
-
- /* Enable channel interrupts required for this transfer. */
- switch (ep_type)
- {
- case EP_TYPE_CTRL:
- case EP_TYPE_BULK:
- USBx_HC((uint32_t)ch_num)->HCINTMSK = USB_OTG_HCINTMSK_XFRCM |
- USB_OTG_HCINTMSK_STALLM |
- USB_OTG_HCINTMSK_TXERRM |
- USB_OTG_HCINTMSK_DTERRM |
- USB_OTG_HCINTMSK_AHBERR |
- USB_OTG_HCINTMSK_NAKM;
-
- if ((epnum & 0x80U) == 0x80U)
- {
- USBx_HC((uint32_t)ch_num)->HCINTMSK |= USB_OTG_HCINTMSK_BBERRM;
- }
- else
- {
- if ((USBx->CID & (0x1U << 8)) != 0U)
- {
- USBx_HC((uint32_t)ch_num)->HCINTMSK |= USB_OTG_HCINTMSK_NYET |
- USB_OTG_HCINTMSK_ACKM;
- }
- }
- break;
-
- case EP_TYPE_INTR:
- USBx_HC((uint32_t)ch_num)->HCINTMSK = USB_OTG_HCINTMSK_XFRCM |
- USB_OTG_HCINTMSK_STALLM |
- USB_OTG_HCINTMSK_TXERRM |
- USB_OTG_HCINTMSK_DTERRM |
- USB_OTG_HCINTMSK_NAKM |
- USB_OTG_HCINTMSK_AHBERR |
- USB_OTG_HCINTMSK_FRMORM;
-
- if ((epnum & 0x80U) == 0x80U)
- {
- USBx_HC((uint32_t)ch_num)->HCINTMSK |= USB_OTG_HCINTMSK_BBERRM;
- }
-
- break;
-
- case EP_TYPE_ISOC:
- USBx_HC((uint32_t)ch_num)->HCINTMSK = USB_OTG_HCINTMSK_XFRCM |
- USB_OTG_HCINTMSK_ACKM |
- USB_OTG_HCINTMSK_AHBERR |
- USB_OTG_HCINTMSK_FRMORM;
-
- if ((epnum & 0x80U) == 0x80U)
- {
- USBx_HC((uint32_t)ch_num)->HCINTMSK |= (USB_OTG_HCINTMSK_TXERRM | USB_OTG_HCINTMSK_BBERRM);
- }
- break;
-
- default:
- ret = HAL_ERROR;
- break;
- }
-
- /* Enable host channel Halt interrupt */
- USBx_HC((uint32_t)ch_num)->HCINTMSK |= USB_OTG_HCINTMSK_CHHM;
-
- /* Enable the top level host channel interrupt. */
- USBx_HOST->HAINTMSK |= 1UL << (ch_num & 0xFU);
-
- /* Make sure host channel interrupts are enabled. */
- USBx->GINTMSK |= USB_OTG_GINTMSK_HCIM;
-
- /* Program the HCCHAR register */
- if ((epnum & 0x80U) == 0x80U)
- {
- HCcharEpDir = (0x1U << 15) & USB_OTG_HCCHAR_EPDIR;
- }
- else
- {
- HCcharEpDir = 0U;
- }
-
- HostCoreSpeed = USB_GetHostSpeed(USBx);
-
- /* LS device plugged to HUB */
- if ((speed == HPRT0_PRTSPD_LOW_SPEED) && (HostCoreSpeed != HPRT0_PRTSPD_LOW_SPEED))
- {
- HCcharLowSpeed = (0x1U << 17) & USB_OTG_HCCHAR_LSDEV;
- }
- else
- {
- HCcharLowSpeed = 0U;
- }
-
- USBx_HC((uint32_t)ch_num)->HCCHAR = (((uint32_t)dev_address << 22) & USB_OTG_HCCHAR_DAD) |
- ((((uint32_t)epnum & 0x7FU) << 11) & USB_OTG_HCCHAR_EPNUM) |
- (((uint32_t)ep_type << 18) & USB_OTG_HCCHAR_EPTYP) |
- ((uint32_t)mps & USB_OTG_HCCHAR_MPSIZ) |
- USB_OTG_HCCHAR_MC_0 | HCcharEpDir | HCcharLowSpeed;
-
- if ((ep_type == EP_TYPE_INTR) || (ep_type == EP_TYPE_ISOC))
- {
- USBx_HC((uint32_t)ch_num)->HCCHAR |= USB_OTG_HCCHAR_ODDFRM;
- }
-
- return ret;
-}
-
-/**
- * @brief Start a transfer over a host channel
- * @param USBx Selected device
- * @param hc pointer to host channel structure
- * @param dma USB dma enabled or disabled
- * This parameter can be one of these values:
- * 0 : DMA feature not used
- * 1 : DMA feature used
- * @retval HAL state
- */
-HAL_StatusTypeDef USB_HC_StartXfer(USB_OTG_GlobalTypeDef *USBx, USB_OTG_HCTypeDef *hc, uint8_t dma)
-{
- uint32_t USBx_BASE = (uint32_t)USBx;
- uint32_t ch_num = (uint32_t)hc->ch_num;
- __IO uint32_t tmpreg;
- uint8_t is_oddframe;
- uint16_t len_words;
- uint16_t num_packets;
- uint16_t max_hc_pkt_count = HC_MAX_PKT_CNT;
-
- if (((USBx->CID & (0x1U << 8)) != 0U) && (hc->speed == USBH_HS_SPEED))
- {
- /* in DMA mode host Core automatically issues ping in case of NYET/NAK */
- if ((dma == 1U) && ((hc->ep_type == EP_TYPE_CTRL) || (hc->ep_type == EP_TYPE_BULK)))
- {
- USBx_HC((uint32_t)ch_num)->HCINTMSK &= ~(USB_OTG_HCINTMSK_NYET |
- USB_OTG_HCINTMSK_ACKM |
- USB_OTG_HCINTMSK_NAKM);
- }
-
- if ((dma == 0U) && (hc->do_ping == 1U))
- {
- (void)USB_DoPing(USBx, hc->ch_num);
- return HAL_OK;
- }
-
- }
-
- /* Compute the expected number of packets associated to the transfer */
- if (hc->xfer_len > 0U)
- {
- num_packets = (uint16_t)((hc->xfer_len + hc->max_packet - 1U) / hc->max_packet);
-
- if (num_packets > max_hc_pkt_count)
- {
- num_packets = max_hc_pkt_count;
- hc->XferSize = (uint32_t)num_packets * hc->max_packet;
- }
- }
- else
- {
- num_packets = 1U;
- }
-
- /*
- * For IN channel HCTSIZ.XferSize is expected to be an integer multiple of
- * max_packet size.
- */
- if (hc->ep_is_in != 0U)
- {
- hc->XferSize = (uint32_t)num_packets * hc->max_packet;
- }
- else
- {
- hc->XferSize = hc->xfer_len;
- }
-
- /* Initialize the HCTSIZn register */
- USBx_HC(ch_num)->HCTSIZ = (hc->XferSize & USB_OTG_HCTSIZ_XFRSIZ) |
- (((uint32_t)num_packets << 19) & USB_OTG_HCTSIZ_PKTCNT) |
- (((uint32_t)hc->data_pid << 29) & USB_OTG_HCTSIZ_DPID);
-
- if (dma != 0U)
- {
- /* xfer_buff MUST be 32-bits aligned */
- USBx_HC(ch_num)->HCDMA = (uint32_t)hc->xfer_buff;
- }
-
- is_oddframe = (((uint32_t)USBx_HOST->HFNUM & 0x01U) != 0U) ? 0U : 1U;
- USBx_HC(ch_num)->HCCHAR &= ~USB_OTG_HCCHAR_ODDFRM;
- USBx_HC(ch_num)->HCCHAR |= (uint32_t)is_oddframe << 29;
-
- /* Set host channel enable */
- tmpreg = USBx_HC(ch_num)->HCCHAR;
- tmpreg &= ~USB_OTG_HCCHAR_CHDIS;
-
- /* make sure to set the correct ep direction */
- if (hc->ep_is_in != 0U)
- {
- tmpreg |= USB_OTG_HCCHAR_EPDIR;
- }
- else
- {
- tmpreg &= ~USB_OTG_HCCHAR_EPDIR;
- }
- tmpreg |= USB_OTG_HCCHAR_CHENA;
- USBx_HC(ch_num)->HCCHAR = tmpreg;
-
- if (dma != 0U) /* dma mode */
- {
- return HAL_OK;
- }
-
- if ((hc->ep_is_in == 0U) && (hc->xfer_len > 0U))
- {
- switch (hc->ep_type)
- {
- /* Non periodic transfer */
- case EP_TYPE_CTRL:
- case EP_TYPE_BULK:
-
- len_words = (uint16_t)((hc->xfer_len + 3U) / 4U);
-
- /* check if there is enough space in FIFO space */
- if (len_words > (USBx->HNPTXSTS & 0xFFFFU))
- {
- /* need to process data in nptxfempty interrupt */
- USBx->GINTMSK |= USB_OTG_GINTMSK_NPTXFEM;
- }
- break;
-
- /* Periodic transfer */
- case EP_TYPE_INTR:
- case EP_TYPE_ISOC:
- len_words = (uint16_t)((hc->xfer_len + 3U) / 4U);
- /* check if there is enough space in FIFO space */
- if (len_words > (USBx_HOST->HPTXSTS & 0xFFFFU)) /* split the transfer */
- {
- /* need to process data in ptxfempty interrupt */
- USBx->GINTMSK |= USB_OTG_GINTMSK_PTXFEM;
- }
- break;
-
- default:
- break;
- }
-
- /* Write packet into the Tx FIFO. */
- (void)USB_WritePacket(USBx, hc->xfer_buff, hc->ch_num, (uint16_t)hc->xfer_len, 0);
- }
-
- return HAL_OK;
-}
-
-/**
- * @brief Read all host channel interrupts status
- * @param USBx Selected device
- * @retval HAL state
- */
-uint32_t USB_HC_ReadInterrupt(USB_OTG_GlobalTypeDef *USBx)
-{
- uint32_t USBx_BASE = (uint32_t)USBx;
-
- return ((USBx_HOST->HAINT) & 0xFFFFU);
-}
-
-/**
- * @brief Halt a host channel
- * @param USBx Selected device
- * @param hc_num Host Channel number
- * This parameter can be a value from 1 to 15
- * @retval HAL state
- */
-HAL_StatusTypeDef USB_HC_Halt(USB_OTG_GlobalTypeDef *USBx, uint8_t hc_num)
-{
- uint32_t USBx_BASE = (uint32_t)USBx;
- uint32_t hcnum = (uint32_t)hc_num;
- __IO uint32_t count = 0U;
- uint32_t HcEpType = (USBx_HC(hcnum)->HCCHAR & USB_OTG_HCCHAR_EPTYP) >> 18;
- uint32_t ChannelEna = (USBx_HC(hcnum)->HCCHAR & USB_OTG_HCCHAR_CHENA) >> 31;
-
- if (((USBx->GAHBCFG & USB_OTG_GAHBCFG_DMAEN) == USB_OTG_GAHBCFG_DMAEN) &&
- (ChannelEna == 0U))
- {
- return HAL_OK;
- }
-
- /* Check for space in the request queue to issue the halt. */
- if ((HcEpType == HCCHAR_CTRL) || (HcEpType == HCCHAR_BULK))
- {
- USBx_HC(hcnum)->HCCHAR |= USB_OTG_HCCHAR_CHDIS;
-
- if ((USBx->GAHBCFG & USB_OTG_GAHBCFG_DMAEN) == 0U)
- {
- if ((USBx->HNPTXSTS & (0xFFU << 16)) == 0U)
- {
- USBx_HC(hcnum)->HCCHAR &= ~USB_OTG_HCCHAR_CHENA;
- USBx_HC(hcnum)->HCCHAR |= USB_OTG_HCCHAR_CHENA;
- do
- {
- count++;
-
- if (count > 1000U)
- {
- break;
- }
- } while ((USBx_HC(hcnum)->HCCHAR & USB_OTG_HCCHAR_CHENA) == USB_OTG_HCCHAR_CHENA);
- }
- else
- {
- USBx_HC(hcnum)->HCCHAR |= USB_OTG_HCCHAR_CHENA;
- }
- }
- }
- else
- {
- USBx_HC(hcnum)->HCCHAR |= USB_OTG_HCCHAR_CHDIS;
-
- if ((USBx_HOST->HPTXSTS & (0xFFU << 16)) == 0U)
- {
- USBx_HC(hcnum)->HCCHAR &= ~USB_OTG_HCCHAR_CHENA;
- USBx_HC(hcnum)->HCCHAR |= USB_OTG_HCCHAR_CHENA;
- do
- {
- count++;
-
- if (count > 1000U)
- {
- break;
- }
- } while ((USBx_HC(hcnum)->HCCHAR & USB_OTG_HCCHAR_CHENA) == USB_OTG_HCCHAR_CHENA);
- }
- else
- {
- USBx_HC(hcnum)->HCCHAR |= USB_OTG_HCCHAR_CHENA;
- }
- }
-
- return HAL_OK;
-}
-
-/**
- * @brief Initiate Do Ping protocol
- * @param USBx Selected device
- * @param hc_num Host Channel number
- * This parameter can be a value from 1 to 15
- * @retval HAL state
- */
-HAL_StatusTypeDef USB_DoPing(USB_OTG_GlobalTypeDef *USBx, uint8_t ch_num)
-{
- uint32_t USBx_BASE = (uint32_t)USBx;
- uint32_t chnum = (uint32_t)ch_num;
- uint32_t num_packets = 1U;
- uint32_t tmpreg;
-
- USBx_HC(chnum)->HCTSIZ = ((num_packets << 19) & USB_OTG_HCTSIZ_PKTCNT) |
- USB_OTG_HCTSIZ_DOPING;
-
- /* Set host channel enable */
- tmpreg = USBx_HC(chnum)->HCCHAR;
- tmpreg &= ~USB_OTG_HCCHAR_CHDIS;
- tmpreg |= USB_OTG_HCCHAR_CHENA;
- USBx_HC(chnum)->HCCHAR = tmpreg;
-
- return HAL_OK;
-}
-
-/**
- * @brief Stop Host Core
- * @param USBx Selected device
- * @retval HAL state
- */
-HAL_StatusTypeDef USB_StopHost(USB_OTG_GlobalTypeDef *USBx)
-{
- HAL_StatusTypeDef ret = HAL_OK;
- uint32_t USBx_BASE = (uint32_t)USBx;
- __IO uint32_t count = 0U;
- uint32_t value;
- uint32_t i;
-
- (void)USB_DisableGlobalInt(USBx);
-
- /* Flush USB FIFO */
- if (USB_FlushTxFifo(USBx, 0x10U) != HAL_OK) /* all Tx FIFOs */
- {
- ret = HAL_ERROR;
- }
-
- if (USB_FlushRxFifo(USBx) != HAL_OK)
- {
- ret = HAL_ERROR;
- }
-
- /* Flush out any leftover queued requests. */
- for (i = 0U; i <= 15U; i++)
- {
- value = USBx_HC(i)->HCCHAR;
- value |= USB_OTG_HCCHAR_CHDIS;
- value &= ~USB_OTG_HCCHAR_CHENA;
- value &= ~USB_OTG_HCCHAR_EPDIR;
- USBx_HC(i)->HCCHAR = value;
- }
-
- /* Halt all channels to put them into a known state. */
- for (i = 0U; i <= 15U; i++)
- {
- value = USBx_HC(i)->HCCHAR;
- value |= USB_OTG_HCCHAR_CHDIS;
- value |= USB_OTG_HCCHAR_CHENA;
- value &= ~USB_OTG_HCCHAR_EPDIR;
- USBx_HC(i)->HCCHAR = value;
-
- do
- {
- count++;
-
- if (count > 1000U)
- {
- break;
- }
- } while ((USBx_HC(i)->HCCHAR & USB_OTG_HCCHAR_CHENA) == USB_OTG_HCCHAR_CHENA);
- }
-
- /* Clear any pending Host interrupts */
- USBx_HOST->HAINT = CLEAR_INTERRUPT_MASK;
- USBx->GINTSTS = CLEAR_INTERRUPT_MASK;
-
- (void)USB_EnableGlobalInt(USBx);
-
- return ret;
-}
-
-/**
- * @brief USB_ActivateRemoteWakeup active remote wakeup signalling
- * @param USBx Selected device
- * @retval HAL status
- */
-HAL_StatusTypeDef USB_ActivateRemoteWakeup(USB_OTG_GlobalTypeDef *USBx)
-{
- uint32_t USBx_BASE = (uint32_t)USBx;
-
- if ((USBx_DEVICE->DSTS & USB_OTG_DSTS_SUSPSTS) == USB_OTG_DSTS_SUSPSTS)
- {
- /* active Remote wakeup signalling */
- USBx_DEVICE->DCTL |= USB_OTG_DCTL_RWUSIG;
- }
-
- return HAL_OK;
-}
-
-/**
- * @brief USB_DeActivateRemoteWakeup de-active remote wakeup signalling
- * @param USBx Selected device
- * @retval HAL status
- */
-HAL_StatusTypeDef USB_DeActivateRemoteWakeup(USB_OTG_GlobalTypeDef *USBx)
-{
- uint32_t USBx_BASE = (uint32_t)USBx;
-
- /* active Remote wakeup signalling */
- USBx_DEVICE->DCTL &= ~(USB_OTG_DCTL_RWUSIG);
-
- return HAL_OK;
-}
-#endif /* defined (USB_OTG_FS) || defined (USB_OTG_HS) */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-#endif /* defined (USB_OTG_FS) || defined (USB_OTG_HS) */
-#endif /* defined (HAL_PCD_MODULE_ENABLED) || defined (HAL_HCD_MODULE_ENABLED) */
-
-/**
- * @}
- */
diff --git a/LED_Ring.ioc b/LED_Ring.ioc
index 4e6391f..f07f232 100644
--- a/LED_Ring.ioc
+++ b/LED_Ring.ioc
@@ -10,13 +10,13 @@ Dma.TIM2_CH1.0.Direction=DMA_MEMORY_TO_PERIPH
Dma.TIM2_CH1.0.EventEnable=DISABLE
Dma.TIM2_CH1.0.FIFOMode=DMA_FIFOMODE_DISABLE
Dma.TIM2_CH1.0.Instance=DMA1_Stream0
-Dma.TIM2_CH1.0.MemDataAlignment=DMA_MDATAALIGN_HALFWORD
+Dma.TIM2_CH1.0.MemDataAlignment=DMA_MDATAALIGN_WORD
Dma.TIM2_CH1.0.MemInc=DMA_MINC_ENABLE
Dma.TIM2_CH1.0.Mode=DMA_NORMAL
-Dma.TIM2_CH1.0.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD
+Dma.TIM2_CH1.0.PeriphDataAlignment=DMA_PDATAALIGN_WORD
Dma.TIM2_CH1.0.PeriphInc=DMA_PINC_DISABLE
Dma.TIM2_CH1.0.Polarity=HAL_DMAMUX_REQ_GEN_RISING
-Dma.TIM2_CH1.0.Priority=DMA_PRIORITY_LOW
+Dma.TIM2_CH1.0.Priority=DMA_PRIORITY_VERY_HIGH
Dma.TIM2_CH1.0.RequestNumber=1
Dma.TIM2_CH1.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber
Dma.TIM2_CH1.0.SignalID=NONE
@@ -28,13 +28,13 @@ Dma.TIM3_CH1.1.Direction=DMA_MEMORY_TO_PERIPH
Dma.TIM3_CH1.1.EventEnable=DISABLE
Dma.TIM3_CH1.1.FIFOMode=DMA_FIFOMODE_DISABLE
Dma.TIM3_CH1.1.Instance=DMA1_Stream1
-Dma.TIM3_CH1.1.MemDataAlignment=DMA_MDATAALIGN_HALFWORD
+Dma.TIM3_CH1.1.MemDataAlignment=DMA_MDATAALIGN_WORD
Dma.TIM3_CH1.1.MemInc=DMA_MINC_ENABLE
Dma.TIM3_CH1.1.Mode=DMA_NORMAL
-Dma.TIM3_CH1.1.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD
+Dma.TIM3_CH1.1.PeriphDataAlignment=DMA_PDATAALIGN_WORD
Dma.TIM3_CH1.1.PeriphInc=DMA_PINC_DISABLE
Dma.TIM3_CH1.1.Polarity=HAL_DMAMUX_REQ_GEN_RISING
-Dma.TIM3_CH1.1.Priority=DMA_PRIORITY_LOW
+Dma.TIM3_CH1.1.Priority=DMA_PRIORITY_VERY_HIGH
Dma.TIM3_CH1.1.RequestNumber=1
Dma.TIM3_CH1.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber
Dma.TIM3_CH1.1.SignalID=NONE
@@ -46,13 +46,13 @@ Dma.TIM4_CH1.2.Direction=DMA_MEMORY_TO_PERIPH
Dma.TIM4_CH1.2.EventEnable=DISABLE
Dma.TIM4_CH1.2.FIFOMode=DMA_FIFOMODE_DISABLE
Dma.TIM4_CH1.2.Instance=DMA1_Stream2
-Dma.TIM4_CH1.2.MemDataAlignment=DMA_MDATAALIGN_HALFWORD
+Dma.TIM4_CH1.2.MemDataAlignment=DMA_MDATAALIGN_WORD
Dma.TIM4_CH1.2.MemInc=DMA_MINC_ENABLE
Dma.TIM4_CH1.2.Mode=DMA_NORMAL
-Dma.TIM4_CH1.2.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD
+Dma.TIM4_CH1.2.PeriphDataAlignment=DMA_PDATAALIGN_WORD
Dma.TIM4_CH1.2.PeriphInc=DMA_PINC_DISABLE
Dma.TIM4_CH1.2.Polarity=HAL_DMAMUX_REQ_GEN_RISING
-Dma.TIM4_CH1.2.Priority=DMA_PRIORITY_LOW
+Dma.TIM4_CH1.2.Priority=DMA_PRIORITY_VERY_HIGH
Dma.TIM4_CH1.2.RequestNumber=1
Dma.TIM4_CH1.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber
Dma.TIM4_CH1.2.SignalID=NONE
@@ -60,24 +60,21 @@ Dma.TIM4_CH1.2.SyncEnable=DISABLE
Dma.TIM4_CH1.2.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT
Dma.TIM4_CH1.2.SyncRequestNumber=1
Dma.TIM4_CH1.2.SyncSignalID=NONE
-ETH.IPParameters=MediaInterface
-ETH.MediaInterface=HAL_ETH_RMII_MODE
File.Version=6
+GPIO.groupedBy=Group By Peripherals
KeepUserPlacement=false
Mcu.CPN=STM32H743ZIT6
Mcu.Family=STM32H7
Mcu.IP0=CORTEX_M7
Mcu.IP1=DMA
-Mcu.IP10=USB_OTG_FS
-Mcu.IP2=ETH
-Mcu.IP3=NVIC
-Mcu.IP4=RCC
-Mcu.IP5=SYS
-Mcu.IP6=TIM2
-Mcu.IP7=TIM3
-Mcu.IP8=TIM4
-Mcu.IP9=USART3
-Mcu.IPNb=11
+Mcu.IP2=NVIC
+Mcu.IP3=RCC
+Mcu.IP4=SYS
+Mcu.IP5=TIM2
+Mcu.IP6=TIM3
+Mcu.IP7=TIM4
+Mcu.IP8=USART3
+Mcu.IPNb=9
Mcu.Name=STM32H743ZITx
Mcu.Package=LQFP144
Mcu.Pin0=PC13
@@ -123,6 +120,7 @@ NVIC.DMA1_Stream0_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:true
NVIC.DMA1_Stream1_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:true
NVIC.DMA1_Stream2_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:true
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
+NVIC.EXTI15_10_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
NVIC.ForceEnableDMAVector=true
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
@@ -134,45 +132,36 @@ NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:false
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
PA0.Signal=S_TIM2_CH1_ETR
PA1.Locked=true
-PA1.Mode=RMII
PA1.Signal=ETH_REF_CLK
PA11.Locked=true
-PA11.Mode=Device_Only
PA11.Signal=USB_OTG_FS_DM
PA12.Locked=true
-PA12.Mode=Device_Only
PA12.Signal=USB_OTG_FS_DP
PA2.Locked=true
-PA2.Mode=RMII
PA2.Signal=ETH_MDIO
PA6.Signal=S_TIM3_CH1
PA7.Locked=true
-PA7.Mode=RMII
PA7.Signal=ETH_CRS_DV
PA8.Locked=true
-PA8.Mode=Activate_SOF_FS
PA8.Signal=USB_OTG_FS_SOF
PA9.Locked=true
-PA9.Mode=Activate_VBUS
PA9.Signal=USB_OTG_FS_VBUS
PB0.GPIOParameters=GPIO_Label
PB0.GPIO_Label=LD1 [Green Led]
PB0.Locked=true
PB0.Signal=GPIO_Output
PB13.Locked=true
-PB13.Mode=RMII
PB13.Signal=ETH_TXD1
PB14.GPIOParameters=GPIO_Label
PB14.GPIO_Label=LD3 [Red Led]
PB14.Locked=true
PB14.Signal=GPIO_Output
PC1.Locked=true
-PC1.Mode=RMII
PC1.Signal=ETH_MDC
PC13.GPIOParameters=GPIO_Label
-PC13.GPIO_Label=B1 [Blue PushButton]
+PC13.GPIO_Label=B1 [User Button]
PC13.Locked=true
-PC13.Signal=GPIO_Input
+PC13.Signal=GPXTI13
PC14-OSC32_IN\ (OSC32_IN).Locked=true
PC14-OSC32_IN\ (OSC32_IN).Mode=LSE-External-Oscillator
PC14-OSC32_IN\ (OSC32_IN).Signal=RCC_OSC32_IN
@@ -180,10 +169,8 @@ PC15-OSC32_OUT\ (OSC32_OUT).Locked=true
PC15-OSC32_OUT\ (OSC32_OUT).Mode=LSE-External-Oscillator
PC15-OSC32_OUT\ (OSC32_OUT).Signal=RCC_OSC32_OUT
PC4.Locked=true
-PC4.Mode=RMII
PC4.Signal=ETH_RXD0
PC5.Locked=true
-PC5.Mode=RMII
PC5.Signal=ETH_RXD1
PD10.GPIOParameters=GPIO_Label
PD10.GPIO_Label=USB_OTG_FS_PWR_EN
@@ -205,10 +192,8 @@ PE1.GPIO_Label=LD2 [Yellow Led]
PE1.Locked=true
PE1.Signal=GPIO_Output
PG11.Locked=true
-PG11.Mode=RMII
PG11.Signal=ETH_TX_EN
PG13.Locked=true
-PG13.Mode=RMII
PG13.Signal=ETH_TXD0
PG7.GPIOParameters=GPIO_Label
PG7.GPIO_Label=USB_OTG_FS_OVCR
@@ -250,7 +235,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_DMA_Init-DMA-false-HAL-true,4-MX_USART3_UART_Init-USART3-false-HAL-true,5-MX_USB_OTG_FS_PCD_Init-USB_OTG_FS-false-HAL-true,6-MX_TIM2_Init-TIM2-false-HAL-true,7-MX_ETH_Init-ETH-false-HAL-true,8-MX_TIM3_Init-TIM3-false-HAL-true,9-MX_TIM4_Init-TIM4-false-HAL-true,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true
+ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_USART3_UART_Init-USART3-false-HAL-true,5-MX_USB_OTG_FS_PCD_Init-USB_OTG_FS-false-HAL-true,5-MX_TIM2_Init-TIM2-false-HAL-true,6-MX_TIM3_Init-TIM3-false-HAL-true,7-MX_TIM4_Init-TIM4-false-HAL-true,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true
RCC.ADCFreq_Value=16125000
RCC.AHB12Freq_Value=64000000
RCC.AHB4Freq_Value=64000000
@@ -287,7 +272,7 @@ RCC.HRTIMFreq_Value=64000000
RCC.HSE_VALUE=8000000
RCC.I2C123Freq_Value=64000000
RCC.I2C4Freq_Value=64000000
-RCC.IPParameters=ADCFreq_Value,AHB12Freq_Value,AHB4Freq_Value,APB1Freq_Value,APB2Freq_Value,APB3Freq_Value,APB4Freq_Value,AXIClockFreq_Value,CECFreq_Value,CKPERFreq_Value,CortexFreq_Value,CpuClockFreq_Value,D1CPREFreq_Value,DFSDMACLkFreq_Value,DFSDMFreq_Value,DIVM1,DIVN1,DIVP1Freq_Value,DIVP2Freq_Value,DIVP3Freq_Value,DIVQ1,DIVQ1Freq_Value,DIVQ2Freq_Value,DIVQ3Freq_Value,DIVR1Freq_Value,DIVR2Freq_Value,DIVR3Freq_Value,FDCANFreq_Value,FMCFreq_Value,FamilyName,HCLK3ClockFreq_Value,HCLKFreq_Value,HRTIMFreq_Value,HSE_VALUE,I2C123Freq_Value,I2C4Freq_Value,LPTIM1Freq_Value,LPTIM2Freq_Value,LPTIM345Freq_Value,LPUART1Freq_Value,LTDCFreq_Value,MCO1PinFreq_Value,MCO2PinFreq_Value,PLLFRACN,PWR_Regulator_Voltage_Scale,QSPIFreq_Value,RNGFreq_Value,RTCFreq_Value,SAI1Freq_Value,SAI23Freq_Value,SAI4AFreq_Value,SAI4BFreq_Value,SDMMCFreq_Value,SPDIFRXFreq_Value,SPI123Freq_Value,SPI45Freq_Value,SPI6Freq_Value,SWPMI1Freq_Value,SYSCLKFreq_VALUE,Tim1OutputFreq_Value,Tim2OutputFreq_Value,TraceFreq_Value,USART16Freq_Value,USART234578Freq_Value,USBFreq_Value,VCO1OutputFreq_Value,VCO2OutputFreq_Value,VCO3OutputFreq_Value,VCOInput1Freq_Value,VCOInput2Freq_Value,VCOInput3Freq_Value
+RCC.IPParameters=ADCFreq_Value,AHB12Freq_Value,AHB4Freq_Value,APB1Freq_Value,APB2Freq_Value,APB3Freq_Value,APB4Freq_Value,AXIClockFreq_Value,CECFreq_Value,CKPERFreq_Value,CortexFreq_Value,CpuClockFreq_Value,D1CPREFreq_Value,DFSDMACLkFreq_Value,DFSDMFreq_Value,DIVM1,DIVN1,DIVP1Freq_Value,DIVP2Freq_Value,DIVP3Freq_Value,DIVQ1,DIVQ1Freq_Value,DIVQ2Freq_Value,DIVQ3Freq_Value,DIVR1Freq_Value,DIVR2Freq_Value,DIVR3Freq_Value,FDCANFreq_Value,FMCFreq_Value,FamilyName,HCLK3ClockFreq_Value,HCLKFreq_Value,HRTIMFreq_Value,HSE_VALUE,I2C123Freq_Value,I2C4Freq_Value,LPTIM1Freq_Value,LPTIM2Freq_Value,LPTIM345Freq_Value,LPUART1Freq_Value,LTDCFreq_Value,MCO1PinFreq_Value,MCO2PinFreq_Value,PLLFRACN,PLLSourceVirtual,PWR_Regulator_Voltage_Scale,QSPIFreq_Value,RNGFreq_Value,RTCFreq_Value,SAI1Freq_Value,SAI23Freq_Value,SAI4AFreq_Value,SAI4BFreq_Value,SDMMCFreq_Value,SPDIFRXFreq_Value,SPI123Freq_Value,SPI45Freq_Value,SPI6Freq_Value,SWPMI1Freq_Value,SYSCLKFreq_VALUE,Tim1OutputFreq_Value,Tim2OutputFreq_Value,TraceFreq_Value,USART16Freq_Value,USART234578Freq_Value,USBFreq_Value,VCO1OutputFreq_Value,VCO2OutputFreq_Value,VCO3OutputFreq_Value,VCOInput1Freq_Value,VCOInput2Freq_Value,VCOInput3Freq_Value
RCC.LPTIM1Freq_Value=64000000
RCC.LPTIM2Freq_Value=64000000
RCC.LPTIM345Freq_Value=64000000
@@ -296,6 +281,7 @@ RCC.LTDCFreq_Value=16125000
RCC.MCO1PinFreq_Value=64000000
RCC.MCO2PinFreq_Value=64000000
RCC.PLLFRACN=0
+RCC.PLLSourceVirtual=RCC_PLLSOURCE_HSE
RCC.PWR_Regulator_Voltage_Scale=PWR_REGULATOR_VOLTAGE_SCALE2
RCC.QSPIFreq_Value=64000000
RCC.RNGFreq_Value=48000000
@@ -323,6 +309,8 @@ RCC.VCO3OutputFreq_Value=32250000
RCC.VCOInput1Freq_Value=8000000
RCC.VCOInput2Freq_Value=250000
RCC.VCOInput3Freq_Value=250000
+SH.GPXTI13.0=GPIO_EXTI13
+SH.GPXTI13.ConfNb=1
SH.GPXTI7.0=GPIO_EXTI7
SH.GPXTI7.ConfNb=1
SH.S_TIM2_CH1_ETR.0=TIM2_CH1,PWM Generation1 CH1
@@ -336,14 +324,12 @@ TIM2.IPParameters=Channel-PWM Generation1 CH1,Period
TIM2.Period=80-1
TIM3.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1
TIM3.IPParameters=Channel-PWM Generation1 CH1,Period
-TIM3.Period=80
+TIM3.Period=80-1
TIM4.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1
TIM4.IPParameters=Channel-PWM Generation1 CH1,Period
-TIM4.Period=80
+TIM4.Period=80-1
USART3.IPParameters=VirtualMode-Asynchronous
USART3.VirtualMode-Asynchronous=VM_ASYNC
-USB_OTG_FS.IPParameters=VirtualMode
-USB_OTG_FS.VirtualMode=Device_Only
VP_SYS_VS_Systick.Mode=SysTick
VP_SYS_VS_Systick.Signal=SYS_VS_Systick
VP_TIM2_VS_ClockSourceINT.Mode=Internal
diff --git a/LED_Ring.launch b/LED_Ring.launch
new file mode 100644
index 0000000..6683653
--- /dev/null
+++ b/LED_Ring.launch
@@ -0,0 +1,83 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Test/Saleae Logs/Testing PWM Output.sal b/Test/Saleae Logs/Testing PWM Output.sal
new file mode 100644
index 0000000..cfff648
Binary files /dev/null and b/Test/Saleae Logs/Testing PWM Output.sal differ
diff --git a/Test/Saleae Logs/Working Full Pulse Ring Animation Capture.sal b/Test/Saleae Logs/Working Full Pulse Ring Animation Capture.sal
new file mode 100644
index 0000000..3595d5a
Binary files /dev/null and b/Test/Saleae Logs/Working Full Pulse Ring Animation Capture.sal differ