Contiki-NG
uart0-putchar.c
1
/*---------------------------------------------------------------------------*/
2
#include "contiki.h"
3
#include "dev/uart0.h"
4
5
#include <string.h>
6
/*---------------------------------------------------------------------------*/
7
#define SLIP_END 0300
8
#undef putchar
9
/*---------------------------------------------------------------------------*/
10
int
11
putchar(
int
c)
12
{
13
#if SLIP_ARCH_CONF_ENABLED
14
static
char
debug_frame = 0;
15
16
if
(!debug_frame) {
/* Start of debug output */
17
uart0_writeb(SLIP_END);
18
uart0_writeb(
'\r'
);
/* Type debug line == '\r' */
19
debug_frame = 1;
20
}
21
#endif
/* SLIP_ARCH_CONF_ENABLED */
22
23
/* Need to also print '\n' because for example COOJA will not show
24
any output before line end */
25
uart0_writeb((
char
)c);
26
27
#if SLIP_ARCH_CONF_ENABLED
28
/*
29
* Line buffered output, a newline marks the end of debug output and
30
* implicitly flushes debug output.
31
*/
32
if
(c ==
'\n'
) {
33
uart0_writeb(SLIP_END);
34
debug_frame = 0;
35
}
36
#endif
/* SLIP_ARCH_CONF_ENABLED */
37
return
c;
38
}
39
40
#if defined(__GNUC__) && (__GNUC__ >= 9)
41
/* The printf() in newlib in GCC 9 from Texas Instruments uses the
42
* "TI C I/O" protocol which is not implemented in GDB. The user manual
43
* suggests overriding write() to redirect printf() output. */
44
int
45
write(
int
fd,
const
char
*buf,
int
len)
46
{
47
int
i = 0;
48
for
(; i < len && buf[i]; i++) {
49
putchar(buf[i]);
50
}
51
return
i;
52
}
53
#endif
54
/*---------------------------------------------------------------------------*/
arch
cpu
msp430
dev
uart0-putchar.c
Generated on Wed Jul 12 2023 12:33:24 for Contiki-NG by
1.9.4