HW_Lib/lib/inc/tool.h

57 lines
1.4 KiB
C
Raw Normal View History

2024-05-09 05:56:55 +00:00
#ifndef HW_LIB_TOOL_H
#define HW_LIB_TOOL_H
typedef unsigned int u32;
typedef unsigned short u16;
typedef unsigned char u8;
typedef int s32;
typedef short int s16;
typedef char s8;
typedef union {
int i;
char c[4];
float f;
s8 s8[4];
s16 s16[2];
s32 s32;
u8 u8[4];
u16 u16[2];
u32 u32;
} Data32;
typedef union {
char c[2];
s8 s8[2];
s16 s16;
u8 u8[2];
u16 u16;
} Data16;
/**
* @Name Mapping
* @brief ()
* @param val: []
* @param I_Min: []
* @param I_Max: []
* @param O_Min: []
* @param O_Max: []
* @retval
* @example Mapping(128,0,4096,0.0,3.3) //0.10
* ADC
**/
float Mapping(float val, float I_Min, float I_Max, float O_Min, float O_Max);
/**
* @brief HEX
* @param name: []
* @param buf: []
* @param size: [] [8,16,32]
* @param len: []
* @param frame: []
* @return void
* @example BufPrint("TX", buf, 8, 64, 16); //将长64的8位buf以16个数据断帧打印
**/
void BufPrint(char *name,void *buf,unsigned char size,unsigned int len,unsigned char frame);
#endif //HW_LIB_TOOL_H