isrpipe.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Kaspar Schleiser <kaspar@schleiser.de>
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
22 #ifndef ISRPIPE_H
23 #define ISRPIPE_H
24 
25 #include <stdint.h>
26 
27 #include "mutex.h"
28 #include "tsrb.h"
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
37 typedef struct {
40 } isrpipe_t;
41 
45 #define ISRPIPE_INIT(tsrb_buf) { .mutex = MUTEX_INIT, .tsrb = TSRB_INIT(tsrb_buf) }
46 
54 void isrpipe_init(isrpipe_t *isrpipe, char *buf, size_t bufsize);
55 
65 int isrpipe_write_one(isrpipe_t *isrpipe, char c);
66 
76 int isrpipe_read(isrpipe_t *isrpipe, char *buf, size_t count);
77 
94 int isrpipe_read_timeout(isrpipe_t *isrpipe, char *buf, size_t count, uint32_t timeout);
95 
110 int isrpipe_read_all_timeout(isrpipe_t *isrpipe, char *buf, size_t count, uint32_t timeout);
111 
112 #ifdef __cplusplus
113 }
114 #endif
115 
116 #endif /* ISRPIPE_H */
int isrpipe_write_one(isrpipe_t *isrpipe, char c)
Put one character into the isrpipe&#39;s buffer.
mutex_t mutex
isrpipe mutex
Definition: isrpipe.h:38
int isrpipe_read(isrpipe_t *isrpipe, char *buf, size_t count)
Read data from isrpipe (blocking)
thread-safe ringbuffer struct
Definition: tsrb.h:40
Thread-safe ringbuffer implementation.
RIOT synchronization API.
Mutex structure.
Definition: mutex.h:36
int isrpipe_read_timeout(isrpipe_t *isrpipe, char *buf, size_t count, uint32_t timeout)
Read data from isrpipe (with timeout, blocking)
int isrpipe_read_all_timeout(isrpipe_t *isrpipe, char *buf, size_t count, uint32_t timeout)
Read data from isrpipe (with timeout, blocking, wait until all read)
tsrb_t tsrb
isrpipe thread safe ringbuffer
Definition: isrpipe.h:39
void isrpipe_init(isrpipe_t *isrpipe, char *buf, size_t bufsize)
Initialisation function for isrpipe.
Context structure for isrpipe.
Definition: isrpipe.h:37