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 
49 #define ISRPIPE_INIT(buf) { .mutex = MUTEX_INIT_LOCKED, \
50  .tsrb = TSRB_INIT(buf) }
51 
61 void isrpipe_init(isrpipe_t *isrpipe, uint8_t *buf, size_t bufsize);
62 
72 int isrpipe_write_one(isrpipe_t *isrpipe, uint8_t c);
73 
84 int isrpipe_write(isrpipe_t *isrpipe, const uint8_t *buf, size_t n);
85 
95 int isrpipe_read(isrpipe_t *isrpipe, uint8_t *buf, size_t count);
96 
97 #ifdef __cplusplus
98 }
99 #endif
101 #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:39
thread-safe ringbuffer struct
Definition: tsrb.h:39
Thread-safe ringbuffer interface definition.