/** ****************************************************************************** * @file main.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.12.18 - 新增:新建第一个版本的软件,待完善解析命令后的程序执行部分 ****************************************************************************** * @attention * *

© Copyright (c) 2025 Yuwell Software Danyang.Jiangsu.China. * All rights reserved.

* * 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 "main.h" #include "fm33_assert.h" #include "fm33lg0xx_fl_common.h" #include "fm33lg0xx_queue.h" #include "fm33lg0xx_event.h" #include "adc_sample.h" #include "bs83b12_capacitive_touch.h" #include "compressor_valve_switch.h" #include "nec_infrared.h" // 定义用于全局控制的消息队列与事件组 MessageQueue global_queue; OxygenEventGroup_t global_event; #define FREQ_CHECK_ENABLE (1) // 选择是否使能频率检查 仅在debug阶段使用 #define WATCHDOG_ENABLE (0) #if FREQ_CHECK_ENABLE uint32_t apb_clk[3]; #endif #if WATCHDOG_ENABLE // 看门狗初始化 static void watchdog_init(void) { FL_WWDT_InitTypeDef WWDT_InitStruct; FL_NVIC_ConfigTypeDef InterruptConfigStruct; WWDT_InitStruct.overflowPeriod = FL_WWDT_PERIOD_1024CNT; FL_WWDT_Init(WWDT, &WWDT_InitStruct); FL_WWDT_ClearFlag_NearOverflow(WWDT); FL_WWDT_EnableIT_NearOverflow(WWDT); InterruptConfigStruct.preemptPriority = 0x02; FL_NVIC_Init(&InterruptConfigStruct, WWDT_IRQn); } void WDT_IRQHandler(void) { if(FL_WWDT_IsActiveFlag_NearOverflow(WWDT)) { FL_WWDT_ClearFlag_NearOverflow(WWDT); FL_WWDT_ReloadCounter(WWDT); return; } } #endif int main(void) { FL_Init(); // 初始化Delay函数 MF_Clock_Init(); // 初始化时钟为RCHF SelXTHFToPLL(FL_CMU_PLL_PSC_DIV8, FL_MAIN_FREQ_Mhz - 1); // 设置芯片工作主频 vOxygenEventGroupInit(&global_event); // 初始化事件组 init_queue(&global_queue); // 初始化消息队列 MF_Config_Init(); // 初始化需要的外设 eeprom_ht24lc02_init(); // 初始化存储并向队列中插入当前累时数据 fault_array_init(); // 故障初始化 接收当前队列中的故障边界值 ht16k33_ui_init(&ui); // 初始化显示 接受当前队列中的累时数据 { ALARM_YELLOW_ON; ui.alarm_led_show = 1; ht16k33_refresh_task(); } adc_sample_init(); // 初始化ADC采样 compressor_valve_init(); oxg_sensor_init(); // 初始化氧传感器 nec_infrared_init(); bs83b12_capacitive_touch_init(); // 初始化定时器任务 #if FREQ_CHECK /* 系统始终频率检测 */ apb_clk[0] = FL_CMU_GetAPBClockFreq(); apb_clk[1] = FL_CMU_GetAHBClockFreq(); apb_clk[2] = FL_CMU_GetSystemClockFreq(); #endif #if WATCHDOG_ENABLE watchdog_init(); #endif while(1) { FL_DelayMs(100); FL_IWDT_ReloadCounter(IWDT); } }