Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZhongTong-ZR5-A
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
赵康弘
ZhongTong-ZR5-A
Commits
8da627ff
Commit
8da627ff
authored
Sep 26, 2025
by
赵康弘
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: SGMCD1020Q开关状态查询功能,当前IO口无法正常回读
parent
e8c71891
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
203 additions
and
87 deletions
+203
-87
test_Port_Port_ecuc.arxml
Config/Config292/Config/ECUC/test_Port_Port_ecuc.arxml
+3
-3
Port_Cfg.h
Config/Config292/Output/Port_OutPut/include/Port_Cfg.h
+1
-1
SGM4591Q.c
GHS/App/SGM4591Q.c
+33
-0
SGMCD1020Q.c
GHS/App/SGMCD1020Q.c
+66
-78
SGMCD1020Q.h
GHS/App/SGMCD1020Q.h
+55
-0
Simulated_SPI_1_Master.c
GHS/Driver/Simulated_SPI_1_Master.c
+13
-1
Sys_Task_List.c
GHS/System/Sys_Task_List.c
+32
-4
No files found.
Config/Config292/Config/ECUC/test_Port_Port_ecuc.arxml
View file @
8da627ff
...
...
@@ -479,7 +479,7 @@
</ECUC-TEXTUAL-PARAM-VALUE>
<ECUC-TEXTUAL-PARAM-VALUE>
<DEFINITION-REF
DEST=
"ECUC-ENUMERATION-PARAM-DEF"
>
/Renesas/EcucDefs_Port/Port/PortConfigSet/PortGroup2/PortPin1/PortPinInitialMode
</DEFINITION-REF>
<VALUE>
GTM1I6_ALT1_IN_SUPP_PFC_PFCE_PFC
AE_PMCSR
</VALUE>
<VALUE>
DIO_SUPP_PFC_PFCE_PFCAE_PFCE
AE_PMCSR
</VALUE>
</ECUC-TEXTUAL-PARAM-VALUE>
<ECUC-TEXTUAL-PARAM-VALUE>
<DEFINITION-REF
DEST=
"ECUC-ENUMERATION-PARAM-DEF"
>
/Renesas/EcucDefs_Port/Port/PortConfigSet/PortGroup2/PortPin1/PortPinDirection
</DEFINITION-REF>
...
...
@@ -495,7 +495,7 @@
</ECUC-NUMERICAL-PARAM-VALUE>
<ECUC-NUMERICAL-PARAM-VALUE>
<DEFINITION-REF
DEST=
"ECUC-BOOLEAN-PARAM-DEF"
>
/Renesas/EcucDefs_Port/Port/PortConfigSet/PortGroup2/PortPin1/PortPullUpOption
</DEFINITION-REF>
<VALUE>
tru
e
</VALUE>
<VALUE>
fals
e
</VALUE>
</ECUC-NUMERICAL-PARAM-VALUE>
<ECUC-NUMERICAL-PARAM-VALUE>
<DEFINITION-REF
DEST=
"ECUC-BOOLEAN-PARAM-DEF"
>
/Renesas/EcucDefs_Port/Port/PortConfigSet/PortGroup2/PortPin1/PortPullDownOption
</DEFINITION-REF>
...
...
@@ -623,7 +623,7 @@
</ECUC-NUMERICAL-PARAM-VALUE>
<ECUC-TEXTUAL-PARAM-VALUE>
<DEFINITION-REF
DEST=
"ECUC-ENUMERATION-PARAM-DEF"
>
/Renesas/EcucDefs_Port/Port/PortConfigSet/PortGroup2/PortPin3/PortPinLevelValue
</DEFINITION-REF>
<VALUE>
PORT_PIN_LEVEL_
LOW
</VALUE>
<VALUE>
PORT_PIN_LEVEL_
HIGH
</VALUE>
</ECUC-TEXTUAL-PARAM-VALUE>
<ECUC-TEXTUAL-PARAM-VALUE>
<DEFINITION-REF
DEST=
"ECUC-ENUMERATION-PARAM-DEF"
>
/Renesas/EcucDefs_Port/Port/PortConfigSet/PortGroup2/PortPin3/PortPinInitialMode
</DEFINITION-REF>
...
...
Config/Config292/Output/Port_OutPut/include/Port_Cfg.h
View file @
8da627ff
...
...
@@ -66,7 +66,7 @@
* E:\Git\中通\ZhongTong-ZR5-A\Config\Config292\generator\BSWMDT\R431_PORT_U2A8_BSWMDT.arxml
* E:\Git\中通\ZhongTong-ZR5-A\Config\Config292\stubs\Dem\xml\Dem_Port.arxml
* E:\Git\中通\ZhongTong-ZR5-A\Config\Config292\Translation.trxml
* GENERATED ON: 26 Sep 2025 - 1
1:32:07
* GENERATED ON: 26 Sep 2025 - 1
5:46:21
*/
...
...
GHS/App/SGM4591Q.c
View file @
8da627ff
...
...
@@ -241,6 +241,39 @@ void SGM4591Q_Control(void)
SGM4591Q_U9_Out_Keep_P1
=
SGM4591Q_U9_Out_P1
;
}
}
volatile
SGM4591Q_Pin_en
SGM4591Q_Chip1_1_Segment0
;
volatile
SGM4591Q_Pin_en
SGM4591Q_Chip1_1_Segment1
;
volatile
SGM4591Q_Pin_en
SGM4591Q_Chip1_2_Segment0
;
volatile
SGM4591Q_Pin_en
SGM4591Q_Chip1_2_Segment1
;
volatile
SGM4591Q_Pin_en
SGM4591Q_Chip1_3_Segment0
;
volatile
SGM4591Q_Pin_en
SGM4591Q_Chip1_3_Segment1
;
volatile
SGM4591Q_Pin_en
SGM4591Q_Chip1_4_Segment0
;
volatile
SGM4591Q_Pin_en
SGM4591Q_Chip1_4_Segment1
;
volatile
SGM4591Q_Pin_en
SGM4591Q_Chip2_1_Segment0
;
volatile
SGM4591Q_Pin_en
SGM4591Q_Chip2_1_Segment1
;
volatile
SGM4591Q_Pin_en
SGM4591Q_Chip2_2_Segment0
;
volatile
SGM4591Q_Pin_en
SGM4591Q_Chip2_2_Segment1
;
volatile
SGM4591Q_Pin_en
SGM4591Q_Chip2_3_Segment0
;
volatile
SGM4591Q_Pin_en
SGM4591Q_Chip2_3_Segment1
;
volatile
SGM4591Q_Pin_en
SGM4591Q_Chip2_4_Segment0
;
volatile
SGM4591Q_Pin_en
SGM4591Q_Chip2_4_Segment1
;
volatile
SGM4591Q_Pin_en
SGM4591Q_Chip3_1_Segment0
;
volatile
SGM4591Q_Pin_en
SGM4591Q_Chip3_1_Segment1
;
volatile
SGM4591Q_Pin_en
SGM4591Q_Chip3_2_Segment0
;
volatile
SGM4591Q_Pin_en
SGM4591Q_Chip3_2_Segment1
;
volatile
SGM4591Q_Pin_en
SGM4591Q_Chip3_3_Segment0
;
volatile
SGM4591Q_Pin_en
SGM4591Q_Chip3_3_Segment1
;
volatile
SGM4591Q_Pin_en
SGM4591Q_Chip3_4_Segment0
;
volatile
SGM4591Q_Pin_en
SGM4591Q_Chip3_4_Segment1
;
volatile
SGM4591Q_Pin_en
SGM4591Q_Chip4_1_Segment0
;
volatile
SGM4591Q_Pin_en
SGM4591Q_Chip4_1_Segment1
;
volatile
SGM4591Q_Pin_en
SGM4591Q_Chip4_2_Segment0
;
volatile
SGM4591Q_Pin_en
SGM4591Q_Chip4_2_Segment1
;
volatile
SGM4591Q_Pin_en
SGM4591Q_Chip4_3_Segment0
;
volatile
SGM4591Q_Pin_en
SGM4591Q_Chip4_3_Segment1
;
volatile
SGM4591Q_Pin_en
SGM4591Q_Chip4_4_Segment0
;
volatile
SGM4591Q_Pin_en
SGM4591Q_Chip4_4_Segment1
;
uint8_t
SGM4591Q_Chip1_1_Segment0_Last
;
uint8_t
SGM4591Q_Chip1_1_Segment1_Last
;
uint8_t
SGM4591Q_Chip1_2_Segment0_Last
;
...
...
GHS/App/SGMCD1020Q.c
View file @
8da627ff
...
...
@@ -5,12 +5,7 @@ static SGMCD_DeviceType currentDevice = SGMCD_DEVICE_1;
/* 选择SGMCD1020Q设备 */
void
SGMCD1020Q_SelectDevice
(
SGMCD_DeviceType
device
)
{
/* 先取消所有设备选择 */
// SGMCD1020Q_CS1_Output_High();
// SGMCD1020Q_CS2_Output_High();
// SGMCD1020Q_CS3_Output_High();
{
/* 选择指定设备 */
switch
(
device
)
{
...
...
@@ -76,7 +71,7 @@ uint32_t SGMCD1020Q_ReadRegister(uint8_t regAddr)
uint32_t
command
;
/* 构建读命令:地址(7位) + 类型0(读) + 24位数据(0) */
command
=
((
uint32_t
)
regAddr
<<
2
5
)
|
(
0
<<
2
4
);
command
=
((
uint32_t
)
regAddr
<<
24
);
return
SGMCD1020Q_SPI_Transfer
(
command
);
}
...
...
@@ -218,75 +213,36 @@ void SGMCD1020Q_Init(void)
deviceInitialized
=
1
;
}
/* 开关闭合处理函数 */
void
SGMCD1020Q_HandleSwitchClosed
(
uint8_t
channel
)
{
/* 根据具体应用处理不同的开关动作 */
switch
(
channel
)
{
case
0
:
/* SG0开关闭合 */
/* 执行相应操作 */
break
;
case
1
:
/* SG1开关闭合 */
/* 执行相应操作 */
break
;
/* 添加更多通道处理... */
default:
break
;
}
}
/* 开关断开处理函数 */
void
SGMCD1020Q_HandleSwitchOpened
(
uint8_t
channel
)
{
/* 根据具体应用处理不同的开关动作 */
switch
(
channel
)
{
case
0
:
/* SG0开关断开 */
/* 执行相应操作 */
break
;
case
1
:
/* SG1开关断开 */
/* 执行相应操作 */
break
;
/* 添加更多通道处理... */
default:
break
;
}
}
volatile
SGMCD1020Q_SwitchStatus_t
SGMCD1020Q_1
;
volatile
SGMCD1020Q_SwitchStatus_t
SGMCD1020Q_2
;
volatile
SGMCD1020Q_SwitchStatus_t
SGMCD1020Q_3
;
/* 读取并处理开关状态 */
void
SGMCD1020Q_ReadAndProcessSwitches
(
void
)
void
SGMCD1020Q_ReadAndProcessSwitches
(
uint8_t
Chip
)
{
if
(
!
deviceInitialized
)
return
;
uint32_t
newStatus
=
SGMCD1020Q_ReadSwitchStatus
();
/* 检查状态变化 */
if
(
newStatus
!=
switchStatus
)
{
/* 处理状态变化 */
for
(
uint8_t
i
=
0
;
i
<
22
;
i
++
)
{
uint32_t
mask
=
1UL
<<
i
;
/* 检查开关闭合 */
if
((
newStatus
&
mask
)
&&
!
(
switchStatus
&
mask
))
{
/* 开关i从断开变为闭合 */
SGMCD1020Q_HandleSwitchClosed
(
i
);
}
/* 检查开关断开 */
if
(
!
(
newStatus
&
mask
)
&&
(
switchStatus
&
mask
))
{
/* 开关i从闭合变为断开 */
SGMCD1020Q_HandleSwitchOpened
(
i
);
}
}
switchStatus
=
newStatus
;
}
if
(
!
deviceInitialized
)
return
;
uint32_t
newStatus
=
0
;
newStatus
=
SGMCD1020Q_ReadSwitchStatus
();
if
(
Chip
==
1
)
{
SGMCD1020Q_1
.
raw_value
=
newStatus
;
}
else
if
(
Chip
==
2
)
{
SGMCD1020Q_2
.
raw_value
=
newStatus
;
}
else
if
(
Chip
==
3
)
{
SGMCD1020Q_3
.
raw_value
=
newStatus
;
}
else
{
;
}
}
/* 故障处理函数 */
...
...
@@ -318,7 +274,7 @@ void SGMCD1020Q_HandleFault(uint32_t faultStatus)
void
SGMCD1020Q_InterruptHandler
(
void
)
{
/* 读取开关状态并处理 */
SGMCD1020Q_ReadAndProcessSwitches
();
SGMCD1020Q_ReadAndProcessSwitches
(
SGMCD_DEVICE_1
);
/* 读取故障状态(可选) */
uint32_t
faultStatus
=
SGMCD1020Q_ReadFaultStatus
();
...
...
@@ -327,7 +283,7 @@ void SGMCD1020Q_InterruptHandler(void)
SGMCD1020Q_HandleFault
(
faultStatus
);
}
}
uint8_t
SGMCD1020Q_Select_Num
=
0
;
/* 主循环处理 */
void
SGMCD1020Q_MainFunction
(
void
)
{
...
...
@@ -336,8 +292,40 @@ void SGMCD1020Q_MainFunction(void)
// {
// SGMCD1020Q_InterruptHandler();
// }
SGMCD1020Q_ReadAndProcessSwitches
();
if
(
SGMCD1020Q_Select_Num
<
3
)
{
SGMCD1020Q_Select_Num
++
;
}
else
{
SGMCD1020Q_Select_Num
=
0
;
}
if
(
SGMCD1020Q_Select_Num
==
0
)
{
/* 选择设备1 */
SGMCD1020Q_SelectDevice
(
SGMCD_DEVICE_1
);
SGMCD1020Q_ReadAndProcessSwitches
(
SGMCD_DEVICE_1
);
SGMCD1020Q_DeselectAllDevices
();
}
else
if
(
SGMCD1020Q_Select_Num
==
1
)
{
/* 选择设备2 */
SGMCD1020Q_SelectDevice
(
SGMCD_DEVICE_2
);
SGMCD1020Q_ReadAndProcessSwitches
(
SGMCD_DEVICE_2
);
SGMCD1020Q_DeselectAllDevices
();
}
else
if
(
SGMCD1020Q_Select_Num
==
2
)
{
/* 选择设备3 */
SGMCD1020Q_SelectDevice
(
SGMCD_DEVICE_3
);
SGMCD1020Q_ReadAndProcessSwitches
(
SGMCD_DEVICE_3
);
SGMCD1020Q_DeselectAllDevices
();
}
else
{
;
}
}
/* 进入低功耗模式 */
...
...
GHS/App/SGMCD1020Q.h
View file @
8da627ff
...
...
@@ -47,6 +47,60 @@ typedef enum {
SGMCD_DEVICE_3
}
SGMCD_DeviceType
;
/* 开关状态联合体定义 */
typedef
union
{
uint32_t
raw_value
;
/* 原始32位数据 */
struct
{
/* 位域定义 - 与SGMCD1020Q寄存器布局完全对应 */
uint32_t
sg0
:
1
;
/* SG0开关状态 */
uint32_t
sg1
:
1
;
/* SG1开关状态 */
uint32_t
sg2
:
1
;
/* SG2开关状态 */
uint32_t
sg3
:
1
;
/* SG3开关状态 */
uint32_t
sg4
:
1
;
/* SG4开关状态 */
uint32_t
sg5
:
1
;
/* SG5开关状态 */
uint32_t
sg6
:
1
;
/* SG6开关状态 */
uint32_t
sg7
:
1
;
/* SG7开关状态 */
uint32_t
sg8
:
1
;
/* SG8开关状态 */
uint32_t
sg9
:
1
;
/* SG9开关状态 */
uint32_t
sg10
:
1
;
/* SG10开关状态 */
uint32_t
sg11
:
1
;
/* SG11开关状态 */
uint32_t
sg12
:
1
;
/* SG12开关状态 */
uint32_t
sg13
:
1
;
/* SG13开关状态 */
uint32_t
sp0
:
1
;
/* SP0开关状态 */
uint32_t
sp1
:
1
;
/* SP1开关状态 */
uint32_t
sp2
:
1
;
/* SP2开关状态 */
uint32_t
sp3
:
1
;
/* SP3开关状态 */
uint32_t
sp4
:
1
;
/* SP4开关状态 */
uint32_t
sp5
:
1
;
/* SP5开关状态 */
uint32_t
sp6
:
1
;
/* SP6开关状态 */
uint32_t
sp7
:
1
;
/* SP7开关状态 */
uint32_t
intflg
:
1
;
/* 中断标志位 */
uint32_t
fault
:
1
;
/* 故障状态位 */
uint32_t
type
:
1
;
/* 类型位(读操作为0) */
uint32_t
addr
:
7
;
/* 地址位(0x3E) */
}
bits
;
}
SGMCD1020Q_SwitchStatus_t
;
extern
volatile
SGMCD1020Q_SwitchStatus_t
SGMCD1020Q_1
;
extern
volatile
SGMCD1020Q_SwitchStatus_t
SGMCD1020Q_2
;
extern
volatile
SGMCD1020Q_SwitchStatus_t
SGMCD1020Q_3
;
/* 开关状态枚举定义 */
typedef
enum
{
SWITCH_OPEN
=
0
,
/* 开关断开 */
SWITCH_CLOSED
=
1
/* 开关闭合 */
}
SwitchState_t
;
/* 通道类型枚举 */
typedef
enum
{
CHANNEL_SG
=
0
,
/* 开关对地通道 */
CHANNEL_SP
=
1
/* 可编程开关通道 */
}
ChannelType_t
;
/* 函数声明 */
void
SGMCD1020Q_Init
(
void
);
void
SGMCD1020Q_SelectDevice
(
SGMCD_DeviceType
device
);
...
...
@@ -56,6 +110,7 @@ void SGMCD1020Q_WriteRegister(uint8_t regAddr, uint32_t data);
uint32_t
SGMCD1020Q_ReadSwitchStatus
(
void
);
void
SGMCD1020Q_SetWettingCurrent
(
uint8_t
channel
,
uint8_t
currentLevel
);
void
SGMCD1020Q_EnableInterrupt
(
uint8_t
channel
,
uint8_t
enable
);
void
SGMCD1020Q_MainFunction
(
void
);
void
SGMCD1020Q_EnterLowPowerMode
(
void
);
void
SGMCD1020Q_Reset
(
void
);
uint32_t
SGMCD1020Q_ReadFaultStatus
(
void
);
...
...
GHS/Driver/Simulated_SPI_1_Master.c
View file @
8da627ff
...
...
@@ -193,7 +193,9 @@ void Sim_SPI_Master_1_Byte_Write(uint8_t Data)
}
}
// uint8 GaaByteAcccccccc[100] = { 0 };
uint8_t
BitPosfsfds
;
uint8_t
gfdgdg
=
0
;
/******************************************************************************
��������Sim_SPI_Master_1_Byte_Read
�� �ܣ���SPI�����϶�ȡһ�ֽ�����
...
...
@@ -242,7 +244,17 @@ uint8_t Sim_SPI_Master_1_Byte_Read(uint8_t TxData)
NOP
();
NOP
();
NOP
();
// if (gfdgdg < 99)
// {
// gfdgdg++;
// }
// else
// {
// gfdgdg = 0;
// }
// GaaByteAcccccccc[gfdgdg] = Dio_ReadChannel(Port_Config_PortGroup2_PortPin3);
if
(
Dio_ReadChannel
(
Port_Config_PortGroup2_PortPin3
))
RxData
|=
BitPos
;
}
...
...
GHS/System/Sys_Task_List.c
View file @
8da627ff
...
...
@@ -7,6 +7,8 @@
#include "Adc.h"
#include "SGM4591Q.h"
#include "MC33984EHFK.h"
#include "SGMCD1020Q.h"
void
Sys_50us_Tasks
(
void
)
{
...
...
@@ -77,7 +79,9 @@ uint16_t ADC_Input_Voltage_Calc(uint16_t u16ADCSample, uint16_t u16ADCRes, uint1
return
u16Result
;
}
uint32_t
time_test
=
0
;
// uint8_t aaaaaaData = 0U;
uint8_t
aaaaaaData
=
0U
;
uint8_t
bcvcb
=
0U
;
// uint8 GaaByteAccfdfss[100] = { 0 };
void
Sys_100ms_Tasks
(
void
)
{
time_test
++
;
...
...
@@ -108,13 +112,37 @@ void Sys_100ms_Tasks(void)
// Port_SetPinDirection(Port_Config_PortGroup4_PortPin8, PORT_PIN_OUT);
Dio_WriteChannel
(
DioConf_DioChannel_P04_08
,
STD_LOW
);
// MC33984EHFK_Read();
// aaaaaaData= Dio_ReadChannel(Port_Config_PortGroup2_PortPin11);
// abbaaaData= Dio_ReadChannel(Port_Config_PortGroup22_PortPin3);
// Port_SetPinDirection(Port_Config_PortGroup22_PortPin3, PORT_PIN_IN);
// if (bcvcb == 1)
// {
// Dio_WriteChannel(DioConf_DioChannel_P02_05, STD_HIGH);
// Dio_WriteChannel(DioConf_DioChannel_P02_01, STD_HIGH);
// bcvcb = 0;
// }
// if (bcvcb == 2)
// {
// Dio_WriteChannel(DioConf_DioChannel_P02_05, STD_LOW);
// Dio_WriteChannel(DioConf_DioChannel_P02_01, STD_LOW);
// bcvcb = 0;
// }
// if (aaaaaaData < 99)
// {
// aaaaaaData++;
// }
// else
// {
// aaaaaaData = 0;
// }
// GaaByteAccfdfss[aaaaaaData] = Dio_ReadChannel(Port_Config_PortGroup2_PortPin1);
// abbaaaData= Dio_ReadChannel(Port_Config_PortGroup22_PortPin3);
// Port_SetPinDirection(Port_Config_PortGroup22_PortPin3, PORT_PIN_IN);
// Port_SetPinDirection(Port_Config_PortGroup22_PortPin4, PORT_PIN_IN);
// Port_SetPinDirection(Port_Config_PortGroup22_PortPin4, PORT_PIN_OUT);
// Port_SetPinDirection(Port_Config_PortGroup22_PortPin3, PORT_PIN_OUT);
SGMCD1020Q_MainFunction
();
}
\ No newline at end of file
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