Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
TianYing_ty100
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
TY
TianYing_ty100
Commits
1b44baf5
Commit
1b44baf5
authored
May 06, 2024
by
李俭双
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'lijianshuang' into 'dev'
Lijianshuang See merge request
!9
parents
c19632df
63eebee0
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
184 additions
and
130 deletions
+184
-130
CAN_CH0_CAN_Communication_Matrix.c
...ce/Application/CAN_APP/CAN_CH0_CAN_Communication_Matrix.c
+4
-4
Can_App.c
Firmware/Source/Application/CAN_User/Can_App.c
+52
-14
Can_App.h
Firmware/Source/Application/CAN_User/Can_App.h
+77
-11
CommonInterface.c
...ware/Source/Application/CommonInterface/CommonInterface.c
+1
-4
Data_VSpeed.c
Firmware/Source/Application/Data_VSpeed/Data_VSpeed.c
+50
-97
No files found.
Firmware/Source/Application/CAN_APP/CAN_CH0_CAN_Communication_Matrix.c
View file @
1b44baf5
...
...
@@ -8,10 +8,10 @@ st_CanMsgTxOp CAN_CH0_CanMsgTxOp;
const
st_CAN_SendAttribute
CAN_CH0_CANSendAttr
[
CAN_CH0_ID_SEND_TOTAL
]
=
{
{
0x220ul
,
8ul
*
1000ul
,
7ul
*
1000ul
,
0u
,
MSG_STD
,
1u
,
8u
,
CAN_MSG_TX_CYCLE
,
Can_Set_Buff_50
0
,
(
void
*
)
0
},
{
0x6EEul
,
8ul
*
1000ul
,
7ul
*
1000ul
,
0u
,
MSG_STD
,
1u
,
8u
,
CAN_MSG_TX_CYCLE
,
Can_Set_Buff_
500
,
(
void
*
)
0
},
{
0x6EFul
,
8ul
*
1000ul
,
7ul
*
1000ul
,
0u
,
MSG_STD
,
1u
,
8u
,
CAN_MSG_TX_CYCLE
,
Can_Set_Buff_
500
,
(
void
*
)
0
},
{
0x450ul
,
8ul
*
1000ul
,
7ul
*
1000ul
,
0u
,
MSG_STD
,
1u
,
8u
,
CAN_MSG_TX_CYCLE
,
Can_Set_Buff_
50
0
,
(
void
*
)
0
},
{
0x220ul
,
50ul
*
1000ul
,
7ul
*
1000ul
,
0u
,
MSG_STD
,
1u
,
8u
,
CAN_MSG_TX_CYCLE
,
Can_Set_Buff_22
0
,
(
void
*
)
0
},
{
0x6EEul
,
8ul
*
1000ul
,
7ul
*
1000ul
,
0u
,
MSG_STD
,
1u
,
8u
,
CAN_MSG_TX_CYCLE
,
Can_Set_Buff_
6EE
,
(
void
*
)
0
},
{
0x6EFul
,
8ul
*
1000ul
,
7ul
*
1000ul
,
0u
,
MSG_STD
,
1u
,
8u
,
CAN_MSG_TX_CYCLE
,
Can_Set_Buff_
6EF
,
(
void
*
)
0
},
{
0x450ul
,
8ul
*
1000ul
,
7ul
*
1000ul
,
0u
,
MSG_STD
,
1u
,
8u
,
CAN_MSG_TX_CYCLE
,
Can_Set_Buff_
45
0
,
(
void
*
)
0
},
};
const
st_CANMsgAttribute
CAN_CH0_CAN_MSG_CONST_ARRAY
[
CAN_CH0_ID_TOTAL_MAX
]
=
...
...
Firmware/Source/Application/CAN_User/Can_App.c
View file @
1b44baf5
#include "Can_App.h"
#include "Components.h"
void
Can_Set_Buff_
50
0
(
canlib_uint8_t
CopyData
[])
void
Can_Set_Buff_
22
0
(
canlib_uint8_t
CopyData
[])
{
CANMsg
500Union
*
p50
0
;
CANMsg
220Union
*
p22
0
;
uint8_t
i
=
0
;
for
(
i
=
0
;
i
<
8
;
i
++
)
p220
=
(
CANMsg220Union
*
)
CopyData
;
if
(
p220
!=
(
void
*
)
0
)
{
for
(
i
=
0u
;
i
<
8u
;
i
++
)
{
p220
->
Msg
[
i
]
=
0xFFu
;
}
}
p220
->
Sig
.
TCS_TX
=
Get_Dis_Tcs_Val
();
}
void
Can_Set_Buff_6EE
(
canlib_uint8_t
CopyData
[])
{
CANMsg6EEUnion
*
p6EE
;
uint8_t
i
=
0
;
p6EE
=
(
CANMsg6EEUnion
*
)
CopyData
;
if
(
p6EE
!=
(
void
*
)
0
)
{
for
(
i
=
0u
;
i
<
8u
;
i
++
)
{
p6EE
->
Msg
[
i
]
=
0xFFu
;
}
}
}
void
Can_Set_Buff_6EF
(
canlib_uint8_t
CopyData
[])
{
CANMsg6EFUnion
*
p6EF
;
uint8_t
i
=
0
;
p6EF
=
(
CANMsg6EFUnion
*
)
CopyData
;
if
(
p6EF
!=
(
void
*
)
0
)
{
CopyData
[
i
]
=
0xFFU
;
for
(
i
=
0u
;
i
<
8u
;
i
++
)
{
p6EF
->
Msg
[
i
]
=
0xFFu
;
}
}
p500
=
(
CANMsg500Union
*
)
CopyData
;
if
(
p500
!=
(
void
*
)
0
)
}
void
Can_Set_Buff_450
(
canlib_uint8_t
CopyData
[])
{
CANMsg450Union
*
p450
;
uint8_t
i
=
0
;
p450
=
(
CANMsg450Union
*
)
CopyData
;
if
(
p450
!=
(
void
*
)
0
)
{
//p500->Sig.Key_ISTOP = Auto_Start_Stop;
p500
->
Msg
[
1
]
=
0x00
;
p500
->
Msg
[
2
]
=
0x00
;
p500
->
Msg
[
3
]
=
0x00
;
p500
->
Msg
[
4
]
=
0x00
;
p500
->
Msg
[
5
]
=
0x00
;
p500
->
Msg
[
6
]
=
0x00
;
p500
->
Msg
[
7
]
=
0x00
;
for
(
i
=
0u
;
i
<
8u
;
i
++
)
{
p450
->
Msg
[
i
]
=
0xFFu
;
}
}
}
Firmware/Source/Application/CAN_User/Can_App.h
View file @
1b44baf5
...
...
@@ -11,22 +11,88 @@ typedef union
uint8_t
Msg
[
8
];
struct
{
uint8_t
Key_ISTOP
:
8
;
uint8_t
Res1
:
8
;
uint8_t
Res2
:
8
;
uint8_t
Res3
:
8
;
uint8_t
Res4
:
8
;
uint8_t
Res5
:
8
;
uint8_t
Res6
:
8
;
uint8_t
Res7
:
8
;
uint32_t
Res0
:
3
;
uint32_t
TCS_TX
:
1
;
uint32_t
Res1
:
4
;
uint32_t
Res2
:
8
;
uint32_t
Res3
:
16
;
uint32_t
Res4
:
32
;
}
Sig
;
}
CANMsg220Union
;
typedef
union
{
uint8_t
Msg
[
8
];
struct
{
uint32_t
Coolant_Seg_TX
:
4
;
uint32_t
Fuel_Seg_TX
:
4
;
uint32_t
Res0
:
8
;
uint32_t
Fuel_Res_TX
:
8
;
uint32_t
Vsppe_H3_TX
:
3
;
uint32_t
Res1
:
1
;
uint32_t
Coolant_Warn_TX
:
1
;
uint32_t
Res2
:
2
;
uint32_t
Uint_TX
:
1
;
uint32_t
Vsppe_L8_TX
:
8
;
uint32_t
ODO_TX
:
24
;
}
Sig
;
}
CANMsg6EEUnion
;
typedef
union
{
uint8_t
Msg
[
8
];
struct
{
uint32_t
Espeed_TX
:
8
;
uint32_t
Coolant_TX
:
8
;
uint32_t
TripA
:
16
;
uint32_t
TripB
:
16
;
uint32_t
Res1
:
16
;
}
Sig
;
}
CANMsg6EFUnion
;
typedef
union
{
uint8_t
Msg
[
8
];
struct
{
uint32_t
Front_Pressure_TX
:
16
;
uint32_t
Rear_Pressure_TX
:
16
;
//uint32_t Front_Air_Leakage_TX : 1;
//uint32_t Rear_Air_Leakage_TX : 1;
//uint32_t Front_Low_Voltage_TX : 1;
//uint32_t Rear_Low_Voltage_TX : 1;
//uint32_t Front_High_Temp_TX : 1;
//uint32_t Rear_High_Temp_TX : 1;
//uint32_t Res0 : 2;
uint32_t
Res1
:
32
;
}
Sig
;
}
CANMsg
50
0Union
;
}
CANMsg
45
0Union
;
void
Can_Set_Buff_500
(
canlib_uint8_t
CopyData
[]);
void
Can_Set_Buff_220
(
canlib_uint8_t
CopyData
[]);
void
Can_Set_Buff_6EE
(
canlib_uint8_t
CopyData
[]);
void
Can_Set_Buff_6EF
(
canlib_uint8_t
CopyData
[]);
void
Can_Set_Buff_450
(
canlib_uint8_t
CopyData
[]);
#endif
Firmware/Source/Application/CommonInterface/CommonInterface.c
View file @
1b44baf5
...
...
@@ -168,10 +168,7 @@ uint32_t Common_GetSocTime(void)
*/
uint32_t
Data_Km_To_Mile
(
uint32_t
Km
)
{
//Km *= 621;
//Km /= 1000;
Km
*=
100
;
Km
/=
161
;
Km
=
(
Km
*
64u
)
/
103u
;
return
Km
;
}
/**
...
...
Firmware/Source/Application/Data_VSpeed/Data_VSpeed.c
View file @
1b44baf5
...
...
@@ -69,108 +69,62 @@ void Data_Vehicle_Speed_Processing_Service(void)
uint16_t
Delta
;
uint32_t
VSpeed
;
uint32_t
VSpeedCal
;
//uint8_t ESC_VehicleSpeedvalid
;
uint8_t
ESC_VehicleSpeedState
;
uint32_t
Vehicle_Speed
;
Vehicle_Speed
=
Get_CAN_CH0_ID_101_Sig_ECU_Vehicle_Speed
(
);
//ESC_VehicleSpeedvalid = Get_CAN_CH0_ID_330_Sig_ESC_Vehicle_speed_valid
( );
ESC_VehicleSpeedState
=
Get_CAN_CH0_ID_101_Sig_ECU_Vehicle_Speed_State
(
);
// 第1步:获取实际车速值及车速有效性
if
(
Common_Get_IG_Sts
(
)
==
COMMON_POWER_ON
)
{
if
((
CAN_MSG_Status
(
&
CAN_CH0_CanMsgOp
,
CAN_CH0_ID_CAN_0x101_Msg_Count
)
==
CAN_SIG_LOST
)
||
(
Vehicle_Speed
>
0XFF
))
{
if
(
CAN_MSG_Status
(
&
CAN_CH0_CanMsgOp
,
CAN_CH0_ID_CAN_0x101_Msg_Count
)
==
CAN_SIG_LOST
)
{
DataVSpeedValid
=
0
;
DataVSpeedActual
=
0
;
DataVSpeedSampler
.
Backup
=
0
;
}
else
{
/* 先判断掉线 */
if
(
CAN_MSG_Status
(
&
CAN_CH0_CanMsgOp
,
CAN_CH0_ID_CAN_0x101_Msg_Count
)
==
CAN_SIG_LOST
)
if
(
ESC_VehicleSpeedState
==
1
)
{
DataVSpeedValid
=
0
;
DataVSpeedActual
=
0
;
DataVSpeedSampler
.
Backup
=
0
;
}
#if 0
else if ( ESC_VehicleSpeedvalid == 1 )//发送can无效标志位
else
{
if ( DataVSpeedSampler.Timer1 <= 10 ) /* 10帧无效 */
{
if ( DataVSpeedValid )//判断车速是否有效,有效采集10次,车速等于上次值
{
DataVSpeedSampler.Timer1++;
DataVSpeedActual = DataVSpeedSampler.Backup;
}
else//无效,不采集,车速=0
{
DataVSpeedSampler.Timer1 = 10;
DataVSpeedActual = 0;
DataVSpeedSampler.Backup = 0;
}
}
else//不采集就,车速=0
if
(
DataVSpeedValid
==
0
)
{
DataVSpeedValid
= 0
;
DataVSpeedActual = 0;
DataVSpeed
Sampler.Backup =
0;
DataVSpeedValid
=
1
;
VSpeed
=
Vehicle_Speed
;
DataVSpeed
Actual
=
VSpeed
*
1
0
;
}
}
#endif
else
/* 收到无效值 */
{
if
(
DataVSpeedSampler
.
Timer
<=
100
)
/* 100帧无效值 */
else
{
if
(
DataVSpeedValid
)
DataVSpeedSampler
.
Buffer
[
DataVSpeedSampler
.
Cnt
]
=
Vehicle_Speed
;
i
=
DataVSpeedSampler
.
Cnt
;
while
(
(
i
>
0
)
&&
(
DataVSpeedSampler
.
Buffer
[
i
]
<
DataVSpeedSampler
.
Buffer
[
i
-
1
])
)
{
DataVSpeedSampler
.
Timer
++
;
DataVSpeedActual
=
DataVSpeedSampler
.
Backup
;
VSpeed
=
DataVSpeedSampler
.
Buffer
[
i
];
DataVSpeedSampler
.
Buffer
[
i
]
=
DataVSpeedSampler
.
Buffer
[
i
-
1
];
DataVSpeedSampler
.
Buffer
[
i
-
1
]
=
VSpeed
;
i
--
;
}
else
DataVSpeedSampler
.
Cnt
++
;
if
(
DataVSpeedSampler
.
Cnt
>=
3
)
{
DataVSpeedSampler
.
Timer
=
10
0
;
DataVSpeedActual
=
0
;
DataVSpeed
Sampler
.
Backup
=
0
;
DataVSpeedSampler
.
Cnt
=
0
;
VSpeed
=
DataVSpeedSampler
.
Buffer
[
1
];
DataVSpeed
Actual
=
VSpeed
*
1
0
;
}
DataVSpeedSampler
.
Timer
=
0
;
DataVSpeedSampler
.
Timer1
=
0
;
DataVSpeedSampler
.
Backup
=
DataVSpeedActual
;
DataVSpeedValid
=
1
;
}
else
// 接收到100帧无效值
{
DataVSpeedValid
=
0
;
DataVSpeedActual
=
0
;
DataVSpeedSampler
.
Backup
=
0
;
}
}
}
else
//车速在线且有效
{
if
(
DataVSpeedValid
==
0
)
{
DataVSpeedValid
=
1
;
VSpeed
=
Vehicle_Speed
;
// VSpeed *= 9;
// VSpeed >>= 4;
DataVSpeedActual
=
VSpeed
*
10
;
}
else
{
DataVSpeedSampler
.
Buffer
[
DataVSpeedSampler
.
Cnt
]
=
Vehicle_Speed
;
i
=
DataVSpeedSampler
.
Cnt
;
while
(
(
i
>
0
)
&&
(
DataVSpeedSampler
.
Buffer
[
i
]
<
DataVSpeedSampler
.
Buffer
[
i
-
1
])
)
{
VSpeed
=
DataVSpeedSampler
.
Buffer
[
i
];
DataVSpeedSampler
.
Buffer
[
i
]
=
DataVSpeedSampler
.
Buffer
[
i
-
1
];
DataVSpeedSampler
.
Buffer
[
i
-
1
]
=
VSpeed
;
i
--
;
}
DataVSpeedSampler
.
Cnt
++
;
if
(
DataVSpeedSampler
.
Cnt
>=
3
)
{
DataVSpeedSampler
.
Cnt
=
0
;
VSpeed
=
DataVSpeedSampler
.
Buffer
[
1
];
//VSpeed *= 9;
//VSpeed >>= 4;
DataVSpeedActual
=
VSpeed
*
10
;
}
DataVSpeedSampler
.
Timer
=
0
;
DataVSpeedSampler
.
Timer1
=
0
;
DataVSpeedSampler
.
Backup
=
DataVSpeedActual
;
}
}
}
...
...
@@ -251,8 +205,8 @@ void Data_Vehicle_Speed_Processing_Service(void)
else
{
DataVSPeedDamping
.
Speed
+=
Delta
;
if
(
DataVSPeedDamping
.
Speed
>
1
20
0
)
DataVSPeedDamping
.
Speed
=
1
20
0
;
if
(
DataVSPeedDamping
.
Speed
>
1
99
0
)
DataVSPeedDamping
.
Speed
=
1
99
0
;
}
}
else
// 显示值正在向实际值减小,则维持当前方向调节增加速度
...
...
@@ -300,8 +254,8 @@ void Data_Vehicle_Speed_Processing_Service(void)
else
{
DataVSPeedDamping
.
Speed
+=
Delta
;
if
(
DataVSPeedDamping
.
Speed
>
1
20
0
)
DataVSPeedDamping
.
Speed
=
1
20
0
;
if
(
DataVSPeedDamping
.
Speed
>
1
99
0
)
DataVSPeedDamping
.
Speed
=
1
99
0
;
}
}
else
// 显示值当前是减小方向
...
...
@@ -336,12 +290,14 @@ void Data_Vehicle_Speed_Processing_Service(void)
if
(
DataVSpeedValid
)
{
VSpeedCal
*=
10
8
;
VSpeedCal
*=
10
7
;
VSpeedCal
/=
100
;
if
((
VSpeedCal
%
10
)
>=
5
)
VSpeedCal
=
VSpeedCal
+
10
;
if
(
VSpeedCal
>
1990
)
{
VSpeedCal
+=
5
;
/* 四舍五入 */
VSpeedCal
=
1990
;
}
DataVSpeedDisp
=
(
uint16_t
)
VSpeedCal
;
}
else
...
...
@@ -366,24 +322,21 @@ uint16_t Get_DispVechileSpeed(void)
uint16_t
Vspeed
=
0
;
if
(
Get_Dis_KM_Unit
()
==
0
)
/* KM */
{
if
(
DataVSpeedDisp
>=
1
20
0
)
if
(
DataVSpeedDisp
>=
1
99
0
)
{
DataVSpeedDisp
=
1
20
0
;
DataVSpeedDisp
=
1
99
0
;
}
Vspeed
=
DataVSpeedDisp
;
}
else
//if (Get_Dis_KM_Unit() == 1)
/* MILE */
else
/* MILE */
{
Vspeed
=
Data_Km_To_Mile
(
DataVSpeedDisp
);
if
(
Vspeed
>=
75
0
)
if
(
Vspeed
>=
123
0
)
{
Vspeed
=
75
0
;
Vspeed
=
123
0
;
}
}
// else
// {
// ;
// }
return
Vspeed
;
}
...
...
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