ChibiOS/HAL
7.2.0
nullstreams.c
Go to the documentation of this file.
1
/*
2
ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
3
4
Licensed under the Apache License, Version 2.0 (the "License");
5
you may not use this file except in compliance with the License.
6
You may obtain a copy of the License at
7
8
http://www.apache.org/licenses/LICENSE-2.0
9
10
Unless required by applicable law or agreed to in writing, software
11
distributed under the License is distributed on an "AS IS" BASIS,
12
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
See the License for the specific language governing permissions and
14
limitations under the License.
15
*/
16
17
/**
18
* @file nullstreams.c
19
* @brief Null streams code.
20
*
21
* @addtogroup HAL_NULL_STREAMS
22
* @details A null streams.
23
* @{
24
*/
25
26
#include "
hal.h
"
27
#include "
nullstreams.h
"
28
29
/*===========================================================================*/
30
/* Driver local definitions. */
31
/*===========================================================================*/
32
33
/*===========================================================================*/
34
/* Driver exported variables. */
35
/*===========================================================================*/
36
37
/*===========================================================================*/
38
/* Driver local variables. */
39
/*===========================================================================*/
40
41
/*===========================================================================*/
42
/* Driver local functions. */
43
/*===========================================================================*/
44
45
static
size_t
writes(
void
*ip,
const
uint8_t *bp,
size_t
n) {
46
47
(void)ip;
48
(void)bp;
49
50
return
n;
51
}
52
53
static
size_t
reads(
void
*ip, uint8_t *bp,
size_t
n) {
54
55
(void)ip;
56
(void)bp;
57
(void)n;
58
59
return
0;
60
}
61
62
static
msg_t
put(
void
*ip, uint8_t b) {
63
64
(void)ip;
65
(void)b;
66
67
return
MSG_OK;
68
}
69
70
static
msg_t
get(
void
*ip) {
71
72
(void)ip;
73
74
return
4;
75
}
76
77
static
msg_t
unget(
void
* ip, uint8_t b)
78
{
79
80
(void)ip;
81
(void)b;
82
83
return
MSG_OK;
84
}
85
86
static
const
struct
NullStreamVMT
vmt = {(size_t)0, writes, reads, put, get, unget};
87
88
/*===========================================================================*/
89
/* Driver exported functions. */
90
/*===========================================================================*/
91
92
/**
93
* @brief Null stream object initialization.
94
*
95
* @param[out] nsp pointer to the @p NullStream object to be initialized
96
*/
97
void
nullObjectInit
(
NullStream
*nsp) {
98
99
nsp->
vmt
= &vmt;
100
}
101
102
/** @} */
NullStream::vmt
const struct NullStreamVMT * vmt
Virtual Methods Table.
Definition:
nullstreams.h:64
NullStream
Null stream object.
Definition:
nullstreams.h:62
hal.h
HAL subsystem header.
NullStreamVMT
NullStream virtual methods table.
Definition:
nullstreams.h:53
msg_t
int32_t msg_t
Type of a message.
Definition:
osal.h:159
nullObjectInit
void nullObjectInit(NullStream *nsp)
Null stream object initialization.
Definition:
nullstreams.c:97
nullstreams.h
Null streams structures and macros.
home
giovanni
Projects
ChibiStudio
chibios_stable-21.6.x
os
hal
lib
streams
nullstreams.c
Generated on Sun Jun 13 2021 16:13:17 for ChibiOS/HAL by
1.8.17