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 */
isrpipe_t::mutex
mutex_t mutex
isrpipe mutex
Definition: isrpipe.h:39
mutex.h
Mutex for thread synchronization.
isrpipe_init
void isrpipe_init(isrpipe_t *isrpipe, uint8_t *buf, size_t bufsize)
Initialisation function for isrpipe.
isrpipe_read
int isrpipe_read(isrpipe_t *isrpipe, uint8_t *buf, size_t count)
Read data from isrpipe (blocking)
tsrb
thread-safe ringbuffer struct
Definition: tsrb.h:39
isrpipe_t
Context structure for isrpipe.
Definition: isrpipe.h:37
isrpipe_write_one
int isrpipe_write_one(isrpipe_t *isrpipe, uint8_t c)
Put one character into the isrpipe's buffer.
isrpipe_t::tsrb
tsrb_t tsrb
isrpipe thread safe ringbuffer
Definition: isrpipe.h:38
mutex_t
Mutex structure.
Definition: mutex.h:120
tsrb.h
Thread-safe ringbuffer interface definition.