WISP ERT (Client)  1.0.0
The WISP Extended Runtime (WISP side)
buf.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "defs.h"
4 
6 typedef struct wio_buf {
8  uint8_t* buffer;
10  uint16_t size;
11 
13  uint16_t pos_a;
15  uint16_t pos_b;
16 } wio_buf_t;
17 
27  wio_buf_t* self,
28  uint8_t* buffer,
29  uint16_t size
30 );
31 
40  wio_buf_t* self,
41  uint16_t size
42 );
43 
52 extern wio_status_t wio_read(
53  wio_buf_t* self,
54  void* data,
55  uint16_t size
56 );
57 
66 extern wio_status_t wio_write(
67  wio_buf_t* self,
68  const void* data,
69  uint16_t size
70 );
71 
80 extern wio_status_t wio_copy(
81  wio_buf_t* from,
82  wio_buf_t* to,
83  uint16_t size
84 );
85 
94 extern wio_status_t wio_alloc(
95  wio_buf_t* self,
96  uint16_t size,
97  void* _ptr
98 );
99 
107 extern wio_status_t wio_free(
108  wio_buf_t* self,
109  uint16_t size
110 );
uint8_t wio_status_t
WIO status type.
Definition: defs.h:40
wio_status_t wio_free(wio_buf_t *self, uint16_t size)
Free memory from WIO buffer in a circular manner.
Definition: buf.c:180
WIO buffer type.
Definition: buf.h:6
uint8_t * buffer
Buffer.
Definition: buf.h:8
wio_status_t wio_buf_init(wio_buf_t *self, uint8_t *buffer, uint16_t size)
Initialize WIO buffer.
Definition: buf.c:8
wio_status_t wio_write(wio_buf_t *self, const void *data, uint16_t size)
Write data to WIO buffer.
Definition: buf.c:90
wio_status_t wio_buf_alloc_init(wio_buf_t *self, uint16_t size)
Initialize WIO buffer with dynamically allocated memory.
Definition: buf.c:27
uint16_t pos_b
Cursor B (Write cursor)
Definition: buf.h:15
wio_status_t wio_alloc(wio_buf_t *self, uint16_t size, void *_ptr)
Allocate memory from WIO buffer in a circlular manner.
Definition: buf.c:156
uint16_t size
Buffer size.
Definition: buf.h:10
uint16_t pos_a
Cursor A (Read cursor)
Definition: buf.h:13
wio_status_t wio_copy(wio_buf_t *from, wio_buf_t *to, uint16_t size)
Copy data from one WIO buffer to another.
Definition: buf.c:136
wio_status_t wio_read(wio_buf_t *self, void *data, uint16_t size)
Read data from WIO buffer.
Definition: buf.c:44