Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jiancetai
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
陈家乐
jiancetai
Commits
54075b63
Commit
54075b63
authored
Apr 05, 2026
by
黄国庆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
✨
feat:移植SIF一线通文件
parent
984eb287
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
1297 additions
and
0 deletions
+1297
-0
WMHComm.c
YueJin_test_bench/source/Appliciation/WMHComm.c
+158
-0
WMHComm.h
YueJin_test_bench/source/Appliciation/WMHComm.h
+41
-0
WMHCommData.c
YueJin_test_bench/source/Appliciation/WMHCommData.c
+204
-0
WMHCommData.h
YueJin_test_bench/source/Appliciation/WMHCommData.h
+306
-0
mwWMHComm.c
YueJin_test_bench/source/Appliciation/mwWMHComm.c
+535
-0
mwWMHComm.h
YueJin_test_bench/source/Appliciation/mwWMHComm.h
+53
-0
No files found.
YueJin_test_bench/source/Appliciation/WMHComm.c
0 → 100644
View file @
54075b63
#include "wmhcomm.h"
#include "wmhcommdata.h"
#include "mwwmhcomm.h"
#include "TYW_stdint.h"
#include "string.h"
#include "Task.h"
#include "CAN_Communication_Matrix.h"
const
WMH_COMM_INIT_FRAME_T
WMHCommRecvInitList
[
EM_WMH_COMM_RECV_MSG_TOTAL
]
=
{
{
0x80u
,
1000u
,
COMM_DATA_UNION_WI_BOX_LENGTH_0X80
,
5000u
,
1u
,
WMHCommDataWiBox_0x80
.
Bytes
,
WMHCommFrameCallBack_WiBox_0x80
,
WMHCommFrameTimeoutFunc_WiBox80
,
WMHCommFrameCheckSumFunc
},
};
const
WMH_COMM_INIT_FRAME_T
WMHCommSendInitList
[
EM_WMH_COMM_SEND_MSG_TOTAL
]
=
{
{
0x90u
,
1000u
,
COMM_DATA_UNION_WI_BOX_LENGTH_0X90
,
10000u
,
1u
,
WMHCommDataWiBox_0x90
.
Bytes
,
WMHCommFrameCallBack_Icm
,
WMHCommFrameTimeoutFunc_WiBox_90
,
WMHCommFrameCheckSumFunc
},
{
0x91u
,
1000u
,
COMM_DATA_UNION_WI_BOX_LENGTH_0X91
,
10000u
,
1u
,
WMHCommDataWiBox_0x91
.
Bytes
,
WMHCommFrameCallBack_Icm
,
WMHCommFrameTimeoutFunc_WiBox_91
,
WMHCommFrameCheckSumFunc
},
{
0x92u
,
1000u
,
COMM_DATA_UNION_WI_BOX_LENGTH_0X92
,
10000u
,
1u
,
WMHCommDataWiBox_0x92
.
Bytes
,
WMHCommFrameCallBack_Icm
,
WMHCommFrameTimeoutFunc_WiBox_92
,
WMHCommFrameCheckSumFunc
},
};
uint32_t
WMHCommRecvMessageTimeout
[
EM_WMH_COMM_RECV_MSG_TOTAL
]
=
{
0
};
uint32_t
WMHCommSendMessageTimeout
[
EM_WMH_COMM_SEND_MSG_TOTAL
]
=
{
0
};
uint32_t
WMHCommAnalysisPos
=
0
;
void
WMHCommInit
(
void
)
{
uint8_t
i
=
0
;
for
(
i
=
0
;
i
<
EM_WMH_COMM_RECV_MSG_TOTAL
;
i
++
)
{
(
void
)
memset
(
WMHCommRecvInitList
[
i
].
SignalList
,
0
,
WMHCommRecvInitList
[
i
].
DLC
);
WMHCommRecvMessageTimeout
[
i
]
=
WMHCommRecvInitList
[
i
].
TimeoutMax
;
}
for
(
i
=
0
;
i
<
EM_WMH_COMM_SEND_MSG_TOTAL
;
i
++
)
{
(
void
)
memset
(
WMHCommSendInitList
[
i
].
SignalList
,
0
,
WMHCommSendInitList
[
i
].
DLC
);
WMHCommSendMessageTimeout
[
i
]
=
WMHCommSendInitList
[
i
].
TimeoutMax
;
}
WMHCommAnalysisPos
=
0
;
}
void
WMHCommFramePackedTransmit
(
EM_WMH_COMM_SEND_MSG_T
MsgIdx
)
{
uint8_t
data
[
64
]
=
{
0
};
uint8_t
length
=
0
;
if
((
MsgIdx
<
EM_WMH_COMM_SEND_MSG_TOTAL
)
&&
(
MsgIdx
>
0
)){
if
((
WMHCommSendInitList
[
MsgIdx
].
DLC
+
4
)
<=
64
)
{
if
(
WMHCommSendInitList
[
MsgIdx
].
FrameCallBackFunc
!=
NULL_P
)
{
WMHCommSendInitList
[
MsgIdx
].
FrameCallBackFunc
();
}
data
[
0
]
=
WMHCommSendInitList
[
MsgIdx
].
ID
;
//id
data
[
1
]
=
WMH_COMM_PROTOCOL_VERSION
;
//主协议版本号
data
[
2
]
=
WMHCommSendInitList
[
MsgIdx
].
DLC
+
1u
;
//数据长度
(
void
)
memcpy
(
&
data
[
3
],
WMHCommSendInitList
[
MsgIdx
].
SignalList
,
WMHCommSendInitList
[
MsgIdx
].
DLC
);
data
[
3
+
WMHCommSendInitList
[
MsgIdx
].
DLC
]
=
WMHCommSendInitList
[
MsgIdx
].
FrameGetCheckSum
(
WMHCommSendInitList
[
MsgIdx
].
ID
,
WMHCommSendInitList
[
MsgIdx
].
DLC
,
data
[
1
],
WMHCommSendInitList
[
MsgIdx
].
SignalList
);
length
=
WMHCommSendInitList
[
MsgIdx
].
DLC
+
4u
;
mwWMHCommTransmitBytes
(
data
,
length
);
WMHCommSendMessageTimeout
[
MsgIdx
]
=
WMHCommSendInitList
[
MsgIdx
].
TimeoutMax
;
}
}
else
if
(
MsgIdx
==
0
)
{
if
((
WMHCommSendInitList
[
MsgIdx
].
DLC
+
4
)
<=
64
)
{
if
(
WMHCommSendInitList
[
MsgIdx
].
FrameCallBackFunc
!=
NULL_P
)
{
WMHCommSendInitList
[
MsgIdx
].
FrameCallBackFunc
();
}
data
[
0
]
=
WMHCommSendInitList
[
MsgIdx
].
ID
;
//id
data
[
1
]
=
WMH_COMM_PROTOCOL_VERSION
;
//主协议版本号
data
[
2
]
=
WMHCommSendInitList
[
MsgIdx
].
DLC
+
1u
;
//数据长度
(
void
)
memcpy
(
&
data
[
3
],
WMHCommSendInitList
[
MsgIdx
].
SignalList
,
WMHCommSendInitList
[
MsgIdx
].
DLC
);
data
[
3
+
WMHCommSendInitList
[
MsgIdx
].
DLC
]
=
WMHCommSendInitList
[
MsgIdx
].
FrameGetCheckSum
(
WMHCommSendInitList
[
MsgIdx
].
ID
,
WMHCommSendInitList
[
MsgIdx
].
DLC
,
data
[
1
],
WMHCommSendInitList
[
MsgIdx
].
SignalList
);
length
=
WMHCommSendInitList
[
MsgIdx
].
DLC
+
4u
;
mwWMHCommTransmitBytes_90
(
data
,
length
);
WMHCommSendMessageTimeout
[
MsgIdx
]
=
WMHCommSendInitList
[
MsgIdx
].
TimeoutMax
;
}
}
}
void
WMHCommFrameUnpacked
(
uint8_t
*
data
,
uint32_t
length
)
{
uint32_t
i
=
EM_WMH_COMM_RECV_MSG_WI_BOX_0x80
;
if
(
length
>
0
)
{
if
(
data
[
0
]
==
WMHCommRecvInitList
[
i
].
ID
)
{
if
((
data
[
2
]
==
(
WMHCommRecvInitList
[
i
].
DLC
+
1
))
&&
(
length
==
(
WMHCommRecvInitList
[
i
].
DLC
+
4
)))
{
if
(
data
[
length
-
1
]
==
WMHCommRecvInitList
[
i
].
FrameGetCheckSum
(
data
[
0
],
WMHCommRecvInitList
[
i
].
DLC
,
data
[
1
],
&
data
[
3
]))
{
(
void
)
memcpy
(
WMHCommRecvInitList
[
i
].
SignalList
,
&
data
[
3
],
WMHCommRecvInitList
[
i
].
DLC
);
if
(
WMHCommRecvInitList
[
i
].
FrameCallBackFunc
!=
NULL_P
)
{
WMHCommRecvInitList
[
i
].
FrameCallBackFunc
();
}
WMHCommRecvMessageTimeout
[
i
]
=
WMHCommRecvInitList
[
i
].
TimeoutMax
;
Can_Msg_Tx_Overwrite
(
&
CAN_CH4_CanMsgTxOp
,
0u
,
1u
,
1000u
);
}
}
}
}
}
void
WMHCommTimeoutService
(
uint32_t
TimerDelta
)
{
uint8_t
i
=
0
;
for
(
i
=
0
;
i
<
EM_WMH_COMM_RECV_MSG_TOTAL
;
i
++
)
{
if
(
WMHCommRecvMessageTimeout
[
i
]
>
TimerDelta
)
{
WMHCommRecvMessageTimeout
[
i
]
-=
TimerDelta
;
}
else
{
if
(
WMHCommRecvMessageTimeout
[
i
]
>
0
)
{
if
(
WMHCommRecvInitList
[
i
].
FrameTimeoutFunc
!=
NULL_P
)
{
WMHCommRecvInitList
[
i
].
FrameTimeoutFunc
();
}
}
WMHCommRecvMessageTimeout
[
i
]
=
0
;
}
}
for
(
i
=
0
;
i
<
EM_WMH_COMM_SEND_MSG_TOTAL
;
i
++
)
{
if
(
WMHCommSendMessageTimeout
[
i
]
>
TimerDelta
)
{
WMHCommSendMessageTimeout
[
i
]
-=
TimerDelta
;
}
else
{
if
(
WMHCommSendMessageTimeout
[
i
]
>
0
)
{
if
(
WMHCommSendInitList
[
i
].
FrameTimeoutFunc
!=
NULL_P
)
{
WMHCommSendInitList
[
i
].
FrameTimeoutFunc
();
}
}
WMHCommSendMessageTimeout
[
i
]
=
0
;
}
}
}
uint32_t
WMHCommServiceCnts
=
0
;
void
WMHCommService
(
uint32_t
TimerDelta
)
{
uint8_t
data
[
64
]
=
{
0
};
uint32_t
length
=
0
;
uint32_t
tmpPos
=
0
;
uint8_t
*
tmpAddr
=
NULL_P
;
uint8_t
i
=
0
;
WMHCommTimeoutService
(
TimerDelta
);
WMHCommServiceCnts
+=
TimerDelta
;
if
(
WMHCommServiceCnts
>=
50
)
{
WMHCommServiceCnts
=
0
;
//mwWMHCommTransmitBytes(tmpBuffer, length);
tmpAddr
=
mwWMHCommGetRecvData
(
&
length
,
&
tmpPos
);
if
(
tmpAddr
!=
NULL_P
)
{
i
=
0
;
while
(
WMHCommAnalysisPos
!=
tmpPos
)
{
data
[
i
++
]
=
(
tmpAddr
[
WMHCommAnalysisPos
++
]);
WMHCommAnalysisPos
=
WMHCommAnalysisPos
%
length
;
}
// if (SYS_OPR_STAT_IGN_ON)
// {
WMHCommFrameUnpacked
(
data
,
i
);
// }
}
}
}
uint8_t
WMHCommFrameGetRecvTimeoutSt
(
uint8_t
n
)
{
uint8_t
ret
=
0
;
if
(
n
<
EM_WMH_COMM_RECV_MSG_TOTAL
)
{
ret
=
(
uint8_t
)(
WMHCommRecvMessageTimeout
[
n
]
==
0
);
}
return
ret
;
}
YueJin_test_bench/source/Appliciation/WMHComm.h
0 → 100644
View file @
54075b63
#ifndef __WMH_COMM_H_
#define __WMH_COMM_H_
#include "TYW_stdint.h"
#define NULL_P (void *)0
typedef
struct
{
uint8_t
ID
;
//ID;
uint16_t
Peroid
;
//报文周期,单位ms;
uint8_t
DLC
;
//报文长度;
uint16_t
TimeoutMax
;
//最大超时时间,单位ms;
uint8_t
RecoverContinueCnts
;
//报文超时后连续收到RecoverContinueCnts条判定报文恢复,报文周期不超过Peroid*1.2,填0或1为收到1条报文即判定报文恢复;
uint8_t
*
SignalList
;
//信号列表数组
void
(
*
FrameCallBackFunc
)(
void
);
//收到报文时会调用该回调函数;
void
(
*
FrameTimeoutFunc
)(
void
);
//TimeoutMax超时时会调用FrameTimeoutFunc(0),TimeoutLv[0]超时时调用FrameTimeoutFunc(1),TimeoutLv[1]超时时调用FrameTimeoutFunc(2),TimeoutLv[2]超时时调用FrameTimeoutFunc(3);
uint8_t
(
*
FrameGetCheckSum
)(
uint32_t
ID
,
uint8_t
DLC
,
uint8_t
ProtocolVersion
,
uint8_t
*
data
);
//接收报文时调用该函数,返回1表示checksum正确,0表示错误,如果错误,则不会调用FrameAnalysisFunc函数
}
WMH_COMM_INIT_FRAME_T
;
typedef
enum
{
EM_WMH_COMM_RECV_MSG_WI_BOX_0x80
=
0
,
// EM_WMH_COMM_RECV_MSG_WI_BOX_0x91,
// EM_WMH_COMM_RECV_MSG_WI_BOX_0x92,
EM_WMH_COMM_RECV_MSG_TOTAL
,
}
EM_WMH_COMM_RECV_MSG_T
;
typedef
enum
{
// EM_WMH_COMM_SEND_MSG_ICM_0x80 = 0,
EM_WMH_COMM_SEND_MSG_ICM_0x90
=
0
,
EM_WMH_COMM_SEND_MSG_ICM_0x91
,
EM_WMH_COMM_SEND_MSG_ICM_0x92
,
EM_WMH_COMM_SEND_MSG_TOTAL
,
}
EM_WMH_COMM_SEND_MSG_T
;
extern
void
WMHCommInit
(
void
);
extern
void
WMHCommService
(
uint32_t
TimerDelta
);
extern
void
WMHCommFramePackedTransmit
(
EM_WMH_COMM_SEND_MSG_T
MsgIdx
);
extern
uint8_t
WMHCommFrameGetRecvTimeoutSt
(
uint8_t
n
);
#endif
YueJin_test_bench/source/Appliciation/WMHCommData.c
0 → 100644
View file @
54075b63
#include "wmhcomm.h"
#include "wmhcommdata.h"
#include "TYW_stdint.h"
#include "string.h"
uint8_t
WMHCommFrameCheckSumFunc
(
uint32_t
ID
,
uint8_t
DLC
,
uint8_t
ProtocolVersion
,
uint8_t
*
data
)
{
uint32_t
ret
=
0
;
uint8_t
i
=
0
;
ret
+=
ID
;
ret
+=
ProtocolVersion
;
ret
+=
DLC
+
1
;
for
(
i
=
0
;
i
<
DLC
;
i
++
)
{
ret
+=
data
[
i
];
}
return
(
uint8_t
)(
ret
&
0xFF
);
}
/*******************************************************************************************
* Recv Message
*******************************************************************************************/
extern
const
WMH_COMM_INIT_FRAME_T
WMHCommRecvInitList
[
EM_WMH_COMM_RECV_MSG_TOTAL
];
COMM_DATA_UNION_WI_BOX_0x80
WMHCommDataWiBox_0x80
;
COMM_DATA_UNION_WI_BOX_0x90
WMHCommDataWiBox_0x90
;
COMM_DATA_UNION_WI_BOX_0x91
WMHCommDataWiBox_0x91
;
COMM_DATA_UNION_WI_BOX_0x92
WMHCommDataWiBox_0x92
;
void
WMHCommFrameCallBack_WiBox_0x80
(
void
)
{
uint8_t
tmpCond
=
0
;
}
void
WMHCommFrameCallBack_WiBox_0x90
(
void
)
{
uint8_t
tmpCond
=
0
;
}
void
WMHCommFrameCallBack_WiBox_0x91
(
void
)
{
uint8_t
tmpCond
=
0
;
}
void
WMHCommFrameTimeoutFunc_WiBox
(
void
)
{
// 替代第一个 memset
for
(
int
i
=
0
;
i
<
COMM_DATA_UNION_WI_BOX_LENGTH_0X90
;
i
++
)
{
WMHCommDataWiBox_0x90
.
Bytes
[
i
]
=
0
;
}
// 替代第二个 memset
for
(
int
i
=
0
;
i
<
COMM_DATA_UNION_WI_BOX_LENGTH_0X91
;
i
++
)
{
WMHCommDataWiBox_0x91
.
Bytes
[
i
]
=
0
;
}
// 替代第三个 memset
for
(
int
i
=
0
;
i
<
COMM_DATA_UNION_WI_BOX_LENGTH_0X92
;
i
++
)
{
WMHCommDataWiBox_0x92
.
Bytes
[
i
]
=
0
;
}
}
void
WMHCommFrameTimeoutFunc_WiBox_90
(
void
)
{
// 替代第一个 memset
for
(
int
i
=
0
;
i
<
COMM_DATA_UNION_WI_BOX_LENGTH_0X90
;
i
++
)
{
WMHCommDataWiBox_0x90
.
Bytes
[
i
]
=
0
;
}
}
void
WMHCommFrameTimeoutFunc_WiBox_91
(
void
)
{
// 替代第二个 memset
for
(
int
i
=
0
;
i
<
COMM_DATA_UNION_WI_BOX_LENGTH_0X91
;
i
++
)
{
WMHCommDataWiBox_0x91
.
Bytes
[
i
]
=
0
;
}
}
void
WMHCommFrameTimeoutFunc_WiBox_92
(
void
)
{
// 替代第三个 memset
for
(
int
i
=
0
;
i
<
COMM_DATA_UNION_WI_BOX_LENGTH_0X92
;
i
++
)
{
WMHCommDataWiBox_0x92
.
Bytes
[
i
]
=
0
;
}
}
void
WMHCommFrameTimeoutFunc_WiBox80
(
void
)
{
// 替代第一个 memset
for
(
int
i
=
0
;
i
<
COMM_DATA_UNION_WI_BOX_LENGTH_0X80
;
i
++
)
{
WMHCommDataWiBox_0x80
.
Bytes
[
i
]
=
0
;
}
}
/*******************************************************************************************
* Send Message
*******************************************************************************************/
COMM_DATA_UNION_ICM
WMHCommDataIcm
;
// uint8_t count = 0;
void
WMHCommFrameCallBack_Icm
(
void
)
{
// uint8_t CardKind = 0;
// //EM_FUEL_STATE_T tmpSt = GetFuelModuleState();
// uint32_t tmpVal = Data_ODO_Read() / 10u;
// WMHCommDataIcm.bits.Mileage_H = 0x11;
// WMHCommDataIcm.bits.Mileage_M = 0x33;
// WMHCommDataIcm.bits.Mileage_L = 0x44;
// //if(WMHCommDataWiBox_0x92.bits.Inquire == 0x11)
// {
// if (tmpVal > 9999999) {
// tmpVal = 9999999;
// }
// // WMHCommDataIcm.bits.Mileage_H = (tmpVal >> 16) & 0xFF;
// // WMHCommDataIcm.bits.Mileage_M = (tmpVal >> 8) & 0xFF;
// // WMHCommDataIcm.bits.Mileage_L = (tmpVal) & 0xFF;
// WMHCommDataIcm.bits.Mileage_H = 0x11;
// WMHCommDataIcm.bits.Mileage_M = 0x33;
// WMHCommDataIcm.bits.Mileage_L = 0x44;
// }
// if(WMHCommDataWiBox_0x92.bits.Inquire == 0x22)
// {
// count = WMHCommDataWiBox_0x92.bits.Card_H / 16;
// if(NFC_CARD[count-1][1] == 0)
// {
// CardKind = 2;
// }
// else
// {
// CardKind = 1;
// }
// WMHCommDataIcm.bits.CardKind = CardKind;
// WMHCommDataIcm.bits.CardNum = count*16+count;
// WMHCommDataIcm.bits.CardID1 = NFC_CARD[count-1][2];
// WMHCommDataIcm.bits.CardID2 = NFC_CARD[count-1][3];
// WMHCommDataIcm.bits.CardID3 = NFC_CARD[count-1][4];
// WMHCommDataIcm.bits.CardID4 = NFC_CARD[count-1][5];
// WMHCommDataIcm.bits.CardTotal = Study_CardCount;
// }
// else
// {
// count = 0;
// WMHCommDataIcm.bits.CardKind = 0;
// WMHCommDataIcm.bits.CardNum = 0;
// WMHCommDataIcm.bits.CardID1 = 0;
// WMHCommDataIcm.bits.CardID2 = 0;
// WMHCommDataIcm.bits.CardID3 = 0;
// WMHCommDataIcm.bits.CardID4 = 0;
// WMHCommDataIcm.bits.CardTotal = 0;
// }
// if(WMHCommDataWiBox_0x92.bits.NfcOperate == 0x11)
// {
// WMHCommDataIcm.bits.AddCardStatus = Add_Card_Status;
// if(WMHCommDataIcm.bits.AddCardStatus == 2)
// {
// WMHCommDataIcm.bits.CardKind = NFC_CARD[NFC_Empty_card][1];
// WMHCommDataIcm.bits.CardNum = (NFC_Empty_card + 1)*17;
// WMHCommDataIcm.bits.CardID1 = NFC_CARD[NFC_Empty_card][2];
// WMHCommDataIcm.bits.CardID2 = NFC_CARD[NFC_Empty_card][3];
// WMHCommDataIcm.bits.CardID3 = NFC_CARD[NFC_Empty_card][4];
// WMHCommDataIcm.bits.CardID4 = NFC_CARD[NFC_Empty_card][5];
// WMHCommDataIcm.bits.CardTotal = Study_CardCount;
// }
// else if(WMHCommDataIcm.bits.AddCardStatus == 1)
// {
// WMHCommDataIcm.bits.CardKind = 0;
// WMHCommDataIcm.bits.CardNum = (NFC_Empty_card + 1)*17;
// WMHCommDataIcm.bits.CardID1 = 0;
// WMHCommDataIcm.bits.CardID2 = 0;
// WMHCommDataIcm.bits.CardID3 = 0;
// WMHCommDataIcm.bits.CardID4 = 0;
// WMHCommDataIcm.bits.CardTotal = Study_CardCount;
// }
// else
// {
// WMHCommDataIcm.bits.CardKind = 0;
// WMHCommDataIcm.bits.CardNum = 0;
// WMHCommDataIcm.bits.CardID1 = 0;
// WMHCommDataIcm.bits.CardID2 = 0;
// WMHCommDataIcm.bits.CardID3 = 0;
// WMHCommDataIcm.bits.CardID4 = 0;
// WMHCommDataIcm.bits.CardTotal = Study_CardCount;
// }
// WMHCommDataIcm.bits.RemoveCardStatus = 0;
// }
// else if(WMHCommDataWiBox_0x92.bits.NfcOperate == 0x22)
// {
// WMHCommDataIcm.bits.RemoveCardStatus = 2;
// WMHCommDataIcm.bits.AddCardStatus = 0;
// }
// else
// {
// WMHCommDataIcm.bits.AddCardStatus = 0xFF;
// WMHCommDataIcm.bits.RemoveCardStatus = 0xFF;
// }
// WMHCommDataIcm.bits.Reserved = 0xFF;
// WMHCommDataWiBox_0x90.bits.Espeed_L = 0xDD;
}
void
WMHCommFrameTimeoutFunc_Icm
(
void
)
{
//if((WMHCommDataWiBox_0x92.bits.Inquire != 0)||(WMHCommDataWiBox_0x92.bits.NfcOperate != 0 ))
{
//WMHCommFramePackedTransmit(EM_WMH_COMM_SEND_MSG_ICM_0x80);
}
}
YueJin_test_bench/source/Appliciation/WMHCommData.h
0 → 100644
View file @
54075b63
#ifndef __WMH_COMM_DATA_H_
#define __WMH_COMM_DATA_H_
#include "TYW_stdint.h"
#define WMH_COMM_PROTOCOL_VERSION 0x2F;
#define COMM_DATA_UNION_WI_BOX_LENGTH_0X80 13
typedef
union
{
struct
{
// ===================== Byte0 =====================
uint8_t
Mileage_H
:
8
;
// 里程高字节
// ===================== Byte1 =====================
uint8_t
Mileage_M
:
8
;
// 里程中字节
// ===================== Byte2 =====================
uint8_t
Mileage_L
:
8
;
// 里程低字节
// ===================== Byte3 =====================
uint8_t
Reserved1
:
8
;
// ~~卡种类 0x01加密卡 0x02未加密卡~~(预留)
// ===================== Byte4 =====================
uint8_t
Reserved2
:
8
;
// ~~卡序号 0x11、0x22、0x33(预留)~~
// ===================== Byte5 =====================
uint8_t
Reserved3
:
8
;
// ~~卡ID(预留)~~
// ===================== Byte6 =====================
uint8_t
Reserved4
:
8
;
// ~~卡ID(预留)~~
// ===================== Byte7 =====================
uint8_t
Reserved5
:
8
;
// ~~卡ID(预留)~~
// ===================== Byte8 =====================
uint8_t
Reserved6
:
8
;
// ~~卡ID(预留)~~
// ===================== Byte9 =====================
uint8_t
Reserved7
:
8
;
// ~~卡总数(预留)~~
// ===================== Byte10 ====================
uint8_t
Reserved8
:
8
;
// ~~添卡状态:0x01进行中、0x02成功、0x03失败、0x04卡已存在(预留)~~
// ===================== Byte11 ====================
uint8_t
Reserved9
:
8
;
// ~~删卡状态:0x01进行中、0x02成功、0x03失败(预留)~~
// ===================== Byte12 ====================
uint8_t
Reserved10
:
8
;
// ~~预留位10~~
}
bits
;
uint8_t
Bytes
[
COMM_DATA_UNION_WI_BOX_LENGTH_0X80
];
}
COMM_DATA_UNION_WI_BOX_0x80
;
extern
COMM_DATA_UNION_WI_BOX_0x80
WMHCommDataWiBox_0x80
;
#define COMM_DATA_UNION_WI_BOX_LENGTH_0X90 16
typedef
union
{
struct
{
// // ===================== Byte0 =====================
// uint8_t ProductModel :6; // 产品型号
// uint8_t ManufacturerCodingRules :2; // 厂家编码规则
// // ===================== Byte1 =====================
// uint8_t DeviceEncoding :8; // 设备编码
// // ===================== Byte2 =====================
// uint8_t SerialNumberL :8; // 流水号
// // ===================== Byte3 =====================
// uint8_t FaultStatus :1; // 故障状态
// uint8_t ConstantSpeedStatus :1; // 定速巡航状态
// uint8_t GearPStatus :1; // P档状态
// uint8_t ReadyStatus :1; // READY状态
// uint8_t SerialNumberH :4; // 流水号高字节4位
// // ===================== Byte4 =====================
// uint8_t EstimateMileage_H :8; // 预估里程高字节
// // ===================== Byte5 =====================
// uint8_t EstimateMileage_L :8; // 预估里程低字节
// // ===================== Byte6 =====================
// uint8_t EnergyConsumption :8; // 能耗系数
// // ===================== Byte7 =====================
// uint8_t Fault8 :1; // 电机缺相故障
// uint8_t Fault7 :1; // 堵转保护故障
// uint8_t Fault6 :1; // 欠压保护故障
// uint8_t Fault5 :1; // 转把故障
// uint8_t Fault4 :1; // 控制器MOS管故障
// uint8_t Fault3 :1; // 刹车故障
// uint8_t Fault2 :1; // 电机霍尔故障
// uint8_t Fault1 :1; // 过压保护故障
// // ===================== Byte8 =====================
// uint8_t Fault16 :1; // 电池充电过流保护故障
// uint8_t Fault15 :1; // 电池SOC过低故障
// uint8_t Fault14 :1; // 电池总压欠压保护故障
// uint8_t Fault13 :1; // 电池总压过压保护故障
// uint8_t Fault12 :1; // 电池放电MOS故障
// uint8_t Fault11 :1; // 电池充电MOS故障
// uint8_t Fault10 :1; // 控制器过热故障
// uint8_t Fault9 :1; // 电机过热故障
// // ===================== Byte9 =====================
// uint8_t Reserved3 :2; // 预留位3
// uint8_t Fault22 :1; // 电池放电握手失败故障
// uint8_t Fault21 :1; // 电池充电过温保护故障
// uint8_t Fault20 :1; // 电池充电低温保护故障
// uint8_t Fault19 :1; // 电池放电过温保护故障
// uint8_t Fault18 :1; // 电池放电低温保护故障
// uint8_t Fault17 :1; // 电池放电过流保护故障
// // ===================== Byte10 =====================
// uint8_t Espeed_H :8; // 电机脉冲数高字节
// // ===================== Byte11 =====================
// uint8_t Espeed_L :8; // 电机脉冲数低字节
// // ===================== Byte12 =====================
// uint8_t Electricity :8; // 电量
// // ===================== Byte13 =====================
// uint8_t Reserved5 :3; // 预留位5
// uint8_t TCSopen :1; // TCS功能开启
// uint8_t TCSa :1; // TCS动作中
// uint8_t Fault23 :1; // 控制器过流故障
// uint8_t GEAR :1; // 1:S档 0:D档
// uint8_t FaultLED :1; // 故障指示灯
// // ===================== Byte14 =====================
// uint8_t BurglarStatus :1; // 防盗状态
// uint8_t Reserved4 :4; // 预留位4
// uint8_t CartStatus :1; // 推车状态
// uint8_t SideBraceStatus :1; // 边撑状态
// uint8_t EBSStatus :1; // EBS状态
// // ===================== Byte15 =====================
// uint8_t VSpeed :8; // 车速
uint8_t
Data90_Byte1
:
8
;
uint8_t
Data90_Byte2
:
8
;
uint8_t
Data90_Byte3
:
8
;
uint8_t
Data90_Byte4
:
8
;
uint8_t
Data90_Byte5
:
8
;
uint8_t
Data90_Byte6
:
8
;
uint8_t
Data90_Byte7
:
8
;
uint8_t
Data90_Byte8
:
8
;
uint8_t
Data90_Byte9
:
8
;
uint8_t
Data90_Byte10
:
8
;
uint8_t
Data90_Byte11
:
8
;
uint8_t
Data90_Byte12
:
8
;
uint8_t
Data90_Byte13
:
8
;
uint8_t
Data90_Byte14
:
8
;
uint8_t
Data90_Byte15
:
8
;
uint8_t
Data90_Byte16
:
8
;
}
bits
;
uint8_t
Bytes
[
COMM_DATA_UNION_WI_BOX_LENGTH_0X90
];
}
COMM_DATA_UNION_WI_BOX_0x90
;
extern
COMM_DATA_UNION_WI_BOX_0x90
WMHCommDataWiBox_0x90
;
#define COMM_DATA_UNION_WI_BOX_LENGTH_0X91 12
typedef
union
{
struct
{
// // ===================== Byte0 =====================
// uint8_t Year :8; // 年
// // ===================== Byte1 =====================
// uint8_t Month :8; // 月
// // ===================== Byte2 =====================
// uint8_t Day :8; // 日
// // ===================== Byte3 =====================
// uint8_t Hour :8; // 小时
// // ===================== Byte4 =====================
// uint8_t Minute :8; // 分钟
// // ===================== Byte5 =====================
// uint8_t Second :8; // 秒
// // ===================== Byte6 =====================
// uint8_t BtDistanceSt :1; // 蓝牙感应距离状态
// uint8_t BtConnection :1; // 蓝牙连接状态
// uint8_t SignalStrengthOf4G :3; // LTE网络信号强度格数(CSQ=0或99→0格,CSQ=1-5→1格,CSQ=6-10→2格,CSQ=11-15→3格,CSQ=16-20→4格,CSQ≥21→5格)
// uint8_t SignalStrengthOfGps :3; // GPS信号连接格数(3颗→0格,4颗→1格,5颗→2格,6颗→3格,≥7颗→4格)
// // ===================== Byte7 =====================
// uint8_t Reserved1 :6; // 预留位1
// uint8_t MessageWaittingToAnswer :1; // 信息待回复
// uint8_t PhoneWaittingToAnswer :1; // 电话待接听
// // ===================== Byte8 =====================
// uint8_t PositFault :1; // 定位故障
// uint8_t MasterControlFault :1; // 主控故障
// uint8_t BtFault :1; // 蓝牙故障
// uint8_t PowerFault :1; // 电源故障
// uint8_t ThreeAxisSensorFault :1; // 三轴传感器故障
// uint8_t OneServiceFault :1; // 一线通故障
// uint8_t NetWorkFault :1; // 网络故障
// uint8_t ACCFault :1; // ACC故障
// // ===================== Byte9 =====================
// uint8_t Reserved2 :6; // 预留位2
// uint8_t AntennaFault :1; // 天线故障
// uint8_t RfFault :1; // 射频故障
// // ===================== Byte10 =====================
// uint8_t EstimateMileage_H :8; // 预估里程高字节
// // ===================== Byte11 =====================
// uint8_t EstimateMileage_L :8; // 预估里程低字节
uint8_t
Data91_Byte1
:
8
;
// 预估里程低字节
uint8_t
Data91_Byte2
:
8
;
// 预估里程低字节
uint8_t
Data91_Byte3
:
8
;
// 预估里程低字节
uint8_t
Data91_Byte4
:
8
;
// 预估里程低字节
uint8_t
Data91_Byte5
:
8
;
// 预估里程低字节
uint8_t
Data91_Byte6
:
8
;
// 预估里程低字节
uint8_t
Data91_Byte7
:
8
;
// 预估里程低字节
uint8_t
Data91_Byte8
:
8
;
// 预估里程低字节
uint8_t
Data91_Byte9
:
8
;
// 预估里程低字节
uint8_t
Data91_Byte10
:
8
;
// 预估里程低字节
uint8_t
Data91_Byte11
:
8
;
// 预估里程低字节
uint8_t
Data91_Byte12
:
8
;
// 预估里程低字节
}
bits
;
uint8_t
Bytes
[
COMM_DATA_UNION_WI_BOX_LENGTH_0X91
];
}
COMM_DATA_UNION_WI_BOX_0x91
;
extern
COMM_DATA_UNION_WI_BOX_0x91
WMHCommDataWiBox_0x91
;
#define COMM_DATA_UNION_WI_BOX_LENGTH_0X92 5
typedef
union
{
struct
{
// // ===================== Byte0 =====================
// uint8_t Inquire :8; // 0x00→未查询,0x11→查询里程,~~0x22→查询NFC卡信息~~
// // ===================== Byte1 =====================
// uint8_t Reserved1 :8; // ~~0x00→无操作,0x11→添卡,0x22→删卡~~
// // ===================== Byte2 =====================
// uint8_t Reserved2 :8; // ~~0x00→暂不响应,0x11~0xFF→卡1~卡15~~
// // ===================== Byte3 =====================
// uint8_t Reserved3 :8; // 预留位3
// // ===================== Byte4 =====================
// uint8_t Reserved4 :8; // 预留位4
uint8_t
Data92_Byte1
:
8
;
// 预估里程低字节
uint8_t
Data92_Byte2
:
8
;
// 预估里程低字节
uint8_t
Data92_Byte3
:
8
;
// 预估里程低字节
uint8_t
Data92_Byte4
:
8
;
// 预估里程低字节
uint8_t
Data92_Byte5
:
8
;
// 预估里程低字节
}
bits
;
uint8_t
Bytes
[
COMM_DATA_UNION_WI_BOX_LENGTH_0X92
];
}
COMM_DATA_UNION_WI_BOX_0x92
;
extern
COMM_DATA_UNION_WI_BOX_0x92
WMHCommDataWiBox_0x92
;
#define COMM_DATA_UNION_ICM_LENGTH 13
typedef
union
{
struct
{
uint8_t
Mileage_H
:
8
;
uint8_t
Mileage_M
:
8
;
uint8_t
Mileage_L
:
8
;
uint8_t
CardKind
:
8
;
//卡种类 0x01加密卡 0x02未加密卡
uint8_t
CardNum
:
8
;
//卡序号 0x11 0x22 0x33
uint8_t
CardID1
:
8
;
//卡ID
uint8_t
CardID2
:
8
;
//卡ID
uint8_t
CardID3
:
8
;
//卡ID
uint8_t
CardID4
:
8
;
//卡ID
uint8_t
CardTotal
:
8
;
//卡总数
uint8_t
AddCardStatus
:
8
;
//添卡状态0x01进行中 0x02成功 0x03失败 0x04卡已存在
uint8_t
RemoveCardStatus
:
8
;
//删卡状态0x01进行中 0x02成功 0x03失败
uint8_t
Reserved
:
8
;
}
bits
;
uint8_t
Bytes
[
COMM_DATA_UNION_ICM_LENGTH
];
}
COMM_DATA_UNION_ICM
;
extern
COMM_DATA_UNION_ICM
WMHCommDataIcm
;
extern
COMM_DATA_UNION_WI_BOX_0x90
WMHCommDataWiBox_0x90
;
extern
COMM_DATA_UNION_WI_BOX_0x91
WMHCommDataWiBox_0x91
;
extern
COMM_DATA_UNION_WI_BOX_0x92
WMHCommDataWiBox_0x92
;
extern
uint8_t
WMHCommFrameCheckSumFunc
(
uint32_t
ID
,
uint8_t
DLC
,
uint8_t
ProtocolVersion
,
uint8_t
*
data
);
extern
void
WMHCommFrameCallBack_WiBox_0x80
(
void
);
extern
void
WMHCommFrameCallBack_WiBox_0x90
(
void
);
extern
void
WMHCommFrameCallBack_WiBox_0x91
(
void
);
extern
void
WMHCommFrameCallBack_WiBox_0x92
(
void
);
extern
void
WMHCommFrameTimeoutFunc_WiBox
(
void
);
extern
void
WMHCommFrameTimeoutFunc_WiBox_90
(
void
);
extern
void
WMHCommFrameTimeoutFunc_WiBox_91
(
void
);
extern
void
WMHCommFrameTimeoutFunc_WiBox_92
(
void
);
extern
void
WMHCommFrameTimeoutFunc_WiBox80
(
void
);
extern
void
WMHCommFrameCallBack_Icm
(
void
);
extern
void
WMHCommFrameTimeoutFunc_Icm
(
void
);
#endif
YueJin_test_bench/source/Appliciation/mwWMHComm.c
0 → 100644
View file @
54075b63
#include "mwwmhcomm.h"
#include "TYW_stdint.h"
#include "string.h"
#include "gpio.h"
#include "rte_gpio.h"
#define MW_WMH_COMM_FRAME_CONVERT_COND(PORT_IDX, FRAME) ((mwWMHCommFrameTimerCnts[PORT_IDX].LowLevelTime >= mwWMHCommSequentialParams[FRAME].LowerLimit.LowLevelTime) &&\
(mwWMHCommFrameTimerCnts[PORT_IDX].LowLevelTime <= mwWMHCommSequentialParams[FRAME].UpperLimit.LowLevelTime) &&\
(mwWMHCommFrameTimerCnts[PORT_IDX].HighLevelTime >= mwWMHCommSequentialParams[FRAME].LowerLimit.HighLevelTime) &&\
(mwWMHCommFrameTimerCnts[PORT_IDX].HighLevelTime <= mwWMHCommSequentialParams[FRAME].UpperLimit.HighLevelTime))
EM_WMH_COMM_FRAME_T
mwWMHCommFrame
[
EM_WMH_COMM_PIN_TOTAL
];
static
const
MW_WMH_COMM_SEQUENTIAL_T
mwWMHCommSequentialParams
[
EM_WMH_COMM_FRAME_TOTAL
]
=
{
// EM_WMH_COMM_FRAME_STANDBAY
{
{
0xFFFFFFFF
,
0xFFFFFFFF
,
},
// Standard
{
0xFFFFFFFF
,
0xFFFFFFFF
,
},
// UpperLimit
{
0xFFFFFFFF
,
0xFFFFFFFF
,
},
// LowerLimit
},
#if 0
// EM_WMH_COMM_FRAME_START
{
{ 20000, 2000, }, // Standard
{ 20400, 2040, }, // UpperLimit
{ 19600, 1960, }, // LowerLimit
}
// EM_WMH_COMM_FRAME_LOGIC_1
{
{ 500, 1500, }, // Standard
{ 510, 1530, }, // UpperLimit
{ 490, 1470, }, // LowerLimit
}
// EM_WMH_COMM_FRAME_LOGIC_0
{
{ 1500, 500, }, // Standard
{ 1530, 510, }, // UpperLimit
{ 1470, 490, }, // LowerLimit
}
// EM_WMH_COMM_FRAME_STOP
{
{ 5000, 50000, }, // Standard
{ 5100, 51000, }, // UpperLimit
{ 4900, 49000, }, // LowerLimit
}
#else
// EM_WMH_COMM_FRAME_START
{
//low high
{
20000
,
2000
,
},
// Standard
{
20400
,
2200
,
},
// UpperLimit
{
19600
,
1800
,
},
// LowerLimit
},
// EM_WMH_COMM_FRAME_LOGIC_1
{
{
500
,
1500
,
},
// Standard
{
700
,
1700
,
},
// UpperLimit
{
300
,
1300
,
},
// LowerLimit
},
// EM_WMH_COMM_FRAME_LOGIC_0
{
{
1500
,
500
,
},
// Standard
{
1700
,
700
,
},
// UpperLimit
{
1300
,
300
,
},
// LowerLimit
},
// EM_WMH_COMM_FRAME_STOP
{
{
5000
,
50000
,
},
// Standard
{
5200
,
51000
,
},
// UpperLimit
{
4800
,
49000
,
},
// LowerLimit
},
#endif
};
MW_WMH_COMM_TIMER_T
mwWMHCommFrameTimerCnts
[
EM_WMH_COMM_PIN_TOTAL
]
=
{
0
};
#define MAX_SERIAL_BUFF_SIZE 64u
typedef
struct
{
uint8_t
Buffer
[
MAX_SERIAL_BUFF_SIZE
];
uint16_t
OptCnts
;
uint16_t
FillCnts
;
uint8_t
Byte
;
uint8_t
Bit
;
uint8_t
Valid
;
}
MW_WMH_COMM_SERIAL_BUFFER_T
;
/* */
MW_WMH_COMM_SERIAL_BUFFER_T
mwWMHCommSerialBuffer
[
EM_WMH_COMM_PIN_TOTAL
];
// #if !(defined (__GNUG__) && defined (size_t))
// __MINGW_EXTENSION typedef __SIZE_TYPE__ size_t;
// void * memset(void * __dst, int __val, size_t __n)
// {
// return __builtin___memset_chk(__dst, __val, __n, __mingw_bos(__dst, 0));
// }
void
mwWMHCommInit
(
void
)
{
uint8_t
i
=
0
;
for
(
i
=
0
;
i
<
EM_WMH_COMM_PIN_TOTAL
;
i
++
)
{
mwWMHCommFrame
[
i
]
=
EM_WMH_COMM_FRAME_STANDBAY
;
mwWMHCommFrameTimerCnts
[
i
].
LowLevelTime
=
0
;
mwWMHCommFrameTimerCnts
[
i
].
HighLevelTime
=
0
;
for
(
int
j
=
0
;
j
<
MAX_SERIAL_BUFF_SIZE
;
j
++
)
{
mwWMHCommSerialBuffer
[
i
].
Buffer
[
j
]
=
0
;
}
mwWMHCommSerialBuffer
[
i
].
OptCnts
=
0
;
mwWMHCommSerialBuffer
[
i
].
FillCnts
=
0
;
mwWMHCommSerialBuffer
[
i
].
Byte
=
0
;
mwWMHCommSerialBuffer
[
i
].
Bit
=
0
;
mwWMHCommSerialBuffer
[
i
].
Valid
=
0
;
}
}
void
mwWMHCommRecvIsr_wibox
(
uint32_t
tmpCnts
)
{
uint16_t
n
=
(
uint16_t
)
EM_WMH_COMM_PIN_RX_ID_wibox
;
uint8_t
tmpVal
=
WMH_COIN
;
if
((
mwWMHCommSerialBuffer
[
n
].
Valid
==
0
)
&&
(
mwWMHCommFrame
[
EM_WMH_COMM_PIN_TX_IDX
]
==
EM_WMH_COMM_FRAME_STANDBAY
))
{
if
(
tmpVal
==
0
)
{
if
(
mwWMHCommFrameTimerCnts
[
n
].
HighLevelTime
>
0
)
{
mwWMHCommFrameTimerCnts
[
n
].
HighLevelTime
=
0
;
mwWMHCommFrameTimerCnts
[
n
].
LowLevelTime
=
0
;
}
mwWMHCommFrameTimerCnts
[
n
].
LowLevelTime
+=
tmpCnts
;
if
(
mwWMHCommFrameTimerCnts
[
n
].
LowLevelTime
>=
50000
)
{
mwWMHCommFrame
[
n
]
=
EM_WMH_COMM_FRAME_STANDBAY
;
mwWMHCommSerialBuffer
[
n
].
Byte
=
0
;
mwWMHCommSerialBuffer
[
n
].
Bit
=
0
;
mwWMHCommFrameTimerCnts
[
n
].
LowLevelTime
=
0
;
mwWMHCommFrameTimerCnts
[
n
].
HighLevelTime
=
0
;
}
}
else
{
mwWMHCommFrameTimerCnts
[
n
].
HighLevelTime
+=
tmpCnts
;
if
(
mwWMHCommFrameTimerCnts
[
n
].
HighLevelTime
>
0
)
{
if
(
mwWMHCommFrame
[
n
]
==
EM_WMH_COMM_FRAME_STANDBAY
)
{
if
(
MW_WMH_COMM_FRAME_CONVERT_COND
(
n
,
EM_WMH_COMM_FRAME_START
)
!=
0
)
{
mwWMHCommFrame
[
n
]
=
EM_WMH_COMM_FRAME_START
;
mwWMHCommSerialBuffer
[
n
].
Byte
=
0
;
mwWMHCommSerialBuffer
[
n
].
Bit
=
0
;
mwWMHCommFrameTimerCnts
[
n
].
LowLevelTime
=
0
;
mwWMHCommFrameTimerCnts
[
n
].
HighLevelTime
=
0
;
}
}
else
if
(
mwWMHCommFrame
[
n
]
==
EM_WMH_COMM_FRAME_START
)
{
if
(
MW_WMH_COMM_FRAME_CONVERT_COND
(
n
,
EM_WMH_COMM_FRAME_LOGIC_1
)
!=
0
)
{
// mwWMHCommSerialBuffer[n].Byte = mwWMHCommSerialBuffer[n].Byte << 1;
mwWMHCommSerialBuffer
[
n
].
Byte
|=
(
1u
<<
mwWMHCommSerialBuffer
[
n
].
Bit
);
mwWMHCommSerialBuffer
[
n
].
Bit
++
;
mwWMHCommFrameTimerCnts
[
n
].
LowLevelTime
=
0
;
mwWMHCommFrameTimerCnts
[
n
].
HighLevelTime
=
0
;
}
else
if
(
MW_WMH_COMM_FRAME_CONVERT_COND
(
n
,
EM_WMH_COMM_FRAME_LOGIC_0
)
!=
0
)
{
// mwWMHCommSerialBuffer[n].Byte = mwWMHCommSerialBuffer[n].Byte << 1;
mwWMHCommSerialBuffer
[
n
].
Byte
&=
~
(
1u
<<
mwWMHCommSerialBuffer
[
n
].
Bit
);
mwWMHCommSerialBuffer
[
n
].
Bit
++
;
mwWMHCommFrameTimerCnts
[
n
].
LowLevelTime
=
0
;
mwWMHCommFrameTimerCnts
[
n
].
HighLevelTime
=
0
;
}
else
if
(
mwWMHCommFrameTimerCnts
[
n
].
HighLevelTime
>=
60000
)
{
mwWMHCommFrame
[
n
]
=
EM_WMH_COMM_FRAME_STANDBAY
;
mwWMHCommSerialBuffer
[
n
].
Valid
=
1
;
mwWMHCommSerialBuffer
[
n
].
Byte
=
0
;
mwWMHCommSerialBuffer
[
n
].
Bit
=
0
;
mwWMHCommFrameTimerCnts
[
n
].
LowLevelTime
=
0
;
mwWMHCommFrameTimerCnts
[
n
].
HighLevelTime
=
0
;
}
else
{
;
}
if
(
mwWMHCommSerialBuffer
[
n
].
Bit
>=
8
)
{
mwWMHCommSerialBuffer
[
n
].
Bit
=
0
;
// Receive One Byte
mwWMHCommRecvByte_wibox
(
mwWMHCommSerialBuffer
[
n
].
Byte
);
mwWMHCommSerialBuffer
[
n
].
Byte
=
0
;
}
}
}
}
}
else
{
}
}
void
mwWMHCommRecvIsr_0x90
(
uint32_t
tmpCnts
)
{
// uint16_t n = (uint16_t)EM_WMH_COMM_PIN_RX_ID_0x90;
// uint8_t tmpVal = (uint8_t)(RTE_GPIO_Get_Level(RTE_GPIO_PORTB_PIN15));
// if (mwWMHCommSerialBuffer[n].Valid == 0) {
// if (tmpVal == 0) {
// if (mwWMHCommFrameTimerCnts[n].HighLevelTime > 0) {
// mwWMHCommFrameTimerCnts[n].HighLevelTime = 0;
// mwWMHCommFrameTimerCnts[n].LowLevelTime = 0;
// }
// mwWMHCommFrameTimerCnts[n].LowLevelTime += tmpCnts;
// if (mwWMHCommFrameTimerCnts[n].LowLevelTime >= 50000) {
// mwWMHCommFrame[n] = EM_WMH_COMM_FRAME_STANDBAY;
// mwWMHCommSerialBuffer[n].Byte = 0;
// mwWMHCommSerialBuffer[n].Bit = 0;
// mwWMHCommFrameTimerCnts[n].LowLevelTime = 0;
// mwWMHCommFrameTimerCnts[n].HighLevelTime = 0;
// }
// } else {
// mwWMHCommFrameTimerCnts[n].HighLevelTime += tmpCnts;
// if (mwWMHCommFrameTimerCnts[n].HighLevelTime > 0) {
// if (mwWMHCommFrame[n] == EM_WMH_COMM_FRAME_STANDBAY) {
// if (MW_WMH_COMM_FRAME_CONVERT_COND(n, EM_WMH_COMM_FRAME_START) != 0) {
// mwWMHCommFrame[n] = EM_WMH_COMM_FRAME_START;
// mwWMHCommSerialBuffer[n].Byte = 0;
// mwWMHCommSerialBuffer[n].Bit = 0;
// mwWMHCommFrameTimerCnts[n].LowLevelTime = 0;
// mwWMHCommFrameTimerCnts[n].HighLevelTime = 0;
// }
// } else if (mwWMHCommFrame[n] == EM_WMH_COMM_FRAME_START) {
// if (MW_WMH_COMM_FRAME_CONVERT_COND(n, EM_WMH_COMM_FRAME_LOGIC_1) != 0) {
// // mwWMHCommSerialBuffer[n].Byte = mwWMHCommSerialBuffer[n].Byte << 1;
// mwWMHCommSerialBuffer[n].Byte |= (1u << mwWMHCommSerialBuffer[n].Bit);
// mwWMHCommSerialBuffer[n].Bit++;
// mwWMHCommFrameTimerCnts[n].LowLevelTime = 0;
// mwWMHCommFrameTimerCnts[n].HighLevelTime = 0;
// } else if (MW_WMH_COMM_FRAME_CONVERT_COND(n, EM_WMH_COMM_FRAME_LOGIC_0) != 0) {
// // mwWMHCommSerialBuffer[n].Byte = mwWMHCommSerialBuffer[n].Byte << 1;
// mwWMHCommSerialBuffer[n].Byte &= ~(1u << mwWMHCommSerialBuffer[n].Bit);
// mwWMHCommSerialBuffer[n].Bit++;
// mwWMHCommFrameTimerCnts[n].LowLevelTime = 0;
// mwWMHCommFrameTimerCnts[n].HighLevelTime = 0;
// } else if (mwWMHCommFrameTimerCnts[n].HighLevelTime >= 50000) {
// mwWMHCommFrame[n] = EM_WMH_COMM_FRAME_STANDBAY;
// mwWMHCommSerialBuffer[n].Valid = 1;
// mwWMHCommSerialBuffer[n].Byte = 0;
// mwWMHCommSerialBuffer[n].Bit = 0;
// mwWMHCommFrameTimerCnts[n].LowLevelTime = 0;
// mwWMHCommFrameTimerCnts[n].HighLevelTime = 0;
// } else {
// ;
// }
// if (mwWMHCommSerialBuffer[n].Bit >= 8) {
// mwWMHCommSerialBuffer[n].Bit = 0;
// // Receive One Byte
// mwWMHCommRecvByte_0x90(mwWMHCommSerialBuffer[n].Byte);
// mwWMHCommSerialBuffer[n].Byte = 0;
// }
// }
// }
// }
// }
}
void
mwWMHCommSendIsr
(
uint32_t
tmpCnts
)
{
uint16_t
n
=
(
uint16_t
)
EM_WMH_COMM_PIN_TX_IDX
;
EM_WMH_COMM_FRAME_T
tmpFrame
=
mwWMHCommFrame
[
n
];
// if (mwWMHCommFrame[EM_WMH_COMM_PIN_RX_ID_wibox] == EM_WMH_COMM_FRAME_STANDBAY){
switch
(
tmpFrame
)
{
case
EM_WMH_COMM_FRAME_STANDBAY
:
{
if
(
mwWMHCommSerialBuffer
[
n
].
OptCnts
!=
mwWMHCommSerialBuffer
[
n
].
FillCnts
)
{
mwWMHCommFrame
[
n
]
=
EM_WMH_COMM_FRAME_START
;
mwWMHCommSerialBuffer
[
n
].
Byte
=
mwWMHCommSerialBuffer
[
n
].
Buffer
[
mwWMHCommSerialBuffer
[
n
].
OptCnts
++
];
mwWMHCommSerialBuffer
[
n
].
OptCnts
=
mwWMHCommSerialBuffer
[
n
].
OptCnts
%
MAX_SERIAL_BUFF_SIZE
;
//RTE_GPIO_Config(RTE_GPIO_PORTB_PIN11, GpioOut_Low);
// GPIOB->PBSC = (1 << (11 + 16));
WMH_COMM
=
0
;
//PORT_ClrBit(GpioMapData[mwWMHCommPin[n]].IoPara.McuIo.pinGroup, GpioMapData[mwWMHCommPin[n]].IoPara.McuIo.pinNum);
}
}
break
;
case
EM_WMH_COMM_FRAME_START
:
case
EM_WMH_COMM_FRAME_LOGIC_1
:
case
EM_WMH_COMM_FRAME_LOGIC_0
:
case
EM_WMH_COMM_FRAME_STOP
:
{
if
(
mwWMHCommFrameTimerCnts
[
n
].
LowLevelTime
<
mwWMHCommSequentialParams
[
tmpFrame
].
Standard
.
LowLevelTime
)
{
//RTE_GPIO_Config(RTE_GPIO_PORTB_PIN11, GpioOut_Low);
// GPIOB->PBSC = (1 << (11 + 16));
WMH_COMM
=
0
;
//PORT_ClrBit(GpioMapData[mwWMHCommPin[n]].IoPara.McuIo.pinGroup, GpioMapData[mwWMHCommPin[n]].IoPara.McuIo.pinNum);
mwWMHCommFrameTimerCnts
[
n
].
LowLevelTime
+=
tmpCnts
;
if
(
mwWMHCommFrameTimerCnts
[
n
].
LowLevelTime
>=
mwWMHCommSequentialParams
[
tmpFrame
].
Standard
.
LowLevelTime
)
{
// GPIOB->PBSC = (1 << 11);
WMH_COMM
=
1
;
//RTE_GPIO_Config(RTE_GPIO_PORTB_PIN11, GpioOut_High);
//PORT_SetBit(GpioMapData[mwWMHCommPin[n]].IoPara.McuIo.pinGroup, GpioMapData[mwWMHCommPin[n]].IoPara.McuIo.pinNum);
}
}
else
if
(
mwWMHCommFrameTimerCnts
[
n
].
HighLevelTime
<
mwWMHCommSequentialParams
[
tmpFrame
].
Standard
.
HighLevelTime
)
{
//RTE_GPIO_Config(RTE_GPIO_PORTB_PIN11, GpioOut_High);
// GPIOB->PBSC = (1 << 11);
WMH_COMM
=
1
;
//PORT_SetBit(GpioMapData[mwWMHCommPin[n]].IoPara.McuIo.pinGroup, GpioMapData[mwWMHCommPin[n]].IoPara.McuIo.pinNum);
mwWMHCommFrameTimerCnts
[
n
].
HighLevelTime
+=
tmpCnts
;
if
(
mwWMHCommFrameTimerCnts
[
n
].
HighLevelTime
>=
mwWMHCommSequentialParams
[
tmpFrame
].
Standard
.
HighLevelTime
)
{
mwWMHCommFrameTimerCnts
[
n
].
LowLevelTime
=
0
;
mwWMHCommFrameTimerCnts
[
n
].
HighLevelTime
=
0
;
if
(
tmpFrame
!=
EM_WMH_COMM_FRAME_STOP
)
{
//RTE_GPIO_Config(RTE_GPIO_PORTB_PIN11, GpioOut_Low);
// GPIOB->PBSC = (1 << (11 + 16));
WMH_COMM
=
0
;
//PORT_ClrBit(GpioMapData[mwWMHCommPin[n]].IoPara.McuIo.pinGroup, GpioMapData[mwWMHCommPin[n]].IoPara.McuIo.pinNum);
if
(
mwWMHCommSerialBuffer
[
n
].
Bit
>=
8
)
{
mwWMHCommSerialBuffer
[
n
].
Bit
=
0
;
if
(
mwWMHCommSerialBuffer
[
n
].
OptCnts
!=
mwWMHCommSerialBuffer
[
n
].
FillCnts
)
{
mwWMHCommSerialBuffer
[
n
].
Byte
=
mwWMHCommSerialBuffer
[
n
].
Buffer
[
mwWMHCommSerialBuffer
[
n
].
OptCnts
++
];
mwWMHCommSerialBuffer
[
n
].
OptCnts
=
mwWMHCommSerialBuffer
[
n
].
OptCnts
%
MAX_SERIAL_BUFF_SIZE
;
}
else
{
mwWMHCommFrame
[
n
]
=
EM_WMH_COMM_FRAME_STOP
;
mwWMHCommSerialBuffer
[
n
].
Valid
=
0
;
//RTE_GPIO_Config(RTE_GPIO_PORTB_PIN11, GpioOut_Low);
// GPIOB->PBSC = (1 << (11 + 16));
WMH_COMM
=
0
;
//PORT_ClrBit(GpioMapData[mwWMHCommPin[n]].IoPara.McuIo.pinGroup, GpioMapData[mwWMHCommPin[n]].IoPara.McuIo.pinNum);
}
}
if
(
mwWMHCommSerialBuffer
[
n
].
Valid
!=
0
)
{
if
((
mwWMHCommSerialBuffer
[
n
].
Byte
&
0x01
)
!=
0
)
{
mwWMHCommFrame
[
n
]
=
EM_WMH_COMM_FRAME_LOGIC_1
;
}
else
{
mwWMHCommFrame
[
n
]
=
EM_WMH_COMM_FRAME_LOGIC_0
;
}
mwWMHCommSerialBuffer
[
n
].
Byte
=
((
mwWMHCommSerialBuffer
[
n
].
Byte
>>
1
)
&
0x7Fu
);
mwWMHCommSerialBuffer
[
n
].
Bit
++
;
}
}
else
{
//RTE_GPIO_Config(RTE_GPIO_PORTB_PIN11, GpioOut_High);
// GPIOB->PBSC = (1 << 11);
WMH_COMM
=
1
;
//PORT_SetBit(GpioMapData[mwWMHCommPin[n]].IoPara.McuIo.pinGroup, GpioMapData[mwWMHCommPin[n]].IoPara.McuIo.pinNum);
mwWMHCommFrame
[
n
]
=
EM_WMH_COMM_FRAME_STANDBAY
;
}
}
}
}
break
;
default:
{
// GPIOB->PBSC = (1 << 11);
WMH_COMM
=
1
;
//PORT_SetBit(GpioMapData[n].IoPara.McuIo.pinGroup, GpioMapData[n].IoPara.McuIo.pinNum);
mwWMHCommFrame
[
n
]
=
EM_WMH_COMM_FRAME_STANDBAY
;
}
break
;
}
// } else {
// mwWMHCommFrameTimerCnts[n].LowLevelTime = 0;
// mwWMHCommFrameTimerCnts[n].HighLevelTime = 0;
// }
}
void
mwWMHCommSendIsr_90
(
uint32_t
tmpCnts
)
{
uint16_t
n
=
(
uint16_t
)
EM_WMH_COMM_PIN_TX_ID_0x90
;
EM_WMH_COMM_FRAME_T
tmpFrame
=
mwWMHCommFrame
[
n
];
// if (mwWMHCommFrame[EM_WMH_COMM_PIN_RX_ID_wibox] == EM_WMH_COMM_FRAME_STANDBAY){
switch
(
tmpFrame
)
{
case
EM_WMH_COMM_FRAME_STANDBAY
:
{
if
(
mwWMHCommSerialBuffer
[
n
].
OptCnts
!=
mwWMHCommSerialBuffer
[
n
].
FillCnts
)
{
mwWMHCommFrame
[
n
]
=
EM_WMH_COMM_FRAME_START
;
mwWMHCommSerialBuffer
[
n
].
Byte
=
mwWMHCommSerialBuffer
[
n
].
Buffer
[
mwWMHCommSerialBuffer
[
n
].
OptCnts
++
];
mwWMHCommSerialBuffer
[
n
].
OptCnts
=
mwWMHCommSerialBuffer
[
n
].
OptCnts
%
MAX_SERIAL_BUFF_SIZE
;
//RTE_GPIO_Config(RTE_GPIO_PORTB_PIN11, GpioOut_Low);
// GPIOB->PBSC = (1 << (11 + 16));
WMH_COMM90
=
0
;
//PORT_ClrBit(GpioMapData[mwWMHCommPin[n]].IoPara.McuIo.pinGroup, GpioMapData[mwWMHCommPin[n]].IoPara.McuIo.pinNum);
}
}
break
;
case
EM_WMH_COMM_FRAME_START
:
case
EM_WMH_COMM_FRAME_LOGIC_1
:
case
EM_WMH_COMM_FRAME_LOGIC_0
:
case
EM_WMH_COMM_FRAME_STOP
:
{
if
(
mwWMHCommFrameTimerCnts
[
n
].
LowLevelTime
<
mwWMHCommSequentialParams
[
tmpFrame
].
Standard
.
LowLevelTime
)
{
//RTE_GPIO_Config(RTE_GPIO_PORTB_PIN11, GpioOut_Low);
// GPIOB->PBSC = (1 << (11 + 16));
WMH_COMM90
=
0
;
//PORT_ClrBit(GpioMapData[mwWMHCommPin[n]].IoPara.McuIo.pinGroup, GpioMapData[mwWMHCommPin[n]].IoPara.McuIo.pinNum);
mwWMHCommFrameTimerCnts
[
n
].
LowLevelTime
+=
tmpCnts
;
if
(
mwWMHCommFrameTimerCnts
[
n
].
LowLevelTime
>=
mwWMHCommSequentialParams
[
tmpFrame
].
Standard
.
LowLevelTime
)
{
// GPIOB->PBSC = (1 << 11);
WMH_COMM90
=
1
;
//RTE_GPIO_Config(RTE_GPIO_PORTB_PIN11, GpioOut_High);
//PORT_SetBit(GpioMapData[mwWMHCommPin[n]].IoPara.McuIo.pinGroup, GpioMapData[mwWMHCommPin[n]].IoPara.McuIo.pinNum);
}
}
else
if
(
mwWMHCommFrameTimerCnts
[
n
].
HighLevelTime
<
mwWMHCommSequentialParams
[
tmpFrame
].
Standard
.
HighLevelTime
)
{
//RTE_GPIO_Config(RTE_GPIO_PORTB_PIN11, GpioOut_High);
// GPIOB->PBSC = (1 << 11);
WMH_COMM90
=
1
;
//PORT_SetBit(GpioMapData[mwWMHCommPin[n]].IoPara.McuIo.pinGroup, GpioMapData[mwWMHCommPin[n]].IoPara.McuIo.pinNum);
mwWMHCommFrameTimerCnts
[
n
].
HighLevelTime
+=
tmpCnts
;
if
(
mwWMHCommFrameTimerCnts
[
n
].
HighLevelTime
>=
mwWMHCommSequentialParams
[
tmpFrame
].
Standard
.
HighLevelTime
)
{
mwWMHCommFrameTimerCnts
[
n
].
LowLevelTime
=
0
;
mwWMHCommFrameTimerCnts
[
n
].
HighLevelTime
=
0
;
if
(
tmpFrame
!=
EM_WMH_COMM_FRAME_STOP
)
{
//RTE_GPIO_Config(RTE_GPIO_PORTB_PIN11, GpioOut_Low);
// GPIOB->PBSC = (1 << (11 + 16));
WMH_COMM90
=
0
;
//PORT_ClrBit(GpioMapData[mwWMHCommPin[n]].IoPara.McuIo.pinGroup, GpioMapData[mwWMHCommPin[n]].IoPara.McuIo.pinNum);
if
(
mwWMHCommSerialBuffer
[
n
].
Bit
>=
8
)
{
mwWMHCommSerialBuffer
[
n
].
Bit
=
0
;
if
(
mwWMHCommSerialBuffer
[
n
].
OptCnts
!=
mwWMHCommSerialBuffer
[
n
].
FillCnts
)
{
mwWMHCommSerialBuffer
[
n
].
Byte
=
mwWMHCommSerialBuffer
[
n
].
Buffer
[
mwWMHCommSerialBuffer
[
n
].
OptCnts
++
];
mwWMHCommSerialBuffer
[
n
].
OptCnts
=
mwWMHCommSerialBuffer
[
n
].
OptCnts
%
MAX_SERIAL_BUFF_SIZE
;
}
else
{
mwWMHCommFrame
[
n
]
=
EM_WMH_COMM_FRAME_STOP
;
mwWMHCommSerialBuffer
[
n
].
Valid
=
0
;
//RTE_GPIO_Config(RTE_GPIO_PORTB_PIN11, GpioOut_Low);
// GPIOB->PBSC = (1 << (11 + 16));
WMH_COMM90
=
0
;
//PORT_ClrBit(GpioMapData[mwWMHCommPin[n]].IoPara.McuIo.pinGroup, GpioMapData[mwWMHCommPin[n]].IoPara.McuIo.pinNum);
}
}
if
(
mwWMHCommSerialBuffer
[
n
].
Valid
!=
0
)
{
if
((
mwWMHCommSerialBuffer
[
n
].
Byte
&
0x01
)
!=
0
)
{
mwWMHCommFrame
[
n
]
=
EM_WMH_COMM_FRAME_LOGIC_1
;
}
else
{
mwWMHCommFrame
[
n
]
=
EM_WMH_COMM_FRAME_LOGIC_0
;
}
mwWMHCommSerialBuffer
[
n
].
Byte
=
((
mwWMHCommSerialBuffer
[
n
].
Byte
>>
1
)
&
0x7Fu
);
mwWMHCommSerialBuffer
[
n
].
Bit
++
;
}
}
else
{
//RTE_GPIO_Config(RTE_GPIO_PORTB_PIN11, GpioOut_High);
// GPIOB->PBSC = (1 << 11);
WMH_COMM90
=
1
;
//PORT_SetBit(GpioMapData[mwWMHCommPin[n]].IoPara.McuIo.pinGroup, GpioMapData[mwWMHCommPin[n]].IoPara.McuIo.pinNum);
mwWMHCommFrame
[
n
]
=
EM_WMH_COMM_FRAME_STANDBAY
;
}
}
}
}
break
;
default:
{
// GPIOB->PBSC = (1 << 11);
WMH_COMM90
=
1
;
//PORT_SetBit(GpioMapData[n].IoPara.McuIo.pinGroup, GpioMapData[n].IoPara.McuIo.pinNum);
mwWMHCommFrame
[
n
]
=
EM_WMH_COMM_FRAME_STANDBAY
;
}
break
;
}
// } else {
// mwWMHCommFrameTimerCnts[n].LowLevelTime = 0;
// mwWMHCommFrameTimerCnts[n].HighLevelTime = 0;
// }
}
void
mwWMHCommTransmitBytes
(
uint8_t
*
data
,
uint32_t
length
)
{
uint32_t
i
=
0
;
uint16_t
n
=
(
uint16_t
)
EM_WMH_COMM_PIN_TX_IDX
;
if
((
length
>
0
)
&&
(
mwWMHCommSerialBuffer
[
n
].
Valid
==
0
))
{
for
(
i
=
0
;
i
<
length
;
i
++
)
{
mwWMHCommSerialBuffer
[
n
].
Buffer
[
mwWMHCommSerialBuffer
[
n
].
FillCnts
++
]
=
data
[
i
];
mwWMHCommSerialBuffer
[
n
].
FillCnts
=
mwWMHCommSerialBuffer
[
n
].
FillCnts
%
MAX_SERIAL_BUFF_SIZE
;
}
mwWMHCommSerialBuffer
[
n
].
Valid
=
1
;
}
}
void
mwWMHCommTransmitBytes_90
(
uint8_t
*
data
,
uint32_t
length
)
{
uint32_t
i
=
0
;
uint16_t
n
=
(
uint16_t
)
EM_WMH_COMM_PIN_TX_ID_0x90
;
if
((
length
>
0
)
&&
(
mwWMHCommSerialBuffer
[
n
].
Valid
==
0
))
{
for
(
i
=
0
;
i
<
length
;
i
++
)
{
mwWMHCommSerialBuffer
[
n
].
Buffer
[
mwWMHCommSerialBuffer
[
n
].
FillCnts
++
]
=
data
[
i
];
mwWMHCommSerialBuffer
[
n
].
FillCnts
=
mwWMHCommSerialBuffer
[
n
].
FillCnts
%
MAX_SERIAL_BUFF_SIZE
;
}
mwWMHCommSerialBuffer
[
n
].
Valid
=
1
;
}
// if ((length > 0) && (mwWMHCommSerialBuffer[n2].Valid == 0))
// {
// for (i = 0; i < length; i++)
// {
// mwWMHCommSerialBuffer[n2].Buffer[mwWMHCommSerialBuffer[n2].FillCnts++] = data[i];
// mwWMHCommSerialBuffer[n2].FillCnts = mwWMHCommSerialBuffer[n2].FillCnts % MAX_SERIAL_BUFF_SIZE;
// }
// mwWMHCommSerialBuffer[n2].Valid = 1;
// }
}
void
mwWMHCommRecvByte_0x90
(
uint8_t
data
)
{
// uint16_t n = (uint16_t)EM_WMH_COMM_PIN_RX_ID_0x90;
// mwWMHCommSerialBuffer[n].Buffer[mwWMHCommSerialBuffer[n].FillCnts++] = data;
// mwWMHCommSerialBuffer[n].FillCnts = mwWMHCommSerialBuffer[n].FillCnts % MAX_SERIAL_BUFF_SIZE;
}
void
mwWMHCommRecvByte_wibox
(
uint8_t
data
)
{
uint16_t
n
=
(
uint16_t
)
EM_WMH_COMM_PIN_RX_ID_wibox
;
mwWMHCommSerialBuffer
[
n
].
Buffer
[
mwWMHCommSerialBuffer
[
n
].
FillCnts
++
]
=
data
;
mwWMHCommSerialBuffer
[
n
].
FillCnts
=
mwWMHCommSerialBuffer
[
n
].
FillCnts
%
MAX_SERIAL_BUFF_SIZE
;
// if ((mwWMHCommSerialBuffer[n].FillCnts / MAX_SERIAL_BUFF_SIZE)==1)
// {
// memset(mwWMHCommSerialBuffer[n].Buffer,0,64);
// }
}
uint8_t
*
mwWMHCommGetRecvData
(
uint32_t
*
BufferLen
,
uint32_t
*
RecvPos
)
{
uint8_t
*
ret
=
NULL_P
;
// uint16_t n1 = (uint16_t)EM_WMH_COMM_PIN_RX_ID_0x90;
uint16_t
n2
=
(
uint16_t
)
EM_WMH_COMM_PIN_RX_ID_wibox
;
// if (mwWMHCommSerialBuffer[n1].Valid == 1) {
// *BufferLen = MAX_SERIAL_BUFF_SIZE;
// *RecvPos = mwWMHCommSerialBuffer[n1].FillCnts;
// ret = mwWMHCommSerialBuffer[n1].Buffer;
// mwWMHCommSerialBuffer[n1].Valid = 0;
// }
if
(
mwWMHCommSerialBuffer
[
n2
].
Valid
==
1
)
{
*
BufferLen
=
MAX_SERIAL_BUFF_SIZE
;
*
RecvPos
=
mwWMHCommSerialBuffer
[
n2
].
FillCnts
;
ret
=
mwWMHCommSerialBuffer
[
n2
].
Buffer
;
mwWMHCommSerialBuffer
[
n2
].
Valid
=
0
;
}
return
ret
;
}
YueJin_test_bench/source/Appliciation/mwWMHComm.h
0 → 100644
View file @
54075b63
#ifndef __MW_WMH_COMM_H_
#define __MW_WMH_COMM_H_
#include "TYW_stdint.h"
#define NULL_P (void *)0
typedef
enum
{
EM_WMH_COMM_PIN_TX_IDX
=
0
,
//91,92
EM_WMH_COMM_PIN_TX_ID_0x90
,
//90
EM_WMH_COMM_PIN_RX_ID_wibox
,
EM_WMH_COMM_PIN_TOTAL
,
}
EM_WMH_COMM_PIN_T
;
// static const IO_NUM_ENUM mwWMHCommPin[EM_WMH_COMM_PIN_TOTAL] = {
// IO_NUM_MCU_ONE_LINE_COMM_TX,
// IO_NUM_MCU_ONE_LINE_COMM_RX,
// };
typedef
enum
{
EM_WMH_COMM_FRAME_STANDBAY
=
0
,
EM_WMH_COMM_FRAME_START
,
EM_WMH_COMM_FRAME_LOGIC_1
,
EM_WMH_COMM_FRAME_LOGIC_0
,
EM_WMH_COMM_FRAME_STOP
,
EM_WMH_COMM_FRAME_TOTAL
,
}
EM_WMH_COMM_FRAME_T
;
typedef
struct
{
uint32_t
LowLevelTime
;
// us
uint32_t
HighLevelTime
;
// us
}
MW_WMH_COMM_TIMER_T
;
typedef
struct
{
MW_WMH_COMM_TIMER_T
Standard
;
MW_WMH_COMM_TIMER_T
UpperLimit
;
MW_WMH_COMM_TIMER_T
LowerLimit
;
}
MW_WMH_COMM_SEQUENTIAL_T
;
extern
void
mwWMHCommInit
(
void
);
extern
void
mwWMHCommRecvIsr_0x90
(
uint32_t
tmpCnts
);
extern
void
mwWMHCommRecvIsr_wibox
(
uint32_t
tmpCnts
);
extern
void
mwWMHCommSendIsr
(
uint32_t
tmpCnts
);
extern
void
mwWMHCommSendIsr_90
(
uint32_t
tmpCnts
);
extern
void
mwWMHCommTransmitBytes
(
uint8_t
*
data
,
uint32_t
length
);
extern
void
mwWMHCommTransmitBytes_90
(
uint8_t
*
data
,
uint32_t
length
);
extern
uint8_t
*
mwWMHCommGetRecvData
(
uint32_t
*
BufferLen
,
uint32_t
*
RecvPos
);
extern
void
mwWMHCommRecvByte_0x90
(
uint8_t
data
);
extern
void
mwWMHCommRecvByte_wibox
(
uint8_t
data
);
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment