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
28e3e310
Commit
28e3e310
authored
Oct 07, 2024
by
高士达
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'CJL' into 'dev'
Cjl See merge request
!104
parents
6c0fb34f
e414aefc
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
231 additions
and
33 deletions
+231
-33
TianYing.uvprojx
...ware/Project/Cmsemicon/BAT32A239/MDK_ARM/TianYing.uvprojx
+2
-2
Can_User.c
Firmware/Source/Application/CAN_User/Can_User.c
+4
-5
eeManager_Interface.c
Firmware/Source/Component/Eeprom/eeManager_Interface.c
+39
-7
eepromManage_20240926.lib
Firmware/Source/Component/Eeprom/eepromManage_20240926.lib
+0
-0
eepromManage_TestVersion.lib
...ware/Source/Component/Eeprom/eepromManage_TestVersion.lib
+0
-0
Key_user.c
Firmware/Source/Component/Key/Key_user.c
+3
-1
Services_Mileage_User.c
Firmware/Source/Component/Mileage/Services_Mileage_User.c
+75
-11
Service_Interval_User.c
...Source/Component/Service_Interval/Service_Interval_User.c
+18
-7
sci_common.c
...evice/Cmsemicon/BAT32A239/Library/Driver/src/sci_common.c
+90
-0
No files found.
Firmware/Project/Cmsemicon/BAT32A239/MDK_ARM/TianYing.uvprojx
View file @
28e3e310
...
...
@@ -844,9 +844,9 @@
<FilePath>
..\..\..\..\Source\Component\CAN_Signal\CAN_Signal.lib
</FilePath>
</File>
<File>
<FileName>
eepromManage_
TestVersion
.lib
</FileName>
<FileName>
eepromManage_
20240926
.lib
</FileName>
<FileType>
4
</FileType>
<FilePath>
..\..\..\..\Source\Component\Eeprom\eepromManage_
TestVersion
.lib
</FilePath>
<FilePath>
..\..\..\..\Source\Component\Eeprom\eepromManage_
20240926
.lib
</FilePath>
</File>
</Files>
</Group>
...
...
Firmware/Source/Application/CAN_User/Can_User.c
View file @
28e3e310
...
...
@@ -317,13 +317,12 @@ void Can_QuickTimer_Init(void)
* @param deltaTime 调用时间 单位ms 10MS调用
*/
uint16_t
cjl_cantest
=
0
;
uint16_t
cjl_canflag
=
0
;
uint16_t
CanRxInitflag
=
0
;
void
Can_BusOff_Recover
(
uint8_t
deltaTime
)
{
if
(
get_can_busoff
(
CAN_CH_0
)
==
2
)
{
cjl_can
flag
=
1
;
CanRxInit
flag
=
1
;
CAN_TX_Count_Init
();
if
(
RSCAN0Busoff
.
Status
==
RSCAN0_BUS_STABLE
)
{
...
...
@@ -379,9 +378,9 @@ void Can_BusOff_Recover(uint8_t deltaTime)
RSCAN0Busoff
.
Timer
=
0
;
RSCAN0Busoff
.
Cnt
=
0
;
}
if
(
cjl_can
flag
==
1
)
if
(
CanRxInit
flag
==
1
)
{
cjl_can
flag
=
0
;
CanRxInit
flag
=
0
;
Can_RX_Apply_Buff
();
}
}
...
...
Firmware/Source/Component/Eeprom/eeManager_Interface.c
View file @
28e3e310
...
...
@@ -35,9 +35,20 @@ void eeprom_comm_DelayUs(ee_uint32_t time)
EE_FeedDog
();
for
(
i
=
0
;
i
<
dalayCnt
;
i
++
)
{
EE_NOP
();
//EE_NOP();
__NOP
();
__NOP
();
__NOP
();
__NOP
();
__NOP
();
__NOP
();
__NOP
();
__NOP
();
__NOP
();
__NOP
();
}
EE_FeedDog
();
//
EE_FeedDog();
}
/*-------------------------------------------------------------------------
...
...
@@ -50,7 +61,8 @@ void eeprom_comm_DelayUs(ee_uint32_t time)
--------------------------------------------------------------------------*/
void
EE_SDA_InConfig
(
void
)
{
RTE_GPIO_Config
(
EE_SDA
,
RTE_GPIO_DIR_IN
);
//RTE_GPIO_Config(EE_SDA, RTE_GPIO_DIR_IN);
PORT
->
PM6
|=
(
1
<<
1
);
}
/*-------------------------------------------------------------------------
* Function Name : EE_SDA_OutConfig
...
...
@@ -62,7 +74,8 @@ void EE_SDA_InConfig(void)
--------------------------------------------------------------------------*/
void
EE_SDA_OutConfig
(
void
)
{
RTE_GPIO_Config
(
EE_SDA
,
RTE_GPIO_DIR_OUT
);
//RTE_GPIO_Config(EE_SDA, RTE_GPIO_DIR_OUT);
PORT
->
PM6
&=
~
(
1
<<
1
);
}
/*-------------------------------------------------------------------------
* Function Name : EE_SDA_GetValue
...
...
@@ -90,7 +103,16 @@ ee_uint8_t EE_SDA_GetValue(void)
void
EE_SDA_OUT
(
ee_uint8_t
data
)
{
// RTE_GPIO_Config(EE_SDA, RTE_GPIO_DIR_OUT | data);
RTE_GPIO_Set_Level
(
EE_SDA
,
data
);
//RTE_GPIO_Set_Level(EE_SDA, data);
if
(
data
)
{
PORT
->
P6
|=
(
1
<<
1
);
}
else
{
PORT
->
P6
&=
~
(
1
<<
1
);
}
}
/*-------------------------------------------------------------------------
...
...
@@ -103,7 +125,8 @@ void EE_SDA_OUT(ee_uint8_t data)
--------------------------------------------------------------------------*/
void
EE_SCL_OutConfig
(
void
)
{
RTE_GPIO_Config
(
EE_SCL
,
RTE_GPIO_DIR_OUT
);
//RTE_GPIO_Config(EE_SCL, RTE_GPIO_DIR_OUT);
PORT
->
PM6
&=
~
(
1
<<
0
);
}
/*-------------------------------------------------------------------------
* Function Name : EE_SCL_OUT
...
...
@@ -116,7 +139,16 @@ void EE_SCL_OutConfig(void)
void
EE_SCL_OUT
(
ee_uint8_t
data
)
{
// RTE_GPIO_Config(EE_SCL, RTE_GPIO_DIR_OUT | data);
RTE_GPIO_Set_Level
(
EE_SCL
,
data
);
//RTE_GPIO_Set_Level(EE_SCL, data);
if
(
data
)
{
PORT
->
P6
|=
(
1
<<
0
);
}
else
{
PORT
->
P6
&=
~
(
1
<<
0
);
}
}
/*-------------------------------------------------------------------------
...
...
Firmware/Source/Component/Eeprom/eepromManage_20240926.lib
0 → 100644
View file @
28e3e310
File added
Firmware/Source/Component/Eeprom/eepromManage_TestVersion.lib
deleted
100644 → 0
View file @
6c0fb34f
File deleted
Firmware/Source/Component/Key/Key_user.c
View file @
28e3e310
...
...
@@ -38,7 +38,9 @@ void Key_Operation_Left(Key_Event_en_t enKeyEvent)//Mode
if
(
Common_GetIgnOnTime
()
>=
3030
)
{
Key_Left_Long_Press
();
TYW_RESET_ODO
();
}
Key_Clear_Time
();
break
;
case
KEY_EVENT_LONG_PRESS_1
:
//7
...
...
@@ -84,7 +86,7 @@ void Key_Operation_Left(Key_Event_en_t enKeyEvent)//Mode
Tpms_TX_Flag
=
0
;
}
TYW_RESET_ODO
();
//
TYW_RESET_ODO();
}
Key_Clear_Time
();
break
;
...
...
Firmware/Source/Component/Mileage/Services_Mileage_User.c
View file @
28e3e310
...
...
@@ -7,6 +7,10 @@ uint8_t DataTripBuf[Data_MEM_Block_Trip * EM_TRIP_MAX];
Mileage_t
g_WriteMileage
;
Mileage_t
g_ReadMileage
;
uint8_t
odo_writeState
;
uint8_t
odoclr_writeState
;
uint8_t
trip_writeState
;
uint8_t
trip_readState
;
uint8_t
odo_readState
;
uint8_t
odo_readState
;
uint32_t
Milleage_InitFlag
=
0U
;
/******************************************************************************
...
...
@@ -31,9 +35,9 @@ void Data_User_Mileage_KL30Init(void)
if
(
TempBuf
[
0
]
==
0xFFFFFFFF
)
{
MileInit
.
Mileage
=
0u
;
}
else
{
}
else
{
MileInit
.
Mileage
=
TempBuf
[
0
];
}
Func
.
Get_Sys_IG_Sts
=
Common_Get_IG_Sts
;
...
...
@@ -98,7 +102,7 @@ void Data_User_Mileage_KL30Init(void)
Data_Trip_KL30_Init
(
DataTripBuf
,
TripInit
,
EM_TRIP_MAX
,
Func
.
EEPromWrite_Cbk
);
//Data_User_EEPROM_Read(EM_MenuData_Tcs_Val, TempBuf, 1u);
eeprom_ReadRecord
(
EEPROM_BLOCK_08
,
(
uint8_t
*
)
TempBufUser
,
1
);
eeprom_ReadRecord
(
EEPROM_BLOCK_08
,
(
uint8_t
*
)
TempBufUser
,
1
);
if
(
TempBufUser
[
0u
]
==
0xFF
)
{
MenuData
.
Tcs_Val
=
1
;
...
...
@@ -107,7 +111,7 @@ void Data_User_Mileage_KL30Init(void)
}
//Data_User_EEPROM_Read(EM_MenuData_TPMS_LEARN, TempBuf, 1u);
eeprom_ReadRecord
(
EEPROM_BLOCK_09
,
(
uint8_t
*
)
TempBufUser
,
2
);
eeprom_ReadRecord
(
EEPROM_BLOCK_09
,
(
uint8_t
*
)
TempBufUser
,
2
);
if
(
TempBufUser
[
0u
]
==
0xFF
)
{
TPMSLearn
[
0
]
=
0
;
//MenuData.TPMS_Front_Learn;
...
...
@@ -145,6 +149,7 @@ uint32_t Get_MileageInit_Status(void)
uint32_t
Data_User_EEPROM_Read
(
uint16_t
u16BlockID
,
uint32_t
u32Data
[],
uint16_t
u16Len
)
{
uint16_t
timeout
=
0
;
switch
(
u16BlockID
)
{
case
EM_MILEAGE_BLOCK
:
...
...
@@ -153,12 +158,41 @@ uint32_t Data_User_EEPROM_Read(uint16_t u16BlockID, uint32_t u32Data[], uint16_t
break
;
case
EM_ODO_BLOCK
:
eeprom_ReadRecord
(
EEPROM_BLOCK_01
,
(
uint8_t
*
)
u32Data
,
u16Len
*
4
);
timeout
=
0
;
odo_readState
=
eeprom_ReadRecord
(
EEPROM_BLOCK_01
,
(
uint8_t
*
)
u32Data
,
u16Len
*
4
);
while
(
odo_readState
!=
WRITE_COMPLETE
)
{
//eeprom_comm_DelayUs(5000);
odo_readState
=
eeprom_ReadRecord
(
EEPROM_BLOCK_01
,
(
uint8_t
*
)
u32Data
,
u16Len
*
4
);
timeout
++
;
if
(
odo_readState
==
WRITE_COMPLETE
)
{
break
;
}
if
(
timeout
>=
3
)
{
break
;
}
}
break
;
case
EM_TRIP_BLOCK
:
eeprom_ReadRecord
(
EEPROM_BLOCK_03
,
(
uint8_t
*
)
u32Data
,
u16Len
*
4
);
timeout
=
0
;
odo_readState
=
eeprom_ReadRecord
(
EEPROM_BLOCK_03
,
(
uint8_t
*
)
u32Data
,
u16Len
*
4
);
while
(
odo_readState
!=
WRITE_COMPLETE
)
{
//eeprom_comm_DelayUs(5000);
odo_readState
=
eeprom_ReadRecord
(
EEPROM_BLOCK_03
,
(
uint8_t
*
)
u32Data
,
u16Len
*
4
);
timeout
++
;
if
(
odo_readState
==
WRITE_COMPLETE
)
{
break
;
}
if
(
timeout
>=
3
)
{
break
;
}
}
break
;
// case EM_Maintenance_BLOCK:
...
...
@@ -186,7 +220,7 @@ uint32_t Data_User_EEPROM_Read(uint16_t u16BlockID, uint32_t u32Data[], uint16_t
void
Data_User_EEPROM_Write
(
Data_EEPROM_Enum_t
BlockID
,
uint32_t
u32Data
[],
uint16_t
u16Len
)
{
// uint8_t i = 0u;
uint8_t
timeout
=
0
;
switch
(
BlockID
)
{
case
EM_MILEAGE_BLOCK
:
...
...
@@ -203,11 +237,41 @@ uint32_t Data_User_EEPROM_Read(uint16_t u16BlockID, uint32_t u32Data[], uint16_t
break
;
case
EM_ODO_BLOCK
:
eeprom_WriteRecord
(
EEPROM_BLOCK_01
,
(
uint8_t
*
)
u32Data
,
u16Len
*
4
);
timeout
=
0
;
odoclr_writeState
=
eeprom_WriteRecord
(
EEPROM_BLOCK_01
,
(
uint8_t
*
)
u32Data
,
u16Len
*
4
);
while
(
odoclr_writeState
!=
WRITE_COMPLETE
)
{
//eeprom_comm_DelayUs(5000);
odoclr_writeState
=
eeprom_WriteRecord
(
EEPROM_BLOCK_01
,
(
uint8_t
*
)
u32Data
,
u16Len
*
4
);
timeout
++
;
if
(
odoclr_writeState
==
WRITE_COMPLETE
)
{
break
;
}
if
(
timeout
>=
3
)
{
return
;
}
}
break
;
case
EM_TRIP_BLOCK
:
eeprom_WriteRecord
(
EEPROM_BLOCK_03
,
(
uint8_t
*
)
u32Data
,
u16Len
*
4
);
timeout
=
0
;
trip_writeState
=
eeprom_WriteRecord
(
EEPROM_BLOCK_03
,
(
uint8_t
*
)
u32Data
,
u16Len
*
4
);
while
(
trip_writeState
!=
WRITE_COMPLETE
)
{
//eeprom_comm_DelayUs(5000);
trip_writeState
=
eeprom_WriteRecord
(
EEPROM_BLOCK_03
,
(
uint8_t
*
)
u32Data
,
u16Len
*
4
);
timeout
++
;
if
(
trip_writeState
==
WRITE_COMPLETE
)
{
break
;
}
if
(
timeout
>=
3
)
{
return
;
}
}
break
;
// case EM_Maintenance_BLOCK:
...
...
Firmware/Source/Component/Service_Interval/Service_Interval_User.c
View file @
28e3e310
...
...
@@ -52,31 +52,42 @@ static void Service_Interval_Write_EEProm(uint32_t u32Data [], uint16_t u16Len)
{
ee_uint16_t
tmpWritestatus
=
0
;
ee_uint16_t
Cnt
=
0
;
ee_uint16_t
TimeOut
=
0
;
tmpWritestatus
=
eeprom_WriteRecord
(
EEPROM_BLOCK_05
,
(
uint8_t
*
)
u32Data
,
u16Len
*
4
);
while
(
tmpWritestatus
==
WRITING
)
while
(
tmpWritestatus
!=
WRITE_COMPLETE
)
{
//eeprom_comm_DelayUs(5000);
tmpWritestatus
=
eeprom_WriteRecord
(
EEPROM_BLOCK_05
,
(
uint8_t
*
)
u32Data
,
u16Len
*
4
);
Cn
t
++
;
if
(
Cnt
>=
1000
)
TimeOu
t
++
;
if
(
tmpWritestatus
==
WRITE_COMPLETE
)
{
break
;
}
if
(
TimeOut
>=
3
)
{
return
;
}
}
}
static
void
Service_Interval_Read_EEProm
(
uint32_t
u32Data
[],
uint16_t
u16Len
)
{
ee_uint16_t
tmpReadstatus
=
0
;
ee_uint16_t
Cn
t
=
0
;
ee_uint16_t
TimeOu
t
=
0
;
tmpReadstatus
=
eeprom_ReadRecord
(
EEPROM_BLOCK_05
,
(
uint8_t
*
)
u32Data
,
u16Len
*
4
);
while
(
tmpReadstatus
==
READING
)
while
(
tmpReadstatus
!=
WRITE_COMPLETE
)
{
//eeprom_comm_DelayUs(5000);
tmpReadstatus
=
eeprom_ReadRecord
(
EEPROM_BLOCK_05
,
(
uint8_t
*
)
u32Data
,
u16Len
*
4
);
Cn
t
++
;
if
(
Cnt
>=
1000
)
TimeOu
t
++
;
if
(
tmpReadstatus
==
WRITE_COMPLETE
)
{
break
;
}
if
(
TimeOut
>=
3
)
{
return
;
}
}
}
...
...
Firmware/Source/Device/Cmsemicon/BAT32A239/Library/Driver/src/sci_common.c
View file @
28e3e310
...
...
@@ -103,7 +103,96 @@ void sci_error_log_internal(int8_t err, const char *file, int32_t line)
/* Do nothing. */
}
}
#if 1
/**
* @brief Calculate the register setting options for baud rate to UART peripheral.
* @param fclk_freq: System clock value on chip.
* @param baud: The target baud rate which want to setting.
* @param pValue: UART baud rate setting option data structure.
* @param cur_sps: current SPS register value, clock sharing it with other channels, Try not to modify it as much as possible.
* if 'cur_sps = 0x00' or 'cur_sps = FORCE_RECONF', Ignore the original register value and force reconfiguration. laidi
* @retval None
*/
float
SCIPeriphal_ClockUpdate
(
SCIAFSelect_TypeDef
func
,
uint32_t
fclk
,
uint32_t
ftclk
,
uint8_t
cur_sps
,
SCIPeriph_Clock_TypeDef
*
clock
)
{
#define CALCULATE_MAX_SPS 0x0F
#define CALCULATE_MAX_SDR 0x7F
#define FORCE_RECONF 0xFF
uint8_t
i
;
uint8_t
min_sdr
,
max_sps
;
uint32_t
cal_fmck
=
0
;
int16_t
idea_sdr
;
uint8_t
sdr_int
;
uint16_t
max_err
=
0xFFFF
,
temp_err
=
0xFFFF
;
float
ret_err
=
100
.
0
;
if
(
ftclk
==
0
)
{
return
ret_err
;
}
if
(
func
&
SCI_UART_MASK
)
{
min_sdr
=
2
;
}
else
if
(
func
&
SCI_I2C_MASK
)
{
min_sdr
=
1
;
}
else
{
min_sdr
=
0
;
}
if
((
cur_sps
==
0x00
)
||
(
cur_sps
==
FORCE_RECONF
))
{
max_sps
=
CALCULATE_MAX_SPS
+
1
;
}
else
{
clock
->
sps
=
cur_sps
;
max_sps
=
1
;
/* for (i..) loop once */
}
for
(
i
=
0
;
i
<
max_sps
;
i
++
)
{
/* cac fMCK, SPS reg*/
if
((
cur_sps
==
0x00
)
||
(
cur_sps
==
FORCE_RECONF
))
{
cal_fmck
=
fclk
/
sps_tab
[
i
];
}
else
{
i
=
cur_sps
;
cal_fmck
=
fclk
/
sps_tab
[
cur_sps
];
}
/* cal_ftclk = cal_fmck /2 /(SDR[15:9]+1), data scaled up 100 times for calculations.*/
idea_sdr
=
((
cal_fmck
>>
1
)
*
100
)
/
ftclk
;
if
((
idea_sdr
>
(
min_sdr
*
100
+
50
))
&&
(
idea_sdr
<
(
CALCULATE_MAX_SDR
*
100
+
50
)))
{
sdr_int
=
(
idea_sdr
+
50
)
/
100
;
temp_err
=
abs
((
sdr_int
*
100
)
-
idea_sdr
)
*
10000
/
idea_sdr
;
if
(
temp_err
<
max_err
)
{
clock
->
sps
=
i
;
clock
->
sdr
=
sdr_int
-
1
;
max_err
=
temp_err
;
}
if
(
max_err
==
0
)
{
return
(
float
)
0
.
0
;
}
}
}
ret_err
=
max_err
/
(
float
)
100
.
0
;
return
ret_err
;
}
#endif
#if 0
/**
* @brief Calculate the register setting options for baud rate to UART peripheral.
* @param fclk_freq: System clock value on chip.
...
...
@@ -167,6 +256,7 @@ float SCIPeriphal_ClockUpdate(SCIAFSelect_TypeDef func, uint32_t fclk, uint32_t
return max_err;
}
#endif
/**
* @brief This function is aimed to check sci unit and its channel is used or not
* @param func: The AF function for SCI channel periphal.
...
...
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