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 
77 int isrpipe_read(isrpipe_t *isrpipe, uint8_t *buf, size_t count);
78 
79 #ifdef __cplusplus
80 }
81 #endif
82 
83 #endif /* ISRPIPE_H */
mutex_t mutex
isrpipe mutex
Definition: isrpipe.h:39
thread-safe ringbuffer struct
Definition: tsrb.h:40
Thread-safe ringbuffer interface definition.
int isrpipe_write_one(isrpipe_t *isrpipe, uint8_t c)
Put one character into the isrpipe&#39;s buffer.
Mutex for thread synchronization.
void isrpipe_init(isrpipe_t *isrpipe, uint8_t *buf, size_t bufsize)
Initialisation function for isrpipe.
Mutex structure.
Definition: mutex.h:36
tsrb_t tsrb
isrpipe thread safe ringbuffer
Definition: isrpipe.h:38
Context structure for isrpipe.
Definition: isrpipe.h:37
int isrpipe_read(isrpipe_t *isrpipe, uint8_t *buf, size_t count)
Read data from isrpipe (blocking)