current_v/Src/fault_probe.c

391 lines
13 KiB
C
Raw Normal View History

2025-12-31 08:21:43 +08:00
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file fault_probe.c
* @author Motor Control SDK Team, Yuwell Software XiangenWang
* @brief Voice Recognition Module Initialization Section,
including peripheral initialization and message node insertion, etc.
* @version 1.0
* @changelog version 1.0 <EFBFBD><EFBFBD>ʼ<EFBFBD> 2025.11.13
- <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>½<EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD>в<EFBFBD><EFBFBD><EFBFBD>
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2025 Yuwell Software Danyang.Jiangsu.China.
* All rights reserved.</center></h2>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted, provided that the following conditions are met:
*
* 1. Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of Yuwell Software nor the names of other
* contributors to this software may be used to endorse or promote products
* derived from this software without specific written permission.
* 4. This software, including modifications and/or derivative works of this
* software, must execute solely and exclusively on microcontroller or
* microprocessor devices manufactured by or for Yuwell Software.
* 5. Redistribution and use of this software other than as permitted under
* this license is void and will automatically terminate your rights under
* this license.
*
* THIS SOFTWARE IS PROVIDED BY Yuwell Software AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
* RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
* SHALL Yuwell Software OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************
*/
/* USER CODE END Header */
#include "fault_probe.h"
FaultInfo fault_info;
void fault_array_init(void)
{
MsgQueueItem msg_item;
// <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>GPIO
FL_GPIO_InitTypeDef GPIO_InitStruct;
GPIO_InitStruct.pin = BEEP_GPIO_PIN;
GPIO_InitStruct.mode = FL_GPIO_MODE_OUTPUT;
GPIO_InitStruct.outputType = FL_GPIO_OUTPUT_PUSHPULL;
GPIO_InitStruct.pull = FL_ENABLE;
GPIO_InitStruct.remapPin = FL_DISABLE;
GPIO_InitStruct.analogSwitch = FL_DISABLE;
FL_GPIO_Init(BEEP_GPIO_PORT, &GPIO_InitStruct);
GPIO_InitStruct.pin = BEEP_LIGHT_GPIO_PIN;
FL_GPIO_Init(BEEP_LIGHT_GPIO_PORT, &GPIO_InitStruct);
// <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD>еı߽<C4B1><DFBD><EFBFBD>Ϣ <20><><EFBFBD>¹<EFBFBD><C2B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
peek_queue_node_by_type(&global_queue, MSG_TYPE_AD_BOUNDARY_SEND, &msg_item);
fault_info.elec_low_boundary = msg_item.data.adc_boundary.elec_low_boundary;
fault_info.elec_high_boundary = msg_item.data.adc_boundary.elec_high_boundary;
fault_info.ntc_low_boundary = msg_item.data.adc_boundary.ntc_low_boundary;
fault_info.ntc_high_boundary = msg_item.data.adc_boundary.ntc_high_boundary;
fault_info.press_low_boundary = msg_item.data.adc_boundary.press_low_boundary;
fault_info.press_high_boundary = msg_item.data.adc_boundary.press_high_boundary;
fault_info.net220v_low_boundary = msg_item.data.adc_boundary.net220v_low_boundary;
fault_info.net220v_high_boundary = msg_item.data.adc_boundary.net220v_high_boundary;
// <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊδ<CEAA><CEB4><EFBFBD><EFBFBD>״̬
fault_info.e1_press_low_state = NO_HAPPEN;
fault_info.e2_press_high_state = NO_HAPPEN;
fault_info.e3_elec_low_state = NO_HAPPEN;
fault_info.e4_elec_high_state = NO_HAPPEN;
fault_info.e5_ntc_high_state = NO_HAPPEN;
fault_info.ll_flow_low_state = NO_HAPPEN;
fault_info.e7_net220v_low_state = NO_HAPPEN;
fault_info.O2_900_low_state = NO_HAPPEN;
fault_info.O2_835_low_state = NO_HAPPEN;
BEEP_LIGHT_ON;
}
void fault_process_task(void)
{
static uint32_t e1_press_low_count = 0;
static uint32_t e2_press_high_count = 0;
static uint32_t e3_elec_low_count = 0;
static uint32_t e4_elec_high_count = 0;
static uint32_t e5_ntc_high_count = 0;
static uint32_t ll_flow_low_count = 0;
static uint32_t e7_220v_low_count = 0;
static uint32_t o2_835_low_count = 0;
// <20><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>
MsgQueueItem o2_sensor_item;
MsgQueueItem adc_sample_item;
MsgQueueItem currentTime_item;
MsgQueueItem stm_item;
// <20>ж<EFBFBD><D0B6><EFBFBD>ǰ״̬<D7B4><CCAC><EFBFBD>Ƿ<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>ģʽ<C4A3><CABD>У׼ģʽ <20><><EFBFBD>Dz<EFBFBD><C7B2>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4>
if(peek_queue_node_by_type(&global_queue, MSG_TYPE_OXG_STM, &stm_item))
{
switch(stm_item.data.state_machine.oxg_stm)
{
case STM_CARLIB:
case STM_DEBUG: // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>м<EFBFBD><D0BC><EFBFBD>
return;
case STM_ERROR_NONE_STOP:
// O90 O8335 E7
if(xOxygenEventGroupCheckBit(&global_event, EVENT_O2_900_LOW)) // Ũ<>ȵ<EFBFBD><C8B5><EFBFBD>90<39>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
BEEP_OFF;
}
if(xOxygenEventGroupCheckAnyBits(&global_event, EVENT_O2_835_LOW | EVENT_E7_220V_LOW))
{
if(xOxygenEventGroupCheckBit(&global_event, EVENT_BEEP_MUTE))
{
BEEP_OFF; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>رձ<D8B1><D5B1><EFBFBD>
}else{
BEEP_ON;
}
}
break;
case STM_ERROR_SHOUNTDOWN: // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if(xOxygenEventGroupCheckBit(&global_event, EVENT_BEEP_MUTE))
{
BEEP_OFF; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>رձ<D8B1><D5B1><EFBFBD>
}else{
BEEP_ON;
}
break;
default: // Ĭ<><C4AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>½<EFBFBD><C2BD>й<EFBFBD><D0B9>ϼ<EFBFBD><CFBC><EFBFBD>
break;
}
}
// <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>Ũ<EFBFBD><C5A8><EFBFBD><EFBFBD><EFBFBD>ݲ<EFBFBD><DDB2>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˹<EFBFBD><CBB9><EFBFBD>
if(peek_queue_node_by_type(&global_queue, MSG_TYPE_OXYGEN_SENSOR, &o2_sensor_item))
{
fault_info.O2_900_low_state = (o2_sensor_item.data.oxygen.concentration < O2_90_PERCENT_BOUNDARY) ? YES_HAPPEND:NO_HAPPEN;
fault_info.O2_835_low_state = (o2_sensor_item.data.oxygen.concentration < O2_83P5_PERCENT_BOUNDARY) ? YES_HAPPEND:NO_HAPPEN;
fault_info.ll_flow_low_state = (o2_sensor_item.data.oxygen.flow_rate < LL_FLOW_BOUNDARY) ? YES_HAPPEND:NO_HAPPEN;
}else{
return;
}
// <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0>ADC<44><43><EFBFBD>ݲ<EFBFBD><DDB2>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˹<EFBFBD><CBB9><EFBFBD>
if(peek_queue_node_by_type(&global_queue, MSG_TYPE_AD_SAMPLING, &adc_sample_item))
{
fault_info.e1_press_low_state = (adc_sample_item.data.adc_data.real_press < fault_info.press_low_boundary) ? YES_HAPPEND:NO_HAPPEN;
fault_info.e2_press_high_state = (adc_sample_item.data.adc_data.real_press > fault_info.press_high_boundary) ? YES_HAPPEND:NO_HAPPEN;
fault_info.e3_elec_low_state = (adc_sample_item.data.adc_data.real_elec < fault_info.elec_low_boundary) ? YES_HAPPEND:NO_HAPPEN;
fault_info.e4_elec_high_state = (adc_sample_item.data.adc_data.real_elec > fault_info.elec_high_boundary) ? YES_HAPPEND:NO_HAPPEN;
fault_info.e5_ntc_high_state = (adc_sample_item.data.adc_data.real_ntc > fault_info.ntc_high_boundary) ? YES_HAPPEND:NO_HAPPEN;
fault_info.e7_net220v_low_state = (adc_sample_item.data.adc_data.real_220V < fault_info.net220v_low_boundary) ? YES_HAPPEND:NO_HAPPEN;
}else{
return;
}
// <20><><EFBFBD>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
if(peek_queue_node_by_type(&global_queue, MSG_TYPE_CURRENT_TIME, &currentTime_item))
{
// E1<45><31><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD> <20><><EFBFBD><EFBFBD>4min<69><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>8<EFBFBD><38><EFBFBD>Ծ<EFBFBD><D4BE><EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>E1<45>¼<EFBFBD>
if((currentTime_item.data.hour_meter.minute >= 4)||(currentTime_item.data.hour_meter.hour >= 1))
{
if(fault_info.e1_press_low_state == YES_HAPPEND)
{
if(e1_press_low_count >= 80) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EBB7A2><EFBFBD><EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
{
vOxygenEventGroupSetBits(&global_event, EVENT_E1_PRESS_LOW); // <20><><EFBFBD>Ǵ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>E1<45>¼<EFBFBD>
}else{
e1_press_low_count++;
}
}else{
e1_press_low_count = 0;
// vOxygenEventGroupClearBits(&global_event, EVENT_E1_PRESS_LOW); // <20><><EFBFBD><EFBFBD>E1<45>¼<EFBFBD>
}
}
// E2<45><32><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD> <20><><EFBFBD><EFBFBD>25<32><35><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0.5<EFBFBD><EFBFBD><EFBFBD>Ծɷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>E2<EFBFBD>¼<EFBFBD>
if((currentTime_item.data.hour_meter.second > 25)||(currentTime_item.data.hour_meter.minute >= 1)||(currentTime_item.data.hour_meter.hour >= 1))
{
if(fault_info.e2_press_high_state == YES_HAPPEND)
{
if(e2_press_high_count >= 5)
{
vOxygenEventGroupSetBits(&global_event, EVENT_E2_PRESS_HIGH); // <20><><EFBFBD>Ǵ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>E2<45>¼<EFBFBD>
}else{
e2_press_high_count++;
}
}else{
e2_press_high_count = 0;
// vOxygenEventGroupClearBits(&global_event, EVENT_E2_PRESS_HIGH); // <20><><EFBFBD><EFBFBD>E2<45>¼<EFBFBD>
}
}
// E3<45><33><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>8s<38><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>E3<45>¼<EFBFBD>
if(fault_info.e3_elec_low_state == YES_HAPPEND)
{
if(e3_elec_low_count >= 80)
{
vOxygenEventGroupSetBits(&global_event, EVENT_E3_ELEC_LOW); // <20><><EFBFBD>Ǵ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>E3<45>¼<EFBFBD>
}else{
e3_elec_low_count++;
}
}else{
e3_elec_low_count = 0;
vOxygenEventGroupClearBits(&global_event, EVENT_E3_ELEC_LOW);
}
// E4<45><34><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>8s<38><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>򱨾<EFBFBD>
if(fault_info.e4_elec_high_state == YES_HAPPEND)
{
if(e4_elec_high_count >= 80)
{
vOxygenEventGroupSetBits(&global_event, EVENT_E4_ELEC_HIGH); // <20><><EFBFBD>Ǵ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>E4<45>¼<EFBFBD>
}else{
e4_elec_high_count++;
}
}else{
e4_elec_high_count = 0;
// vOxygenEventGroupClearBits(&global_event, EVENT_E4_ELEC_HIGH);
}
// E5<45><35><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2min <20><><EFBFBD><EFBFBD>4s<34>¶ȸ<C2B6>
if((currentTime_item.data.hour_meter.minute >= 2)||(currentTime_item.data.hour_meter.hour >= 1))
{
if(fault_info.e5_ntc_high_state == YES_HAPPEND)
{
if(e5_ntc_high_count >= 40)
{
vOxygenEventGroupSetBits(&global_event, EVENT_E5_NTC_HIGH); // <20><><EFBFBD>Ǵ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>E5<45>¼<EFBFBD>
}else{
e5_ntc_high_count++;
}
}else{
e5_ntc_high_count = 0;
// vOxygenEventGroupClearBits(&global_event, EVENT_E5_NTC_HIGH);
}
}
// LL<4C>ж<EFBFBD>
if(fault_info.ll_flow_low_state == YES_HAPPEND)
{
if(ll_flow_low_count >= 320)
{
vOxygenEventGroupSetBits(&global_event, EVENT_LL_FLOW_LOW); // <20><><EFBFBD>Ǵ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>LL<4C>¼<EFBFBD>
}else{
ll_flow_low_count++;
}
}else{
ll_flow_low_count = 0;
// vOxygenEventGroupClearBits(&global_event, EVENT_LL_FLOW_LOW);
}
// E7<45>ж<EFBFBD>
if((currentTime_item.data.hour_meter.minute >= 5)||(currentTime_item.data.hour_meter.hour >= 1))
{
if(fault_info.e7_net220v_low_state == YES_HAPPEND)
{
if(e7_220v_low_count >= 80)
{
vOxygenEventGroupSetBits(&global_event, EVENT_E7_220V_LOW); // <20><><EFBFBD>Ǵ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>E7<45>¼<EFBFBD>
}else{
e7_220v_low_count++;
}
}else{
e7_220v_low_count = 0;
vOxygenEventGroupClearBits(&global_event, EVENT_E7_220V_LOW);
}
}
// O2Ũ<32>ȵ<EFBFBD><C8B5>ж<EFBFBD>
if(((currentTime_item.data.hour_meter.minute >= 2)&&(currentTime_item.data.hour_meter.hour == 0)) &&
((currentTime_item.data.hour_meter.minute <= 5)&&(currentTime_item.data.hour_meter.hour == 0)))
{
if(fault_info.O2_900_low_state == YES_HAPPEND)
{
// <20><><EFBFBD><EFBFBD>2-5min<69><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ũ<EFBFBD>ȵ<EFBFBD><C8B5><EFBFBD>90% <20><><EFBFBD>Ʋ<EFBFBD>ͣ<EFBFBD><CDA3> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
vOxygenEventGroupSetBits(&global_event, EVENT_O2_900_LOW); // <20><><EFBFBD>Ǵ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ũ<EFBFBD>ȵ<EFBFBD><C8B5><EFBFBD>90%<25>¼<EFBFBD>
}
}else{
// <20><><EFBFBD><EFBFBD>5min<69>󲻹<EFBFBD>Ũ<EFBFBD>ȵ<EFBFBD><C8B5><EFBFBD>90<39><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
vOxygenEventGroupClearBits(&global_event, EVENT_O2_900_LOW);
}
if((currentTime_item.data.hour_meter.minute >= 5)||(currentTime_item.data.hour_meter.hour >= 1))
{
if(fault_info.O2_835_low_state == YES_HAPPEND)
{
if(o2_835_low_count >= 600)
{
vOxygenEventGroupSetBits(&global_event, EVENT_O2_835_LOW); // <20><><EFBFBD>Ǵ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ũ<EFBFBD>ȵ<EFBFBD><C8B5><EFBFBD>83.5%<25>¼<EFBFBD>
}else{
o2_835_low_count++;
}
}else{
o2_835_low_count = 0;
vOxygenEventGroupClearBits(&global_event, EVENT_O2_835_LOW);
}
}
}
}
/************************ (C) COPYRIGHT FMSH *****END OF FILE****/