From 1a4e3e51142377ecdabc41b51cf01048a24c3bbf Mon Sep 17 00:00:00 2001 From: zhaohe Date: Sun, 12 May 2024 11:15:48 +0800 Subject: [PATCH] v1 --- .project | 2 +- dbdb_liquid_path_control_v2 Debug.launch | 83 ---- dbdb_liquid_path_control_v2.cfg | 44 -- dbdb_liquid_path_control_v2.ioc | 316 -------------- dbdb_liquid_path_control_v2.launch | 98 ----- iflytop_canbus_protocol | 2 +- ...ce_disinfection__liquid_ctrl_board Debug.launch | 83 ++++ large_space_disinfection__liquid_ctrl_board.cfg | 44 ++ large_space_disinfection__liquid_ctrl_board.ioc | 316 ++++++++++++++ large_space_disinfection__liquid_ctrl_board.launch | 98 +++++ usrc/base/device_info.cpp | 4 +- usrc/base/hardware.cpp | 32 +- usrc/base/hardware.hpp | 44 +- usrc/project_configs.h | 47 ++- usrc/protocol_impl/basic/fn_mgr.cpp | 4 + usrc/protocol_impl/basic/fn_mgr.hpp | 35 ++ usrc/protocol_impl/basic/report_flag_mgr.cpp | 16 + usrc/protocol_impl/basic/report_flag_mgr.hpp | 32 ++ .../protocol_impl/function_impl/afunction_impl.hpp | 61 +++ usrc/protocol_impl/function_impl/basic_fn.cpp | 91 ++++ .../function_impl/pressure_fn_impl.cpp | 72 ++++ usrc/protocol_impl/function_impl/pump_fn_impl.cpp | 209 ++++++++++ .../function_impl/triple_warning_light_ctl.cpp | 18 + .../function_impl/water_sensor_report_fn_impl.cpp | 64 +++ usrc/protocol_impl/protocol_impl_service.cpp | 456 +++------------------ usrc/protocol_impl/protocol_impl_service.hpp | 1 + usrc/protocol_impl/report_flag_mgr.cpp | 16 - usrc/protocol_impl/report_flag_mgr.hpp | 32 -- 28 files changed, 1289 insertions(+), 1031 deletions(-) delete mode 100644 dbdb_liquid_path_control_v2 Debug.launch delete mode 100644 dbdb_liquid_path_control_v2.cfg delete mode 100644 dbdb_liquid_path_control_v2.ioc delete mode 100644 dbdb_liquid_path_control_v2.launch create mode 100644 large_space_disinfection__liquid_ctrl_board Debug.launch create mode 100644 large_space_disinfection__liquid_ctrl_board.cfg create mode 100644 large_space_disinfection__liquid_ctrl_board.ioc create mode 100644 large_space_disinfection__liquid_ctrl_board.launch create mode 100644 usrc/protocol_impl/basic/fn_mgr.cpp create mode 100644 usrc/protocol_impl/basic/fn_mgr.hpp create mode 100644 usrc/protocol_impl/basic/report_flag_mgr.cpp create mode 100644 usrc/protocol_impl/basic/report_flag_mgr.hpp create mode 100644 usrc/protocol_impl/function_impl/afunction_impl.hpp create mode 100644 usrc/protocol_impl/function_impl/basic_fn.cpp create mode 100644 usrc/protocol_impl/function_impl/pressure_fn_impl.cpp create mode 100644 usrc/protocol_impl/function_impl/pump_fn_impl.cpp create mode 100644 usrc/protocol_impl/function_impl/triple_warning_light_ctl.cpp create mode 100644 usrc/protocol_impl/function_impl/water_sensor_report_fn_impl.cpp delete mode 100644 usrc/protocol_impl/report_flag_mgr.cpp delete mode 100644 usrc/protocol_impl/report_flag_mgr.hpp diff --git a/.project b/.project index b7aad73..3c18559 100644 --- a/.project +++ b/.project @@ -1,6 +1,6 @@ - dbdb_liquid_path_control_v2 + large_space_disinfection__liquid_ctrl_board diff --git a/dbdb_liquid_path_control_v2 Debug.launch b/dbdb_liquid_path_control_v2 Debug.launch deleted file mode 100644 index 2fdd3b8..0000000 --- a/dbdb_liquid_path_control_v2 Debug.launch +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dbdb_liquid_path_control_v2.cfg b/dbdb_liquid_path_control_v2.cfg deleted file mode 100644 index ef37116..0000000 --- a/dbdb_liquid_path_control_v2.cfg +++ /dev/null @@ -1,44 +0,0 @@ -# This is an genericBoard board with a single STM32F407VETx chip -# -# Generated by STM32CubeIDE -# Take care that such file, as generated, may be overridden without any early notice. Please have a look to debug launch configuration setup(s) - -source [find interface/stlink-dap.cfg] - - -set WORKAREASIZE 0x8000 - -transport select "dapdirect_swd" - -set CHIPNAME STM32F407VETx -set BOARDNAME genericBoard - -# Enable debug when in low power modes -set ENABLE_LOW_POWER 1 - -# Stop Watchdog counters when halt -set STOP_WATCHDOG 1 - -# STlink Debug clock frequency -set CLOCK_FREQ 8000 - -# Reset configuration -# use hardware reset, connect under reset -# connect_assert_srst needed if low power mode application running (WFI...) -reset_config srst_only srst_nogate connect_assert_srst -set CONNECT_UNDER_RESET 1 -set CORE_RESET 0 - -# ACCESS PORT NUMBER -set AP_NUM 0 -# GDB PORT -set GDB_PORT 3333 - - - - - -# BCTM CPU variables - -source [find target/stm32f4x.cfg] - diff --git a/dbdb_liquid_path_control_v2.ioc b/dbdb_liquid_path_control_v2.ioc deleted file mode 100644 index 0f5dbb5..0000000 --- a/dbdb_liquid_path_control_v2.ioc +++ /dev/null @@ -1,316 +0,0 @@ -#MicroXplorer Configuration settings - do not modify -CAD.formats= -CAD.pinconfig= -CAD.provider= -CAN1.ABOM=ENABLE -CAN1.BS1=CAN_BS1_14TQ -CAN1.BS2=CAN_BS2_3TQ -CAN1.CalculateBaudRate=500000 -CAN1.CalculateTimeBit=2000 -CAN1.CalculateTimeQuantum=111.11111111111111 -CAN1.IPParameters=CalculateTimeQuantum,CalculateTimeBit,CalculateBaudRate,Prescaler,BS1,BS2,SJW,TTCM,ABOM,NART,RFLM -CAN1.NART=ENABLE -CAN1.Prescaler=4 -CAN1.RFLM=ENABLE -CAN1.SJW=CAN_SJW_3TQ -CAN1.TTCM=ENABLE -Dma.Request0=USART3_RX -Dma.Request1=USART3_TX -Dma.RequestsNb=2 -Dma.USART3_RX.0.Direction=DMA_PERIPH_TO_MEMORY -Dma.USART3_RX.0.FIFOMode=DMA_FIFOMODE_DISABLE -Dma.USART3_RX.0.Instance=DMA1_Stream1 -Dma.USART3_RX.0.MemDataAlignment=DMA_MDATAALIGN_BYTE -Dma.USART3_RX.0.MemInc=DMA_MINC_ENABLE -Dma.USART3_RX.0.Mode=DMA_NORMAL -Dma.USART3_RX.0.PeriphDataAlignment=DMA_PDATAALIGN_BYTE -Dma.USART3_RX.0.PeriphInc=DMA_PINC_DISABLE -Dma.USART3_RX.0.Priority=DMA_PRIORITY_LOW -Dma.USART3_RX.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode -Dma.USART3_TX.1.Direction=DMA_MEMORY_TO_PERIPH -Dma.USART3_TX.1.FIFOMode=DMA_FIFOMODE_DISABLE -Dma.USART3_TX.1.Instance=DMA1_Stream3 -Dma.USART3_TX.1.MemDataAlignment=DMA_MDATAALIGN_BYTE -Dma.USART3_TX.1.MemInc=DMA_MINC_ENABLE -Dma.USART3_TX.1.Mode=DMA_NORMAL -Dma.USART3_TX.1.PeriphDataAlignment=DMA_PDATAALIGN_BYTE -Dma.USART3_TX.1.PeriphInc=DMA_PINC_DISABLE -Dma.USART3_TX.1.Priority=DMA_PRIORITY_LOW -Dma.USART3_TX.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode -FREERTOS.FootprintOK=true -FREERTOS.INCLUDE_uxTaskGetStackHighWaterMark=1 -FREERTOS.IPParameters=Tasks01,FootprintOK,configUSE_NEWLIB_REENTRANT,configUSE_RECURSIVE_MUTEXES,configUSE_COUNTING_SEMAPHORES,configRECORD_STACK_HIGH_ADDRESS,configENABLE_FPU,configTOTAL_HEAP_SIZE,configMINIMAL_STACK_SIZE,INCLUDE_uxTaskGetStackHighWaterMark,configUSE_MALLOC_FAILED_HOOK,configCHECK_FOR_STACK_OVERFLOW,configUSE_TIMERS,configTIMER_TASK_PRIORITY,configUSE_TRACE_FACILITY,configGENERATE_RUN_TIME_STATS,configUSE_STATS_FORMATTING_FUNCTIONS,configUSE_IDLE_HOOK,configUSE_TICK_HOOK -FREERTOS.Tasks01=defaultTask,-3,1024,StartDefaultTask,As weak,NULL,Dynamic,NULL,NULL -FREERTOS.configCHECK_FOR_STACK_OVERFLOW=1 -FREERTOS.configENABLE_FPU=1 -FREERTOS.configGENERATE_RUN_TIME_STATS=1 -FREERTOS.configMINIMAL_STACK_SIZE=512 -FREERTOS.configRECORD_STACK_HIGH_ADDRESS=1 -FREERTOS.configTIMER_TASK_PRIORITY=3 -FREERTOS.configTOTAL_HEAP_SIZE=50000 -FREERTOS.configUSE_COUNTING_SEMAPHORES=1 -FREERTOS.configUSE_IDLE_HOOK=1 -FREERTOS.configUSE_MALLOC_FAILED_HOOK=1 -FREERTOS.configUSE_NEWLIB_REENTRANT=1 -FREERTOS.configUSE_RECURSIVE_MUTEXES=1 -FREERTOS.configUSE_STATS_FORMATTING_FUNCTIONS=1 -FREERTOS.configUSE_TICK_HOOK=1 -FREERTOS.configUSE_TIMERS=1 -FREERTOS.configUSE_TRACE_FACILITY=1 -File.Version=6 -GPIO.groupedBy=Group By Peripherals -IWDG.IPParameters=Prescaler,Reload -IWDG.Prescaler=IWDG_PRESCALER_256 -IWDG.Reload=500 -KeepUserPlacement=false -Mcu.CPN=STM32F407VET6 -Mcu.Family=STM32F4 -Mcu.IP0=CAN1 -Mcu.IP1=CRC -Mcu.IP10=TIM1 -Mcu.IP11=TIM3 -Mcu.IP12=TIM6 -Mcu.IP13=TIM7 -Mcu.IP14=USART1 -Mcu.IP15=USART2 -Mcu.IP16=USART3 -Mcu.IP2=DMA -Mcu.IP3=FREERTOS -Mcu.IP4=IWDG -Mcu.IP5=NVIC -Mcu.IP6=RCC -Mcu.IP7=RNG -Mcu.IP8=SPI1 -Mcu.IP9=SYS -Mcu.IPNb=17 -Mcu.Name=STM32F407V(E-G)Tx -Mcu.Package=LQFP100 -Mcu.Pin0=PH0-OSC_IN -Mcu.Pin1=PH1-OSC_OUT -Mcu.Pin10=PB11 -Mcu.Pin11=PC9 -Mcu.Pin12=PA9 -Mcu.Pin13=PA10 -Mcu.Pin14=PA11 -Mcu.Pin15=PA12 -Mcu.Pin16=PA13 -Mcu.Pin17=PA14 -Mcu.Pin18=PD3 -Mcu.Pin19=VP_CRC_VS_CRC -Mcu.Pin2=PC0 -Mcu.Pin20=VP_FREERTOS_VS_CMSIS_V1 -Mcu.Pin21=VP_IWDG_VS_IWDG -Mcu.Pin22=VP_RNG_VS_RNG -Mcu.Pin23=VP_SYS_VS_tim11 -Mcu.Pin24=VP_TIM1_VS_ClockSourceINT -Mcu.Pin25=VP_TIM3_VS_ClockSourceINT -Mcu.Pin26=VP_TIM6_VS_ClockSourceINT -Mcu.Pin27=VP_TIM7_VS_ClockSourceINT -Mcu.Pin3=PA2 -Mcu.Pin4=PA3 -Mcu.Pin5=PA5 -Mcu.Pin6=PA6 -Mcu.Pin7=PA7 -Mcu.Pin8=PC4 -Mcu.Pin9=PB10 -Mcu.PinsNb=28 -Mcu.ThirdPartyNb=0 -Mcu.UserConstants= -Mcu.UserName=STM32F407VETx -MxCube.Version=6.11.0 -MxDb.Version=DB.6.0.110 -NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false -NVIC.CAN1_RX0_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true -NVIC.CAN1_RX1_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true -NVIC.CAN1_SCE_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true -NVIC.CAN1_TX_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true -NVIC.DMA1_Stream1_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true\:true -NVIC.DMA1_Stream3_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true\:true -NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false -NVIC.ForceEnableDMAVector=true -NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false -NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false -NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false -NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:false\:false\:false -NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 -NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false\:false -NVIC.SavedPendsvIrqHandlerGenerated=true -NVIC.SavedSvcallIrqHandlerGenerated=true -NVIC.SavedSystickIrqHandlerGenerated=true -NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:false\:true\:false\:true\:false -NVIC.TIM1_TRG_COM_TIM11_IRQn=true\:15\:0\:false\:false\:true\:false\:false\:true\:true -NVIC.TIM6_DAC_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true -NVIC.TIM7_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true -NVIC.TimeBase=TIM1_TRG_COM_TIM11_IRQn -NVIC.TimeBaseIP=TIM11 -NVIC.USART3_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true -NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false -PA10.Mode=Asynchronous -PA10.Signal=USART1_RX -PA11.Locked=true -PA11.Mode=CAN_Activate -PA11.Signal=CAN1_RX -PA12.Locked=true -PA12.Mode=CAN_Activate -PA12.Signal=CAN1_TX -PA13.Mode=Serial_Wire -PA13.Signal=SYS_JTMS-SWDIO -PA14.Mode=Serial_Wire -PA14.Signal=SYS_JTCK-SWCLK -PA2.Locked=true -PA2.Mode=Asynchronous -PA2.Signal=USART2_TX -PA3.Locked=true -PA3.Mode=Asynchronous -PA3.Signal=USART2_RX -PA5.Mode=Full_Duplex_Master -PA5.Signal=SPI1_SCK -PA6.Mode=Full_Duplex_Master -PA6.Signal=SPI1_MISO -PA7.Mode=Full_Duplex_Master -PA7.Signal=SPI1_MOSI -PA9.Locked=true -PA9.Mode=Asynchronous -PA9.Signal=USART1_TX -PB10.Locked=true -PB10.Mode=Asynchronous -PB10.Signal=USART3_TX -PB11.Locked=true -PB11.Mode=Asynchronous -PB11.Signal=USART3_RX -PC0.Locked=true -PC0.Signal=GPXTI0 -PC4.Locked=true -PC4.Signal=GPXTI4 -PC9.Locked=true -PC9.Mode=Clock-out-2 -PC9.Signal=RCC_MCO_2 -PD3.Locked=true -PD3.Signal=GPIO_Output -PH0-OSC_IN.Mode=HSE-External-Oscillator -PH0-OSC_IN.Signal=RCC_OSC_IN -PH1-OSC_OUT.Mode=HSE-External-Oscillator -PH1-OSC_OUT.Signal=RCC_OSC_OUT -PinOutPanel.RotationAngle=0 -ProjectManager.AskForMigrate=true -ProjectManager.BackupPrevious=false -ProjectManager.CompilerOptimize=6 -ProjectManager.ComputerToolchain=false -ProjectManager.CoupleFile=true -ProjectManager.CustomerFirmwarePackage= -ProjectManager.DefaultFWLocation=true -ProjectManager.DeletePrevious=false -ProjectManager.DeviceId=STM32F407VETx -ProjectManager.FirmwarePackage=STM32Cube FW_F4 V1.28.0 -ProjectManager.FreePins=true -ProjectManager.HalAssertFull=true -ProjectManager.HeapSize=0x0000 -ProjectManager.KeepUserCode=true -ProjectManager.LastFirmware=true -ProjectManager.LibraryCopy=1 -ProjectManager.MainLocation=Core/Src -ProjectManager.MultiThreaded=true -ProjectManager.NoMain=false -ProjectManager.PreviousToolchain=STM32CubeIDE -ProjectManager.ProjectBuild=false -ProjectManager.ProjectFileName=dbdb_liquid_path_control_v2.ioc -ProjectManager.ProjectName=dbdb_liquid_path_control_v2 -ProjectManager.ProjectStructure= -ProjectManager.RegisterCallBack= -ProjectManager.StackSize=0x2000 -ProjectManager.TargetToolchain=STM32CubeIDE -ProjectManager.ThreadSafeStrategy=Cortex-M4NS\:FreeRtosStrategy4, -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_USART1_UART_Init-USART1-false-HAL-true,5-MX_TIM3_Init-TIM3-false-HAL-true,6-MX_CRC_Init-CRC-false-HAL-true,7-MX_RNG_Init-RNG-false-HAL-true,8-MX_TIM7_Init-TIM7-false-HAL-true,9-MX_TIM6_Init-TIM6-false-HAL-true,10-MX_TIM1_Init-TIM1-false-HAL-true,11-MX_USART3_UART_Init-USART3-false-HAL-true,12-MX_CAN1_Init-CAN1-false-HAL-true,13-MX_SPI1_Init-SPI1-false-HAL-true,14-MX_USART2_UART_Init-USART2-false-HAL-true -RCC.48MHZClocksFreq_Value=48000000 -RCC.AHBFreq_Value=144000000 -RCC.APB1CLKDivider=RCC_HCLK_DIV4 -RCC.APB1Freq_Value=36000000 -RCC.APB1TimFreq_Value=72000000 -RCC.APB2CLKDivider=RCC_HCLK_DIV2 -RCC.APB2Freq_Value=72000000 -RCC.APB2TimFreq_Value=144000000 -RCC.CortexFreq_Value=144000000 -RCC.EthernetFreq_Value=144000000 -RCC.FCLKCortexFreq_Value=144000000 -RCC.FamilyName=M -RCC.HCLKFreq_Value=144000000 -RCC.HSE_VALUE=8000000 -RCC.HSI_VALUE=16000000 -RCC.I2SClocksFreq_Value=64000000 -RCC.IPParameters=48MHZClocksFreq_Value,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2CLKDivider,APB2Freq_Value,APB2TimFreq_Value,CortexFreq_Value,EthernetFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,HSI_VALUE,I2SClocksFreq_Value,LSE_VALUE,LSI_VALUE,MCO1PinFreq_Value,MCO2PinFreq_Value,PLLCLKFreq_Value,PLLI2SN,PLLM,PLLN,PLLQ,PLLQCLKFreq_Value,PLLSourceVirtual,RCC_MCO1Source,RCC_MCO2Source,RCC_MCODiv1,RCC_MCODiv2,RTCFreq_Value,RTCHSEDivFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,VCOI2SOutputFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VcooutputI2S -RCC.LSE_VALUE=32768 -RCC.LSI_VALUE=32000 -RCC.MCO1PinFreq_Value=36000000 -RCC.MCO2PinFreq_Value=16000000 -RCC.PLLCLKFreq_Value=144000000 -RCC.PLLI2SN=64 -RCC.PLLM=4 -RCC.PLLN=144 -RCC.PLLQ=6 -RCC.PLLQCLKFreq_Value=48000000 -RCC.PLLSourceVirtual=RCC_PLLSOURCE_HSE -RCC.RCC_MCO1Source=RCC_MCO1SOURCE_PLLCLK -RCC.RCC_MCO2Source=RCC_MCO2SOURCE_PLLI2SCLK -RCC.RCC_MCODiv1=RCC_MCODIV_4 -RCC.RCC_MCODiv2=RCC_MCODIV_4 -RCC.RTCFreq_Value=32000 -RCC.RTCHSEDivFreq_Value=4000000 -RCC.SYSCLKFreq_VALUE=144000000 -RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK -RCC.VCOI2SOutputFreq_Value=128000000 -RCC.VCOInputFreq_Value=2000000 -RCC.VCOOutputFreq_Value=288000000 -RCC.VcooutputI2S=64000000 -SH.GPXTI0.0=GPIO_EXTI0 -SH.GPXTI0.ConfNb=1 -SH.GPXTI4.0=GPIO_EXTI4 -SH.GPXTI4.ConfNb=1 -SPI1.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_128 -SPI1.CalculateBaudRate=562.5 KBits/s -SPI1.Direction=SPI_DIRECTION_2LINES -SPI1.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler -SPI1.Mode=SPI_MODE_MASTER -SPI1.VirtualType=VM_MASTER -TIM1.IPParameters=Period,Prescaler -TIM1.Period=9999 -TIM1.Prescaler=143 -TIM3.IPParameters=Prescaler,Period -TIM3.Period=9999 -TIM3.Prescaler=71 -TIM6.IPParameters=Prescaler -TIM6.Prescaler=71 -TIM7.IPParameters=Prescaler -TIM7.Prescaler=81 -USART1.BaudRate=460800 -USART1.IPParameters=VirtualMode,BaudRate -USART1.VirtualMode=VM_ASYNC -USART2.IPParameters=VirtualMode -USART2.VirtualMode=VM_ASYNC -USART3.BaudRate=9600 -USART3.IPParameters=VirtualMode,BaudRate -USART3.VirtualMode=VM_ASYNC -VP_CRC_VS_CRC.Mode=CRC_Activate -VP_CRC_VS_CRC.Signal=CRC_VS_CRC -VP_FREERTOS_VS_CMSIS_V1.Mode=CMSIS_V1 -VP_FREERTOS_VS_CMSIS_V1.Signal=FREERTOS_VS_CMSIS_V1 -VP_IWDG_VS_IWDG.Mode=IWDG_Activate -VP_IWDG_VS_IWDG.Signal=IWDG_VS_IWDG -VP_RNG_VS_RNG.Mode=RNG_Activate -VP_RNG_VS_RNG.Signal=RNG_VS_RNG -VP_SYS_VS_tim11.Mode=TIM11 -VP_SYS_VS_tim11.Signal=SYS_VS_tim11 -VP_TIM1_VS_ClockSourceINT.Mode=Internal -VP_TIM1_VS_ClockSourceINT.Signal=TIM1_VS_ClockSourceINT -VP_TIM3_VS_ClockSourceINT.Mode=Internal -VP_TIM3_VS_ClockSourceINT.Signal=TIM3_VS_ClockSourceINT -VP_TIM6_VS_ClockSourceINT.Mode=Enable_Timer -VP_TIM6_VS_ClockSourceINT.Signal=TIM6_VS_ClockSourceINT -VP_TIM7_VS_ClockSourceINT.Mode=Enable_Timer -VP_TIM7_VS_ClockSourceINT.Signal=TIM7_VS_ClockSourceINT -board=custom -rtos.0.ip=FREERTOS -isbadioc=false diff --git a/dbdb_liquid_path_control_v2.launch b/dbdb_liquid_path_control_v2.launch deleted file mode 100644 index 34468c0..0000000 --- a/dbdb_liquid_path_control_v2.launch +++ /dev/null @@ -1,98 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/iflytop_canbus_protocol b/iflytop_canbus_protocol index 0e47768..eb739c1 160000 --- a/iflytop_canbus_protocol +++ b/iflytop_canbus_protocol @@ -1 +1 @@ -Subproject commit 0e47768d3761fa4926957ad385416dc9410861bc +Subproject commit eb739c10f2971294ee3a12e845e9bfb4cb40f32d diff --git a/large_space_disinfection__liquid_ctrl_board Debug.launch b/large_space_disinfection__liquid_ctrl_board Debug.launch new file mode 100644 index 0000000..a2544d6 --- /dev/null +++ b/large_space_disinfection__liquid_ctrl_board Debug.launch @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/large_space_disinfection__liquid_ctrl_board.cfg b/large_space_disinfection__liquid_ctrl_board.cfg new file mode 100644 index 0000000..ef37116 --- /dev/null +++ b/large_space_disinfection__liquid_ctrl_board.cfg @@ -0,0 +1,44 @@ +# This is an genericBoard board with a single STM32F407VETx chip +# +# Generated by STM32CubeIDE +# Take care that such file, as generated, may be overridden without any early notice. Please have a look to debug launch configuration setup(s) + +source [find interface/stlink-dap.cfg] + + +set WORKAREASIZE 0x8000 + +transport select "dapdirect_swd" + +set CHIPNAME STM32F407VETx +set BOARDNAME genericBoard + +# Enable debug when in low power modes +set ENABLE_LOW_POWER 1 + +# Stop Watchdog counters when halt +set STOP_WATCHDOG 1 + +# STlink Debug clock frequency +set CLOCK_FREQ 8000 + +# Reset configuration +# use hardware reset, connect under reset +# connect_assert_srst needed if low power mode application running (WFI...) +reset_config srst_only srst_nogate connect_assert_srst +set CONNECT_UNDER_RESET 1 +set CORE_RESET 0 + +# ACCESS PORT NUMBER +set AP_NUM 0 +# GDB PORT +set GDB_PORT 3333 + + + + + +# BCTM CPU variables + +source [find target/stm32f4x.cfg] + diff --git a/large_space_disinfection__liquid_ctrl_board.ioc b/large_space_disinfection__liquid_ctrl_board.ioc new file mode 100644 index 0000000..abd9746 --- /dev/null +++ b/large_space_disinfection__liquid_ctrl_board.ioc @@ -0,0 +1,316 @@ +#MicroXplorer Configuration settings - do not modify +CAD.formats= +CAD.pinconfig= +CAD.provider= +CAN1.ABOM=ENABLE +CAN1.BS1=CAN_BS1_14TQ +CAN1.BS2=CAN_BS2_3TQ +CAN1.CalculateBaudRate=500000 +CAN1.CalculateTimeBit=2000 +CAN1.CalculateTimeQuantum=111.11111111111111 +CAN1.IPParameters=CalculateTimeQuantum,CalculateTimeBit,CalculateBaudRate,Prescaler,BS1,BS2,SJW,TTCM,ABOM,NART,RFLM +CAN1.NART=ENABLE +CAN1.Prescaler=4 +CAN1.RFLM=ENABLE +CAN1.SJW=CAN_SJW_3TQ +CAN1.TTCM=ENABLE +Dma.Request0=USART3_RX +Dma.Request1=USART3_TX +Dma.RequestsNb=2 +Dma.USART3_RX.0.Direction=DMA_PERIPH_TO_MEMORY +Dma.USART3_RX.0.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.USART3_RX.0.Instance=DMA1_Stream1 +Dma.USART3_RX.0.MemDataAlignment=DMA_MDATAALIGN_BYTE +Dma.USART3_RX.0.MemInc=DMA_MINC_ENABLE +Dma.USART3_RX.0.Mode=DMA_NORMAL +Dma.USART3_RX.0.PeriphDataAlignment=DMA_PDATAALIGN_BYTE +Dma.USART3_RX.0.PeriphInc=DMA_PINC_DISABLE +Dma.USART3_RX.0.Priority=DMA_PRIORITY_LOW +Dma.USART3_RX.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode +Dma.USART3_TX.1.Direction=DMA_MEMORY_TO_PERIPH +Dma.USART3_TX.1.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.USART3_TX.1.Instance=DMA1_Stream3 +Dma.USART3_TX.1.MemDataAlignment=DMA_MDATAALIGN_BYTE +Dma.USART3_TX.1.MemInc=DMA_MINC_ENABLE +Dma.USART3_TX.1.Mode=DMA_NORMAL +Dma.USART3_TX.1.PeriphDataAlignment=DMA_PDATAALIGN_BYTE +Dma.USART3_TX.1.PeriphInc=DMA_PINC_DISABLE +Dma.USART3_TX.1.Priority=DMA_PRIORITY_LOW +Dma.USART3_TX.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode +FREERTOS.FootprintOK=true +FREERTOS.INCLUDE_uxTaskGetStackHighWaterMark=1 +FREERTOS.IPParameters=Tasks01,FootprintOK,configUSE_NEWLIB_REENTRANT,configUSE_RECURSIVE_MUTEXES,configUSE_COUNTING_SEMAPHORES,configRECORD_STACK_HIGH_ADDRESS,configENABLE_FPU,configTOTAL_HEAP_SIZE,configMINIMAL_STACK_SIZE,INCLUDE_uxTaskGetStackHighWaterMark,configUSE_MALLOC_FAILED_HOOK,configCHECK_FOR_STACK_OVERFLOW,configUSE_TIMERS,configTIMER_TASK_PRIORITY,configUSE_TRACE_FACILITY,configGENERATE_RUN_TIME_STATS,configUSE_STATS_FORMATTING_FUNCTIONS,configUSE_IDLE_HOOK,configUSE_TICK_HOOK +FREERTOS.Tasks01=defaultTask,-3,1024,StartDefaultTask,As weak,NULL,Dynamic,NULL,NULL +FREERTOS.configCHECK_FOR_STACK_OVERFLOW=1 +FREERTOS.configENABLE_FPU=1 +FREERTOS.configGENERATE_RUN_TIME_STATS=1 +FREERTOS.configMINIMAL_STACK_SIZE=512 +FREERTOS.configRECORD_STACK_HIGH_ADDRESS=1 +FREERTOS.configTIMER_TASK_PRIORITY=3 +FREERTOS.configTOTAL_HEAP_SIZE=50000 +FREERTOS.configUSE_COUNTING_SEMAPHORES=1 +FREERTOS.configUSE_IDLE_HOOK=1 +FREERTOS.configUSE_MALLOC_FAILED_HOOK=1 +FREERTOS.configUSE_NEWLIB_REENTRANT=1 +FREERTOS.configUSE_RECURSIVE_MUTEXES=1 +FREERTOS.configUSE_STATS_FORMATTING_FUNCTIONS=1 +FREERTOS.configUSE_TICK_HOOK=1 +FREERTOS.configUSE_TIMERS=1 +FREERTOS.configUSE_TRACE_FACILITY=1 +File.Version=6 +GPIO.groupedBy=Group By Peripherals +IWDG.IPParameters=Prescaler,Reload +IWDG.Prescaler=IWDG_PRESCALER_256 +IWDG.Reload=500 +KeepUserPlacement=false +Mcu.CPN=STM32F407VET6 +Mcu.Family=STM32F4 +Mcu.IP0=CAN1 +Mcu.IP1=CRC +Mcu.IP10=TIM1 +Mcu.IP11=TIM3 +Mcu.IP12=TIM6 +Mcu.IP13=TIM7 +Mcu.IP14=USART1 +Mcu.IP15=USART2 +Mcu.IP16=USART3 +Mcu.IP2=DMA +Mcu.IP3=FREERTOS +Mcu.IP4=IWDG +Mcu.IP5=NVIC +Mcu.IP6=RCC +Mcu.IP7=RNG +Mcu.IP8=SPI1 +Mcu.IP9=SYS +Mcu.IPNb=17 +Mcu.Name=STM32F407V(E-G)Tx +Mcu.Package=LQFP100 +Mcu.Pin0=PH0-OSC_IN +Mcu.Pin1=PH1-OSC_OUT +Mcu.Pin10=PB11 +Mcu.Pin11=PC9 +Mcu.Pin12=PA9 +Mcu.Pin13=PA10 +Mcu.Pin14=PA11 +Mcu.Pin15=PA12 +Mcu.Pin16=PA13 +Mcu.Pin17=PA14 +Mcu.Pin18=PD3 +Mcu.Pin19=VP_CRC_VS_CRC +Mcu.Pin2=PC0 +Mcu.Pin20=VP_FREERTOS_VS_CMSIS_V1 +Mcu.Pin21=VP_IWDG_VS_IWDG +Mcu.Pin22=VP_RNG_VS_RNG +Mcu.Pin23=VP_SYS_VS_tim11 +Mcu.Pin24=VP_TIM1_VS_ClockSourceINT +Mcu.Pin25=VP_TIM3_VS_ClockSourceINT +Mcu.Pin26=VP_TIM6_VS_ClockSourceINT +Mcu.Pin27=VP_TIM7_VS_ClockSourceINT +Mcu.Pin3=PA2 +Mcu.Pin4=PA3 +Mcu.Pin5=PA5 +Mcu.Pin6=PA6 +Mcu.Pin7=PA7 +Mcu.Pin8=PC4 +Mcu.Pin9=PB10 +Mcu.PinsNb=28 +Mcu.ThirdPartyNb=0 +Mcu.UserConstants= +Mcu.UserName=STM32F407VETx +MxCube.Version=6.11.0 +MxDb.Version=DB.6.0.110 +NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false +NVIC.CAN1_RX0_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true +NVIC.CAN1_RX1_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true +NVIC.CAN1_SCE_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true +NVIC.CAN1_TX_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true +NVIC.DMA1_Stream1_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true\:true +NVIC.DMA1_Stream3_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true\:true +NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false +NVIC.ForceEnableDMAVector=true +NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false +NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false +NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false +NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:false\:false\:false +NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 +NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false\:false +NVIC.SavedPendsvIrqHandlerGenerated=true +NVIC.SavedSvcallIrqHandlerGenerated=true +NVIC.SavedSystickIrqHandlerGenerated=true +NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:false\:true\:false\:true\:false +NVIC.TIM1_TRG_COM_TIM11_IRQn=true\:15\:0\:false\:false\:true\:false\:false\:true\:true +NVIC.TIM6_DAC_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true +NVIC.TIM7_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true +NVIC.TimeBase=TIM1_TRG_COM_TIM11_IRQn +NVIC.TimeBaseIP=TIM11 +NVIC.USART3_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true +NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false +PA10.Mode=Asynchronous +PA10.Signal=USART1_RX +PA11.Locked=true +PA11.Mode=CAN_Activate +PA11.Signal=CAN1_RX +PA12.Locked=true +PA12.Mode=CAN_Activate +PA12.Signal=CAN1_TX +PA13.Mode=Serial_Wire +PA13.Signal=SYS_JTMS-SWDIO +PA14.Mode=Serial_Wire +PA14.Signal=SYS_JTCK-SWCLK +PA2.Locked=true +PA2.Mode=Asynchronous +PA2.Signal=USART2_TX +PA3.Locked=true +PA3.Mode=Asynchronous +PA3.Signal=USART2_RX +PA5.Mode=Full_Duplex_Master +PA5.Signal=SPI1_SCK +PA6.Mode=Full_Duplex_Master +PA6.Signal=SPI1_MISO +PA7.Mode=Full_Duplex_Master +PA7.Signal=SPI1_MOSI +PA9.Locked=true +PA9.Mode=Asynchronous +PA9.Signal=USART1_TX +PB10.Locked=true +PB10.Mode=Asynchronous +PB10.Signal=USART3_TX +PB11.Locked=true +PB11.Mode=Asynchronous +PB11.Signal=USART3_RX +PC0.Locked=true +PC0.Signal=GPXTI0 +PC4.Locked=true +PC4.Signal=GPXTI4 +PC9.Locked=true +PC9.Mode=Clock-out-2 +PC9.Signal=RCC_MCO_2 +PD3.Locked=true +PD3.Signal=GPIO_Output +PH0-OSC_IN.Mode=HSE-External-Oscillator +PH0-OSC_IN.Signal=RCC_OSC_IN +PH1-OSC_OUT.Mode=HSE-External-Oscillator +PH1-OSC_OUT.Signal=RCC_OSC_OUT +PinOutPanel.RotationAngle=0 +ProjectManager.AskForMigrate=true +ProjectManager.BackupPrevious=false +ProjectManager.CompilerOptimize=6 +ProjectManager.ComputerToolchain=false +ProjectManager.CoupleFile=true +ProjectManager.CustomerFirmwarePackage= +ProjectManager.DefaultFWLocation=true +ProjectManager.DeletePrevious=false +ProjectManager.DeviceId=STM32F407VETx +ProjectManager.FirmwarePackage=STM32Cube FW_F4 V1.28.0 +ProjectManager.FreePins=true +ProjectManager.HalAssertFull=true +ProjectManager.HeapSize=0x0000 +ProjectManager.KeepUserCode=true +ProjectManager.LastFirmware=true +ProjectManager.LibraryCopy=1 +ProjectManager.MainLocation=Core/Src +ProjectManager.MultiThreaded=true +ProjectManager.NoMain=false +ProjectManager.PreviousToolchain=STM32CubeIDE +ProjectManager.ProjectBuild=false +ProjectManager.ProjectFileName=large_space_disinfection__liquid_ctrl_board.ioc +ProjectManager.ProjectName=large_space_disinfection__liquid_ctrl_board +ProjectManager.ProjectStructure= +ProjectManager.RegisterCallBack= +ProjectManager.StackSize=0x2000 +ProjectManager.TargetToolchain=STM32CubeIDE +ProjectManager.ThreadSafeStrategy=Cortex-M4NS\:FreeRtosStrategy4, +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_USART1_UART_Init-USART1-false-HAL-true,5-MX_TIM3_Init-TIM3-false-HAL-true,6-MX_CRC_Init-CRC-false-HAL-true,7-MX_RNG_Init-RNG-false-HAL-true,8-MX_TIM7_Init-TIM7-false-HAL-true,9-MX_TIM6_Init-TIM6-false-HAL-true,10-MX_TIM1_Init-TIM1-false-HAL-true,11-MX_USART3_UART_Init-USART3-false-HAL-true,12-MX_CAN1_Init-CAN1-false-HAL-true,13-MX_SPI1_Init-SPI1-false-HAL-true,14-MX_USART2_UART_Init-USART2-false-HAL-true +RCC.48MHZClocksFreq_Value=48000000 +RCC.AHBFreq_Value=144000000 +RCC.APB1CLKDivider=RCC_HCLK_DIV4 +RCC.APB1Freq_Value=36000000 +RCC.APB1TimFreq_Value=72000000 +RCC.APB2CLKDivider=RCC_HCLK_DIV2 +RCC.APB2Freq_Value=72000000 +RCC.APB2TimFreq_Value=144000000 +RCC.CortexFreq_Value=144000000 +RCC.EthernetFreq_Value=144000000 +RCC.FCLKCortexFreq_Value=144000000 +RCC.FamilyName=M +RCC.HCLKFreq_Value=144000000 +RCC.HSE_VALUE=8000000 +RCC.HSI_VALUE=16000000 +RCC.I2SClocksFreq_Value=64000000 +RCC.IPParameters=48MHZClocksFreq_Value,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2CLKDivider,APB2Freq_Value,APB2TimFreq_Value,CortexFreq_Value,EthernetFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,HSI_VALUE,I2SClocksFreq_Value,LSE_VALUE,LSI_VALUE,MCO1PinFreq_Value,MCO2PinFreq_Value,PLLCLKFreq_Value,PLLI2SN,PLLM,PLLN,PLLQ,PLLQCLKFreq_Value,PLLSourceVirtual,RCC_MCO1Source,RCC_MCO2Source,RCC_MCODiv1,RCC_MCODiv2,RTCFreq_Value,RTCHSEDivFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,VCOI2SOutputFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VcooutputI2S +RCC.LSE_VALUE=32768 +RCC.LSI_VALUE=32000 +RCC.MCO1PinFreq_Value=36000000 +RCC.MCO2PinFreq_Value=16000000 +RCC.PLLCLKFreq_Value=144000000 +RCC.PLLI2SN=64 +RCC.PLLM=4 +RCC.PLLN=144 +RCC.PLLQ=6 +RCC.PLLQCLKFreq_Value=48000000 +RCC.PLLSourceVirtual=RCC_PLLSOURCE_HSE +RCC.RCC_MCO1Source=RCC_MCO1SOURCE_PLLCLK +RCC.RCC_MCO2Source=RCC_MCO2SOURCE_PLLI2SCLK +RCC.RCC_MCODiv1=RCC_MCODIV_4 +RCC.RCC_MCODiv2=RCC_MCODIV_4 +RCC.RTCFreq_Value=32000 +RCC.RTCHSEDivFreq_Value=4000000 +RCC.SYSCLKFreq_VALUE=144000000 +RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK +RCC.VCOI2SOutputFreq_Value=128000000 +RCC.VCOInputFreq_Value=2000000 +RCC.VCOOutputFreq_Value=288000000 +RCC.VcooutputI2S=64000000 +SH.GPXTI0.0=GPIO_EXTI0 +SH.GPXTI0.ConfNb=1 +SH.GPXTI4.0=GPIO_EXTI4 +SH.GPXTI4.ConfNb=1 +SPI1.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_128 +SPI1.CalculateBaudRate=562.5 KBits/s +SPI1.Direction=SPI_DIRECTION_2LINES +SPI1.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler +SPI1.Mode=SPI_MODE_MASTER +SPI1.VirtualType=VM_MASTER +TIM1.IPParameters=Period,Prescaler +TIM1.Period=9999 +TIM1.Prescaler=143 +TIM3.IPParameters=Prescaler,Period +TIM3.Period=9999 +TIM3.Prescaler=71 +TIM6.IPParameters=Prescaler +TIM6.Prescaler=71 +TIM7.IPParameters=Prescaler +TIM7.Prescaler=81 +USART1.BaudRate=460800 +USART1.IPParameters=VirtualMode,BaudRate +USART1.VirtualMode=VM_ASYNC +USART2.IPParameters=VirtualMode +USART2.VirtualMode=VM_ASYNC +USART3.BaudRate=9600 +USART3.IPParameters=VirtualMode,BaudRate +USART3.VirtualMode=VM_ASYNC +VP_CRC_VS_CRC.Mode=CRC_Activate +VP_CRC_VS_CRC.Signal=CRC_VS_CRC +VP_FREERTOS_VS_CMSIS_V1.Mode=CMSIS_V1 +VP_FREERTOS_VS_CMSIS_V1.Signal=FREERTOS_VS_CMSIS_V1 +VP_IWDG_VS_IWDG.Mode=IWDG_Activate +VP_IWDG_VS_IWDG.Signal=IWDG_VS_IWDG +VP_RNG_VS_RNG.Mode=RNG_Activate +VP_RNG_VS_RNG.Signal=RNG_VS_RNG +VP_SYS_VS_tim11.Mode=TIM11 +VP_SYS_VS_tim11.Signal=SYS_VS_tim11 +VP_TIM1_VS_ClockSourceINT.Mode=Internal +VP_TIM1_VS_ClockSourceINT.Signal=TIM1_VS_ClockSourceINT +VP_TIM3_VS_ClockSourceINT.Mode=Internal +VP_TIM3_VS_ClockSourceINT.Signal=TIM3_VS_ClockSourceINT +VP_TIM6_VS_ClockSourceINT.Mode=Enable_Timer +VP_TIM6_VS_ClockSourceINT.Signal=TIM6_VS_ClockSourceINT +VP_TIM7_VS_ClockSourceINT.Mode=Enable_Timer +VP_TIM7_VS_ClockSourceINT.Signal=TIM7_VS_ClockSourceINT +board=custom +rtos.0.ip=FREERTOS +isbadioc=false diff --git a/large_space_disinfection__liquid_ctrl_board.launch b/large_space_disinfection__liquid_ctrl_board.launch new file mode 100644 index 0000000..34468c0 --- /dev/null +++ b/large_space_disinfection__liquid_ctrl_board.launch @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/usrc/base/device_info.cpp b/usrc/base/device_info.cpp index fb66dae..3fcf499 100644 --- a/usrc/base/device_info.cpp +++ b/usrc/base/device_info.cpp @@ -4,8 +4,8 @@ uint16_t deviceInfo_init() { return 0; } uint16_t deviceInfo_getBoardId() { return DEVICE_ID; } -uint16_t deviceInfo_getProjectId() { return kdraw_bar_disinfection_box; } -uint16_t deviceInfo_getBoardType() { return kBoardType_LiquidCtrl; } +uint16_t deviceInfo_getProjectId() { return PROJECT_ID; } +uint16_t deviceInfo_getBoardType() { return BOARD_TYPE; } uint16_t deviceInfo_getProtocolVersion() { return PROTOCOL_VERSION; } uint16_t deviceInfo_getSoftwareVersion() { return SOFTWARE_VERSION; } uint16_t deviceInfo_getHardwareVersion() { return HARDWARE_VERSION; } diff --git a/usrc/base/hardware.cpp b/usrc/base/hardware.cpp index 7bcce77..96fc4b4 100644 --- a/usrc/base/hardware.cpp +++ b/usrc/base/hardware.cpp @@ -8,11 +8,16 @@ using namespace iflytop; * EXT * ***********************************************************************************************************************/ void Hardware::init() { - m_motor_spi.init(&MOTOR_SPI); - m_modbusBlockHost.initialize(&huart3); + /*********************************************************************************************************************** + * 水浸传感器初始化 * + ***********************************************************************************************************************/ + m_evaporation_bin_water_sensor.initAsInput(EVAPORATION_BIN_WATER_SENSOR_GPIO, kxs_gpio_nopull, kxs_gpio_no_irq, EVAPORATION_BIN_WATER_SENSOR_MIRROR /*mirror*/); + m_device_bottom_water_sensor.initAsInput(DEVICE_BOTTOM_WATER_SENSOR_GPIO, kxs_gpio_nopull, kxs_gpio_no_irq, DEVICE_BOTTOM_WATER_SENSOR_MIRROR /*mirror*/); - m_sl_mini_ac_ctrl.initAsOutput(PD14, kxs_gpio_nopull, true, false); // m_sl_mini_ac_ctrl - m_atta_mini_air_compressor_ctrl.initAsOutput(PD15, kxs_gpio_nopull, true, false); // m_atta_mini_air_compressor_ctrl + /*********************************************************************************************************************** + * 驱动器初始化 * + ***********************************************************************************************************************/ + m_motor_spi.init(&MOTOR_SPI); m_motor[0].initialize(&m_motor_spi, MOTOR1_ENN, MOTOR1_CSN); m_motor[0].setIHOLD_IRUN(1, 15, 0); @@ -38,12 +43,25 @@ void Hardware::init() { ZLOGI(TAG, "motor0: reset:%d drv_err:%d uv_cp:%d", gstate0.reset, gstate0.drv_err, gstate0.uv_cp); ZLOGI(TAG, "motor1: reset:%d drv_err:%d uv_cp:%d", gstate1.reset, gstate1.drv_err, gstate1.uv_cp); - gstate0 = m_motor[0].getGState(); - gstate1 = m_motor[1].getGState(); + gstate0 = m_motor[0].getGState(); + gstate1 = m_motor[1].getGState(); ZLOGI(TAG, "motor0: reset:%d drv_err:%d uv_cp:%d", gstate0.reset, gstate0.drv_err, gstate0.uv_cp); ZLOGI(TAG, "motor1: reset:%d drv_err:%d uv_cp:%d", gstate1.reset, gstate1.drv_err, gstate1.uv_cp); - osDelay(1500);//等待传感器上电 + /*********************************************************************************************************************** + * 三色指示灯初始化 * + ***********************************************************************************************************************/ + + triLight_R.initAsOutput(TRI_LIGHT_R, kxs_gpio_nopull, false, false); + triLight_G.initAsOutput(TRI_LIGHT_G, kxs_gpio_nopull, false, false); + triLight_B.initAsOutput(TRI_LIGHT_B, kxs_gpio_nopull, false, false); + triLight_BEEP.initAsOutput(TRI_LIGHT_BEEP, kxs_gpio_nopull, false, false); + + /*********************************************************************************************************************** + * 压力传感器初始化 * + ***********************************************************************************************************************/ + osDelay(1500); // 等待传感器上电 + m_modbusBlockHost.initialize(&PRESSURE_SENSOR_UART); m_pressureSensorBus.init(&m_modbusBlockHost); } diff --git a/usrc/base/hardware.hpp b/usrc/base/hardware.hpp index e244aa6..76b74ab 100644 --- a/usrc/base/hardware.hpp +++ b/usrc/base/hardware.hpp @@ -14,13 +14,20 @@ void hardware_init(); namespace iflytop { class Hardware { - ZSPI m_motor_spi; // - ModbusBlockHost m_modbusBlockHost; // + public: + ZGPIO m_evaporation_bin_water_sensor; // 蒸发仓水浸 + ZGPIO m_device_bottom_water_sensor; // 设备底部水浸 + + ZSPI m_motor_spi; // SPI + TMC5130 m_motor[2]; // 蠕动泵控制 + + ZGPIO triLight_R; + ZGPIO triLight_G; + ZGPIO triLight_B; + ZGPIO triLight_BEEP; - TMC5130 m_motor[2]; // 蠕动泵控制 - ZGPIO m_sl_mini_ac_ctrl; // 喷液空压机(MINI) - ZGPIO m_atta_mini_air_compressor_ctrl; // 气密性测试空压机(MINI) - PXXPressureSensorBus m_pressureSensorBus; // PXX压力传感器总线 + ModbusBlockHost m_modbusBlockHost; // + PXXPressureSensorBus m_pressureSensorBus; // PXX压力传感器总线 public: static Hardware& ins() { @@ -37,10 +44,29 @@ class Hardware { } return nullptr; } - ZGPIO* sl_mini_ac_ctrl() { return &m_sl_mini_ac_ctrl; } - ZGPIO* atta_mini_air_compressor_ctrl() { return &m_atta_mini_air_compressor_ctrl; } - PXXPressureSensorBus* pressureSensorBus() { return &m_pressureSensorBus; } + + void setRGB(int32_t r, int32_t g, int32_t b, int32_t beep) { + if (r > 0) + triLight_R.write(1); + else + triLight_R.write(0); + + if (g > 0) + triLight_G.write(1); + else + triLight_G.write(0); + + if (b > 0) + triLight_B.write(1); + else + triLight_B.write(0); + + if (beep > 0) + triLight_BEEP.write(1); + else + triLight_BEEP.write(0); + } }; } // namespace iflytop diff --git a/usrc/project_configs.h b/usrc/project_configs.h index 9d7a819..d211429 100644 --- a/usrc/project_configs.h +++ b/usrc/project_configs.h @@ -1,5 +1,13 @@ #pragma once #include "iflytop_canbus_protocol/iflytop_canbus_protocol.hpp" +/*********************************************************************************************************************** + * SDK_CONFIG * + ***********************************************************************************************************************/ +#define SDK_DELAY_US_TIMER htim6 // 微秒延迟定时器,注意该延时定时器需要按照以下文档进行配置 http://192.168.1.3:3000/zwikipedia/iflytop_wikipedia/src/branch/master/doc/stm32cubemx_us_timer.md +#define SDK_IRQ_PREEMPTPRIORITY_DEFAULT 5 // IO中断默认中断等级 +#define SDK_CFG__CFG_FLASH_ADDR 0x080C0000 // +#define SDK_CFG__SN_FLASH_ADDR 0x080E0000 // +#define SDK_MAX_TASK 10 /*********************************************************************************************************************** * PROJECT_CONFIG * @@ -9,13 +17,19 @@ * @brief 基础配置 * */ -#define SOFTWARE_VERSION 5 -#define HARDWARE_VERSION 1 -#define PROJECT "dbdb_liquid_path_control" -#define SN_HEADER "SN" -#define DEVICE_ID (kFixBoardId_LiquidCtrl) -#define DEBUG_UART huart1 // 调试串口 -#define DEBUG_LIGHT_GPIO PE8 // 调试指示灯 +#define SOFTWARE_VERSION 1 // 软件版本 +#define HARDWARE_VERSION 1 // 硬件版本 +#define PROJECT "large_space_disinfection__liquid_ctrl_board" // 工程名称 +#define SN_HEADER "SN" // SN号前缀 +#define DEVICE_ID (kFixBoardId_LiquidCtrl) // 设备ID +#define PROJECT_ID klarge_space_disinfection_machine // 项目ID +#define BOARD_TYPE kBoardType_LiquidCtrl // 板子类型 +#define DEBUG_UART huart1 // 调试串口 +#define DEBUG_LIGHT_GPIO PE8 // 调试指示灯 + +/*********************************************************************************************************************** + * 硬件配置 * + ***********************************************************************************************************************/ /** * @brief 驱动器配置 @@ -27,11 +41,14 @@ #define MOTOR1_CSN PC4 // #define MOTOR1_ENN PE12 -/*********************************************************************************************************************** - * SDK_CONFIG * - ***********************************************************************************************************************/ -#define SDK_DELAY_US_TIMER htim6 // 微秒延迟定时器,注意该延时定时器需要按照以下文档进行配置 http://192.168.1.3:3000/zwikipedia/iflytop_wikipedia/src/branch/master/doc/stm32cubemx_us_timer.md -#define SDK_IRQ_PREEMPTPRIORITY_DEFAULT 5 // IO中断默认中断等级 -#define SDK_CFG__CFG_FLASH_ADDR 0x080C0000 // -#define SDK_CFG__SN_FLASH_ADDR 0x080E0000 // -#define SDK_MAX_TASK 10 \ No newline at end of file +#define PRESSURE_SENSOR_UART huart3 + +#define TRI_LIGHT_R PD8 +#define TRI_LIGHT_G PD7 +#define TRI_LIGHT_B PD9 +#define TRI_LIGHT_BEEP PD10 + +#define EVAPORATION_BIN_WATER_SENSOR_GPIO PC7 // 消毒加热仓内部水浸 +#define EVAPORATION_BIN_WATER_SENSOR_MIRROR true +#define DEVICE_BOTTOM_WATER_SENSOR_GPIO PD13 // 设备底部水浸 +#define DEVICE_BOTTOM_WATER_SENSOR_MIRROR true \ No newline at end of file diff --git a/usrc/protocol_impl/basic/fn_mgr.cpp b/usrc/protocol_impl/basic/fn_mgr.cpp new file mode 100644 index 0000000..2a6a9bc --- /dev/null +++ b/usrc/protocol_impl/basic/fn_mgr.cpp @@ -0,0 +1,4 @@ +#include "fn_mgr.hpp" + +void fn_map_reg(uint16_t function_id, protocol_impl_func_t funtion) {} +bool fn_map_process(uint16_t function_id, uint8_t from, uint8_t to, uint8_t* rawpacket, size_t len) { return true; } \ No newline at end of file diff --git a/usrc/protocol_impl/basic/fn_mgr.hpp b/usrc/protocol_impl/basic/fn_mgr.hpp new file mode 100644 index 0000000..864b6a0 --- /dev/null +++ b/usrc/protocol_impl/basic/fn_mgr.hpp @@ -0,0 +1,35 @@ +#include +#include + +#include "base/config_service.hpp" +#include "zsdk/zsdk.hpp" + +/*********************************************************************************************************************** + * MARCO * + ***********************************************************************************************************************/ + +#define CHECK_PARAM_LEN(_paramNum, expectNum) \ + if (_paramNum != expectNum) { \ + zcanbus_send_errorack(packet, kerr_invalid_param_num); \ + return; \ + } + +#define CHECK_MOTOR_INDEX(_subindex) \ + if (_subindex > Hardware::ins().motorNum()) { \ + zcanbus_send_errorack(packet, kerr_invalid_param); \ + return; \ + } +#define GET_PARAM(buff, off) ((((int32_t*)(buff))[off])) +#define PRAAM_LEN() ((len - sizeof(zcanbus_packet_t)) / 4) + +#define CLEAR_BIT(val, bit) (val &= ~(1 << bit)) +#define SET_BIT(val, bit) (val |= (1 << bit)) + +/*********************************************************************************************************************** + * FUNC * + ***********************************************************************************************************************/ + +typedef void(protocol_impl_func_t)(uint8_t from, uint8_t to, zcanbus_packet_t* rawpacket, size_t len); + +void fn_map_reg(uint16_t function_id, protocol_impl_func_t funtion); +bool fn_map_process(uint16_t function_id, uint8_t from, uint8_t to, uint8_t* rawpacket, size_t len); diff --git a/usrc/protocol_impl/basic/report_flag_mgr.cpp b/usrc/protocol_impl/basic/report_flag_mgr.cpp new file mode 100644 index 0000000..ee889d2 --- /dev/null +++ b/usrc/protocol_impl/basic/report_flag_mgr.cpp @@ -0,0 +1,16 @@ +#include "report_flag_mgr.hpp" +using namespace iflytop; + +ForceReportFlagMgr* ForceReportFlagMgr::ins() { + static ForceReportFlagMgr instance; + return &instance; +} + +void ForceReportFlagMgr::init() { + m_lock.init(); + memset(&m_flag, 0, sizeof(m_flag)); +} +void ForceReportFlagMgr::trigger() { + zlock_guard lock(m_lock); + memset(&m_flag, 1, sizeof(m_flag)); +} \ No newline at end of file diff --git a/usrc/protocol_impl/basic/report_flag_mgr.hpp b/usrc/protocol_impl/basic/report_flag_mgr.hpp new file mode 100644 index 0000000..275416b --- /dev/null +++ b/usrc/protocol_impl/basic/report_flag_mgr.hpp @@ -0,0 +1,32 @@ +#include +#include +#include + +#include "base/config_service.hpp" +#include "zsdk/zsdk.hpp" + +namespace iflytop { + +class ForceReportFlagMgr { + private: + typedef struct { + bool pad; + } flag_t; + + zmutex m_lock; + flag_t m_flag; + + public: + static ForceReportFlagMgr* ins(); + + void init(); + + void trigger(); + + void clearPad() { + zlock_guard lock(m_lock); + m_flag.pad = false; + } +}; + +} // namespace iflytop diff --git a/usrc/protocol_impl/function_impl/afunction_impl.hpp b/usrc/protocol_impl/function_impl/afunction_impl.hpp new file mode 100644 index 0000000..e9c5cbd --- /dev/null +++ b/usrc/protocol_impl/function_impl/afunction_impl.hpp @@ -0,0 +1,61 @@ +#pragma ocne +#include +#include + +#include "../basic/fn_mgr.hpp" +#include "../basic/report_flag_mgr.hpp" +// +#include "base/device_info.hpp" +#include "base/hardware.hpp" +#include "zsdk/modbus/modbus_block_host.hpp" +#include "zsdk/zcanreceiver/zcanreceiver.hpp" + +/*********************************************************************************************************************** + * basic_fn * + ***********************************************************************************************************************/ + +void fn_cmd_read_board_info(uint8_t from, uint8_t to, zcanbus_packet_t* packet, size_t len); +void fn_cmd_read_sysinfo(uint8_t from, uint8_t to, zcanbus_packet_t* packet, size_t len); +void fn_cmd_read_taskinfo(uint8_t from, uint8_t to, zcanbus_packet_t* packet, size_t len); +void fn_cmd_heart_ping(uint8_t from, uint8_t to, zcanbus_packet_t* packet, size_t len); +void fn_cmd_clear_reset_flag(uint8_t from, uint8_t to, zcanbus_packet_t* packet, size_t len); + +void basic_fn_init(); + +/*********************************************************************************************************************** + * pump_fn * + ***********************************************************************************************************************/ + +void fn_cmd_pump_rotate(uint8_t from, uint8_t to, zcanbus_packet_t* packet, size_t len); +void fn_cmd_pump_stop(uint8_t from, uint8_t to, zcanbus_packet_t* packet, size_t len); +void fn_cmd_pump_set_ihold_irun_idelay(uint8_t from, uint8_t to, zcanbus_packet_t* packet, size_t len); +void fn_cmd_pump_set_acc(uint8_t from, uint8_t to, zcanbus_packet_t* packet, size_t len); +void fn_cmd_pump_set_subic_reg(uint8_t from, uint8_t to, zcanbus_packet_t* packet, size_t len); +void fn_cmd_pump_get_subic_reg(uint8_t from, uint8_t to, zcanbus_packet_t* packet, size_t len); +void fn_cmd_pump_ping(uint8_t from, uint8_t to, zcanbus_packet_t* packet, size_t len); + +void pump_fn_init(); +void pump_fn_report_tmr_start(); + +/*********************************************************************************************************************** + * pressure_fn_impl * + ***********************************************************************************************************************/ +void fn_cmd_pressure_sensor_bus_read_data(uint8_t from, uint8_t to, zcanbus_packet_t* packet, size_t len); +void fn_cmd_pressure_sensor_bus_set_report_period_ms(uint8_t from, uint8_t to, zcanbus_packet_t* packet, size_t len); + +void pressure_fn_impl_init(); + +/*********************************************************************************************************************** + * triple_warning_light_fn_impl * + ***********************************************************************************************************************/ +void fn_cmd_triple_warning_light_ctl(uint8_t from, uint8_t to, zcanbus_packet_t* packet, size_t len); + +/*********************************************************************************************************************** + * water_sensor_report_fn_impl * + ***********************************************************************************************************************/ +void fn_cmd_evaporation_bin_water_sensor_read_state(uint8_t from, uint8_t to, zcanbus_packet_t* packet, size_t len); +void fn_cmd_device_bottom_water_sensor_read_state(uint8_t from, uint8_t to, zcanbus_packet_t* packet, size_t len); + +void water_sensor_report_fn_impl_init(); +void water_sensor_report_fn_impl_start_tmr(); +void water_sensor_report_fn_impl_force_report(); diff --git a/usrc/protocol_impl/function_impl/basic_fn.cpp b/usrc/protocol_impl/function_impl/basic_fn.cpp new file mode 100644 index 0000000..3cde232 --- /dev/null +++ b/usrc/protocol_impl/function_impl/basic_fn.cpp @@ -0,0 +1,91 @@ + +#include "afunction_impl.hpp" +using namespace iflytop; + +static uint8_t m_boardflag; // 0: 重启标志 + +/** + * @brief 读取板子信息 + * + * @param from + * @param to + * @param packet + * @param len + */ +void fn_cmd_read_board_info(uint8_t from, uint8_t to, zcanbus_packet_t* packet, size_t len) { + static ack_read_board_info_data_t ack; + ack.boardType = deviceInfo_getBoardType(); + ack.projectId = deviceInfo_getProjectId(); + ack.protcol_version = deviceInfo_getProtocolVersion(); + ack.software_version = deviceInfo_getSoftwareVersion(); + ack.hardware_version = deviceInfo_getHardwareVersion(); + + zcanbus_send_ack(packet, (uint8_t*)&ack, sizeof(ack)); +} +/** + * @brief 读取系统信息 + * + * @param from + * @param to + * @param packet + * @param len + */ +void fn_cmd_read_sysinfo(uint8_t from, uint8_t to, zcanbus_packet_t* packet, size_t len) { + static ack_sysinfo_t ack; + ack.free_heap_size = SysMgr::ins()->osGetMinimumEverFreeHeapSize(); + ack.total_heap_size = SysMgr::ins()->osGetTotalHeapSize(); + ack.taskNum = SysMgr::ins()->getTaskNum(); + ack.sysHasRun = SysMgr::ins()->osGetSysRunTime() / 1000; + zcanbus_send_ack(packet, (uint8_t*)&ack, sizeof(ack)); +} +/** + * @brief 读取线程信息 + * + * @param from + * @param to + * @param packet + * @param len + */ +void fn_cmd_read_taskinfo(uint8_t from, uint8_t to, zcanbus_packet_t* packet, size_t len) { + static ask_taskinfo_t ack; + int32_t taskoff = GET_PARAM(packet->params, 0); + osThreadId taskId = SysMgr::ins()->osGetId(taskoff); + SysMgr::ins()->osTaskName(taskId, (char*)ack.taskName, sizeof(ack.taskName)); + SysMgr::ins()->osTaskStackRemainingSize(taskId, &ack.stackRemindSize); + SysMgr::ins()->osTaskPriority(taskId, &ack.priority); + SysMgr::ins()->osTaskGetState(taskId, (char*)&ack.state); + + zcanbus_send_ack(packet, (uint8_t*)&ack, sizeof(ack)); +} +/** + * @brief PING + * + * @param from + * @param to + * @param packet + * @param len + */ +void fn_cmd_heart_ping(uint8_t from, uint8_t to, zcanbus_packet_t* packet, size_t len) { + static report_heatpacket_data_t heatpacket; + heatpacket.boardType = deviceInfo_getBoardType(); + heatpacket.heartIndex = GET_PARAM(packet->params, 0); + heatpacket.flag = m_boardflag; + zcanbus_send_report(kreport_heatpacket_pong, (uint8_t*)&heatpacket, sizeof(heatpacket), 30); +} +/** + * @brief 清除板子复位标志位 + * + * @param from + * @param to + * @param packet + * @param len + */ +void fn_cmd_clear_reset_flag(uint8_t from, uint8_t to, zcanbus_packet_t* packet, size_t len) { + CLEAR_BIT(m_boardflag, 0); + zcanbus_send_ack(packet, NULL, 0); +} + +void basic_fn_init() { + m_boardflag = 0x00; + SET_BIT(m_boardflag, 0); +} \ No newline at end of file diff --git a/usrc/protocol_impl/function_impl/pressure_fn_impl.cpp b/usrc/protocol_impl/function_impl/pressure_fn_impl.cpp new file mode 100644 index 0000000..6a88e9b --- /dev/null +++ b/usrc/protocol_impl/function_impl/pressure_fn_impl.cpp @@ -0,0 +1,72 @@ + +#include "afunction_impl.hpp" +using namespace iflytop; + +#define TAG "PRESSURE_FN" + +static osTimerId PressureSensorDataReportTimerId; // 压力传感器数值上报 +static uint32_t m_pressureSensorDataReportPeriodMs = 3000; + +static void onPressureSensorDataReportTimer(void const* argument) { + // 压力传感器数据上报 + static uint8_t reportcache[100]; + static report_pressure_data_t* report = (report_pressure_data_t*)reportcache; + + int sensorNum = 0; + + for (size_t i = 0; i < PXX_PRESSURE_SENSOR_NUM; i++) { + int16_t val = 0; + bool suc = Hardware::ins().pressureSensorBus()->readData(i, &val); + + if (suc) { + report->data[sensorNum].subid = i; + report->data[sensorNum].pressureVal = val; + sensorNum++; + } + } + + report->sensorDataNum = sensorNum; + zcanbus_send_report(kreport_pressure_data, (uint8_t*)report, // + sizeof(report_pressure_data_t) + sensorNum * sizeof(report->data[0]), 10); +} + + +void fn_cmd_pressure_sensor_bus_read_data(uint8_t from, uint8_t to, zcanbus_packet_t* packet, size_t len) { + CHECK_PARAM_LEN(PRAAM_LEN(), 1); + int32_t index = GET_PARAM(packet->params, 0); + + int16_t val = 0; + int32_t reportVal = 0; + bool suc = Hardware::ins().pressureSensorBus()->readData(index, &val); + + reportVal = val; + + if (suc) { + zcanbus_send_ack(packet, (uint8_t*)&reportVal, sizeof(reportVal)); + } else { + zcanbus_send_errorack(packet, kerr_subdevice_offline); + } +} +void fn_cmd_pressure_sensor_bus_set_report_period_ms(uint8_t from, uint8_t to, zcanbus_packet_t* packet, size_t len) { + CHECK_PARAM_LEN(PRAAM_LEN(), 1); + int32_t period = GET_PARAM(packet->params, 0); + + ZLOGI(TAG, "set pressure sensor data report period %d ms", period); + + if (period != 0) { + if (period < 200) period = 200; + osTimerStop(PressureSensorDataReportTimerId); + osTimerStart(PressureSensorDataReportTimerId, period); + m_pressureSensorDataReportPeriodMs = period; + } else { + osTimerStop(PressureSensorDataReportTimerId); + } + + zcanbus_send_ack(packet, NULL, 0); +} + +void pressure_fn_impl_init() { + osTimerDef(PressureSensorDataReportTimer, onPressureSensorDataReportTimer); + PressureSensorDataReportTimerId = osTimerCreate(osTimer(PressureSensorDataReportTimer), osTimerPeriodic, NULL); + // osTimerStart(PressureSensorDataReportTimerId, m_pressureSensorDataReportPeriodMs); +} \ No newline at end of file diff --git a/usrc/protocol_impl/function_impl/pump_fn_impl.cpp b/usrc/protocol_impl/function_impl/pump_fn_impl.cpp new file mode 100644 index 0000000..788100f --- /dev/null +++ b/usrc/protocol_impl/function_impl/pump_fn_impl.cpp @@ -0,0 +1,209 @@ + +#include "afunction_impl.hpp" +using namespace iflytop; + +#define TAG "PUMP_FN" + +static osTimerId MotorMonitorTimerId; // 压力传感器数值上报 +static bool motorErrorFlagCache[10]; // 电机异常状态上报标志位 +static zmutex motorErrorFlagCacheLock; + +static bool motorErrorFlag_get(int subindex) { + bool ret; + { + zlock_guard guard(motorErrorFlagCacheLock); + ret = motorErrorFlagCache[subindex]; + } + return ret; +} + +static void motorErrorFlag_set(int subindex, bool val) { + { + zlock_guard guard(motorErrorFlagCacheLock); + motorErrorFlagCache[subindex] = val; + } +} + +void fn_cmd_pump_rotate(uint8_t from, uint8_t to, zcanbus_packet_t* packet, size_t len) { + CHECK_PARAM_LEN(PRAAM_LEN(), 2); + + int32_t subindex = GET_PARAM(packet->params, 0); + int32_t velocity = GET_PARAM(packet->params, 1); + + if (subindex >= Hardware::ins().motorNum()) { + zcanbus_send_errorack(packet, kerr_invalid_param); + return; + } + if (!Hardware::ins().motor(subindex)->ping()) { + zcanbus_send_errorack(packet, kerr_motor_subdevice_offline); + return; + } + + Hardware::ins().motor(subindex)->enableIC(false); + Hardware::ins().motor(subindex)->enableIC(true); + Hardware::ins().motor(subindex)->rotate(velocity); + + zcanbus_send_ack(packet, NULL, 0); + motorErrorFlag_set(subindex, false); +} +void fn_cmd_pump_stop(uint8_t from, uint8_t to, zcanbus_packet_t* packet, size_t len) { + CHECK_PARAM_LEN(PRAAM_LEN(), 1); + + int32_t subindex = GET_PARAM(packet->params, 0); + + if (subindex >= Hardware::ins().motorNum()) { + zcanbus_send_errorack(packet, kerr_invalid_param); + return; + } + + if (!Hardware::ins().motor(subindex)->ping()) { + zcanbus_send_errorack(packet, kerr_motor_subdevice_offline); + return; + } + + Hardware::ins().motor(subindex)->stop(); + zcanbus_send_ack(packet, NULL, 0); +} +void fn_cmd_pump_set_ihold_irun_idelay(uint8_t from, uint8_t to, zcanbus_packet_t* packet, size_t len) { + CHECK_PARAM_LEN(PRAAM_LEN(), 4); + + int32_t subindex = GET_PARAM(packet->params, 0); + int32_t ihold = GET_PARAM(packet->params, 1); + int32_t irun = GET_PARAM(packet->params, 2); + int32_t idelay = GET_PARAM(packet->params, 3); + + if (subindex >= Hardware::ins().motorNum()) { + zcanbus_send_errorack(packet, kerr_invalid_param); + return; + } + + if (!Hardware::ins().motor(subindex)->ping()) { + zcanbus_send_errorack(packet, kerr_motor_subdevice_offline); + return; + } + + Hardware::ins().motor(subindex)->setIHOLD_IRUN(ihold, irun, idelay); + zcanbus_send_ack(packet, NULL, 0); +} +void fn_cmd_pump_set_acc(uint8_t from, uint8_t to, zcanbus_packet_t* packet, size_t len) { + CHECK_PARAM_LEN(PRAAM_LEN(), 2); + + int32_t subindex = GET_PARAM(packet->params, 0); + int32_t acc = GET_PARAM(packet->params, 1); + + if (subindex >= Hardware::ins().motorNum()) { + zcanbus_send_errorack(packet, kerr_invalid_param); + return; + } + + if (!Hardware::ins().motor(subindex)->ping()) { + zcanbus_send_errorack(packet, kerr_motor_subdevice_offline); + return; + } + + Hardware::ins().motor(subindex)->setAcceleration(acc); + Hardware::ins().motor(subindex)->setDeceleration(acc); + zcanbus_send_ack(packet, NULL, 0); +} +void fn_cmd_pump_set_subic_reg(uint8_t from, uint8_t to, zcanbus_packet_t* packet, size_t len) { + CHECK_PARAM_LEN(PRAAM_LEN(), 3); + + int32_t subindex = GET_PARAM(packet->params, 0); + int32_t regadd = GET_PARAM(packet->params, 1); + int32_t regval = GET_PARAM(packet->params, 2); + + if (subindex >= Hardware::ins().motorNum()) { + zcanbus_send_errorack(packet, kerr_invalid_param); + return; + } + + if (!Hardware::ins().motor(subindex)->ping()) { + zcanbus_send_errorack(packet, kerr_motor_subdevice_offline); + return; + } + + Hardware::ins().motor(subindex)->writeInt(regadd, regval); +} +void fn_cmd_pump_get_subic_reg(uint8_t from, uint8_t to, zcanbus_packet_t* packet, size_t len) { + CHECK_PARAM_LEN(PRAAM_LEN(), 3); + + int32_t subindex = GET_PARAM(packet->params, 0); + int32_t regadd = GET_PARAM(packet->params, 1); + int32_t regval = GET_PARAM(packet->params, 2); + + if (subindex >= Hardware::ins().motorNum()) { + zcanbus_send_errorack(packet, kerr_invalid_param); + return; + } + + if (!Hardware::ins().motor(subindex)->ping()) { + zcanbus_send_errorack(packet, kerr_motor_subdevice_offline); + return; + } + + Hardware::ins().motor(subindex)->writeInt(regadd, regval); +} +void fn_cmd_pump_ping(uint8_t from, uint8_t to, zcanbus_packet_t* packet, size_t len) { + CHECK_PARAM_LEN(PRAAM_LEN(), 1); + + int32_t subindex = GET_PARAM(packet->params, 0); + + if (subindex >= Hardware::ins().motorNum()) { + zcanbus_send_errorack(packet, kerr_invalid_param); + return; + } + + if (!Hardware::ins().motor(subindex)->ping()) { + zcanbus_send_errorack(packet, kerr_motor_subdevice_offline); + return; + } + zcanbus_send_ack(packet, NULL, 0); +} + +static void onMotorMonitorTimer(void const* argument) { + // 电机异常检查 + + report_exeception_data_t data; + for (size_t i = 0; i < Hardware::ins().motorNum(); i++) { + bool estate = motorErrorFlag_get(i); + + if (!Hardware::ins().motor(i)->ping()) { + data.subid = i; + data.ecode = kerr_motor_subdevice_offline; + + if (!estate) { + motorErrorFlag_set(i, true); + ZLOGE(TAG, "motor %d offline error", i); + zcanbus_send_emergency_report(kreport_exception_error, (uint8_t*)&data, sizeof(data), 100); + } + } else { + auto gstate = Hardware::ins().motor(i)->getGState(); + bool flag = gstate.reset || gstate.drv_err || gstate.uv_cp; + if (!flag && estate) { + motorErrorFlag_set(i, false); + } else if (flag && !estate) { + ZLOGE(TAG, "motor %d error, reset %d, drv_err %d, uv_cp %d", i, gstate.reset, gstate.drv_err, gstate.uv_cp); + if (gstate.reset) { + data.ecode = kerr_motor_reset_error; + } else if (gstate.uv_cp) { + data.ecode = kerr_motor_undervoltage_error; + } else if (gstate.drv_err) { + data.ecode = kerr_motor_driver_error; + } else { + data.ecode = kerr_motor_unkown_error; + } + data.subid = i; + motorErrorFlag_set(i, true); + zcanbus_send_emergency_report(kreport_exception_error, (uint8_t*)&data, sizeof(data), 100); + } + } + } +} + +void pump_fn_init() { motorErrorFlagCacheLock.init(); } + +void pump_fn_report_tmr_start() { + osTimerDef(MotorMonitorTimer, onMotorMonitorTimer); + MotorMonitorTimerId = osTimerCreate(osTimer(MotorMonitorTimer), osTimerPeriodic, NULL); + osTimerStart(MotorMonitorTimerId, 1000); +} \ No newline at end of file diff --git a/usrc/protocol_impl/function_impl/triple_warning_light_ctl.cpp b/usrc/protocol_impl/function_impl/triple_warning_light_ctl.cpp new file mode 100644 index 0000000..ff3dafa --- /dev/null +++ b/usrc/protocol_impl/function_impl/triple_warning_light_ctl.cpp @@ -0,0 +1,18 @@ +#include "afunction_impl.hpp" +using namespace iflytop; + +#define TAG "TRIPLE_WARNING_LIGHT" + +// kcmd_triple_warning_light_ctl + +void fn_cmd_triple_warning_light_ctl(uint8_t from, uint8_t to, zcanbus_packet_t* packet, size_t len) { + CHECK_PARAM_LEN(PRAAM_LEN(), 4); + + int32_t r = GET_PARAM(packet->params, 0); + int32_t g = GET_PARAM(packet->params, 1); + int32_t b = GET_PARAM(packet->params, 2); + int32_t warning = GET_PARAM(packet->params, 3); + + Hardware::ins().setRGB(r, g, b, warning); + zcanbus_send_ack(packet, NULL, 0); +} \ No newline at end of file diff --git a/usrc/protocol_impl/function_impl/water_sensor_report_fn_impl.cpp b/usrc/protocol_impl/function_impl/water_sensor_report_fn_impl.cpp new file mode 100644 index 0000000..10a5df4 --- /dev/null +++ b/usrc/protocol_impl/function_impl/water_sensor_report_fn_impl.cpp @@ -0,0 +1,64 @@ + +#include "afunction_impl.hpp" +using namespace iflytop; + +#define TAG "WATER_SENSOR_REPORT_FN" + +static osTimerId WaterSensorReportTimerId; // +static bool m_force_report = false; + +static void onWaterSensorReportTimer(void const* argument) { + // 水浸传感器数据上报 + static uint8_t reportcache[50]; + static report_water_sensor_state_t* report = (report_water_sensor_state_t*)reportcache; + + static bool state = true; + + int16_t val = 0; + static bool evaporation_bin_water_sensor_state; + { + bool state = Hardware::ins().m_evaporation_bin_water_sensor.read(); + if (m_force_report || state != evaporation_bin_water_sensor_state) { + evaporation_bin_water_sensor_state = state; + ZLOGI(TAG, "evaporation_bin_water_sensor state %d", state); + report->state = val; + zcanbus_send_report(kreport_evaporation_bin_water_sensor, (uint8_t*)report, sizeof(report_water_sensor_state_t), 10); + } + } + + static bool device_bottom_water_sensor_state; + { + bool state = Hardware::ins().m_device_bottom_water_sensor.read(); + if (m_force_report || state != device_bottom_water_sensor_state) { + device_bottom_water_sensor_state = state; + ZLOGI(TAG, "device_bottom_water_sensor state %d", state); + report->state = val; + zcanbus_send_report(kreport_device_bottom_water_sensor, (uint8_t*)report, sizeof(report_water_sensor_state_t), 10); + } + } + + m_force_report = false; +} + +void fn_cmd_evaporation_bin_water_sensor_read_state(uint8_t from, uint8_t to, zcanbus_packet_t* packet, size_t len) { + CHECK_PARAM_LEN(PRAAM_LEN(), 0); + + int32_t val = Hardware::ins().m_evaporation_bin_water_sensor.read(); + zcanbus_send_ack(packet, (uint8_t*)&val, sizeof(val)); +} + +void fn_cmd_device_bottom_water_sensor_read_state(uint8_t from, uint8_t to, zcanbus_packet_t* packet, size_t len) { + CHECK_PARAM_LEN(PRAAM_LEN(), 0); + + int32_t val = Hardware::ins().m_device_bottom_water_sensor.read(); + zcanbus_send_ack(packet, (uint8_t*)&val, sizeof(val)); +} + +void water_sensor_report_fn_impl_init() { + osTimerDef(WaterSensorReportTimer, onWaterSensorReportTimer); + WaterSensorReportTimerId = osTimerCreate(osTimer(WaterSensorReportTimer), osTimerPeriodic, NULL); +} + +void water_sensor_report_fn_impl_start_tmr() { osTimerStart(WaterSensorReportTimerId, 20); } + +void water_sensor_report_fn_impl_force_report() { m_force_report = true; } diff --git a/usrc/protocol_impl/protocol_impl_service.cpp b/usrc/protocol_impl/protocol_impl_service.cpp index abb898b..589ba07 100644 --- a/usrc/protocol_impl/protocol_impl_service.cpp +++ b/usrc/protocol_impl/protocol_impl_service.cpp @@ -1,453 +1,95 @@ #include "protocol_impl_service.hpp" -#include "base/device_info.hpp" -#include "base/hardware.hpp" -#include "report_flag_mgr.hpp" -#include "zsdk/modbus/modbus_block_host.hpp" -#include "zsdk/zcanreceiver/zcanreceiver.hpp" +#include "function_impl/afunction_impl.hpp" + #define TAG "PROTO" using namespace iflytop; -/*********************************************************************************************************************** - * FUNCTION_LIST * - ***********************************************************************************************************************/ - -#define CHECK_PARAM_LEN(_paramNum, expectNum) \ - if (_paramNum != expectNum) { \ - zcanbus_send_errorack(packet, kerr_invalid_param_num); \ - return; \ - } - -#define CHECK_MOTOR_INDEX(_subindex) \ - if (_subindex > Hardware::ins().motorNum()) { \ - zcanbus_send_errorack(packet, kerr_invalid_param); \ - return; \ - } -#define GET_PARAM(buff, off) ((((int32_t*)(buff))[off])) - -#define CLEAR_BIT(val, bit) (val &= ~(1 << bit)) -#define SET_BIT(val, bit) (val |= (1 << bit)) /*********************************************************************************************************************** * VAR_LIST * ***********************************************************************************************************************/ -static osTimerId HeartReportTimerId; static osThreadId PacketRxThreadId; -static osTimerId PressureSensorDataReportTimerId; // 压力传感器数值上报 -static uint32_t m_pressureSensorDataReportPeriodMs = 3000; - -static osTimerId MotorMonitorTimerId; // 压力传感器数值上报 -static bool motorErrorFlagCache[10]; // 电机异常状态上报标志位 -static zmutex motorErrorFlagCacheLock; -static uint8_t m_dflag; - -static bool motorErrorFlag_get(int subindex) { - bool ret; - { - zlock_guard guard(motorErrorFlagCacheLock); - ret = motorErrorFlagCache[subindex]; - } - return ret; -} - -static void motorErrorFlag_set(int subindex, bool val) { - { - zlock_guard guard(motorErrorFlagCacheLock); - motorErrorFlagCache[subindex] = val; - } -} - -/*********************************************************************************************************************** - * FUNCTION_IMPL * - ***********************************************************************************************************************/ - -static void basic_func_impl(uint8_t from, uint8_t to, uint8_t* rawpacket, size_t len) { - zcanbus_packet_t* packet = (zcanbus_packet_t*)rawpacket; - int32_t paramLen = (len - sizeof(zcanbus_packet_t)) / 4; - - // 读板子信息 - if (packet->function_id == kcmd_read_board_info) { - static ack_read_board_info_data_t ack; - ack.boardType = deviceInfo_getBoardType(); - ack.projectId = deviceInfo_getProjectId(); - ack.protcol_version = deviceInfo_getProtocolVersion(); - ack.software_version = deviceInfo_getSoftwareVersion(); - ack.hardware_version = deviceInfo_getHardwareVersion(); - - zcanbus_send_ack(packet, (uint8_t*)&ack, sizeof(ack)); - } - - // 读系统信息 - else if (packet->function_id == kcmd_read_sysinfo) { - static ack_sysinfo_t ack; - ack.free_heap_size = SysMgr::ins()->osGetMinimumEverFreeHeapSize(); - ack.total_heap_size = SysMgr::ins()->osGetTotalHeapSize(); - ack.taskNum = SysMgr::ins()->getTaskNum(); - ack.sysHasRun = SysMgr::ins()->osGetSysRunTime() / 1000; - zcanbus_send_ack(packet, (uint8_t*)&ack, sizeof(ack)); - } - - // 读任务信息 - else if (packet->function_id == kcmd_read_taskinfo) { - static ask_taskinfo_t ack; - int32_t taskoff = GET_PARAM(packet->params, 0); - osThreadId taskId = SysMgr::ins()->osGetId(taskoff); - SysMgr::ins()->osTaskName(taskId, (char*)ack.taskName, sizeof(ack.taskName)); - SysMgr::ins()->osTaskStackRemainingSize(taskId, &ack.stackRemindSize); - SysMgr::ins()->osTaskPriority(taskId, &ack.priority); - SysMgr::ins()->osTaskGetState(taskId, (char*)&ack.state); - - zcanbus_send_ack(packet, (uint8_t*)&ack, sizeof(ack)); - } - // 心跳 ping pong - else if (packet->function_id == kcmd_heart_ping) { - static report_heatpacket_data_t heatpacket; - heatpacket.boardType = deviceInfo_getBoardType(); - heatpacket.heartIndex = GET_PARAM(packet->params, 0); - heatpacket.flag = m_dflag; - zcanbus_send_report(kreport_heatpacket_pong, (uint8_t*)&heatpacket, sizeof(heatpacket), 30); - } - - else if (packet->function_id == kcmd_clear_reset_flag) { - CLEAR_BIT(m_dflag, 0); - zcanbus_send_ack(packet, NULL, 0); - } - // 触发一次强制上报事件 - if (packet->function_id == kcmd_force_report) { - ForceReportFlagMgr::ins()->trigger(); - if (from != 0xff) zcanbus_send_ack(packet, NULL, 0); - } -} - -static void pump_func_impl(uint8_t from, uint8_t to, uint8_t* rawpacket, size_t len) { - zcanbus_packet_t* packet = (zcanbus_packet_t*)rawpacket; - int32_t paramNum = (len - sizeof(zcanbus_packet_t)) / 4; - - // 泵机转动 - if (packet->function_id == kcmd_pump_rotate) { - CHECK_PARAM_LEN(paramNum, 2); - - int32_t subindex = GET_PARAM(packet->params, 0); - int32_t velocity = GET_PARAM(packet->params, 1); - - if (subindex >= Hardware::ins().motorNum()) { - zcanbus_send_errorack(packet, kerr_invalid_param); - return; - } - if (!Hardware::ins().motor(subindex)->ping()) { - zcanbus_send_errorack(packet, kerr_motor_subdevice_offline); - return; - } - - Hardware::ins().motor(subindex)->enableIC(false); - Hardware::ins().motor(subindex)->enableIC(true); - Hardware::ins().motor(subindex)->rotate(velocity); - - zcanbus_send_ack(packet, NULL, 0); - motorErrorFlag_set(subindex, false); - } - - // 泵机停止 - else if (packet->function_id == kcmd_pump_stop) { - CHECK_PARAM_LEN(paramNum, 1); - - int32_t subindex = GET_PARAM(packet->params, 0); - - if (subindex >= Hardware::ins().motorNum()) { - zcanbus_send_errorack(packet, kerr_invalid_param); - return; - } - - if (!Hardware::ins().motor(subindex)->ping()) { - zcanbus_send_errorack(packet, kerr_motor_subdevice_offline); - return; - } - - Hardware::ins().motor(subindex)->stop(); - zcanbus_send_ack(packet, NULL, 0); - } - - // 设置电流/保持电流/IDELAY - else if (packet->function_id == kcmd_pump_set_ihold_irun_idelay) { - CHECK_PARAM_LEN(paramNum, 4); - - int32_t subindex = GET_PARAM(packet->params, 0); - int32_t ihold = GET_PARAM(packet->params, 1); - int32_t irun = GET_PARAM(packet->params, 2); - int32_t idelay = GET_PARAM(packet->params, 3); - - if (subindex >= Hardware::ins().motorNum()) { - zcanbus_send_errorack(packet, kerr_invalid_param); - return; - } - - if (!Hardware::ins().motor(subindex)->ping()) { - zcanbus_send_errorack(packet, kerr_motor_subdevice_offline); - return; - } - - Hardware::ins().motor(subindex)->setIHOLD_IRUN(ihold, irun, idelay); - zcanbus_send_ack(packet, NULL, 0); - } - // 设置加速度 - else if (packet->function_id == kcmd_pump_set_acc) { - CHECK_PARAM_LEN(paramNum, 2); - - int32_t subindex = GET_PARAM(packet->params, 0); - int32_t acc = GET_PARAM(packet->params, 1); - - if (subindex >= Hardware::ins().motorNum()) { - zcanbus_send_errorack(packet, kerr_invalid_param); - return; - } - - if (!Hardware::ins().motor(subindex)->ping()) { - zcanbus_send_errorack(packet, kerr_motor_subdevice_offline); - return; - } - - Hardware::ins().motor(subindex)->setAcceleration(acc); - Hardware::ins().motor(subindex)->setDeceleration(acc); - zcanbus_send_ack(packet, NULL, 0); - - } - - // 设置5130寄存器 - else if (packet->function_id == kcmd_pump_set_subic_reg) { - CHECK_PARAM_LEN(paramNum, 3); - - int32_t subindex = GET_PARAM(packet->params, 0); - int32_t regadd = GET_PARAM(packet->params, 1); - int32_t regval = GET_PARAM(packet->params, 2); - - if (subindex >= Hardware::ins().motorNum()) { - zcanbus_send_errorack(packet, kerr_invalid_param); - return; - } - - if (!Hardware::ins().motor(subindex)->ping()) { - zcanbus_send_errorack(packet, kerr_motor_subdevice_offline); - return; - } - - Hardware::ins().motor(subindex)->writeInt(regadd, regval); - } - - // 读取5130寄存器 - else if (packet->function_id == kcmd_pump_get_subic_reg) { - CHECK_PARAM_LEN(paramNum, 2); - - int32_t subindex = GET_PARAM(packet->params, 0); - int32_t regadd = GET_PARAM(packet->params, 1); - - if (subindex >= Hardware::ins().motorNum()) { - zcanbus_send_errorack(packet, kerr_invalid_param); - return; - } - - if (!Hardware::ins().motor(subindex)->ping()) { - zcanbus_send_errorack(packet, kerr_motor_subdevice_offline); - return; - } - - int32_t regval = Hardware::ins().motor(subindex)->readInt(regadd); - zcanbus_send_ack(packet, (uint8_t*)®val, sizeof(regval)); - } - - // ping - else if (packet->function_id == kcmd_pump_get_subic_reg) { - CHECK_PARAM_LEN(paramNum, 1); - - int32_t subindex = GET_PARAM(packet->params, 0); - - if (subindex >= Hardware::ins().motorNum()) { - zcanbus_send_errorack(packet, kerr_invalid_param); - return; - } - - if (!Hardware::ins().motor(subindex)->ping()) { - zcanbus_send_errorack(packet, kerr_motor_subdevice_offline); - return; - } - zcanbus_send_ack(packet, NULL, 0); - } -} - -static void others_func_impl(uint8_t from, uint8_t to, uint8_t* rawpacket, size_t len) { - zcanbus_packet_t* packet = (zcanbus_packet_t*)rawpacket; - int32_t paramNum = (len - sizeof(zcanbus_packet_t)) / 4; - - // m_atta_mini_air_compressor_ctrl - - // 喷液MINI真空泵 - if (packet->function_id == kcmd_sl_mini_ac_ctrl) { - CHECK_PARAM_LEN(paramNum, 1); - Hardware::ins().sl_mini_ac_ctrl()->write(GET_PARAM(packet->params, 0)); - zcanbus_send_ack(packet, NULL, 0); - } - // 气密性测试MINI真空泵 - else if (packet->function_id == kcmd_atta_mini_air_compressor_ctrl) { - CHECK_PARAM_LEN(paramNum, 1); - Hardware::ins().atta_mini_air_compressor_ctrl()->write(GET_PARAM(packet->params, 0)); - zcanbus_send_ack(packet, NULL, 0); - } - - // 压力传感器数据上报 - else if (packet->function_id == kcmd_pressure_sensor_bus_read_data) { - CHECK_PARAM_LEN(paramNum, 1); - int32_t index = GET_PARAM(packet->params, 0); - - int16_t val = 0; - int32_t reportVal = 0; - bool suc = Hardware::ins().pressureSensorBus()->readData(index, &val); - - reportVal = val; - - if (suc) { - zcanbus_send_ack(packet, (uint8_t*)&reportVal, sizeof(reportVal)); - } else { - zcanbus_send_errorack(packet, kerr_subdevice_offline); - } - } -#if 0 - // 压力传感器数据上报 - else if (packet->function_id == kcmd_pressure_sensor_bus_set_report_period_ms) { - CHECK_PARAM_LEN(paramNum, 1); - int32_t period = GET_PARAM(packet->params, 0); - - ZLOGI(TAG, "set pressure sensor data report period %d ms", period); - - if (period != 0) { - if (period < 200) period = 200; - osTimerStop(PressureSensorDataReportTimerId); - osTimerStart(PressureSensorDataReportTimerId, period); - m_pressureSensorDataReportPeriodMs = period; - } else { - osTimerStop(PressureSensorDataReportTimerId); - } - - zcanbus_send_ack(packet, NULL, 0); - } -#endif -} - -/*********************************************************************************************************************** - * SCHEDULER * - ***********************************************************************************************************************/ static void onPacketRxThreadStart(void const* argument) { while (true) { zcanbus_schedule(); osDelay(1); } } + static void zcanbus_on_rx(uint8_t from, uint8_t to, uint8_t* rawpacket, size_t len) { // zcanbus_packet_t* packet = (zcanbus_packet_t*)rawpacket; ZLOGI(TAG, "process packet from %d to %d, function_id %d, len %d", from, to, packet->function_id, len); - - basic_func_impl(from, to, rawpacket, len); - pump_func_impl(from, to, rawpacket, len); - others_func_impl(from, to, rawpacket, len); - + bool processed = fn_map_process(packet->function_id, from, to, rawpacket, len); + if (!processed) { + zcanbus_send_errorack(packet, kerr_function_not_support); + } ZLOGI(TAG, "process end"); } static void zcanbus_on_connected(bool connected) { if (connected) { ZLOGI(TAG, "connected to host"); + water_sensor_report_fn_impl_force_report(); } else { ZLOGI(TAG, "disconnected from host"); } } -#if 0 -static void onPressureSensorDataReportTimer(void const* argument) { - // 压力传感器数据上报 - static uint8_t reportcache[100]; - static report_pressure_data_t* report = (report_pressure_data_t*)reportcache; - int sensorNum = 0; +void fn_cmd_triple_warning_light_ctl(uint8_t from, uint8_t to, zcanbus_packet_t* packet, size_t len); - for (size_t i = 0; i < PXX_PRESSURE_SENSOR_NUM; i++) { - int16_t val = 0; - bool suc = Hardware::ins().pressureSensorBus()->readData(i, &val); - - if (suc) { - report->data[sensorNum].subid = i; - report->data[sensorNum].pressureVal = val; - sensorNum++; - } - } - - report->sensorDataNum = sensorNum; - zcanbus_send_report(kreport_pressure_data, (uint8_t*)report, // - sizeof(report_pressure_data_t) + sensorNum * sizeof(report->data[0]), 10); -} -#endif - -static void onMotorMonitorTimer(void const* argument) { - // 电机异常检查 - - report_exeception_data_t data; - for (size_t i = 0; i < Hardware::ins().motorNum(); i++) { - bool estate = motorErrorFlag_get(i); - - if (!Hardware::ins().motor(i)->ping()) { - data.subid = i; - data.ecode = kerr_motor_subdevice_offline; - - if (!estate) { - motorErrorFlag_set(i, true); - ZLOGE(TAG, "motor %d offline error", i); - zcanbus_send_emergency_report(kreport_exception_error, (uint8_t*)&data, sizeof(data), 100); - } - } else { - auto gstate = Hardware::ins().motor(i)->getGState(); - bool flag = gstate.reset || gstate.drv_err || gstate.uv_cp; - if (!flag && estate) { - motorErrorFlag_set(i, false); - } else if (flag && !estate) { - ZLOGE(TAG, "motor %d error, reset %d, drv_err %d, uv_cp %d", i, gstate.reset, gstate.drv_err, gstate.uv_cp); - if (gstate.reset) { - data.ecode = kerr_motor_reset_error; - } else if (gstate.uv_cp) { - data.ecode = kerr_motor_undervoltage_error; - } else if (gstate.drv_err) { - data.ecode = kerr_motor_driver_error; - } else { - data.ecode = kerr_motor_unkown_error; - } - data.subid = i; - motorErrorFlag_set(i, true); - zcanbus_send_emergency_report(kreport_exception_error, (uint8_t*)&data, sizeof(data), 100); - } - } - } -} +void fn_cmd_evaporation_bin_water_sensor_read_state(uint8_t from, uint8_t to, zcanbus_packet_t* packet, size_t len); +void fn_cmd_device_bottom_water_sensor_read_state(uint8_t from, uint8_t to, zcanbus_packet_t* packet, size_t len); -/*********************************************************************************************************************** - * EXT * - ***********************************************************************************************************************/ +void water_sensor_report_fn_impl_init(); +void water_sensor_report_fn_impl_start_tmr(); +void water_sensor_report_fn_impl_force_report(); void protocol_impl_service_init() { // Hardware::ins().init(); ForceReportFlagMgr::ins()->init(); - motorErrorFlagCacheLock.init(); - m_dflag = 0x00; - SET_BIT(m_dflag, 0); zcanbus_init(deviceInfo_getBoardId()); zcanbus_reglistener(zcanbus_on_rx); zcanbus_reg_on_connected_listener(zcanbus_on_connected); -#if 0 - osTimerDef(PressureSensorDataReportTimer, onPressureSensorDataReportTimer); - PressureSensorDataReportTimerId = osTimerCreate(osTimer(PressureSensorDataReportTimer), osTimerPeriodic, NULL); - osTimerStart(PressureSensorDataReportTimerId, m_pressureSensorDataReportPeriodMs); -#endif + { + basic_fn_init(); + fn_map_reg(kcmd_read_board_info, fn_cmd_read_board_info); + fn_map_reg(kcmd_read_sysinfo, fn_cmd_read_sysinfo); + fn_map_reg(kcmd_read_taskinfo, fn_cmd_read_taskinfo); + fn_map_reg(kcmd_heart_ping, fn_cmd_heart_ping); + fn_map_reg(kcmd_clear_reset_flag, fn_cmd_clear_reset_flag); + } + + { + water_sensor_report_fn_impl_init(); + fn_map_reg(kcmd_evaporation_bin_water_sensor_read_state, fn_cmd_evaporation_bin_water_sensor_read_state); + fn_map_reg(kcmd_device_bottom_water_sensor_read_state, fn_cmd_device_bottom_water_sensor_read_state); + water_sensor_report_fn_impl_start_tmr(); + } - osTimerDef(MotorMonitorTimer, onMotorMonitorTimer); - MotorMonitorTimerId = osTimerCreate(osTimer(MotorMonitorTimer), osTimerPeriodic, NULL); - osTimerStart(MotorMonitorTimerId, 1000); + { + pump_fn_init(); + pump_fn_report_tmr_start(); + + fn_map_reg(kcmd_pump_rotate, fn_cmd_pump_rotate); + fn_map_reg(kcmd_pump_stop, fn_cmd_pump_stop); + fn_map_reg(kcmd_pump_set_ihold_irun_idelay, fn_cmd_pump_set_ihold_irun_idelay); + fn_map_reg(kcmd_pump_set_acc, fn_cmd_pump_set_acc); + fn_map_reg(kcmd_pump_set_subic_reg, fn_cmd_pump_set_subic_reg); + fn_map_reg(kcmd_pump_get_subic_reg, fn_cmd_pump_get_subic_reg); + fn_map_reg(kcmd_pump_ping, fn_cmd_pump_ping); + } + + { fn_map_reg(kcmd_triple_warning_light_ctl, fn_cmd_triple_warning_light_ctl); } + + { + pressure_fn_impl_init(); + fn_map_reg(kcmd_pressure_sensor_bus_read_data, fn_cmd_pressure_sensor_bus_read_data); + fn_map_reg(kcmd_pressure_sensor_bus_set_report_period_ms, fn_cmd_pressure_sensor_bus_set_report_period_ms); + } osThreadDef(PacketRxThread, onPacketRxThreadStart, osPriorityNormal, 0, 1024); PacketRxThreadId = osThreadCreate(osThread(PacketRxThread), NULL); diff --git a/usrc/protocol_impl/protocol_impl_service.hpp b/usrc/protocol_impl/protocol_impl_service.hpp index 2d7419c..8ee77b7 100644 --- a/usrc/protocol_impl/protocol_impl_service.hpp +++ b/usrc/protocol_impl/protocol_impl_service.hpp @@ -5,3 +5,4 @@ #include "zsdk/zsdk.hpp" void protocol_impl_service_init(); + diff --git a/usrc/protocol_impl/report_flag_mgr.cpp b/usrc/protocol_impl/report_flag_mgr.cpp deleted file mode 100644 index ee889d2..0000000 --- a/usrc/protocol_impl/report_flag_mgr.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "report_flag_mgr.hpp" -using namespace iflytop; - -ForceReportFlagMgr* ForceReportFlagMgr::ins() { - static ForceReportFlagMgr instance; - return &instance; -} - -void ForceReportFlagMgr::init() { - m_lock.init(); - memset(&m_flag, 0, sizeof(m_flag)); -} -void ForceReportFlagMgr::trigger() { - zlock_guard lock(m_lock); - memset(&m_flag, 1, sizeof(m_flag)); -} \ No newline at end of file diff --git a/usrc/protocol_impl/report_flag_mgr.hpp b/usrc/protocol_impl/report_flag_mgr.hpp deleted file mode 100644 index 275416b..0000000 --- a/usrc/protocol_impl/report_flag_mgr.hpp +++ /dev/null @@ -1,32 +0,0 @@ -#include -#include -#include - -#include "base/config_service.hpp" -#include "zsdk/zsdk.hpp" - -namespace iflytop { - -class ForceReportFlagMgr { - private: - typedef struct { - bool pad; - } flag_t; - - zmutex m_lock; - flag_t m_flag; - - public: - static ForceReportFlagMgr* ins(); - - void init(); - - void trigger(); - - void clearPad() { - zlock_guard lock(m_lock); - m_flag.pad = false; - } -}; - -} // namespace iflytop