移植与电子模块通信相关代码
This commit is contained in:
60
source/elec_det/base/utility.h
Normal file
60
source/elec_det/base/utility.h
Normal file
@@ -0,0 +1,60 @@
|
||||
#ifndef _UTILITY_H
|
||||
#define _UTILITY_H
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "stm32f10x.h"
|
||||
|
||||
float myatof(const char* str);
|
||||
uint16_t atoi16(const char* str,uint16_t base); /* Convert a string to integer number */
|
||||
uint32_t atoi32(const char* str,uint16_t base); /* Convert a string to integer number */
|
||||
void itoa(uint16_t n,uint8_t* str, uint8_t len);
|
||||
int validatoi(const char* str, int base, uint32_t* ret); /* Verify character string and Convert it to (hexa-)decimal. */
|
||||
char c2d(uint8_t c);
|
||||
char d2c(uint8_t c);
|
||||
uint16_t swaps(uint16_t i);
|
||||
uint32_t swapl(uint32_t l);
|
||||
|
||||
void replacetochar(char * str, char oldchar, char newchar);
|
||||
|
||||
void mid(const char* src, const char* s1, const char* s2, char* sub);
|
||||
|
||||
void bytes2hexString(const char* data, uint32_t len, char* str);
|
||||
//冒泡排序16位数据
|
||||
void Bubble_Sort_u16(uint16_t* buf,uint32_t len);
|
||||
//数据左移
|
||||
void BufMoveLeft(uint8_t* srcbuf,uint16_t offset,uint16_t data_len);
|
||||
//数据右移
|
||||
void BufMoveRight(uint8_t* srcbuf,uint16_t offset,uint16_t data_len);
|
||||
/*
|
||||
Hex Datas to Bytes
|
||||
*/
|
||||
uint8_t HexStrings2Byte(char**strs,uint16_t size,uint8_t* buf,uint16_t buf_size);
|
||||
/*
|
||||
Hex Datas to uint32_t
|
||||
*/
|
||||
uint32_t HexStrings2UInt(char*str);
|
||||
//@brief 计算数组异或校验值
|
||||
//@param *srcbuf 数据源
|
||||
//@param len 计算长度
|
||||
//@rtvl 返回计算结果
|
||||
uint8_t CheckCRC_8(uint8_t* Ptr,uint16_t num);
|
||||
//@brief 计算CRC32
|
||||
//@param *srcbuf 数据源
|
||||
//@param len 计算长度
|
||||
//@rtvl 返回计算结果
|
||||
uint32_t Crc32Calu(uint32_t* buf, uint32_t len);
|
||||
/*
|
||||
@brief 获取数组中的最大值和最小值
|
||||
@param *aus_buf 缓存数组
|
||||
@param us_size 数组长度
|
||||
@param *us_max 最大值
|
||||
@param *us_min 最小值
|
||||
*/
|
||||
|
||||
void GetMaxAndMinValue(uint16_t* aus_buf,uint16_t us_size,uint16_t* us_max,uint16_t* us_min);
|
||||
//@brief 计算数组的CRC8值
|
||||
//@param *srcbuf 数据源指针
|
||||
//@param len 数据源长度
|
||||
//@rtvl 返回计算结果
|
||||
uint8_t CheckXOR_8(uint8_t* srcbuf,uint16_t len);
|
||||
#endif
|
Reference in New Issue
Block a user