ChibiOS
20.3.4
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
const
struct
NullStreamVMT
vmt = {(size_t)0, writes, reads, put, get};
78
79
/*===========================================================================*/
80
/* Driver exported functions. */
81
/*===========================================================================*/
82
83
/**
84
* @brief Null stream object initialization.
85
*
86
* @param[out] nsp pointer to the @p NullStream object to be initialized
87
*/
88
void
nullObjectInit
(
NullStream
*nsp) {
89
90
nsp->
vmt
= &vmt;
91
}
92
93
/** @} */
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_OK
#define MSG_OK
Normal wakeup message.
Definition:
chschd.h:39
nullObjectInit
void nullObjectInit(NullStream *nsp)
Null stream object initialization.
Definition:
nullstreams.c:88
msg_t
int32_t msg_t
Definition:
chtypes.h:51
nullstreams.h
Null streams structures and macros.
home
giovanni
Projects
ChibiStudio
chibios_stable-20.3.x
os
hal
lib
streams
nullstreams.c
Generated on Sun Oct 31 2021 10:28:08 for ChibiOS by
1.8.17