Zephyr Project API 3.7.0
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
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
64struct modem_pipe {
65 void *data;
66 struct modem_pipe_api *api;
68 void *user_data;
69 struct k_spinlock spinlock;
70 struct k_event event;
71};
72
80void modem_pipe_init(struct modem_pipe *pipe, void *data, struct modem_pipe_api *api);
81
98int modem_pipe_open(struct modem_pipe *pipe);
99
111int modem_pipe_open_async(struct modem_pipe *pipe);
112
123void modem_pipe_attach(struct modem_pipe *pipe, modem_pipe_api_callback callback, void *user_data);
124
138int modem_pipe_transmit(struct modem_pipe *pipe, const uint8_t *buf, size_t size);
139
153int modem_pipe_receive(struct modem_pipe *pipe, uint8_t *buf, size_t size);
154
160void modem_pipe_release(struct modem_pipe *pipe);
161
174int modem_pipe_close(struct modem_pipe *pipe);
175
187int modem_pipe_close_async(struct modem_pipe *pipe);
188
200void modem_pipe_notify_opened(struct modem_pipe *pipe);
201
209void modem_pipe_notify_closed(struct modem_pipe *pipe);
210
218void modem_pipe_notify_receive_ready(struct modem_pipe *pipe);
219
227void modem_pipe_notify_transmit_idle(struct modem_pipe *pipe);
228
237#ifdef __cplusplus
238}
239#endif
240
241#endif /* ZEPHYR_MODEM_PIPE_ */
int open(const char *name, int flags,...)
static int close(int sock)
POSIX wrapper for zsock_close.
Definition socket.h:879
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
Public kernel APIs.
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
Event Structure.
Definition kernel.h:2224
Kernel Spin Lock.
Definition spinlock.h:45
static fdata_t data[2]
Definition test_fifo_contexts.c:15
static struct k_pipe pipe
Definition test_mutex_error.c:18
static const intptr_t user_data[5]
Definition main.c:588