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 @@ ...@@ -101,7 +101,7 @@
<sRunDeb>0</sRunDeb> <sRunDeb>0</sRunDeb>
<sLrtime>1</sLrtime> <sLrtime>1</sLrtime>
<bEvRecOn>1</bEvRecOn> <bEvRecOn>1</bEvRecOn>
<nTsel>19</nTsel> <nTsel>7</nTsel>
<sDll></sDll> <sDll></sDll>
<sDllPa></sDllPa> <sDllPa></sDllPa>
<sDlgDll></sDlgDll> <sDlgDll></sDlgDll>
...@@ -112,7 +112,7 @@ ...@@ -112,7 +112,7 @@
<tDlgDll></tDlgDll> <tDlgDll></tDlgDll>
<tDlgPa></tDlgPa> <tDlgPa></tDlgPa>
<tIfile></tIfile> <tIfile></tIfile>
<pMon>Bin\Nu_Link.dll</pMon> <pMon>NULink\Nu_Link.dll</pMon>
</DebugOpt> </DebugOpt>
<TargetDriverDllRegistry> <TargetDriverDllRegistry>
<SetRegEntry> <SetRegEntry>
...@@ -140,89 +140,89 @@ ...@@ -140,89 +140,89 @@
<Bp> <Bp>
<Number>0</Number> <Number>0</Number>
<Type>0</Type> <Type>0</Type>
<LineNumber>293</LineNumber> <LineNumber>65</LineNumber>
<EnabledFlag>1</EnabledFlag> <EnabledFlag>1</EnabledFlag>
<Address>212</Address> <Address>5624</Address>
<ByteObject>0</ByteObject> <ByteObject>0</ByteObject>
<HtxType>0</HtxType> <HtxType>0</HtxType>
<ManyObjects>0</ManyObjects> <ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject> <SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess> <BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount> <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> <ExecCommand></ExecCommand>
<Expression>\\AllToOneThermostatPannel\../Library/StdDriver/src/retarget.c\293</Expression> <Expression>\\AllToOneThermostatPannel\../Library/StdDriver/src/retarget.c\65</Expression>
</Bp> </Bp>
<Bp> <Bp>
<Number>1</Number> <Number>1</Number>
<Type>0</Type> <Type>0</Type>
<LineNumber>109</LineNumber> <LineNumber>1218</LineNumber>
<EnabledFlag>1</EnabledFlag> <EnabledFlag>1</EnabledFlag>
<Address>27080</Address> <Address>4294</Address>
<ByteObject>0</ByteObject> <ByteObject>0</ByteObject>
<HtxType>0</HtxType> <HtxType>0</HtxType>
<ManyObjects>0</ManyObjects> <ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject> <SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess> <BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount> <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> <ExecCommand></ExecCommand>
<Expression>\\AllToOneThermostatPannel\User/src/mfg_factort.c\109</Expression> <Expression>\\AllToOneThermostatPannel\User/src/display_common.c\1218</Expression>
</Bp> </Bp>
<Bp> <Bp>
<Number>2</Number> <Number>2</Number>
<Type>0</Type> <Type>0</Type>
<LineNumber>105</LineNumber> <LineNumber>303</LineNumber>
<EnabledFlag>1</EnabledFlag> <EnabledFlag>1</EnabledFlag>
<Address>27076</Address> <Address>232</Address>
<ByteObject>0</ByteObject> <ByteObject>0</ByteObject>
<HtxType>0</HtxType> <HtxType>0</HtxType>
<ManyObjects>0</ManyObjects> <ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject> <SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess> <BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount> <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> <ExecCommand></ExecCommand>
<Expression>\\AllToOneThermostatPannel\User/src/mfg_factort.c\105</Expression> <Expression>\\AllToOneThermostatPannel\../Library/StdDriver/src/retarget.c\303</Expression>
</Bp> </Bp>
<Bp> <Bp>
<Number>3</Number> <Number>3</Number>
<Type>0</Type> <Type>0</Type>
<LineNumber>580</LineNumber> <LineNumber>110</LineNumber>
<EnabledFlag>1</EnabledFlag> <EnabledFlag>1</EnabledFlag>
<Address>13540</Address> <Address>26502</Address>
<ByteObject>0</ByteObject> <ByteObject>0</ByteObject>
<HtxType>0</HtxType> <HtxType>0</HtxType>
<ManyObjects>0</ManyObjects> <ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject> <SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess> <BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount> <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> <ExecCommand></ExecCommand>
<Expression>\\AllToOneThermostatPannel\User/src/control_comm.c\580</Expression> <Expression>\\AllToOneThermostatPannel\User/src/mfg_factort.c\110</Expression>
</Bp> </Bp>
<Bp> <Bp>
<Number>4</Number> <Number>4</Number>
<Type>0</Type> <Type>0</Type>
<LineNumber>690</LineNumber> <LineNumber>53</LineNumber>
<EnabledFlag>1</EnabledFlag> <EnabledFlag>1</EnabledFlag>
<Address>24284</Address> <Address>24644</Address>
<ByteObject>0</ByteObject> <ByteObject>0</ByteObject>
<HtxType>0</HtxType> <HtxType>0</HtxType>
<ManyObjects>0</ManyObjects> <ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject> <SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess> <BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount> <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> <ExecCommand></ExecCommand>
<Expression>\\AllToOneThermostatPannel\User/src/control_comm.c\690</Expression> <Expression>\\AllToOneThermostatPannel\main.c\53</Expression>
</Bp> </Bp>
</Breakpoint> </Breakpoint>
<WatchWindow1> <WatchWindow1>
<Ww> <Ww>
<count>0</count> <count>0</count>
<WinNumber>1</WinNumber> <WinNumber>1</WinNumber>
<ItemText>Device_status</ItemText> <ItemText>temp1</ItemText>
</Ww> </Ww>
<Ww> <Ww>
<count>1</count> <count>1</count>
...@@ -259,6 +259,31 @@ ...@@ -259,6 +259,31 @@
<WinNumber>1</WinNumber> <WinNumber>1</WinNumber>
<ItemText>static_transprent_buff_mfg</ItemText> <ItemText>static_transprent_buff_mfg</ItemText>
</Ww> </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> </WatchWindow1>
<WatchWindow2> <WatchWindow2>
<Ww> <Ww>
...@@ -315,7 +340,7 @@ ...@@ -315,7 +340,7 @@
<MemoryWindow1> <MemoryWindow1>
<Mm> <Mm>
<WinNumber>1</WinNumber> <WinNumber>1</WinNumber>
<SubType>0</SubType> <SubType>2</SubType>
<ItemText>0x200006BD</ItemText> <ItemText>0x200006BD</ItemText>
<AccSizeX>0</AccSizeX> <AccSizeX>0</AccSizeX>
</Mm> </Mm>
...@@ -371,7 +396,7 @@ ...@@ -371,7 +396,7 @@
<Group> <Group>
<GroupName>CMSIS</GroupName> <GroupName>CMSIS</GroupName>
<tvExp>1</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel> <cbSel>0</cbSel>
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
...@@ -403,7 +428,7 @@ ...@@ -403,7 +428,7 @@
<Group> <Group>
<GroupName>Library</GroupName> <GroupName>Library</GroupName>
<tvExp>0</tvExp> <tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel> <cbSel>0</cbSel>
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
......
...@@ -148,7 +148,7 @@ ...@@ -148,7 +148,7 @@
<RestoreSysVw>1</RestoreSysVw> <RestoreSysVw>1</RestoreSysVw>
</Target> </Target>
<RunDebugAfterBuild>0</RunDebugAfterBuild> <RunDebugAfterBuild>0</RunDebugAfterBuild>
<TargetSelection>19</TargetSelection> <TargetSelection>7</TargetSelection>
<SimDlls> <SimDlls>
<CpuDll></CpuDll> <CpuDll></CpuDll>
<CpuDllArguments></CpuDllArguments> <CpuDllArguments></CpuDllArguments>
...@@ -162,7 +162,7 @@ ...@@ -162,7 +162,7 @@
<PeripheralDll></PeripheralDll> <PeripheralDll></PeripheralDll>
<PeripheralDllArguments></PeripheralDllArguments> <PeripheralDllArguments></PeripheralDllArguments>
<InitializationFile></InitializationFile> <InitializationFile></InitializationFile>
<Driver>Bin\Nu_Link.dll</Driver> <Driver>NULink\Nu_Link.dll</Driver>
</TargetDlls> </TargetDlls>
</DebugOption> </DebugOption>
<Utilities> <Utilities>
......
[Version] [Version]
Nu_LinkVersion=V5.14 Nu_LinkVersion=V5.14
[Process] [Process]
ProcessID=0x00003f04 ProcessID=0x0000e77c
ProcessCreationTime_L=0x72edddaf ProcessCreationTime_L=0xcec60db7
ProcessCreationTime_H=0x01d6cd03 ProcessCreationTime_H=0x01d6d90f
NuLinkID=0x18101887 NuLinkID=0x18101887
NuLinkID0=0x18101887 NuLinkID0=0x18101887
NuLinkIDs_Count=0x00000001 NuLinkIDs_Count=0x00000001
......
...@@ -65,8 +65,8 @@ typedef enum {TP_ERROR = 0, TP_SUCCESS = !TP_ERROR} TP_ErrorStatus; ...@@ -65,8 +65,8 @@ typedef enum {TP_ERROR = 0, TP_SUCCESS = !TP_ERROR} TP_ErrorStatus;
#define SOF_HIGH_BYTE_DEF 0XAA #define SOF_HIGH_BYTE_DEF 0XAA
#define SOF_LOW_BYTE_DEF 0X55 #define SOF_LOW_BYTE_DEF 0X55
#define USART_RECIVE_LEN_DEF 40 //串口最多一次接受的数据量 #define USART_RECIVE_LEN_DEF 48 //串口最多一次接受的数据量
#define USART_RECIVE_DEPTH 3 //缓存的深度 #define USART_RECIVE_DEPTH 12 //缓存的深度
//透传数据接受最大间隔时间,超时未接收到数据,停止一串数据接收 //透传数据接受最大间隔时间,超时未接收到数据,停止一串数据接收
#define DEF_TRANSPARENT_MAXIMUM_INTERVAL 100 //(ms) #define DEF_TRANSPARENT_MAXIMUM_INTERVAL 100 //(ms)
......
...@@ -43,34 +43,18 @@ typedef uint16_t u16; ...@@ -43,34 +43,18 @@ typedef uint16_t u16;
typedef uint8_t u8; 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 typedef struct
{ {
volatile u32 operate_delay_off_ms; volatile u32 operate_delay_off_ms;
volatile u32 operate_delay_off_s; volatile u32 operate_delay_off_s;
volatile u32 operate_delay_off_min; volatile u32 operate_delay_off_min;
volatile u32 operate_delay_off_h; volatile u32 operate_delay_off_h;
u8 operate_delay_off_display_flag;
}Filter_Wash_Calc; }Filter_Wash_Calc;
typedef struct KEY_OPERATE typedef struct KEY_OPERATE
{ {
u8 operate_delay_off_status; //延时关机操作期间标志位判断 u8 operate_delay_off_status; //延时关机操作期间标志位判断
u8 operate_delay_off_display_flag;
volatile u32 operate_delay_off_ms; volatile u32 operate_delay_off_ms;
volatile u32 operate_delay_off_s; volatile u32 operate_delay_off_s;
volatile u32 operate_delay_off_min; volatile u32 operate_delay_off_min;
......
...@@ -43,12 +43,14 @@ typedef struct Power_Off_Time ...@@ -43,12 +43,14 @@ typedef struct Power_Off_Time
typedef struct typedef struct
{ {
u8 blacklight_flag; u8 blacklight_flag;
u8 blacklight_display_flag;
volatile u32 time_blacklight_ms; volatile u32 time_blacklight_ms;
volatile u16 time_blacklight_s; volatile u16 time_blacklight_s;
}BACKLIGHT_CONTROL; }BACKLIGHT_CONTROL;
typedef struct typedef struct
{ {
u8 zigbee_uart_flag; u8 zigbee_uart_flag;
u8 zigbee_uart_display_flag;
volatile u32 zigbee_uart_ms; volatile u32 zigbee_uart_ms;
volatile u16 zigbee_uart_s; volatile u16 zigbee_uart_s;
}ZIGBEE_UART_CONTROL; }ZIGBEE_UART_CONTROL;
......
...@@ -54,8 +54,9 @@ typedef struct ...@@ -54,8 +54,9 @@ typedef struct
u16 screen_save_time; //屏保时间 00 代表30 u16 screen_save_time; //屏保时间 00 代表30
u16 filter_wash_time; //滤网清洗时间 3000 u16 filter_wash_time; //滤网清洗时间 3000
u8 no_disturb_mode; //勿扰模式 0 u8 no_disturb_mode; //勿扰模式 0
u8 air_product_id; u8 air_product_id; //空调品牌
u8 air_type; u8 air_type ; //空调类型
u8 air_master_slavery_mode; //主从模式
}OLED_AIR_DSD; }OLED_AIR_DSD;
typedef struct typedef struct
{ {
...@@ -131,6 +132,7 @@ typedef struct{ ...@@ -131,6 +132,7 @@ typedef struct{
u8 support_function_list[6]; //1,风机盘管管制设置 2,温度校准 3,是否显示当前房间温度设置,4, 超时进入屏保时间设置 10 恢复出厂设置 u8 support_function_list[6]; //1,风机盘管管制设置 2,温度校准 3,是否显示当前房间温度设置,4, 超时进入屏保时间设置 10 恢复出厂设置
volatile u32 config_time_ms; volatile u32 config_time_ms;
volatile u8 config_time_s; volatile u8 config_time_s;
u8 config_timeout_display;
}Local_Config_Operation; }Local_Config_Operation;
typedef enum { typedef enum {
LOCAL_FUNC_FAN_PANEL_SETTING = 1, LOCAL_FUNC_FAN_PANEL_SETTING = 1,
......
...@@ -20,8 +20,8 @@ ...@@ -20,8 +20,8 @@
#define SOF_HIGH_BYTE_DEF 0XAA #define SOF_HIGH_BYTE_DEF 0XAA
#define SOF_LOW_BYTE_DEF 0X55 #define SOF_LOW_BYTE_DEF 0X55
#define MAX_USART_RECIVE_LEN 56 //串口最多一次接受的数据量 #define MAX_USART_RECIVE_LEN 48 //串口最多一次接受的数据量
#define USART_RECIVE_DEPTHS 3 //缓存的深度 #define USART_RECIVE_DEPTHS 10 //缓存的深度
......
...@@ -50,7 +50,7 @@ static void (*non_permeable_opcode_analysis)(PROTOCOL_DEAL protocol_data); ...@@ -50,7 +50,7 @@ static void (*non_permeable_opcode_analysis)(PROTOCOL_DEAL protocol_data);
static void (*transparent_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 TP_ErrorStatus transparent_protocol_analysis(TP_uc8 *data,TP_uc8 len);
static u8 Record_Last_Seq = 0xFF;
/************************************************************************************************************** /**************************************************************************************************************
全局变量,用于 transparent_protocol_send 全局变量,用于 transparent_protocol_send
***************************************************************************************************************/ ***************************************************************************************************************/
...@@ -435,6 +435,7 @@ static TP_u8 Usart_recive_write_buff(TP_uc8 *data,TP_uc16 len) ...@@ -435,6 +435,7 @@ static TP_u8 Usart_recive_write_buff(TP_uc8 *data,TP_uc16 len)
{ {
//printf("data deal too slow"); //printf("data deal too slow");
static_transprent_buff.Download_serial_num = rem_serial; static_transprent_buff.Download_serial_num = rem_serial;
static_transprent_buff.Buff_send_serial_num = rem_serial;
return 0; return 0;
} }
...@@ -456,7 +457,6 @@ static TP_u8 Usart_recive_write_buff(TP_uc8 *data,TP_uc16 len) ...@@ -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) static TP_ErrorStatus transparent_protocol_analysis(TP_uc8 *data, TP_uc8 len)
{ {
PROTOCOL_DEAL Usart_protocol_deal = {0}; PROTOCOL_DEAL Usart_protocol_deal = {0};
if((data == NULL) || (len < 5) || (len > USART_RECIVE_LEN_DEF)) if((data == NULL) || (len < 5) || (len > USART_RECIVE_LEN_DEF))
{ {
//printf("non valied msg,discard it all\r\n"); //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) ...@@ -464,17 +464,22 @@ static TP_ErrorStatus transparent_protocol_analysis(TP_uc8 *data, TP_uc8 len)
} }
Usart_protocol_deal.SEQ = *(data + 4); //记录 seq 的值 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校验 if(BYTE_MOVE(*(data + len -2),*(data + len -1)) != CreateCrc16(data+ 3,len - 5)) //CRC校验
{ //校验不对 { //校验不对
send_crc_error(Usart_protocol_deal.SEQ); send_crc_error(Usart_protocol_deal.SEQ);
return TP_ERROR; return TP_ERROR;
} }
Record_Last_Seq = Usart_protocol_deal.SEQ;
Usart_protocol_deal.Opcode = BYTE_MOVE(*(data + 7),*(data + 8)); //赋值功能码 Usart_protocol_deal.Opcode = BYTE_MOVE(*(data + 7),*(data + 8)); //赋值功能码
Usart_protocol_deal.Channel_ID = *(data + 6); Usart_protocol_deal.Channel_ID = *(data + 6);
Usart_protocol_deal.ControlField = *(data + 3); Usart_protocol_deal.ControlField = *(data + 3);
Usart_protocol_deal.ARG = (data + 9); Usart_protocol_deal.ARG = (data + 9);
Usart_protocol_deal.ARG_len = (*(data + 2) - 6); //根据协议,此处应该 data + 2 Usart_protocol_deal.ARG_len = (*(data + 2) - 6); //根据协议,此处应该 data + 2
//DEBUG_USATR1("[cc->stm]RECIVE OPCODE: %16x \r\n",Usart_protocol_deal.Opcode); //DEBUG_USATR1("[cc->stm]RECIVE OPCODE: %16x \r\n",Usart_protocol_deal.Opcode);
if((Usart_protocol_deal.ControlField & 0x80) == 0x80)//非透传的数据 if((Usart_protocol_deal.ControlField & 0x80) == 0x80)//非透传的数据
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "key.h" #include "key.h"
#include "ZH_protocol.h" #include "ZH_protocol.h"
#include "display_common.h" #include "display_common.h"
#include "BL55072A.h"
/************************************************************************************************ /************************************************************************************************
时间:2019.9.16 时间:2019.9.16
作者:吴明军 作者:吴明军
...@@ -12,112 +13,35 @@ ...@@ -12,112 +13,35 @@
参数: 传递opearoteID,productID协议的第三位,此位表示品牌编号 参数: 传递opearoteID,productID协议的第三位,此位表示品牌编号
返回值:无 返回值:无
*****************************************************************************************************/ *****************************************************************************************************/
extern Lcd_Status_Info_t LCDShowTemp_state_t;
u32 use_oprearoteID = 0xff, use_productID = 0xff;
u32 use_oprearoteID = MIDEA_OPERATE_ID, use_productID = MIDEA_PRODUCT_ID; #define SIMULATOR 0 //模拟器
#define DAIKIN 1 //品牌 :大金
#define HITACHI 2 //品牌 :日立
void transfer_opearoteID_productID(uint8_t brand) #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) Oled_Display_Info.Air_Device.air_product_id = brand;
{ Oled_Display_Info.Air_Device.air_cond_type = type;
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;
}
} }
extern KEY_OPERATE sKey_Operation[3]; extern KEY_OPERATE sKey_Operation[3];
static void air_report_process(void) static void air_report_process(void)
...@@ -125,7 +49,7 @@ static void air_report_process(void) ...@@ -125,7 +49,7 @@ static void air_report_process(void)
/*读取oprearoteID,productID*/ /*读取oprearoteID,productID*/
if(ZH_protocol_i->poll_check_receive[SWITCH] == 0xAA)//带此标志的专为读取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 else
{ {
...@@ -167,12 +91,11 @@ static void air_report_process(void) ...@@ -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) ) && if( (ZH_protocol_i->poll_check_receive[TEMPERATURE] != (Oled_Display_Info.Air_Device.set_temperature/10) ) &&
(ZH_protocol_i->poll_check_receive[TEMPERATURE] != 0xFF)) (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 = 10*ZH_protocol_i->poll_check_receive[TEMPERATURE];
Oled_Display_Info.Air_Device.set_temperature = sKey_Operation[0].set_temper_temp;
if (Oled_Display_Info.Air_Device.on_off) //开机状态 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);// 上报状态 state_change_report(OPCODE_GENERAL_REPORT_STATUS,1);// 上报状态
} }
...@@ -182,13 +105,30 @@ static void air_report_process(void) ...@@ -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)) 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]; 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) if(Oled_Display_Info.Air_Device.on_off)
Control_OnOff_handler(AIR_CONDITION,1); Control_OnOff_handler(AIR_CONDITION,1);
else else
{
BL55072A_Clear();
Control_OnOff_handler(AIR_CONDITION,0); Control_OnOff_handler(AIR_CONDITION,0);
}
state_change_report(OPCODE_GENERAL_REPORT_STATUS,1); //状态改变通知 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) void ZH_msg_deal(void)
......
...@@ -7,11 +7,11 @@ ...@@ -7,11 +7,11 @@
extern Lcd_Status_Info_t LCDShowTemp_state_t; extern Lcd_Status_Info_t LCDShowTemp_state_t;
#if DEVICE_TYPE_AIR_CONDITION #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 #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 #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 #endif
Key_Operation_Status gKey_Press_Info = {0}; Key_Operation_Status gKey_Press_Info = {0};
// .device_type = 1, //AIR_CONDITION // .device_type = 1, //AIR_CONDITION
...@@ -531,9 +531,9 @@ void Display_Up_Contend(u8 device_type) ...@@ -531,9 +531,9 @@ void Display_Up_Contend(u8 device_type)
{ {
display_error(Oled_Display_Info.FAN_Device.error); 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); Display_Current_Temper(Oled_Display_Info.FAN_Device.real_temperature);
} }
} }
} }
...@@ -558,12 +558,15 @@ void Fan_Oled_Display() ...@@ -558,12 +558,15 @@ void Fan_Oled_Display()
/******************************************** /********************************************
显示当前风速 显示当前风速
*********************************************/ *********************************************/
display_set_temp(1,Oled_Display_Info.FAN_Device.wind_speed,1); 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); //显示当前温度
/******************************************** /********************************************
显示延时关机、错误码、当前温度字符 显示延时关机、错误码、当前温度字符
*********************************************/ *********************************************/
Display_Up_Contend(FAN); if(!IsLcdEnterScreenSave())
Display_Up_Contend(FAN);
} }
void Floor_Heating_Oled_Display() void Floor_Heating_Oled_Display()
{ {
...@@ -591,7 +594,8 @@ void Floor_Heating_Oled_Display() ...@@ -591,7 +594,8 @@ void Floor_Heating_Oled_Display()
/******************************************** /********************************************
显示延时关机、错误码、当前温度字符 显示延时关机、错误码、当前温度字符
*********************************************/ *********************************************/
Display_Up_Contend(FLOOR_HEATING); if(!IsLcdEnterScreenSave())
Display_Up_Contend(FLOOR_HEATING);
} }
void Air_Oled_Display(void) void Air_Oled_Display(void)
{ {
...@@ -619,7 +623,24 @@ void Air_Oled_Display(void) ...@@ -619,7 +623,24 @@ void Air_Oled_Display(void)
/******************************************** /********************************************
显示延时关机、错误码、当前温度字符 显示延时关机、错误码、当前温度字符
*********************************************/ *********************************************/
Display_Up_Contend(AIR_CONDITION); 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,16 +1351,9 @@ void Set_CMD_Handler(u8 device_type,u16 opcode,u8 *arg,u8 arg_len) ...@@ -1330,16 +1351,9 @@ 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)) 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); 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; 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) #if (DEV_TYPE == 0) &&(DEVICE_TYPE_AIR_CONDITION ==1)
delay_control_set_temp_start(); delay_control_set_temp_start();
#else #else
...@@ -1951,7 +1965,7 @@ void Set_CMD_Handler(u8 device_type,u16 opcode,u8 *arg,u8 arg_len) ...@@ -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秒计时 设置模式10秒计时
...@@ -1970,7 +1984,7 @@ void Setup_Mode_Handle (void) ...@@ -1970,7 +1984,7 @@ void Setup_Mode_Handle (void)
local_config_operate.config_time_s = 0; local_config_operate.config_time_s = 0;
//退出配置模式 //退出配置模式
local_config_operate.enter_config_mode = 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) ...@@ -42,6 +42,7 @@ static TP_u8 uart_recive_write_buff(TP_uc8 *data,TP_uc16 len)
{ {
//printf("data deal too slow"); //printf("data deal too slow");
static_transprent_buff.Download_serial_num = rem_serial; static_transprent_buff.Download_serial_num = rem_serial;
static_transprent_buff.Buff_send_serial_num = rem_serial;
return 0; return 0;
} }
} }
......
...@@ -16,26 +16,7 @@ ...@@ -16,26 +16,7 @@
#include "control_comm.h" #include "control_comm.h"
#include "hardware_init.h" #include "hardware_init.h"
#include "BL55072A.h" #include "BL55072A.h"
//void SYS_Init(void) #include "CC2530_transparent_analyze.h"
//{
// /* 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();
//}
Lcd_Status_Info_t LCDShowTemp_state_t = {0X00,0,ON,0X14,10}; Lcd_Status_Info_t LCDShowTemp_state_t = {0X00,0,ON,0X14,10};
...@@ -69,7 +50,6 @@ int main() ...@@ -69,7 +50,6 @@ int main()
hardware_init(); hardware_init();
zero_check_init(); zero_check_init();
printf("\n\nCPU @ %dHz\n", SystemCoreClock);
while(1) while(1)
{ {
task_process(); task_process();
......
...@@ -570,17 +570,39 @@ void CLK_DisablePLL(void) ...@@ -570,17 +570,39 @@ void CLK_DisablePLL(void)
* @details Use the SysTick to generate the delay time and the UNIT is in us. * @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. * 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) void CLK_SysTickDelay(uint32_t us)
{ {
__IO uint32_t j= 2;
SysTick->LOAD = us * CyclesPerUs; SysTick->LOAD = us * CyclesPerUs;
SysTick->VAL = (0x00); SysTick->VAL = (0x00);
SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_ENABLE_Msk; 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 */ /* 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; 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 * @brief This function check selected clock source status
* @param[in] u32ClkMask is selected clock source. Including * @param[in] u32ClkMask is selected clock source. Including
......
...@@ -62,13 +62,13 @@ void stackDump(uint32_t stack[]) ...@@ -62,13 +62,13 @@ void stackDump(uint32_t stack[])
void Hard_Fault_Handler(uint32_t stack[]) void Hard_Fault_Handler(uint32_t stack[])
{ {
printf("In Hard Fault Handler\n"); //printf("In Hard Fault Handler\n");
stackDump(stack); stackDump(stack);
//Chip Reset //Chip Reset
//SYS_UnlockReg(); SYS_UnlockReg();
//SYS->IPRSTC1 |= SYS_IPRSTC1_CHIP_RST_Msk; SYS_ResetChip();
while(1); while(1);
} }
......
...@@ -211,117 +211,117 @@ uint32_t UART_Read(UART_T* uart, uint8_t *pu8RxBuf, uint32_t u32ReadBytes) ...@@ -211,117 +211,117 @@ uint32_t UART_Read(UART_T* uart, uint8_t *pu8RxBuf, uint32_t u32ReadBytes)
} }
//lmm modified for decrease code size
/** ///**
* @brief This function use to config UART line setting. // * @brief This function use to config UART line setting.
* // *
* @param[in] uart The base address of UART module. // * @param[in] uart The base address of UART module.
* @param[in] u32baudrate The register value of baudrate of UART module. // * @param[in] u32baudrate The register value of baudrate of UART module.
* if u32baudrate = 0, UART baudrate will not change. // * if u32baudrate = 0, UART baudrate will not change.
* @param[in] u32data_width The data length of UART module. // * @param[in] u32data_width The data length of UART module.
* @param[in] u32parity The parity setting (odd/even/none) 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. // * @param[in] u32stop_bits The stop bit length (1/1.5 bit) of UART module.
* // *
* @return None // * @return None
*/ // */
void UART_SetLine_Config(UART_T* uart, uint32_t u32baudrate, uint32_t u32data_width, uint32_t u32parity, uint32_t u32stop_bits) //void UART_SetLine_Config(UART_T* uart, uint32_t u32baudrate, uint32_t u32data_width, uint32_t u32parity, uint32_t u32stop_bits)
{ //{
uint8_t u8UartClkSrcSel; // uint8_t u8UartClkSrcSel;
uint32_t u32Clk = 0; // uint32_t u32Clk = 0;
uint32_t u32ClkDiv = 0; // uint32_t u32ClkDiv = 0;
uint32_t u32Baud_Div = 0; // uint32_t u32Baud_Div = 0;
u8UartClkSrcSel = (CLK->CLKSEL1 & CLK_CLKSEL1_UARTSEL_Msk) >> CLK_CLKSEL1_UARTSEL_Pos; // u8UartClkSrcSel = (CLK->CLKSEL1 & CLK_CLKSEL1_UARTSEL_Msk) >> CLK_CLKSEL1_UARTSEL_Pos;
if(u8UartClkSrcSel == 0) // if(u8UartClkSrcSel == 0)
u32Clk = __XTAL; // u32Clk = __XTAL;
else if(u8UartClkSrcSel == 1) // else if(u8UartClkSrcSel == 1)
u32Clk = CLK_GetPLLClockFreq(); // u32Clk = CLK_GetPLLClockFreq();
else if(u8UartClkSrcSel >= 2) // else if(u8UartClkSrcSel >= 2)
u32Clk = __HSI; // u32Clk = __HSI;
u32ClkDiv = ( (CLK->CLKDIV & CLK_CLKDIV_UARTDIV_Msk) >> CLK_CLKDIV_UARTDIV_Pos ); // u32ClkDiv = ( (CLK->CLKDIV & CLK_CLKDIV_UARTDIV_Msk) >> CLK_CLKDIV_UARTDIV_Pos );
u32Clk = u32Clk/(u32ClkDiv + 1); // u32Clk = u32Clk/(u32ClkDiv + 1);
if(u32baudrate != 0) { // if(u32baudrate != 0) {
u32Baud_Div = UART_BAUD_MODE2_DIVIDER(u32Clk, u32baudrate); // u32Baud_Div = UART_BAUD_MODE2_DIVIDER(u32Clk, u32baudrate);
if(u32Baud_Div > 0xFFFF) // if(u32Baud_Div > 0xFFFF)
uart->BAUD = (UART_BAUD_MODE0 | UART_BAUD_MODE0_DIVIDER(u32Clk, u32baudrate)); // uart->BAUD = (UART_BAUD_MODE0 | UART_BAUD_MODE0_DIVIDER(u32Clk, u32baudrate));
else // else
uart->BAUD = (UART_BAUD_MODE2 | u32Baud_Div); // uart->BAUD = (UART_BAUD_MODE2 | u32Baud_Div);
} // }
uart->LINE = u32data_width | u32parity | u32stop_bits; // uart->LINE = u32data_width | u32parity | u32stop_bits;
} //}
/** ///**
* @brief This function use to set Rx timeout count. // * @brief This function use to set Rx timeout count.
* // *
* @param[in] uart The base address of UART module. // * @param[in] uart The base address of UART module.
* @param[in] u32TOC Rx timeout counter. // * @param[in] u32TOC Rx timeout counter.
* // *
* @return None // * @return None
*/ // */
void UART_SetTimeoutCnt(UART_T* uart, uint32_t u32TOC) //void UART_SetTimeoutCnt(UART_T* uart, uint32_t u32TOC)
{ //{
uart->TOUT = (uart->TOUT & ~UART_TOUT_TOIC_Msk)| (u32TOC); // uart->TOUT = (uart->TOUT & ~UART_TOUT_TOIC_Msk)| (u32TOC);
uart->INTEN |= UART_INTEN_TOCNTEN_Msk; // 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. // * @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] uart The base address of UART module.
* @param[in] u32Buadrate The baudrate 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. // * @param[in] u32Direction The direction(transmit:1/receive:0) of UART module in IrDA mode.
* // *
* @return None // * @return None
*/ // */
void UART_SelectIrDAMode(UART_T* uart, uint32_t u32Buadrate, uint32_t u32Direction) //void UART_SelectIrDAMode(UART_T* uart, uint32_t u32Buadrate, uint32_t u32Direction)
{ //{
uint8_t u8UartClkSrcSel; // uint8_t u8UartClkSrcSel;
uint32_t u32Clk = 0; // uint32_t u32Clk = 0;
uint32_t u32ClkDiv = 0; // uint32_t u32ClkDiv = 0;
u8UartClkSrcSel = (CLK->CLKSEL1 & CLK_CLKSEL1_UARTSEL_Msk) >> CLK_CLKSEL1_UARTSEL_Pos; // u8UartClkSrcSel = (CLK->CLKSEL1 & CLK_CLKSEL1_UARTSEL_Msk) >> CLK_CLKSEL1_UARTSEL_Pos;
if(u8UartClkSrcSel == 0) // if(u8UartClkSrcSel == 0)
u32Clk = __XTAL; // u32Clk = __XTAL;
else if(u8UartClkSrcSel == 1) // else if(u8UartClkSrcSel == 1)
u32Clk = CLK_GetPLLClockFreq(); // u32Clk = CLK_GetPLLClockFreq();
else if(u8UartClkSrcSel >= 2) // else if(u8UartClkSrcSel >= 2)
u32Clk = __HSI; // u32Clk = __HSI;
u32ClkDiv = ( (CLK->CLKDIV & CLK_CLKDIV_UARTDIV_Msk) >> CLK_CLKDIV_UARTDIV_Pos ); // u32ClkDiv = ( (CLK->CLKDIV & CLK_CLKDIV_UARTDIV_Msk) >> CLK_CLKDIV_UARTDIV_Pos );
u32Clk = u32Clk/(u32ClkDiv + 1); // u32Clk = u32Clk/(u32ClkDiv + 1);
uart->BAUD = UART_BAUD_MODE0 | UART_BAUD_MODE0_DIVIDER(u32Clk, u32Buadrate); // uart->BAUD = UART_BAUD_MODE0 | UART_BAUD_MODE0_DIVIDER(u32Clk, u32Buadrate);
uart->IRDA &= ~UART_IRDA_TXINV_Msk; // uart->IRDA &= ~UART_IRDA_TXINV_Msk;
uart->IRDA |= UART_IRDA_RXINV_Msk; // uart->IRDA |= UART_IRDA_RXINV_Msk;
uart->IRDA = u32Direction ? uart->IRDA | UART_IRDA_TXEN_Msk : uart->IRDA &~ UART_IRDA_TXEN_Msk; // uart->IRDA = u32Direction ? uart->IRDA | UART_IRDA_TXEN_Msk : uart->IRDA &~ UART_IRDA_TXEN_Msk;
uart->FUNSEL = (0x2 << UART_FUNSEL_FUN_SEL_Pos); // uart->FUNSEL = (0x2 << UART_FUNSEL_FUN_SEL_Pos);
} //}
/** ///**
* @brief The function is used to set RS485 relative setting. // * @brief The function is used to set RS485 relative setting.
* // *
* @param[in] uart The base address of UART module. // * @param[in] uart The base address of UART module.
* @param[in] u32Mode The operation mode(NMM/AUD/AAD). // * @param[in] u32Mode The operation mode(NMM/AUD/AAD).
* @param[in] u32Addr The RS485 address. // * @param[in] u32Addr The RS485 address.
* // *
* @return None // * @return None
*/ // */
void UART_SelectRS485Mode(UART_T* uart, uint32_t u32Mode, uint32_t u32Addr) //void UART_SelectRS485Mode(UART_T* uart, uint32_t u32Mode, uint32_t u32Addr)
{ //{
uart->FUNSEL = UART_FUNC_SEL_RS485; // uart->FUNSEL = UART_FUNC_SEL_RS485;
uart->ALTCTL = 0; // uart->ALTCTL = 0;
uart->ALTCTL |= u32Mode | (u32Addr << UART_ALTCTL_ADDRMV_Pos); // 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