210 lines
6.7 KiB
C
210 lines
6.7 KiB
C
/* USER CODE BEGIN Header */
|
||
/**
|
||
******************************************************************************
|
||
* @file fm33lg0xx_fl_it.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 初始版本 2025.11.13
|
||
- 新增:新建第一个版本的软件,待完善解析命令后的程序执行部分
|
||
******************************************************************************
|
||
* @attention
|
||
*
|
||
* <h2><center>© 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 "fm33lg0xx_fl_it.h"
|
||
|
||
|
||
|
||
|
||
|
||
CycleTask task_state = TASK_1_ADC;
|
||
|
||
|
||
|
||
void BSTIM_IRQHandler(void)
|
||
{
|
||
if(FL_BSTIM32_IsEnabledIT_Update(BSTIM32) && FL_BSTIM32_IsActiveFlag_Update(BSTIM32))
|
||
{
|
||
FL_BSTIM32_ClearFlag_Update(BSTIM32);
|
||
|
||
/* 执行1ms执行一次的中断函数 */
|
||
main_task_20ms();
|
||
}
|
||
}
|
||
|
||
|
||
// 将轮询任务分割为5段,每段分20ms进行一次 完整执行完时间为100ms
|
||
void main_task_20ms(void)
|
||
{
|
||
static uint32_t main_start_delay4s = 0;
|
||
MsgQueueItem stm_item;
|
||
uint8_t net_code = 0;
|
||
peek_queue_node_by_type(&global_queue, MSG_TYPE_OXG_STM, &stm_item);
|
||
|
||
|
||
|
||
// 通过检测各个任务传输的内容切换当前状态机的状态
|
||
if(main_start_delay4s < 200) // 当处于初始启动的4S内则
|
||
{
|
||
main_start_delay4s++;
|
||
if(main_start_delay4s <= 70)
|
||
{
|
||
// 移动到了Main中进行执行
|
||
|
||
}else{
|
||
ALARM_YELLOW_OFF;
|
||
ui.alarm_led_show = 0;
|
||
|
||
}
|
||
|
||
}else if(stm_item.data.state_machine.oxg_stm == STM_INIT){
|
||
|
||
stm_item.data.state_machine.oxg_stm = STM_NOM; // 四秒后若还是初始状态则将其改为正常状态
|
||
|
||
modify_or_add_queue_node_by_type(&global_queue, MSG_TYPE_OXG_STM, stm_item);
|
||
|
||
}else{
|
||
|
||
// 若当前跳帽接入则判定进入校准模式
|
||
net_code = ~((FL_GPIO_ReadInputPort(NET_CODE_GPIO_PORT) >> 8)|0xF0);
|
||
|
||
if (net_code == NETCODE_E1_CALIB || net_code == NETCODE_E2_CALIB ||
|
||
net_code == NETCODE_E4_CALIB || net_code == NETCODE_E7_CALIB)
|
||
{
|
||
|
||
|
||
// 进入到标定模式 只修改显示内容 可以通过按键进行标定
|
||
stm_item.data.state_machine.oxg_stm = STM_CARLIB;
|
||
stm_item.data.state_machine.data = net_code;
|
||
modify_or_add_queue_node_by_type(&global_queue, MSG_TYPE_OXG_STM, stm_item);
|
||
|
||
}else if(net_code == NETCODE_PRESS || net_code == NETCODE_O2 ||
|
||
net_code == NETCODE_TEMP_PRESS || net_code == NETCODE_ELEC)
|
||
{
|
||
|
||
|
||
// 进入到调试模式,一切正常工作 只修改显示 不报警
|
||
stm_item.data.state_machine.oxg_stm = STM_DEBUG;
|
||
stm_item.data.state_machine.data = net_code;
|
||
modify_or_add_queue_node_by_type(&global_queue, MSG_TYPE_OXG_STM, stm_item);
|
||
|
||
}else if(xOxygenEventGroupCheckAnyBits(&global_event, FAULT_MASK_ERROR_SHOUNTDOWN))
|
||
{
|
||
|
||
stm_item.data.state_machine.oxg_stm = STM_ERROR_SHOUNTDOWN;
|
||
stm_item.data.state_machine.data = ulOxygenEventGroupGetFaultByMask(&global_event, FAULT_MASK_ERROR_SHOUNTDOWN);
|
||
|
||
modify_or_add_queue_node_by_type(&global_queue, MSG_TYPE_OXG_STM, stm_item);
|
||
|
||
}else if(xOxygenEventGroupCheckAnyBits(&global_event, FAULT_MASK_ERROR_NONE_STOP))
|
||
{
|
||
|
||
stm_item.data.state_machine.oxg_stm = STM_ERROR_NONE_STOP;
|
||
stm_item.data.state_machine.data = ulOxygenEventGroupGetFaultByMask(&global_event, FAULT_MASK_ERROR_NONE_STOP);
|
||
|
||
modify_or_add_queue_node_by_type(&global_queue, MSG_TYPE_OXG_STM, stm_item);
|
||
|
||
|
||
}else{
|
||
|
||
stm_item.data.state_machine.oxg_stm = STM_NOM;
|
||
modify_or_add_queue_node_by_type(&global_queue, MSG_TYPE_OXG_STM, stm_item);
|
||
}
|
||
|
||
}
|
||
|
||
|
||
compressor_valve_task(); // 电磁阀切换任务
|
||
|
||
switch(task_state)
|
||
{
|
||
case TASK_1_ADC:
|
||
task_state++;
|
||
sample_adc_process_task(); // 修改队列中的ADC数据
|
||
|
||
bs83b12_touch_read_task();
|
||
break;
|
||
|
||
case TASK_2_LED: // LED闪烁任务
|
||
task_state++;
|
||
|
||
led_blink_task();
|
||
oxg_sensor_task(); // 每隔100ms请求一次氧浓度数据
|
||
|
||
break;
|
||
|
||
case TASK_3_ALARM:
|
||
task_state++;
|
||
|
||
fault_process_task();
|
||
break;
|
||
|
||
case TASK_4_SCREEN:
|
||
task_state++;
|
||
|
||
ht16k33_refresh_task(); // 显示屏刷新任务
|
||
break;
|
||
|
||
case TASK_5_TIME:
|
||
task_state = TASK_1_ADC;
|
||
|
||
total_time_record_task(); // 累时任务存储任务
|
||
eeprom_ht24lc02_save_task(&global_queue); // 对分钟与小时进行保存
|
||
break;
|
||
|
||
default:
|
||
task_state = TASK_1_ADC;
|
||
break;
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/************************ (C) COPYRIGHT FMSH *****END OF FILE****/
|