Loading...
Searching...
No Matches
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
9#pragma once
10
23
24#include <stdint.h>
25
26#include "mutex.h"
27#include "tsrb.h"
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
36typedef struct {
39} isrpipe_t;
40
48#define ISRPIPE_INIT(buf) { .mutex = MUTEX_INIT_LOCKED, \
49 .tsrb = TSRB_INIT(buf) }
50
60void isrpipe_init(isrpipe_t *isrpipe, uint8_t *buf, size_t bufsize);
61
71int isrpipe_write_one(isrpipe_t *isrpipe, uint8_t c);
72
83int isrpipe_write(isrpipe_t *isrpipe, const uint8_t *buf, size_t n);
84
94int isrpipe_read(isrpipe_t *isrpipe, uint8_t *buf, size_t count);
95
96#ifdef __cplusplus
97}
98#endif
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.
struct tsrb tsrb_t
thread-safe ringbuffer struct
Mutex for thread synchronization.
Context structure for isrpipe.
Definition isrpipe.h:36
tsrb_t tsrb
isrpipe thread safe ringbuffer
Definition isrpipe.h:37
mutex_t mutex
isrpipe mutex
Definition isrpipe.h:38
Mutex structure.
Definition mutex.h:39
Thread-safe ringbuffer interface definition.