Zephyr API 3.6.99
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 const 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, const struct modem_pipe_api *api);
81
99int modem_pipe_open(struct modem_pipe *pipe, k_timeout_t timeout);
100
112int modem_pipe_open_async(struct modem_pipe *pipe);
113
124void modem_pipe_attach(struct modem_pipe *pipe, modem_pipe_api_callback callback, void *user_data);
125
139int modem_pipe_transmit(struct modem_pipe *pipe, const uint8_t *buf, size_t size);
140
154int modem_pipe_receive(struct modem_pipe *pipe, uint8_t *buf, size_t size);
155
161void modem_pipe_release(struct modem_pipe *pipe);
162
176int modem_pipe_close(struct modem_pipe *pipe, k_timeout_t timeout);
177
189int modem_pipe_close_async(struct modem_pipe *pipe);
190
202void modem_pipe_notify_opened(struct modem_pipe *pipe);
203
211void modem_pipe_notify_closed(struct modem_pipe *pipe);
212
220void modem_pipe_notify_receive_ready(struct modem_pipe *pipe);
221
229void modem_pipe_notify_transmit_idle(struct modem_pipe *pipe);
230
239#ifdef __cplusplus
240}
241#endif
242
243#endif /* ZEPHYR_MODEM_PIPE_ */
int open(const char *name, int flags,...)
static int close(int sock)
POSIX wrapper for zsock_close.
Definition socket.h:828
int modem_pipe_open_async(struct modem_pipe *pipe)
Open pipe asynchronously.
int modem_pipe_close(struct modem_pipe *pipe, k_timeout_t timeout)
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_open(struct modem_pipe *pipe, k_timeout_t timeout)
Open 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.
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:2301
Kernel Spin Lock.
Definition spinlock.h:45
Kernel timeout type.
Definition sys_clock.h:65