WISP ERT (Client)  1.0.0
The WISP Extended Runtime (WISP side)
buf.h File Reference
#include "defs.h"

Go to the source code of this file.

Data Structures

struct  wio_buf_t
 WIO buffer type. More...
 

Functions

wio_status_t wio_buf_init (wio_buf_t *self, uint8_t *buffer, uint16_t size)
 Initialize WIO buffer. More...
 
wio_status_t wio_buf_alloc_init (wio_buf_t *self, uint16_t size)
 Initialize WIO buffer with dynamically allocated memory. More...
 
wio_status_t wio_read (wio_buf_t *self, void *data, uint16_t size)
 Read data from WIO buffer. More...
 
wio_status_t wio_write (wio_buf_t *self, const void *data, uint16_t size)
 Write data to WIO buffer. More...
 
wio_status_t wio_copy (wio_buf_t *from, wio_buf_t *to, uint16_t size)
 Copy data from one WIO buffer to another. More...
 
wio_status_t wio_alloc (wio_buf_t *self, uint16_t size, void *_ptr)
 Allocate memory from WIO buffer in a circlular manner. More...
 
wio_status_t wio_free (wio_buf_t *self, uint16_t size)
 Free memory from WIO buffer in a circular manner. More...
 

Function Documentation

◆ wio_alloc()

wio_status_t wio_alloc ( wio_buf_t self,
uint16_t  size,
void *  _ptr 
)

Allocate memory from WIO buffer in a circlular manner.

Parameters
selfWIO buffer instance.
sizeSize of the memory to allocate.
_ptrPointer to memory for holding pointer to allocated memory.
Returns
WIO_ERR_NO_MEMORY if no memory available for allocation, otherwise WIO_OK.

◆ wio_buf_alloc_init()

wio_status_t wio_buf_alloc_init ( wio_buf_t self,
uint16_t  size 
)

Initialize WIO buffer with dynamically allocated memory.

Parameters
selfWIO buffer instance.
sizeSize of underlying buffer.
Returns
WIO_ERR_NO_MEMORY if allocation failed, otherwise WIO_OK.

◆ wio_buf_init()

wio_status_t wio_buf_init ( wio_buf_t self,
uint8_t *  buffer,
uint16_t  size 
)

Initialize WIO buffer.

Parameters
selfWIO buffer instance.
bufferUnderlying buffer.
sizeSize of underlying buffer.
Returns
WIO_OK.

◆ wio_copy()

wio_status_t wio_copy ( wio_buf_t from,
wio_buf_t to,
uint16_t  size 
)

Copy data from one WIO buffer to another.

Parameters
fromSource WIO buffer.
toTarget WIO buffer.
sizeSize of data to copy.
Returns
WIO_ERR_OUT_OF_RANGE if out-of-range read or write happens, otherwise WIO_OK.

◆ wio_free()

wio_status_t wio_free ( wio_buf_t self,
uint16_t  size 
)

Free memory from WIO buffer in a circular manner.

Parameters
selfWIO buffer instance.
sizeSize of the memory to free.
Returns
WIO_OK.

◆ wio_read()

wio_status_t wio_read ( wio_buf_t self,
void *  data,
uint16_t  size 
)

Read data from WIO buffer.

Parameters
selfWIO buffer instance.
dataPointer to memory for holding read data.
sizeSize of data to read.
Returns
WIO_ERR_OUT_OF_RANGE if read beyond buffer range, otherwise WIO_OK.

◆ wio_write()

wio_status_t wio_write ( wio_buf_t self,
const void *  data,
uint16_t  size 
)

Write data to WIO buffer.

Parameters
selfWIO buffer instance.
dataPointer to write data.
sizeSize of data to write.
Returns
WIO_ERR_OUT_OF_RANGE if write beyond buffer range, otherwise WIO_OK.