1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- /***
- * @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 <stdarg.h>
- #include "stdio.h"
- #include <math.h>
- #include "rtwtypes.h"
- #ifndef va_copy
- #define va_copy(dst, src) memcpy(&(dst), &(src), sizeof(va_list))
- #endif
- #ifndef min
- #define min(A, B) ((A) <= (B) ? (A) : (B))
- #endif
- #ifndef max
- #define max(A, B) ((A) < (B) ? (B) : (A))
- #endif
- #define getbit(x, y) ((x) >> (y)&1) // 获取x的第y位的数值
- #define setbit(x, y) x |= (1 << y) // x的第y位置1
- #define clrbit(x, y) x &= ~(1 << y) // x的第y位置0
- uint16_t GetErrorNum(uint16_t *ErrorArray, uint8_t Errorlen);
- uint8_t PutErrorNum(uint16_t *ErrorArray, uint8_t Errorlen, uint16_t ErrorNum);
- uint16_t ATstrdel(char *str);
- uint16_t 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_t AtStrCompare(const char *a, const char *b);
- unsigned short CRC16_Modbus(unsigned char *pdata, int len);
- uint8_t bcc_chk(uint8_t *data, uint16_t 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_t crc_chk(uint8_t *data, uint8_t 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_ */
|