1520 lines
64 KiB
C
1520 lines
64 KiB
C
/* ###################################################################
|
|
** This component module is generated by Processor Expert. Do not modify it.
|
|
** Filename : McuUtility.h
|
|
** Project : FRDM-K64F_Generator
|
|
** Processor : MK64FN1M0VLL12
|
|
** Component : Utility
|
|
** Version : Component 01.172, Driver 01.00, CPU db: 3.00.000
|
|
** Compiler : GNU C Compiler
|
|
** Date/Time : 2024-07-09, 10:10, # CodeGen: 829
|
|
** Abstract :
|
|
** Contains various utility functions.
|
|
** Settings :
|
|
** Component name : McuUtility
|
|
** Contents :
|
|
** SkipSpaces - void McuUtility_SkipSpaces(const unsigned char **str);
|
|
** strcpy - void McuUtility_strcpy(uint8_t *dst, size_t dstSize, const unsigned char *src);
|
|
** strcat - void McuUtility_strcat(uint8_t *dst, size_t dstSize, const unsigned char *src);
|
|
** strcatPad - void McuUtility_strcatPad(uint8_t *dst, size_t dstSize, const unsigned char...
|
|
** chcat - void McuUtility_chcat(uint8_t *dst, size_t dstSize, uint8_t ch);
|
|
** Num8sToStr - void McuUtility_Num8sToStr(uint8_t *dst, size_t dstSize, signed char val);
|
|
** Num8uToStr - void McuUtility_Num8uToStr(uint8_t *dst, size_t dstSize, uint8_t val);
|
|
** Num16sToStr - void McuUtility_Num16sToStr(uint8_t *dst, size_t dstSize, int16_t val);
|
|
** Num16uToStr - void McuUtility_Num16uToStr(uint8_t *dst, size_t dstSize, uint16_t val);
|
|
** Num32uToStr - void McuUtility_Num32uToStr(uint8_t *dst, size_t dstSize, uint32_t val);
|
|
** Num32sToStr - void McuUtility_Num32sToStr(uint8_t *dst, size_t dstSize, int32_t val);
|
|
** NumFloatToStr - void McuUtility_NumFloatToStr(uint8_t *dst, size_t dstSize, float val,...
|
|
** Num16sToStrFormatted - void McuUtility_Num16sToStrFormatted(uint8_t *dst, size_t dstSize, int16_t...
|
|
** Num16uToStrFormatted - void McuUtility_Num16uToStrFormatted(uint8_t *dst, size_t dstSize, uint16_t...
|
|
** Num32uToStrFormatted - void McuUtility_Num32uToStrFormatted(uint8_t *dst, size_t dstSize, uint32_t...
|
|
** Num32sToStrFormatted - void McuUtility_Num32sToStrFormatted(uint8_t *dst, size_t dstSize, int32_t...
|
|
** strcatNum8u - void McuUtility_strcatNum8u(uint8_t *dst, size_t dstSize, uint8_t val);
|
|
** strcatNum8s - void McuUtility_strcatNum8s(uint8_t *dst, size_t dstSize, signed char val);
|
|
** strcatNum16u - void McuUtility_strcatNum16u(uint8_t *dst, size_t dstSize, uint16_t val);
|
|
** strcatNum16s - void McuUtility_strcatNum16s(uint8_t *dst, size_t dstSize, int16_t val);
|
|
** strcatNum32u - void McuUtility_strcatNum32u(uint8_t *dst, size_t dstSize, uint32_t val);
|
|
** strcatNum32s - void McuUtility_strcatNum32s(uint8_t *dst, size_t dstSize, int32_t val);
|
|
** strcatNum16uFormatted - void McuUtility_strcatNum16uFormatted(uint8_t *dst, size_t dstSize, uint16_t...
|
|
** strcatNum16sFormatted - void McuUtility_strcatNum16sFormatted(uint8_t *dst, size_t dstSize, int16_t...
|
|
** strcatNum32uFormatted - void McuUtility_strcatNum32uFormatted(uint8_t *dst, size_t dstSize, uint32_t...
|
|
** strcatNum32sFormatted - void McuUtility_strcatNum32sFormatted(uint8_t *dst, size_t dstSize, int32_t...
|
|
** strcatNumHex - void McuUtility_strcatNumHex(uint8_t *dst, size_t dstSize, uint32_t num,...
|
|
** strcatNum8Hex - void McuUtility_strcatNum8Hex(uint8_t *dst, size_t dstSize, uint8_t num);
|
|
** strcatNum16Hex - void McuUtility_strcatNum16Hex(uint8_t *dst, size_t dstSize, uint16_t num);
|
|
** strcatNum24Hex - void McuUtility_strcatNum24Hex(uint8_t *dst, size_t dstSize, uint32_t num);
|
|
** strcatNum32Hex - void McuUtility_strcatNum32Hex(uint8_t *dst, size_t dstSize, uint32_t num);
|
|
** strcatNum32sDotValue100 - void McuUtility_strcatNum32sDotValue100(uint8_t *dst, size_t dstSize, int32_t...
|
|
** strcatNumFloat - void McuUtility_strcatNumFloat(uint8_t *dst, size_t dstSize, float val,...
|
|
** IsLeapYear - bool McuUtility_IsLeapYear(uint16_t year);
|
|
** WeekDay - uint8_t McuUtility_WeekDay(uint16_t year, uint8_t month, uint8_t day);
|
|
** ReadEscapedName - uint8_t McuUtility_ReadEscapedName(const unsigned char *filename, uint8_t...
|
|
** xatoi - uint8_t McuUtility_xatoi(const unsigned char **str, int32_t *res);
|
|
** ScanDate - uint8_t McuUtility_ScanDate(const unsigned char **str, uint8_t *day, uint8_t...
|
|
** ScanTime - uint8_t McuUtility_ScanTime(const unsigned char **str, uint8_t *hour, uint8_t...
|
|
** ScanDecimal8uNumber - uint8_t McuUtility_ScanDecimal8uNumber(const unsigned char **str, uint8_t *val);
|
|
** ScanDecimal8sNumber - uint8_t McuUtility_ScanDecimal8sNumber(const unsigned char **str, signed char...
|
|
** ScanDecimal16uNumber - uint8_t McuUtility_ScanDecimal16uNumber(const unsigned char **str, uint16_t...
|
|
** ScanDecimal16sNumber - uint8_t McuUtility_ScanDecimal16sNumber(const unsigned char **str, int16_t...
|
|
** ScanDecimal32uNumber - uint8_t McuUtility_ScanDecimal32uNumber(const unsigned char **str, uint32_t...
|
|
** ScanDecimal32sNumber - uint8_t McuUtility_ScanDecimal32sNumber(const unsigned char **str, int32_t...
|
|
** ScanDecimal32sDotNumber - uint8_t McuUtility_ScanDecimal32sDotNumber(const unsigned char **str, int32_t...
|
|
** ScanHex8uNumber - uint8_t McuUtility_ScanHex8uNumber(const unsigned char **str, uint8_t *val);
|
|
** ScanHex8uNumberNoPrefix - uint8_t McuUtility_ScanHex8uNumberNoPrefix(const unsigned char **str, uint8_t...
|
|
** ScanHex16uNumber - uint8_t McuUtility_ScanHex16uNumber(const unsigned char **str, uint16_t *val);
|
|
** ScanHex32uNumber - uint8_t McuUtility_ScanHex32uNumber(const unsigned char **str, uint32_t *val);
|
|
** ScanSeparatedNumbers - uint8_t McuUtility_ScanSeparatedNumbers(const unsigned char **str, uint8_t...
|
|
** ScanDoubleQuotedString - uint8_t McuUtility_ScanDoubleQuotedString(const uint8_t **cmd, uint8_t *buf,...
|
|
** ScanRGB - uint8_t McuUtility_ScanRGB(const unsigned char **str, uint8_t *r, uint8_t *g,...
|
|
** ScanWRGB - uint8_t McuUtility_ScanWRGB(const unsigned char **str, uint8_t *w, uint8_t...
|
|
** ScanRGB32 - uint8_t McuUtility_ScanRGB32(const unsigned char **str, uint32_t *rgb);
|
|
** ScanWRGB32 - uint8_t McuUtility_ScanWRGB32(const unsigned char **str, uint32_t *rgbw);
|
|
** strcmp - int16_t McuUtility_strcmp(const char *, const char *);
|
|
** strncmp - int16_t McuUtility_strncmp(const char *, const char *, size_t size);
|
|
** strFind - int16_t McuUtility_strFind(uint8_t *str, uint8_t *subStr);
|
|
** strtailcmp - uint8_t McuUtility_strtailcmp(const uint8_t *str, const uint8_t *tail);
|
|
** strlen - uint16_t McuUtility_strlen(const char *);
|
|
** strCutTail - uint8_t McuUtility_strCutTail(uint8_t *str, uint8_t *tail);
|
|
** GetValue16LE - uint16_t McuUtility_GetValue16LE(uint8_t *dataP);
|
|
** GetValue24LE - uint32_t McuUtility_GetValue24LE(uint8_t *dataP);
|
|
** GetValue32LE - uint32_t McuUtility_GetValue32LE(uint8_t *dataP);
|
|
** SetValue16LE - void McuUtility_SetValue16LE(uint16_t data, uint8_t *dataP);
|
|
** SetValue24LE - void McuUtility_SetValue24LE(uint32_t data, uint8_t *dataP);
|
|
** SetValue32LE - void McuUtility_SetValue32LE(uint32_t data, uint8_t *dataP);
|
|
** map - int32_t McuUtility_map(int32_t x, int32_t in_min, int32_t in_max, int32_t...
|
|
** map64 - int64_t McuUtility_map64(int64_t x, int64_t in_min, int64_t in_max, int64_t...
|
|
** constrain - int32_t McuUtility_constrain(int32_t val, int32_t min, int32_t max);
|
|
** random - int32_t McuUtility_random(int32_t min, int32_t max);
|
|
** randomSetSeed - void McuUtility_randomSetSeed(unsigned int seed);
|
|
** Deinit - void McuUtility_Deinit(void);
|
|
** Init - void McuUtility_Init(void);
|
|
**
|
|
** * Copyright (c) 2014-2024, Erich Styger
|
|
** * Web: https://mcuoneclipse.com
|
|
** * SourceForge: https://sourceforge.net/projects/mcuoneclipse
|
|
** * Git: https://github.com/ErichStyger/McuOnEclipse_PEx
|
|
** * All rights reserved.
|
|
** *
|
|
** * Redistribution and use in source and binary forms, with or without modification,
|
|
** * are permitted provided that the following conditions are met:
|
|
** *
|
|
** * - Redistributions of source code must retain the above copyright notice, this list
|
|
** * of conditions and the following disclaimer.
|
|
** *
|
|
** * - Redistributions in binary form must reproduce the above copyright notice, this
|
|
** * list of conditions and the following disclaimer in the documentation and/or
|
|
** * other materials provided with the distribution.
|
|
** *
|
|
** * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
** * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
** * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
** * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
|
** * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
** * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
** * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
** * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
** * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
** * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
** ###################################################################*/
|
|
/*!
|
|
** @file McuUtility.h
|
|
** @version 01.00
|
|
** @brief
|
|
** Contains various utility functions.
|
|
*/
|
|
/*!
|
|
** @addtogroup McuUtility_module McuUtility module documentation
|
|
** @{
|
|
*/
|
|
|
|
#ifndef __McuUtility_H
|
|
#define __McuUtility_H
|
|
|
|
/* MODULE McuUtility. */
|
|
#include "McuLib.h" /* SDK and API used */
|
|
#include "McuUtilityconfig.h" /* configuration */
|
|
|
|
/* other includes needed */
|
|
#include <string.h>
|
|
#include <stddef.h> /* for size_t */
|
|
/* special version */
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
typedef enum {
|
|
McuUtility_SEP_NUM_TYPE_UINT8, /* uint8_t number type */
|
|
McuUtility_SEP_NUM_TYPE_UINT8_HEX_NO_PREFIX /* uint8_t hex number type, no 0x prefix */
|
|
} McuUtility_SeparatedNumberType;
|
|
|
|
void McuUtility_strcpy(uint8_t *dst, size_t dstSize, const unsigned char *src);
|
|
/*
|
|
** ===================================================================
|
|
** Method : strcpy (component Utility)
|
|
**
|
|
** Description :
|
|
** Same as normal strcpy, but safe as it does not write beyond
|
|
** the buffer.
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** * dst - Pointer to destination string
|
|
** dstSize - Size of the destination buffer (in
|
|
** bytes).
|
|
** * src - Pointer to source string.
|
|
** Returns : Nothing
|
|
** ===================================================================
|
|
*/
|
|
|
|
void McuUtility_strcat(uint8_t *dst, size_t dstSize, const unsigned char *src);
|
|
/*
|
|
** ===================================================================
|
|
** Method : strcat (component Utility)
|
|
**
|
|
** Description :
|
|
** Same as normal strcat, but safe as it does not write beyond
|
|
** the buffer.
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** * dst - Pointer to destination string
|
|
** dstSize - Size of the destination buffer (in
|
|
** bytes).
|
|
** * src - Pointer to source string.
|
|
** Returns : Nothing
|
|
** ===================================================================
|
|
*/
|
|
|
|
void McuUtility_Num16sToStr(uint8_t *dst, size_t dstSize, int16_t val);
|
|
/*
|
|
** ===================================================================
|
|
** Method : Num16sToStr (component Utility)
|
|
**
|
|
** Description :
|
|
** Converts a signed 16bit value into a string.
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** * dst - Pointer to destination string
|
|
** dstSize - Size of the destination buffer (in
|
|
** bytes).
|
|
** val - Value to be converted.
|
|
** Returns : Nothing
|
|
** ===================================================================
|
|
*/
|
|
|
|
void McuUtility_Num16sToStrFormatted(uint8_t *dst, size_t dstSize, int16_t val, char fill, uint8_t nofFill);
|
|
/*
|
|
** ===================================================================
|
|
** Method : Num16sToStrFormatted (component Utility)
|
|
**
|
|
** Description :
|
|
** Converts a 16bit signed value to string.
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** * dst - Pointer to destination string
|
|
** dstSize - Size of the destination buffer (in
|
|
** bytes).
|
|
** val - Value to convert.
|
|
** fill - Fill character
|
|
** nofFill - Number of fill characters
|
|
** Returns : Nothing
|
|
** ===================================================================
|
|
*/
|
|
|
|
void McuUtility_strcatNum16s(uint8_t *dst, size_t dstSize, int16_t val);
|
|
/*
|
|
** ===================================================================
|
|
** Method : strcatNum16s (component Utility)
|
|
**
|
|
** Description :
|
|
** Appends a 16bit signed value to a string buffer.
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** * dst - Pointer to destination string
|
|
** dstSize - Size of the destination buffer (in
|
|
** bytes).
|
|
** val - Value to convert.
|
|
** Returns : Nothing
|
|
** ===================================================================
|
|
*/
|
|
|
|
void McuUtility_strcatNum16sFormatted(uint8_t *dst, size_t dstSize, int16_t val, char fill, uint8_t nofFill);
|
|
/*
|
|
** ===================================================================
|
|
** Method : strcatNum16sFormatted (component Utility)
|
|
**
|
|
** Description :
|
|
** Appends a 16bit signed value to a string buffer in a
|
|
** formatted way.
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** * dst - Pointer to destination string
|
|
** dstSize - Size of the destination buffer (in
|
|
** bytes).
|
|
** val - Value to convert.
|
|
** fill - Fill character
|
|
** nofFill - Number of fill characters
|
|
** Returns : Nothing
|
|
** ===================================================================
|
|
*/
|
|
|
|
void McuUtility_strcatNum8Hex(uint8_t *dst, size_t dstSize, uint8_t num);
|
|
/*
|
|
** ===================================================================
|
|
** Method : strcatNum8Hex (component Utility)
|
|
**
|
|
** Description :
|
|
** Appends a 8bit unsigned value to a string buffer as hex
|
|
** number (without a 0x prefix).
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** * dst - Pointer to destination string
|
|
** dstSize - Size of the destination buffer (in
|
|
** bytes).
|
|
** num - Value to convert.
|
|
** Returns : Nothing
|
|
** ===================================================================
|
|
*/
|
|
|
|
void McuUtility_strcatNum16Hex(uint8_t *dst, size_t dstSize, uint16_t num);
|
|
/*
|
|
** ===================================================================
|
|
** Method : strcatNum16Hex (component Utility)
|
|
**
|
|
** Description :
|
|
** Appends a 16bit unsigned value to a string buffer as hex
|
|
** number (without a 0x prefix).
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** * dst - Pointer to destination string
|
|
** dstSize - Size of the destination buffer (in
|
|
** bytes).
|
|
** num - Value to convert.
|
|
** Returns : Nothing
|
|
** ===================================================================
|
|
*/
|
|
|
|
void McuUtility_strcatNum32s(uint8_t *dst, size_t dstSize, int32_t val);
|
|
/*
|
|
** ===================================================================
|
|
** Method : strcatNum32s (component Utility)
|
|
**
|
|
** Description :
|
|
** Appends a 32bit signed value to a string buffer.
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** * dst - Pointer to destination string
|
|
** dstSize - Size of the destination buffer (in
|
|
** bytes).
|
|
** val - Value to convert.
|
|
** Returns : Nothing
|
|
** ===================================================================
|
|
*/
|
|
|
|
void McuUtility_Num32sToStr(uint8_t *dst, size_t dstSize, int32_t val);
|
|
/*
|
|
** ===================================================================
|
|
** Method : Num32sToStr (component Utility)
|
|
**
|
|
** Description :
|
|
** Converts a signed 32bit value into a string.
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** * dst - Pointer to destination string
|
|
** dstSize - Size of the destination buffer (in
|
|
** bytes).
|
|
** val - Value to be converted.
|
|
** Returns : Nothing
|
|
** ===================================================================
|
|
*/
|
|
|
|
void McuUtility_strcatNum32Hex(uint8_t *dst, size_t dstSize, uint32_t num);
|
|
/*
|
|
** ===================================================================
|
|
** Method : strcatNum32Hex (component Utility)
|
|
**
|
|
** Description :
|
|
** Appends a 32bit unsigned value to a string buffer as hex
|
|
** number (without a 0x prefix).
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** * dst - Pointer to destination string
|
|
** dstSize - Size of the destination buffer (in
|
|
** bytes).
|
|
** num - Value to convert.
|
|
** Returns : Nothing
|
|
** ===================================================================
|
|
*/
|
|
|
|
bool McuUtility_IsLeapYear(uint16_t year);
|
|
/*
|
|
** ===================================================================
|
|
** Method : IsLeapYear (component Utility)
|
|
**
|
|
** Description :
|
|
** Returns true if a given year is a leap year
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** year - Year, in the YYYY format.
|
|
** Returns :
|
|
** --- - If the year is a leap year or not.
|
|
** ===================================================================
|
|
*/
|
|
|
|
uint8_t McuUtility_WeekDay(uint16_t year, uint8_t month, uint8_t day);
|
|
/*
|
|
** ===================================================================
|
|
** Method : WeekDay (component Utility)
|
|
**
|
|
** Description :
|
|
** Returns the weekday for a given date >= 1.Jan.1900
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** year - year in YYYY format
|
|
** month - month of the year (1: January, 2:
|
|
** February, etc)
|
|
** day - day of the moth (starting with 1)
|
|
** Returns :
|
|
** --- - Returns the weekday, 0 for Sunday, 1 for
|
|
** Monday, 2 for Tuesday, etc.
|
|
** ===================================================================
|
|
*/
|
|
|
|
void McuUtility_chcat(uint8_t *dst, size_t dstSize, uint8_t ch);
|
|
/*
|
|
** ===================================================================
|
|
** Method : chcat (component Utility)
|
|
**
|
|
** Description :
|
|
** Adds a single character to a zero byte terminated string
|
|
** buffer. It cares about buffer overflow.
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** * dst - Pointer to destination string
|
|
** dstSize - Size of the destination buffer (in
|
|
** bytes).
|
|
** ch - character to append
|
|
** Returns : Nothing
|
|
** ===================================================================
|
|
*/
|
|
|
|
void McuUtility_strcatNum32u(uint8_t *dst, size_t dstSize, uint32_t val);
|
|
/*
|
|
** ===================================================================
|
|
** Method : strcatNum32u (component Utility)
|
|
**
|
|
** Description :
|
|
** Appends a 32bit signed value to a string buffer.
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** * dst - Pointer to destination string
|
|
** dstSize - Size of the destination buffer (in
|
|
** bytes).
|
|
** val - Value to convert.
|
|
** Returns : Nothing
|
|
** ===================================================================
|
|
*/
|
|
|
|
void McuUtility_Num32uToStr(uint8_t *dst, size_t dstSize, uint32_t val);
|
|
/*
|
|
** ===================================================================
|
|
** Method : Num32uToStr (component Utility)
|
|
**
|
|
** Description :
|
|
** Converts an unsigned 32bit value into a string.
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** * dst - Pointer to destination string
|
|
** dstSize - Size of the destination buffer (in
|
|
** bytes).
|
|
** val - Value to be converted.
|
|
** Returns : Nothing
|
|
** ===================================================================
|
|
*/
|
|
|
|
void McuUtility_strcatNum32uFormatted(uint8_t *dst, size_t dstSize, uint32_t val, char fill, uint8_t nofFill);
|
|
/*
|
|
** ===================================================================
|
|
** Method : strcatNum32uFormatted (component Utility)
|
|
**
|
|
** Description :
|
|
** Appends a 32bit unsigned value to a string buffer in a
|
|
** formatted way.
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** * dst - Pointer to destination string
|
|
** dstSize - Size of the destination buffer (in
|
|
** bytes).
|
|
** val - Value to convert.
|
|
** fill - Fill character
|
|
** nofFill - Number of fill characters
|
|
** Returns : Nothing
|
|
** ===================================================================
|
|
*/
|
|
|
|
void McuUtility_Num32uToStrFormatted(uint8_t *dst, size_t dstSize, uint32_t val, char fill, uint8_t nofFill);
|
|
/*
|
|
** ===================================================================
|
|
** Method : Num32uToStrFormatted (component Utility)
|
|
**
|
|
** Description :
|
|
** Converts a 32bit unsigned value to string.
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** * dst - Pointer to destination string
|
|
** dstSize - Size of the destination buffer (in
|
|
** bytes).
|
|
** val - Value to convert.
|
|
** fill - Fill character
|
|
** nofFill - Number of fill characters
|
|
** Returns : Nothing
|
|
** ===================================================================
|
|
*/
|
|
|
|
void McuUtility_strcatNum24Hex(uint8_t *dst, size_t dstSize, uint32_t num);
|
|
/*
|
|
** ===================================================================
|
|
** Method : strcatNum24Hex (component Utility)
|
|
**
|
|
** Description :
|
|
** Appends a 32bit unsigned value to a string buffer as hex
|
|
** number (without a 0x prefix). Only 24bits are used.
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** * dst - Pointer to destination string
|
|
** dstSize - Size of the destination buffer (in
|
|
** bytes).
|
|
** num - Value to convert.
|
|
** Returns : Nothing
|
|
** ===================================================================
|
|
*/
|
|
|
|
uint8_t McuUtility_ReadEscapedName(const unsigned char *filename, uint8_t *destname, size_t maxlen, size_t *lenRead, size_t *lenWritten, const char *terminators);
|
|
/*
|
|
** ===================================================================
|
|
** Method : ReadEscapedName (component Utility)
|
|
**
|
|
** Description :
|
|
** Scans an escaped name from a string. This is useful e.g. for
|
|
** double quoted file names.
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** * filename - the name to be copied. Names may
|
|
** be in quoted format
|
|
** * destname - the destination of the copy.
|
|
** Names are not in quoted format. destname
|
|
** may be NULL to get the other return values
|
|
** only
|
|
** maxlen - length allocated for destname
|
|
** * lenRead - length read in filename to copy
|
|
** the whole name. Note that filenames maybe
|
|
** space terminated, so *lenRead <
|
|
** strlen(filename)
|
|
** lenWritten - the size written in destname.
|
|
** In case of overflows in destname,
|
|
** lenWritten is still increased but destname
|
|
** no longer written. The have the string
|
|
** length in these cases use strlen(destname)
|
|
** terminators - additional characters
|
|
** where a name should terminate. May be NULL
|
|
** Returns :
|
|
** --- - Error code
|
|
** ===================================================================
|
|
*/
|
|
|
|
uint8_t McuUtility_xatoi(const unsigned char **str, int32_t *res);
|
|
/*
|
|
** ===================================================================
|
|
** Method : xatoi (component Utility)
|
|
**
|
|
** Description :
|
|
** Custom atoi() (ascii to int) implementation by Elm Chan
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** * str - Pointer to string to scan. Returns until
|
|
** where it has scanned.
|
|
** * res - Pointer to where to store the result
|
|
** Returns :
|
|
** --- - Error code
|
|
** ===================================================================
|
|
*/
|
|
|
|
uint8_t McuUtility_ScanDate(const unsigned char **str, uint8_t *day, uint8_t *month, uint16_t *year);
|
|
/*
|
|
** ===================================================================
|
|
** Method : ScanDate (component Utility)
|
|
**
|
|
** Description :
|
|
** Scans a date in the format "dd.mm.yyyy" or "dd-mm-yyyy". For
|
|
** yy it will expand it to 20yy.
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** * str - Pointer to the string to be scanned. The
|
|
** function advances the pointer.
|
|
** * day - Pointer to where to store the day value
|
|
** * month - Pointer to where to store the month
|
|
** value
|
|
** * year - Pointer to where to store the year value
|
|
** Returns :
|
|
** --- - Error code
|
|
** ===================================================================
|
|
*/
|
|
|
|
uint8_t McuUtility_ScanTime(const unsigned char **str, uint8_t *hour, uint8_t *minute, uint8_t *second, uint8_t *hSecond);
|
|
/*
|
|
** ===================================================================
|
|
** Method : ScanTime (component Utility)
|
|
**
|
|
** Description :
|
|
** Scans a time string in the format "hh:mm:ss,hh" with the
|
|
** part for the ",hh" is optional.
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** str - Pointer to the string to be scanned. The
|
|
** function advances the pointer.
|
|
** * hour - Pointer to where to store the hour value
|
|
** * minute - Pointer to where to store the minute
|
|
** value
|
|
** * second - Pointer to where to store the second
|
|
** value
|
|
** * hSecond - Pointer to scans the hundreds of
|
|
** second part. If not present in string, zero
|
|
** is stored
|
|
** Returns :
|
|
** --- - Error code
|
|
** ===================================================================
|
|
*/
|
|
|
|
uint8_t McuUtility_ScanDecimal16uNumber(const unsigned char **str, uint16_t *val);
|
|
/*
|
|
** ===================================================================
|
|
** Method : ScanDecimal16uNumber (component Utility)
|
|
**
|
|
** Description :
|
|
** Scans a decimal 16bit unsigned number
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** str - String to scan. It returns as well until
|
|
** where it has scanned
|
|
** * val - Pointer to value
|
|
** Returns :
|
|
** --- - Error code
|
|
** ===================================================================
|
|
*/
|
|
|
|
uint8_t McuUtility_ScanDecimal8uNumber(const unsigned char **str, uint8_t *val);
|
|
/*
|
|
** ===================================================================
|
|
** Method : ScanDecimal8uNumber (component Utility)
|
|
**
|
|
** Description :
|
|
** Scans a decimal 8bit unsigned number
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** str - String to scan. It returns as well until
|
|
** where it has scanned
|
|
** * val - Pointer to value
|
|
** Returns :
|
|
** --- - Error code
|
|
** ===================================================================
|
|
*/
|
|
|
|
void McuUtility_Num16uToStr(uint8_t *dst, size_t dstSize, uint16_t val);
|
|
/*
|
|
** ===================================================================
|
|
** Method : Num16uToStr (component Utility)
|
|
**
|
|
** Description :
|
|
** Converts a signed 16bit value into a string.
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** * dst - Pointer to destination string
|
|
** dstSize - Size of the destination buffer (in
|
|
** bytes).
|
|
** val - Value to be converted.
|
|
** Returns : Nothing
|
|
** ===================================================================
|
|
*/
|
|
|
|
void McuUtility_Num8sToStr(uint8_t *dst, size_t dstSize, signed char val);
|
|
/*
|
|
** ===================================================================
|
|
** Method : Num8sToStr (component Utility)
|
|
**
|
|
** Description :
|
|
** Converts a signed 8bit value into a string.
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** * dst - Pointer to destination string
|
|
** dstSize - Size of the destination buffer (in
|
|
** bytes).
|
|
** val - Value to be converted.
|
|
** Returns : Nothing
|
|
** ===================================================================
|
|
*/
|
|
|
|
void McuUtility_Num8uToStr(uint8_t *dst, size_t dstSize, uint8_t val);
|
|
/*
|
|
** ===================================================================
|
|
** Method : Num8uToStr (component Utility)
|
|
**
|
|
** Description :
|
|
** Converts an unsigned 8bit value into a string.
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** * dst - Pointer to destination string
|
|
** dstSize - Size of the destination buffer (in
|
|
** bytes).
|
|
** val - Value to be converted.
|
|
** Returns : Nothing
|
|
** ===================================================================
|
|
*/
|
|
|
|
void McuUtility_Num16uToStrFormatted(uint8_t *dst, size_t dstSize, uint16_t val, char fill, uint8_t nofFill);
|
|
/*
|
|
** ===================================================================
|
|
** Method : Num16uToStrFormatted (component Utility)
|
|
**
|
|
** Description :
|
|
** Converts a 16bit unsigned value to string.
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** * dst - Pointer to destination string
|
|
** dstSize - Size of the destination buffer (in
|
|
** bytes).
|
|
** val - Value to convert.
|
|
** fill - Fill character
|
|
** nofFill - Number of fill characters
|
|
** Returns : Nothing
|
|
** ===================================================================
|
|
*/
|
|
|
|
void McuUtility_Num32sToStrFormatted(uint8_t *dst, size_t dstSize, int32_t val, char fill, uint8_t nofFill);
|
|
/*
|
|
** ===================================================================
|
|
** Method : Num32sToStrFormatted (component Utility)
|
|
**
|
|
** Description :
|
|
** Converts a 32bit signed value to string.
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** * dst - Pointer to destination string
|
|
** dstSize - Size of the destination buffer (in
|
|
** bytes).
|
|
** val - Value to convert.
|
|
** fill - Fill character
|
|
** nofFill - Number of fill characters
|
|
** Returns : Nothing
|
|
** ===================================================================
|
|
*/
|
|
|
|
void McuUtility_strcatNum16u(uint8_t *dst, size_t dstSize, uint16_t val);
|
|
/*
|
|
** ===================================================================
|
|
** Method : strcatNum16u (component Utility)
|
|
**
|
|
** Description :
|
|
** Appends a 16bit unsigned value to a string buffer.
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** * dst - Pointer to destination string
|
|
** dstSize - Size of the destination buffer (in
|
|
** bytes).
|
|
** val - Value to convert.
|
|
** Returns : Nothing
|
|
** ===================================================================
|
|
*/
|
|
|
|
void McuUtility_strcatNum16uFormatted(uint8_t *dst, size_t dstSize, uint16_t val, char fill, uint8_t nofFill);
|
|
/*
|
|
** ===================================================================
|
|
** Method : strcatNum16uFormatted (component Utility)
|
|
**
|
|
** Description :
|
|
** Appends a 16bit unsigned value to a string buffer in a
|
|
** formatted way.
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** * dst - Pointer to destination string
|
|
** dstSize - Size of the destination buffer (in
|
|
** bytes).
|
|
** val - Value to convert.
|
|
** fill - Fill character
|
|
** nofFill - Number of fill characters
|
|
** Returns : Nothing
|
|
** ===================================================================
|
|
*/
|
|
|
|
void McuUtility_strcatNum32sFormatted(uint8_t *dst, size_t dstSize, int32_t val, char fill, uint8_t nofFill);
|
|
/*
|
|
** ===================================================================
|
|
** Method : strcatNum32sFormatted (component Utility)
|
|
**
|
|
** Description :
|
|
** Appends a 32bit signed value to a string buffer in a
|
|
** formatted way.
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** * dst - Pointer to destination string
|
|
** dstSize - Size of the destination buffer (in
|
|
** bytes).
|
|
** val - Value to convert.
|
|
** fill - Fill character
|
|
** nofFill - Number of fill characters
|
|
** Returns : Nothing
|
|
** ===================================================================
|
|
*/
|
|
|
|
uint8_t McuUtility_ScanDecimal32uNumber(const unsigned char **str, uint32_t *val);
|
|
/*
|
|
** ===================================================================
|
|
** Method : ScanDecimal32uNumber (component Utility)
|
|
**
|
|
** Description :
|
|
** Scans a decimal 32bit unsigned number
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** str - string to scan. It returns as well until
|
|
** where it has scanned
|
|
** * val - Pointer to value
|
|
** Returns :
|
|
** --- - Error code
|
|
** ===================================================================
|
|
*/
|
|
|
|
void McuUtility_strcatNum8u(uint8_t *dst, size_t dstSize, uint8_t val);
|
|
/*
|
|
** ===================================================================
|
|
** Method : strcatNum8u (component Utility)
|
|
**
|
|
** Description :
|
|
** Appends a 8bit unsigned value to a string buffer.
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** * dst - Pointer to destination string
|
|
** dstSize - Size of the destination buffer (in
|
|
** bytes).
|
|
** val - Value to convert.
|
|
** Returns : Nothing
|
|
** ===================================================================
|
|
*/
|
|
|
|
void McuUtility_strcatNum8s(uint8_t *dst, size_t dstSize, signed char val);
|
|
/*
|
|
** ===================================================================
|
|
** Method : strcatNum8s (component Utility)
|
|
**
|
|
** Description :
|
|
** Appends a 8bit signed value to a string buffer.
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** * dst - Pointer to destination string
|
|
** dstSize - Size of the destination buffer (in
|
|
** bytes).
|
|
** val - Value to convert.
|
|
** Returns : Nothing
|
|
** ===================================================================
|
|
*/
|
|
|
|
#define McuUtility_strcmp(str1, str2) \
|
|
strcmp(str1, str2)
|
|
|
|
/*
|
|
** ===================================================================
|
|
** Method : strcmp (component Utility)
|
|
**
|
|
** Description :
|
|
** Wrapper to the standard strcmp() routine
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** * str1 - Pointer to string
|
|
** * str2 - Pointer to string
|
|
** Returns :
|
|
** --- - Returns zero if the two strings are the
|
|
** same
|
|
** ===================================================================
|
|
*/
|
|
|
|
#define McuUtility_strncmp(str1, str2, size) \
|
|
strncmp(str1, str2, size)
|
|
|
|
/*
|
|
** ===================================================================
|
|
** Method : strncmp (component Utility)
|
|
**
|
|
** Description :
|
|
** Wrapper to the standard strncmp() routine
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** * str1 - Pointer to string
|
|
** * str2 - Pointer to string
|
|
** size -
|
|
** Returns :
|
|
** --- - Returns zero if the two strings are the
|
|
** same
|
|
** ===================================================================
|
|
*/
|
|
|
|
#define McuUtility_strlen(str) \
|
|
strlen(str)
|
|
|
|
/*
|
|
** ===================================================================
|
|
** Method : strlen (component Utility)
|
|
**
|
|
** Description :
|
|
** Wrapper to the standard strlen() function.
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** str -
|
|
** Returns :
|
|
** --- - size of strinig
|
|
** ===================================================================
|
|
*/
|
|
|
|
uint8_t McuUtility_ScanHex32uNumber(const unsigned char **str, uint32_t *val);
|
|
/*
|
|
** ===================================================================
|
|
** Method : ScanHex32uNumber (component Utility)
|
|
**
|
|
** Description :
|
|
** Scans a hexadecimal 32bit number, starting with 0x
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** str - String to scan, starting with 0x. It
|
|
** returns as well until where it has scanned
|
|
** * val - Pointer to value
|
|
** Returns :
|
|
** --- - Error code
|
|
** ===================================================================
|
|
*/
|
|
|
|
uint8_t McuUtility_ScanHex16uNumber(const unsigned char **str, uint16_t *val);
|
|
/*
|
|
** ===================================================================
|
|
** Method : ScanHex16uNumber (component Utility)
|
|
**
|
|
** Description :
|
|
** Scans a hexadecimal 16bit number, starting with 0x
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** str - String to scan, starting with 0x.. It
|
|
** returns as well until where it has scanned
|
|
** * val - Pointer to value
|
|
** Returns :
|
|
** --- - Error code
|
|
** ===================================================================
|
|
*/
|
|
|
|
uint8_t McuUtility_ScanHex8uNumber(const unsigned char **str, uint8_t *val);
|
|
/*
|
|
** ===================================================================
|
|
** Method : ScanHex8uNumber (component Utility)
|
|
**
|
|
** Description :
|
|
** Scans a hexadecimal 8bit number, starting with 0x
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** str - String to scan, starting with 0x. It
|
|
** returns as well until where it has scanned
|
|
** * val - Pointer to value
|
|
** Returns :
|
|
** --- - Error code
|
|
** ===================================================================
|
|
*/
|
|
|
|
uint8_t McuUtility_strtailcmp(const uint8_t *str, const uint8_t *tail);
|
|
/*
|
|
** ===================================================================
|
|
** Method : strtailcmp (component Utility)
|
|
**
|
|
** Description :
|
|
** Compares the tail of a string and returns 0 if it matches, 1
|
|
** otherwise
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** * str - Pointer to string. This string is compared
|
|
** if it contains the tail.
|
|
** * tail - Pointer to tail string.
|
|
** Returns :
|
|
** --- - returns 0 if tail matches, -1 otherwise
|
|
** ===================================================================
|
|
*/
|
|
|
|
uint8_t McuUtility_strCutTail(uint8_t *str, uint8_t *tail);
|
|
/*
|
|
** ===================================================================
|
|
** Method : strCutTail (component Utility)
|
|
**
|
|
** Description :
|
|
** Removes a tailing substring from a string. The string passed
|
|
** will be modified (the tail is cut by writing a zero byte to
|
|
** the string!)
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** * str - Pointer to string where to remove the tail
|
|
** * tail - Pointer to substring to remove
|
|
** Returns :
|
|
** --- - Error code, ERR_OK if no error, otherwise
|
|
** ERR_FAIL if tail is not found
|
|
** ===================================================================
|
|
*/
|
|
|
|
uint8_t McuUtility_ScanHex8uNumberNoPrefix(const unsigned char **str, uint8_t *val);
|
|
/*
|
|
** ===================================================================
|
|
** Method : ScanHex8uNumberNoPrefix (component Utility)
|
|
**
|
|
** Description :
|
|
** Scans a hexadecimal 8bit number, without 0x
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** str - String to scan, starting with 0x. It
|
|
** returns as well until where it has scanned
|
|
** * val - Pointer to value
|
|
** Returns :
|
|
** --- - Error code
|
|
** ===================================================================
|
|
*/
|
|
|
|
void McuUtility_strcatNum32sDotValue100(uint8_t *dst, size_t dstSize, int32_t num);
|
|
/*
|
|
** ===================================================================
|
|
** Method : strcatNum32sDotValue100 (component Utility)
|
|
**
|
|
** Description :
|
|
** Appends a 32bit signed value to a string buffer. The value
|
|
** is in 1/100 units. For example for the value -13456 it will
|
|
** append the string "-134.56"
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** * dst - Pointer to destination string
|
|
** dstSize - Size of the destination buffer (in
|
|
** bytes).
|
|
** num - Value to convert.
|
|
** Returns : Nothing
|
|
** ===================================================================
|
|
*/
|
|
|
|
uint8_t McuUtility_ScanDecimal8sNumber(const unsigned char **str, signed char *val);
|
|
/*
|
|
** ===================================================================
|
|
** Method : ScanDecimal8sNumber (component Utility)
|
|
**
|
|
** Description :
|
|
** Scans a decimal 8bit signed number
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** str - String to scan. It returns as well until
|
|
** where it has scanned
|
|
** * val - Pointer to value
|
|
** Returns :
|
|
** --- - Error code
|
|
** ===================================================================
|
|
*/
|
|
|
|
uint8_t McuUtility_ScanDecimal16sNumber(const unsigned char **str, int16_t *val);
|
|
/*
|
|
** ===================================================================
|
|
** Method : ScanDecimal16sNumber (component Utility)
|
|
**
|
|
** Description :
|
|
** Scans a decimal 16bit signed number
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** str - String to scan. It returns as well until
|
|
** where it has scanned
|
|
** * val - Pointer to value
|
|
** Returns :
|
|
** --- - Error code
|
|
** ===================================================================
|
|
*/
|
|
|
|
uint8_t McuUtility_ScanDecimal32sNumber(const unsigned char **str, int32_t *val);
|
|
/*
|
|
** ===================================================================
|
|
** Method : ScanDecimal32sNumber (component Utility)
|
|
**
|
|
** Description :
|
|
** Scans a decimal 32bit signed number
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** str - string to scan. It returns as well until
|
|
** where it has scanned
|
|
** * val - Pointer to value
|
|
** Returns :
|
|
** --- - Error code
|
|
** ===================================================================
|
|
*/
|
|
|
|
int16_t McuUtility_strFind(uint8_t *str, uint8_t *subStr);
|
|
/*
|
|
** ===================================================================
|
|
** Method : strFind (component Utility)
|
|
**
|
|
** Description :
|
|
** Searches a substring inside a string and returns the
|
|
** position.
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** * str - Pointer to string which will be searched
|
|
** * subStr - Pointer to substring to search
|
|
** inside str
|
|
** Returns :
|
|
** --- - -1 if not found, otherwise the character
|
|
** index.
|
|
** ===================================================================
|
|
*/
|
|
|
|
uint8_t McuUtility_ScanSeparatedNumbers(const unsigned char **str, uint8_t *values, uint8_t nofValues, char separator, McuUtility_SeparatedNumberType numberType);
|
|
/*
|
|
** ===================================================================
|
|
** Method : ScanSeparatedNumbers (component Utility)
|
|
**
|
|
** Description :
|
|
** Scans multiple numbers separated by character, e.g. "123.68.
|
|
** 5.3"
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** str - String to scan. It returns as well until
|
|
** where it has scanned
|
|
** * values - Pointer to array where to store the
|
|
** values
|
|
** nofValues - Number of values in the array
|
|
** separator - Character separator, e.g. '.'
|
|
** numberType - type of number to scan
|
|
** Returns :
|
|
** --- - Error code
|
|
** ===================================================================
|
|
*/
|
|
|
|
uint8_t McuUtility_ScanDoubleQuotedString(const uint8_t **cmd, uint8_t *buf, size_t bufSize);
|
|
/*
|
|
** ===================================================================
|
|
** Method : ScanDoubleQuotedString (component Utility)
|
|
**
|
|
** Description :
|
|
** Scans a string inside double quotes and returns it without
|
|
** the double quotes.
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** cmd - Pointer to pointer to string to parse.
|
|
** This pointer will be advanced as much as
|
|
** parsing is done.
|
|
** * buf - Pointer to buffer where to store the string
|
|
** bufSize - Size of buffer in bytes
|
|
** Returns :
|
|
** --- - Error code
|
|
** ===================================================================
|
|
*/
|
|
|
|
uint8_t McuUtility_ScanDecimal32sDotNumber(const unsigned char **str, int32_t *integral, uint32_t *fractional, uint8_t *nofFractionalZeros);
|
|
/*
|
|
** ===================================================================
|
|
** Method : ScanDecimal32sDotNumber (component Utility)
|
|
**
|
|
** Description :
|
|
** Scans a decimal 32bit signed number with a following dot
|
|
** (fractional part), e.g. "-34587.0248", it will return the
|
|
** (signed) integral and fractional part with number of
|
|
** fractional zeros. The function accepts as well numbers like
|
|
** "17" (no fractional part" or "17.0"
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** str - string to scan. It returns as well until
|
|
** where it has scanned
|
|
** * integral - Pointer to value before the dot
|
|
** * fractional - Pointer to value after the
|
|
** dot, e.g. 32 for "-134.0032"
|
|
** nofFractionalZeros - Number of
|
|
** fractional leading zeros, e.g. 2 for "-134.
|
|
** 0032"
|
|
** Returns :
|
|
** --- - Error code
|
|
** ===================================================================
|
|
*/
|
|
|
|
void McuUtility_strcatPad(uint8_t *dst, size_t dstSize, const unsigned char *src, char padChar, uint8_t srcPadSize);
|
|
/*
|
|
** ===================================================================
|
|
** Method : strcatPad (component Utility)
|
|
**
|
|
** Description :
|
|
** Same as normal strcat, but safe as it does not write beyond
|
|
** the buffer. The buffer will be filled with a pad character
|
|
** for a given length.
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** * dst - Pointer to destination string
|
|
** dstSize - Size of the destination buffer (in
|
|
** bytes).
|
|
** * src - Pointer to source string.
|
|
** padChar - Character to be used for padding
|
|
** srcPadSize - To which size the src string
|
|
** has to be padded.
|
|
** Returns : Nothing
|
|
** ===================================================================
|
|
*/
|
|
|
|
void McuUtility_NumFloatToStr(uint8_t *dst, size_t dstSize, float val, uint8_t nofFracDigits);
|
|
/*
|
|
** ===================================================================
|
|
** Method : NumFloatToStr (component Utility)
|
|
**
|
|
** Description :
|
|
** Converts a float value into a string.
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** * dst - Pointer to destination string
|
|
** dstSize - Size of the destination buffer (in
|
|
** bytes).
|
|
** val - Value to be converted.
|
|
** nofFracDigits - Number of fractional
|
|
** digits to print
|
|
** Returns : Nothing
|
|
** ===================================================================
|
|
*/
|
|
|
|
void McuUtility_strcatNumFloat(uint8_t *dst, size_t dstSize, float val, uint8_t nofFracDigits);
|
|
/*
|
|
** ===================================================================
|
|
** Method : strcatNumFloat (component Utility)
|
|
**
|
|
** Description :
|
|
** Converts a float value into a string.
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** * dst - Pointer to destination string
|
|
** dstSize - Size of the destination buffer (in
|
|
** bytes).
|
|
** val - Value to be converted.
|
|
** nofFracDigits - Number of factional
|
|
** digits to print
|
|
** Returns : Nothing
|
|
** ===================================================================
|
|
*/
|
|
|
|
uint16_t McuUtility_GetValue16LE(uint8_t *dataP);
|
|
/*
|
|
** ===================================================================
|
|
** Method : GetValue16LE (component Utility)
|
|
**
|
|
** Description :
|
|
** Returns a 16bit Little Endian value from memory
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** * dataP - Pointer to memory
|
|
** Returns :
|
|
** --- - Error code
|
|
** ===================================================================
|
|
*/
|
|
|
|
uint32_t McuUtility_GetValue24LE(uint8_t *dataP);
|
|
/*
|
|
** ===================================================================
|
|
** Method : GetValue24LE (component Utility)
|
|
**
|
|
** Description :
|
|
** Returns a 24bit Little Endian value from memory
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** * dataP - Pointer to memory
|
|
** Returns :
|
|
** --- - Error code
|
|
** ===================================================================
|
|
*/
|
|
|
|
uint32_t McuUtility_GetValue32LE(uint8_t *dataP);
|
|
/*
|
|
** ===================================================================
|
|
** Method : GetValue32LE (component Utility)
|
|
**
|
|
** Description :
|
|
** Returns a 32bit Little Endian value from memory
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** * dataP - Pointer to memory
|
|
** Returns :
|
|
** --- - Error code
|
|
** ===================================================================
|
|
*/
|
|
|
|
void McuUtility_SetValue16LE(uint16_t data, uint8_t *dataP);
|
|
/*
|
|
** ===================================================================
|
|
** Method : SetValue16LE (component Utility)
|
|
**
|
|
** Description :
|
|
** Stores a 16bit value in memory as Little Endian
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** data - Value to store
|
|
** * dataP - Pointer to memory
|
|
** Returns : Nothing
|
|
** ===================================================================
|
|
*/
|
|
|
|
void McuUtility_SetValue24LE(uint32_t data, uint8_t *dataP);
|
|
/*
|
|
** ===================================================================
|
|
** Method : SetValue24LE (component Utility)
|
|
**
|
|
** Description :
|
|
** Stores a 24bit value in memory as Little Endian
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** data - Value to store
|
|
** * dataP - Pointer to memory
|
|
** Returns : Nothing
|
|
** ===================================================================
|
|
*/
|
|
|
|
void McuUtility_SetValue32LE(uint32_t data, uint8_t *dataP);
|
|
/*
|
|
** ===================================================================
|
|
** Method : SetValue32LE (component Utility)
|
|
**
|
|
** Description :
|
|
** Stores a 32bit value in memory as Little Endian
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** data - Value to store
|
|
** * dataP - Pointer to memory
|
|
** Returns : Nothing
|
|
** ===================================================================
|
|
*/
|
|
|
|
void McuUtility_Deinit(void);
|
|
/*
|
|
** ===================================================================
|
|
** Method : Deinit (component Utility)
|
|
**
|
|
** Description :
|
|
** Driver De-Initialization
|
|
** Parameters : None
|
|
** Returns : Nothing
|
|
** ===================================================================
|
|
*/
|
|
|
|
void McuUtility_Init(void);
|
|
/*
|
|
** ===================================================================
|
|
** Method : Init (component Utility)
|
|
**
|
|
** Description :
|
|
** Driver Initialization
|
|
** Parameters : None
|
|
** Returns : Nothing
|
|
** ===================================================================
|
|
*/
|
|
|
|
int32_t McuUtility_map(int32_t x, int32_t in_min, int32_t in_max, int32_t out_min, int32_t out_max);
|
|
/*
|
|
** ===================================================================
|
|
** Method : map (component Utility)
|
|
**
|
|
** Description :
|
|
** Maps a value from one range to another
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** x - value to be mapped
|
|
** in_min - input range minimum value
|
|
** in_max - input range maximum value
|
|
** out_min - output range minimum value
|
|
** out_max - output range maximum value
|
|
** Returns :
|
|
** --- - remapped value
|
|
** ===================================================================
|
|
*/
|
|
|
|
int32_t McuUtility_constrain(int32_t val, int32_t min, int32_t max);
|
|
/*
|
|
** ===================================================================
|
|
** Method : constrain (component Utility)
|
|
**
|
|
** Description :
|
|
** Makes sure that a given input value is inside a given range.
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** val - input value
|
|
** min - range minimum value
|
|
** max - range maximum value
|
|
** Returns :
|
|
** --- - the constrained value
|
|
** ===================================================================
|
|
*/
|
|
|
|
int32_t McuUtility_random(int32_t min, int32_t max);
|
|
/*
|
|
** ===================================================================
|
|
** Method : random (component Utility)
|
|
**
|
|
** Description :
|
|
** Provides a random value. You have to call intialize the
|
|
** random number generator with randomSetSeed() first!
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** min - range minimum value
|
|
** max - range maximum value
|
|
** Returns :
|
|
** --- - random value between min and max
|
|
** ===================================================================
|
|
*/
|
|
|
|
void McuUtility_randomSetSeed(unsigned int seed);
|
|
/*
|
|
** ===================================================================
|
|
** Method : randomSetSeed (component Utility)
|
|
**
|
|
** Description :
|
|
** Sets a seed for the random number generator
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** seed - seed to be used for random number
|
|
** generator
|
|
** Returns : Nothing
|
|
** ===================================================================
|
|
*/
|
|
|
|
#ifdef __GNUC__ /* HIWARE compiler does not support 64bit data types */
|
|
int64_t McuUtility_map64(int64_t x, int64_t in_min, int64_t in_max, int64_t out_min, int64_t out_max);
|
|
#endif
|
|
/*
|
|
** ===================================================================
|
|
** Method : map64 (component Utility)
|
|
**
|
|
** Description :
|
|
** Maps a value from one range to another, using 64bit math
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** x - value to be mapped
|
|
** in_min - input range minimum value
|
|
** in_max - input range maximum value
|
|
** out_min - output range maximum value
|
|
** out_max -
|
|
** Returns :
|
|
** --- - remapped value
|
|
** ===================================================================
|
|
*/
|
|
|
|
void McuUtility_strcatNumHex(uint8_t *dst, size_t dstSize, uint32_t num, uint8_t nofBytes);
|
|
/*
|
|
** ===================================================================
|
|
** Method : strcatNumHex (component Utility)
|
|
**
|
|
** Description :
|
|
** Appends a value as hex valalue to a string buffer as hex
|
|
** number (without a 0x prefix), with variable number of digits
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** * dst - Pointer to destination string
|
|
** dstSize - Size of the destination buffer (in
|
|
** bytes).
|
|
** num - Value to convert.
|
|
** nofBytes - Number of bytes to write
|
|
** Returns : Nothing
|
|
** ===================================================================
|
|
*/
|
|
|
|
uint8_t McuUtility_ScanRGB(const unsigned char **str, uint8_t *r, uint8_t *g, uint8_t *b);
|
|
/*
|
|
** ===================================================================
|
|
** Method : ScanRGB (component Utility)
|
|
**
|
|
** Description :
|
|
** Scans a RGB value and stores it in r, g and b. String can be
|
|
** a single hex number (0x120506) or three decimal values (18 5
|
|
** 6)
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** str - String to scan
|
|
** * r - Pointer to red value
|
|
** * g - Pointer to green value
|
|
** * b - Pointer to blue value
|
|
** Returns :
|
|
** --- - Error code
|
|
** ===================================================================
|
|
*/
|
|
|
|
uint8_t McuUtility_ScanRGB32(const unsigned char **str, uint32_t *rgb);
|
|
/*
|
|
** ===================================================================
|
|
** Method : ScanRGB32 (component Utility)
|
|
**
|
|
** Description :
|
|
** Scans a RGB value and stores it in a single 32bit value.
|
|
** String can be a single hex number (0x120506) or three
|
|
** decimal values (18 5 6)
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** str - String to scan
|
|
** * rgb - Pointer to rgb value
|
|
** Returns :
|
|
** --- - Error code
|
|
** ===================================================================
|
|
*/
|
|
|
|
void McuUtility_SkipSpaces(const unsigned char **str);
|
|
/*
|
|
** ===================================================================
|
|
** Method : SkipSpaces (component Utility)
|
|
**
|
|
** Description :
|
|
** Skips spaces
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** * str - Pointer to string to scan. Returns until
|
|
** where it has scanned.
|
|
** Returns : Nothing
|
|
** ===================================================================
|
|
*/
|
|
|
|
uint8_t McuUtility_ScanWRGB32(const unsigned char **str, uint32_t *rgbw);
|
|
/*
|
|
** ===================================================================
|
|
** Method : ScanWRGB32 (component Utility)
|
|
**
|
|
** Description :
|
|
** Scans a WRGB value and stores it in a single 32bit value.
|
|
** String can be a single hex number (0x12050608) or three
|
|
** decimal values (18 5 6 8)
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** str - String to scan
|
|
** * rgbw - Pointer to wrgb value
|
|
** Returns :
|
|
** --- - Error code
|
|
** ===================================================================
|
|
*/
|
|
|
|
uint8_t McuUtility_ScanWRGB(const unsigned char **str, uint8_t *w, uint8_t *r, uint8_t *g, uint8_t *b);
|
|
/*
|
|
** ===================================================================
|
|
** Method : ScanWRGB (component Utility)
|
|
**
|
|
** Description :
|
|
** Scans a WRGB value and stores it in r, g, b and w. String
|
|
** can be a single hex number (0x12050608) or three decimal
|
|
** values (18 5 6 8)
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** str - String to scan
|
|
** * w - Pointer to white value
|
|
** * r - Pointer to red value
|
|
** * g - Pointer to green value
|
|
** * b - Pointer to blue value
|
|
** Returns :
|
|
** --- - Error code
|
|
** ===================================================================
|
|
*/
|
|
|
|
/* END McuUtility. */
|
|
|
|
#ifdef __cplusplus
|
|
} /* extern "C" */
|
|
#endif
|
|
|
|
#endif
|
|
/* ifndef __McuUtility_H */
|
|
/*!
|
|
** @}
|
|
*/
|