Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
ch32v003fun
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Andreas Horn
ch32v003fun
Commits
4d10bbd0
Commit
4d10bbd0
authored
1 year ago
by
Eric Brombaugh
Browse files
Options
Downloads
Patches
Plain Diff
cnlohr's separate putchar() for UART and Debug for speed.
parent
a37c90dc
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ch32v003fun/ch32v003fun.c
+20
-8
20 additions, 8 deletions
ch32v003fun/ch32v003fun.c
with
20 additions
and
8 deletions
ch32v003fun/ch32v003fun.c
+
20
−
8
View file @
4d10bbd0
...
@@ -31,11 +31,6 @@ int printf(const char* format, ...)
...
@@ -31,11 +31,6 @@ int printf(const char* format, ...)
va_end
(
args
);
va_end
(
args
);
return
ret_status
;
return
ret_status
;
}
}
int
putchar
(
int
c
)
{
return
_write
(
0
,
(
const
char
*
)(
&
c
),
1
);
}
/* Some stuff from MUSL
/* Some stuff from MUSL
...
@@ -883,13 +878,21 @@ int _write(int fd, const char *buf, int size)
...
@@ -883,13 +878,21 @@ int _write(int fd, const char *buf, int size)
}
}
return
size
;
return
size
;
}
}
// single char to UART
int
putchar
(
int
c
)
{
while
(
!
(
USART1
->
STATR
&
USART_FLAG_TC
));
USART1
->
DATAR
=
(
const
char
)
c
;
return
1
;
}
#else
#else
// For debug writing to the debug interface.
// For debug writing to the debug interface.
#define DMDATA0 ((volatile uint32_t*)0xe00000f4)
#define DMDATA1 ((volatile uint32_t*)0xe00000f8)
int
_write
(
int
fd
,
const
char
*
buf
,
int
size
)
int
_write
(
int
fd
,
const
char
*
buf
,
int
size
)
{
{
#define DMDATA0 ((volatile uint32_t*)0xe00000f4)
#define DMDATA1 ((volatile uint32_t*)0xe00000f8)
char
buffer
[
4
]
=
{
0
};
char
buffer
[
4
]
=
{
0
};
int
place
=
0
;
int
place
=
0
;
uint32_t
timeout
=
160000
;
// Give up after ~40ms
uint32_t
timeout
=
160000
;
// Give up after ~40ms
...
@@ -924,6 +927,15 @@ int _write(int fd, const char *buf, int size)
...
@@ -924,6 +927,15 @@ int _write(int fd, const char *buf, int size)
return
size
;
return
size
;
}
}
// single to debug intf
int
putchar
(
int
c
)
{
int
timeout
=
16000
;
while
(
((
*
DMDATA0
)
&
0x80
)
)
if
(
timeout
--
==
0
)
return
0
;
*
DMDATA0
=
0x85
|
((
const
char
)
c
<<
8
);
return
1
;
}
void
SetupDebugPrintf
()
void
SetupDebugPrintf
()
{
{
// Clear out the sending flag.
// Clear out the sending flag.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment