1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- /***
- * @Author: chenjie
- * @Date: 2022-06-06
- * @LastEditTime: 2022-11-10
- * @LastEditors: chenjie
- * @Description:
- * @FilePath: \S32K146_4G\code\app\lib\AppFuncLib.h
- * @Copyright (c) 2022 by chenjie, All Rights Reserved.
- */
- #ifndef APPFUNCLIB_H_
- #define APPFUNCLIB_H_
- #include "hal_adapter.h"
- #include <stdarg.h>
- #include "stdio.h"
- #include <math.h>
- #ifndef va_copy
- #define va_copy(dst, src) memcpy(&(dst), &(src), sizeof(va_list))
- #endif
- uint16 GetErrorNum(uint16 *ErrorArray, uint8 Errorlen);
- uint8 PutErrorNum(uint16 *ErrorArray, uint8 Errorlen, uint16 ErrorNum);
- uint16 ATstrdel(char *str);
- uint16 mstrlen(const char *s);
- int mstrncmp(const char *s1, const char *s2, int n);
- unsigned char HexToChar(unsigned char bHex);
- unsigned char CharToHex(unsigned char bChar);
- uint8 AtStrCompare(const char *a, const char *b);
- unsigned short CRC16_Modbus(unsigned char *pdata, int len);
- uint8 bcc_chk(uint8 *data, uint16 length);
- char *Myitoa(int value, char *result, int base);
- // 整数转字符串
- int _itoa(int num, char buf[32]);
- int _i2a(int num, char buf[32], int radix);
- // 浮点转字符串
- int _ftoa(double val, char buf[32], int eps);
- // 浮点转字符串,范围(-1,1)
- int __ftoa(double val, char buf[32], int eps);
- // 替代sprintf
- int _sprintf(char *dst, const char *format, ...);
- // 串口校验
- uint16 crc_chk(uint8 *data, uint8 length);
- /*********************************************************************************************/
- #define SIZE_FFT 64
- typedef struct _fft_Freq
- {
- real_T freq;
- real_T amp;
- }fft_type;
- extern uint16_T ArrMax(uint16_T *Data, uint16_T m);
- extern uint16_T ArrMin(uint16_T *Data, uint16_T m);
- extern int16_T ArrMean(int16_T *Data, uint16_T n);
- extern real_T Saturation_r(real_T in, real_T LowLim, real_T UpLim);
- extern uint16_T Saturation_u(uint16_T in, uint16_T LowLim, uint16_T UpLim);
- extern uint16_T DataFilt(uint16_T in, uint16_T *out, uint16_T Lim);
- extern uint8_T DataFilt8(uint8_T in, uint8_T *out, uint8_T Lim);
- extern uint16_T look1_i16tu16(int16_T u0, const int16_T *bp0, const uint16_T *table, uint16_T MaxLen);
- extern uint16_T look1_u16tu16(uint16_T u0, const uint16_T *bp0, const uint16_T *table, uint16_T MaxLen);
- extern uint16_T look2_u16u16tu16(uint16_T x, uint16_T y, const uint16_T xTable[], const uint16_T yTable[], const uint16_T zTable[], uint16_T xLen, uint16_T yLen);
- extern boolean_T DiagThrSystem1(boolean_T Enable, boolean_T precondition, uint16_T Input, uint16_T fltThr, uint16_T recThr, uint8_T fltNumThr, uint8_T recNumThr, uint8_T *fltNum, uint8_T *recNum, boolean_T *fitFlg);
- extern boolean_T DiagThrSystem2(boolean_T Enable, boolean_T precondition, uint16_T Input, uint16_T fltThr, uint16_T recThr, uint8_T fltNumThr, uint8_T recNumThr, uint8_T *fltNum, uint8_T *recNum, boolean_T *fitFlg);
- extern boolean_T JudgeTimeSystem(boolean_T Enable, boolean_T Input, uint16_T *N, uint16_T Thr);
- extern void RaderReverse(creal_T *X, uint16_T N);
- extern void fft(real_T *S, uint16_T N, real_T freq, real_T *returnFreq, real_T *returnP);
- extern void cmul(creal_T a, creal_T b, creal_T *c);
- extern void cadd(creal_T a, creal_T b, creal_T *c);
- extern void csub(creal_T a, creal_T b, creal_T *c);
- /***********************************************************************************************/
- #endif /* APPFUNCLIB_H_ */
|