PS_Fgen_FW
4da88f4073c1cc65ea45c3a652a2751e495e50db
Firmware for an Power Supply and Function Generator build from an ATX power supply
Loading...
Searching...
No Matches
config.h
Go to the documentation of this file.
1
/*-
2
* BSD 2-Clause License
3
*
4
* Copyright (c) 2012-2018, Jan Breuer
5
* All rights reserved.
6
*
7
* Redistribution and use in source and binary forms, with or without
8
* modification, are permitted provided that the following conditions are met:
9
*
10
* * Redistributions of source code must retain the above copyright notice, this
11
* list of conditions and the following disclaimer.
12
*
13
* * Redistributions in binary form must reproduce the above copyright notice,
14
* this list of conditions and the following disclaimer in the documentation
15
* and/or other materials provided with the distribution.
16
*
17
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
*/
28
37
38
#ifndef __SCPI_CONFIG_H_
39
#define __SCPI_CONFIG_H_
40
41
#ifdef __cplusplus
42
extern
"C"
{
43
#endif
44
45
#include "
cc.h
"
46
47
#ifdef SCPI_USER_CONFIG
48
#include "scpi_user_config.h"
49
#endif
50
51
/* set the termination character(s) */
52
#define LINE_ENDING_CR "\r"
/* use a <CR> carriage return as termination charcter */
53
#define LINE_ENDING_LF "\n"
/* use a <LF> line feed as termination charcter */
54
#define LINE_ENDING_CRLF "\r\n"
/* use <CR><LF> carriage return + line feed as termination charcters */
55
56
#ifndef SCPI_LINE_ENDING
57
#define SCPI_LINE_ENDING LINE_ENDING_CRLF
58
#endif
59
64
#define SYSTEM_BARE_METAL 0
65
#define SYSTEM_FULL_BLOWN 1
66
67
/* This should cover all windows compilers (msvc, mingw, cvi) and all Linux/OSX/BSD and other UNIX compatible systems (gcc, clang) */
68
#if defined(_WIN32) || defined(_WIN64) || defined(__unix) || defined(__unix__) || defined(__APPLE__)
69
#define SYSTEM_TYPE SYSTEM_FULL_BLOWN
70
#else
71
#define SYSTEM_TYPE SYSTEM_BARE_METAL
72
#endif
73
82
#ifndef USE_FULL_ERROR_LIST
83
#define USE_FULL_ERROR_LIST SYSTEM_TYPE
84
#endif
85
91
#ifndef USE_USER_ERROR_LIST
92
#define USE_USER_ERROR_LIST 0
93
#endif
94
95
#ifndef USE_DEVICE_DEPENDENT_ERROR_INFORMATION
96
#define USE_DEVICE_DEPENDENT_ERROR_INFORMATION SYSTEM_TYPE
97
#endif
98
99
#if USE_DEVICE_DEPENDENT_ERROR_INFORMATION
100
#ifndef USE_MEMORY_ALLOCATION_FREE
101
#define USE_MEMORY_ALLOCATION_FREE 1
102
#endif
103
#else
104
#ifndef USE_MEMORY_ALLOCATION_FREE
105
#define USE_MEMORY_ALLOCATION_FREE 0
106
#endif
107
#endif
108
109
#ifndef USE_COMMAND_TAGS
110
#define USE_COMMAND_TAGS 1
111
#endif
112
113
#ifndef USE_DEPRECATED_FUNCTIONS
114
#define USE_DEPRECATED_FUNCTIONS 0
115
#endif
116
117
#ifndef USE_CUSTOM_DTOSTRE
118
#define USE_CUSTOM_DTOSTRE 0
119
#endif
120
121
#ifndef USE_UNITS_IMPERIAL
122
#define USE_UNITS_IMPERIAL 0
123
#endif
124
125
#ifndef USE_UNITS_ANGLE
126
#define USE_UNITS_ANGLE SYSTEM_TYPE
127
#endif
128
129
#ifndef USE_UNITS_PARTICLES
130
#define USE_UNITS_PARTICLES SYSTEM_TYPE
131
#endif
132
133
#ifndef USE_UNITS_DISTANCE
134
#define USE_UNITS_DISTANCE SYSTEM_TYPE
135
#endif
136
137
#ifndef USE_UNITS_MAGNETIC
138
#define USE_UNITS_MAGNETIC SYSTEM_TYPE
139
#endif
140
141
#ifndef USE_UNITS_LIGHT
142
#define USE_UNITS_LIGHT SYSTEM_TYPE
143
#endif
144
145
#ifndef USE_UNITS_ENERGY_FORCE_MASS
146
#define USE_UNITS_ENERGY_FORCE_MASS SYSTEM_TYPE
147
#endif
148
149
#ifndef USE_UNITS_TIME
150
#define USE_UNITS_TIME 1
151
#endif
152
153
#ifndef USE_UNITS_TEMPERATURE
154
#define USE_UNITS_TEMPERATURE SYSTEM_TYPE
155
#endif
156
157
#ifndef USE_UNITS_RATIO
158
#define USE_UNITS_RATIO SYSTEM_TYPE
159
#endif
160
161
#ifndef USE_UNITS_POWER
162
#define USE_UNITS_POWER 1
163
#endif
164
165
#ifndef USE_UNITS_FREQUENCY
166
#define USE_UNITS_FREQUENCY 1
167
#endif
168
169
#ifndef USE_UNITS_ELECTRIC
170
#define USE_UNITS_ELECTRIC 1
171
#endif
172
173
#ifndef USE_UNITS_ELECTRIC_CHARGE_CONDUCTANCE
174
#define USE_UNITS_ELECTRIC_CHARGE_CONDUCTANCE SYSTEM_TYPE
175
#endif
176
177
/* define local macros depending on existance of strnlen */
178
#if HAVE_STRNLEN
179
#define SCPIDEFINE_strnlen(s, l) strnlen((s), (l))
180
#else
181
#define SCPIDEFINE_strnlen(s, l) BSD_strnlen((s), (l))
182
#endif
183
184
/* define local macros depending on existance of strncasecmp and strnicmp */
185
#if HAVE_STRNCASECMP
186
#define SCPIDEFINE_strncasecmp(s1, s2, l) strncasecmp((s1), (s2), (l))
187
#elif HAVE_STRNICMP
188
#define SCPIDEFINE_strncasecmp(s1, s2, l) strnicmp((s1), (s2), (l))
189
#else
190
#define SCPIDEFINE_strncasecmp(s1, s2, l) OUR_strncasecmp((s1), (s2), (l))
191
#endif
192
193
#if HAVE_DTOSTRE
194
#define SCPIDEFINE_floatToStr(v, s, l) dtostre((double)(v), (s), 6, DTOSTR_PLUS_SIGN | DTOSTR_ALWAYS_SIGN | DTOSTR_UPPERCASE)
195
#elif USE_CUSTOM_DTOSTRE
196
#define SCPIDEFINE_floatToStr(v, s, l) SCPI_dtostre((v), (s), (l), 6, 0)
197
#elif HAVE_SNPRINTF
198
#define SCPIDEFINE_floatToStr(v, s, l) snprintf((s), (l), "%g", (v))
199
#else
200
#define SCPIDEFINE_floatToStr(v, s, l) SCPI_dtostre((v), (s), (l), 6, 0)
201
#endif
202
203
#if HAVE_DTOSTRE
204
#define SCPIDEFINE_doubleToStr(v, s, l) dtostre((v), (s), 15, DTOSTR_PLUS_SIGN | DTOSTR_ALWAYS_SIGN | DTOSTR_UPPERCASE)
205
#elif USE_CUSTOM_DTOSTRE
206
#define SCPIDEFINE_doubleToStr(v, s, l) SCPI_dtostre((v), (s), (l), 15, 0)
207
#elif HAVE_SNPRINTF
208
#define SCPIDEFINE_doubleToStr(v, s, l) snprintf((s), (l), "%.15lg", (v))
209
#else
210
#define SCPIDEFINE_doubleToStr(v, s, l) SCPI_dtostre((v), (s), (l), 15, 0)
211
#endif
212
213
#if USE_DEVICE_DEPENDENT_ERROR_INFORMATION
214
215
#if USE_MEMORY_ALLOCATION_FREE
216
#include <stdlib.h>
217
#include <string.h>
218
#define SCPIDEFINE_DESCRIPTION_MAX_PARTS 2
219
#if HAVE_STRNDUP
220
#define SCPIDEFINE_strndup(h, s, l) strndup((s), (l))
221
#else
222
#define SCPIDEFINE_strndup(h, s, l) OUR_strndup((s), (l))
223
#endif
224
#define SCPIDEFINE_free(h, s, r) free((s))
225
#else
226
#define SCPIDEFINE_DESCRIPTION_MAX_PARTS 3
227
#define SCPIDEFINE_strndup(h, s, l) scpiheap_strndup((h), (s), (l))
228
#define SCPIDEFINE_free(h, s, r) scpiheap_free((h), (s), (r))
229
#define SCPIDEFINE_get_parts(h, s, l1, s2, l2) scpiheap_get_parts((h), (s), (l1), (s2), (l2))
230
#endif
231
#else
232
#define SCPIDEFINE_DESCRIPTION_MAX_PARTS 1
233
#define SCPIDEFINE_strndup(h, s, l) NULL
234
#define SCPIDEFINE_free(h, s, r)
235
#endif
236
237
#if HAVE_SIGNBIT
238
#define SCPIDEFINE_signbit(n) signbit(n)
239
#else
240
#define SCPIDEFINE_signbit(n) ((n)<0)
241
#endif
242
243
#if HAVE_FINITE
244
#define SCPIDEFINE_isfinite(n) finite(n)
245
#elif HAVE_ISFINITE
246
#define SCPIDEFINE_isfinite(n) isfinite(n)
247
#else
248
#define SCPIDEFINE_isfinite(n) (!SCPIDEFINE_isnan((n)) && ((n) < INFINITY) && ((n) > -INFINITY))
249
#endif
250
251
#if HAVE_STRTOF
252
#define SCPIDEFINE_strtof(n, p) strtof((n), (p))
253
#else
254
#define SCPIDEFINE_strtof(n, p) strtod((n), (p))
255
#endif
256
257
#if HAVE_STRTOLL
258
#define SCPIDEFINE_strtoll(n, p, b) strtoll((n), (p), (b))
259
#define SCPIDEFINE_strtoull(n, p, b) strtoull((n), (p), (b))
260
#else
261
#define SCPIDEFINE_strtoll(n, p, b) strtoll((n), (p), (b))
262
#define SCPIDEFINE_strtoull(n, p, b) strtoull((n), (p), (b))
263
extern
long
long
int
strtoll(
const
char
*nptr,
char
**endptr,
int
base);
264
extern
unsigned
long
long
int
strtoull(
const
char
*nptr,
char
**endptr,
int
base);
265
/* TODO: implement OUR_strtoll and OUR_strtoull */
266
/* #warning "64bit string to int conversion not implemented" */
267
#endif
268
269
#if HAVE_ISNAN
270
#define SCPIDEFINE_isnan(n) isnan((n))
271
#else
272
#define SCPIDEFINE_isnan(n) ((n) != (n))
273
#endif
274
275
#ifndef NAN
276
#define NAN (0.0 / 0.0)
277
#endif
278
279
#ifndef INFINITY
280
#define INFINITY (1.0 / 0.0)
281
#endif
282
283
#ifdef __cplusplus
284
}
285
#endif
286
287
#endif
cc.h
compiler detection
PS_Fgen_FW
libraries
scpi-parser
inc
scpi
config.h
Generated on Mon Jan 20 2025 17:33:36 for PS_Fgen_FW by
1.13.2