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, \
46  .tsrb = TSRB_INIT(tsrb_buf) }
47 
55 void isrpipe_init(isrpipe_t *isrpipe, uint8_t *buf, size_t bufsize);
56 
66 int isrpipe_write_one(isrpipe_t *isrpipe, uint8_t c);
67 
78 int isrpipe_write(isrpipe_t *isrpipe, const uint8_t *buf, size_t n);
79 
89 int isrpipe_read(isrpipe_t *isrpipe, uint8_t *buf, size_t count);
90 
91 #ifdef __cplusplus
92 }
93 #endif
95 #endif /* ISRPIPE_H */
int isrpipe_write_one(isrpipe_t *isrpipe, uint8_t c)
Put one byte into the isrpipe's buffer.
void isrpipe_init(isrpipe_t *isrpipe, uint8_t *buf, size_t bufsize)
Initialisation function for isrpipe.
int isrpipe_read(isrpipe_t *isrpipe, uint8_t *buf, size_t count)
Read data from isrpipe (blocking)
int isrpipe_write(isrpipe_t *isrpipe, const uint8_t *buf, size_t n)
Put number of bytes into the isrpipe's buffer.
Mutex for thread synchronization.
Context structure for isrpipe.
Definition: isrpipe.h:37
tsrb_t tsrb
isrpipe thread safe ringbuffer
Definition: isrpipe.h:38
mutex_t mutex
isrpipe mutex
Definition: isrpipe.h:39
Mutex structure.
Definition: mutex.h:146
thread-safe ringbuffer struct
Definition: tsrb.h:39
Thread-safe ringbuffer interface definition.