1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
#include "project.h"
int
_open (const char *name,
int flags,
int mode)
{
errno = ENOSYS;
return -1; /* Always fails */
} /* _open () */
int
_close (int file)
{
errno = EBADF;
return -1; /* Always fails */
} /* _close () */
int
_write (int file,
char *buf,
int nbytes)
{
int ret;
ret = usart2_write (buf, nbytes, 1);
cdcacm_write (buf, nbytes, 0);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
} /* _write () */
int
_read (int file,
char *buf,
int nbytes)
{
errno = -EAGAIN;
return -1; /* EOF */
} /* _read () */
int
_fstat (int file,
struct stat *st)
{
st->st_mode = S_IFCHR;
return 0;
} /* _fstat () */
int
_lseek (int file,
int offset,
int whence)
{
return 0;
} /* _lseek () */
int
isatty (int file)
{
return 1;
} /* _isatty () */
void stdio_drain (void)
{
usart2_drain();
}
|