tinyproto
tiny_fd_i_queue_control_int.h
1 /*
2  Copyright 2019-2025 (C) Alexey Dynda
3 
4  This file is part of Tiny Protocol Library.
5 
6  GNU General Public License Usage
7 
8  Protocol Library is free software: you can redistribute it and/or modify
9  it under the terms of the GNU Lesser General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  Protocol Library is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public License
19  along with Protocol Library. If not, see <http://www.gnu.org/licenses/>.
20 
21  Commercial License Usage
22 
23  Licensees holding valid commercial Tiny Protocol licenses may use this file in
24  accordance with the commercial license agreement provided in accordance with
25  the terms contained in a written agreement between you and Alexey Dynda.
26  For further information contact via email on github account.
27 */
28 
29 #pragma once
30 
31 #include "tiny_fd.h"
32 #include "tiny_fd_defines_int.h"
33 
34 #include <stdbool.h>
35 
36 typedef struct i_queue_control_send_t
37 {
38  uint8_t last_ns; // next free frame to send in cycle buffer
39  uint8_t confirm_ns; // next sent frame to be confirmed
40  uint8_t next_ns; // next frame to be sent
42 
43 typedef struct i_queue_control_t
44 {
45  struct i_queue_control_send_t tx_state;
47 
49 
50 static inline uint8_t __i_queue_control_get_next_frame_to_confirm(i_queue_control_t *control)
51 {
52  return control->tx_state.confirm_ns;
53 }
54 
56 
57 typedef bool (*on_frame_confirmed_cb_t)(void *ctx, uint8_t nr);
58 
59 bool __i_queue_control_confirm_sent_frames(i_queue_control_t *control, uint8_t nr, on_frame_confirmed_cb_t cb, void *ctx);
60 
62 
63 uint8_t __i_queue_control_get_next_frame_to_send(tiny_fd_handle_t handle, uint8_t peer);
64 
66 
67 void __i_queue_control_move_to_previous_ns(tiny_fd_handle_t handle, uint8_t peer);
68 
70 
71 void __i_queue_control_move_to_next_ns(tiny_fd_handle_t handle, uint8_t peer);
72 
74 
75 bool __i_queue_control_has_unconfirmed_frames(i_queue_control_t *control);
76 
78 
79 bool __all_frames_are_sent(tiny_fd_handle_t handle, uint8_t peer);
80 
82 
83 uint32_t __time_passed_since_last_sent_i_frame(tiny_fd_handle_t handle, uint8_t peer);
84 
86 
87 bool __can_accept_i_frames(i_queue_control_t *control);
88 
90 
91 bool __put_i_frame_to_tx_queue(tiny_fd_handle_t handle, uint8_t peer, const void *data, int len);
92 
94 
95 void __reset_i_queue_control(tiny_fd_handle_t handle, uint8_t peer);
96 
98 
99 void __i_queue_control_log_statistics(tiny_fd_handle_t handle, uint8_t peer, uint8_t is_full);
100 
Definition: tiny_fd_int.h:103
Definition: tiny_fd_i_queue_control_int.h:36
Definition: tiny_fd_i_queue_control_int.h:43
This is Tiny Full-Duplex protocol implementation for microcontrollers.