Loading...
Searching...
No Matches
isrpipe.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2016 Kaspar Schleiser <kaspar@schleiser.de>
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
20
21#include <stdint.h>
22
23#include "mutex.h"
24#include "tsrb.h"
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
33typedef struct {
36} isrpipe_t;
37
45#define ISRPIPE_INIT(buf) { .mutex = MUTEX_INIT_LOCKED, \
46 .tsrb = TSRB_INIT(buf) }
47
57void isrpipe_init(isrpipe_t *isrpipe, uint8_t *buf, size_t bufsize);
58
68int isrpipe_write_one(isrpipe_t *isrpipe, uint8_t c);
69
80int isrpipe_write(isrpipe_t *isrpipe, const uint8_t *buf, size_t n);
81
91int isrpipe_read(isrpipe_t *isrpipe, uint8_t *buf, size_t count);
92
100uint8_t isrpipe_read_one(isrpipe_t *isrpipe);
101
112
120unsigned int isrpipe_available(isrpipe_t *isrpipe);
121
122#ifdef __cplusplus
123}
124#endif
int isrpipe_write_one(isrpipe_t *isrpipe, uint8_t c)
Put one byte into the isrpipe's buffer.
unsigned int isrpipe_available(isrpipe_t *isrpipe)
Get the number of bytes available for reading from the isrpipe.
void isrpipe_init(isrpipe_t *isrpipe, uint8_t *buf, size_t bufsize)
Initialisation function for isrpipe.
uint8_t isrpipe_read_one(isrpipe_t *isrpipe)
Read a single byte from isrpipe (blocking)
void isrpipe_clear(isrpipe_t *isrpipe)
Clear the isrpipe's buffer.
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.
struct tsrb tsrb_t
thread-safe ringbuffer struct
Mutex for thread synchronization.
Context structure for isrpipe.
Definition isrpipe.h:33
tsrb_t tsrb
isrpipe thread safe ringbuffer
Definition isrpipe.h:34
mutex_t mutex
isrpipe mutex
Definition isrpipe.h:35
Mutex structure.
Definition mutex.h:36
Thread-safe ringbuffer interface definition.