diff --git a/.mxproject b/.mxproject index dbb9a2a..d8f73e4 100644 --- a/.mxproject +++ b/.mxproject @@ -1,8 +1,8 @@ [PreviousLibFiles] -LibFiles=Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_tim.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_tim_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_adc.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_adc_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_adc.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_def.h;Drivers\STM32G4xx_HAL_Driver\Inc\Legacy\stm32_hal_legacy.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_rcc.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_rcc_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_bus.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_rcc.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_system.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_utils.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_crs.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_flash.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_flash_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_flash_ramfunc.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_gpio.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_gpio_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_gpio.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_exti.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_exti.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_dma.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_dma_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_dma.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_dmamux.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_pwr.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_pwr_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_pwr.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_cortex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_cortex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_spi.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_spi.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_spi_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_tim.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_uart.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_usart.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_lpuart.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_uart_ex.h;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_tim.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_tim_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_adc.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_adc_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_ll_adc.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_rcc.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_rcc_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_flash.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_flash_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_flash_ramfunc.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_gpio.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_exti.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_dma.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_dma_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_pwr.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_pwr_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_cortex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_spi.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_spi_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_uart.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_uart_ex.c;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_tim.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_tim_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_adc.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_adc_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_adc.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_def.h;Drivers\STM32G4xx_HAL_Driver\Inc\Legacy\stm32_hal_legacy.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_rcc.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_rcc_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_bus.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_rcc.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_system.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_utils.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_crs.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_flash.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_flash_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_flash_ramfunc.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_gpio.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_gpio_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_gpio.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_exti.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_exti.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_dma.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_dma_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_dma.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_dmamux.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_pwr.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_pwr_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_pwr.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_cortex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_cortex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_spi.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_spi.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_spi_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_tim.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_uart.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_usart.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_lpuart.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_uart_ex.h;Drivers\CMSIS\Device\ST\STM32G4xx\Include\stm32g431xx.h;Drivers\CMSIS\Device\ST\STM32G4xx\Include\stm32g4xx.h;Drivers\CMSIS\Device\ST\STM32G4xx\Include\system_stm32g4xx.h;Drivers\CMSIS\Device\ST\STM32G4xx\Include\system_stm32g4xx.h;Drivers\CMSIS\Device\ST\STM32G4xx\Source\Templates\system_stm32g4xx.c;Drivers\CMSIS\Include\cmsis_armcc.h;Drivers\CMSIS\Include\cmsis_armclang.h;Drivers\CMSIS\Include\cmsis_armclang_ltm.h;Drivers\CMSIS\Include\cmsis_compiler.h;Drivers\CMSIS\Include\cmsis_gcc.h;Drivers\CMSIS\Include\cmsis_iccarm.h;Drivers\CMSIS\Include\cmsis_version.h;Drivers\CMSIS\Include\core_armv81mml.h;Drivers\CMSIS\Include\core_armv8mbl.h;Drivers\CMSIS\Include\core_armv8mml.h;Drivers\CMSIS\Include\core_cm0.h;Drivers\CMSIS\Include\core_cm0plus.h;Drivers\CMSIS\Include\core_cm1.h;Drivers\CMSIS\Include\core_cm23.h;Drivers\CMSIS\Include\core_cm3.h;Drivers\CMSIS\Include\core_cm33.h;Drivers\CMSIS\Include\core_cm35p.h;Drivers\CMSIS\Include\core_cm4.h;Drivers\CMSIS\Include\core_cm7.h;Drivers\CMSIS\Include\core_sc000.h;Drivers\CMSIS\Include\core_sc300.h;Drivers\CMSIS\Include\mpu_armv7.h;Drivers\CMSIS\Include\mpu_armv8.h;Drivers\CMSIS\Include\tz_context.h; +LibFiles=Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_adc.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_adc_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_adc.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_def.h;Drivers\STM32G4xx_HAL_Driver\Inc\Legacy\stm32_hal_legacy.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_rcc.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_rcc_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_bus.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_rcc.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_system.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_utils.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_crs.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_flash.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_flash_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_flash_ramfunc.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_gpio.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_gpio_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_gpio.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_exti.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_exti.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_dma.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_dma_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_dma.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_dmamux.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_pwr.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_pwr_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_pwr.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_cortex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_cortex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_spi.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_spi.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_spi_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_tim.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_tim.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_tim_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_uart.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_usart.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_lpuart.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_uart_ex.h;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_adc.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_adc_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_ll_adc.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_rcc.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_rcc_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_flash.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_flash_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_flash_ramfunc.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_gpio.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_exti.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_dma.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_dma_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_pwr.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_pwr_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_cortex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_spi.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_spi_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_tim.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_tim_ex.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_uart.c;Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_uart_ex.c;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_adc.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_adc_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_adc.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_def.h;Drivers\STM32G4xx_HAL_Driver\Inc\Legacy\stm32_hal_legacy.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_rcc.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_rcc_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_bus.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_rcc.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_system.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_utils.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_crs.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_flash.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_flash_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_flash_ramfunc.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_gpio.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_gpio_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_gpio.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_exti.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_exti.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_dma.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_dma_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_dma.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_dmamux.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_pwr.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_pwr_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_pwr.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_cortex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_cortex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_spi.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_spi.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_spi_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_tim.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_tim.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_tim_ex.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_uart.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_usart.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_ll_lpuart.h;Drivers\STM32G4xx_HAL_Driver\Inc\stm32g4xx_hal_uart_ex.h;Drivers\CMSIS\Device\ST\STM32G4xx\Include\stm32g431xx.h;Drivers\CMSIS\Device\ST\STM32G4xx\Include\stm32g4xx.h;Drivers\CMSIS\Device\ST\STM32G4xx\Include\system_stm32g4xx.h;Drivers\CMSIS\Device\ST\STM32G4xx\Include\system_stm32g4xx.h;Drivers\CMSIS\Device\ST\STM32G4xx\Source\Templates\system_stm32g4xx.c;Drivers\CMSIS\Include\cmsis_armcc.h;Drivers\CMSIS\Include\cmsis_armclang.h;Drivers\CMSIS\Include\cmsis_armclang_ltm.h;Drivers\CMSIS\Include\cmsis_compiler.h;Drivers\CMSIS\Include\cmsis_gcc.h;Drivers\CMSIS\Include\cmsis_iccarm.h;Drivers\CMSIS\Include\cmsis_version.h;Drivers\CMSIS\Include\core_armv81mml.h;Drivers\CMSIS\Include\core_armv8mbl.h;Drivers\CMSIS\Include\core_armv8mml.h;Drivers\CMSIS\Include\core_cm0.h;Drivers\CMSIS\Include\core_cm0plus.h;Drivers\CMSIS\Include\core_cm1.h;Drivers\CMSIS\Include\core_cm23.h;Drivers\CMSIS\Include\core_cm3.h;Drivers\CMSIS\Include\core_cm33.h;Drivers\CMSIS\Include\core_cm35p.h;Drivers\CMSIS\Include\core_cm4.h;Drivers\CMSIS\Include\core_cm7.h;Drivers\CMSIS\Include\core_sc000.h;Drivers\CMSIS\Include\core_sc300.h;Drivers\CMSIS\Include\mpu_armv7.h;Drivers\CMSIS\Include\mpu_armv8.h;Drivers\CMSIS\Include\tz_context.h; [PreviousUsedIarFiles] -SourceFiles=..\Core\Src\main.c;..\Core\Src\gpio.c;..\Core\Src\adc.c;..\Core\Src\dma.c;..\Core\Src\spi.c;..\Core\Src\tim.c;..\Core\Src\usart.c;..\Core\Src\stm32g4xx_it.c;..\Core\Src\stm32g4xx_hal_msp.c;..\Core\Src\stm32g4xx_hal_timebase_tim.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_tim.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_tim_ex.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_adc.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_adc_ex.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_ll_adc.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_rcc.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_rcc_ex.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_flash.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_flash_ex.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_flash_ramfunc.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_gpio.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_exti.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_dma.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_dma_ex.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_pwr.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_pwr_ex.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_cortex.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_spi.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_spi_ex.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_uart.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_uart_ex.c;..\Drivers\CMSIS\Device\ST\STM32G4xx\Source\Templates\system_stm32g4xx.c;..\Core\Src\system_stm32g4xx.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_tim.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_tim_ex.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_adc.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_adc_ex.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_ll_adc.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_rcc.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_rcc_ex.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_flash.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_flash_ex.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_flash_ramfunc.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_gpio.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_exti.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_dma.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_dma_ex.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_pwr.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_pwr_ex.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_cortex.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_spi.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_spi_ex.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_uart.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_uart_ex.c;..\Drivers\CMSIS\Device\ST\STM32G4xx\Source\Templates\system_stm32g4xx.c;..\Core\Src\system_stm32g4xx.c;;; +SourceFiles=..\Core\Src\main.c;..\Core\Src\gpio.c;..\Core\Src\adc.c;..\Core\Src\dma.c;..\Core\Src\spi.c;..\Core\Src\tim.c;..\Core\Src\usart.c;..\Core\Src\stm32g4xx_it.c;..\Core\Src\stm32g4xx_hal_msp.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_adc.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_adc_ex.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_ll_adc.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_rcc.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_rcc_ex.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_flash.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_flash_ex.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_flash_ramfunc.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_gpio.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_exti.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_dma.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_dma_ex.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_pwr.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_pwr_ex.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_cortex.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_spi.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_spi_ex.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_tim.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_tim_ex.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_uart.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_uart_ex.c;..\Drivers\CMSIS\Device\ST\STM32G4xx\Source\Templates\system_stm32g4xx.c;..\Core\Src\system_stm32g4xx.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_adc.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_adc_ex.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_ll_adc.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_rcc.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_rcc_ex.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_flash.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_flash_ex.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_flash_ramfunc.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_gpio.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_exti.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_dma.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_dma_ex.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_pwr.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_pwr_ex.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_cortex.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_spi.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_spi_ex.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_tim.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_tim_ex.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_uart.c;..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_uart_ex.c;..\Drivers\CMSIS\Device\ST\STM32G4xx\Source\Templates\system_stm32g4xx.c;..\Core\Src\system_stm32g4xx.c;;; HeaderPath=..\Drivers\STM32G4xx_HAL_Driver\Inc;..\Drivers\STM32G4xx_HAL_Driver\Inc\Legacy;..\Drivers\CMSIS\Device\ST\STM32G4xx\Include;..\Drivers\CMSIS\Include;..\Middlewares\ST\ARM\DSP\Inc;..\Core\Inc; CDefines=USE_HAL_DRIVER;STM32G431xx;USE_HAL_DRIVER;USE_HAL_DRIVER; @@ -21,7 +21,7 @@ HeaderFiles#8=..\Core\Inc\main.h HeaderFolderListSize=1 HeaderPath#0=..\Core\Inc HeaderFiles=; -SourceFileListSize=10 +SourceFileListSize=9 SourceFiles#0=..\Core\Src\gpio.c SourceFiles#1=..\Core\Src\adc.c SourceFiles#2=..\Core\Src\dma.c @@ -30,8 +30,7 @@ SourceFiles#4=..\Core\Src\tim.c SourceFiles#5=..\Core\Src\usart.c SourceFiles#6=..\Core\Src\stm32g4xx_it.c SourceFiles#7=..\Core\Src\stm32g4xx_hal_msp.c -SourceFiles#8=..\Core\Src\stm32g4xx_hal_timebase_tim.c -SourceFiles#9=..\Core\Src\main.c +SourceFiles#8=..\Core\Src\main.c SourceFolderListSize=1 SourcePath#0=..\Core\Src SourceFiles=; diff --git a/APP/application/Src/start.c b/APP/application/Src/start.c index 278b375..74d6ef8 100644 --- a/APP/application/Src/start.c +++ b/APP/application/Src/start.c @@ -3,13 +3,15 @@ #include "TimeSliceOffset.h" #include "Init.h" #include "task.h" - +#include "pDebug.h" void start(void) { Init(); task_Init(); + debug("start\n"); + TimeSliceOffset_Start(); } diff --git a/APP/businessLogic/Inc/abnormalManage.h b/APP/businessLogic/Inc/abnormalManage.h index e3dfcfb..d9af49a 100644 --- a/APP/businessLogic/Inc/abnormalManage.h +++ b/APP/businessLogic/Inc/abnormalManage.h @@ -3,13 +3,29 @@ #define BL_ABNORMAL_MANAGE_H_ #include "FM_TIM.h" +#include "comm_types.h" +#include "FM_GPIO.h" +BOOL getChargOverLoad(void); + +uint8_t getShortCircuit(void); +void zeroShortCircuit(void); +void setShortCircuitFlag(BOOL state); +BOOL getShortCircuitFlag(void); + +void zeroExcessiveLoad(void); +uint8_t getExcessiveLoad(void); +void setExcessiveLoadFlag(BOOL state); +BOOL getExcessiveLoadFlag(void); + +void setPowerOutput(BOOL state); void checkAbnormal(void); - +void WORK_VOLT_Interrupt(void); +void DSG_PROT_Interrupt(void); #endif \ No newline at end of file diff --git a/APP/businessLogic/Inc/inFlash.h b/APP/businessLogic/Inc/inFlash.h index 6bc985f..042ff59 100644 --- a/APP/businessLogic/Inc/inFlash.h +++ b/APP/businessLogic/Inc/inFlash.h @@ -12,8 +12,8 @@ typedef struct _recv_config_info{ uint8_t start_Flag[2]; /* 开始标志 */ /* SL */ uint8_t address[7]; /* 地址 */ - uint8_t Access_Node_Type[2]; /* 接入节点类型 */ - uint8_t Communication_Methods[2]; /* 通信方式 */ + // uint8_t Access_Node_Type[2]; /* 接入节点类型 */ + // uint8_t Communication_Methods[2]; /* 通信方式 */ uint8_t gw485_Baud[4]; /* 串口波特率 */ uint8_t bat485_Baud[4]; /* 串口波特率,为0代表bms不支持通信 */ @@ -38,8 +38,8 @@ typedef struct _recv_config_info{ uint8_t HighSideMosTemperature_end[2]; /* 当上桥温度上升到该值时,降低功率运行 (°C) */ uint8_t HighSideMosTemperature_start[2];/* 当上桥温度降低到该值时,按照正常情况输出 (°C) */ - uint8_t checkSolarOpenCircuitVTime[2]; /* 启动任务中太阳能板开路电压检测间隔时间 (S) */ - uint8_t sensorEnableBroadcastTime[2]; /* 传感器运行再次注册的间隔 (S) */ + // uint8_t checkSolarOpenCircuitVTime[2]; /* 启动任务中太阳能板开路电压检测间隔时间 (S) */ + // uint8_t sensorEnableBroadcastTime[2]; /* 传感器运行再次注册的间隔 (S) */ uint8_t outputAgainFlagTime[2]; /* 出现短路保护后延长该段时间再次检测是否短路,仍然短路则关闭输出 (S) */ uint8_t excessiveLoadFlagTime[2]; /* 出现过载后,在该间隔时间中多次(2次)出现过载,则关闭输出 (S) */ uint8_t eLAgainTime[2]; /* 出现过载过载保护后,在该间隔段时间后,再次尝试输出 (S) */ @@ -51,8 +51,8 @@ typedef struct _recv_config_info{ typedef struct _config_info{ /* SL */ uint8_t address[7]; /* 地址 */ - uint16_t Access_Node_Type; /* 接入节点类型 */ - uint16_t Communication_Methods; /* 通信方式 */ + // uint16_t Access_Node_Type; /* 接入节点类型 */ + // uint16_t Communication_Methods; /* 通信方式 */ uint32_t gw485_Baud; /* 串口波特率,为0代表bms不支持通信 */ uint32_t bat485_Baud; /* 串口波特率 */ @@ -76,8 +76,8 @@ typedef struct _config_info{ float HighSideMosTemperature_end; /* 当上桥温度上升到该值时,降低功率运行 */ float HighSideMosTemperature_start; /* 当上桥温度降低到该值时,按照正常情况输出 */ - uint16_t checkSolarOpenCircuitVTime; /* 启动任务中太阳能板开路电压检测时间 */ - uint16_t sensorEnableBroadcastTime; /* 传感器运行再次注册的间隔 */ + // uint16_t checkSolarOpenCircuitVTime; /* 启动任务中太阳能板开路电压检测时间 */ + // uint16_t sensorEnableBroadcastTime; /* 传感器运行再次注册的间隔 */ uint16_t outputAgainFlagTime; /* 出现短路保护后延长该段时间再次检测是否短路,仍然短路则关闭输出 */ uint16_t excessiveLoadFlagTime; /* 出现过载后,在该段时间中再次出现过载,则关闭输出 */ uint16_t eLAgainTime; /* 出现过载过载保护后,该段时间后,再次尝试输出 */ @@ -95,8 +95,9 @@ typedef struct _config_info{ #define totalElectricityConsumption_SAVE_addr (CONFIG_INFO_SIZE + CONFIG_INFO_SIZE + 20) #define totalChargCapacity_SAVE_addr (CONFIG_INFO_SIZE + CONFIG_INFO_SIZE + 30) -void save_config_info(config_info *save_config_info); +// void save_config_info(config_info *save_config_info); void read_config_info(config_info *output_config_info); +void saveConfigInfo(config_info *config_info); void config_info_start(void); void saveLoopImpedance(float *loopImpedance); diff --git a/APP/businessLogic/Inc/parameter.h b/APP/businessLogic/Inc/parameter.h index d8ae50f..61bb13e 100644 --- a/APP/businessLogic/Inc/parameter.h +++ b/APP/businessLogic/Inc/parameter.h @@ -23,11 +23,11 @@ typedef struct _config_parameter{ float HighSideMosTemperature_start; /* 当上桥温度降低到该值时,按照正常情况输出 (°C) */ uint16_t sensorEnableBroadcastTime; /* 传感器运行再次注册的间隔 (S) */ - uint16_t checkSolarOpenCircuitVTime; /* 启动任务中太阳能板开路电压检测间隔时间 (S) */ + // uint16_t checkSolarOpenCircuitVTime; /* 启动任务中太阳能板开路电压检测间隔时间 (S) */ uint16_t outputAgainFlagTime; /* 出现短路保护后延长该段时间再次检测是否短路,仍然短路则关闭输出 (S) */ uint16_t excessiveLoadFlagTime; /* 出现过载后,在该间隔时间中多次(2次)出现过载,则关闭输出 (S) */ uint16_t eLAgainTime; /* 出现过载过载保护后,在该间隔段时间后,再次尝试输出 (S) */ - uint32_t collectOpenCircuitVoltageTime; /* 开路电压采集时间间隔 */ + uint32_t collectOpenCircuitVoltageTime; /* 充电时开路电压采集时间间隔 */ /* SL */ uint16_t Access_Node_Type; /* 接入节点类型 */ diff --git a/APP/businessLogic/Inc/task.h b/APP/businessLogic/Inc/task.h index 9df07f5..2d1d20d 100644 --- a/APP/businessLogic/Inc/task.h +++ b/APP/businessLogic/Inc/task.h @@ -11,8 +11,10 @@ void task_Init(void); void beginStartControlTask(void); void beginSoftStartTask(void); void beginHYconfigMode(void); +void uartTaskInit(void); - - +void startShortCircuitProtection(void); +void stopShortCircuitProtection(void); +void startExcessiveLoadProtection(void); #endif diff --git a/APP/businessLogic/Inc/test.h b/APP/businessLogic/Inc/test.h deleted file mode 100644 index 443642a..0000000 --- a/APP/businessLogic/Inc/test.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef BL_TEST_H_ -#define BL_TEST_H_ - - - -void test(void); - -#endif diff --git a/APP/businessLogic/Src/Init.c b/APP/businessLogic/Src/Init.c index ec6ae00..54c6bd5 100644 --- a/APP/businessLogic/Src/Init.c +++ b/APP/businessLogic/Src/Init.c @@ -1,14 +1,15 @@ #include "Init.h" #include "capture.h" -#include "FM_GPIO.h" #include "inFlash.h" -#include "parameter.h" #include "FM_GPIO.h" #include "FM_TIM.h" #include "uart_dev.h" +#include "parameter.h" +#include "abnormalManage.h" extern int getMPPT_Mode(void); +//extern config_parameter g_cfgParameter; /** * @brief 初始化外设,同时通过配置文件初始化系统参数 @@ -26,12 +27,14 @@ void Init(void) tim_Init(); Init_debug_uart(); - Init_BAT485_uart(); - Init_GW485_uart(); +// Init_BAT485_uart(g_cfgParameter.bat485_Baud); +// Init_GW485_uart(g_cfgParameter.gw485_Baud); + Init_BAT485_uart(115200); + Init_GW485_uart(115200); start_gw485Rx_It(); start_bat485Rx_It(); - POW_FF_PCON_Open(); - POW_OUT_PCON_Open(); - + // POW_FF_PCON_Open(); + // POW_OUT_PCON_Open(); + setPowerOutput(TRUE); } diff --git a/APP/businessLogic/Src/abnormalManage.c b/APP/businessLogic/Src/abnormalManage.c index 4bfce1f..b10a91f 100644 --- a/APP/businessLogic/Src/abnormalManage.c +++ b/APP/businessLogic/Src/abnormalManage.c @@ -4,6 +4,202 @@ #include "capture.h" #include "checkTime.h" #include "FM_GPIO.h" +#include "task.h" + + + +/* 软件输出过载标志位 */ +static BOOL disChargOverLoad = FALSE; + +/* 短路标志位 */ +static uint8_t shortCircuit = 0; +static BOOL shortCircuitFlag = FALSE; + +/* 硬件过载状态位 */ +static uint8_t excessiveLoad = 0; +static BOOL excessiveLoadFlag = FALSE; + + +/** + * @brief 设定放电过载状态 + * @param state TRUE 过载 + * FALSE 未过载 + * @retval + * + */ +void setDisChargOverLoad(void) +{ + if (getDischargCurrent() > 30.0f) { + disChargOverLoad = TRUE; + } else { + disChargOverLoad = FALSE; + } +} + +/** + * @brief 得到放电过载状态 + * @param + * @retval + * + */ +BOOL getChargOverLoad(void) +{ + return disChargOverLoad; +} + +/** + * @brief 设置短路状态位 + * @param + * @retval + * + */ +void setShortCircuit(void) +{ + shortCircuit++; +} + +/** + * @brief 清零短路状位 + * @param + * @retval + * + */ +void zeroShortCircuit(void) +{ + shortCircuit = 0; +} + +/** + * @brief 得到短路状位 + * @param + * @retval + * + */ +uint8_t getShortCircuit(void) +{ + return shortCircuit; +} + +/** + * @brief 设定短路标志位 + * @param state TRUE 短路 + * FALSE 未短路 + * @retval + * + */ +void setShortCircuitFlag(BOOL state) +{ + if (state == TRUE || state == FALSE) { + shortCircuitFlag = state; + } + +} + +/** + * @brief 得到短路标志位 + * @param + * @retval + * + */ +BOOL getShortCircuitFlag(void) +{ + return shortCircuitFlag; +} + +/** + * @brief 设置硬件过载状态位 + * @param + * @retval + * + */ +void setExcessiveLoad(void) +{ + excessiveLoad++; +} + +/** + * @brief 清零硬件过载状态位 + * @param + * @retval + * + */ +void zeroExcessiveLoad(void) +{ + excessiveLoad = 0; +} + +/** + * @brief 得到硬件过载状态位 + * @param + * @retval + * + */ +uint8_t getExcessiveLoad(void) +{ + return excessiveLoad; +} + +/** + * @brief 设定硬件过载标志位 + * @param state TRUE 过载 + * FALSE 未过载 + * @retval + * + */ +void setExcessiveLoadFlag(BOOL state) +{ + if (state == TRUE || state == FALSE) { + excessiveLoadFlag = state; + } + +} + +/** + * @brief 得到硬件过载标志位 + * @param + * @retval + * + */ +BOOL getExcessiveLoadFlag(void) +{ + return excessiveLoadFlag; +} + +/** + * @brief 设置输出状态 + * @param + * @retval + * + */ + void setPowerOutput(BOOL state) +{ + if (state == TRUE) { + POW_FF_PCON_Open(); + POW_OUT_PCON_Open(); + } else { + POW_FF_PCON_Close(); + POW_OUT_PCON_Close(); + } +} + + +/** + * @brief 判断是否打开充电理想二极管 + * @param + * @retval + * + */ +void checkFFMOS_CON(void) +{ + if (get_CHG_CURR() > 2.0f) { + FFMOS_CON_Open(); + } + else if (get_CHG_CURR() < 1.0f) { + FFMOS_CON_Close(); + } +} + + void checkAbnormal(void) @@ -19,17 +215,62 @@ void checkAbnormal(void) setSolarInCircuitVoltage(); /* 判断 */ - - /* 是否打开充电理想二极管 */ - if (get_CHG_CURR() > 2.0f) { - FFMOS_CON_Open(); - } - else if (get_CHG_CURR() < 1.0f) { - FFMOS_CON_Close(); - } + checkFFMOS_CON(); + setDisChargOverLoad(); // checkAbnormalTime = getCheckTime(); } +/** + * @brief 工作电压异常中断,过载(输入大于输出) + * @param + * @retval + * + */ +void WORK_VOLT_Interrupt(void) +{ + setExcessiveLoad(); + /* 第一次进入输出过载,启动过载保护任务 */ + if (getExcessiveLoad() == 1) { + setExcessiveLoadFlag(TRUE); + startExcessiveLoadProtection(); + } + + /* 多次进入输出过载,关闭输出 */ + if (getExcessiveLoad() > 2) { + zeroExcessiveLoad(); + setPowerOutput(FALSE); + } +} + +/** + * @brief 短路中断,输出电流大于一定值 + * @param + * @retval + * + */ +void DSG_PROT_Interrupt(void) +{ + setShortCircuit(); + /* 第一次进入输出短路,启动短路任务 */ + if (getShortCircuit() == 1) { + setShortCircuitFlag(TRUE); + startShortCircuitProtection(); + } + + /* 一定时间内第二次进入输出短路保护,关闭输出 */ + else if (getShortCircuit() >= 2) { + stopShortCircuitProtection(); + setPowerOutput(FALSE); + zeroShortCircuit(); + } +} + + + + + + + diff --git a/APP/businessLogic/Src/bl_chargControl.c b/APP/businessLogic/Src/bl_chargControl.c index fcd7ecd..c2b584a 100644 --- a/APP/businessLogic/Src/bl_chargControl.c +++ b/APP/businessLogic/Src/bl_chargControl.c @@ -654,12 +654,13 @@ void setChargControlFlag(BOOL state) */ void bl_chargControl(void) { + setBatteryVoltage(); + if (getChargControlFlag() == FALSE) { return; } // getCVData(); - setBatteryVoltage(); judgeYNBattery(); chargControlMode(); diff --git a/APP/businessLogic/Src/bl_comm.c b/APP/businessLogic/Src/bl_comm.c index 1f9966e..b2293c5 100644 --- a/APP/businessLogic/Src/bl_comm.c +++ b/APP/businessLogic/Src/bl_comm.c @@ -28,11 +28,20 @@ void BAT485_comm(void) */ void gw485_RxIt(void) { + // uart_device_info *dev = (uart_device_info *)g_gw485_uart2_handle; + // if(!RingQueueFull(&dev->uart_ring_queue)) + // InRingQueue(&dev->uart_ring_queue, rx_gw485_buf[0]); + + uint8_t c = 0; + c = rx_gw485_buf[0]; + uart_device_info *dev = (uart_device_info *)g_gw485_uart2_handle; if(!RingQueueFull(&dev->uart_ring_queue)) - InRingQueue(&dev->uart_ring_queue, rx_gw485_buf[0]); + InRingQueue(&dev->uart_ring_queue, c); + + start_gw485Rx_It(); } - + /** * @brief bat485串口接收中断回调函数 * @param @@ -44,4 +53,6 @@ void bat485_RxIt(void) uart_device_info *dev = (uart_device_info *)g_bat485_uart3_handle; if(!RingQueueFull(&dev->uart_ring_queue)) InRingQueue(&dev->uart_ring_queue, rx_bat485_buf[0]); + + start_bat485Rx_It(); } \ No newline at end of file diff --git a/APP/businessLogic/Src/cfg_protocol.c b/APP/businessLogic/Src/cfg_protocol.c index b61f822..2259da7 100644 --- a/APP/businessLogic/Src/cfg_protocol.c +++ b/APP/businessLogic/Src/cfg_protocol.c @@ -5,10 +5,11 @@ #include "parameter.h" #include "string.h" #include "chargControlEnum.h" +#include "pDebug.h" #define cfgBuffLen 200 -uint8_t configBuff[cfgBuffLen]; -uint8_t cfigLen = 0; +static uint8_t configBuff[cfgBuffLen]; +static uint8_t cfigLen = 0; /* 配置文件中的部分数据放大倍数 */ #define enlargeScale 100 @@ -37,7 +38,8 @@ void outConfigBuff(void) { if (cfigLen > 0) { cfigLen--; - memcpy(configBuff, configBuff + 1, cfigLen - 1); + memcpy(configBuff, configBuff + 1, cfigLen); + // memcpy(configBuff, configBuff + 1, sizeof(configBuff) - 1); } } @@ -85,32 +87,33 @@ void zeroConfigBuff(void) */ void read_and_process_config_data(void) { - recv_config_info *pack = (recv_config_info *)cfgBuffLen; + recv_config_info *pack = (recv_config_info *)configBuff; static config_info save_configInfo; while (cfigLen >= RECV_CONFIG_INFO) { /* 判断起始标志是否正确 */ + debug_printf(" start_Flag : 0x%x, 0x%x \n", pack->start_Flag[0], pack->start_Flag[1]); if (pack->start_Flag[0] != g_cfgParameter.startFlagSL[0] || pack->start_Flag[1] != g_cfgParameter.startFlagSL[1]) { -// debug(" start_Flag : 0x%x, 0x%x \n", pack->start_Flag[0], pack->start_Flag[1]); + // debug(" start_Flag : 0x%x, 0x%x \n", pack->start_Flag[0], pack->start_Flag[1]); goto err; } + +// /* 判断接入节点类型是否正确 */ +// save_configInfo.Access_Node_Type = (uint16_t)pack->Access_Node_Type[0] << 8 +// | (uint16_t)pack->Access_Node_Type[1]; +// if (save_configInfo.Access_Node_Type != POWERBOX) { +// // debug(" Access_Node_Type : 0x%x \n", save_configInfo.Access_Node_Type); +// goto err; +// } - /* 判断接入节点类型是否正确 */ - save_configInfo.Access_Node_Type = (uint16_t)pack->Access_Node_Type[0] << 8 - | (uint16_t)pack->Access_Node_Type[1]; -// debug(" Access_Node_Type : 0x%x \n", save_configInfo.Access_Node_Type); - if (save_configInfo.Access_Node_Type != POWERBOX) { - goto err; - } - - /* 判断通信方式是否正确 */ - save_configInfo.Communication_Methods = (uint16_t)pack->Communication_Methods[0] << 8 - | (uint16_t)pack->Communication_Methods[1]; -// debug(" Communication_Methods : 0x%x \n", save_configInfo.Communication_Methods); -// if (temp_u16 != RS485 || temp_u16 != RJ45) { - if (save_configInfo.Communication_Methods != RS485) { - goto err; - } +// /* 判断通信方式是否正确 */ +// save_configInfo.Communication_Methods = (uint16_t)pack->Communication_Methods[0] << 8 +// | (uint16_t)pack->Communication_Methods[1]; +// // if (temp_u16 != RS485 || temp_u16 != RJ45) { +// if (save_configInfo.Communication_Methods != RS485) { +// debug(" Communication_Methods : 0x%x \n", save_configInfo.Communication_Methods); +// goto err; +// } /* 判断波特率是否正确 */ save_configInfo.gw485_Baud = (uint32_t)pack->gw485_Baud[0] << 24 @@ -118,9 +121,9 @@ void read_and_process_config_data(void) | (uint32_t)pack->gw485_Baud[2] << 8 | (uint32_t)pack->gw485_Baud[3]; // debug(" gw485_Baud : 0x%x, %d \n", save_configInfo.gw485_Baud, save_configInfo.gw485_Baud); - if (save_configInfo.gw485_Baud != 9600 && save_configInfo.gw485_Baud != 115200) { -// if (save_configInfo.gw485_Baud != 0x2580 || save_configInfo.gw485_Baud != 115200) { -// debug(" error : %d\n", save_configInfo.gw485_Baud); + if (save_configInfo.gw485_Baud != 9600 + && save_configInfo.gw485_Baud != 115200) { + // debug(" gw485_Baud : %d\n", save_configInfo.gw485_Baud); goto err; } @@ -128,152 +131,162 @@ void read_and_process_config_data(void) | (uint32_t)pack->bat485_Baud[1] << 16 | (uint32_t)pack->bat485_Baud[2] << 8 | (uint32_t)pack->bat485_Baud[3]; -// debug(" bat485_Baud : 0x%x, %d \n", save_configInfo.bat485_Baud, save_configInfo.bat485_Baud); - if (save_configInfo.bat485_Baud != 9600 && save_configInfo.bat485_Baud!= 115200 && save_configInfo.bat485_Baud!= 0) { + if (save_configInfo.bat485_Baud != 9600 + && save_configInfo.bat485_Baud!= 115200 + && save_configInfo.bat485_Baud!= 0) { + // debug(" bat485_Baud : 0x%x, %d \n", save_configInfo.bat485_Baud, save_configInfo.bat485_Baud); goto err; } - /* 判断协议类型是否正确 */ + /* 判断汇源协议类型是否正确 */ if (pack->protocolType != 0x01 && pack->protocolType != 0x02) { + // debug(" protocolType : 0x%x \n", pack->protocolType); goto err; } -// debug(" protocolType : 0x%x \n", pack->protocolType); /* 判断通信协议类型是否正确 */ - if (pack->CommunicationProtocolType != 0x00 && pack->CommunicationProtocolType != 0x01) { + if (pack->CommunicationProtocolType != 0x00 + && pack->CommunicationProtocolType != 0x01) { + // debug(" CommunicationProtocolType : 0x%x \n", pack->CommunicationProtocolType); goto err; } -// debug(" CommunicationProtocolType : 0x%x \n", pack->CommunicationProtocolType); /* 判断电源盒类型是否正确 */ if (pack->onlyPower != 0x00 && pack->onlyPower != 0x01) { + // debug(" onlyPower : 0x%x \n", pack->onlyPower); goto err; } -// debug(" onlyPower : 0x%x \n", pack->onlyPower); /* 判断恒压充电阈值是否正确 */ save_configInfo.constantVoltageV = (float)(pack->ConstantVoltageV[0] << 8 | pack->ConstantVoltageV[1]) / enlargeScale; -// debug(" constantVoltageV : %f \n", save_configInfo.constantVoltageV); - if (save_configInfo.constantVoltageV > (float)14.4 || save_configInfo.constantVoltageV < (float)13.5) { + if (!((save_configInfo.constantVoltageV < 14.4f && save_configInfo.constantVoltageV > 13.5f) + || save_configInfo.constantVoltageV == 0)) { + // debug(" constantVoltageV : %f \n", save_configInfo.constantVoltageV); goto err; } /* 判断浮充充电阈值是否正确 */ save_configInfo.floatI = (float)(pack->FloatI[0] << 8 | pack->FloatI[1]) / enlargeScale; -// debug(" floatI : %f \n", save_configInfo.floatI); - if (save_configInfo.floatI > (float)0.2 || save_configInfo.floatI < (float)0) { + if (save_configInfo.floatI > 0.2f || save_configInfo.floatI < 0) { + // debug(" floatI : %f \n", save_configInfo.floatI); goto err; } /* 判断太阳能板开路启动电压是否正确 */ save_configInfo.startSolarOpenCircuitV = (float)(pack->startSolarOpenCircuitV[0] << 8 | pack->startSolarOpenCircuitV[1]) / enlargeScale; -// debug(" startSolarOpenCircuitV : %f \n", save_configInfo.startSolarOpenCircuitV); - if (save_configInfo.startSolarOpenCircuitV > 24 || save_configInfo.startSolarOpenCircuitV < 14) { + if (!((save_configInfo.startSolarOpenCircuitV < 24 && save_configInfo.startSolarOpenCircuitV > 14) + || save_configInfo.startSolarOpenCircuitV == 0)) { + // debug(" startSolarOpenCircuitV : %f \n", save_configInfo.startSolarOpenCircuitV); goto err; } /* 判断太阳能板关闭电压是否正确 */ save_configInfo.stopSolarOpenCircuitV = (float)(pack->stopSolarOpenCircuitV[0] << 8 | pack->stopSolarOpenCircuitV[1]) / enlargeScale; -// debug(" stopSolarOpenCircuitV : %f \n", save_configInfo.stopSolarOpenCircuitV); - if (save_configInfo.stopSolarOpenCircuitV > 17 || save_configInfo.stopSolarOpenCircuitV < 13) { + if (!((save_configInfo.stopSolarOpenCircuitV > 17 && save_configInfo.stopSolarOpenCircuitV < 13) + || save_configInfo.stopSolarOpenCircuitV == 0)) { + // debug(" stopSolarOpenCircuitV : %f \n", save_configInfo.stopSolarOpenCircuitV); goto err; } /* 判断恒压充电时的输出电压是否正确 */ save_configInfo.constantVoltageChargeV = (float)(pack->constantVoltageChargeV[0] << 8 | pack->constantVoltageChargeV[1]) / enlargeScale; -// debug(" constantVoltageChargeV : %f \n", save_configInfo.constantVoltageChargeV); - if (save_configInfo.constantVoltageChargeV > (float)14.6 || save_configInfo.constantVoltageChargeV < (float)14) { + if (!((save_configInfo.constantVoltageChargeV < 14.6f && save_configInfo.constantVoltageChargeV > 14) + || save_configInfo.constantVoltageChargeV == 0)) { + // debug(" constantVoltageChargeV : %f \n", save_configInfo.constantVoltageChargeV); goto err; } /* 判断浮充充电时的输出电压是否正确 */ save_configInfo.FloatChargeV = (float)(pack->FloatChargeV[0] << 8 | pack->FloatChargeV[1]) / enlargeScale; -// debug(" FloatChargeV : %f \n", save_configInfo.FloatChargeV); - if (save_configInfo.FloatChargeV > (float)14.4 || save_configInfo.FloatChargeV < (float)13.8) { + if (!((save_configInfo.FloatChargeV < 14.4f && save_configInfo.FloatChargeV > 13.8f) + || save_configInfo.FloatChargeV == 0)) { + // debug(" FloatChargeV : %f \n", save_configInfo.FloatChargeV); goto err; } /* 判断mos管停止工作温度是否正确 */ save_configInfo.HighSideMosTemperature_stop = (float)(pack->HighSideMosTemperature_stop[0] << 8 | pack->HighSideMosTemperature_stop[1]) / enlargeScale; -// debug(" HighSideMosTemperature_stop : %f \n", save_configInfo.HighSideMosTemperature_stop); - if (save_configInfo.HighSideMosTemperature_stop < 60) { + if (save_configInfo.HighSideMosTemperature_stop < 50 && save_configInfo.HighSideMosTemperature_stop != 0) { + // debug(" HighSideMosTemperature_stop : %f \n", save_configInfo.HighSideMosTemperature_stop); goto err; } /* 判断mos管降低工作功率工作温度是否正确 */ save_configInfo.HighSideMosTemperature_end = (float)(pack->HighSideMosTemperature_end[0] << 8 | pack->HighSideMosTemperature_end[1]) / enlargeScale; -// debug(" HighSideMosTemperature_end : %f \n", save_configInfo.HighSideMosTemperature_end)); - if (save_configInfo.HighSideMosTemperature_end < 50) { + if (save_configInfo.HighSideMosTemperature_end < 40 && save_configInfo.HighSideMosTemperature_end != 0) { + // debug(" HighSideMosTemperature_end : %f \n", save_configInfo.HighSideMosTemperature_end); goto err; } /* 判断mos管完全恢复工作温度是否正确 */ save_configInfo.HighSideMosTemperature_start = (float)(pack->HighSideMosTemperature_start[0] << 8 | pack->HighSideMosTemperature_start[1]) / enlargeScale; -// debug(" HighSideMosTemperature_start : %d \n", save_configInfo.HighSideMosTemperature_start); - if (save_configInfo.HighSideMosTemperature_start < 40) { + if (save_configInfo.HighSideMosTemperature_start > 70 && save_configInfo.HighSideMosTemperature_start != 0) { + debug(" HighSideMosTemperature_start : %d \n", save_configInfo.HighSideMosTemperature_start); goto err; } - /* 判断启动任务中太阳能板开路电压检测间隔时间是否正确 */ - save_configInfo.checkSolarOpenCircuitVTime = - pack->checkSolarOpenCircuitVTime[0] << 8 | pack->checkSolarOpenCircuitVTime[1]; -// debug(" checkSolarOpenCircuitVTime : %d \n", save_configInfo.checkSolarOpenCircuitVTime); - if (save_configInfo.checkSolarOpenCircuitVTime > 1800 || save_configInfo.checkSolarOpenCircuitVTime < 5) { - goto err; - } + // /* 判断启动任务中太阳能板开路电压检测间隔时间是否正确 */ + // save_configInfo.checkSolarOpenCircuitVTime = + // pack->checkSolarOpenCircuitVTime[0] << 8 | pack->checkSolarOpenCircuitVTime[1]; + // if (save_configInfo.checkSolarOpenCircuitVTime > 1800 || save_configInfo.checkSolarOpenCircuitVTime < 5) { + // debug(" checkSolarOpenCircuitVTime : %d \n", save_configInfo.checkSolarOpenCircuitVTime); + // goto err; + // } - /* 判断传感器运行再次注册的间隔是否正确 */ - save_configInfo.sensorEnableBroadcastTime = - pack->sensorEnableBroadcastTime[0] << 8 | pack->sensorEnableBroadcastTime[1]; -// debug(" sensorEnableBroadcastTime : %d \n", save_configInfo.sensorEnableBroadcastTime); - if (save_configInfo.sensorEnableBroadcastTime > 60 || save_configInfo.sensorEnableBroadcastTime < 10) { - goto err; - } + // /* 判断传感器运行再次注册的间隔是否正确 */ + // save_configInfo.sensorEnableBroadcastTime = + // pack->sensorEnableBroadcastTime[0] << 8 | pack->sensorEnableBroadcastTime[1]; + // if (save_configInfo.sensorEnableBroadcastTime > 60 || save_configInfo.sensorEnableBroadcastTime < 10) { + // debug(" sensorEnableBroadcastTime : %d \n", save_configInfo.sensorEnableBroadcastTime); + // goto err; + // } /* 判断出现短路保护后延长该段时间再次检测是否短路,仍然短路则关闭输出的间隔是否正确 */ save_configInfo.outputAgainFlagTime = pack->outputAgainFlagTime[0] << 8 | pack->outputAgainFlagTime[1]; -// debug(" outputAgainFlagTime : %d \n", save_configInfo.outputAgainFlagTime); - if (save_configInfo.sensorEnableBroadcastTime > 30 || save_configInfo.sensorEnableBroadcastTime < 5) { + if (!((save_configInfo.sensorEnableBroadcastTime < 30 && save_configInfo.sensorEnableBroadcastTime > 5) + || saveConfigInfo.sensorEnableBroadcastTime == 0)) { + // debug(" outputAgainFlagTime : %d \n", save_configInfo.outputAgainFlagTime); goto err; } /* 判断出现过载后,在该间隔时间中多次(2次)出现过载,则关闭输出的间隔是否正确 */ save_configInfo.excessiveLoadFlagTime = pack->excessiveLoadFlagTime[0] << 8 | pack->excessiveLoadFlagTime[1]; -// debug(" excessiveLoadFlagTime : %d \n", save_configInfo.excessiveLoadFlagTime); - if (save_configInfo.excessiveLoadFlagTime > 90 || save_configInfo.excessiveLoadFlagTime < 30) { + if (!((save_configInfo.excessiveLoadFlagTime < 90 && save_configInfo.excessiveLoadFlagTime > 20) + || save_configInfo.excessiveLoadFlagTime == 0)) { + // debug(" excessiveLoadFlagTime : %d \n", save_configInfo.excessiveLoadFlagTime); goto err; } /* 判断出现过载过载保护后,在该间隔段时间后,再次尝试输出的间隔是否正确 */ save_configInfo.eLAgainTime = pack->eLAgainTime[0] << 8 | pack->eLAgainTime[1]; -// debug(" eLAgainTime : %d \n", save_configInfo.eLAgainTime); if (save_configInfo.eLAgainTime > 3000 || save_configInfo.eLAgainTime < 1000) { + debug(" eLAgainTime : %d \n", save_configInfo.eLAgainTime); goto err; } /* crc校验 */ save_configInfo.crc = pack->crc[0] << 8 | pack->crc[1]; -// debug(" crc : %x%x \n", pack->crc[0], pack->crc[1]); if (save_configInfo.crc != checkModebusCrc(configBuff, RECV_CONFIG_INFO - 3)) { -// debug(" checkModebusCrc : %x \n", checkModebusCrc(configBuff, RECV_CONFIG_INFO)); + debug(" crc : %x%x \n", pack->crc[0], pack->crc[1]); + debug(" checkModebusCrc : %x \n", checkModebusCrc(configBuff, RECV_CONFIG_INFO)); goto err; } /* 结束标志 */ -// debug(" end_Flag : %x \n", pack->end_Flag); if (pack->end_Flag != 0x16) { + debug(" end_Flag : %x \n", pack->end_Flag); goto err; } @@ -351,10 +364,12 @@ void read_and_process_config_data(void) save_configInfo.CommunicationProtocolType = pack->CommunicationProtocolType; save_configInfo.onlyPower = pack->onlyPower; + save_configInfo.crc = checkModebusCrc((uint8_t *)&save_configInfo, CONFIG_INFO_SIZE - 2); - save_backups_config_info(&save_configInfo); - save_config_info(&save_configInfo); + // save_backups_config_info(&save_configInfo); + // save_config_info(&save_configInfo); + saveConfigInfo(&save_configInfo); // memset(config_buff, 0, sizeof(config_buff)); zeroConfigBuff(); @@ -391,12 +406,11 @@ void read_and_process_config_data(void) // } // Delay_Ms(randomDelay()); // } + uart_dev_write(g_gw485_uart2_handle, "hello world\n", sizeof("hello world\n")); /* 复位 */ NVIC_SystemReset(); - return; - err: // config_buff_pos--; // memcpy(config_buff, config_buff + 1, sizeof(config_buff) - 1); diff --git a/APP/businessLogic/Src/hy_protocol.c b/APP/businessLogic/Src/hy_protocol.c index 649303c..de779cf 100644 --- a/APP/businessLogic/Src/hy_protocol.c +++ b/APP/businessLogic/Src/hy_protocol.c @@ -726,7 +726,7 @@ static int Match_BroadcastCommunicationID(u_int8_t communicationID[4]) communicationID[1] == 0xFF && \ communicationID[2] == 0xFF && \ communicationID[3] == 0xFF) { - log_info("Match_BroadcastCommunicationID success\r\n"); + // log_info("Match_BroadcastCommunicationID success\r\n"); return 1; } return 0; @@ -744,7 +744,7 @@ static int HY_matchCommunicationID(u_int8_t communicationID[4]) (communicationID[1] == g_cfgParameter.communicationID[1]) && \ (communicationID[2] == g_cfgParameter.communicationID[2]) && \ (communicationID[3] == g_cfgParameter.communicationID[3])) { - log_info("Match_CommunicationIDHY success \r\n"); + // log_info("Match_CommunicationIDHY success \r\n"); return 1; } return 0; @@ -763,7 +763,7 @@ static int HY_matchHardwareID(u_int8_t hardwareID[6]) (hardwareID[3] == g_cfgParameter.hardwareID[3]) && \ (hardwareID[4] == g_cfgParameter.hardwareID[4]) && \ (hardwareID[5] == g_cfgParameter.hardwareID[5])) { - log_info("Match_hardwareIDHY success \r\n"); + // log_info("Match_hardwareIDHY success \r\n"); return 1; } return 0; @@ -783,7 +783,7 @@ static int Match_BroadcastHardwareID(u_int8_t hardwareID[6]) hardwareID[3] == 0xFF && \ hardwareID[4] == 0xFF && \ hardwareID[5] == 0xFF) { - log_info("Match_BroadcastHardwareID success\r\n"); + // log_info("Match_BroadcastHardwareID success\r\n"); return 1; } return 0; @@ -807,7 +807,7 @@ static int HY_uart_read_climate_pack(device_handle uart_handle,uint8_t *buff, ui * 0x02 硬件ID **/ uint8_t hardwordIDType = 0; - char c = 0; + uint8_t c = 0; HY_Recv_pack *pack = (HY_Recv_pack *)buff; @@ -825,7 +825,7 @@ static int HY_uart_read_climate_pack(device_handle uart_handle,uint8_t *buff, ui /* 匹配起始标志位 */ if (offset == HY_analyzeStartFlag || (flag_run > 0)) { if (pack->start_Flag != g_cfgParameter.startFlagHY) { - log_info(" Match_start_Flag error %x ", pack->start_Flag); + // log_info(" Match_start_Flag error %x ", pack->start_Flag); // printf("1 : %x \n", pack->start_Flag); memcpy(buff, buff+1, offset-1); offset--; @@ -846,7 +846,7 @@ static int HY_uart_read_climate_pack(device_handle uart_handle,uint8_t *buff, ui } else { - log_info("Match_hardwordID error"); + // log_info("Match_hardwordID error"); hardwordIDType = 0x00; if (flag_run < 1) { flag_run = 1; @@ -863,7 +863,7 @@ static int HY_uart_read_climate_pack(device_handle uart_handle,uint8_t *buff, ui if (flag_run < 2) { flag_run = 2; } - log_info("Match_CommunicationID error"); + // log_info("Match_CommunicationID error"); memcpy(buff, buff+1, offset-1); offset--; continue; @@ -942,7 +942,7 @@ static int HY_uart_read_climate_pack(device_handle uart_handle,uint8_t *buff, ui if (flag_run < 3) { flag_run = 3; } - log_info("Match_controlWord error"); + // log_info("Match_controlWord error"); memcpy(buff, buff+1, offset-1); offset--; continue; @@ -955,10 +955,10 @@ static int HY_uart_read_climate_pack(device_handle uart_handle,uint8_t *buff, ui if (flag_run < 4) { flag_run = 4; } - log_info("Match_dataLen error: %x", len); - log_info("Match_dataLen error: %x", (pack->dataLen[0] << 8 | pack->dataLen[1]) + 16); - log_info("Match_dataLen error: %x", pack->dataLen[0]); - log_info("Match_dataLen error: %x", pack->dataLen[1]); + // log_info("Match_dataLen error: %x", len); + // log_info("Match_dataLen error: %x", (pack->dataLen[0] << 8 | pack->dataLen[1]) + 16); + // log_info("Match_dataLen error: %x", pack->dataLen[0]); + // log_info("Match_dataLen error: %x", pack->dataLen[1]); memcpy(buff, buff+1, offset-1); offset--; continue; @@ -971,7 +971,7 @@ static int HY_uart_read_climate_pack(device_handle uart_handle,uint8_t *buff, ui if (flag_run < 5) { flag_run = 5; } - log_info("check: %x, %x", (HY_CheckFunc(buff, len - 2) & 0xff), buff[len - 2]); + // log_info("check: %x, %x", (HY_CheckFunc(buff, len - 2) & 0xff), buff[len - 2]); memcpy(buff, buff+1, offset-1); offset--; continue; @@ -1107,11 +1107,11 @@ void HY_MsgProcFunc_electricityStatistics(device_handle device, void *pMsg, uint totalChargCapacityInt(0); totalElectricityConsumptionInt(0); - float temp = 0; - // temp = getTotalChargCapacity(); - savetotalChargCapacity(&temp); - // temp = getTotalElectricityConsumption(); - savetotalElectricityConsumption(&temp); + // float temp = 0; + // // temp = getTotalChargCapacity(); + // savetotalChargCapacity(&temp); + // // temp = getTotalElectricityConsumption(); + // savetotalElectricityConsumption(&temp); HY_electricityStatisticsQuery *Tpack = (HY_electricityStatisticsQuery *)pMsg; pack.frameNumber = Tpack->frameNumber; @@ -1145,7 +1145,7 @@ void HY_MsgProcFunc_sensorNumberConfiguration(device_handle device, void *pMsg, temp_configInfo.communicationID[3] = Tpack->newCommunicationID[3]; temp_configInfo.crc = checkModebusCrc((uint8_t *)&temp_configInfo, CONFIG_INFO_SIZE - 2); - save_config_info(&temp_configInfo); + saveConfigInfo(&temp_configInfo); pack.state = HY_success; } @@ -1382,7 +1382,7 @@ void HY_MsgProcFunc_configureProtocolType(device_handle device, void *pMsg, uint temp_configInfo.protocolType = Tpack->protocolType; temp_configInfo.crc = checkModebusCrc((uint8_t *)&temp_configInfo, CONFIG_INFO_SIZE - 2); - save_config_info(&temp_configInfo); + saveConfigInfo(&temp_configInfo); if (g_cfgParameter.protocolType == 0x01) { g_cfgParameter.gw485_Baud = 9600; @@ -1420,7 +1420,7 @@ void HY_MsgProcFunc_configureProtocolType(device_handle device, void *pMsg, uint uart_dev_write(device, &pack, HY_configProtocolTypeResponse_PACK_SIZE); - Init_GW485_uart(); + Init_GW485_uart(g_cfgParameter.gw485_Baud); } @@ -1563,7 +1563,7 @@ void HY_MsgProcFunc_configureHardwareID(device_handle device, void *pMsg, uint32 temp_configInfo.hardwareID[5] = Tpack->hardwareID[5]; temp_configInfo.crc = checkModebusCrc((uint8_t *)&temp_configInfo, CONFIG_INFO_SIZE - 2); - save_config_info(&temp_configInfo); + saveConfigInfo(&temp_configInfo); pack.state = HY_success; } @@ -1665,7 +1665,7 @@ void HY_MsgProcFunc_modifyCommunicationID(device_handle device, void *pMsg, uint temp_configInfo.communicationID[3] = Tpack->newCommunicationID[3]; temp_configInfo.crc = checkModebusCrc((uint8_t *)&temp_configInfo, CONFIG_INFO_SIZE - 2); - save_config_info(&temp_configInfo); + saveConfigInfo(&temp_configInfo); pack.state = HY_success1; } diff --git a/APP/businessLogic/Src/inFlash.c b/APP/businessLogic/Src/inFlash.c index cd9948f..029f2f2 100644 --- a/APP/businessLogic/Src/inFlash.c +++ b/APP/businessLogic/Src/inFlash.c @@ -3,6 +3,7 @@ #include "parameter.h" #include "pDebug.h" +static void save_config_info(config_info *save_config_info); /** * @brief 保存配置信息 @@ -14,15 +15,15 @@ void save_config_info(config_info *save_config_info) write_Flash((uint8_t *)save_config_info, CONFIG_SAVE_ADDR_BEGIN, CONFIG_INFO_SIZE); } -/** - * @brief 保存配置信息到备份区 - * @param save_config_info 需要保存的配置信息 - * @retval None - */ -static void save_backups_config_info(config_info *save_config_info) -{ - write_Flash((uint8_t *)save_config_info, CONFIG_SAVE_addr, CONFIG_INFO_SIZE); -} +// /** +// * @brief 保存配置信息到备份区 +// * @param save_config_info 需要保存的配置信息 +// * @retval None +// */ +// static void save_backups_config_info(config_info *save_config_info) +// { +// write_Flash((uint8_t *)save_config_info, CONFIG_SAVE_addr, CONFIG_INFO_SIZE); +// } /** * @brief 读取配置信息 @@ -34,14 +35,20 @@ void read_config_info(config_info *output_config_info) read_Flash((uint8_t *)output_config_info, CONFIG_SAVE_ADDR_BEGIN, CONFIG_INFO_SIZE); } -/** - * @brief 读取备份的配置信息 - * @param read_config_info 读取配置信息并保存在output_config_info中 - * @retval None - */ -static void read_backups_config_info(config_info *output_config_info) +// /** +// * @brief 读取备份的配置信息 +// * @param read_config_info 读取配置信息并保存在output_config_info中 +// * @retval None +// */ +// static void read_backups_config_info(config_info *output_config_info) +// { +// read_Flash((uint8_t *)output_config_info, CONFIG_SAVE_addr, CONFIG_INFO_SIZE); +// } + +void saveConfigInfo(config_info *config_info) { - read_Flash((uint8_t *)output_config_info, CONFIG_SAVE_addr, CONFIG_INFO_SIZE); + save_config_info(config_info); + // save_backups_config_info(config_info); } /** @@ -52,12 +59,11 @@ static void read_backups_config_info(config_info *output_config_info) */ static void readFlashContent(config_info *config_info) { - // read_config_info(config_info); - - // /* 配置文件正确就返回 */ - // if (config_info->crc == configCheckFunc((uint8_t *)config_info, CONFIG_INFO_SIZE - 2)) { - // return; - // } + read_config_info(config_info); + /* 配置文件正确就返回 */ + if (config_info->crc == configCheckFunc((uint8_t *)config_info, CONFIG_INFO_SIZE - 2)) { + return; + } // /* 更深处的配置文件正确就返回 */ // read_backups_config_info(config_info); @@ -74,8 +80,8 @@ static void readFlashContent(config_info *config_info) config_info->address[4] = 0x11; config_info->address[5] = 0x11; config_info->address[6] = 0x11; - config_info->Access_Node_Type = 0x01; - config_info->Communication_Methods = 0x02; + // config_info->Access_Node_Type = 0x01; + // config_info->Communication_Methods = 0x02; config_info->gw485_Baud = 9600; config_info->bat485_Baud = 115200; @@ -91,7 +97,7 @@ static void readFlashContent(config_info *config_info) config_info->communicationID[3] = 0x01; config_info->protocolType = 0x01; - // config_info->CommunicationProtocolType = 0x00; + config_info->CommunicationProtocolType = 0x01; config_info->onlyPower = 0x01; config_info->constantVoltageV = 14; @@ -104,8 +110,8 @@ static void readFlashContent(config_info *config_info) config_info->HighSideMosTemperature_end = 90; config_info->HighSideMosTemperature_start = 50; - config_info->checkSolarOpenCircuitVTime = 10; - config_info->sensorEnableBroadcastTime = 20; + // config_info->checkSolarOpenCircuitVTime = 10; + // config_info->sensorEnableBroadcastTime = 20; config_info->outputAgainFlagTime = 10; config_info->excessiveLoadFlagTime = 60; config_info->eLAgainTime = 1800; @@ -133,8 +139,8 @@ void config_info_start(void) g_cfgParameter.HighSideMosTemperature_stop = temp_configInfo.HighSideMosTemperature_stop; g_cfgParameter.HighSideMosTemperature_end = temp_configInfo.HighSideMosTemperature_end; g_cfgParameter.HighSideMosTemperature_start = temp_configInfo.HighSideMosTemperature_start; - g_cfgParameter.sensorEnableBroadcastTime = temp_configInfo.sensorEnableBroadcastTime; - g_cfgParameter.checkSolarOpenCircuitVTime = temp_configInfo.checkSolarOpenCircuitVTime; + // g_cfgParameter.sensorEnableBroadcastTime = temp_configInfo.sensorEnableBroadcastTime; +// g_cfgParameter.checkSolarOpenCircuitVTime = temp_configInfo.checkSolarOpenCircuitVTime; g_cfgParameter.outputAgainFlagTime = temp_configInfo.outputAgainFlagTime; g_cfgParameter.excessiveLoadFlagTime = temp_configInfo.excessiveLoadFlagTime; g_cfgParameter.eLAgainTime = temp_configInfo.eLAgainTime; @@ -146,8 +152,8 @@ void config_info_start(void) g_cfgParameter.address[4] = temp_configInfo.address[4]; g_cfgParameter.address[5] = temp_configInfo.address[5]; g_cfgParameter.address[6] = temp_configInfo.address[6]; - g_cfgParameter.Access_Node_Type = temp_configInfo.Access_Node_Type; - g_cfgParameter.Communication_Methods = temp_configInfo.Communication_Methods; + // g_cfgParameter.Access_Node_Type = temp_configInfo.Access_Node_Type; + // g_cfgParameter.Communication_Methods = temp_configInfo.Communication_Methods; g_cfgParameter.hardwareID[0] = temp_configInfo.hardwareID[0]; g_cfgParameter.hardwareID[1] = temp_configInfo.hardwareID[1]; g_cfgParameter.hardwareID[2] = temp_configInfo.hardwareID[2]; @@ -178,9 +184,9 @@ void config_info_start(void) // } else if (g_cfgParameter.protocolType == 0x02) { // g_cfgParameter.gw485_Baud = 115200; // } - // } - g_cfgParameter.gw485_Baud = 9600; + // } g_cfgParameter.gw485_Baud = 115200; + g_cfgParameter.bat485_Baud = 115200; float fTemp; readLoopImpedance(&fTemp); diff --git a/APP/businessLogic/Src/parameter.c b/APP/businessLogic/Src/parameter.c index dc6f88f..7196a29 100644 --- a/APP/businessLogic/Src/parameter.c +++ b/APP/businessLogic/Src/parameter.c @@ -301,7 +301,7 @@ float getTotalElectricityConsumption(void) */ void setTotalElectricityConsumption(void) { - g_otherParameter.totalElectricityConsumption += g_otherParameter.Discharg_Current * g_otherParameter.Output_Voltage; + g_otherParameter.totalElectricityConsumption += g_otherParameter.Discharg_Current / 3600000.0f; } /** @@ -331,7 +331,7 @@ float getTotalChargCapacity(void) */ void setTotalChargCapacity(void) { - g_otherParameter.totalChargCapacity += g_otherParameter.Charg_Current * g_otherParameter.Output_Voltage; + g_otherParameter.totalChargCapacity += g_otherParameter.Charg_Current / 3600000.0f; } /** diff --git a/APP/businessLogic/Src/task.c b/APP/businessLogic/Src/task.c index f337c4e..49a9873 100644 --- a/APP/businessLogic/Src/task.c +++ b/APP/businessLogic/Src/task.c @@ -6,6 +6,10 @@ #include "chargControlEnum.h" #include "bl_chargControl.h" #include "hy_protocol.h" +#include "cfg_protocol.h" +#include "uart_dev.h" +#include "abnormalManage.h" + /* 控制运行指示灯和喂狗 */ // #define runled_reloadVal 1000 /* 任务执行间隔 */ @@ -27,7 +31,7 @@ static STR_TimeSliceOffset m_refreshJudgeData; static void Task_refreshJudgeData(void); /* 启动任务 */ -#define startControl_reloadVal 5000 /* 任务执行间隔 */ +#define startControl_reloadVal 1000 /* 任务执行间隔 */ #define startControl_offset 100 /* 任务执行偏移量 */ static STR_TimeSliceOffset m_startControl; static void Task_startControl(void); @@ -53,11 +57,40 @@ void Task_collectOpenCircuitVoltage(void); /* 限时开启HY协议配置模式 */ #define beginHYconfigMode_reloadVal 1000 /* 任务执行间隔 */ #define beginHYconfigMode_offset 0 /* 任务执行偏移量 */ -STR_TimeSliceOffset m_beginHYconfigMode; -void Task_beginHYconfigMode(void); +static STR_TimeSliceOffset m_beginHYconfigMode; +static void Task_beginHYconfigMode(void); +/* 串口数据接收判断 */ +#define usartJudge_reloadVal 100 /* 任务执行间隔 */ +#define usartJudge_offset 0 /* 任务执行偏移量 */ +static STR_TimeSliceOffset m_usartJudge; +static void Task_usartJudge(void); +/* 串口数据解析和处理 */ +#define usartHandle_reloadVal 20 /* 任务执行间隔 */ +#define usartHandle_offset 0 /* 任务执行偏移量 */ +static STR_TimeSliceOffset m_usartHandle; +static void Task_usartHandle(void); +typedef void (*uartJudgeHandle)(device_handle device); +static uartJudgeHandle uart_judge_handle; +/* 配置文件数据解析和处理 */ +#define usartCfg_reloadVal 200 /* 任务执行间隔 */ +#define usartCfg_offset 0 /* 任务执行偏移量 */ +static STR_TimeSliceOffset m_usartCfg; +static void Task_usartCfg(void); + +/* 短路保护 */ +#define shortCircuitProtection_reloadVal 1000 /* 任务执行间隔 */ +#define shortCircuitProtection_offset 0 /* 任务执行偏移量 */ +static STR_TimeSliceOffset m_shortCircuitProtection; +static void Task_shortCircuitProtection(void); + +/* 过载保护 */ +#define excessiveLoad_reloadVal 1000 /* 任务执行间隔 */ +#define excessiveLoad_offset 0 /* 任务执行偏移量 */ +STR_TimeSliceOffset m_excessiveLoad; +void Task_excessiveLoad(void); /** * @brief 启动时初始化各任务 @@ -75,6 +108,9 @@ void task_Init(void) TimeSliceOffset_Register(&m_collectOpenCircuitVoltage, Task_collectOpenCircuitVoltage , collectOpenCircuitVoltage_reloadVal, collectOpenCircuitVoltage_offset); + uartTaskInit(); + TimeSliceOffset_Register(&m_usartJudge, Task_usartJudge, usartJudge_reloadVal, usartJudge_offset); + TimeSliceOffset_Register(&m_usartCfg, Task_usartCfg, usartCfg_reloadVal, usartCfg_offset); } /** @@ -97,17 +133,17 @@ void Task_wdi(void) { feedDog(); - debug_printf("chargCurrent:%f \n", getChargCurrent()); - debug_printf("outputVoltage:%f \n", getOutputVoltage()); - debug_printf("BatteryVoltage:%f \n", getBatteryVoltage()); - debug_printf("dischargCurrent:%f \n", getDischargCurrent()); - debug_printf("solarInCircuitVoltage:%f \n", getSolarInCircuitVoltage()); - debug_printf("HighSideMosTemperature:%f \n", getHighSideMosTemperature()); - debug_printf("InputVoltage:%f \n", getInputVoltage()); - debug_printf("DischargMosState:%d \n", getDischargMosState()); - debug_printf("MPPT_Mode:%d \n", getMPPT_Mode()); - debug_printf("loopImpedance:%f \n", g_cfgParameter.loopImpedance); - debug_printf("DutyRatio:%f \n", getDutyRatio()); + // debug_printf("chargCurrent:%f \n", getChargCurrent()); + // debug_printf("outputVoltage:%f \n", getOutputVoltage()); + // debug_printf("BatteryVoltage:%f \n", getBatteryVoltage()); + // debug_printf("dischargCurrent:%f \n", getDischargCurrent()); + // debug_printf("solarInCircuitVoltage:%f \n", getSolarInCircuitVoltage()); + // debug_printf("HighSideMosTemperature:%f \n", getHighSideMosTemperature()); + // debug_printf("InputVoltage:%f \n", getInputVoltage()); + // debug_printf("DischargMosState:%d \n", getDischargMosState()); + // debug_printf("MPPT_Mode:%d \n", getMPPT_Mode()); + // debug_printf("loopImpedance:%f \n", g_cfgParameter.loopImpedance); + // debug_printf("DutyRatio:%f \n", getDutyRatio()); /* 每天复位一次,复位前将电量信息写入flash中 */ static uint32_t temp = 60 * 60 * 24; @@ -188,7 +224,7 @@ void Task_startControl(void) /* 判断有无电池 */ - if (getOutputVoltage() > 10) { + if (getOutputVoltage() > 11.0f) { setBatteryState(TRUE); } else { setBatteryState(FALSE); @@ -389,3 +425,175 @@ void beginHYconfigMode(void) , beginHYconfigMode_reloadVal, beginHYconfigMode_offset); } +/** + * @brief 初始化串口任务,确定使用的协议 + * @param + * @retval + */ +void uartTaskInit(void) +{ + // if (g_cfgParameter.CommunicationProtocolType == 0x00) { + // uart_judge_handle = read_and_process_uart_data; + // } else if (g_cfgParameter.CommunicationProtocolType == 0x01) { + // uart_judge_handle = HY_read_and_process_uart_data; + // } + + uart_judge_handle = HY_read_and_process_uart_data; +} + +/** + * @brief 检测有无通信数据传来 + * @param + * @retval + */ +void Task_usartJudge(void) +{ + /* 检测到对上通信串口有数据启动读取并解析任务 */ + if (uart_dev_char_present(g_gw485_uart2_handle)) { + TimeSliceOffset_Register(&m_usartHandle, Task_usartHandle + , usartHandle_reloadVal, usartHandle_offset); + } +} + +/** + * @brief 读取并解析对上通讯的数据 + * @param + * @retval + */ +void Task_usartHandle(void) +{ + TimeSliceOffset_Unregister(&m_usartHandle); + m_usartHandle.runFlag = 0; + uart_judge_handle(g_gw485_uart2_handle); +} + +/** + * @brief 读取并解析配置文件的数据 + * @param + * @retval + */ +void Task_usartCfg(void) +{ + read_and_process_config_data(); +} + +/** + * @brief 短路保护任务,短路后启动该任务 + * @param + * @retval + */ +void Task_shortCircuitProtection(void) +{ + static uint8_t num = 0; + num++; + + /* 设定输出短路保护时间 */ + if (num == g_cfgParameter.outputAgainFlagTime) { + num = 0; + zeroShortCircuit(); + TimeSliceOffset_Unregister(&m_shortCircuitProtection); + m_shortCircuitProtection.runFlag = 0; + + /* 仍然过流,彻底关闭输出 */ + if (readOverCurrState() == FALSE) { + setPowerOutput(FALSE); + } + /* 不过流,则状态位复位 */ + else { + setShortCircuitFlag(FALSE); + } + } +} + +/** + * @brief 启动短路保护任务 + * @param + * @retval + */ +void startShortCircuitProtection(void) +{ + TimeSliceOffset_Register(&m_shortCircuitProtection, Task_shortCircuitProtection + , shortCircuitProtection_reloadVal, shortCircuitProtection_offset); +} + +/** + * @brief 关闭短路保护任务 + * @param + * @retval + */ +void stopShortCircuitProtection(void) +{ + TimeSliceOffset_Unregister(&m_shortCircuitProtection); + m_shortCircuitProtection.runFlag = 0; +} + +/** + * @brief 过载保护任务,输入不够供给输出后启动该任务 + * @param + * @retval + */ +void Task_excessiveLoad(void) +{ + static uint8_t num = 0; + static uint16_t numLong = 0; + + /* 短路保护了则退出过载保护 */ + if (getShortCircuitFlag() == TRUE) { + num = 0; + numLong = 0; + zeroExcessiveLoad(); + setExcessiveLoadFlag(FALSE); + TimeSliceOffset_Unregister(&m_excessiveLoad); + m_excessiveLoad.runFlag = 0; + } + + /* 过载一次 */ + if (getExcessiveLoad() == 1) { + num++; + } + + /* 延迟一段时间打开输出接口 */ + if (num == 1 && getExcessiveLoad() == 1) { + setPowerOutput(TRUE); + } + + /* 多次过载则关闭输出(关闭输出中断中完成),尝试一段时间后再次输出 */ + if (getExcessiveLoad() >= 2) { +// GPIO_WriteBit(POW_OUT_CON_GPIO, POW_OUT_CON_PIN, RESET); + num = 0; + } + + /* 仅过载一次,达到时间后关闭该任务 */ + if (num == g_cfgParameter.excessiveLoadFlagTime) { + num = 0; + setExcessiveLoadFlag(FALSE); + TimeSliceOffset_Unregister(&m_excessiveLoad); + m_excessiveLoad.runFlag = 0; + return; + } + + /* 关闭输出后开始计时 */ + if (readPOW_OUT_PCON_State() == FALSE) { + numLong++; + } + + /* 达到时间就重新尝试输出 */ + if (numLong == g_cfgParameter.eLAgainTime) { + numLong = 0; + TimeSliceOffset_Unregister(&m_excessiveLoad); + m_excessiveLoad.runFlag = 0; + setPowerOutput(TRUE); + setExcessiveLoadFlag(FALSE); + } +} + +/** + * @brief 启动硬件过载保护任务 + * @param + * @retval + */ +void startExcessiveLoadProtection(void) +{ + TimeSliceOffset_Register(&m_excessiveLoad, Task_excessiveLoad + , excessiveLoad_reloadVal, excessiveLoad_offset); +} \ No newline at end of file diff --git a/APP/businessLogic/Src/test.c b/APP/businessLogic/Src/test.c deleted file mode 100644 index bc28a6a..0000000 --- a/APP/businessLogic/Src/test.c +++ /dev/null @@ -1,29 +0,0 @@ - -#include "test.h" -#include "checkTime.h" -#include "uart_dev.h" -#include "HD_TIM.h" -#include "pDebug.h" -#include "parameter.h" -#include "FM_TIM.h" - -void test(void) -{ - tim_Init(); - Init_debug_uart(); - - - while (1) { - HAL_Delay(1000); - // debug_printf("time:%f\r\n", checkAbnormalTime); - // debug_printf("chargCurrent:%f\r\n", getChargCurrent()); - // debug_printf("outputVoltage:%f\r\n", getOutputVoltage()); - // debug_printf("dischargCurrent:%f\r\n", getDischargCurrent()); - // debug_printf("solarInCircuitVoltage:%f\r\n", getSolarInCircuitVoltage()); - } -} - - - - - diff --git a/APP/functionalModule/Inc/FM_GPIO.h b/APP/functionalModule/Inc/FM_GPIO.h index 0ec5672..7774ee4 100644 --- a/APP/functionalModule/Inc/FM_GPIO.h +++ b/APP/functionalModule/Inc/FM_GPIO.h @@ -2,6 +2,7 @@ #define FM_GPIO_H_ #include "HD_GPIO.h" +#include "comm_types.h" void FM_GPIO_Init(void); @@ -10,6 +11,7 @@ void POW_FF_PCON_Close(void); void POW_OUT_PCON_Open(void); void POW_OUT_PCON_Close(void); +BOOL readPOW_OUT_PCON_State(void); void RUN_LEN_Open(void); void RUN_LEN_Close(void); @@ -23,10 +25,12 @@ void EN_PWMOUT_Diseable(void); void feedDog(void); +BOOL readOverCurrState(void); + BOOL readOnlyPowerOutputState(void); BOOL readOutputState(void); -// extern void WORK_VOLT_Interrupt(void); -// extern void DSG_PROT_Interrupt(void); +extern void WORK_VOLT_Interrupt(void); +extern void DSG_PROT_Interrupt(void); #endif diff --git a/APP/functionalModule/Inc/FM_TIM.h b/APP/functionalModule/Inc/FM_TIM.h index 19554dc..3d27411 100644 --- a/APP/functionalModule/Inc/FM_TIM.h +++ b/APP/functionalModule/Inc/FM_TIM.h @@ -13,4 +13,7 @@ extern void chargControl(void); extern void checkAbnormal(void); extern void hw_inc_tick(void); +extern void setTotalElectricityConsumption(void); +extern void setTotalChargCapacity(void); + #endif diff --git a/APP/functionalModule/Inc/uart_dev.h b/APP/functionalModule/Inc/uart_dev.h index 3a62e0a..424197a 100644 --- a/APP/functionalModule/Inc/uart_dev.h +++ b/APP/functionalModule/Inc/uart_dev.h @@ -40,8 +40,8 @@ void uart_close(uartIndex_e uart_index); void uart_sendstr(device_handle device, char *str); void debug_printf(char *format, ...); void Init_debug_uart(void); -void Init_BAT485_uart(void); -void Init_GW485_uart(void); +void Init_BAT485_uart(uint32_t baud); +void Init_GW485_uart(uint32_t baud); uint8_t uart_dev_in_char(device_handle device); int uart_dev_char_present(device_handle device); void uart_dev_write(device_handle device, void *data, int len); diff --git a/APP/functionalModule/Src/FM_GPIO.c b/APP/functionalModule/Src/FM_GPIO.c index 1573679..9a4d97a 100644 --- a/APP/functionalModule/Src/FM_GPIO.c +++ b/APP/functionalModule/Src/FM_GPIO.c @@ -1,6 +1,8 @@ #include "FM_GPIO.h" +#include "uart_dev.h" + void FM_GPIO_Init(void) { HD_GPIO_Init(); @@ -46,6 +48,21 @@ void POW_OUT_PCON_Close(void) HAL_GPIO_WritePin(POW_OUT_CON_GPIO_Port, POW_OUT_CON_Pin, GPIO_PIN_RESET); } +/** + * @brief 读取输出控制引脚状态 + * @param None + * @retval TRUE 打开 + * FALSE 关闭 + */ +BOOL readPOW_OUT_PCON_State(void) +{ + if (HAL_GPIO_ReadPin(POW_OUT_CON_GPIO_Port, POW_OUT_CON_Pin)) { + return TRUE; + } + + return FALSE; +} + /** * @brief 打开LED灯 * @param None @@ -127,6 +144,20 @@ void feedDog(void) HAL_GPIO_WritePin(WDI_INPUT_GPIO_Port, WDI_INPUT_Pin, GPIO_PIN_RESET); } +/** + * @brief 判断过流状态 + * @param None + * @retval + */ +BOOL readOverCurrState(void) +{ + if (HAL_GPIO_ReadPin(DSG_PROT_GPIO_Port, DSG_PROT_Pin)) { + return TRUE; + } + + return FALSE; +} + /** * @brief 仅有充电控制器时,判断输出开关是否打开 * @param None @@ -165,12 +196,12 @@ BOOL readOutputState(void) */ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) { - if (GPIO_Pin == WORK_VOLT_Pin) { - // WORK_VOLT_Interrupt(); + if (GPIO_Pin == WORK_VOLT_INT_Pin) { + WORK_VOLT_Interrupt(); } else if (GPIO_Pin == DSG_PROT_Pin) { - // DSG_PROT_Interrupt(); + DSG_PROT_Interrupt(); } } diff --git a/APP/functionalModule/Src/FM_TIM.c b/APP/functionalModule/Src/FM_TIM.c index d465741..83a6e0e 100644 --- a/APP/functionalModule/Src/FM_TIM.c +++ b/APP/functionalModule/Src/FM_TIM.c @@ -25,8 +25,8 @@ void tim_Init(void) HD_taskBaseTim_Init(); HAL_TIM_Base_Start_IT(&htim16); - HD_time_Init(); - HAL_TIM_Base_Start_IT(&htim15); + // HD_time_Init(); + // HAL_TIM_Base_Start_IT(&htim15); } /** @@ -83,22 +83,27 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) /* USER CODE BEGIN Callback 0 */ /* USER CODE END Callback 0 */ - if (htim->Instance == TIM1) { - HAL_IncTick(); - } + // if (htim->Instance == TIM1) { + // HAL_IncTick(); + // } /* USER CODE BEGIN Callback 1 */ - else if (htim->Instance == TIM7) { + // else if (htim->Instance == TIM7) { + // chargControl(); + // } + if (htim->Instance == TIM7) { chargControl(); } else if (htim->Instance == TIM16) { TimeSliceOffset_Produce(); + setTotalElectricityConsumption(); + setTotalChargCapacity(); } - else if (htim->Instance == TIM15) { - hw_inc_tick(); - } + // else if (htim->Instance == TIM15) { + // hw_inc_tick(); + // } /* USER CODE END Callback 1 */ } \ No newline at end of file diff --git a/APP/functionalModule/Src/uart_dev.c b/APP/functionalModule/Src/uart_dev.c index 768d037..98cd2d0 100644 --- a/APP/functionalModule/Src/uart_dev.c +++ b/APP/functionalModule/Src/uart_dev.c @@ -179,8 +179,9 @@ void Init_debug_uart(void) * @brief 初始化向下通信对电池pack串口. * @retval None */ -void Init_BAT485_uart(void) +void Init_BAT485_uart(uint32_t baud) { + uart_devices[1].uart_baudrate = baud; g_bat485_uart3_handle = uart_dev_init(BAT485_UART_INDEX, Bat485_in_buff, sizeof(Bat485_in_buff)); } @@ -188,8 +189,9 @@ void Init_BAT485_uart(void) * @brief 初始化向上对网关通信485串口. * @retval None */ -void Init_GW485_uart(void) -{ +void Init_GW485_uart(uint32_t baud) +{ + uart_devices[0].uart_baudrate = baud; g_gw485_uart2_handle = uart_dev_init(GW485_UART_INDEX, Gw485_in_buff, sizeof(Gw485_in_buff)); } @@ -215,12 +217,12 @@ uint8_t uart_dev_in_char(device_handle device) */ int uart_dev_char_present(device_handle device) { - uart_device_info *device_info = (uart_device_info *)device; + uart_device_info *device_info = (uart_device_info *)device; - if((!device) || (!device_info->init)) - return 0; + if((!device) || (!device_info->init)) + return 0; - return !RingQueueEmpty(&device_info->uart_ring_queue); + return !RingQueueEmpty(&device_info->uart_ring_queue); } /** @@ -242,7 +244,7 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) gw485_RxIt(); } else if (huart->Instance == USART3) { - bat485_RxIt(); + bat485_RxIt(); } } diff --git a/Core/Inc/stm32g4xx_it.h b/Core/Inc/stm32g4xx_it.h index 6ae9d66..615361c 100644 --- a/Core/Inc/stm32g4xx_it.h +++ b/Core/Inc/stm32g4xx_it.h @@ -61,7 +61,6 @@ void TIM1_UP_TIM16_IRQHandler(void); void USART2_IRQHandler(void); void USART3_IRQHandler(void); void EXTI15_10_IRQHandler(void); -void TIM6_DAC_IRQHandler(void); void TIM7_IRQHandler(void); /* USER CODE BEGIN EFP */ diff --git a/Core/Src/dma.c b/Core/Src/dma.c index b32cd27..6d0d038 100644 --- a/Core/Src/dma.c +++ b/Core/Src/dma.c @@ -45,7 +45,7 @@ void MX_DMA_Init(void) /* DMA interrupt init */ /* DMA1_Channel1_IRQn interrupt configuration */ - HAL_NVIC_SetPriority(DMA1_Channel1_IRQn, 0, 0); + HAL_NVIC_SetPriority(DMA1_Channel1_IRQn, 4, 0); HAL_NVIC_EnableIRQ(DMA1_Channel1_IRQn); } diff --git a/Core/Src/gpio.c b/Core/Src/gpio.c index bae3ca5..39047be 100644 --- a/Core/Src/gpio.c +++ b/Core/Src/gpio.c @@ -81,8 +81,8 @@ void MX_GPIO_Init(void) /*Configure GPIO pin : WORK_VOLT_INT_Pin */ GPIO_InitStruct.Pin = WORK_VOLT_INT_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; - GPIO_InitStruct.Pull = GPIO_PULLUP; + GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; + GPIO_InitStruct.Pull = GPIO_PULLDOWN; HAL_GPIO_Init(WORK_VOLT_INT_GPIO_Port, &GPIO_InitStruct); /* EXTI interrupt init*/ diff --git a/Core/Src/main.c b/Core/Src/main.c index 0a9700f..9c335cf 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -176,27 +176,6 @@ void SystemClock_Config(void) /* USER CODE END 4 */ -/** - * @brief Period elapsed callback in non blocking mode - * @note This function is called when TIM1 interrupt took place, inside - * HAL_TIM_IRQHandler(). It makes a direct call to HAL_IncTick() to increment - * a global variable "uwTick" used as application time base. - * @param htim : TIM handle - * @retval None - */ -// void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) -// { -// /* USER CODE BEGIN Callback 0 */ - -// /* USER CODE END Callback 0 */ -// if (htim->Instance == TIM1) { -// HAL_IncTick(); -// } -// /* USER CODE BEGIN Callback 1 */ - -// /* USER CODE END Callback 1 */ -// } - /** * @brief This function is executed in case of error occurrence. * @retval None diff --git a/Core/Src/stm32g4xx_hal_timebase_tim.c b/Core/Src/stm32g4xx_hal_timebase_tim.c deleted file mode 100644 index 7ac4d76..0000000 --- a/Core/Src/stm32g4xx_hal_timebase_tim.c +++ /dev/null @@ -1,127 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file stm32g4xx_hal_timebase_tim.c - * @brief HAL time base based on the hardware TIM. - ****************************************************************************** - * @attention - * - * Copyright (c) 2024 STMicroelectronics. - * All rights reserved. - * - * This software is licensed under terms that can be found in the LICENSE file - * in the root directory of this software component. - * If no LICENSE file comes with this software, it is provided AS-IS. - * - ****************************************************************************** - */ -/* USER CODE END Header */ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32g4xx_hal.h" -#include "stm32g4xx_hal_tim.h" - -/* Private typedef -----------------------------------------------------------*/ -/* Private define ------------------------------------------------------------*/ -/* Private macro -------------------------------------------------------------*/ -/* Private variables ---------------------------------------------------------*/ -TIM_HandleTypeDef htim1; -/* Private function prototypes -----------------------------------------------*/ -/* Private functions ---------------------------------------------------------*/ - -/** - * @brief This function configures the TIM1 as a time base source. - * The time source is configured to have 1ms time base with a dedicated - * Tick interrupt priority. - * @note This function is called automatically at the beginning of program after - * reset by HAL_Init() or at any time when clock is configured, by HAL_RCC_ClockConfig(). - * @param TickPriority: Tick interrupt priority. - * @retval HAL status - */ -HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) -{ - RCC_ClkInitTypeDef clkconfig; - uint32_t uwTimclock = 0; - uint32_t uwPrescalerValue = 0; - uint32_t pFLatency; - - HAL_StatusTypeDef status; - - /* Enable TIM1 clock */ - __HAL_RCC_TIM1_CLK_ENABLE(); - -/* Get clock configuration */ - HAL_RCC_GetClockConfig(&clkconfig, &pFLatency); - - /* Compute TIM1 clock */ - uwTimclock = HAL_RCC_GetPCLK2Freq(); - - /* Compute the prescaler value to have TIM1 counter clock equal to 1MHz */ - uwPrescalerValue = (uint32_t) ((uwTimclock / 1000000U) - 1U); - - /* Initialize TIM1 */ - htim1.Instance = TIM1; - - /* Initialize TIMx peripheral as follow: - - + Period = [(TIM1CLK/1000) - 1]. to have a (1/1000) s time base. - + Prescaler = (uwTimclock/1000000 - 1) to have a 1MHz counter clock. - + ClockDivision = 0 - + Counter direction = Up - */ - htim1.Init.Period = (1000000U / 1000U) - 1U; - htim1.Init.Prescaler = uwPrescalerValue; - htim1.Init.ClockDivision = 0; - htim1.Init.CounterMode = TIM_COUNTERMODE_UP; - - status = HAL_TIM_Base_Init(&htim1); - if (status == HAL_OK) - { - /* Start the TIM time Base generation in interrupt mode */ - status = HAL_TIM_Base_Start_IT(&htim1); - if (status == HAL_OK) - { - /* Enable the TIM1 global Interrupt */ - HAL_NVIC_EnableIRQ(TIM1_UP_TIM16_IRQn); - /* Configure the SysTick IRQ priority */ - if (TickPriority < (1UL << __NVIC_PRIO_BITS)) - { - /* Configure the TIM IRQ priority */ - HAL_NVIC_SetPriority(TIM1_UP_TIM16_IRQn, TickPriority, 0U); - uwTickPrio = TickPriority; - } - else - { - status = HAL_ERROR; - } - } - } - - /* Return function status */ - return status; -} - -/** - * @brief Suspend Tick increment. - * @note Disable the tick increment by disabling TIM1 update interrupt. - * @param None - * @retval None - */ -void HAL_SuspendTick(void) -{ - /* Disable TIM1 update Interrupt */ - __HAL_TIM_DISABLE_IT(&htim1, TIM_IT_UPDATE); -} - -/** - * @brief Resume Tick increment. - * @note Enable the tick increment by Enabling TIM1 update interrupt. - * @param None - * @retval None - */ -void HAL_ResumeTick(void) -{ - /* Enable TIM1 Update interrupt */ - __HAL_TIM_ENABLE_IT(&htim1, TIM_IT_UPDATE); -} - diff --git a/Core/Src/stm32g4xx_it.c b/Core/Src/stm32g4xx_it.c index 529c085..a335e8a 100644 --- a/Core/Src/stm32g4xx_it.c +++ b/Core/Src/stm32g4xx_it.c @@ -56,14 +56,11 @@ /* External variables --------------------------------------------------------*/ extern DMA_HandleTypeDef hdma_adc1; -extern TIM_HandleTypeDef htim6; extern TIM_HandleTypeDef htim7; extern TIM_HandleTypeDef htim15; extern TIM_HandleTypeDef htim16; extern UART_HandleTypeDef huart2; extern UART_HandleTypeDef huart3; -extern TIM_HandleTypeDef htim1; - /* USER CODE BEGIN EV */ /* USER CODE END EV */ @@ -193,7 +190,7 @@ void SysTick_Handler(void) /* USER CODE BEGIN SysTick_IRQn 0 */ /* USER CODE END SysTick_IRQn 0 */ - + HAL_IncTick(); /* USER CODE BEGIN SysTick_IRQn 1 */ /* USER CODE END SysTick_IRQn 1 */ @@ -242,14 +239,7 @@ void TIM1_UP_TIM16_IRQHandler(void) /* USER CODE BEGIN TIM1_UP_TIM16_IRQn 0 */ /* USER CODE END TIM1_UP_TIM16_IRQn 0 */ - if (htim1.Instance != NULL) - { - HAL_TIM_IRQHandler(&htim1); - } - if (htim16.Instance != NULL) - { - HAL_TIM_IRQHandler(&htim16); - } + HAL_TIM_IRQHandler(&htim16); /* USER CODE BEGIN TIM1_UP_TIM16_IRQn 1 */ /* USER CODE END TIM1_UP_TIM16_IRQn 1 */ @@ -298,20 +288,6 @@ void EXTI15_10_IRQHandler(void) /* USER CODE END EXTI15_10_IRQn 1 */ } -/** - * @brief This function handles TIM6 global interrupt, DAC1 and DAC3 channel underrun error interrupts. - */ -void TIM6_DAC_IRQHandler(void) -{ - /* USER CODE BEGIN TIM6_DAC_IRQn 0 */ - - /* USER CODE END TIM6_DAC_IRQn 0 */ - HAL_TIM_IRQHandler(&htim6); - /* USER CODE BEGIN TIM6_DAC_IRQn 1 */ - - /* USER CODE END TIM6_DAC_IRQn 1 */ -} - /** * @brief This function handles TIM7 global interrupt. */ diff --git a/Core/Src/tim.c b/Core/Src/tim.c index 8e523a8..68aaaab 100644 --- a/Core/Src/tim.c +++ b/Core/Src/tim.c @@ -235,10 +235,6 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle) /* USER CODE END TIM6_MspInit 0 */ /* TIM6 clock enable */ __HAL_RCC_TIM6_CLK_ENABLE(); - - /* TIM6 interrupt Init */ - HAL_NVIC_SetPriority(TIM6_DAC_IRQn, 0, 0); - HAL_NVIC_EnableIRQ(TIM6_DAC_IRQn); /* USER CODE BEGIN TIM6_MspInit 1 */ /* USER CODE END TIM6_MspInit 1 */ @@ -267,7 +263,7 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle) __HAL_RCC_TIM15_CLK_ENABLE(); /* TIM15 interrupt Init */ - HAL_NVIC_SetPriority(TIM1_BRK_TIM15_IRQn, 0, 0); + HAL_NVIC_SetPriority(TIM1_BRK_TIM15_IRQn, 4, 0); HAL_NVIC_EnableIRQ(TIM1_BRK_TIM15_IRQn); /* USER CODE BEGIN TIM15_MspInit 1 */ @@ -282,7 +278,7 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle) __HAL_RCC_TIM16_CLK_ENABLE(); /* TIM16 interrupt Init */ - HAL_NVIC_SetPriority(TIM1_UP_TIM16_IRQn, 15, 0); + HAL_NVIC_SetPriority(TIM1_UP_TIM16_IRQn, 4, 0); HAL_NVIC_EnableIRQ(TIM1_UP_TIM16_IRQn); /* USER CODE BEGIN TIM16_MspInit 1 */ @@ -343,9 +339,6 @@ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* tim_baseHandle) /* USER CODE END TIM6_MspDeInit 0 */ /* Peripheral clock disable */ __HAL_RCC_TIM6_CLK_DISABLE(); - - /* TIM6 interrupt Deinit */ - HAL_NVIC_DisableIRQ(TIM6_DAC_IRQn); /* USER CODE BEGIN TIM6_MspDeInit 1 */ /* USER CODE END TIM6_MspDeInit 1 */ diff --git a/Core/Src/usart.c b/Core/Src/usart.c index 9d48af7..4c22c7f 100644 --- a/Core/Src/usart.c +++ b/Core/Src/usart.c @@ -223,15 +223,22 @@ void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle) PA2 ------> USART2_TX PA3 ------> USART2_RX */ - GPIO_InitStruct.Pin = GW485_RDE_Pin|GW485_TX_Pin|GW485_RX_Pin; + GPIO_InitStruct.Pin = GW485_RDE_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; + GPIO_InitStruct.Alternate = GPIO_AF7_USART2; + HAL_GPIO_Init(GW485_RDE_GPIO_Port, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GW485_TX_Pin|GW485_RX_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_PULLUP; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; GPIO_InitStruct.Alternate = GPIO_AF7_USART2; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* USART2 interrupt Init */ - HAL_NVIC_SetPriority(USART2_IRQn, 0, 0); + HAL_NVIC_SetPriority(USART2_IRQn, 2, 0); HAL_NVIC_EnableIRQ(USART2_IRQn); /* USER CODE BEGIN USART2_MspInit 1 */ @@ -261,15 +268,22 @@ void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle) PB11 ------> USART3_RX PB14 ------> USART3_DE */ - GPIO_InitStruct.Pin = BAT485_TX_Pin|BAT485_RX_Pin|BAT_485_RDE_Pin; + GPIO_InitStruct.Pin = BAT485_TX_Pin|BAT485_RX_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_PULLUP; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; + GPIO_InitStruct.Alternate = GPIO_AF7_USART3; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = BAT_485_RDE_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Alternate = GPIO_AF7_USART3; - HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + HAL_GPIO_Init(BAT_485_RDE_GPIO_Port, &GPIO_InitStruct); /* USART3 interrupt Init */ - HAL_NVIC_SetPriority(USART3_IRQn, 0, 0); + HAL_NVIC_SetPriority(USART3_IRQn, 2, 0); HAL_NVIC_EnableIRQ(USART3_IRQn); /* USER CODE BEGIN USART3_MspInit 1 */ diff --git a/EWARM/chargeController.ewp b/EWARM/chargeController.ewp index d31b98c..922f78c 100644 --- a/EWARM/chargeController.ewp +++ b/EWARM/chargeController.ewp @@ -668,15 +668,15 @@