tinyproto
no_platform_hal.h
1 /*
2  Copyright 2016-2022 (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 <stdint.h>
32 
33 /* For fastest version of protocol assign all defines to zero.
34  * In this case protocol supports no CRC field, and
35  * all api functions become not thread-safe.
36  */
37 
38 #ifndef CONFIG_ENABLE_CHECKSUM
39 #define CONFIG_ENABLE_CHECKSUM
40 #endif
41 
42 #ifndef CONFIG_ENABLE_FCS16
43 #define CONFIG_ENABLE_FCS16
44 #endif
45 
46 #ifndef CONFIG_ENABLE_FCS32
47 #define CONFIG_ENABLE_FCS32
48 #endif
49 
54 typedef uintptr_t tiny_mutex_t;
55 
60 typedef struct
61 {
63  tiny_mutex_t mutex;
65  uint8_t bits;
67 
71 typedef struct
72 {
74  void (*mutex_create)(tiny_mutex_t *mutex);
75 
77  void (*mutex_destroy)(tiny_mutex_t *mutex);
78 
80  uint8_t (*mutex_try_lock)(tiny_mutex_t *mutex);
81 
83  void (*mutex_unlock)(tiny_mutex_t *mutex);
84 
89  void (*mutex_lock)(tiny_mutex_t *mutex);
90 
92  void (*events_create)(tiny_events_t *events);
93 
95  void (*events_destroy)(tiny_events_t *events);
96 
101  uint8_t (*events_wait)(tiny_events_t *events, uint8_t bits, uint8_t clear, uint32_t timeout);
102 
104  uint8_t (*events_check_int)(tiny_events_t *events, uint8_t bits, uint8_t clear);
105 
107  void (*events_set)(tiny_events_t *events, uint8_t bits);
108 
110  void (*events_clear)(tiny_events_t *events, uint8_t bits);
111 
113  void (*sleep)(uint32_t ms);
114 
116  uint32_t (*millis)(void);
117 
119  void (*sleep_us)(uint32_t us);
120 
122  uint32_t (*micros)(void);
124 
129 extern void tiny_hal_init(tiny_platform_hal_t *hal);
Structure of HAL abstraction layer.
Definition: no_platform_hal.h:71
Events group type used by Tiny Protocol implementation.
Definition: cpp_hal.h:60