Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
multipass
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
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
derf
multipass
Commits
540974f8
Commit
540974f8
authored
7 years ago
by
Birte Kristina Friesel
Browse files
Options
Downloads
Patches
Plain Diff
"Fix" esp8266 UART output by removing virtual functions
parent
dcf84169
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/esp8266/driver/stdout.h
+45
-6
45 additions, 6 deletions
include/esp8266/driver/stdout.h
src/arch/esp8266/driver/stdout.cc
+190
-0
190 additions, 0 deletions
src/arch/esp8266/driver/stdout.cc
src/os/main.cc
+1
-0
1 addition, 0 deletions
src/os/main.cc
with
236 additions
and
6 deletions
include/esp8266/driver/stdout.h
+
45
−
6
View file @
540974f8
#ifndef STANDARDOUTPUT_H
#define STANDANDOUTPUT_H
#include
"object/outputstream.h"
class
StandardOutput
:
public
OutputStream
{
class
StandardOutput
{
private:
StandardOutput
(
const
StandardOutput
&
copy
);
char
digit_buffer
[
sizeof
(
long
long
)
*
8
];
unsigned
char
base
;
public:
StandardOutput
()
{}
StandardOutput
()
;
void
setup
();
virtual
void
put
(
char
c
)
override
;
virtual
void
write
(
const
char
*
s
)
override
;
void
put
(
char
c
);
void
write
(
const
char
*
s
);
void
flush
()
{}
StandardOutput
&
operator
<<
(
char
c
);
StandardOutput
&
operator
<<
(
unsigned
char
c
);
StandardOutput
&
operator
<<
(
unsigned
short
number
);
StandardOutput
&
operator
<<
(
short
number
);
StandardOutput
&
operator
<<
(
unsigned
int
number
);
StandardOutput
&
operator
<<
(
int
number
);
StandardOutput
&
operator
<<
(
unsigned
long
number
);
StandardOutput
&
operator
<<
(
long
number
);
StandardOutput
&
operator
<<
(
unsigned
long
long
number
);
StandardOutput
&
operator
<<
(
long
long
number
);
StandardOutput
&
operator
<<
(
void
*
pointer
);
StandardOutput
&
operator
<<
(
const
char
*
text
);
StandardOutput
&
operator
<<
(
StandardOutput
&
(
*
fun
)
(
StandardOutput
&
));
void
setBase
(
unsigned
char
b
);
};
// ENDL: new line character (and flush)
StandardOutput
&
endl
(
StandardOutput
&
os
);
// BIN: print numbers in binary form.
StandardOutput
&
bin
(
StandardOutput
&
os
);
// OCT: print numbers in octal form.
StandardOutput
&
oct
(
StandardOutput
&
os
);
// DEC: print numbers in decimal form.
StandardOutput
&
dec
(
StandardOutput
&
os
);
// HEX: print numbers in hexadecimal form.
StandardOutput
&
hex
(
StandardOutput
&
os
);
// FLUSH: flush StandardOutput buffer
StandardOutput
&
flush
(
StandardOutput
&
os
);
// TERM: zero-termination
StandardOutput
&
term
(
StandardOutput
&
os
);
extern
StandardOutput
kout
;
#endif
This diff is collapsed.
Click to expand it.
src/arch/esp8266/driver/stdout.cc
+
190
−
0
View file @
540974f8
...
...
@@ -7,6 +7,196 @@ void uart_div_modify(uint8_t uart_no, uint32 DivLatchValue);
void
os_printf_plus
(
const
char
*
s
,
...);
}
StandardOutput
&
StandardOutput
::
operator
<<
(
unsigned
char
c
)
{
put
(
c
);
return
*
this
;
}
StandardOutput
&
StandardOutput
::
operator
<<
(
char
c
)
{
put
(
c
);
return
*
this
;
}
StandardOutput
&
StandardOutput
::
operator
<<
(
unsigned
short
number
)
{
*
this
<<
(
unsigned
long
long
)
number
;
return
*
this
;
}
StandardOutput
&
StandardOutput
::
operator
<<
(
short
number
)
{
*
this
<<
(
long
long
)
number
;
return
*
this
;
}
StandardOutput
&
StandardOutput
::
operator
<<
(
unsigned
int
number
)
{
*
this
<<
(
unsigned
long
long
)
number
;
return
*
this
;
}
StandardOutput
&
StandardOutput
::
operator
<<
(
int
number
)
{
*
this
<<
(
long
long
)
number
;
return
*
this
;
}
StandardOutput
&
StandardOutput
::
operator
<<
(
unsigned
long
number
)
{
*
this
<<
(
unsigned
long
long
)
number
;
return
*
this
;
}
StandardOutput
&
StandardOutput
::
operator
<<
(
long
number
)
{
*
this
<<
(
long
long
)
number
;
return
*
this
;
}
StandardOutput
&
StandardOutput
::
operator
<<
(
unsigned
long
long
number
)
{
switch
(
base
)
{
case
2
:
put
(
'0'
);
put
(
'b'
);
break
;
case
8
:
put
(
'0'
);
break
;
case
16
:
put
(
'0'
);
put
(
'x'
);
break
;
}
if
(
number
==
0
)
{
put
(
'0'
);
return
*
this
;
}
signed
int
i
=
0
;
while
(
number
>
0
)
{
if
(
base
==
16
&&
number
%
base
>
9
)
{
digit_buffer
[
i
]
=
'a'
+
(
number
%
base
)
-
10
;
}
else
{
digit_buffer
[
i
]
=
'0'
+
(
number
%
base
);
}
number
/=
base
;
i
++
;
}
i
--
;
for
(;
i
>=
0
;
i
--
)
{
put
(
digit_buffer
[
i
]);
}
return
*
this
;
}
StandardOutput
&
StandardOutput
::
operator
<<
(
long
long
number
)
{
if
(
number
<
0
)
{
put
(
'-'
);
number
*=
-
1
;
}
*
this
<<
(
unsigned
long
long
)
number
;
return
*
this
;
}
StandardOutput
&
StandardOutput
::
operator
<<
(
void
*
pointer
)
{
unsigned
short
temp_base
=
base
;
*
this
<<
hex
<<
(
long
)
pointer
;
switch
(
temp_base
)
{
case
2
:
*
this
<<
bin
;
break
;
case
8
:
*
this
<<
oct
;
break
;
case
10
:
*
this
<<
dec
;
break
;
}
return
*
this
;
}
StandardOutput
&
StandardOutput
::
operator
<<
(
const
char
*
text
)
{
int
i
=
0
;
while
(
text
[
i
]
!=
'\0'
)
{
put
(
text
[
i
++
]);
}
return
*
this
;
}
StandardOutput
&
StandardOutput
::
operator
<<
(
StandardOutput
&
(
*
fkt
)
(
StandardOutput
&
))
{
return
fkt
(
*
this
);
}
void
StandardOutput
::
setBase
(
uint8_t
b
)
{
if
(
b
==
2
||
b
==
8
||
b
==
10
||
b
==
16
)
{
base
=
b
;
}
}
// FLUSH
StandardOutput
&
flush
(
StandardOutput
&
os
)
{
os
.
flush
();
return
os
;
}
// ENDL: fuegt einen Zeilenumbruch in die Ausgabe ein.
StandardOutput
&
endl
(
StandardOutput
&
os
)
{
os
.
put
(
'\n'
);
os
.
flush
();
return
os
;
}
// BIN: print numbers in binary form
StandardOutput
&
bin
(
StandardOutput
&
os
)
{
os
.
setBase
(
2
);
return
os
;
}
// OCT: print numbers in octal form.
StandardOutput
&
oct
(
StandardOutput
&
os
)
{
os
.
setBase
(
8
);
return
os
;
}
// DEC: print numbers in decimal form.
StandardOutput
&
dec
(
StandardOutput
&
os
)
{
os
.
setBase
(
10
);
return
os
;
}
// HEX: print numbers in hexadecimal form.
StandardOutput
&
hex
(
StandardOutput
&
os
)
{
os
.
setBase
(
16
);
return
os
;
}
// TERM: null-termination
StandardOutput
&
term
(
StandardOutput
&
os
)
{
os
.
put
(
'\0'
);
os
.
flush
();
return
os
;
}
StandardOutput
::
StandardOutput
()
{
base
=
10
;
}
void
StandardOutput
::
setup
()
{
uart_div_modify
(
0
,
UART_CLK_FREQ
/
115200
);
...
...
This diff is collapsed.
Click to expand it.
src/os/main.cc
+
1
−
0
View file @
540974f8
...
...
@@ -98,6 +98,7 @@ int main(void)
gpio
.
led_on
(
0
);
kout
<<
"Hello, World!"
<<
endl
;
kout
<<
"Test, World!"
<<
endl
;
arch
.
idle_loop
();
...
...
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