tinyproto
tiny_fd_frames_queue_int.h
1 /*
2  Copyright 2021-2024 (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 #ifndef DOXYGEN_SHOULD_SKIP_THIS
32 
33 #ifdef __cplusplus
34 extern "C"
35 {
36 #endif
37 
38 #include "tiny_fd_frames_int.h"
39 #include "hal/tiny_types.h"
40 #include <stdint.h>
41 #include <stdbool.h>
42 
43  typedef struct
44  {
46  int size;
48  int mtu;
50 
51  typedef struct
52  {
58  tiny_mutex_t mutex;
59 
61 
72  int tiny_fd_queue_init(tiny_fd_queue_t *queue, uint8_t *buffer,
73  int max_size, int max_frames, int mtu);
74 
78  void tiny_fd_queue_reset(tiny_fd_queue_t *queue);
79 
83  void tiny_fd_queue_reset_for(tiny_fd_queue_t *queue, uint8_t address);
84 
88  bool tiny_fd_queue_has_free_slots(tiny_fd_queue_t *queue);
89 
93  int tiny_fd_queue_get_mtu(tiny_fd_queue_t *queue);
94 
99  tiny_fd_frame_info_t *tiny_fd_queue_allocate(tiny_fd_queue_t *queue, uint8_t type, const uint8_t *data, int len);
100 
110  tiny_fd_frame_info_t *tiny_fd_queue_get_next(tiny_fd_queue_t *queue, uint8_t type, uint8_t address, uint8_t arg);
111 
118  void tiny_fd_queue_free(tiny_fd_queue_t *queue, tiny_fd_frame_info_t *frame);
119 
126  void tiny_fd_queue_free_by_header(tiny_fd_queue_t *queue, const void *header);
127 
128 #ifdef __cplusplus
129 }
130 #endif
131 
132 #endif
tiny_fd_queue_t i_queue
Storage for all I- frames.
Definition: tiny_fd_frames_queue_int.h:54
int mtu
Maximum supported payload size.
Definition: tiny_fd_frames_queue_int.h:48
Definition: tiny_fd_frames_int.h:56
This is Tiny HAL implementation for microcontrollers.
int lookup_index
First index to start search from.
Definition: tiny_fd_frames_queue_int.h:47
Definition: tiny_fd_frames_queue_int.h:51
int size
number of elements in the table
Definition: tiny_fd_frames_queue_int.h:46
Definition: tiny_fd_frames_queue_int.h:43
tiny_fd_queue_t s_queue
Storage for all S- and U- service frames.
Definition: tiny_fd_frames_queue_int.h:56
tiny_fd_frame_info_t ** frames
pointer to the frame table
Definition: tiny_fd_frames_queue_int.h:45
tiny_mutex_t mutex
Global mutex.
Definition: tiny_fd_frames_queue_int.h:58