33#ifndef __VSF_SIMPLE_STREAM_H__
34#define __VSF_SIMPLE_STREAM_H__
41#if VSF_USE_SIMPLE_STREAM == ENABLED
43#if defined(__VSF_SIMPLE_STREAM_CLASS_IMPLEMENT)
44# define __VSF_CLASS_IMPLEMENT__
45#elif defined(__VSF_SIMPLE_STREAM_CLASS_INHERIT__)
46# define __VSF_CLASS_INHERIT__
66#ifndef VSF_STREAM_CFG_TICKTOCK
67# define VSF_STREAM_CFG_TICKTOCK ENABLED
79#ifndef VSF_STREAM_CFG_THRESHOLD
80# define VSF_STREAM_CFG_THRESHOLD ENABLED
85#define __VSF_STREAM_ADAPTER_INIT(__STREAM_TX, __STREAM_RX, __THRESHOLD_TX, __THRESHOLD_RX)\
86 .stream_tx = (vsf_stream_t *)(__STREAM_TX), \
87 .stream_rx = (vsf_stream_t *)(__STREAM_RX), \
88 .threshold_tx = (__THRESHOLD_TX), \
89 .threshold_rx = (__THRESHOLD_RX),
90#define VSF_STREAM_ADAPTER_INIT0(__STREAM_TX, __STREAM_RX) \
91 __VSF_STREAM_ADAPTER_INIT((__STREAM_TX), (__STREAM_RX), 0, 0)
92#define VSF_STREAM_ADAPTER_INIT1(__STREAM_TX, __STREAM_RX, __THRESHOLD_TX) \
93 __VSF_STREAM_ADAPTER_INIT((__STREAM_TX), (__STREAM_RX), (__THRESHOLD_TX), 0)
94#define VSF_STREAM_ADAPTER_INIT2(__STREAM_TX, __STREAM_RX, __THRESHOLD_TX, __THRESHOLD_RX)\
95 __VSF_STREAM_ADAPTER_INIT((__STREAM_TX), (__STREAM_RX), (__THRESHOLD_TX), (__THRESHOLD_RX))
97#define VSF_STREAM_ADAPTER_INIT(__STREAM_TX, __STREAM_RX, ...) \
98 __PLOOC_EVAL(VSF_STREAM_ADAPTER_INIT, __VA_ARGS__)((__STREAM_TX), (__STREAM_RX), ##__VA_ARGS__)
100#define __declare_stream_adapter(__name) \
101 vsf_dcl_class(vsf_stream_adapter_t)
103#define declare_stream_adapter(__name) \
104 __declare_stream_adapter(__name)
105#define dcl_stream_adapter(__name) \
106 declare_stream_adapter(__name)
108#define __describe_stream_adapter(__name, __stream_tx, __stream_rx, __threshold_tx, __threshold_rx)\
109 vsf_stream_adapter_t __name = { \
110 VSF_STREAM_ADAPTER_INIT((__stream_tx), (__stream_rx), (__threshold_tx), (__threshold_rx))\
113#define describe_stream_adapter0(__name, __stream_tx, __stream_rx) \
114 __describe_stream_adapter(__name, (__stream_tx), (__stream_rx), 0, 0)
115#define describe_stream_adapter1(__name, __stream_tx, __stream_rx, __threshold_tx)\
116 __describe_stream_adapter(__name, (__stream_tx), (__stream_rx), (__threshold_tx), 0)
117#define describe_stream_adapter2(__name, __stream_tx, __stream_rx, __threshold_tx, __threshold_rx) \
118 __describe_stream_adapter(__name, (__stream_tx), (__stream_rx), (__threshold_tx), __threshold_rx)
120#define describe_stream_adapter(__name, __stream_tx, __stream_rx, ...) \
121 __PLOOC_EVAL(describe_stream_adapter, __VA_ARGS__)(__name, (__stream_tx), (__stream_rx), ##__VA_ARGS__)
126#define VSF_STREAM_INIT(__stream) vsf_stream_init((vsf_stream_t *)(__stream))
127#define VSF_STREAM_FINI(__stream) vsf_stream_fini((vsf_stream_t *)(__stream))
128#define VSF_STREAM_WRITE(__stream, __buf, __size) vsf_stream_write((vsf_stream_t *)(__stream), (__buf), (__size))
129#define VSF_STREAM_READ(__stream, __buf, __size) vsf_stream_read((vsf_stream_t *)(__stream), (__buf), (__size))
130#define VSF_STREAM_GET_BUFF_SIZE(__stream) vsf_stream_get_buff_size((vsf_stream_t *)(__stream))
131#define VSF_STREAM_GET_DATA_SIZE(__stream) vsf_stream_get_data_size((vsf_stream_t *)(__stream))
132#define VSF_STREAM_GET_FREE_SIZE(__stream) vsf_stream_get_free_size((vsf_stream_t *)(__stream))
133#define VSF_STREAM_GET_WBUF(__stream, p) vsf_stream_get_wbuf((vsf_stream_t *)(__stream), (p))
134#define VSF_STREAM_GET_RBUF(__stream, p) vsf_stream_get_rbuf((vsf_stream_t *)(__stream), (p))
135#define VSF_STREAM_CONNECT_RX(__stream) vsf_stream_connect_rx((vsf_stream_t *)(__stream))
136#define VSF_STREAM_CONNECT_TX(__stream) vsf_stream_connect_tx((vsf_stream_t *)(__stream))
137#define VSF_STREAM_DISCONNECT_RX(__stream) vsf_stream_disconnect_rx((vsf_stream_t *)(__stream))
138#define VSF_STREAM_DISCONNECT_TX(__stream) vsf_stream_disconnect_tx((vsf_stream_t *)(__stream))
139#define VSF_STREAM_IS_RX_CONNECTED(__stream) vsf_stream_is_rx_connected((vsf_stream_t *)(__stream))
140#define VSF_STREAM_IS_TX_CONNECTED(__stream) vsf_stream_is_tx_connected((vsf_stream_t *)(__stream))
141#if VSF_STREAM_CFG_THRESHOLD == ENABLED
143#define VSF_STREAM_SET_RX_THRESHOLD(__stream, __thres) vsf_stream_set_rx_threshold((vsf_stream_t *)(__stream), (__thres))
144#define VSF_STREAM_SET_TX_THRESHOLD(__stream, __thres) vsf_stream_set_tx_threshold((vsf_stream_t *)(__stream), (__thres))
258#if VSF_STREAM_CFG_TICKTOCK == ENABLED
259 bool is_ticktock_read;
260 bool is_ticktock_write;
334#if VSF_STREAM_CFG_THRESHOLD == ENABLED
351#if defined(__VSF_SIMPLE_STREAM_CLASS_IMPLEMENT) \
352 || defined(__VSF_SIMPLE_STREAM_CLASS_INHERIT__)
366#undef __VSF_SIMPLE_STREAM_CLASS_IMPLEMENT
367#undef __VSF_SIMPLE_STREAM_CLASS_INHERIT__
#define ENABLED
Definition __type.h:28
vsf_err_t
Definition __type.h:42
Definition vsf_simple_stream.h:286
Definition vsf_simple_stream.h:176
Definition vsf_simple_stream.h:254
Definition vsf_simple_stream.h:231
uint_fast32_t vsf_stream_get_free_size(vsf_stream_t *stream)
Definition vsf_simple_stream.c:120
uint_fast32_t vsf_stream_adapter_evthandler(vsf_stream_t *stream, void *param, vsf_stream_evt_t evt)
Definition vsf_simple_stream.c:245
void vsf_stream_adapter_init(vsf_stream_adapter_t *adapter)
Definition vsf_simple_stream.c:288
uint_fast32_t vsf_stream_get_rbuf(vsf_stream_t *stream, uint8_t **ptr)
Definition vsf_simple_stream.c:139
bool vsf_stream_is_tx_connected(vsf_stream_t *stream)
Definition vsf_simple_stream.c:188
bool vsf_stream_is_rx_connected(vsf_stream_t *stream)
Definition vsf_simple_stream.c:182
uint_fast32_t vsf_stream_read(vsf_stream_t *stream, uint8_t *buf, uint_fast32_t size)
Definition vsf_simple_stream.c:76
uint_fast32_t vsf_stream_get_wbuf(vsf_stream_t *stream, uint8_t **ptr)
Definition vsf_simple_stream.c:126
void vsf_stream_set_rx_threshold(vsf_stream_t *stream, uint_fast32_t threshold)
Definition vsf_simple_stream.c:100
#define VSF_STREAM_CFG_THRESHOLD
Definition vsf_simple_stream.h:80
uint_fast32_t vsf_stream_write(vsf_stream_t *stream, uint8_t *buf, uint_fast32_t size)
Definition vsf_simple_stream.c:84
void vsf_stream_connect_rx(vsf_stream_t *stream)
Definition vsf_simple_stream.c:170
void vsf_stream_set_tx_threshold(vsf_stream_t *stream, uint_fast32_t threshold)
Definition vsf_simple_stream.c:93
uint_fast32_t vsf_stream_get_data_size(vsf_stream_t *stream)
Definition vsf_simple_stream.c:114
vsf_stream_evt_t
Definition vsf_simple_stream.h:160
void vsf_stream_disconnect_tx(vsf_stream_t *stream)
Definition vsf_simple_stream.c:211
uint_fast32_t vsf_stream_get_buff_size(vsf_stream_t *stream)
Definition vsf_simple_stream.c:108
vsf_err_t vsf_stream_fini(vsf_stream_t *stream)
Definition vsf_simple_stream.c:230
void vsf_stream_connect_tx(vsf_stream_t *stream)
Definition vsf_simple_stream.c:176
vsf_err_t vsf_stream_init(vsf_stream_t *stream)
Definition vsf_simple_stream.c:217
void vsf_stream_disconnect_rx(vsf_stream_t *stream)
Definition vsf_simple_stream.c:205
@ VSF_STREAM_ON_DISCONNECT
Definition vsf_simple_stream.h:162
@ VSF_STREAM_ON_CONNECT
Definition vsf_simple_stream.h:161
@ VSF_STREAM_ON_TX
Definition vsf_simple_stream.h:166
@ VSF_STREAM_ON_OUT
Definition vsf_simple_stream.h:165
@ VSF_STREAM_ON_IN
Definition vsf_simple_stream.h:163
@ VSF_STREAM_ON_RX
Definition vsf_simple_stream.h:164
unsigned int uint32_t
Definition lvgl.h:43
unsigned char uint8_t
Definition lvgl.h:40
#define vsf_dcl_class
Definition ooc_class.h:46
#define vsf_class(__name)
Definition ooc_class.h:48
unsigned int uint_fast32_t
Definition stdint.h:27
#define read
Definition unistd.h:124
#define write
Definition unistd.h:125
uint32_t size
Definition vsf_memfs.h:50
void __vsf_stream_on_write(vsf_stream_t *stream)
Definition vsf_simple_stream.c:38
void __vsf_stream_on_read(vsf_stream_t *stream)
Definition vsf_simple_stream.c:57