Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
triazo
/
kernel
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
3
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
21818eb9
authored
Sep 28, 2015
by
triazo
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Adds hex output to serial
parent
3e6dc6c2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
0 deletions
src/serial.c
src/serial.h
src/serial.c
View file @
21818eb9
...
...
@@ -32,3 +32,18 @@ void serial_writestring(char* s) {
s
++
;
}
}
const
char
*
hexchars
=
"0123456789abcdef"
;
void
serial_hexword
(
uint32_t
x
)
{
for
(
int
i
=
8
;
i
!=
0
;
i
--
)
{
serial_writechar
(
hexchars
[
x
>>
i
*
4
&
0xf
]);
}
}
void
serial_hexstring
(
void
*
s
,
uint32_t
n
)
{
char
*
d
=
(
char
*
)
s
;
for
(
uint32_t
i
=
0
;
i
<
n
;
i
++
)
{
serial_writechar
(
hexchars
[(
d
[
i
]
>>
4
)
&
0xf
]);
serial_writechar
(
hexchars
[
d
[
i
]
&
0xf
]);
}
}
src/serial.h
View file @
21818eb9
...
...
@@ -2,7 +2,11 @@
serial.h contains headers for the serial interaction functions
*/
#ifndef _SERIAL_INC
#define _SERIAL_INC
#include "asm.h"
#include <stdint.h>
// Initilizes the first serial port
void
serial_init
();
...
...
@@ -15,3 +19,9 @@ void serial_writechar(char a);
// Write a null terminated string to serial
void
serial_writestring
(
char
*
s
);
// Function to write a 4 byte word toserial in hex
void
serial_hexword
(
uint32_t
x
);
void
serial_hexstring
(
void
*
s
,
uint32_t
n
);
#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