Zephyr API Documentation  3.6.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
pipe.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2022 Trackunit Corporation
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#include <zephyr/types.h>
8#include <zephyr/kernel.h>
9
10#ifndef ZEPHYR_MODEM_PIPE_
11#define ZEPHYR_MODEM_PIPE_
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
30};
31
36struct modem_pipe;
37
42typedef void (*modem_pipe_api_callback)(struct modem_pipe *pipe, enum modem_pipe_event event,
43 void *user_data);
44
49typedef int (*modem_pipe_api_open)(void *data);
50
51typedef int (*modem_pipe_api_transmit)(void *data, const uint8_t *buf, size_t size);
52
53typedef int (*modem_pipe_api_receive)(void *data, uint8_t *buf, size_t size);
54
55typedef int (*modem_pipe_api_close)(void *data);
56
57struct modem_pipe_api {
58 modem_pipe_api_open open;
59 modem_pipe_api_transmit transmit;
60 modem_pipe_api_receive receive;
61 modem_pipe_api_close close;
62};
63
64enum modem_pipe_state {
65 MODEM_PIPE_STATE_CLOSED = 0,
66 MODEM_PIPE_STATE_OPEN,
67};
68
69struct modem_pipe {
70 void *data;
71 struct modem_pipe_api *api;
73 void *user_data;
74 enum modem_pipe_state state;
75 struct k_mutex lock;
76 struct k_condvar condvar;
77 uint8_t receive_ready_pending : 1;
78 uint8_t transmit_idle_pending : 1;
79};
80
88void modem_pipe_init(struct modem_pipe *pipe, void *data, struct modem_pipe_api *api);
89
106int modem_pipe_open(struct modem_pipe *pipe);
107
119int modem_pipe_open_async(struct modem_pipe *pipe);
120
131void modem_pipe_attach(struct modem_pipe *pipe, modem_pipe_api_callback callback, void *user_data);
132
146int modem_pipe_transmit(struct modem_pipe *pipe, const uint8_t *buf, size_t size);
147
161int modem_pipe_receive(struct modem_pipe *pipe, uint8_t *buf, size_t size);
162
168void modem_pipe_release(struct modem_pipe *pipe);
169
182int modem_pipe_close(struct modem_pipe *pipe);
183
195int modem_pipe_close_async(struct modem_pipe *pipe);
196
208void modem_pipe_notify_opened(struct modem_pipe *pipe);
209
217void modem_pipe_notify_closed(struct modem_pipe *pipe);
218
226void modem_pipe_notify_receive_ready(struct modem_pipe *pipe);
227
235void modem_pipe_notify_transmit_idle(struct modem_pipe *pipe);
236
245#ifdef __cplusplus
246}
247#endif
248
249#endif /* ZEPHYR_MODEM_PIPE_ */
static int close(int sock)
POSIX wrapper for zsock_close.
Definition: socket.h:880
int modem_pipe_open_async(struct modem_pipe *pipe)
Open pipe asynchronously.
int modem_pipe_close(struct modem_pipe *pipe)
Close pipe.
void modem_pipe_attach(struct modem_pipe *pipe, modem_pipe_api_callback callback, void *user_data)
Attach pipe to callback.
int modem_pipe_transmit(struct modem_pipe *pipe, const uint8_t *buf, size_t size)
Transmit data through pipe.
int modem_pipe_close_async(struct modem_pipe *pipe)
Close pipe asynchronously.
int modem_pipe_receive(struct modem_pipe *pipe, uint8_t *buf, size_t size)
Receive data through pipe.
modem_pipe_event
Modem pipe event.
Definition: pipe.h:25
void modem_pipe_release(struct modem_pipe *pipe)
Clear callback.
int modem_pipe_open(struct modem_pipe *pipe)
Open pipe.
void(* modem_pipe_api_callback)(struct modem_pipe *pipe, enum modem_pipe_event event, void *user_data)
Definition: pipe.h:42
@ MODEM_PIPE_EVENT_RECEIVE_READY
Definition: pipe.h:27
@ MODEM_PIPE_EVENT_OPENED
Definition: pipe.h:26
@ MODEM_PIPE_EVENT_TRANSMIT_IDLE
Definition: pipe.h:28
@ MODEM_PIPE_EVENT_CLOSED
Definition: pipe.h:29
int open(const char *name, int flags,...)
Public kernel APIs.
state
Definition: parser_state.h:29
__UINT8_TYPE__ uint8_t
Definition: stdint.h:88
Definition: kernel.h:3026
Mutex Structure.
Definition: kernel.h:2914