Liqun Wu / Mbed 2 deprecated 90418_mbed_controller

Dependencies:   mbed

Committer:
wuliqunyy
Date:
Mon Jan 17 13:20:09 2022 +0000
Revision:
0:be95bfb06686
a working non_flat + adc_didt for ehp regulation version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wuliqunyy 0:be95bfb06686 1 /*-
wuliqunyy 0:be95bfb06686 2 * BSD 2-Clause License
wuliqunyy 0:be95bfb06686 3 *
wuliqunyy 0:be95bfb06686 4 * Copyright (c) 2012-2018, Jan Breuer
wuliqunyy 0:be95bfb06686 5 * All rights reserved.
wuliqunyy 0:be95bfb06686 6 *
wuliqunyy 0:be95bfb06686 7 * Redistribution and use in source and binary forms, with or without
wuliqunyy 0:be95bfb06686 8 * modification, are permitted provided that the following conditions are met:
wuliqunyy 0:be95bfb06686 9 *
wuliqunyy 0:be95bfb06686 10 * * Redistributions of source code must retain the above copyright notice, this
wuliqunyy 0:be95bfb06686 11 * list of conditions and the following disclaimer.
wuliqunyy 0:be95bfb06686 12 *
wuliqunyy 0:be95bfb06686 13 * * Redistributions in binary form must reproduce the above copyright notice,
wuliqunyy 0:be95bfb06686 14 * this list of conditions and the following disclaimer in the documentation
wuliqunyy 0:be95bfb06686 15 * and/or other materials provided with the distribution.
wuliqunyy 0:be95bfb06686 16 *
wuliqunyy 0:be95bfb06686 17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
wuliqunyy 0:be95bfb06686 18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
wuliqunyy 0:be95bfb06686 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
wuliqunyy 0:be95bfb06686 20 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
wuliqunyy 0:be95bfb06686 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
wuliqunyy 0:be95bfb06686 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
wuliqunyy 0:be95bfb06686 23 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
wuliqunyy 0:be95bfb06686 24 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
wuliqunyy 0:be95bfb06686 25 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
wuliqunyy 0:be95bfb06686 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
wuliqunyy 0:be95bfb06686 27 */
wuliqunyy 0:be95bfb06686 28
wuliqunyy 0:be95bfb06686 29 /**
wuliqunyy 0:be95bfb06686 30 * @file scpi_utils.h
wuliqunyy 0:be95bfb06686 31 * @date Thu Nov 15 10:58:45 UTC 2012
wuliqunyy 0:be95bfb06686 32 *
wuliqunyy 0:be95bfb06686 33 * @brief Conversion routines and string manipulation routines
wuliqunyy 0:be95bfb06686 34 *
wuliqunyy 0:be95bfb06686 35 *
wuliqunyy 0:be95bfb06686 36 */
wuliqunyy 0:be95bfb06686 37
wuliqunyy 0:be95bfb06686 38 #ifndef SCPI_UTILS_PRIVATE_H
wuliqunyy 0:be95bfb06686 39 #define SCPI_UTILS_PRIVATE_H
wuliqunyy 0:be95bfb06686 40
wuliqunyy 0:be95bfb06686 41 #include <stdint.h>
wuliqunyy 0:be95bfb06686 42 #include "scpi/config.h"
wuliqunyy 0:be95bfb06686 43 #include "scpi/types.h"
wuliqunyy 0:be95bfb06686 44
wuliqunyy 0:be95bfb06686 45 #ifdef __cplusplus
wuliqunyy 0:be95bfb06686 46 extern "C" {
wuliqunyy 0:be95bfb06686 47 #endif
wuliqunyy 0:be95bfb06686 48
wuliqunyy 0:be95bfb06686 49 #if defined(__GNUC__) && (__GNUC__ >= 4)
wuliqunyy 0:be95bfb06686 50 #define LOCAL __attribute__((visibility ("hidden")))
wuliqunyy 0:be95bfb06686 51 #else
wuliqunyy 0:be95bfb06686 52 #define LOCAL
wuliqunyy 0:be95bfb06686 53 #endif
wuliqunyy 0:be95bfb06686 54
wuliqunyy 0:be95bfb06686 55 char * strnpbrk(const char *str, size_t size, const char *set) LOCAL;
wuliqunyy 0:be95bfb06686 56 scpi_bool_t compareStr(const char * str1, size_t len1, const char * str2, size_t len2) LOCAL;
wuliqunyy 0:be95bfb06686 57 scpi_bool_t compareStrAndNum(const char * str1, size_t len1, const char * str2, size_t len2, int32_t * num) LOCAL;
wuliqunyy 0:be95bfb06686 58 size_t UInt32ToStrBaseSign(uint32_t val, char * str, size_t len, int8_t base, scpi_bool_t sign) LOCAL;
wuliqunyy 0:be95bfb06686 59 size_t UInt64ToStrBaseSign(uint64_t val, char * str, size_t len, int8_t base, scpi_bool_t sign) LOCAL;
wuliqunyy 0:be95bfb06686 60 size_t strBaseToInt32(const char * str, int32_t * val, int8_t base) LOCAL;
wuliqunyy 0:be95bfb06686 61 size_t strBaseToUInt32(const char * str, uint32_t * val, int8_t base) LOCAL;
wuliqunyy 0:be95bfb06686 62 size_t strBaseToInt64(const char * str, int64_t * val, int8_t base) LOCAL;
wuliqunyy 0:be95bfb06686 63 size_t strBaseToUInt64(const char * str, uint64_t * val, int8_t base) LOCAL;
wuliqunyy 0:be95bfb06686 64 size_t strToFloat(const char * str, float * val) LOCAL;
wuliqunyy 0:be95bfb06686 65 size_t strToDouble(const char * str, double * val) LOCAL;
wuliqunyy 0:be95bfb06686 66 scpi_bool_t locateText(const char * str1, size_t len1, const char ** str2, size_t * len2) LOCAL;
wuliqunyy 0:be95bfb06686 67 scpi_bool_t locateStr(const char * str1, size_t len1, const char ** str2, size_t * len2) LOCAL;
wuliqunyy 0:be95bfb06686 68 size_t skipWhitespace(const char * cmd, size_t len) LOCAL;
wuliqunyy 0:be95bfb06686 69 scpi_bool_t matchPattern(const char * pattern, size_t pattern_len, const char * str, size_t str_len, int32_t * num) LOCAL;
wuliqunyy 0:be95bfb06686 70 scpi_bool_t matchCommand(const char * pattern, const char * cmd, size_t len, int32_t *numbers, size_t numbers_len, int32_t default_value) LOCAL;
wuliqunyy 0:be95bfb06686 71 scpi_bool_t composeCompoundCommand(const scpi_token_t * prev, scpi_token_t * current) LOCAL;
wuliqunyy 0:be95bfb06686 72
wuliqunyy 0:be95bfb06686 73 #define SCPI_DTOSTRE_UPPERCASE 1
wuliqunyy 0:be95bfb06686 74 #define SCPI_DTOSTRE_ALWAYS_SIGN 2
wuliqunyy 0:be95bfb06686 75 #define SCPI_DTOSTRE_PLUS_SIGN 4
wuliqunyy 0:be95bfb06686 76 char * SCPI_dtostre(double __val, char * __s, size_t __ssize, unsigned char __prec, unsigned char __flags);
wuliqunyy 0:be95bfb06686 77
wuliqunyy 0:be95bfb06686 78 scpi_array_format_t SCPI_GetNativeFormat(void);
wuliqunyy 0:be95bfb06686 79 uint16_t SCPI_Swap16(uint16_t val);
wuliqunyy 0:be95bfb06686 80 uint32_t SCPI_Swap32(uint32_t val);
wuliqunyy 0:be95bfb06686 81 uint64_t SCPI_Swap64(uint64_t val);
wuliqunyy 0:be95bfb06686 82
wuliqunyy 0:be95bfb06686 83 #if !HAVE_STRNLEN
wuliqunyy 0:be95bfb06686 84 size_t BSD_strnlen(const char *s, size_t maxlen) LOCAL;
wuliqunyy 0:be95bfb06686 85 #endif
wuliqunyy 0:be95bfb06686 86
wuliqunyy 0:be95bfb06686 87 #if !HAVE_STRNCASECMP && !HAVE_STRNICMP
wuliqunyy 0:be95bfb06686 88 int OUR_strncasecmp(const char *s1, const char *s2, size_t n) LOCAL;
wuliqunyy 0:be95bfb06686 89 #endif
wuliqunyy 0:be95bfb06686 90
wuliqunyy 0:be95bfb06686 91 #if USE_DEVICE_DEPENDENT_ERROR_INFORMATION && !USE_MEMORY_ALLOCATION_FREE
wuliqunyy 0:be95bfb06686 92 void scpiheap_init(scpi_error_info_heap_t * heap, char * error_info_heap, size_t error_info_heap_length);
wuliqunyy 0:be95bfb06686 93 char * scpiheap_strndup(scpi_error_info_heap_t * heap, const char *s, size_t n) LOCAL;
wuliqunyy 0:be95bfb06686 94 void scpiheap_free(scpi_error_info_heap_t * heap, char *s, scpi_bool_t rollback) LOCAL;
wuliqunyy 0:be95bfb06686 95 scpi_bool_t scpiheap_get_parts(scpi_error_info_heap_t * heap, const char *s1, size_t * len1, const char ** s2, size_t * len2) LOCAL;
wuliqunyy 0:be95bfb06686 96 #endif
wuliqunyy 0:be95bfb06686 97
wuliqunyy 0:be95bfb06686 98 #if !HAVE_STRNDUP
wuliqunyy 0:be95bfb06686 99 char *OUR_strndup(const char *s, size_t n);
wuliqunyy 0:be95bfb06686 100 #endif
wuliqunyy 0:be95bfb06686 101
wuliqunyy 0:be95bfb06686 102 #ifndef min
wuliqunyy 0:be95bfb06686 103 #define min(a, b) (((a) < (b)) ? (a) : (b))
wuliqunyy 0:be95bfb06686 104 #endif
wuliqunyy 0:be95bfb06686 105
wuliqunyy 0:be95bfb06686 106 #ifndef max
wuliqunyy 0:be95bfb06686 107 #define max(a, b) (((a) > (b)) ? (a) : (b))
wuliqunyy 0:be95bfb06686 108 #endif
wuliqunyy 0:be95bfb06686 109
wuliqunyy 0:be95bfb06686 110 #if 0
wuliqunyy 0:be95bfb06686 111 #define max(a,b) \
wuliqunyy 0:be95bfb06686 112 ({ __typeof__ (a) _a = (a); \
wuliqunyy 0:be95bfb06686 113 __typeof__ (b) _b = (b); \
wuliqunyy 0:be95bfb06686 114 _a > _b ? _a : _b; })
wuliqunyy 0:be95bfb06686 115
wuliqunyy 0:be95bfb06686 116 #define min(a,b) \
wuliqunyy 0:be95bfb06686 117 ({ __typeof__ (a) _a = (a); \
wuliqunyy 0:be95bfb06686 118 __typeof__ (b) _b = (b); \
wuliqunyy 0:be95bfb06686 119 _a < _b ? _a : _b; })
wuliqunyy 0:be95bfb06686 120
wuliqunyy 0:be95bfb06686 121 #endif
wuliqunyy 0:be95bfb06686 122
wuliqunyy 0:be95bfb06686 123 #ifdef __cplusplus
wuliqunyy 0:be95bfb06686 124 }
wuliqunyy 0:be95bfb06686 125 #endif
wuliqunyy 0:be95bfb06686 126
wuliqunyy 0:be95bfb06686 127 #endif /* SCPI_UTILS_PRIVATE_H */
wuliqunyy 0:be95bfb06686 128
wuliqunyy 0:be95bfb06686 129