待测试程序
This commit is contained in:
parent
0bcf9288c5
commit
44a6c38a30
237
Inc/coulombmeter.h
Normal file
237
Inc/coulombmeter.h
Normal file
@ -0,0 +1,237 @@
|
||||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file : coulombmeter.h
|
||||
* @brief : 电量计驱动程序
|
||||
* @version : 1.0
|
||||
* @changelog : version 1.0 初始版本 2025.12.31
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2025 Yuwell Software Danyang.Jiangsu.China
|
||||
* THIS SOFTWARE is licensed under the Mulan PSL v1.
|
||||
* can use this software according to the terms and conditions of the Mulan PSL v1.
|
||||
* You may obtain a copy of Mulan PSL v1 at:
|
||||
* http://license.coscl.org.cn/MulanPSL
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v1 for more details.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __COULOMBMETER_H
|
||||
#define __COULOMBMETER_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include "mf_config.h"
|
||||
#include "string.h"
|
||||
|
||||
|
||||
/************************** 硬件参数重映射 **************************/
|
||||
/* 对硬件使用进行配置 */
|
||||
#define COULOMBMETER_USED_UART_NUM UART5
|
||||
#define COULOMBMETER_UART_TX_GPIO_PORT GPIOC
|
||||
#define COULOMBMETER_UART_TX_GPIO_PIN FL_GPIO_PIN_5
|
||||
#define COULOMBMETER_UART_RX_GPIO_PORT GPIOC
|
||||
#define COULOMBMETER_UART_RX_GPIO_PIN FL_GPIO_PIN_4
|
||||
|
||||
|
||||
#define COULOMBMETER_IRQn UART5_IRQn
|
||||
|
||||
|
||||
// CPU阻塞式发送
|
||||
#define CHECK_TRANS_DONE while(FL_UART_IsActiveFlag_TXShiftBuffEmpty(COULOMBMETER_USED_UART_NUM) != FL_SET){};
|
||||
#define COULOMBMETER_UART_TRANS_BYTE(x) FL_UART_WriteTXBuff(COULOMBMETER_USED_UART_NUM, x);CHECK_TRANS_DONE;
|
||||
|
||||
|
||||
|
||||
/************************** 芯片内部寄存器地址定义 **************************/
|
||||
// 电参数寄存器(只读)
|
||||
#define Addr_I_WAVE 0x01 // 电流通道波形
|
||||
#define Addr_V_WAVE 0x02 // 电压通道波形
|
||||
#define Addr_I_RMS 0x03 // 电流有效值
|
||||
#define Addr_V_RMS 0x04 // 电压有效值
|
||||
#define Addr_I_FAST_RMS 0x05 // 电流快速有效值
|
||||
#define Addr_WATT 0x06 // 有功功率
|
||||
#define Addr_CF_CNT 0x07 // 有功电能脉冲计数
|
||||
#define Addr_FREQ 0x08 // 工频频率
|
||||
#define Addr_STATUS 0x09 // 状态
|
||||
#define Addr_VERSION 0x0F // 版本
|
||||
|
||||
// 用户操作寄存器(读写)
|
||||
#define Addr_I_CHOS 0x11 // 电流通道直流偏置校正
|
||||
#define Addr_I_RMSOS 0x12 // 电流通道有效值小信号校正
|
||||
#define Addr_WA_CREEP 0x14 // 有功功率防潜阈值
|
||||
#define Addr_FAST_RMS_TH 0x15 // 电流快速有效值阈值寄存器
|
||||
#define Addr_FAST_RMS_CYC 0x16 // 电流快速有效值刷新周期寄存器
|
||||
#define Addr_FREQ_CYC 0x17 // 线电压频率刷新周期寄存器
|
||||
#define Addr_MASK 0x18 // 输出配置寄存器
|
||||
#define Addr_MODE 0x19 // 用户模式选择寄存器
|
||||
#define Addr_GAIN_CR 0x1A // 电流通道增益控制寄存器
|
||||
#define Addr_SOFT_RESET 0x1C // 软复位
|
||||
#define Addr_WRPROT 0x1D // 用户写保护设置
|
||||
|
||||
|
||||
|
||||
//注意 BL0940的读命令字节固定为0x58+ICAddr,写命令字节固定为0xA8+ICAddr;SOP10封装芯片的IC_Addr地址固定为0
|
||||
// BL0942 TSSOP14封装带地址选择管脚,需根据A1~A2地址选择管脚的电平配置命令字节,可以进行多机并联通信
|
||||
// 8F-5AW 制氧机采用的是SOP-10封装芯片 地址为ICAddr = 0
|
||||
#define BL0942_ADDR_R 0x58
|
||||
#define BL0942_ADDR_W 0xA8
|
||||
|
||||
|
||||
|
||||
//出厂校准芯片,增益控制1%以内,外围器件精度控制1%以内,采用同一系数,不用 EEPROM保存参数
|
||||
// 功率转换系数=3537*1毫欧*0.51K*1000/(1.218*1.218)/(390K*5+0.51K)=623.39 ,整数运算考虑,放大10倍,*10=6234
|
||||
// 电流转换系数=305978*1毫欧/1.218=251213,整数运算考虑,防止运算溢出,缩小10倍,/10=25121
|
||||
// 电压转换系数=73989*0.51K*1000/1.218/(390K*5+0.51K)=15883
|
||||
// 电能系数=3600000*Power_K/1638.4/256=5350.6,对应于1度电的脉冲计数
|
||||
// 电流采用1毫欧电阻采样,电压采用390K*5+0.51K进行分压,实际测试发现电阻存在偏差,进行微调
|
||||
// BL0942评估版,立创直接贴片合金电阻(台湾厚声MS121WF100NT4E ),实际测量比1毫欧偏小,约0.93毫欧
|
||||
|
||||
#define Power_K 5798; //理论值*0.93
|
||||
#define Current_K 23362; //理论值*0.93
|
||||
#define Voltage_K 15883; //
|
||||
#define Energy_K 4976; //理论值*0.93
|
||||
|
||||
//采用美隆1毫欧贴片合金电阻,实际比1毫欧偏大,约1.023毫欧
|
||||
/*
|
||||
#define Power_K 6378; //理论值*1.023
|
||||
#define Current_K 25699; //理论值*1.023
|
||||
#define Voltage_K 15883; //
|
||||
#define Energy_K 5474; //理论值*1.023
|
||||
*/
|
||||
|
||||
|
||||
|
||||
typedef union
|
||||
{
|
||||
uint8_t uByte[4];
|
||||
uint16_t uInt[2];
|
||||
uint32_t uLongs;
|
||||
}FourBytes_Type;
|
||||
|
||||
typedef union
|
||||
{
|
||||
uint8_t uByte[2];
|
||||
uint16_t uInt;
|
||||
}TwoByte_Type;
|
||||
|
||||
//全电参数数据包格式
|
||||
typedef struct
|
||||
{
|
||||
uint8_t head;
|
||||
uint8_t I_RMS[3];
|
||||
uint8_t V_RMS[3];
|
||||
uint8_t I_FAST_RMS[3];
|
||||
uint8_t WATT[3];
|
||||
uint8_t CF_CNT[3];
|
||||
uint8_t FREQ[3];
|
||||
uint8_t STATUS[3];
|
||||
uint8_t CHKSUM;
|
||||
}AllFlame_StructDef;
|
||||
|
||||
|
||||
|
||||
typedef union
|
||||
{
|
||||
uint8_t B8[23];
|
||||
AllFlame_StructDef Flame;
|
||||
}AllFlame_TypeDef;
|
||||
|
||||
//BL0942/0940的电参数定义
|
||||
typedef struct
|
||||
{
|
||||
uint16_t Energy_kwh; // 实际用电量,千瓦小时 XXXXXX,1度电/LSB,最大65535度电
|
||||
uint32_t Fir_CF_CNT; // 上一次的CF_CNT寄存器读数
|
||||
uint32_t Mid_CF_CNT; // 小于1度电的脉冲底数
|
||||
uint16_t Power_Value; // unit: 0.1W XXXX.X,整型变量,最低位代表0.1W
|
||||
|
||||
uint16_t Current_Value; // unit: 0.001A XX.XXX,整型变量,最低位代表0.001A
|
||||
uint16_t Voltage_Value; // unit:0.01V XXX.XX,整型变量,最低位代表0.01V
|
||||
uint16_t Freq; // unit:0.01Hz XX.XX,整型变量,最低位代表0.01Hz
|
||||
uint16_t F_Current_Value;
|
||||
}Elect_StructDef;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
BUS_COM_STATE_IDLE,
|
||||
BUS_COM_STATE_WAITE_CURRENT,
|
||||
BUS_COM_STATE_WAITE_VOLTAGE,
|
||||
BUS_CHECK_ERROR,
|
||||
BUS_COM_STATE_WAITE_CHECK
|
||||
|
||||
}Bus_Com_State;
|
||||
|
||||
|
||||
|
||||
typedef union
|
||||
{
|
||||
uint32_t raw_long;
|
||||
uint8_t raw_b8[4];
|
||||
|
||||
}Raw_Data;
|
||||
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
||||
uint16_t bus_rms_current_mA; // 总线供电电路有效值 单位为mA
|
||||
uint16_t bus_rms_voltage_V; // 总线供电电压有效值 单位为V
|
||||
|
||||
uint32_t voltage_raw;
|
||||
uint32_t current_raw;
|
||||
|
||||
Bus_Com_State bus_com_stm;
|
||||
|
||||
uint8_t current_index;
|
||||
|
||||
}EleC_V_data;
|
||||
|
||||
extern EleC_V_data elec_v_data;
|
||||
|
||||
|
||||
|
||||
|
||||
extern Elect_StructDef BL0942_Elect;
|
||||
extern uint16_t u16_TmrCnt; //定时计数
|
||||
extern bool IsGetBL0942EData; //定时到1秒,与BL0942通信获取电参数;
|
||||
|
||||
extern bool flg_Comm; //读数据是否成功状态
|
||||
|
||||
void Delay_MS(uint16_t Count);
|
||||
void Uart_Init(void);
|
||||
void Delay_100uS(uint16_t Count);
|
||||
void BL0942_Uart_Init(void);
|
||||
bool BL0942_Uart1_R(uint8_t ICAddr,uint8_t cmd);
|
||||
void BL0942_Uart1_W(uint8_t ICAddr,uint8_t cmd);
|
||||
void BL0942_Uart_ReadEData(void);
|
||||
void BL0942_Uart_ConfigInit(void);
|
||||
bool BL0942_Uart1_ReadAll(uint8_t ICAddr);
|
||||
void BL0942_Uart_ReadEDataAll(void);
|
||||
|
||||
|
||||
|
||||
/************************** 外部API函数导出 **************************/
|
||||
void User_Coulombmeter_Init(void);
|
||||
void UART5_IRQHandler(void);
|
||||
|
||||
void User_Coulombmeter_Data_refresh(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __COULOMBMETER_H */
|
||||
|
||||
/************************ (C) COPYRIGHT Yuwell *****END OF FILE****/
|
||||
12499
MDK-ARM/JLinkLog.txt
12499
MDK-ARM/JLinkLog.txt
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@ -22,7 +22,7 @@
|
||||
</DaveTm>
|
||||
|
||||
<Target>
|
||||
<TargetName>8F-10W</TargetName>
|
||||
<TargetName>Coulombmeter</TargetName>
|
||||
<ToolsetNumber>0x4</ToolsetNumber>
|
||||
<ToolsetName>ARM-ADS</ToolsetName>
|
||||
<TargetOption>
|
||||
@ -117,6 +117,20 @@
|
||||
<pMon>Segger\JL2CM3.dll</pMon>
|
||||
</DebugOpt>
|
||||
<TargetDriverDllRegistry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>DLGUARM</Key>
|
||||
</SetRegEntry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>JL2CM3</Key>
|
||||
<Name>-U601012352 -O111 -S2 -ZTIFSpeedSel5000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(0BB11477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8013 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO15 -FD20000000 -FC1000 -FN1 -FF0FM33LG02X_FLASH128.FLM -FS00 -FL020000 -FP0($$Device:FM33LG02X$Flash\FM33LG02X_FLASH128.FLM)</Name>
|
||||
</SetRegEntry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>UL2CM3</Key>
|
||||
<Name>UL2CM3(-S0 -C0 -P0 ) -FN1 -FC1000 -FD20000000 -FF0FM33LG02X_FLASH128 -FL020000 -FS00 -FP0($$Device:FM33LG02X$Flash\FM33LG02X_FLASH128.FLM)</Name>
|
||||
</SetRegEntry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>ARMRTXEVENTFLAGS</Key>
|
||||
@ -132,73 +146,13 @@
|
||||
<Key>ARMDBGFLAGS</Key>
|
||||
<Name></Name>
|
||||
</SetRegEntry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>JL2CM3</Key>
|
||||
<Name>-U601012352 -O111 -S2 -ZTIFSpeedSel5000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST3 -N00("ARM CoreSight SW-DP") -D00(0BB11477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8013 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO15 -FD20000000 -FC1000 -FN1 -FF0FM33LG04X_FLASH256.FLM -FS00 -FL040000 -FP0($$Device:FM33LG04X$Flash\FM33LG04X_FLASH256.FLM)</Name>
|
||||
</SetRegEntry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>UL2CM3</Key>
|
||||
<Name>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0FM33LG04X_FLASH256 -FS00 -FL040000 -FP0($$Device:FM33LG04X$Flash\FM33LG04X_FLASH256.FLM))</Name>
|
||||
</SetRegEntry>
|
||||
</TargetDriverDllRegistry>
|
||||
<Breakpoint/>
|
||||
<WatchWindow1>
|
||||
<Ww>
|
||||
<count>0</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>ui,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>1</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>EEcount</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>2</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>o2_sensor_data</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>3</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>global_queue,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>4</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>fault_info</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>5</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>global_event</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>6</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>apb_clk,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>7</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>infrared_info,0x10</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>8</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>blue_blink_count,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>9</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>panel_display_info</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>10</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>global_queue,0x0A</ItemText>
|
||||
<ItemText>elec_v_data,0x0A</ItemText>
|
||||
</Ww>
|
||||
</WatchWindow1>
|
||||
<WatchWindow2>
|
||||
@ -214,7 +168,7 @@
|
||||
<DebugFlag>
|
||||
<trace>0</trace>
|
||||
<periodic>1</periodic>
|
||||
<aLwin>1</aLwin>
|
||||
<aLwin>0</aLwin>
|
||||
<aCover>0</aCover>
|
||||
<aSer1>0</aSer1>
|
||||
<aSer2>0</aSer2>
|
||||
@ -255,6 +209,10 @@
|
||||
<Name>System Viewer\LPTIM32</Name>
|
||||
<WinId>35905</WinId>
|
||||
</Entry>
|
||||
<Entry>
|
||||
<Name>System Viewer\UART5</Name>
|
||||
<WinId>35904</WinId>
|
||||
</Entry>
|
||||
</SystemViewers>
|
||||
<DebugDescription>
|
||||
<Enable>1</Enable>
|
||||
@ -355,116 +313,8 @@
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\Src\fault_probe.c</PathWithFileName>
|
||||
<FilenameWithoutPath>fault_probe.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>7</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\Src\ht16k33_led_i2c.c</PathWithFileName>
|
||||
<FilenameWithoutPath>ht16k33_led_i2c.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>8</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\Src\ht16k33_dot_matrix.c</PathWithFileName>
|
||||
<FilenameWithoutPath>ht16k33_dot_matrix.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>9</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\Src\nec_infrared.c</PathWithFileName>
|
||||
<FilenameWithoutPath>nec_infrared.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>10</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\Src\ht24lc02_eeprom.c</PathWithFileName>
|
||||
<FilenameWithoutPath>ht24lc02_eeprom.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>11</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\Src\o2_sensor.c</PathWithFileName>
|
||||
<FilenameWithoutPath>o2_sensor.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>12</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\Src\adc_sample.c</PathWithFileName>
|
||||
<FilenameWithoutPath>adc_sample.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>13</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\Src\fm33lg0xx_queue.c</PathWithFileName>
|
||||
<FilenameWithoutPath>fm33lg0xx_queue.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>14</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\Src\bs83b12_capacitive_touch.c</PathWithFileName>
|
||||
<FilenameWithoutPath>bs83b12_capacitive_touch.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>15</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\Src\compressor_valve_switch.c</PathWithFileName>
|
||||
<FilenameWithoutPath>compressor_valve_switch.c</FilenameWithoutPath>
|
||||
<PathWithFileName>..\Src\coulombmeter.c</PathWithFileName>
|
||||
<FilenameWithoutPath>coulombmeter.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
@ -478,7 +328,7 @@
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>4</GroupNumber>
|
||||
<FileNumber>16</FileNumber>
|
||||
<FileNumber>7</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -498,7 +348,7 @@
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>17</FileNumber>
|
||||
<FileNumber>8</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -510,7 +360,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>18</FileNumber>
|
||||
<FileNumber>9</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -522,7 +372,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>19</FileNumber>
|
||||
<FileNumber>10</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -534,7 +384,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>20</FileNumber>
|
||||
<FileNumber>11</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -546,7 +396,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>21</FileNumber>
|
||||
<FileNumber>12</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -558,7 +408,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>22</FileNumber>
|
||||
<FileNumber>13</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -570,7 +420,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>23</FileNumber>
|
||||
<FileNumber>14</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -582,7 +432,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>24</FileNumber>
|
||||
<FileNumber>15</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -594,7 +444,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>25</FileNumber>
|
||||
<FileNumber>16</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -606,7 +456,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>26</FileNumber>
|
||||
<FileNumber>17</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -618,7 +468,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>27</FileNumber>
|
||||
<FileNumber>18</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -630,7 +480,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>28</FileNumber>
|
||||
<FileNumber>19</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -642,7 +492,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>29</FileNumber>
|
||||
<FileNumber>20</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -654,7 +504,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>30</FileNumber>
|
||||
<FileNumber>21</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -666,7 +516,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>31</FileNumber>
|
||||
<FileNumber>22</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -678,7 +528,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>32</FileNumber>
|
||||
<FileNumber>23</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -690,7 +540,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>33</FileNumber>
|
||||
<FileNumber>24</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -702,7 +552,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>34</FileNumber>
|
||||
<FileNumber>25</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -714,7 +564,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>35</FileNumber>
|
||||
<FileNumber>26</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -726,7 +576,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>36</FileNumber>
|
||||
<FileNumber>27</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -738,7 +588,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>37</FileNumber>
|
||||
<FileNumber>28</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -750,7 +600,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>38</FileNumber>
|
||||
<FileNumber>29</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -762,7 +612,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>39</FileNumber>
|
||||
<FileNumber>30</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -774,7 +624,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>40</FileNumber>
|
||||
<FileNumber>31</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -786,7 +636,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>41</FileNumber>
|
||||
<FileNumber>32</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -798,7 +648,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>42</FileNumber>
|
||||
<FileNumber>33</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -810,7 +660,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>43</FileNumber>
|
||||
<FileNumber>34</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -822,7 +672,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>44</FileNumber>
|
||||
<FileNumber>35</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -834,7 +684,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>45</FileNumber>
|
||||
<FileNumber>36</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -846,7 +696,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>46</FileNumber>
|
||||
<FileNumber>37</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -858,7 +708,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>47</FileNumber>
|
||||
<FileNumber>38</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -870,7 +720,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>48</FileNumber>
|
||||
<FileNumber>39</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -882,7 +732,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>49</FileNumber>
|
||||
<FileNumber>40</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -894,7 +744,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>50</FileNumber>
|
||||
<FileNumber>41</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -906,7 +756,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>51</FileNumber>
|
||||
<FileNumber>42</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -918,7 +768,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>52</FileNumber>
|
||||
<FileNumber>43</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
||||
@ -7,23 +7,23 @@
|
||||
|
||||
<Targets>
|
||||
<Target>
|
||||
<TargetName>8F-10W</TargetName>
|
||||
<TargetName>Coulombmeter</TargetName>
|
||||
<ToolsetNumber>0x4</ToolsetNumber>
|
||||
<ToolsetName>ARM-ADS</ToolsetName>
|
||||
<pCCUsed>5060960::V5.06 update 7 (build 960)::.\ARM_Compiler_5.06u7</pCCUsed>
|
||||
<uAC6>0</uAC6>
|
||||
<TargetOption>
|
||||
<TargetCommonOption>
|
||||
<Device>FM33LG04X</Device>
|
||||
<Device>FM33LG02X</Device>
|
||||
<Vendor>FMSH</Vendor>
|
||||
<PackID>FMSH.FM33LG0XX_DFP.3.0.1</PackID>
|
||||
<PackURL>https://fmdevelopers.oss-cn-shanghai.aliyuncs.com/</PackURL>
|
||||
<Cpu>IRAM(0x20000000,0x8000) IROM(0x00000000,0x40000) CPUTYPE("Cortex-M0") CLOCK(12000000) ELITTLE</Cpu>
|
||||
<Cpu>IRAM(0x20000000,0x8000) IROM(0x00000000,0x20000) CPUTYPE("Cortex-M0") CLOCK(12000000) ELITTLE</Cpu>
|
||||
<FlashUtilSpec></FlashUtilSpec>
|
||||
<StartupFile></StartupFile>
|
||||
<FlashDriverDll>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0FM33LG04X_FLASH256 -FS00 -FL040000 -FP0($$Device:FM33LG04X$Flash\FM33LG04X_FLASH256.FLM))</FlashDriverDll>
|
||||
<FlashDriverDll>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0FM33LG02X_FLASH128 -FS00 -FL020000 -FP0($$Device:FM33LG02X$Flash\FM33LG02X_FLASH128.FLM))</FlashDriverDll>
|
||||
<DeviceId>0</DeviceId>
|
||||
<RegisterFile>$$Device:FM33LG04X$Device\Include\fm33lg0xx.h</RegisterFile>
|
||||
<RegisterFile>$$Device:FM33LG02X$Device\Include\fm33lg0xx.h</RegisterFile>
|
||||
<MemoryEnv></MemoryEnv>
|
||||
<Cmp></Cmp>
|
||||
<Asm></Asm>
|
||||
@ -33,7 +33,7 @@
|
||||
<SLE66CMisc></SLE66CMisc>
|
||||
<SLE66AMisc></SLE66AMisc>
|
||||
<SLE66LinkerMisc></SLE66LinkerMisc>
|
||||
<SFDFile>$$Device:FM33LG04X$SVD\FM33LG0XX.SVD</SFDFile>
|
||||
<SFDFile>$$Device:FM33LG02X$SVD\FM33LG0XX.SVD</SFDFile>
|
||||
<bCustSvd>0</bCustSvd>
|
||||
<UseEnv>0</UseEnv>
|
||||
<BinPath></BinPath>
|
||||
@ -82,7 +82,7 @@
|
||||
<AfterMake>
|
||||
<RunUserProg1>1</RunUserProg1>
|
||||
<RunUserProg2>0</RunUserProg2>
|
||||
<UserProg1Name>fromelf --bin --output=./objects/8F-10W.bin ./objects/LG048-8F-10W.axf</UserProg1Name>
|
||||
<UserProg1Name>fromelf --bin --output=./objects/LG048-8F-10W.bin ./objects/LG048-8F-10W.axf</UserProg1Name>
|
||||
<UserProg2Name></UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||
@ -138,7 +138,7 @@
|
||||
</Flash1>
|
||||
<bUseTDR>1</bUseTDR>
|
||||
<Flash2>BIN\UL2CM3.DLL</Flash2>
|
||||
<Flash3>"" ()</Flash3>
|
||||
<Flash3></Flash3>
|
||||
<Flash4></Flash4>
|
||||
<pFcarmOut></pFcarmOut>
|
||||
<pFcarmGrp></pFcarmGrp>
|
||||
@ -252,7 +252,7 @@
|
||||
<IROM>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x40000</Size>
|
||||
<Size>0x20000</Size>
|
||||
</IROM>
|
||||
<XRAM>
|
||||
<Type>0</Type>
|
||||
@ -277,7 +277,7 @@
|
||||
<OCR_RVCT4>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x40000</Size>
|
||||
<Size>0x20000</Size>
|
||||
</OCR_RVCT4>
|
||||
<OCR_RVCT5>
|
||||
<Type>1</Type>
|
||||
@ -420,54 +420,9 @@
|
||||
<FilePath>..\Src\fm33lg0xx_fl_common.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>fault_probe.c</FileName>
|
||||
<FileName>coulombmeter.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\Src\fault_probe.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>ht16k33_led_i2c.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\Src\ht16k33_led_i2c.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>ht16k33_dot_matrix.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\Src\ht16k33_dot_matrix.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>nec_infrared.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\Src\nec_infrared.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>ht24lc02_eeprom.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\Src\ht24lc02_eeprom.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>o2_sensor.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\Src\o2_sensor.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>adc_sample.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\Src\adc_sample.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>fm33lg0xx_queue.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\Src\fm33lg0xx_queue.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>bs83b12_capacitive_touch.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\Src\bs83b12_capacitive_touch.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>compressor_valve_switch.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\Src\compressor_valve_switch.c</FilePath>
|
||||
<FilePath>..\Src\coulombmeter.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
|
||||
247
Src/coulombmeter.c
Normal file
247
Src/coulombmeter.c
Normal file
@ -0,0 +1,247 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file coulombmeter.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.31
|
||||
******************************************************************************
|
||||
* @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 "coulombmeter.h"
|
||||
|
||||
|
||||
// 提供给外部的采样结果数据
|
||||
EleC_V_data elec_v_data;
|
||||
|
||||
|
||||
// 向对应寄存器写入数据 低位在低位 高位在高位
|
||||
// 共24bit,不足处用0补齐,低位先行
|
||||
// 发送数据大小限定为3个字节
|
||||
static void coulombmeter_write_reg(uint8_t addr, uint8_t* reg_data)
|
||||
{
|
||||
uint8_t check_sum = 0;
|
||||
|
||||
// 1. 下发命令字节 BL0942_ADDR_W
|
||||
COULOMBMETER_UART_TRANS_BYTE(BL0942_ADDR_W);
|
||||
|
||||
// 2. 下发需要写寄存器的地址
|
||||
COULOMBMETER_UART_TRANS_BYTE(addr);
|
||||
|
||||
// 3. 发送需要往寄存器地址写入的数据
|
||||
COULOMBMETER_UART_TRANS_BYTE(reg_data[0]);
|
||||
COULOMBMETER_UART_TRANS_BYTE(reg_data[1]);
|
||||
COULOMBMETER_UART_TRANS_BYTE(reg_data[2]);
|
||||
|
||||
// 4. 发送校验和
|
||||
check_sum = (BL0942_ADDR_W + addr + reg_data[0] + reg_data[1] + reg_data[2]);
|
||||
check_sum = ~(check_sum & 0xFF);
|
||||
COULOMBMETER_UART_TRANS_BYTE(check_sum);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 从特定寄存器读取数据 芯片将通过串口接收中断返回
|
||||
// 芯片收到消息后将在150us内返回数据
|
||||
// 1s执行一次 数据在接收中断中处理
|
||||
static void coulombmeter_read_reg(uint8_t addr)
|
||||
{
|
||||
// 1. 下发命令字节 BL0942_ADDR_R
|
||||
COULOMBMETER_UART_TRANS_BYTE(BL0942_ADDR_R);
|
||||
|
||||
// 2. 下发地址数据
|
||||
COULOMBMETER_UART_TRANS_BYTE(addr);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
|
||||
uint8_t data[32];
|
||||
void User_Coulombmeter_Init(void)
|
||||
{
|
||||
|
||||
FL_GPIO_InitTypeDef GPIO_InitStruct;
|
||||
|
||||
// 初始化GPIO
|
||||
GPIO_InitStruct.pin = COULOMBMETER_UART_RX_GPIO_PIN;
|
||||
GPIO_InitStruct.mode = FL_GPIO_MODE_DIGITAL;
|
||||
GPIO_InitStruct.outputType = FL_GPIO_OUTPUT_PUSHPULL;
|
||||
GPIO_InitStruct.pull = FL_DISABLE;
|
||||
GPIO_InitStruct.remapPin = FL_DISABLE;
|
||||
GPIO_InitStruct.analogSwitch = FL_DISABLE;
|
||||
|
||||
FL_GPIO_Init(COULOMBMETER_UART_RX_GPIO_PORT, &GPIO_InitStruct);
|
||||
|
||||
GPIO_InitStruct.pin = COULOMBMETER_UART_TX_GPIO_PIN;
|
||||
FL_GPIO_Init(COULOMBMETER_UART_TX_GPIO_PORT, &GPIO_InitStruct);
|
||||
|
||||
// 初始化串口参数
|
||||
FL_UART_InitTypeDef UART_InitStruct = {0};
|
||||
UART_InitStruct.baudRate = 9600; //波特率
|
||||
UART_InitStruct.dataWidth = FL_UART_DATA_WIDTH_8B; //数据位数
|
||||
UART_InitStruct.stopBits = FL_UART_STOP_BIT_WIDTH_1B; //停止位
|
||||
UART_InitStruct.parity = FL_UART_PARITY_NONE; //奇偶校验
|
||||
UART_InitStruct.transferDirection = FL_UART_DIRECTION_TX_RX; //接收-发送使能
|
||||
FL_UART_Init(COULOMBMETER_USED_UART_NUM, &UART_InitStruct);
|
||||
|
||||
NVIC_DisableIRQ(COULOMBMETER_IRQn);
|
||||
NVIC_SetPriority(COULOMBMETER_IRQn,2); //中断优先级配置
|
||||
NVIC_EnableIRQ(COULOMBMETER_IRQn);
|
||||
|
||||
// 开启接收中断
|
||||
FL_UART_ClearFlag_RXBuffFull(COULOMBMETER_USED_UART_NUM);
|
||||
FL_UART_EnableIT_RXBuffFull(COULOMBMETER_USED_UART_NUM);
|
||||
|
||||
// 开启发送完毕中断(由于需要发送的字节较少 此处不使用)
|
||||
// FL_UART_ClearFlag_TXShiftBuffEmpty(COULOMBMETER_USED_UART_NUM);
|
||||
// FL_UART_EnableIT_TXShiftBuffEmpty(COULOMBMETER_USED_UART_NUM);
|
||||
|
||||
|
||||
// 清空结果
|
||||
memset(&elec_v_data, 0, sizeof(elec_v_data));
|
||||
memset(data, 0, sizeof(data));
|
||||
|
||||
}
|
||||
//
|
||||
|
||||
|
||||
// 推荐1s刷新一次 最终数据将存储在全局变量elec_v_data中
|
||||
void User_Coulombmeter_Data_refresh(void)
|
||||
{
|
||||
static uint8_t mod = 0;
|
||||
|
||||
if(mod == 0)
|
||||
{
|
||||
mod = 1;
|
||||
|
||||
coulombmeter_read_reg(Addr_V_RMS);
|
||||
|
||||
elec_v_data.bus_com_stm = BUS_COM_STATE_WAITE_VOLTAGE; // 转入等待电压数据状态
|
||||
elec_v_data.current_index = 0;
|
||||
elec_v_data.voltage_raw = 0;
|
||||
}else{
|
||||
|
||||
mod = 0;
|
||||
coulombmeter_read_reg(Addr_I_RMS);
|
||||
|
||||
elec_v_data.bus_com_stm = BUS_COM_STATE_WAITE_CURRENT; // 转入等待电压数据状态
|
||||
elec_v_data.current_index = 0;
|
||||
elec_v_data.current_raw = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
uint8_t i = 0;
|
||||
|
||||
void UART5_IRQHandler(void)
|
||||
{
|
||||
|
||||
// 接收中断处理
|
||||
if(FL_UART_IsEnabledIT_RXBuffFull(COULOMBMETER_USED_UART_NUM) &&
|
||||
FL_UART_IsActiveFlag_RXBuffFull(COULOMBMETER_USED_UART_NUM))
|
||||
{
|
||||
|
||||
if(elec_v_data.bus_com_stm == BUS_COM_STATE_WAITE_VOLTAGE)
|
||||
{
|
||||
|
||||
//接收中断标志可通过读取rxreg寄存器清除
|
||||
uint8_t tmp_data = 0;
|
||||
tmp_data = FL_UART_ReadRXBuff(COULOMBMETER_USED_UART_NUM);
|
||||
|
||||
elec_v_data.voltage_raw |= (tmp_data<<(elec_v_data.current_index*8));
|
||||
|
||||
elec_v_data.current_index++;
|
||||
if(elec_v_data.current_index == 3)
|
||||
{
|
||||
elec_v_data.bus_com_stm = BUS_COM_STATE_IDLE;
|
||||
|
||||
elec_v_data.bus_rms_voltage_V =elec_v_data.voltage_raw / Voltage_K;
|
||||
|
||||
elec_v_data.voltage_raw = 0;
|
||||
|
||||
elec_v_data.current_index = 0;
|
||||
}
|
||||
|
||||
}else if(elec_v_data.bus_com_stm == BUS_COM_STATE_WAITE_CURRENT)
|
||||
{
|
||||
uint8_t tmp_data = 0;
|
||||
tmp_data = FL_UART_ReadRXBuff(COULOMBMETER_USED_UART_NUM);
|
||||
|
||||
elec_v_data.current_raw |= (tmp_data<<(elec_v_data.current_index*8));
|
||||
|
||||
elec_v_data.current_index++;
|
||||
if(elec_v_data.current_index == 3)
|
||||
{
|
||||
elec_v_data.bus_com_stm = BUS_COM_STATE_IDLE;
|
||||
|
||||
elec_v_data.bus_rms_current_mA =elec_v_data.current_raw / Current_K;
|
||||
|
||||
// elec_v_data.current_raw = 0;
|
||||
|
||||
elec_v_data.current_index = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 发送中断处理
|
||||
if(FL_UART_IsEnabledIT_TXShiftBuffEmpty(COULOMBMETER_USED_UART_NUM) &&
|
||||
FL_UART_IsActiveFlag_TXShiftBuffEmpty(COULOMBMETER_USED_UART_NUM))
|
||||
{
|
||||
|
||||
|
||||
FL_UART_ClearFlag_TXShiftBuffEmpty(COULOMBMETER_USED_UART_NUM); //清除发送中断标志
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/************************ (C) COPYRIGHT YUWELL *****END OF FILE****/
|
||||
@ -52,170 +52,6 @@
|
||||
|
||||
|
||||
|
||||
void total_time_record_task(void)
|
||||
{
|
||||
static uint16_t ms_count = 0;
|
||||
|
||||
// 记录本次开机累计运行的时间
|
||||
static uint32_t current_seconds = 0;
|
||||
static uint32_t current_minutes = 0;
|
||||
static uint32_t current_hours = 0;
|
||||
|
||||
MsgQueueItem queue_item_time_send;
|
||||
MsgQueueItem qitem_current_time_modify;
|
||||
MsgQueueItem filter_item;
|
||||
|
||||
if(ms_count < 10) // 在后台悄摸刷新累时 1秒钟刷新一次全局变量
|
||||
{
|
||||
ms_count++;
|
||||
}else{
|
||||
|
||||
ms_count = 0;
|
||||
if(ui.disp_info.work_seconds < 59)
|
||||
{
|
||||
ui.disp_info.work_seconds++;
|
||||
}else{
|
||||
ui.disp_info.work_seconds = 0;
|
||||
|
||||
if(ui.disp_info.work_minutes < 59)
|
||||
{
|
||||
|
||||
ui.disp_info.work_minutes++;
|
||||
queue_item_time_send.type = MSG_TYPE_MINUTE_SAVE;
|
||||
queue_item_time_send.data.hour_meter.minute = ui.disp_info.work_minutes;
|
||||
insert_queue_node_in_head(&global_queue, queue_item_time_send); // 向队列中插入一个分钟数存储消息
|
||||
|
||||
}else{
|
||||
|
||||
ui.disp_info.work_minutes = 1;
|
||||
queue_item_time_send.type = MSG_TYPE_MINUTE_SAVE;
|
||||
queue_item_time_send.data.hour_meter.minute = ui.disp_info.work_minutes;
|
||||
insert_queue_node_in_head(&global_queue, queue_item_time_send); // 向队列中插入一个分钟数存储消息
|
||||
|
||||
ui.disp_info.work_hours++;
|
||||
queue_item_time_send.type = MSG_TYPE_HOUR_SAVE;
|
||||
queue_item_time_send.data.hour_meter.hour = ui.disp_info.work_hours;
|
||||
insert_queue_node_in_head(&global_queue, queue_item_time_send); // 向队列中插入一个小时数存储消息
|
||||
|
||||
|
||||
peek_queue_node_by_type(&global_queue, MSG_TYPE_FILTER_SERVER, &filter_item);
|
||||
|
||||
// 1800小时换一次滤盒、100小时清洁一次滤清器 出现标志后重新开机可取消显示等待下个周期重新显示
|
||||
if(ui.disp_info.work_hours%100 == 0) // 到达第100小时
|
||||
{
|
||||
|
||||
if(ui.disp_info.work_hours%1800 == 0)
|
||||
{
|
||||
|
||||
if((ui.disp_info.work_hours > filter_item.data.filter_server.last_replace_filter_hours)&&
|
||||
!xOxygenEventGroupCheckBit(&global_event, EVENT_REPLACE_FILTER_NOTIFY))
|
||||
{
|
||||
|
||||
vOxygenEventGroupSetBits(&global_event, EVENT_CLEAN_FILTER_NOTIFY);
|
||||
vOxygenEventGroupSetBits(&global_event, EVENT_REPLACE_FILTER_NOTIFY);
|
||||
|
||||
// 向EEPROM中写入当前清理滤清器的时间
|
||||
filter_item.data.filter_server.last_clean_filter_hours = ui.disp_info.work_hours;
|
||||
filter_item.data.filter_server.last_replace_filter_hours = ui.disp_info.work_hours;
|
||||
filter_item.data.filter_server.clean_filter_time_need_stored = true;
|
||||
filter_item.data.filter_server.replace_filter_time_need_stored = true;
|
||||
|
||||
modify_or_add_queue_node_by_type(&global_queue, MSG_TYPE_FILTER_TIME_SAVE, filter_item);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}else{
|
||||
|
||||
if((ui.disp_info.work_hours > filter_item.data.filter_server.last_clean_filter_hours)&&
|
||||
!xOxygenEventGroupCheckBit(&global_event, EVENT_CLEAN_FILTER_NOTIFY))
|
||||
{
|
||||
|
||||
vOxygenEventGroupSetBits(&global_event, EVENT_CLEAN_FILTER_NOTIFY);
|
||||
|
||||
// 向EEPROM中写入当前清理滤清器的时间
|
||||
filter_item.data.filter_server.last_clean_filter_hours = ui.disp_info.work_hours;
|
||||
filter_item.data.filter_server.clean_filter_time_need_stored = true;
|
||||
filter_item.data.filter_server.replace_filter_time_need_stored = false;
|
||||
|
||||
modify_or_add_queue_node_by_type(&global_queue, MSG_TYPE_FILTER_TIME_SAVE, filter_item);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 本次开机时间累加
|
||||
if(current_seconds < 60)
|
||||
{
|
||||
current_seconds++; // 累加一秒钟
|
||||
qitem_current_time_modify.type = MSG_TYPE_CURRENT_TIME;
|
||||
|
||||
qitem_current_time_modify.data.hour_meter.second = current_seconds;
|
||||
qitem_current_time_modify.data.hour_meter.minute = current_minutes;
|
||||
qitem_current_time_modify.data.hour_meter.hour = current_hours;
|
||||
|
||||
modify_or_add_queue_node_by_type(&global_queue, MSG_TYPE_CURRENT_TIME, qitem_current_time_modify);
|
||||
|
||||
}else{
|
||||
|
||||
current_seconds = 0; // 满一分钟 清零
|
||||
|
||||
if(current_minutes < 60)
|
||||
{
|
||||
current_minutes++;
|
||||
}else{
|
||||
|
||||
current_minutes = 1;
|
||||
|
||||
if(current_hours < 4000000000) // 单次运行最大记录四十亿小时
|
||||
{
|
||||
current_hours++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void led_blink_task(void)
|
||||
{
|
||||
|
||||
static uint16_t state_led_blink_count = 0;
|
||||
|
||||
const uint16_t BLINK_FREQ_HZ = 2; // 定义闪烁频率为1s一次 可选频率为1Hz 2Hz 5Hz 10Hz
|
||||
|
||||
MsgQueueItem stm_item;
|
||||
|
||||
peek_queue_node_by_type(&global_queue, MSG_TYPE_OXG_STM, &stm_item); // 取出当前节点关于系统状态的记录
|
||||
|
||||
if(stm_item.data.state_machine.oxg_stm == STM_INIT) // 根据状态机确定LED显示状态
|
||||
{
|
||||
STATE_LED_ON;
|
||||
return;
|
||||
}
|
||||
|
||||
if(state_led_blink_count == 10/BLINK_FREQ_HZ)
|
||||
{
|
||||
STATE_LED_TOGGLE;
|
||||
|
||||
|
||||
state_led_blink_count = 1;
|
||||
}else{
|
||||
|
||||
state_led_blink_count++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -54,156 +54,6 @@
|
||||
|
||||
|
||||
|
||||
|
||||
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****/
|
||||
|
||||
100
Src/main.c
100
Src/main.c
@ -50,20 +50,8 @@
|
||||
|
||||
#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;
|
||||
|
||||
#include "coulombmeter.h"
|
||||
|
||||
|
||||
#define FREQ_CHECK_ENABLE (1) // 选择是否使能频率检查 仅在debug阶段使用
|
||||
@ -74,37 +62,6 @@ 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
|
||||
|
||||
|
||||
|
||||
@ -115,31 +72,21 @@ int main(void)
|
||||
MF_Clock_Init(); // 初始化时钟为RCHF
|
||||
SelXTHFToPLL(FL_CMU_PLL_PSC_DIV8, FL_MAIN_FREQ_Mhz - 1); // 设置芯片工作主频
|
||||
|
||||
vOxygenEventGroupInit(&global_event); // 初始化事件组
|
||||
init_queue(&global_queue); // 初始化消息队列
|
||||
|
||||
|
||||
FL_GPIO_InitTypeDef GPIO_InitStruct;
|
||||
|
||||
// 初始化GPIO
|
||||
GPIO_InitStruct.pin = FL_GPIO_PIN_5;
|
||||
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(GPIOD, &GPIO_InitStruct);
|
||||
|
||||
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();
|
||||
|
||||
|
||||
// FL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||
// 初始化定时器任务
|
||||
#if FREQ_CHECK
|
||||
/* 系统始终频率检测 */
|
||||
@ -149,16 +96,17 @@ int main(void)
|
||||
#endif
|
||||
|
||||
|
||||
#if WATCHDOG_ENABLE
|
||||
watchdog_init();
|
||||
#endif
|
||||
User_Coulombmeter_Init(); // 初始化电量计芯片
|
||||
|
||||
while(1)
|
||||
{
|
||||
FL_DelayMs(100);
|
||||
|
||||
FL_IWDT_ReloadCounter(IWDT);
|
||||
}
|
||||
while(1)
|
||||
{
|
||||
FL_DelayMs(1000);
|
||||
|
||||
User_Coulombmeter_Data_refresh();
|
||||
FL_GPIO_ToggleOutputPin(GPIOD, FL_GPIO_PIN_5);
|
||||
|
||||
// FL_GPIO_ToggleOutputPin(GPIOC, FL_GPIO_PIN_5);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user