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
012b8d05
Commit
012b8d05
authored
Sep 26, 2024
by
陈家乐
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🐞
fix:优化串口初始化速度(中微厂家更改)
parent
344db24e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
90 additions
and
0 deletions
+90
-0
sci_common.c
...evice/Cmsemicon/BAT32A239/Library/Driver/src/sci_common.c
+90
-0
No files found.
Firmware/Source/Device/Cmsemicon/BAT32A239/Library/Driver/src/sci_common.c
View file @
012b8d05
...
@@ -103,7 +103,96 @@ void sci_error_log_internal(int8_t err, const char *file, int32_t line)
...
@@ -103,7 +103,96 @@ void sci_error_log_internal(int8_t err, const char *file, int32_t line)
/* Do nothing. */
/* 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.
* @brief Calculate the register setting options for baud rate to UART peripheral.
* @param fclk_freq: System clock value on chip.
* @param fclk_freq: System clock value on chip.
...
@@ -167,6 +256,7 @@ float SCIPeriphal_ClockUpdate(SCIAFSelect_TypeDef func, uint32_t fclk, uint32_t
...
@@ -167,6 +256,7 @@ float SCIPeriphal_ClockUpdate(SCIAFSelect_TypeDef func, uint32_t fclk, uint32_t
return max_err;
return max_err;
}
}
#endif
/**
/**
* @brief This function is aimed to check sci unit and its channel is used or not
* @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.
* @param func: The AF function for SCI channel periphal.
...
...
陈家乐
@chenjiale
·
Sep 28, 2024
Developer
62938 【天鹰TY200】【TCS外发】重新上大电,TCS外发前22帧发无效值,从第23帧开始发正确值
62938 【天鹰TY200】【TCS外发】重新上大电,TCS外发前22帧发无效值,从第23帧开始发正确值
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