Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
V
VC66_7C
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
ISUZU
VC66_7C
Commits
435ca6de
Commit
435ca6de
authored
Oct 21, 2023
by
hu
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'menutest' into withBoot_ENCN
parents
54509772
fa5f01c5
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
1238 additions
and
1014 deletions
+1238
-1014
Data_VehicleSpeed.c
source/Application/APP/Data_VehicleSpeed/Data_VehicleSpeed.c
+1
-1
PowerManagement_user.c
...ce/Application/APP/PowerManagement/PowerManagement_user.c
+4
-1
System_Monitor.c
source/Application/APP/PowerManagement/System_Monitor.c
+756
-593
System_Monitor.h
source/Application/APP/PowerManagement/System_Monitor.h
+97
-106
System_Monitor_user.c
source/Application/APP/PowerManagement/System_Monitor_user.c
+154
-182
Common_Interface.c
source/Application/RTE/Common_Interface.c
+25
-25
Common_Interface.h
source/Application/RTE/Common_Interface.h
+1
-1
Rscan.c
source/Driver/CAN/Rscan.c
+190
-95
Clock.c
source/Driver/Clock/Clock.c
+3
-3
d1mx.ld
source/System/d1mx.ld
+1
-1
init.c
source/System/init.c
+4
-4
init.h
source/System/init.h
+1
-1
tasks.c
source/System/tasks.c
+1
-1
No files found.
source/Application/APP/Data_VehicleSpeed/Data_VehicleSpeed.c
View file @
435ca6de
...
...
@@ -146,7 +146,7 @@ void Speed_Processing_Service(void)
{
Vehicle_ACT_Speed
=
1400u
;
}
else
if
(
VehValCup
<=
4
0u
)
else
if
(
VehValCup
<=
3
0u
)
{
Vehicle_ACT_Speed
=
0u
;
}
...
...
source/Application/APP/PowerManagement/PowerManagement_user.c
View file @
435ca6de
...
...
@@ -67,6 +67,8 @@
static
uint8_t
PowerGetNMStatus
(
void
);
extern
void
SEG_LCD_Window_Switch
(
uint8_t
Sw
);
extern
void
DelayUs
(
uint32_t
time
);
extern
void
Sys_KL30_Init
(
void
);
extern
void
Sys_Wakeup_Init
(
void
);
Power_Status_t
Power_KL30_Init
(
void
)
{
...
...
@@ -311,7 +313,8 @@ Power_Status_t Power_Stay_ON(void)
u8PowerSts
=
m_IGN_ON
;
}
}
if
(((
u8Condition3
==
1u
)
||
(
u8Condition3
>=
7u
)))
//if (((u8Condition3 == 1u) || (u8Condition3 >= 7u)))
if
(
SYS_OPR_STAT_HALT
)
{
u8PowerSts
=
m_IGN_LIMIT
;
}
...
...
source/Application/APP/PowerManagement/System_Monitor.c
View file @
435ca6de
...
...
@@ -2,8 +2,22 @@
#include "System_Monitor.h"
#define Base_Vol 0u
typedef
struct
{
monitorlib_uint8_t
SumCnt
;
monitorlib_uint16_t
DebounceTimer
;
monitorlib_uint32_t
ActVoltage
;
monitorlib_uint8_t
FinalSts
;
monitorlib_uint8_t
ActSts
;
}
MonitorStruct
;
MonitorStruct
SysFun_KL30Monitor
;
MonitorStruct
SysFun_KL15Monitor
;
MonitorStruct
SysNM_KL30Monitor
;
MonitorStruct
SysNM_KL15Monitor
;
#define Base_Vol 0u
#define ENTER_LOW_N_RANGE 6500U
#define EXIT_LOW_N_RANGE 7000U
...
...
@@ -20,21 +34,19 @@
#define Top_Vol 0xffffu
MonitorStruct
SysFun_KL30Monitor
;
MonitorStruct
SysFun_KL15Monitor
;
static
monitorlib_uint8_t
System_Calc_NMRange
(
monitorlib_uint16_t
u16Vol
);
static
monitorlib_uint8_t
System_Calc_FunRange
(
monitorlib_uint16_t
u16Vol
);
MonitorStruct
SysNM_KL30Monitor
;
MonitorStruct
SysNM_KL15Monitor
;
static
void
System_Fast_WakeUp
(
void
);
static
void
System_Fun_Process
(
void
);
static
void
System_NM_Process
(
void
);
uint8_t
SysWakeUpMode
=
0u
;
static
uint8_t
SetVolFlag
=
0u
;
MonitorExt_st
pfunction
;
static
uint16_t
t_NM_KL30_Debounce
;
static
uint16_t
t_NM_KL15_Debounce
;
static
uint16_t
t_FUN_KL30_Debounce
;
static
uint16_t
t_FUN_KL15_Debounce
;
monitorlib_uint8_t
SysWakeUpMode
=
0u
;
monitorlib_uint8_t
SetVolFlag
=
0u
;
static
uint16_t
FUNSysVol_Range
[
10u
]
=
monitorlib_uint16_t
FUNSysVol_Range
[
10u
]
=
{
Base_Vol
,
ENTER_LOW_N_RANGE
,
...
...
@@ -48,7 +60,7 @@ static uint16_t FUNSysVol_Range[10u] =
Top_Vol
,
};
static
uint16_t
NMSysVol_Range
[
10u
]
=
monitorlib_uint16_t
NMSysVol_Range
[
10u
]
=
{
Base_Vol
,
ENTER_LOW_N_RANGE
,
...
...
@@ -62,17 +74,29 @@ static uint16_t NMSysVol_Range[10u] =
Top_Vol
,
};
uint8_t
Read_KL30_ConvertFinish
(
void
)
monitorlib_uint16_t
t_FUN_KL30_Debounce
;
monitorlib_uint16_t
t_FUN_KL15_Debounce
;
monitorlib_uint16_t
t_NM_KL30_Debounce
;
monitorlib_uint16_t
t_NM_KL15_Debounce
;
monitorlib_uint16_t
t_NM_KL30_Debounce_Cancel
;
monitorlib_uint16_t
t_NM_KL15_Debounce_Cancel
;
monitorlib_uint16_t
t_FUN_KL30_Debounce_Cancel
;
monitorlib_uint16_t
t_FUN_KL15_Debounce_Cancel
;
monitorlib_uint16_t
t_NM_KL30_timer
;
monitorlib_uint16_t
t_FUN_KL30_timer
;
monitorlib_uint8_t
Read_KL30_ConvertFinish
(
void
)
{
return
SysWakeUpMode
;
}
static
uint8_t
System_Calc_FunRange
(
uint16_t
u16Vol
)
static
monitorlib_uint8_t
System_Calc_FunRange
(
monitorlib_uint16_t
u16Vol
)
{
uint8_t
i
;
for
(
i
=
0u
;
i
<
(
sizeof
(
FUNSysVol_Range
)
/
sizeof
(
FUNSysVol_Range
[
0
]));
i
++
)
monitorlib_uint8_t
i
;
for
(
i
=
0u
;
i
<
(
sizeof
(
FUNSysVol_Range
)
/
sizeof
(
FUNSysVol_Range
[
0
]));
i
++
)
{
if
(
u16Vol
<
FUNSysVol_Range
[
i
])
if
(
u16Vol
<
FUNSysVol_Range
[
i
]
)
{
break
;
}
...
...
@@ -80,12 +104,12 @@ static uint8_t System_Calc_FunRange(uint16_t u16Vol)
return
i
;
}
static
uint8_t
System_Calc_NMRange
(
uint16_t
u16Vol
)
static
monitorlib_uint8_t
System_Calc_NMRange
(
monitorlib_uint16_t
u16Vol
)
{
uint8_t
i
;
for
(
i
=
0u
;
i
<
(
sizeof
(
NMSysVol_Range
)
/
sizeof
(
NMSysVol_Range
[
0
]));
i
++
)
monitorlib_uint8_t
i
;
for
(
i
=
0u
;
i
<
(
sizeof
(
NMSysVol_Range
)
/
sizeof
(
NMSysVol_Range
[
0
]));
i
++
)
{
if
(
u16Vol
<
NMSysVol_Range
[
i
])
if
(
u16Vol
<
NMSysVol_Range
[
i
]
)
{
break
;
}
...
...
@@ -93,38 +117,50 @@ static uint8_t System_Calc_NMRange(uint16_t u16Vol)
return
i
;
}
void
Sys_Set_
VolRange
(
const
uint16_t
FUN_Vol
[],
const
uint16_t
NM_Vol
[])
void
Sys_Set_
Pata
(
const
monitorlib_uint16_t
FUN_Vol
[],
MonitorExt_st
*
pfunc
)
{
FUNSysVol_Range
[
0
]
=
FUN_Vol
[
0
];
FUNSysVol_Range
[
1
]
=
FUN_Vol
[
1
];
FUNSysVol_Range
[
2
]
=
FUN_Vol
[
2
];
FUNSysVol_Range
[
3
]
=
FUN_Vol
[
3
];
FUNSysVol_Range
[
4
]
=
FUN_Vol
[
4
];
FUNSysVol_Range
[
5
]
=
FUN_Vol
[
5
];
FUNSysVol_Range
[
6
]
=
FUN_Vol
[
6
];
FUNSysVol_Range
[
7
]
=
FUN_Vol
[
7
];
FUNSysVol_Range
[
8
]
=
FUN_Vol
[
8
];
FUNSysVol_Range
[
9
]
=
FUN_Vol
[
9
];
NMSysVol_Range
[
0
]
=
NM_Vol
[
0
];
NMSysVol_Range
[
1
]
=
NM_Vol
[
1
];
NMSysVol_Range
[
2
]
=
NM_Vol
[
2
];
NMSysVol_Range
[
3
]
=
NM_Vol
[
3
];
NMSysVol_Range
[
4
]
=
NM_Vol
[
4
];
NMSysVol_Range
[
5
]
=
NM_Vol
[
5
];
NMSysVol_Range
[
6
]
=
NM_Vol
[
6
];
NMSysVol_Range
[
7
]
=
NM_Vol
[
7
];
NMSysVol_Range
[
8
]
=
NM_Vol
[
8
];
NMSysVol_Range
[
9
]
=
NM_Vol
[
9
];
SetVolFlag
=
0x55u
;
}
FUNSysVol_Range
[
0
]
=
FUN_Vol
[
0
];
FUNSysVol_Range
[
1
]
=
FUN_Vol
[
1
];
FUNSysVol_Range
[
2
]
=
FUN_Vol
[
2
];
FUNSysVol_Range
[
3
]
=
FUN_Vol
[
3
];
FUNSysVol_Range
[
4
]
=
FUN_Vol
[
4
];
FUNSysVol_Range
[
5
]
=
FUN_Vol
[
5
];
FUNSysVol_Range
[
6
]
=
FUN_Vol
[
6
];
FUNSysVol_Range
[
7
]
=
FUN_Vol
[
7
];
FUNSysVol_Range
[
8
]
=
FUN_Vol
[
8
];
FUNSysVol_Range
[
9
]
=
FUN_Vol
[
9
];
t_FUN_KL30_Debounce
=
FUN_Vol
[
10
];
t_FUN_KL15_Debounce
=
FUN_Vol
[
11
];
NMSysVol_Range
[
0
]
=
FUN_Vol
[
12
];
NMSysVol_Range
[
1
]
=
FUN_Vol
[
13
];
NMSysVol_Range
[
2
]
=
FUN_Vol
[
14
];
NMSysVol_Range
[
3
]
=
FUN_Vol
[
15
];
NMSysVol_Range
[
4
]
=
FUN_Vol
[
16
];
NMSysVol_Range
[
5
]
=
FUN_Vol
[
17
];
NMSysVol_Range
[
6
]
=
FUN_Vol
[
18
];
NMSysVol_Range
[
7
]
=
FUN_Vol
[
19
];
NMSysVol_Range
[
8
]
=
FUN_Vol
[
20
];
NMSysVol_Range
[
9
]
=
FUN_Vol
[
21
];
t_NM_KL30_Debounce
=
FUN_Vol
[
22
];
t_NM_KL15_Debounce
=
FUN_Vol
[
23
];
t_NM_KL30_Debounce_Cancel
=
FUN_Vol
[
24
];
t_FUN_KL30_Debounce_Cancel
=
FUN_Vol
[
25
];
pfunction
.
SysGet_KL30_Valid
=
pfunc
->
SysGet_KL30_Valid
;
pfunction
.
SysGet_KL15_Valid
=
pfunc
->
SysGet_KL15_Valid
;
pfunction
.
SysGet_KL30_value_Force
=
pfunc
->
SysGet_KL30_value_Force
;
pfunction
.
SysGet_KL15_value_Force
=
pfunc
->
SysGet_KL15_value_Force
;
pfunction
.
SysGet_KL30_value
=
pfunc
->
SysGet_KL30_value
;
pfunction
.
SysGet_KL15_value
=
pfunc
->
SysGet_KL15_value
;
pfunction
.
SysGet_KL15Line
=
pfunc
->
SysGet_KL15Line
;
pfunction
.
COM_Delay
=
pfunc
->
COM_Delay
;
pfunction
.
SysMonitorLogic
=
pfunc
->
SysMonitorLogic
;
void
Sys_Set_DebounceTimer
(
uint16_t
u16NMKL30
,
uint16_t
u16NMKL15
,
uint16_t
u16FUNKL30
,
uint16_t
u16FUNKL15
)
{
t_NM_KL30_Debounce
=
u16NMKL30
;
t_NM_KL15_Debounce
=
u16NMKL15
;
t_FUN_KL30_Debounce
=
u16FUNKL30
;
t_FUN_KL15_Debounce
=
u16FUNKL15
;
SetVolFlag
=
0x55u
;
}
void
System_Monitor_KL30Init
(
void
)
...
...
@@ -154,48 +190,46 @@ void System_Monitor_KL30Init(void)
SysNM_KL15Monitor
.
FinalSts
=
0u
;
SysNM_KL15Monitor
.
ActSts
=
0u
;
if
(
t_NM_KL30_Debounce
==
0U
)
if
(
SetVolFlag
!=
0x55u
)
{
t_NM_KL30_Debounce
=
1000u
;
}
if
(
t_NM_KL15_Debounce
==
0U
)
{
t_NM_KL15_Debounce
=
2u
;
}
if
(
t_FUN_KL30_Debounce
==
0U
)
{
t_FUN_KL30_Debounce
=
1000u
;
}
if
(
t_FUN_KL15_Debounce
==
0U
)
{
t_FUN_KL15_Debounce
=
2u
;
}
if
(
SetVolFlag
!=
0x55u
)
{
FUNSysVol_Range
[
0
]
=
Base_Vol
;
FUNSysVol_Range
[
1
]
=
ENTER_LOW_N_RANGE
;
FUNSysVol_Range
[
2
]
=
EXIT_LOW_N_RANGE
;
FUNSysVol_Range
[
3
]
=
ENTER_LOW_Y_RANGE
;
FUNSysVol_Range
[
4
]
=
EXIT_LOW_Y_RANGE
;
FUNSysVol_Range
[
5
]
=
EXIT_HIGH_Y_RANGE
;
FUNSysVol_Range
[
6
]
=
ENTER_HIGH_Y_RANGE
;
FUNSysVol_Range
[
7
]
=
EXIT_HIGH_N_RANGE
;
FUNSysVol_Range
[
8
]
=
ENTER_HIGH_N_RANGE
;
FUNSysVol_Range
[
9
]
=
Top_Vol
;
NMSysVol_Range
[
0
]
=
Base_Vol
;
NMSysVol_Range
[
1
]
=
ENTER_LOW_N_RANGE
;
NMSysVol_Range
[
2
]
=
EXIT_LOW_N_RANGE
;
NMSysVol_Range
[
3
]
=
ENTER_LOW_Y_RANGE
;
NMSysVol_Range
[
4
]
=
EXIT_LOW_Y_RANGE
;
NMSysVol_Range
[
5
]
=
EXIT_HIGH_Y_RANGE
;
NMSysVol_Range
[
6
]
=
ENTER_HIGH_Y_RANGE
;
NMSysVol_Range
[
7
]
=
EXIT_HIGH_N_RANGE
;
NMSysVol_Range
[
8
]
=
ENTER_HIGH_N_RANGE
;
NMSysVol_Range
[
9
]
=
Top_Vol
;
t_NM_KL30_Debounce_Cancel
=
1000U
;
t_NM_KL15_Debounce_Cancel
=
2U
;
t_FUN_KL30_Debounce_Cancel
=
1000U
;
t_FUN_KL15_Debounce_Cancel
=
2U
;
FUNSysVol_Range
[
0
]
=
Base_Vol
;
FUNSysVol_Range
[
1
]
=
ENTER_LOW_N_RANGE
;
FUNSysVol_Range
[
2
]
=
EXIT_LOW_N_RANGE
;
FUNSysVol_Range
[
3
]
=
ENTER_LOW_Y_RANGE
;
FUNSysVol_Range
[
4
]
=
EXIT_LOW_Y_RANGE
;
FUNSysVol_Range
[
5
]
=
EXIT_HIGH_Y_RANGE
;
FUNSysVol_Range
[
6
]
=
ENTER_HIGH_Y_RANGE
;
FUNSysVol_Range
[
7
]
=
EXIT_HIGH_N_RANGE
;
FUNSysVol_Range
[
8
]
=
ENTER_HIGH_N_RANGE
;
FUNSysVol_Range
[
9
]
=
Top_Vol
;
NMSysVol_Range
[
0
]
=
Base_Vol
;
NMSysVol_Range
[
1
]
=
ENTER_LOW_N_RANGE
;
NMSysVol_Range
[
2
]
=
EXIT_LOW_N_RANGE
;
NMSysVol_Range
[
3
]
=
ENTER_LOW_Y_RANGE
;
NMSysVol_Range
[
4
]
=
EXIT_LOW_Y_RANGE
;
NMSysVol_Range
[
5
]
=
EXIT_HIGH_Y_RANGE
;
NMSysVol_Range
[
6
]
=
ENTER_HIGH_Y_RANGE
;
NMSysVol_Range
[
7
]
=
EXIT_HIGH_N_RANGE
;
NMSysVol_Range
[
8
]
=
ENTER_HIGH_N_RANGE
;
NMSysVol_Range
[
9
]
=
Top_Vol
;
SetVolFlag
=
0x55u
;
}
if
(
pfunction
.
COM_Delay
!=
((
void
*
)
0
)
)
{
pfunction
.
COM_Delay
(
260U
);
}
System_Fast_WakeUp
(
);
}
void
System_Monitor_WakeupInit
(
void
)
...
...
@@ -225,78 +259,87 @@ void System_Monitor_WakeupInit(void)
SysNM_KL15Monitor
.
FinalSts
=
0u
;
SysNM_KL15Monitor
.
ActSts
=
0u
;
if
(
t_NM_KL30_Debounce
==
0U
)
if
(
SetVolFlag
!=
0x55u
)
{
t_NM_KL30_Debounce
=
1000u
;
}
if
(
t_NM_KL15_Debounce
==
0U
)
{
t_NM_KL15_Debounce
=
2u
;
}
if
(
t_FUN_KL30_Debounce
==
0U
)
{
t_FUN_KL30_Debounce
=
1000u
;
}
if
(
t_FUN_KL15_Debounce
==
0U
)
{
t_FUN_KL15_Debounce
=
2u
;
}
if
(
SetVolFlag
!=
0x55u
)
{
FUNSysVol_Range
[
0
]
=
Base_Vol
;
FUNSysVol_Range
[
1
]
=
ENTER_LOW_N_RANGE
;
FUNSysVol_Range
[
2
]
=
EXIT_LOW_N_RANGE
;
FUNSysVol_Range
[
3
]
=
ENTER_LOW_Y_RANGE
;
FUNSysVol_Range
[
4
]
=
EXIT_LOW_Y_RANGE
;
FUNSysVol_Range
[
5
]
=
EXIT_HIGH_Y_RANGE
;
FUNSysVol_Range
[
6
]
=
ENTER_HIGH_Y_RANGE
;
FUNSysVol_Range
[
7
]
=
EXIT_HIGH_N_RANGE
;
FUNSysVol_Range
[
8
]
=
ENTER_HIGH_N_RANGE
;
FUNSysVol_Range
[
9
]
=
Top_Vol
;
NMSysVol_Range
[
0
]
=
Base_Vol
;
NMSysVol_Range
[
1
]
=
ENTER_LOW_N_RANGE
;
NMSysVol_Range
[
2
]
=
EXIT_LOW_N_RANGE
;
NMSysVol_Range
[
3
]
=
ENTER_LOW_Y_RANGE
;
NMSysVol_Range
[
4
]
=
EXIT_LOW_Y_RANGE
;
NMSysVol_Range
[
5
]
=
EXIT_HIGH_Y_RANGE
;
NMSysVol_Range
[
6
]
=
ENTER_HIGH_Y_RANGE
;
NMSysVol_Range
[
7
]
=
EXIT_HIGH_N_RANGE
;
NMSysVol_Range
[
8
]
=
ENTER_HIGH_N_RANGE
;
NMSysVol_Range
[
9
]
=
Top_Vol
;
t_NM_KL30_Debounce_Cancel
=
1000U
;
t_NM_KL15_Debounce_Cancel
=
2U
;
t_FUN_KL30_Debounce_Cancel
=
1000U
;
t_FUN_KL15_Debounce_Cancel
=
2U
;
FUNSysVol_Range
[
0
]
=
Base_Vol
;
FUNSysVol_Range
[
1
]
=
ENTER_LOW_N_RANGE
;
FUNSysVol_Range
[
2
]
=
EXIT_LOW_N_RANGE
;
FUNSysVol_Range
[
3
]
=
ENTER_LOW_Y_RANGE
;
FUNSysVol_Range
[
4
]
=
EXIT_LOW_Y_RANGE
;
FUNSysVol_Range
[
5
]
=
EXIT_HIGH_Y_RANGE
;
FUNSysVol_Range
[
6
]
=
ENTER_HIGH_Y_RANGE
;
FUNSysVol_Range
[
7
]
=
EXIT_HIGH_N_RANGE
;
FUNSysVol_Range
[
8
]
=
ENTER_HIGH_N_RANGE
;
FUNSysVol_Range
[
9
]
=
Top_Vol
;
NMSysVol_Range
[
0
]
=
Base_Vol
;
NMSysVol_Range
[
1
]
=
ENTER_LOW_N_RANGE
;
NMSysVol_Range
[
2
]
=
EXIT_LOW_N_RANGE
;
NMSysVol_Range
[
3
]
=
ENTER_LOW_Y_RANGE
;
NMSysVol_Range
[
4
]
=
EXIT_LOW_Y_RANGE
;
NMSysVol_Range
[
5
]
=
EXIT_HIGH_Y_RANGE
;
NMSysVol_Range
[
6
]
=
ENTER_HIGH_Y_RANGE
;
NMSysVol_Range
[
7
]
=
EXIT_HIGH_N_RANGE
;
NMSysVol_Range
[
8
]
=
ENTER_HIGH_N_RANGE
;
NMSysVol_Range
[
9
]
=
Top_Vol
;
SetVolFlag
=
0x55u
;
}
System_Fast_WakeUp
(
);
}
void
Sys_Status_Update_Service
(
void
)
{
System_Fun_Process
();
System_NM_Process
();
Sys_LogicProcess
();
System_Fun_Process
(
);
System_NM_Process
(
);
if
(
pfunction
.
SysMonitorLogic
!=
((
void
*
)
0
)
)
{
pfunction
.
SysMonitorLogic
(
);
}
}
void
System_Fast_WakeUp
(
void
)
static
void
System_Fast_WakeUp
(
void
)
{
uint16_t
KL30_Voltage
=
0U
;
uint16_t
KL15_Voltage
=
0U
;
uint8_t
KL30_Valid
=
0U
;
uint8_t
KL15_Valid
=
0U
;
uint16_t
Voltage
=
0U
;
uint8_t
NormalKL30Cnt
=
0U
;
uint8_t
abnormalKL30Cnt
=
0U
;
uint8_t
AttemptCnt
=
0U
;
monitorlib_uint16_t
KL30_Voltage
;
monitorlib_uint16_t
KL15_Voltage
;
monitorlib_uint16_t
Voltage
;
monitorlib_uint8_t
NormalKL30Cnt
=
0U
;
monitorlib_uint8_t
abnormalKL30Cnt
=
0U
;
monitorlib_uint8_t
AttemptCnt
=
0U
;
AttemptCnt
=
0u
;
KL30_Voltage
=
Sys_Force_Read_KL30_Voltage
();
KL15_Voltage
=
Sys_Force_Read_KL15_Voltage
();
while
(
SysNM_KL30Monitor
.
FinalSts
==
0u
)
while
(
SysNM_KL30Monitor
.
FinalSts
==
0u
)
{
if
(
pfunction
.
COM_Delay
!=
((
void
*
)
0
)
)
{
/*KL30 KL15电压采集*/
KL30_Voltage
=
Sys_Force_Read_KL30_Voltage
();
KL15_Voltage
=
Sys_Force_Read_KL15_Voltage
();
if
(
KL30_Voltage
>
KL15_Voltage
)
pfunction
.
COM_Delay
(
2U
);
}
/*KL30 KL15 voltage */
if
(
pfunction
.
SysGet_KL30_value_Force
!=
(
void
*
)
0
)
{
KL30_Voltage
=
pfunction
.
SysGet_KL30_value_Force
(
);
}
else
{
KL30_Voltage
=
0u
;
}
if
(
pfunction
.
SysGet_KL15_value_Force
!=
(
void
*
)
0
)
{
KL15_Voltage
=
pfunction
.
SysGet_KL15_value_Force
(
);
}
else
{
KL15_Voltage
=
0u
;
}
if
(
KL30_Voltage
>
KL15_Voltage
)
{
Voltage
=
KL30_Voltage
;
}
...
...
@@ -305,7 +348,7 @@ void System_Fast_WakeUp(void)
Voltage
=
KL15_Voltage
;
}
if
((
Voltage
<=
FUNSysVol_Range
[
1
])
||
(
Voltage
>=
FUNSysVol_Range
[
8
]))
if
(
(
Voltage
<=
NMSysVol_Range
[
2
])
||
(
Voltage
>=
NMSysVol_Range
[
7
])
)
{
NormalKL30Cnt
=
0U
;
abnormalKL30Cnt
++
;
...
...
@@ -315,73 +358,119 @@ void System_Fast_WakeUp(void)
NormalKL30Cnt
++
;
abnormalKL30Cnt
=
0U
;
}
/*消抖次数设置*/
if
(
NormalKL30Cnt
>=
5U
)
AttemptCnt
++
;
if
(
AttemptCnt
>=
10u
)
{
break
;
}
if
(
NormalKL30Cnt
>=
5U
)
{
SysNM_KL30Monitor
.
FinalSts
=
5u
;
}
if
(
abnormalKL30Cnt
>=
5U
)
if
(
abnormalKL30Cnt
>=
5U
)
{
/*设置成HALT模式*/
SysNM_KL30Monitor
.
FinalSts
=
9u
;
}
}
Sys_BlockDelay
(
20U
);
/*1*50us*/
AttemptCnt
++
;
if
(
AttemptCnt
>=
100u
)
if
(
(
SysNM_KL30Monitor
.
FinalSts
!=
0u
)
)
{
break
;
SysWakeUpMode
=
0x55U
;
if
(
pfunction
.
SysGet_KL15Line
!=
((
void
*
)
0
)
)
{
SysNM_KL15Monitor
.
FinalSts
=
pfunction
.
SysGet_KL15Line
(
);
SysNM_KL15Monitor
.
ActSts
=
pfunction
.
SysGet_KL15Line
(
);
}
else
{
SysNM_KL15Monitor
.
FinalSts
=
0u
;
SysNM_KL15Monitor
.
ActSts
=
0u
;
}
/*KL15 KL30采集结束,切换模式*/
if
((
SysNM_KL30Monitor
.
FinalSts
!=
0u
))
if
(
pfunction
.
SysMonitorLogic
!=
(
void
*
)
0
)
{
/*切换模式*/
SysWakeUpMode
=
0x55U
;
SysNM_KL15Monitor
.
FinalSts
=
System_LINE_KL15
();
SysNM_KL15Monitor
.
ActSts
=
System_LINE_KL15
();
SysFun_KL30Monitor
.
FinalSts
=
SysNM_KL30Monitor
.
FinalSts
;
SysFun_KL15Monitor
.
FinalSts
=
SysNM_KL15Monitor
.
ActSts
;
/*发送唤醒状态*/
Sys_LogicProcess
();
pfunction
.
SysMonitorLogic
(
);
}
}
}
static
void
System_NM_Process
(
void
)
{
uint8_t
m8
;
static
uint16_t
DebpounceTimer
;
uint16_t
Voltage
;
uint8_t
VoltageKL30Valid
;
uint8_t
VoltageKL15Valid
;
uint16_t
Voltage_KL15
;
uint16_t
Voltage_KL30
;
monitorlib_uint8_t
m8
;
static
monitorlib_uint16_t
DebpounceTimer
;
monitorlib_uint16_t
Voltage
;
monitorlib_uint8_t
VoltageKL30Valid
;
monitorlib_uint8_t
VoltageKL15Valid
;
monitorlib_uint16_t
Voltage_KL15
;
monitorlib_uint16_t
Voltage_KL30
;
if
(
SysNM_KL15Monitor
.
ActSts
!=
SysNM_KL15Monitor
.
FinalSts
)
if
(
pfunction
.
SysGet_KL15Line
!=
((
void
*
)
0
)
)
{
if
(
SysNM_KL15Monitor
.
ActSts
==
pfunction
.
SysGet_KL15Line
(
)
)
{
if
(
SysNM_KL15Monitor
.
DebounceTimer
<
t_NM_KL15_Debounce
)
{
SysNM_KL15Monitor
.
DebounceTimer
++
;
if
(
SysNM_KL15Monitor
.
DebounceTimer
>=
t_NM_KL15_Debounce
)
}
else
{
SysNM_KL15Monitor
.
FinalSts
=
SysNM_KL15Monitor
.
ActSts
;
}
}
else
{
SysNM_KL15Monitor
.
FinalSts
=
System_LINE_KL15
();
SysNM_KL15Monitor
.
DebounceTimer
=
0u
;
SysNM_KL15Monitor
.
ActSts
=
pfunction
.
SysGet_KL15Line
(
);
}
}
else
{
SysNM_KL15Monitor
.
FinalSts
=
0u
;
SysNM_KL15Monitor
.
ActSts
=
0u
;
SysNM_KL15Monitor
.
DebounceTimer
=
0u
;
SysNM_KL15Monitor
.
ActSts
=
System_LINE_KL15
();
}
VoltageKL30Valid
=
Sys_Read_KL30_Valid
();
VoltageKL15Valid
=
Sys_Read_KL15_Valid
();
if
(
pfunction
.
SysGet_KL30_Valid
!=
(
void
*
)
0
)
{
VoltageKL30Valid
=
pfunction
.
SysGet_KL30_Valid
(
);
}
else
{
VoltageKL30Valid
=
0u
;
}
if
(
pfunction
.
SysGet_KL15_Valid
!=
(
void
*
)
0
)
{
VoltageKL15Valid
=
pfunction
.
SysGet_KL15_Valid
(
);
}
else
{
VoltageKL15Valid
=
0u
;
}
if
(
(
VoltageKL30Valid
==
1U
)
&&
(
VoltageKL15Valid
==
1U
)
)
{
if
(
pfunction
.
SysGet_KL15_value
!=
((
void
*
)
0
)
)
{
Voltage_KL15
=
pfunction
.
SysGet_KL15_value
(
);
}
else
{
Voltage_KL15
=
0u
;
}
if
((
VoltageKL30Valid
==
1U
)
&&
(
VoltageKL15Valid
==
1U
))
if
(
pfunction
.
SysGet_KL15_value
!=
((
void
*
)
0
)
)
{
Voltage_KL15
=
Sys_Read_KL15_Voltage
();
Voltage_KL30
=
Sys_Read_KL30_Voltage
();
if
(
Voltage_KL30
>
Voltage_KL15
)
Voltage_KL30
=
pfunction
.
SysGet_KL30_value
(
);
}
else
{
Voltage_KL30
=
0u
;
}
if
(
Voltage_KL30
>
Voltage_KL15
)
{
Voltage
=
Voltage_KL30
;
}
...
...
@@ -389,11 +478,11 @@ static void System_NM_Process(void)
{
Voltage
=
Voltage_KL15
;
}
if
(
SysNM_KL30Monitor
.
SumCnt
<
50u
)
if
(
SysNM_KL30Monitor
.
SumCnt
<
50u
)
{
SysNM_KL30Monitor
.
ActVoltage
+=
Voltage
;
SysNM_KL30Monitor
.
SumCnt
+=
1u
;
Voltage
=
(
uint16_t
)(
SysNM_KL30Monitor
.
ActVoltage
/
SysNM_KL30Monitor
.
SumCnt
);
Voltage
=
(
monitorlib_uint16_t
)(
SysNM_KL30Monitor
.
ActVoltage
/
SysNM_KL30Monitor
.
SumCnt
);
}
else
{
...
...
@@ -401,54 +490,66 @@ static void System_NM_Process(void)
SysNM_KL30Monitor
.
ActVoltage
=
0u
;
SysNM_KL30Monitor
.
ActVoltage
+=
Voltage
;
SysNM_KL30Monitor
.
SumCnt
+=
1u
;
Voltage
=
(
uint16_t
)(
SysNM_KL30Monitor
.
ActVoltage
/
SysNM_KL30Monitor
.
SumCnt
);
Voltage
=
(
monitorlib_uint16_t
)(
SysNM_KL30Monitor
.
ActVoltage
/
SysNM_KL30Monitor
.
SumCnt
);
}
m8
=
System_Calc_NMRange
(
Voltage
);
if
(
SysNM_KL30Monitor
.
ActSts
==
m8
)
if
(
SysNM_KL30Monitor
.
ActSts
==
m8
)
{
SysNM_KL30Monitor
.
DebounceTimer
++
;
switch
(
SysNM_KL30Monitor
.
FinalSts
)
{
case
0
:
case
1
:
case
9
:
t_NM_KL30_timer
=
t_NM_KL30_Debounce_Cancel
;
break
;
/*计时累计时间1000*2ms*/
if
(
SysNM_KL30Monitor
.
DebounceTimer
>=
t_NM_KL30_Debounce
)
default:
t_NM_KL30_timer
=
t_NM_KL30_Debounce
;
break
;
}
if
(
SysNM_KL30Monitor
.
DebounceTimer
<
t_NM_KL30_timer
)
/*40202-8*/
{
SysNM_KL30Monitor
.
DebounceTimer
++
;
}
else
{
SysNM_KL30Monitor
.
DebounceTimer
=
0U
;
DebpounceTimer
=
0u
;
if
(
SysNM_KL30Monitor
.
FinalSts
==
9u
)
/* 高压 */
if
(
SysNM_KL30Monitor
.
FinalSts
==
9u
)
/* 高压 */
{
if
(
(
m8
==
9u
)
||
(
m8
==
8u
))
if
(
(
m8
==
9u
)
||
(
m8
==
8u
)
)
{
SysNM_KL30Monitor
.
FinalSts
=
9u
;
SysNM_KL30Monitor
.
FinalSts
=
9u
;
/** 维持不变 **/
}
else
{
SysNM_KL30Monitor
.
FinalSts
=
m8
;
SysNM_KL30Monitor
.
FinalSts
=
m8
;
/**退出*/
}
}
if
(
SysNM_KL30Monitor
.
FinalSts
==
1u
)
/* 低压 */
if
(
SysNM_KL30Monitor
.
FinalSts
==
1u
)
/* 低压 */
{
if
(
(
m8
==
1u
)
||
(
m8
==
2u
))
if
(
(
m8
==
1u
)
||
(
m8
==
2u
)
)
{
SysNM_KL30Monitor
.
FinalSts
=
1u
;
SysNM_KL30Monitor
.
FinalSts
=
1u
;
/** 维持不变 */
}
else
{
SysNM_KL30Monitor
.
FinalSts
=
m8
;
SysNM_KL30Monitor
.
FinalSts
=
m8
;
/**退出*/
}
}
/*
非高低压*/
if
(
(
SysNM_KL30Monitor
.
FinalSts
!=
1u
)
&&
(
SysNM_KL30Monitor
.
FinalSts
!=
9u
))
/*
非高低压 */
if
(
(
SysNM_KL30Monitor
.
FinalSts
!=
1u
)
&&
(
SysNM_KL30Monitor
.
FinalSts
!=
9u
)
)
{
SysNM_KL30Monitor
.
FinalSts
=
m8
;
SysNM_KL30Monitor
.
FinalSts
=
m8
;
/** 进入*/
}
}
}
else
{
/*
计时时间清除*/
/*
计时时间清除 */
SysNM_KL30Monitor
.
DebounceTimer
=
0U
;
DebpounceTimer
++
;
if
(
DebpounceTimer
>=
5u
)
if
(
DebpounceTimer
>=
5u
)
{
DebpounceTimer
=
0u
;
SysNM_KL30Monitor
.
ActSts
=
m8
;
...
...
@@ -459,37 +560,80 @@ static void System_NM_Process(void)
static
void
System_Fun_Process
(
void
)
{
uint8_t
m8
;
uint8_t
VoltageKL30Valid
;
uint8_t
VoltageKL15Valid
;
uint16_t
Voltage
;
uint16_t
Voltage_KL15
;
uint16_t
Voltage_KL30
;
static
uint16_t
DebpounceTimer
;
monitorlib_uint8_t
m8
;
monitorlib_uint8_t
VoltageKL30Valid
;
monitorlib_uint8_t
VoltageKL15Valid
;
monitorlib_uint16_t
Voltage
;
monitorlib_uint16_t
Voltage_KL15
;
monitorlib_uint16_t
Voltage_KL30
;
static
monitorlib_uint16_t
DebpounceTimer
;
if
(
SysFun_KL15Monitor
.
ActSts
!=
SysFun_KL15Monitor
.
FinalSts
)
if
(
pfunction
.
SysGet_KL15Line
!=
((
void
*
)
0
)
)
{
if
(
SysFun_KL15Monitor
.
ActSts
==
pfunction
.
SysGet_KL15Line
(
)
)
{
if
(
SysFun_KL15Monitor
.
DebounceTimer
<
t_FUN_KL15_Debounce
)
{
SysFun_KL15Monitor
.
DebounceTimer
++
;
if
(
SysFun_KL15Monitor
.
DebounceTimer
>=
t_FUN_KL15_Debounce
)
}
else
{
SysFun_KL15Monitor
.
FinalSts
=
SysFun_KL15Monitor
.
ActSts
;
}
}
else
{
SysFun_KL15Monitor
.
FinalSts
=
System_LINE_KL15
();
SysFun_KL15Monitor
.
DebounceTimer
=
0u
;
SysFun_KL15Monitor
.
ActSts
=
pfunction
.
SysGet_KL15Line
(
);
}
}
else
{
SysFun_KL15Monitor
.
DebounceTimer
=
0u
;
SysFun_KL15Monitor
.
ActSts
=
System_LINE_KL15
();
SysFun_KL15Monitor
.
FinalSts
=
0u
;
SysFun_KL15Monitor
.
ActSts
=
0u
;
}
if
(
pfunction
.
SysGet_KL30_Valid
!=
((
void
*
)
0
)
)
{
VoltageKL30Valid
=
pfunction
.
SysGet_KL30_Valid
(
);
}
else
{
VoltageKL30Valid
=
0u
;
}
if
(
pfunction
.
SysGet_KL15_Valid
!=
((
void
*
)
0
)
)
{
VoltageKL15Valid
=
pfunction
.
SysGet_KL15_Valid
(
);
}
else
{
VoltageKL15Valid
=
0u
;
}
VoltageKL30Valid
=
Sys_Read_KL30_Valid
();
VoltageKL15Valid
=
Sys_Read_KL15_Valid
();
if
((
VoltageKL30Valid
==
1U
)
&&
(
VoltageKL15Valid
==
1U
))
if
(
(
VoltageKL30Valid
==
1U
)
&&
(
VoltageKL15Valid
==
1U
)
)
{
if
(
pfunction
.
SysGet_KL15_value
!=
((
void
*
)
0
)
)
{
Voltage_KL15
=
Sys_Read_KL15_Voltage
();
Voltage_KL30
=
Sys_Read_KL30_Voltage
();
if
(
Voltage_KL30
>
Voltage_KL15
)
Voltage_KL15
=
pfunction
.
SysGet_KL15_value
(
);
}
else
{
Voltage_KL15
=
0u
;
}
if
(
pfunction
.
SysGet_KL30_value
!=
((
void
*
)
0
)
)
{
Voltage_KL30
=
pfunction
.
SysGet_KL30_value
(
);
}
else
{
Voltage_KL30
=
0u
;
}
if
(
Voltage_KL30
>
Voltage_KL15
)
{
Voltage
=
Voltage_KL30
;
}
...
...
@@ -497,11 +641,11 @@ static void System_Fun_Process(void)
{
Voltage
=
Voltage_KL15
;
}
if
(
SysFun_KL30Monitor
.
SumCnt
<
50u
)
if
(
SysFun_KL30Monitor
.
SumCnt
<
50u
)
{
SysFun_KL30Monitor
.
ActVoltage
+=
Voltage
;
SysFun_KL30Monitor
.
SumCnt
+=
1u
;
Voltage
=
(
uint16_t
)(
SysFun_KL30Monitor
.
ActVoltage
/
SysFun_KL30Monitor
.
SumCnt
);
Voltage
=
(
monitorlib_uint16_t
)(
SysFun_KL30Monitor
.
ActVoltage
/
SysFun_KL30Monitor
.
SumCnt
);
}
else
{
...
...
@@ -509,23 +653,38 @@ static void System_Fun_Process(void)
SysFun_KL30Monitor
.
ActVoltage
=
0u
;
SysFun_KL30Monitor
.
ActVoltage
+=
Voltage
;
SysFun_KL30Monitor
.
SumCnt
+=
1u
;
Voltage
=
(
uint16_t
)(
SysFun_KL30Monitor
.
ActVoltage
/
SysFun_KL30Monitor
.
SumCnt
);
Voltage
=
(
monitorlib_uint16_t
)(
SysFun_KL30Monitor
.
ActVoltage
/
SysFun_KL30Monitor
.
SumCnt
);
}
m8
=
System_Calc_FunRange
(
Voltage
);
if
(
SysFun_KL30Monitor
.
ActSts
==
m8
)
if
(
SysFun_KL30Monitor
.
ActSts
==
m8
)
{
SysFun_KL30Monitor
.
DebounceTimer
++
;
DebpounceTimer
=
0u
;
/*计时累计时间1000*2ms*/
if
(
SysFun_KL30Monitor
.
DebounceTimer
>=
t_FUN_KL30_Debounce
)
/*40202-8*/
{
SysFun_KL30Monitor
.
DebounceTimer
=
0U
;
switch
(
SysFun_KL30Monitor
.
FinalSts
)
{
case
0
:
case
1
:
case
3
:
case
7
:
case
9
:
t_FUN_KL30_timer
=
t_FUN_KL30_Debounce_Cancel
;
break
;
if
(
SysFun_KL30Monitor
.
FinalSts
>=
7u
)
/* 高压 */
default:
t_FUN_KL30_timer
=
t_FUN_KL30_Debounce
;
break
;
}
/* 计时累计时间1000*2ms */
if
(
SysFun_KL30Monitor
.
DebounceTimer
<
t_FUN_KL30_timer
)
/*40202-8*/
{
if
((
m8
==
9u
)
||
(
m8
==
8u
)
||
(
m8
==
7u
))
SysFun_KL30Monitor
.
DebounceTimer
++
;
}
else
{
if
(
SysFun_KL30Monitor
.
FinalSts
>
7u
)
/* 高压 */
{
if
(
(
m8
==
9u
)
||
(
m8
==
8u
)
||
(
m8
==
7u
)
)
{
SysFun_KL30Monitor
.
FinalSts
=
9u
;
SysFun_KL15Monitor
.
FinalSts
=
0u
;
...
...
@@ -535,9 +694,9 @@ static void System_Fun_Process(void)
SysFun_KL30Monitor
.
FinalSts
=
m8
;
}
}
if
(
SysFun_KL30Monitor
.
FinalSts
==
1u
)
/* 低压 */
if
(
SysFun_KL30Monitor
.
FinalSts
==
1u
)
/* 低压 */
{
if
(
(
m8
==
1u
)
||
(
m8
==
2u
))
if
(
(
m8
==
1u
)
||
(
m8
==
2u
)
)
{
SysFun_KL30Monitor
.
FinalSts
=
1u
;
SysFun_KL15Monitor
.
FinalSts
=
0u
;
...
...
@@ -547,8 +706,8 @@ static void System_Fun_Process(void)
SysFun_KL30Monitor
.
FinalSts
=
m8
;
}
}
/*
非高低压*/
if
(
(
SysFun_KL30Monitor
.
FinalSts
!=
1u
)
&&
(
SysFun_KL30Monitor
.
FinalSts
<
7u
))
/*
非高低压 */
if
(
(
SysFun_KL30Monitor
.
FinalSts
!=
1u
)
&&
(
SysFun_KL30Monitor
.
FinalSts
<=
7u
)
)
{
SysFun_KL30Monitor
.
FinalSts
=
m8
;
}
...
...
@@ -556,10 +715,10 @@ static void System_Fun_Process(void)
}
else
{
/*
计时时间清除*/
/*
计时时间清除 */
SysFun_KL30Monitor
.
DebounceTimer
=
0U
;
DebpounceTimer
++
;
if
(
DebpounceTimer
>=
5u
)
if
(
DebpounceTimer
>=
5u
)
{
DebpounceTimer
=
0u
;
SysFun_KL30Monitor
.
ActSts
=
m8
;
...
...
@@ -574,20 +733,24 @@ static void System_Fun_Process(void)
}*/
}
uint8_t
System_NM_KL30_Status_Get
(
void
)
monitorlib_uint8_t
System_NM_KL30_Status_Get
(
void
)
{
return
SysNM_KL30Monitor
.
FinalSts
;
}
uint8_t
System_NM_KL15_Status_Get
(
void
)
monitorlib_uint8_t
System_NM_KL15_Status_Get
(
void
)
{
return
SysNM_KL15Monitor
.
FinalSts
;
}
uint8_t
System_FUN_KL30_Status_Get
(
void
)
monitorlib_uint8_t
System_FUN_KL30_Status_Get
(
void
)
{
return
SysFun_KL30Monitor
.
FinalSts
;
}
uint8_t
System_FUN_KL15_Status_Get
(
void
)
monitorlib_uint8_t
System_FUN_KL15_Status_Get
(
void
)
{
return
SysFun_KL15Monitor
.
FinalSts
;
}
monitorlib_uint16_t
Get_Sysmonitor_Version
(
void
)
{
return
0x0002u
;
}
source/Application/APP/PowerManagement/System_Monitor.h
View file @
435ca6de
#ifndef SYSTEM_
MONITOR_H
#define SYSTEM_
MONITOR_H
#ifndef SYSTEM_
_MONITOR__H
#define SYSTEM_
_MONITOR__H
#include "System_Monitor.h"
#include "TYW_stdint.h"
/* #define Platform_16Bit
#define Platform_32Bit*/
#ifdef Platform_16Bit
#define monitorlib_uint8_t unsigned char
#define monitorlib_uint16_t unsigned int
#define monitorlib_uint32_t unsigned long
typedef
struct
{
uint8_t
SumCnt
;
uint16_t
DebounceTimer
;
uint32_t
ActVoltage
;
uint8_t
FinalSts
;
uint8_t
ActSts
;
}
MonitorStruct
;
#else
#define monitorlib_uint8_t unsigned char
#define monitorlib_uint16_t unsigned short
#define monitorlib_uint32_t unsigned int
#define monitorlib_uint64_t unsigned long long
#endif
/*
0 ----1st-------6500 不可运行 1
...
...
@@ -38,69 +40,58 @@ typedef struct
6.5-18.5 CAN 可运行区间
*/
typedef
monitorlib_uint8_t
(
*
Get_Voltage_Vaild
)(
void
);
typedef
monitorlib_uint16_t
(
*
Get_Voltage_Value
)(
void
);
typedef
monitorlib_uint8_t
(
*
Get_LineInStatus
)(
void
);
typedef
void
(
*
COMMON_Delay
)(
monitorlib_uint32_t
mMs
);
typedef
void
(
*
pfunLogic
)(
void
);
/*电源运行状态*/
#define SYS_OPR_STAT_RUN ((System_FUN_KL30_Status_Get() > 1u)&&(System_FUN_KL30_Status_Get() < 7u ))
#define SYS_OPR_STAT_HALT ((System_FUN_KL30_Status_Get() == 1u) || (System_FUN_KL30_Status_Get() >= 7u))
#define SYS_OPR_STAT_LIM_LVP (System_FUN_KL30_Status_Get() == 1U)
#define SYS_OPR_STAT_LIM_OVP (System_FUN_KL30_Status_Get() >= 7u)
/*仪表工作状态*/
#define SYS_OPR_STAT_IGN_ON (System_FUN_KL15_Status_Get() == 1U)
#define SYS_OPR_STAT_IGN_OFF (System_FUN_KL15_Status_Get() == 0U)
/*网络管理电源工作状态*/
#define SYS_OPR_STAT_IGN_ON_NM (System_NM_KL15_Status_Get() == 1U)
#define SYS_OPR_STAT_IGN_OFF_NM (System_NM_KL15_Status_Get() == 0U)
/*网络管理电源运行状态*/
#define SYS_OPR_STAT_RUN_NM ((System_NM_KL30_Status_Get() > 1u) && (System_NM_KL30_Status_Get() < 9u ))
#define SYS_OPR_STAT_HALT_NM ((System_NM_KL30_Status_Get() == 9u) || (System_NM_KL30_Status_Get() == 1u))
static
uint8_t
System_Calc_FunRange
(
uint16_t
u16Vol
);
static
uint8_t
System_Calc_NMRange
(
uint16_t
u16Vol
);
uint8_t
Read_KL30_ConvertFinish
(
void
);
static
void
System_Fun_Process
(
void
);
static
void
System_NM_Process
(
void
);
void
Sys_LogicProcess
(
void
);
void
Sys_Status_Update_Service
(
void
);
uint16_t
Sys_Read_KL30_Voltage
(
void
);
uint16_t
Sys_Read_KL15_Voltage
(
void
);
uint8_t
Sys_Read_KL30_Valid
(
void
);
uint8_t
Sys_Read_KL15_Valid
(
void
);
uint16_t
Sys_Force_Read_KL30_Voltage
(
void
);
uint16_t
Sys_Force_Read_KL15_Voltage
(
void
);
uint8_t
System_FUN_KL30_Status_Get
(
void
);
uint8_t
System_FUN_KL15_Status_Get
(
void
);
uint8_t
System_NM_KL15_Status_Get
(
void
);
uint8_t
System_NM_KL30_Status_Get
(
void
);
uint8_t
System_LINE_KL15
(
void
);
void
Sys_Set_DebounceTimer
(
uint16_t
u16NMKL30
,
uint16_t
u16NMKL15
,
uint16_t
u16FUNKL30
,
uint16_t
u16FUNKL15
);
/*void Sys_Set_VolRange(uint16_t FUN_Vol[], uint16_t NM_Vol[]);*/
void
Sys_Set_VolRange
(
const
uint16_t
FUN_Vol
[],
const
uint16_t
NM_Vol
[]);
typedef
struct
{
Get_Voltage_Vaild
SysGet_KL30_Valid
;
Get_Voltage_Vaild
SysGet_KL15_Valid
;
Get_Voltage_Value
SysGet_KL30_value_Force
;
Get_Voltage_Value
SysGet_KL15_value_Force
;
Get_Voltage_Value
SysGet_KL30_value
;
Get_Voltage_Value
SysGet_KL15_value
;
Get_LineInStatus
SysGet_KL15Line
;
COMMON_Delay
COM_Delay
;
pfunLogic
SysMonitorLogic
;
}
MonitorExt_st
;
/* SYS RUN Status */
#define SYS_OPR_STAT_RUN ((System_FUN_KL30_Status_Get( ) > 1u) && (System_FUN_KL30_Status_Get( ) < 7u))
#define SYS_OPR_STAT_HALT ((System_FUN_KL30_Status_Get( ) == 3u) || (System_FUN_KL30_Status_Get( ) > 7u))
#define SYS_OPR_STAT_LIM_LVP (System_FUN_KL30_Status_Get( ) == 1U)
#define SYS_OPR_STAT_LIM_OVP (System_FUN_KL30_Status_Get( ) > 7u)
/*fun status*/
#define SYS_OPR_STAT_IGN_ON (System_FUN_KL15_Status_Get( ) == 1U)
#define SYS_OPR_STAT_IGN_OFF (System_FUN_KL15_Status_Get( ) == 0U)
/*nm run status*/
#define SYS_OPR_STAT_IGN_ON_NM (System_NM_KL15_Status_Get( ) == 1U)
#define SYS_OPR_STAT_IGN_OFF_NM (System_NM_KL15_Status_Get( ) == 0U)
/*nm status*/
#define SYS_OPR_STAT_RUN_NM ((System_NM_KL30_Status_Get( ) > 1u) && (System_NM_KL30_Status_Get( ) < 9u))
#define SYS_OPR_STAT_HALT_NM ((System_NM_KL30_Status_Get( ) == 9u) || (System_NM_KL30_Status_Get( ) == 1u))
monitorlib_uint8_t
Read_KL30_ConvertFinish
(
void
);
monitorlib_uint16_t
Get_Sysmonitor_Version
(
void
);
void
Sys_Status_Update_Service
(
void
);
void
Sys_Set_Pata
(
const
monitorlib_uint16_t
FUN_Vol
[],
MonitorExt_st
*
pfunc
);
void
System_Monitor_KL30Init
(
void
);
void
System_Monitor_WakeupInit
(
void
);
void
System_
Fast_WakeUp
(
void
);
void
System_
XHY_CheckWakeup
(
void
);
void
Sys_KL30_Init
(
void
);
void
Sys_WakeUp_Init
(
void
);
void
Sys_BlockDelay
(
uint32_t
u32Ms
);
void
Sys_Rolling
(
void
);
void
Sys_RollingClear
(
void
);
uint32_t
Sys_Get_ms_Rolling_Counter
(
void
);
monitorlib_uint8_t
System_FUN_KL30_Status_Get
(
void
);
monitorlib_uint8_t
System_FUN_KL15_Status_Get
(
void
);
monitorlib_uint8_t
System_NM_KL15_Status_Get
(
void
);
monitorlib_uint8_t
System_NM_KL30_Status_Get
(
void
);
monitorlib_uint8_t
System_LINE_KL15
(
void
);
void
Sys_WakeUp_Init
(
void
);
#endif
source/Application/APP/PowerManagement/System_Monitor_user.c
View file @
435ca6de
#include "System_Monitor.h"
#include "RTE_ADC.h"
#include "GenDelay.h"
#include "GPIO.h"
#include "dr7f701441.dvf.h"
#include "Watchdog.h"
#include "COM_CAN.h"
#define u16Base_Vol 0u
#define u16ENTER_LOW_N_RANGE 6500U
#define u16EXIT_LOW_N_RANGE 7000U
#define u16ENTER_LOW_Y_RANGE 9000U
#define u16EXIT_LOW_Y_RANGE 9500U
#define u16EXIT_HIGH_Y_RANGE 30000U
#define u16ENTER_HIGH_Y_RANGE 32000U
#define u16EXIT_HIGH_N_RANGE 31000U
#define u16ENTER_HIGH_N_RANGE 33000U
#include "ADC.h"
#include "System_Monitor.h"
#include "Analog_Signals.h"
#define u16Base_Vol 0u // 0
#define u16ENTER_LOW_N_RANGE 6500U // 1
#define u16EXIT_LOW_N_RANGE 7000U // 2
#define u16ENTER_LOW_Y_RANGE 19500U // 3
#define u16EXIT_LOW_Y_RANGE 20000U // 4
#define u16EXIT_HIGH_Y_RANGE 32000U // 5
#define u16ENTER_HIGH_Y_RANGE 32500U // 6
#define u16EXIT_HIGH_N_RANGE 33000U // 7
#define u16ENTER_HIGH_N_RANGE 33500U // 8
#define u16Top_Vol 0xffffu
uint32_t
u32SysRollingCounter
;
static
const
uint16_t
SysFun_Range
[
10u
]
=
{
#pragma alignvar(8)
static
const
monitorlib_uint16_t
SysFun_Range
[
26u
]
=
{
u16Base_Vol
,
u16ENTER_LOW_N_RANGE
,
...
...
@@ -42,10 +32,8 @@ static const uint16_t SysFun_Range[10u] =
u16ENTER_HIGH_N_RANGE
,
u16Top_Vol
,
};
static
const
uint16_t
SysNM_Range
[
10u
]
=
{
30000u
,
/**进入保护的时间*/
10u
,
u16Base_Vol
,
u16ENTER_LOW_N_RANGE
,
...
...
@@ -61,122 +49,106 @@ static const uint16_t SysNM_Range[10u] =
u16ENTER_HIGH_N_RANGE
,
u16Top_Vol
,
10000u
,
10u
,
10u
,
/**退出保护的时间*/
10u
,
/**退出保护的时间*/
};
uint16_t
Sys_Force_Read_KL30_Voltage
(
void
)
monitorlib_uint16_t
Sys_Read_KL30_Voltage_F
(
void
)
{
uint16_t
u16Voltage
;
u16Voltage
=
(
uint16_t
)
RTE_ForceRead_KL30_Voltage
();
monitorlib_uint16_t
u16Voltage
;
u16Voltage
=
ADC_Conv_Single_Channel
(
ADC_CH_KL30_VOLTAGE
);
return
u16Voltage
;
}
uint16_t
Sys_Force_Read_KL15_Voltage
(
void
)
monitorlib_uint16_t
Sys_Read_KL15_Voltage_F
(
void
)
{
uint16_t
u16Voltage
;
u16Voltage
=
(
uint16_t
)
RTE_ForceRead_KL15_Voltage
();
monitorlib_uint16_t
u16Voltage
;
u16Voltage
=
ADC_Conv_Single_Channel
(
ADC_CH_KL30_VOLTAGE
);
return
u16Voltage
;
}
uint16_t
Sys_Read_KL30_Voltage
(
void
)
monitorlib_uint16_t
Sys_Read_KL30_Voltage
(
void
)
{
uint16_t
u16Voltage
;
u16Voltage
=
(
uint16_t
)
RTE_Read_KL30_Voltage
();
monitorlib_uint16_t
u16Voltage
;
u16Voltage
=
ADC_Read_Signal
(
ADC_CH_KL30_VOLTAGE
);
return
u16Voltage
;
}
uint16_t
Sys_Read_KL15_Voltage
(
void
)
monitorlib_uint16_t
Sys_Read_KL15_Voltage
(
void
)
{
uint16_t
u16Voltage
;
u16Voltage
=
(
uint16_t
)
RTE_Read_KL15_Voltage
();
monitorlib_uint16_t
u16Voltage
;
u16Voltage
=
ADC_Read_Signal
(
ADC_CH_KL30_VOLTAGE
);
return
u16Voltage
;
}
uint8_t
Sys_Read_KL30_Valid
(
void
)
monitorlib_uint8_t
Sys_Read_KL30_Valid
(
void
)
{
uint8_t
u8Valid
;
u8Valid
=
RTE_Read_KL30_Valid
();
monitorlib_uint8_t
u8Valid
;
u8Valid
=
ADC_Read_Signal_Valid
(
ADC_CH_KL30_VOLTAGE
);
return
u8Valid
;
}
uint8_t
Sys_Read_KL15_Valid
(
void
)
monitorlib_uint8_t
Sys_Read_KL15_Valid
(
void
)
{
uint8_t
u8Valid
;
u8Valid
=
RTE_Read_KL15_Valid
();
monitorlib_uint8_t
u8Valid
;
u8Valid
=
ADC_Read_Signal_Valid
(
ADC_CH_KL30_VOLTAGE
);
return
u8Valid
;
}
uint8_t
System_LINE_KL15
(
void
)
{
uint8_t
u8KL15
;
u8KL15
=
ADC_KL15_IN
;
//15��Ӳ��
return
u8KL15
;
}
void
Sys_KL30_Init
(
void
)
{
Sys_Set_DebounceTimer
(
1000u
,
2u
,
1000u
,
80u
);
Sys_Set_VolRange
(
SysFun_Range
,
SysNM_Range
);
System_Monitor_KL30Init
();
System_Fast_WakeUp
();
}
void
Sys_WakeUp_Init
(
void
)
{
Sys_Set_DebounceTimer
(
1000u
,
2u
,
1000u
,
80u
);
Sys_Set_VolRange
(
SysFun_Range
,
SysNM_Range
);
System_Monitor_WakeupInit
();
System_Fast_WakeUp
();
}
/*����������ִ�������*/
void
Sys_LogicProcess
(
void
)
monitorlib_uint8_t
System_LINE_KL15
(
void
)
{
COM_NM_ACT
();
}
monitorlib_uint8_t
u8KL15
;
void
Sys_Rolling
(
void
)
{
if
(
u32SysRollingCounter
!=
65535ul
)
if
(
ADC_KL15_IN
==
1u
)
{
u
32SysRollingCounter
++
;
u
8KL15
=
1u
;
}
else
{
u
32SysRollingCounter
=
0
;
u
8KL15
=
0u
;
}
return
u8KL15
;
}
void
Sys_RollingClear
(
void
)
void
Common_BlockDelay
(
monitorlib_uint32_t
u32Ms
)
{
u32SysRollingCounter
=
0
;
Gen_TimeDelay
(
u32Ms
*
1000u
,
50u
);
}
uint32_t
Sys_Get_ms_Rolling_Counter
(
void
)
void
Sys_LogicProcess
(
void
)
{
return
u32SysRollingCounter
;
}
void
Sys_BlockDelay
(
uint32_t
u32Ms
)
{
uint32_t
RocBackup
,
Counter
;
Sys_RollingClear
();
RocBackup
=
Sys_Get_ms_Rolling_Counter
();
do
{
WDT_Clear
();
Counter
=
Sys_Get_ms_Rolling_Counter
();
if
(
Counter
>=
RocBackup
)
{
Counter
-=
RocBackup
;
}
else
{
Counter
=
65535U
-
RocBackup
+
Counter
+
1U
;
}
}
while
(
Counter
<
u32Ms
);
void
Sys_KL30_Init
(
void
)
{
MonitorExt_st
m_st
;
m_st
.
COM_Delay
=
Common_BlockDelay
;
m_st
.
SysGet_KL15Line
=
System_LINE_KL15
;
m_st
.
SysGet_KL15_Valid
=
Sys_Read_KL15_Valid
;
m_st
.
SysGet_KL30_Valid
=
Sys_Read_KL30_Valid
;
m_st
.
SysGet_KL15_value
=
Sys_Read_KL15_Voltage
;
m_st
.
SysGet_KL30_value
=
Sys_Read_KL30_Voltage
;
m_st
.
SysGet_KL15_value_Force
=
Sys_Read_KL15_Voltage_F
;
m_st
.
SysGet_KL30_value_Force
=
Sys_Read_KL30_Voltage_F
;
m_st
.
SysMonitorLogic
=
Sys_LogicProcess
;
Sys_Set_Pata
(
SysFun_Range
,
&
m_st
);
System_Monitor_KL30Init
(
);
}
void
Sys_WakeUp_Init
(
void
)
{
MonitorExt_st
m_st
;
m_st
.
COM_Delay
=
Common_BlockDelay
;
m_st
.
SysGet_KL15Line
=
System_LINE_KL15
;
m_st
.
SysGet_KL15_Valid
=
Sys_Read_KL15_Valid
;
m_st
.
SysGet_KL30_Valid
=
Sys_Read_KL30_Valid
;
m_st
.
SysGet_KL15_value
=
Sys_Read_KL15_Voltage
;
m_st
.
SysGet_KL30_value
=
Sys_Read_KL30_Voltage
;
m_st
.
SysGet_KL15_value_Force
=
Sys_Read_KL15_Voltage_F
;
m_st
.
SysGet_KL30_value_Force
=
Sys_Read_KL30_Voltage_F
;
m_st
.
SysMonitorLogic
=
Sys_LogicProcess
;
Sys_Set_Pata
(
SysFun_Range
,
&
m_st
);
System_Monitor_WakeupInit
(
);
}
source/Application/RTE/Common_Interface.c
View file @
435ca6de
...
...
@@ -673,31 +673,31 @@ uint16_t Common_ReadRollingCounter(void)
return
SysRollingCounter
;
}
void
Common_BlockDelay
(
uint16_t
m_MS
)
{
uint16_t
RocBackup
;
uint16_t
Counter
;
uint16_t
DIMCounter
;
DIMCounter
=
m_MS
*
20u
;
Common_RollingCounterClear
();
RocBackup
=
Common_ReadRollingCounter
();
do
{
Counter
=
Common_ReadRollingCounter
();
if
(
Counter
>=
RocBackup
)
{
Counter
-=
RocBackup
;
}
else
{
Counter
=
65535u
-
RocBackup
+
Counter
+
1u
;
}
}
while
(
Counter
<
DIMCounter
);
}
//
void Common_BlockDelay(uint16_t m_MS)
//
{
//
uint16_t RocBackup;
//
uint16_t Counter;
//
uint16_t DIMCounter;
//
//
DIMCounter = m_MS * 20u;
//
Common_RollingCounterClear();
//
RocBackup = Common_ReadRollingCounter();
//
do
//
{
//
Counter = Common_ReadRollingCounter();
//
//
if (Counter >= RocBackup)
//
{
//
Counter -= RocBackup;
//
}
//
else
//
{
//
Counter = 65535u - RocBackup + Counter + 1u;
//
}
//
//
}
//
while (Counter < DIMCounter);
//
}
uint32_t
Common_GetIgnOnTime
(
void
)
{
...
...
source/Application/RTE/Common_Interface.h
View file @
435ca6de
...
...
@@ -30,7 +30,7 @@ uint32_t Common_GetIgnOffTime(void); /*ms*/
void
Common_RollingCounterAdd
(
void
);
void
Common_RollingCounterClear
(
void
);
void
Common_BlockDelay
(
uint16_t
m_MS
);
//
void Common_BlockDelay(uint16_t m_MS);
uint16_t
Common_ReadRollingCounter
(
void
);
void
Set_Can18FF5510_FirstRecv_Event
(
void
);
...
...
source/Driver/CAN/Rscan.c
View file @
435ca6de
...
...
@@ -15,26 +15,26 @@
#define RSCAN0_BASE_ADDRESS 0xFFD00000UL
/*--------------500K-----------------------------*/
#define RSCAN0_500K_BAUD_RATE 500U //波特率,单位kbps
#define RSCAN0_500K_T_SEG1 12U //时间段1的Tq数
#define RSCAN0_500K_T_SEG2 3U //时间段2的Tq数
#define RSCAN0_500K_SJW 3U //同步跳转宽度
#define RSCAN0_500K_BAUD_RATE 500U //
波特率,单位kbps
#define RSCAN0_500K_T_SEG1 12U //
时间段1的Tq数
#define RSCAN0_500K_T_SEG2 3U //
时间段2的Tq数
#define RSCAN0_500K_SJW 3U //
同步跳转宽度
#define RSCAN_500K_BIT_RATE_DIV (RSCAN_F_CAN / (RSCAN0_500K_BAUD_RATE) / (RSCAN0_500K_T_SEG1 + RSCAN0_500K_T_SEG2 + 1UL) / 1000UL)
/*-----------------250K---------------------------------*/
#define RSCAN0_250K_BAUD_RATE 250U //波特率,单位kbps
#define RSCAN0_250K_T_SEG1 13U //11 //时间段1的Tq数
#define RSCAN0_250K_T_SEG2 2U //4 //时间段2的Tq数
#define RSCAN0_250K_SJW 1U //2 //3
#define RSCAN0_250K_BAUD_RATE 250U //
波特率,单位kbps
#define RSCAN0_250K_T_SEG1 13U //
11 //时间段1的Tq数
#define RSCAN0_250K_T_SEG2 2U //
4 //时间段2的Tq数
#define RSCAN0_250K_SJW 1U //
2 //3
#define RSCAN_250K_BIT_RATE_DIV (RSCAN_F_CAN / (RSCAN0_250K_BAUD_RATE) / (RSCAN0_250K_T_SEG1 + RSCAN0_250K_T_SEG2 + 1UL) / 1000UL)
/*-----------------125K---------------------------------*/
#define RSCAN0_125K_BAUD_RATE 125U //波特率,单位kbps
#define RSCAN0_125K_T_SEG1 13U //11 //时间段1的Tq数
#define RSCAN0_125K_T_SEG2 2U //4 //时间段2的Tq数
#define RSCAN0_125K_SJW 1U //2 //3
#define RSCAN0_125K_BAUD_RATE 125U //
波特率,单位kbps
#define RSCAN0_125K_T_SEG1 13U //
11 //时间段1的Tq数
#define RSCAN0_125K_T_SEG2 2U //
4 //时间段2的Tq数
#define RSCAN0_125K_SJW 1U //
2 //3
#define RSCAN_125K_BIT_RATE_DIV (RSCAN_F_CAN / (RSCAN0_125K_BAUD_RATE) / (RSCAN0_125K_T_SEG1 + RSCAN0_125K_T_SEG2 + 1UL) / 1000UL)
/*------------------------------------------------*/
...
...
@@ -53,7 +53,7 @@
#endif
/*---------------------------------------*/
#define RSCAN_TIME_OUT_MAX 0X0000FFFFUL
/*---------------------------------------*/
/***************************************************/
...
...
@@ -174,6 +174,7 @@ uint8_t RSCAN0_CH_Init(const RSCANFD_Filter_st_t pstRSCANFilter[], RSCAN0_Config
uint32_t
u32CANFDCalBuf
=
0UL
;
uint8_t
u8Status
=
1U
;
uint32_t
u32RSCANChannelRuleTotal
=
0UL
;
uint32_t
u32RSCANTimeCount
=
0UL
;
volatile
RSCANFD_Filter_st_t
*
pstCANFDRule
;
...
...
@@ -211,18 +212,28 @@ uint8_t RSCAN0_CH_Init(const RSCANFD_Filter_st_t pstRSCANFilter[], RSCAN0_Config
if
(
u8Status
==
1U
)
{
/* Waiting for CAN RAM initialization is completed */
while
(
RSCAN0GSTS
&
0x08UL
)
u32RSCANTimeCount
=
0UL
;
while
((
RSCAN0GSTS
&
0x08UL
)
&&
(
u32RSCANTimeCount
<
RSCAN_TIME_OUT_MAX
))
{
u32RSCANTimeCount
++
;
}
if
(
u32RSCANTimeCount
>=
RSCAN_TIME_OUT_MAX
)
{
;
u8Status
=
0U
;
}
/* Waiting for CAN entry global reset mdoe */
RSCAN0GCTR
&=
0xfffffff9UL
;
RSCAN0GCTR
|=
0x01UL
;
while
((
RSCAN0GSTS
&
0x07UL
)
!=
0X01UL
)
u32RSCANTimeCount
=
0UL
;
while
(((
RSCAN0GSTS
&
0x07UL
)
!=
0X01UL
)
&&
(
u32RSCANTimeCount
<
RSCAN_TIME_OUT_MAX
))
{
u32RSCANTimeCount
++
;
}
if
(
u32RSCANTimeCount
>=
RSCAN_TIME_OUT_MAX
)
{
;
u8Status
=
0U
;
}
/* Waiting for CAN entry channel reset mdoe */
...
...
@@ -246,23 +257,40 @@ uint8_t RSCAN0_CH_Init(const RSCANFD_Filter_st_t pstRSCANFilter[], RSCAN0_Config
/* waiting */
if
(
pstRSCANConfig
->
stRSCANCh0
.
u32RSCANChEn
)
{
while
((
RSCAN0C0STS
&
0x07UL
)
!=
0X01UL
)
u32RSCANTimeCount
=
0UL
;
while
(((
RSCAN0C0STS
&
0x07UL
)
!=
0X01UL
)
&&
(
u32RSCANTimeCount
<
RSCAN_TIME_OUT_MAX
))
{
u32RSCANTimeCount
++
;
}
if
(
u32RSCANTimeCount
>=
RSCAN_TIME_OUT_MAX
)
{
;
u8Status
=
0U
;
}
}
if
(
pstRSCANConfig
->
stRSCANCh1
.
u32RSCANChEn
)
{
while
((
RSCAN0C1STS
&
0x07UL
)
!=
0X01UL
)
u32RSCANTimeCount
=
0UL
;
while
(((
RSCAN0C1STS
&
0x07UL
)
!=
0X01UL
)
&&
(
u32RSCANTimeCount
<
RSCAN_TIME_OUT_MAX
))
{
u32RSCANTimeCount
++
;
}
if
(
u32RSCANTimeCount
>=
RSCAN_TIME_OUT_MAX
)
{
;
u8Status
=
0U
;
}
}
if
(
pstRSCANConfig
->
stRSCANCh2
.
u32RSCANChEn
)
{
while
((
RSCAN0C2STS
&
0x07UL
)
!=
0X01UL
)
u32RSCANTimeCount
=
0UL
;
while
(((
RSCAN0C2STS
&
0x07UL
)
!=
0X01UL
)
&&
(
u32RSCANTimeCount
<
RSCAN_TIME_OUT_MAX
))
{
u32RSCANTimeCount
++
;
}
if
(
u32RSCANTimeCount
>=
RSCAN_TIME_OUT_MAX
)
{
;
u8Status
=
0U
;
}
}
...
...
@@ -435,9 +463,15 @@ uint8_t RSCAN0_CH_Init(const RSCANFD_Filter_st_t pstRSCANFilter[], RSCAN0_Config
/*Transition to global operating mode*/
RSCAN0GCTR
&=
0xFFFFFFFCUL
;
while
((
RSCAN0GSTS
&
0x07UL
)
!=
0X00UL
)
u32RSCANTimeCount
=
0UL
;
while
(((
RSCAN0GSTS
&
0x07UL
)
!=
0X00UL
)
&&
(
u32RSCANTimeCount
<
RSCAN_TIME_OUT_MAX
))
{
u32RSCANTimeCount
++
;
}
if
(
u32RSCANTimeCount
>=
RSCAN_TIME_OUT_MAX
)
{
;
u8Status
=
0U
;
}
/*Transition to channel communication mode*/
...
...
@@ -456,20 +490,40 @@ uint8_t RSCAN0_CH_Init(const RSCANFD_Filter_st_t pstRSCANFilter[], RSCAN0_Config
if
(
pstRSCANConfig
->
stRSCANCh0
.
u32RSCANChEn
)
{
while
((
RSCAN0C0STS
&
0x80UL
)
==
0x0UL
)
u32RSCANTimeCount
=
0UL
;
while
(((
RSCAN0C0STS
&
0x80UL
)
==
0x0UL
)
&&
(
u32RSCANTimeCount
<
RSCAN_TIME_OUT_MAX
))
{
u32RSCANTimeCount
++
;
}
if
(
u32RSCANTimeCount
>=
RSCAN_TIME_OUT_MAX
)
{
u8Status
=
0U
;
}
}
if
(
pstRSCANConfig
->
stRSCANCh1
.
u32RSCANChEn
)
{
while
((
RSCAN0C1STS
&
0x80UL
)
==
0x0UL
)
u32RSCANTimeCount
=
0UL
;
while
(((
RSCAN0C1STS
&
0x80UL
)
==
0x0UL
)
&&
(
u32RSCANTimeCount
<
RSCAN_TIME_OUT_MAX
))
{
u32RSCANTimeCount
++
;
}
if
(
u32RSCANTimeCount
>=
RSCAN_TIME_OUT_MAX
)
{
u8Status
=
0U
;
}
}
if
(
pstRSCANConfig
->
stRSCANCh2
.
u32RSCANChEn
)
{
while
((
RSCAN0C2STS
&
0x80UL
)
==
0x0UL
)
u32RSCANTimeCount
=
0UL
;
while
(((
RSCAN0C2STS
&
0x80UL
)
==
0x0UL
)
&&
(
u32RSCANTimeCount
<
RSCAN_TIME_OUT_MAX
))
{
u32RSCANTimeCount
++
;
}
if
(
u32RSCANTimeCount
>=
RSCAN_TIME_OUT_MAX
)
{
u8Status
=
0U
;
}
}
...
...
@@ -540,7 +594,7 @@ RSCAN_SetState RSCAN0_CH0_Set_FIFO0_Data(CAN_Frame_st_t *pstCANFrame)
u32RSCANAddress
=
u32RSCANBufIndexK
*
4UL
+
0X178UL
+
RSCAN0_BASE_ADDRESS
;
if
(((
*
((
uint32_t
*
)(
u32RSCANAddress
)))
&
0x00000002UL
)
==
0x0U
)
//if ((RSCAN0CFSTS3 & 0x00000002UL) == 0x0U)
//
if ((RSCAN0CFSTS3 & 0x00000002UL) == 0x0U)
{
u32RSCANDataBuf
=
pstCANFrame
->
u8CANFrameIDE
;
...
...
@@ -549,23 +603,23 @@ RSCAN_SetState RSCAN0_CH0_Set_FIFO0_Data(CAN_Frame_st_t *pstCANFrame)
u32RSCANAddress
=
u32RSCANBufIndexK
*
0x10UL
+
0XE80UL
+
RSCAN0_BASE_ADDRESS
;
(
*
((
uint32_t
*
)(
u32RSCANAddress
)))
=
u32RSCANDataBuf
;
//RCFDC0CFDCFID3 = u32RSCANDataBuf;
//
RCFDC0CFDCFID3 = u32RSCANDataBuf;
u32RSCANDataBuf
=
pstCANFrame
->
u8CANLEN
;
u32RSCANAddress
=
u32RSCANBufIndexK
*
0x10UL
+
0XE84UL
+
RSCAN0_BASE_ADDRESS
;
(
*
((
uint32_t
*
)(
u32RSCANAddress
)))
=
((
u32RSCANDataBuf
)
<<
28U
);
//RCFDC0CFDCFPTR3 = ((u32RSCANDataBuf) << 28U);
//
RCFDC0CFDCFPTR3 = ((u32RSCANDataBuf) << 28U);
u32RSCANAddress
=
u32RSCANBufIndexK
*
0x10UL
+
0XE88UL
+
RSCAN0_BASE_ADDRESS
;
(
*
((
uint32_t
*
)(
u32RSCANAddress
)))
=
pstCANFrame
->
unCANData
.
u32CANData
[
0U
];
//RCFDC0CFDCFDF0_3 = pstCANFrame->unCANData.u32CANData[0U];
//
RCFDC0CFDCFDF0_3 = pstCANFrame->unCANData.u32CANData[0U];
u32RSCANAddress
+=
0X04UL
;
(
*
((
uint32_t
*
)(
u32RSCANAddress
)))
=
pstCANFrame
->
unCANData
.
u32CANData
[
1U
];
//RCFDC0CFDCFDF1_3 = pstCANFrame->unCANData.u32CANData[1U];
//
RCFDC0CFDCFDF1_3 = pstCANFrame->unCANData.u32CANData[1U];
u32RSCANAddress
=
u32RSCANBufIndexK
*
0x4UL
+
0X1D8UL
+
RSCAN0_BASE_ADDRESS
;
(
*
((
uint32_t
*
)(
u32RSCANAddress
)))
=
0XFFUL
;
//RCFDC0CFDCFPCTR3 = 0XFFUL;
//
RCFDC0CFDCFPCTR3 = 0XFFUL;
enRSCANStatus
=
RSCAN_SET_COMPLETE
;
}
...
...
@@ -595,7 +649,7 @@ RSCAN_SetState RSCAN0_CH1_Set_FIFO0_Data(CAN_Frame_st_t *pstCANFrame)
u32RSCANAddress
=
u32RSCANBufIndexK
*
4UL
+
0X178UL
+
RSCAN0_BASE_ADDRESS
;
if
(((
*
((
uint32_t
*
)(
u32RSCANAddress
)))
&
0x00000002UL
)
==
0x0U
)
//if ((RSCAN0CFSTS3 & 0x00000002UL) == 0x0U)
//
if ((RSCAN0CFSTS3 & 0x00000002UL) == 0x0U)
{
u32RSCANDataBuf
=
pstCANFrame
->
u8CANFrameIDE
;
...
...
@@ -604,23 +658,23 @@ RSCAN_SetState RSCAN0_CH1_Set_FIFO0_Data(CAN_Frame_st_t *pstCANFrame)
u32RSCANAddress
=
u32RSCANBufIndexK
*
0x10UL
+
0XE80UL
+
RSCAN0_BASE_ADDRESS
;
(
*
((
uint32_t
*
)(
u32RSCANAddress
)))
=
u32RSCANDataBuf
;
//RCFDC0CFDCFID3 = u32RSCANDataBuf;
//
RCFDC0CFDCFID3 = u32RSCANDataBuf;
u32RSCANDataBuf
=
pstCANFrame
->
u8CANLEN
;
u32RSCANAddress
=
u32RSCANBufIndexK
*
0x10UL
+
0XE84UL
+
RSCAN0_BASE_ADDRESS
;
(
*
((
uint32_t
*
)(
u32RSCANAddress
)))
=
((
u32RSCANDataBuf
)
<<
28U
);
//RCFDC0CFDCFPTR3 = ((u32RSCANDataBuf) << 28U);
//
RCFDC0CFDCFPTR3 = ((u32RSCANDataBuf) << 28U);
u32RSCANAddress
=
u32RSCANBufIndexK
*
0x10UL
+
0XE88UL
+
RSCAN0_BASE_ADDRESS
;
(
*
((
uint32_t
*
)(
u32RSCANAddress
)))
=
pstCANFrame
->
unCANData
.
u32CANData
[
0U
];
//RCFDC0CFDCFDF0_3 = pstCANFrame->unCANData.u32CANData[0U];
//
RCFDC0CFDCFDF0_3 = pstCANFrame->unCANData.u32CANData[0U];
u32RSCANAddress
+=
0X04UL
;
(
*
((
uint32_t
*
)(
u32RSCANAddress
)))
=
pstCANFrame
->
unCANData
.
u32CANData
[
1U
];
//RCFDC0CFDCFDF1_3 = pstCANFrame->unCANData.u32CANData[1U];
//
RCFDC0CFDCFDF1_3 = pstCANFrame->unCANData.u32CANData[1U];
u32RSCANAddress
=
u32RSCANBufIndexK
*
0x4UL
+
0X1D8UL
+
RSCAN0_BASE_ADDRESS
;
(
*
((
uint32_t
*
)(
u32RSCANAddress
)))
=
0XFFUL
;
//RCFDC0CFDCFPCTR3 = 0XFFUL;
//
RCFDC0CFDCFPCTR3 = 0XFFUL;
enRSCANStatus
=
RSCAN_SET_COMPLETE
;
}
...
...
@@ -649,7 +703,7 @@ RSCAN_SetState RSCAN0_CH2_Set_FIFO0_Data(CAN_Frame_st_t *pstCANFrame)
u32RSCANAddress
=
u32RSCANBufIndexK
*
4UL
+
0X178UL
+
RSCAN0_BASE_ADDRESS
;
if
(((
*
((
uint32_t
*
)(
u32RSCANAddress
)))
&
0x00000002UL
)
==
0x0U
)
//if ((RSCAN0CFSTS3 & 0x00000002UL) == 0x0U)
//
if ((RSCAN0CFSTS3 & 0x00000002UL) == 0x0U)
{
u32RSCANDataBuf
=
pstCANFrame
->
u8CANFrameIDE
;
...
...
@@ -658,23 +712,23 @@ RSCAN_SetState RSCAN0_CH2_Set_FIFO0_Data(CAN_Frame_st_t *pstCANFrame)
u32RSCANAddress
=
u32RSCANBufIndexK
*
0x10UL
+
0XE80UL
+
RSCAN0_BASE_ADDRESS
;
(
*
((
uint32_t
*
)(
u32RSCANAddress
)))
=
u32RSCANDataBuf
;
//RCFDC0CFDCFID3 = u32RSCANDataBuf;
//
RCFDC0CFDCFID3 = u32RSCANDataBuf;
u32RSCANDataBuf
=
pstCANFrame
->
u8CANLEN
;
u32RSCANAddress
=
u32RSCANBufIndexK
*
0x10UL
+
0XE84UL
+
RSCAN0_BASE_ADDRESS
;
(
*
((
uint32_t
*
)(
u32RSCANAddress
)))
=
((
u32RSCANDataBuf
)
<<
28U
);
//RCFDC0CFDCFPTR3 = ((u32RSCANDataBuf) << 28U);
//
RCFDC0CFDCFPTR3 = ((u32RSCANDataBuf) << 28U);
u32RSCANAddress
=
u32RSCANBufIndexK
*
0x10UL
+
0XE88UL
+
RSCAN0_BASE_ADDRESS
;
(
*
((
uint32_t
*
)(
u32RSCANAddress
)))
=
pstCANFrame
->
unCANData
.
u32CANData
[
0U
];
//RCFDC0CFDCFDF0_3 = pstCANFrame->unCANData.u32CANData[0U];
//
RCFDC0CFDCFDF0_3 = pstCANFrame->unCANData.u32CANData[0U];
u32RSCANAddress
+=
0X04UL
;
(
*
((
uint32_t
*
)(
u32RSCANAddress
)))
=
pstCANFrame
->
unCANData
.
u32CANData
[
1U
];
//RCFDC0CFDCFDF1_3 = pstCANFrame->unCANData.u32CANData[1U];
//
RCFDC0CFDCFDF1_3 = pstCANFrame->unCANData.u32CANData[1U];
u32RSCANAddress
=
u32RSCANBufIndexK
*
0x4UL
+
0X1D8UL
+
RSCAN0_BASE_ADDRESS
;
(
*
((
uint32_t
*
)(
u32RSCANAddress
)))
=
0XFFUL
;
//RCFDC0CFDCFPCTR3 = 0XFFUL;
//
RCFDC0CFDCFPCTR3 = 0XFFUL;
enRSCANStatus
=
RSCAN_SET_COMPLETE
;
}
...
...
@@ -705,33 +759,33 @@ RSCAN_SetState RSCAN0_CH0_Set_TXBUF_Data(RSCAN_Channel_Buf_en_t enBufIndex, CAN_
{
u32RSCANAddress
=
u32RSCANBufIndexP
+
0X2D0UL
+
RSCAN0_BASE_ADDRESS
;
if
(((
*
((
uint8_t
*
)
u32RSCANAddress
))
&
0x08U
)
==
0x0U
)
//if ((RSCAN0TMSTS0 & 0x08U) == 0x0U)
//
if ((RSCAN0TMSTS0 & 0x08U) == 0x0U)
{
(
*
((
uint8_t
*
)
u32RSCANAddress
))
=
0UL
;
//RSCAN0TMSTS0 = 0UL;
//
RSCAN0TMSTS0 = 0UL;
u32RSCANDataBuf
=
pstCANFrame
->
u8CANFrameIDE
;
u32RSCANDataBuf
=
u32RSCANDataBuf
<<
31U
;
u32RSCANDataBuf
|=
pstCANFrame
->
u32CANID
;
u32RSCANAddress
=
u32RSCANBufIndexP
*
0X10UL
+
0X1000UL
+
RSCAN0_BASE_ADDRESS
;
(
*
((
uint32_t
*
)
u32RSCANAddress
))
=
u32RSCANDataBuf
;
//RCFDC0CFDTMID0 = u32RSCANDataBuf;
//
RCFDC0CFDTMID0 = u32RSCANDataBuf;
u32RSCANDataBuf
=
pstCANFrame
->
u8CANLEN
;
u32RSCANAddress
=
u32RSCANBufIndexP
*
0X10UL
+
0X1004UL
+
RSCAN0_BASE_ADDRESS
;
(
*
((
uint32_t
*
)
u32RSCANAddress
))
=
(
uint32_t
)((
u32RSCANDataBuf
)
<<
28U
);
//RCFDC0CFDTMPTR0 = (uint32_t)((u32RSCANDataBuf) << 28U);
//
RCFDC0CFDTMPTR0 = (uint32_t)((u32RSCANDataBuf) << 28U);
u32RSCANAddress
=
u32RSCANBufIndexP
*
0X10UL
+
0X1008UL
+
RSCAN0_BASE_ADDRESS
;
(
*
((
uint32_t
*
)
u32RSCANAddress
))
=
pstCANFrame
->
unCANData
.
u32CANData
[
0U
];
//RCFDC0CFDTMDF0_0 = pstCANFrame->unCANData.u32CANData[0U];
//
RCFDC0CFDTMDF0_0 = pstCANFrame->unCANData.u32CANData[0U];
u32RSCANAddress
+=
0X04UL
;
(
*
((
uint32_t
*
)
u32RSCANAddress
))
=
pstCANFrame
->
unCANData
.
u32CANData
[
1U
];
//RCFDC0CFDTMDF1_0 = pstCANFrame->unCANData.u32CANData[1U];
//
RCFDC0CFDTMDF1_0 = pstCANFrame->unCANData.u32CANData[1U];
u32RSCANAddress
=
u32RSCANBufIndexP
+
0X250UL
+
RSCAN0_BASE_ADDRESS
;
(
*
((
uint8_t
*
)
u32RSCANAddress
))
|=
0X01
;
//RCFDC0CFDTMC0 |= 0X01;
//
RCFDC0CFDTMC0 |= 0X01;
enRSCANStatus
=
RSCAN_SET_COMPLETE
;
}
...
...
@@ -761,33 +815,33 @@ RSCAN_SetState RSCAN0_CH1_Set_TXBUF_Data(RSCAN_Channel_Buf_en_t enBufIndex, CAN_
{
u32RSCANAddress
=
u32RSCANBufIndexP
+
0X2D0UL
+
RSCAN0_BASE_ADDRESS
;
if
(((
*
((
uint8_t
*
)
u32RSCANAddress
))
&
0x08U
)
==
0x0U
)
//if ((RSCAN0TMSTS0 & 0x08U) == 0x0U)
//
if ((RSCAN0TMSTS0 & 0x08U) == 0x0U)
{
(
*
((
uint8_t
*
)
u32RSCANAddress
))
=
0UL
;
//RSCAN0TMSTS0 = 0UL;
//
RSCAN0TMSTS0 = 0UL;
u32RSCANDataBuf
=
pstCANFrame
->
u8CANFrameIDE
;
u32RSCANDataBuf
=
u32RSCANDataBuf
<<
31U
;
u32RSCANDataBuf
|=
pstCANFrame
->
u32CANID
;
u32RSCANAddress
=
u32RSCANBufIndexP
*
0X10UL
+
0X1000UL
+
RSCAN0_BASE_ADDRESS
;
(
*
((
uint32_t
*
)
u32RSCANAddress
))
=
u32RSCANDataBuf
;
//RCFDC0CFDTMID0 = u32RSCANDataBuf;
//
RCFDC0CFDTMID0 = u32RSCANDataBuf;
u32RSCANDataBuf
=
pstCANFrame
->
u8CANLEN
;
u32RSCANAddress
=
u32RSCANBufIndexP
*
0X10UL
+
0X1004UL
+
RSCAN0_BASE_ADDRESS
;
(
*
((
uint32_t
*
)
u32RSCANAddress
))
=
(
uint32_t
)((
u32RSCANDataBuf
)
<<
28U
);
//RCFDC0CFDTMPTR0 = (uint32_t)((u32RSCANDataBuf) << 28U);
//
RCFDC0CFDTMPTR0 = (uint32_t)((u32RSCANDataBuf) << 28U);
u32RSCANAddress
=
u32RSCANBufIndexP
*
0X10UL
+
0X1008UL
+
RSCAN0_BASE_ADDRESS
;
(
*
((
uint32_t
*
)
u32RSCANAddress
))
=
pstCANFrame
->
unCANData
.
u32CANData
[
0U
];
//RCFDC0CFDTMDF0_0 = pstCANFrame->unCANData.u32CANData[0U];
//
RCFDC0CFDTMDF0_0 = pstCANFrame->unCANData.u32CANData[0U];
u32RSCANAddress
+=
0X04UL
;
(
*
((
uint32_t
*
)
u32RSCANAddress
))
=
pstCANFrame
->
unCANData
.
u32CANData
[
1U
];
//RCFDC0CFDTMDF1_0 = pstCANFrame->unCANData.u32CANData[1U];
//
RCFDC0CFDTMDF1_0 = pstCANFrame->unCANData.u32CANData[1U];
u32RSCANAddress
=
u32RSCANBufIndexP
+
0X250UL
+
RSCAN0_BASE_ADDRESS
;
(
*
((
uint8_t
*
)
u32RSCANAddress
))
|=
0X01
;
//RCFDC0CFDTMC0 |= 0X01;
//
RCFDC0CFDTMC0 |= 0X01;
enRSCANStatus
=
RSCAN_SET_COMPLETE
;
}
...
...
@@ -817,33 +871,33 @@ RSCAN_SetState RSCAN0_CH2_Set_TXBUF_Data(RSCAN_Channel_Buf_en_t enBufIndex, CAN_
{
u32RSCANAddress
=
u32RSCANBufIndexP
+
0X2D0UL
+
RSCAN0_BASE_ADDRESS
;
if
(((
*
((
uint8_t
*
)
u32RSCANAddress
))
&
0x08U
)
==
0x0U
)
//if ((RSCAN0TMSTS0 & 0x08U) == 0x0U)
//
if ((RSCAN0TMSTS0 & 0x08U) == 0x0U)
{
(
*
((
uint8_t
*
)
u32RSCANAddress
))
=
0UL
;
//RSCAN0TMSTS0 = 0UL;
//
RSCAN0TMSTS0 = 0UL;
u32RSCANDataBuf
=
pstCANFrame
->
u8CANFrameIDE
;
u32RSCANDataBuf
=
u32RSCANDataBuf
<<
31U
;
u32RSCANDataBuf
|=
pstCANFrame
->
u32CANID
;
u32RSCANAddress
=
u32RSCANBufIndexP
*
0X10UL
+
0X1000UL
+
RSCAN0_BASE_ADDRESS
;
(
*
((
uint32_t
*
)
u32RSCANAddress
))
=
u32RSCANDataBuf
;
//RCFDC0CFDTMID0 = u32RSCANDataBuf;
//
RCFDC0CFDTMID0 = u32RSCANDataBuf;
u32RSCANDataBuf
=
pstCANFrame
->
u8CANLEN
;
u32RSCANAddress
=
u32RSCANBufIndexP
*
0X10UL
+
0X1004UL
+
RSCAN0_BASE_ADDRESS
;
(
*
((
uint32_t
*
)
u32RSCANAddress
))
=
(
uint32_t
)((
u32RSCANDataBuf
)
<<
28U
);
//RCFDC0CFDTMPTR0 = (uint32_t)((u32RSCANDataBuf) << 28U);
//
RCFDC0CFDTMPTR0 = (uint32_t)((u32RSCANDataBuf) << 28U);
u32RSCANAddress
=
u32RSCANBufIndexP
*
0X10UL
+
0X1008UL
+
RSCAN0_BASE_ADDRESS
;
(
*
((
uint32_t
*
)
u32RSCANAddress
))
=
pstCANFrame
->
unCANData
.
u32CANData
[
0U
];
//RCFDC0CFDTMDF0_0 = pstCANFrame->unCANData.u32CANData[0U];
//
RCFDC0CFDTMDF0_0 = pstCANFrame->unCANData.u32CANData[0U];
u32RSCANAddress
+=
0X04UL
;
(
*
((
uint32_t
*
)
u32RSCANAddress
))
=
pstCANFrame
->
unCANData
.
u32CANData
[
1U
];
//RCFDC0CFDTMDF1_0 = pstCANFrame->unCANData.u32CANData[1U];
//
RCFDC0CFDTMDF1_0 = pstCANFrame->unCANData.u32CANData[1U];
u32RSCANAddress
=
u32RSCANBufIndexP
+
0X250UL
+
RSCAN0_BASE_ADDRESS
;
(
*
((
uint8_t
*
)
u32RSCANAddress
))
|=
0X01
;
//RCFDC0CFDTMC0 |= 0X01;
//
RCFDC0CFDTMC0 |= 0X01;
enRSCANStatus
=
RSCAN_SET_COMPLETE
;
}
...
...
@@ -932,10 +986,15 @@ void RSCAN0_CH0_Busoff_Recover(void)
{
if
(
RSCAN0_CH0_Get_Busoff_Status
())
{
uint32_t
u32RSCANTimeCount
=
0UL
;
RSCAN0C0ERFL
&=
0xFFFFFFF7UL
;
RSCAN0C0CTR
&=
0xFFFFFFF8UL
;
/* CommunicationMode */
while
((
RSCAN0C0STS
&
0x87UL
)
!=
0x80UL
)
u32RSCANTimeCount
=
0UL
;
while
(((
RSCAN0C0STS
&
0x87UL
)
!=
0x80UL
)
&&
(
u32RSCANTimeCount
<
RSCAN_TIME_OUT_MAX
))
{
u32RSCANTimeCount
++
;
}
}
}
...
...
@@ -943,10 +1002,14 @@ void RSCAN0_CH1_Busoff_Recover(void)
{
if
(
RSCAN0_CH1_Get_Busoff_Status
())
{
uint32_t
u32RSCANTimeCount
=
0UL
;
RSCAN0C1ERFL
&=
0xFFFFFFF7UL
;
RSCAN0C1CTR
&=
0xFFFFFFF8UL
;
/* CommunicationMode */
while
((
RSCAN0C1STS
&
0x87UL
)
!=
0x80UL
)
u32RSCANTimeCount
=
0UL
;
while
(((
RSCAN0C1STS
&
0x87UL
)
!=
0x80UL
)
&&
(
u32RSCANTimeCount
<
RSCAN_TIME_OUT_MAX
))
{
u32RSCANTimeCount
++
;
}
}
}
...
...
@@ -954,10 +1017,14 @@ void RSCAN0_CH2_Busoff_Recover(void)
{
if
(
RSCAN0_CH2_Get_Busoff_Status
())
{
uint32_t
u32RSCANTimeCount
=
0UL
;
RSCAN0C2ERFL
&=
0xFFFFFFF7UL
;
RSCAN0C2CTR
&=
0xFFFFFFF8UL
;
/* CommunicationMode */
while
((
RSCAN0C2STS
&
0x87UL
)
!=
0x80UL
)
u32RSCANTimeCount
=
0UL
;
while
(((
RSCAN0C2STS
&
0x87UL
)
!=
0x80UL
)
&&
(
u32RSCANTimeCount
<
RSCAN_TIME_OUT_MAX
))
{
u32RSCANTimeCount
++
;
}
}
}
...
...
@@ -977,7 +1044,7 @@ void RSCAN0_CH0_Abort(RSCAN_Channel_Buf_en_t enBufIndex)
{
u32RSCANAddress
=
u32RSCANBufIndexP
+
0X250UL
+
RSCAN0_BASE_ADDRESS
;
(
*
((
uint8_t
*
)
u32RSCANAddress
))
|=
0X02U
;
//RCFDC0CFDTMC0 |= 0X02;
//
RCFDC0CFDTMC0 |= 0X02;
}
}
void
RSCAN0_CH1_Abort
(
RSCAN_Channel_Buf_en_t
enBufIndex
)
...
...
@@ -995,7 +1062,7 @@ void RSCAN0_CH1_Abort(RSCAN_Channel_Buf_en_t enBufIndex)
{
u32RSCANAddress
=
u32RSCANBufIndexP
+
0X250UL
+
RSCAN0_BASE_ADDRESS
;
(
*
((
uint8_t
*
)
u32RSCANAddress
))
|=
0X02U
;
//RCFDC0CFDTMC0 |= 0X02;
//
RCFDC0CFDTMC0 |= 0X02;
}
}
void
RSCAN0_CH2_Abort
(
RSCAN_Channel_Buf_en_t
enBufIndex
)
...
...
@@ -1013,7 +1080,7 @@ void RSCAN0_CH2_Abort(RSCAN_Channel_Buf_en_t enBufIndex)
{
u32RSCANAddress
=
u32RSCANBufIndexP
+
0X250UL
+
RSCAN0_BASE_ADDRESS
;
(
*
((
uint8_t
*
)
u32RSCANAddress
))
|=
0X02U
;
//RCFDC0CFDTMC0 |= 0X02;
//
RCFDC0CFDTMC0 |= 0X02;
}
}
...
...
@@ -1022,65 +1089,82 @@ void RSCAN0_CH2_Abort(RSCAN_Channel_Buf_en_t enBufIndex)
*/
void
RSCAN0_CH0_Sleep_Init
(
void
)
{
uint32_t
u32RSCANTimeCount
=
0UL
;
RSCAN0C0CTR
&=
0xfffffff9UL
;
RSCAN0C0CTR
|=
0x01UL
;
while
((
RSCAN0C0STS
&
0x07UL
)
!=
0X01UL
)
u32RSCANTimeCount
=
0UL
;
while
(((
RSCAN0C0STS
&
0x07UL
)
!=
0X01UL
)
&&
(
u32RSCANTimeCount
<
RSCAN_TIME_OUT_MAX
))
{
;
u32RSCANTimeCount
++
;
}
RSCAN0C0CTR
|=
0x04UL
;
while
((
RSCAN0C0STS
&
0x07UL
)
!=
0X04UL
)
u32RSCANTimeCount
=
0UL
;
while
(((
RSCAN0C0STS
&
0x07UL
)
!=
0X04UL
)
&&
(
u32RSCANTimeCount
<
RSCAN_TIME_OUT_MAX
))
{
;
u32RSCANTimeCount
++
;
}
}
void
RSCAN0_CH1_Sleep_Init
(
void
)
{
uint32_t
u32RSCANTimeCount
=
0UL
;
RSCAN0C1CTR
&=
0xfffffff9UL
;
RSCAN0C1CTR
|=
0x01UL
;
while
((
RSCAN0C1STS
&
0x07UL
)
!=
0X01UL
)
u32RSCANTimeCount
=
0UL
;
while
(((
RSCAN0C1STS
&
0x07UL
)
!=
0X01UL
)
&&
(
u32RSCANTimeCount
<
RSCAN_TIME_OUT_MAX
))
{
;
u32RSCANTimeCount
++
;
}
RSCAN0C1CTR
|=
0x04UL
;
while
((
RSCAN0C1STS
&
0x07UL
)
!=
0X04UL
)
u32RSCANTimeCount
=
0UL
;
while
(((
RSCAN0C1STS
&
0x07UL
)
!=
0X04UL
)
&&
(
u32RSCANTimeCount
<
RSCAN_TIME_OUT_MAX
))
{
;
u32RSCANTimeCount
++
;
}
}
void
RSCAN0_CH2_Sleep_Init
(
void
)
{
uint32_t
u32RSCANTimeCount
=
0UL
;
RSCAN0C2CTR
&=
0xfffffff9UL
;
RSCAN0C2CTR
|=
0x01UL
;
while
((
RSCAN0C2STS
&
0x07UL
)
!=
0X01UL
)
u32RSCANTimeCount
=
0UL
;
while
(((
RSCAN0C2STS
&
0x07UL
)
!=
0X01UL
)
&&
(
u32RSCANTimeCount
<
RSCAN_TIME_OUT_MAX
))
{
;
u32RSCANTimeCount
++
;
}
RSCAN0C2CTR
|=
0x04UL
;
while
((
RSCAN0C2STS
&
0x07UL
)
!=
0X04UL
)
u32RSCANTimeCount
=
0UL
;
while
(((
RSCAN0C2STS
&
0x07UL
)
!=
0X04UL
)
&&
(
u32RSCANTimeCount
<
RSCAN_TIME_OUT_MAX
))
{
;
u32RSCANTimeCount
++
;
}
}
void
RSCAN0_Sleep_Init
(
void
)
{
uint32_t
u32RSCANTimeCount
=
0UL
;
RSCAN0GCTR
&=
0xfffffff9UL
;
RSCAN0GCTR
|=
0x01UL
;
while
((
RSCAN0GSTS
&
0x07UL
)
!=
0X01UL
)
u32RSCANTimeCount
=
0UL
;
while
(((
RSCAN0GSTS
&
0x07UL
)
!=
0X01UL
)
&&
(
u32RSCANTimeCount
<
RSCAN_TIME_OUT_MAX
))
{
;
u32RSCANTimeCount
++
;
}
RSCAN0GCTR
|=
0x04UL
;
// while ( (RSCAN0GSTS & 0x07UL) != 0X04UL )
while
((
RSCAN0GSTS
&
0x04UL
)
!=
0X04UL
)
u32RSCANTimeCount
=
0UL
;
while
((
(
RSCAN0GSTS
&
0x04UL
)
!=
0X04UL
)
&&
(
u32RSCANTimeCount
<
RSCAN_TIME_OUT_MAX
)
)
{
;
u32RSCANTimeCount
++
;
}
}
...
...
@@ -1130,11 +1214,15 @@ void RSCAN0_CH0_RX_ISR(void)
{
if
(
RSCAN0CFSTS2
&
0X08UL
)
{
uint32_t
u32RSCANTimeCount
=
0UL
;
CAN_Frame_Receive_st_t
stCANFrameReceive
;
RSCAN0CFSTS2
&=
0xFFFFFFF7UL
;
while
((
RSCAN0CFSTS2
&
0x01UL
)
==
0U
)
u32RSCANTimeCount
=
0UL
;
while
(((
RSCAN0CFSTS2
&
0x01UL
)
==
0U
)
&&
(
u32RSCANTimeCount
<
128U
))
{
u32RSCANTimeCount
++
;
stCANFrameReceive
.
stReceiveContent
.
u32CANID
=
(
uint32_t
)(
RSCAN0CFID2
&
0x1FFFFFFFUL
);
stCANFrameReceive
.
stReceiveContent
.
u8CANLEN
=
(
uint8_t
)(
RSCAN0CFPTR2
>>
28U
);
stCANFrameReceive
.
stReceiveContent
.
u8CANFrameIDE
=
(
uint8_t
)((
RSCAN0CFID2
>>
31U
));
...
...
@@ -1152,11 +1240,15 @@ void RSCAN0_CH1_RX_ISR(void)
{
if
(
RSCAN0CFSTS5
&
0X08UL
)
{
uint32_t
u32RSCANTimeCount
=
0UL
;
CAN_Frame_Receive_st_t
stCANFrameReceive
;
RSCAN0CFSTS5
&=
0xFFFFFFF7UL
;
while
((
RSCAN0CFSTS5
&
0x01UL
)
==
0U
)
u32RSCANTimeCount
=
0UL
;
while
(((
RSCAN0CFSTS5
&
0x01UL
)
==
0U
)
&&
(
u32RSCANTimeCount
<
128U
))
{
u32RSCANTimeCount
++
;
stCANFrameReceive
.
stReceiveContent
.
u32CANID
=
(
uint32_t
)(
RSCAN0CFID5
&
0x1FFFFFFFUL
);
stCANFrameReceive
.
stReceiveContent
.
u8CANLEN
=
(
uint8_t
)(
RSCAN0CFPTR5
>>
28U
);
stCANFrameReceive
.
stReceiveContent
.
u8CANFrameIDE
=
(
uint8_t
)((
RSCAN0CFID5
>>
31U
));
...
...
@@ -1175,11 +1267,14 @@ void RSCAN0_CH2_RX_ISR(void)
if
(
RSCAN0CFSTS8
&
0X08UL
)
{
uint32_t
u32RSCANTimeCount
=
0UL
;
CAN_Frame_Receive_st_t
stCANFrameReceive
;
RSCAN0CFSTS8
&=
0xFFFFFFF7UL
;
while
((
RSCAN0CFSTS8
&
0x01UL
)
==
0U
)
u32RSCANTimeCount
=
0UL
;
while
((
(
RSCAN0CFSTS8
&
0x01UL
)
==
0U
)
&&
(
u32RSCANTimeCount
<
128U
)
)
{
u32RSCANTimeCount
++
;
stCANFrameReceive
.
stReceiveContent
.
u32CANID
=
(
uint32_t
)(
RSCAN0CFID8
&
0x1FFFFFFFUL
);
stCANFrameReceive
.
stReceiveContent
.
u8CANLEN
=
(
uint8_t
)(
RSCAN0CFPTR8
>>
28U
);
stCANFrameReceive
.
stReceiveContent
.
u8CANFrameIDE
=
(
uint8_t
)((
RSCAN0CFID8
>>
31U
));
...
...
source/Driver/Clock/Clock.c
View file @
435ca6de
source/System/d1mx.ld
View file @
435ca6de
...
...
@@ -111,7 +111,7 @@ SECTIONS
.tdata align(4) MAX_SIZE(0x0400) :>. /* initialized and zero-initialized data in TDA area */
.ramfunc align(4) :>. /* program code in RAM area */
.stack align(4)
pad(0x8000)
:>. /* definition of stack size */
.stack align(4)
pad(0x4000)
:>. /* definition of stack size */
/* Renesas FDL data sections */
...
...
source/System/init.c
View file @
435ca6de
...
...
@@ -228,8 +228,8 @@ void Sys_Sleep_Init(void)
* \attention
* \retval None
******************************************************************************/
void
Sys_Wakeup_Init
(
void
)
{
}
//
void Sys_Wakeup_Init(void)
//
{
//
//
}
source/System/init.h
View file @
435ca6de
...
...
@@ -28,7 +28,7 @@ extern {
extern
void
Sys_Startup_Pre_Init
(
void
);
extern
void
Sys_Startup_Init
(
void
);
extern
void
Sys_Sleep_Init
(
void
);
extern
void
Sys_Wakeup_Init
(
void
);
//
extern void Sys_Wakeup_Init(void);
#ifdef __cplusplus
}
...
...
source/System/tasks.c
View file @
435ca6de
...
...
@@ -323,7 +323,7 @@ void Sys_Exact_50us_Tasks(void)
{
static
uint32_t
PerCounter
=
0u
;
GenDelay_Tick
();
Sys_Rolling
();
//
Sys_Rolling();
COM_NM_Process
();
COM_TX_Process
();
DoCAN_Timer_Update
(
50
);
...
...
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