284 lines
7.8 KiB
C
284 lines
7.8 KiB
C
|
#ifndef __PUBLIC_H
|
|||
|
#define __PUBLIC_H
|
|||
|
#include "mm32_device.h"
|
|||
|
#include <stdio.h>
|
|||
|
|
|||
|
#define SW16(X) ( (( (u16)(X) & 0xFF00) >> 8) |\
|
|||
|
(( (u16)(X) & 0x00FF) << 8) )
|
|||
|
|
|||
|
#define WARNING_TEMP 490
|
|||
|
#define ORDER_TIME 25
|
|||
|
#define PROTECT_TEMP 150
|
|||
|
#define AD_0_15_USE 0
|
|||
|
#define USE_2_High 1
|
|||
|
#define FULL_V 4.0
|
|||
|
|
|||
|
typedef struct _time
|
|||
|
{
|
|||
|
u16 _work_time; // ms
|
|||
|
u32 _hot_work_time; // 加热工作时间
|
|||
|
u32 _beep_run_time; // 蜂鸣器工作时间
|
|||
|
u32 _Sleep_time; // 工作时间
|
|||
|
u32 _key_down_time; // 按键按下时间
|
|||
|
u32 _Uart_match_time; // 串口通信刷新时间
|
|||
|
u32 _Last_time;
|
|||
|
u32 _full_stop_led_time; // 满电结束充电时间
|
|||
|
u32 _Standby_time; // 检测充电芯片IO口输出高电平时间
|
|||
|
u32 _Charge_start_time; // 开始充电计时
|
|||
|
u32 _Pwm_time; // pwm 刷新时间
|
|||
|
u32 _uart_receive_time; // 串口接收时间
|
|||
|
u32 _check_temp_time; // 检测温度时间
|
|||
|
u32 _get_v_time; //电池检测电压
|
|||
|
}Time;
|
|||
|
typedef struct _Set_Order_hot
|
|||
|
{
|
|||
|
u16 _head;
|
|||
|
u16 _hot_up_num; // 上段 加热段数
|
|||
|
u16 _hot_down_num; // 下段 加热段数
|
|||
|
u16 _hot_up_time; // 上段加热时间
|
|||
|
u16 _hot_down_time; // 下段段加热时间
|
|||
|
u16 _hot_up_Value[29];
|
|||
|
u16 _hot_down_Value[29];
|
|||
|
u16 _add;
|
|||
|
}Set_order_hot;
|
|||
|
typedef struct _Set
|
|||
|
{
|
|||
|
u16 _head;
|
|||
|
u16 _one_High_temp; // 最高温度
|
|||
|
u16 _one_keep_temp; // 保温温度
|
|||
|
u16 _one_low_temp; // 低温温度
|
|||
|
u16 _one_High_time; // 高温时间
|
|||
|
u16 _one_Keep_time; // 保温时间
|
|||
|
u16 _two_up_temp; // 升温速率
|
|||
|
u16 _two_keep_temp; // 保温温度
|
|||
|
u16 _two_keep_time; // 保温时间
|
|||
|
|
|||
|
u16 _Hight_adjust; // 第一段高温场
|
|||
|
u16 _Keep_adjust; // 第一段保温场
|
|||
|
u16 _Two_keep_adjust; // 第二段保温场
|
|||
|
u16 _up_R; // 25℃ 上段标定R
|
|||
|
u16 _down_R; // 25℃ 下段标定R
|
|||
|
|
|||
|
u16 _K_18_Value; // k值 180摄氏度
|
|||
|
u16 _K_18_Value_1; // k值 180摄氏度
|
|||
|
|
|||
|
u16 _K_24_Value; // k值 180摄氏度
|
|||
|
u16 _K_24_Value_1; // k值 180摄氏度
|
|||
|
|
|||
|
//u16 _K_Value;
|
|||
|
u16 add;
|
|||
|
}Set;
|
|||
|
typedef struct _Condtion
|
|||
|
{
|
|||
|
u16 head;
|
|||
|
u16 V_conditon; // 电量状态
|
|||
|
u16 nor_T_value; // 常温温度
|
|||
|
u16 nor_R_value; // 常温阻值
|
|||
|
u16 TCR_Value; // TCR 值
|
|||
|
u16 lock; // 童锁
|
|||
|
u16 add;
|
|||
|
}Condtion; // 状态
|
|||
|
|
|||
|
typedef union _Set_Conditon
|
|||
|
{
|
|||
|
u16 arr[64];
|
|||
|
Condtion m_conditon;
|
|||
|
|
|||
|
}Set_Conditon;
|
|||
|
typedef union _Set_Oreder
|
|||
|
{
|
|||
|
u16 arr[128];
|
|||
|
Set m_set;
|
|||
|
|
|||
|
|
|||
|
}Set_order;
|
|||
|
|
|||
|
|
|||
|
typedef struct _Other_oder
|
|||
|
{
|
|||
|
u16 _time;
|
|||
|
u16 _temp;
|
|||
|
}Other_oder;
|
|||
|
typedef struct _Set_other
|
|||
|
{
|
|||
|
u16 head;
|
|||
|
u16 set_all_time; // 设定加热总时间
|
|||
|
u16 set_order_time; // 设定预加热时间
|
|||
|
u16 TCR_vlaue; // TCR 值
|
|||
|
u16 set_up_num; // 设定加热段数
|
|||
|
u16 normal_T_Value; // 设定常温温度值
|
|||
|
u16 normal_R_Value; // 设定常温阻值
|
|||
|
Other_oder m_set_up[30]; // 加热设定
|
|||
|
Other_oder m_set_down[30];
|
|||
|
|
|||
|
u16 crc;
|
|||
|
}Set_other_hot;
|
|||
|
typedef enum _condtion
|
|||
|
{
|
|||
|
STANDY = 0,
|
|||
|
ORDER_HOT,
|
|||
|
HOT_1,
|
|||
|
HOT_2,
|
|||
|
HOT_3,
|
|||
|
FINISH,
|
|||
|
TEST,
|
|||
|
}Conditon;
|
|||
|
|
|||
|
enum Charge
|
|||
|
{
|
|||
|
CHARGE,
|
|||
|
NOCHARGE,
|
|||
|
};
|
|||
|
enum Err_message
|
|||
|
{
|
|||
|
NO_WARING = 0,
|
|||
|
LOW_T_ERR,
|
|||
|
PRO_T_ERR,
|
|||
|
HIG_T_ERR,
|
|||
|
OPEN_ERR,
|
|||
|
SHORT_ERR,
|
|||
|
BATT_HIG_ERR,
|
|||
|
NO_HOT_ERR,
|
|||
|
};
|
|||
|
enum
|
|||
|
{
|
|||
|
NOR_MATH = 0,
|
|||
|
|
|||
|
RESET_MATH = 1,
|
|||
|
|
|||
|
};
|
|||
|
typedef struct _work_flag
|
|||
|
{
|
|||
|
unsigned char led_err_flag; // 错误警告灯闪标志
|
|||
|
|
|||
|
unsigned char chargeflag; // 充电标志
|
|||
|
|
|||
|
unsigned char Adc_Conrtrol_flag; // adc 控制标志
|
|||
|
unsigned char _temp_open_flag; // 开始测温标志
|
|||
|
unsigned char zero_T_flag; // 零度温度标志
|
|||
|
unsigned char warning_beep_flag; // 蜂鸣器警告 0
|
|||
|
unsigned char test_flag; // 老化测试
|
|||
|
// unsigned char _sleep_flag;
|
|||
|
|
|||
|
unsigned char _Uart_match; // 串口模式 两个模式 正常 boot
|
|||
|
unsigned char _match_scuess; // 匹配成功标志
|
|||
|
unsigned char _get_uart_scuess; // 一串数据成功标志
|
|||
|
unsigned char _get_uart_receive_flag;// 接收数据标志
|
|||
|
|
|||
|
unsigned char _beep_flag; // 蜂鸣器标志
|
|||
|
|
|||
|
unsigned char _get_uart_flag; // 得到串口数据标志
|
|||
|
|
|||
|
unsigned char _pid_sotp_flag; // 温度上升阶段结束标志
|
|||
|
|
|||
|
unsigned char _nor_stand_flag; // 常温标定标志
|
|||
|
|
|||
|
unsigned char _high_stand_flag; // 高温标定标志
|
|||
|
|
|||
|
|
|||
|
}Work_flag;
|
|||
|
typedef struct _work
|
|||
|
{
|
|||
|
Time m_time;
|
|||
|
Work_flag m_work_flag;
|
|||
|
Set_other_hot m_set_other_hot;
|
|||
|
Set_Conditon m_conditon;
|
|||
|
|
|||
|
u8 power; // 开关机
|
|||
|
u8 err_fault; // 报警信息
|
|||
|
u8 v_condtion; // 电压状态
|
|||
|
u8 adc_count; // adc 采集计数
|
|||
|
u8 key_value; // 按键值
|
|||
|
u8 key_down; // 按键按下
|
|||
|
u16 V_real_Value; // 电池电压
|
|||
|
float temp_1;
|
|||
|
u16 temp_P;
|
|||
|
u16 last_temp; // 上一次温度
|
|||
|
u16 last_check_temp; // 上一次检测温度
|
|||
|
Conditon work_conditon; // 0: 看电压 1: 预加热 2: 加热 3: 结束
|
|||
|
|
|||
|
|
|||
|
unsigned char _get_v_from_down; //从ADC_down获取电压
|
|||
|
unsigned char _write_v_ok; //从ADC_down获取电压 写入flash中
|
|||
|
unsigned char real_time_flag;
|
|||
|
u8 ati_repeat;
|
|||
|
u32 time_keep_flag;
|
|||
|
u16 r_value;
|
|||
|
u8 check_info;
|
|||
|
|
|||
|
u8 get_r_flag; //开始检测电阻
|
|||
|
uint16_t temp_delay; //常温标定延迟
|
|||
|
|
|||
|
|
|||
|
}Work;
|
|||
|
typedef struct _agreement
|
|||
|
{
|
|||
|
u16 head; // 协议头
|
|||
|
u8 mod; // 指令 读写
|
|||
|
u16 address; // 地址
|
|||
|
u8 num; // 数量
|
|||
|
u8 arr[64]; // 数值
|
|||
|
}Agreement;
|
|||
|
extern Work g_work;
|
|||
|
extern void analysis();
|
|||
|
extern void analysis_set_temp();
|
|||
|
extern float R_1;
|
|||
|
extern float R_2;
|
|||
|
extern uint8_t K1_PressFlag;
|
|||
|
extern uint8_t Low_Power_Flag;
|
|||
|
extern unsigned char have_key ;// __attribute__((at(0x200000C4)));
|
|||
|
void work();
|
|||
|
void work_new();
|
|||
|
extern void get_normal_r(); //常温标定
|
|||
|
void DELAY_Ms(__IO u32 count);
|
|||
|
void temp_control(u16 temp,u8 mod );
|
|||
|
void temp_control_new(u16 temp,u8 mod );
|
|||
|
void send_TCR(u16 value) ;
|
|||
|
void send_ack(u8 value);
|
|||
|
void send_TCR_value(u16 value, u16 low_r, u16 low_temp);
|
|||
|
void send_now_time_value(u16 time,u16 value ,u16 r_value);
|
|||
|
void send_now_temp_value(u16 value) ;
|
|||
|
int fputc(int ch, FILE *f);
|
|||
|
|
|||
|
extern float ADCVolatge_new[4];
|
|||
|
extern float BAT_current_v;
|
|||
|
extern float temp_k;//热电偶温差
|
|||
|
extern float temp_ntc;//热敏电阻温度(环境温度)
|
|||
|
extern float temp_all;//烟具真实温度
|
|||
|
|
|||
|
|
|||
|
extern u8 work_mode;//工作状态 0 待机;1开机;2加热
|
|||
|
extern volatile u16 OFF_delay_time;
|
|||
|
extern u8 restart;//是否从低功耗开机标志位 0不是 1 是
|
|||
|
extern u8 heat_start;
|
|||
|
extern u8 heat_stage;//加热阶段 0不加热状态 1升温 2恒温抽吸 3一轮加热完成
|
|||
|
extern volatile u32 heat_on_delay;//升温时间
|
|||
|
extern volatile u32 keep_temp_time;//恒温时间
|
|||
|
extern volatile u8 IR_delay;//防抖延时
|
|||
|
extern volatile u8 key_delay;//防抖延时
|
|||
|
extern volatile u32 temp_time_clok;//整个加热过程的时间
|
|||
|
|
|||
|
//动画更新标志 1开机动画 2电压显示 3升温动画 4抽吸动画 5抽吸结束动画
|
|||
|
extern u8 logo1_flag;
|
|||
|
extern u8 logo2_flag;
|
|||
|
extern u8 logo3_flag;
|
|||
|
extern u8 logo4_flag;
|
|||
|
extern u8 logo5_flag;
|
|||
|
|
|||
|
extern volatile u8 battery_level;//电量等级
|
|||
|
extern volatile u32 pic_clock;//动画刷新时间ms
|
|||
|
extern volatile u32 bat_v_delay;//电池电压恢复时间
|
|||
|
|
|||
|
|
|||
|
#ifdef package_3
|
|||
|
extern const unsigned char gImage_17[4428];
|
|||
|
extern const unsigned char gImage_18[1764];
|
|||
|
#endif
|
|||
|
extern u8 is_charging;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
#endif
|
|||
|
|
|||
|
|