Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
Software for White Rabbit PTP Core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
28
Issues
28
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Software for White Rabbit PTP Core
Commits
c64cb5c6
Commit
c64cb5c6
authored
Jul 31, 2011
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
uart code: fixed write_byte, added write_string
parent
fba4cbd6
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
8 deletions
+18
-8
uart.c
dev/uart.c
+15
-6
uart.h
include/uart.h
+3
-2
No files found.
dev/uart.c
View file @
c64cb5c6
...
@@ -5,7 +5,9 @@
...
@@ -5,7 +5,9 @@
#include <hw/wb_vuart.h>
#include <hw/wb_vuart.h>
#define CALC_BAUD(baudrate) (((((unsigned long long)baudrate*8ULL)<<(16-7))+(CPU_CLOCK>>8))/(CPU_CLOCK>>7))
#define CALC_BAUD(baudrate) \
( ((( (unsigned long long)baudrate * 8ULL) << (16 - 7)) + \
(CPU_CLOCK >> 8)) / (CPU_CLOCK >> 7) )
static
volatile
struct
UART_WB
*
uart
=
(
volatile
struct
UART_WB
*
)
BASE_UART
;
static
volatile
struct
UART_WB
*
uart
=
(
volatile
struct
UART_WB
*
)
BASE_UART
;
...
@@ -14,10 +16,17 @@ void uart_init()
...
@@ -14,10 +16,17 @@ void uart_init()
uart
->
BCR
=
CALC_BAUD
(
UART_BAUDRATE
);
uart
->
BCR
=
CALC_BAUD
(
UART_BAUDRATE
);
}
}
void
uart_write_byte
(
unsigned
char
x
)
void
uart_write_byte
(
int
b
)
{
{
while
(
uart
->
SR
&
UART_SR_TX_BUSY
);
if
(
b
==
'\n'
)
uart
->
TDR
=
x
;
if
(
x
==
'\n'
)
uart_write_byte
(
'\r'
);
uart_write_byte
(
'\r'
);
while
(
uart
->
SR
&
UART_SR_TX_BUSY
)
;
uart
->
TDR
=
b
;
}
void
uart_write_string
(
char
*
s
)
{
while
(
*
s
)
uart_write_byte
(
*
(
s
++
));
}
}
include/uart.h
View file @
c64cb5c6
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
int
mprintf
(
char
const
*
format
,
...);
int
mprintf
(
char
const
*
format
,
...);
void
uart_init
();
void
uart_init
();
void
uart_write_byte
(
unsigned
char
x
);
void
uart_write_byte
(
int
b
);
void
uart_write_string
(
char
*
s
);
#endif
#endif
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