Commit 4f2cd626 authored by limm's avatar limm

V1.2

parent e7d3c114
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -101,7 +101,7 @@
<sRunDeb>0</sRunDeb>
<sLrtime>1</sLrtime>
<bEvRecOn>1</bEvRecOn>
<nTsel>19</nTsel>
<nTsel>7</nTsel>
<sDll></sDll>
<sDllPa></sDllPa>
<sDlgDll></sDlgDll>
......@@ -112,7 +112,7 @@
<tDlgDll></tDlgDll>
<tDlgPa></tDlgPa>
<tIfile></tIfile>
<pMon>Bin\Nu_Link.dll</pMon>
<pMon>NULink\Nu_Link.dll</pMon>
</DebugOpt>
<TargetDriverDllRegistry>
<SetRegEntry>
......@@ -140,89 +140,89 @@
<Bp>
<Number>0</Number>
<Type>0</Type>
<LineNumber>293</LineNumber>
<LineNumber>65</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>212</Address>
<Address>5624</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>..\Library\StdDriver\src\retarget.c</Filename>
<Filename>D:\Users\11730\SimplicityStudio\v4_workspace\KKAll-In-OneThermostatPanelMG21V1\z3s_thermostatallinonemg21sdk665v2\Code\娴烽】-澶氬悎涓€鏂伴闈㈡澘\Library\StdDriver\src\retarget.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\AllToOneThermostatPannel\../Library/StdDriver/src/retarget.c\293</Expression>
<Expression>\\AllToOneThermostatPannel\../Library/StdDriver/src/retarget.c\65</Expression>
</Bp>
<Bp>
<Number>1</Number>
<Type>0</Type>
<LineNumber>109</LineNumber>
<LineNumber>1218</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>27080</Address>
<Address>4294</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>D:\Users\11730\SimplicityStudio\v4_workspace\KKAll-In-OneThermostatPanelMG21V1\z3s_thermostatallinonemg21sdk665v2\Code\娴烽】-澶氬悎涓€鏂伴闈㈡澘\APP\User\src\mfg_factort.c</Filename>
<Filename>D:\Users\11730\SimplicityStudio\v4_workspace\KKAll-In-OneThermostatPanelMG21V1\z3s_thermostatallinonemg21sdk665v2\Code\娴烽】-澶氬悎涓€鏂伴闈㈡澘\APP\User\src\display_common.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\AllToOneThermostatPannel\User/src/mfg_factort.c\109</Expression>
<Expression>\\AllToOneThermostatPannel\User/src/display_common.c\1218</Expression>
</Bp>
<Bp>
<Number>2</Number>
<Type>0</Type>
<LineNumber>105</LineNumber>
<LineNumber>303</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>27076</Address>
<Address>232</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>D:\Users\11730\SimplicityStudio\v4_workspace\KKAll-In-OneThermostatPanelMG21V1\z3s_thermostatallinonemg21sdk665v2\Code\娴烽】-澶氬悎涓€鏂伴闈㈡澘\APP\User\src\mfg_factort.c</Filename>
<Filename>..\Library\StdDriver\src\retarget.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\AllToOneThermostatPannel\User/src/mfg_factort.c\105</Expression>
<Expression>\\AllToOneThermostatPannel\../Library/StdDriver/src/retarget.c\303</Expression>
</Bp>
<Bp>
<Number>3</Number>
<Type>0</Type>
<LineNumber>580</LineNumber>
<LineNumber>110</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>13540</Address>
<Address>26502</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>D:\Users\11730\SimplicityStudio\v4_workspace\KKAll-In-OneThermostatPanelMG21V1\z3s_thermostatallinonemg21sdk665v2\Code\娴烽】-澶氬悎涓€鏂伴闈㈡澘\APP\User\src\control_comm.c</Filename>
<Filename>D:\Users\11730\SimplicityStudio\v4_workspace\KKAll-In-OneThermostatPanelMG21V1\z3s_thermostatallinonemg21sdk665v2\Code\娴烽】-澶氬悎涓€鏂伴闈㈡澘\APP\User\src\mfg_factort.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\AllToOneThermostatPannel\User/src/control_comm.c\580</Expression>
<Expression>\\AllToOneThermostatPannel\User/src/mfg_factort.c\110</Expression>
</Bp>
<Bp>
<Number>4</Number>
<Type>0</Type>
<LineNumber>690</LineNumber>
<LineNumber>53</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>24284</Address>
<Address>24644</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>D:\Users\11730\SimplicityStudio\v4_workspace\KKAll-In-OneThermostatPanelMG21V1\z3s_thermostatallinonemg21sdk665v2\Code\娴烽】-澶氬悎涓€鏂伴闈㈡澘\APP\User\src\control_comm.c</Filename>
<Filename>D:\Users\11730\SimplicityStudio\v4_workspace\KKAll-In-OneThermostatPanelMG21V1\z3s_thermostatallinonemg21sdk665v2\Code\娴烽】-澶氬悎涓€鏂伴闈㈡澘\APP\main.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\AllToOneThermostatPannel\User/src/control_comm.c\690</Expression>
<Expression>\\AllToOneThermostatPannel\main.c\53</Expression>
</Bp>
</Breakpoint>
<WatchWindow1>
<Ww>
<count>0</count>
<WinNumber>1</WinNumber>
<ItemText>Device_status</ItemText>
<ItemText>temp1</ItemText>
</Ww>
<Ww>
<count>1</count>
......@@ -259,6 +259,31 @@
<WinNumber>1</WinNumber>
<ItemText>static_transprent_buff_mfg</ItemText>
</Ww>
<Ww>
<count>8</count>
<WinNumber>1</WinNumber>
<ItemText>temp1</ItemText>
</Ww>
<Ww>
<count>9</count>
<WinNumber>1</WinNumber>
<ItemText>g_NetOptIndicator[i].offCounter</ItemText>
</Ww>
<Ww>
<count>10</count>
<WinNumber>1</WinNumber>
<ItemText>static_transprent_buff</ItemText>
</Ww>
<Ww>
<count>11</count>
<WinNumber>1</WinNumber>
<ItemText>((SysTick_Type *) ((0xE000E000UL) + 0x0010UL) )</ItemText>
</Ww>
<Ww>
<count>12</count>
<WinNumber>1</WinNumber>
<ItemText>SysTick</ItemText>
</Ww>
</WatchWindow1>
<WatchWindow2>
<Ww>
......@@ -315,7 +340,7 @@
<MemoryWindow1>
<Mm>
<WinNumber>1</WinNumber>
<SubType>0</SubType>
<SubType>2</SubType>
<ItemText>0x200006BD</ItemText>
<AccSizeX>0</AccSizeX>
</Mm>
......@@ -371,7 +396,7 @@
<Group>
<GroupName>CMSIS</GroupName>
<tvExp>1</tvExp>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
......@@ -403,7 +428,7 @@
<Group>
<GroupName>Library</GroupName>
<tvExp>0</tvExp>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
......
......@@ -148,7 +148,7 @@
<RestoreSysVw>1</RestoreSysVw>
</Target>
<RunDebugAfterBuild>0</RunDebugAfterBuild>
<TargetSelection>19</TargetSelection>
<TargetSelection>7</TargetSelection>
<SimDlls>
<CpuDll></CpuDll>
<CpuDllArguments></CpuDllArguments>
......@@ -162,7 +162,7 @@
<PeripheralDll></PeripheralDll>
<PeripheralDllArguments></PeripheralDllArguments>
<InitializationFile></InitializationFile>
<Driver>Bin\Nu_Link.dll</Driver>
<Driver>NULink\Nu_Link.dll</Driver>
</TargetDlls>
</DebugOption>
<Utilities>
......
[Version]
Nu_LinkVersion=V5.14
[Process]
ProcessID=0x00003f04
ProcessCreationTime_L=0x72edddaf
ProcessCreationTime_H=0x01d6cd03
ProcessID=0x0000e77c
ProcessCreationTime_L=0xcec60db7
ProcessCreationTime_H=0x01d6d90f
NuLinkID=0x18101887
NuLinkID0=0x18101887
NuLinkIDs_Count=0x00000001
......
......@@ -65,8 +65,8 @@ typedef enum {TP_ERROR = 0, TP_SUCCESS = !TP_ERROR} TP_ErrorStatus;
#define SOF_HIGH_BYTE_DEF 0XAA
#define SOF_LOW_BYTE_DEF 0X55
#define USART_RECIVE_LEN_DEF 40 //串口最多一次接受的数据量
#define USART_RECIVE_DEPTH 3 //缓存的深度
#define USART_RECIVE_LEN_DEF 48 //串口最多一次接受的数据量
#define USART_RECIVE_DEPTH 12 //缓存的深度
//透传数据接受最大间隔时间,超时未接收到数据,停止一串数据接收
#define DEF_TRANSPARENT_MAXIMUM_INTERVAL 100 //(ms)
......
......@@ -43,34 +43,18 @@ typedef uint16_t u16;
typedef uint8_t u8;
typedef struct Time_To_Power_Off
{
u8 timekey_start_status; //按下定时键
u8 timer_status; //定时器开启状态
u8 power_switch_status; //开关按键状态
u8 time_data; //倒计时时间
u8 set_up_status; //进入长按设置状态
u8 set_up_option; //设置选项
s8 temperature_correct; //温度校准值
s16 temperature_value; //实际温度值
u16 temperature_set_value; //设定温度值
u8 system_type; //系统类型
u8 wind_auto_air_status; //风速自动通风状态
u8 lock_status; //按键锁定状态
}TIMEING_INFO;
typedef struct
{
volatile u32 operate_delay_off_ms;
volatile u32 operate_delay_off_s;
volatile u32 operate_delay_off_min;
volatile u32 operate_delay_off_h;
u8 operate_delay_off_display_flag;
}Filter_Wash_Calc;
typedef struct KEY_OPERATE
{
u8 operate_delay_off_status; //延时关机操作期间标志位判断
u8 operate_delay_off_display_flag;
volatile u32 operate_delay_off_ms;
volatile u32 operate_delay_off_s;
volatile u32 operate_delay_off_min;
......
......@@ -43,12 +43,14 @@ typedef struct Power_Off_Time
typedef struct
{
u8 blacklight_flag;
u8 blacklight_display_flag;
volatile u32 time_blacklight_ms;
volatile u16 time_blacklight_s;
}BACKLIGHT_CONTROL;
typedef struct
{
u8 zigbee_uart_flag;
u8 zigbee_uart_display_flag;
volatile u32 zigbee_uart_ms;
volatile u16 zigbee_uart_s;
}ZIGBEE_UART_CONTROL;
......
......@@ -54,8 +54,9 @@ typedef struct
u16 screen_save_time; //屏保时间 00 代表30
u16 filter_wash_time; //滤网清洗时间 3000
u8 no_disturb_mode; //勿扰模式 0
u8 air_product_id;
u8 air_type;
u8 air_product_id; //空调品牌
u8 air_type ; //空调类型
u8 air_master_slavery_mode; //主从模式
}OLED_AIR_DSD;
typedef struct
{
......@@ -131,6 +132,7 @@ typedef struct{
u8 support_function_list[6]; //1,风机盘管管制设置 2,温度校准 3,是否显示当前房间温度设置,4, 超时进入屏保时间设置 10 恢复出厂设置
volatile u32 config_time_ms;
volatile u8 config_time_s;
u8 config_timeout_display;
}Local_Config_Operation;
typedef enum {
LOCAL_FUNC_FAN_PANEL_SETTING = 1,
......
......@@ -20,8 +20,8 @@
#define SOF_HIGH_BYTE_DEF 0XAA
#define SOF_LOW_BYTE_DEF 0X55
#define MAX_USART_RECIVE_LEN 56 //串口最多一次接受的数据量
#define USART_RECIVE_DEPTHS 3 //缓存的深度
#define MAX_USART_RECIVE_LEN 48 //串口最多一次接受的数据量
#define USART_RECIVE_DEPTHS 10 //缓存的深度
......
......@@ -50,7 +50,7 @@ static void (*non_permeable_opcode_analysis)(PROTOCOL_DEAL protocol_data);
static void (*transparent_opcode_analysis)(PROTOCOL_DEAL protocol_data);
static TP_ErrorStatus transparent_protocol_analysis(TP_uc8 *data,TP_uc8 len);
static u8 Record_Last_Seq = 0xFF;
/**************************************************************************************************************
全局变量,用于 transparent_protocol_send
***************************************************************************************************************/
......@@ -435,6 +435,7 @@ static TP_u8 Usart_recive_write_buff(TP_uc8 *data,TP_uc16 len)
{
//printf("data deal too slow");
static_transprent_buff.Download_serial_num = rem_serial;
static_transprent_buff.Buff_send_serial_num = rem_serial;
return 0;
}
......@@ -456,7 +457,6 @@ static TP_u8 Usart_recive_write_buff(TP_uc8 *data,TP_uc16 len)
static TP_ErrorStatus transparent_protocol_analysis(TP_uc8 *data, TP_uc8 len)
{
PROTOCOL_DEAL Usart_protocol_deal = {0};
if((data == NULL) || (len < 5) || (len > USART_RECIVE_LEN_DEF))
{
//printf("non valied msg,discard it all\r\n");
......@@ -464,17 +464,22 @@ static TP_ErrorStatus transparent_protocol_analysis(TP_uc8 *data, TP_uc8 len)
}
Usart_protocol_deal.SEQ = *(data + 4); //记录 seq 的值
if(Usart_protocol_deal.SEQ == Record_Last_Seq)
return TP_ERROR;
if(BYTE_MOVE(*(data + len -2),*(data + len -1)) != CreateCrc16(data+ 3,len - 5)) //CRC校验
{ //校验不对
send_crc_error(Usart_protocol_deal.SEQ);
return TP_ERROR;
}
Record_Last_Seq = Usart_protocol_deal.SEQ;
Usart_protocol_deal.Opcode = BYTE_MOVE(*(data + 7),*(data + 8)); //赋值功能码
Usart_protocol_deal.Channel_ID = *(data + 6);
Usart_protocol_deal.ControlField = *(data + 3);
Usart_protocol_deal.ARG = (data + 9);
Usart_protocol_deal.ARG_len = (*(data + 2) - 6); //根据协议,此处应该 data + 2
//DEBUG_USATR1("[cc->stm]RECIVE OPCODE: %16x \r\n",Usart_protocol_deal.Opcode);
if((Usart_protocol_deal.ControlField & 0x80) == 0x80)//非透传的数据
......
......@@ -24,7 +24,7 @@ KeyConfigInit_t gKey_Button_Config[] = { { 1, P3, BIT6, High},\
};
u8 boad_test_falg[6] = {0,0,0,0,0,0}; //index 0 - 5分别代表按键1 - 按键6
KEY_OPERATE sKey_Operation[3] = {{0,0,0,0,0,0,0,0,0,0,{0,0,0,0},0},{0,0,0,0,0,0,0,0,0,0,{0,0,0,0},0},{0,0,0,0,0,0,0,0,0,0,{0,0,0,0},0}};
KEY_OPERATE sKey_Operation[3] = {0};
#if 1
TAP_CONTROL_ST Tap_Control = {6,{0,0,0,0,0,0},{0,0,0,0,0,0},0,0} ;
#else
......@@ -414,6 +414,7 @@ void KeyProcess_Handler_Callbacks(u8 key_id,u8 KeyPressEvent)
if(IsLcdEnterScreenSave()) //息屏状态,触摸按键,该次触发只唤醒,不做有效触发
{
Reload_Save_Time();
Detect_Human_Dispaly(); //cannot delete
return;
}
Reload_Save_Time();
......@@ -537,7 +538,10 @@ void Delay_Power_Off_Control(u8 control_type,u16 flashing_time_ms,u16 flash_inte
{
LCDShowTemp_state_t.LCD_state = FLASHING;
if(flash_interval_time_ms)
LCDShowTemp_state_t.LCD_display_count = flashing_time_ms/flash_interval_time_ms; //15s
else
LCDShowTemp_state_t.LCD_display_count = 0;
LCDShowTemp_state_t.LCD_display_timer = flash_interval_time_ms/10;
}
else
......@@ -567,7 +571,8 @@ void Delay_OFF_Rel_Display(u8 stop_flash,u8 delay_timer,u8 dispaly_data,u8 H_cha
}
if(H_char){
if(H_char)
{
//显示H图标
LCDShowTemp_state_t.LCD_place = H_CHAR_DISPLAY;
LCDShowTemp_state_t.LCD_state = ON;
......@@ -612,7 +617,10 @@ void Calib_Temp_Control(u8 control_type,u16 flashing_time_ms,u16 flash_interval_
{
LCDShowTemp_state_t.LCD_state = FLASHING;
if(flash_interval_time_ms)
LCDShowTemp_state_t.LCD_display_count = flashing_time_ms/flash_interval_time_ms; //15s
else
LCDShowTemp_state_t.LCD_display_count = 0;
LCDShowTemp_state_t.LCD_display_timer = flash_interval_time_ms/10;
}
else
......@@ -1219,41 +1227,42 @@ static void KEY5_Botton_Process_Handler(u8 KeyPressEvent)
//Control_AIR_CONDITION_By_RS485(AIR_CMD_FAN_SPEED,next_speed); //控制空调风速
}
}
else if(Oled_Display_Info.Air_Device.air_cond_type == 1) //风机盘管,新风只支持3档+自动调节
{
if(Oled_Display_Info.Air_Device.system_type != SYSTEM_MODE_DRY) //美的空调,除湿模式下改变风速无效
{
next_speed = Get_NextOne_By_Current_Speed_Level(1,Oled_Display_Info.Air_Device.wind_speed,0);
display_wind_speed(next_speed,0);
//Oled_Display_Info.Air_Device.wind_speed = next_speed;
//Control_AIR_CONDITION_By_RS485(AIR_CMD_FAN_SPEED,Oled_Display_Info.Air_Device.wind_speed); //控制空调风速
state_change_report(OPCODE_GENERAL_REPORT_STATUS,1); //状态改变通知
}
}
break;
}
else if(gKey_Press_Info.adjust_fan_speed_status == 2)
{
u8 speed_direct = 0;
speed_direct = Get_NextOne_By_Current_wind_direct(1,Oled_Display_Info.Air_Device.air_wind_direct);
switch(speed_direct) //显示当前风向
{
case 0:
display_wind_direct(1,0,0);
break;
case 1:
display_wind_direct(0,1,0);
break;
case 2:
display_wind_direct(0,0,1);
break;
default:
break;
}
// else if(Oled_Display_Info.Air_Device.air_cond_type == 1) //风机盘管,新风只支持3档+自动调节
// {
// if(Oled_Display_Info.Air_Device.system_type != SYSTEM_MODE_DRY) //美的空调,除湿模式下改变风速无效
// {
// next_speed = Get_NextOne_By_Current_Speed_Level(1,Oled_Display_Info.Air_Device.wind_speed,0);
// display_wind_speed(next_speed,0);
// //Oled_Display_Info.Air_Device.wind_speed = next_speed;
//
// //Control_AIR_CONDITION_By_RS485(AIR_CMD_FAN_SPEED,Oled_Display_Info.Air_Device.wind_speed); //控制空调风速
//
// state_change_report(OPCODE_GENERAL_REPORT_STATUS,1); //状态改变通知
// }
// }
break;
}
// else if(gKey_Press_Info.adjust_fan_speed_status == 2)
// {
// u8 speed_direct = 0;
// speed_direct = Get_NextOne_By_Current_wind_direct(1,Oled_Display_Info.Air_Device.air_wind_direct);
// switch(speed_direct) //显示当前风向
// {
// case 0:
// display_wind_direct(1,0,0);
// break;
// case 1:
// display_wind_direct(0,1,0);
// break;
// case 2:
// display_wind_direct(0,0,1);
// break;
// default:
// break;
// }
// Control_AIR_CONDITION_By_RS485(AIR_CMD_FAN_DIRECT,speed_direct); //控制空调风向
// break;
// }
if(sKey_Operation[0].operate_delay_off_status)
{
sKey_Operation[0].record_adjust_delay_off += 5;
......@@ -1272,19 +1281,11 @@ static void KEY5_Botton_Process_Handler(u8 KeyPressEvent)
/**************************************************
调节设置温度
**************************************************/
sKey_Operation[0].set_temper_temp = Oled_Display_Info.Air_Device.set_temperature;
sKey_Operation[0].set_temper_temp += 5;
if(sKey_Operation[0].set_temper_temp >= 300)
sKey_Operation[0].set_temper_temp = 300;
display_set_temp(0,sKey_Operation[0].set_temper_temp,0); //显示设置温度
Oled_Display_Info.Air_Device.set_temperature += 5;
if(Oled_Display_Info.Air_Device.set_temperature >= 300)
Oled_Display_Info.Air_Device.set_temperature = 300;
display_set_temp(0,Oled_Display_Info.Air_Device.set_temperature,0); //显示设置温度
if( (sKey_Operation[0].set_temper_temp /10) == (Oled_Display_Info.Air_Device.set_temperature/10)) //26.0调整到26.6度时,不管空调的反馈,直接上报
{
Oled_Display_Info.Air_Device.set_temperature = sKey_Operation[0].set_temper_temp;
sKey_Operation[0].set_temper_temp = 0xff; //不需要下发控制命令给空调
}
else
Oled_Display_Info.Air_Device.set_temperature = sKey_Operation[0].set_temper_temp;
#if (DEV_TYPE == 0) &&(DEVICE_TYPE_AIR_CONDITION ==1)
delay_control_set_temp_start();
#else
......@@ -1493,21 +1494,13 @@ static void KEY6_Botton_Process_Handler(u8 KeyPressEvent)
delay_operate_delay_off_Task_Start(); //开启15s倒计时
break;
}
sKey_Operation[0].set_temper_temp = Oled_Display_Info.Air_Device.set_temperature;
if(Oled_Display_Info.Air_Device.system_type != SYSTEM_MODE_AIR)
{
sKey_Operation[0].set_temper_temp -= 5;
if(sKey_Operation[0].set_temper_temp <= 160) //美的空调温度调节范围 17度 - 30度
sKey_Operation[0].set_temper_temp = 160;
display_set_temp(0,sKey_Operation[0].set_temper_temp,0); //显示设置温度
Oled_Display_Info.Air_Device.set_temperature -= 5;
if(Oled_Display_Info.Air_Device.set_temperature <= 160) //美的空调温度调节范围 17度 - 30度
Oled_Display_Info.Air_Device.set_temperature = 160;
display_set_temp(0,Oled_Display_Info.Air_Device.set_temperature,0); //显示设置温度
if( (sKey_Operation[0].set_temper_temp /10) == (Oled_Display_Info.Air_Device.set_temperature/10)) //26.5调整到26度时,不管空调的反馈,直接上报
{
Oled_Display_Info.Air_Device.set_temperature = sKey_Operation[0].set_temper_temp;
sKey_Operation[0].set_temper_temp = 0xff; //不需要下发控制命令给空调
}
else
Oled_Display_Info.Air_Device.set_temperature = sKey_Operation[0].set_temper_temp;
#if (DEV_TYPE == 0) &&(DEVICE_TYPE_AIR_CONDITION ==1)
delay_control_set_temp_start();
#else
......@@ -1664,29 +1657,29 @@ plus_or_sub
wind_direct 表示当前的风向
return 返回下个风向
**********************************************************/
u8 Get_NextOne_By_Current_wind_direct(u8 plus_or_sub,u8 wind_direct)
{
u8 next_direct = 0;
switch(wind_direct)
{
case 0:
{
((plus_or_sub) ? (next_direct = 1):(next_direct = 2));
}
break;
case 1:
{
((plus_or_sub) ? (next_direct = 2):(next_direct = 0));
}
break;
case 2:
{
((plus_or_sub) ? (next_direct = 0):(next_direct =1));
}
break;
}
return next_direct;
}
//u8 Get_NextOne_By_Current_wind_direct(u8 plus_or_sub,u8 wind_direct)
//{
// u8 next_direct = 0;
// switch(wind_direct)
// {
// case 0:
// {
// ((plus_or_sub) ? (next_direct = 1):(next_direct = 2));
// }
// break;
// case 1:
// {
// ((plus_or_sub) ? (next_direct = 2):(next_direct = 0));
// }
// break;
// case 2:
// {
// ((plus_or_sub) ? (next_direct = 0):(next_direct =1));
// }
// break;
// }
// return next_direct;
//}
/*********************************************************
查询下一个风速
plus_or_sub 代表是增加还是减少 1,代表调高,0代表调小
......@@ -1800,6 +1793,7 @@ u8 Get_NextOne_By_Current_Speed_Level(u8 plus_or_sub,u8 fan_speed,u8 type_suppor
}
return next_level;
}
#if ( (DEV_TYPE == 1) &&(DEVICE_TYPE_AIR_CONDITION ==1)) ||(DEVICE_TYPE_FLOOR_HEATING) ||(DEVICE_TYPE_FAN)
/******************************************
阀门开关控制(K1,K2,K3,K4,K5)
......@@ -1888,6 +1882,18 @@ void Tap_Init(void)
}
}
else if(Oled_Display_Info.FLOOR_Device.system_type == SYSTEM_MODE_AUTO)
{
if( 260 - Oled_Display_Info.FLOOR_Device.real_temperature > 20)
{
Relay_Action(0x01,0x01); //继电器吸合
}
else if (Oled_Display_Info.FLOOR_Device.real_temperature -260 > 10)
{
Relay_Action(0x01,0x00); //继电器断开
}
}
}
#elif DEVICE_TYPE_FAN
Fan_Speed_Control(Oled_Display_Info.FAN_Device.wind_speed); //默认打开
......@@ -1900,6 +1906,57 @@ void Tap_Init(void)
#endif
}
/******************************************
//新风模式切换,打开关闭旁通模式
*******************************************/
void Fan_PassbyONOFF_By_Mode_Trans(u8 system_mdoe,u8 reset_count_time)
{
if(system_mdoe == SYSTEM_MODE_MANUAL)
{
Relay_Action(0x08,0x00);
Tap_Status_Scan_Task_Stop();
}
else if(system_mdoe == SYSTEM_MODE_ROLL)
{
//开启状态扫描事件
Tap_Status_Scan_Task_Start();
Relay_Action(0x08,0x08);
}
if(reset_count_time)
{
auto_time = 0;
auto_type = 0;
}
}
/******************************************
//新风风速切换
*******************************************/
void Fan_Speed_Control(u8 wind_speed)
{
switch(wind_speed)
{
//K3
case WIND_SPEED_LOW:
{
Relay_Action(0x07,0x04);
}
break;
//K2
case WIND_SPEED_MID:
{
Relay_Action(0x07,0x02);
}
break;
//K1
case WIND_SPEED_HIGH:
{
Relay_Action(0x07,0x01);
}
break;
}
}
#endif
/******************************************
//风阀 冷热阀 轮训,根据温度开启关闭
*******************************************/
......@@ -1920,6 +1977,18 @@ void Tap_Status_Scan(void)
}
}
else if(Oled_Display_Info.FLOOR_Device.system_type == SYSTEM_MODE_AUTO)
{
if( 260 - Oled_Display_Info.FLOOR_Device.real_temperature > 20)
{
Relay_Action(0x01,0x01); //继电器吸合
}
else if (Oled_Display_Info.FLOOR_Device.real_temperature -260 > 10)
{
Relay_Action(0x01,0x00); //继电器断开
}
}
}
#elif DEVICE_TYPE_FAN
if((Oled_Display_Info.FAN_Device.on_off ==1)&&(Oled_Display_Info.aging_test_flag != 1)) //开机状态且没处于15min-4h老化期间
......@@ -1961,56 +2030,6 @@ void Tap_Status_Scan(void)
}
#endif
}
/******************************************
//新风模式切换,打开关闭旁通模式
*******************************************/
void Fan_PassbyONOFF_By_Mode_Trans(u8 system_mdoe,u8 reset_count_time)
{
if(system_mdoe == SYSTEM_MODE_MANUAL)
{
Relay_Action(0x08,0x00);
Tap_Status_Scan_Task_Stop();
}
else if(system_mdoe == SYSTEM_MODE_ROLL)
{
//开启状态扫描事件
Tap_Status_Scan_Task_Start();
Relay_Action(0x08,0x08);
}
if(reset_count_time)
{
auto_time = 0;
auto_type = 0;
}
}
/******************************************
//新风风速切换
*******************************************/
void Fan_Speed_Control(u8 wind_speed)
{
switch(wind_speed)
{
//K3
case WIND_SPEED_LOW:
{
Relay_Action(0x07,0x04);
}
break;
//K2
case WIND_SPEED_MID:
{
Relay_Action(0x07,0x02);
}
break;
//K1
case WIND_SPEED_HIGH:
{
Relay_Action(0x07,0x01);
}
break;
}
}
/******************************************
//童锁操作
*******************************************/
......@@ -2070,4 +2089,3 @@ void Control_ChildLock_Onoff(u8 device_type,u8 onoff)
}
save_data();
}
......@@ -5,6 +5,7 @@
#include "key.h"
#include "ZH_protocol.h"
#include "display_common.h"
#include "BL55072A.h"
/************************************************************************************************
时间:2019.9.16
作者:吴明军
......@@ -12,112 +13,35 @@
参数: 传递opearoteID,productID协议的第三位,此位表示品牌编号
返回值:无
*****************************************************************************************************/
u32 use_oprearoteID = MIDEA_OPERATE_ID, use_productID = MIDEA_PRODUCT_ID;
void transfer_opearoteID_productID(uint8_t brand)
extern Lcd_Status_Info_t LCDShowTemp_state_t;
u32 use_oprearoteID = 0xff, use_productID = 0xff;
#define SIMULATOR 0 //模拟器
#define DAIKIN 1 //品牌 :大金
#define HITACHI 2 //品牌 :日立
#define TOSHIBA 3 //东芝
#define MITSUBISHI 4 //三菱重工
#define MITSUBISHI_ELECTRIC 5 //三菱电机
#define GREE 6 //格力
#define MIDEA_TRADEMARK 7 //美的
#define DAIKIN_MX 8 //大金MX
#define HITACHI_US 9 //日立US
#define DAIKIN_NEW_WIND 10 //大金新风
#define HITACHI_NEW_WIND 11 //日立新风
#define PANASONIC_NEW_WIND 12 //松下新风
#define GREE_A_PAD 13 //格力A 型风管
#define YORK 14 //约克
#define MCQUARY 15 //麦克斯韦尔
#define GREE_HOTEL_PAD 16 //格力酒店风管
#define TRANE 17 //特灵一拖一
#define HAIER 18 //海尔一拖一
#define MIDEA_COOL_WIND 19 //美的酷风
#define GREE_C1_PAD 20 //格力C1风管
#define GREE_NEW_WIND_AREFACTION 21 //格力新风除湿
void transfer_opearoteID_productID(u8 brand ,u8 type)
{
switch(brand)
{
case SIMULATOR :
break;
case DAIKIN :
use_oprearoteID = DAIKIN_OPERATE_ID;
use_productID = DAIKIN_PRODUCT_ID;
break;
case HITACHI:
use_oprearoteID = HITACHI_OPERATE_ID;
use_productID = HITACHI_PRODUCT_ID;
break;
case TOSHIBA:
use_oprearoteID = TOSHIBA_OPERATE_ID;
use_productID = TOSHIBA_PRODUCT_ID;
break;
case MITSUBISHI:
use_oprearoteID = MITSUBISHI_OPERATE_ID;
use_productID = MITSUBISHI_PRODUCT_ID;
break;
case MITSUBISHI_ELECTRIC:
use_oprearoteID = MITSUBISHI_ELECTRIC_OPERATE_ID;
use_productID = MITSUBISHI_ELECTRIC_PRODUCT_ID;
break;
case GREE:
use_oprearoteID = GREE_OPERATE_ID;
use_productID = GREE_PRODUCT_ID;
break;
case MIDEA_TRADEMARK:
use_oprearoteID = MIDEA_OPERATE_ID;
use_productID = MIDEA_PRODUCT_ID;
break;
case DAIKIN_MX:
use_oprearoteID = DAIKIN_MX_OPERATE_ID;
use_productID = DAIKIN_MX_PRODUCT_ID;
break;
case HITACHI_US:
use_oprearoteID = HITACHI_US_OPERATE_ID;
use_productID = HITACHI_US_PRODUCT_ID;
break;
case DAIKIN_NEW_WIND:
use_oprearoteID = DAIKIN_NEW_WIND_OPERATE_ID;
use_productID = DAIKIN_NEW_WIND_PRODUCT_ID;
break;
case HITACHI_NEW_WIND:
use_oprearoteID = HITACHI_NEW_WIND_OPERATE_ID;
use_productID = HITACHI_NEW_WIND_PRODUCT_ID;
break;
case PANASONIC_NEW_WIND:
use_oprearoteID = PANASONIC_NEW_WIND_OPERATE_ID;
use_productID = PANASONIC_NEW_WIND_PRODUCT_ID;
break;
case GREE_A_PAD:
use_oprearoteID = GREE_A_PAD_OPERATE_ID;
use_productID = GREE_A_PAD_PRODUCT_ID;
break;
case YORK:
use_oprearoteID = YORK_OPERATE_ID;
use_productID = YORK_PRODUCT_ID;
break;
case MCQUARY:
use_oprearoteID = MCQUARY_PAD_OPERATE_ID;
use_productID = MCQUARY_PRODUCT_ID;
break;
case GREE_HOTEL_PAD:
use_oprearoteID = GREE_HOTEL_PAD_OPERATE_ID;
use_productID = GREE_HOTEL_PAD_PRODUCT_ID;
break;
case TRANE:
use_oprearoteID = TRANE_OPERATE_ID;
use_productID = TRANE_PRODUCT_ID;
break;
case HAIER:
use_oprearoteID = HAIER_OPERATE_ID;
use_productID = HAIER_PRODUCT_ID;
break;
case MIDEA_COOL_WIND:
use_oprearoteID = MIDEA_COOL_WIND_OPERATE_ID;
use_productID = MIDEA_COOL_WIND_PRODUCT_ID;
break;
case GREE_C1_PAD:
use_oprearoteID = GREE_C1_PAD_OPERATE_ID;
use_productID = GREE_C1_PAD_PRODUCT_ID;
break;
case GREE_NEW_WIND_AREFACTION:
use_oprearoteID = GREE_NEW_WIND_AREFACTION_OPERATE_ID;
use_productID = GREE_NEW_WIND_AREFACTION_PRODUCT_ID;
break;
default :
break;
}
Oled_Display_Info.Air_Device.air_product_id = brand;
Oled_Display_Info.Air_Device.air_cond_type = type;
}
extern KEY_OPERATE sKey_Operation[3];
static void air_report_process(void)
......@@ -125,7 +49,7 @@ static void air_report_process(void)
/*读取oprearoteID,productID*/
if(ZH_protocol_i->poll_check_receive[SWITCH] == 0xAA)//带此标志的专为读取oprearoteID,productID,故之后不再次解读
{
transfer_opearoteID_productID(ZH_protocol_i->poll_check_receive[MODE]);//此命令中此处存放的是品牌
transfer_opearoteID_productID(ZH_protocol_i->poll_check_receive[MODE],ZH_protocol_i->poll_check_receive[TEMPERATURE]);//此命令中此处存放的是品牌
}
else
{
......@@ -167,12 +91,11 @@ static void air_report_process(void)
if( (ZH_protocol_i->poll_check_receive[TEMPERATURE] != (Oled_Display_Info.Air_Device.set_temperature/10) ) &&
(ZH_protocol_i->poll_check_receive[TEMPERATURE] != 0xFF))
{
if(sKey_Operation[0].set_temper_temp >= 10*ZH_protocol_i->poll_check_receive[TEMPERATURE])
Oled_Display_Info.Air_Device.set_temperature = sKey_Operation[0].set_temper_temp;
Oled_Display_Info.Air_Device.set_temperature = 10*ZH_protocol_i->poll_check_receive[TEMPERATURE];
if (Oled_Display_Info.Air_Device.on_off) //开机状态
{
//display_set_temp(Oled_Display_Info.Air_Device.set_temperature,0);
display_set_temp(0,Oled_Display_Info.Air_Device.set_temperature,0);
state_change_report(OPCODE_GENERAL_REPORT_STATUS,1);// 上报状态
}
......@@ -182,13 +105,30 @@ static void air_report_process(void)
if((ZH_protocol_i->poll_check_receive[SWITCH] != Oled_Display_Info.Air_Device.on_off) && (ZH_protocol_i->poll_check_receive[SWITCH] != 0xFF))
{
Oled_Display_Info.Air_Device.on_off = ZH_protocol_i->poll_check_receive[SWITCH];
printf("on off =%d\r\n",Oled_Display_Info.Air_Device.on_off);
//printf("on off =%d\r\n",Oled_Display_Info.Air_Device.on_off);
if(Oled_Display_Info.Air_Device.on_off)
Control_OnOff_handler(AIR_CONDITION,1);
else
{
BL55072A_Clear();
Control_OnOff_handler(AIR_CONDITION,0);
}
state_change_report(OPCODE_GENERAL_REPORT_STATUS,1); //状态改变通知
}
#if (DEV_TYPE == 0) &&(DEVICE_TYPE_AIR_CONDITION ==1)
if(ZH_protocol_i->poll_check_receive[STATE] &0x10)
{
Oled_Display_Info.Air_Device.air_master_slavery_mode = 1;
if(!IsLcdEnterScreenSave()&&(Oled_Display_Info.Air_Device.power_off_time ==0)&&(Oled_Display_Info.Air_Device.on_off))
{
LCDShowTemp_state_t.LCD_place = H_CHAR_DISPLAY;
LCDShowTemp_state_t.LCD_state = ON;
LcdShowCTR(LCDShowTemp_state_t);
}
}
#endif
}
}
void ZH_msg_deal(void)
......
......@@ -65,7 +65,7 @@ u8 Device_status[25]= {
TIMEING_OPTION _Time_Power_Off = {0,0,0,0};
#define sBacklight_INIT { 1,0,0}
BACKLIGHT_CONTROL sBacklight = sBacklight_INIT;
ZIGBEE_UART_CONTROL sUartDetect = {1,0,0};
ZIGBEE_UART_CONTROL sUartDetect = {1,0,0,0};
//STRAINER_OPTION Strainer_Net_Used_Time = {0,0,0,0}; //产测时间,状态保存
......@@ -171,6 +171,7 @@ static void delay_300ms_report_stop(void);
//
//
//}
void Display_Status(void);
/***********************************************************************
* 重要任务,不停的轮询
***********************************************************************/
......@@ -181,6 +182,7 @@ void main_task(void)
LcdShowRunningAll();
uart_msg_deal(); //产测数据解析
kLedModuleActionDetectCallback(); //zigbee指示灯操作
Display_Status();
#ifndef DEVICE_TYPE_AIR_CONDITION
Tap_Switch();
......@@ -271,14 +273,34 @@ void shtc3_sensor_measure_loop(void)
{
u8 i = 0;
s16 tmep_data;
static u16 abnormal_times = 0;
int temp_new_data = 0;
SHTC3_GetTemp(&tmep_data);
if( (tmep_data >1000)||(tmep_data <- 100)) //温度传感器错误
{
if(abnormal_times < 0xfe)
abnormal_times++;
else
abnormal_times = 3;
if(abnormal_times >=3 )
Set_Error_Code(1); //温度传感器错误
}
else
{
if((Oled_Display_Info.screen_page == 1)&&(Oled_Display_Info.Air_Device.error == 1)) //传感器故障
{
Oled_Display_Info.Air_Device.error = 0;
if( Get_Display_Status())
{
LCDShowTemp_state_t.LCD_place = DELAY_OFF_TIME_DISPLAY;
LCDShowTemp_state_t.LCD_display_count = 0;
LCDShowTemp_state_t.LCD_state = OFF;
LcdShowCTR(LCDShowTemp_state_t);
}
state_change_report(OPCODE_GENERAL_REPORT_STATUS,1);
}
temp_new_data = tmep_data;
for (i = 0;i < data_number - 1;i ++)
......@@ -313,7 +335,7 @@ void shtc3_sensor_measure_loop(void)
{
temp_new_data = 995;
}
printf("measure temp data = %d\r\n",temp_new_data);
// printf("measure temp data = %d\r\n",temp_new_data);
if ( (ABS(Oled_Display_Info.Air_Device.real_temperature, temp_new_data)>10)
&&(Oled_Display_Info.screen_page == 1) ) {
......@@ -927,7 +949,7 @@ void delay_operate_delay_off(void)
{
sKey_Operation[Oled_Display_Info.screen_page-1].operate_delay_off_status = 0;
//超时,关闭
Delay_OFF_Rel_Display(0,0,NULL,0,0,0);
Delay_OFF_Rel_Display(0,0,0,0,0,0);
Oled_Display_whole();
}
}
......@@ -1148,13 +1170,8 @@ struct task_components_t task_comps[] =
{6, SWITCH_OFF, RUN_FLAG_0, SET_FLAG_0, Ms_500,Ms_500, setup_handler }, //上电延时启动
{7, SWITCH_OFF, RUN_FLAG_0, SET_FLAG_0, Sec_15,Sec_15, delay_operate_calibrate_temper }, //15s操作倒计时
{8, SWITCH_OFF, RUN_FLAG_0, SET_FLAG_0, Sec_2,Sec_2, operate_calibrate_temper_delay_2s_off }, //确认校准温度后延时2s关机
#if DEVICE_TYPE_AIR_CONDITION
{9, SWITCH_OFF, RUN_FLAG_0, SET_FLAG_0, Sec_1,Sec_1, task_retransmit }, //重传
{10,SWITCH_ON, RUN_FLAG_0, SET_FLAG_0, Sec_15,Sec_15, task_poll_check } , //查询空调状态15s
#else
{9, SWITCH_OFF, RUN_FLAG_0, SET_FLAG_0, Sec_1,Sec_1, NULL }, //重传
{10,SWITCH_OFF, RUN_FLAG_0, SET_FLAG_0, Sec_15,Sec_15, NULL } , //查询空调状态15s
#endif
{11,SWITCH_OFF, RUN_FLAG_1, SET_FLAG_0, Sec_1,Sec_1, aging_test }, //老化测试
{12,SWITCH_ON, RUN_FLAG_1, SET_FLAG_0, Sec_3,Sec_3, task_feed_dog }, //喂狗
{13,SWITCH_OFF, RUN_FLAG_0, SET_FLAG_0, Sec_3,Sec_3, task_exit_aging_test }, //退老化5s快闪
......@@ -1182,7 +1199,6 @@ void UART1_IRQHandler(void) //
transparent_msg_recive(ch);
}
}
void UART0_IRQHandler(void) //串口接收中断
{
uint8_t ch = 0xFF;
......@@ -1193,7 +1209,7 @@ void UART0_IRQHandler(void) //
ch = UART_READ(UART0);
//单板测试相关数据解析
// //单板测试相关数据解析
if(!uart_msg_recive(ch))
return;
}
......@@ -1241,70 +1257,20 @@ void Power_Off_Scan (void)
if (sKey_Operation[i].operate_delay_off_min >= 30)
{
u8 display_data[3] = {0};
sKey_Operation[i].operate_delay_off_min = 0;
if (i == 0){ //定时关机
if(Oled_Display_Info.Air_Device.power_off_time >=5)
Oled_Display_Info.Air_Device.power_off_time -= 5;
display_data[0] = Oled_Display_Info.Air_Device.power_off_time;
}
else if(i == 1){
if(Oled_Display_Info.FLOOR_Device.power_off_time >=5)
Oled_Display_Info.FLOOR_Device.power_off_time -= 5;
display_data[1] = Oled_Display_Info.FLOOR_Device.power_off_time;
}
else if(i == 2){
if(Oled_Display_Info.FAN_Device.power_off_time >=5)
Oled_Display_Info.FAN_Device.power_off_time -= 5;
display_data[2] = Oled_Display_Info.FAN_Device.power_off_time;
}
/*显示当前的延时关机剩余时间*/
//如果未处于屏保状态,则显示当前的延时关机时间
if((Oled_Display_Info.screen_page == (i+1))&&(Get_Display_Status()))
{
if(IsPowerOffFlashing())
{
Delay_Power_Off_Control(FLASHING,15000,500,display_data[i]);
sKey_Operation[i].record_adjust_delay_off = display_data[i];
}
else
Display_poweroff_time(display_data[i]);
}
state_change_report(OPCODE_GENERAL_REPORT_STATUS,i+1);// 上报状态
if ( (Oled_Display_Info.Air_Device.power_off_time <= 0 )&&(i == 0) )
{
if(Oled_Display_Info.screen_page == AIR_CONDITION)
PowerOff();
Oled_Display_Info.Air_Device.on_off = 0;
Oled_Display_Info.Air_Device.power_off_flage = 0;
state_change_report(OPCODE_GENERAL_REPORT_STATUS,1);
}
if((Oled_Display_Info.FLOOR_Device.power_off_time <= 0)&&(i == 1) )
{
if(Oled_Display_Info.screen_page == FLOOR_HEATING)
PowerOff();
#if FLOOR_HEATING
Control_OnOff_handler(FLOOR_HEATING,0);
#endif
Oled_Display_Info.FLOOR_Device.on_off = 0;
Oled_Display_Info.FLOOR_Device.power_off_flage = 0;
state_change_report(OPCODE_GENERAL_REPORT_STATUS,2);
}
if((Oled_Display_Info.FAN_Device.power_off_time <= 0)&&(i == 2) )
{
if(Oled_Display_Info.screen_page == FAN)
PowerOff();
#if DEVICE_TYPE_FAN
Control_OnOff_handler(FAN,0);
#endif
Oled_Display_Info.FAN_Device.on_off = 0;
Oled_Display_Info.FAN_Device.power_off_flage = 0;
state_change_report(OPCODE_GENERAL_REPORT_STATUS,3);
}
sKey_Operation[i].operate_delay_off_display_flag = 1;
}
}
}
......@@ -1352,32 +1318,29 @@ void Filter_Start_Scan (void)
sKey_Operation[i].filter_calc.operate_delay_off_h++;
if ((i == 0)&&(Oled_Display_Info.Air_Device.filter_wash_time>=1)){ //定时关机
Oled_Display_Info.Air_Device.filter_wash_time -= 1;
save_data();
}
else if((i == 2)&&(Oled_Display_Info.FAN_Device.filter_wash_time >=1)){
Oled_Display_Info.FAN_Device.filter_wash_time -= 1;
}
save_data();
//printf("filter time = %d\r\n",Oled_Display_Info.Air_Device.filter_wash_time);
}
if ( (Oled_Display_Info.Air_Device.filter_wash_time <= 0 )&&(i == 0) ) //Test
{
Oled_Display_Info.Air_Device.error = 3; //滤网清洗时间
Reset_Fiter_Time(AIR_CONDITION);
if(Get_Display_Status())
if(Oled_Display_Info.Air_Device.error !=3)
{
Display_Up_Contend(AIR_CONDITION);
Oled_Display_Info.Air_Device.error = 3; //滤网清洗时间
sKey_Operation[i].filter_calc.operate_delay_off_display_flag = 1;
}
state_change_report(OPCODE_GENERAL_REPORT_STATUS,1);
}
if((Oled_Display_Info.FAN_Device.filter_wash_time <= 0)&&(i == 2) )
{
Oled_Display_Info.FAN_Device.error = 3; //滤网清洗时间
Reset_Fiter_Time(FAN);
if(Get_Display_Status())
if(Oled_Display_Info.FAN_Device.error !=3)
{
Display_Up_Contend(FAN);
Oled_Display_Info.FAN_Device.error = 3; //滤网清洗时间
sKey_Operation[i].filter_calc.operate_delay_off_display_flag = 1;
}
state_change_report(OPCODE_GENERAL_REPORT_STATUS,3);
}
}
}
......@@ -1413,8 +1376,112 @@ void Backlight_Handle (void)
{
sBacklight.time_blacklight_s = 0;
sBacklight.blacklight_flag = 0;
sBacklight.blacklight_display_flag = 1;
}
}
}
}
extern Local_Config_Operation local_config_operate;
void Display_Status(void)
{
u8 i = 0;
//息屏显示
if(sBacklight.blacklight_display_flag)
{
sBacklight.blacklight_display_flag = 0;
EnterScreenSaveMode(); //熄灭进入屏保模式
}
//串口故障显示
if(sUartDetect.zigbee_uart_display_flag)
{
sUartDetect.zigbee_uart_display_flag = 0;
Set_Error_Code(2); //ZIGBEE串口故障
}
//配置模式超时显示
if(local_config_operate.config_timeout_display)
{
local_config_operate.config_timeout_display = 0;
Control_OnOff_handler(Oled_Display_Info.device_type,0); //显示关
}
for(i = 0;i<3;i++)
{
//延时关机显示
if(sKey_Operation[i].operate_delay_off_display_flag)
{
u8 dispaly_data ;
sKey_Operation[i].operate_delay_off_display_flag = 0;
if(Oled_Display_Info.screen_page==1)
dispaly_data = Oled_Display_Info.Air_Device.power_off_time;
else if(Oled_Display_Info.screen_page==2)
dispaly_data = Oled_Display_Info.FLOOR_Device.power_off_time;
else
dispaly_data = Oled_Display_Info.FAN_Device.power_off_time;
if((Oled_Display_Info.screen_page == (i+1))&&(Get_Display_Status()))
{
if(IsPowerOffFlashing())
{
Delay_Power_Off_Control(FLASHING,15000,500,dispaly_data);
sKey_Operation[i].record_adjust_delay_off = dispaly_data;
}
else
Display_poweroff_time(dispaly_data);
}
if ( (Oled_Display_Info.Air_Device.power_off_time <= 0 )&&(i == 0) )
{
if(Oled_Display_Info.screen_page == AIR_CONDITION)
PowerOff();
Oled_Display_Info.Air_Device.on_off = 0;
#if ( (DEV_TYPE == 0) &&(DEVICE_TYPE_AIR_CONDITION ==1))
Control_AIR_CONDITION_By_RS485(AIR_CMD_ONOFF,Oled_Display_Info.Air_Device.on_off); //控制开关
#endif
Oled_Display_Info.Air_Device.power_off_flage = 0;
}
else if((Oled_Display_Info.FLOOR_Device.power_off_time <= 0)&&(i == 1) )
{
if(Oled_Display_Info.screen_page == FLOOR_HEATING)
PowerOff();
#if FLOOR_HEATING
Control_OnOff_handler(FLOOR_HEATING,0);
#endif
Oled_Display_Info.FLOOR_Device.on_off = 0;
Oled_Display_Info.FLOOR_Device.power_off_flage = 0;
}
else if((Oled_Display_Info.FAN_Device.power_off_time <= 0)&&(i == 2) )
{
if(Oled_Display_Info.screen_page == FAN)
PowerOff();
#if DEVICE_TYPE_FAN
Control_OnOff_handler(FAN,0);
#endif
Oled_Display_Info.FAN_Device.on_off = 0;
Oled_Display_Info.FAN_Device.power_off_flage = 0;
}
state_change_report(OPCODE_GENERAL_REPORT_STATUS,i+1);// 上报状态
}
//滤网时间显示
if(sKey_Operation[i].filter_calc.operate_delay_off_display_flag)
{
sKey_Operation[i].filter_calc.operate_delay_off_display_flag = 0;
if(i == 0)
{
if(Get_Display_Status())
{
Display_Up_Contend(AIR_CONDITION);
}
state_change_report(OPCODE_GENERAL_REPORT_STATUS,1);
}
else if(i == 2)
{
if(Get_Display_Status())
{
Display_Up_Contend(FAN);
}
state_change_report(OPCODE_GENERAL_REPORT_STATUS,3);
}
}
}
}
......@@ -1438,11 +1505,11 @@ void Zigbee_Uart_Error_Handle (void)
{
sUartDetect.zigbee_uart_ms = 0;
sUartDetect.zigbee_uart_s ++;
if (sUartDetect.zigbee_uart_s >= 33)
if (sUartDetect.zigbee_uart_s >= 105)
{
sUartDetect.zigbee_uart_s = 0;
sUartDetect.zigbee_uart_flag = 0;
Set_Error_Code(2); //ZIGBEE串口故障
sUartDetect.zigbee_uart_display_flag = 1;
}
}
}
......@@ -1529,8 +1596,6 @@ void TMR0_IRQHandler(void)
Setup_Mode_Handle(); //配置模式10s超时
Zigbee_Uart_Error_Handle(); //zigbee串口故障检测
//kLedModuleActionDetectCallback(); //zigbee指示灯操作
}
/*********************************************************************/
void zero_check_init(void)
......@@ -1823,23 +1888,28 @@ void transparent_data_analyze(PROTOCOL_DEAL recv_data)
switch(recv_data.Opcode)
{
/********************************************Common CMD Handler*************************************************************/
case OPCODE_GENERAL_MODEID_REPORT: //modeid 推送
{
Set_CMD_Handler(device_type,OPCODE_GENERAL_MODEID_REPORT,recv_data.ARG,recv_data.ARG_len);
memset(arg_data,0,sizeof(arg_data));
arg_data[0] = 0X00;
ack_dev_info(recv_data,arg_data,1);
break;
}
case _OPCODE_QUERY_NET_STATE: //网络状态查询
{
Oled_Display_Info.net_work_flage = recv_data.ARG[1];
if(!kNetIndicatorIsBlinking()) //是否在闪烁
if( (kNetIndicatorIsBlinking() ) &&(((recv_data.ARG[1] == IN_LINE)&&(Oled_Display_Info.net_work_flage ==OUT_LINE ) )||
((recv_data.ARG[1] == OUT_LINE)&&(Oled_Display_Info.net_work_flage ==IN_LINE ) ))) //是否在闪烁
{
memset(arg_data,0,sizeof(arg_data));
network_state_machine(recv_data.ARG[1]);
}
Reset_Uart_Detect_Flag();
if((Oled_Display_Info.screen_page == 1)&&(Oled_Display_Info.Air_Device.error == 2)) //通讯故障
{
Oled_Display_Info.Air_Device.error = 0;
if( Get_Display_Status())
{
LCDShowTemp_state_t.LCD_place = DELAY_OFF_TIME_DISPLAY;
LCDShowTemp_state_t.LCD_display_count = 0;
LCDShowTemp_state_t.LCD_state = OFF;
LcdShowCTR(LCDShowTemp_state_t);
}
state_change_report(OPCODE_GENERAL_REPORT_STATUS,1);
}
break;
}
case OPCODE_GENERAL_BING_DEVICE: //绑定设备
......@@ -2274,10 +2344,6 @@ void Send_Device_Data(u8 channel_id,u16 opcode ,u8 *arg,u8 len)
***********************************************************************/
static void network_state_machine(TP_uc8 recv_network_state)
{
if( ((Oled_Display_Info.screen_page == 1)&&(Oled_Display_Info.Air_Device.on_off)) ||
((Oled_Display_Info.screen_page == 2)&&(Oled_Display_Info.FLOOR_Device.on_off))||
((Oled_Display_Info.screen_page == 3)&&(Oled_Display_Info.FAN_Device.on_off )) )
{
switch(recv_network_state)
{
case OUT_LINE: //未入网
......@@ -2302,7 +2368,6 @@ static void network_state_machine(TP_uc8 recv_network_state)
default :
break;
}
}
}
u8 Get_Channel_Id(u8 device_type)
{
......
......@@ -7,11 +7,11 @@
extern Lcd_Status_Info_t LCDShowTemp_state_t;
#if DEVICE_TYPE_AIR_CONDITION
OLED_ALL_DSD Oled_Display_Info = { 1,0,1,0,0,0x11,0,0,0,0,{0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},{1,0,0,0,260,0,3,0,5,0,2,1,0,0,3000,0,0xff,0xff},{1,0,0,0,260,0,2,0,DEV_TYPE,0,0,0},{1,0,0,0,0,2,1,0,0,0,3000,0}};
OLED_ALL_DSD Oled_Display_Info = { 1,0,1,0,0,0x11,0,0,0,0,{0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},{1,0,0,0,260,0,3,0,5,0,2,1,0,0,3000,0,0xff,0xff,0},{1,0,0,0,260,0,2,0,DEV_TYPE,0,0,0},{1,0,0,0,0,2,1,0,0,0,3000,0}};
#elif DEVICE_TYPE_FLOOR_HEATING
OLED_ALL_DSD Oled_Display_Info = { 2,0,2,0,0,0x11,0,0,0,0,{0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},{1,0,0,0,260,0,3,0,5,0,2,1,0,0,3000,0,0xff,0xff},{1,0,0,0,260,0,2,0,DEV_TYPE,0,0,0},{1,0,0,0,0,2,1,0,0,0,3000,0}};
OLED_ALL_DSD Oled_Display_Info = { 2,0,2,0,0,0x11,0,0,0,0,{0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},{1,0,0,0,260,0,3,0,5,0,2,1,0,0,3000,0,0xff,0xff,0},{1,0,0,0,260,0,2,0,DEV_TYPE,0,0,0},{1,0,0,0,0,2,1,0,0,0,3000,0}};
#elif DEVICE_TYPE_FAN
OLED_ALL_DSD Oled_Display_Info = { 3,0,3,0,0,0x11,0,0,0,0,{0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},{1,0,0,0,260,0,3,0,5,0,2,1,0,0,3000,0,0xff,0xff},{1,0,0,0,260,0,2,0,0,0,0,0},{1,0,0,0,0,2,1,0,0,0,3000,0}};
OLED_ALL_DSD Oled_Display_Info = { 3,0,3,0,0,0x12,0,0,0,0,{0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},{1,0,0,0,260,0,3,0,5,0,2,1,0,0,3000,0,0xff,0xff,0},{1,0,0,0,260,0,2,0,0,0,0,0},{1,0,0,0,0,2,1,0,0,0,3000,0}};
#endif
Key_Operation_Status gKey_Press_Info = {0};
// .device_type = 1, //AIR_CONDITION
......@@ -531,7 +531,7 @@ void Display_Up_Contend(u8 device_type)
{
display_error(Oled_Display_Info.FAN_Device.error);
}
else if(Oled_Display_Info.is_dispaly_cur_temp)
else if((Oled_Display_Info.is_dispaly_cur_temp))
{
Display_Current_Temper(Oled_Display_Info.FAN_Device.real_temperature);
}
......@@ -558,11 +558,14 @@ void Fan_Oled_Display()
/********************************************
显示当前风速
*********************************************/
if(!IsLcdEnterScreenSave())
display_set_temp(1,Oled_Display_Info.FAN_Device.wind_speed,1);
else
display_set_temp(0,Oled_Display_Info.FAN_Device.real_temperature,0); //显示当前温度
/********************************************
显示延时关机、错误码、当前温度字符
*********************************************/
if(!IsLcdEnterScreenSave())
Display_Up_Contend(FAN);
}
void Floor_Heating_Oled_Display()
......@@ -591,6 +594,7 @@ void Floor_Heating_Oled_Display()
/********************************************
显示延时关机、错误码、当前温度字符
*********************************************/
if(!IsLcdEnterScreenSave())
Display_Up_Contend(FLOOR_HEATING);
}
void Air_Oled_Display(void)
......@@ -619,7 +623,24 @@ void Air_Oled_Display(void)
/********************************************
显示延时关机、错误码、当前温度字符
*********************************************/
if(!IsLcdEnterScreenSave())
Display_Up_Contend(AIR_CONDITION);
/********************************************
显示主从模式
*********************************************/
#if (DEV_TYPE == 0) &&(DEVICE_TYPE_AIR_CONDITION ==1)
if( (Oled_Display_Info.Air_Device.power_off_time == 0) &&(Oled_Display_Info.Air_Device.air_master_slavery_mode))
{
//显示H图标
if(!IsLcdEnterScreenSave())
{
LCDShowTemp_state_t.LCD_place = H_CHAR_DISPLAY;
LCDShowTemp_state_t.LCD_state = ON;
LcdShowCTR(LCDShowTemp_state_t);
}
}
#endif
}
/*************************************************
开机显示选项
......@@ -1330,15 +1351,8 @@ void Set_CMD_Handler(u8 device_type,u16 opcode,u8 *arg,u8 arg_len)
if((Oled_Display_Info.Air_Device.on_off)&&(Oled_Display_Info.Air_Device.system_type !=SYSTEM_MODE_AIR))
{
display_set_temp(0,set_temper,0);
sKey_Operation[0].set_temper_temp = set_temper;
Oled_Display_Info.Air_Device.set_temperature = set_temper;
arg[0] = 0;
if( (sKey_Operation[0].set_temper_temp /10) == (Oled_Display_Info.Air_Device.set_temperature/10)) //26.5调整到26度时,不管空调的反馈,直接上报
{
Oled_Display_Info.Air_Device.set_temperature = sKey_Operation[0].set_temper_temp;
sKey_Operation[0].set_temper_temp = 0xff;
}
else
Oled_Display_Info.Air_Device.set_temperature = sKey_Operation[0].set_temper_temp;
#if (DEV_TYPE == 0) &&(DEVICE_TYPE_AIR_CONDITION ==1)
delay_control_set_temp_start();
......@@ -1951,7 +1965,7 @@ void Set_CMD_Handler(u8 device_type,u16 opcode,u8 *arg,u8 arg_len)
}
}
//进入本地配置界面
Local_Config_Operation local_config_operate = {0,0,0,0,2,{3,100},0,0};
Local_Config_Operation local_config_operate = {0,0,0,0,2,{3,100},0,0,0};
/************************************************************
设置模式10秒计时
......@@ -1970,7 +1984,7 @@ void Setup_Mode_Handle (void)
local_config_operate.config_time_s = 0;
//退出配置模式
local_config_operate.enter_config_mode = 0;
Control_OnOff_handler(Oled_Display_Info.device_type,0); //显示关
local_config_operate.config_timeout_display = 1;
}
}
}
......
......@@ -42,6 +42,7 @@ static TP_u8 uart_recive_write_buff(TP_uc8 *data,TP_uc16 len)
{
//printf("data deal too slow");
static_transprent_buff.Download_serial_num = rem_serial;
static_transprent_buff.Buff_send_serial_num = rem_serial;
return 0;
}
}
......
......@@ -16,26 +16,7 @@
#include "control_comm.h"
#include "hardware_init.h"
#include "BL55072A.h"
//void SYS_Init(void)
//{
// /* Unlock protected registers */
// SYS_UnlockReg();
// // Enable UART clock
// CLK_EnableModuleClock(UART0_MODULE);
// /* Update System Core Clock */
// /* User can use SystemCoreClockUpdate() to calculate SystemCoreClock and cyclesPerUs automatically. */
// SystemCoreClockUpdate();
// /* Set P1 multi-function pins for UART RXD, TXD */
// SYS->P1_MFP = SYS_MFP_P12_UART0_RXD | SYS_MFP_P13_UART0_TXD;
// /* Lock protected registers */
// SYS_LockReg();
//}
#include "CC2530_transparent_analyze.h"
Lcd_Status_Info_t LCDShowTemp_state_t = {0X00,0,ON,0X14,10};
......@@ -69,7 +50,6 @@ int main()
hardware_init();
zero_check_init();
printf("\n\nCPU @ %dHz\n", SystemCoreClock);
while(1)
{
task_process();
......
......@@ -570,17 +570,39 @@ void CLK_DisablePLL(void)
* @details Use the SysTick to generate the delay time and the UNIT is in us.
* The SysTick clock source is from HCLK, i.e the same as system core clock.
*/
//void CLK_SysTickDelay(uint32_t us)
//{
// SysTick->LOAD = us * CyclesPerUs;
// SysTick->VAL = (0x00);
// SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_ENABLE_Msk;
// /* Waiting for down-count to zero */
// while((SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) == 0);
// SysTick->CTRL = 0;
//}
void CLK_SysTickDelay(uint32_t us)
{
__IO uint32_t j= 2;
SysTick->LOAD = us * CyclesPerUs;
SysTick->VAL = (0x00);
SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_ENABLE_Msk;
if(us ==1)
j = j+ us;
else if(us == 5000)
j = 3500+us;
else
j = 5+us;
/* Waiting for down-count to zero */
while((SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) == 0);
//while( (SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) == 0)
while( ((SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) == 0)&&(--j)); //lmm add
SysTick->CTRL = 0;
}
//void CLK_SysTickDelay(uint32_t us)
//{
// __IO uint32_t i,j;
// for(i=0;i<us;i++);
// for(j=0;j<6;j++);
//}
/**
* @brief This function check selected clock source status
* @param[in] u32ClkMask is selected clock source. Including
......
......@@ -62,13 +62,13 @@ void stackDump(uint32_t stack[])
void Hard_Fault_Handler(uint32_t stack[])
{
printf("In Hard Fault Handler\n");
//printf("In Hard Fault Handler\n");
stackDump(stack);
//Chip Reset
//SYS_UnlockReg();
//SYS->IPRSTC1 |= SYS_IPRSTC1_CHIP_RST_Msk;
SYS_UnlockReg();
SYS_ResetChip();
while(1);
}
......
......@@ -211,117 +211,117 @@ uint32_t UART_Read(UART_T* uart, uint8_t *pu8RxBuf, uint32_t u32ReadBytes)
}
/**
* @brief This function use to config UART line setting.
*
* @param[in] uart The base address of UART module.
* @param[in] u32baudrate The register value of baudrate of UART module.
* if u32baudrate = 0, UART baudrate will not change.
* @param[in] u32data_width The data length of UART module.
* @param[in] u32parity The parity setting (odd/even/none) of UART module.
* @param[in] u32stop_bits The stop bit length (1/1.5 bit) of UART module.
*
* @return None
*/
void UART_SetLine_Config(UART_T* uart, uint32_t u32baudrate, uint32_t u32data_width, uint32_t u32parity, uint32_t u32stop_bits)
{
uint8_t u8UartClkSrcSel;
uint32_t u32Clk = 0;
uint32_t u32ClkDiv = 0;
uint32_t u32Baud_Div = 0;
u8UartClkSrcSel = (CLK->CLKSEL1 & CLK_CLKSEL1_UARTSEL_Msk) >> CLK_CLKSEL1_UARTSEL_Pos;
if(u8UartClkSrcSel == 0)
u32Clk = __XTAL;
else if(u8UartClkSrcSel == 1)
u32Clk = CLK_GetPLLClockFreq();
else if(u8UartClkSrcSel >= 2)
u32Clk = __HSI;
u32ClkDiv = ( (CLK->CLKDIV & CLK_CLKDIV_UARTDIV_Msk) >> CLK_CLKDIV_UARTDIV_Pos );
u32Clk = u32Clk/(u32ClkDiv + 1);
if(u32baudrate != 0) {
u32Baud_Div = UART_BAUD_MODE2_DIVIDER(u32Clk, u32baudrate);
if(u32Baud_Div > 0xFFFF)
uart->BAUD = (UART_BAUD_MODE0 | UART_BAUD_MODE0_DIVIDER(u32Clk, u32baudrate));
else
uart->BAUD = (UART_BAUD_MODE2 | u32Baud_Div);
}
uart->LINE = u32data_width | u32parity | u32stop_bits;
}
/**
* @brief This function use to set Rx timeout count.
*
* @param[in] uart The base address of UART module.
* @param[in] u32TOC Rx timeout counter.
*
* @return None
*/
void UART_SetTimeoutCnt(UART_T* uart, uint32_t u32TOC)
{
uart->TOUT = (uart->TOUT & ~UART_TOUT_TOIC_Msk)| (u32TOC);
uart->INTEN |= UART_INTEN_TOCNTEN_Msk;
}
/**
* @brief The function is used to configure IrDA relative settings. It consists of TX or RX mode and baudrate.
*
* @param[in] uart The base address of UART module.
* @param[in] u32Buadrate The baudrate of UART module.
* @param[in] u32Direction The direction(transmit:1/receive:0) of UART module in IrDA mode.
*
* @return None
*/
void UART_SelectIrDAMode(UART_T* uart, uint32_t u32Buadrate, uint32_t u32Direction)
{
uint8_t u8UartClkSrcSel;
uint32_t u32Clk = 0;
uint32_t u32ClkDiv = 0;
u8UartClkSrcSel = (CLK->CLKSEL1 & CLK_CLKSEL1_UARTSEL_Msk) >> CLK_CLKSEL1_UARTSEL_Pos;
if(u8UartClkSrcSel == 0)
u32Clk = __XTAL;
else if(u8UartClkSrcSel == 1)
u32Clk = CLK_GetPLLClockFreq();
else if(u8UartClkSrcSel >= 2)
u32Clk = __HSI;
u32ClkDiv = ( (CLK->CLKDIV & CLK_CLKDIV_UARTDIV_Msk) >> CLK_CLKDIV_UARTDIV_Pos );
u32Clk = u32Clk/(u32ClkDiv + 1);
uart->BAUD = UART_BAUD_MODE0 | UART_BAUD_MODE0_DIVIDER(u32Clk, u32Buadrate);
uart->IRDA &= ~UART_IRDA_TXINV_Msk;
uart->IRDA |= UART_IRDA_RXINV_Msk;
uart->IRDA = u32Direction ? uart->IRDA | UART_IRDA_TXEN_Msk : uart->IRDA &~ UART_IRDA_TXEN_Msk;
uart->FUNSEL = (0x2 << UART_FUNSEL_FUN_SEL_Pos);
}
/**
* @brief The function is used to set RS485 relative setting.
*
* @param[in] uart The base address of UART module.
* @param[in] u32Mode The operation mode(NMM/AUD/AAD).
* @param[in] u32Addr The RS485 address.
*
* @return None
*/
void UART_SelectRS485Mode(UART_T* uart, uint32_t u32Mode, uint32_t u32Addr)
{
uart->FUNSEL = UART_FUNC_SEL_RS485;
uart->ALTCTL = 0;
uart->ALTCTL |= u32Mode | (u32Addr << UART_ALTCTL_ADDRMV_Pos);
}
//lmm modified for decrease code size
///**
// * @brief This function use to config UART line setting.
// *
// * @param[in] uart The base address of UART module.
// * @param[in] u32baudrate The register value of baudrate of UART module.
// * if u32baudrate = 0, UART baudrate will not change.
// * @param[in] u32data_width The data length of UART module.
// * @param[in] u32parity The parity setting (odd/even/none) of UART module.
// * @param[in] u32stop_bits The stop bit length (1/1.5 bit) of UART module.
// *
// * @return None
// */
//void UART_SetLine_Config(UART_T* uart, uint32_t u32baudrate, uint32_t u32data_width, uint32_t u32parity, uint32_t u32stop_bits)
//{
// uint8_t u8UartClkSrcSel;
// uint32_t u32Clk = 0;
// uint32_t u32ClkDiv = 0;
// uint32_t u32Baud_Div = 0;
// u8UartClkSrcSel = (CLK->CLKSEL1 & CLK_CLKSEL1_UARTSEL_Msk) >> CLK_CLKSEL1_UARTSEL_Pos;
// if(u8UartClkSrcSel == 0)
// u32Clk = __XTAL;
// else if(u8UartClkSrcSel == 1)
// u32Clk = CLK_GetPLLClockFreq();
// else if(u8UartClkSrcSel >= 2)
// u32Clk = __HSI;
// u32ClkDiv = ( (CLK->CLKDIV & CLK_CLKDIV_UARTDIV_Msk) >> CLK_CLKDIV_UARTDIV_Pos );
// u32Clk = u32Clk/(u32ClkDiv + 1);
// if(u32baudrate != 0) {
// u32Baud_Div = UART_BAUD_MODE2_DIVIDER(u32Clk, u32baudrate);
// if(u32Baud_Div > 0xFFFF)
// uart->BAUD = (UART_BAUD_MODE0 | UART_BAUD_MODE0_DIVIDER(u32Clk, u32baudrate));
// else
// uart->BAUD = (UART_BAUD_MODE2 | u32Baud_Div);
// }
// uart->LINE = u32data_width | u32parity | u32stop_bits;
//}
///**
// * @brief This function use to set Rx timeout count.
// *
// * @param[in] uart The base address of UART module.
// * @param[in] u32TOC Rx timeout counter.
// *
// * @return None
// */
//void UART_SetTimeoutCnt(UART_T* uart, uint32_t u32TOC)
//{
// uart->TOUT = (uart->TOUT & ~UART_TOUT_TOIC_Msk)| (u32TOC);
// uart->INTEN |= UART_INTEN_TOCNTEN_Msk;
//}
///**
// * @brief The function is used to configure IrDA relative settings. It consists of TX or RX mode and baudrate.
// *
// * @param[in] uart The base address of UART module.
// * @param[in] u32Buadrate The baudrate of UART module.
// * @param[in] u32Direction The direction(transmit:1/receive:0) of UART module in IrDA mode.
// *
// * @return None
// */
//void UART_SelectIrDAMode(UART_T* uart, uint32_t u32Buadrate, uint32_t u32Direction)
//{
// uint8_t u8UartClkSrcSel;
// uint32_t u32Clk = 0;
// uint32_t u32ClkDiv = 0;
// u8UartClkSrcSel = (CLK->CLKSEL1 & CLK_CLKSEL1_UARTSEL_Msk) >> CLK_CLKSEL1_UARTSEL_Pos;
// if(u8UartClkSrcSel == 0)
// u32Clk = __XTAL;
// else if(u8UartClkSrcSel == 1)
// u32Clk = CLK_GetPLLClockFreq();
// else if(u8UartClkSrcSel >= 2)
// u32Clk = __HSI;
// u32ClkDiv = ( (CLK->CLKDIV & CLK_CLKDIV_UARTDIV_Msk) >> CLK_CLKDIV_UARTDIV_Pos );
// u32Clk = u32Clk/(u32ClkDiv + 1);
// uart->BAUD = UART_BAUD_MODE0 | UART_BAUD_MODE0_DIVIDER(u32Clk, u32Buadrate);
// uart->IRDA &= ~UART_IRDA_TXINV_Msk;
// uart->IRDA |= UART_IRDA_RXINV_Msk;
// uart->IRDA = u32Direction ? uart->IRDA | UART_IRDA_TXEN_Msk : uart->IRDA &~ UART_IRDA_TXEN_Msk;
// uart->FUNSEL = (0x2 << UART_FUNSEL_FUN_SEL_Pos);
//}
///**
// * @brief The function is used to set RS485 relative setting.
// *
// * @param[in] uart The base address of UART module.
// * @param[in] u32Mode The operation mode(NMM/AUD/AAD).
// * @param[in] u32Addr The RS485 address.
// *
// * @return None
// */
//void UART_SelectRS485Mode(UART_T* uart, uint32_t u32Mode, uint32_t u32Addr)
//{
// uart->FUNSEL = UART_FUNC_SEL_RS485;
// uart->ALTCTL = 0;
// uart->ALTCTL |= u32Mode | (u32Addr << UART_ALTCTL_ADDRMV_Pos);
//}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment