Line data Source code
1 : /* Copyright 2017 noseglasses <shinynoseglasses@gmail.com>
2 : *
3 : * This program is free software: you can redistribute it and/or modify
4 : * it under the terms of the GNU Lesser General Public License as published by
5 : * the Free Software Foundation, either version 3 of the License, or
6 : * (at your option) any later version.
7 : *
8 : * This program is distributed in the hope that it will be useful,
9 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 : * GNU Lesser General Public License for more details.
12 : *
13 : * You should have received a copy of the GNU Lesser General Public License
14 : * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 : */
16 :
17 : #ifndef PPG_TYPES_H
18 : #define PPG_TYPES_H
19 :
20 : /** @file */
21 :
22 : #include "stdint.h"
23 :
24 : // The maximum number of events that can be stored
25 : //
26 : /** @brief The maximum lenght of a sequence of events that can represent a pattern.
27 : */
28 : #define PPG_MAX_EVENTS 100
29 :
30 : /** @brief The maximum number of inputs that can be used continuously.
31 : *
32 : * Please be careful when increasing this number, as memory
33 : * is allocated for the number of inputs. Also larger interger
34 : * data types must be used in some places when this value exceeds 256.
35 : */
36 : #define PPG_MAX_INPUTS 255
37 :
38 : /** @brief The maximum number of tokens that can wait for
39 : * further events to arrive
40 : */
41 : #define PPG_MAX_ACTIVE_TOKENS 255
42 :
43 : /** @brief An unsigned integer type that is used to store
44 : * small numbers
45 : */
46 : #define PPG_SMALL_UNSIGNED_INT_TYPE uint8_t
47 :
48 : /** @brief A signed integer type that is used to store
49 : * small numbers
50 : */
51 : #define PPG_SMALL_SIGNED_INT_TYPE int8_t
52 :
53 : /** @brief A signed integer type that is used to store
54 : * larger numbers
55 : */
56 : #define PPG_MEDIUM_SIGNED_INT_TYPE int16_t
57 :
58 : /** @brief This macro enables to define the count type from outside the
59 : * compile process, e.g. from a build system
60 : */
61 : #define PPG_COUNT_TYPE uint8_t
62 :
63 : /** @brief An integer type that is generally used to count entities and as loop counter
64 : */
65 : typedef PPG_COUNT_TYPE PPG_Count;
66 :
67 : /** @brief This macro enables to define the id type from outside the
68 : * compile process, e.g. from a build system
69 : */
70 : #define PPG_ID_TYPE int16_t
71 :
72 : /** @brief An integer type that is used whenever a signed id is used to code non zero initial state as error
73 : */
74 : typedef PPG_ID_TYPE PPG_Id;
75 :
76 : /** @brief This macro enables to define the action flags type from outside the
77 : * compile process, e.g. from a build system
78 : */
79 : #define PPG_ACTION_FLAGS_TYPE uint8_t
80 :
81 : /** @brief The data type used to store action flags
82 : */
83 : typedef PPG_ACTION_FLAGS_TYPE PPG_Action_Flags_Type;
84 :
85 : /** @brief This macro enables to define the layer type from outside the
86 : * compile process, e.g. from a build system
87 : */
88 : #define PPG_LAYER_TYPE int8_t
89 :
90 : /** The data type that is used to reference layers
91 : */
92 : typedef PPG_LAYER_TYPE PPG_Layer;
93 :
94 : /** @brief This macro enables to define the signal id type from outside the
95 : * compile process, e.g. from a build system
96 : */
97 : #define PPG_SLOT_ID_TYPE uint8_t
98 :
99 : /** @brief The data type used to identify signals
100 : */
101 : typedef PPG_SLOT_ID_TYPE PPG_Signal_Id;
102 :
103 : /** @brief This macro enables to define the time comparison result type from outside the
104 : * compile process, e.g. from a build system
105 : */
106 : #define PPG_TIME_COMPARISON_RESULT_TYPE int8_t
107 :
108 : /** @brief The signed integer type used to code the result of the time comparison function
109 : */
110 : typedef PPG_TIME_COMPARISON_RESULT_TYPE PPG_Time_Comparison_Result_Type;
111 :
112 : /** @brief This macro enables to define the event buffer index type from outside the
113 : * compile process, e.g. from a build system
114 : */
115 : #define PPG_EVENT_BUFFER_INDEX_TYPE int8_t
116 :
117 : /** @brief The signed data type that is used to index events
118 : */
119 : typedef PPG_SMALL_SIGNED_INT_TYPE PPG_Event_Buffer_Index_Type;
120 :
121 : /** @brief This macro enables to define the processing state flag type from outside the
122 : * compile process, e.g. from a build system
123 : */
124 : #define PPG_PROCESSING_STATE_TYPE uint8_t
125 :
126 : /** @brief The data type used for processing states
127 : */
128 : typedef PPG_PROCESSING_STATE_TYPE PPG_Processing_State;
129 :
130 : /** @brief This macro enables to define the time identifier type from outside the
131 : * compile process, e.g. from a build system
132 : */
133 : #define PPG_TIME_IDENTIFIER_TYPE long unsigned
134 :
135 : /** @brief Time identifier type.
136 : */
137 : typedef PPG_TIME_IDENTIFIER_TYPE PPG_Time;
138 :
139 : #define PPG_PRINT_SELF_ENABLED 1
140 :
141 : #define PPG_HAVE_ASSERTIONS 1
142 :
143 : #define PPG_DISABLE_CONTEXT_SWITCHING 0
144 :
145 : #define PPG_HAVE_STATISTICS 0
146 :
147 : #define PPG_HAVE_LOGGING 1
148 :
149 : #define PPG_HAVE_DEBUGGING 1
150 :
151 : #if PPG_PRINT_SELF_ENABLED
152 :
153 : #include <stdio.h>
154 :
155 : inline
156 37820 : static void ppg_indent(int tabs)
157 : {
158 124024 : for(int i = 0; i < tabs; ++i) {
159 86204 : printf("\t");
160 : }
161 37820 : }
162 :
163 : #define PPG_I ppg_indent(indent);
164 :
165 : #endif
166 :
167 : #endif
|